[llvm-commits] [llvm] r110826 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/RenderMachineFunction.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Aug 11 09:50:17 PDT 2010


Author: stoklund
Date: Wed Aug 11 11:50:17 2010
New Revision: 110826

URL: http://llvm.org/viewvc/llvm-project?rev=110826&view=rev
Log:
Fix a FIXME. The SlotIndex::Slot enum should be private.

Modified:
    llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
    llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp

Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=110826&r1=110825&r2=110826&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Wed Aug 11 11:50:17 2010
@@ -128,7 +128,8 @@
     friend class SlotIndexes;
     friend struct DenseMapInfo<SlotIndex>;
 
-  private:
+    enum Slot { LOAD, USE, DEF, STORE, NUM };
+
     static const unsigned PHI_BIT = 1 << 2;
 
     PointerIntPair<IndexListEntry*, 3, unsigned> lie;
@@ -146,6 +147,11 @@
       return entry().getIndex() | getSlot();
     }
 
+    /// Returns the slot for this SlotIndex.
+    Slot getSlot() const {
+      return static_cast<Slot>(lie.getInt()  & ~PHI_BIT);
+    }
+
     static inline unsigned getHashValue(const SlotIndex &v) {
       IndexListEntry *ptrVal = &v.entry();
       return (unsigned((intptr_t)ptrVal) >> 4) ^
@@ -153,11 +159,6 @@
     }
 
   public:
-
-    // FIXME: Ugh. This is public because LiveIntervalAnalysis is still using it
-    // for some spill weight stuff. Fix that, then make this private.
-    enum Slot { LOAD, USE, DEF, STORE, NUM };
-
     static inline SlotIndex getEmptyKey() {
       return SlotIndex(IndexListEntry::getEmptyKeyEntry(), 0);
     }
@@ -235,16 +236,31 @@
       return other.getIndex() - getIndex();
     }
 
-    /// Returns the slot for this SlotIndex.
-    Slot getSlot() const {
-      return static_cast<Slot>(lie.getInt()  & ~PHI_BIT);
-    }
-
     /// Returns the state of the PHI bit.
     bool isPHI() const {
       return lie.getInt() & PHI_BIT;
     }
 
+    /// isLoad - Return true if this is a LOAD slot.
+    bool isLoad() const {
+      return getSlot() == LOAD;
+    }
+
+    /// isDef - Return true if this is a DEF slot.
+    bool isDef() const {
+      return getSlot() == DEF;
+    }
+
+    /// isUse - Return true if this is a USE slot.
+    bool isUse() const {
+      return getSlot() == USE;
+    }
+
+    /// isStore - Return true if this is a STORE slot.
+    bool isStore() const {
+      return getSlot() == STORE;
+    }
+
     /// Returns the base index for associated with this index. The base index
     /// is the one associated with the LOAD slot for the instruction pointed to
     /// by this index.

Modified: llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp?rev=110826&r1=110825&r2=110826&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp Wed Aug 11 11:50:17 2010
@@ -551,11 +551,9 @@
           return AliveStack;
         }
       } else {
-        if (i.getSlot() == SlotIndex::DEF &&
-            mi->definesRegister(li->reg, tri)) {
+        if (i.isDef() && mi->definesRegister(li->reg, tri)) {
           return Defined;
-        } else if (i.getSlot() == SlotIndex::USE &&
-                   mi->readsRegister(li->reg)) {
+        } else if (i.isUse() && mi->readsRegister(li->reg)) {
           return Used;
         } else {
           if (vrm == 0 || 
@@ -771,7 +769,7 @@
       os << indent + s(2) << "<tr height=6ex>\n";
       
       // Render the code column.
-      if (i.getSlot() == SlotIndex::LOAD) {
+      if (i.isLoad()) {
         MachineBasicBlock *mbb = sis->getMBBFromIndex(i);
         mi = sis->getInstructionFromIndex(i);
 





More information about the llvm-commits mailing list