OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 RUNTIME_VM_BRANCH_OPTIMIZER_H_ | 5 #ifndef RUNTIME_VM_BRANCH_OPTIMIZER_H_ |
6 #define RUNTIME_VM_BRANCH_OPTIMIZER_H_ | 6 #define RUNTIME_VM_BRANCH_OPTIMIZER_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 class FlowGraph; | 12 class FlowGraph; |
13 class JoinEntryInstr; | 13 class JoinEntryInstr; |
14 class Zone; | 14 class Zone; |
15 class TargetEntryInstr; | 15 class TargetEntryInstr; |
16 class Value; | 16 class Value; |
17 class BranchInstr; | 17 class BranchInstr; |
18 | 18 |
19 // Rewrite branches to eliminate materialization of boolean values after | 19 // Rewrite branches to eliminate materialization of boolean values after |
20 // inlining, and to expose other optimizations (e.g., constant folding of | 20 // inlining, and to expose other optimizations (e.g., constant folding of |
21 // branches, unreachable code elimination). | 21 // branches, unreachable code elimination). |
22 class BranchSimplifier : public AllStatic { | 22 class BranchSimplifier : public AllStatic { |
23 public: | 23 public: |
24 static void Simplify(FlowGraph* flow_graph); | 24 static void Simplify(FlowGraph* flow_graph); |
25 | 25 |
26 // Replace a target entry instruction with a join entry instruction. Does | 26 // Replace a target entry instruction with a join entry instruction. Does |
27 // not update the original target's predecessors to point to the new block | 27 // not update the original target's predecessors to point to the new block |
28 // and does not replace the target in already computed block order lists. | 28 // and does not replace the target in already computed block order lists. |
29 static JoinEntryInstr* ToJoinEntry(Zone* zone, | 29 static JoinEntryInstr* ToJoinEntry(Zone* zone, TargetEntryInstr* target); |
30 TargetEntryInstr* target); | |
31 | 30 |
32 private: | 31 private: |
33 // Match an instance of the pattern to rewrite. See the implementation | 32 // Match an instance of the pattern to rewrite. See the implementation |
34 // for the patterns that are handled by this pass. | 33 // for the patterns that are handled by this pass. |
35 static bool Match(JoinEntryInstr* block); | 34 static bool Match(JoinEntryInstr* block); |
36 | 35 |
37 // Duplicate a branch while replacing its comparison's left and right | 36 // Duplicate a branch while replacing its comparison's left and right |
38 // inputs. | 37 // inputs. |
39 static BranchInstr* CloneBranch(Zone* zone, | 38 static BranchInstr* CloneBranch(Zone* zone, |
40 BranchInstr* branch, | 39 BranchInstr* branch, |
41 Value* new_left, | 40 Value* new_left, |
42 Value* new_right); | 41 Value* new_right); |
43 }; | 42 }; |
44 | 43 |
45 | 44 |
46 // Rewrite diamond control flow patterns that materialize values to use more | 45 // Rewrite diamond control flow patterns that materialize values to use more |
47 // efficient branchless code patterns if such are supported on the current | 46 // efficient branchless code patterns if such are supported on the current |
48 // platform. | 47 // platform. |
49 class IfConverter : public AllStatic { | 48 class IfConverter : public AllStatic { |
50 public: | 49 public: |
51 static void Simplify(FlowGraph* flow_graph); | 50 static void Simplify(FlowGraph* flow_graph); |
52 }; | 51 }; |
53 | 52 |
54 } // namespace dart | 53 } // namespace dart |
55 | 54 |
56 #endif // RUNTIME_VM_BRANCH_OPTIMIZER_H_ | 55 #endif // RUNTIME_VM_BRANCH_OPTIMIZER_H_ |
OLD | NEW |