forked from OSchip/llvm-project
Add a new helper method to get log2(type alignment)
llvm-svn: 15887
This commit is contained in:
parent
65066a40ea
commit
0c2ab8a9d4
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue