diff options
author | Chris Lattner <sabre@nondot.org> | 2004-08-17 19:13:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-08-17 19:13:00 +0000 |
commit | d2b0bb41f45c1d2381904221c780da8f750d2823 (patch) | |
tree | 19ebfbb3c6b8f21705e8b74d2c8de04e57098886 /lib | |
parent | cdab78f036f7deef6fc9c15a45f9c1adf91c63ad (diff) | |
download | external_llvm-d2b0bb41f45c1d2381904221c780da8f750d2823.zip external_llvm-d2b0bb41f45c1d2381904221c780da8f750d2823.tar.gz external_llvm-d2b0bb41f45c1d2381904221c780da8f750d2823.tar.bz2 |
Add a new helper method to get log2(type alignment)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15887 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/TargetData.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 8aea154..22dde60 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -21,6 +21,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" #include "llvm/Support/GetElementPtrTypeIterator.h" +#include "Support/MathExtras.h" using namespace llvm; // Handle the Pass registration stuff necessary to use TargetData's. @@ -201,6 +202,12 @@ unsigned char TargetData::getTypeAlignment(const Type *Ty) const { return Align; } +unsigned char TargetData::getTypeAlignmentShift(const Type *Ty) const { + unsigned Align = getTypeAlignment(Ty); + assert(!(Align & (Align-1)) && "Alignment is not a power of two!"); + return log2(Align); +} + /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. const Type *TargetData::getIntPtrType() const { |