This patch implements the general dynamic TLS model for 64-bit PowerPC.
[oota-llvm.git] / include / llvm / Support / IntegersSubset.h
index 4d76fab2d0941a4dcc959b8074e165488aeb7d2d..d6a3b2f541b2a424177848dfa281a8cb9ad3e224 100644 (file)
 #ifndef CONSTANTRANGESSET_H_
 #define CONSTANTRANGESSET_H_
 
-#include <list>
-
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/LLVMContext.h"
+#include <list>
 
 namespace llvm {
 
@@ -182,12 +181,7 @@ protected:
     IntType Low;
     IntType High;
     bool IsEmpty : 1;
-    enum Type {
-      SINGLE_NUMBER,
-      RANGE,
-      UNKNOWN
-    };
-    Type RangeType;
+    bool IsSingleNumber : 1;
 
 public:
     typedef IntRange<IntType> self;
@@ -196,30 +190,15 @@ public:
     IntRange() : IsEmpty(true) {}
     IntRange(const self &RHS) :
       Low(RHS.Low), High(RHS.High),
-      IsEmpty(RHS.IsEmpty), RangeType(RHS.RangeType) {}
+      IsEmpty(RHS.IsEmpty), IsSingleNumber(RHS.IsSingleNumber) {}
     IntRange(const IntType &C) :
-      Low(C), High(C), IsEmpty(false), RangeType(SINGLE_NUMBER) {}
+      Low(C), High(C), IsEmpty(false), IsSingleNumber(true) {}
 
     IntRange(const IntType &L, const IntType &H) : Low(L), High(H),
-      IsEmpty(false), RangeType(UNKNOWN) {}
+      IsEmpty(false), IsSingleNumber(Low == High) {}
 
     bool isEmpty() const { return IsEmpty; }
-    bool isSingleNumber() const {
-      switch (RangeType) {
-      case SINGLE_NUMBER:
-        return true;
-      case RANGE:
-        return false;
-      case UNKNOWN:
-        if (Low == High) {
-          const_cast<Type&>(RangeType) = SINGLE_NUMBER;
-          return true;
-        }
-        const_cast<Type&>(RangeType) = RANGE;
-        return false;
-      }
-      llvm_unreachable("Unknown state?!");
-    }
+    bool isSingleNumber() const { return IsSingleNumber; }
 
     const IntType& getLow() const {
       assert(!IsEmpty && "Range is empty.");
@@ -233,13 +212,13 @@ public:
     bool operator<(const self &RHS) const {
       assert(!IsEmpty && "Left range is empty.");
       assert(!RHS.IsEmpty && "Right range is empty.");
-      if (Low < RHS.Low)
-        return true;
       if (Low == RHS.Low) {
         if (High > RHS.High)
           return true;
         return false;
       }
+      if (Low < RHS.Low)
+        return true;
       return false;
     }
 
@@ -431,8 +410,8 @@ public:
   unsigned getSize() const {
     APInt sz(((const APInt&)getItem(0).getLow()).getBitWidth(), 0);
     for (unsigned i = 0, e = getNumItems(); i != e; ++i) {
-      const APInt &Low = getItem(i).getLow();
-      const APInt &High = getItem(i).getHigh();
+      const APInt Low = getItem(i).getLow();
+      const APInt High = getItem(i).getHigh();
       APInt S = High - Low + 1;
       sz += S;
     }
@@ -446,8 +425,8 @@ public:
   APInt getSingleValue(unsigned idx) const {
     APInt sz(((const APInt&)getItem(0).getLow()).getBitWidth(), 0);
     for (unsigned i = 0, e = getNumItems(); i != e; ++i) {
-      const APInt &Low = getItem(i).getLow();
-      const APInt &High = getItem(i).getHigh();
+      const APInt Low = getItem(i).getLow();
+      const APInt High = getItem(i).getHigh();
       APInt S = High - Low + 1;
       APInt oldSz = sz;
       sz += S;
@@ -532,7 +511,7 @@ public:
          e = Src.end(); i != e; ++i) {
       const Range &R = *i;
       std::vector<Constant*> r;
-      if (!R.isSingleNumber()) {
+      if (R.isSingleNumber()) {
         r.reserve(2);
         // FIXME: Since currently we have ConstantInt based numbers
         // use hack-conversion of IntItem to ConstantInt