OLD | NEW |
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 }; | 281 }; |
282 | 282 |
283 | 283 |
284 // Rewrite branches to eliminate materialization of boolean values after | 284 // Rewrite branches to eliminate materialization of boolean values after |
285 // inlining, and to expose other optimizations (e.g., constant folding of | 285 // inlining, and to expose other optimizations (e.g., constant folding of |
286 // branches, unreachable code elimination). | 286 // branches, unreachable code elimination). |
287 class BranchSimplifier : public AllStatic { | 287 class BranchSimplifier : public AllStatic { |
288 public: | 288 public: |
289 static void Simplify(FlowGraph* flow_graph); | 289 static void Simplify(FlowGraph* flow_graph); |
290 | 290 |
| 291 // Replace a target entry instruction with a join entry instruction. Does |
| 292 // not update the original target's predecessors to point to the new block |
| 293 // and does not replace the target in already computed block order lists. |
| 294 static JoinEntryInstr* ToJoinEntry(TargetEntryInstr* target); |
| 295 |
291 private: | 296 private: |
292 // Match an instance of the pattern to rewrite. See the implementation | 297 // Match an instance of the pattern to rewrite. See the implementation |
293 // for the patterns that are handled by this pass. | 298 // for the patterns that are handled by this pass. |
294 static bool Match(JoinEntryInstr* block); | 299 static bool Match(JoinEntryInstr* block); |
295 | 300 |
296 // Replace a target entry instruction with a join entry instruction. Does | |
297 // not update the original target's predecessors to point to the new block | |
298 // and does not replace the target in already computed block order lists. | |
299 static JoinEntryInstr* ToJoinEntry(TargetEntryInstr* target); | |
300 | |
301 // Duplicate a constant, assigning it a new SSA name. | 301 // Duplicate a constant, assigning it a new SSA name. |
302 static ConstantInstr* CloneConstant(FlowGraph* flow_graph, | 302 static ConstantInstr* CloneConstant(FlowGraph* flow_graph, |
303 ConstantInstr* constant); | 303 ConstantInstr* constant); |
304 | 304 |
305 // Duplicate a branch while replacing its comparison's left and right | 305 // Duplicate a branch while replacing its comparison's left and right |
306 // inputs. | 306 // inputs. |
307 static BranchInstr* CloneBranch(BranchInstr* branch, | 307 static BranchInstr* CloneBranch(BranchInstr* branch, |
308 Value* left, | 308 Value* left, |
309 Value* right); | 309 Value* right); |
310 }; | 310 }; |
311 | 311 |
312 | 312 |
313 // Rewrite diamond control flow patterns that materialize values to use more | 313 // Rewrite diamond control flow patterns that materialize values to use more |
314 // efficient branchless code patterns if such are supported on the current | 314 // efficient branchless code patterns if such are supported on the current |
315 // platform. | 315 // platform. |
316 class IfConverter : public AllStatic { | 316 class IfConverter : public AllStatic { |
317 public: | 317 public: |
318 static void Simplify(FlowGraph* flow_graph); | 318 static void Simplify(FlowGraph* flow_graph); |
319 }; | 319 }; |
320 | 320 |
321 | 321 |
322 } // namespace dart | 322 } // namespace dart |
323 | 323 |
324 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 324 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |