summaryrefslogtreecommitdiffstats
path: root/include/llvm/Support/ConstantFolder.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Support/ConstantFolder.h')
-rw-r--r--include/llvm/Support/ConstantFolder.h42
1 files changed, 34 insertions, 8 deletions
diff --git a/include/llvm/Support/ConstantFolder.h b/include/llvm/Support/ConstantFolder.h
index 35065a0..99cb920 100644
--- a/include/llvm/Support/ConstantFolder.h
+++ b/include/llvm/Support/ConstantFolder.h
@@ -21,9 +21,12 @@
namespace llvm {
+class LLVMContext;
+
/// ConstantFolder - Create constants with minimum, target independent, folding.
class ConstantFolder {
public:
+ explicit ConstantFolder(LLVMContext &) {}
//===--------------------------------------------------------------------===//
// Binary Operators
@@ -32,12 +35,18 @@ public:
Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getAdd(LHS, RHS);
}
+ Constant *CreateNSWAdd(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getNSWAdd(LHS, RHS);
+ }
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFAdd(LHS, RHS);
}
Constant *CreateSub(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getSub(LHS, RHS);
}
+ Constant *CreateNSWSub(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getNSWSub(LHS, RHS);
+ }
Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFSub(LHS, RHS);
}
@@ -53,6 +62,9 @@ public:
Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getSDiv(LHS, RHS);
}
+ Constant *CreateExactSDiv(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getExactSDiv(LHS, RHS);
+ }
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getFDiv(LHS, RHS);
}
@@ -116,6 +128,15 @@ public:
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
}
+ Constant *CreateInBoundsGetElementPtr(Constant *C, Constant* const *IdxList,
+ unsigned NumIdx) const {
+ return ConstantExpr::getInBoundsGetElementPtr(C, IdxList, NumIdx);
+ }
+ Constant *CreateInBoundsGetElementPtr(Constant *C, Value* const *IdxList,
+ unsigned NumIdx) const {
+ return ConstantExpr::getInBoundsGetElementPtr(C, IdxList, NumIdx);
+ }
+
//===--------------------------------------------------------------------===//
// Cast/Conversion Operators
//===--------------------------------------------------------------------===//
@@ -124,10 +145,16 @@ public:
const Type *DestTy) const {
return ConstantExpr::getCast(Op, C, DestTy);
}
+ Constant *CreatePointerCast(Constant *C, const Type *DestTy) const {
+ return ConstantExpr::getPointerCast(C, DestTy);
+ }
Constant *CreateIntCast(Constant *C, const Type *DestTy,
bool isSigned) const {
return ConstantExpr::getIntegerCast(C, DestTy, isSigned);
}
+ Constant *CreateFPCast(Constant *C, const Type *DestTy) const {
+ return ConstantExpr::getFPCast(C, DestTy);
+ }
Constant *CreateBitCast(Constant *C, const Type *DestTy) const {
return CreateCast(Instruction::BitCast, C, DestTy);
@@ -138,6 +165,13 @@ public:
Constant *CreatePtrToInt(Constant *C, const Type *DestTy) const {
return CreateCast(Instruction::PtrToInt, C, DestTy);
}
+ Constant *CreateZExtOrBitCast(Constant *C, const Type *DestTy) const {
+ return ConstantExpr::getZExtOrBitCast(C, DestTy);
+ }
+ Constant *CreateSExtOrBitCast(Constant *C, const Type *DestTy) const {
+ return ConstantExpr::getSExtOrBitCast(C, DestTy);
+ }
+
Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const {
return ConstantExpr::getTruncOrBitCast(C, DestTy);
}
@@ -154,14 +188,6 @@ public:
Constant *RHS) const {
return ConstantExpr::getCompare(P, LHS, RHS);
}
- Constant *CreateVICmp(CmpInst::Predicate P, Constant *LHS,
- Constant *RHS) const {
- return ConstantExpr::getCompare(P, LHS, RHS);
- }
- Constant *CreateVFCmp(CmpInst::Predicate P, Constant *LHS,
- Constant *RHS) const {
- return ConstantExpr::getCompare(P, LHS, RHS);
- }
//===--------------------------------------------------------------------===//
// Other Instructions
OpenPOWER on IntegriCloud