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

Side by Side Diff: runtime/vm/flow_graph_optimizer.h

Issue 12540002: Implement a branch optimization pass. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_ 5 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_
6 #define VM_FLOW_GRAPH_OPTIMIZER_H_ 6 #define VM_FLOW_GRAPH_OPTIMIZER_H_
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 #include "vm/flow_graph.h" 9 #include "vm/flow_graph.h"
10 10
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // indicate that they are already on the worklist in order to avoid adding 253 // indicate that they are already on the worklist in order to avoid adding
254 // them again. Indexed by SSA temp index. 254 // them again. Indexed by SSA temp index.
255 BitVector* definition_marks_; 255 BitVector* definition_marks_;
256 256
257 // Worklists of blocks and definitions. 257 // Worklists of blocks and definitions.
258 GrowableArray<BlockEntryInstr*> block_worklist_; 258 GrowableArray<BlockEntryInstr*> block_worklist_;
259 GrowableArray<Definition*> definition_worklist_; 259 GrowableArray<Definition*> definition_worklist_;
260 }; 260 };
261 261
262 262
263 // Rewrite branches to eliminate materialization of boolean values after
264 // inlining, and to expose other optimizations (e.g., constant folding of
265 // branches, unreachable code elimination).
266 class BranchSimplifier : public AllStatic {
267 public:
268 static void Simplify(FlowGraph* flow_graph);
269
270 private:
271 // Match an instance of the pattern to rewrite. See the implementation
272 // for the patterns that are handled by this pass.
273 static bool Match(JoinEntryInstr* block);
274
275 // Replace a target entry instruction with a join entry instruction. Does
276 // not update the original target's predecessors to point to the new block
277 // and does not replace the target in already computed block order lists.
278 static JoinEntryInstr* ToJoinEntry(TargetEntryInstr* target);
279
280 // Duplicate a constant, assigning it a new SSA name.
281 static ConstantInstr* CloneConstant(FlowGraph* flow_graph,
282 ConstantInstr* constant);
283
284 // Duplicate a branch while replacing its comparison's left and right
285 // inputs.
286 static BranchInstr* RewriteBranch(BranchInstr* branch,
287 Value* left,
288 Value* right);
289 };
290
291
263 } // namespace dart 292 } // namespace dart
264 293
265 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ 294 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698