blob: 8c8bde63ea5789ea145c06d4e7b56500f28ebabe [file] [log] [blame]
Jean Christophe Beyler2469e602014-05-06 20:36:55 -07001/*
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
Andreas Gampe0b9203e2015-01-22 20:39:27 -080017#include "pass_driver_me_opts.h"
18
19#include "base/logging.h"
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070020#include "base/macros.h"
21#include "bb_optimizations.h"
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070022#include "dataflow_iterator.h"
23#include "dataflow_iterator-inl.h"
Mathieu Chartier5bdab122015-01-26 18:30:19 -080024#include "pass_driver_me_opts.h"
25#include "pass_manager.h"
Vladimir Marko7baa6f82014-10-09 18:01:24 +010026#include "post_opt_passes.h"
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070027
28namespace art {
29
Mathieu Chartier5bdab122015-01-26 18:30:19 -080030void PassDriverMEOpts::SetupPasses(PassManager* pass_manager) {
31 /*
32 * Create the pass list. These passes are immutable and are shared across the threads.
33 *
34 * Advantage is that there will be no race conditions here.
35 * Disadvantage is the passes can't change their internal states depending on CompilationUnit:
36 * - This is not yet an issue: no current pass would require it.
37 */
38 pass_manager->AddPass(new CacheFieldLoweringInfo);
39 pass_manager->AddPass(new CacheMethodLoweringInfo);
40 pass_manager->AddPass(new CalculatePredecessors);
41 pass_manager->AddPass(new DFSOrders);
42 pass_manager->AddPass(new ClassInitCheckElimination);
43 pass_manager->AddPass(new SpecialMethodInliner);
44 pass_manager->AddPass(new NullCheckElimination);
45 pass_manager->AddPass(new BBCombine);
46 pass_manager->AddPass(new CodeLayout);
47 pass_manager->AddPass(new GlobalValueNumberingPass);
48 pass_manager->AddPass(new ConstantPropagation);
49 pass_manager->AddPass(new MethodUseCount);
50 pass_manager->AddPass(new BBOptimizations);
51 pass_manager->AddPass(new SuspendCheckElimination);
52}
Razvan A Lupusorubd25d4b2014-07-02 18:16:51 -070053
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070054void PassDriverMEOpts::ApplyPass(PassDataHolder* data, const Pass* pass) {
Mathieu Chartier5bdab122015-01-26 18:30:19 -080055 const PassME* const pass_me = down_cast<const PassME*>(pass);
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070056 DCHECK(pass_me != nullptr);
Mathieu Chartier5bdab122015-01-26 18:30:19 -080057 PassMEDataHolder* const pass_me_data_holder = down_cast<PassMEDataHolder*>(data);
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070058 // Set to dirty.
59 pass_me_data_holder->dirty = true;
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070060 // First call the base class' version.
61 PassDriver::ApplyPass(data, pass);
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070062 // Now we care about flags.
63 if ((pass_me->GetFlag(kOptimizationBasicBlockChange) == true) ||
64 (pass_me->GetFlag(kOptimizationDefUsesChange) == true)) {
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070065 // Is it dirty at least?
66 if (pass_me_data_holder->dirty == true) {
Jean Christophe Beylerfbebc692014-09-02 14:22:17 -070067 CompilationUnit* c_unit = pass_me_data_holder->c_unit;
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070068 c_unit->mir_graph.get()->CalculateBasicBlockInformation();
69 }
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070070 }
71}
72
73} // namespace art