Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 1 | //===-- ConstantRange.cpp - ConstantRange implementation ------------------===// |
Misha Brukman | fd93908 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | fd93908 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 9 | // |
| 10 | // Represent a range of possible values that may occur when the program is run |
| 11 | // for an integral value. This keeps track of a lower and upper bound for the |
| 12 | // constant, which MAY wrap around the end of the numeric range. To do this, it |
| 13 | // keeps track of a [lower, upper) bound, which specifies an interval just like |
| 14 | // STL iterators. When used with boolean values, the following are important |
| 15 | // ranges (other integral ranges use min/max values for special range values): |
| 16 | // |
| 17 | // [F, F) = {} = Empty set |
| 18 | // [T, F) = {T} |
| 19 | // [F, T) = {F} |
| 20 | // [T, T) = {F, T} = Full set |
| 21 | // |
| 22 | //===----------------------------------------------------------------------===// |
| 23 | |
| 24 | #include "llvm/Support/ConstantRange.h" |
Chris Lattner | 944fac7 | 2008-08-23 22:23:09 +0000 | [diff] [blame] | 25 | #include "llvm/Support/raw_ostream.h" |
Nick Lewycky | bf8c7f0 | 2009-07-11 06:15:39 +0000 | [diff] [blame] | 26 | #include "llvm/Instructions.h" |
Chris Lattner | 2cdd21c | 2003-12-14 21:35:53 +0000 | [diff] [blame] | 27 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 28 | |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 29 | /// Initialize a full (the default) or empty set for the specified type. |
| 30 | /// |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 31 | ConstantRange::ConstantRange(uint32_t BitWidth, bool Full) { |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 32 | if (Full) |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 33 | Lower = Upper = APInt::getMaxValue(BitWidth); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 34 | else |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 35 | Lower = Upper = APInt::getMinValue(BitWidth); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 38 | /// Initialize a range to hold the single specified value. |
| 39 | /// |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 40 | ConstantRange::ConstantRange(const APInt & V) : Lower(V), Upper(V + 1) {} |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 41 | |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 42 | ConstantRange::ConstantRange(const APInt &L, const APInt &U) : |
| 43 | Lower(L), Upper(U) { |
| 44 | assert(L.getBitWidth() == U.getBitWidth() && |
| 45 | "ConstantRange with unequal bit widths"); |
Zhou Sheng | c125c00 | 2007-04-26 16:42:07 +0000 | [diff] [blame] | 46 | assert((L != U || (L.isMaxValue() || L.isMinValue())) && |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 47 | "Lower == Upper, but they aren't min or max value!"); |
| 48 | } |
| 49 | |
Nick Lewycky | bf8c7f0 | 2009-07-11 06:15:39 +0000 | [diff] [blame] | 50 | ConstantRange ConstantRange::makeICmpRegion(unsigned Pred, |
| 51 | const ConstantRange &CR) { |
| 52 | uint32_t W = CR.getBitWidth(); |
| 53 | switch (Pred) { |
| 54 | default: assert(!"Invalid ICmp predicate to makeICmpRegion()"); |
| 55 | case ICmpInst::ICMP_EQ: |
Nick Lewycky | f067a23 | 2009-07-11 17:04:01 +0000 | [diff] [blame] | 56 | return CR; |
Nick Lewycky | bf8c7f0 | 2009-07-11 06:15:39 +0000 | [diff] [blame] | 57 | case ICmpInst::ICMP_NE: |
| 58 | if (CR.isSingleElement()) |
| 59 | return ConstantRange(CR.getUpper(), CR.getLower()); |
| 60 | return ConstantRange(W); |
| 61 | case ICmpInst::ICMP_ULT: |
| 62 | return ConstantRange(APInt::getMinValue(W), CR.getUnsignedMax()); |
| 63 | case ICmpInst::ICMP_SLT: |
| 64 | return ConstantRange(APInt::getSignedMinValue(W), CR.getSignedMax()); |
| 65 | case ICmpInst::ICMP_ULE: { |
| 66 | APInt UMax(CR.getUnsignedMax()); |
| 67 | if (UMax.isMaxValue()) |
| 68 | return ConstantRange(W); |
| 69 | return ConstantRange(APInt::getMinValue(W), UMax + 1); |
| 70 | } |
| 71 | case ICmpInst::ICMP_SLE: { |
| 72 | APInt SMax(CR.getSignedMax()); |
| 73 | if (SMax.isMaxSignedValue() || (SMax+1).isMaxSignedValue()) |
| 74 | return ConstantRange(W); |
| 75 | return ConstantRange(APInt::getSignedMinValue(W), SMax + 1); |
| 76 | } |
| 77 | case ICmpInst::ICMP_UGT: |
| 78 | return ConstantRange(CR.getUnsignedMin() + 1, APInt::getNullValue(W)); |
| 79 | case ICmpInst::ICMP_SGT: |
| 80 | return ConstantRange(CR.getSignedMin() + 1, |
| 81 | APInt::getSignedMinValue(W)); |
| 82 | case ICmpInst::ICMP_UGE: { |
| 83 | APInt UMin(CR.getUnsignedMin()); |
| 84 | if (UMin.isMinValue()) |
| 85 | return ConstantRange(W); |
| 86 | return ConstantRange(UMin, APInt::getNullValue(W)); |
| 87 | } |
| 88 | case ICmpInst::ICMP_SGE: { |
| 89 | APInt SMin(CR.getSignedMin()); |
| 90 | if (SMin.isMinSignedValue()) |
| 91 | return ConstantRange(W); |
| 92 | return ConstantRange(SMin, APInt::getSignedMinValue(W)); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 97 | /// isFullSet - Return true if this set contains all of the elements possible |
| 98 | /// for this data-type |
| 99 | bool ConstantRange::isFullSet() const { |
Zhou Sheng | c125c00 | 2007-04-26 16:42:07 +0000 | [diff] [blame] | 100 | return Lower == Upper && Lower.isMaxValue(); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 101 | } |
Misha Brukman | fd93908 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 102 | |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 103 | /// isEmptySet - Return true if this set contains no members. |
| 104 | /// |
| 105 | bool ConstantRange::isEmptySet() const { |
Zhou Sheng | c125c00 | 2007-04-26 16:42:07 +0000 | [diff] [blame] | 106 | return Lower == Upper && Lower.isMinValue(); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /// isWrappedSet - Return true if this set wraps around the top of the range, |
| 110 | /// for example: [100, 8) |
| 111 | /// |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 112 | bool ConstantRange::isWrappedSet() const { |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 113 | return Lower.ugt(Upper); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 116 | /// getSetSize - Return the number of elements in this set. |
| 117 | /// |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 118 | APInt ConstantRange::getSetSize() const { |
| 119 | if (isEmptySet()) |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 120 | return APInt(getBitWidth(), 0); |
| 121 | if (getBitWidth() == 1) { |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 122 | if (Lower != Upper) // One of T or F in the set... |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 123 | return APInt(2, 1); |
| 124 | return APInt(2, 2); // Must be full set... |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 125 | } |
Misha Brukman | fd93908 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 126 | |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 127 | // Simply subtract the bounds... |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 128 | return Upper - Lower; |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 129 | } |
| 130 | |
Nick Lewycky | 3400e6a | 2007-03-10 15:54:12 +0000 | [diff] [blame] | 131 | /// getUnsignedMax - Return the largest unsigned value contained in the |
| 132 | /// ConstantRange. |
| 133 | /// |
| 134 | APInt ConstantRange::getUnsignedMax() const { |
| 135 | if (isFullSet() || isWrappedSet()) |
| 136 | return APInt::getMaxValue(getBitWidth()); |
| 137 | else |
| 138 | return getUpper() - 1; |
| 139 | } |
| 140 | |
| 141 | /// getUnsignedMin - Return the smallest unsigned value contained in the |
| 142 | /// ConstantRange. |
| 143 | /// |
| 144 | APInt ConstantRange::getUnsignedMin() const { |
| 145 | if (isFullSet() || (isWrappedSet() && getUpper() != 0)) |
| 146 | return APInt::getMinValue(getBitWidth()); |
| 147 | else |
| 148 | return getLower(); |
| 149 | } |
| 150 | |
| 151 | /// getSignedMax - Return the largest signed value contained in the |
| 152 | /// ConstantRange. |
| 153 | /// |
| 154 | APInt ConstantRange::getSignedMax() const { |
Zhou Sheng | daacf22 | 2007-04-13 05:57:32 +0000 | [diff] [blame] | 155 | APInt SignedMax(APInt::getSignedMaxValue(getBitWidth())); |
Nick Lewycky | 3400e6a | 2007-03-10 15:54:12 +0000 | [diff] [blame] | 156 | if (!isWrappedSet()) { |
Nick Lewycky | ae5eb7a | 2007-06-09 04:20:33 +0000 | [diff] [blame] | 157 | if (getLower().sle(getUpper() - 1)) |
Nick Lewycky | 3400e6a | 2007-03-10 15:54:12 +0000 | [diff] [blame] | 158 | return getUpper() - 1; |
| 159 | else |
| 160 | return SignedMax; |
| 161 | } else { |
Nick Lewycky | 780905e | 2009-07-13 04:50:21 +0000 | [diff] [blame^] | 162 | if (getLower().isNegative() == getUpper().isNegative()) |
| 163 | return SignedMax; |
| 164 | else |
Nick Lewycky | 3400e6a | 2007-03-10 15:54:12 +0000 | [diff] [blame] | 165 | return getUpper() - 1; |
Nick Lewycky | 3400e6a | 2007-03-10 15:54:12 +0000 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
| 169 | /// getSignedMin - Return the smallest signed value contained in the |
| 170 | /// ConstantRange. |
| 171 | /// |
| 172 | APInt ConstantRange::getSignedMin() const { |
Zhou Sheng | daacf22 | 2007-04-13 05:57:32 +0000 | [diff] [blame] | 173 | APInt SignedMin(APInt::getSignedMinValue(getBitWidth())); |
Nick Lewycky | 3400e6a | 2007-03-10 15:54:12 +0000 | [diff] [blame] | 174 | if (!isWrappedSet()) { |
Nick Lewycky | ae5eb7a | 2007-06-09 04:20:33 +0000 | [diff] [blame] | 175 | if (getLower().sle(getUpper() - 1)) |
Nick Lewycky | 3400e6a | 2007-03-10 15:54:12 +0000 | [diff] [blame] | 176 | return getLower(); |
| 177 | else |
| 178 | return SignedMin; |
| 179 | } else { |
| 180 | if ((getUpper() - 1).slt(getLower())) { |
| 181 | if (getUpper() != SignedMin) |
| 182 | return SignedMin; |
| 183 | else |
| 184 | return getLower(); |
| 185 | } else { |
| 186 | return getLower(); |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 191 | /// contains - Return true if the specified value is in the set. |
| 192 | /// |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 193 | bool ConstantRange::contains(const APInt &V) const { |
| 194 | if (Lower == Upper) |
| 195 | return isFullSet(); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 196 | |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 197 | if (!isWrappedSet()) |
| 198 | return Lower.ule(V) && V.ult(Upper); |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 199 | else |
| 200 | return Lower.ule(V) || V.ult(Upper); |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Nick Lewycky | bf8c7f0 | 2009-07-11 06:15:39 +0000 | [diff] [blame] | 203 | /// contains - Return true if the argument is a subset of this range. |
| 204 | /// Two equal set contain each other. The empty set is considered to be |
| 205 | /// contained by all other sets. |
| 206 | /// |
| 207 | bool ConstantRange::contains(const ConstantRange &Other) const { |
| 208 | if (isFullSet()) return true; |
| 209 | if (Other.isFullSet()) return false; |
| 210 | if (Other.isEmptySet()) return true; |
| 211 | if (isEmptySet()) return false; |
| 212 | |
| 213 | if (!isWrappedSet()) { |
| 214 | if (Other.isWrappedSet()) |
| 215 | return false; |
| 216 | |
| 217 | return Lower.ule(Other.getLower()) && Other.getUpper().ule(Upper); |
| 218 | } |
| 219 | |
| 220 | if (!Other.isWrappedSet()) |
| 221 | return Other.getUpper().ule(Upper) || |
| 222 | Lower.ule(Other.getLower()); |
| 223 | |
| 224 | return Other.getUpper().ule(Upper) && Lower.ule(Other.getLower()); |
| 225 | } |
| 226 | |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 227 | /// subtract - Subtract the specified constant from the endpoints of this |
| 228 | /// constant range. |
Reid Spencer | 581b0d4 | 2007-02-28 19:57:34 +0000 | [diff] [blame] | 229 | ConstantRange ConstantRange::subtract(const APInt &Val) const { |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 230 | assert(Val.getBitWidth() == getBitWidth() && "Wrong bit width"); |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 231 | // If the set is empty or full, don't modify the endpoints. |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 232 | if (Lower == Upper) |
| 233 | return *this; |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 234 | return ConstantRange(Lower - Val, Upper - Val); |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 235 | } |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 236 | |
| 237 | |
| 238 | // intersect1Wrapped - This helper function is used to intersect two ranges when |
| 239 | // it is known that LHS is wrapped and RHS isn't. |
| 240 | // |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 241 | ConstantRange |
| 242 | ConstantRange::intersect1Wrapped(const ConstantRange &LHS, |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 243 | const ConstantRange &RHS) { |
| 244 | assert(LHS.isWrappedSet() && !RHS.isWrappedSet()); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 245 | |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 246 | // Check to see if we overlap on the Left side of RHS... |
| 247 | // |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 248 | if (RHS.Lower.ult(LHS.Upper)) { |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 249 | // We do overlap on the left side of RHS, see if we overlap on the right of |
| 250 | // RHS... |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 251 | if (RHS.Upper.ugt(LHS.Lower)) { |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 252 | // Ok, the result overlaps on both the left and right sides. See if the |
| 253 | // resultant interval will be smaller if we wrap or not... |
| 254 | // |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 255 | if (LHS.getSetSize().ult(RHS.getSetSize())) |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 256 | return LHS; |
| 257 | else |
| 258 | return RHS; |
| 259 | |
| 260 | } else { |
| 261 | // No overlap on the right, just on the left. |
Reid Spencer | dc5c159 | 2007-02-28 18:57:32 +0000 | [diff] [blame] | 262 | return ConstantRange(RHS.Lower, LHS.Upper); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 263 | } |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 264 | } else { |
| 265 | // We don't overlap on the left side of RHS, see if we overlap on the right |
| 266 | // of RHS... |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 267 | if (RHS.Upper.ugt(LHS.Lower)) { |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 268 | // Simple overlap... |
Reid Spencer | dc5c159 | 2007-02-28 18:57:32 +0000 | [diff] [blame] | 269 | return ConstantRange(LHS.Lower, RHS.Upper); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 270 | } else { |
| 271 | // No overlap... |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 272 | return ConstantRange(LHS.getBitWidth(), false); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
Nick Lewycky | 3e05164 | 2007-02-11 00:58:49 +0000 | [diff] [blame] | 277 | /// intersectWith - Return the range that results from the intersection of this |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 278 | /// range with another range. |
| 279 | /// |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 280 | ConstantRange ConstantRange::intersectWith(const ConstantRange &CR) const { |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 281 | assert(getBitWidth() == CR.getBitWidth() && |
| 282 | "ConstantRange types don't agree!"); |
Chris Lattner | d122f4b | 2002-09-02 20:49:27 +0000 | [diff] [blame] | 283 | // Handle common special cases |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 284 | if (isEmptySet() || CR.isFullSet()) |
| 285 | return *this; |
| 286 | if (isFullSet() || CR.isEmptySet()) |
| 287 | return CR; |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 288 | |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 289 | if (!isWrappedSet()) { |
| 290 | if (!CR.isWrappedSet()) { |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 291 | APInt L = APIntOps::umax(Lower, CR.Lower); |
| 292 | APInt U = APIntOps::umin(Upper, CR.Upper); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 293 | |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 294 | if (L.ult(U)) // If range isn't empty... |
Chris Lattner | d122f4b | 2002-09-02 20:49:27 +0000 | [diff] [blame] | 295 | return ConstantRange(L, U); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 296 | else |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 297 | return ConstantRange(getBitWidth(), false);// Otherwise, empty set |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 298 | } else |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 299 | return intersect1Wrapped(CR, *this); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 300 | } else { // We know "this" is wrapped... |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 301 | if (!CR.isWrappedSet()) |
| 302 | return intersect1Wrapped(*this, CR); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 303 | else { |
| 304 | // Both ranges are wrapped... |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 305 | APInt L = APIntOps::umax(Lower, CR.Lower); |
| 306 | APInt U = APIntOps::umin(Upper, CR.Upper); |
Chris Lattner | d122f4b | 2002-09-02 20:49:27 +0000 | [diff] [blame] | 307 | return ConstantRange(L, U); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | return *this; |
| 311 | } |
| 312 | |
Nick Lewycky | 377b119 | 2007-07-14 02:51:34 +0000 | [diff] [blame] | 313 | /// maximalIntersectWith - Return the range that results from the intersection |
| 314 | /// of this range with another range. The resultant range is guaranteed to |
Nick Lewycky | 28753f8 | 2007-07-14 17:41:03 +0000 | [diff] [blame] | 315 | /// include all elements contained in both input ranges, and to have the |
| 316 | /// smallest possible set size that does so. Because there may be two |
| 317 | /// intersections with the same set size, A.maximalIntersectWith(B) might not |
| 318 | /// be equal to B.maximalIntersect(A). |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 319 | ConstantRange |
| 320 | ConstantRange::maximalIntersectWith(const ConstantRange &CR) const { |
Nick Lewycky | 377b119 | 2007-07-14 02:51:34 +0000 | [diff] [blame] | 321 | assert(getBitWidth() == CR.getBitWidth() && |
| 322 | "ConstantRange types don't agree!"); |
| 323 | |
| 324 | // Handle common cases. |
| 325 | if ( isEmptySet() || CR.isFullSet()) return *this; |
| 326 | if (CR.isEmptySet() || isFullSet()) return CR; |
| 327 | |
| 328 | if (!isWrappedSet() && CR.isWrappedSet()) |
| 329 | return CR.maximalIntersectWith(*this); |
| 330 | |
| 331 | if (!isWrappedSet() && !CR.isWrappedSet()) { |
| 332 | if (Lower.ult(CR.Lower)) { |
| 333 | if (Upper.ule(CR.Lower)) |
| 334 | return ConstantRange(getBitWidth(), false); |
| 335 | |
| 336 | if (Upper.ult(CR.Upper)) |
| 337 | return ConstantRange(CR.Lower, Upper); |
| 338 | |
| 339 | return CR; |
| 340 | } else { |
| 341 | if (Upper.ult(CR.Upper)) |
| 342 | return *this; |
| 343 | |
| 344 | if (Lower.ult(CR.Upper)) |
| 345 | return ConstantRange(Lower, CR.Upper); |
| 346 | |
| 347 | return ConstantRange(getBitWidth(), false); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | if (isWrappedSet() && !CR.isWrappedSet()) { |
| 352 | if (CR.Lower.ult(Upper)) { |
| 353 | if (CR.Upper.ult(Upper)) |
| 354 | return CR; |
| 355 | |
| 356 | if (CR.Upper.ult(Lower)) |
| 357 | return ConstantRange(CR.Lower, Upper); |
| 358 | |
| 359 | if (getSetSize().ult(CR.getSetSize())) |
| 360 | return *this; |
| 361 | else |
| 362 | return CR; |
| 363 | } else if (CR.Lower.ult(Lower)) { |
| 364 | if (CR.Upper.ule(Lower)) |
| 365 | return ConstantRange(getBitWidth(), false); |
| 366 | |
| 367 | return ConstantRange(Lower, CR.Upper); |
| 368 | } |
| 369 | return CR; |
| 370 | } |
| 371 | |
| 372 | if (CR.Upper.ult(Upper)) { |
| 373 | if (CR.Lower.ult(Upper)) { |
| 374 | if (getSetSize().ult(CR.getSetSize())) |
| 375 | return *this; |
| 376 | else |
| 377 | return CR; |
| 378 | } |
| 379 | |
| 380 | if (CR.Lower.ult(Lower)) |
| 381 | return ConstantRange(Lower, CR.Upper); |
| 382 | |
| 383 | return CR; |
| 384 | } else if (CR.Upper.ult(Lower)) { |
| 385 | if (CR.Lower.ult(Lower)) |
| 386 | return *this; |
| 387 | |
| 388 | return ConstantRange(CR.Lower, Upper); |
| 389 | } |
| 390 | if (getSetSize().ult(CR.getSetSize())) |
| 391 | return *this; |
| 392 | else |
| 393 | return CR; |
| 394 | } |
| 395 | |
| 396 | |
Nick Lewycky | 3e05164 | 2007-02-11 00:58:49 +0000 | [diff] [blame] | 397 | /// unionWith - Return the range that results from the union of this range with |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 398 | /// another range. The resultant range is guaranteed to include the elements of |
Nick Lewycky | 9babd0e | 2007-04-01 03:47:44 +0000 | [diff] [blame] | 399 | /// both sets, but may contain more. For example, [3, 9) union [12,15) is |
| 400 | /// [3, 15), which includes 9, 10, and 11, which were not included in either |
| 401 | /// set before. |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 402 | /// |
Reid Spencer | a6e8a95 | 2007-03-01 07:54:15 +0000 | [diff] [blame] | 403 | ConstantRange ConstantRange::unionWith(const ConstantRange &CR) const { |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 404 | assert(getBitWidth() == CR.getBitWidth() && |
| 405 | "ConstantRange types don't agree!"); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 406 | |
Nick Lewycky | c6a28fc | 2007-03-02 03:33:05 +0000 | [diff] [blame] | 407 | if ( isFullSet() || CR.isEmptySet()) return *this; |
| 408 | if (CR.isFullSet() || isEmptySet()) return CR; |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 409 | |
Nick Lewycky | 9babd0e | 2007-04-01 03:47:44 +0000 | [diff] [blame] | 410 | if (!isWrappedSet() && CR.isWrappedSet()) return CR.unionWith(*this); |
| 411 | |
Nick Lewycky | c6a28fc | 2007-03-02 03:33:05 +0000 | [diff] [blame] | 412 | APInt L = Lower, U = Upper; |
| 413 | |
Nick Lewycky | 9babd0e | 2007-04-01 03:47:44 +0000 | [diff] [blame] | 414 | if (!isWrappedSet() && !CR.isWrappedSet()) { |
| 415 | if (CR.Lower.ult(L)) |
| 416 | L = CR.Lower; |
Nick Lewycky | c6a28fc | 2007-03-02 03:33:05 +0000 | [diff] [blame] | 417 | |
Nick Lewycky | 9babd0e | 2007-04-01 03:47:44 +0000 | [diff] [blame] | 418 | if (CR.Upper.ugt(U)) |
| 419 | U = CR.Upper; |
| 420 | } |
| 421 | |
| 422 | if (isWrappedSet() && !CR.isWrappedSet()) { |
| 423 | if ((CR.Lower.ult(Upper) && CR.Upper.ult(Upper)) || |
| 424 | (CR.Lower.ugt(Lower) && CR.Upper.ugt(Lower))) { |
| 425 | return *this; |
| 426 | } |
| 427 | |
| 428 | if (CR.Lower.ule(Upper) && Lower.ule(CR.Upper)) { |
| 429 | return ConstantRange(getBitWidth()); |
| 430 | } |
| 431 | |
| 432 | if (CR.Lower.ule(Upper) && CR.Upper.ule(Lower)) { |
| 433 | APInt d1 = CR.Upper - Upper, d2 = Lower - CR.Upper; |
| 434 | if (d1.ult(d2)) { |
| 435 | U = CR.Upper; |
| 436 | } else { |
| 437 | L = CR.Upper; |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | if (Upper.ult(CR.Lower) && CR.Upper.ult(Lower)) { |
| 442 | APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Upper; |
| 443 | if (d1.ult(d2)) { |
| 444 | U = CR.Lower + 1; |
| 445 | } else { |
| 446 | L = CR.Upper - 1; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | if (Upper.ult(CR.Lower) && Lower.ult(CR.Upper)) { |
| 451 | APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Lower; |
| 452 | |
| 453 | if (d1.ult(d2)) { |
| 454 | U = CR.Lower + 1; |
| 455 | } else { |
| 456 | L = CR.Lower; |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | if (isWrappedSet() && CR.isWrappedSet()) { |
| 462 | if (Lower.ult(CR.Upper) || CR.Lower.ult(Upper)) |
| 463 | return ConstantRange(getBitWidth()); |
| 464 | |
| 465 | if (CR.Upper.ugt(U)) { |
| 466 | U = CR.Upper; |
| 467 | } |
| 468 | |
| 469 | if (CR.Lower.ult(L)) { |
| 470 | L = CR.Lower; |
| 471 | } |
| 472 | |
| 473 | if (L == U) return ConstantRange(getBitWidth()); |
| 474 | } |
Nick Lewycky | c6a28fc | 2007-03-02 03:33:05 +0000 | [diff] [blame] | 475 | |
| 476 | return ConstantRange(L, U); |
Chris Lattner | 645e00d | 2002-09-01 23:53:36 +0000 | [diff] [blame] | 477 | } |
Chris Lattner | 96f9d72 | 2002-09-02 00:18:22 +0000 | [diff] [blame] | 478 | |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 479 | /// zeroExtend - Return a new range in the specified integer type, which must |
| 480 | /// be strictly larger than the current type. The returned range will |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 481 | /// correspond to the possible range of values as if the source range had been |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 482 | /// zero extended. |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 483 | ConstantRange ConstantRange::zeroExtend(uint32_t DstTySize) const { |
| 484 | unsigned SrcTySize = getBitWidth(); |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 485 | assert(SrcTySize < DstTySize && "Not a value extension"); |
Reid Spencer | dc5c159 | 2007-02-28 18:57:32 +0000 | [diff] [blame] | 486 | if (isFullSet()) |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 487 | // Change a source full set into [0, 1 << 8*numbytes) |
Reid Spencer | dc5c159 | 2007-02-28 18:57:32 +0000 | [diff] [blame] | 488 | return ConstantRange(APInt(DstTySize,0), APInt(DstTySize,1).shl(SrcTySize)); |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 489 | |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 490 | APInt L = Lower; L.zext(DstTySize); |
| 491 | APInt U = Upper; U.zext(DstTySize); |
| 492 | return ConstantRange(L, U); |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 493 | } |
| 494 | |
Nick Lewycky | e32157c | 2007-04-07 15:41:33 +0000 | [diff] [blame] | 495 | /// signExtend - Return a new range in the specified integer type, which must |
| 496 | /// be strictly larger than the current type. The returned range will |
| 497 | /// correspond to the possible range of values as if the source range had been |
| 498 | /// sign extended. |
| 499 | ConstantRange ConstantRange::signExtend(uint32_t DstTySize) const { |
| 500 | unsigned SrcTySize = getBitWidth(); |
| 501 | assert(SrcTySize < DstTySize && "Not a value extension"); |
| 502 | if (isFullSet()) { |
| 503 | return ConstantRange(APInt::getHighBitsSet(DstTySize,DstTySize-SrcTySize+1), |
Nick Lewycky | ff84de7 | 2009-07-13 04:17:23 +0000 | [diff] [blame] | 504 | APInt::getLowBitsSet(DstTySize, SrcTySize-1) + 1); |
Nick Lewycky | e32157c | 2007-04-07 15:41:33 +0000 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | APInt L = Lower; L.sext(DstTySize); |
| 508 | APInt U = Upper; U.sext(DstTySize); |
| 509 | return ConstantRange(L, U); |
| 510 | } |
| 511 | |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 512 | /// truncate - Return a new range in the specified integer type, which must be |
| 513 | /// strictly smaller than the current type. The returned range will |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 514 | /// correspond to the possible range of values as if the source range had been |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 515 | /// truncated to the specified type. |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 516 | ConstantRange ConstantRange::truncate(uint32_t DstTySize) const { |
| 517 | unsigned SrcTySize = getBitWidth(); |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 518 | assert(SrcTySize > DstTySize && "Not a value truncation"); |
Zhou Sheng | daacf22 | 2007-04-13 05:57:32 +0000 | [diff] [blame] | 519 | APInt Size(APInt::getLowBitsSet(SrcTySize, DstTySize)); |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 520 | if (isFullSet() || getSetSize().ugt(Size)) |
Reid Spencer | bb626a6 | 2007-02-28 22:02:48 +0000 | [diff] [blame] | 521 | return ConstantRange(DstTySize); |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 522 | |
Reid Spencer | 663e711 | 2007-02-28 17:36:23 +0000 | [diff] [blame] | 523 | APInt L = Lower; L.trunc(DstTySize); |
| 524 | APInt U = Upper; U.trunc(DstTySize); |
| 525 | return ConstantRange(L, U); |
Chris Lattner | fc33d30 | 2004-03-30 00:20:08 +0000 | [diff] [blame] | 526 | } |
| 527 | |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 528 | ConstantRange |
| 529 | ConstantRange::add(const ConstantRange &Other) const { |
| 530 | if (isEmptySet() || Other.isEmptySet()) |
| 531 | return ConstantRange(getBitWidth(), /*isFullSet=*/false); |
Nick Lewycky | cf9e07d | 2009-07-13 02:49:08 +0000 | [diff] [blame] | 532 | if (isFullSet() || Other.isFullSet()) |
| 533 | return ConstantRange(getBitWidth(), /*isFullSet=*/true); |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 534 | |
| 535 | APInt Spread_X = getSetSize(), Spread_Y = Other.getSetSize(); |
| 536 | APInt NewLower = getLower() + Other.getLower(); |
| 537 | APInt NewUpper = getUpper() + Other.getUpper() - 1; |
| 538 | if (NewLower == NewUpper) |
| 539 | return ConstantRange(getBitWidth(), /*isFullSet=*/true); |
| 540 | |
| 541 | ConstantRange X = ConstantRange(NewLower, NewUpper); |
| 542 | if (X.getSetSize().ult(Spread_X) || X.getSetSize().ult(Spread_Y)) |
| 543 | // We've wrapped, therefore, full set. |
| 544 | return ConstantRange(getBitWidth(), /*isFullSet=*/true); |
| 545 | |
| 546 | return X; |
Chris Lattner | 96f9d72 | 2002-09-02 00:18:22 +0000 | [diff] [blame] | 547 | } |
| 548 | |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 549 | ConstantRange |
| 550 | ConstantRange::multiply(const ConstantRange &Other) const { |
Nick Lewycky | 2ff893f | 2009-07-12 02:19:05 +0000 | [diff] [blame] | 551 | if (isEmptySet() || Other.isEmptySet()) |
| 552 | return ConstantRange(getBitWidth(), /*isFullSet=*/false); |
| 553 | if (isFullSet() || Other.isFullSet()) |
| 554 | return ConstantRange(getBitWidth(), /*isFullSet=*/true); |
| 555 | |
Nick Lewycky | f1db120 | 2009-07-13 03:27:41 +0000 | [diff] [blame] | 556 | APInt this_min = getUnsignedMin().zext(getBitWidth() * 2); |
| 557 | APInt this_max = getUnsignedMax().zext(getBitWidth() * 2); |
| 558 | APInt Other_min = Other.getUnsignedMin().zext(getBitWidth() * 2); |
| 559 | APInt Other_max = Other.getUnsignedMax().zext(getBitWidth() * 2); |
Nick Lewycky | 2ff893f | 2009-07-12 02:19:05 +0000 | [diff] [blame] | 560 | |
Nick Lewycky | f1db120 | 2009-07-13 03:27:41 +0000 | [diff] [blame] | 561 | ConstantRange Result_zext = ConstantRange(this_min * Other_min, |
| 562 | this_max * Other_max + 1); |
Nick Lewycky | 2ff893f | 2009-07-12 02:19:05 +0000 | [diff] [blame] | 563 | return Result_zext.truncate(getBitWidth()); |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | ConstantRange |
| 567 | ConstantRange::smax(const ConstantRange &Other) const { |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 568 | // X smax Y is: range(smax(X_smin, Y_smin), |
| 569 | // smax(X_smax, Y_smax)) |
| 570 | if (isEmptySet() || Other.isEmptySet()) |
| 571 | return ConstantRange(getBitWidth(), /*isFullSet=*/false); |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 572 | APInt NewL = APIntOps::smax(getSignedMin(), Other.getSignedMin()); |
| 573 | APInt NewU = APIntOps::smax(getSignedMax(), Other.getSignedMax()) + 1; |
| 574 | if (NewU == NewL) |
| 575 | return ConstantRange(getBitWidth(), /*isFullSet=*/true); |
| 576 | return ConstantRange(NewL, NewU); |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | ConstantRange |
| 580 | ConstantRange::umax(const ConstantRange &Other) const { |
| 581 | // X umax Y is: range(umax(X_umin, Y_umin), |
| 582 | // umax(X_umax, Y_umax)) |
| 583 | if (isEmptySet() || Other.isEmptySet()) |
| 584 | return ConstantRange(getBitWidth(), /*isFullSet=*/false); |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 585 | APInt NewL = APIntOps::umax(getUnsignedMin(), Other.getUnsignedMin()); |
| 586 | APInt NewU = APIntOps::umax(getUnsignedMax(), Other.getUnsignedMax()) + 1; |
| 587 | if (NewU == NewL) |
| 588 | return ConstantRange(getBitWidth(), /*isFullSet=*/true); |
| 589 | return ConstantRange(NewL, NewU); |
| 590 | } |
| 591 | |
| 592 | ConstantRange |
Nick Lewycky | 956daf0 | 2009-07-12 05:18:18 +0000 | [diff] [blame] | 593 | ConstantRange::udiv(const ConstantRange &RHS) const { |
| 594 | if (isEmptySet() || RHS.isEmptySet() || RHS.getUnsignedMax() == 0) |
| 595 | return ConstantRange(getBitWidth(), /*isFullSet=*/false); |
| 596 | if (RHS.isFullSet()) |
| 597 | return ConstantRange(getBitWidth(), /*isFullSet=*/true); |
| 598 | |
| 599 | APInt Lower = getUnsignedMin().udiv(RHS.getUnsignedMax()); |
| 600 | |
| 601 | APInt RHS_umin = RHS.getUnsignedMin(); |
| 602 | if (RHS_umin == 0) { |
| 603 | // We want the lowest value in RHS excluding zero. Usually that would be 1 |
| 604 | // except for a range in the form of [X, 1) in which case it would be X. |
| 605 | if (RHS.getUpper() == 1) |
| 606 | RHS_umin = RHS.getLower(); |
| 607 | else |
| 608 | RHS_umin = APInt(getBitWidth(), 1); |
| 609 | } |
| 610 | |
| 611 | APInt Upper = getUnsignedMax().udiv(RHS_umin) + 1; |
| 612 | |
| 613 | // If the LHS is Full and the RHS is a wrapped interval containing 1 then |
| 614 | // this could occur. |
| 615 | if (Lower == Upper) |
| 616 | return ConstantRange(getBitWidth(), /*isFullSet=*/true); |
| 617 | |
| 618 | return ConstantRange(Lower, Upper); |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 619 | } |
| 620 | |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 621 | /// print - Print out the bounds to a stream... |
Chris Lattner | 96f9d72 | 2002-09-02 00:18:22 +0000 | [diff] [blame] | 622 | /// |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 623 | void ConstantRange::print(raw_ostream &OS) const { |
| 624 | OS << "[" << Lower << "," << Upper << ")"; |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 625 | } |
| 626 | |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 627 | /// dump - Allow printing from a debugger easily... |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 628 | /// |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 629 | void ConstantRange::dump() const { |
| 630 | print(errs()); |
Dan Gohman | a3755d8 | 2009-07-09 22:07:27 +0000 | [diff] [blame] | 631 | } |
| 632 | |
Dan Gohman | 38b0644 | 2009-07-09 23:16:10 +0000 | [diff] [blame] | 633 | std::ostream &llvm::operator<<(std::ostream &o, |
| 634 | const ConstantRange &CR) { |
| 635 | raw_os_ostream OS(o); |
| 636 | OS << CR; |
| 637 | return o; |
Chris Lattner | 96f9d72 | 2002-09-02 00:18:22 +0000 | [diff] [blame] | 638 | } |