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