Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 //===- subzero/src/IceLiveness.h - Liveness analysis ------------*- C++ -*-===// | |
| 2 // | |
| 3 // The Subzero Code Generator | |
| 4 // | |
| 5 // This file is distributed under the University of Illinois Open Source | |
| 6 // License. See LICENSE.TXT for details. | |
| 7 // | |
| 8 //===----------------------------------------------------------------------===// | |
| 9 // | |
| 10 // This file declares the Liveness and LivenessNode classes, | |
| 11 // which are used for liveness analysis. The node-specific | |
| 12 // information tracked for each Variable includes whether it is | |
| 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 | |
| 15 // its live range. At the Cfg level, the actual live intervals are | |
| 16 // recorded. | |
| 17 // | |
| 18 //===----------------------------------------------------------------------===// | |
| 19 | |
| 20 #ifndef SUBZERO_SRC_ICELIVENESS_H | |
| 21 #define SUBZERO_SRC_ICELIVENESS_H | |
| 22 | |
| 23 #include "IceDefs.h" | |
| 24 #include "IceTypes.h" | |
| 25 | |
| 26 namespace Ice { | |
| 27 | |
| 28 class LivenessNode { | |
| 29 public: | |
| 30 LivenessNode() : NumLocals(0) {} | |
| 31 // NumLocals is the number of Variables local to this block. | |
| 32 SizeT NumLocals; | |
| 33 // LiveToVarMap maps a liveness bitvector index to a Variable. This | |
| 34 // is generally just for printing/dumping. The index should be less | |
| 35 // than NumLocals + Liveness::NumGlobals. | |
| 36 std::vector<Variable *> LiveToVarMap; | |
| 37 // LiveIn and LiveOut track the in- and out-liveness of the global | |
| 38 // variables. The size of each vector is | |
| 39 // LivenessNode::NumGlobals. | |
| 40 llvm::BitVector LiveIn, LiveOut; | |
| 41 // LiveBegin and LiveEnd track the instruction numbers of the start | |
| 42 // and end of each variable's live range within this block. The | |
| 43 // size of each vector is NumLocals + Liveness::NumGlobals. | |
| 44 std::vector<int> LiveBegin, LiveEnd; | |
|
jvoung (off chromium)
2014/05/30 15:41:31
int32_t to match InstNumber's usual type?
Jim Stichnoth
2014/05/30 23:06:18
Done. While I'm at it, I changed int32_t to Ice::
jvoung (off chromium)
2014/06/02 17:07:40
This instance is still "int"?
Jim Stichnoth
2014/06/04 14:18:03
<embarrassed>
Done. Also changed several int32_t
| |
| 45 | |
| 46 private: | |
| 47 // TODO: Disable these constructors when Liveness::Nodes is no | |
| 48 // longer an STL container. | |
| 49 // LivenessNode(const LivenessNode &) LLVM_DELETED_FUNCTION; | |
| 50 // LivenessNode &operator=(const LivenessNode &) LLVM_DELETED_FUNCTION; | |
| 51 }; | |
| 52 | |
| 53 class Liveness { | |
| 54 public: | |
| 55 Liveness(Cfg *Func, LivenessMode Mode) | |
| 56 : Func(Func), Mode(Mode), NumGlobals(0) {} | |
| 57 void init(); | |
| 58 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const; | |
| 59 SizeT getLiveIndex(const Variable *Var) const; | |
| 60 SizeT getGlobalSize() const { return NumGlobals; } | |
| 61 SizeT getLocalSize(const CfgNode *Node) const { | |
|
jvoung (off chromium)
2014/05/30 15:41:31
nit: Name seems a bit misleading since this has Nu
Jim Stichnoth
2014/05/30 23:06:18
Changed to getNumVarsInNode(). Also getGlobalSize
jvoung (off chromium)
2014/06/02 17:07:40
sgtm
| |
| 62 return NumGlobals + Nodes[Node->getIndex()].NumLocals; | |
| 63 } | |
| 64 llvm::BitVector &getLiveIn(const CfgNode *Node) { | |
| 65 return Nodes[Node->getIndex()].LiveIn; | |
| 66 } | |
| 67 llvm::BitVector &getLiveOut(const CfgNode *Node) { | |
| 68 return Nodes[Node->getIndex()].LiveOut; | |
| 69 } | |
| 70 std::vector<int> &getLiveBegin(const CfgNode *Node) { | |
| 71 return Nodes[Node->getIndex()].LiveBegin; | |
| 72 } | |
| 73 std::vector<int> &getLiveEnd(const CfgNode *Node) { | |
| 74 return Nodes[Node->getIndex()].LiveEnd; | |
| 75 } | |
| 76 LiveRange &getLiveRange(Variable *Var); | |
| 77 void addLiveRange(Variable *Var, int32_t Start, int32_t End, | |
| 78 uint32_t WeightDelta); | |
| 79 | |
| 80 private: | |
| 81 Cfg *Func; | |
| 82 LivenessMode Mode; | |
| 83 SizeT NumGlobals; | |
| 84 // Size of Nodes is Cfg::Nodes.size(). | |
| 85 std::vector<LivenessNode> Nodes; | |
| 86 // VarToLiveMap maps a Variable's Variable::Number to its live index | |
| 87 // within its basic block. | |
| 88 std::vector<SizeT> VarToLiveMap; | |
| 89 // LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for | |
| 90 // non-local variables. | |
| 91 std::vector<Variable *> LiveToVarMap; | |
| 92 // LiveRanges maps a Variable::Number to its live range. | |
| 93 std::vector<LiveRange> LiveRanges; | |
| 94 Liveness(const Liveness &) LLVM_DELETED_FUNCTION; | |
| 95 Liveness &operator=(const Liveness &) LLVM_DELETED_FUNCTION; | |
| 96 }; | |
| 97 | |
| 98 } // end of namespace Ice | |
| 99 | |
| 100 #endif // SUBZERO_SRC_ICELIVENESS_H | |
| OLD | NEW |