Skip to content

Commit

Permalink
De-constify Types in FunctionType::get().
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134888 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
jayfoad committed Jul 11, 2011
1 parent 7f0ce34 commit f362aff
Show file tree
Hide file tree
Showing 31 changed files with 112 additions and 124 deletions.
2 changes: 0 additions & 2 deletions include/llvm/DerivedTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ class FunctionType : public Type {
/// FunctionType::get - This static method is the primary way of constructing
/// a FunctionType.
///
static FunctionType *get(const Type *Result,
ArrayRef<const Type*> Params, bool isVarArg);
static FunctionType *get(const Type *Result,
ArrayRef<Type*> Params, bool isVarArg);

Expand Down
6 changes: 3 additions & 3 deletions include/llvm/Intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ namespace Intrinsic {

/// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as
/// "llvm.ppc.altivec.lvx".
std::string getName(ID id, const Type **Tys = 0, unsigned numTys = 0);
std::string getName(ID id, Type **Tys = 0, unsigned numTys = 0);

/// Intrinsic::getType(ID) - Return the function type for an intrinsic.
///
const FunctionType *getType(LLVMContext &Context, ID id,
const Type **Tys = 0, unsigned numTys = 0);
Type **Tys = 0, unsigned numTys = 0);

/// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be
/// overloaded.
Expand All @@ -67,7 +67,7 @@ namespace Intrinsic {
/// overloaded intrinsic, Tys should point to an array of numTys pointers to
/// Type, and must provide exactly one type for each overloaded type in the
/// intrinsic.
Function *getDeclaration(Module *M, ID id, const Type **Tys = 0,
Function *getDeclaration(Module *M, ID id, Type **Tys = 0,
unsigned numTys = 0);

/// Map a GCC builtin name to an intrinsic ID.
Expand Down
74 changes: 37 additions & 37 deletions include/llvm/Support/TypeBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace llvm {
/// namespace llvm {
/// template<bool xcompile> class TypeBuilder<MyType, xcompile> {
/// public:
/// static const StructType *get(LLVMContext &Context) {
/// static StructType *get(LLVMContext &Context) {
/// // If you cache this result, be sure to cache it separately
/// // for each LLVMContext.
/// return StructType::get(
Expand Down Expand Up @@ -104,7 +104,7 @@ template<typename T, bool cross> class TypeBuilder<const volatile T, cross>
// Pointers
template<typename T, bool cross> class TypeBuilder<T*, cross> {
public:
static const PointerType *get(LLVMContext &Context) {
static PointerType *get(LLVMContext &Context) {
return PointerType::getUnqual(TypeBuilder<T,cross>::get(Context));
}
};
Expand All @@ -115,14 +115,14 @@ template<typename T, bool cross> class TypeBuilder<T&, cross> {};
// Arrays
template<typename T, size_t N, bool cross> class TypeBuilder<T[N], cross> {
public:
static const ArrayType *get(LLVMContext &Context) {
static ArrayType *get(LLVMContext &Context) {
return ArrayType::get(TypeBuilder<T, cross>::get(Context), N);
}
};
/// LLVM uses an array of length 0 to represent an unknown-length array.
template<typename T, bool cross> class TypeBuilder<T[], cross> {
public:
static const ArrayType *get(LLVMContext &Context) {
static ArrayType *get(LLVMContext &Context) {
return ArrayType::get(TypeBuilder<T, cross>::get(Context), 0);
}
};
Expand Down Expand Up @@ -152,7 +152,7 @@ template<typename T, bool cross> class TypeBuilder<T[], cross> {
#define DEFINE_INTEGRAL_TYPEBUILDER(T) \
template<> class TypeBuilder<T, false> { \
public: \
static const IntegerType *get(LLVMContext &Context) { \
static IntegerType *get(LLVMContext &Context) { \
return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \
} \
}; \
Expand Down Expand Up @@ -181,55 +181,55 @@ DEFINE_INTEGRAL_TYPEBUILDER(unsigned long long);
template<uint32_t num_bits, bool cross>
class TypeBuilder<types::i<num_bits>, cross> {
public:
static const IntegerType *get(LLVMContext &C) {
static IntegerType *get(LLVMContext &C) {
return IntegerType::get(C, num_bits);
}
};

template<> class TypeBuilder<float, false> {
public:
static const Type *get(LLVMContext& C) {
static Type *get(LLVMContext& C) {
return Type::getFloatTy(C);
}
};
template<> class TypeBuilder<float, true> {};

template<> class TypeBuilder<double, false> {
public:
static const Type *get(LLVMContext& C) {
static Type *get(LLVMContext& C) {
return Type::getDoubleTy(C);
}
};
template<> class TypeBuilder<double, true> {};

template<bool cross> class TypeBuilder<types::ieee_float, cross> {
public:
static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); }
static Type *get(LLVMContext& C) { return Type::getFloatTy(C); }
};
template<bool cross> class TypeBuilder<types::ieee_double, cross> {
public:
static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); }
static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); }
};
template<bool cross> class TypeBuilder<types::x86_fp80, cross> {
public:
static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); }
static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); }
};
template<bool cross> class TypeBuilder<types::fp128, cross> {
public:
static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); }
static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); }
};
template<bool cross> class TypeBuilder<types::ppc_fp128, cross> {
public:
static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); }
static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); }
};
template<bool cross> class TypeBuilder<types::x86_mmx, cross> {
public:
static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); }
static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); }
};

