1
0
mirror of https://github.com/RPCSX/llvm.git synced 2025-04-06 18:21:51 +00:00

De-constify Types in StructType::get() and TargetData::getIntPtrType().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134893 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jay Foad 2011-07-11 09:56:20 +00:00
parent ce3a9f51ce
commit eeb64ae6e5
13 changed files with 19 additions and 32 deletions

@ -204,11 +204,6 @@ public:
/// StructType::get - This static method is the primary way to create a /// StructType::get - This static method is the primary way to create a
/// StructType. /// StructType.
///
/// FIXME: Remove the 'const Type*' version of this when types are pervasively
/// de-constified.
static StructType *get(LLVMContext &Context, ArrayRef<const Type*> Elements,
bool isPacked = false);
static StructType *get(LLVMContext &Context, ArrayRef<Type*> Elements, static StructType *get(LLVMContext &Context, ArrayRef<Type*> Elements,
bool isPacked = false); bool isPacked = false);
@ -220,7 +215,7 @@ public:
/// structure types by specifying the elements as arguments. Note that this /// structure types by specifying the elements as arguments. Note that this
/// method always returns a non-packed struct, and requires at least one /// method always returns a non-packed struct, and requires at least one
/// element type. /// element type.
static StructType *get(const Type *elt1, ...) END_WITH_NULL; static StructType *get(Type *elt1, ...) END_WITH_NULL;
bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; } bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; }

@ -259,7 +259,7 @@ public:
/// 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.
/// ///
const IntegerType *getIntPtrType(LLVMContext &C) const; IntegerType *getIntPtrType(LLVMContext &C) const;
/// getIndexedOffset - return the offset from the beginning of the type for /// getIndexedOffset - return the offset from the beginning of the type for
/// the specified indices. This is used to implement getelementptr. /// the specified indices. This is used to implement getelementptr.

