Finish pushing LLVMContext through the IRBuilder/ConstantFolder interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75213 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2009-07-10 00:49:53 +00:00
parent b5619f42f4
commit 45524c58fd
4 changed files with 98 additions and 82 deletions

View File

@ -38,7 +38,7 @@ namespace llvm {
public: public:
explicit SCEVExpander(ScalarEvolution &se) explicit SCEVExpander(ScalarEvolution &se)
: SE(se), Builder(*se.getContext(), : SE(se), Builder(*se.getContext(),
TargetFolder(se.TD, se.getContext())) {} TargetFolder(se.TD, *se.getContext())) {}
/// clear - Erase the contents of the InsertedExpressions map so that users /// clear - Erase the contents of the InsertedExpressions map so that users
/// trying to expand the same expression into multiple BasicBlocks or /// trying to expand the same expression into multiple BasicBlocks or

View File

@ -18,75 +18,79 @@
#define LLVM_SUPPORT_CONSTANTFOLDER_H #define LLVM_SUPPORT_CONSTANTFOLDER_H
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/LLVMContext.h"
namespace llvm { namespace llvm {
/// ConstantFolder - Create constants with minimum, target independent, folding. /// ConstantFolder - Create constants with minimum, target independent, folding.
class ConstantFolder { class ConstantFolder {
LLVMContext &Context;
public: public:
ConstantFolder(LLVMContext &C) : Context(C) { }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Binary Operators // Binary Operators
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
Constant *CreateAdd(Constant *LHS, Constant *RHS) const { Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getAdd(LHS, RHS); return Context.getConstantExprAdd(LHS, RHS);
} }
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const { Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFAdd(LHS, RHS); return Context.getConstantExprFAdd(LHS, RHS);
} }
Constant *CreateSub(Constant *LHS, Constant *RHS) const { Constant *CreateSub(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getSub(LHS, RHS); return Context.getConstantExprSub(LHS, RHS);
} }
Constant *CreateFSub(Constant *LHS, Constant *RHS) const { Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFSub(LHS, RHS); return Context.getConstantExprFSub(LHS, RHS);
} }
Constant *CreateMul(Constant *LHS, Constant *RHS) const { Constant *CreateMul(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getMul(LHS, RHS); return Context.getConstantExprMul(LHS, RHS);
} }
Constant *CreateFMul(Constant *LHS, Constant *RHS) const { Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFMul(LHS, RHS); return Context.getConstantExprFMul(LHS, RHS);
} }
Constant *CreateUDiv(Constant *LHS, Constant *RHS) const { Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getUDiv(LHS, RHS); return Context.getConstantExprUDiv(LHS, RHS);
} }
Constant *CreateSDiv(Constant *LHS, Constant *RHS) const { Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getSDiv(LHS, RHS); return Context.getConstantExprSDiv(LHS, RHS);
} }
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const { Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFDiv(LHS, RHS); return Context.getConstantExprFDiv(LHS, RHS);
} }
Constant *CreateURem(Constant *LHS, Constant *RHS) const { Constant *CreateURem(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getURem(LHS, RHS); return Context.getConstantExprURem(LHS, RHS);
} }
Constant *CreateSRem(Constant *LHS, Constant *RHS) const { Constant *CreateSRem(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getSRem(LHS, RHS); return Context.getConstantExprSRem(LHS, RHS);
} }
Constant *CreateFRem(Constant *LHS, Constant *RHS) const { Constant *CreateFRem(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFRem(LHS, RHS); return Context.getConstantExprFRem(LHS, RHS);
} }
Constant *CreateShl(Constant *LHS, Constant *RHS) const { Constant *CreateShl(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getShl(LHS, RHS); return Context.getConstantExprShl(LHS, RHS);
} }
Constant *CreateLShr(Constant *LHS, Constant *RHS) const { Constant *CreateLShr(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getLShr(LHS, RHS); return Context.getConstantExprLShr(LHS, RHS);
} }
Constant *CreateAShr(Constant *LHS, Constant *RHS) const { Constant *CreateAShr(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getAShr(LHS, RHS); return Context.getConstantExprAShr(LHS, RHS);
} }
Constant *CreateAnd(Constant *LHS, Constant *RHS) const { Constant *CreateAnd(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getAnd(LHS, RHS); return Context.getConstantExprAnd(LHS, RHS);
} }
Constant *CreateOr(Constant *LHS, Constant *RHS) const { Constant *CreateOr(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getOr(LHS, RHS); return Context.getConstantExprOr(LHS, RHS);
} }
Constant *CreateXor(Constant *LHS, Constant *RHS) const { Constant *CreateXor(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getXor(LHS, RHS); return Context.getConstantExprXor(LHS, RHS);
} }
Constant *CreateBinOp(Instruction::BinaryOps Opc, Constant *CreateBinOp(Instruction::BinaryOps Opc,
Constant *LHS, Constant *RHS) const { Constant *LHS, Constant *RHS) const {
return ConstantExpr::get(Opc, LHS, RHS); return Context.getConstantExpr(Opc, LHS, RHS);
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -94,13 +98,13 @@ public:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
Constant *CreateNeg(Constant *C) const { Constant *CreateNeg(Constant *C) const {
return ConstantExpr::getNeg(C); return Context.getConstantExprNeg(C);
} }
Constant *CreateFNeg(Constant *C) const { Constant *CreateFNeg(Constant *C) const {
return ConstantExpr::getFNeg(C); return Context.getConstantExprFNeg(C);
} }
Constant *CreateNot(Constant *C) const { Constant *CreateNot(Constant *C) const {
return ConstantExpr::getNot(C); return Context.getConstantExprNot(C);
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -109,11 +113,11 @@ public:
Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList, Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList,
unsigned NumIdx) const { unsigned NumIdx) const {
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx); return Context.getConstantExprGetElementPtr(C, IdxList, NumIdx);
} }
Constant *CreateGetElementPtr(Constant *C, Value* const *IdxList, Constant *CreateGetElementPtr(Constant *C, Value* const *IdxList,
unsigned NumIdx) const { unsigned NumIdx) const {
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx); return Context.getConstantExprGetElementPtr(C, IdxList, NumIdx);
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -122,11 +126,11 @@ public:
Constant *CreateCast(Instruction::CastOps Op, Constant *C, Constant *CreateCast(Instruction::CastOps Op, Constant *C,
const Type *DestTy) const { const Type *DestTy) const {
return ConstantExpr::getCast(Op, C, DestTy); return Context.getConstantExprCast(Op, C, DestTy);
} }
Constant *CreateIntCast(Constant *C, const Type *DestTy, Constant *CreateIntCast(Constant *C, const Type *DestTy,
bool isSigned) const { bool isSigned) const {
return ConstantExpr::getIntegerCast(C, DestTy, isSigned); return Context.getConstantExprIntegerCast(C, DestTy, isSigned);
} }
Constant *CreateBitCast(Constant *C, const Type *DestTy) const { Constant *CreateBitCast(Constant *C, const Type *DestTy) const {
@ -139,7 +143,7 @@ public:
return CreateCast(Instruction::PtrToInt, C, DestTy); return CreateCast(Instruction::PtrToInt, C, DestTy);
} }
Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const { Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const {
return ConstantExpr::getTruncOrBitCast(C, DestTy); return Context.getConstantExprTruncOrBitCast(C, DestTy);
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -148,11 +152,11 @@ public:
Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS, Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS,
Constant *RHS) const { Constant *RHS) const {
return ConstantExpr::getCompare(P, LHS, RHS); return Context.getConstantExprCompare(P, LHS, RHS);
} }
Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
Constant *RHS) const { Constant *RHS) const {
return ConstantExpr::getCompare(P, LHS, RHS); return Context.getConstantExprCompare(P, LHS, RHS);
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -160,31 +164,31 @@ public:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const { Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const {
return ConstantExpr::getSelect(C, True, False); return Context.getConstantExprSelect(C, True, False);
} }
Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const { Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const {
return ConstantExpr::getExtractElement(Vec, Idx); return Context.getConstantExprExtractElement(Vec, Idx);
} }
Constant *CreateInsertElement(Constant *Vec, Constant *NewElt, Constant *CreateInsertElement(Constant *Vec, Constant *NewElt,
Constant *Idx) const { Constant *Idx) const {
return ConstantExpr::getInsertElement(Vec, NewElt, Idx); return Context.getConstantExprInsertElement(Vec, NewElt, Idx);
} }
Constant *CreateShuffleVector(Constant *V1, Constant *V2, Constant *CreateShuffleVector(Constant *V1, Constant *V2,
Constant *Mask) const { Constant *Mask) const {
return ConstantExpr::getShuffleVector(V1, V2, Mask); return Context.getConstantExprShuffleVector(V1, V2, Mask);
} }
Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList, Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
unsigned NumIdx) const { unsigned NumIdx) const {
return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx); return Context.getConstantExprExtractValue(Agg, IdxList, NumIdx);
} }
Constant *CreateInsertValue(Constant *Agg, Constant *Val, Constant *CreateInsertValue(Constant *Agg, Constant *Val,
const unsigned *IdxList, unsigned NumIdx) const { const unsigned *IdxList, unsigned NumIdx) const {
return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx); return Context.getConstantExprInsertValue(Agg, Val, IdxList, NumIdx);
} }
}; };