template<bool cross> class TypeBuilder<void, cross> {
public:
static const Type *get(LLVMContext &C) {
static Type *get(LLVMContext &C) {
return Type::getVoidTy(C);
}
};
Expand All @@ -247,14 +247,14 @@ template<> class TypeBuilder<const volatile void*, false>

template<typename R, bool cross> class TypeBuilder<R(), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
static FunctionType *get(LLVMContext &Context) {
return FunctionType::get(TypeBuilder<R, cross>::get(Context), false);
}
};
template<typename R, typename A1, bool cross> class TypeBuilder<R(A1), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(1);
params.push_back(TypeBuilder<A1, cross>::get(Context));
return FunctionType::get(TypeBuilder<R, cross>::get(Context),
Expand All @@ -264,8 +264,8 @@ template<typename R, typename A1, bool cross> class TypeBuilder<R(A1), cross> {
template<typename R, typename A1, typename A2, bool cross>
class TypeBuilder<R(A1, A2), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(2);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
Expand All @@ -276,8 +276,8 @@ class TypeBuilder<R(A1, A2), cross> {
template<typename R, typename A1, typename A2, typename A3, bool cross>
class TypeBuilder<R(A1, A2, A3), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(3);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
Expand All @@ -291,8 +291,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
bool cross>
class TypeBuilder<R(A1, A2, A3, A4), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(4);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
Expand All @@ -307,8 +307,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, bool cross>
class TypeBuilder<R(A1, A2, A3, A4, A5), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(5);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
Expand All @@ -322,15 +322,15 @@ class TypeBuilder<R(A1, A2, A3, A4, A5), cross> {

template<typename R, bool cross> class TypeBuilder<R(...), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
static FunctionType *get(LLVMContext &Context) {
return FunctionType::get(TypeBuilder<R, cross>::get(Context), true);
}
};
template<typename R, typename A1, bool cross>
class TypeBuilder<R(A1, ...), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(1);
params.push_back(TypeBuilder<A1, cross>::get(Context));
return FunctionType::get(TypeBuilder<R, cross>::get(Context), params, true);
Expand All @@ -339,8 +339,8 @@ class TypeBuilder<R(A1, ...), cross> {
template<typename R, typename A1, typename A2, bool cross>
class TypeBuilder<R(A1, A2, ...), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(2);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
Expand All @@ -351,8 +351,8 @@ class TypeBuilder<R(A1, A2, ...), cross> {
template<typename R, typename A1, typename A2, typename A3, bool cross>
class TypeBuilder<R(A1, A2, A3, ...), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(3);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
Expand All @@ -366,8 +366,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
bool cross>
class TypeBuilder<R(A1, A2, A3, A4, ...), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(4);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
Expand All @@ -382,8 +382,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, bool cross>
class TypeBuilder<R(A1, A2, A3, A4, A5, ...), cross> {
public:
static const FunctionType *get(LLVMContext &Context) {
std::vector<const Type*> params;
static FunctionType *get(LLVMContext &Context) {
std::vector<Type*> params;
params.reserve(5);
params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context));
Expand Down
8 changes: 4 additions & 4 deletions lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ bool LLParser::ParseFunctionType(Type *&Result) {
"argument attributes invalid in function type");
}

SmallVector<const Type*, 16> ArgListTy;
SmallVector<Type*, 16> ArgListTy;
for (unsigned i = 0, e = ArgList.size(); i != e; ++i)
ArgListTy.push_back(ArgList[i].Ty);

Expand Down Expand Up @@ -2655,7 +2655,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {

// Okay, if we got here, the function is syntactically valid. Convert types
// and do semantic checks.
std::vector<const Type*> ParamTypeList;
std::vector<Type*> ParamTypeList;
SmallVector<AttributeWithIndex, 8> Attrs;

if (RetAttrs != Attribute::None)
Expand Down Expand Up @@ -3171,7 +3171,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
if (!(PFTy = dyn_cast<PointerType>(RetType)) ||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
// Pull out the types of all of the arguments...
std::vector<const Type*> ParamTypes;
std::vector<Type*> ParamTypes;
for (unsigned i = 0, e = ArgList.size(); i != e; ++i)
ParamTypes.push_back(ArgList[i].V->getType());

Expand Down Expand Up @@ -3508,7 +3508,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
if (!(PFTy = dyn_cast<PointerType>(RetType)) ||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
// Pull out the types of all of the arguments...
std::vector<const Type*> ParamTypes;
std::vector<Type*> ParamTypes;
for (unsigned i = 0, e = ArgList.size(); i != e; ++i)
ParamTypes.push_back(ArgList[i].V->getType());

Expand Down
4 changes: 2 additions & 2 deletions lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ bool BitcodeReader::ParseTypeTableBody() {
// FUNCTION: [vararg, attrid, retty, paramty x N]
if (Record.size() < 3)
return Error("Invalid FUNCTION type record");
std::vector<const Type*> ArgTys;
std::vector<Type*> ArgTys;
for (unsigned i = 3, e = Record.size(); i != e; ++i) {
if (Type *T = getTypeByID(Record[i]))
ArgTys.push_back(T);
Expand Down Expand Up @@ -838,7 +838,7 @@ bool BitcodeReader::ParseOldTypeTable() {
// FUNCTION: [vararg, attrid, retty, paramty x N]
if (Record.size() < 3)
return Error("Invalid FUNCTION type record");
std::vector<const Type*> ArgTys;
std::vector<Type*> ArgTys;
for (unsigned i = 3, e = Record.size(); i != e; ++i) {
if (Type *Elt = getTypeByIDOrNull(Record[i]))
ArgTys.push_back(Elt);
Expand Down
4 changes: 1 addition & 3 deletions lib/CodeGen/DwarfEHPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,8 @@ bool DwarfEHPrepare::LowerUnwindsAndResumes() {
// Find the rewind function if we didn't already.
if (!RewindFunction) {
LLVMContext &Ctx = ResumeInsts[0]->getContext();
std::vector<const Type*>
Params(1, Type::getInt8PtrTy(Ctx));
FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx),
Params, false);
Type::getInt8PtrTy(Ctx), false);
const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME);
RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/CodeGen/IntrinsicLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static void EnsureFunctionExists(Module &M, const char *Name,
ArgIt ArgBegin, ArgIt ArgEnd,
const Type *RetTy) {
// Insert a correctly-typed definition now.
std::vector<const Type *> ParamTys;
std::vector<Type *> ParamTys;
for (ArgIt I = ArgBegin; I != ArgEnd; ++I)
ParamTys.push_back(I->getType());
M.getOrInsertFunction(Name, FunctionType::get(RetTy, ParamTys, false));
Expand Down Expand Up @@ -69,7 +69,7 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
// program already contains a function with this name.
Module *M = CI->getParent()->getParent()->getParent();
// Get or insert the definition now.
std::vector<const Type *> ParamTys;
std::vector<Type *> ParamTys;
for (ArgIt I = ArgBegin; I != ArgEnd; ++I)
ParamTys.push_back((*I)->getType());
Constant* FCache = M->getOrInsertFunction(NewFn,
Expand Down Expand Up @@ -553,12 +553,12 @@ bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) {
!CI->getType()->isIntegerTy())
return false;

const IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
IntegerType *Ty = dyn_cast<IntegerType>(CI->getType());
if (!Ty)
return false;

// Okay, we can do this xform, do so now.
const Type *Tys[] = { Ty };
Type *Tys[] = { Ty };
Module *M = CI->getParent()->getParent()->getParent();
Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1);

Expand Down
2 changes: 1 addition & 1 deletion lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool BlackfinIntrinsicInfo::isOverloaded(unsigned IntrID) const {

static const FunctionType *getType(LLVMContext &Context, unsigned id) {
const Type *ResultTy = NULL;
std::vector<const Type*> ArgTys;
std::vector<Type*> ArgTys;
bool IsVarArg = false;

#define GET_INTRINSIC_GENERATOR
Expand Down
2 changes: 1 addition & 1 deletion lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bool MBlazeIntrinsicInfo::isOverloaded(unsigned IntrID) const {

static const FunctionType *getType(LLVMContext &Context, unsigned id) {
const Type *ResultTy = NULL;
std::vector<const Type*> ArgTys;
std::vector<Type*> ArgTys;
bool IsVarArg = false;

#define GET_INTRINSIC_GENERATOR
Expand Down
2 changes: 1 addition & 1 deletion lib/Transforms/IPO/ArgumentPromotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Start by computing a new prototype for the function, which is the same as
// the old function, but has modified arguments.
const FunctionType *FTy = F->getFunctionType();
std::vector<const Type*> Params;
std::vector<Type*> Params;

typedef std::set<IndicesVector> ScalarizeTable;

Expand Down
Loading

0 comments on commit f362aff

Please sign in to comment.