2 * mini-codegen.c: Arch independent code generation functionality
4 * (C) 2003 Ximian, Inc.
12 #include <mono/metadata/appdomain.h>
13 #include <mono/metadata/debug-helpers.h>
14 #include <mono/metadata/threads.h>
15 #include <mono/metadata/profiler-private.h>
16 #include <mono/utils/mono-math.h>
21 #include "mini-arch.h"
23 #define DEBUG(a) if (cfg->verbose_level > 1) a
25 #if defined(__x86_64__)
26 const char * const amd64_desc [OP_LAST];
27 static const char*const * ins_spec = amd64_desc;
28 #elif defined(__sparc__) || defined(sparc)
29 const char * const sparc_desc [OP_LAST];
30 static const char*const * ins_spec = sparc_desc;
31 #elif defined(__i386__)
32 const char * const pentium_desc [OP_LAST];
33 static const char*const * ins_spec = pentium_desc;
34 #elif defined(__ia64__)
35 const char * const ia64_desc [OP_LAST];
36 static const char*const * ins_spec = ia64_desc;
38 #error "Not implemented"
41 #define use_fpstack MONO_ARCH_USE_FPSTACK
44 mono_regname_full (int reg, gboolean fp)
47 return mono_arch_fregname (reg);
49 return mono_arch_regname (reg);
53 mono_call_inst_add_outarg_reg (MonoCallInst *call, int vreg, int hreg, gboolean fp)
57 regpair = (((guint32)hreg) << 24) + vreg;
59 call->out_freg_args = g_slist_append (call->out_freg_args, (gpointer)(gssize)(regpair));
61 call->out_ireg_args = g_slist_append (call->out_ireg_args, (gpointer)(gssize)(regpair));
65 * returns the offset used by spillvar. It allocates a new
66 * spill variable if necessary.
69 mono_spillvar_offset (MonoCompile *cfg, int spillvar)
71 MonoSpillInfo **si, *info;
74 si = &cfg->spill_info;
76 while (i <= spillvar) {
79 *si = info = mono_mempool_alloc (cfg->mempool, sizeof (MonoSpillInfo));
81 cfg->stack_offset += sizeof (gpointer);
82 info->offset = - cfg->stack_offset;
92 g_assert_not_reached ();
97 * returns the offset used by spillvar. It allocates a new
98 * spill float variable if necessary.
99 * (same as mono_spillvar_offset but for float)
102 mono_spillvar_offset_float (MonoCompile *cfg, int spillvar)
104 MonoSpillInfo **si, *info;
107 si = &cfg->spill_info_float;
109 while (i <= spillvar) {
112 *si = info = mono_mempool_alloc (cfg->mempool, sizeof (MonoSpillInfo));
114 cfg->stack_offset += sizeof (double);
115 info->offset = - cfg->stack_offset;
119 return (*si)->offset;
125 g_assert_not_reached ();
130 * Creates a store for spilled floating point items
133 create_spilled_store_float (MonoCompile *cfg, int spill, int reg, MonoInst *ins)
136 MONO_INST_NEW (cfg, store, OP_STORER8_MEMBASE_REG);
138 store->inst_destbasereg = cfg->frame_reg;
139 store->inst_offset = mono_spillvar_offset_float (cfg, spill);
141 DEBUG (g_print ("SPILLED FLOAT STORE (%d at 0x%08lx(%%sp)) (from %d)\n", spill, (long)store->inst_offset, reg));
146 * Creates a load for spilled floating point items
149 create_spilled_load_float (MonoCompile *cfg, int spill, int reg, MonoInst *ins)
152 MONO_INST_NEW (cfg, load, OP_LOADR8_SPILL_MEMBASE);
154 load->inst_basereg = cfg->frame_reg;
155 load->inst_offset = mono_spillvar_offset_float (cfg, spill);
157 DEBUG (g_print ("SPILLED FLOAT LOAD (%d at 0x%08lx(%%sp)) (from %d)\n", spill, (long)load->inst_offset, reg));
161 #define is_hard_ireg(r) ((r) >= 0 && (r) < MONO_MAX_IREGS)
162 #define is_hard_freg(r) ((r) >= 0 && (r) < MONO_MAX_FREGS)
163 #define is_global_ireg(r) (is_hard_ireg ((r)) && (MONO_ARCH_CALLEE_SAVED_REGS & (1 << (r))))
164 #define is_local_ireg(r) (is_hard_ireg ((r)) && (MONO_ARCH_CALLEE_REGS & (1 << (r))))
165 #define is_global_freg(r) (is_hard_freg ((r)) && (MONO_ARCH_CALLEE_SAVED_FREGS & (1 << (r))))
166 #define is_local_freg(r) (is_hard_ireg ((r)) && (MONO_ARCH_CALLEE_FREGS & (1 << (r))))
167 #define ireg_is_freeable(r) is_local_ireg ((r))
168 #define freg_is_freeable(r) is_hard_freg ((r))
170 #define reg_is_freeable(r,fp) ((fp) ? freg_is_freeable ((r)) : ireg_is_freeable ((r)))
171 #define is_hard_reg(r,fp) ((fp) ? ((r) < MONO_MAX_FREGS) : ((r) < MONO_MAX_IREGS))
172 #define is_soft_reg(r,fp) (!is_hard_reg((r),(fp)))
173 #define rassign(cfg,reg,fp) ((fp) ? (cfg)->rs->fassign [(reg)] : (cfg)->rs->iassign [(reg)])
174 #define sreg1_is_fp(ins) (ins_spec [(ins)->opcode] [MONO_INST_SRC1] == 'f')
175 #define sreg2_is_fp(ins) (ins_spec [(ins)->opcode] [MONO_INST_SRC2] == 'f')
177 #ifdef MONO_ARCH_INST_IS_FLOAT
178 #define dreg_is_fp(ins) (MONO_ARCH_INST_IS_FLOAT (ins_spec [(ins)->opcode] [MONO_INST_DEST]))
180 #define dreg_is_fp(ins) (ins_spec [(ins)->opcode] [MONO_INST_DEST] == 'f')
183 #define regpair_reg2_mask(desc,hreg1) ((MONO_ARCH_INST_REGPAIR_REG2 (desc,hreg1) != -1) ? (1 << MONO_ARCH_INST_REGPAIR_REG2 (desc,hreg1)) : MONO_ARCH_CALLEE_REGS)
190 int flags; /* used to track fp spill/load */
191 guint32 preferred_mask; /* the hreg where the register should be allocated, or 0 */
195 print_ins (int i, MonoInst *ins)
197 const char *spec = ins_spec [ins->opcode];
198 g_print ("\t%-2d %s", i, mono_inst_name (ins->opcode));
200 g_error ("Unknown opcode: %s\n", mono_inst_name (ins->opcode));
202 if (spec [MONO_INST_DEST]) {
203 gboolean fp = dreg_is_fp (ins);
204 if (is_soft_reg (ins->dreg, fp))
205 g_print (" R%d <-", ins->dreg);
206 else if (spec [MONO_INST_DEST] == 'b') {
207 if (ins->inst_offset == 0)
208 g_print (" [%s] <-", mono_arch_regname (ins->dreg));
210 g_print (" [%s + 0x%lx] <-", mono_arch_regname (ins->dreg), (long)ins->inst_offset);
212 g_print (" %s <-", mono_regname_full (ins->dreg, fp));
214 if (spec [MONO_INST_SRC1]) {
215 gboolean fp = (spec [MONO_INST_SRC1] == 'f');
216 if (is_soft_reg (ins->sreg1, fp))
217 g_print (" R%d", ins->sreg1);
218 else if (spec [MONO_INST_SRC1] == 'b')
219 g_print (" [%s + 0x%lx]", mono_arch_regname (ins->sreg1), (long)ins->inst_offset);
221 g_print (" %s", mono_regname_full (ins->sreg1, fp));
223 if (spec [MONO_INST_SRC2]) {
224 gboolean fp = (spec [MONO_INST_SRC2] == 'f');
225 if (is_soft_reg (ins->sreg2, fp))
226 g_print (" R%d", ins->sreg2);
228 g_print (" %s", mono_regname_full (ins->sreg2, fp));
230 if (spec [MONO_INST_CLOB])
231 g_print (" clobbers: %c", spec [MONO_INST_CLOB]);
236 print_regtrack (RegTrack *t, int num)
242 for (i = 0; i < num; ++i) {
245 if (i >= MONO_MAX_IREGS) {
246 g_snprintf (buf, sizeof(buf), "R%d", i);
249 r = mono_arch_regname (i);
250 g_print ("liveness: %s [%d - %d]\n", r, t [i].born_in, t[i].last_use);
254 typedef struct InstList InstList;
262 static inline InstList*
263 inst_list_prepend (MonoMemPool *pool, InstList *list, MonoInst *data)
265 InstList *item = mono_mempool_alloc (pool, sizeof (InstList));
275 * Force the spilling of the variable in the symbolic register 'reg'.
278 get_register_force_spilling (MonoCompile *cfg, InstList *item, MonoInst *ins, int reg, gboolean fp)
282 int *assign, *symbolic;
285 assign = cfg->rs->fassign;
286 symbolic = cfg->rs->fsymbolic;
289 assign = cfg->rs->iassign;
290 symbolic = cfg->rs->isymbolic;
294 /*i = cfg->rs->isymbolic [sel];
295 g_assert (i == reg);*/
297 spill = ++cfg->spill_count;
298 assign [i] = -spill - 1;
300 mono_regstate_free_float (cfg->rs, sel);
302 mono_regstate_free_int (cfg->rs, sel);
303 /* we need to create a spill var and insert a load to sel after the current instruction */
305 MONO_INST_NEW (cfg, load, OP_LOADR8_MEMBASE);
307 MONO_INST_NEW (cfg, load, OP_LOAD_MEMBASE);
309 load->inst_basereg = cfg->frame_reg;
310 load->inst_offset = mono_spillvar_offset (cfg, spill);
312 while (ins->next != item->prev->data)
315 load->next = ins->next;
317 DEBUG (g_print ("SPILLED LOAD (%d at 0x%08lx(%%ebp)) R%d (freed %s)\n", spill, (long)load->inst_offset, i, mono_regname_full (sel, fp)));
319 i = mono_regstate_alloc_float (cfg->rs, 1 << sel);
321 i = mono_regstate_alloc_int (cfg->rs, 1 << sel);
328 get_register_spilling (MonoCompile *cfg, InstList *item, MonoInst *ins, guint32 regmask, int reg, gboolean fp)
332 int *assign, *symbolic;
335 assign = cfg->rs->fassign;
336 symbolic = cfg->rs->fsymbolic;
339 assign = cfg->rs->iassign;
340 symbolic = cfg->rs->isymbolic;
343 DEBUG (g_print ("\tstart regmask to assign R%d: 0x%08x (R%d <- R%d R%d)\n", reg, regmask, ins->dreg, ins->sreg1, ins->sreg2));
344 /* exclude the registers in the current instruction */
345 if ((sreg1_is_fp (ins) == fp) && (reg != ins->sreg1) && (reg_is_freeable (ins->sreg1, fp) || (is_soft_reg (ins->sreg1, fp) && rassign (cfg, ins->sreg1, fp) >= 0))) {
346 if (is_soft_reg (ins->sreg1, fp))
347 regmask &= ~ (1 << rassign (cfg, ins->sreg1, fp));
349 regmask &= ~ (1 << ins->sreg1);
350 DEBUG (g_print ("\t\texcluding sreg1 %s\n", mono_regname_full (ins->sreg1, fp)));
352 if ((sreg2_is_fp (ins) == fp) && (reg != ins->sreg2) && (reg_is_freeable (ins->sreg2, fp) || (is_soft_reg (ins->sreg2, fp) && rassign (cfg, ins->sreg2, fp) >= 0))) {
353 if (is_soft_reg (ins->sreg2, fp))
354 regmask &= ~ (1 << rassign (cfg, ins->sreg2, fp));
356 regmask &= ~ (1 << ins->sreg2);
357 DEBUG (g_print ("\t\texcluding sreg2 %s %d\n", mono_regname_full (ins->sreg2, fp), ins->sreg2));
359 if ((dreg_is_fp (ins) == fp) && (reg != ins->dreg) && reg_is_freeable (ins->dreg, fp)) {
360 regmask &= ~ (1 << ins->dreg);
361 DEBUG (g_print ("\t\texcluding dreg %s\n", mono_regname_full (ins->dreg, fp)));
364 DEBUG (g_print ("\t\tavailable regmask: 0x%08x\n", regmask));
365 g_assert (regmask); /* need at least a register we can free */
367 /* we should track prev_use and spill the register that's farther */
369 for (i = 0; i < MONO_MAX_FREGS; ++i) {
370 if (regmask & (1 << i)) {
372 DEBUG (g_print ("\t\tselected register %s has assignment %d\n", mono_arch_fregname (sel), cfg->rs->fsymbolic [sel]));
377 i = cfg->rs->fsymbolic [sel];
378 spill = ++cfg->spill_count;
379 cfg->rs->fassign [i] = -spill - 1;
380 mono_regstate_free_float (cfg->rs, sel);
383 for (i = 0; i < MONO_MAX_IREGS; ++i) {
384 if (regmask & (1 << i)) {
386 DEBUG (g_print ("\t\tselected register %s has assignment %d\n", mono_arch_regname (sel), cfg->rs->isymbolic [sel]));
391 i = cfg->rs->isymbolic [sel];
392 spill = ++cfg->spill_count;
393 cfg->rs->iassign [i] = -spill - 1;
394 mono_regstate_free_int (cfg->rs, sel);
397 /* we need to create a spill var and insert a load to sel after the current instruction */
398 MONO_INST_NEW (cfg, load, fp ? OP_LOADR8_MEMBASE : OP_LOAD_MEMBASE);
400 load->inst_basereg = cfg->frame_reg;
401 load->inst_offset = mono_spillvar_offset (cfg, spill);
403 while (ins->next != item->prev->data)
406 load->next = ins->next;
408 DEBUG (g_print ("\tSPILLED LOAD (%d at 0x%08lx(%%ebp)) R%d (freed %s)\n", spill, (long)load->inst_offset, i, mono_regname_full (sel, fp)));
410 i = mono_regstate_alloc_float (cfg->rs, 1 << sel);
412 i = mono_regstate_alloc_int (cfg->rs, 1 << sel);
419 free_up_ireg (MonoCompile *cfg, InstList *item, MonoInst *ins, int hreg)
421 if (!(cfg->rs->ifree_mask & (1 << hreg))) {
422 DEBUG (g_print ("\tforced spill of R%d\n", cfg->rs->isymbolic [hreg]));
423 get_register_force_spilling (cfg, item, ins, cfg->rs->isymbolic [hreg], FALSE);
424 mono_regstate_free_int (cfg->rs, hreg);
429 free_up_reg (MonoCompile *cfg, InstList *item, MonoInst *ins, int hreg, gboolean fp)
432 if (!(cfg->rs->ffree_mask & (1 << hreg))) {
433 DEBUG (g_print ("\tforced spill of R%d\n", cfg->rs->isymbolic [hreg]));
434 get_register_force_spilling (cfg, item, ins, cfg->rs->isymbolic [hreg], fp);
435 mono_regstate_free_float (cfg->rs, hreg);
439 if (!(cfg->rs->ifree_mask & (1 << hreg))) {
440 DEBUG (g_print ("\tforced spill of R%d\n", cfg->rs->isymbolic [hreg]));
441 get_register_force_spilling (cfg, item, ins, cfg->rs->isymbolic [hreg], fp);
442 mono_regstate_free_int (cfg->rs, hreg);
448 create_copy_ins (MonoCompile *cfg, int dest, int src, MonoInst *ins, gboolean fp)
453 MONO_INST_NEW (cfg, copy, OP_FMOVE);
455 MONO_INST_NEW (cfg, copy, OP_MOVE);
460 copy->next = ins->next;
463 DEBUG (g_print ("\tforced copy from %s to %s\n", mono_regname_full (src, fp), mono_regname_full (dest, fp)));
468 create_spilled_store (MonoCompile *cfg, int spill, int reg, int prev_reg, MonoInst *ins, gboolean fp)
471 MONO_INST_NEW (cfg, store, fp ? OP_STORER8_MEMBASE_REG : OP_STORE_MEMBASE_REG);
473 store->inst_destbasereg = cfg->frame_reg;
474 store->inst_offset = mono_spillvar_offset (cfg, spill);
476 store->next = ins->next;
479 DEBUG (g_print ("\tSPILLED STORE (%d at 0x%08lx(%%ebp)) R%d (from %s)\n", spill, (long)store->inst_offset, prev_reg, mono_regname_full (reg, fp)));
484 insert_before_ins (MonoInst *ins, InstList *item, MonoInst* to_insert)
488 prev = item->next->data;
490 while (prev->next != ins)
492 to_insert->next = ins;
493 prev->next = to_insert;
495 to_insert->next = ins;
498 * needed otherwise in the next instruction we can add an ins to the
499 * end and that would get past this instruction.
501 item->data = to_insert;
504 /* flags used in reginfo->flags */
506 MONO_FP_NEEDS_LOAD_SPILL = 1 << 0,
507 MONO_FP_NEEDS_SPILL = 1 << 1,
508 MONO_FP_NEEDS_LOAD = 1 << 2
512 alloc_int_reg (MonoCompile *cfg, InstList *tmp, MonoInst *ins, guint32 dest_mask, int sym_reg, RegTrack *info)
516 if (info && info->preferred_mask) {
517 val = mono_regstate_alloc_int (cfg->rs, info->preferred_mask & dest_mask);
519 DEBUG (g_print ("\tallocated preferred reg R%d to %s\n", sym_reg, mono_arch_regname (val)));
524 val = mono_regstate_alloc_int (cfg->rs, dest_mask);
526 val = get_register_spilling (cfg, tmp, ins, dest_mask, sym_reg, FALSE);
532 alloc_float_reg (MonoCompile *cfg, InstList *tmp, MonoInst *ins, guint32 dest_mask, int sym_reg)
536 val = mono_regstate_alloc_float (cfg->rs, dest_mask);
539 val = get_register_spilling (cfg, tmp, ins, dest_mask, sym_reg, TRUE);
546 alloc_reg (MonoCompile *cfg, InstList *tmp, MonoInst *ins, guint32 dest_mask, int sym_reg, RegTrack *info, gboolean fp)
549 return alloc_float_reg (cfg, tmp, ins, dest_mask, sym_reg);
551 return alloc_int_reg (cfg, tmp, ins, dest_mask, sym_reg, info);
555 assign_reg (MonoRegState *rs, int reg, int hreg, gboolean fp)
558 g_assert (reg >= MONO_MAX_FREGS);
559 g_assert (hreg < MONO_MAX_FREGS);
560 g_assert (! is_global_freg (hreg));
562 rs->fassign [reg] = hreg;
563 rs->fsymbolic [hreg] = reg;
564 rs->ffree_mask &= ~ (1 << hreg);
567 g_assert (reg >= MONO_MAX_IREGS);
568 g_assert (hreg < MONO_MAX_IREGS);
569 g_assert (! is_global_ireg (hreg));
571 rs->iassign [reg] = hreg;
572 rs->isymbolic [hreg] = reg;
573 rs->ifree_mask &= ~ (1 << hreg);
578 assign_ireg (MonoRegState *rs, int reg, int hreg)
580 assign_reg (rs, reg, hreg, FALSE);
584 * Local register allocation.
585 * We first scan the list of instructions and we save the liveness info of
586 * each register (when the register is first used, when it's value is set etc.).
587 * We also reverse the list of instructions (in the InstList list) because assigning
588 * registers backwards allows for more tricks to be used.
591 mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
594 MonoRegState *rs = cfg->rs;
596 RegTrack *reginfo, *reginfof;
597 RegTrack *reginfo1, *reginfo2, *reginfod;
598 InstList *tmp, *reversed = NULL;
600 GList *fspill_list = NULL;
607 rs->next_vireg = bb->max_ireg;
608 rs->next_vfreg = bb->max_freg;
609 mono_regstate_assign (rs);
610 reginfo = g_malloc0 (sizeof (RegTrack) * rs->next_vireg);
611 reginfof = g_malloc0 (sizeof (RegTrack) * rs->next_vfreg);
612 rs->ifree_mask = MONO_ARCH_CALLEE_REGS;
613 rs->ffree_mask = MONO_ARCH_CALLEE_FREGS;
616 rs->ffree_mask = 0xff & ~(1 << MONO_ARCH_FPSTACK_SIZE);
620 /*if (cfg->opt & MONO_OPT_COPYPROP)
621 local_copy_prop (cfg, ins);*/
625 DEBUG (g_print ("LOCAL regalloc: basic block: %d\n", bb->block_num));
626 /* forward pass on the instructions to collect register liveness info */
628 spec = ins_spec [ins->opcode];
631 g_error ("Opcode '%s' missing from machine description file.", mono_inst_name (ins->opcode));
634 DEBUG (print_ins (i, ins));
642 if (spec [MONO_INST_SRC1] == 'f') {
643 spill = g_list_first (fspill_list);
644 if (spill && fpcount < MONO_ARCH_FPSTACK_SIZE) {
645 reginfof [ins->sreg1].flags |= MONO_FP_NEEDS_LOAD;
646 fspill_list = g_list_remove (fspill_list, spill->data);
651 if (spec [MONO_INST_SRC2] == 'f') {
652 spill = g_list_first (fspill_list);
654 reginfof [ins->sreg2].flags |= MONO_FP_NEEDS_LOAD;
655 fspill_list = g_list_remove (fspill_list, spill->data);
656 if (fpcount >= MONO_ARCH_FPSTACK_SIZE) {
658 fspill_list = g_list_prepend (fspill_list, GINT_TO_POINTER(fspill));
659 reginfof [ins->sreg2].flags |= MONO_FP_NEEDS_LOAD_SPILL;
665 if (dreg_is_fp (ins)) {
666 if (use_fpstack && (spec [MONO_INST_CLOB] != 'm')) {
667 if (fpcount >= MONO_ARCH_FPSTACK_SIZE) {
668 reginfof [ins->dreg].flags |= MONO_FP_NEEDS_SPILL;
670 fspill_list = g_list_prepend (fspill_list, GINT_TO_POINTER(fspill));
678 if (spec [MONO_INST_SRC1]) {
679 if (spec [MONO_INST_SRC1] == 'f')
683 reginfo1 [ins->sreg1].prev_use = reginfo1 [ins->sreg1].last_use;
684 reginfo1 [ins->sreg1].last_use = i;
685 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_SRC2])) {
686 /* The virtual register is allocated sequentially */
687 reginfo1 [ins->sreg1 + 1].prev_use = reginfo1 [ins->sreg1 + 1].last_use;
688 reginfo1 [ins->sreg1 + 1].last_use = i;
689 if (reginfo1 [ins->sreg1 + 1].born_in == 0 || reginfo1 [ins->sreg1 + 1].born_in > i)
690 reginfo1 [ins->sreg1 + 1].born_in = i;
695 if (spec [MONO_INST_SRC2]) {
696 if (spec [MONO_INST_SRC2] == 'f')
700 reginfo2 [ins->sreg2].prev_use = reginfo2 [ins->sreg2].last_use;
701 reginfo2 [ins->sreg2].last_use = i;
702 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_SRC2])) {
703 /* The virtual register is allocated sequentially */
704 reginfo2 [ins->sreg2 + 1].prev_use = reginfo2 [ins->sreg2 + 1].last_use;
705 reginfo2 [ins->sreg2 + 1].last_use = i;
706 if (reginfo2 [ins->sreg2 + 1].born_in == 0 || reginfo2 [ins->sreg2 + 1].born_in > i)
707 reginfo2 [ins->sreg2 + 1].born_in = i;
712 if (spec [MONO_INST_DEST]) {
715 if (dreg_is_fp (ins))
719 if (spec [MONO_INST_DEST] != 'b') /* it's not just a base register */
720 reginfod [ins->dreg].killed_in = i;
721 reginfod [ins->dreg].prev_use = reginfod [ins->dreg].last_use;
722 reginfod [ins->dreg].last_use = i;
723 if (reginfod [ins->dreg].born_in == 0 || reginfod [ins->dreg].born_in > i)
724 reginfod [ins->dreg].born_in = i;
726 dest_dreg = MONO_ARCH_INST_FIXED_REG (spec [MONO_INST_DEST]);
728 reginfod [ins->dreg].preferred_mask = (1 << dest_dreg);
730 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_DEST])) {
731 /* The virtual register is allocated sequentially */
732 reginfod [ins->dreg + 1].prev_use = reginfod [ins->dreg + 1].last_use;
733 reginfod [ins->dreg + 1].last_use = i;
734 if (reginfod [ins->dreg + 1].born_in == 0 || reginfod [ins->dreg + 1].born_in > i)
735 reginfod [ins->dreg + 1].born_in = i;
736 if (MONO_ARCH_INST_REGPAIR_REG2 (spec [MONO_INST_DEST], -1) != -1)
737 reginfod [ins->dreg + 1].preferred_mask = regpair_reg2_mask (spec [MONO_INST_DEST], -1);
743 if (spec [MONO_INST_CLOB] == 'c') {
744 /* A call instruction implicitly uses all registers in call->out_ireg_args */
746 MonoCallInst *call = (MonoCallInst*)ins;
749 list = call->out_ireg_args;
755 regpair = (guint32)(gssize)(list->data);
756 hreg = regpair >> 24;
757 reg = regpair & 0xffffff;
759 reginfo [reg].prev_use = reginfo [reg].last_use;
760 reginfo [reg].last_use = i;
762 list = g_slist_next (list);
766 list = call->out_freg_args;
767 if (!use_fpstack && list) {
772 regpair = (guint32)(gssize)(list->data);
773 hreg = regpair >> 24;
774 reg = regpair & 0xffffff;
776 reginfof [reg].prev_use = reginfof [reg].last_use;
777 reginfof [reg].last_use = i;
779 list = g_slist_next (list);
784 reversed = inst_list_prepend (cfg->mempool, reversed, ins);
789 // todo: check if we have anything left on fp stack, in verify mode?
792 DEBUG (print_regtrack (reginfo, rs->next_vireg));
793 DEBUG (print_regtrack (reginfof, rs->next_vfreg));
796 int prev_dreg, prev_sreg1, prev_sreg2, clob_dreg;
797 int dest_dreg, dest_sreg1, dest_sreg2, clob_reg;
798 int dreg_high, sreg1_high;
799 guint32 dreg_mask, sreg1_mask, sreg2_mask, mask;
802 spec = ins_spec [ins->opcode];
809 dreg_mask = dreg_is_fp (ins) ? MONO_ARCH_CALLEE_FREGS : MONO_ARCH_CALLEE_REGS;
810 sreg1_mask = sreg1_is_fp (ins) ? MONO_ARCH_CALLEE_FREGS : MONO_ARCH_CALLEE_REGS;
811 sreg2_mask = sreg2_is_fp (ins) ? MONO_ARCH_CALLEE_FREGS : MONO_ARCH_CALLEE_REGS;
813 DEBUG (g_print ("processing:"));
814 DEBUG (print_ins (i, ins));
819 dest_sreg1 = MONO_ARCH_INST_FIXED_REG (spec [MONO_INST_SRC1]);
820 dest_sreg2 = MONO_ARCH_INST_FIXED_REG (spec [MONO_INST_SRC2]);
821 dest_dreg = MONO_ARCH_INST_FIXED_REG (spec [MONO_INST_DEST]);
822 clob_reg = MONO_ARCH_INST_FIXED_REG (spec [MONO_INST_CLOB]);
823 sreg2_mask &= ~ (MONO_ARCH_INST_SREG2_MASK (spec));
828 if (use_fpstack && (spec [MONO_INST_CLOB] != 'm')) {
829 if (dreg_is_fp (ins)) {
830 if (reginfof [ins->dreg].flags & MONO_FP_NEEDS_SPILL) {
833 spill_node = g_list_first (fspill_list);
834 g_assert (spill_node);
836 store = create_spilled_store_float (cfg, GPOINTER_TO_INT (spill_node->data), ins->dreg, ins);
837 insert_before_ins (ins, tmp, store);
838 fspill_list = g_list_remove (fspill_list, spill_node->data);
843 if (spec [MONO_INST_SRC1] == 'f') {
844 if (reginfof [ins->sreg1].flags & MONO_FP_NEEDS_LOAD) {
846 MonoInst *store = NULL;
848 if (reginfof [ins->sreg1].flags & MONO_FP_NEEDS_LOAD_SPILL) {
850 spill_node = g_list_first (fspill_list);
851 g_assert (spill_node);
853 store = create_spilled_store_float (cfg, GPOINTER_TO_INT (spill_node->data), ins->sreg1, ins);
854 fspill_list = g_list_remove (fspill_list, spill_node->data);
858 fspill_list = g_list_prepend (fspill_list, GINT_TO_POINTER(fspill));
859 load = create_spilled_load_float (cfg, fspill, ins->sreg1, ins);
860 insert_before_ins (ins, tmp, load);
862 insert_before_ins (load, tmp, store);
866 if (spec [MONO_INST_SRC2] == 'f') {
867 if (reginfof [ins->sreg2].flags & MONO_FP_NEEDS_LOAD) {
869 MonoInst *store = NULL;
871 if (reginfof [ins->sreg2].flags & MONO_FP_NEEDS_LOAD_SPILL) {
874 spill_node = g_list_first (fspill_list);
875 g_assert (spill_node);
876 if (spec [MONO_INST_SRC1] == 'f' && (reginfof [ins->sreg2].flags & MONO_FP_NEEDS_LOAD_SPILL))
877 spill_node = g_list_next (spill_node);
879 store = create_spilled_store_float (cfg, GPOINTER_TO_INT (spill_node->data), ins->sreg2, ins);
880 fspill_list = g_list_remove (fspill_list, spill_node->data);
884 fspill_list = g_list_prepend (fspill_list, GINT_TO_POINTER(fspill));
885 load = create_spilled_load_float (cfg, fspill, ins->sreg2, ins);
886 insert_before_ins (ins, tmp, load);
888 insert_before_ins (load, tmp, store);
896 if (dest_sreg2 != -1) {
897 if (rs->ifree_mask & (1 << dest_sreg2)) {
898 if (is_global_ireg (ins->sreg2)) {
899 /* Argument already in hard reg, need to copy */
900 MonoInst *copy = create_copy_ins (cfg, dest_sreg2, ins->sreg2, NULL, FALSE);
901 insert_before_ins (ins, tmp, copy);
904 DEBUG (g_print ("\tshortcut assignment of R%d to %s\n", ins->sreg2, mono_arch_regname (dest_sreg2)));
905 assign_ireg (rs, ins->sreg2, dest_sreg2);
908 int need_spill = TRUE;
910 dreg_mask &= ~ (1 << dest_sreg2);
911 sreg1_mask &= ~ (1 << dest_sreg2);
914 * First check if dreg is assigned to dest_sreg2, since we
915 * can't spill a dreg.
917 val = rs->iassign [ins->dreg];
918 if (val == dest_sreg2 && ins->dreg != ins->sreg2) {
920 * the destination register is already assigned to
921 * dest_sreg2: we need to allocate another register for it
922 * and then copy from this to dest_sreg2.
925 new_dest = alloc_int_reg (cfg, tmp, ins, dreg_mask, ins->dreg, ®info [ins->dreg]);
926 g_assert (new_dest >= 0);
927 DEBUG (g_print ("\tchanging dreg R%d to %s from %s\n", ins->dreg, mono_arch_regname (new_dest), mono_arch_regname (dest_sreg2)));
929 prev_dreg = ins->dreg;
930 assign_ireg (rs, ins->dreg, new_dest);
931 clob_dreg = ins->dreg;
932 create_copy_ins (cfg, dest_sreg2, new_dest, ins, FALSE);
936 if (is_global_ireg (ins->sreg2)) {
937 MonoInst *copy = create_copy_ins (cfg, dest_sreg2, ins->sreg2, NULL, FALSE);
938 insert_before_ins (ins, tmp, copy);
941 val = rs->iassign [ins->sreg2];
942 if (val == dest_sreg2) {
943 /* sreg2 is already assigned to the correct register */
946 else if ((val >= 0) || (val < -1)) {
947 /* FIXME: sreg2 already assigned to another register */
948 g_assert_not_reached ();
953 DEBUG (g_print ("\tforced spill of R%d\n", rs->isymbolic [dest_sreg2]));
954 get_register_force_spilling (cfg, tmp, ins, rs->isymbolic [dest_sreg2], FALSE);
955 mono_regstate_free_int (rs, dest_sreg2);
958 if (!is_global_ireg (ins->sreg2))
959 /* force-set sreg2 */
960 assign_ireg (rs, ins->sreg2, dest_sreg2);
962 ins->sreg2 = dest_sreg2;
968 fp = dreg_is_fp (ins);
969 if (spec [MONO_INST_DEST] && (!fp || (fp && !use_fpstack)) && is_soft_reg (ins->dreg, fp))
970 prev_dreg = ins->dreg;
973 * If dreg is a fixed regpair, free up both of the needed hregs to avoid
974 * various complex situations.
976 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_DEST])) {
977 guint32 dreg2, dest_dreg2;
979 g_assert (is_soft_reg (ins->dreg, fp));
981 if (dest_dreg != -1) {
982 if (rs->iassign [ins->dreg] != dest_dreg)
983 free_up_ireg (cfg, tmp, ins, dest_dreg);
985 dreg2 = ins->dreg + 1;
986 dest_dreg2 = MONO_ARCH_INST_REGPAIR_REG2 (spec [MONO_INST_DEST], dest_dreg);
987 if (dest_dreg2 != -1) {
988 if (rs->iassign [dreg2] != dest_dreg2)
989 free_up_ireg (cfg, tmp, ins, dest_dreg2);
994 if ((!fp || (fp && !use_fpstack)) && (is_soft_reg (ins->dreg, fp))) {
996 dreg_mask = (1 << dest_dreg);
998 val = rassign (cfg, ins->dreg, fp);
1003 /* the register gets spilled after this inst */
1006 val = alloc_reg (cfg, tmp, ins, dreg_mask, ins->dreg, ®info [ins->dreg], fp);
1007 assign_reg (rs, ins->dreg, val, fp);
1009 create_spilled_store (cfg, spill, val, prev_dreg, ins, fp);
1012 DEBUG (g_print ("\tassigned dreg %s to dest R%d\n", mono_regname_full (val, fp), ins->dreg));
1016 /* Handle regpairs */
1017 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_DEST])) {
1018 int reg2 = prev_dreg + 1;
1021 g_assert (prev_dreg > -1);
1022 g_assert (!is_global_ireg (rs->iassign [prev_dreg]));
1023 mask = regpair_reg2_mask (spec [MONO_INST_DEST], rs->iassign [prev_dreg]);
1024 val = rs->iassign [reg2];
1028 /* the register gets spilled after this inst */
1031 val = mono_regstate_alloc_int (rs, mask);
1033 val = get_register_spilling (cfg, tmp, ins, mask, reg2, fp);
1035 create_spilled_store (cfg, spill, val, reg2, ins, fp);
1038 if (! (mask & (1 << val))) {
1039 val = mono_regstate_alloc_int (rs, mask);
1041 val = get_register_spilling (cfg, tmp, ins, mask, reg2, fp);
1043 /* Reallocate hreg to the correct register */
1044 create_copy_ins (cfg, rs->iassign [reg2], val, ins, fp);
1046 mono_regstate_free_int (rs, rs->iassign [reg2]);
1050 DEBUG (g_print ("\tassigned dreg-high %s to dest R%d\n", mono_arch_regname (val), reg2));
1051 assign_reg (rs, reg2, val, fp);
1056 if (reg_is_freeable (val, fp) && reg2 >= 0 && (reginfo [reg2].born_in >= i)) {
1057 DEBUG (g_print ("\tfreeable %s (R%d)\n", mono_arch_regname (val), reg2));
1058 mono_regstate_free_int (rs, val);
1062 if ((!fp || (fp && !use_fpstack)) && prev_dreg >= 0 && is_soft_reg (prev_dreg, fp) && (fp ? reginfof : reginfo) [prev_dreg].born_in >= i) {
1064 * In theory, we could free up the hreg even if the vreg is alive,
1065 * but branches inside bblocks force us to assign the same hreg
1066 * to a vreg every time it is encountered.
1068 int dreg = rassign (cfg, prev_dreg, fp);
1069 g_assert (dreg >= 0);
1070 DEBUG (g_print ("\tfreeable %s (R%d) (born in %d)\n", mono_regname_full (dreg, fp), prev_dreg, (fp ? reginfof : reginfo) [prev_dreg].born_in));
1072 mono_regstate_free_float (rs, dreg);
1074 mono_regstate_free_int (rs, dreg);
1077 if ((dest_dreg != -1) && (ins->dreg != dest_dreg)) {
1078 /* this instruction only outputs to dest_dreg, need to copy */
1079 create_copy_ins (cfg, ins->dreg, dest_dreg, ins, fp);
1080 ins->dreg = dest_dreg;
1083 if (rs->fsymbolic [dest_dreg] >= MONO_MAX_FREGS)
1084 free_up_reg (cfg, tmp, ins, dest_dreg, fp);
1087 if (rs->isymbolic [dest_dreg] >= MONO_MAX_IREGS)
1088 free_up_reg (cfg, tmp, ins, dest_dreg, fp);
1095 if ((clob_reg != -1) && (!(rs->ifree_mask & (1 << clob_reg)))) {
1096 DEBUG (g_print ("\tforced spill of clobbered reg R%d\n", rs->isymbolic [clob_reg]));
1097 get_register_force_spilling (cfg, tmp, ins, rs->isymbolic [clob_reg], FALSE);
1098 mono_regstate_free_int (rs, clob_reg);
1101 if (spec [MONO_INST_CLOB] == 'c') {
1102 int j, s, dreg, dreg2;
1105 clob_mask = MONO_ARCH_CALLEE_REGS;
1108 * Need to avoid spilling the dreg since the dreg is not really
1109 * clobbered by the call.
1111 if ((prev_dreg != -1) && !dreg_is_fp (ins))
1112 dreg = rassign (cfg, prev_dreg, dreg_is_fp (ins));
1116 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_DEST]))
1117 dreg2 = rassign (cfg, prev_dreg + 1, dreg_is_fp (ins));
1121 for (j = 0; j < MONO_MAX_IREGS; ++j) {
1123 if ((clob_mask & s) && !(rs->ifree_mask & s) && (j != ins->sreg1) && (j != dreg) && (j != dreg2)) {
1124 get_register_force_spilling (cfg, tmp, ins, rs->isymbolic [j], FALSE);
1125 mono_regstate_free_int (rs, j);
1130 clob_mask = MONO_ARCH_CALLEE_FREGS;
1131 if ((prev_dreg != -1) && dreg_is_fp (ins))
1132 dreg = rassign (cfg, prev_dreg, dreg_is_fp (ins));
1136 for (j = 0; j < MONO_MAX_FREGS; ++j) {
1138 if ((clob_mask & s) && !(rs->ffree_mask & s) && (j != ins->sreg1) && (j != dreg)) {
1139 get_register_force_spilling (cfg, tmp, ins, rs->fsymbolic [j], TRUE);
1140 mono_regstate_free_float (rs, j);
1147 * TRACK ARGUMENT REGS
1149 if (spec [MONO_INST_CLOB] == 'c') {
1150 MonoCallInst *call = (MonoCallInst*)ins;
1154 * This needs to be done before assigning sreg1, so sreg1 will
1155 * not be assigned one of the argument regs.
1159 * Assign all registers in call->out_reg_args to the proper
1160 * argument registers.
1163 list = call->out_ireg_args;
1169 regpair = (guint32)(gssize)(list->data);
1170 hreg = regpair >> 24;
1171 reg = regpair & 0xffffff;
1173 assign_reg (rs, reg, hreg, FALSE);
1175 sreg1_mask &= ~(1 << hreg);
1177 DEBUG (g_print ("\tassigned arg reg %s to R%d\n", mono_arch_regname (hreg), reg));
1179 list = g_slist_next (list);
1181 g_slist_free (call->out_ireg_args);
1184 list = call->out_freg_args;
1185 if (list && !use_fpstack) {
1190 regpair = (guint32)(gssize)(list->data);
1191 hreg = regpair >> 24;
1192 reg = regpair & 0xffffff;
1194 assign_reg (rs, reg, hreg, TRUE);
1196 DEBUG (g_print ("\tassigned arg reg %s to R%d\n", mono_arch_fregname (hreg), reg));
1198 list = g_slist_next (list);
1201 if (call->out_freg_args)
1202 g_slist_free (call->out_freg_args);
1208 fp = sreg1_is_fp (ins);
1209 if ((!fp || (fp && !use_fpstack))) {
1210 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_DEST]) && (spec [MONO_INST_CLOB] == '1')) {
1211 g_assert (is_soft_reg (ins->sreg1, fp));
1213 /* To simplify things, we allocate the same regpair to sreg1 and dreg */
1214 if (dest_sreg1 != -1)
1215 g_assert (dest_sreg1 == ins->dreg);
1216 val = mono_regstate_alloc_int (rs, 1 << ins->dreg);
1217 g_assert (val >= 0);
1218 assign_reg (rs, ins->sreg1, val, fp);
1220 DEBUG (g_print ("\tassigned sreg1-low %s to R%d\n", mono_regname_full (val, fp), ins->sreg1));
1222 g_assert ((1 << dreg_high) & regpair_reg2_mask (spec [MONO_INST_SRC1], ins->dreg));
1223 val = mono_regstate_alloc_int (rs, 1 << dreg_high);
1224 g_assert (val >= 0);
1225 assign_reg (rs, ins->sreg1 + 1, val, fp);
1227 DEBUG (g_print ("\tassigned sreg1-high %s to R%d\n", mono_regname_full (val, fp), ins->sreg1 + 1));
1229 /* Skip rest of this section */
1233 if (dest_sreg1 != -1) {
1234 sreg1_mask = 1 << dest_sreg1;
1236 if (!(rs->ifree_mask & (1 << dest_sreg1))) {
1237 DEBUG (g_print ("\tforced spill of R%d\n", rs->isymbolic [dest_sreg1]));
1238 get_register_force_spilling (cfg, tmp, ins, rs->isymbolic [dest_sreg1], FALSE);
1239 mono_regstate_free_int (rs, dest_sreg1);
1241 if (is_global_ireg (ins->sreg1)) {
1242 /* The argument is already in a hard reg, need to copy */
1243 MonoInst *copy = create_copy_ins (cfg, dest_sreg1, ins->sreg1, NULL, FALSE);
1244 insert_before_ins (ins, tmp, copy);
1245 ins->sreg1 = dest_sreg1;
1249 if (is_soft_reg (ins->sreg1, fp)) {
1250 val = rassign (cfg, ins->sreg1, fp);
1251 prev_sreg1 = ins->sreg1;
1255 /* the register gets spilled after this inst */
1259 if (((ins->opcode == OP_MOVE) || (ins->opcode == OP_SETREG)) && !spill && !fp && (!is_global_ireg (ins->dreg) && (rs->ifree_mask & (1 << ins->dreg)))) {
1261 * Allocate the same hreg to sreg1 as well so the
1262 * peephole can get rid of the move.
1264 sreg1_mask = 1 << ins->dreg;
1267 val = alloc_reg (cfg, tmp, ins, sreg1_mask, ins->sreg1, ®info [ins->sreg1], fp);
1268 assign_reg (rs, ins->sreg1, val, fp);
1269 DEBUG (g_print ("\tassigned sreg1 %s to R%d\n", mono_regname_full (val, fp), ins->sreg1));
1272 MonoInst *store = create_spilled_store (cfg, spill, val, prev_sreg1, NULL, fp);
1274 * Need to insert before the instruction since it can
1277 insert_before_ins (ins, tmp, store);
1280 else if ((dest_sreg1 != -1) && (dest_sreg1 != val)) {
1281 g_assert_not_reached ();
1289 sreg2_mask &= ~(1 << ins->sreg1);
1292 /* Handle the case when sreg1 is a regpair but dreg is not */
1293 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_SRC1]) && (spec [MONO_INST_CLOB] != '1')) {
1294 int reg2 = prev_sreg1 + 1;
1297 g_assert (prev_sreg1 > -1);
1298 g_assert (!is_global_ireg (rs->iassign [prev_sreg1]));
1299 mask = regpair_reg2_mask (spec [MONO_INST_SRC1], rs->iassign [prev_sreg1]);
1300 val = rs->iassign [reg2];
1304 /* the register gets spilled after this inst */
1307 val = mono_regstate_alloc_int (rs, mask);
1309 val = get_register_spilling (cfg, tmp, ins, mask, reg2, fp);
1311 g_assert_not_reached ();
1314 if (! (mask & (1 << val))) {
1315 /* The vreg is already allocated to a wrong hreg */
1317 g_assert_not_reached ();
1319 val = mono_regstate_alloc_int (rs, mask);
1321 val = get_register_spilling (cfg, tmp, ins, mask, reg2, fp);
1323 /* Reallocate hreg to the correct register */
1324 create_copy_ins (cfg, rs->iassign [reg2], val, ins, fp);
1326 mono_regstate_free_int (rs, rs->iassign [reg2]);
1332 DEBUG (g_print ("\tassigned sreg1 hreg %s to dest R%d\n", mono_arch_regname (val), reg2));
1333 assign_reg (rs, reg2, val, fp);
1336 /* Handle dreg==sreg1 */
1337 if (((dreg_is_fp (ins) && spec [MONO_INST_SRC1] == 'f' && !use_fpstack) || spec [MONO_INST_CLOB] == '1') && ins->dreg != ins->sreg1) {
1338 MonoInst *sreg2_copy = NULL;
1340 gboolean fp = (spec [MONO_INST_SRC1] == 'f');
1342 if (ins->dreg == ins->sreg2) {
1344 * copying sreg1 to dreg could clobber sreg2, so allocate a new
1347 int reg2 = alloc_reg (cfg, tmp, ins, dreg_mask, ins->sreg2, NULL, fp);
1349 DEBUG (g_print ("\tneed to copy sreg2 %s to reg %s\n", mono_regname_full (ins->sreg2, fp), mono_regname_full (reg2, fp)));
1350 sreg2_copy = create_copy_ins (cfg, reg2, ins->sreg2, NULL, fp);
1351 prev_sreg2 = ins->sreg2 = reg2;
1354 mono_regstate_free_float (rs, reg2);
1356 mono_regstate_free_int (rs, reg2);
1359 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_SRC1])) {
1360 /* Copying sreg1_high to dreg could also clobber sreg2 */
1361 if (rs->iassign [prev_sreg1 + 1] == ins->sreg2)
1363 g_assert_not_reached ();
1366 * sreg1 and dest are already allocated to the same regpair by the
1367 * SREG1 allocation code.
1369 g_assert (ins->sreg1 == ins->dreg);
1370 g_assert (dreg_high == sreg1_high);
1373 DEBUG (g_print ("\tneed to copy sreg1 %s to dreg %s\n", mono_regname_full (ins->sreg1, fp), mono_regname_full (ins->dreg, fp)));
1374 copy = create_copy_ins (cfg, ins->dreg, ins->sreg1, NULL, fp);
1375 insert_before_ins (ins, tmp, copy);
1378 insert_before_ins (copy, tmp, sreg2_copy);
1381 * Need to prevent sreg2 to be allocated to sreg1, since that
1382 * would screw up the previous copy.
1384 sreg2_mask &= ~ (1 << ins->sreg1);
1385 /* we set sreg1 to dest as well */
1386 prev_sreg1 = ins->sreg1 = ins->dreg;
1387 sreg2_mask &= ~ (1 << ins->dreg);
1393 fp = sreg2_is_fp (ins);
1394 if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_SRC2]))
1395 g_assert_not_reached ();
1396 if ((!fp || (fp && !use_fpstack)) && (is_soft_reg (ins->sreg2, fp))) {
1397 val = rassign (cfg, ins->sreg2, fp);
1402 /* the register gets spilled after this inst */
1405 val = alloc_reg (cfg, tmp, ins, sreg2_mask, ins->sreg2, ®info [ins->sreg2], fp);
1406 assign_reg (rs, ins->sreg2, val, fp);
1407 DEBUG (g_print ("\tassigned sreg2 %s to R%d\n", mono_regname_full (val, fp), ins->sreg2));
1409 create_spilled_store (cfg, spill, val, prev_sreg2, ins, fp);
1417 /*if (reg_is_freeable (ins->sreg1) && prev_sreg1 >= 0 && reginfo [prev_sreg1].born_in >= i) {
1418 DEBUG (g_print ("freeable %s\n", mono_arch_regname (ins->sreg1)));
1419 mono_regstate_free_int (rs, ins->sreg1);
1421 if (reg_is_freeable (ins->sreg2) && prev_sreg2 >= 0 && reginfo [prev_sreg2].born_in >= i) {
1422 DEBUG (g_print ("freeable %s\n", mono_arch_regname (ins->sreg2)));
1423 mono_regstate_free_int (rs, ins->sreg2);
1426 DEBUG (print_ins (i, ins));
1427 /* this may result from a insert_before call */
1429 bb->code = tmp->data;
1435 g_list_free (fspill_list);