diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index f0c2200c7a3..d338e0de676 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -54,147 +54,151 @@ public: ~LLVMContext(); // ConstantInt accessors - ConstantInt* getConstantIntTrue(); - ConstantInt* getConstantIntFalse(); + ConstantInt* getConstantIntTrue() const; + ConstantInt* getConstantIntFalse() const; ConstantInt* getConstantInt(const IntegerType* Ty, uint64_t V, - bool isSigned = false); - ConstantInt* getConstantIntSigned(const IntegerType* Ty, int64_t V); - ConstantInt* getConstantInt(const APInt& V); - Constant* getConstantInt(const Type* Ty, const APInt& V); - ConstantInt* getAllOnesConstantInt(const Type* Ty); + bool isSigned = false) const; + ConstantInt* getConstantIntSigned(const IntegerType* Ty, int64_t V) const; + ConstantInt* getConstantInt(const APInt& V) const; + Constant* getConstantInt(const Type* Ty, const APInt& V) const; + ConstantInt* getAllOnesConstantInt(const Type* Ty) const; // ConstantPointerNull accessors - ConstantPointerNull* getConstantPointerNull(const PointerType* T); + ConstantPointerNull* getConstantPointerNull(const PointerType* T) const; // ConstantStruct accessors Constant* getConstantStruct(const StructType* T, - const std::vector& V); + const std::vector& V) const; Constant* getConstantStruct(const std::vector& V, - bool Packed = false); + bool Packed = false) const; Constant* getConstantStruct(Constant* const *Vals, unsigned NumVals, - bool Packed = false); + bool Packed = false) const; // ConstantAggregateZero accessors - ConstantAggregateZero* getConstantAggregateZero(const Type* Ty); + ConstantAggregateZero* getConstantAggregateZero(const Type* Ty) const; // ConstantArray accessors Constant* getConstantArray(const ArrayType* T, - const std::vector& V); + const std::vector& V) const; Constant* getConstantArray(const ArrayType* T, Constant* const* Vals, - unsigned NumVals); + unsigned NumVals) const; Constant* getConstantArray(const std::string& Initializer, - bool AddNull = false); + bool AddNull = false) const; // ConstantExpr accessors - Constant* getConstantExpr(unsigned Opcode, Constant* C1, Constant* C2); - Constant* getConstantExprTrunc(Constant* C, const Type* Ty); - Constant* getConstantExprSExt(Constant* C, const Type* Ty); - Constant* getConstantExprZExt(Constant* C, const Type* Ty); - Constant* getConstantExprFPTrunc(Constant* C, const Type* Ty); - Constant* getConstantExprFPExtend(Constant* C, const Type* Ty); - Constant* getConstantExprUIToFP(Constant* C, const Type* Ty); - Constant* getConstantExprSIToFP(Constant* C, const Type* Ty); - Constant* getConstantExprFPToUI(Constant* C, const Type* Ty); - Constant* getConstantExprFPToSI(Constant* C, const Type* Ty); - Constant* getConstantExprPtrToInt(Constant* C, const Type* Ty); - Constant* getConstantExprIntToPtr(Constant* C, const Type* Ty); - Constant* getConstantExprBitCast(Constant* C, const Type* Ty); - Constant* getConstantExprCast(unsigned ops, Constant* C, const Type* Ty); - Constant* getConstantExprZExtOrBitCast(Constant* C, const Type* Ty); - Constant* getConstantExprSExtOrBitCast(Constant* C, const Type* Ty); - Constant* getConstantExprTruncOrBitCast(Constant* C, const Type* Ty); - Constant* getConstantExprPointerCast(Constant* C, const Type* Ty); + Constant* getConstantExpr(unsigned Opcode, Constant* C1, Constant* C2) const; + Constant* getConstantExprTrunc(Constant* C, const Type* Ty) const; + Constant* getConstantExprSExt(Constant* C, const Type* Ty) const; + Constant* getConstantExprZExt(Constant* C, const Type* Ty) const; + Constant* getConstantExprFPTrunc(Constant* C, const Type* Ty) const; + Constant* getConstantExprFPExtend(Constant* C, const Type* Ty) const; + Constant* getConstantExprUIToFP(Constant* C, const Type* Ty) const; + Constant* getConstantExprSIToFP(Constant* C, const Type* Ty) const; + Constant* getConstantExprFPToUI(Constant* C, const Type* Ty) const; + Constant* getConstantExprFPToSI(Constant* C, const Type* Ty) const; + Constant* getConstantExprPtrToInt(Constant* C, const Type* Ty) const; + Constant* getConstantExprIntToPtr(Constant* C, const Type* Ty) const; + Constant* getConstantExprBitCast(Constant* C, const Type* Ty) const; + Constant* getConstantExprCast(unsigned ops, Constant* C, + const Type* Ty) const; + Constant* getConstantExprZExtOrBitCast(Constant* C, const Type* Ty) const; + Constant* getConstantExprSExtOrBitCast(Constant* C, const Type* Ty) const; + Constant* getConstantExprTruncOrBitCast(Constant* C, const Type* Ty) const; + Constant* getConstantExprPointerCast(Constant* C, const Type* Ty) const; Constant* getConstantExprIntegerCast(Constant* C, const Type* Ty, - bool isSigned); - Constant* getConstantExprFPCast(Constant* C, const Type* Ty); - Constant* getConstantExprSelect(Constant* C, Constant* V1, Constant* V2); - Constant* getConstantExprAlignOf(const Type* Ty); + bool isSigned) const; + Constant* getConstantExprFPCast(Constant* C, const Type* Ty) const; + Constant* getConstantExprSelect(Constant* C, Constant* V1, + Constant* V2) const; + Constant* getConstantExprAlignOf(const Type* Ty) const; Constant* getConstantExprCompare(unsigned short pred, - Constant* C1, Constant* C2); - Constant* getConstantExprNeg(Constant* C); - Constant* getConstantExprFNeg(Constant* C); - Constant* getConstantExprNot(Constant* C); - Constant* getConstantExprAdd(Constant* C1, Constant* C2); - Constant* getConstantExprFAdd(Constant* C1, Constant* C2); - Constant* getConstantExprSub(Constant* C1, Constant* C2); - Constant* getConstantExprFSub(Constant* C1, Constant* C2); - Constant* getConstantExprMul(Constant* C1, Constant* C2); - Constant* getConstantExprFMul(Constant* C1, Constant* C2); - Constant* getConstantExprUDiv(Constant* C1, Constant* C2); - Constant* getConstantExprSDiv(Constant* C1, Constant* C2); - Constant* getConstantExprFDiv(Constant* C1, Constant* C2); - Constant* getConstantExprURem(Constant* C1, Constant* C2); - Constant* getConstantExprSRem(Constant* C1, Constant* C2); - Constant* getConstantExprFRem(Constant* C1, Constant* C2); - Constant* getConstantExprAnd(Constant* C1, Constant* C2); - Constant* getConstantExprOr(Constant* C1, Constant* C2); - Constant* getConstantExprXor(Constant* C1, Constant* C2); + Constant* C1, Constant* C2) const; + Constant* getConstantExprNeg(Constant* C) const; + Constant* getConstantExprFNeg(Constant* C) const; + Constant* getConstantExprNot(Constant* C) const; + Constant* getConstantExprAdd(Constant* C1, Constant* C2) const; + Constant* getConstantExprFAdd(Constant* C1, Constant* C2) const; + Constant* getConstantExprSub(Constant* C1, Constant* C2) const; + Constant* getConstantExprFSub(Constant* C1, Constant* C2) const; + Constant* getConstantExprMul(Constant* C1, Constant* C2) const; + Constant* getConstantExprFMul(Constant* C1, Constant* C2) const; + Constant* getConstantExprUDiv(Constant* C1, Constant* C2) const; + Constant* getConstantExprSDiv(Constant* C1, Constant* C2) const; + Constant* getConstantExprFDiv(Constant* C1, Constant* C2) const; + Constant* getConstantExprURem(Constant* C1, Constant* C2) const; + Constant* getConstantExprSRem(Constant* C1, Constant* C2) const; + Constant* getConstantExprFRem(Constant* C1, Constant* C2) const; + Constant* getConstantExprAnd(Constant* C1, Constant* C2) const; + Constant* getConstantExprOr(Constant* C1, Constant* C2) const; + Constant* getConstantExprXor(Constant* C1, Constant* C2) const; Constant* getConstantExprICmp(unsigned short pred, Constant* LHS, - Constant* RHS); + Constant* RHS) const; Constant* getConstantExprFCmp(unsigned short pred, Constant* LHS, - Constant* RHS); + Constant* RHS) const; Constant* getConstantExprVICmp(unsigned short pred, Constant* LHS, - Constant* RHS); + Constant* RHS) const; Constant* getConstantExprVFCmp(unsigned short pred, Constant* LHS, - Constant* RHS); - Constant* getConstantExprShl(Constant* C1, Constant* C2); - Constant* getConstantExprLShr(Constant* C1, Constant* C2); - Constant* getConstantExprAShr(Constant* C1, Constant* C2); + Constant* RHS) const; + Constant* getConstantExprShl(Constant* C1, Constant* C2) const; + Constant* getConstantExprLShr(Constant* C1, Constant* C2) const; + Constant* getConstantExprAShr(Constant* C1, Constant* C2) const; Constant* getConstantExprGetElementPtr(Constant* C, Constant* const* IdxList, - unsigned NumIdx); + unsigned NumIdx) const; Constant* getConstantExprGetElementPtr(Constant* C, Value* const* IdxList, - unsigned NumIdx); - Constant* getConstantExprExtractElement(Constant* Vec, Constant* Idx); + unsigned NumIdx) const; + Constant* getConstantExprExtractElement(Constant* Vec, Constant* Idx) const; Constant* getConstantExprInsertElement(Constant* Vec, Constant* Elt, - Constant* Idx); + Constant* Idx) const; Constant* getConstantExprShuffleVector(Constant* V1, Constant* V2, - Constant* Mask); + Constant* Mask) const; Constant* getConstantExprExtractValue(Constant* Agg, const unsigned* IdxList, - unsigned NumIdx); + unsigned NumIdx) const; Constant* getConstantExprInsertValue(Constant* Agg, Constant* Val, const unsigned* IdxList, - unsigned NumIdx); - Constant* getZeroValueForNegation(const Type* Ty); + unsigned NumIdx) const; + Constant* getZeroValueForNegation(const Type* Ty) const; // ConstantFP accessors - ConstantFP* getConstantFP(const APFloat& V); - Constant* getConstantFP(const Type* Ty, double V); - ConstantFP* getConstantFPNegativeZero(const Type* Ty); + ConstantFP* getConstantFP(const APFloat& V) const; + Constant* getConstantFP(const Type* Ty, double V) const; + ConstantFP* getConstantFPNegativeZero(const Type* Ty) const; // ConstantVector accessors Constant* getConstantVector(const VectorType* T, - const std::vector& V); - Constant* getConstantVector(const std::vector& V); - Constant* getConstantVector(Constant* const* Vals, unsigned NumVals); - ConstantVector* getConstantVectorAllOnes(const VectorType* Ty); + const std::vector& V) const; + Constant* getConstantVector(const std::vector& V) const; + Constant* getConstantVector(Constant* const* Vals, unsigned NumVals) const; + ConstantVector* getConstantVectorAllOnes(const VectorType* Ty) const; // FunctionType accessors FunctionType* getFunctionType(const Type* Result, const std::vector& Params, - bool isVarArg); + bool isVarArg) const; // IntegerType accessors - const IntegerType* getIntegerType(unsigned NumBits); + const IntegerType* getIntegerType(unsigned NumBits) const; // OpaqueType accessors - OpaqueType* getOpaqueType(); + OpaqueType* getOpaqueType() const; // StructType accessors StructType* getStructType(const std::vector& Params, - bool isPacked = false); + bool isPacked = false) const; // ArrayType accessors - ArrayType* getArrayType(const Type* ElementType, uint64_t NumElements); + ArrayType* getArrayType(const Type* ElementType, uint64_t NumElements) const; // PointerType accessors - PointerType* getPointerType(const Type* ElementType, unsigned AddressSpace); - PointerType* getPointerTypeUnqualified(const Type* ElementType); + PointerType* getPointerType(const Type* ElementType, + unsigned AddressSpace) const; + PointerType* getPointerTypeUnqualified(const Type* ElementType) const; // VectorType accessors - VectorType* getVectorType(const Type* ElementType, unsigned NumElements); - VectorType* getVectorTypeInteger(const VectorType* VTy); - VectorType* getVectorTypeExtendedElement(const VectorType* VTy); - VectorType* getVectorTypeTruncatedElement(const VectorType* VTy); + VectorType* getVectorType(const Type* ElementType, + unsigned NumElements) const; + VectorType* getVectorTypeInteger(const VectorType* VTy) const; + VectorType* getVectorTypeExtendedElement(const VectorType* VTy) const; + VectorType* getVectorTypeTruncatedElement(const VectorType* VTy) const; }; /// FOR BACKWARDS COMPATIBILITY - Returns a global context. diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 4ab0f26f75d..011d1137975 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -18,6 +18,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/InlineAsm.h" #include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" #include "llvm/MDNode.h" #include "llvm/Module.h" #include "llvm/ValueSymbolTable.h" @@ -1653,11 +1654,11 @@ bool LLParser::ParseValID(ValID &ID) { ID.Kind = ValID::t_APFloat; break; case lltok::kw_true: - ID.ConstantVal = ConstantInt::getTrue(); + ID.ConstantVal = Context.getConstantIntTrue(); ID.Kind = ValID::t_Constant; break; case lltok::kw_false: - ID.ConstantVal = ConstantInt::getFalse(); + ID.ConstantVal = Context.getConstantIntFalse(); ID.Kind = ValID::t_Constant; break; case lltok::kw_null: ID.Kind = ValID::t_Null; break; @@ -2037,7 +2038,7 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, if (!isa(Ty)) return Error(ID.Loc, "integer constant must have integer type"); ID.APSIntVal.extOrTrunc(Ty->getPrimitiveSizeInBits()); - V = ConstantInt::get(ID.APSIntVal); + V = Context.getConstantInt(ID.APSIntVal); return false; case ValID::t_APFloat: if (!Ty->isFloatingPoint() || diff --git a/lib/AsmParser/LLParser.h b/lib/AsmParser/LLParser.h index 41c2ee75c60..924c9293cb1 100644 --- a/lib/AsmParser/LLParser.h +++ b/lib/AsmParser/LLParser.h @@ -15,6 +15,7 @@ #define LLVM_ASMPARSER_LLPARSER_H #include "LLLexer.h" +#include "llvm/Module.h" #include "llvm/Type.h" #include @@ -29,13 +30,14 @@ namespace llvm { class GlobalValue; class MDString; class MDNode; + class LLVMContext; struct ValID; class LLParser { public: typedef LLLexer::LocTy LocTy; private: - + const LLVMContext& Context; LLLexer Lex; Module *M; @@ -72,7 +74,8 @@ namespace llvm { std::map > ForwardRefValIDs; std::vector NumberedVals; public: - LLParser(MemoryBuffer *F, ParseError &Err, Module *m) : Lex(F, Err), M(m) {} + LLParser(MemoryBuffer *F, ParseError &Err, Module *m) : + Context(M->getContext()), Lex(F, Err), M(m) {} bool Run(); private: diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp index d29b758ea74..be5b24f9d7d 100644 --- a/lib/VMCore/LLVMContext.cpp +++ b/lib/VMCore/LLVMContext.cpp @@ -22,7 +22,7 @@ using namespace llvm; static ManagedStatic GlobalContext; -const LLVMContext& llvm::getGlobalContext() { +LLVMContext& llvm::getGlobalContext() { return *GlobalContext; } @@ -30,420 +30,438 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { } LLVMContext::~LLVMContext() { delete pImpl; } // ConstantInt accessors. -ConstantInt* LLVMContext::getConstantIntTrue() { +ConstantInt* LLVMContext::getConstantIntTrue() const { return ConstantInt::getTrue(); } -ConstantInt* LLVMContext::getConstantIntFalse() { +ConstantInt* LLVMContext::getConstantIntFalse() const { return ConstantInt::getFalse(); } ConstantInt* LLVMContext::getConstantInt(const IntegerType* Ty, uint64_t V, - bool isSigned) { + bool isSigned) const { return ConstantInt::get(Ty, V, isSigned); } ConstantInt* LLVMContext::getConstantIntSigned(const IntegerType* Ty, - int64_t V) { + int64_t V) const { return ConstantInt::getSigned(Ty, V); } -ConstantInt* LLVMContext::getConstantInt(const APInt& V) { +ConstantInt* LLVMContext::getConstantInt(const APInt& V) const { return ConstantInt::get(V); } -Constant* LLVMContext::getConstantInt(const Type* Ty, const APInt& V) { +Constant* LLVMContext::getConstantInt(const Type* Ty, const APInt& V) const { return ConstantInt::get(Ty, V); } -ConstantInt* LLVMContext::getAllOnesConstantInt(const Type* Ty) { +ConstantInt* LLVMContext::getAllOnesConstantInt(const Type* Ty) const { return ConstantInt::getAllOnesValue(Ty); } // ConstantPointerNull accessors. -ConstantPointerNull* LLVMContext::getConstantPointerNull(const PointerType* T) { +ConstantPointerNull* +LLVMContext::getConstantPointerNull(const PointerType* T) const { return ConstantPointerNull::get(T); } // ConstantStruct accessors. Constant* LLVMContext::getConstantStruct(const StructType* T, - const std::vector& V) { + const std::vector& V) const { return ConstantStruct::get(T, V); } Constant* LLVMContext::getConstantStruct(const std::vector& V, - bool Packed) { + bool Packed) const { return ConstantStruct::get(V, Packed); } Constant* LLVMContext::getConstantStruct(Constant* const *Vals, - unsigned NumVals, bool Packed) { + unsigned NumVals, bool Packed) const { return ConstantStruct::get(Vals, NumVals, Packed); } // ConstantAggregateZero accessors. -ConstantAggregateZero* LLVMContext::getConstantAggregateZero(const Type* Ty) { +ConstantAggregateZero* +LLVMContext::getConstantAggregateZero(const Type* Ty) const { return ConstantAggregateZero::get(Ty); } // ConstantArray accessors. Constant* LLVMContext::getConstantArray(const ArrayType* T, - const std::vector& V) { + const std::vector& V) const { return ConstantArray::get(T, V); } Constant* LLVMContext::getConstantArray(const ArrayType* T, Constant* const* Vals, - unsigned NumVals) { + unsigned NumVals) const { return ConstantArray::get(T, Vals, NumVals); } Constant* LLVMContext::getConstantArray(const std::string& Initializer, - bool AddNull) { + bool AddNull) const { return ConstantArray::get(Initializer, AddNull); } // ConstantExpr accessors. Constant* LLVMContext::getConstantExpr(unsigned Opcode, Constant* C1, - Constant* C2) { + Constant* C2) const { return ConstantExpr::get(Opcode, C1, C2); } -Constant* LLVMContext::getConstantExprTrunc(Constant* C, const Type* Ty) { +Constant* LLVMContext::getConstantExprTrunc(Constant* C, const Type* Ty) const { return ConstantExpr::getTrunc(C, Ty); } -Constant* LLVMContext::getConstantExprSExt(Constant* C, const Type* Ty) { +Constant* LLVMContext::getConstantExprSExt(Constant* C, const Type* Ty) const { return ConstantExpr::getSExt(C, Ty); } -Constant* LLVMContext::getConstantExprZExt(Constant* C, const Type* Ty) { +Constant* LLVMContext::getConstantExprZExt(Constant* C, const Type* Ty) const { return ConstantExpr::getZExt(C, Ty); } -Constant* LLVMContext::getConstantExprFPTrunc(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprFPTrunc(Constant* C, const Type* Ty) const { return ConstantExpr::getFPTrunc(C, Ty); } -Constant* LLVMContext::getConstantExprFPExtend(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprFPExtend(Constant* C, const Type* Ty) const { return ConstantExpr::getFPExtend(C, Ty); } -Constant* LLVMContext::getConstantExprUIToFP(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprUIToFP(Constant* C, const Type* Ty) const { return ConstantExpr::getUIToFP(C, Ty); } -Constant* LLVMContext::getConstantExprSIToFP(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprSIToFP(Constant* C, const Type* Ty) const { return ConstantExpr::getSIToFP(C, Ty); } -Constant* LLVMContext::getConstantExprFPToUI(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprFPToUI(Constant* C, const Type* Ty) const { return ConstantExpr::getFPToUI(C, Ty); } -Constant* LLVMContext::getConstantExprFPToSI(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprFPToSI(Constant* C, const Type* Ty) const { return ConstantExpr::getFPToSI(C, Ty); } -Constant* LLVMContext::getConstantExprPtrToInt(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprPtrToInt(Constant* C, const Type* Ty) const { return ConstantExpr::getPtrToInt(C, Ty); } -Constant* LLVMContext::getConstantExprIntToPtr(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprIntToPtr(Constant* C, const Type* Ty) const { return ConstantExpr::getIntToPtr(C, Ty); } -Constant* LLVMContext::getConstantExprBitCast(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprBitCast(Constant* C, const Type* Ty) const { return ConstantExpr::getBitCast(C, Ty); } Constant* LLVMContext::getConstantExprCast(unsigned ops, Constant* C, - const Type* Ty) { + const Type* Ty) const { return ConstantExpr::getCast(ops, C, Ty); } Constant* LLVMContext::getConstantExprZExtOrBitCast(Constant* C, - const Type* Ty) { + const Type* Ty) const { return ConstantExpr::getZExtOrBitCast(C, Ty); } Constant* LLVMContext::getConstantExprSExtOrBitCast(Constant* C, - const Type* Ty) { + const Type* Ty) const { return ConstantExpr::getSExtOrBitCast(C, Ty); } Constant* LLVMContext::getConstantExprTruncOrBitCast(Constant* C, - const Type* Ty) { + const Type* Ty) const { return ConstantExpr::getTruncOrBitCast(C, Ty); } -Constant* LLVMContext::getConstantExprPointerCast(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprPointerCast(Constant* C, const Type* Ty) const { return ConstantExpr::getPointerCast(C, Ty); } Constant* LLVMContext::getConstantExprIntegerCast(Constant* C, const Type* Ty, - bool isSigned) { + bool isSigned) const { return ConstantExpr::getIntegerCast(C, Ty, isSigned); } -Constant* LLVMContext::getConstantExprFPCast(Constant* C, const Type* Ty) { +Constant* +LLVMContext::getConstantExprFPCast(Constant* C, const Type* Ty) const { return ConstantExpr::getFPCast(C, Ty); } Constant* LLVMContext::getConstantExprSelect(Constant* C, Constant* V1, - Constant* V2) { + Constant* V2) const { return ConstantExpr::getSelect(C, V1, V2); } -Constant* LLVMContext::getConstantExprAlignOf(const Type* Ty) { +Constant* LLVMContext::getConstantExprAlignOf(const Type* Ty) const { return ConstantExpr::getAlignOf(Ty); } Constant* LLVMContext::getConstantExprCompare(unsigned short pred, - Constant* C1, Constant* C2) { + Constant* C1, Constant* C2) const { return ConstantExpr::getCompare(pred, C1, C2); } -Constant* LLVMContext::getConstantExprNeg(Constant* C) { +Constant* LLVMContext::getConstantExprNeg(Constant* C) const { return ConstantExpr::getNeg(C); } -Constant* LLVMContext::getConstantExprFNeg(Constant* C) { +Constant* LLVMContext::getConstantExprFNeg(Constant* C) const { return ConstantExpr::getFNeg(C); } -Constant* LLVMContext::getConstantExprNot(Constant* C) { +Constant* LLVMContext::getConstantExprNot(Constant* C) const { return ConstantExpr::getNot(C); } -Constant* LLVMContext::getConstantExprAdd(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprAdd(Constant* C1, Constant* C2) const { return ConstantExpr::getAdd(C1, C2); } -Constant* LLVMContext::getConstantExprFAdd(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprFAdd(Constant* C1, Constant* C2) const { return ConstantExpr::getFAdd(C1, C2); } -Constant* LLVMContext::getConstantExprSub(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprSub(Constant* C1, Constant* C2) const { return ConstantExpr::getSub(C1, C2); } -Constant* LLVMContext::getConstantExprFSub(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprFSub(Constant* C1, Constant* C2) const { return ConstantExpr::getFSub(C1, C2); } -Constant* LLVMContext::getConstantExprMul(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprMul(Constant* C1, Constant* C2) const { return ConstantExpr::getMul(C1, C2); } -Constant* LLVMContext::getConstantExprFMul(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprFMul(Constant* C1, Constant* C2) const { return ConstantExpr::getFMul(C1, C2); } -Constant* LLVMContext::getConstantExprUDiv(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprUDiv(Constant* C1, Constant* C2) const { return ConstantExpr::getUDiv(C1, C2); } -Constant* LLVMContext::getConstantExprSDiv(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprSDiv(Constant* C1, Constant* C2) const { return ConstantExpr::getSDiv(C1, C2); } -Constant* LLVMContext::getConstantExprFDiv(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprFDiv(Constant* C1, Constant* C2) const { return ConstantExpr::getFDiv(C1, C2); } -Constant* LLVMContext::getConstantExprURem(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprURem(Constant* C1, Constant* C2) const { return ConstantExpr::getURem(C1, C2); } -Constant* LLVMContext::getConstantExprSRem(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprSRem(Constant* C1, Constant* C2) const { return ConstantExpr::getSRem(C1, C2); } -Constant* LLVMContext::getConstantExprFRem(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprFRem(Constant* C1, Constant* C2) const { return ConstantExpr::getFRem(C1, C2); } -Constant* LLVMContext::getConstantExprAnd(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprAnd(Constant* C1, Constant* C2) const { return ConstantExpr::getAnd(C1, C2); } -Constant* LLVMContext::getConstantExprOr(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprOr(Constant* C1, Constant* C2) const { return ConstantExpr::getOr(C1, C2); } -Constant* LLVMContext::getConstantExprXor(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprXor(Constant* C1, Constant* C2) const { return ConstantExpr::getXor(C1, C2); } Constant* LLVMContext::getConstantExprICmp(unsigned short pred, Constant* LHS, - Constant* RHS) { + Constant* RHS) const { return ConstantExpr::getICmp(pred, LHS, RHS); } Constant* LLVMContext::getConstantExprFCmp(unsigned short pred, Constant* LHS, - Constant* RHS) { + Constant* RHS) const { return ConstantExpr::getFCmp(pred, LHS, RHS); } Constant* LLVMContext::getConstantExprVICmp(unsigned short pred, Constant* LHS, - Constant* RHS) { + Constant* RHS) const { return ConstantExpr::getVICmp(pred, LHS, RHS); } Constant* LLVMContext::getConstantExprVFCmp(unsigned short pred, Constant* LHS, - Constant* RHS) { + Constant* RHS) const { return ConstantExpr::getVFCmp(pred, LHS, RHS); } -Constant* LLVMContext::getConstantExprShl(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprShl(Constant* C1, Constant* C2) const { return ConstantExpr::getShl(C1, C2); } -Constant* LLVMContext::getConstantExprLShr(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprLShr(Constant* C1, Constant* C2) const { return ConstantExpr::getLShr(C1, C2); } -Constant* LLVMContext::getConstantExprAShr(Constant* C1, Constant* C2) { +Constant* LLVMContext::getConstantExprAShr(Constant* C1, Constant* C2) const { return ConstantExpr::getAShr(C1, C2); } Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C, Constant* const* IdxList, - unsigned NumIdx) { + unsigned NumIdx) const { return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx); } Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C, Value* const* IdxList, - unsigned NumIdx) { + unsigned NumIdx) const { return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx); } Constant* LLVMContext::getConstantExprExtractElement(Constant* Vec, - Constant* Idx) { + Constant* Idx) const { return ConstantExpr::getExtractElement(Vec, Idx); } Constant* LLVMContext::getConstantExprInsertElement(Constant* Vec, Constant* Elt, - Constant* Idx) { + Constant* Idx) const { return ConstantExpr::getInsertElement(Vec, Elt, Idx); } Constant* LLVMContext::getConstantExprShuffleVector(Constant* V1, Constant* V2, - Constant* Mask) { + Constant* Mask) const { return ConstantExpr::getShuffleVector(V1, V2, Mask); } Constant* LLVMContext::getConstantExprExtractValue(Constant* Agg, const unsigned* IdxList, - unsigned NumIdx) { + unsigned NumIdx) const { return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx); } Constant* LLVMContext::getConstantExprInsertValue(Constant* Agg, Constant* Val, const unsigned* IdxList, - unsigned NumIdx) { + unsigned NumIdx) const { return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx); } -Constant* LLVMContext::getZeroValueForNegation(const Type* Ty) { +Constant* LLVMContext::getZeroValueForNegation(const Type* Ty) const { return ConstantExpr::getZeroValueForNegationExpr(Ty); } // ConstantFP accessors. -ConstantFP* LLVMContext::getConstantFP(const APFloat& V) { +ConstantFP* LLVMContext::getConstantFP(const APFloat& V) const { return ConstantFP::get(V); } -Constant* LLVMContext::getConstantFP(const Type* Ty, double V) { +Constant* LLVMContext::getConstantFP(const Type* Ty, double V) const { return ConstantFP::get(Ty, V); } -ConstantFP* LLVMContext::getConstantFPNegativeZero(const Type* Ty) { +ConstantFP* LLVMContext::getConstantFPNegativeZero(const Type* Ty) const { return ConstantFP::getNegativeZero(Ty); } // ConstantVector accessors. Constant* LLVMContext::getConstantVector(const VectorType* T, - const std::vector& V) { + const std::vector& V) const { return ConstantVector::get(T, V); } -Constant* LLVMContext::getConstantVector(const std::vector& V) { +Constant* +LLVMContext::getConstantVector(const std::vector& V) const { return ConstantVector::get(V); } Constant* LLVMContext::getConstantVector(Constant* const* Vals, - unsigned NumVals) { + unsigned NumVals) const { return ConstantVector::get(Vals, NumVals); } -ConstantVector* LLVMContext::getConstantVectorAllOnes(const VectorType* Ty) { +ConstantVector* +LLVMContext::getConstantVectorAllOnes(const VectorType* Ty) const { return ConstantVector::getAllOnesValue(Ty); } // FunctionType accessors FunctionType* LLVMContext::getFunctionType(const Type* Result, const std::vector& Params, - bool isVarArg) { + bool isVarArg) const { return FunctionType::get(Result, Params, isVarArg); } // IntegerType accessors -const IntegerType* LLVMContext::getIntegerType(unsigned NumBits) { +const IntegerType* LLVMContext::getIntegerType(unsigned NumBits) const { return IntegerType::get(NumBits); } // OpaqueType accessors -OpaqueType* LLVMContext::getOpaqueType() { +OpaqueType* LLVMContext::getOpaqueType() const { return OpaqueType::get(); } // StructType accessors StructType* LLVMContext::getStructType(const std::vector& Params, - bool isPacked) { + bool isPacked) const { return StructType::get(Params, isPacked); } // ArrayType accessors ArrayType* LLVMContext::getArrayType(const Type* ElementType, - uint64_t NumElements) { + uint64_t NumElements) const { return ArrayType::get(ElementType, NumElements); } // PointerType accessors PointerType* LLVMContext::getPointerType(const Type* ElementType, - unsigned AddressSpace) { + unsigned AddressSpace) const { return PointerType::get(ElementType, AddressSpace); } -PointerType* LLVMContext::getPointerTypeUnqualified(const Type* ElementType) { +PointerType* +LLVMContext::getPointerTypeUnqualified(const Type* ElementType) const { return PointerType::getUnqual(ElementType); } // VectorType accessors VectorType* LLVMContext::getVectorType(const Type* ElementType, - unsigned NumElements) { + unsigned NumElements) const { return VectorType::get(ElementType, NumElements); } -VectorType* LLVMContext::getVectorTypeInteger(const VectorType* VTy) { +VectorType* LLVMContext::getVectorTypeInteger(const VectorType* VTy) const { return VectorType::getInteger(VTy); } -VectorType* LLVMContext::getVectorTypeExtendedElement(const VectorType* VTy) { +VectorType* +LLVMContext::getVectorTypeExtendedElement(const VectorType* VTy) const { return VectorType::getExtendedElementVectorType(VTy); } -VectorType* LLVMContext::getVectorTypeTruncatedElement(const VectorType* VTy) { +VectorType* +LLVMContext::getVectorTypeTruncatedElement(const VectorType* VTy) const { return VectorType::getTruncatedElementVectorType(VTy); }