View File

@ -42,19 +42,31 @@ namespace llvm {
template <bool preserveNames=true, typename T = ConstantFolder> class IRBuilder{ template <bool preserveNames=true, typename T = ConstantFolder> class IRBuilder{
BasicBlock *BB; BasicBlock *BB;
BasicBlock::iterator InsertPt; BasicBlock::iterator InsertPt;
T Folder;
LLVMContext &Context; LLVMContext &Context;
T Folder;
public: public:
IRBuilder(LLVMContext &C, const T& F = T()) : IRBuilder(LLVMContext &C, const T& F) :
Folder(F), Context(C) { ClearInsertionPoint(); } Context(C), Folder(F) { ClearInsertionPoint(); }
explicit IRBuilder(BasicBlock *TheBB, const T& F = T()) IRBuilder(LLVMContext &C) : Context(C), Folder(C) { ClearInsertionPoint(); }
: Folder(F), Context(*TheBB->getParent()->getContext()) {
explicit IRBuilder(BasicBlock *TheBB, const T& F)
: Context(*TheBB->getParent()->getContext()), Folder(F) {
SetInsertPoint(TheBB); SetInsertPoint(TheBB);
} }
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F = T()) explicit IRBuilder(BasicBlock *TheBB)
: Folder(F), Context(*TheBB->getParent()->getContext()) { : Context(*TheBB->getParent()->getContext()), Folder(Context) {
SetInsertPoint(TheBB);
}
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F)
: Context(*TheBB->getParent()->getContext()), Folder(F) {
SetInsertPoint(TheBB, IP);
}
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP)
: Context(*TheBB->getParent()->getContext()), Folder(Context) {
SetInsertPoint(TheBB, IP); SetInsertPoint(TheBB, IP);
} }

