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

Side by Side Diff: src/IceCfg.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 | « crosstest/runtests.sh ('k') | src/IceCfg.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceCfg.h - Control flow graph ----------------*- C++ -*-===// 1 //===- subzero/src/IceCfg.h - Control flow graph ----------------*- 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 Cfg class, which represents the control flow 10 // This file declares the Cfg class, which represents the control flow
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 // Manage nodes (a.k.a. basic blocks, CfgNodes). 52 // Manage nodes (a.k.a. basic blocks, CfgNodes).
53 void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; } 53 void setEntryNode(CfgNode *EntryNode) { Entry = EntryNode; }
54 CfgNode *getEntryNode() const { return Entry; } 54 CfgNode *getEntryNode() const { return Entry; }
55 // Create a node and append it to the end of the linearized list. 55 // Create a node and append it to the end of the linearized list.
56 CfgNode *makeNode(const IceString &Name = ""); 56 CfgNode *makeNode(const IceString &Name = "");
57 SizeT getNumNodes() const { return Nodes.size(); } 57 SizeT getNumNodes() const { return Nodes.size(); }
58 const NodeList &getNodes() const { return Nodes; } 58 const NodeList &getNodes() const { return Nodes; }
59 59
60 // Manage instruction numbering. 60 // Manage instruction numbering.
61 int32_t newInstNumber() { return NextInstNumber++; } 61 InstNumberT newInstNumber() { return NextInstNumber++; }
62 62
63 // Manage Variables. 63 // Manage Variables.
64 Variable *makeVariable(Type Ty, const CfgNode *Node, 64 Variable *makeVariable(Type Ty, const CfgNode *Node,
65 const IceString &Name = ""); 65 const IceString &Name = "");
66 SizeT getNumVariables() const { return Variables.size(); } 66 SizeT getNumVariables() const { return Variables.size(); }
67 const VarList &getVariables() const { return Variables; } 67 const VarList &getVariables() const { return Variables; }
68 68
69 // Manage arguments to the function. 69 // Manage arguments to the function.
70 void addArg(Variable *Arg); 70 void addArg(Variable *Arg);
71 const VarList &getArgs() const { return Args; } 71 const VarList &getArgs() const { return Args; }
72 72
73 // Miscellaneous accessors. 73 // Miscellaneous accessors.
74 TargetLowering *getTarget() const { return Target.get(); } 74 TargetLowering *getTarget() const { return Target.get(); }
75 Liveness *getLiveness() const { return Live.get(); }
75 bool hasComputedFrame() const; 76 bool hasComputedFrame() const;
76 77
77 // Passes over the CFG. 78 // Passes over the CFG.
78 void translate(); 79 void translate();
79 // After the CFG is fully constructed, iterate over the nodes and 80 // After the CFG is fully constructed, iterate over the nodes and
80 // compute the predecessor edges, in the form of 81 // compute the predecessor edges, in the form of
81 // CfgNode::InEdges[]. 82 // CfgNode::InEdges[].
82 void computePredecessors(); 83 void computePredecessors();
84 void renumberInstructions();
83 void placePhiLoads(); 85 void placePhiLoads();
84 void placePhiStores(); 86 void placePhiStores();
85 void deletePhis(); 87 void deletePhis();
88 void doAddressOpt();
86 void genCode(); 89 void genCode();
87 void genFrame(); 90 void genFrame();
91 void livenessLightweight();
92 void liveness(LivenessMode Mode);
93 bool validateLiveness() const;
88 94
89 // Manage the CurrentNode field, which is used for validating the 95 // Manage the CurrentNode field, which is used for validating the
90 // Variable::DefNode field during dumping/emitting. 96 // Variable::DefNode field during dumping/emitting.
91 void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; } 97 void setCurrentNode(const CfgNode *Node) { CurrentNode = Node; }
92 const CfgNode *getCurrentNode() const { return CurrentNode; } 98 const CfgNode *getCurrentNode() const { return CurrentNode; }
93 99
94 void emit(); 100 void emit();
95 void dump(); 101 void dump(const IceString &Message = "");
96 102
97 // Allocate data of type T using the per-Cfg allocator. 103 // Allocate data of type T using the per-Cfg allocator.
98 template <typename T> T *allocate() { return Allocator.Allocate<T>(); } 104 template <typename T> T *allocate() { return Allocator.Allocate<T>(); }
99 105
100 // Allocate an instruction of type T using the per-Cfg instruction allocator. 106 // Allocate an instruction of type T using the per-Cfg instruction allocator.
101 template <typename T> T *allocateInst() { return Allocator.Allocate<T>(); } 107 template <typename T> T *allocateInst() { return Allocator.Allocate<T>(); }
102 108
103 // Allocate an array of data of type T using the per-Cfg allocator. 109 // Allocate an array of data of type T using the per-Cfg allocator.
104 template <typename T> T *allocateArrayOf(size_t NumElems) { 110 template <typename T> T *allocateArrayOf(size_t NumElems) {
105 return Allocator.Allocate<T>(NumElems); 111 return Allocator.Allocate<T>(NumElems);
(...skipping 23 matching lines...) Expand all
129 llvm::BumpPtrAllocator Allocator; 135 llvm::BumpPtrAllocator Allocator;
130 136
131 GlobalContext *Ctx; 137 GlobalContext *Ctx;
132 IceString FunctionName; 138 IceString FunctionName;
133 Type ReturnType; 139 Type ReturnType;
134 bool IsInternalLinkage; 140 bool IsInternalLinkage;
135 bool HasError; 141 bool HasError;
136 IceString ErrorMessage; 142 IceString ErrorMessage;
137 CfgNode *Entry; // entry basic block 143 CfgNode *Entry; // entry basic block
138 NodeList Nodes; // linearized node list; Entry should be first 144 NodeList Nodes; // linearized node list; Entry should be first
139 int32_t NextInstNumber; 145 InstNumberT NextInstNumber;
140 VarList Variables; 146 VarList Variables;
141 VarList Args; // subset of Variables, in argument order 147 VarList Args; // subset of Variables, in argument order
148 llvm::OwningPtr<Liveness> Live;
142 llvm::OwningPtr<TargetLowering> Target; 149 llvm::OwningPtr<TargetLowering> Target;
143 150
144 // CurrentNode is maintained during dumping/emitting just for 151 // CurrentNode is maintained during dumping/emitting just for
145 // validating Variable::DefNode. Normally, a traversal over 152 // validating Variable::DefNode. Normally, a traversal over
146 // CfgNodes maintains this, but before global operations like 153 // CfgNodes maintains this, but before global operations like
147 // register allocation, setCurrentNode(NULL) should be called to 154 // register allocation, setCurrentNode(NULL) should be called to
148 // avoid spurious validation failures. 155 // avoid spurious validation failures.
149 const CfgNode *CurrentNode; 156 const CfgNode *CurrentNode;
150 157
151 Cfg(const Cfg &) LLVM_DELETED_FUNCTION; 158 Cfg(const Cfg &) LLVM_DELETED_FUNCTION;
152 Cfg &operator=(const Cfg &) LLVM_DELETED_FUNCTION; 159 Cfg &operator=(const Cfg &) LLVM_DELETED_FUNCTION;
153 }; 160 };
154 161
155 } // end of namespace Ice 162 } // end of namespace Ice
156 163
157 #endif // SUBZERO_SRC_ICECFG_H 164 #endif // SUBZERO_SRC_ICECFG_H
OLDNEW
« no previous file with comments | « crosstest/runtests.sh ('k') | src/IceCfg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698