blob: d8e130a329c9ca5031e80499491372c0f57f3225 [file] [log] [blame]
Ruchira Sasankac7136d22001-09-08 14:10:34 +00001/* Title: LiveRange.h
2 Author: Ruchira Sasanka
3 Date: July 25, 01
4 Purpose: To keep info about a live range.
5 Asuumptions:
6
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.
9*/
10
11#ifndef LIVE_RANGE_H
12#define LIVE_RANGE_H
13
14#include "llvm/Analysis/LiveVar/ValueSet.h"
15#include "llvm/Type.h"
16
17
18
19
20class RegClass;
21class IGNode;
22
23
24class LiveRange : public ValueSet
25{
26 private:
27
28 RegClass *MyRegClass; // register classs (e.g., int, FP) for this LR
29
30 // a list of call instructions that interferes with this live range
31 vector<const Instruction *> CallInterferenceList;
32
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
36
37 // whether this LR must be saved accross calls
38 bool mustSaveAcrossCalls;
39
40 // bool mustLoadFromStack; // must load from stack at start of method
41
42 public:
43
44
45 ~LiveRange() {} // empty destructor
46
47 void setRegClass(RegClass *const RC)
48 { MyRegClass = RC; }
49
50 inline RegClass *const getRegClass() const
51 { assert(MyRegClass); return MyRegClass; }
52
53 inline bool hasColor() const
54 { return Color != -1; }
55
56 inline unsigned int getColor() const
57 { assert( Color != -1); return (unsigned) Color ; }
58
59 inline void setColor(unsigned int Col)
60 { Color = (int) Col ; }
61
62
63 inline void addCallInterference(const Instruction *const Inst)
64 { CallInterferenceList.push_back( Inst ); }
65
66 inline const Instruction *const getCallInterference(const unsigned i) const {
67 assert( i < CallInterferenceList.size() );
68 return CallInterferenceList[i];
69 }
70
71 inline unsigned int getNumOfCallInterferences() const
72 { return CallInterferenceList.size(); }
73
74
75 inline void markForSpill() { mustSpill = true; }
76
77 inline void markForSaveAcrossCalls() { mustSaveAcrossCalls = true; }
78
79 // inline void markForLoadFromStack() { mustLoadFromStack = true;
80
81
82 inline void setUserIGNode( IGNode *const IGN)
83 { assert( !UserIGNode); UserIGNode = IGN; }
84
85 inline IGNode * getUserIGNode() const
86 { return UserIGNode; } // NULL if the user is not allocated
87
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();
92 }
93
94
95 inline LiveRange() : ValueSet() , CallInterferenceList()
96 {
97 Color = -1; // not yet colored
98 mustSpill = mustSaveAcrossCalls = false;
99 MyRegClass = NULL;
100 UserIGNode = NULL;
101 }
102
103};
104
105
106
107
108
109#endif
110