Add getABITypeSize, getABITypeSizeInBits

llvm-svn: 42488
This commit is contained in:
Dale Johannesen 2007-10-01 16:03:14 +00:00
parent 9b943453f5
commit 28e19a48ce
2 changed files with 19 additions and 1 deletions

View File

@ -159,10 +159,23 @@ public:
/// type.
uint64_t getTypeSize(const Type *Ty) const;
/// getABITypeSize - Return the number of bytes allocated for the specified
/// type when used as an element in a larger object, including alignment
/// padding.
uint64_t getABITypeSize(const Type *Ty) const {
unsigned char Align = getABITypeAlignment(Ty);
return (getTypeSize(Ty) + Align - 1)/Align*Align;
}
/// getTypeSizeInBits - Return the number of bits necessary to hold the
/// specified type.
uint64_t getTypeSizeInBits(const Type* Ty) const;
/// getABITypeSizeInBits - Return the number of bytes allocated for the
/// specified type when used as an element in a larger object, including
/// alignment padding.
uint64_t getABITypeSizeInBits(const Type* Ty) const;
/// getABITypeAlignment - Return the minimum ABI-required alignment for the
/// specified type.
unsigned char getABITypeAlignment(const Type *Ty) const;

View File

@ -471,7 +471,12 @@ uint64_t TargetData::getTypeSizeInBits(const Type *Ty) const {
return getTypeSize(Ty) * 8;
}
uint64_t TargetData::getABITypeSizeInBits(const Type *Ty) const {
if (Ty->isInteger())
return cast<IntegerType>(Ty)->getBitWidth();
else
return getABITypeSize(Ty) * 8;
}
/*!
\param abi_or_pref Flag that determines which alignment is returned. true
returns the ABI alignment, false returns the preferred alignment.