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 | |
Narayan Kamath | fd5a852 | 2014-05-30 11:58:09 +0100 | [diff] [blame] | 17 | #ifndef ART_COMPILER_DEX_POST_OPT_PASSES_H_ |
| 18 | #define ART_COMPILER_DEX_POST_OPT_PASSES_H_ |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 19 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 20 | #include "dex/quick/mir_to_lir.h" |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 21 | #include "compiler_internals.h" |
| 22 | #include "pass_me.h" |
| 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | /** |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 27 | * @class PassMEMirSsaRep |
| 28 | * @brief Convenience class for passes that check MIRGraph::MirSsaRepUpToDate(). |
| 29 | */ |
| 30 | class PassMEMirSsaRep : public PassME { |
| 31 | public: |
| 32 | PassMEMirSsaRep(const char* name, DataFlowAnalysisMode type = kAllNodes) |
| 33 | : PassME(name, type) { |
| 34 | } |
| 35 | |
| 36 | bool Gate(const PassDataHolder* data) const OVERRIDE { |
| 37 | DCHECK(data != nullptr); |
| 38 | CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 39 | DCHECK(c_unit != nullptr); |
| 40 | return !c_unit->mir_graph->MirSsaRepUpToDate(); |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | /** |
| 45 | * @class InitializeSSATransformation |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 46 | * @brief There is some data that needs to be initialized before performing |
| 47 | * the post optimization passes. |
| 48 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 49 | class InitializeSSATransformation : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 50 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 51 | InitializeSSATransformation() : PassMEMirSsaRep("InitializeSSATransformation", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 54 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 55 | // New blocks may have been inserted so the first thing we do is ensure that |
| 56 | // the c_unit's number of blocks matches the actual count of basic blocks. |
| 57 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 58 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 59 | DCHECK(c_unit != nullptr); |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 60 | c_unit->mir_graph->SSATransformationStart(); |
| 61 | c_unit->mir_graph->CompilerInitializeSSAConversion(); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 62 | } |
| 63 | }; |
| 64 | |
| 65 | /** |
| 66 | * @class MethodUseCount |
| 67 | * @brief Count the register uses of the method |
| 68 | */ |
| 69 | class MethodUseCount : public PassME { |
| 70 | public: |
| 71 | MethodUseCount() : PassME("UseCount") { |
| 72 | } |
| 73 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 74 | bool Worker(PassDataHolder* data) const; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 75 | |
| 76 | bool Gate(const PassDataHolder* data) const; |
| 77 | }; |
| 78 | |
| 79 | /** |
| 80 | * @class ClearPhiInformation |
| 81 | * @brief Clear the PHI nodes from the CFG. |
| 82 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 83 | class ClearPhiInstructions : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 84 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 85 | ClearPhiInstructions() : PassMEMirSsaRep("ClearPhiInstructions") { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 88 | bool Worker(PassDataHolder* data) const; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | /** |
| 92 | * @class CalculatePredecessors |
| 93 | * @brief Calculate the predecessor BitVector of each Basicblock. |
| 94 | */ |
| 95 | class CalculatePredecessors : public PassME { |
| 96 | public: |
Vladimir Marko | aa7b8a3 | 2014-10-15 11:35:44 +0100 | [diff] [blame] | 97 | CalculatePredecessors() : PassME("CalculatePredecessors", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 100 | void Start(PassDataHolder* data) const; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | /** |
| 104 | * @class DFSOrders |
| 105 | * @brief Compute the DFS order of the MIR graph |
| 106 | */ |
| 107 | class DFSOrders : public PassME { |
| 108 | public: |
Vladimir Marko | aa7b8a3 | 2014-10-15 11:35:44 +0100 | [diff] [blame] | 109 | DFSOrders() : PassME("DFSOrders", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Vladimir Marko | 312eb25 | 2014-10-07 15:01:57 +0100 | [diff] [blame] | 112 | bool Gate(const PassDataHolder* data) const { |
| 113 | DCHECK(data != nullptr); |
| 114 | CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 115 | DCHECK(c_unit != nullptr); |
| 116 | return !c_unit->mir_graph->DfsOrdersUpToDate(); |
| 117 | } |
| 118 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 119 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 120 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 121 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 122 | DCHECK(c_unit != nullptr); |
| 123 | c_unit->mir_graph.get()->ComputeDFSOrders(); |
| 124 | } |
| 125 | }; |
| 126 | |
| 127 | /** |
| 128 | * @class BuildDomination |
| 129 | * @brief Build the domination information of the MIR Graph |
| 130 | */ |
| 131 | class BuildDomination : public PassME { |
| 132 | public: |
Vladimir Marko | aa7b8a3 | 2014-10-15 11:35:44 +0100 | [diff] [blame] | 133 | BuildDomination() : PassME("BuildDomination", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 136 | bool Gate(const PassDataHolder* data) const { |
| 137 | DCHECK(data != nullptr); |
| 138 | CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 139 | DCHECK(c_unit != nullptr); |
| 140 | return !c_unit->mir_graph->DominationUpToDate(); |
| 141 | } |
| 142 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 143 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 144 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 145 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 146 | DCHECK(c_unit != nullptr); |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 147 | c_unit->mir_graph->ComputeDominators(); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 150 | void End(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 151 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 152 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 153 | DCHECK(c_unit != nullptr); |
| 154 | // Verify the dataflow information after the pass. |
| 155 | if (c_unit->enable_debug & (1 << kDebugVerifyDataflow)) { |
| 156 | c_unit->mir_graph->VerifyDataflow(); |
| 157 | } |
| 158 | } |
| 159 | }; |
| 160 | |
| 161 | /** |
Vladimir Marko | 622bdbe | 2014-06-19 14:59:05 +0100 | [diff] [blame] | 162 | * @class TopologicalSortOrders |
| 163 | * @brief Compute the topological sort order of the MIR graph |
| 164 | */ |
| 165 | class TopologicalSortOrders : public PassME { |
| 166 | public: |
Vladimir Marko | aa7b8a3 | 2014-10-15 11:35:44 +0100 | [diff] [blame] | 167 | TopologicalSortOrders() : PassME("TopologicalSortOrders", kNoNodes) { |
Vladimir Marko | 622bdbe | 2014-06-19 14:59:05 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 170 | bool Gate(const PassDataHolder* data) const { |
| 171 | DCHECK(data != nullptr); |
| 172 | CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 173 | DCHECK(c_unit != nullptr); |
| 174 | return !c_unit->mir_graph->TopologicalOrderUpToDate(); |
| 175 | } |
| 176 | |
Vladimir Marko | 622bdbe | 2014-06-19 14:59:05 +0100 | [diff] [blame] | 177 | void Start(PassDataHolder* data) const { |
| 178 | DCHECK(data != nullptr); |
| 179 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
| 180 | DCHECK(c_unit != nullptr); |
| 181 | c_unit->mir_graph.get()->ComputeTopologicalSortOrder(); |
| 182 | } |
| 183 | }; |
| 184 | |
| 185 | /** |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 186 | * @class DefBlockMatrix |
| 187 | * @brief Calculate the matrix of definition per basic block |
| 188 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 189 | class DefBlockMatrix : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 190 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 191 | DefBlockMatrix() : PassMEMirSsaRep("DefBlockMatrix", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 194 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 195 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 196 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 197 | DCHECK(c_unit != nullptr); |
| 198 | c_unit->mir_graph.get()->ComputeDefBlockMatrix(); |
| 199 | } |
| 200 | }; |
| 201 | |
| 202 | /** |
| 203 | * @class CreatePhiNodes |
| 204 | * @brief Pass to create the phi nodes after SSA calculation |
| 205 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 206 | class CreatePhiNodes : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 207 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 208 | CreatePhiNodes() : PassMEMirSsaRep("CreatePhiNodes", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 211 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 212 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 213 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 214 | DCHECK(c_unit != nullptr); |
| 215 | c_unit->mir_graph.get()->InsertPhiNodes(); |
| 216 | } |
| 217 | }; |
| 218 | |
| 219 | /** |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 220 | * @class SSAConversion |
| 221 | * @brief Pass for SSA conversion of MIRs |
| 222 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 223 | class SSAConversion : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 224 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 225 | SSAConversion() : PassMEMirSsaRep("SSAConversion", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 226 | } |
| 227 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 228 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 229 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 230 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 231 | DCHECK(c_unit != nullptr); |
| 232 | MIRGraph *mir_graph = c_unit->mir_graph.get(); |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 233 | mir_graph->ClearAllVisitedFlags(); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 234 | mir_graph->DoDFSPreOrderSSARename(mir_graph->GetEntryBlock()); |
| 235 | } |
| 236 | }; |
| 237 | |
| 238 | /** |
| 239 | * @class PhiNodeOperands |
| 240 | * @brief Pass to insert the Phi node operands to basic blocks |
| 241 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 242 | class PhiNodeOperands : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 243 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 244 | PhiNodeOperands() : PassMEMirSsaRep("PhiNodeOperands", kPreOrderDFSTraversal) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 245 | } |
| 246 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 247 | bool Worker(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 248 | DCHECK(data != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 249 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 250 | DCHECK(c_unit != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 251 | BasicBlock* bb = down_cast<PassMEDataHolder*>(data)->bb; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 252 | DCHECK(bb != nullptr); |
| 253 | c_unit->mir_graph->InsertPhiNodeOperands(bb); |
| 254 | // No need of repeating, so just return false. |
| 255 | return false; |
| 256 | } |
| 257 | }; |
| 258 | |
| 259 | /** |
| 260 | * @class InitRegLocations |
| 261 | * @brief Initialize Register Locations. |
| 262 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 263 | class PerformInitRegLocations : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 264 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 265 | PerformInitRegLocations() : PassMEMirSsaRep("PerformInitRegLocation", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 266 | } |
| 267 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 268 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 269 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 270 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 271 | DCHECK(c_unit != nullptr); |
| 272 | c_unit->mir_graph->InitRegLocations(); |
| 273 | } |
| 274 | }; |
| 275 | |
| 276 | /** |
| 277 | * @class ConstantPropagation |
| 278 | * @brief Perform a constant propagation pass. |
| 279 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 280 | class ConstantPropagation : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 281 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 282 | ConstantPropagation() : PassMEMirSsaRep("ConstantPropagation") { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 285 | bool Worker(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 286 | DCHECK(data != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 287 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 288 | DCHECK(c_unit != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 289 | BasicBlock* bb = down_cast<PassMEDataHolder*>(data)->bb; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 290 | DCHECK(bb != nullptr); |
| 291 | c_unit->mir_graph->DoConstantPropagation(bb); |
| 292 | // No need of repeating, so just return false. |
| 293 | return false; |
| 294 | } |
| 295 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 296 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 297 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 298 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 299 | DCHECK(c_unit != nullptr); |
| 300 | c_unit->mir_graph->InitializeConstantPropagation(); |
| 301 | } |
| 302 | }; |
| 303 | |
| 304 | /** |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 305 | * @class FinishSSATransformation |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 306 | * @brief There is some data that needs to be freed after performing the post optimization passes. |
| 307 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 308 | class FinishSSATransformation : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 309 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 310 | FinishSSATransformation() : PassMEMirSsaRep("FinishSSATransformation", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 311 | } |
| 312 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 313 | void End(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 314 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 315 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 316 | DCHECK(c_unit != nullptr); |
| 317 | c_unit->mir_graph.get()->SSATransformationEnd(); |
| 318 | } |
| 319 | }; |
| 320 | |
| 321 | } // namespace art |
| 322 | |
Narayan Kamath | fd5a852 | 2014-05-30 11:58:09 +0100 | [diff] [blame] | 323 | #endif // ART_COMPILER_DEX_POST_OPT_PASSES_H_ |