From debcb01b0f0a15f568ca69e8f288fade4bfc7297 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 29 Jul 2009 22:17:13 +0000 Subject: 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 --- include/llvm/CodeGen/ValueTypes.h | 2 +- include/llvm/InstrTypes.h | 8 ++++++++ include/llvm/Instructions.h | 13 ++++++------- include/llvm/LLVMContext.h | 34 ---------------------------------- include/llvm/Support/TypeBuilder.h | 35 +++++++++++++++++------------------ 5 files changed, 32 insertions(+), 60 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 57ca285..5069f9e 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 43fe664..ddb6ad3 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(V) && classof(cast(V)); } + + /// @brief Create a result type for fcmp/icmp + static const Type* makeCmpResultType(const Type* opnd_type) { + if (const VectorType* vt = dyn_cast(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 2b53fac..ad5a4a9 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(V) && classof(cast(V)); } - }; //===----------------------------------------------------------------------===// diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 8c3e2ef..00a6581 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& 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& 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 5ea7f9e..1f85f1d 100644 --- a/include/llvm/Support/TypeBuilder.h +++ b/include/llvm/Support/TypeBuilder.h @@ -107,7 +107,7 @@ template class TypeBuilder { public: static const PointerType *get(LLVMContext &Context) { static const PointerType *const result = - Context.getPointerTypeUnqual(TypeBuilder::get(Context)); + PointerType::getUnqual(TypeBuilder::get(Context)); return result; } }; @@ -120,7 +120,7 @@ template class TypeBuilder { public: static const ArrayType *get(LLVMContext &Context) { static const ArrayType *const result = - Context.getArrayType(TypeBuilder::get(Context), N); + ArrayType::get(TypeBuilder::get(Context), N); return result; } }; @@ -129,7 +129,7 @@ template class TypeBuilder { public: static const ArrayType *get(LLVMContext &Context) { static const ArrayType *const result = - Context.getArrayType(TypeBuilder::get(Context), 0); + ArrayType::get(TypeBuilder::get(Context), 0); return result; } }; @@ -161,7 +161,7 @@ template<> class TypeBuilder { \ 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 class TypeBuilder, 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::get(Context), false); + return FunctionType::get(TypeBuilder::get(Context), false); } }; template class TypeBuilder { @@ -269,7 +269,7 @@ private: std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -287,7 +287,7 @@ private: params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -306,7 +306,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -328,7 +328,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -351,7 +351,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -365,7 +365,7 @@ public: private: static const FunctionType *create(LLVMContext &Context) { - return Context.getFunctionType(TypeBuilder::get(Context), true); + return FunctionType::get(TypeBuilder::get(Context), true); } }; template @@ -381,8 +381,7 @@ private: std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), - params, true); + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; template @@ -399,7 +398,7 @@ private: params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; @@ -418,7 +417,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; @@ -440,7 +439,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; @@ -463,7 +462,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; -- cgit v1.1