Changes in directory llvm/include/llvm/Support:
ConstantRange.h updated: 1.12 -> 1.13 InstVisitor.h updated: 1.44 -> 1.45 PatternMatch.h updated: 1.14 -> 1.15 --- Log message: For PR950: http://llvm.org/PR950 : This patch removes the SetCC instructions and replaces them with the ICmp and FCmp instructions. The SetCondInst instruction has been removed and been replaced with ICmpInst and FCmpInst. --- Diffs of the changes: (+57 -16) ConstantRange.h | 26 ++++++++++++++++++-------- InstVisitor.h | 1 - PatternMatch.h | 46 +++++++++++++++++++++++++++++++++++++++------- 3 files changed, 57 insertions(+), 16 deletions(-) Index: llvm/include/llvm/Support/ConstantRange.h diff -u llvm/include/llvm/Support/ConstantRange.h:1.12 llvm/include/llvm/Support/ConstantRange.h:1.13 --- llvm/include/llvm/Support/ConstantRange.h:1.12 Sat Dec 16 23:15:12 2006 +++ llvm/include/llvm/Support/ConstantRange.h Sat Dec 23 00:05:40 2006 @@ -12,13 +12,19 @@ // constant, which MAY wrap around the end of the numeric range. To do this, it // keeps track of a [lower, upper) bound, which specifies an interval just like // STL iterators. When used with boolean values, the following are important -// ranges (other integral ranges use min/max values for special range values): +// ranges: : // // [F, F) = {} = Empty set // [T, F) = {T} // [F, T) = {F} // [T, T) = {F, T} = Full set // +// The other integral ranges use min/max values for special range values. For +// example, for 8-bit types, it uses: +// [0, 0) = {} = Empty set +// [255, 255) = {0..255} = Full Set +// +// Note that ConstantRange always keeps unsigned values. //===----------------------------------------------------------------------===// #ifndef LLVM_SUPPORT_CONSTANT_RANGE_H @@ -51,9 +57,11 @@ /// ConstantRange(Constant *Lower, Constant *Upper); - /// Initialize a set of values that all satisfy the condition with C. - /// - ConstantRange(unsigned SetCCOpcode, ConstantIntegral *C); + /// Initialize a set of values that all satisfy the predicate with C. The + /// predicate should be either an ICmpInst::Predicate or FCmpInst::Predicate + /// value. + /// @brief Get a range for a relation with a constant integral. + ConstantRange(unsigned short predicate, ConstantIntegral *C); /// getLower - Return the lower value for this range... /// @@ -79,11 +87,13 @@ /// isWrappedSet - Return true if this set wraps around the top of the range, /// for example: [100, 8) /// - bool isWrappedSet() const; + bool isWrappedSet(bool isSigned) const; /// contains - Return true if the specified value is in the set. + /// The isSigned parameter indicates whether the comparisons should be + /// performed as if the values are signed or not. /// - bool contains(ConstantInt *Val) const; + bool contains(ConstantInt *Val, bool isSigned) const; /// getSingleElement - If this set contains a single element, return it, /// otherwise return null. @@ -117,7 +127,7 @@ /// one of the sets but not the other. For example: [100, 8) intersect [3, /// 120) yields [3, 120) /// - ConstantRange intersectWith(const ConstantRange &CR) const; + ConstantRange intersectWith(const ConstantRange &CR, bool isSigned) const; /// union - Return the range that results from the union of this range with /// another range. The resultant range is guaranteed to include the elements @@ -125,7 +135,7 @@ /// [3, 15), which includes 9, 10, and 11, which were not included in either /// set before. /// - ConstantRange unionWith(const ConstantRange &CR) const; + ConstantRange unionWith(const ConstantRange &CR, bool isSigned) const; /// zeroExtend - Return a new range in the specified integer type, which must /// be strictly larger than the current type. The returned range will Index: llvm/include/llvm/Support/InstVisitor.h diff -u llvm/include/llvm/Support/InstVisitor.h:1.44 llvm/include/llvm/Support/InstVisitor.h:1.45 --- llvm/include/llvm/Support/InstVisitor.h:1.44 Wed Nov 29 15:37:00 2006 +++ llvm/include/llvm/Support/InstVisitor.h Sat Dec 23 00:05:40 2006 @@ -167,7 +167,6 @@ RetTy visitInvokeInst(InvokeInst &I) { DELEGATE(TerminatorInst);} RetTy visitUnwindInst(UnwindInst &I) { DELEGATE(TerminatorInst);} RetTy visitUnreachableInst(UnreachableInst &I) { DELEGATE(TerminatorInst);} - RetTy visitSetCondInst(SetCondInst &I) { DELEGATE(BinaryOperator);} RetTy visitICmpInst(ICmpInst &I) { DELEGATE(CmpInst);} RetTy visitFCmpInst(FCmpInst &I) { DELEGATE(CmpInst);} RetTy visitMallocInst(MallocInst &I) { DELEGATE(AllocationInst);} Index: llvm/include/llvm/Support/PatternMatch.h diff -u llvm/include/llvm/Support/PatternMatch.h:1.14 llvm/include/llvm/Support/PatternMatch.h:1.15 --- llvm/include/llvm/Support/PatternMatch.h:1.14 Sun Nov 26 19:05:09 2006 +++ llvm/include/llvm/Support/PatternMatch.h Sat Dec 23 00:05:40 2006 @@ -248,13 +248,6 @@ }; template<typename LHS, typename RHS> -inline BinaryOpClass_match<LHS, RHS, SetCondInst, Instruction::BinaryOps> -m_SetCond(Instruction::BinaryOps &Op, const LHS &L, const RHS &R) { - return BinaryOpClass_match<LHS, RHS, - SetCondInst, Instruction::BinaryOps>(Op, L, R); -} - -template<typename LHS, typename RHS> inline BinaryOpClass_match<LHS, RHS, ShiftInst, Instruction::OtherOps> m_Shift(Instruction::OtherOps &Op, const LHS &L, const RHS &R) { return BinaryOpClass_match<LHS, RHS, @@ -270,6 +263,45 @@ } //===----------------------------------------------------------------------===// +// Matchers for CmpInst classes +// + +template<typename LHS_t, typename RHS_t, typename Class, typename PredicateTy> +struct CmpClass_match { + PredicateTy &Predicate; + LHS_t L; + RHS_t R; + + CmpClass_match(PredicateTy &Pred, const LHS_t &LHS, + const RHS_t &RHS) + : Predicate(Pred), L(LHS), R(RHS) {} + + template<typename OpTy> + bool match(OpTy *V) { + if (Class *I = dyn_cast<Class>(V)) + if (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) { + Predicate = I->getPredicate(); + return true; + } + return false; + } +}; + +template<typename LHS, typename RHS> +inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate> +m_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) { + return CmpClass_match<LHS, RHS, + ICmpInst, ICmpInst::Predicate>(Pred, L, R); +} + +template<typename LHS, typename RHS> +inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate> +m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &R) { + return CmpClass_match<LHS, RHS, + FCmpInst, FCmpInst::Predicate>(Pred, L, R); +} + +//===----------------------------------------------------------------------===// // Matchers for unary operators // _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits