Author: zoltan
Date: 2005-04-11 17:56:11 -0400 (Mon, 11 Apr 2005)
New Revision: 42809

Modified:
   branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/ChangeLog
   branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-amd64.h
   branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-codegen.c
   branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-sparc.c
   branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-sparc.h
   branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini.h
Log:
2005-04-12  Zoltan Varga  <[EMAIL PROTECTED]>

        * mini.h mini-codegen.c mini-amd64.c: Rename mono_arch_regname_full () 
to
        mono_regname_full () and move it to mini-codegen.c.

        * mini-amd64.h: Add some defines needed by the new allocator.

        * mini-codegen.c: Add sparc register pair support.

        * mini-sparc.c mini-sparc.h Makefile.am: Use the new register allocator.


Modified: branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/ChangeLog
===================================================================
--- branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/ChangeLog     
2005-04-11 21:34:15 UTC (rev 42808)
+++ branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/ChangeLog     
2005-04-11 21:56:11 UTC (rev 42809)
@@ -1,3 +1,14 @@
+2005-04-12  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * mini.h mini-codegen.c mini-amd64.c: Rename mono_arch_regname_full () 
to
+       mono_regname_full () and move it to mini-codegen.c.
+
+       * mini-amd64.h: Add some defines needed by the new allocator.
+
+       * mini-codegen.c: Add sparc register pair support.
+
+       * mini-sparc.c mini-sparc.h Makefile.am: Use the new register allocator.
+
 2005-04-10  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * mini-codegen.c (mono_local_regalloc): Move tracking of fp stack into

Modified: branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-amd64.h
===================================================================
--- branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-amd64.h  
2005-04-11 21:34:15 UTC (rev 42808)
+++ branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-amd64.h  
2005-04-11 21:56:11 UTC (rev 42809)
@@ -80,6 +80,8 @@
 
 #define MONO_MAX_FREGS AMD64_XMM_NREG
 
+#define MONO_ARCH_HAS_XP_LOCAL_REGALLOC
+
 /* xmm15 is reserved for use by some opcodes */
 #define MONO_ARCH_CALLEE_FREGS 0xef
 #define MONO_ARCH_CALLEE_SAVED_FREGS 0
@@ -96,6 +98,8 @@
 /* RDX is clobbered by the opcode implementation before accessing sreg2 */
 #define MONO_ARCH_INST_SREG2_MASK(ins) (((ins [MONO_INST_CLOB] == 'a') || (ins 
[MONO_INST_CLOB] == 'd')) ? (1 << AMD64_RDX) : 0)
 
+#define MONO_ARCH_INST_IS_REGPAIR(desc) FALSE
+
 #define MONO_ARCH_FRAME_ALIGNMENT 16
 
 /* fixme: align to 16byte instead of 32byte (we align to 32byte to get 

Modified: branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-codegen.c
===================================================================
--- branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-codegen.c        
2005-04-11 21:34:15 UTC (rev 42808)
+++ branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-codegen.c        
2005-04-11 21:56:11 UTC (rev 42809)
@@ -22,11 +22,27 @@
 
 #define DEBUG(a) if (cfg->verbose_level > 1) a
 
+#if defined(__x86_64__)
 const char * const amd64_desc [OP_LAST];
 static const char*const * ins_spec = amd64_desc;
+#elif defined(__sparc__) || defined(sparc)
+const char * const sparc_desc [OP_LAST];
+static const char*const * ins_spec = sparc_desc;
+#else
+#error "Not implemented"
+#endif
 
 #define use_fpstack MONO_ARCH_USE_FPSTACK
 
+const char*
+mono_regname_full (int reg, gboolean fp)
+{
+       if (fp)
+               return mono_arch_fregname (reg);
+       else
+               return mono_arch_regname (reg);
+}
+
 /*
  * returns the offset used by spillvar. It allocates a new
  * spill variable if necessary. 
@@ -160,22 +176,26 @@
                gboolean fp = (spec [MONO_INST_DEST] == 'f');
                if (is_soft_reg (ins->dreg, fp))
                        g_print (" R%d <-", ins->dreg);
+               else if (spec [MONO_INST_DEST] == 'b')
+                       g_print (" [%s + 0x%lx] <-", mono_arch_regname 
(ins->dreg), (long)ins->inst_offset);
                else
-                       g_print (" %s <-", mono_arch_regname_full (ins->dreg, 
fp));
+                       g_print (" %s <-", mono_regname_full (ins->dreg, fp));
        }
        if (spec [MONO_INST_SRC1]) {
                gboolean fp = (spec [MONO_INST_SRC1] == 'f');
                if (is_soft_reg (ins->sreg1, fp))
                        g_print (" R%d", ins->sreg1);
+               else if (spec [MONO_INST_SRC1] == 'b')
+                       g_print (" [%s + 0x%lx]", mono_arch_regname 
(ins->sreg1), (long)ins->inst_offset);
                else
-                       g_print (" %s", mono_arch_regname_full (ins->sreg1, 
fp));
+                       g_print (" %s", mono_regname_full (ins->sreg1, fp));
        }
        if (spec [MONO_INST_SRC2]) {
                gboolean fp = (spec [MONO_INST_SRC2] == 'f');
                if (is_soft_reg (ins->sreg2, fp))
                        g_print (" R%d", ins->sreg2);
                else
-                       g_print (" %s", mono_arch_regname_full (ins->sreg2, 
fp));
+                       g_print (" %s", mono_regname_full (ins->sreg2, fp));
        }
        if (spec [MONO_INST_CLOB])
                g_print (" clobbers: %c", spec [MONO_INST_CLOB]);
@@ -264,7 +284,7 @@
        }
        load->next = ins->next;
        ins->next = load;
-       DEBUG (g_print ("SPILLED LOAD (%d at 0x%08lx(%%ebp)) R%d (freed %s)\n", 
spill, (long)load->inst_offset, i, mono_arch_regname_full (sel, fp)));
+       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)));
        if (fp)
                i = mono_regstate_alloc_float (cfg->rs, 1 << sel);
        else
@@ -297,18 +317,18 @@
                        regmask &= ~ (1 << rassign (cfg, ins->sreg1, fp));
                else
                        regmask &= ~ (1 << ins->sreg1);
-               DEBUG (g_print ("\t\texcluding sreg1 %s\n", 
mono_arch_regname_full (ins->sreg1, fp)));
+               DEBUG (g_print ("\t\texcluding sreg1 %s\n", mono_regname_full 
(ins->sreg1, fp)));
        }
        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))) {
                if (is_soft_reg (ins->sreg2, fp))
                        regmask &= ~ (1 << rassign (cfg, ins->sreg2, fp));
                else
                        regmask &= ~ (1 << ins->sreg2);
-               DEBUG (g_print ("\t\texcluding sreg2 %s %d\n", 
mono_arch_regname_full (ins->sreg2, fp), ins->sreg2));
+               DEBUG (g_print ("\t\texcluding sreg2 %s %d\n", 
mono_regname_full (ins->sreg2, fp), ins->sreg2));
        }
        if ((dreg_is_fp (ins) == fp) && (reg != ins->dreg) && reg_is_freeable 
(ins->dreg, fp)) {
                regmask &= ~ (1 << ins->dreg);
-               DEBUG (g_print ("\t\texcluding dreg %s\n", 
mono_arch_regname_full (ins->dreg, fp)));
+               DEBUG (g_print ("\t\texcluding dreg %s\n", mono_regname_full 
(ins->dreg, fp)));
        }
 
        DEBUG (g_print ("\t\tavailable regmask: 0x%08x\n", regmask));
@@ -355,7 +375,7 @@
        }
        load->next = ins->next;
        ins->next = load;
-       DEBUG (g_print ("\tSPILLED LOAD (%d at 0x%08lx(%%ebp)) R%d (freed 
%s)\n", spill, (long)load->inst_offset, i, mono_arch_regname_full (sel, fp)));
+       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)));
        if (fp)
                i = mono_regstate_alloc_float (cfg->rs, 1 << sel);
        else
@@ -397,7 +417,7 @@
                store->next = ins->next;
                ins->next = store;
        }
-       DEBUG (g_print ("\tSPILLED STORE (%d at 0x%08lx(%%ebp)) R%d (from 
%s)\n", spill, (long)store->inst_offset, prev_reg, mono_arch_regname_full (reg, 
fp)));
+       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)));
        return store;
 }
 
@@ -641,15 +661,12 @@
                        reginfod [ins->dreg].last_use = i;
                        if (reginfod [ins->dreg].born_in == 0 || reginfod 
[ins->dreg].born_in > i)
                                reginfod [ins->dreg].born_in = i;
-                       if (spec [MONO_INST_DEST] == 'l' || spec 
[MONO_INST_DEST] == 'L') {
+                       if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_DEST])) {
                                /* The virtual register is allocated 
sequentially */
                                reginfod [ins->dreg + 1].prev_use = reginfod 
