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 | #ifndef ART_COMPILER_DEX_BB_OPTIMIZATIONS_H_ |
| 18 | #define ART_COMPILER_DEX_BB_OPTIMIZATIONS_H_ |
| 19 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 20 | #include "base/casts.h" |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 21 | #include "compiler_internals.h" |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 22 | #include "pass_me.h" |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | /** |
Vladimir Marko | be0e546 | 2014-02-26 11:24:15 +0000 | [diff] [blame] | 27 | * @class CacheFieldLoweringInfo |
| 28 | * @brief Cache the lowering info for fields used by IGET/IPUT/SGET/SPUT insns. |
| 29 | */ |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 30 | class CacheFieldLoweringInfo : public PassME { |
Vladimir Marko | be0e546 | 2014-02-26 11:24:15 +0000 | [diff] [blame] | 31 | public: |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 32 | CacheFieldLoweringInfo() : PassME("CacheFieldLoweringInfo", kNoNodes) { |
Vladimir Marko | be0e546 | 2014-02-26 11:24:15 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 35 | void Start(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 36 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 37 | CompilationUnit* cUnit = down_cast<PassMEDataHolder*>(data)->c_unit; |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 38 | DCHECK(cUnit != nullptr); |
Vladimir Marko | be0e546 | 2014-02-26 11:24:15 +0000 | [diff] [blame] | 39 | cUnit->mir_graph->DoCacheFieldLoweringInfo(); |
| 40 | } |
Vladimir Marko | 3d73ba2 | 2014-03-06 15:18:04 +0000 | [diff] [blame] | 41 | |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 42 | bool Gate(const PassDataHolder* data) const { |
| 43 | DCHECK(data != nullptr); |
| 44 | CompilationUnit* cUnit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 45 | DCHECK(cUnit != nullptr); |
Vladimir Marko | 3d73ba2 | 2014-03-06 15:18:04 +0000 | [diff] [blame] | 46 | return cUnit->mir_graph->HasFieldAccess(); |
| 47 | } |
Vladimir Marko | be0e546 | 2014-02-26 11:24:15 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | /** |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 51 | * @class CacheMethodLoweringInfo |
| 52 | * @brief Cache the lowering info for methods called by INVOKEs. |
| 53 | */ |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 54 | class CacheMethodLoweringInfo : public PassME { |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 55 | public: |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 56 | CacheMethodLoweringInfo() : PassME("CacheMethodLoweringInfo", kNoNodes) { |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 57 | } |
| 58 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 59 | void Start(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 60 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 61 | CompilationUnit* cUnit = down_cast<PassMEDataHolder*>(data)->c_unit; |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 62 | DCHECK(cUnit != nullptr); |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 63 | cUnit->mir_graph->DoCacheMethodLoweringInfo(); |
| 64 | } |
Vladimir Marko | 3d73ba2 | 2014-03-06 15:18:04 +0000 | [diff] [blame] | 65 | |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 66 | bool Gate(const PassDataHolder* data) const { |
| 67 | DCHECK(data != nullptr); |
| 68 | CompilationUnit* cUnit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 69 | DCHECK(cUnit != nullptr); |
Vladimir Marko | 3d73ba2 | 2014-03-06 15:18:04 +0000 | [diff] [blame] | 70 | return cUnit->mir_graph->HasInvokes(); |
| 71 | } |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | /** |
Razvan A Lupusoru | cb80474 | 2014-07-09 16:42:19 -0700 | [diff] [blame] | 75 | * @class SpecialMethodInliner |
| 76 | * @brief Performs method inlining pass on special kinds of methods. |
| 77 | * @details Special methods are methods that fall in one of the following categories: |
| 78 | * empty, instance getter, instance setter, argument return, and constant return. |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 79 | */ |
Razvan A Lupusoru | cb80474 | 2014-07-09 16:42:19 -0700 | [diff] [blame] | 80 | class SpecialMethodInliner : public PassME { |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 81 | public: |
Razvan A Lupusoru | cb80474 | 2014-07-09 16:42:19 -0700 | [diff] [blame] | 82 | SpecialMethodInliner() : PassME("SpecialMethodInliner") { |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 83 | } |
| 84 | |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 85 | bool Gate(const PassDataHolder* data) const { |
| 86 | DCHECK(data != nullptr); |
| 87 | CompilationUnit* cUnit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 88 | DCHECK(cUnit != nullptr); |
Razvan A Lupusoru | cb80474 | 2014-07-09 16:42:19 -0700 | [diff] [blame] | 89 | return cUnit->mir_graph->InlineSpecialMethodsGate(); |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 92 | void Start(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 93 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 94 | CompilationUnit* cUnit = down_cast<PassMEDataHolder*>(data)->c_unit; |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 95 | DCHECK(cUnit != nullptr); |
Razvan A Lupusoru | cb80474 | 2014-07-09 16:42:19 -0700 | [diff] [blame] | 96 | cUnit->mir_graph->InlineSpecialMethodsStart(); |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 99 | bool Worker(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 100 | DCHECK(data != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 101 | PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data); |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 102 | CompilationUnit* cUnit = pass_me_data_holder->c_unit; |
| 103 | DCHECK(cUnit != nullptr); |
| 104 | BasicBlock* bb = pass_me_data_holder->bb; |
| 105 | DCHECK(bb != nullptr); |
Razvan A Lupusoru | cb80474 | 2014-07-09 16:42:19 -0700 | [diff] [blame] | 106 | cUnit->mir_graph->InlineSpecialMethods(bb); |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 107 | // No need of repeating, so just return false. |
| 108 | return false; |
| 109 | } |
| 110 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 111 | void End(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 112 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 113 | CompilationUnit* cUnit = down_cast<PassMEDataHolder*>(data)->c_unit; |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 114 | DCHECK(cUnit != nullptr); |
Razvan A Lupusoru | cb80474 | 2014-07-09 16:42:19 -0700 | [diff] [blame] | 115 | cUnit->mir_graph->InlineSpecialMethodsEnd(); |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 116 | } |
| 117 | }; |
| 118 | |
| 119 | /** |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 120 | * @class CodeLayout |
| 121 | * @brief Perform the code layout pass. |
| 122 | */ |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 123 | class CodeLayout : public PassME { |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 124 | public: |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 125 | CodeLayout() : PassME("CodeLayout", kAllNodes, kOptimizationBasicBlockChange, "2_post_layout_cfg") { |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 126 | } |
| 127 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 128 | void Start(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 129 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 130 | CompilationUnit* cUnit = down_cast<PassMEDataHolder*>(data)->c_unit; |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 131 | DCHECK(cUnit != nullptr); |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 132 | cUnit->mir_graph->VerifyDataflow(); |
| 133 | } |
| 134 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 135 | bool Worker(PassDataHolder* data) const; |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | /** |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 139 | * @class NullCheckEliminationAndTypeInference |
| 140 | * @brief Null check elimination and type inference. |
| 141 | */ |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 142 | class NullCheckEliminationAndTypeInference : public PassME { |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 143 | public: |
Vladimir Marko | 75ba13f | 2014-01-28 12:15:24 +0000 | [diff] [blame] | 144 | NullCheckEliminationAndTypeInference() |
Vladimir Marko | 622bdbe | 2014-06-19 14:59:05 +0100 | [diff] [blame] | 145 | : PassME("NCE_TypeInference", kRepeatingTopologicalSortTraversal, "4_post_nce_cfg") { |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 146 | } |
| 147 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 148 | void Start(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 149 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 150 | CompilationUnit* cUnit = down_cast<PassMEDataHolder*>(data)->c_unit; |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 151 | DCHECK(cUnit != nullptr); |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 152 | cUnit->mir_graph->EliminateNullChecksAndInferTypesStart(); |
| 153 | } |
| 154 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 155 | bool Worker(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 156 | DCHECK(data != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 157 | PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data); |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 158 | CompilationUnit* cUnit = pass_me_data_holder->c_unit; |
| 159 | DCHECK(cUnit != nullptr); |
| 160 | BasicBlock* bb = pass_me_data_holder->bb; |
| 161 | DCHECK(bb != nullptr); |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 162 | return cUnit->mir_graph->EliminateNullChecksAndInferTypes(bb); |
| 163 | } |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 164 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 165 | void End(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 166 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 167 | CompilationUnit* cUnit = down_cast<PassMEDataHolder*>(data)->c_unit; |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 168 | DCHECK(cUnit != nullptr); |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 169 | cUnit->mir_graph->EliminateNullChecksAndInferTypesEnd(); |
| 170 | } |
| 171 | }; |
| 172 | |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 173 | class ClassInitCheckElimination : public PassME { |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 174 | public: |
Vladimir Marko | 622bdbe | 2014-06-19 14:59:05 +0100 | [diff] [blame] | 175 | ClassInitCheckElimination() |
Vladimir Marko | 55fff04 | 2014-07-10 12:42:52 +0100 | [diff] [blame] | 176 | : PassME("ClInitCheckElimination", kLoopRepeatingTopologicalSortTraversal) { |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 177 | } |
| 178 | |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 179 | bool Gate(const PassDataHolder* data) const { |
| 180 | DCHECK(data != nullptr); |
| 181 | CompilationUnit* cUnit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 182 | DCHECK(cUnit != nullptr); |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 183 | return cUnit->mir_graph->EliminateClassInitChecksGate(); |
| 184 | } |
| 185 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 186 | bool Worker(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 187 | DCHECK(data != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 188 | PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data); |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 189 | CompilationUnit* cUnit = pass_me_data_holder->c_unit; |
| 190 | DCHECK(cUnit != nullptr); |
| 191 | BasicBlock* bb = pass_me_data_holder->bb; |
| 192 | DCHECK(bb != nullptr); |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 193 | return cUnit->mir_graph->EliminateClassInitChecks(bb); |
| 194 | } |
| 195 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 196 | void End(PassDataHolder* data) const { |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 197 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 198 | CompilationUnit* cUnit = down_cast<PassMEDataHolder*>(data)->c_unit; |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 199 | DCHECK(cUnit != nullptr); |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 200 | cUnit->mir_graph->EliminateClassInitChecksEnd(); |
| 201 | } |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 202 | }; |
| 203 | |
| 204 | /** |
Vladimir Marko | 95a0597 | 2014-05-30 10:01:32 +0100 | [diff] [blame] | 205 | * @class GlobalValueNumberingPass |
| 206 | * @brief Performs the global value numbering pass. |
| 207 | */ |
| 208 | class GlobalValueNumberingPass : public PassME { |
| 209 | public: |
| 210 | GlobalValueNumberingPass() |
Vladimir Marko | 55fff04 | 2014-07-10 12:42:52 +0100 | [diff] [blame] | 211 | : PassME("GVN", kLoopRepeatingTopologicalSortTraversal, "4_post_gvn_cfg") { |
Vladimir Marko | 95a0597 | 2014-05-30 10:01:32 +0100 | [diff] [blame] | 212 | } |
| 213 | |
Vladimir Marko | 55fff04 | 2014-07-10 12:42:52 +0100 | [diff] [blame] | 214 | bool Gate(const PassDataHolder* data) const OVERRIDE { |
Vladimir Marko | 95a0597 | 2014-05-30 10:01:32 +0100 | [diff] [blame] | 215 | DCHECK(data != nullptr); |
| 216 | CompilationUnit* cUnit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 217 | DCHECK(cUnit != nullptr); |
| 218 | return cUnit->mir_graph->ApplyGlobalValueNumberingGate(); |
| 219 | } |
| 220 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 221 | bool Worker(PassDataHolder* data) const { |
Vladimir Marko | 95a0597 | 2014-05-30 10:01:32 +0100 | [diff] [blame] | 222 | DCHECK(data != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 223 | PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data); |
Vladimir Marko | 95a0597 | 2014-05-30 10:01:32 +0100 | [diff] [blame] | 224 | CompilationUnit* cUnit = pass_me_data_holder->c_unit; |
| 225 | DCHECK(cUnit != nullptr); |
| 226 | BasicBlock* bb = pass_me_data_holder->bb; |
| 227 | DCHECK(bb != nullptr); |
| 228 | return cUnit->mir_graph->ApplyGlobalValueNumbering(bb); |
| 229 | } |
| 230 | |
Vladimir Marko | 55fff04 | 2014-07-10 12:42:52 +0100 | [diff] [blame] | 231 | void End(PassDataHolder* data) const OVERRIDE { |
Vladimir Marko | 95a0597 | 2014-05-30 10:01:32 +0100 | [diff] [blame] | 232 | DCHECK(data != nullptr); |
| 233 | CompilationUnit* cUnit = down_cast<PassMEDataHolder*>(data)->c_unit; |
| 234 | DCHECK(cUnit != nullptr); |
| 235 | cUnit->mir_graph->ApplyGlobalValueNumberingEnd(); |
| 236 | } |
| 237 | }; |
| 238 | |
| 239 | /** |
| 240 | * @class BBCombine |
| 241 | * @brief Perform the basic block combination pass. |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 242 | */ |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 243 | class BBCombine : public PassME { |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 244 | public: |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 245 | BBCombine() : PassME("BBCombine", kPreOrderDFSTraversal, "5_post_bbcombine_cfg") { |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 246 | } |
| 247 | |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 248 | bool Gate(const PassDataHolder* data) const { |
| 249 | DCHECK(data != nullptr); |
| 250 | CompilationUnit* cUnit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 251 | DCHECK(cUnit != nullptr); |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 252 | return ((cUnit->disable_opt & (1 << kSuppressExceptionEdges)) != 0); |
| 253 | } |
| 254 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 255 | bool Worker(PassDataHolder* data) const; |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | /** |
| 259 | * @class BasicBlock Optimizations |
| 260 | * @brief Any simple BasicBlock optimization can be put here. |
| 261 | */ |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 262 | class BBOptimizations : public PassME { |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 263 | public: |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 264 | BBOptimizations() : PassME("BBOptimizations", kNoNodes, "5_post_bbo_cfg") { |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 265 | } |
| 266 | |
James C Scott | 4f59668 | 2014-05-01 05:52:04 -0700 | [diff] [blame] | 267 | bool Gate(const PassDataHolder* data) const { |
| 268 | DCHECK(data != nullptr); |
| 269 | CompilationUnit* cUnit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 270 | DCHECK(cUnit != nullptr); |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 271 | return ((cUnit->disable_opt & (1 << kBBOpt)) == 0); |
| 272 | } |
| 273 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 274 | void Start(PassDataHolder* data) const; |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 275 | }; |
| 276 | |
| 277 | } // namespace art |
| 278 | |
| 279 | #endif // ART_COMPILER_DEX_BB_OPTIMIZATIONS_H_ |