mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Revert "Add const to a bunch of Type* in DataLayout. NFC."
This reverts commit r243135. Feedback from Craig Topper and David Blaikie was that we don't put const on Type as it has no mutable state. llvm-svn: 243283
This commit is contained in:
parent
89fb65d96c
commit
8f1d7fbe9e
@ -150,12 +150,12 @@ 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;
|
||||||
void setPointerAlignment(uint32_t AddrSpace, unsigned ABIAlign,
|
void setPointerAlignment(uint32_t AddrSpace, unsigned ABIAlign,
|
||||||
unsigned PrefAlign, uint32_t TypeByteWidth);
|
unsigned PrefAlign, uint32_t TypeByteWidth);
|
||||||
|
|
||||||
/// 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;
|
||||||
|
|
||||||
/// \brief Valid alignment predicate.
|
/// \brief Valid alignment predicate.
|
||||||
///
|
///
|
||||||
@ -335,9 +335,9 @@ public:
|
|||||||
/// If this function is called with a vector of pointers, then the type size
|
/// If this function is called with a vector of pointers, then the type size
|
||||||
/// of the pointer is returned. This should only be called with a pointer or
|
/// of the pointer is returned. This should only be called with a pointer or
|
||||||
/// vector of pointers.
|
/// vector of pointers.
|
||||||
unsigned getPointerTypeSizeInBits(const Type *) const;
|
unsigned getPointerTypeSizeInBits(Type *) const;
|
||||||
|
|
||||||
unsigned getPointerTypeSize(const Type *Ty) const {
|
unsigned getPointerTypeSize(Type *Ty) const {
|
||||||
return getPointerTypeSizeInBits(Ty) / 8;
|
return getPointerTypeSizeInBits(Ty) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,13 +362,13 @@ public:
|
|||||||
///
|
///
|
||||||
/// For example, returns 36 for i36 and 80 for x86_fp80. The type passed must
|
/// For example, returns 36 for i36 and 80 for x86_fp80. The type passed must
|
||||||
/// have a size (Type::isSized() must return true).
|
/// have a size (Type::isSized() must return true).
|
||||||
uint64_t getTypeSizeInBits(const Type *Ty) const;
|
uint64_t getTypeSizeInBits(Type *Ty) const;
|
||||||
|
|
||||||
/// \brief Returns the maximum number of bytes that may be overwritten by
|
/// \brief Returns the maximum number of bytes that may be overwritten by
|
||||||
/// storing the specified type.
|
/// storing the specified type.
|
||||||
///
|
///
|
||||||
/// For example, returns 5 for i36 and 10 for x86_fp80.
|
/// For example, returns 5 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ public:
|
|||||||
/// storing the specified type; always a multiple of 8.
|
/// storing the specified type; always a multiple of 8.
|
||||||
///
|
///
|
||||||
/// For example, returns 40 for i36 and 80 for x86_fp80.
|
/// For 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// This is the amount that alloca reserves for this type. For example,
|
/// This is the amount that alloca reserves for this type. For example,
|
||||||
/// returns 12 or 16 for x86_fp80, depending on alignment.
|
/// returns 12 or 16 for 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 RoundUpToAlignment(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
|
return RoundUpToAlignment(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
|
||||||
}
|
}
|
||||||
@ -395,12 +395,12 @@ public:
|
|||||||
///
|
///
|
||||||
/// This is the amount that alloca reserves for this type. For example,
|
/// This is the amount that alloca reserves for this type. For example,
|
||||||
/// returns 96 or 128 for x86_fp80, depending on alignment.
|
/// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Returns the minimum ABI-required alignment for the specified type.
|
/// \brief Returns the minimum ABI-required alignment for the specified type.
|
||||||
unsigned getABITypeAlignment(const Type *Ty) const;
|
unsigned getABITypeAlignment(Type *Ty) const;
|
||||||
|
|
||||||
/// \brief Returns the minimum ABI-required alignment for an integer type of
|
/// \brief Returns the minimum ABI-required alignment for an integer type of
|
||||||
/// the specified bitwidth.
|
/// the specified bitwidth.
|
||||||
@ -410,11 +410,11 @@ public:
|
|||||||
/// type.
|
/// type.
|
||||||
///
|
///
|
||||||
/// This is always at least as good as the ABI alignment.
|
/// This is always at least as good as the ABI alignment.
|
||||||
unsigned getPrefTypeAlignment(const Type *Ty) const;
|
unsigned getPrefTypeAlignment(Type *Ty) const;
|
||||||
|
|
||||||
/// \brief Returns the preferred alignment for the specified type, returned as
|
/// \brief Returns the preferred alignment for the specified type, returned as
|
||||||
/// log2 of the value (a shift amount).
|
/// log2 of the value (a shift amount).
|
||||||
unsigned getPreferredTypeAlignmentShift(const Type *Ty) const;
|
unsigned getPreferredTypeAlignmentShift(Type *Ty) const;
|
||||||
|
|
||||||
/// \brief Returns an integer type with size at least as big as that of a
|
/// \brief Returns an integer type with size at least as big as that of a
|
||||||
/// pointer in the given address space.
|
/// pointer in the given address space.
|
||||||
@ -422,7 +422,7 @@ public:
|
|||||||
|
|
||||||
/// \brief Returns an integer (vector of integer) type with size at least as
|
/// \brief Returns an integer (vector of integer) type with size at least as
|
||||||
/// big as that of a pointer of the given pointer (vector of pointer) type.
|
/// big as that of a pointer of the given pointer (vector of pointer) type.
|
||||||
Type *getIntPtrType(const Type *) const;
|
Type *getIntPtrType(Type *) const;
|
||||||
|
|
||||||
/// \brief Returns the smallest integer type with size at least as big as
|
/// \brief Returns the smallest integer type with size at least as big as
|
||||||
/// Width bits.
|
/// Width bits.
|
||||||
@ -448,7 +448,7 @@ public:
|
|||||||
/// struct, its size, and the offsets of its fields.
|
/// struct, its size, and the offsets of its fields.
|
||||||
///
|
///
|
||||||
/// Note that this information is lazily cached.
|
/// Note that this information is lazily cached.
|
||||||
const StructLayout *getStructLayout(const StructType *Ty) const;
|
const StructLayout *getStructLayout(StructType *Ty) const;
|
||||||
|
|
||||||
/// \brief Returns the preferred alignment of the specified global.
|
/// \brief Returns the preferred alignment of the specified global.
|
||||||
///
|
///
|
||||||
@ -499,12 +499,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class DataLayout; // Only DataLayout can create this class
|
friend class DataLayout; // Only DataLayout can create this class
|
||||||
StructLayout(const StructType *ST, const DataLayout &DL);
|
StructLayout(StructType *ST, const DataLayout &DL);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The implementation of this method is provided inline as it is particularly
|
// The implementation of this method is provided inline as it is particularly
|
||||||
// well suited to constant folding when called on a specific Type subclass.
|
// well suited to constant folding when called on a specific Type subclass.
|
||||||
inline uint64_t DataLayout::getTypeSizeInBits(const Type *Ty) const {
|
inline uint64_t DataLayout::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:
|
||||||
@ -512,7 +512,7 @@ inline uint64_t DataLayout::getTypeSizeInBits(const Type *Ty) const {
|
|||||||
case Type::PointerTyID:
|
case Type::PointerTyID:
|
||||||
return getPointerSizeInBits(Ty->getPointerAddressSpace());
|
return getPointerSizeInBits(Ty->getPointerAddressSpace());
|
||||||
case Type::ArrayTyID: {
|
case Type::ArrayTyID: {
|
||||||
const ArrayType *ATy = cast<ArrayType>(Ty);
|
ArrayType *ATy = cast<ArrayType>(Ty);
|
||||||
return ATy->getNumElements() *
|
return ATy->getNumElements() *
|
||||||
getTypeAllocSizeInBits(ATy->getElementType());
|
getTypeAllocSizeInBits(ATy->getElementType());
|
||||||
}
|
}
|
||||||
@ -536,7 +536,7 @@ inline uint64_t DataLayout::getTypeSizeInBits(const Type *Ty) const {
|
|||||||
case Type::X86_FP80TyID:
|
case Type::X86_FP80TyID:
|
||||||
return 80;
|
return 80;
|
||||||
case Type::VectorTyID: {
|
case Type::VectorTyID: {
|
||||||
const VectorType *VTy = cast<VectorType>(Ty);
|
VectorType *VTy = cast<VectorType>(Ty);
|
||||||
return VTy->getNumElements() * getTypeSizeInBits(VTy->getElementType());
|
return VTy->getNumElements() * getTypeSizeInBits(VTy->getElementType());
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -37,7 +37,7 @@ using namespace llvm;
|
|||||||
// Support for StructLayout
|
// Support for StructLayout
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
StructLayout::StructLayout(const StructType *ST, const DataLayout &DL) {
|
StructLayout::StructLayout(StructType *ST, const DataLayout &DL) {
|
||||||
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;
|
||||||
@ -451,7 +451,7 @@ void DataLayout::setPointerAlignment(uint32_t AddrSpace, unsigned ABIAlign,
|
|||||||
/// preferred if ABIInfo = false) the layout wants for the specified datatype.
|
/// preferred if ABIInfo = false) the layout wants for the specified datatype.
|
||||||
unsigned DataLayout::getAlignmentInfo(AlignTypeEnum AlignType,
|
unsigned DataLayout::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;
|
||||||
@ -516,7 +516,7 @@ unsigned DataLayout::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:
|
||||||
@ -529,7 +529,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StructLayout *&operator[](const StructType *STy) {
|
StructLayout *&operator[](StructType *STy) {
|
||||||
return LayoutInfo[STy];
|
return LayoutInfo[STy];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -548,7 +548,7 @@ DataLayout::~DataLayout() {
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const StructLayout *DataLayout::getStructLayout(const StructType *Ty) const {
|
const StructLayout *DataLayout::getStructLayout(StructType *Ty) const {
|
||||||
if (!LayoutMap)
|
if (!LayoutMap)
|
||||||
LayoutMap = new StructLayoutMap();
|
LayoutMap = new StructLayoutMap();
|
||||||
|
|
||||||
@ -599,7 +599,7 @@ unsigned DataLayout::getPointerSize(unsigned AS) const {
|
|||||||
return I->TypeByteWidth;
|
return I->TypeByteWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DataLayout::getPointerTypeSizeInBits(const Type *Ty) const {
|
unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const {
|
||||||
assert(Ty->isPtrOrPtrVectorTy() &&
|
assert(Ty->isPtrOrPtrVectorTy() &&
|
||||||
"This should only be called with a pointer or pointer vector type");
|
"This should only be called with a pointer or pointer vector type");
|
||||||
|
|
||||||
@ -617,7 +617,7 @@ unsigned DataLayout::getPointerTypeSizeInBits(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 DataLayout::getAlignment(const Type *Ty, bool abi_or_pref) const {
|
unsigned DataLayout::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!");
|
||||||
@ -671,7 +671,7 @@ unsigned DataLayout::getAlignment(const Type *Ty, bool abi_or_pref) const {
|
|||||||
abi_or_pref, Ty);
|
abi_or_pref, Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DataLayout::getABITypeAlignment(const Type *Ty) const {
|
unsigned DataLayout::getABITypeAlignment(Type *Ty) const {
|
||||||
return getAlignment(Ty, true);
|
return getAlignment(Ty, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,11 +681,11 @@ unsigned DataLayout::getABIIntegerTypeAlignment(unsigned BitWidth) const {
|
|||||||
return getAlignmentInfo(INTEGER_ALIGN, BitWidth, true, nullptr);
|
return getAlignmentInfo(INTEGER_ALIGN, BitWidth, true, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DataLayout::getPrefTypeAlignment(const Type *Ty) const {
|
unsigned DataLayout::getPrefTypeAlignment(Type *Ty) const {
|
||||||
return getAlignment(Ty, false);
|
return getAlignment(Ty, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DataLayout::getPreferredTypeAlignmentShift(const Type *Ty) const {
|
unsigned DataLayout::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);
|
||||||
@ -696,12 +696,12 @@ IntegerType *DataLayout::getIntPtrType(LLVMContext &C,
|
|||||||
return IntegerType::get(C, getPointerSizeInBits(AddressSpace));
|
return IntegerType::get(C, getPointerSizeInBits(AddressSpace));
|
||||||
}
|
}
|
||||||
|
|
||||||
Type *DataLayout::getIntPtrType(const Type *Ty) const {
|
Type *DataLayout::getIntPtrType(Type *Ty) const {
|
||||||
assert(Ty->isPtrOrPtrVectorTy() &&
|
assert(Ty->isPtrOrPtrVectorTy() &&
|
||||||
"Expected a pointer or pointer vector type.");
|
"Expected a pointer or pointer vector type.");
|
||||||
unsigned NumBits = getPointerTypeSizeInBits(Ty);
|
unsigned NumBits = getPointerTypeSizeInBits(Ty);
|
||||||
IntegerType *IntTy = IntegerType::get(Ty->getContext(), NumBits);
|
IntegerType *IntTy = IntegerType::get(Ty->getContext(), NumBits);
|
||||||
if (const VectorType *VecTy = dyn_cast<VectorType>(Ty))
|
if (VectorType *VecTy = dyn_cast<VectorType>(Ty))
|
||||||
return VectorType::get(IntTy, VecTy->getNumElements());
|
return VectorType::get(IntTy, VecTy->getNumElements());
|
||||||
return IntTy;
|
return IntTy;
|
||||||
}
|
}
|
||||||
@ -720,7 +720,7 @@ unsigned DataLayout::getLargestLegalIntTypeSize() const {
|
|||||||
|
|
||||||
uint64_t DataLayout::getIndexedOffset(Type *ptrTy,
|
uint64_t DataLayout::getIndexedOffset(Type *ptrTy,
|
||||||
ArrayRef<Value *> Indices) const {
|
ArrayRef<Value *> Indices) const {
|
||||||
const Type *Ty = ptrTy;
|
Type *Ty = ptrTy;
|
||||||
assert(Ty->isPointerTy() && "Illegal argument for getIndexedOffset()");
|
assert(Ty->isPointerTy() && "Illegal argument for getIndexedOffset()");
|
||||||
uint64_t Result = 0;
|
uint64_t Result = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user