aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2009-09-26 15:35:35 +0000
committerDuncan Sands <baldrick@free.fr>2009-09-26 15:35:35 +0000
commit3548ea8e905269e819fdd4c7fab42142b745c6c5 (patch)
tree10e110cbda235efd41cf7f7a5a0d219f1e613ff0
parent11eab02b770086c119a18aae0fe214fbe5eed0d0 (diff)
downloadexternal_llvm-3548ea8e905269e819fdd4c7fab42142b745c6c5.zip
external_llvm-3548ea8e905269e819fdd4c7fab42142b745c6c5.tar.gz
external_llvm-3548ea8e905269e819fdd4c7fab42142b745c6c5.tar.bz2
For the NSWSub support in the builder to actually be useable,
there need to be corresponding changes to the constant folders, done in this patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82862 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Constants.h1
-rw-r--r--include/llvm/Support/ConstantFolder.h3
-rw-r--r--include/llvm/Support/NoFolder.h3
-rw-r--r--include/llvm/Support/TargetFolder.h3
-rw-r--r--lib/VMCore/Constants.cpp5
5 files changed, 15 insertions, 0 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 4999998..260a89a 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -654,6 +654,7 @@ public:
static Constant *getBitCast (Constant *C, const Type *Ty);
static Constant* getNSWAdd(Constant* C1, Constant* C2);
+ static Constant* getNSWSub(Constant* C1, Constant* C2);
static Constant* getExactSDiv(Constant* C1, Constant* C2);
/// Transparently provide more efficient getOperand methods.
diff --git a/include/llvm/Support/ConstantFolder.h b/include/llvm/Support/ConstantFolder.h
index 3c9278a..99cb920 100644
--- a/include/llvm/Support/ConstantFolder.h
+++ b/include/llvm/Support/ConstantFolder.h
@@ -44,6 +44,9 @@ public:
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);
}
diff --git a/include/llvm/Support/NoFolder.h b/include/llvm/Support/NoFolder.h
index 4540f02..1f671c1 100644
--- a/include/llvm/Support/NoFolder.h
+++ b/include/llvm/Support/NoFolder.h
@@ -51,6 +51,9 @@ public:
Value *CreateSub(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateSub(LHS, RHS);
}
+ Value *CreateNSWSub(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateNSWSub(LHS, RHS);
+ }
Value *CreateFSub(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateFSub(LHS, RHS);
}
diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h
index 77533c0..8e28632 100644
--- a/include/llvm/Support/TargetFolder.h
+++ b/include/llvm/Support/TargetFolder.h
@@ -60,6 +60,9 @@ public:
Constant *CreateSub(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getSub(LHS, RHS));
}
+ Constant *CreateNSWSub(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getNSWSub(LHS, RHS));
+ }
Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getFSub(LHS, RHS));
}
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index ecaf9ab..eb7e7c0 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -643,6 +643,11 @@ Constant* ConstantExpr::getNSWAdd(Constant* C1, Constant* C2) {
OverflowingBinaryOperator::NoSignedWrap);
}
+Constant* ConstantExpr::getNSWSub(Constant* C1, Constant* C2) {
+ return getTy(C1->getType(), Instruction::Sub, C1, C2,
+ OverflowingBinaryOperator::NoSignedWrap);
+}
+
Constant* ConstantExpr::getExactSDiv(Constant* C1, Constant* C2) {
return getTy(C1->getType(), Instruction::SDiv, C1, C2,
SDivOperator::IsExact);