pass_driver_me_opts.cc revision 2469e60e6ff08c2a0b4cd1e209246c5d91027679
1/*
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>(),
38  GetPassInstance<CallInlining>(),
39  GetPassInstance<CodeLayout>(),
40  GetPassInstance<NullCheckEliminationAndTypeInference>(),
41  GetPassInstance<ClassInitCheckElimination>(),
42  GetPassInstance<BBCombine>(),
43  GetPassInstance<BBOptimizations>(),
44};
45
46// The number of the passes in the initial list of Passes (g_passes).
47template<>
48uint16_t const PassDriver<PassDriverMEOpts>::g_passes_size =
49    arraysize(PassDriver<PassDriverMEOpts>::g_passes);
50
51// The default pass list is used by the PassDriverME instance of PassDriver
52// to initialize pass_list_.
53template<>
54std::vector<const Pass*> PassDriver<PassDriverMEOpts>::g_default_pass_list(
55    PassDriver<PassDriverMEOpts>::g_passes,
56    PassDriver<PassDriverMEOpts>::g_passes +
57    PassDriver<PassDriverMEOpts>::g_passes_size);
58
59// By default, do not have a dump pass list.
60template<>
61std::string PassDriver<PassDriverMEOpts>::dump_pass_list_ = std::string();
62
63// By default, do not have a print pass list.
64template<>
65std::string PassDriver<PassDriverMEOpts>::print_pass_list_ = std::string();
66
67// By default, we do not print the pass' information.
68template<>
69bool PassDriver<PassDriverMEOpts>::default_print_passes_ = false;
70
71void PassDriverMEOpts::ApplyPass(PassDataHolder* data, const Pass* pass) {
72  // First call the base class' version.
73  PassDriver::ApplyPass(data, pass);
74
75  const PassME* pass_me = down_cast<const PassME*> (pass);
76  DCHECK(pass_me != nullptr);
77
78  PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data);
79
80  // Now we care about flags.
81  if ((pass_me->GetFlag(kOptimizationBasicBlockChange) == true) ||
82      (pass_me->GetFlag(kOptimizationDefUsesChange) == true)) {
83    CompilationUnit* c_unit = pass_me_data_holder->c_unit;
84    c_unit->mir_graph.get()->CalculateBasicBlockInformation();
85  }
86}
87
88}  // namespace art
89