| 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, |
| 11 // which are used for liveness analysis. The node-specific | 11 // which are used for liveness analysis. The node-specific |
| 12 // information tracked for each Variable includes whether it is | 12 // information tracked for each Variable includes whether it is |
| 13 // live on entry, whether it is live on exit, the instruction number | 13 // live on entry, whether it is live on exit, the instruction number |
| 14 // that starts its live range, and the instruction number that ends | 14 // that starts its live range, and the instruction number that ends |
| 15 // its live range. At the Cfg level, the actual live intervals are | 15 // its live range. At the Cfg level, the actual live intervals are |
| 16 // recorded. | 16 // recorded. |
| 17 // | 17 // |
| 18 //===----------------------------------------------------------------------===// | 18 //===----------------------------------------------------------------------===// |
| 19 | 19 |
| 20 #ifndef SUBZERO_SRC_ICELIVENESS_H | 20 #ifndef SUBZERO_SRC_ICELIVENESS_H |
| 21 #define SUBZERO_SRC_ICELIVENESS_H | 21 #define SUBZERO_SRC_ICELIVENESS_H |
| 22 | 22 |
| 23 #include "IceDefs.h" | 23 #include "IceDefs.h" |
| 24 #include "IceTypes.h" | 24 #include "IceTypes.h" |
| 25 | 25 |
| 26 namespace Ice { | 26 namespace Ice { |
| 27 | 27 |
| 28 class LivenessNode { | |
| 29 // TODO: Disable these constructors when Liveness::Nodes is no | |
| 30 // longer an STL container. | |
| 31 // LivenessNode(const LivenessNode &) = delete; | |
| 32 // LivenessNode &operator=(const LivenessNode &) = delete; | |
| 33 | |
| 34 public: | |
| 35 LivenessNode() : NumLocals(0), NumNonDeadPhis(0) {} | |
| 36 // NumLocals is the number of Variables local to this block. | |
| 37 SizeT NumLocals; | |
| 38 // NumNonDeadPhis tracks the number of Phi instructions that | |
| 39 // Inst::liveness() identified as tentatively live. If | |
| 40 // NumNonDeadPhis changes from the last liveness pass, then liveness | |
| 41 // has not yet converged. | |
| 42 SizeT NumNonDeadPhis; | |
| 43 // LiveToVarMap maps a liveness bitvector index to a Variable. This | |
| 44 // is generally just for printing/dumping. The index should be less | |
| 45 // than NumLocals + Liveness::NumGlobals. | |
| 46 std::vector<Variable *> LiveToVarMap; | |
| 47 // LiveIn and LiveOut track the in- and out-liveness of the global | |
| 48 // variables. The size of each vector is | |
| 49 // LivenessNode::NumGlobals. | |
| 50 LivenessBV LiveIn, LiveOut; | |
| 51 // LiveBegin and LiveEnd track the instruction numbers of the start | |
| 52 // and end of each variable's live range within this block. The | |
| 53 // index/key of each element is less than NumLocals + | |
| 54 // Liveness::NumGlobals. | |
| 55 LiveBeginEndMap LiveBegin, LiveEnd; | |
| 56 }; | |
| 57 | |
| 58 class Liveness { | 28 class Liveness { |
| 59 Liveness(const Liveness &) = delete; | 29 Liveness(const Liveness &) = delete; |
| 60 Liveness &operator=(const Liveness &) = delete; | 30 Liveness &operator=(const Liveness &) = delete; |
| 61 | 31 |
| 32 class LivenessNode { |
| 33 LivenessNode &operator=(const LivenessNode &) = delete; |
| 34 |
| 35 public: |
| 36 LivenessNode() : NumLocals(0), NumNonDeadPhis(0) {} |
| 37 LivenessNode(const LivenessNode &) = default; |
| 38 // NumLocals is the number of Variables local to this block. |
| 39 SizeT NumLocals; |
| 40 // NumNonDeadPhis tracks the number of Phi instructions that |
| 41 // Inst::liveness() identified as tentatively live. If |
| 42 // NumNonDeadPhis changes from the last liveness pass, then liveness |
| 43 // has not yet converged. |
| 44 SizeT NumNonDeadPhis; |
| 45 // LiveToVarMap maps a liveness bitvector index to a Variable. This |
| 46 // is generally just for printing/dumping. The index should be less |
| 47 // than NumLocals + Liveness::NumGlobals. |
| 48 std::vector<Variable *> LiveToVarMap; |
| 49 // LiveIn and LiveOut track the in- and out-liveness of the global |
| 50 // variables. The size of each vector is |
| 51 // LivenessNode::NumGlobals. |
| 52 LivenessBV LiveIn, LiveOut; |
| 53 // LiveBegin and LiveEnd track the instruction numbers of the start |
| 54 // and end of each variable's live range within this block. The |
| 55 // index/key of each element is less than NumLocals + |
| 56 // Liveness::NumGlobals. |
| 57 LiveBeginEndMap LiveBegin, LiveEnd; |
| 58 }; |
| 59 |
| 62 public: | 60 public: |
| 63 Liveness(Cfg *Func, LivenessMode Mode) | 61 Liveness(Cfg *Func, LivenessMode Mode) |
| 64 : Func(Func), Mode(Mode), NumGlobals(0) {} | 62 : Func(Func), Mode(Mode), NumGlobals(0) {} |
| 65 void init(); | 63 void init(); |
| 66 Cfg *getFunc() const { return Func; } | 64 Cfg *getFunc() const { return Func; } |
| 67 LivenessMode getMode() const { return Mode; } | 65 LivenessMode getMode() const { return Mode; } |
| 68 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const; | 66 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const; |
| 69 SizeT getLiveIndex(SizeT VarIndex) const { return VarToLiveMap[VarIndex]; } | 67 SizeT getLiveIndex(SizeT VarIndex) const { return VarToLiveMap[VarIndex]; } |
| 70 SizeT getNumGlobalVars() const { return NumGlobals; } | 68 SizeT getNumGlobalVars() const { return NumGlobals; } |
| 71 SizeT getNumVarsInNode(const CfgNode *Node) const { | 69 SizeT getNumVarsInNode(const CfgNode *Node) const { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // within its basic block. | 108 // within its basic block. |
| 111 std::vector<SizeT> VarToLiveMap; | 109 std::vector<SizeT> VarToLiveMap; |
| 112 // LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for | 110 // LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for |
| 113 // non-local variables. | 111 // non-local variables. |
| 114 std::vector<Variable *> LiveToVarMap; | 112 std::vector<Variable *> LiveToVarMap; |
| 115 }; | 113 }; |
| 116 | 114 |
| 117 } // end of namespace Ice | 115 } // end of namespace Ice |
| 118 | 116 |
| 119 #endif // SUBZERO_SRC_ICELIVENESS_H | 117 #endif // SUBZERO_SRC_ICELIVENESS_H |
| OLD | NEW |