Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: src/IceLiveness.h

Issue 1253833002: Subzero: Cleanly implement register allocation after phi lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Cleanup Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /// \file 10 /// \file
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // LiveBegin and LiveEnd track the instruction numbers of the start 56 // LiveBegin and LiveEnd track the instruction numbers of the start
57 // and end of each variable's live range within this block. The 57 // and end of each variable's live range within this block. The
58 // index/key of each element is less than NumLocals + 58 // index/key of each element is less than NumLocals +
59 // Liveness::NumGlobals. 59 // Liveness::NumGlobals.
60 LiveBeginEndMap LiveBegin, LiveEnd; 60 LiveBeginEndMap LiveBegin, LiveEnd;
61 }; 61 };
62 62
63 public: 63 public:
64 Liveness(Cfg *Func, LivenessMode Mode) : Func(Func), Mode(Mode) {} 64 Liveness(Cfg *Func, LivenessMode Mode) : Func(Func), Mode(Mode) {}
65 void init(); 65 void init();
66 void initPhiEdgeSplits(NodeList::const_iterator FirstNode,
67 VarList::const_iterator FirstVar);
66 Cfg *getFunc() const { return Func; } 68 Cfg *getFunc() const { return Func; }
67 LivenessMode getMode() const { return Mode; } 69 LivenessMode getMode() const { return Mode; }
68 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const; 70 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const;
69 SizeT getLiveIndex(SizeT VarIndex) const { return VarToLiveMap[VarIndex]; } 71 SizeT getLiveIndex(SizeT VarIndex) const { return VarToLiveMap[VarIndex]; }
70 SizeT getNumGlobalVars() const { return NumGlobals; } 72 SizeT getNumGlobalVars() const { return NumGlobals; }
71 SizeT getNumVarsInNode(const CfgNode *Node) const { 73 SizeT getNumVarsInNode(const CfgNode *Node) const {
72 return NumGlobals + Nodes[Node->getIndex()].NumLocals; 74 return NumGlobals + Nodes[Node->getIndex()].NumLocals;
73 } 75 }
74 SizeT &getNumNonDeadPhis(const CfgNode *Node) { 76 SizeT &getNumNonDeadPhis(const CfgNode *Node) {
75 return Nodes[Node->getIndex()].NumNonDeadPhis; 77 return Nodes[Node->getIndex()].NumNonDeadPhis;
(...skipping 13 matching lines...) Expand all
89 resize(Index); 91 resize(Index);
90 return &Nodes[Index].LiveBegin; 92 return &Nodes[Index].LiveBegin;
91 } 93 }
92 LiveBeginEndMap *getLiveEnd(const CfgNode *Node) { 94 LiveBeginEndMap *getLiveEnd(const CfgNode *Node) {
93 SizeT Index = Node->getIndex(); 95 SizeT Index = Node->getIndex();
94 resize(Index); 96 resize(Index);
95 return &Nodes[Index].LiveEnd; 97 return &Nodes[Index].LiveEnd;
96 } 98 }
97 99
98 private: 100 private:
101 void initInternal(NodeList::const_iterator FirstNode,
102 VarList::const_iterator FirstVar, bool IsFullInit);
99 /// Resize Nodes so that Nodes[Index] is valid. 103 /// Resize Nodes so that Nodes[Index] is valid.
100 void resize(SizeT Index) { 104 void resize(SizeT Index) {
101 if (Index >= Nodes.size()) 105 if (Index >= Nodes.size())
102 Nodes.resize(Index + 1); 106 Nodes.resize(Index + 1);
103 } 107 }
104 Cfg *Func; 108 Cfg *Func;
105 LivenessMode Mode; 109 LivenessMode Mode;
106 SizeT NumGlobals = 0; 110 SizeT NumGlobals = 0;
107 /// Size of Nodes is Cfg::Nodes.size(). 111 /// Size of Nodes is Cfg::Nodes.size().
108 std::vector<LivenessNode> Nodes; 112 std::vector<LivenessNode> Nodes;
109 /// VarToLiveMap maps a Variable's Variable::Number to its live index 113 /// VarToLiveMap maps a Variable's Variable::Number to its live index
110 /// within its basic block. 114 /// within its basic block.
111 std::vector<SizeT> VarToLiveMap; 115 std::vector<SizeT> VarToLiveMap;
112 /// LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for 116 /// LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for
113 /// non-local variables. 117 /// non-local variables.
114 std::vector<Variable *> LiveToVarMap; 118 std::vector<Variable *> LiveToVarMap;
115 }; 119 };
116 120
117 } // end of namespace Ice 121 } // end of namespace Ice
118 122
119 #endif // SUBZERO_SRC_ICELIVENESS_H 123 #endif // SUBZERO_SRC_ICELIVENESS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698