blob: c2b6b911b908e0edefb8a53817fb6dfadab477f4 [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"
Vladimir Marko7baa6f82014-10-09 18:01:24 +010024#include "post_opt_passes.h"
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070025
26namespace art {
27
28/*
29 * Create the pass list. These passes are immutable and are shared across the threads.
30 *
31 * Advantage is that there will be no race conditions here.
32 * Disadvantage is the passes can't change their internal states depending on CompilationUnit:
33 * - This is not yet an issue: no current pass would require it.
34 */
35// The initial list of passes to be used by the PassDriveMEOpts.
36template<>
37const Pass* const PassDriver<PassDriverMEOpts>::g_passes[] = {
38 GetPassInstance<CacheFieldLoweringInfo>(),
39 GetPassInstance<CacheMethodLoweringInfo>(),
Vladimir Marko7baa6f82014-10-09 18:01:24 +010040 GetPassInstance<CalculatePredecessors>(),
41 GetPassInstance<DFSOrders>(),
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070042 GetPassInstance<ClassInitCheckElimination>(),
Vladimir Marko7baa6f82014-10-09 18:01:24 +010043 GetPassInstance<SpecialMethodInliner>(),
44 GetPassInstance<NullCheckElimination>(),
Vladimir Marko312eb252014-10-07 15:01:57 +010045 GetPassInstance<BBCombine>(),
Vladimir Marko7baa6f82014-10-09 18:01:24 +010046 GetPassInstance<CodeLayout>(),
Vladimir Marko95a05972014-05-30 10:01:32 +010047 GetPassInstance<GlobalValueNumberingPass>(),
Vladimir Marko066f9e42015-01-16 16:04:43 +000048 GetPassInstance<ConstantPropagation>(),
49 GetPassInstance<MethodUseCount>(),
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070050 GetPassInstance<BBOptimizations>(),
Vladimir Marko8b858e12014-11-27 14:52:37 +000051 GetPassInstance<SuspendCheckElimination>(),
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070052};
53
54// The number of the passes in the initial list of Passes (g_passes).
55template<>
56uint16_t const PassDriver<PassDriverMEOpts>::g_passes_size =
57 arraysize(PassDriver<PassDriverMEOpts>::g_passes);
58
59// The default pass list is used by the PassDriverME instance of PassDriver
60// to initialize pass_list_.
61template<>
62std::vector<const Pass*> PassDriver<PassDriverMEOpts>::g_default_pass_list(
63 PassDriver<PassDriverMEOpts>::g_passes,
64 PassDriver<PassDriverMEOpts>::g_passes +
65 PassDriver<PassDriverMEOpts>::g_passes_size);
66
67// By default, do not have a dump pass list.
68template<>
69std::string PassDriver<PassDriverMEOpts>::dump_pass_list_ = std::string();
70
71// By default, do not have a print pass list.
72template<>
73std::string PassDriver<PassDriverMEOpts>::print_pass_list_ = std::string();
74
75// By default, we do not print the pass' information.
76template<>
77bool PassDriver<PassDriverMEOpts>::default_print_passes_ = false;
78
Razvan A Lupusorubd25d4b2014-07-02 18:16:51 -070079// By default, there are no overridden pass settings.
80template<>
81std::string PassDriver<PassDriverMEOpts>::overridden_pass_options_list_ = std::string();
82
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070083void PassDriverMEOpts::ApplyPass(PassDataHolder* data, const Pass* pass) {
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070084 const PassME* pass_me = down_cast<const PassME*> (pass);
85 DCHECK(pass_me != nullptr);
86
87 PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data);
88
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070089 // Set to dirty.
90 pass_me_data_holder->dirty = true;
91
92 // First call the base class' version.
93 PassDriver::ApplyPass(data, pass);
94
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070095 // Now we care about flags.
96 if ((pass_me->GetFlag(kOptimizationBasicBlockChange) == true) ||
97 (pass_me->GetFlag(kOptimizationDefUsesChange) == true)) {
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070098 // Is it dirty at least?
99 if (pass_me_data_holder->dirty == true) {
Jean Christophe Beylerfbebc692014-09-02 14:22:17 -0700100 CompilationUnit* c_unit = pass_me_data_holder->c_unit;
Jean Christophe Beyler09321df2014-07-18 15:33:57 -0700101 c_unit->mir_graph.get()->CalculateBasicBlockInformation();
102 }
Jean Christophe Beyler2469e602014-05-06 20:36:55 -0700103 }
104}
105
106} // namespace art