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 | 0c2ab8a9d4963a9fd282d59c90422b3b05dd498d (patch) | |
tree | 27d870e57f587f2b1d0cdc1784098e64bd00bca8 | |
parent | 65066a40ea9db89fdf07583d7a3157fa5ddf2b79 (diff) | |
download | bcm5719-llvm-0c2ab8a9d4963a9fd282d59c90422b3b05dd498d.tar.gz bcm5719-llvm-0c2ab8a9d4963a9fd282d59c90422b3b05dd498d.zip |
Add a new helper method to get log2(type alignment)
llvm-svn: 15887
-rw-r--r-- | llvm/lib/Target/TargetData.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp index 8aea1543083..22dde60d8f6 100644 --- a/llvm/lib/Target/TargetData.cpp +++ b/llvm/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 { |