summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-02-09 16:43:07 +0000
committerChris Lattner <sabre@nondot.org>2011-02-09 16:43:07 +0000
commit0d75eac3504faa26bae730577e63c002928b5900 (patch)
tree18d3b5350597e9bcd1af3f8e61b70e63b2f13e86
parente787786999af4f7d478b6cc5bf084bc0adf08c13 (diff)
downloadbcm5719-llvm-0d75eac3504faa26bae730577e63c002928b5900.tar.gz
bcm5719-llvm-0d75eac3504faa26bae730577e63c002928b5900.zip
refactor ConstantExpr interfaces a bit around "exactness".
llvm-svn: 125190
-rw-r--r--llvm/include/llvm/Constants.h24
-rw-r--r--llvm/lib/VMCore/Constants.cpp41
2 files changed, 28 insertions, 37 deletions
diff --git a/llvm/include/llvm/Constants.h b/llvm/include/llvm/Constants.h
index 56f39b9b092..5648d992b95 100644
--- a/llvm/include/llvm/Constants.h
+++ b/llvm/include/llvm/Constants.h
@@ -691,8 +691,8 @@ public:
static Constant *getFSub(Constant *C1, Constant *C2);
static Constant *getMul(Constant *C1, Constant *C2);
static Constant *getFMul(Constant *C1, Constant *C2);
- static Constant *getUDiv(Constant *C1, Constant *C2);
- static Constant *getSDiv(Constant *C1, Constant *C2);
+ static Constant *getUDiv(Constant *C1, Constant *C2, bool isExact = false);
+ static Constant *getSDiv(Constant *C1, Constant *C2, bool isExact = false);
static Constant *getFDiv(Constant *C1, Constant *C2);
static Constant *getURem(Constant *C1, Constant *C2);
static Constant *getSRem(Constant *C1, Constant *C2);
@@ -701,8 +701,8 @@ public:
static Constant *getOr(Constant *C1, Constant *C2);
static Constant *getXor(Constant *C1, Constant *C2);
static Constant *getShl(Constant *C1, Constant *C2);
- static Constant *getLShr(Constant *C1, Constant *C2);
- static Constant *getAShr(Constant *C1, Constant *C2);
+ static Constant *getLShr(Constant *C1, Constant *C2, bool isExact = false);
+ static Constant *getAShr(Constant *C1, Constant *C2, bool isExact = false);
static Constant *getTrunc (Constant *C, const Type *Ty);
static Constant *getSExt (Constant *C, const Type *Ty);
static Constant *getZExt (Constant *C, const Type *Ty);
@@ -726,10 +726,18 @@ public:
static Constant *getNUWMul(Constant *C1, Constant *C2);
static Constant *getNSWShl(Constant *C1, Constant *C2);
static Constant *getNUWShl(Constant *C1, Constant *C2);
- static Constant *getExactSDiv(Constant *C1, Constant *C2);
- static Constant *getExactUDiv(Constant *C1, Constant *C2);
- static Constant *getExactAShr(Constant *C1, Constant *C2);
- static Constant *getExactLShr(Constant *C1, Constant *C2);
+ static Constant *getExactSDiv(Constant *C1, Constant *C2) {
+ return getSDiv(C1, C2, true);
+ }
+ static Constant *getExactUDiv(Constant *C1, Constant *C2) {
+ return getUDiv(C1, C2, true);
+ }
+ static Constant *getExactAShr(Constant *C1, Constant *C2) {
+ return getAShr(C1, C2, true);
+ }
+ static Constant *getExactLShr(Constant *C1, Constant *C2) {
+ return getLShr(C1, C2, true);
+ }
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index a74d6970d58..4ce2af10ecf 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -691,27 +691,6 @@ Constant *ConstantExpr::getNUWShl(Constant *C1, Constant *C2) {
OverflowingBinaryOperator::NoUnsignedWrap);
}
-Constant *ConstantExpr::getExactSDiv(Constant *C1, Constant *C2) {
- return getTy(C1->getType(), Instruction::SDiv, C1, C2,
- PossiblyExactOperator::IsExact);
-}
-
-Constant *ConstantExpr::getExactUDiv(Constant *C1, Constant *C2) {
- return getTy(C1->getType(), Instruction::UDiv, C1, C2,
- PossiblyExactOperator::IsExact);
-}
-
-Constant *ConstantExpr::getExactAShr(Constant *C1, Constant *C2) {
- return getTy(C1->getType(), Instruction::AShr, C1, C2,
- PossiblyExactOperator::IsExact);
-}
-
-Constant *ConstantExpr::getExactLShr(Constant *C1, Constant *C2) {
- return getTy(C1->getType(), Instruction::LShr, C1, C2,
- PossiblyExactOperator::IsExact);
-}
-
-
// Utility function for determining if a ConstantExpr is a CastOp or not. This
// can't be inline because we don't want to #include Instruction.h into
// Constant.h
@@ -1890,12 +1869,14 @@ Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2) {
return get(Instruction::FMul, C1, C2);
}
-Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2) {
- return get(Instruction::UDiv, C1, C2);
+Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2, bool isExact) {
+ return get(Instruction::UDiv, C1, C2,
+ isExact ? PossiblyExactOperator::IsExact : 0);
}
-Constant *ConstantExpr::getSDiv(Constant *C1, Constant *C2) {
- return get(Instruction::SDiv, C1, C2);
+Constant *ConstantExpr::getSDiv(Constant *C1, Constant *C2, bool isExact) {
+ return get(Instruction::SDiv, C1, C2,
+ isExact ? PossiblyExactOperator::IsExact : 0);
}
Constant *ConstantExpr::getFDiv(Constant *C1, Constant *C2) {
@@ -1930,12 +1911,14 @@ Constant *ConstantExpr::getShl(Constant *C1, Constant *C2) {
return get(Instruction::Shl, C1, C2);
}
-Constant *ConstantExpr::getLShr(Constant *C1, Constant *C2) {
- return get(Instruction::LShr, C1, C2);
+Constant *ConstantExpr::getLShr(Constant *C1, Constant *C2, bool isExact) {
+ return get(Instruction::LShr, C1, C2,
+ isExact ? PossiblyExactOperator::IsExact : 0);
}
-Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2) {
- return get(Instruction::AShr, C1, C2);
+Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2, bool isExact) {
+ return get(Instruction::AShr, C1, C2,
+ isExact ? PossiblyExactOperator::IsExact : 0);
}
// destroyConstant - Remove the constant from the constant table...
OpenPOWER on IntegriCloud