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