aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2010-02-02 12:53:04 +0000
committerDuncan Sands <baldrick@free.fr>2010-02-02 12:53:04 +0000
commit8991d51ddcea31e198aff1fd01c05af2679ee8f8 (patch)
tree09ee28307520a9d70966506f399eb0a0fa256335 /lib/VMCore
parent769e2ad872538a203072ecdbb1ad9249a711a0d4 (diff)
downloadexternal_llvm-8991d51ddcea31e198aff1fd01c05af2679ee8f8.zip
external_llvm-8991d51ddcea31e198aff1fd01c05af2679ee8f8.tar.gz
external_llvm-8991d51ddcea31e198aff1fd01c05af2679ee8f8.tar.bz2
Adding missing methods for creating Add, Mul, Neg and Sub with NUW.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95086 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Constants.cpp20
-rw-r--r--lib/VMCore/Instructions.cpp12
2 files changed, 30 insertions, 2 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 762fbe4..2250626 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -645,18 +645,29 @@ Constant* ConstantExpr::getNSWNeg(Constant* C) {
return getNSWSub(ConstantFP::getZeroValueForNegation(C->getType()), C);
}
+Constant* ConstantExpr::getNUWNeg(Constant* C) {
+ assert(C->getType()->isIntOrIntVector() &&
+ "Cannot NEG a nonintegral value!");
+ return getNUWSub(ConstantFP::getZeroValueForNegation(C->getType()), C);
+}
+
Constant* ConstantExpr::getNSWAdd(Constant* C1, Constant* C2) {
return getTy(C1->getType(), Instruction::Add, C1, C2,
OverflowingBinaryOperator::NoSignedWrap);
}
+Constant* ConstantExpr::getNUWAdd(Constant* C1, Constant* C2) {
+ return getTy(C1->getType(), Instruction::Add, C1, C2,
+ OverflowingBinaryOperator::NoUnsignedWrap);
+}
+
Constant* ConstantExpr::getNSWSub(Constant* C1, Constant* C2) {
return getTy(C1->getType(), Instruction::Sub, C1, C2,
OverflowingBinaryOperator::NoSignedWrap);
}
-Constant* ConstantExpr::getNUWMul(Constant* C1, Constant* C2) {
- return getTy(C1->getType(), Instruction::Mul, C1, C2,
+Constant* ConstantExpr::getNUWSub(Constant* C1, Constant* C2) {
+ return getTy(C1->getType(), Instruction::Sub, C1, C2,
OverflowingBinaryOperator::NoUnsignedWrap);
}
@@ -665,6 +676,11 @@ Constant* ConstantExpr::getNSWMul(Constant* C1, Constant* C2) {
OverflowingBinaryOperator::NoSignedWrap);
}
+Constant* ConstantExpr::getNUWMul(Constant* C1, Constant* C2) {
+ return getTy(C1->getType(), Instruction::Mul, C1, C2,
+ OverflowingBinaryOperator::NoUnsignedWrap);
+}
+
Constant* ConstantExpr::getExactSDiv(Constant* C1, Constant* C2) {
return getTy(C1->getType(), Instruction::SDiv, C1, C2,
SDivOperator::IsExact);
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index a9b2cab..4ec8295 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -1786,6 +1786,18 @@ BinaryOperator *BinaryOperator::CreateNSWNeg(Value *Op, const Twine &Name,
return BinaryOperator::CreateNSWSub(zero, Op, Name, InsertAtEnd);
}
+BinaryOperator *BinaryOperator::CreateNUWNeg(Value *Op, const Twine &Name,
+ Instruction *InsertBefore) {
+ Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
+ return BinaryOperator::CreateNUWSub(zero, Op, Name, InsertBefore);
+}
+
+BinaryOperator *BinaryOperator::CreateNUWNeg(Value *Op, const Twine &Name,
+ BasicBlock *InsertAtEnd) {
+ Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
+ return BinaryOperator::CreateNUWSub(zero, Op, Name, InsertAtEnd);
+}
+
BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const Twine &Name,
Instruction *InsertBefore) {
Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());