buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | |
buzbee | efc6369 | 2012-11-14 16:31:52 -0800 | [diff] [blame] | 17 | #include "compiler_internals.h" |
| 18 | #include "dataflow.h" |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 19 | #include "codegen/ralloc_util.h" |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 20 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 21 | namespace art { |
| 22 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 23 | static bool SetFp(CompilationUnit* cu, int index, bool is_fp) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 24 | bool change = false; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 25 | if (is_fp && !cu->reg_location[index].fp) { |
| 26 | cu->reg_location[index].fp = true; |
| 27 | cu->reg_location[index].defined = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 28 | change = true; |
| 29 | } |
| 30 | return change; |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 31 | } |
| 32 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 33 | static bool SetCore(CompilationUnit* cu, int index, bool is_core) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 34 | bool change = false; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 35 | if (is_core && !cu->reg_location[index].defined) { |
| 36 | cu->reg_location[index].core = true; |
| 37 | cu->reg_location[index].defined = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 38 | change = true; |
| 39 | } |
| 40 | return change; |
buzbee | 03fa263 | 2011-09-20 17:10:57 -0700 | [diff] [blame] | 41 | } |
| 42 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 43 | static bool SetRef(CompilationUnit* cu, int index, bool is_ref) { |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 44 | bool change = false; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 45 | if (is_ref && !cu->reg_location[index].defined) { |
| 46 | cu->reg_location[index].ref = true; |
| 47 | cu->reg_location[index].defined = true; |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 48 | change = true; |
| 49 | } |
| 50 | return change; |
| 51 | } |
| 52 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 53 | static bool SetWide(CompilationUnit* cu, int index, bool is_wide) { |
buzbee | 2a83e8f | 2012-07-13 16:42:30 -0700 | [diff] [blame] | 54 | bool change = false; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 55 | if (is_wide && !cu->reg_location[index].wide) { |
| 56 | cu->reg_location[index].wide = true; |
buzbee | 2a83e8f | 2012-07-13 16:42:30 -0700 | [diff] [blame] | 57 | change = true; |
| 58 | } |
| 59 | return change; |
| 60 | } |
| 61 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 62 | static bool SetHigh(CompilationUnit* cu, int index, bool is_high) { |
buzbee | 2a83e8f | 2012-07-13 16:42:30 -0700 | [diff] [blame] | 63 | bool change = false; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 64 | if (is_high && !cu->reg_location[index].high_word) { |
| 65 | cu->reg_location[index].high_word = true; |
buzbee | 2a83e8f | 2012-07-13 16:42:30 -0700 | [diff] [blame] | 66 | change = true; |
| 67 | } |
| 68 | return change; |
| 69 | } |
| 70 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 71 | static bool RemapNames(CompilationUnit* cu, BasicBlock* bb) |
buzbee | c0ecd65 | 2011-09-25 18:11:54 -0700 | [diff] [blame] | 72 | { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 73 | if (bb->block_type != kDalvikByteCode && bb->block_type != kEntryBlock && |
| 74 | bb->block_type != kExitBlock) |
buzbee | c0ecd65 | 2011-09-25 18:11:54 -0700 | [diff] [blame] | 75 | return false; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 76 | |
buzbee | 28c9a83 | 2012-11-21 15:39:13 -0800 | [diff] [blame^] | 77 | for (MIR* mir = bb->first_mir_insn; mir != NULL; mir = mir->next) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 78 | SSARepresentation *ssa_rep = mir->ssa_rep; |
| 79 | if (ssa_rep) { |
| 80 | for (int i = 0; i < ssa_rep->num_uses; i++) { |
| 81 | ssa_rep->uses[i] = cu->phi_alias_map[ssa_rep->uses[i]]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 82 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 83 | for (int i = 0; i < ssa_rep->num_defs; i++) { |
| 84 | ssa_rep->defs[i] = cu->phi_alias_map[ssa_rep->defs[i]]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 85 | } |
| 86 | } |
| 87 | } |
| 88 | return false; |
buzbee | c0ecd65 | 2011-09-25 18:11:54 -0700 | [diff] [blame] | 89 | } |
| 90 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 91 | /* |
buzbee | 03fa263 | 2011-09-20 17:10:57 -0700 | [diff] [blame] | 92 | * Infer types and sizes. We don't need to track change on sizes, |
| 93 | * as it doesn't propagate. We're guaranteed at least one pass through |
| 94 | * the cfg. |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 95 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 96 | static bool InferTypeAndSize(CompilationUnit* cu, BasicBlock* bb) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 97 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 98 | MIR *mir; |
| 99 | bool changed = false; // Did anything change? |
buzbee | 03fa263 | 2011-09-20 17:10:57 -0700 | [diff] [blame] | 100 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 101 | if (bb->data_flow_info == NULL) return false; |
| 102 | if (bb->block_type != kDalvikByteCode && bb->block_type != kEntryBlock) |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 103 | return false; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 104 | |
buzbee | 28c9a83 | 2012-11-21 15:39:13 -0800 | [diff] [blame^] | 105 | for (mir = bb->first_mir_insn; mir != NULL; mir = mir->next) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 106 | SSARepresentation *ssa_rep = mir->ssa_rep; |
| 107 | if (ssa_rep) { |
| 108 | int attrs = oat_data_flow_attributes[mir->dalvikInsn.opcode]; |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 109 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 110 | // Handle defs |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 111 | if (attrs & DF_DA) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 112 | if (attrs & DF_CORE_A) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 113 | changed |= SetCore(cu, ssa_rep->defs[0], true); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 114 | } |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 115 | if (attrs & DF_REF_A) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 116 | changed |= SetRef(cu, ssa_rep->defs[0], true); |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 117 | } |
| 118 | if (attrs & DF_A_WIDE) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 119 | cu->reg_location[ssa_rep->defs[0]].wide = true; |
| 120 | cu->reg_location[ssa_rep->defs[1]].wide = true; |
| 121 | cu->reg_location[ssa_rep->defs[1]].high_word = true; |
| 122 | DCHECK_EQ(SRegToVReg(cu, ssa_rep->defs[0])+1, |
| 123 | SRegToVReg(cu, ssa_rep->defs[1])); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | |
| 127 | // Handles uses |
| 128 | int next = 0; |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 129 | if (attrs & DF_UA) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 130 | if (attrs & DF_CORE_A) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 131 | changed |= SetCore(cu, ssa_rep->uses[next], true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 132 | } |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 133 | if (attrs & DF_REF_A) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 134 | changed |= SetRef(cu, ssa_rep->uses[next], true); |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 135 | } |
| 136 | if (attrs & DF_A_WIDE) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 137 | cu->reg_location[ssa_rep->uses[next]].wide = true; |
| 138 | cu->reg_location[ssa_rep->uses[next + 1]].wide = true; |
| 139 | cu->reg_location[ssa_rep->uses[next + 1]].high_word = true; |
| 140 | DCHECK_EQ(SRegToVReg(cu, ssa_rep->uses[next])+1, |
| 141 | SRegToVReg(cu, ssa_rep->uses[next + 1])); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 142 | next += 2; |
| 143 | } else { |
| 144 | next++; |
| 145 | } |
| 146 | } |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 147 | if (attrs & DF_UB) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 148 | if (attrs & DF_CORE_B) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 149 | changed |= SetCore(cu, ssa_rep->uses[next], true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 150 | } |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 151 | if (attrs & DF_REF_B) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 152 | changed |= SetRef(cu, ssa_rep->uses[next], true); |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 153 | } |
| 154 | if (attrs & DF_B_WIDE) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 155 | cu->reg_location[ssa_rep->uses[next]].wide = true; |
| 156 | cu->reg_location[ssa_rep->uses[next + 1]].wide = true; |
| 157 | cu->reg_location[ssa_rep->uses[next + 1]].high_word = true; |
| 158 | DCHECK_EQ(SRegToVReg(cu, ssa_rep->uses[next])+1, |
| 159 | SRegToVReg(cu, ssa_rep->uses[next + 1])); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 160 | next += 2; |
| 161 | } else { |
| 162 | next++; |
| 163 | } |
| 164 | } |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 165 | if (attrs & DF_UC) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 166 | if (attrs & DF_CORE_C) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 167 | changed |= SetCore(cu, ssa_rep->uses[next], true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 168 | } |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 169 | if (attrs & DF_REF_C) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 170 | changed |= SetRef(cu, ssa_rep->uses[next], true); |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 171 | } |
| 172 | if (attrs & DF_C_WIDE) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 173 | cu->reg_location[ssa_rep->uses[next]].wide = true; |
| 174 | cu->reg_location[ssa_rep->uses[next + 1]].wide = true; |
| 175 | cu->reg_location[ssa_rep->uses[next + 1]].high_word = true; |
| 176 | DCHECK_EQ(SRegToVReg(cu, ssa_rep->uses[next])+1, |
| 177 | SRegToVReg(cu, ssa_rep->uses[next + 1])); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 178 | } |
| 179 | } |
| 180 | |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 181 | // Special-case return handling |
| 182 | if ((mir->dalvikInsn.opcode == Instruction::RETURN) || |
| 183 | (mir->dalvikInsn.opcode == Instruction::RETURN_WIDE) || |
| 184 | (mir->dalvikInsn.opcode == Instruction::RETURN_OBJECT)) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 185 | switch(cu->shorty[0]) { |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 186 | case 'I': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 187 | changed |= SetCore(cu, ssa_rep->uses[0], true); |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 188 | break; |
| 189 | case 'J': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 190 | changed |= SetCore(cu, ssa_rep->uses[0], true); |
| 191 | changed |= SetCore(cu, ssa_rep->uses[1], true); |
| 192 | cu->reg_location[ssa_rep->uses[0]].wide = true; |
| 193 | cu->reg_location[ssa_rep->uses[1]].wide = true; |
| 194 | cu->reg_location[ssa_rep->uses[1]].high_word = true; |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 195 | break; |
| 196 | case 'F': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 197 | changed |= SetFp(cu, ssa_rep->uses[0], true); |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 198 | break; |
| 199 | case 'D': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 200 | changed |= SetFp(cu, ssa_rep->uses[0], true); |
| 201 | changed |= SetFp(cu, ssa_rep->uses[1], true); |
| 202 | cu->reg_location[ssa_rep->uses[0]].wide = true; |
| 203 | cu->reg_location[ssa_rep->uses[1]].wide = true; |
| 204 | cu->reg_location[ssa_rep->uses[1]].high_word = true; |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 205 | break; |
| 206 | case 'L': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 207 | changed |= SetRef(cu, ssa_rep->uses[0], true); |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 208 | break; |
| 209 | default: break; |
| 210 | } |
| 211 | } |
| 212 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 213 | // Special-case handling for format 35c/3rc invokes |
| 214 | Instruction::Code opcode = mir->dalvikInsn.opcode; |
| 215 | int flags = (static_cast<int>(opcode) >= kNumPackedOpcodes) |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 216 | ? 0 : Instruction::FlagsOf(mir->dalvikInsn.opcode); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 217 | if ((flags & Instruction::kInvoke) && |
| 218 | (attrs & (DF_FORMAT_35C | DF_FORMAT_3RC))) { |
| 219 | DCHECK_EQ(next, 0); |
| 220 | int target_idx = mir->dalvikInsn.vB; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 221 | const char* shorty = GetShortyFromTargetIdx(cu, target_idx); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 222 | // Handle result type if floating point |
| 223 | if ((shorty[0] == 'F') || (shorty[0] == 'D')) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 224 | MIR* move_result_mir = FindMoveResult(cu, bb, mir); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 225 | // Result might not be used at all, so no move-result |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 226 | if (move_result_mir && (move_result_mir->dalvikInsn.opcode != |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 227 | Instruction::MOVE_RESULT_OBJECT)) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 228 | SSARepresentation* tgt_rep = move_result_mir->ssa_rep; |
| 229 | DCHECK(tgt_rep != NULL); |
| 230 | tgt_rep->fp_def[0] = true; |
| 231 | changed |= SetFp(cu, tgt_rep->defs[0], true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 232 | if (shorty[0] == 'D') { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 233 | tgt_rep->fp_def[1] = true; |
| 234 | changed |= SetFp(cu, tgt_rep->defs[1], true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 238 | int num_uses = mir->dalvikInsn.vA; |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 239 | // If this is a non-static invoke, mark implicit "this" |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 240 | if (((mir->dalvikInsn.opcode != Instruction::INVOKE_STATIC) && |
| 241 | (mir->dalvikInsn.opcode != Instruction::INVOKE_STATIC_RANGE))) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 242 | cu->reg_location[ssa_rep->uses[next]].defined = true; |
| 243 | cu->reg_location[ssa_rep->uses[next]].ref = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 244 | next++; |
| 245 | } |
| 246 | uint32_t cpos = 1; |
| 247 | if (strlen(shorty) > 1) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 248 | for (int i = next; i < num_uses;) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 249 | DCHECK_LT(cpos, strlen(shorty)); |
| 250 | switch (shorty[cpos++]) { |
| 251 | case 'D': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 252 | ssa_rep->fp_use[i] = true; |
| 253 | ssa_rep->fp_use[i+1] = true; |
| 254 | cu->reg_location[ssa_rep->uses[i]].wide = true; |
| 255 | cu->reg_location[ssa_rep->uses[i+1]].wide = true; |
| 256 | cu->reg_location[ssa_rep->uses[i+1]].high_word = true; |
| 257 | DCHECK_EQ(SRegToVReg(cu, ssa_rep->uses[i])+1, |
| 258 | SRegToVReg(cu, ssa_rep->uses[i+1])); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 259 | i++; |
| 260 | break; |
| 261 | case 'J': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 262 | cu->reg_location[ssa_rep->uses[i]].wide = true; |
| 263 | cu->reg_location[ssa_rep->uses[i+1]].wide = true; |
| 264 | cu->reg_location[ssa_rep->uses[i+1]].high_word = true; |
| 265 | DCHECK_EQ(SRegToVReg(cu, ssa_rep->uses[i])+1, |
| 266 | SRegToVReg(cu, ssa_rep->uses[i+1])); |
| 267 | changed |= SetCore(cu, ssa_rep->uses[i],true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 268 | i++; |
| 269 | break; |
| 270 | case 'F': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 271 | ssa_rep->fp_use[i] = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 272 | break; |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 273 | case 'L': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 274 | changed |= SetRef(cu,ssa_rep->uses[i], true); |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 275 | break; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 276 | default: |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 277 | changed |= SetCore(cu,ssa_rep->uses[i], true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 278 | break; |
| 279 | } |
| 280 | i++; |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 285 | for (int i=0; ssa_rep->fp_use && i< ssa_rep->num_uses; i++) { |
| 286 | if (ssa_rep->fp_use[i]) |
| 287 | changed |= SetFp(cu, ssa_rep->uses[i], true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 288 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 289 | for (int i=0; ssa_rep->fp_def && i< ssa_rep->num_defs; i++) { |
| 290 | if (ssa_rep->fp_def[i]) |
| 291 | changed |= SetFp(cu, ssa_rep->defs[i], true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 292 | } |
| 293 | // Special-case handling for moves & Phi |
| 294 | if (attrs & (DF_IS_MOVE | DF_NULL_TRANSFER_N)) { |
buzbee | 2a83e8f | 2012-07-13 16:42:30 -0700 | [diff] [blame] | 295 | /* |
| 296 | * If any of our inputs or outputs is defined, set all. |
| 297 | * Some ugliness related to Phi nodes and wide values. |
| 298 | * The Phi set will include all low words or all high |
| 299 | * words, so we have to treat them specially. |
| 300 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 301 | bool is_phi = (static_cast<int>(mir->dalvikInsn.opcode) == |
buzbee | 2a83e8f | 2012-07-13 16:42:30 -0700 | [diff] [blame] | 302 | kMirOpPhi); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 303 | RegLocation rl_temp = cu->reg_location[ssa_rep->defs[0]]; |
| 304 | bool defined_fp = rl_temp.defined && rl_temp.fp; |
| 305 | bool defined_core = rl_temp.defined && rl_temp.core; |
| 306 | bool defined_ref = rl_temp.defined && rl_temp.ref; |
| 307 | bool is_wide = rl_temp.wide || ((attrs & DF_A_WIDE) != 0); |
| 308 | bool is_high = is_phi && rl_temp.wide && rl_temp.high_word; |
| 309 | for (int i = 0; i < ssa_rep->num_uses;i++) { |
| 310 | rl_temp = cu->reg_location[ssa_rep->uses[i]]; |
| 311 | defined_fp |= rl_temp.defined && rl_temp.fp; |
| 312 | defined_core |= rl_temp.defined && rl_temp.core; |
| 313 | defined_ref |= rl_temp.defined && rl_temp.ref; |
| 314 | is_wide |= rl_temp.wide; |
| 315 | is_high |= is_phi && rl_temp.wide && rl_temp.high_word; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 316 | } |
| 317 | /* |
| 318 | * TODO: cleaner fix |
| 319 | * We don't normally expect to see a Dalvik register |
| 320 | * definition used both as a floating point and core |
| 321 | * value. However, the instruction rewriting that occurs |
| 322 | * during verification can eliminate some type information, |
| 323 | * leaving us confused. The real fix here is either to |
| 324 | * add explicit type information to Dalvik byte codes, |
| 325 | * or to recognize THROW_VERIFICATION_ERROR as |
| 326 | * an unconditional branch and support dead code elimination. |
| 327 | * As a workaround we can detect this situation and |
| 328 | * disable register promotion (which is the only thing that |
| 329 | * relies on distinctions between core and fp usages. |
| 330 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 331 | if ((defined_fp && (defined_core | defined_ref)) && |
| 332 | ((cu->disable_opt & (1 << kPromoteRegs)) == 0)) { |
| 333 | LOG(WARNING) << PrettyMethod(cu->method_idx, *cu->dex_file) |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 334 | << " op at block " << bb->id |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 335 | << " has both fp and core/ref uses for same def."; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 336 | cu->disable_opt |= (1 << kPromoteRegs); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 337 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 338 | changed |= SetFp(cu, ssa_rep->defs[0], defined_fp); |
| 339 | changed |= SetCore(cu, ssa_rep->defs[0], defined_core); |
| 340 | changed |= SetRef(cu, ssa_rep->defs[0], defined_ref); |
| 341 | changed |= SetWide(cu, ssa_rep->defs[0], is_wide); |
| 342 | changed |= SetHigh(cu, ssa_rep->defs[0], is_high); |
buzbee | 2a83e8f | 2012-07-13 16:42:30 -0700 | [diff] [blame] | 343 | if (attrs & DF_A_WIDE) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 344 | changed |= SetWide(cu, ssa_rep->defs[1], true); |
| 345 | changed |= SetHigh(cu, ssa_rep->defs[1], true); |
buzbee | 2a83e8f | 2012-07-13 16:42:30 -0700 | [diff] [blame] | 346 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 347 | for (int i = 0; i < ssa_rep->num_uses; i++) { |
| 348 | changed |= SetFp(cu, ssa_rep->uses[i], defined_fp); |
| 349 | changed |= SetCore(cu, ssa_rep->uses[i], defined_core); |
| 350 | changed |= SetRef(cu, ssa_rep->uses[i], defined_ref); |
| 351 | changed |= SetWide(cu, ssa_rep->uses[i], is_wide); |
| 352 | changed |= SetHigh(cu, ssa_rep->uses[i], is_high); |
buzbee | 2a83e8f | 2012-07-13 16:42:30 -0700 | [diff] [blame] | 353 | } |
| 354 | if (attrs & DF_A_WIDE) { |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 355 | DCHECK_EQ(ssa_rep->num_uses, 2); |
| 356 | changed |= SetWide(cu, ssa_rep->uses[1], true); |
| 357 | changed |= SetHigh(cu, ssa_rep->uses[1], true); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 358 | } |
| 359 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 360 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 361 | } |
| 362 | return changed; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 363 | } |
| 364 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 365 | static const char* storage_name[] = {" Frame ", "PhysReg", " Spill "}; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 366 | |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame] | 367 | static void DumpRegLocTable(RegLocation* table, int count) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 368 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 369 | for (int i = 0; i < count; i++) { |
| 370 | LOG(INFO) << StringPrintf("Loc[%02d] : %s, %c %c %c %c %c %c%d %c%d S%d", |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 371 | table[i].orig_sreg, storage_name[table[i].location], |
buzbee | ca7a5e4 | 2012-08-20 11:12:18 -0700 | [diff] [blame] | 372 | table[i].wide ? 'W' : 'N', table[i].defined ? 'D' : 'U', |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 373 | table[i].fp ? 'F' : table[i].ref ? 'R' :'C', |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 374 | table[i].high_word ? 'H' : 'L', table[i].home ? 'h' : 't', |
| 375 | IsFpReg(table[i].low_reg) ? 's' : 'r', |
| 376 | table[i].low_reg & FpRegMask(), |
| 377 | IsFpReg(table[i].high_reg) ? 's' : 'r', |
| 378 | table[i].high_reg & FpRegMask(), table[i].s_reg_low); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 379 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 380 | } |
| 381 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 382 | static const RegLocation fresh_loc = {kLocDalvikFrame, 0, 0, 0, 0, 0, 0, 0, 0, |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 383 | INVALID_REG, INVALID_REG, INVALID_SREG, |
| 384 | INVALID_SREG}; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 385 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 386 | int ComputeFrameSize(CompilationUnit* cu) { |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 387 | /* Figure out the frame size */ |
| 388 | static const uint32_t kAlignMask = kStackAlignment - 1; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 389 | uint32_t size = (cu->num_core_spills + cu->num_fp_spills + |
| 390 | 1 /* filler word */ + cu->num_regs + cu->num_outs + |
| 391 | cu->num_compiler_temps + 1 /* cur_method* */) |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 392 | * sizeof(uint32_t); |
| 393 | /* Align and set */ |
| 394 | return (size + kAlignMask) & ~(kAlignMask); |
| 395 | } |
| 396 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 397 | /* |
| 398 | * Simple register allocation. Some Dalvik virtual registers may |
| 399 | * be promoted to physical registers. Most of the work for temp |
Ian Rogers | b5d09b2 | 2012-03-06 22:14:17 -0800 | [diff] [blame] | 400 | * allocation is done on the fly. We also do some initialization and |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 401 | * type inference here. |
| 402 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 403 | void SimpleRegAlloc(CompilationUnit* cu) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 404 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 405 | int i; |
| 406 | RegLocation* loc; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 407 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 408 | /* Allocate the location map */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 409 | loc = static_cast<RegLocation*>(NewMem(cu, cu->num_ssa_regs * sizeof(*loc), |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 410 | true, kAllocRegAlloc)); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 411 | for (i=0; i< cu->num_ssa_regs; i++) { |
| 412 | loc[i] = fresh_loc; |
| 413 | loc[i].s_reg_low = i; |
| 414 | loc[i].is_const = IsBitSet(cu->is_constant_v, i); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | /* Patch up the locations for Method* and the compiler temps */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 418 | loc[cu->method_sreg].location = kLocCompilerTemp; |
| 419 | loc[cu->method_sreg].defined = true; |
| 420 | for (i = 0; i < cu->num_compiler_temps; i++) { |
| 421 | CompilerTemp* ct = reinterpret_cast<CompilerTemp*>(cu->compiler_temps.elem_list[i]); |
| 422 | loc[ct->s_reg].location = kLocCompilerTemp; |
| 423 | loc[ct->s_reg].defined = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 424 | } |
| 425 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 426 | cu->reg_location = loc; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 427 | |
| 428 | /* Allocation the promotion map */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 429 | int num_regs = cu->num_dalvik_registers; |
| 430 | cu->promotion_map = static_cast<PromotionMap*> |
| 431 | (NewMem(cu, (num_regs + cu->num_compiler_temps + 1) * sizeof(cu->promotion_map[0]), |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 432 | true, kAllocRegAlloc)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 433 | |
| 434 | /* Add types of incoming arguments based on signature */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 435 | int num_ins = cu->num_ins; |
| 436 | if (num_ins > 0) { |
| 437 | int s_reg = num_regs - num_ins; |
| 438 | if ((cu->access_flags & kAccStatic) == 0) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 439 | // For non-static, skip past "this" |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 440 | cu->reg_location[s_reg].defined = true; |
| 441 | cu->reg_location[s_reg].ref = true; |
| 442 | s_reg++; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 443 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 444 | const char* shorty = cu->shorty; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 445 | int shorty_len = strlen(shorty); |
| 446 | for (int i = 1; i < shorty_len; i++) { |
| 447 | switch (shorty[i]) { |
| 448 | case 'D': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 449 | cu->reg_location[s_reg].wide = true; |
| 450 | cu->reg_location[s_reg+1].high_word = true; |
| 451 | cu->reg_location[s_reg+1].fp = true; |
| 452 | DCHECK_EQ(SRegToVReg(cu, s_reg)+1, SRegToVReg(cu, s_reg+1)); |
| 453 | cu->reg_location[s_reg].fp = true; |
| 454 | cu->reg_location[s_reg].defined = true; |
| 455 | s_reg++; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 456 | break; |
| 457 | case 'J': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 458 | cu->reg_location[s_reg].wide = true; |
| 459 | cu->reg_location[s_reg+1].high_word = true; |
| 460 | DCHECK_EQ(SRegToVReg(cu, s_reg)+1, SRegToVReg(cu, s_reg+1)); |
| 461 | cu->reg_location[s_reg].core = true; |
| 462 | cu->reg_location[s_reg].defined = true; |
| 463 | s_reg++; |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 464 | break; |
| 465 | case 'F': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 466 | cu->reg_location[s_reg].fp = true; |
| 467 | cu->reg_location[s_reg].defined = true; |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 468 | break; |
| 469 | case 'L': |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 470 | cu->reg_location[s_reg].ref = true; |
| 471 | cu->reg_location[s_reg].defined = true; |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 472 | break; |
| 473 | default: |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 474 | cu->reg_location[s_reg].core = true; |
| 475 | cu->reg_location[s_reg].defined = true; |
buzbee | d501889 | 2012-07-11 14:23:40 -0700 | [diff] [blame] | 476 | break; |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 477 | } |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 478 | s_reg++; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 482 | if (!cu->gen_bitcode) { |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 483 | /* Remap names */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 484 | DataFlowAnalysisDispatcher(cu, RemapNames, |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 485 | kPreOrderDFSTraversal, |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 486 | false /* is_iterative */); |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 487 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 488 | |
| 489 | /* Do type & size inference pass */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 490 | DataFlowAnalysisDispatcher(cu, InferTypeAndSize, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 491 | kPreOrderDFSTraversal, |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 492 | true /* is_iterative */); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 493 | |
| 494 | /* |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 495 | * Set the s_reg_low field to refer to the pre-SSA name of the |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 496 | * base Dalvik virtual register. Once we add a better register |
| 497 | * allocator, remove this remapping. |
| 498 | */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 499 | for (i=0; i < cu->num_ssa_regs; i++) { |
| 500 | if (cu->reg_location[i].location != kLocCompilerTemp) { |
| 501 | int orig_sreg = cu->reg_location[i].s_reg_low; |
| 502 | cu->reg_location[i].orig_sreg = orig_sreg; |
| 503 | cu->reg_location[i].s_reg_low = SRegToVReg(cu, orig_sreg); |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 504 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 505 | } |
buzbee | e9a72f6 | 2011-09-04 17:59:07 -0700 | [diff] [blame] | 506 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 507 | cu->core_spill_mask = 0; |
| 508 | cu->fp_spill_mask = 0; |
| 509 | cu->num_core_spills = 0; |
buzbee | c0ecd65 | 2011-09-25 18:11:54 -0700 | [diff] [blame] | 510 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 511 | DoPromotion(cu); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 512 | |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 513 | /* Get easily-accessable post-promotion copy of RegLocation for Method* */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 514 | cu->method_loc = cu->reg_location[cu->method_sreg]; |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 515 | |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 516 | if (cu->verbose && !(cu->disable_opt & (1 << kPromoteRegs))) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 517 | LOG(INFO) << "After Promotion"; |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 518 | DumpRegLocTable(cu->reg_location, cu->num_ssa_regs); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 519 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 520 | |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 521 | /* Set the frame size */ |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 522 | cu->frame_size = ComputeFrameSize(cu); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 523 | } |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 524 | |
| 525 | } // namespace art |