blob: c476b2aabcb0892d6ea4c83562c4fda47320c60a [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
17#include "base/macros.h"
18#include "bb_optimizations.h"
19#include "compiler_internals.h"
20#include "dataflow_iterator.h"
21#include "dataflow_iterator-inl.h"
22#include "pass_driver_me_opts.h"
Vladimir Marko7baa6f82014-10-09 18:01:24 +010023#include "post_opt_passes.h"
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070024
25namespace art {
26
27/*
28 * Create the pass list. These passes are immutable and are shared across the threads.
29 *
30 * Advantage is that there will be no race conditions here.
31 * Disadvantage is the passes can't change their internal states depending on CompilationUnit:
32 * - This is not yet an issue: no current pass would require it.
33 */
34// The initial list of passes to be used by the PassDriveMEOpts.
35template<>
36const Pass* const PassDriver<PassDriverMEOpts>::g_passes[] = {
37 GetPassInstance<CacheFieldLoweringInfo>(),
38 GetPassInstance<CacheMethodLoweringInfo>(),
Vladimir Marko7baa6f82014-10-09 18:01:24 +010039 GetPassInstance<CalculatePredecessors>(),
40 GetPassInstance<DFSOrders>(),
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070041 GetPassInstance<ClassInitCheckElimination>(),
Vladimir Marko7baa6f82014-10-09 18:01:24 +010042 GetPassInstance<SpecialMethodInliner>(),
43 GetPassInstance<NullCheckElimination>(),
Vladimir Marko312eb252014-10-07 15:01:57 +010044 GetPassInstance<BBCombine>(),
Vladimir Marko7baa6f82014-10-09 18:01:24 +010045 GetPassInstance<CodeLayout>(),
46 GetPassInstance<TypeInference>(),
Vladimir Marko95a05972014-05-30 10:01:32 +010047 GetPassInstance<GlobalValueNumberingPass>(),
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070048 GetPassInstance<BBOptimizations>(),
Vladimir Marko8b858e12014-11-27 14:52:37 +000049 GetPassInstance<SuspendCheckElimination>(),
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070050};
51
52// The number of the passes in the initial list of Passes (g_passes).
53template<>
54uint16_t const PassDriver<PassDriverMEOpts>::g_passes_size =
55 arraysize(PassDriver<PassDriverMEOpts>::g_passes);
56
57// The default pass list is used by the PassDriverME instance of PassDriver
58// to initialize pass_list_.
59template<>
60std::vector<const Pass*> PassDriver<PassDriverMEOpts>::g_default_pass_list(
61 PassDriver<PassDriverMEOpts>::g_passes,
62 PassDriver<PassDriverMEOpts>::g_passes +
63 PassDriver<PassDriverMEOpts>::g_passes_size);
64
65// By default, do not have a dump pass list.
66template<>
67std::string PassDriver<PassDriverMEOpts>::dump_pass_list_ = std::string();
68
69// By default, do not have a print pass list.
70template<>
71std::string PassDriver<PassDriverMEOpts>::print_pass_list_ = std::string();
72
73// By default, we do not print the pass' information.
74template<>
75bool PassDriver<PassDriverMEOpts>::default_print_passes_ = false;
76
Razvan A Lupusorubd25d4b2014-07-02 18:16:51 -070077// By default, there are no overridden pass settings.
78template<>
79std::string PassDriver<PassDriverMEOpts>::overridden_pass_options_list_ = std::string();
80
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070081void PassDriverMEOpts::ApplyPass(PassDataHolder* data, const Pass* pass) {
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070082 const PassME* pass_me = down_cast<const PassME*> (pass);
83 DCHECK(pass_me != nullptr);
84
85 PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data);
86
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070087 // Set to dirty.
88 pass_me_data_holder->dirty = true;
89
90 // First call the base class' version.
91 PassDriver::ApplyPass(data, pass);
92
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070093 // Now we care about flags.
94 if ((pass_me->GetFlag(kOptimizationBasicBlockChange) == true) ||
95 (pass_me->GetFlag(kOptimizationDefUsesChange) == true)) {
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070096 // Is it dirty at least?
97 if (pass_me_data_holder->dirty == true) {
Jean Christophe Beylerfbebc692014-09-02 14:22:17 -070098 CompilationUnit* c_unit = pass_me_data_holder->c_unit;
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070099 c_unit->mir_graph.get()->CalculateBasicBlockInformation();
100 }
Jean Christophe Beyler2469e602014-05-06 20:36:55 -0700101 }
102}
103
104} // namespace art