[llvm-commits] CVS: llvm/lib/Target/TargetData.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 17 12:13:11 PDT 2004



Changes in directory llvm/lib/Target:

TargetData.cpp updated: 1.50 -> 1.51
---
Log message:

Add a new helper method to get log2(type alignment)


---
Diffs of the changes:  (+7 -0)

Index: llvm/lib/Target/TargetData.cpp
diff -u llvm/lib/Target/TargetData.cpp:1.50 llvm/lib/Target/TargetData.cpp:1.51
--- llvm/lib/Target/TargetData.cpp:1.50	Thu Jul 22 20:09:52 2004
+++ llvm/lib/Target/TargetData.cpp	Tue Aug 17 14:13:00 2004
@@ -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 @@
   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 {






More information about the llvm-commits mailing list