- bool isLittleEndian() const { return LittleEndian; }
- bool isBigEndian() const { return !LittleEndian; }
-
- /// Target alignment constraints
- unsigned char getSubWordDataSize() const { return SubWordDataSize; }
- unsigned char getByteAlignment() const { return ByteAlignment; }
- unsigned char getShortAlignment() const { return ShortAlignment; }
- unsigned char getIntAlignment() const { return IntAlignment; }
- unsigned char getLongAlignment() const { return LongAlignment; }
- unsigned char getFloatAlignment() const { return FloatAlignment; }
- unsigned char getDoubleAlignment() const { return DoubleAlignment; }
- unsigned char getPointerAlignment() const { return PointerAlignment; }
- unsigned char getPointerSize() const { return PointerSize; }
- unsigned char getIntegerRegize() const { return IntegerRegSize; }
- AnnotationID getStructLayoutAID() const { return AID; }
-
- // getTypeSize - Return the number of bytes neccesary to hold the specified
- // type
- uint64_t getTypeSize (const Type *Ty) const;
-
- // getTypeAlignment - Return the minimum required alignment for the specified
- // type
- unsigned char getTypeAlignment(const Type *Ty) const;
-
- // getIndexOffset - return the offset from the beginning of the type for the
- // specified indices. This is used to implement getelementptr.
- //
- uint64_t getIndexedOffset(const Type *Ty,
- const std::vector<Value*> &Indices) const;
-
- inline const StructLayout *getStructLayout(const StructType *Ty) const {
- return (const StructLayout*)
- ((const Annotable*)Ty)->getOrCreateAnnotation(AID);
+ bool isLittleEndian() const { return LittleEndian; }
+ bool isBigEndian() const { return !LittleEndian; }
+
+ /// getStringRepresentation - Return the string representation of the
+ /// TargetData. This representation is in the same format accepted by the
+ /// string constructor above.
+ std::string getStringRepresentation() const;
+ /// Target pointer alignment
+ unsigned char getPointerABIAlignment() const { return PointerABIAlign; }
+ /// Return target's alignment for stack-based pointers
+ unsigned char getPointerPrefAlignment() const { return PointerPrefAlign; }
+ /// Target pointer size
+ unsigned char getPointerSize() const { return PointerMemSize; }
+ /// Target pointer size, in bits
+ unsigned char getPointerSizeInBits() const { return 8*PointerMemSize; }
+
+ /// Size examples:
+ ///
+ /// Type SizeInBits StoreSizeInBits AllocSizeInBits[*]
+ /// ---- ---------- --------------- ---------------
+ /// i1 1 8 8
+ /// i8 8 8 8
+ /// i19 19 24 32
+ /// i32 32 32 32
+ /// i100 100 104 128
+ /// i128 128 128 128
+ /// Float 32 32 32
+ /// Double 64 64 64
+ /// X86_FP80 80 80 96
+ ///
+ /// [*] The alloc size depends on the alignment, and thus on the target.
+ /// These values are for x86-32 linux.
+
+ /// getTypeSizeInBits - Return the number of bits necessary to hold the
+ /// specified type. For example, returns 36 for i36 and 80 for x86_fp80.
+ uint64_t getTypeSizeInBits(const Type* Ty) const;
+
+ /// getTypeStoreSize - Return the maximum number of bytes that may be
+ /// overwritten by storing the specified type. For example, returns 5
+ /// for i36 and 10 for x86_fp80.
+ uint64_t getTypeStoreSize(const Type *Ty) const {
+ return (getTypeSizeInBits(Ty)+7)/8;
+ }
+
+ /// getTypeStoreSizeInBits - Return the maximum number of bits that may be
+ /// overwritten by storing the specified type; always a multiple of 8. For
+ /// example, returns 40 for i36 and 80 for x86_fp80.
+ uint64_t getTypeStoreSizeInBits(const Type *Ty) const {
+ return 8*getTypeStoreSize(Ty);
+ }
+
+ /// getTypeAllocSize - Return the offset in bytes between successive objects
+ /// of the specified type, including alignment padding. This is the amount
+ /// that alloca reserves for this type. For example, returns 12 or 16 for
+ /// x86_fp80, depending on alignment.
+ uint64_t getTypeAllocSize(const Type* Ty) const {
+ // Round up to the next alignment boundary.
+ return RoundUpAlignment(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
+ }
+
+ /// getTypeAllocSizeInBits - Return the offset in bits between successive
+ /// objects of the specified type, including alignment padding; always a
+ /// multiple of 8. This is the amount that alloca reserves for this type.
+ /// For example, returns 96 or 128 for x86_fp80, depending on alignment.
+ uint64_t getTypeAllocSizeInBits(const Type* Ty) const {
+ return 8*getTypeAllocSize(Ty);
+ }
+
+ /// getABITypeAlignment - Return the minimum ABI-required alignment for the
+ /// specified type.
+ unsigned char getABITypeAlignment(const Type *Ty) const;
+
+ /// getCallFrameTypeAlignment - Return the minimum ABI-required alignment
+ /// for the specified type when it is part of a call frame.
+ unsigned char getCallFrameTypeAlignment(const Type *Ty) const;
+
+
+ /// getPrefTypeAlignment - Return the preferred stack/global alignment for
+ /// the specified type. This is always at least as good as the ABI alignment.
+ unsigned char getPrefTypeAlignment(const Type *Ty) const;
+
+ /// getPreferredTypeAlignmentShift - Return the preferred alignment for the
+ /// specified type, returned as log2 of the value (a shift amount).
+ ///
+ unsigned char getPreferredTypeAlignmentShift(const Type *Ty) const;
+
+ /// getIntPtrType - Return an unsigned integer type that is the same size or
+ /// greater to the host pointer size.
+ ///
+ const IntegerType *getIntPtrType(LLVMContext &C) const;
+
+ /// getIndexedOffset - return the offset from the beginning of the type for
+ /// the specified indices. This is used to implement getelementptr.
+ ///
+ uint64_t getIndexedOffset(const Type *Ty,
+ Value* const* Indices, unsigned NumIndices) const;
+
+ /// getStructLayout - Return a StructLayout object, indicating the alignment
+ /// of the struct, its size, and the offsets of its fields. Note that this
+ /// information is lazily cached.
+ const StructLayout *getStructLayout(const StructType *Ty) const;
+
+ /// InvalidateStructLayoutInfo - TargetData speculatively caches StructLayout
+ /// objects. If a TargetData object is alive when types are being refined and
+ /// removed, this method must be called whenever a StructType is removed to
+ /// avoid a dangling pointer in this cache.
+ void InvalidateStructLayoutInfo(const StructType *Ty) const;
+
+ /// getPreferredAlignment - Return the preferred alignment of the specified
+ /// global. This includes an explicitly requested alignment (if the global
+ /// has one).
+ unsigned getPreferredAlignment(const GlobalVariable *GV) const;
+
+ /// getPreferredAlignmentLog - Return the preferred alignment of the
+ /// specified global, returned in log form. This includes an explicitly
+ /// requested alignment (if the global has one).
+ unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const;
+
+ /// RoundUpAlignment - Round the specified value up to the next alignment
+ /// boundary specified by Alignment. For example, 7 rounded up to an
+ /// alignment boundary of 4 is 8. 8 rounded up to the alignment boundary of 4
+ /// is 8 because it is already aligned.
+ template <typename UIntTy>
+ static UIntTy RoundUpAlignment(UIntTy Val, unsigned Alignment) {
+ assert((Alignment & (Alignment-1)) == 0 && "Alignment must be power of 2!");
+ return (Val + (Alignment-1)) & ~UIntTy(Alignment-1);