llvm.org GIT mirror llvm / 0d82a54
* Order #includes as per style guide * Doxygen-ify comments * Make code layout more consistent git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9431 91177308-0d34-0410-b5e6-96231b3b80d8 Misha Brukman 16 years ago
6 changed file(s) with 90 addition(s) and 92 deletion(s). Raw diff Collapse all Expand all
1717 #ifndef LIVERANGE_H
1818 #define LIVERANGE_H
1919
20 #include "llvm/Value.h"
2021 #include "llvm/CodeGen/ValueSet.h"
21 #include "llvm/Value.h"
2222
2323 class RegClass;
2424 class IGNode;
2525
2626 class LiveRange : public ValueSet {
27 RegClass *MyRegClass; // register classs (e.g., int, FP) for this LR
27 RegClass *MyRegClass; // register class (e.g., int, FP) for this LR
2828
29 // doesSpanAcrossCalls - Does this live range span across calls?
30 // This information is used by graph
31 // coloring algo to avoid allocating volatile colors to live ranges
32 // that span across calls (since they have to be saved/restored)
33 //
29 /// doesSpanAcrossCalls - Does this live range span across calls?
30 /// This information is used by graph coloring algo to avoid allocating
31 /// volatile colors to live ranges that span across calls (since they have to
32 /// be saved/restored)
33 ///
3434 bool doesSpanAcrossCalls;
3535
3636 IGNode *UserIGNode; // IGNode which uses this LR
3737 int Color; // color assigned to this live range
3838 bool mustSpill; // whether this LR must be spilt
3939
40 // mustSaveAcrossCalls - whether this LR must be saved accross calls
41 // ***TODO REMOVE this
42 //
40 /// mustSaveAcrossCalls - whether this LR must be saved accross calls
41 /// ***TODO REMOVE this
42 ///
4343 bool mustSaveAcrossCalls;
4444
45 // SuggestedColor - if this LR has a suggested color, can it be
46 // really alloated? A suggested color cannot be allocated when the
47 // suggested color is volatile and when there are call
48 // interferences.
49 //
45 /// SuggestedColor - if this LR has a suggested color, can it be
46 /// really alloated? A suggested color cannot be allocated when the
47 /// suggested color is volatile and when there are call
48 /// interferences.
49 ///
5050 int SuggestedColor; // The suggested color for this LR
5151
52 // CanUseSuggestedCol - It is possible that a suggested color for
53 // this live range is not available before graph coloring (e.g., it
54 // can be allocated to another live range which interferes with
55 // this)
56 //
52 /// CanUseSuggestedCol - It is possible that a suggested color for
53 /// this live range is not available before graph coloring (e.g., it
54 /// can be allocated to another live range which interferes with
55 /// this)
56 ///
5757 bool CanUseSuggestedCol;
5858
59 // SpilledStackOffsetFromFP - If this LR is spilled, its stack
60 // offset from *FP*. The spilled offsets must always be relative to
61 // the FP.
62 //
59 /// SpilledStackOffsetFromFP - If this LR is spilled, its stack
60 /// offset from *FP*. The spilled offsets must always be relative to
61 /// the FP.
62 ///
6363 int SpilledStackOffsetFromFP;
6464
65 // HasSpillOffset 0 Whether this live range has a spill offset
66 //
65 /// HasSpillOffset 0 Whether this live range has a spill offset
66 ///
6767 bool HasSpillOffset;
6868
69 // The spill cost of this live range. Calculated using loop depth of
70 // each reference to each Value in the live range
71 //
69 /// The spill cost of this live range. Calculated using loop depth of
70 /// each reference to each Value in the live range
71 ///
7272 unsigned SpillCost;
7373
7474 public:
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "IGNode.h"
1314 #include "LiveRangeInfo.h"
1415 #include "RegAllocCommon.h"
1516 #include "RegClass.h"
16 #include "IGNode.h"
17 #include "llvm/Function.h"
1718 #include "llvm/CodeGen/MachineInstr.h"
1819 #include "llvm/CodeGen/MachineFunction.h"
1920 #include "llvm/Target/TargetMachine.h"
2021 #include "llvm/Target/TargetInstrInfo.h"
2122 #include "llvm/Target/TargetRegInfo.h"
22 #include "llvm/Function.h"
2323 #include "Support/SetOperations.h"
2424
2525 unsigned LiveRange::getRegClassID() const { return getRegClass()->getID(); }
216216 }
217217
218218 } // for all machine instructions in the BB
219
220219 } // for all BBs in function
221220
222221 // Now we have to suggest clors for call and return arg live ranges.
277276 // Checks if live range LR interferes with any node assigned or suggested to
278277 // be assigned the specified color
279278 //
280 inline bool InterferesWithColor(const LiveRange& LR, unsigned color)
281 {
279 inline bool InterferesWithColor(const LiveRange& LR, unsigned color) {
282280 IGNode* lrNode = LR.getUserIGNode();
283281 for (unsigned n=0, NN = lrNode->getNumOfNeighbors(); n < NN; n++) {
284282 LiveRange *neighLR = lrNode->getAdjIGNode(n)->getParentLR();
298296 // (4) LR2 has color and LR1 interferes with any LR that has the same color
299297 //
300298 inline bool InterfsPreventCoalescing(const LiveRange& LROfDef,
301 const LiveRange& LROfUse)
302 {
299 const LiveRange& LROfUse) {
303300 // (4) if they have different suggested colors, cannot coalesce
304301 if (LROfDef.hasSuggestedColor() && LROfUse.hasSuggestedColor())
305302 return true;
8686 std::vector & RCList);
8787
8888
89 // Destructor to destroy all LiveRanges in the LiveRange Map
89 /// Destructor to destroy all LiveRanges in the LiveRange Map
90 ///
9091 ~LiveRangeInfo();
9192
9293 // Main entry point for live range construction
9394 //
9495 void constructLiveRanges();
9596
96 // return the common live range map for this method
97 //
97 /// return the common live range map for this method
98 ///
9899 inline const LiveRangeMapType *getLiveRangeMap() const
99100 { return &LiveRangeMap; }
100101
101 // Method used to get the live range containing a Value.
102 // This may return NULL if no live range exists for a Value (eg, some consts)
102 /// Method used to get the live range containing a Value.
103 /// This may return NULL if no live range exists for a Value (eg, some consts)
104 ///
103105 inline LiveRange *getLiveRangeForValue(const Value *Val) {
104106 return LiveRangeMap[Val];
105107 }
108110 return I->second;
109111 }
110112
111 // Method for coalescing live ranges. Called only after interference info
112 // is calculated.
113 //
113 /// Method for coalescing live ranges. Called only after interference info
114 /// is calculated.
115 ///
114116 void coalesceLRs();
115117
116 // debugging method to print the live ranges
117 //
118 /// debugging method to print the live ranges
119 ///
118120 void printLiveRanges();
119121 };
120122
1717 #ifndef LIVERANGE_H
1818 #define LIVERANGE_H
1919
20 #include "llvm/Value.h"
2021 #include "llvm/CodeGen/ValueSet.h"
21 #include "llvm/Value.h"
2222
2323 class RegClass;
2424 class IGNode;
2525
2626 class LiveRange : public ValueSet {
27 RegClass *MyRegClass; // register classs (e.g., int, FP) for this LR
27 RegClass *MyRegClass; // register class (e.g., int, FP) for this LR
2828
29 // doesSpanAcrossCalls - Does this live range span across calls?
30 // This information is used by graph
31 // coloring algo to avoid allocating volatile colors to live ranges
32 // that span across calls (since they have to be saved/restored)
33 //
29 /// doesSpanAcrossCalls - Does this live range span across calls?
30 /// This information is used by graph coloring algo to avoid allocating
31 /// volatile colors to live ranges that span across calls (since they have to
32 /// be saved/restored)
33 ///
3434 bool doesSpanAcrossCalls;
3535
3636 IGNode *UserIGNode; // IGNode which uses this LR
3737 int Color; // color assigned to this live range
3838 bool mustSpill; // whether this LR must be spilt
3939
40 // mustSaveAcrossCalls - whether this LR must be saved accross calls
41 // ***TODO REMOVE this
42 //
40 /// mustSaveAcrossCalls - whether this LR must be saved accross calls
41 /// ***TODO REMOVE this
42 ///
4343 bool mustSaveAcrossCalls;
4444
45 // SuggestedColor - if this LR has a suggested color, can it be
46 // really alloated? A suggested color cannot be allocated when the
47 // suggested color is volatile and when there are call
48 // interferences.
49 //
45 /// SuggestedColor - if this LR has a suggested color, can it be
46 /// really alloated? A suggested color cannot be allocated when the
47 /// suggested color is volatile and when there are call
48 /// interferences.
49 ///
5050 int SuggestedColor; // The suggested color for this LR
5151
52 // CanUseSuggestedCol - It is possible that a suggested color for
53 // this live range is not available before graph coloring (e.g., it
54 // can be allocated to another live range which interferes with
55 // this)
56 //
52 /// CanUseSuggestedCol - It is possible that a suggested color for
53 /// this live range is not available before graph coloring (e.g., it
54 /// can be allocated to another live range which interferes with
55 /// this)
56 ///
5757 bool CanUseSuggestedCol;
5858
59 // SpilledStackOffsetFromFP - If this LR is spilled, its stack
60 // offset from *FP*. The spilled offsets must always be relative to
61 // the FP.
62 //
59 /// SpilledStackOffsetFromFP - If this LR is spilled, its stack
60 /// offset from *FP*. The spilled offsets must always be relative to
61 /// the FP.
62 ///
6363 int SpilledStackOffsetFromFP;
6464
65 // HasSpillOffset 0 Whether this live range has a spill offset
66 //
65 /// HasSpillOffset 0 Whether this live range has a spill offset
66 ///
6767 bool HasSpillOffset;
6868
69 // The spill cost of this live range. Calculated using loop depth of
70 // each reference to each Value in the live range
71 //
69 /// The spill cost of this live range. Calculated using loop depth of
70 /// each reference to each Value in the live range
71 ///
7272 unsigned SpillCost;
7373
7474 public:
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "IGNode.h"
1314 #include "LiveRangeInfo.h"
1415 #include "RegAllocCommon.h"
1516 #include "RegClass.h"
16 #include "IGNode.h"
17 #include "llvm/Function.h"
1718 #include "llvm/CodeGen/MachineInstr.h"
1819 #include "llvm/CodeGen/MachineFunction.h"
1920 #include "llvm/Target/TargetMachine.h"
2021 #include "llvm/Target/TargetInstrInfo.h"
2122 #include "llvm/Target/TargetRegInfo.h"
22 #include "llvm/Function.h"
2323 #include "Support/SetOperations.h"
2424
2525 unsigned LiveRange::getRegClassID() const { return getRegClass()->getID(); }
216216 }
217217
218218 } // for all machine instructions in the BB
219
220219 } // for all BBs in function
221220
222221 // Now we have to suggest clors for call and return arg live ranges.
277276 // Checks if live range LR interferes with any node assigned or suggested to
278277 // be assigned the specified color
279278 //
280 inline bool InterferesWithColor(const LiveRange& LR, unsigned color)
281 {
279 inline bool InterferesWithColor(const LiveRange& LR, unsigned color) {
282280 IGNode* lrNode = LR.getUserIGNode();
283281 for (unsigned n=0, NN = lrNode->getNumOfNeighbors(); n < NN; n++) {
284282 LiveRange *neighLR = lrNode->getAdjIGNode(n)->getParentLR();
298296 // (4) LR2 has color and LR1 interferes with any LR that has the same color
299297 //
300298 inline bool InterfsPreventCoalescing(const LiveRange& LROfDef,
301 const LiveRange& LROfUse)
302 {
299 const LiveRange& LROfUse) {
303300 // (4) if they have different suggested colors, cannot coalesce
304301 if (LROfDef.hasSuggestedColor() && LROfUse.hasSuggestedColor())
305302 return true;
8686 std::vector & RCList);
8787
8888
89 // Destructor to destroy all LiveRanges in the LiveRange Map
89 /// Destructor to destroy all LiveRanges in the LiveRange Map
90 ///
9091 ~LiveRangeInfo();
9192
9293 // Main entry point for live range construction
9394 //
9495 void constructLiveRanges();
9596
96 // return the common live range map for this method
97 //
97 /// return the common live range map for this method
98 ///
9899 inline const LiveRangeMapType *getLiveRangeMap() const
99100 { return &LiveRangeMap; }
100101
101 // Method used to get the live range containing a Value.
102 // This may return NULL if no live range exists for a Value (eg, some consts)
102 /// Method used to get the live range containing a Value.
103 /// This may return NULL if no live range exists for a Value (eg, some consts)
104 ///
103105 inline LiveRange *getLiveRangeForValue(const Value *Val) {
104106 return LiveRangeMap[Val];
105107 }
108110 return I->second;
109111 }
110112
111 // Method for coalescing live ranges. Called only after interference info
112 // is calculated.
113 //
113 /// Method for coalescing live ranges. Called only after interference info
114 /// is calculated.
115 ///
114116 void coalesceLRs();
115117
116 // debugging method to print the live ranges
117 //
118 /// debugging method to print the live ranges
119 ///
118120 void printLiveRanges();
119121 };
120122