Re-add DataLayout pointer size convenience functions.

These were reverted in r167222 along with the rest
of the last different address space pointer size attempt.
These will be used in later commits.

llvm-svn: 187223
This commit is contained in:
Matt Arsenault 2013-07-26 17:37:20 +00:00
parent 8ea2e40296
commit 6f4be90570
2 changed files with 22 additions and 0 deletions

View File

@ -271,6 +271,18 @@ public:
unsigned getPointerSizeInBits(unsigned AS = 0) const {
return getPointerSize(AS) * 8;
}
/// Layout pointer size, in bits, based on the type. If this function is
/// called with a pointer type, then the type size of the pointer is returned.
/// If this function is called with a vector of pointers, then the type size
/// of the pointer is returned. This should only be called with a pointer or
/// vector of pointers.
unsigned getPointerTypeSizeInBits(Type *) const;
unsigned getPointerTypeSize(Type *Ty) const {
return getPointerTypeSizeInBits(Ty) / 8;
}
/// Size examples:
///
/// Type SizeInBits StoreSizeInBits AllocSizeInBits[*]

View File

@ -507,6 +507,16 @@ std::string DataLayout::getStringRepresentation() const {
return OS.str();
}
unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const {
assert(Ty->isPtrOrPtrVectorTy() &&
"This should only be called with a pointer or pointer vector type");
if (Ty->isPointerTy())
return getTypeSizeInBits(Ty);
Type *EleTy = cast<VectorType>(Ty)->getElementType();
return getTypeSizeInBits(EleTy);
}
/*!
\param abi_or_pref Flag that determines which alignment is returned. true