blob: db383c4d0b8f4d946f9aee82d0e72fccfad7b730 [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 */
buzbee1da1e2f2013-11-15 13:37:01 -0800124bool MIRGraph::InferTypeAndSize(BasicBlock* bb, MIR* mir, bool changed) {
125 SSARepresentation *ssa_rep = mir->ssa_rep;
buzbee8c7a02a2014-06-14 12:33:09 -0700126
127 /*
128 * The dex bytecode definition does not explicitly outlaw the definition of the same
129 * virtual register to be used in both a 32-bit and 64-bit pair context. However, dx
130 * does not generate this pattern (at least recently). Further, in the next revision of
131 * dex, we will forbid this. To support the few cases in the wild, detect this pattern
132 * and punt to the interpreter.
133 */
134 bool type_mismatch = false;
135
buzbee1da1e2f2013-11-15 13:37:01 -0800136 if (ssa_rep) {
Jean Christophe Beylercc794c32014-05-02 09:34:13 -0700137 uint64_t attrs = GetDataFlowAttributes(mir);
buzbee1da1e2f2013-11-15 13:37:01 -0800138 const int* uses = ssa_rep->uses;
139 const int* defs = ssa_rep->defs;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700140
buzbee1da1e2f2013-11-15 13:37:01 -0800141 // Handle defs
142 if (attrs & DF_DA) {
143 if (attrs & DF_CORE_A) {
144 changed |= SetCore(defs[0]);
145 }
146 if (attrs & DF_REF_A) {
147 changed |= SetRef(defs[0]);
148 }
149 if (attrs & DF_A_WIDE) {
150 reg_location_[defs[0]].wide = true;
151 reg_location_[defs[1]].wide = true;
152 reg_location_[defs[1]].high_word = true;
153 DCHECK_EQ(SRegToVReg(defs[0])+1,
154 SRegToVReg(defs[1]));
155 }
156 }
Brian Carlstrom7940e442013-07-12 13:46:57 -0700157
buzbee8c7a02a2014-06-14 12:33:09 -0700158
buzbee1da1e2f2013-11-15 13:37:01 -0800159 // Handles uses
160 int next = 0;
161 if (attrs & DF_UA) {
162 if (attrs & DF_CORE_A) {
163 changed |= SetCore(uses[next]);
164 }
165 if (attrs & DF_REF_A) {
166 changed |= SetRef(uses[next]);
167 }
168 if (attrs & DF_A_WIDE) {
169 reg_location_[uses[next]].wide = true;
170 reg_location_[uses[next + 1]].wide = true;
171 reg_location_[uses[next + 1]].high_word = true;
172 DCHECK_EQ(SRegToVReg(uses[next])+1,
173 SRegToVReg(uses[next + 1]));
174 next += 2;
175 } else {
buzbee8c7a02a2014-06-14 12:33:09 -0700176 type_mismatch |= reg_location_[uses[next]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800177 next++;
178 }
179 }
180 if (attrs & DF_UB) {
181 if (attrs & DF_CORE_B) {
182 changed |= SetCore(uses[next]);
183 }
184 if (attrs & DF_REF_B) {
185 changed |= SetRef(uses[next]);
186 }
187 if (attrs & DF_B_WIDE) {
188 reg_location_[uses[next]].wide = true;
189 reg_location_[uses[next + 1]].wide = true;
190 reg_location_[uses[next + 1]].high_word = true;
191 DCHECK_EQ(SRegToVReg(uses[next])+1,
192 SRegToVReg(uses[next + 1]));
193 next += 2;
194 } else {
buzbee8c7a02a2014-06-14 12:33:09 -0700195 type_mismatch |= reg_location_[uses[next]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800196 next++;
197 }
198 }
199 if (attrs & DF_UC) {
200 if (attrs & DF_CORE_C) {
201 changed |= SetCore(uses[next]);
202 }
203 if (attrs & DF_REF_C) {
204 changed |= SetRef(uses[next]);
205 }
206 if (attrs & DF_C_WIDE) {
207 reg_location_[uses[next]].wide = true;
208 reg_location_[uses[next + 1]].wide = true;
209 reg_location_[uses[next + 1]].high_word = true;
210 DCHECK_EQ(SRegToVReg(uses[next])+1,
211 SRegToVReg(uses[next + 1]));
buzbee8c7a02a2014-06-14 12:33:09 -0700212 } else {
213 type_mismatch |= reg_location_[uses[next]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800214 }
215 }
Brian Carlstrom7940e442013-07-12 13:46:57 -0700216
buzbee1da1e2f2013-11-15 13:37:01 -0800217 // Special-case return handling
218 if ((mir->dalvikInsn.opcode == Instruction::RETURN) ||
219 (mir->dalvikInsn.opcode == Instruction::RETURN_WIDE) ||
220 (mir->dalvikInsn.opcode == Instruction::RETURN_OBJECT)) {
221 switch (cu_->shorty[0]) {
222 case 'I':
buzbee8c7a02a2014-06-14 12:33:09 -0700223 type_mismatch |= reg_location_[uses[0]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800224 changed |= SetCore(uses[0]);
225 break;
226 case 'J':
227 changed |= SetCore(uses[0]);
228 changed |= SetCore(uses[1]);
229 reg_location_[uses[0]].wide = true;
230 reg_location_[uses[1]].wide = true;
231 reg_location_[uses[1]].high_word = true;
232 break;
233 case 'F':
buzbee8c7a02a2014-06-14 12:33:09 -0700234 type_mismatch |= reg_location_[uses[0]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800235 changed |= SetFp(uses[0]);
236 break;
237 case 'D':
238 changed |= SetFp(uses[0]);
239 changed |= SetFp(uses[1]);
240 reg_location_[uses[0]].wide = true;
241 reg_location_[uses[1]].wide = true;
242 reg_location_[uses[1]].high_word = true;
243 break;
244 case 'L':
buzbee8c7a02a2014-06-14 12:33:09 -0700245 type_mismatch |= reg_location_[uses[0]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800246 changed |= SetRef(uses[0]);
247 break;
248 default: break;
249 }
250 }
251
252 // Special-case handling for format 35c/3rc invokes
253 Instruction::Code opcode = mir->dalvikInsn.opcode;
buzbee35ba7f32014-05-31 08:59:01 -0700254 int flags = IsPseudoMirOp(opcode) ? 0 : Instruction::FlagsOf(mir->dalvikInsn.opcode);
buzbee1da1e2f2013-11-15 13:37:01 -0800255 if ((flags & Instruction::kInvoke) &&
256 (attrs & (DF_FORMAT_35C | DF_FORMAT_3RC))) {
257 DCHECK_EQ(next, 0);
258 int target_idx = mir->dalvikInsn.vB;
259 const char* shorty = GetShortyFromTargetIdx(target_idx);
260 // Handle result type if floating point
261 if ((shorty[0] == 'F') || (shorty[0] == 'D')) {
262 MIR* move_result_mir = FindMoveResult(bb, mir);
263 // Result might not be used at all, so no move-result
264 if (move_result_mir && (move_result_mir->dalvikInsn.opcode !=
265 Instruction::MOVE_RESULT_OBJECT)) {
266 SSARepresentation* tgt_rep = move_result_mir->ssa_rep;
267 DCHECK(tgt_rep != NULL);
268 tgt_rep->fp_def[0] = true;
269 changed |= SetFp(tgt_rep->defs[0]);
270 if (shorty[0] == 'D') {
271 tgt_rep->fp_def[1] = true;
272 changed |= SetFp(tgt_rep->defs[1]);
273 }
Brian Carlstrom7940e442013-07-12 13:46:57 -0700274 }
275 }
buzbee1da1e2f2013-11-15 13:37:01 -0800276 int num_uses = mir->dalvikInsn.vA;
277 // If this is a non-static invoke, mark implicit "this"
278 if (((mir->dalvikInsn.opcode != Instruction::INVOKE_STATIC) &&
279 (mir->dalvikInsn.opcode != Instruction::INVOKE_STATIC_RANGE))) {
280 reg_location_[uses[next]].defined = true;
281 reg_location_[uses[next]].ref = true;
buzbee8c7a02a2014-06-14 12:33:09 -0700282 type_mismatch |= reg_location_[uses[next]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800283 next++;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700284 }
buzbee1da1e2f2013-11-15 13:37:01 -0800285 uint32_t cpos = 1;
286 if (strlen(shorty) > 1) {
287 for (int i = next; i < num_uses;) {
288 DCHECK_LT(cpos, strlen(shorty));
289 switch (shorty[cpos++]) {
290 case 'D':
291 ssa_rep->fp_use[i] = true;
292 ssa_rep->fp_use[i+1] = true;
293 reg_location_[uses[i]].wide = true;
294 reg_location_[uses[i+1]].wide = true;
295 reg_location_[uses[i+1]].high_word = true;
296 DCHECK_EQ(SRegToVReg(uses[i])+1, SRegToVReg(uses[i+1]));
297 i++;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700298 break;
299 case 'J':
buzbee1da1e2f2013-11-15 13:37:01 -0800300 reg_location_[uses[i]].wide = true;
301 reg_location_[uses[i+1]].wide = true;
302 reg_location_[uses[i+1]].high_word = true;
303 DCHECK_EQ(SRegToVReg(uses[i])+1, SRegToVReg(uses[i+1]));
304 changed |= SetCore(uses[i]);
305 i++;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700306 break;
307 case 'F':
buzbee8c7a02a2014-06-14 12:33:09 -0700308 type_mismatch |= reg_location_[uses[i]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800309 ssa_rep->fp_use[i] = true;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700310 break;
311 case 'L':
buzbee8c7a02a2014-06-14 12:33:09 -0700312 type_mismatch |= reg_location_[uses[i]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800313 changed |= SetRef(uses[i]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700314 break;
buzbee1da1e2f2013-11-15 13:37:01 -0800315 default:
buzbee8c7a02a2014-06-14 12:33:09 -0700316 type_mismatch |= reg_location_[uses[i]].wide;
buzbee1da1e2f2013-11-15 13:37:01 -0800317 changed |= SetCore(uses[i]);
318 break;
319 }
320 i++;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700321 }
322 }
buzbee1da1e2f2013-11-15 13:37:01 -0800323 }
Brian Carlstrom7940e442013-07-12 13:46:57 -0700324
buzbee1da1e2f2013-11-15 13:37:01 -0800325 for (int i = 0; ssa_rep->fp_use && i< ssa_rep->num_uses; i++) {
326 if (ssa_rep->fp_use[i])
327 changed |= SetFp(uses[i]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700328 }
buzbee1da1e2f2013-11-15 13:37:01 -0800329 for (int i = 0; ssa_rep->fp_def && i< ssa_rep->num_defs; i++) {
330 if (ssa_rep->fp_def[i])
331 changed |= SetFp(defs[i]);
332 }
333 // Special-case handling for moves & Phi
334 if (attrs & (DF_IS_MOVE | DF_NULL_TRANSFER_N)) {
335 /*
336 * If any of our inputs or outputs is defined, set all.
337 * Some ugliness related to Phi nodes and wide values.
338 * The Phi set will include all low words or all high
339 * words, so we have to treat them specially.
340 */
buzbee35ba7f32014-05-31 08:59:01 -0700341 bool is_phi = (static_cast<int>(mir->dalvikInsn.opcode) == kMirOpPhi);
buzbee1da1e2f2013-11-15 13:37:01 -0800342 RegLocation rl_temp = reg_location_[defs[0]];
343 bool defined_fp = rl_temp.defined && rl_temp.fp;
344 bool defined_core = rl_temp.defined && rl_temp.core;
345 bool defined_ref = rl_temp.defined && rl_temp.ref;
346 bool is_wide = rl_temp.wide || ((attrs & DF_A_WIDE) != 0);
347 bool is_high = is_phi && rl_temp.wide && rl_temp.high_word;
348 for (int i = 0; i < ssa_rep->num_uses; i++) {
349 rl_temp = reg_location_[uses[i]];
350 defined_fp |= rl_temp.defined && rl_temp.fp;
351 defined_core |= rl_temp.defined && rl_temp.core;
352 defined_ref |= rl_temp.defined && rl_temp.ref;
353 is_wide |= rl_temp.wide;
354 is_high |= is_phi && rl_temp.wide && rl_temp.high_word;
355 }
356 /*
357 * We don't normally expect to see a Dalvik register definition used both as a
358 * floating point and core value, though technically it could happen with constants.
359 * Until we have proper typing, detect this situation and disable register promotion
360 * (which relies on the distinction between core a fp usages).
361 */
362 if ((defined_fp && (defined_core | defined_ref)) &&
363 ((cu_->disable_opt & (1 << kPromoteRegs)) == 0)) {
364 LOG(WARNING) << PrettyMethod(cu_->method_idx, *cu_->dex_file)
365 << " op at block " << bb->id
366 << " has both fp and core/ref uses for same def.";
367 cu_->disable_opt |= (1 << kPromoteRegs);
368 }
369 changed |= SetFp(defs[0], defined_fp);
370 changed |= SetCore(defs[0], defined_core);
371 changed |= SetRef(defs[0], defined_ref);
372 changed |= SetWide(defs[0], is_wide);
373 changed |= SetHigh(defs[0], is_high);
374 if (attrs & DF_A_WIDE) {
375 changed |= SetWide(defs[1]);
376 changed |= SetHigh(defs[1]);
377 }
378 for (int i = 0; i < ssa_rep->num_uses; i++) {
379 changed |= SetFp(uses[i], defined_fp);
380 changed |= SetCore(uses[i], defined_core);
381 changed |= SetRef(uses[i], defined_ref);
382 changed |= SetWide(uses[i], is_wide);
383 changed |= SetHigh(uses[i], is_high);
384 }
385 if (attrs & DF_A_WIDE) {
386 DCHECK_EQ(ssa_rep->num_uses, 2);
387 changed |= SetWide(uses[1]);
388 changed |= SetHigh(uses[1]);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700389 }
390 }
391 }
buzbee8c7a02a2014-06-14 12:33:09 -0700392 if (type_mismatch) {
393 LOG(WARNING) << "Deprecated dex type mismatch, interpreting "
394 << PrettyMethod(cu_->method_idx, *cu_->dex_file);
395 LOG(INFO) << "@ 0x" << std::hex << mir->offset;
396 SetPuntToInterpreter(true);
397 }
Brian Carlstrom7940e442013-07-12 13:46:57 -0700398 return changed;
399}
400
401static const char* storage_name[] = {" Frame ", "PhysReg", " Spill "};
402
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700403void MIRGraph::DumpRegLocTable(RegLocation* table, int count) {
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700404 // FIXME: Quick-specific. Move to Quick (and make a generic version for MIRGraph?
Brian Carlstrom7940e442013-07-12 13:46:57 -0700405 Mir2Lir* cg = static_cast<Mir2Lir*>(cu_->cg.get());
406 if (cg != NULL) {
407 for (int i = 0; i < count; i++) {
Bill Buzbee00e1ec62014-02-27 23:44:13 +0000408 LOG(INFO) << StringPrintf("Loc[%02d] : %s, %c %c %c %c %c %c 0x%04x S%d",
Brian Carlstrom7940e442013-07-12 13:46:57 -0700409 table[i].orig_sreg, storage_name[table[i].location],
410 table[i].wide ? 'W' : 'N', table[i].defined ? 'D' : 'U',
411 table[i].fp ? 'F' : table[i].ref ? 'R' :'C',
412 table[i].is_const ? 'c' : 'n',
413 table[i].high_word ? 'H' : 'L', table[i].home ? 'h' : 't',
Bill Buzbee00e1ec62014-02-27 23:44:13 +0000414 table[i].reg.GetRawBits(),
415 table[i].s_reg_low);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700416 }
417 } else {
418 // Either pre-regalloc or Portable.
419 for (int i = 0; i < count; i++) {
420 LOG(INFO) << StringPrintf("Loc[%02d] : %s, %c %c %c %c %c %c S%d",
421 table[i].orig_sreg, storage_name[table[i].location],
422 table[i].wide ? 'W' : 'N', table[i].defined ? 'D' : 'U',
423 table[i].fp ? 'F' : table[i].ref ? 'R' :'C',
424 table[i].is_const ? 'c' : 'n',
425 table[i].high_word ? 'H' : 'L', table[i].home ? 'h' : 't',
426 table[i].s_reg_low);
427 }
428 }
429}
430
Bill Buzbee00e1ec62014-02-27 23:44:13 +0000431// FIXME - will likely need to revisit all uses of this.
buzbee091cc402014-03-31 10:14:40 -0700432static const RegLocation fresh_loc = {kLocDalvikFrame, 0, 0, 0, 0, 0, 0, 0, 0,
Bill Buzbee00e1ec62014-02-27 23:44:13 +0000433 RegStorage(), INVALID_SREG, INVALID_SREG};
Brian Carlstrom7940e442013-07-12 13:46:57 -0700434
buzbee1da1e2f2013-11-15 13:37:01 -0800435void MIRGraph::InitRegLocations() {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700436 /* Allocate the location map */
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800437 int max_regs = GetNumSSARegs() + GetMaxPossibleCompilerTemps();
438 RegLocation* loc = static_cast<RegLocation*>(arena_->Alloc(max_regs * sizeof(*loc),
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000439 kArenaAllocRegAlloc));
Brian Carlstrom38f85e42013-07-18 14:45:22 -0700440 for (int i = 0; i < GetNumSSARegs(); i++) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700441 loc[i] = fresh_loc;
442 loc[i].s_reg_low = i;
443 loc[i].is_const = is_constant_v_->IsBitSet(i);
Jean Christophe Beyler1ceea7e2014-04-15 16:18:48 -0700444 loc[i].wide = false;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700445 }
446
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800447 /* Patch up the locations for the compiler temps */
448 GrowableArray<CompilerTemp*>::Iterator iter(&compiler_temps_);
449 for (CompilerTemp* ct = iter.Next(); ct != NULL; ct = iter.Next()) {
450 loc[ct->s_reg_low].location = kLocCompilerTemp;
451 loc[ct->s_reg_low].defined = true;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700452 }
453
buzbeef2c3e562014-05-29 12:37:25 -0700454 /* Treat Method* as a normal reference */
455 loc[GetMethodSReg()].ref = true;
456
Brian Carlstrom7940e442013-07-12 13:46:57 -0700457 reg_location_ = loc;
458
459 int num_regs = cu_->num_dalvik_registers;
460
461 /* Add types of incoming arguments based on signature */
462 int num_ins = cu_->num_ins;
463 if (num_ins > 0) {
464 int s_reg = num_regs - num_ins;
465 if ((cu_->access_flags & kAccStatic) == 0) {
466 // For non-static, skip past "this"
467 reg_location_[s_reg].defined = true;
468 reg_location_[s_reg].ref = true;
469 s_reg++;
470 }
471 const char* shorty = cu_->shorty;
472 int shorty_len = strlen(shorty);
473 for (int i = 1; i < shorty_len; i++) {
474 switch (shorty[i]) {
475 case 'D':
476 reg_location_[s_reg].wide = true;
477 reg_location_[s_reg+1].high_word = true;
478 reg_location_[s_reg+1].fp = true;
479 DCHECK_EQ(SRegToVReg(s_reg)+1, SRegToVReg(s_reg+1));
480 reg_location_[s_reg].fp = true;
481 reg_location_[s_reg].defined = true;
482 s_reg++;
483 break;
484 case 'J':
485 reg_location_[s_reg].wide = true;
486 reg_location_[s_reg+1].high_word = true;
487 DCHECK_EQ(SRegToVReg(s_reg)+1, SRegToVReg(s_reg+1));
488 reg_location_[s_reg].core = true;
489 reg_location_[s_reg].defined = true;
490 s_reg++;
491 break;
492 case 'F':
493 reg_location_[s_reg].fp = true;
494 reg_location_[s_reg].defined = true;
495 break;
496 case 'L':
497 reg_location_[s_reg].ref = true;
498 reg_location_[s_reg].defined = true;
499 break;
500 default:
501 reg_location_[s_reg].core = true;
502 reg_location_[s_reg].defined = true;
503 break;
504 }
505 s_reg++;
506 }
507 }
buzbee1da1e2f2013-11-15 13:37:01 -0800508}
Brian Carlstrom7940e442013-07-12 13:46:57 -0700509
buzbee1da1e2f2013-11-15 13:37:01 -0800510/*
511 * Set the s_reg_low field to refer to the pre-SSA name of the
512 * base Dalvik virtual register. Once we add a better register
513 * allocator, remove this remapping.
514 */
515void MIRGraph::RemapRegLocations() {
Brian Carlstrom38f85e42013-07-18 14:45:22 -0700516 for (int i = 0; i < GetNumSSARegs(); i++) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700517 if (reg_location_[i].location != kLocCompilerTemp) {
518 int orig_sreg = reg_location_[i].s_reg_low;
519 reg_location_[i].orig_sreg = orig_sreg;
520 reg_location_[i].s_reg_low = SRegToVReg(orig_sreg);
521 }
522 }
523}
524
525} // namespace art