buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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_SRC_COMPILER_DEX_MIRGRAPH_H_ |
| 18 | #define ART_SRC_COMPILER_DEX_MIRGRAPH_H_ |
| 19 | |
| 20 | #include "dex_file.h" |
| 21 | #include "dex_instruction.h" |
| 22 | #include "compiler_ir.h" |
| 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | enum DataFlowAttributePos { |
| 27 | kUA = 0, |
| 28 | kUB, |
| 29 | kUC, |
| 30 | kAWide, |
| 31 | kBWide, |
| 32 | kCWide, |
| 33 | kDA, |
| 34 | kIsMove, |
| 35 | kSetsConst, |
| 36 | kFormat35c, |
| 37 | kFormat3rc, |
| 38 | kNullCheckSrc0, // Null check of uses[0]. |
| 39 | kNullCheckSrc1, // Null check of uses[1]. |
| 40 | kNullCheckSrc2, // Null check of uses[2]. |
| 41 | kNullCheckOut0, // Null check out outgoing arg0. |
| 42 | kDstNonNull, // May assume dst is non-null. |
| 43 | kRetNonNull, // May assume retval is non-null. |
| 44 | kNullTransferSrc0, // Object copy src[0] -> dst. |
| 45 | kNullTransferSrcN, // Phi null check state transfer. |
| 46 | kRangeCheckSrc1, // Range check of uses[1]. |
| 47 | kRangeCheckSrc2, // Range check of uses[2]. |
| 48 | kRangeCheckSrc3, // Range check of uses[3]. |
| 49 | kFPA, |
| 50 | kFPB, |
| 51 | kFPC, |
| 52 | kCoreA, |
| 53 | kCoreB, |
| 54 | kCoreC, |
| 55 | kRefA, |
| 56 | kRefB, |
| 57 | kRefC, |
| 58 | kUsesMethodStar, // Implicit use of Method*. |
| 59 | }; |
| 60 | |
| 61 | #define DF_NOP 0 |
| 62 | #define DF_UA (1 << kUA) |
| 63 | #define DF_UB (1 << kUB) |
| 64 | #define DF_UC (1 << kUC) |
| 65 | #define DF_A_WIDE (1 << kAWide) |
| 66 | #define DF_B_WIDE (1 << kBWide) |
| 67 | #define DF_C_WIDE (1 << kCWide) |
| 68 | #define DF_DA (1 << kDA) |
| 69 | #define DF_IS_MOVE (1 << kIsMove) |
| 70 | #define DF_SETS_CONST (1 << kSetsConst) |
| 71 | #define DF_FORMAT_35C (1 << kFormat35c) |
| 72 | #define DF_FORMAT_3RC (1 << kFormat3rc) |
| 73 | #define DF_NULL_CHK_0 (1 << kNullCheckSrc0) |
| 74 | #define DF_NULL_CHK_1 (1 << kNullCheckSrc1) |
| 75 | #define DF_NULL_CHK_2 (1 << kNullCheckSrc2) |
| 76 | #define DF_NULL_CHK_OUT0 (1 << kNullCheckOut0) |
| 77 | #define DF_NON_NULL_DST (1 << kDstNonNull) |
| 78 | #define DF_NON_NULL_RET (1 << kRetNonNull) |
| 79 | #define DF_NULL_TRANSFER_0 (1 << kNullTransferSrc0) |
| 80 | #define DF_NULL_TRANSFER_N (1 << kNullTransferSrcN) |
| 81 | #define DF_RANGE_CHK_1 (1 << kRangeCheckSrc1) |
| 82 | #define DF_RANGE_CHK_2 (1 << kRangeCheckSrc2) |
| 83 | #define DF_RANGE_CHK_3 (1 << kRangeCheckSrc3) |
| 84 | #define DF_FP_A (1 << kFPA) |
| 85 | #define DF_FP_B (1 << kFPB) |
| 86 | #define DF_FP_C (1 << kFPC) |
| 87 | #define DF_CORE_A (1 << kCoreA) |
| 88 | #define DF_CORE_B (1 << kCoreB) |
| 89 | #define DF_CORE_C (1 << kCoreC) |
| 90 | #define DF_REF_A (1 << kRefA) |
| 91 | #define DF_REF_B (1 << kRefB) |
| 92 | #define DF_REF_C (1 << kRefC) |
| 93 | #define DF_UMS (1 << kUsesMethodStar) |
| 94 | |
| 95 | #define DF_HAS_USES (DF_UA | DF_UB | DF_UC) |
| 96 | |
| 97 | #define DF_HAS_DEFS (DF_DA) |
| 98 | |
| 99 | #define DF_HAS_NULL_CHKS (DF_NULL_CHK_0 | \ |
| 100 | DF_NULL_CHK_1 | \ |
| 101 | DF_NULL_CHK_2 | \ |
| 102 | DF_NULL_CHK_OUT0) |
| 103 | |
| 104 | #define DF_HAS_RANGE_CHKS (DF_RANGE_CHK_1 | \ |
| 105 | DF_RANGE_CHK_2 | \ |
| 106 | DF_RANGE_CHK_3) |
| 107 | |
| 108 | #define DF_HAS_NR_CHKS (DF_HAS_NULL_CHKS | \ |
| 109 | DF_HAS_RANGE_CHKS) |
| 110 | |
| 111 | #define DF_A_IS_REG (DF_UA | DF_DA) |
| 112 | #define DF_B_IS_REG (DF_UB) |
| 113 | #define DF_C_IS_REG (DF_UC) |
| 114 | #define DF_IS_GETTER_OR_SETTER (DF_IS_GETTER | DF_IS_SETTER) |
| 115 | #define DF_USES_FP (DF_FP_A | DF_FP_B | DF_FP_C) |
| 116 | |
| 117 | extern const int oat_data_flow_attributes[kMirOpLast]; |
| 118 | |
| 119 | class MIRGraph { |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 120 | public: |
| 121 | MIRGraph(CompilationUnit* cu); |
| 122 | ~MIRGraph() {} |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 123 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 124 | /* |
| 125 | * Parse dex method and add MIR at current insert point. Returns id (which is |
| 126 | * actually the index of the method in the m_units_ array). |
| 127 | */ |
| 128 | void InlineMethod(const DexFile::CodeItem* code_item, uint32_t access_flags, |
| 129 | InvokeType invoke_type, uint32_t class_def_idx, |
| 130 | uint32_t method_idx, jobject class_loader, const DexFile& dex_file); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 131 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 132 | /* Find existing block */ |
| 133 | BasicBlock* FindBlock(unsigned int code_offset) { |
| 134 | return FindBlock(code_offset, false, false, NULL); |
| 135 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 136 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 137 | const uint16_t* GetCurrentInsns() const { |
| 138 | return current_code_item_->insns_; |
| 139 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 140 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 141 | const uint16_t* GetInsns(int m_unit_index) const { |
| 142 | return m_units_[m_unit_index]->GetCodeItem()->insns_; |
| 143 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 144 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 145 | int GetNumBlocks() const { |
| 146 | return num_blocks_; |
| 147 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 148 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 149 | ArenaBitVector* GetTryBlockAddr() const { |
| 150 | return try_block_addr_; |
| 151 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 152 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 153 | BasicBlock* GetEntryBlock() const { |
| 154 | return entry_block_; |
| 155 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 156 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 157 | BasicBlock* GetExitBlock() const { |
| 158 | return exit_block_; |
| 159 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 160 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 161 | GrowableListIterator GetBasicBlockIterator() { |
| 162 | GrowableListIterator iterator; |
| 163 | GrowableListIteratorInit(&block_list_, &iterator); |
| 164 | return iterator; |
| 165 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 166 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 167 | BasicBlock* GetBasicBlock(int block_id) const { |
| 168 | return reinterpret_cast<BasicBlock*>(GrowableListGetElement(&block_list_, block_id)); |
| 169 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 170 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 171 | size_t GetBasicBlockListCount() const { |
| 172 | return block_list_.num_used; |
| 173 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 174 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 175 | GrowableList* GetBlockList() { |
| 176 | return &block_list_; |
| 177 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 178 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 179 | GrowableList* GetDfsOrder() { |
| 180 | return &dfs_order_; |
| 181 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 182 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 183 | GrowableList* GetDfsPostOrder() { |
| 184 | return &dfs_post_order_; |
| 185 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 186 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 187 | GrowableList* GetDomPostOrder() { |
| 188 | return &dom_post_order_traversal_; |
| 189 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 190 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 191 | GrowableList* GetSSASubscripts() { |
| 192 | return ssa_subscripts_; |
| 193 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 194 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 195 | int GetDefCount() const { |
| 196 | return def_count_; |
| 197 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 198 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 199 | void EnableOpcodeCounting() { |
| 200 | opcode_count_ = static_cast<int*>(NewMem(cu_, kNumPackedOpcodes * sizeof(int), true, |
| 201 | kAllocMisc)); |
| 202 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 203 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 204 | void ShowOpcodeStats(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 205 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 206 | DexCompilationUnit* GetCurrentDexCompilationUnit() const { |
| 207 | return m_units_[current_method_]; |
| 208 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 209 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 210 | void DumpCFG(const char* dir_prefix, bool all_blocks); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 211 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 212 | void BuildRegLocations(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 213 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 214 | void DumpRegLocTable(RegLocation* table, int count); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 215 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 216 | int ComputeFrameSize(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 217 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 218 | void BasicBlockOptimization(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 219 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 220 | bool IsConst(int32_t s_reg) const { |
| 221 | return (IsBitSet(is_constant_v_, s_reg)); |
| 222 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 223 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 224 | bool IsConst(RegLocation loc) const { |
| 225 | return (IsConst(loc.orig_sreg)); |
| 226 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 227 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 228 | int32_t ConstantValue(RegLocation loc) const { |
| 229 | DCHECK(IsConst(loc)); |
| 230 | return constant_values_[loc.orig_sreg]; |
| 231 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 232 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 233 | int32_t ConstantValue(int32_t s_reg) const { |
| 234 | DCHECK(IsConst(s_reg)); |
| 235 | return constant_values_[s_reg]; |
| 236 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 237 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 238 | int64_t ConstantValueWide(RegLocation loc) const { |
| 239 | DCHECK(IsConst(loc)); |
| 240 | return (static_cast<int64_t>(constant_values_[loc.orig_sreg + 1]) << 32) | |
| 241 | Low32Bits(static_cast<int64_t>(constant_values_[loc.orig_sreg])); |
| 242 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 243 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 244 | bool IsConstantNullRef(RegLocation loc) const { |
| 245 | return loc.ref && loc.is_const && (ConstantValue(loc) == 0); |
| 246 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 247 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 248 | int GetNumSSARegs() const { |
| 249 | return num_ssa_regs_; |
| 250 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 251 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 252 | void SetNumSSARegs(int new_num) { |
| 253 | num_ssa_regs_ = new_num; |
| 254 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 255 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 256 | int GetNumReachableBlocks() const { |
| 257 | return num_reachable_blocks_; |
| 258 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 259 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 260 | int GetUseCount(int vreg) const { |
| 261 | return GrowableListGetElement(&use_counts_, vreg); |
| 262 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 263 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 264 | int GetRawUseCount(int vreg) const { |
| 265 | return GrowableListGetElement(&raw_use_counts_, vreg); |
| 266 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 267 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 268 | int GetSSASubscript(int ssa_reg) const { |
| 269 | return GrowableListGetElement(ssa_subscripts_, ssa_reg); |
| 270 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 271 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 272 | const char* GetSSAString(int ssa_reg) const { |
| 273 | return GET_ELEM_N(ssa_strings_, char*, ssa_reg); |
| 274 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 275 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 276 | void BasicBlockCombine(); |
| 277 | void CodeLayout(); |
| 278 | void DumpCheckStats(); |
| 279 | void PropagateConstants(); |
| 280 | MIR* FindMoveResult(BasicBlock* bb, MIR* mir); |
| 281 | int SRegToVReg(int ssa_reg) const; |
| 282 | void VerifyDataflow(); |
| 283 | void MethodUseCount(); |
| 284 | void SSATransformation(); |
| 285 | void CheckForDominanceFrontier(BasicBlock* dom_bb, const BasicBlock* succ_bb); |
| 286 | void NullCheckElimination(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 287 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 288 | /* |
| 289 | * IsDebugBuild sanity check: keep track of the Dex PCs for catch entries so that later on |
| 290 | * we can verify that all catch entries have native PC entries. |
| 291 | */ |
| 292 | std::set<uint32_t> catches_; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 293 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 294 | private: |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 295 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 296 | int FindCommonParent(int block1, int block2); |
| 297 | void ComputeSuccLineIn(ArenaBitVector* dest, const ArenaBitVector* src1, |
| 298 | const ArenaBitVector* src2); |
| 299 | void HandleLiveInUse(ArenaBitVector* use_v, ArenaBitVector* def_v, |
| 300 | ArenaBitVector* live_in_v, int dalvik_reg_id); |
| 301 | void HandleDef(ArenaBitVector* def_v, int dalvik_reg_id); |
| 302 | void CompilerInitializeSSAConversion(); |
| 303 | bool DoSSAConversion(BasicBlock* bb); |
| 304 | bool InvokeUsesMethodStar(MIR* mir); |
| 305 | int ParseInsn(const uint16_t* code_ptr, DecodedInstruction* decoded_instruction); |
| 306 | bool ContentIsInsn(const uint16_t* code_ptr); |
| 307 | BasicBlock* SplitBlock(unsigned int code_offset, BasicBlock* orig_block, |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 308 | BasicBlock** immed_pred_block_p); |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 309 | BasicBlock* FindBlock(unsigned int code_offset, bool split, bool create, |
| 310 | BasicBlock** immed_pred_block_p); |
| 311 | void ProcessTryCatchBlocks(); |
| 312 | BasicBlock* ProcessCanBranch(BasicBlock* cur_block, MIR* insn, int cur_offset, int width, |
| 313 | int flags, const uint16_t* code_ptr, const uint16_t* code_end); |
| 314 | void ProcessCanSwitch(BasicBlock* cur_block, MIR* insn, int cur_offset, int width, int flags); |
| 315 | BasicBlock* ProcessCanThrow(BasicBlock* cur_block, MIR* insn, int cur_offset, int width, |
| 316 | int flags, ArenaBitVector* try_block_addr, const uint16_t* code_ptr, |
| 317 | const uint16_t* code_end); |
| 318 | int AddNewSReg(int v_reg); |
| 319 | void HandleSSAUse(int* uses, int dalvik_reg, int reg_index); |
| 320 | void HandleSSADef(int* defs, int dalvik_reg, int reg_index); |
| 321 | void DataFlowSSAFormat35C(MIR* mir); |
| 322 | void DataFlowSSAFormat3RC(MIR* mir); |
| 323 | bool FindLocalLiveIn(BasicBlock* bb); |
| 324 | bool ClearVisitedFlag(struct BasicBlock* bb); |
| 325 | bool CountUses(struct BasicBlock* bb); |
| 326 | bool InferTypeAndSize(BasicBlock* bb); |
| 327 | bool VerifyPredInfo(BasicBlock* bb); |
| 328 | BasicBlock* NeedsVisit(BasicBlock* bb); |
| 329 | BasicBlock* NextUnvisitedSuccessor(BasicBlock* bb); |
| 330 | void MarkPreOrder(BasicBlock* bb); |
| 331 | void RecordDFSOrders(BasicBlock* bb); |
| 332 | void ComputeDFSOrders(); |
| 333 | void ComputeDefBlockMatrix(); |
| 334 | void ComputeDomPostOrderTraversal(BasicBlock* bb); |
| 335 | void ComputeDominators(); |
| 336 | void InsertPhiNodes(); |
| 337 | void DoDFSPreOrderSSARename(BasicBlock* block); |
| 338 | void SetConstant(int32_t ssa_reg, int value); |
| 339 | void SetConstantWide(int ssa_reg, int64_t value); |
| 340 | int GetSSAUseCount(int s_reg); |
| 341 | bool BasicBlockOpt(BasicBlock* bb); |
| 342 | bool EliminateNullChecks(BasicBlock* bb); |
| 343 | bool NullCheckEliminationInit(BasicBlock* bb); |
| 344 | bool BuildExtendedBBList(struct BasicBlock* bb); |
| 345 | bool FillDefBlockMatrix(BasicBlock* bb); |
| 346 | bool InitializeDominationInfo(BasicBlock* bb); |
| 347 | bool ComputeblockIDom(BasicBlock* bb); |
| 348 | bool ComputeBlockDominators(BasicBlock* bb); |
| 349 | bool SetDominators(BasicBlock* bb); |
| 350 | bool ComputeBlockLiveIns(BasicBlock* bb); |
| 351 | bool InsertPhiNodeOperands(BasicBlock* bb); |
| 352 | bool ComputeDominanceFrontier(BasicBlock* bb); |
| 353 | bool DoConstantPropogation(BasicBlock* bb); |
| 354 | bool CountChecks(BasicBlock* bb); |
| 355 | bool CombineBlocks(BasicBlock* bb); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 356 | |
Ian Rogers | 71fe267 | 2013-03-19 20:45:02 -0700 | [diff] [blame^] | 357 | CompilationUnit* const cu_; |
| 358 | GrowableList* ssa_base_vregs_; |
| 359 | GrowableList* ssa_subscripts_; |
| 360 | GrowableList* ssa_strings_; |
| 361 | // Map original Dalvik virtual reg i to the current SSA name. |
| 362 | int* vreg_to_ssa_map_; // length == method->registers_size |
| 363 | int* ssa_last_defs_; // length == method->registers_size |
| 364 | ArenaBitVector* is_constant_v_; // length == num_ssa_reg |
| 365 | int* constant_values_; // length == num_ssa_reg |
| 366 | // Use counts of ssa names. |
| 367 | GrowableList use_counts_; // Weighted by nesting depth |
| 368 | GrowableList raw_use_counts_; // Not weighted |
| 369 | int num_reachable_blocks_; |
| 370 | GrowableList dfs_order_; |
| 371 | GrowableList dfs_post_order_; |
| 372 | GrowableList dom_post_order_traversal_; |
| 373 | int* i_dom_list_; |
| 374 | ArenaBitVector** def_block_matrix_; // num_dalvik_register x num_blocks. |
| 375 | ArenaBitVector* temp_block_v_; |
| 376 | ArenaBitVector* temp_dalvik_register_v_; |
| 377 | ArenaBitVector* temp_ssa_register_v_; // num_ssa_regs. |
| 378 | static const int kInvalidEntry = -1; |
| 379 | GrowableList block_list_; |
| 380 | ArenaBitVector* try_block_addr_; |
| 381 | BasicBlock* entry_block_; |
| 382 | BasicBlock* exit_block_; |
| 383 | BasicBlock* cur_block_; |
| 384 | int num_blocks_; |
| 385 | const DexFile::CodeItem* current_code_item_; |
| 386 | SafeMap<unsigned int, BasicBlock*> block_map_; // FindBlock lookup cache. |
| 387 | std::vector<DexCompilationUnit*> m_units_; // List of methods included in this graph |
| 388 | typedef std::pair<int, int> MIRLocation; // Insert point, (m_unit_ index, offset) |
| 389 | std::vector<MIRLocation> method_stack_; // Include stack |
| 390 | int current_method_; |
| 391 | int current_offset_; |
| 392 | int def_count_; // Used to estimate size of ssa name storage. |
| 393 | int* opcode_count_; // Dex opcode coverage stats. |
| 394 | int num_ssa_regs_; // Number of names following SSA transformation. |
| 395 | std::vector<BasicBlock*> extended_basic_blocks_; // Heads of block "traces". |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 396 | }; |
| 397 | |
| 398 | } // namespace art |
| 399 | |
| 400 | #endif // ART_SRC_COMPILER_DEX_MIRGRAPH_H_ |