Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [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 | |
| 17 | #include "bb_optimizations.h" |
| 18 | #include "dataflow_iterator.h" |
| 19 | #include "dataflow_iterator-inl.h" |
| 20 | |
| 21 | namespace art { |
| 22 | |
| 23 | /* |
| 24 | * Code Layout pass implementation start. |
| 25 | */ |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 26 | bool CodeLayout::Worker(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 27 | DCHECK(data != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 28 | PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 29 | CompilationUnit* c_unit = pass_me_data_holder->c_unit; |
| 30 | DCHECK(c_unit != nullptr); |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 31 | BasicBlock* bb = pass_me_data_holder->bb; |
| 32 | DCHECK(bb != nullptr); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 33 | c_unit->mir_graph->LayoutBlocks(bb); |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 34 | // No need of repeating, so just return false. |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | /* |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 39 | * BasicBlock Combine pass implementation start. |
| 40 | */ |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 41 | bool BBCombine::Worker(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 42 | DCHECK(data != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 43 | PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 44 | CompilationUnit* c_unit = pass_me_data_holder->c_unit; |
| 45 | DCHECK(c_unit != nullptr); |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 46 | BasicBlock* bb = pass_me_data_holder->bb; |
| 47 | DCHECK(bb != nullptr); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 48 | c_unit->mir_graph->CombineBlocks(bb); |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 49 | |
| 50 | // No need of repeating, so just return false. |
| 51 | return false; |
| 52 | } |
| 53 | |
Vladimir Marko | 066f9e4 | 2015-01-16 16:04:43 +0000 | [diff] [blame] | 54 | /* |
| 55 | * MethodUseCount pass implementation start. |
| 56 | */ |
| 57 | bool MethodUseCount::Gate(const PassDataHolder* data) const { |
| 58 | DCHECK(data != nullptr); |
| 59 | CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 60 | DCHECK(c_unit != nullptr); |
| 61 | // First initialize the data. |
| 62 | c_unit->mir_graph->InitializeMethodUses(); |
| 63 | |
| 64 | // Now check if the pass is to be ignored. |
| 65 | bool res = ((c_unit->disable_opt & (1 << kPromoteRegs)) == 0); |
| 66 | |
| 67 | return res; |
| 68 | } |
| 69 | |
| 70 | bool MethodUseCount::Worker(PassDataHolder* data) const { |
| 71 | DCHECK(data != nullptr); |
| 72 | PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data); |
| 73 | CompilationUnit* c_unit = pass_me_data_holder->c_unit; |
| 74 | DCHECK(c_unit != nullptr); |
| 75 | BasicBlock* bb = pass_me_data_holder->bb; |
| 76 | DCHECK(bb != nullptr); |
| 77 | c_unit->mir_graph->CountUses(bb); |
| 78 | // No need of repeating, so just return false. |
| 79 | return false; |
| 80 | } |
| 81 | |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 82 | } // namespace art |