OLD | NEW |
1 //===- subzero/src/IceLiveness.h - Liveness analysis ------------*- C++ -*-===// | 1 //===- subzero/src/IceLiveness.h - Liveness analysis ------------*- C++ -*-===// |
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 declares the Liveness and LivenessNode classes, | 10 // This file declares the Liveness and LivenessNode classes, |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 class Liveness { | 28 class Liveness { |
29 Liveness() = delete; | 29 Liveness() = delete; |
30 Liveness(const Liveness &) = delete; | 30 Liveness(const Liveness &) = delete; |
31 Liveness &operator=(const Liveness &) = delete; | 31 Liveness &operator=(const Liveness &) = delete; |
32 | 32 |
33 class LivenessNode { | 33 class LivenessNode { |
34 LivenessNode &operator=(const LivenessNode &) = delete; | 34 LivenessNode &operator=(const LivenessNode &) = delete; |
35 | 35 |
36 public: | 36 public: |
37 LivenessNode() : NumLocals(0), NumNonDeadPhis(0) {} | 37 LivenessNode() = default; |
38 LivenessNode(const LivenessNode &) = default; | 38 LivenessNode(const LivenessNode &) = default; |
39 // NumLocals is the number of Variables local to this block. | 39 // NumLocals is the number of Variables local to this block. |
40 SizeT NumLocals; | 40 SizeT NumLocals = 0; |
41 // NumNonDeadPhis tracks the number of Phi instructions that | 41 // NumNonDeadPhis tracks the number of Phi instructions that |
42 // Inst::liveness() identified as tentatively live. If | 42 // Inst::liveness() identified as tentatively live. If |
43 // NumNonDeadPhis changes from the last liveness pass, then liveness | 43 // NumNonDeadPhis changes from the last liveness pass, then liveness |
44 // has not yet converged. | 44 // has not yet converged. |
45 SizeT NumNonDeadPhis; | 45 SizeT NumNonDeadPhis = 0; |
46 // LiveToVarMap maps a liveness bitvector index to a Variable. This | 46 // LiveToVarMap maps a liveness bitvector index to a Variable. This |
47 // is generally just for printing/dumping. The index should be less | 47 // is generally just for printing/dumping. The index should be less |
48 // than NumLocals + Liveness::NumGlobals. | 48 // than NumLocals + Liveness::NumGlobals. |
49 std::vector<Variable *> LiveToVarMap; | 49 std::vector<Variable *> LiveToVarMap; |
50 // LiveIn and LiveOut track the in- and out-liveness of the global | 50 // LiveIn and LiveOut track the in- and out-liveness of the global |
51 // variables. The size of each vector is | 51 // variables. The size of each vector is |
52 // LivenessNode::NumGlobals. | 52 // LivenessNode::NumGlobals. |
53 LivenessBV LiveIn, LiveOut; | 53 LivenessBV LiveIn, LiveOut; |
54 // LiveBegin and LiveEnd track the instruction numbers of the start | 54 // LiveBegin and LiveEnd track the instruction numbers of the start |
55 // and end of each variable's live range within this block. The | 55 // and end of each variable's live range within this block. The |
56 // index/key of each element is less than NumLocals + | 56 // index/key of each element is less than NumLocals + |
57 // Liveness::NumGlobals. | 57 // Liveness::NumGlobals. |
58 LiveBeginEndMap LiveBegin, LiveEnd; | 58 LiveBeginEndMap LiveBegin, LiveEnd; |
59 }; | 59 }; |
60 | 60 |
61 public: | 61 public: |
62 Liveness(Cfg *Func, LivenessMode Mode) | 62 Liveness(Cfg *Func, LivenessMode Mode) : Func(Func), Mode(Mode) {} |
63 : Func(Func), Mode(Mode), NumGlobals(0) {} | |
64 void init(); | 63 void init(); |
65 Cfg *getFunc() const { return Func; } | 64 Cfg *getFunc() const { return Func; } |
66 LivenessMode getMode() const { return Mode; } | 65 LivenessMode getMode() const { return Mode; } |
67 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const; | 66 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const; |
68 SizeT getLiveIndex(SizeT VarIndex) const { return VarToLiveMap[VarIndex]; } | 67 SizeT getLiveIndex(SizeT VarIndex) const { return VarToLiveMap[VarIndex]; } |
69 SizeT getNumGlobalVars() const { return NumGlobals; } | 68 SizeT getNumGlobalVars() const { return NumGlobals; } |
70 SizeT getNumVarsInNode(const CfgNode *Node) const { | 69 SizeT getNumVarsInNode(const CfgNode *Node) const { |
71 return NumGlobals + Nodes[Node->getIndex()].NumLocals; | 70 return NumGlobals + Nodes[Node->getIndex()].NumLocals; |
72 } | 71 } |
73 SizeT &getNumNonDeadPhis(const CfgNode *Node) { | 72 SizeT &getNumNonDeadPhis(const CfgNode *Node) { |
(...skipping 21 matching lines...) Expand all Loading... |
95 } | 94 } |
96 | 95 |
97 private: | 96 private: |
98 // Resize Nodes so that Nodes[Index] is valid. | 97 // Resize Nodes so that Nodes[Index] is valid. |
99 void resize(SizeT Index) { | 98 void resize(SizeT Index) { |
100 if (Index >= Nodes.size()) | 99 if (Index >= Nodes.size()) |
101 Nodes.resize(Index + 1); | 100 Nodes.resize(Index + 1); |
102 } | 101 } |
103 Cfg *Func; | 102 Cfg *Func; |
104 LivenessMode Mode; | 103 LivenessMode Mode; |
105 SizeT NumGlobals; | 104 SizeT NumGlobals = 0; |
106 // Size of Nodes is Cfg::Nodes.size(). | 105 // Size of Nodes is Cfg::Nodes.size(). |
107 std::vector<LivenessNode> Nodes; | 106 std::vector<LivenessNode> Nodes; |
108 // VarToLiveMap maps a Variable's Variable::Number to its live index | 107 // VarToLiveMap maps a Variable's Variable::Number to its live index |
109 // within its basic block. | 108 // within its basic block. |
110 std::vector<SizeT> VarToLiveMap; | 109 std::vector<SizeT> VarToLiveMap; |
111 // LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for | 110 // LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for |
112 // non-local variables. | 111 // non-local variables. |
113 std::vector<Variable *> LiveToVarMap; | 112 std::vector<Variable *> LiveToVarMap; |
114 }; | 113 }; |
115 | 114 |
116 } // end of namespace Ice | 115 } // end of namespace Ice |
117 | 116 |
118 #endif // SUBZERO_SRC_ICELIVENESS_H | 117 #endif // SUBZERO_SRC_ICELIVENESS_H |
OLD | NEW |