diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-29 22:17:13 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-29 22:17:13 +0000 |
commit | debcb01b0f0a15f568ca69e8f288fade4bfc7297 (patch) | |
tree | 22a274838cf6c55205a8a3f0a80262b09b63b069 | |
parent | 37c4a2d6f15ff32c9ae91e333d655a349e195993 (diff) |
Move types back to the 2.5 API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77516 91177308-0d34-0410-b5e6-96231b3b80d8
71 files changed, 287 insertions, 439 deletions
diff --git a/docs/tutorial/LangImpl3.html b/docs/tutorial/LangImpl3.html index c56b1edac6..5f1072f632 100644 --- a/docs/tutorial/LangImpl3.html +++ b/docs/tutorial/LangImpl3.html @@ -308,7 +308,7 @@ bodies and external function declarations. The code starts with:</p> Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); </pre> @@ -1082,7 +1082,7 @@ Value *CallExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/docs/tutorial/LangImpl4.html b/docs/tutorial/LangImpl4.html index 45002d29ea..5eb69d3357 100644 --- a/docs/tutorial/LangImpl4.html +++ b/docs/tutorial/LangImpl4.html @@ -917,7 +917,7 @@ Value *CallExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/docs/tutorial/LangImpl5.html b/docs/tutorial/LangImpl5.html index 62a0dd9739..8d77d5ec89 100644 --- a/docs/tutorial/LangImpl5.html +++ b/docs/tutorial/LangImpl5.html @@ -1551,7 +1551,7 @@ Value *ForExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/docs/tutorial/LangImpl6.html b/docs/tutorial/LangImpl6.html index 5a553b7b8a..0f714b385a 100644 --- a/docs/tutorial/LangImpl6.html +++ b/docs/tutorial/LangImpl6.html @@ -1576,7 +1576,7 @@ Value *ForExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/docs/tutorial/LangImpl7.html b/docs/tutorial/LangImpl7.html index d3ebd962c5..844c48fff2 100644 --- a/docs/tutorial/LangImpl7.html +++ b/docs/tutorial/LangImpl7.html @@ -1911,7 +1911,7 @@ Value *VarExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp index e47365bfa1..e1615569d2 100644 --- a/examples/BrainF/BrainF.cpp +++ b/examples/BrainF/BrainF.cpp @@ -138,7 +138,7 @@ void BrainF::header(LLVMContext& C) { //declare i32 @puts(i8 *) Function *puts_func = cast<Function>(module-> getOrInsertFunction("puts", IntegerType::Int32Ty, - C.getPointerTypeUnqual(IntegerType::Int8Ty), NULL)); + PointerType::getUnqual(IntegerType::Int8Ty), NULL)); //brainf.aberror: aberrorbb = BasicBlock::Create(label, brainf_func); @@ -284,7 +284,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb, // Make part of PHI instruction now, wait until end of loop to finish PHINode *phi_0 = - PHINode::Create(C.getPointerTypeUnqual(IntegerType::Int8Ty), + PHINode::Create(PointerType::getUnqual(IntegerType::Int8Ty), headreg, testbb); phi_0->reserveOperandSpace(2); phi_0->addIncoming(curhead, bb_0); @@ -440,7 +440,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb, //%head.%d = phi i8 *[%head.%d, %main.%d] PHINode *phi_1 = builder-> - CreatePHI(C.getPointerTypeUnqual(IntegerType::Int8Ty), headreg); + CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg); phi_1->reserveOperandSpace(1); phi_1->addIncoming(head_0, testbb); curhead = phi_1; diff --git a/examples/Kaleidoscope/toy.cpp b/examples/Kaleidoscope/toy.cpp index 6f7f0ee206..004c7b7c06 100644 --- a/examples/Kaleidoscope/toy.cpp +++ b/examples/Kaleidoscope/toy.cpp @@ -909,8 +909,7 @@ Value *VarExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = - getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp index 1baa8c98ef..fc487af056 100644 --- a/examples/ModuleMaker/ModuleMaker.cpp +++ b/examples/ModuleMaker/ModuleMaker.cpp @@ -31,7 +31,7 @@ int main() { // Create the main function: first create the type 'int ()' FunctionType *FT = - Context.getFunctionType(Type::Int32Ty, /*not vararg*/false); + FunctionType::get(Type::Int32Ty, /*not vararg*/false); // By passing a module as the last parameter to the Function constructor, // it automatically gets appended to the Module. diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 57ca285fac..5069f9e00a 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -477,7 +477,7 @@ namespace llvm { /// getTypeForMVT - This method returns an LLVM type corresponding to the /// specified MVT. For integer types, this returns an unsigned type. Note /// that this will abort for types that cannot be represented. - const Type *getTypeForMVT(LLVMContext &Context) const; + const Type *getTypeForMVT() const; /// getMVT - Return the value type corresponding to the specified type. /// This returns all pointers as iPTR. If HandleUnknown is true, unknown diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 43fe664003..ddb6ad377d 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -667,6 +667,14 @@ public: static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); } + + /// @brief Create a result type for fcmp/icmp + static const Type* makeCmpResultType(const Type* opnd_type) { + if (const VectorType* vt = dyn_cast<const VectorType>(opnd_type)) { + return VectorType::get(Type::Int1Ty, vt->getNumElements()); + } + return Type::Int1Ty; + } }; diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 2b53fac465..ad5a4a9d3e 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -645,7 +645,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr, InsertBefore) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && @@ -666,7 +666,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr, &InsertAtEnd) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && @@ -687,7 +687,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(Context.makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && pred <= CmpInst::LAST_ICMP_PREDICATE && @@ -820,7 +820,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::FCmp, pred, LHS, RHS, NameStr, InsertBefore) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && @@ -839,7 +839,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::FCmp, pred, LHS, RHS, NameStr, &InsertAtEnd) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && @@ -858,7 +858,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(Context.makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::FCmp, pred, LHS, RHS, NameStr) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && "Invalid FCmp predicate value"); @@ -910,7 +910,6 @@ public: static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); } - }; //===----------------------------------------------------------------------===// diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 8c3e2eff96..00a6581dab 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -91,40 +91,6 @@ public: // MDString accessors MDString* getMDString(const StringRef &Str); - // FunctionType accessors - FunctionType* getFunctionType(const Type* Result, bool isVarArg); - FunctionType* getFunctionType(const Type* Result, - const std::vector<const Type*>& Params, - bool isVarArg); - - // IntegerType accessors - const IntegerType* getIntegerType(unsigned NumBits); - - // OpaqueType accessors - OpaqueType* getOpaqueType(); - - // StructType accessors - StructType* getStructType(bool isPacked=false); - StructType* getStructType(const std::vector<const Type*>& Params, - bool isPacked = false); - StructType* getStructType(const Type* type, ...); - - // ArrayType accessors - ArrayType* getArrayType(const Type* ElementType, uint64_t NumElements); - - // PointerType accessors - PointerType* getPointerType(const Type* ElementType, unsigned AddressSpace); - PointerType* getPointerTypeUnqual(const Type* ElementType); - - // VectorType accessors - VectorType* getVectorType(const Type* ElementType, unsigned NumElements); - VectorType* getVectorTypeInteger(const VectorType* VTy); - VectorType* getVectorTypeExtendedElement(const VectorType* VTy); - VectorType* getVectorTypeTruncatedElement(const VectorType* VTy); - - // Other helpers - /// @brief Create a result type for fcmp/icmp - const Type* makeCmpResultType(const Type* opnd_type); // Methods for erasing constants void erase(MDString *M); diff --git a/include/llvm/Support/TypeBuilder.h b/include/llvm/Support/TypeBuilder.h index 5ea7f9ebcf..1f85f1d125 100644 --- a/include/llvm/Support/TypeBuilder.h +++ b/include/llvm/Support/TypeBuilder.h @@ -107,7 +107,7 @@ template<typename T, bool cross> class TypeBuilder<T*, cross> { public: static const PointerType *get(LLVMContext &Context) { static const PointerType *const result = - Context.getPointerTypeUnqual(TypeBuilder<T,cross>::get(Context)); + PointerType::getUnqual(TypeBuilder<T,cross>::get(Context)); return result; } }; @@ -120,7 +120,7 @@ template<typename T, size_t N, bool cross> class TypeBuilder<T[N], cross> { public: static const ArrayType *get(LLVMContext &Context) { static const ArrayType *const result = - Context.getArrayType(TypeBuilder<T, cross>::get(Context), N); + ArrayType::get(TypeBuilder<T, cross>::get(Context), N); return result; } }; @@ -129,7 +129,7 @@ template<typename T, bool cross> class TypeBuilder<T[], cross> { public: static const ArrayType *get(LLVMContext &Context) { static const ArrayType *const result = - Context.getArrayType(TypeBuilder<T, cross>::get(Context), 0); + ArrayType::get(TypeBuilder<T, cross>::get(Context), 0); return result; } }; @@ -161,7 +161,7 @@ template<> class TypeBuilder<T, false> { \ public: \ static const IntegerType *get(LLVMContext &Context) { \ static const IntegerType *const result = \ - Context.getIntegerType(sizeof(T) * CHAR_BIT); \ + IntegerType::get(sizeof(T) * CHAR_BIT); \ return result; \ } \ }; \ @@ -191,7 +191,7 @@ template<uint32_t num_bits, bool cross> class TypeBuilder<types::i<num_bits>, cross> { public: static const IntegerType *get(LLVMContext &Context) { - static const IntegerType *const result = Context.getIntegerType(num_bits); + static const IntegerType *const result = IntegerType::get(num_bits); return result; } }; @@ -254,7 +254,7 @@ public: private: static const FunctionType *create(LLVMContext &Context) { - return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), false); + return FunctionType::get(TypeBuilder<R, cross>::get(Context), false); } }; template<typename R, typename A1, bool cross> class TypeBuilder<R(A1), cross> { @@ -269,7 +269,7 @@ private: std::vector<const Type*> params; params.reserve(1); params.push_back(TypeBuilder<A1, cross>::get(Context)); - return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), + return FunctionType::get(TypeBuilder<R, cross>::get(Context), params, false); } }; @@ -287,7 +287,7 @@ private: params.reserve(2); params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); - return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), + return FunctionType::get(TypeBuilder<R, cross>::get(Context), params, false); } }; @@ -306,7 +306,7 @@ private: params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); params.push_back(TypeBuilder<A3, cross>::get(Context)); - return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), + return FunctionType::get(TypeBuilder<R, cross>::get(Context), params, false); } }; @@ -328,7 +328,7 @@ private: params.push_back(TypeBuilder<A2, cross>::get(Context)); params.push_back(TypeBuilder<A3, cross>::get(Context));< |