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