diff options
author | Ruchira Sasanka <sasanka@students.uiuc.edu> | 2002-01-07 19:16:26 +0000 |
---|---|---|
committer | Ruchira Sasanka <sasanka@students.uiuc.edu> | 2002-01-07 19:16:26 +0000 |
commit | 42bd177eae30b6bdef578b6efb21e6c609aa5204 (patch) | |
tree | f113d735eac3bf8c2be56e02c17761224714eacb /lib/CodeGen/RegAlloc/LiveRange.h | |
parent | 977fa8df93ac03b89ef07c94fa12ed7aec11f41c (diff) |
Added comments, destructors where necessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1491 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAlloc/LiveRange.h')
-rw-r--r-- | lib/CodeGen/RegAlloc/LiveRange.h | 90 |
1 files changed, 55 insertions, 35 deletions
diff --git a/lib/CodeGen/RegAlloc/LiveRange.h b/lib/CodeGen/RegAlloc/LiveRange.h index 3ef627ed98..778e070046 100644 --- a/lib/CodeGen/RegAlloc/LiveRange.h +++ b/lib/CodeGen/RegAlloc/LiveRange.h @@ -14,56 +14,88 @@ #include "llvm/Analysis/LiveVar/ValueSet.h" #include "llvm/Type.h" - - - class RegClass; class IGNode; +//---------------------------------------------------------------------------- +// Class LiveRange +// +// Implements a live range using a ValueSet. A LiveRange is a simple set +// of Values. +//---------------------------------------------------------------------------- + class LiveRange : public ValueSet { private: RegClass *MyRegClass; // register classs (e.g., int, FP) for this LR - // a list of call instructions that interferes with this live range - //vector<const Instruction *> CallInterferenceList; - // does this live range span across calls? + bool doesSpanAcrossCalls; + // + // Does this live range span across calls? // This information is used by graph // coloring algo to avoid allocating volatile colors to live ranges // that span across calls (since they have to be saved/restored) - - bool doesSpanAcrossCalls; + IGNode *UserIGNode; // IGNode which uses this LR - int Color; // color assigned to this live range - bool mustSpill; // whether this LR must be spilt - // whether this LR must be saved accross calls ***TODO REMOVE this - bool mustSaveAcrossCalls; + int Color; // color assigned to this live range - // bool mustLoadFromStack; // must load from stack at start of method + bool mustSpill; // whether this LR must be spilt + bool mustSaveAcrossCalls; + // + // whether this LR must be saved accross calls ***TODO REMOVE this + int SuggestedColor; // The suggested color for this LR - + // // if this LR has a suggested color, can it be really alloated? // A suggested color cannot be allocated when the suggested color is // volatile and when there are call interferences. bool CanUseSuggestedCol; + // + // It is possible that a suggested color for this live range is not + // available before graph coloring (e.g., it can be allocated to another + // live range which interferes with this) + int SpilledStackOffsetFromFP; + // // if this LR is spilled, its stack offset from *FP*. The spilled offsets // must always be relative to the FP. - int SpilledStackOffsetFromFP; + bool HasSpillOffset; + // + // Whether this live range has a spill offset + + unsigned SpillCost; + // + // The spill cost of this live range. Calculated using loop depth of + // each reference to each Value in the live range public: + // constructor + // + LiveRange() : ValueSet() { + Color = SuggestedColor = -1; // not yet colored + mustSpill = mustSaveAcrossCalls = false; + MyRegClass = NULL; + UserIGNode = NULL; + doesSpanAcrossCalls = false; + CanUseSuggestedCol = true; + HasSpillOffset = false; + SpillCost = 0; + } + + // empty destructor since there are nothing to be deleted + // + ~LiveRange() {} - ~LiveRange() {} // empty destructor void setRegClass(RegClass *const RC) { MyRegClass = RC; } @@ -90,7 +122,6 @@ class LiveRange : public ValueSet return (doesSpanAcrossCalls == 1); } - inline void markForSpill() { mustSpill = true; } inline bool isMarkedForSpill() { return mustSpill; } @@ -122,9 +153,7 @@ class LiveRange : public ValueSet inline void markForSaveAcrossCalls() { mustSaveAcrossCalls = true; } - // inline void markForLoadFromStack() { mustLoadFromStack = true; - - + inline void setUserIGNode( IGNode *const IGN) { assert( !UserIGNode); UserIGNode = IGN; } @@ -169,22 +198,13 @@ class LiveRange : public ValueSet CanUseSuggestedCol = val; } + inline void addSpillCost(unsigned cost) { + SpillCost += cost; + } - - - - - - inline LiveRange() : ValueSet() /* , CallInterferenceList() */ - { - Color = SuggestedColor = -1; // not yet colored - mustSpill = mustSaveAcrossCalls = false; - MyRegClass = NULL; - UserIGNode = NULL; - doesSpanAcrossCalls = false; - CanUseSuggestedCol = true; - HasSpillOffset = false; - } + inline unsigned getSpillCost() const { + return SpillCost; + } }; |