[ins->dreg + 1].last_use;
                                reginfod [ins->dreg + 1].last_use = i;
                                if (reginfod [ins->dreg + 1].born_in == 0 || 
reginfod [ins->dreg + 1].born_in > i)
                                        reginfod [ins->dreg + 1].born_in = i;
-
-                               reginfod [ins->dreg].flags |= MONO_X86_REG_EAX;
-                               reginfod [ins->dreg + 1].flags |= 
MONO_X86_REG_EDX;
                        }
                } else {
                        ins->dreg = -1;
@@ -900,10 +917,53 @@
                                if (spill)
                                        create_spilled_store (cfg, spill, val, 
prev_dreg, ins, fp);
                        }
-                       DEBUG (g_print ("\tassigned dreg %s to dest R%d\n", 
mono_arch_regname_full (val, fp), ins->dreg));
+                       DEBUG (g_print ("\tassigned dreg %s to dest R%d\n", 
mono_regname_full (val, fp), ins->dreg));
                        ins->dreg = val;
                }
 
+               /* Handle regpairs */
+               if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_DEST])) {
+                       int hreg = prev_dreg + 1;
+                       val = rs->iassign [hreg];
+                       if (val < 0) {
+                               int spill = 0;
+                               if (val < -1) {
+                                       /* the register gets spilled after this 
inst */
+                                       spill = -val -1;
+                               }
+                               /* The second register must be a pair of the 
first */
+                               dreg_mask = 1 << (rs->iassign [prev_dreg] + 1);
+                               val = mono_regstate_alloc_int (rs, dreg_mask);
+                               if (val < 0)
+                                       val = get_register_spilling (cfg, tmp, 
ins, dreg_mask, hreg, fp);
+                               if (spill)
+                                       create_spilled_store (cfg, spill, val, 
hreg, ins, fp);
+                       }
+                       else {
+                               /* The second register must be a pair of the 
first */
+                               if (val != rs->iassign [prev_dreg] + 1) {
+                                       dreg_mask = 1 << (rs->iassign 
[prev_dreg] + 1);
+                                       
+                                       val = mono_regstate_alloc_int (rs, 
dreg_mask);
+                                       if (val < 0)
+                                               val = get_register_spilling 
(cfg, tmp, ins, dreg_mask, hreg, fp);
+
+                                       /* Reallocate hreg to the correct 
register */
+                                       create_copy_ins (cfg, rs->iassign 
[hreg], val, ins, fp);
+
+                                       mono_regstate_free_int (rs, rs->iassign 
[hreg]);
+                               }
+                       }                                       
+
+                       DEBUG (g_print ("\tassigned hreg %s to dest R%d\n", 
mono_arch_regname (val), hreg));
+                       assign_reg (rs, hreg, val, fp);
+
+                       if (reg_is_freeable (val, fp) && hreg >= 0 && (reginfo 
[hreg].born_in >= i)) {
+                               DEBUG (g_print ("\tfreeable %s (R%d)\n", 
mono_arch_regname (val), hreg));
+                               mono_regstate_free_int (rs, val);
+                       }
+               }
+
                if ((!fp || (fp && !use_fpstack)) && prev_dreg >= 0 && 
is_soft_reg (prev_dreg, fp) && (fp ? reginfof : reginfo) [prev_dreg].born_in >= 
i) {
                        /* 
                         * In theory, we could free up the hreg even if the 
vreg is alive,
@@ -912,7 +972,7 @@
                         */
                        int dreg = rassign (cfg, prev_dreg, fp);
                        g_assert (dreg >= 0);
-                       DEBUG (g_print ("\tfreeable %s (R%d) (born in %d)\n", 
mono_arch_regname_full (dreg, fp), prev_dreg, (fp ? reginfof : reginfo) 
[prev_dreg].born_in));
+                       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));
                        if (fp)
                                mono_regstate_free_float (rs, dreg);
                        else
