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