blob: 32fac0b393f0709d482495b9d70bd3bb063f3a3f [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
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
17#include "compiler_internals.h"
18#include "dex/dataflow_iterator-inl.h"
19
20namespace art {
21
22bool MIRGraph::SetFp(int index, bool is_fp) {
23 bool change = false;
24 if (is_fp && !reg_location_[index].fp) {
25 reg_location_[index].fp = true;
26 reg_location_[index].defined = true;
27 change = true;
28 }
29 return change;
30}
31
buzbee28c23002013-09-07 09:12:27 -070032bool MIRGraph::SetFp(int index) {
33 bool change = false;
34 if (!reg_location_[index].fp) {
35 reg_location_[index].fp = true;
36 reg_location_[index].defined = true;
37 change = true;
38 }
39 return change;
40}
41
Brian Carlstrom7940e442013-07-12 13:46:57 -070042bool MIRGraph::SetCore(int index, bool is_core) {
43 bool change = false;
44 if (is_core && !reg_location_[index].defined) {
45 reg_location_[index].core = true;
46 reg_location_[index].defined = true;
47 change = true;
48 }
49 return change;
50}
51
buzbee28c23002013-09-07 09:12:27 -070052bool MIRGraph::SetCore(int index) {
53 bool change = false;
54 if (!reg_location_[index].defined) {
55 reg_location_[index].core = true;
56 reg_location_[index].defined = true;
57 change = true;
58 }
59 return change;
60}
61
Brian Carlstrom7940e442013-07-12 13:46:57 -070062bool MIRGraph::SetRef(int index, bool is_ref) {
63 bool change = false;
64 if (is_ref && !reg_location_[index].defined) {
65 reg_location_[index].ref = true;
66 reg_location_[index].defined = true;
67 change = true;
68 }
69 return change;
70}
71
buzbee28c23002013-09-07 09:12:27 -070072bool MIRGraph::SetRef(int index) {
73 bool change = false;
74 if (!reg_location_[index].defined) {
75 reg_location_[index].ref = true;
76 reg_location_[index].defined = true;
77 change = true;
78 }
79 return change;
80}
81
Brian Carlstrom7940e442013-07-12 13:46:57 -070082bool MIRGraph::SetWide(int index, bool is_wide) {
83 bool change = false;
84 if (is_wide && !reg_location_[index].wide) {
85 reg_location_[index].wide = true;
86 change = true;
87 }
88 return change;
89}
90
buzbee28c23002013-09-07 09:12:27 -070091bool MIRGraph::SetWide(int index) {
92 bool change = false;
93 if (!reg_location_[index].wide) {
94 reg_location_[index].wide = true;
95 change = true;
96 }
97 return change;
98}
99
Brian Carlstrom7940e442013-07-12 13:46:57 -0700100bool MIRGraph::SetHigh(int index, bool is_high) {
101 bool change = false;
102 if (is_high && !reg_location_[index].high_word) {
103 reg_location_[index].high_word = true;
104 change = true;
105 }
106 return change;
107}
108
buzbee28c23002013-09-07 09:12:27 -0700109bool MIRGraph::SetHigh(int index) {
110 bool change = false;
111 if (!reg_location_[index].high_word) {
112 reg_location_[index].high_word = true;
113 change = true;
114 }
115 return change;
116}
117
118
Brian Carlstrom7940e442013-07-12 13:46:57 -0700119/*
120 * Infer types and sizes. We don't need to track change on sizes,
121 * as it doesn't propagate. We're guaranteed at least one pass through
122 * the cfg.
123 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700124bool MIRGraph::InferTypeAndSize(BasicBlock* bb) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700125 MIR *mir;
126 bool changed = false; // Did anything change?
127
128 if (bb->data_flow_info == NULL) return false;
129 if (bb->block_type != kDalvikByteCode && bb->block_type != kEntryBlock)
130 return false;
131
132 for (mir = bb->first_mir_insn; mir != NULL; mir = mir->next) {
133 SSARepresentation *ssa_rep = mir->ssa_rep;
134 if (ssa_rep) {
135 int attrs = oat_data_flow_attributes_[mir->dalvikInsn.opcode];
buzbee28c23002013-09-07 09:12:27 -0700136 const int* uses = ssa_rep->uses;
137 const int* defs = ssa_rep->defs;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700138
139 // Handle defs
140 if (attrs & DF_DA) {
141 if (attrs & DF_CORE_A) {
buzbee28c23002013-09-07 09:12:27 -0700142 changed |= SetCore(defs[0]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700143 }
144 if (attrs & DF_REF_A) {
buzbee28c23002013-09-07 09:12:27 -0700145 changed |= SetRef(defs[0]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700146 }
147 if (attrs & DF_A_WIDE) {
buzbee28c23002013-09-07 09:12:27 -0700148 reg_location_[defs[0]].wide = true;
149 reg_location_[defs[1]].wide = true;
150 reg_location_[defs[1]].high_word = true;
151 DCHECK_EQ(SRegToVReg(defs[0])+1,
152 SRegToVReg(defs[1]));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700153 }
154 }
155
156 // Handles uses
157 int next = 0;
158 if (attrs & DF_UA) {
159 if (attrs & DF_CORE_A) {
buzbee28c23002013-09-07 09:12:27 -0700160 changed |= SetCore(uses[next]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700161 }
162 if (attrs & DF_REF_A) {
buzbee28c23002013-09-07 09:12:27 -0700163 changed |= SetRef(uses[next]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700164 }
165 if (attrs & DF_A_WIDE) {
buzbee28c23002013-09-07 09:12:27 -0700166 reg_location_[uses[next]].wide = true;
167 reg_location_[uses[next + 1]].wide = true;
168 reg_location_[uses[next + 1]].high_word = true;
169 DCHECK_EQ(SRegToVReg(uses[next])+1,
170 SRegToVReg(uses[next + 1]));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700171 next += 2;
172 } else {
173 next++;
174 }
175 }
176 if (attrs & DF_UB) {
177 if (attrs & DF_CORE_B) {
buzbee28c23002013-09-07 09:12:27 -0700178 changed |= SetCore(uses[next]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700179 }
180 if (attrs & DF_REF_B) {
buzbee28c23002013-09-07 09:12:27 -0700181 changed |= SetRef(uses[next]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700182 }
183 if (attrs & DF_B_WIDE) {
buzbee28c23002013-09-07 09:12:27 -0700184 reg_location_[uses[next]].wide = true;
185 reg_location_[uses[next + 1]].wide = true;
186 reg_location_[uses[next + 1]].high_word = true;
187 DCHECK_EQ(SRegToVReg(uses[next])+1,
188 SRegToVReg(uses[next + 1]));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700189 next += 2;
190 } else {
191 next++;
192 }
193 }
194 if (attrs & DF_UC) {
195 if (attrs & DF_CORE_C) {
buzbee28c23002013-09-07 09:12:27 -0700196 changed |= SetCore(uses[next]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700197 }
198 if (attrs & DF_REF_C) {
buzbee28c23002013-09-07 09:12:27 -0700199 changed |= SetRef(uses[next]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700200 }
201 if (attrs & DF_C_WIDE) {
buzbee28c23002013-09-07 09:12:27 -0700202 reg_location_[uses[next]].wide = true;
203 reg_location_[uses[next + 1]].wide = true;
204 reg_location_[uses[next + 1]].high_word = true;
205 DCHECK_EQ(SRegToVReg(uses[next])+1,
206 SRegToVReg(uses[next + 1]));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700207 }
208 }
209
210 // Special-case return handling
211 if ((mir->dalvikInsn.opcode == Instruction::RETURN) ||
212 (mir->dalvikInsn.opcode == Instruction::RETURN_WIDE) ||
213 (mir->dalvikInsn.opcode == Instruction::RETURN_OBJECT)) {
Brian Carlstromdf629502013-07-17 22:39:56 -0700214 switch (cu_->shorty[0]) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700215 case 'I':
buzbee28c23002013-09-07 09:12:27 -0700216 changed |= SetCore(uses[0]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700217 break;
218 case 'J':
buzbee28c23002013-09-07 09:12:27 -0700219 changed |= SetCore(uses[0]);
220 changed |= SetCore(uses[1]);
221 reg_location_[uses[0]].wide = true;
222 reg_location_[uses[1]].wide = true;
223 reg_location_[uses[1]].high_word = true;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700224 break;
225 case 'F':
buzbee28c23002013-09-07 09:12:27 -0700226 changed |= SetFp(uses[0]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700227 break;
228 case 'D':
buzbee28c23002013-09-07 09:12:27 -0700229 changed |= SetFp(uses[0]);
230 changed |= SetFp(uses[1]);
231 reg_location_[uses[0]].wide = true;
232 reg_location_[uses[1]].wide = true;
233 reg_location_[uses[1]].high_word = true;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700234 break;
235 case 'L':
buzbee28c23002013-09-07 09:12:27 -0700236 changed |= SetRef(uses[0]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700237 break;
238 default: break;
239 }
240 }
241
242 // Special-case handling for format 35c/3rc invokes
243 Instruction::Code opcode = mir->dalvikInsn.opcode;
244 int flags = (static_cast<int>(opcode) >= kNumPackedOpcodes)
245 ? 0 : Instruction::FlagsOf(mir->dalvikInsn.opcode);
246 if ((flags & Instruction::kInvoke) &&
247 (attrs & (DF_FORMAT_35C | DF_FORMAT_3RC))) {
248 DCHECK_EQ(next, 0);
249 int target_idx = mir->dalvikInsn.vB;
250 const char* shorty = GetShortyFromTargetIdx(target_idx);
251 // Handle result type if floating point
252 if ((shorty[0] == 'F') || (shorty[0] == 'D')) {
253 MIR* move_result_mir = FindMoveResult(bb, mir);
254 // Result might not be used at all, so no move-result
255 if (move_result_mir && (move_result_mir->dalvikInsn.opcode !=
256 Instruction::MOVE_RESULT_OBJECT)) {
257 SSARepresentation* tgt_rep = move_result_mir->ssa_rep;
258 DCHECK(tgt_rep != NULL);
259 tgt_rep->fp_def[0] = true;
buzbee28c23002013-09-07 09:12:27 -0700260 changed |= SetFp(tgt_rep->defs[0]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700261 if (shorty[0] == 'D') {
262 tgt_rep->fp_def[1] = true;
buzbee28c23002013-09-07 09:12:27 -0700263 changed |= SetFp(tgt_rep->defs[1]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700264 }
265 }
266 }
267 int num_uses = mir->dalvikInsn.vA;
268 // If this is a non-static invoke, mark implicit "this"
269 if (((mir->dalvikInsn.opcode != Instruction::INVOKE_STATIC) &&
270 (mir->dalvikInsn.opcode != Instruction::INVOKE_STATIC_RANGE))) {
buzbee28c23002013-09-07 09:12:27 -0700271 reg_location_[uses[next]].defined = true;
272 reg_location_[uses[next]].ref = true;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700273 next++;
274 }
275 uint32_t cpos = 1;
276 if (strlen(shorty) > 1) {
277 for (int i = next; i < num_uses;) {
278 DCHECK_LT(cpos, strlen(shorty));
279 switch (shorty[cpos++]) {
280 case 'D':
281 ssa_rep->fp_use[i] = true;
282 ssa_rep->fp_use[i+1] = true;
buzbee28c23002013-09-07 09:12:27 -0700283 reg_location_[uses[i]].wide = true;
284 reg_location_[uses[i+1]].wide = true;
285 reg_location_[uses[i+1]].high_word = true;
286 DCHECK_EQ(SRegToVReg(uses[i])+1, SRegToVReg(uses[i+1]));
Brian Carlstrom7940e442013-07-12 13:46:57 -0700287 i++;
288 break;
289 case 'J':
buzbee28c23002013-09-07 09:12:27 -0700290 reg_location_[uses[i]].wide = true;
291 reg_location_[uses[i+1]].wide = true;
292 reg_location_[uses[i+1]].high_word = true;
293 DCHECK_EQ(SRegToVReg(uses[i])+1, SRegToVReg(uses[i+1]));
294 changed |= SetCore(uses[i]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700295 i++;
296 break;
297 case 'F':
298 ssa_rep->fp_use[i] = true;
299 break;
300 case 'L':
buzbee28c23002013-09-07 09:12:27 -0700301 changed |= SetRef(uses[i]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700302 break;
303 default:
buzbee28c23002013-09-07 09:12:27 -0700304 changed |= SetCore(uses[i]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700305 break;
306 }
307 i++;
308 }
309 }
310 }
311
Brian Carlstrom38f85e42013-07-18 14:45:22 -0700312 for (int i = 0; ssa_rep->fp_use && i< ssa_rep->num_uses; i++) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700313 if (ssa_rep->fp_use[i])
buzbee28c23002013-09-07 09:12:27 -0700314 changed |= SetFp(uses[i]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700315 }
Brian Carlstrom38f85e42013-07-18 14:45:22 -0700316 for (int i = 0; ssa_rep->fp_def && i< ssa_rep->num_defs; i++) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700317 if (ssa_rep->fp_def[i])
buzbee28c23002013-09-07 09:12:27 -0700318 changed |= SetFp(defs[i]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700319 }
320 // Special-case handling for moves & Phi
321 if (attrs & (DF_IS_MOVE | DF_NULL_TRANSFER_N)) {
322 /*
323 * If any of our inputs or outputs is defined, set all.
324 * Some ugliness related to Phi nodes and wide values.
325 * The Phi set will include all low words or all high
326 * words, so we have to treat them specially.
327 */
328 bool is_phi = (static_cast<int>(mir->dalvikInsn.opcode) ==
329 kMirOpPhi);
buzbee28c23002013-09-07 09:12:27 -0700330 RegLocation rl_temp = reg_location_[defs[0]];
Brian Carlstrom7940e442013-07-12 13:46:57 -0700331 bool defined_fp = rl_temp.defined && rl_temp.fp;
332 bool defined_core = rl_temp.defined && rl_temp.core;
333 bool defined_ref = rl_temp.defined && rl_temp.ref;
334 bool is_wide = rl_temp.wide || ((attrs & DF_A_WIDE) != 0);
335 bool is_high = is_phi && rl_temp.wide && rl_temp.high_word;
Brian Carlstrom02c8cc62013-07-18 15:54:44 -0700336 for (int i = 0; i < ssa_rep->num_uses; i++) {
buzbee28c23002013-09-07 09:12:27 -0700337 rl_temp = reg_location_[uses[i]];
Brian Carlstrom7940e442013-07-12 13:46:57 -0700338 defined_fp |= rl_temp.defined && rl_temp.fp;
339 defined_core |= rl_temp.defined && rl_temp.core;
340 defined_ref |= rl_temp.defined && rl_temp.ref;
341 is_wide |= rl_temp.wide;
342 is_high |= is_phi && rl_temp.wide && rl_temp.high_word;
343 }
344 /*
345 * We don't normally expect to see a Dalvik register definition used both as a
346 * floating point and core value, though technically it could happen with constants.
347 * Until we have proper typing, detect this situation and disable register promotion
348 * (which relies on the distinction between core a fp usages).
349 */
350 if ((defined_fp && (defined_core | defined_ref)) &&
351 ((cu_->disable_opt & (1 << kPromoteRegs)) == 0)) {
352 LOG(WARNING) << PrettyMethod(cu_->method_idx, *cu_->dex_file)
353 << " op at block " << bb->id
354 << " has both fp and core/ref uses for same def.";
355 cu_->disable_opt |= (1 << kPromoteRegs);
356 }
buzbee28c23002013-09-07 09:12:27 -0700357 changed |= SetFp(defs[0], defined_fp);
358 changed |= SetCore(defs[0], defined_core);
359 changed |= SetRef(defs[0], defined_ref);
360 changed |= SetWide(defs[0], is_wide);
361 changed |= SetHigh(defs[0], is_high);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700362 if (attrs & DF_A_WIDE) {
buzbee28c23002013-09-07 09:12:27 -0700363 changed |= SetWide(defs[1]);
364 changed |= SetHigh(defs[1]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700365 }
366 for (int i = 0; i < ssa_rep->num_uses; i++) {
buzbee28c23002013-09-07 09:12:27 -0700367 changed |= SetFp(uses[i], defined_fp);
368 changed |= SetCore(uses[i], defined_core);
369 changed |= SetRef(uses[i], defined_ref);
370 changed |= SetWide(uses[i], is_wide);
371 changed |= SetHigh(uses[i], is_high);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700372 }
373 if (attrs & DF_A_WIDE) {
374 DCHECK_EQ(ssa_rep->num_uses, 2);
buzbee28c23002013-09-07 09:12:27 -0700375 changed |= SetWide(uses[1]);
376 changed |= SetHigh(uses[1]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700377 }
378 }
379 }
380 }
381 return changed;
382}
383
384static const char* storage_name[] = {" Frame ", "PhysReg", " Spill "};
385
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700386void MIRGraph::DumpRegLocTable(RegLocation* table, int count) {
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700387 // FIXME: Quick-specific. Move to Quick (and make a generic version for MIRGraph?
Brian Carlstrom7940e442013-07-12 13:46:57 -0700388 Mir2Lir* cg = static_cast<Mir2Lir*>(cu_->cg.get());
389 if (cg != NULL) {
390 for (int i = 0; i < count; i++) {
391 LOG(INFO) << StringPrintf("Loc[%02d] : %s, %c %c %c %c %c %c %c%d %c%d S%d",
392 table[i].orig_sreg, storage_name[table[i].location],
393 table[i].wide ? 'W' : 'N', table[i].defined ? 'D' : 'U',
394 table[i].fp ? 'F' : table[i].ref ? 'R' :'C',
395 table[i].is_const ? 'c' : 'n',
396 table[i].high_word ? 'H' : 'L', table[i].home ? 'h' : 't',
397 cg->IsFpReg(table[i].low_reg) ? 's' : 'r',
398 table[i].low_reg & cg->FpRegMask(),
399 cg->IsFpReg(table[i].high_reg) ? 's' : 'r',
400 table[i].high_reg & cg->FpRegMask(), table[i].s_reg_low);
401 }
402 } else {
403 // Either pre-regalloc or Portable.
404 for (int i = 0; i < count; i++) {
405 LOG(INFO) << StringPrintf("Loc[%02d] : %s, %c %c %c %c %c %c S%d",
406 table[i].orig_sreg, storage_name[table[i].location],
407 table[i].wide ? 'W' : 'N', table[i].defined ? 'D' : 'U',
408 table[i].fp ? 'F' : table[i].ref ? 'R' :'C',
409 table[i].is_const ? 'c' : 'n',
410 table[i].high_word ? 'H' : 'L', table[i].home ? 'h' : 't',
411 table[i].s_reg_low);
412 }
413 }
414}
415
416static const RegLocation fresh_loc = {kLocDalvikFrame, 0, 0, 0, 0, 0, 0, 0, 0,
417 INVALID_REG, INVALID_REG, INVALID_SREG,
418 INVALID_SREG};
419
420/*
421 * Simple register allocation. Some Dalvik virtual registers may
422 * be promoted to physical registers. Most of the work for temp
423 * allocation is done on the fly. We also do some initialization and
424 * type inference here.
425 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700426void MIRGraph::BuildRegLocations() {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700427 /* Allocate the location map */
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700428 RegLocation* loc = static_cast<RegLocation*>(arena_->Alloc(GetNumSSARegs() * sizeof(*loc),
429 ArenaAllocator::kAllocRegAlloc));
Brian Carlstrom38f85e42013-07-18 14:45:22 -0700430 for (int i = 0; i < GetNumSSARegs(); i++) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700431 loc[i] = fresh_loc;
432 loc[i].s_reg_low = i;
433 loc[i].is_const = is_constant_v_->IsBitSet(i);
434 }
435
436 /* Patch up the locations for Method* and the compiler temps */
437 loc[method_sreg_].location = kLocCompilerTemp;
438 loc[method_sreg_].defined = true;
Brian Carlstrom38f85e42013-07-18 14:45:22 -0700439 for (int i = 0; i < cu_->num_compiler_temps; i++) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700440 CompilerTemp* ct = compiler_temps_.Get(i);
441 loc[ct->s_reg].location = kLocCompilerTemp;
442 loc[ct->s_reg].defined = true;
443 }
444
445 reg_location_ = loc;
446
447 int num_regs = cu_->num_dalvik_registers;
448
449 /* Add types of incoming arguments based on signature */
450 int num_ins = cu_->num_ins;
451 if (num_ins > 0) {
452 int s_reg = num_regs - num_ins;
453 if ((cu_->access_flags & kAccStatic) == 0) {
454 // For non-static, skip past "this"
455 reg_location_[s_reg].defined = true;
456 reg_location_[s_reg].ref = true;
457 s_reg++;
458 }
459 const char* shorty = cu_->shorty;
460 int shorty_len = strlen(shorty);
461 for (int i = 1; i < shorty_len; i++) {
462 switch (shorty[i]) {
463 case 'D':
464 reg_location_[s_reg].wide = true;
465 reg_location_[s_reg+1].high_word = true;
466 reg_location_[s_reg+1].fp = true;
467 DCHECK_EQ(SRegToVReg(s_reg)+1, SRegToVReg(s_reg+1));
468 reg_location_[s_reg].fp = true;
469 reg_location_[s_reg].defined = true;
470 s_reg++;
471 break;
472 case 'J':
473 reg_location_[s_reg].wide = true;
474 reg_location_[s_reg+1].high_word = true;
475 DCHECK_EQ(SRegToVReg(s_reg)+1, SRegToVReg(s_reg+1));
476 reg_location_[s_reg].core = true;
477 reg_location_[s_reg].defined = true;
478 s_reg++;
479 break;
480 case 'F':
481 reg_location_[s_reg].fp = true;
482 reg_location_[s_reg].defined = true;
483 break;
484 case 'L':
485 reg_location_[s_reg].ref = true;
486 reg_location_[s_reg].defined = true;
487 break;
488 default:
489 reg_location_[s_reg].core = true;
490 reg_location_[s_reg].defined = true;
491 break;
492 }
493 s_reg++;
494 }
495 }
496
497 /* Do type & size inference pass */
buzbee56c71782013-09-05 17:13:19 -0700498 RepeatingPreOrderDfsIterator iter(this);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700499 bool change = false;
500 for (BasicBlock* bb = iter.Next(false); bb != NULL; bb = iter.Next(change)) {
501 change = InferTypeAndSize(bb);
502 }
503
504 /*
505 * Set the s_reg_low field to refer to the pre-SSA name of the
506 * base Dalvik virtual register. Once we add a better register
507 * allocator, remove this remapping.
508 */
Brian Carlstrom38f85e42013-07-18 14:45:22 -0700509 for (int i = 0; i < GetNumSSARegs(); i++) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700510 if (reg_location_[i].location != kLocCompilerTemp) {
511 int orig_sreg = reg_location_[i].s_reg_low;
512 reg_location_[i].orig_sreg = orig_sreg;
513 reg_location_[i].s_reg_low = SRegToVReg(orig_sreg);
514 }
515 }
516}
517
518} // namespace art