X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTargetData.cpp;h=fc58f577497143d12d2ae23afcac08fb3cf72f6d;hb=f311e8b901bbaa2d4749d257461866861501edf2;hp=8aea15430833caadf223e2d771db5e4263f96674;hpb=c8e876470572817295362737d8fbcf460e4cbfa8;p=oota-llvm.git diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 8aea1543083..fc58f577497 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 "llvm/Support/MathExtras.h" using namespace llvm; // Handle the Pass registration stuff necessary to use TargetData's. @@ -106,7 +107,7 @@ TargetData::TargetData(const std::string &ToolName, const Module *M) { PointerAlignment = PointerSize; DoubleAlignment = PointerSize; FloatAlignment = 4; - LongAlignment = 8; + LongAlignment = PointerSize; IntAlignment = 4; ShortAlignment = 2; ByteAlignment = 1; @@ -174,6 +175,13 @@ static inline void getTypeInfo(const Type *Ty, const TargetData *TD, Size = AlignedSize*ATy->getNumElements(); return; } + case Type::PackedTyID: { + const PackedType *PTy = cast(Ty); + getTypeInfo(PTy->getElementType(), TD, Size, Alignment); + unsigned AlignedSize = (Size + Alignment - 1)/Alignment*Alignment; + Size = AlignedSize*PTy->getNumElements(); + return; + } case Type::StructTyID: { // Get the layout annotation... which is lazily created on demand. const StructLayout *Layout = TD->getStructLayout(cast(Ty)); @@ -201,6 +209,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 {