@@ -941,7 +1001,7 @@
                }
 
                if (spec [MONO_INST_CLOB] == 'c') {
-                       int j, s, dreg;
+                       int j, s, dreg, dreg2;
                        guint32 clob_mask;
 
                        clob_mask = MONO_ARCH_CALLEE_REGS;
@@ -955,9 +1015,14 @@
                        else
                                dreg = -1;
 
+                       if (MONO_ARCH_INST_IS_REGPAIR (spec [MONO_INST_DEST]))
+                               dreg2 = rassign (cfg, prev_dreg + 1, dreg_is_fp 
(ins));
+                       else
+                               dreg2 = -1;
+
                        for (j = 0; j < MONO_MAX_IREGS; ++j) {
                                s = 1 << j;
-                               if ((clob_mask & s) && !(rs->ifree_mask & s) && 
(j != ins->sreg1) && (j != dreg)) {
+                               if ((clob_mask & s) && !(rs->ifree_mask & s) && 
(j != ins->sreg1) && (j != dreg) && (j != dreg2)) {
                                        get_register_force_spilling (cfg, tmp, 
ins, rs->isymbolic [j], FALSE);
                                        mono_regstate_free_int (rs, j);
                                }
@@ -1078,7 +1143,7 @@
 
                                        val = alloc_reg (cfg, tmp, ins, 
sreg1_mask, ins->sreg1, reginfo [ins->sreg1].flags, fp);
                                        assign_reg (rs, ins->sreg1, val, fp);
-                                       DEBUG (g_print ("\tassigned sreg1 %s to 
R%d\n", mono_arch_regname_full (val, fp), ins->sreg1));
+                                       DEBUG (g_print ("\tassigned sreg1 %s to 
R%d\n", mono_regname_full (val, fp), ins->sreg1));
 
                                        if (spill) {
                                                MonoInst *store = 
create_spilled_store (cfg, spill, val, prev_sreg1, NULL, fp);
@@ -1114,7 +1179,7 @@
                                 */
                                int reg2 = alloc_reg (cfg, tmp, ins, dreg_mask, 
ins->sreg2, 0, fp);
 
-                               DEBUG (g_print ("\tneed to copy sreg2 %s to reg 
%s\n", mono_arch_regname_full (ins->sreg2, fp), mono_arch_regname_full (reg2, 
fp)));
+                               DEBUG (g_print ("\tneed to copy sreg2 %s to reg 
%s\n", mono_regname_full (ins->sreg2, fp), mono_regname_full (reg2, fp)));
                                sreg2_copy = create_copy_ins (cfg, reg2, 
ins->sreg2, NULL, fp);
                                prev_sreg2 = ins->sreg2 = reg2;
 
@@ -1125,7 +1190,7 @@
                        }
 
                        copy = create_copy_ins (cfg, ins->dreg, ins->sreg1, 
NULL, fp);
-                       DEBUG (g_print ("\tneed to copy sreg1 %s to dreg %s\n", 
mono_arch_regname_full (ins->sreg1, fp), mono_arch_regname_full (ins->dreg, 
fp)));
+                       DEBUG (g_print ("\tneed to copy sreg1 %s to dreg %s\n", 
mono_regname_full (ins->sreg1, fp), mono_regname_full (ins->dreg, fp)));
                        insert_before_ins (ins, tmp, copy);
 
                        if (sreg2_copy)
@@ -1156,7 +1221,7 @@
                                }
                                val = alloc_reg (cfg, tmp, ins, sreg2_mask, 
ins->sreg2, reginfo [ins->sreg2].flags, fp);
                                assign_reg (rs, ins->sreg2, val, fp);
-                               DEBUG (g_print ("\tassigned sreg2 %s to R%d\n", 
mono_arch_regname_full (val, fp), ins->sreg2));
+                               DEBUG (g_print ("\tassigned sreg2 %s to R%d\n", 
mono_regname_full (val, fp), ins->sreg2));
                                if (spill)
                                        create_spilled_store (cfg, spill, val, 
prev_sreg2, ins, fp);
                        }

Modified: branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-sparc.c
===================================================================
--- branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-sparc.c  
2005-04-11 21:34:15 UTC (rev 42808)
+++ branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-sparc.c  
2005-04-11 21:56:11 UTC (rev 42809)
@@ -184,6 +184,24 @@
        return "unknown";
 }
 
+const char*
+mono_arch_fregname (int reg) {
+       static const char *rnames [] = {
+               "sparc_f0", "sparc_f1", "sparc_f2", "sparc_f3", "sparc_f4", 
+               "sparc_f5", "sparc_f6", "sparc_f7", "sparc_f8", "sparc_f9",
+               "sparc_f10", "sparc_f11", "sparc_f12", "sparc_f13", 
"sparc_f14", 
+               "sparc_f15", "sparc_f16", "sparc_f17", "sparc_f18", "sparc_f19",
+               "sparc_f20", "sparc_f21", "sparc_f22", "sparc_f23", 
"sparc_f24", 
+               "sparc_f25", "sparc_f26", "sparc_f27", "sparc_f28", "sparc_f29",
+               "sparc_f30", "sparc_f31"
+       };
+
+       if (reg >= 0 && reg < 32)
+               return rnames [reg];
+       else
+               return "unknown";
+}
+
 /*
  * Initialize the cpu to execute managed code.
  */
@@ -1153,6 +1171,8 @@
                call->out_args = prev;
        }
        call->stack_usage = cinfo->stack_usage + extra_space;
+       call->out_ireg_args = NULL;
+       call->out_freg_args = NULL;
        cfg->param_area = MAX (cfg->param_area, call->stack_usage);
        cfg->flags |= MONO_CFG_HAS_CALLS;
 
@@ -1677,33 +1697,6 @@
        bb->last_ins = last_ins;
 }
 
-/* Parameters used by the register allocator */
-
-/* Use %l4..%l7 as local registers */
-#define ARCH_CALLER_REGS (0xf0<<16)
-
-#ifdef SPARCV9
-/* Use %d34..%d62 as the double precision floating point local registers */
-/* %d32 has the same encoding as %f1, so %d36%d38 == 0b1010 == 0xa */
-#define ARCH_CALLER_FREGS (0xaaaaaaa8)
-#else
-/* Use %f2..%f30 as the double precision floating point local registers */
-#define ARCH_CALLER_FREGS (0x55555554)
-#endif
-
-#undef DEBUG
-#define DEBUG(a) if (cfg->verbose_level > 1) a
-//#define DEBUG(a)
-#define reg_is_freeable(r) ((1 << (r)) & ARCH_CALLER_REGS)
-#define freg_is_freeable(r) (((1) << (r)) & ARCH_CALLER_FREGS)
-
-typedef struct {
-       int born_in;
-       int killed_in;
-       int last_use;
-       int prev_use;
-} RegTrack;
-
 static const char*const * ins_spec = sparc_desc;
 
 static inline const char*
@@ -1715,114 +1708,7 @@
                return ins_spec [CEE_ADD];
 }
 
-static void
-print_ins (int i, MonoInst *ins)
-{
-       const char *spec = get_ins_spec (ins->opcode);
-       g_print ("\t%-2d %s", i, mono_inst_name (ins->opcode));
-       if (spec [MONO_INST_DEST]) {
-               if (ins->dreg >= MONO_MAX_IREGS)
-                       g_print (" R%d <-", ins->dreg);
-               else
-                       if (spec [MONO_INST_DEST] == 'b')
-                               g_print (" [%s + 0x%lx] <-", mono_arch_regname 
(ins->dreg), (long)ins->inst_offset);
-               else
-                       g_print (" %s <-", mono_arch_regname (ins->dreg));
-       }
-       if (spec [MONO_INST_SRC1]) {
-               if (ins->sreg1 >= MONO_MAX_IREGS)
-                       g_print (" R%d", ins->sreg1);
-               else
-                       if (spec [MONO_INST_SRC1] == 'b')
-                               g_print (" [%s + 0x%lx]", mono_arch_regname 
(ins->sreg1), (long)ins->inst_offset);
-               else
-                       g_print (" %s", mono_arch_regname (ins->sreg1));
-       }
-       if (spec [MONO_INST_SRC2]) {
-               if (ins->sreg2 >= MONO_MAX_IREGS)
-                       g_print (" R%d", ins->sreg2);
-               else
-                       g_print (" %s", mono_arch_regname (ins->sreg2));
-       }
-       if (spec [MONO_INST_CLOB])
-               g_print (" clobbers: %c", spec [MONO_INST_CLOB]);
-       g_print ("\n");
-}
-
-static void
-print_regtrack (RegTrack *t, int num)
-{
-       int i;
-       char buf [32];
-       const char *r;
-       
-       for (i = 0; i < num; ++i) {
-               if (!t [i].born_in)
-                       continue;
-               if (i >= MONO_MAX_IREGS) {
-                       g_snprintf (buf, sizeof(buf), "R%d", i);
-                       r = buf;
-               } else
-                       r = mono_arch_regname (i);
-               g_print ("liveness: %s [%d - %d]\n", r, t [i].born_in, 
t[i].last_use);
-       }
-}
-
-typedef struct InstList InstList;
-
-struct InstList {
-       InstList *prev;
-       InstList *next;
-       MonoInst *data;
-};
-
-static inline InstList*
-inst_list_prepend (MonoMemPool *pool, InstList *list, MonoInst *data)
-{
-       InstList *item = mono_mempool_alloc (pool, sizeof (InstList));
-       item->data = data;
-       item->prev = NULL;
-       item->next = list;
-       if (list)
-               list->prev = item;
-       return item;
-}
-
-#define STACK_OFFSETS_POSITIVE
-
-/*
- * returns the offset used by spillvar. It allocates a new
- * spill variable if necessary.
- */
 static int
-mono_spillvar_offset (MonoCompile *cfg, int spillvar)
-{
-       MonoSpillInfo **si, *info;
-       int i = 0;
-
-       si = &cfg->spill_info; 
-       
-       while (i <= spillvar) {
-
-               if (!*si) {
-                       *si = info = mono_mempool_alloc (cfg->mempool, sizeof 
(MonoSpillInfo));
-                       info->next = NULL;
-                       cfg->stack_offset += sizeof (gpointer);
-                       info->offset = - cfg->stack_offset;
-               }
-
-               if (i == spillvar)
-                       return MONO_SPARC_STACK_BIAS + (*si)->offset;
-
-               i++;
-               si = &(*si)->next;
-       }
-
-       g_assert_not_reached ();
-       return 0;
-}
-
-static int
 mono_spillvar_offset_float (MonoCompile *cfg, int spillvar)
 {
        MonoSpillInfo **si, *info;
@@ -1851,639 +1737,12 @@
        return 0;
 }
 
-/*
- * Force the spilling of the variable in the symbolic register 'reg'.
- */
-G_GNUC_UNUSED static int
-get_register_force_spilling (MonoCompile *cfg, InstList *item, MonoInst *ins, 
int reg)
-{
-       MonoInst *load;
-       int i, sel, spill;
-       
-       sel = cfg->rs->iassign [reg];
-       /*i = cfg->rs->isymbolic [sel];
-       g_assert (i == reg);*/
-       i = reg;
-       spill = ++cfg->spill_count;
-       cfg->rs->iassign [i] = -spill - 1;
-       mono_regstate_free_int (cfg->rs, sel);
-       /* we need to create a spill var and insert a load to sel after the 
current instruction */
-       MONO_INST_NEW (cfg, load, OP_LOAD_MEMBASE);
-       load->dreg = sel;
-       load->inst_basereg = cfg->frame_reg;
-       load->inst_offset = mono_spillvar_offset (cfg, spill);
-       if (item->prev) {
-               while (ins->next != item->prev->data)
-                       ins = ins->next;
-       }
-       load->next = ins->next;
-       ins->next = load;
-       DEBUG (g_print ("SPILLED LOAD (%d at 0x%08lx(%%sp)) R%d (freed %s)\n", 
spill, (long)load->inst_offset, i, mono_arch_regname (sel)));
-       i = mono_regstate_alloc_int (cfg->rs, 1 << sel);
-       g_assert (i == sel);
-
-       return sel;
-}
-
-static int
-get_register_spilling (MonoCompile *cfg, InstList *item, MonoInst *ins, 
guint32 regmask, int reg)
-{
-       MonoInst *load;
-       int i, sel, spill;
-
-       DEBUG (g_print ("start regmask to assign R%d: 0x%08x (R%d <- R%d 
R%d)\n", reg, regmask, ins->dreg, ins->sreg1, ins->sreg2));
-       /* exclude the registers in the current instruction */
-       if (reg != ins->sreg1 && (reg_is_freeable (ins->sreg1) || (ins->sreg1 
>= MONO_MAX_IREGS && cfg->rs->iassign [ins->sreg1] >= 0))) {
-               if (ins->sreg1 >= MONO_MAX_IREGS)
-                       regmask &= ~ (1 << cfg->rs->iassign [ins->sreg1]);
-               else
-                       regmask &= ~ (1 << ins->sreg1);
-               DEBUG (g_print ("excluding sreg1 %s\n", mono_arch_regname 
(ins->sreg1)));
-       }
-       if (reg != ins->sreg2 && (reg_is_freeable (ins->sreg2) || (ins->sreg2 
>= MONO_MAX_IREGS && cfg->rs->iassign [ins->sreg2] >= 0))) {
-               if (ins->sreg2 >= MONO_MAX_IREGS)
-                       regmask &= ~ (1 << cfg->rs->iassign [ins->sreg2]);
-               else
-                       regmask &= ~ (1 << ins->sreg2);
-               DEBUG (g_print ("excluding sreg2 %s %d\n", mono_arch_regname 
(ins->sreg2), ins->sreg2));
-       }
-       if (reg != ins->dreg && reg_is_freeable (ins->dreg)) {
-               regmask &= ~ (1 << ins->dreg);
-               DEBUG (g_print ("excluding dreg %s\n", mono_arch_regname 
(ins->dreg)));
-       }
-
-       DEBUG (g_print ("available regmask: 0x%08x\n", regmask));
-       g_assert (regmask); /* need at least a register we can free */
-       sel = -1;
-       /* we should track prev_use and spill the register that's farther */
-       for (i = 0; i < MONO_MAX_IREGS; ++i) {
-               if (regmask & (1 << i)) {
-                       sel = i;
-                       DEBUG (g_print ("selected register %s has assignment 
%d\n", mono_arch_regname (sel), cfg->rs->iassign [sel]));
-                       break;
-               }
-       }
-       i = cfg->rs->isymbolic [sel];
-       spill = ++cfg->spill_count;
-       cfg->rs->iassign [i] = -spill - 1;
-       mono_regstate_free_int (cfg->rs, sel);
-       /* we need to create a spill var and insert a load to sel after the 
current instruction */
-       MONO_INST_NEW (cfg, load, OP_LOAD_MEMBASE);
-       load->dreg = sel;
-       load->inst_basereg = cfg->frame_reg;
-       load->inst_offset = mono_spillvar_offset (cfg, spill);
-       if (item->prev) {
-               while (ins->next != item->prev->data)
-                       ins = ins->next;
-       }
-       load->next = ins->next;
-       ins->next = load;
-       DEBUG (g_print ("SPILLED LOAD (%d at 0x%08lx(%%sp)) R%d (freed %s)\n", 
spill, (long)load->inst_offset, i, mono_arch_regname (sel)));
-       i = mono_regstate_alloc_int (cfg->rs, 1 << sel);
-       g_assert (i == sel);
-       
-       return sel;
-}
-
-static int
-get_float_register_spilling (MonoCompile *cfg, InstList *item, MonoInst *ins, 
guint32 regmask, int reg)
-{
-       MonoInst *load;
-       int i, sel, spill;
-
-       DEBUG (g_print ("start regmask to assign R%d: 0x%08x (R%d <- R%d 
R%d)\n", reg, regmask, ins->dreg, ins->sreg1, ins->sreg2));
-       /* exclude the registers in the current instruction */
-       if (reg != ins->sreg1 && (freg_is_freeable (ins->sreg1) || (ins->sreg1 
>= MONO_MAX_FREGS && cfg->rs->fassign [ins->sreg1] >= 0))) {
-               if (ins->sreg1 >= MONO_MAX_FREGS)
-                       regmask &= ~ (1 << cfg->rs->fassign [ins->sreg1]);
-               else
-                       regmask &= ~ (1 << ins->sreg1);
-               DEBUG (g_print ("excluding sreg1 %s\n", mono_arch_regname 
(ins->sreg1)));
-       }
-       if (reg != ins->sreg2 && (freg_is_freeable (ins->sreg2) || (ins->sreg2 
>= MONO_MAX_FREGS && cfg->rs->fassign [ins->sreg2] >= 0))) {
-               if (ins->sreg2 >= MONO_MAX_FREGS)
-                       regmask &= ~ (1 << cfg->rs->fassign [ins->sreg2]);
-               else
-                       regmask &= ~ (1 << ins->sreg2);
-               DEBUG (g_print ("excluding sreg2 %s %d\n", mono_arch_regname 
(ins->sreg2), ins->sreg2));
-       }
-       if (reg != ins->dreg && freg_is_freeable (ins->dreg)) {
-               regmask &= ~ (1 << ins->dreg);
-               DEBUG (g_print ("excluding dreg %s\n", mono_arch_regname 
(ins->dreg)));
-       }
-
-       DEBUG (g_print ("available regmask: 0x%08x\n", regmask));
-       g_assert (regmask); /* need at least a register we can free */
-       sel = -1;
-       /* we should track prev_use and spill the register that's farther */
-       for (i = 0; i < MONO_MAX_FREGS; ++i) {
-               if (regmask & (1 << i)) {
-                       sel = i;
-                       DEBUG (g_print ("selected register %s has assignment 
%d\n", mono_arch_regname (sel), cfg->rs->fassign [sel]));
-                       break;
-               }
-       }
-       i = cfg->rs->fsymbolic [sel];
-       spill = ++cfg->spill_count;
-       cfg->rs->fassign [i] = -spill - 1;
-       mono_regstate_free_float(cfg->rs, sel);
-       /* we need to create a spill var and insert a load to sel after the 
current instruction */
-       MONO_INST_NEW (cfg, load, OP_LOADR8_MEMBASE);
-       load->dreg = sel;
-       load->inst_basereg = cfg->frame_reg;
-       load->inst_offset = mono_spillvar_offset_float (cfg, spill);
-       if (item->prev) {
-               while (ins->next != item->prev->data)
-                       ins = ins->next;
-       }
-       load->next = ins->next;
-       ins->next = load;
-       DEBUG (g_print ("SPILLED LOAD (%d at 0x%08lx(%%sp)) R%d (freed %s)\n", 
spill, (long)load->inst_offset, i, mono_arch_regname (sel)));
-       i = mono_regstate_alloc_float (cfg->rs, 1 << sel);
-       g_assert (i == sel);
-       
-       return sel;
-}
-
-static MonoInst*
-create_copy_ins (MonoCompile *cfg, int dest, int src, MonoInst *ins)
-{
-       MonoInst *copy;
-       MONO_INST_NEW (cfg, copy, OP_MOVE);
-       copy->dreg = dest;
-       copy->sreg1 = src;
-       if (ins) {
-               copy->next = ins->next;
-               ins->next = copy;
-       }
-       DEBUG (g_print ("\tforced copy from %s to %s\n", mono_arch_regname 
(src), mono_arch_regname (dest)));
-       return copy;
-}
-
-G_GNUC_UNUSED static MonoInst*
-create_copy_ins_float (MonoCompile *cfg, int dest, int src, MonoInst *ins)
-{
-       MonoInst *copy;
-       MONO_INST_NEW (cfg, copy, OP_FMOVE);
-       copy->dreg = dest;
-       copy->sreg1 = src;
-       if (ins) {
-               copy->next = ins->next;
-               ins->next = copy;
-       }
-       DEBUG (g_print ("\tforced copy from %s to %s\n", mono_arch_regname 
(src), mono_arch_regname (dest)));
-       return copy;
-}
-
-static MonoInst*
-create_spilled_store (MonoCompile *cfg, int spill, int reg, int prev_reg, 
MonoInst *ins)
-{
-       MonoInst *store;
-       MONO_INST_NEW (cfg, store, OP_STORE_MEMBASE_REG);
-       store->sreg1 = reg;
-       store->inst_destbasereg = cfg->frame_reg;
-       store->inst_offset = mono_spillvar_offset (cfg, spill);
-       if (ins) {
-               store->next = ins->next;
-               ins->next = store;
-       }
-       DEBUG (g_print ("SPILLED STORE (%d at 0x%08lx(%%sp)) R%d (from %s)\n", 
spill, (long)store->inst_offset, prev_reg, mono_arch_regname (reg)));
-       return store;
-}
-
-static MonoInst*
-create_spilled_store_float (MonoCompile *cfg, int spill, int reg, int 
prev_reg, MonoInst *ins)
-{
-       MonoInst *store;
-       MONO_INST_NEW (cfg, store, OP_STORER8_MEMBASE_REG);
-       store->sreg1 = reg;
-       store->inst_destbasereg = cfg->frame_reg;
-       store->inst_offset = mono_spillvar_offset_float (cfg, spill);
-       if (ins) {
-               store->next = ins->next;
-               ins->next = store;
-       }
-       DEBUG (g_print ("SPILLED STORE (%d at 0x%08lx(%%sp)) R%d (from %s)\n", 
spill, (long)store->inst_offset, prev_reg, mono_arch_regname (reg)));
-       return store;
-}
-
-static void
-insert_before_ins (MonoInst *ins, InstList *item, MonoInst* to_insert)
-{
-       MonoInst *prev;
-       g_assert (item->next);
-       prev = item->next->data;
-
-       while (prev->next != ins)
-               prev = prev->next;
-       to_insert->next = ins;
-       prev->next = to_insert;
-       /* 
-        * needed otherwise in the next instruction we can add an ins to the 
-        * end and that would get past this instruction.
-        */
-       item->data = to_insert; 
-}
-
-G_GNUC_UNUSED static int
-alloc_int_reg (MonoCompile *cfg, InstList *curinst, MonoInst *ins, int 
sym_reg, guint32 allow_mask)
-{
-       int val = cfg->rs->iassign [sym_reg];
-       if (val < 0) {
-               int spill = 0;
-               if (val < -1) {
-                       /* the register gets spilled after this inst */
-                       spill = -val -1;
-               }
-               val = mono_regstate_alloc_int (cfg->rs, allow_mask);
-               if (val < 0)
-                       val = get_register_spilling (cfg, curinst, ins, 
allow_mask, sym_reg);
-               cfg->rs->iassign [sym_reg] = val;
-               /* add option to store before the instruction for src registers 
*/
-               if (spill)
-                       create_spilled_store (cfg, spill, val, sym_reg, ins);
-       }
-       cfg->rs->isymbolic [val] = sym_reg;
-       return val;
-}
-
 /* FIXME: Strange loads from the stack in basic-float.cs:test_2_rem */
 
-/*
- * Local register allocation.
- * We first scan the list of instructions and we save the liveness info of
- * each register (when the register is first used, when it's value is set 
etc.).
- * We also reverse the list of instructions (in the InstList list) because 
assigning
- * registers backwards allows for more tricks to be used.
- */
 void
 mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
 {
-       MonoInst *ins;
-       MonoRegState *rs = cfg->rs;
-       int i, val;
-       RegTrack *reginfo, *reginfof;
-       RegTrack *reginfo1, *reginfo2, *reginfod;
-       InstList *tmp, *reversed = NULL;
-       const char *spec;
-       guint32 src1_mask, src2_mask, dest_mask;
-       guint32 cur_iregs, cur_fregs;
-
-       /* FIXME: Use caller saved regs and %i1-%2 for allocation */
-
-       if (!bb->code)
-               return;
-       rs->next_vireg = bb->max_ireg;
-       rs->next_vfreg = bb->max_freg;
-       mono_regstate_assign (rs);
-       reginfo = mono_mempool_alloc0 (cfg->mempool, sizeof (RegTrack) * 
rs->next_vireg);
-       reginfof = mono_mempool_alloc0 (cfg->mempool, sizeof (RegTrack) * 
rs->next_vfreg);
-       rs->ifree_mask = ARCH_CALLER_REGS;
-       rs->ffree_mask = ARCH_CALLER_FREGS;
-
-       ins = bb->code;
-       i = 1;
-       DEBUG (g_print ("LOCAL regalloc: basic block: %d\n", bb->block_num));
-       /* forward pass on the instructions to collect register liveness info */
-       while (ins) {
-               spec = ins_spec [ins->opcode];
-               if (!spec) {
-                       /* Use a default */
-                       spec = ins_spec [CEE_ADD];
-               }
-               DEBUG (print_ins (i, ins));
-
-               if (spec [MONO_INST_SRC1]) {
-                       if (spec [MONO_INST_SRC1] == 'f')
-                               reginfo1 = reginfof;
-                       else
-                               reginfo1 = reginfo;
-                       reginfo1 [ins->sreg1].prev_use = reginfo1 
[ins->sreg1].last_use;
-                       reginfo1 [ins->sreg1].last_use = i;
-               } else {
-                       ins->sreg1 = -1;
-               }
-               if (spec [MONO_INST_SRC2]) {
-                       if (spec [MONO_INST_SRC2] == 'f')
-                               reginfo2 = reginfof;
-                       else
-                               reginfo2 = reginfo;
-                       reginfo2 [ins->sreg2].prev_use = reginfo2 
[ins->sreg2].last_use;
-                       reginfo2 [ins->sreg2].last_use = i;
-               } else {
-                       ins->sreg2 = -1;
-               }
-               if (spec [MONO_INST_DEST]) {
-                       if (spec [MONO_INST_DEST] == 'f')
-                               reginfod = reginfof;
-                       else
-                               reginfod = reginfo;
-                       if (spec [MONO_INST_DEST] != 'b') /* it's not just a 
base register */
-                               reginfod [ins->dreg].killed_in = i;
-                       reginfod [ins->dreg].prev_use = reginfod 
[ins->dreg].last_use;
-                       reginfod [ins->dreg].last_use = i;
-                       if (reginfod [ins->dreg].born_in == 0 || reginfod 
[ins->dreg].born_in > i)
-                               reginfod [ins->dreg].born_in = i;
-                       if (!v64 && (spec [MONO_INST_DEST] == 'l')) {
-                               /* result in a regpair, the virtual register is 
allocated sequentially */
-                               reginfod [ins->dreg + 1].prev_use = reginfod 
[ins->dreg + 1].last_use;
-                               reginfod [ins->dreg + 1].last_use = i;
-                               if (reginfod [ins->dreg + 1].born_in == 0 || 
reginfod [ins->dreg + 1].born_in > i)
-                                       reginfod [ins->dreg + 1].born_in = i;
-                       }
-               } else {
-                       ins->dreg = -1;
-               }
-               reversed = inst_list_prepend (cfg->mempool, reversed, ins);
-               ++i;
-               ins = ins->next;
-       }
-
-       cur_iregs = ARCH_CALLER_REGS;
-       cur_fregs = ARCH_CALLER_FREGS;
-
-       DEBUG (print_regtrack (reginfo, rs->next_vireg));
-       DEBUG (print_regtrack (reginfof, rs->next_vfreg));
-       tmp = reversed;
-       while (tmp) {
-               int prev_dreg, prev_sreg1, prev_sreg2;
-               --i;
-               ins = tmp->data;
-               spec = ins_spec [ins->opcode];
-               if (!spec)
-                       spec = ins_spec [CEE_ADD];
-               DEBUG (g_print ("processing:"));
-               DEBUG (print_ins (i, ins));
-
-               /* make the register available for allocation: FIXME add fp reg 
*/
-               if (ins->opcode == OP_SETREG || ins->opcode == OP_SETREGIMM) {
-                       /* Dont free register which can't be allocated */
-                       if (reg_is_freeable (ins->dreg)) {
-                               cur_iregs |= 1 << ins->dreg;
-                               DEBUG (g_print ("adding %d to cur_iregs\n", 
ins->dreg));
-                       }
-               } else if (ins->opcode == OP_SETFREG) {
-                       if (freg_is_freeable (ins->dreg)) {
-                               cur_fregs |= 1 << ins->dreg;
-                               DEBUG (g_print ("adding %d to cur_fregs\n", 
ins->dreg));
-                       }
-               } else if (spec [MONO_INST_CLOB] == 'c') {
-                       MonoCallInst *cinst = (MonoCallInst*)ins;
-                       DEBUG (g_print ("excluding regs 0x%lx from cur_iregs 
(0x%x)\n", (long)cinst->used_iregs, cur_iregs));
-                       cur_iregs &= ~cinst->used_iregs;
-                       cur_fregs &= ~cinst->used_fregs;
-                       DEBUG (g_print ("available cur_iregs: 0x%x\n", 
cur_iregs));
-                       /* registers used by the calling convention are 
excluded from 
-                        * allocation: they will be selectively enabled when 
they are 
-                        * assigned by the special SETREG opcodes.
-                        */
-               }
-               dest_mask = src1_mask = src2_mask = cur_iregs;
-
-               /*
-                * DEST
-                */
-               /* update for use with FP regs... */
-               if (spec [MONO_INST_DEST] == 'f') {
-                       if (ins->dreg >= MONO_MAX_FREGS) {
-                               val = rs->fassign [ins->dreg];
-                               prev_dreg = ins->dreg;
-                               if (val < 0) {
-                                       int spill = 0;
-                                       if (val < -1) {
-                                               /* the register gets spilled 
after this inst */
-                                               spill = -val -1;
-                                       }
-                                       dest_mask = cur_fregs;
-                                       val = mono_regstate_alloc_float (rs, 
dest_mask);
-                                       if (val < 0)
-                                               val = 
get_float_register_spilling (cfg, tmp, ins, dest_mask, ins->dreg);
-                                       rs->fassign [ins->dreg] = val;
-                                       if (spill)
-                                               create_spilled_store_float 
(cfg, spill, val, prev_dreg, ins);
-                               }
-                               DEBUG (g_print ("\tassigned dreg %s to dest 
R%d\n", mono_arch_regname (val), ins->dreg));
-                               rs->fsymbolic [val] = prev_dreg;
-                               ins->dreg = val;
-                       } else {
-                               prev_dreg = -1;
-                       }
-                       if (freg_is_freeable (ins->dreg) && prev_dreg >= 0 && 
(reginfo [prev_dreg].born_in >= i || !(cur_fregs & (1 << ins->dreg)))) {
-                               DEBUG (g_print ("\tfreeable %s (R%d) (born in 
%d)\n", mono_arch_regname (ins->dreg), prev_dreg, reginfo [prev_dreg].born_in));
-                               mono_regstate_free_float (rs, ins->dreg);
-                       }
-               } else if (ins->dreg >= MONO_MAX_IREGS) {
-                       val = rs->iassign [ins->dreg];
-                       prev_dreg = ins->dreg;
-                       if (val < 0) {
-                               int spill = 0;
-                               if (val < -1) {
-                                       /* the register gets spilled after this 
inst */
-                                       spill = -val -1;
-                               }
-                               val = mono_regstate_alloc_int (rs, dest_mask);
-                               if (val < 0)
-                                       val = get_register_spilling (cfg, tmp, 
ins, dest_mask, ins->dreg);
-                               rs->iassign [ins->dreg] = val;
-                               if (spill)
-                                       create_spilled_store (cfg, spill, val, 
prev_dreg, ins);
-                       }
-                       DEBUG (g_print ("\tassigned dreg %s to dest R%d\n", 
mono_arch_regname (val), ins->dreg));
-                       rs->isymbolic [val] = prev_dreg;
-                       ins->dreg = val;
-                       if (!v64 && spec [MONO_INST_DEST] == 'l') {
-                               int hreg = prev_dreg + 1;
-                               val = rs->iassign [hreg];
-                               if (val < 0) {
-                                       int spill = 0;
-                                       if (val < -1) {
-                                               /* the register gets spilled 
after this inst */
-                                               spill = -val -1;
-                                       }
-                                       /* The second register must be a pair 
of the first */
-                                       dest_mask = 1 << (rs->iassign 
[prev_dreg] + 1);
-                                       val = mono_regstate_alloc_int (rs, 
dest_mask);
-                                       if (val < 0)
-                                               val = get_register_spilling 
(cfg, tmp, ins, dest_mask, hreg);
-                                       rs->iassign [hreg] = val;
-                                       if (spill)
-                                               create_spilled_store (cfg, 
spill, val, hreg, ins);
-                               }
-                               else {
-                                       /* The second register must be a pair 
of the first */
-                                       if (val != rs->iassign [prev_dreg] + 1) 
{
-                                               dest_mask = 1 << (rs->iassign 
[prev_dreg] + 1);
-
-                                               val = mono_regstate_alloc_int 
(rs, dest_mask);
-                                               if (val < 0)
-                                                       val = 
get_register_spilling (cfg, tmp, ins, dest_mask, hreg);
-
-                                               create_copy_ins (cfg, 
rs->iassign [hreg], val, ins);
-
-                                               rs->iassign [hreg] = val;
-                                       }
-                               }                                       
-
-                               DEBUG (g_print ("\tassigned hreg %s to dest 
R%d\n", mono_arch_regname (val), hreg));
-                               rs->isymbolic [val] = hreg;
-
-                               if (reg_is_freeable (val) && hreg >= 0 && 
(reginfo [hreg].born_in >= i && !(cur_iregs & (1 << val)))) {
-                                       DEBUG (g_print ("\tfreeable %s 
(R%d)\n", mono_arch_regname (val), hreg));
-                                       mono_regstate_free_int (rs, val);
-                               }
-                       }
-               } else {
-                       prev_dreg = -1;
-               }
-               if (spec [MONO_INST_DEST] != 'f' && reg_is_freeable (ins->dreg) 
&& prev_dreg >= 0 && (reginfo [prev_dreg].born_in >= i)) {
-                       DEBUG (g_print ("\tfreeable %s (R%d) (born in %d)\n", 
mono_arch_regname (ins->dreg), prev_dreg, reginfo [prev_dreg].born_in));
-                       mono_regstate_free_int (rs, ins->dreg);
-               }
-
-               /*
-                * SRC1
-                */
-               if (spec [MONO_INST_SRC1] == 'f') {
-                       if (ins->sreg1 >= MONO_MAX_FREGS) {
-                               val = rs->fassign [ins->sreg1];
-                               prev_sreg1 = ins->sreg1;
-                               if (val < 0) {
-                                       int spill = 0;
-                                       if (val < -1) {
-                                               /* the register gets spilled 
after this inst */
-                                               spill = -val -1;
-                                       }
-                                       //g_assert (val == -1); /* source 
cannot be spilled */
-                                       src1_mask = cur_fregs;
-                                       val = mono_regstate_alloc_float (rs, 
src1_mask);
-                                       if (val < 0)
-                                               val = 
get_float_register_spilling (cfg, tmp, ins, src1_mask, ins->sreg1);
-                                       rs->fassign [ins->sreg1] = val;
-                                       DEBUG (g_print ("\tassigned sreg1 %s to 
R%d\n", mono_arch_regname (val), ins->sreg1));
-                                       if (spill) {
-                                               MonoInst *store = 
create_spilled_store_float (cfg, spill, val, prev_sreg1, NULL);
-                                               insert_before_ins (ins, tmp, 
store);
-                                       }
-                               }
-                               rs->fsymbolic [val] = prev_sreg1;
-                               ins->sreg1 = val;
-                       } else {
-                               prev_sreg1 = -1;
-                       }
-               } else if (ins->sreg1 >= MONO_MAX_IREGS) {
-                       val = rs->iassign [ins->sreg1];
-                       prev_sreg1 = ins->sreg1;
-                       if (val < 0) {
-                               int spill = 0;
-                               if (val < -1) {
-                                       /* the register gets spilled after this 
inst */
-                                       spill = -val -1;
-                               }
-                               if (0 && (ins->opcode == OP_MOVE) && 
reg_is_freeable (ins->dreg)) {
-                                       /* 
-                                        * small optimization: the dest 
register is already allocated
-                                        * but the src one is not: we can 
simply assign the same register
-                                        * here and peephole will get rid of 
the instruction later.
-                                        * This optimization may interfere with 
the clobbering handling:
-                                        * it removes a mov operation that will 
be added again to handle clobbering.
-                                        * There are also some other issues 
that should with make testjit.
-                                        */
-                                       mono_regstate_alloc_int (rs, 1 << 
ins->dreg);
-                                       val = rs->iassign [ins->sreg1] = 
ins->dreg;
-                                       //g_assert (val >= 0);
-                                       DEBUG (g_print ("\tfast assigned sreg1 
%s to R%d\n", mono_arch_regname (val), ins->sreg1));
-                               } else {
-                                       //g_assert (val == -1); /* source 
cannot be spilled */
-                                       val = mono_regstate_alloc_int (rs, 
src1_mask);
-                                       if (val < 0)
-                                               val = get_register_spilling 
(cfg, tmp, ins, src1_mask, ins->sreg1);
-                                       rs->iassign [ins->sreg1] = val;
-                                       DEBUG (g_print ("\tassigned sreg1 %s to 
R%d\n", mono_arch_regname (val), ins->sreg1));
-                               }
-                               if (spill) {
-                                       MonoInst *store = create_spilled_store 
(cfg, spill, val, prev_sreg1, NULL);
-                                       insert_before_ins (ins, tmp, store);
-                               }
-                       }
-                       rs->isymbolic [val] = prev_sreg1;
-                       ins->sreg1 = val;
-               } else {
-                       prev_sreg1 = -1;
-               }
-
-               /*
-                * SRC2
-                */
-               if (spec [MONO_INST_SRC2] == 'f') {
-                       if (ins->sreg2 >= MONO_MAX_FREGS) {
-                               val = rs->fassign [ins->sreg2];
-                               prev_sreg2 = ins->sreg2;
-                               if (val < 0) {
-                                       int spill = 0;
-                                       if (val < -1) {
-                                               /* the register gets spilled 
after this inst */
-                                               spill = -val -1;
-                                       }
-                                       src2_mask = cur_fregs;
-                                       val = mono_regstate_alloc_float (rs, 
src2_mask);
-                                       if (val < 0)
-                                               val = 
get_float_register_spilling (cfg, tmp, ins, src2_mask, ins->sreg2);
-                                       rs->fassign [ins->sreg2] = val;
-                                       DEBUG (g_print ("\tassigned sreg2 %s to 
R%d\n", mono_arch_regname (val), ins->sreg2));
-                                       if (spill)
-                                               create_spilled_store_float 
(cfg, spill, val, prev_sreg2, ins);
-                               }
-                               rs->fsymbolic [val] = prev_sreg2;
-                               ins->sreg2 = val;
-                       } else {
-                               prev_sreg2 = -1;
-                       }
-               } else if (ins->sreg2 >= MONO_MAX_IREGS) {
-                       val = rs->iassign [ins->sreg2];
-                       prev_sreg2 = ins->sreg2;
-                       if (val < 0) {
-                               int spill = 0;
-                               if (val < -1) {
-                                       /* the register gets spilled after this 
inst */
-                                       spill = -val -1;
-                               }
-                               val = mono_regstate_alloc_int (rs, src2_mask);
-                               if (val < 0)
-                                       val = get_register_spilling (cfg, tmp, 
ins, src2_mask, ins->sreg2);
-                               rs->iassign [ins->sreg2] = val;
-                               DEBUG (g_print ("\tassigned sreg2 %s to R%d\n", 
mono_arch_regname (val), ins->sreg2));
-                               if (spill)
-                                       create_spilled_store (cfg, spill, val, 
prev_sreg2, ins);
-                       }
-                       rs->isymbolic [val] = prev_sreg2;
-                       ins->sreg2 = val;
-               } else {
-                       prev_sreg2 = -1;
-               }
-
-               if (spec [MONO_INST_CLOB] == 'c') {
-                       int j, s;
-                       guint32 clob_mask = ARCH_CALLER_REGS;
-                       for (j = 0; j < MONO_MAX_IREGS; ++j) {
-                               s = 1 << j;
-                               if ((clob_mask & s) && !(rs->ifree_mask & s) && 
j != ins->sreg1) {
-                                       //g_warning ("register %s busy at call 
site\n", mono_arch_regname (j));
-                               }
-                       }
-               }
-               /*if (reg_is_freeable (ins->sreg1) && prev_sreg1 >= 0 && 
reginfo [prev_sreg1].born_in >= i) {
-                       DEBUG (g_print ("freeable %s\n", mono_arch_regname 
(ins->sreg1)));
-                       mono_regstate_free_int (rs, ins->sreg1);
-               }
-               if (reg_is_freeable (ins->sreg2) && prev_sreg2 >= 0 && reginfo 
[prev_sreg2].born_in >= i) {
-                       DEBUG (g_print ("freeable %s\n", mono_arch_regname 
(ins->sreg2)));
-                       mono_regstate_free_int (rs, ins->sreg2);
-               }*/
-               
-               //DEBUG (print_ins (i, ins));
-
-               tmp = tmp->next;
-       }
+       mono_local_regalloc (cfg, bb);
 }
 
 static void

Modified: branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-sparc.h
===================================================================
--- branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-sparc.h  
2005-04-11 21:34:15 UTC (rev 42808)
+++ branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini-sparc.h  
2005-04-11 21:56:11 UTC (rev 42809)
@@ -8,6 +8,38 @@
 #define MONO_MAX_IREGS 32
 #define MONO_MAX_FREGS 32
 
+/* Parameters used by the register allocator */
+
+#define MONO_ARCH_HAS_XP_LOCAL_REGALLOC
+
+/* Use %l4..%l7 as local registers */
+#define MONO_ARCH_CALLEE_REGS (0xf0<<16)
+
+#define MONO_ARCH_CALLEE_SAVED_REGS (~MONO_ARCH_CALLEE_REGS)
+
+#ifdef SPARCV9
+/* Use %d34..%d62 as the double precision floating point local registers */
+/* %d32 has the same encoding as %f1, so %d36%d38 == 0b1010 == 0xa */
+#define MONO_ARCH_CALLEE_FREGS (0xaaaaaaa8)
+#else
+/* Use %f2..%f30 as the double precision floating point local registers */
+#define MONO_ARCH_CALLEE_FREGS (0x55555554)
+#endif
+
+#define MONO_ARCH_CALLEE_SAVED_FREGS 0
+
+#define MONO_ARCH_USE_FPSTACK FALSE
+#define MONO_ARCH_FPSTACK_SIZE 0
+#define MONO_ARCH_INST_FIXED_REG(desc) (-1)
+#define MONO_ARCH_INST_SREG2_MASK(ins) (0)
+
+#ifdef SPARCV9
+#define MONO_ARCH_INST_IS_REGPAIR(desc) FALSE
+#else
+#define MONO_ARCH_INST_IS_REGPAIR(desc) (desc == 'l')
+#endif
+
+
 #define MONO_ARCH_FRAME_ALIGNMENT (sizeof (gpointer) * 2)
 
 #define MONO_ARCH_CODE_ALIGNMENT 32

Modified: branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini.h
===================================================================
--- branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini.h        
2005-04-11 21:34:15 UTC (rev 42808)
+++ branches/vargaz/mini-xp-local-regalloc/mono/mono/mini/mini.h        
2005-04-11 21:56:11 UTC (rev 42809)
@@ -280,7 +280,7 @@
        gboolean virtual;
        regmask_t used_iregs;
        regmask_t used_fregs;
-#ifdef __x86_64__
+#ifdef MONO_ARCH_HAS_XP_LOCAL_REGALLOC
        GSList *out_ireg_args;
        GSList *out_freg_args;
 #endif
@@ -825,6 +825,7 @@
 
 gboolean          mono_running_on_valgrind (void);
 void*             mono_global_codeman_reserve (int size);
+const char       *mono_regname_full (int reg, gboolean fp);
 gint32*           mono_allocate_stack_slots (MonoCompile *cfg, guint32 
*stack_size, guint32 *stack_align);
 void              mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb);
 
@@ -839,7 +840,6 @@
 void      mono_codegen                          (MonoCompile *cfg);
 const char *mono_arch_regname                   (int reg);
 const char *mono_arch_fregname                  (int reg);
-const char *mono_arch_regname_full              (int reg, gboolean fp);
 gpointer  mono_arch_get_throw_exception         (void);
 gpointer  mono_arch_get_rethrow_exception       (void);
 gpointer  mono_arch_get_throw_exception_by_name (void);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to