diff options
author | Dan Gohman <gohman@apple.com> | 2009-09-03 23:34:49 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-09-03 23:34:49 +0000 |
commit | 6e7ad958683f34bf6c014c88fef723e5a2d741be (patch) | |
tree | d9a3addec2c194094cb027f2daa97815a2862048 /lib/VMCore/Constants.cpp | |
parent | b405bbe6648d24b0cb5b03dc43c3997ac4f50a9b (diff) |
Revert 80959. It isn't sufficient to solve the full problem. And it
introduced regressions in the Ocaml bindings tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r-- | lib/VMCore/Constants.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 1ddc1e27b0..37efafc9b2 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -631,6 +631,24 @@ Constant* ConstantVector::get(Constant* const* Vals, unsigned NumVals) { return get(std::vector<Constant*>(Vals, Vals+NumVals)); } +Constant* ConstantExpr::getNSWAdd(Constant* C1, Constant* C2) { + Constant *C = getAdd(C1, C2); + // Set nsw attribute, assuming constant folding didn't eliminate the + // Add. + if (AddOperator *Add = dyn_cast<AddOperator>(C)) + Add->setHasNoSignedWrap(true); + return C; +} + +Constant* ConstantExpr::getExactSDiv(Constant* C1, Constant* C2) { + Constant *C = getSDiv(C1, C2); + // Set exact attribute, assuming constant folding didn't eliminate the + // SDiv. + if (SDivOperator *SDiv = dyn_cast<SDivOperator>(C)) + SDiv->setIsExact(true); + return C; +} + // 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 @@ -1473,11 +1491,28 @@ Constant *ConstantExpr::getGetElementPtr(Constant *C, Value* const *Idxs, return getGetElementPtrTy(PointerType::get(Ty, As), C, Idxs, NumIdx); } +Constant *ConstantExpr::getInBoundsGetElementPtr(Constant *C, + Value* const *Idxs, + unsigned NumIdx) { + Constant *Result = getGetElementPtr(C, Idxs, NumIdx); + // Set in bounds attribute, assuming constant folding didn't eliminate the + // GEP. + if (GEPOperator *GEP = dyn_cast<GEPOperator>(Result)) + GEP->setIsInBounds(true); + return Result; +} + Constant *ConstantExpr::getGetElementPtr(Constant *C, Constant* const *Idxs, unsigned NumIdx) { return getGetElementPtr(C, (Value* const *)Idxs, NumIdx); } +Constant *ConstantExpr::getInBoundsGetElementPtr(Constant *C, + Constant* const *Idxs, + unsigned NumIdx) { + return getInBoundsGetElementPtr(C, (Value* const *)Idxs, NumIdx); +} + Constant * ConstantExpr::getICmp(unsigned short pred, Constant* LHS, Constant* RHS) { assert(LHS->getType() == RHS->getType()); |