# Changeset View

Changeset View

# Standalone View

Standalone View

# llvm/trunk/include/llvm/IR/ConstantRange.h

Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Line(s) | 60 | public: | |||
---|---|---|---|---|---|

111 | /// returns the exact answer when the superset of 'union over all y in Other | 111 | /// returns the exact answer when the superset of 'union over all y in Other | ||

112 | /// is exactly same as the subset of intersection over all y in Other. | 112 | /// is exactly same as the subset of intersection over all y in Other. | ||

113 | /// { x : icmp op x y is true}'. | 113 | /// { x : icmp op x y is true}'. | ||

114 | /// | 114 | /// | ||

115 | /// Example: Pred = ult and Other = i8 3 returns [0, 3) | 115 | /// Example: Pred = ult and Other = i8 3 returns [0, 3) | ||

116 | static ConstantRange makeExactICmpRegion(CmpInst::Predicate Pred, | 116 | static ConstantRange makeExactICmpRegion(CmpInst::Predicate Pred, | ||

117 | const APInt &Other); | 117 | const APInt &Other); | ||

118 | 118 | | |||

119 | /// Return the largest range containing all X such that "X BinOpC Y" is | 119 | /// Return the exact range containing all X such that "X BinOpC Y" is | ||

120 | /// guaranteed not to wrap (overflow) for all Y in Other. | 120 | /// guaranteed not to wrap (overflow) for all Y in Other. | ||

121 | /// | 121 | /// | ||

122 | /// If only one of NoUnsignedWrap or NoSignedWrap is specified, the returned | 122 | /// NoWrapKind must be one of OBO::NoUnsignedWrap or OBO::NoSignedWrap. | ||

123 | /// range is exact: It contains *all* possible values of X for which | | |||

124 | /// "X BinOpC Y" does not wrap. However, if both NUW and NSW are specified, it | | |||

125 | /// may return only a subset of non-wrapping values. In this case the | | |||

126 | /// returned region cannot be used to constrain X's range. E.g. in the | | |||

127 | /// fourth example, "(-2) + 1" is both nsw and nuw (so the "X" could be -2), | | |||

128 | /// but (-2) is not in the set returned. | | |||

129 | /// | 123 | /// | ||

130 | /// Examples: | 124 | /// Examples: | ||

131 | /// typedef OverflowingBinaryOperator OBO; | 125 | /// typedef OverflowingBinaryOperator OBO; | ||

132 | /// #define MGNR makeGuaranteedNoWrapRegion | 126 | /// #define MGNR makeGuaranteedNoWrapRegion | ||

133 | /// MGNR(Add, [i8 1, 2), OBO::NoSignedWrap) == [-128, 127) | 127 | /// MGNR(Add, [i8 1, 2), OBO::NoSignedWrap) == [-128, 127) | ||

134 | /// MGNR(Add, [i8 1, 2), OBO::NoUnsignedWrap) == [0, -1) | 128 | /// MGNR(Add, [i8 1, 2), OBO::NoUnsignedWrap) == [0, -1) | ||

135 | /// MGNR(Add, [i8 0, 1), OBO::NoUnsignedWrap) == Full Set | 129 | /// MGNR(Add, [i8 0, 1), OBO::NoUnsignedWrap) == Full Set | ||

136 | /// MGNR(Add, [i8 1, 2), OBO::NoUnsignedWrap | OBO::NoSignedWrap) | | |||

137 | /// == [0,INT_MAX) | | |||

138 | /// MGNR(Add, [i8 -1, 6), OBO::NoSignedWrap) == [INT_MIN+1, INT_MAX-4) | 130 | /// MGNR(Add, [i8 -1, 6), OBO::NoSignedWrap) == [INT_MIN+1, INT_MAX-4) | ||

139 | /// MGNR(Sub, [i8 1, 2), OBO::NoSignedWrap) == [-127, 128) | 131 | /// MGNR(Sub, [i8 1, 2), OBO::NoSignedWrap) == [-127, 128) | ||

140 | /// MGNR(Sub, [i8 1, 2), OBO::NoUnsignedWrap) == [1, 0) | 132 | /// MGNR(Sub, [i8 1, 2), OBO::NoUnsignedWrap) == [1, 0) | ||

141 | /// MGNR(Sub, [i8 1, 2), OBO::NoUnsignedWrap | OBO::NoSignedWrap) | | |||

142 | /// == [1,INT_MAX) | | |||

143 | static ConstantRange makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp, | 133 | static ConstantRange makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp, | ||

144 | const ConstantRange &Other, | 134 | const ConstantRange &Other, | ||

145 | unsigned NoWrapKind); | 135 | unsigned NoWrapKind); | ||

146 | 136 | | |||

147 | /// Set up \p Pred and \p RHS such that | 137 | /// Set up \p Pred and \p RHS such that | ||

148 | /// ConstantRange::makeExactICmpRegion(Pred, RHS) == *this. Return true if | 138 | /// ConstantRange::makeExactICmpRegion(Pred, RHS) == *this. Return true if | ||

149 | /// successful. | 139 | /// successful. | ||

150 | bool getEquivalentICmp(CmpInst::Predicate &Pred, APInt &RHS) const; | 140 | bool getEquivalentICmp(CmpInst::Predicate &Pred, APInt &RHS) const; | ||

▲ Show 20 Lines • Show All 276 Lines • Show Last 20 Lines |