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 | /** |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 66 | * @class ClearPhiInformation |
| 67 | * @brief Clear the PHI nodes from the CFG. |
| 68 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 69 | class ClearPhiInstructions : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 70 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 71 | ClearPhiInstructions() : PassMEMirSsaRep("ClearPhiInstructions") { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 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 | |
| 77 | /** |
| 78 | * @class CalculatePredecessors |
| 79 | * @brief Calculate the predecessor BitVector of each Basicblock. |
| 80 | */ |
| 81 | class CalculatePredecessors : public PassME { |
| 82 | public: |
Vladimir Marko | aa7b8a3 | 2014-10-15 11:35:44 +0100 | [diff] [blame] | 83 | CalculatePredecessors() : PassME("CalculatePredecessors", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 86 | void Start(PassDataHolder* data) const; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | /** |
| 90 | * @class DFSOrders |
| 91 | * @brief Compute the DFS order of the MIR graph |
| 92 | */ |
| 93 | class DFSOrders : public PassME { |
| 94 | public: |
Vladimir Marko | aa7b8a3 | 2014-10-15 11:35:44 +0100 | [diff] [blame] | 95 | DFSOrders() : PassME("DFSOrders", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Vladimir Marko | 312eb25 | 2014-10-07 15:01:57 +0100 | [diff] [blame] | 98 | bool Gate(const PassDataHolder* data) const { |
| 99 | DCHECK(data != nullptr); |
| 100 | CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 101 | DCHECK(c_unit != nullptr); |
| 102 | return !c_unit->mir_graph->DfsOrdersUpToDate(); |
| 103 | } |
| 104 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 105 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 106 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 107 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 108 | DCHECK(c_unit != nullptr); |
| 109 | c_unit->mir_graph.get()->ComputeDFSOrders(); |
| 110 | } |
| 111 | }; |
| 112 | |
| 113 | /** |
| 114 | * @class BuildDomination |
| 115 | * @brief Build the domination information of the MIR Graph |
| 116 | */ |
| 117 | class BuildDomination : public PassME { |
| 118 | public: |
Vladimir Marko | aa7b8a3 | 2014-10-15 11:35:44 +0100 | [diff] [blame] | 119 | BuildDomination() : PassME("BuildDomination", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 122 | bool Gate(const PassDataHolder* data) const { |
| 123 | DCHECK(data != nullptr); |
| 124 | CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 125 | DCHECK(c_unit != nullptr); |
| 126 | return !c_unit->mir_graph->DominationUpToDate(); |
| 127 | } |
| 128 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 129 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 130 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 131 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 132 | DCHECK(c_unit != nullptr); |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 133 | c_unit->mir_graph->ComputeDominators(); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 136 | void End(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 137 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 138 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 139 | DCHECK(c_unit != nullptr); |
| 140 | // Verify the dataflow information after the pass. |
| 141 | if (c_unit->enable_debug & (1 << kDebugVerifyDataflow)) { |
| 142 | c_unit->mir_graph->VerifyDataflow(); |
| 143 | } |
| 144 | } |
| 145 | }; |
| 146 | |
| 147 | /** |
Vladimir Marko | 622bdbe | 2014-06-19 14:59:05 +0100 | [diff] [blame] | 148 | * @class TopologicalSortOrders |
| 149 | * @brief Compute the topological sort order of the MIR graph |
| 150 | */ |
| 151 | class TopologicalSortOrders : public PassME { |
| 152 | public: |
Vladimir Marko | aa7b8a3 | 2014-10-15 11:35:44 +0100 | [diff] [blame] | 153 | TopologicalSortOrders() : PassME("TopologicalSortOrders", kNoNodes) { |
Vladimir Marko | 622bdbe | 2014-06-19 14:59:05 +0100 | [diff] [blame] | 154 | } |
| 155 | |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 156 | bool Gate(const PassDataHolder* data) const { |
| 157 | DCHECK(data != nullptr); |
| 158 | CompilationUnit* c_unit = down_cast<const PassMEDataHolder*>(data)->c_unit; |
| 159 | DCHECK(c_unit != nullptr); |
| 160 | return !c_unit->mir_graph->TopologicalOrderUpToDate(); |
| 161 | } |
| 162 | |
Vladimir Marko | 622bdbe | 2014-06-19 14:59:05 +0100 | [diff] [blame] | 163 | void Start(PassDataHolder* data) const { |
| 164 | DCHECK(data != nullptr); |
| 165 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
| 166 | DCHECK(c_unit != nullptr); |
| 167 | c_unit->mir_graph.get()->ComputeTopologicalSortOrder(); |
| 168 | } |
| 169 | }; |
| 170 | |
| 171 | /** |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 172 | * @class DefBlockMatrix |
| 173 | * @brief Calculate the matrix of definition per basic block |
| 174 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 175 | class DefBlockMatrix : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 176 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 177 | DefBlockMatrix() : PassMEMirSsaRep("DefBlockMatrix", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 180 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 181 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 182 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 183 | DCHECK(c_unit != nullptr); |
| 184 | c_unit->mir_graph.get()->ComputeDefBlockMatrix(); |
| 185 | } |
| 186 | }; |
| 187 | |
| 188 | /** |
| 189 | * @class CreatePhiNodes |
| 190 | * @brief Pass to create the phi nodes after SSA calculation |
| 191 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 192 | class CreatePhiNodes : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 193 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 194 | CreatePhiNodes() : PassMEMirSsaRep("CreatePhiNodes", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 197 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 198 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 199 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 200 | DCHECK(c_unit != nullptr); |
| 201 | c_unit->mir_graph.get()->InsertPhiNodes(); |
| 202 | } |
| 203 | }; |
| 204 | |
| 205 | /** |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 206 | * @class SSAConversion |
| 207 | * @brief Pass for SSA conversion of MIRs |
| 208 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 209 | class SSAConversion : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 210 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 211 | SSAConversion() : PassMEMirSsaRep("SSAConversion", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 212 | } |
| 213 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 214 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 215 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 216 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 217 | DCHECK(c_unit != nullptr); |
| 218 | MIRGraph *mir_graph = c_unit->mir_graph.get(); |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 219 | mir_graph->ClearAllVisitedFlags(); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 220 | mir_graph->DoDFSPreOrderSSARename(mir_graph->GetEntryBlock()); |
| 221 | } |
| 222 | }; |
| 223 | |
| 224 | /** |
| 225 | * @class PhiNodeOperands |
| 226 | * @brief Pass to insert the Phi node operands to basic blocks |
| 227 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 228 | class PhiNodeOperands : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 229 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 230 | PhiNodeOperands() : PassMEMirSsaRep("PhiNodeOperands", kPreOrderDFSTraversal) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 231 | } |
| 232 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 233 | bool Worker(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 234 | DCHECK(data != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 235 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 236 | DCHECK(c_unit != nullptr); |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 237 | BasicBlock* bb = down_cast<PassMEDataHolder*>(data)->bb; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 238 | DCHECK(bb != nullptr); |
| 239 | c_unit->mir_graph->InsertPhiNodeOperands(bb); |
| 240 | // No need of repeating, so just return false. |
| 241 | return false; |
| 242 | } |
| 243 | }; |
| 244 | |
| 245 | /** |
| 246 | * @class InitRegLocations |
| 247 | * @brief Initialize Register Locations. |
| 248 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 249 | class PerformInitRegLocations : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 250 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 251 | PerformInitRegLocations() : PassMEMirSsaRep("PerformInitRegLocation", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 254 | void Start(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 255 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 256 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 257 | DCHECK(c_unit != nullptr); |
| 258 | c_unit->mir_graph->InitRegLocations(); |
| 259 | } |
| 260 | }; |
| 261 | |
| 262 | /** |
Vladimir Marko | 066f9e4 | 2015-01-16 16:04:43 +0000 | [diff] [blame] | 263 | * @class TypeInference |
| 264 | * @brief Type inference pass. |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 265 | */ |
Vladimir Marko | 066f9e4 | 2015-01-16 16:04:43 +0000 | [diff] [blame] | 266 | class TypeInference : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 267 | public: |
Vladimir Marko | 066f9e4 | 2015-01-16 16:04:43 +0000 | [diff] [blame] | 268 | TypeInference() : PassMEMirSsaRep("TypeInference", kRepeatingPreOrderDFSTraversal) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Jean Christophe Beyler | 09321df | 2014-07-18 15:33:57 -0700 | [diff] [blame] | 271 | bool Worker(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 272 | DCHECK(data != nullptr); |
Vladimir Marko | 066f9e4 | 2015-01-16 16:04:43 +0000 | [diff] [blame] | 273 | PassMEDataHolder* pass_me_data_holder = down_cast<PassMEDataHolder*>(data); |
| 274 | CompilationUnit* c_unit = pass_me_data_holder->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 275 | DCHECK(c_unit != nullptr); |
Vladimir Marko | 066f9e4 | 2015-01-16 16:04:43 +0000 | [diff] [blame] | 276 | BasicBlock* bb = pass_me_data_holder->bb; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 277 | DCHECK(bb != nullptr); |
Vladimir Marko | 066f9e4 | 2015-01-16 16:04:43 +0000 | [diff] [blame] | 278 | return c_unit->mir_graph->InferTypes(bb); |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 279 | } |
| 280 | }; |
| 281 | |
| 282 | /** |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 283 | * @class FinishSSATransformation |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 284 | * @brief There is some data that needs to be freed after performing the post optimization passes. |
| 285 | */ |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 286 | class FinishSSATransformation : public PassMEMirSsaRep { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 287 | public: |
Vladimir Marko | ffda499 | 2014-12-18 17:05:58 +0000 | [diff] [blame] | 288 | FinishSSATransformation() : PassMEMirSsaRep("FinishSSATransformation", kNoNodes) { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 289 | } |
| 290 | |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 291 | void End(PassDataHolder* data) const { |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 292 | DCHECK(data != nullptr); |
Jean Christophe Beyler | e1f65bc | 2014-06-09 10:18:26 -0700 | [diff] [blame] | 293 | CompilationUnit* c_unit = down_cast<PassMEDataHolder*>(data)->c_unit; |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 294 | DCHECK(c_unit != nullptr); |
| 295 | c_unit->mir_graph.get()->SSATransformationEnd(); |
| 296 | } |
| 297 | }; |
| 298 | |
| 299 | } // namespace art |
| 300 | |
Narayan Kamath | fd5a852 | 2014-05-30 11:58:09 +0100 | [diff] [blame] | 301 | #endif // ART_COMPILER_DEX_POST_OPT_PASSES_H_ |