2 Author: Ruchira Sasanka
4 Purpose: To keep info about a live range.
7 Since the Value pointed by a use is the same as of its def, it is sufficient
8 to keep only defs in a LiveRange.
14 #include "llvm/Analysis/LiveVar/ValueSet.h"
15 #include "llvm/Type.h"
24 class LiveRange : public ValueSet
28 RegClass *MyRegClass; // register classs (e.g., int, FP) for this LR
30 // a list of call instructions that interferes with this live range
31 vector<const Instruction *> CallInterferenceList;
33 IGNode *UserIGNode; // IGNode which uses this LR
34 int Color; // color assigned to this live range
35 bool mustSpill; // whether this LR must be spilt
37 // whether this LR must be saved accross calls
38 bool mustSaveAcrossCalls;
40 // bool mustLoadFromStack; // must load from stack at start of method
45 ~LiveRange() {} // empty destructor
47 void setRegClass(RegClass *const RC)
50 inline RegClass *const getRegClass() const
51 { assert(MyRegClass); return MyRegClass; }
53 inline bool hasColor() const
54 { return Color != -1; }
56 inline unsigned int getColor() const
57 { assert( Color != -1); return (unsigned) Color ; }
59 inline void setColor(unsigned int Col)
60 { Color = (int) Col ; }
63 inline void addCallInterference(const Instruction *const Inst)
64 { CallInterferenceList.push_back( Inst ); }
66 inline const Instruction *const getCallInterference(const unsigned i) const {
67 assert( i < CallInterferenceList.size() );
68 return CallInterferenceList[i];
71 inline unsigned int getNumOfCallInterferences() const
72 { return CallInterferenceList.size(); }
75 inline void markForSpill() { mustSpill = true; }
77 inline void markForSaveAcrossCalls() { mustSaveAcrossCalls = true; }
79 // inline void markForLoadFromStack() { mustLoadFromStack = true;
82 inline void setUserIGNode( IGNode *const IGN)
83 { assert( !UserIGNode); UserIGNode = IGN; }
85 inline IGNode * getUserIGNode() const
86 { return UserIGNode; } // NULL if the user is not allocated
88 inline Type::PrimitiveID getTypeID() const {
89 const Value *val = *begin();
90 assert(val && "Can't find type - Live range is empty" );
91 return (val->getType())->getPrimitiveID();
95 inline LiveRange() : ValueSet() , CallInterferenceList()
97 Color = -1; // not yet colored
98 mustSpill = mustSaveAcrossCalls = false;