blob: 2ab6252a87661d952614a3683e56b2477b5267d3 [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 */
Vladimir Marko75ba13f2014-01-28 12:15:24 +000026bool CodeLayout::WalkBasicBlocks(CompilationUnit* cUnit, BasicBlock* bb) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080027 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 */
Vladimir Marko75ba13f2014-01-28 12:15:24 +000035bool SSATransformation::WalkBasicBlocks(CompilationUnit* cUnit, BasicBlock* bb) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080036 cUnit->mir_graph->InsertPhiNodeOperands(bb);
37 // No need of repeating, so just return false.
38 return false;
39}
40
Vladimir Marko75ba13f2014-01-28 12:15:24 +000041void SSATransformation::End(CompilationUnit* cUnit) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080042 // 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 */
Vladimir Marko75ba13f2014-01-28 12:15:24 +000051bool ConstantPropagation::WalkBasicBlocks(CompilationUnit* cUnit, BasicBlock* bb) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080052 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 */
Vladimir Marko75ba13f2014-01-28 12:15:24 +000060bool MethodUseCount::Gate(const CompilationUnit* cUnit) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080061 // 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
Vladimir Marko75ba13f2014-01-28 12:15:24 +000070bool MethodUseCount::WalkBasicBlocks(CompilationUnit* cUnit, BasicBlock* bb) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080071 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
Vladimir Marko75ba13f2014-01-28 12:15:24 +000080bool NullCheckEliminationAndTypeInferenceInit::Gate(const CompilationUnit* cUnit) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080081 // 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
Vladimir Marko75ba13f2014-01-28 12:15:24 +000090bool NullCheckEliminationAndTypeInferenceInit::WalkBasicBlocks(CompilationUnit* cUnit,
91 BasicBlock* bb) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080092 cUnit->mir_graph->NullCheckEliminationInit(bb);
93 // No need of repeating, so just return false.
94 return false;
95}
96
97/*
98 * BasicBlock Combine pass implementation start.
99 */
Vladimir Marko75ba13f2014-01-28 12:15:24 +0000100bool BBCombine::WalkBasicBlocks(CompilationUnit* cUnit, BasicBlock* bb) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -0800101 cUnit->mir_graph->CombineBlocks(bb);
102
103 // No need of repeating, so just return false.
104 return false;
105}
106
107/*
108 * BasicBlock Optimization pass implementation start.
109 */
Vladimir Marko75ba13f2014-01-28 12:15:24 +0000110void BBOptimizations::Start(CompilationUnit* cUnit) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -0800111 /*
112 * This pass has a different ordering depEnding on the suppress exception,
113 * so do the pass here for now:
114 * - Later, the Start should just change the ordering and we can move the extended
115 * creation into the pass driver's main job with a new iterator
116 */
117 cUnit->mir_graph->BasicBlockOptimization();
118}
119
120} // namespace art