mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 22:07:27 +00:00
Revert r161371. Removing the 'const' before Type is a "good thing".
--- Reverse-merging r161371 into '.': U include/llvm/Target/TargetData.h U lib/Target/TargetData.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161394 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5b0e9ce2e5
commit
cbfce45577
@ -100,9 +100,9 @@ private:
|
|||||||
void setAlignment(AlignTypeEnum align_type, unsigned abi_align,
|
void setAlignment(AlignTypeEnum align_type, unsigned abi_align,
|
||||||
unsigned pref_align, uint32_t bit_width);
|
unsigned pref_align, uint32_t bit_width);
|
||||||
unsigned getAlignmentInfo(AlignTypeEnum align_type, uint32_t bit_width,
|
unsigned getAlignmentInfo(AlignTypeEnum align_type, uint32_t bit_width,
|
||||||
bool ABIAlign, const Type *Ty) const;
|
bool ABIAlign, Type *Ty) const;
|
||||||
//! Internal helper method that returns requested alignment for type.
|
//! Internal helper method that returns requested alignment for type.
|
||||||
unsigned getAlignment(const Type *Ty, bool abi_or_pref) const;
|
unsigned getAlignment(Type *Ty, bool abi_or_pref) const;
|
||||||
|
|
||||||
/// Valid alignment predicate.
|
/// Valid alignment predicate.
|
||||||
///
|
///
|
||||||
@ -223,19 +223,19 @@ public:
|
|||||||
|
|
||||||
/// getTypeSizeInBits - Return the number of bits necessary to hold the
|
/// getTypeSizeInBits - Return the number of bits necessary to hold the
|
||||||
/// specified type. For example, returns 36 for i36 and 80 for x86_fp80.
|
/// specified type. For example, returns 36 for i36 and 80 for x86_fp80.
|
||||||
uint64_t getTypeSizeInBits(const Type* Ty) const;
|
uint64_t getTypeSizeInBits(Type* Ty) const;
|
||||||
|
|
||||||
/// getTypeStoreSize - Return the maximum number of bytes that may be
|
/// getTypeStoreSize - Return the maximum number of bytes that may be
|
||||||
/// overwritten by storing the specified type. For example, returns 5
|
/// overwritten by storing the specified type. For example, returns 5
|
||||||
/// for i36 and 10 for x86_fp80.
|
/// for i36 and 10 for x86_fp80.
|
||||||
uint64_t getTypeStoreSize(const Type *Ty) const {
|
uint64_t getTypeStoreSize(Type *Ty) const {
|
||||||
return (getTypeSizeInBits(Ty)+7)/8;
|
return (getTypeSizeInBits(Ty)+7)/8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getTypeStoreSizeInBits - Return the maximum number of bits that may be
|
/// getTypeStoreSizeInBits - Return the maximum number of bits that may be
|
||||||
/// overwritten by storing the specified type; always a multiple of 8. For
|
/// overwritten by storing the specified type; always a multiple of 8. For
|
||||||
/// example, returns 40 for i36 and 80 for x86_fp80.
|
/// example, returns 40 for i36 and 80 for x86_fp80.
|
||||||
uint64_t getTypeStoreSizeInBits(const Type *Ty) const {
|
uint64_t getTypeStoreSizeInBits(Type *Ty) const {
|
||||||
return 8*getTypeStoreSize(Ty);
|
return 8*getTypeStoreSize(Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ public:
|
|||||||
/// of the specified type, including alignment padding. This is the amount
|
/// of the specified type, including alignment padding. This is the amount
|
||||||
/// that alloca reserves for this type. For example, returns 12 or 16 for
|
/// that alloca reserves for this type. For example, returns 12 or 16 for
|
||||||
/// x86_fp80, depending on alignment.
|
/// x86_fp80, depending on alignment.
|
||||||
uint64_t getTypeAllocSize(const Type* Ty) const {
|
uint64_t getTypeAllocSize(Type* Ty) const {
|
||||||
// Round up to the next alignment boundary.
|
// Round up to the next alignment boundary.
|
||||||
return RoundUpAlignment(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
|
return RoundUpAlignment(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
|
||||||
}
|
}
|
||||||
@ -252,13 +252,13 @@ public:
|
|||||||
/// objects of the specified type, including alignment padding; always a
|
/// objects of the specified type, including alignment padding; always a
|
||||||
/// multiple of 8. This is the amount that alloca reserves for this type.
|
/// 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.
|
/// For example, returns 96 or 128 for x86_fp80, depending on alignment.
|
||||||
uint64_t getTypeAllocSizeInBits(const Type* Ty) const {
|
uint64_t getTypeAllocSizeInBits(Type* Ty) const {
|
||||||
return 8*getTypeAllocSize(Ty);
|
return 8*getTypeAllocSize(Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getABITypeAlignment - Return the minimum ABI-required alignment for the
|
/// getABITypeAlignment - Return the minimum ABI-required alignment for the
|
||||||
/// specified type.
|
/// specified type.
|
||||||
unsigned getABITypeAlignment(const Type *Ty) const;
|
unsigned getABITypeAlignment(Type *Ty) const;
|
||||||
|
|
||||||
/// getABIIntegerTypeAlignment - Return the minimum ABI-required alignment for
|
/// getABIIntegerTypeAlignment - Return the minimum ABI-required alignment for
|
||||||
/// an integer type of the specified bitwidth.
|
/// an integer type of the specified bitwidth.
|
||||||
@ -267,17 +267,17 @@ public:
|
|||||||
|
|
||||||
/// getCallFrameTypeAlignment - Return the minimum ABI-required alignment
|
/// getCallFrameTypeAlignment - Return the minimum ABI-required alignment
|
||||||
/// for the specified type when it is part of a call frame.
|
/// for the specified type when it is part of a call frame.
|
||||||
unsigned getCallFrameTypeAlignment(const Type *Ty) const;
|
unsigned getCallFrameTypeAlignment(Type *Ty) const;
|
||||||
|
|
||||||
|
|
||||||
/// getPrefTypeAlignment - Return the preferred stack/global alignment for
|
/// getPrefTypeAlignment - Return the preferred stack/global alignment for
|
||||||
/// the specified type. This is always at least as good as the ABI alignment.
|
/// the specified type. This is always at least as good as the ABI alignment.
|
||||||
unsigned getPrefTypeAlignment(const Type *Ty) const;
|
unsigned getPrefTypeAlignment(Type *Ty) const;
|
||||||
|
|
||||||
/// getPreferredTypeAlignmentShift - Return the preferred alignment for the
|
/// getPreferredTypeAlignmentShift - Return the preferred alignment for the
|
||||||
/// specified type, returned as log2 of the value (a shift amount).
|
/// specified type, returned as log2 of the value (a shift amount).
|
||||||
///
|
///
|
||||||
unsigned getPreferredTypeAlignmentShift(const Type *Ty) const;
|
unsigned getPreferredTypeAlignmentShift(Type *Ty) const;
|
||||||
|
|
||||||
/// getIntPtrType - Return an unsigned integer type that is the same size or
|
/// getIntPtrType - Return an unsigned integer type that is the same size or
|
||||||
/// greater to the host pointer size.
|
/// greater to the host pointer size.
|
||||||
@ -292,7 +292,7 @@ public:
|
|||||||
/// getStructLayout - Return a StructLayout object, indicating the alignment
|
/// getStructLayout - Return a StructLayout object, indicating the alignment
|
||||||
/// of the struct, its size, and the offsets of its fields. Note that this
|
/// of the struct, its size, and the offsets of its fields. Note that this
|
||||||
/// information is lazily cached.
|
/// information is lazily cached.
|
||||||
const StructLayout *getStructLayout(const StructType *Ty) const;
|
const StructLayout *getStructLayout(StructType *Ty) const;
|
||||||
|
|
||||||
/// getPreferredAlignment - Return the preferred alignment of the specified
|
/// getPreferredAlignment - Return the preferred alignment of the specified
|
||||||
/// global. This includes an explicitly requested alignment (if the global
|
/// global. This includes an explicitly requested alignment (if the global
|
||||||
@ -355,7 +355,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class TargetData; // Only TargetData can create this class
|
friend class TargetData; // Only TargetData can create this class
|
||||||
StructLayout(const StructType *ST, const TargetData &TD);
|
StructLayout(StructType *ST, const TargetData &TD);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@ -41,7 +41,7 @@ char TargetData::ID = 0;
|
|||||||
// Support for StructLayout
|
// Support for StructLayout
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
StructLayout::StructLayout(const StructType *ST, const TargetData &TD) {
|
StructLayout::StructLayout(StructType *ST, const TargetData &TD) {
|
||||||
assert(!ST->isOpaque() && "Cannot get layout of opaque structs");
|
assert(!ST->isOpaque() && "Cannot get layout of opaque structs");
|
||||||
StructAlignment = 0;
|
StructAlignment = 0;
|
||||||
StructSize = 0;
|
StructSize = 0;
|
||||||
@ -332,7 +332,7 @@ TargetData::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
|
|||||||
/// preferred if ABIInfo = false) the target wants for the specified datatype.
|
/// preferred if ABIInfo = false) the target wants for the specified datatype.
|
||||||
unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType,
|
unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType,
|
||||||
uint32_t BitWidth, bool ABIInfo,
|
uint32_t BitWidth, bool ABIInfo,
|
||||||
const Type *Ty) const {
|
Type *Ty) const {
|
||||||
// Check to see if we have an exact match and remember the best match we see.
|
// Check to see if we have an exact match and remember the best match we see.
|
||||||
int BestMatchIdx = -1;
|
int BestMatchIdx = -1;
|
||||||
int LargestInt = -1;
|
int LargestInt = -1;
|
||||||
@ -386,7 +386,7 @@ unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType,
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class StructLayoutMap {
|
class StructLayoutMap {
|
||||||
typedef DenseMap<const StructType*, StructLayout*> LayoutInfoTy;
|
typedef DenseMap<StructType*, StructLayout*> LayoutInfoTy;
|
||||||
LayoutInfoTy LayoutInfo;
|
LayoutInfoTy LayoutInfo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -400,7 +400,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StructLayout *&operator[](const StructType *STy) {
|
StructLayout *&operator[](StructType *STy) {
|
||||||
return LayoutInfo[STy];
|
return LayoutInfo[STy];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ TargetData::~TargetData() {
|
|||||||
delete static_cast<StructLayoutMap*>(LayoutMap);
|
delete static_cast<StructLayoutMap*>(LayoutMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
const StructLayout *TargetData::getStructLayout(const StructType *Ty) const {
|
const StructLayout *TargetData::getStructLayout(StructType *Ty) const {
|
||||||
if (!LayoutMap)
|
if (!LayoutMap)
|
||||||
LayoutMap = new StructLayoutMap();
|
LayoutMap = new StructLayoutMap();
|
||||||
|
|
||||||
@ -462,14 +462,14 @@ std::string TargetData::getStringRepresentation() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint64_t TargetData::getTypeSizeInBits(const Type *Ty) const {
|
uint64_t TargetData::getTypeSizeInBits(Type *Ty) const {
|
||||||
assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
|
assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
|
||||||
switch (Ty->getTypeID()) {
|
switch (Ty->getTypeID()) {
|
||||||
case Type::LabelTyID:
|
case Type::LabelTyID:
|
||||||
case Type::PointerTyID:
|
case Type::PointerTyID:
|
||||||
return getPointerSizeInBits();
|
return getPointerSizeInBits();
|
||||||
case Type::ArrayTyID: {
|
case Type::ArrayTyID: {
|
||||||
const ArrayType *ATy = cast<ArrayType>(Ty);
|
ArrayType *ATy = cast<ArrayType>(Ty);
|
||||||
return getTypeAllocSizeInBits(ATy->getElementType())*ATy->getNumElements();
|
return getTypeAllocSizeInBits(ATy->getElementType())*ATy->getNumElements();
|
||||||
}
|
}
|
||||||
case Type::StructTyID:
|
case Type::StructTyID:
|
||||||
@ -508,7 +508,7 @@ uint64_t TargetData::getTypeSizeInBits(const Type *Ty) const {
|
|||||||
Get the ABI (\a abi_or_pref == true) or preferred alignment (\a abi_or_pref
|
Get the ABI (\a abi_or_pref == true) or preferred alignment (\a abi_or_pref
|
||||||
== false) for the requested type \a Ty.
|
== false) for the requested type \a Ty.
|
||||||
*/
|
*/
|
||||||
unsigned TargetData::getAlignment(const Type *Ty, bool abi_or_pref) const {
|
unsigned TargetData::getAlignment(Type *Ty, bool abi_or_pref) const {
|
||||||
int AlignType = -1;
|
int AlignType = -1;
|
||||||
|
|
||||||
assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
|
assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
|
||||||
@ -558,7 +558,7 @@ unsigned TargetData::getAlignment(const Type *Ty, bool abi_or_pref) const {
|
|||||||
abi_or_pref, Ty);
|
abi_or_pref, Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned TargetData::getABITypeAlignment(const Type *Ty) const {
|
unsigned TargetData::getABITypeAlignment(Type *Ty) const {
|
||||||
return getAlignment(Ty, true);
|
return getAlignment(Ty, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,7 +569,7 @@ unsigned TargetData::getABIIntegerTypeAlignment(unsigned BitWidth) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned TargetData::getCallFrameTypeAlignment(const Type *Ty) const {
|
unsigned TargetData::getCallFrameTypeAlignment(Type *Ty) const {
|
||||||
for (unsigned i = 0, e = Alignments.size(); i != e; ++i)
|
for (unsigned i = 0, e = Alignments.size(); i != e; ++i)
|
||||||
if (Alignments[i].AlignType == STACK_ALIGN)
|
if (Alignments[i].AlignType == STACK_ALIGN)
|
||||||
return Alignments[i].ABIAlign;
|
return Alignments[i].ABIAlign;
|
||||||
@ -577,11 +577,11 @@ unsigned TargetData::getCallFrameTypeAlignment(const Type *Ty) const {
|
|||||||
return getABITypeAlignment(Ty);
|
return getABITypeAlignment(Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned TargetData::getPrefTypeAlignment(const Type *Ty) const {
|
unsigned TargetData::getPrefTypeAlignment(Type *Ty) const {
|
||||||
return getAlignment(Ty, false);
|
return getAlignment(Ty, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned TargetData::getPreferredTypeAlignmentShift(const Type *Ty) const {
|
unsigned TargetData::getPreferredTypeAlignmentShift(Type *Ty) const {
|
||||||
unsigned Align = getPrefTypeAlignment(Ty);
|
unsigned Align = getPrefTypeAlignment(Ty);
|
||||||
assert(!(Align & (Align-1)) && "Alignment is not a power of two!");
|
assert(!(Align & (Align-1)) && "Alignment is not a power of two!");
|
||||||
return Log2_32(Align);
|
return Log2_32(Align);
|
||||||
|
Loading…
Reference in New Issue
Block a user