| 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 23 matching lines...) Expand all Loading... |
| 34 SizeT NumNodes = Func->getNumNodes(); | 34 SizeT NumNodes = Func->getNumNodes(); |
| 35 Nodes.resize(NumNodes); | 35 Nodes.resize(NumNodes); |
| 36 VarToLiveMap.resize(NumVars); | 36 VarToLiveMap.resize(NumVars); |
| 37 if (Mode == Liveness_Intervals) | 37 if (Mode == Liveness_Intervals) |
| 38 LiveRanges.resize(NumVars); | 38 LiveRanges.resize(NumVars); |
| 39 | 39 |
| 40 // Count the number of globals, and the number of locals for each | 40 // Count the number of globals, and the number of locals for each |
| 41 // block. | 41 // block. |
| 42 for (SizeT i = 0; i < NumVars; ++i) { | 42 for (SizeT i = 0; i < NumVars; ++i) { |
| 43 Variable *Var = Func->getVariables()[i]; | 43 Variable *Var = Func->getVariables()[i]; |
| 44 if (Var->isMultiblockLife()) { | 44 if (Func->getVMetadata()->isMultiBlock(Var)) { |
| 45 ++NumGlobals; | 45 ++NumGlobals; |
| 46 } else { | 46 } else { |
| 47 SizeT Index = Var->getLocalUseNode()->getIndex(); | 47 SizeT Index = Func->getVMetadata()->getLocalUseNode(Var)->getIndex(); |
| 48 ++Nodes[Index].NumLocals; | 48 ++Nodes[Index].NumLocals; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Resize each LivenessNode::LiveToVarMap, and the global | 52 // Resize each LivenessNode::LiveToVarMap, and the global |
| 53 // LiveToVarMap. Reset the counts to 0. | 53 // LiveToVarMap. Reset the counts to 0. |
| 54 for (SizeT i = 0; i < NumNodes; ++i) { | 54 for (SizeT i = 0; i < NumNodes; ++i) { |
| 55 Nodes[i].LiveToVarMap.assign(Nodes[i].NumLocals, NULL); | 55 Nodes[i].LiveToVarMap.assign(Nodes[i].NumLocals, NULL); |
| 56 Nodes[i].NumLocals = 0; | 56 Nodes[i].NumLocals = 0; |
| 57 } | 57 } |
| 58 LiveToVarMap.assign(NumGlobals, NULL); | 58 LiveToVarMap.assign(NumGlobals, NULL); |
| 59 | 59 |
| 60 // Sort each variable into the appropriate LiveToVarMap. Also set | 60 // Sort each variable into the appropriate LiveToVarMap. Also set |
| 61 // VarToLiveMap. | 61 // VarToLiveMap. |
| 62 SizeT TmpNumGlobals = 0; | 62 SizeT TmpNumGlobals = 0; |
| 63 for (SizeT i = 0; i < NumVars; ++i) { | 63 for (SizeT i = 0; i < NumVars; ++i) { |
| 64 Variable *Var = Func->getVariables()[i]; | 64 Variable *Var = Func->getVariables()[i]; |
| 65 SizeT VarIndex = Var->getIndex(); | 65 SizeT VarIndex = Var->getIndex(); |
| 66 SizeT LiveIndex; | 66 SizeT LiveIndex; |
| 67 if (Var->isMultiblockLife()) { | 67 if (Func->getVMetadata()->isMultiBlock(Var)) { |
| 68 LiveIndex = TmpNumGlobals++; | 68 LiveIndex = TmpNumGlobals++; |
| 69 LiveToVarMap[LiveIndex] = Var; | 69 LiveToVarMap[LiveIndex] = Var; |
| 70 } else { | 70 } else { |
| 71 SizeT NodeIndex = Var->getLocalUseNode()->getIndex(); | 71 SizeT NodeIndex = Func->getVMetadata()->getLocalUseNode(Var)->getIndex(); |
| 72 LiveIndex = Nodes[NodeIndex].NumLocals++; | 72 LiveIndex = Nodes[NodeIndex].NumLocals++; |
| 73 Nodes[NodeIndex].LiveToVarMap[LiveIndex] = Var; | 73 Nodes[NodeIndex].LiveToVarMap[LiveIndex] = Var; |
| 74 LiveIndex += NumGlobals; | 74 LiveIndex += NumGlobals; |
| 75 } | 75 } |
| 76 VarToLiveMap[VarIndex] = LiveIndex; | 76 VarToLiveMap[VarIndex] = LiveIndex; |
| 77 } | 77 } |
| 78 assert(NumGlobals == TmpNumGlobals); | 78 assert(NumGlobals == TmpNumGlobals); |
| 79 | 79 |
| 80 // Process each node. | 80 // Process each node. |
| 81 const NodeList &LNodes = Func->getNodes(); | 81 const NodeList &LNodes = Func->getNodes(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 107 assert(WeightDelta != RegWeight::Inf); | 107 assert(WeightDelta != RegWeight::Inf); |
| 108 LiveRange.addSegment(Start, End); | 108 LiveRange.addSegment(Start, End); |
| 109 LiveRange.addWeight(WeightDelta); | 109 LiveRange.addWeight(WeightDelta); |
| 110 } | 110 } |
| 111 | 111 |
| 112 LiveRange &Liveness::getLiveRange(Variable *Var) { | 112 LiveRange &Liveness::getLiveRange(Variable *Var) { |
| 113 return LiveRanges[Var->getIndex()]; | 113 return LiveRanges[Var->getIndex()]; |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // end of namespace Ice | 116 } // end of namespace Ice |
| OLD | NEW |