OLD | NEW |
1 //===- subzero/src/IceLiveness.cpp - Liveness analysis implementation -----===// | 1 //===- subzero/src/IceLiveness.cpp - Liveness analysis implementation -----===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file provides some of the support for the Liveness class. In | 10 // This file provides some of the support for the Liveness class. In |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace Ice { | 29 namespace Ice { |
30 | 30 |
31 void Liveness::init() { | 31 void Liveness::init() { |
32 // Initialize most of the container sizes. | 32 // Initialize most of the container sizes. |
33 SizeT NumVars = Func->getVariables().size(); | 33 SizeT NumVars = Func->getVariables().size(); |
34 SizeT NumNodes = Func->getNumNodes(); | 34 SizeT NumNodes = Func->getNumNodes(); |
35 VariablesMetadata *VMetadata = Func->getVMetadata(); | 35 VariablesMetadata *VMetadata = Func->getVMetadata(); |
36 Nodes.resize(NumNodes); | 36 Nodes.resize(NumNodes); |
37 VarToLiveMap.resize(NumVars); | 37 VarToLiveMap.resize(NumVars); |
38 if (Mode == Liveness_Intervals) | |
39 LiveRanges.resize(NumVars); | |
40 | 38 |
41 // Count the number of globals, and the number of locals for each | 39 // Count the number of globals, and the number of locals for each |
42 // block. | 40 // block. |
43 for (SizeT i = 0; i < NumVars; ++i) { | 41 for (SizeT i = 0; i < NumVars; ++i) { |
44 Variable *Var = Func->getVariables()[i]; | 42 Variable *Var = Func->getVariables()[i]; |
45 if (VMetadata->isMultiBlock(Var)) { | 43 if (VMetadata->isMultiBlock(Var)) { |
46 ++NumGlobals; | 44 ++NumGlobals; |
47 } else { | 45 } else { |
48 SizeT Index = VMetadata->getLocalUseNode(Var)->getIndex(); | 46 SizeT Index = VMetadata->getLocalUseNode(Var)->getIndex(); |
49 ++Nodes[Index].NumLocals; | 47 ++Nodes[Index].NumLocals; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 89 } |
92 } | 90 } |
93 | 91 |
94 Variable *Liveness::getVariable(SizeT LiveIndex, const CfgNode *Node) const { | 92 Variable *Liveness::getVariable(SizeT LiveIndex, const CfgNode *Node) const { |
95 if (LiveIndex < NumGlobals) | 93 if (LiveIndex < NumGlobals) |
96 return LiveToVarMap[LiveIndex]; | 94 return LiveToVarMap[LiveIndex]; |
97 SizeT NodeIndex = Node->getIndex(); | 95 SizeT NodeIndex = Node->getIndex(); |
98 return Nodes[NodeIndex].LiveToVarMap[LiveIndex - NumGlobals]; | 96 return Nodes[NodeIndex].LiveToVarMap[LiveIndex - NumGlobals]; |
99 } | 97 } |
100 | 98 |
101 void Liveness::addLiveRange(Variable *Var, InstNumberT Start, InstNumberT End, | |
102 uint32_t WeightDelta) { | |
103 LiveRange &LiveRange = LiveRanges[Var->getIndex()]; | |
104 assert(WeightDelta != RegWeight::Inf); | |
105 LiveRange.addSegment(Start, End); | |
106 LiveRange.addWeight(WeightDelta); | |
107 } | |
108 | |
109 LiveRange &Liveness::getLiveRange(Variable *Var) { | |
110 return LiveRanges[Var->getIndex()]; | |
111 } | |
112 | |
113 } // end of namespace Ice | 99 } // end of namespace Ice |
OLD | NEW |