blob: cd3ffd4cc834a8506d3d351f904cd0a531b57272 [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"
23
24namespace art {
25
26/*
27 * Create the pass list. These passes are immutable and are shared across the threads.
28 *
29 * Advantage is that there will be no race conditions here.
30 * Disadvantage is the passes can't change their internal states depending on CompilationUnit:
31 * - This is not yet an issue: no current pass would require it.
32 */
33// The initial list of passes to be used by the PassDriveMEOpts.
34template<>
35const Pass* const PassDriver<PassDriverMEOpts>::g_passes[] = {
36 GetPassInstance<CacheFieldLoweringInfo>(),
37 GetPassInstance<CacheMethodLoweringInfo>(),
Razvan A Lupusorucb804742014-07-09 16:42:19 -070038 GetPassInstance<SpecialMethodInliner>(),
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070039 GetPassInstance<CodeLayout>(),
Vladimir Marko67c72b82014-10-09 12:26:10 +010040 GetPassInstance<NullCheckElimination>(),
41 GetPassInstance<TypeInference>(),
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070042 GetPassInstance<ClassInitCheckElimination>(),
Vladimir Marko95a05972014-05-30 10:01:32 +010043 GetPassInstance<GlobalValueNumberingPass>(),
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070044 GetPassInstance<BBCombine>(),
45 GetPassInstance<BBOptimizations>(),
46};
47
48// The number of the passes in the initial list of Passes (g_passes).
49template<>
50uint16_t const PassDriver<PassDriverMEOpts>::g_passes_size =
51 arraysize(PassDriver<PassDriverMEOpts>::g_passes);
52
53// The default pass list is used by the PassDriverME instance of PassDriver
54// to initialize pass_list_.
55template<>
56std::vector<const Pass*> PassDriver<PassDriverMEOpts>::g_default_pass_list(
57 PassDriver<PassDriverMEOpts>::g_passes,
58 PassDriver<PassDriverMEOpts>::g_passes +
59 PassDriver<PassDriverMEOpts>::g_passes_size);
60
61// By default, do not have a dump pass list.
62template<>
63std::string PassDriver<PassDriverMEOpts>::dump_pass_list_ = std::string();
64
65// By default, do not have a print pass list.
66template<>
67std::string PassDriver<PassDriverMEOpts>::print_pass_list_ = std::string();
68
69// By default, we do not print the pass' information.
70template<>
71bool PassDriver<PassDriverMEOpts>::default_print_passes_ = false;
72
Razvan A Lupusorubd25d4b2014-07-02 18:16:51 -070073// By default, there are no overridden pass settings.
74template<>
75std::string PassDriver<PassDriverMEOpts>::overridden_pass_options_list_ = std::string();
76
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070077void PassDriverMEOpts::ApplyPass(PassDataHolder* data, const Pass* pass) {
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070078 const PassME* pass_me = down_cast<const PassME*> (pass);
79 DCHECK(pass_me != nullptr);
80
81 PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data);
82
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070083 // Set to dirty.
84 pass_me_data_holder->dirty = true;
85
86 // First call the base class' version.
87 PassDriver::ApplyPass(data, pass);
88
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070089 // Now we care about flags.
90 if ((pass_me->GetFlag(kOptimizationBasicBlockChange) == true) ||
91 (pass_me->GetFlag(kOptimizationDefUsesChange) == true)) {
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070092 // Is it dirty at least?
93 if (pass_me_data_holder->dirty == true) {
Jean Christophe Beylerfbebc692014-09-02 14:22:17 -070094 CompilationUnit* c_unit = pass_me_data_holder->c_unit;
Jean Christophe Beyler09321df2014-07-18 15:33:57 -070095 c_unit->mir_graph.get()->CalculateBasicBlockInformation();
96 }
Jean Christophe Beyler2469e602014-05-06 20:36:55 -070097 }
98}
99
100} // namespace art