Rewrote uses of deprecated `MachineFunction::get(BasicBlock *BB)'.
[oota-llvm.git] / lib / Target / SparcV9 / RegAlloc / IGNode.h
index 03bcfc07b1a3bf7722f82e6b7e9bf48080632afa..edb178f5bc912fe56107069af0a004a59cbb9ecd 100644 (file)
@@ -1,4 +1,4 @@
-/* Title:   IGNode.h
+/* Title:   IGNode.h                      -*- C++ -*-
    Author:  Ruchira Sasanka
    Date:    July 25, 01
    Purpose: Represents a node in an interference graph. 
@@ -14,9 +14,9 @@
    OnStack flag set (therefore, they are in the IG).
 
    The methods that modify/use the CurDegree Must be called only
-   fter all modifications to the IG are over (i.e., all neighbors are fixed).
+   after all modifications to the IG are over (i.e., all neighbors are fixed).
 
-   The vector representation the most efficient one for adj list.
+   The vector representation is the most efficient one for adj list.
    Though nodes are removed when coalsing is done, we access it in sequence
    for far many times when coloring (colorNode()).
 
 #ifndef IG_NODE_H
 #define IG_NODE_H
 
-
-#include "llvm/CodeGen/RegAllocCommon.h"
 #include "llvm/CodeGen/LiveRange.h"
+class LiveRange;
+class RegClass;
 
-class IGNode
-{
- private:
-
-  const int Index;            // index within IGNodeList 
-
-  bool OnStack;               // this has been pushed on to stack for coloring
-
-  vector<IGNode *> AdjList;   // adjacency list for this live range
+//----------------------------------------------------------------------------
+// Class IGNode
+//
+// Represents a node in an interference graph.
+//----------------------------------------------------------------------------
 
+class IGNode {
+  const unsigned Index;         // index within IGNodeList 
+  bool OnStack;                 // this has been pushed on to stack for coloring
+  std::vector<IGNode *> AdjList;// adjacency list for this live range
 
+  int CurDegree;     
+  //
   // set by InterferenceGraph::setCurDegreeOfIGNodes() after calculating
   // all adjacency lists.
   // Decremented when a neighbor is pushed on to the stack. 
   // After that, never incremented/set again nor used.
-  int CurDegree;     
-
-  LiveRange *const ParentLR;            // parent LR (cannot be a const)
 
+  LiveRange *const ParentLR;
+public:
 
- public:
+  IGNode(LiveRange *LR, unsigned index) : Index(index), ParentLR(LR) {
+    OnStack = false;
+    CurDegree = -1;
+    ParentLR->setUserIGNode(this);
+  }
 
-  inline unsigned int getIndex() const 
-    { return Index; }
+  inline unsigned int getIndex() const { return Index; }
 
   // adjLists must be updated only once.  However, the CurDegree can be changed
-  inline void addAdjIGNode( IGNode *const AdjNode) 
-    { AdjList.push_back(AdjNode);  } 
+  //
+  inline void addAdjIGNode(IGNode *AdjNode) { AdjList.push_back(AdjNode);  } 
 
-  inline IGNode * getAdjIGNode(unsigned int ind) const 
-    { assert ( ind < AdjList.size()); return AdjList[ ind ]; }
+  inline IGNode *getAdjIGNode(unsigned ind) const 
+    { assert ( ind < AdjList.size()); return AdjList[ind]; }
 
   // delete a node in AdjList - node must be in the list
   // should not be called often
-  void delAdjIGNode(const IGNode *const Node); 
+  //
+  void delAdjIGNode(const IGNode *Node); 
 
-  inline unsigned int getNumOfNeighbors() const 
-    { return AdjList.size() ; }
+  inline unsigned getNumOfNeighbors() const { return AdjList.size(); }
 
+  // Get the number of unique neighbors if these two nodes are merged
+  unsigned getCombinedDegree(const IGNode* otherNode) const;
 
-  inline bool isOnStack() const 
-    { return OnStack; }
+  inline bool isOnStack() const { return OnStack; }
 
   // remove form IG and pushes on to stack (reduce the degree of neighbors)
+  //
   void pushOnStack(); 
 
   // CurDegree is the effective number of neighbors when neighbors are
   // pushed on to the stack during the coloring phase. Must be called
   // after all modifications to the IG are over (i.e., all neighbors are
   // fixed).
+  //
+  inline void setCurDegree() {
+    assert(CurDegree == -1);
+    CurDegree = AdjList.size();
+  }
 
-  inline void setCurDegree() 
-    { assert( CurDegree == -1);   CurDegree = AdjList.size(); }
-
-  inline int getCurDegree() const 
-    { return CurDegree; }
+  inline int getCurDegree() const { return CurDegree; }
 
   // called when a neigh is pushed on to stack
-  inline void decCurDegree() 
-    { assert( CurDegree > 0 ); --CurDegree; }
+  //
+  inline void decCurDegree() { assert(CurDegree > 0); --CurDegree; }
 
 
   // The following methods call the methods in ParentLR
@@ -96,57 +103,24 @@ class IGNode
   // If many of these are called within a single scope,
   // consider calling the methods directly on LR
 
+  inline void setRegClass(RegClass *RC) { ParentLR->setRegClass(RC);  }
 
-  inline void setRegClass(RegClass *const RC) 
-    { ParentLR->setRegClass(RC);  }
-
-  inline RegClass *const getRegClass() const 
-    { return ParentLR->getRegClass(); } 
-
-  inline bool hasColor() const 
-    { return ParentLR->hasColor();  }
-
-  inline unsigned int getColor() const 
-    { return ParentLR->getColor();  }
-
-  inline void setColor(unsigned int Col) 
-    { ParentLR->setColor(Col);  }
-
-  inline void markForSpill() 
-    { ParentLR->markForSpill();  }
+  inline RegClass *getRegClass() const { return ParentLR->getRegClass(); }
 
-  inline void markForSaveAcrossCalls() 
-    { ParentLR->markForSaveAcrossCalls();  }
+  inline bool hasColor() const { return ParentLR->hasColor();  }
 
-  // inline void markForLoadFromStack() 
-  //  { ParentLR->markForLoadFromStack();  }
+  inline unsigned int getColor() const { return ParentLR->getColor();  }
 
+  inline void setColor(unsigned Col) { ParentLR->setColor(Col);  }
 
-  inline unsigned int getNumOfCallInterferences() const 
-    { return ParentLR->getNumOfCallInterferences(); } 
+  inline void markForSpill() { ParentLR->markForSpill(); }
 
-  inline LiveRange *getParentLR() const 
-    { return ParentLR; }
-
-  inline Type::PrimitiveID getTypeID() const 
-    { return ParentLR->getTypeID(); }
-
-
-
-  //---- constructor and destructor ----
-
-
-  IGNode(LiveRange *const LR, unsigned int index);
-
-  ~IGNode() { }                         // an empty destructor
+  inline void markForSaveAcrossCalls() { ParentLR->markForSaveAcrossCalls();  }
 
+  inline unsigned int isCallInterference() const 
+  { return ParentLR->isCallInterference(); } 
 
+  inline LiveRange *getParentLR() const { return ParentLR; }
 };
 
-
-
-
-
-
-
 #endif