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

Side by Side Diff: src/IceLiveness.h

Issue 300563003: Subzero: Initial O2 lowering (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Jan's third-round comments Created 6 years, 6 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
« no previous file with comments | « src/IceInst.cpp ('k') | src/IceLiveness.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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<InstNumberT> LiveBegin, LiveEnd;
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 getNumGlobalVars() const { return NumGlobals; }
61 SizeT getNumVarsInNode(const CfgNode *Node) const {
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<InstNumberT> &getLiveBegin(const CfgNode *Node) {
71 return Nodes[Node->getIndex()].LiveBegin;
72 }
73 std::vector<InstNumberT> &getLiveEnd(const CfgNode *Node) {
74 return Nodes[Node->getIndex()].LiveEnd;
75 }
76 LiveRange &getLiveRange(Variable *Var);
77 void addLiveRange(Variable *Var, InstNumberT Start, InstNumberT 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
OLDNEW
« no previous file with comments | « src/IceInst.cpp ('k') | src/IceLiveness.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698