View File

@ -30,18 +30,18 @@ class LLVMContext;
/// TargetFolder - Create constants with target dependent folding. /// TargetFolder - Create constants with target dependent folding.
class TargetFolder { class TargetFolder {
const TargetData *TD; const TargetData *TD;
LLVMContext *Context; LLVMContext &Context;
/// Fold - Fold the constant using target specific information. /// Fold - Fold the constant using target specific information.
Constant *Fold(Constant *C) const { Constant *Fold(Constant *C) const {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
if (Constant *CF = ConstantFoldConstantExpression(CE, Context, TD)) if (Constant *CF = ConstantFoldConstantExpression(CE, &Context, TD))
return CF; return CF;
return C; return C;
} }
public: public:
explicit TargetFolder(const TargetData *TheTD, LLVMContext *C) : explicit TargetFolder(const TargetData *TheTD, LLVMContext &C) :
TD(TheTD), Context(C) {} TD(TheTD), Context(C) {}
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -49,63 +49,63 @@ public:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
Constant *CreateAdd(Constant *LHS, Constant *RHS) const { Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getAdd(LHS, RHS)); return Fold(Context.getConstantExprAdd(LHS, RHS));
} }
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const { Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getFAdd(LHS, RHS)); return Fold(Context.getConstantExprFAdd(LHS, RHS));
} }
Constant *CreateSub(Constant *LHS, Constant *RHS) const { Constant *CreateSub(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getSub(LHS, RHS)); return Fold(Context.getConstantExprSub(LHS, RHS));
} }
Constant *CreateFSub(Constant *LHS, Constant *RHS) const { Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getFSub(LHS, RHS)); return Fold(Context.getConstantExprFSub(LHS, RHS));
} }
Constant *CreateMul(Constant *LHS, Constant *RHS) const { Constant *CreateMul(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getMul(LHS, RHS)); return Fold(Context.getConstantExprMul(LHS, RHS));
} }
Constant *CreateFMul(Constant *LHS, Constant *RHS) const { Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getFMul(LHS, RHS)); return Fold(Context.getConstantExprFMul(LHS, RHS));
} }
Constant *CreateUDiv(Constant *LHS, Constant *RHS) const { Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getUDiv(LHS, RHS)); return Fold(Context.getConstantExprUDiv(LHS, RHS));
} }
Constant *CreateSDiv(Constant *LHS, Constant *RHS) const { Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getSDiv(LHS, RHS)); return Fold(Context.getConstantExprSDiv(LHS, RHS));
} }
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const { Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getFDiv(LHS, RHS)); return Fold(Context.getConstantExprFDiv(LHS, RHS));
} }
Constant *CreateURem(Constant *LHS, Constant *RHS) const { Constant *CreateURem(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getURem(LHS, RHS)); return Fold(Context.getConstantExprURem(LHS, RHS));
} }
Constant *CreateSRem(Constant *LHS, Constant *RHS) const { Constant *CreateSRem(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getSRem(LHS, RHS)); return Fold(Context.getConstantExprSRem(LHS, RHS));
} }
Constant *CreateFRem(Constant *LHS, Constant *RHS) const { Constant *CreateFRem(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getFRem(LHS, RHS)); return Fold(Context.getConstantExprFRem(LHS, RHS));
} }
Constant *CreateShl(Constant *LHS, Constant *RHS) const { Constant *CreateShl(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getShl(LHS, RHS)); return Fold(Context.getConstantExprShl(LHS, RHS));
} }
Constant *CreateLShr(Constant *LHS, Constant *RHS) const { Constant *CreateLShr(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getLShr(LHS, RHS)); return Fold(Context.getConstantExprLShr(LHS, RHS));
} }
Constant *CreateAShr(Constant *LHS, Constant *RHS) const { Constant *CreateAShr(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getAShr(LHS, RHS)); return Fold(Context.getConstantExprAShr(LHS, RHS));
} }
Constant *CreateAnd(Constant *LHS, Constant *RHS) const { Constant *CreateAnd(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getAnd(LHS, RHS)); return Fold(Context.getConstantExprAnd(LHS, RHS));
} }
Constant *CreateOr(Constant *LHS, Constant *RHS) const { Constant *CreateOr(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getOr(LHS, RHS)); return Fold(Context.getConstantExprOr(LHS, RHS));
} }
Constant *CreateXor(Constant *LHS, Constant *RHS) const { Constant *CreateXor(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getXor(LHS, RHS)); return Fold(Context.getConstantExprXor(LHS, RHS));
} }
Constant *CreateBinOp(Instruction::BinaryOps Opc, Constant *CreateBinOp(Instruction::BinaryOps Opc,
Constant *LHS, Constant *RHS) const { Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::get(Opc, LHS, RHS)); return Fold(Context.getConstantExpr(Opc, LHS, RHS));
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -113,13 +113,13 @@ public:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
Constant *CreateNeg(Constant *C) const { Constant *CreateNeg(Constant *C) const {
return Fold(ConstantExpr::getNeg(C)); return Fold(Context.getConstantExprNeg(C));
} }
Constant *CreateFNeg(Constant *C) const { Constant *CreateFNeg(Constant *C) const {
return Fold(ConstantExpr::getFNeg(C)); return Fold(Context.getConstantExprFNeg(C));
} }
Constant *CreateNot(Constant *C) const { Constant *CreateNot(Constant *C) const {
return Fold(ConstantExpr::getNot(C)); return Fold(Context.getConstantExprNot(C));
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -128,11 +128,11 @@ public:
Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList, Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList,
unsigned NumIdx) const { unsigned NumIdx) const {
return Fold(ConstantExpr::getGetElementPtr(C, IdxList, NumIdx)); return Fold(Context.getConstantExprGetElementPtr(C, IdxList, NumIdx));
} }
Constant *CreateGetElementPtr(Constant *C, Value* const *IdxList, Constant *CreateGetElementPtr(Constant *C, Value* const *IdxList,
unsigned NumIdx) const { unsigned NumIdx) const {
return Fold(ConstantExpr::getGetElementPtr(C, IdxList, NumIdx)); return Fold(Context.getConstantExprGetElementPtr(C, IdxList, NumIdx));
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -143,13 +143,13 @@ public:
const Type *DestTy) const { const Type *DestTy) const {
if (C->getType() == DestTy) if (C->getType() == DestTy)
return C; // avoid calling Fold return C; // avoid calling Fold
return Fold(ConstantExpr::getCast(Op, C, DestTy)); return Fold(Context.getConstantExprCast(Op, C, DestTy));
} }
Constant *CreateIntCast(Constant *C, const Type *DestTy, Constant *CreateIntCast(Constant *C, const Type *DestTy,
bool isSigned) const { bool isSigned) const {
if (C->getType() == DestTy) if (C->getType() == DestTy)
return C; // avoid calling Fold return C; // avoid calling Fold
return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned)); return Fold(Context.getConstantExprIntegerCast(C, DestTy, isSigned));
} }
Constant *CreateBitCast(Constant *C, const Type *DestTy) const { Constant *CreateBitCast(Constant *C, const Type *DestTy) const {
@ -164,7 +164,7 @@ public:
Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const { Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const {
if (C->getType() == DestTy) if (C->getType() == DestTy)
return C; // avoid calling Fold return C; // avoid calling Fold
return Fold(ConstantExpr::getTruncOrBitCast(C, DestTy)); return Fold(Context.getConstantExprTruncOrBitCast(C, DestTy));
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -173,11 +173,11 @@ public:
Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS, Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS,
Constant *RHS) const { Constant *RHS) const {
return Fold(ConstantExpr::getCompare(P, LHS, RHS)); return Fold(Context.getConstantExprCompare(P, LHS, RHS));
} }
Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
Constant *RHS) const { Constant *RHS) const {
return Fold(ConstantExpr::getCompare(P, LHS, RHS)); return Fold(Context.getConstantExprCompare(P, LHS, RHS));
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -185,31 +185,31 @@ public:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const { Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const {
return Fold(ConstantExpr::getSelect(C, True, False)); return Fold(Context.getConstantExprSelect(C, True, False));
} }
Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const { Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const {
return Fold(ConstantExpr::getExtractElement(Vec, Idx)); return Fold(Context.getConstantExprExtractElement(Vec, Idx));
} }
Constant *CreateInsertElement(Constant *Vec, Constant *NewElt, Constant *CreateInsertElement(Constant *Vec, Constant *NewElt,
Constant *Idx) const { Constant *Idx) const {
return Fold(ConstantExpr::getInsertElement(Vec, NewElt, Idx)); return Fold(Context.getConstantExprInsertElement(Vec, NewElt, Idx));
} }
Constant *CreateShuffleVector(Constant *V1, Constant *V2, Constant *CreateShuffleVector(Constant *V1, Constant *V2,
Constant *Mask) const { Constant *Mask) const {
return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask)); return Fold(Context.getConstantExprShuffleVector(V1, V2, Mask));
} }
Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList, Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
unsigned NumIdx) const { unsigned NumIdx) const {
return Fold(ConstantExpr::getExtractValue(Agg, IdxList, NumIdx)); return Fold(Context.getConstantExprExtractValue(Agg, IdxList, NumIdx));
} }
Constant *CreateInsertValue(Constant *Agg, Constant *Val, Constant *CreateInsertValue(Constant *Agg, Constant *Val,
const unsigned *IdxList, unsigned NumIdx) const { const unsigned *IdxList, unsigned NumIdx) const {
return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx)); return Fold(Context.getConstantExprInsertValue(Agg, Val, IdxList, NumIdx));
} }
}; };