blob: f0130674b5cbcd94958078c2b9c34d42b167fc04 [file] [log] [blame]
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "bb_optimizations.h"
18#include "dataflow_iterator.h"
19#include "dataflow_iterator-inl.h"
20
21namespace art {
22
23/*
24 * Code Layout pass implementation start.
25 */
26bool CodeLayout::WalkBasicBlocks(CompilationUnit *cUnit, BasicBlock *bb) const {
27 cUnit->mir_graph->LayoutBlocks(bb);
28 // No need of repeating, so just return false.
29 return false;
30}
31
32/*
33 * SSATransformation pass implementation start.
34 */
35bool SSATransformation::WalkBasicBlocks(CompilationUnit *cUnit, BasicBlock *bb) const {
36 cUnit->mir_graph->InsertPhiNodeOperands(bb);
37 // No need of repeating, so just return false.
38 return false;
39}
40
41void SSATransformation::End(CompilationUnit *cUnit) const {
42 // Verify the dataflow information after the pass.
43 if (cUnit->enable_debug & (1 << kDebugVerifyDataflow)) {
44 cUnit->mir_graph->VerifyDataflow();
45 }
46}
47
48/*
49 * ConstantPropagation pass implementation start
50 */
51bool ConstantPropagation::WalkBasicBlocks(CompilationUnit *cUnit, BasicBlock *bb) const {
52 cUnit->mir_graph->DoConstantPropagation(bb);
53 // No need of repeating, so just return false.
54 return false;
55}
56
57/*
58 * MethodUseCount pass implementation start.
59 */
60bool MethodUseCount::Gate(const CompilationUnit *cUnit) const {
61 // First initialize the data.
62 cUnit->mir_graph->InitializeMethodUses();
63
64 // Now check if the pass is to be ignored.
65 bool res = ((cUnit->disable_opt & (1 << kPromoteRegs)) == 0);
66
67 return res;
68}
69
70bool MethodUseCount::WalkBasicBlocks(CompilationUnit *cUnit, BasicBlock *bb) const {
71 cUnit->mir_graph->CountUses(bb);
72 // No need of repeating, so just return false.
73 return false;
74}
75
76/*
77 * Null Check Elimination and Type Inference Initialization pass implementation start.
78 */
79
80bool NullCheckEliminationAndTypeInferenceInit::Gate(const CompilationUnit *cUnit) const {
81 // First check the ssa register vector
82 cUnit->mir_graph->CheckSSARegisterVector();
83
84 // Did we disable the pass?
85 bool performInit = ((cUnit->disable_opt & (1 << kNullCheckElimination)) == 0);
86
87 return performInit;
88}
89
90bool NullCheckEliminationAndTypeInferenceInit::WalkBasicBlocks(CompilationUnit *cUnit, BasicBlock *bb) const {
91 cUnit->mir_graph->NullCheckEliminationInit(bb);
92 // No need of repeating, so just return false.
93 return false;
94}
95
96/*
97 * BasicBlock Combine pass implementation start.
98 */
99bool BBCombine::WalkBasicBlocks(CompilationUnit *cUnit, BasicBlock *bb) const {
100 cUnit->mir_graph->CombineBlocks(bb);
101
102 // No need of repeating, so just return false.
103 return false;
104}
105
106/*
107 * BasicBlock Optimization pass implementation start.
108 */
109void BBOptimizations::Start(CompilationUnit *cUnit) const {
110 DCHECK_EQ(cUnit->num_compiler_temps, 0);
111
112 /*
113 * This pass has a different ordering depEnding on the suppress exception,
114 * so do the pass here for now:
115 * - Later, the Start should just change the ordering and we can move the extended
116 * creation into the pass driver's main job with a new iterator
117 */
118 cUnit->mir_graph->BasicBlockOptimization();
119}
120
121} // namespace art