Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
branch_optimizer.h
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_COMPILER_BACKEND_BRANCH_OPTIMIZER_H_
6#define RUNTIME_VM_COMPILER_BACKEND_BRANCH_OPTIMIZER_H_
7
8#if defined(DART_PRECOMPILED_RUNTIME)
9#error "AOT runtime should not use compiler sources (including header files)"
10#endif // defined(DART_PRECOMPILED_RUNTIME)
11
12#include "vm/allocation.h"
13
14namespace dart {
15
16class BlockEntryInstr;
17class FlowGraph;
18class FunctionEntryInstr;
19class JoinEntryInstr;
20class Zone;
21class TargetEntryInstr;
22class Value;
23class BranchInstr;
24
25// Rewrite branches to eliminate materialization of boolean values after
26// inlining, and to expose other optimizations (e.g., constant folding of
27// branches, unreachable code elimination).
29 public:
30 static void Simplify(FlowGraph* flow_graph);
31
32 // Replace a block entry instruction with a join entry instruction. Does
33 // not update the original target's predecessors to point to the new block
34 // and does not replace the target in already computed block order lists.
36
37 // Replace a block entry instruction with a target entry instruction. Does
38 // not update the original target's predecessors to point to the new block and
39 // does not replace the target in already computed block order lists.
41
42 private:
43 // Match an instance of the pattern to rewrite. See the implementation
44 // for the patterns that are handled by this pass.
45 static bool Match(JoinEntryInstr* block);
46
47 // Duplicate a branch while replacing its comparison's left and right
48 // inputs.
49 static BranchInstr* CloneBranch(Zone* zone,
50 BranchInstr* branch,
51 Value* new_left,
52 Value* new_right);
53};
54
55// Rewrite diamond control flow patterns that materialize values to use more
56// efficient branchless code patterns if such are supported on the current
57// platform.
58class IfConverter : public AllStatic {
59 public:
60 static void Simplify(FlowGraph* flow_graph);
61};
62
63} // namespace dart
64
65#endif // RUNTIME_VM_COMPILER_BACKEND_BRANCH_OPTIMIZER_H_
static TargetEntryInstr * ToTargetEntry(Zone *zone, BlockEntryInstr *target)
static JoinEntryInstr * ToJoinEntry(Zone *zone, BlockEntryInstr *target)
static void Simplify(FlowGraph *flow_graph)
static void Simplify(FlowGraph *flow_graph)
uint32_t * target