#ifndef IG_NODE_H
#define IG_NODE_H
-
-#include "llvm/CodeGen/RegAllocCommon.h"
#include "llvm/CodeGen/LiveRange.h"
class LiveRange;
class RegClass;
//----------------------------------------------------------------------------
class IGNode {
- const int 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
+ 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;
//
// Decremented when a neighbor is pushed on to the stack.
// After that, never incremented/set again nor used.
- LiveRange *const ParentLR; // parent LR (cannot be a const)
+ LiveRange *const ParentLR;
public:
- // constructor
- //
- IGNode(LiveRange *const LR, unsigned int index);
-
- // an empty destructor
- //
- ~IGNode() { }
-
+ 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)
//
// 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
// 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 RegClass *getRegClass() const { return ParentLR->getRegClass(); }
- inline bool hasColor() const
- { return ParentLR->hasColor(); }
+ inline bool hasColor() const { return ParentLR->hasColor(); }
- inline unsigned int getColor() const
- { return ParentLR->getColor(); }
+ inline unsigned int getColor() const { return ParentLR->getColor(); }
- inline void setColor(unsigned int Col)
- { ParentLR->setColor(Col); }
+ inline void setColor(unsigned Col) { ParentLR->setColor(Col); }
- inline void markForSpill()
- { ParentLR->markForSpill(); }
+ inline void markForSpill() { ParentLR->markForSpill(); }
- inline void markForSaveAcrossCalls()
- { ParentLR->markForSaveAcrossCalls(); }
+ inline void markForSaveAcrossCalls() { ParentLR->markForSaveAcrossCalls(); }
inline unsigned int isCallInterference() const
{ return ParentLR->isCallInterference(); }
- inline LiveRange *getParentLR() const
- { return ParentLR; }
-
- inline Type::PrimitiveID getTypeID() const
- { return ParentLR->getTypeID(); }
-
-
+ inline LiveRange *getParentLR() const { return ParentLR; }
};
#endif