| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 LiveBeginEndMap LiveBegin, LiveEnd; | 45 LiveBeginEndMap LiveBegin, LiveEnd; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 // TODO: Disable these constructors when Liveness::Nodes is no | 48 // TODO: Disable these constructors when Liveness::Nodes is no |
| 49 // longer an STL container. | 49 // longer an STL container. |
| 50 // LivenessNode(const LivenessNode &) = delete; | 50 // LivenessNode(const LivenessNode &) = delete; |
| 51 // LivenessNode &operator=(const LivenessNode &) = delete; | 51 // LivenessNode &operator=(const LivenessNode &) = delete; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 class Liveness { | 54 class Liveness { |
| 55 Liveness(const Liveness &) = delete; |
| 56 Liveness &operator=(const Liveness &) = delete; |
| 57 |
| 55 public: | 58 public: |
| 56 Liveness(Cfg *Func, LivenessMode Mode) | 59 Liveness(Cfg *Func, LivenessMode Mode) |
| 57 : Func(Func), Mode(Mode), NumGlobals(0) {} | 60 : Func(Func), Mode(Mode), NumGlobals(0) {} |
| 58 void init(); | 61 void init(); |
| 59 Cfg *getFunc() const { return Func; } | 62 Cfg *getFunc() const { return Func; } |
| 60 LivenessMode getMode() const { return Mode; } | 63 LivenessMode getMode() const { return Mode; } |
| 61 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const; | 64 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const; |
| 62 SizeT getLiveIndex(SizeT VarIndex) const { return VarToLiveMap[VarIndex]; } | 65 SizeT getLiveIndex(SizeT VarIndex) const { return VarToLiveMap[VarIndex]; } |
| 63 SizeT getNumGlobalVars() const { return NumGlobals; } | 66 SizeT getNumGlobalVars() const { return NumGlobals; } |
| 64 SizeT getNumVarsInNode(const CfgNode *Node) const { | 67 SizeT getNumVarsInNode(const CfgNode *Node) const { |
| 65 return NumGlobals + Nodes[Node->getIndex()].NumLocals; | 68 return NumGlobals + Nodes[Node->getIndex()].NumLocals; |
| 66 } | 69 } |
| 67 LivenessBV &getLiveIn(const CfgNode *Node) { | 70 LivenessBV &getLiveIn(const CfgNode *Node) { |
| 68 return Nodes[Node->getIndex()].LiveIn; | 71 return Nodes[Node->getIndex()].LiveIn; |
| 69 } | 72 } |
| 70 LivenessBV &getLiveOut(const CfgNode *Node) { | 73 LivenessBV &getLiveOut(const CfgNode *Node) { |
| 71 return Nodes[Node->getIndex()].LiveOut; | 74 return Nodes[Node->getIndex()].LiveOut; |
| 72 } | 75 } |
| 73 LiveBeginEndMap *getLiveBegin(const CfgNode *Node) { | 76 LiveBeginEndMap *getLiveBegin(const CfgNode *Node) { |
| 74 return &Nodes[Node->getIndex()].LiveBegin; | 77 return &Nodes[Node->getIndex()].LiveBegin; |
| 75 } | 78 } |
| 76 LiveBeginEndMap *getLiveEnd(const CfgNode *Node) { | 79 LiveBeginEndMap *getLiveEnd(const CfgNode *Node) { |
| 77 return &Nodes[Node->getIndex()].LiveEnd; | 80 return &Nodes[Node->getIndex()].LiveEnd; |
| 78 } | 81 } |
| 79 LiveRange &getLiveRange(Variable *Var); | |
| 80 void addLiveRange(Variable *Var, InstNumberT Start, InstNumberT End, | |
| 81 uint32_t WeightDelta); | |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 Cfg *Func; | 84 Cfg *Func; |
| 85 LivenessMode Mode; | 85 LivenessMode Mode; |
| 86 SizeT NumGlobals; | 86 SizeT NumGlobals; |
| 87 // Size of Nodes is Cfg::Nodes.size(). | 87 // Size of Nodes is Cfg::Nodes.size(). |
| 88 std::vector<LivenessNode> Nodes; | 88 std::vector<LivenessNode> Nodes; |
| 89 // VarToLiveMap maps a Variable's Variable::Number to its live index | 89 // VarToLiveMap maps a Variable's Variable::Number to its live index |
| 90 // within its basic block. | 90 // within its basic block. |
| 91 std::vector<SizeT> VarToLiveMap; | 91 std::vector<SizeT> VarToLiveMap; |
| 92 // LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for | 92 // LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for |
| 93 // non-local variables. | 93 // non-local variables. |
| 94 std::vector<Variable *> LiveToVarMap; | 94 std::vector<Variable *> LiveToVarMap; |
| 95 // LiveRanges maps a Variable::Number to its live range. | |
| 96 std::vector<LiveRange> LiveRanges; | |
| 97 Liveness(const Liveness &) = delete; | |
| 98 Liveness &operator=(const Liveness &) = delete; | |
| 99 }; | 95 }; |
| 100 | 96 |
| 101 } // end of namespace Ice | 97 } // end of namespace Ice |
| 102 | 98 |
| 103 #endif // SUBZERO_SRC_ICELIVENESS_H | 99 #endif // SUBZERO_SRC_ICELIVENESS_H |
| OLD | NEW |