Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 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 | |
Andreas Gampe | 0b9203e | 2015-01-22 20:39:27 -0800 | [diff] [blame] | 17 | #include "pass_driver_me_opts.h" |
| 18 | |
| 19 | #include "base/logging.h" |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 20 | #include "base/macros.h" |
| 21 | #include "bb_optimizations.h" |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 22 | #include "dataflow_iterator.h" |
| 23 | #include "dataflow_iterator-inl.h" |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 24 | #include "pass_driver_me_opts.h" |
| 25 | #include "pass_manager.h" |
Vladimir Marko | 7baa6f8 | 2014-10-09 18:01:24 +0100 | [diff] [blame] | 26 | #include "post_opt_passes.h" |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 27 | |
| 28 | namespace art { |
| 29 | |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 30 | void 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 Lupusoru | bd25d4b | 2014-07-02 18:16:51 -0700 | [diff] [blame] | 53 | |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 54 | void PassDriverMEOpts::ApplyPass(PassDataHolder* data, const Pass* pass) { |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 55 | const PassME* const pass_me = down_cast<const PassME*>(pass); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 56 | DCHECK(pass_me != nullptr); |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 57 | PassMEDataHolder* const pass_me_data_holder = down_cast<PassMEDataHolder*>(data); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 58 | // Set to dirty. |
| 59 | pass_me_data_holder->dirty = true; |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 60 | // First call the base class' version. |
| 61 | PassDriver::ApplyPass(data, pass); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 62 | // Now we care about flags. |
| 63 | if ((pass_me->GetFlag(kOptimizationBasicBlockChange) == true) || |
| 64 | (pass_me->GetFlag(kOptimizationDefUsesChange) == true)) { |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 65 | // Is it dirty at least? |
| 66 | if (pass_me_data_holder->dirty == true) { |
Jean Christophe Beyler | fbebc69 | 2014-09-02 14:22:17 -0700 | [diff] [blame] | 67 | CompilationUnit* c_unit = pass_me_data_holder->c_unit; |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 68 | c_unit->mir_graph.get()->CalculateBasicBlockInformation(); |
| 69 | } |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 70 | } |
| 71 | } |
| 72 | |
| 73 | } // namespace art |