blob: abfa7a7eb7351b0c73a48b71fd5ba46beba0ea90 [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/*
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080077 * BasicBlock Combine pass implementation start.
78 */
Vladimir Marko75ba13f2014-01-28 12:15:24 +000079bool BBCombine::WalkBasicBlocks(CompilationUnit* cUnit, BasicBlock* bb) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080080 cUnit->mir_graph->CombineBlocks(bb);
81
82 // No need of repeating, so just return false.
83 return false;
84}
85
86/*
87 * BasicBlock Optimization pass implementation start.
88 */
Vladimir Marko75ba13f2014-01-28 12:15:24 +000089void BBOptimizations::Start(CompilationUnit* cUnit) const {
Jean Christophe Beyler4e97c532014-01-07 10:07:18 -080090 /*
91 * This pass has a different ordering depEnding on the suppress exception,
92 * so do the pass here for now:
93 * - Later, the Start should just change the ordering and we can move the extended
94 * creation into the pass driver's main job with a new iterator
95 */
96 cUnit->mir_graph->BasicBlockOptimization();
97}
98
99} // namespace art