@ -87,9 +87,8 @@ FunctionPass *llvm::createSjLjEHPass(const TargetLowering *TLI) {
bool SjLjEHPass::doInitialization(Module &M) { bool SjLjEHPass::doInitialization(Module &M) {
// Build the function context structure. // Build the function context structure.
// builtin_setjmp uses a five word jbuf // builtin_setjmp uses a five word jbuf
const Type *VoidPtrTy = Type *VoidPtrTy = Type::getInt8PtrTy(M.getContext());
Type::getInt8PtrTy(M.getContext()); Type *Int32Ty = Type::getInt32Ty(M.getContext());
const Type *Int32Ty = Type::getInt32Ty(M.getContext());
FunctionContextTy = FunctionContextTy =
StructType::get(VoidPtrTy, // __prev StructType::get(VoidPtrTy, // __prev
Int32Ty, // call_site Int32Ty, // call_site

@ -128,10 +128,10 @@ bool ARMGlobalMerge::doMerge(SmallVectorImpl<GlobalVariable*> &Globals,
for (size_t i = 0, e = Globals.size(); i != e; ) { for (size_t i = 0, e = Globals.size(); i != e; ) {
size_t j = 0; size_t j = 0;
uint64_t MergedSize = 0; uint64_t MergedSize = 0;
std::vector<const Type*> Tys; std::vector<Type*> Tys;
std::vector<Constant*> Inits; std::vector<Constant*> Inits;
for (j = i; j != e; ++j) { for (j = i; j != e; ++j) {
const Type *Ty = Globals[j]->getType()->getElementType(); Type *Ty = Globals[j]->getType()->getElementType();
MergedSize += TD->getTypeAllocSize(Ty); MergedSize += TD->getTypeAllocSize(Ty);
if (MergedSize > MaxOffset) { if (MergedSize > MaxOffset) {
break; break;

@ -535,7 +535,7 @@ unsigned TargetData::getPreferredTypeAlignmentShift(const 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.
const IntegerType *TargetData::getIntPtrType(LLVMContext &C) const { IntegerType *TargetData::getIntPtrType(LLVMContext &C) const {
return IntegerType::get(C, getPointerSizeInBits()); return IntegerType::get(C, getPointerSizeInBits());
} }

@ -659,13 +659,13 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// Find out the new return value. // Find out the new return value.
const Type *RetTy = FTy->getReturnType(); Type *RetTy = FTy->getReturnType();
const Type *NRetTy = NULL; const Type *NRetTy = NULL;
unsigned RetCount = NumRetVals(F); unsigned RetCount = NumRetVals(F);
// -1 means unused, other numbers are the new index // -1 means unused, other numbers are the new index
SmallVector<int, 5> NewRetIdxs(RetCount, -1); SmallVector<int, 5> NewRetIdxs(RetCount, -1);
std::vector<const Type*> RetTypes; std::vector<Type*> RetTypes;
if (RetTy->isVoidTy()) { if (RetTy->isVoidTy()) {
NRetTy = RetTy; NRetTy = RetTy;
} else { } else {

@ -134,7 +134,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
void llvm::InsertProfilingShutdownCall(Function *Callee, Module *Mod) { void llvm::InsertProfilingShutdownCall(Function *Callee, Module *Mod) {
// llvm.global_dtors is an array of type { i32, void ()* }. Prepare those // llvm.global_dtors is an array of type { i32, void ()* }. Prepare those
// types. // types.
const Type *GlobalDtorElems[2] = { Type *GlobalDtorElems[2] = {
Type::getInt32Ty(Mod->getContext()), Type::getInt32Ty(Mod->getContext()),
FunctionType::get(Type::getVoidTy(Mod->getContext()), false)->getPointerTo() FunctionType::get(Type::getVoidTy(Mod->getContext()), false)->getPointerTo()
}; };

@ -403,7 +403,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
AllocaInst *Struct = 0; AllocaInst *Struct = 0;
if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
std::vector<const Type*> ArgTypes; std::vector<Type*> ArgTypes;
for (Values::iterator v = StructValues.begin(), for (Values::iterator v = StructValues.begin(),
ve = StructValues.end(); v != ve; ++v) ve = StructValues.end(); v != ve; ++v)
ArgTypes.push_back((*v)->getType()); ArgTypes.push_back((*v)->getType());

@ -619,7 +619,7 @@ Constant *ConstantArray::get(LLVMContext &Context, StringRef Str,
StructType *ConstantStruct::getTypeForElements(LLVMContext &Context, StructType *ConstantStruct::getTypeForElements(LLVMContext &Context,
ArrayRef<Constant*> V, ArrayRef<Constant*> V,
bool Packed) { bool Packed) {
SmallVector<const Type*, 16> EltTypes; SmallVector<Type*, 16> EltTypes;
for (unsigned i = 0, e = V.size(); i != e; ++i) for (unsigned i = 0, e = V.size(); i != e; ++i)
EltTypes.push_back(V[i]->getType()); EltTypes.push_back(V[i]->getType());

@ -290,7 +290,7 @@ void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest) {
LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
unsigned ElementCount, LLVMBool Packed) { unsigned ElementCount, LLVMBool Packed) {
std::vector<const Type*> Tys; std::vector<Type*> Tys;
for (LLVMTypeRef *I = ElementTypes, for (LLVMTypeRef *I = ElementTypes,
*E = ElementTypes + ElementCount; I != E; ++I) *E = ElementTypes + ElementCount; I != E; ++I)
Tys.push_back(unwrap(*I)); Tys.push_back(unwrap(*I));

@ -458,22 +458,15 @@ void StructType::setName(StringRef Name) {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// StructType Helper functions. // StructType Helper functions.
// FIXME: Remove this version.
StructType *StructType::get(LLVMContext &Context, ArrayRef<const Type*>Elements,
bool isPacked) {
return get(Context, ArrayRef<Type*>(const_cast<Type**>(Elements.data()),
Elements.size()), isPacked);
}
StructType *StructType::get(LLVMContext &Context, bool isPacked) { StructType *StructType::get(LLVMContext &Context, bool isPacked) {
return get(Context, llvm::ArrayRef<const Type*>(), isPacked); return get(Context, llvm::ArrayRef<Type*>(), isPacked);
} }
StructType *StructType::get(const Type *type, ...) { StructType *StructType::get(Type *type, ...) {
assert(type != 0 && "Cannot create a struct type with no elements with this"); assert(type != 0 && "Cannot create a struct type with no elements with this");
LLVMContext &Ctx = type->getContext(); LLVMContext &Ctx = type->getContext();
va_list ap; va_list ap;
SmallVector<const llvm::Type*, 8> StructFields; SmallVector<llvm::Type*, 8> StructFields;
va_start(ap, type); va_start(ap, type);
while (type) { while (type) {
StructFields.push_back(type); StructFields.push_back(type);

@ -173,7 +173,7 @@ void llvm::DeleteFunctionBody(Function *F) {
static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) { static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) {
assert(!TorList.empty() && "Don't create empty tor list!"); assert(!TorList.empty() && "Don't create empty tor list!");
std::vector<Constant*> ArrayElts; std::vector<Constant*> ArrayElts;
const Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext()); Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext());
const StructType *STy = const StructType *STy =
StructType::get(Int32Ty, TorList[0].first->getType(), NULL); StructType::get(Int32Ty, TorList[0].first->getType(), NULL);

@ -187,7 +187,7 @@ public:
static const StructType *get(LLVMContext &Context) { static const StructType *get(LLVMContext &Context) {
// Using the static result variable ensures that the type is // Using the static result variable ensures that the type is
// only looked up once. // only looked up once.
std::vector<const Type*> st; std::vector<Type*> st;
st.push_back(TypeBuilder<int, cross>::get(Context)); st.push_back(TypeBuilder<int, cross>::get(Context));
st.push_back(TypeBuilder<int*, cross>::get(Context)); st.push_back(TypeBuilder<int*, cross>::get(Context));
st.push_back(TypeBuilder<void*[], cross>::get(Context)); st.push_back(TypeBuilder<void*[], cross>::get(Context));
@ -210,7 +210,7 @@ public:
static const StructType *get(LLVMContext &Context) { static const StructType *get(LLVMContext &Context) {
// Using the static result variable ensures that the type is // Using the static result variable ensures that the type is
// only looked up once. // only looked up once.
std::vector<const Type*> st; std::vector<Type*> st;
st.push_back(TypeBuilder<types::i<32>, cross>::get(Context)); st.push_back(TypeBuilder<types::i<32>, cross>::get(Context));
st.push_back(TypeBuilder<types::i<32>*, cross>::get(Context)); st.push_back(TypeBuilder<types::i<32>*, cross>::get(Context));
st.push_back(TypeBuilder<types::i<8>*[], cross>::get(Context)); st.push_back(TypeBuilder<types::i<8>*[], cross>::get(Context));