Author: zoltan
Date: 2008-02-07 08:17:12 -0500 (Thu, 07 Feb 2008)
New Revision: 95134

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/mini-alpha.c
   trunk/mono/mono/mini/mini-amd64.c
   trunk/mono/mono/mini/mini-arm.c
   trunk/mono/mono/mini/mini-hppa.c
   trunk/mono/mono/mini/mini-ia64.c
   trunk/mono/mono/mini/mini-mips.c
   trunk/mono/mono/mini/mini-ppc.c
   trunk/mono/mono/mini/mini-s390.c
   trunk/mono/mono/mini/mini-s390x.c
   trunk/mono/mono/mini/mini-sparc.c
   trunk/mono/mono/mini/mini-x86.c
   trunk/mono/mono/mini/mini.c
   trunk/mono/mono/mini/mini.h
Log:
2008-02-07  Zoltan Varga  <[EMAIL PROTECTED]>

        * mini.c mini-<ARCH>.c: Remove mono_arch_local_regalloc (), instead 
make 
        arch specific functions for its parts. Call the peephole pass after 
local
        regalloc so the prolog can compute a more accurate max_offset.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/ChangeLog      2008-02-07 13:17:12 UTC (rev 95134)
@@ -1,5 +1,9 @@
 2008-02-07  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * mini.c mini-<ARCH>.c: Remove mono_arch_local_regalloc (), instead 
make 
+       arch specific functions for its parts. Call the peephole pass after 
local
+       regalloc so the prolog can compute a more accurate max_offset.
+       
        * mini.c (mono_normalize_opcodes): New mini pass to convert CEE_ 
opcodes to
        the corresponding OP_I/OP_L opcodes.
 

Modified: trunk/mono/mono/mini/mini-alpha.c
===================================================================
--- trunk/mono/mono/mini/mini-alpha.c   2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-alpha.c   2008-02-07 13:17:12 UTC (rev 95134)
@@ -419,9 +419,14 @@
 
 /*========================= End of Function ========================*/
 
-static void
-  peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
+}
+
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
+{
   MonoInst *ins, *n;
    
   CFG_DEBUG(3) g_print ("ALPHA: PEEPHOLE pass\n");
@@ -574,8 +579,11 @@
     }
 }
 
+void
+mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+{
+}
 
-
 // Convert to opposite branch opcode
 static guint16 cvt_branch_opcode(guint16 opcode)
 {
@@ -2193,9 +2201,6 @@
    
    CFG_DEBUG(2) ALPHA_DEBUG("mono_arch_output_basic_block");
    
-   if (cfg->opt & MONO_OPT_PEEPHOLE)
-     peephole_pass (cfg, bb);
-    
    CFG_DEBUG(2) g_print ("Basic block %d(%p) starting at offset 0x%x\n",
                         bb->block_num, bb, bb->native_offset);
    

Modified: trunk/mono/mono/mini/mini-amd64.c
===================================================================
--- trunk/mono/mono/mini/mini-amd64.c   2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-amd64.c   2008-02-07 13:17:12 UTC (rev 95134)
@@ -1607,12 +1607,12 @@
 #define INST_IGNORES_CFLAGS(opcode) (!(((opcode) == OP_ADC) || ((opcode) == 
OP_ADC_IMM) || ((opcode) == OP_IADC) || ((opcode) == OP_IADC_IMM) || ((opcode) 
== OP_SBB) || ((opcode) == OP_SBB_IMM) || ((opcode) == OP_ISBB) || ((opcode) == 
OP_ISBB_IMM)))
 
 /*
- * peephole_pass_1:
+ * mono_arch_peephole_pass_1:
  *
  *   Perform peephole opts which should/can be performed before local regalloc
  */
-static void
-peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *n;
 
@@ -1839,8 +1839,8 @@
        }
 }
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *n;
 
@@ -2094,7 +2094,7 @@
  *  Converts complex opcodes into simpler ones so that each IR instruction
  * corresponds to one machine instruction.
  */
-static void
+void
 mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *n, *temp;
@@ -2191,27 +2191,6 @@
 
 /*#include "cprop.c"*/
 
-/*
- * 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)
-{
-       if (MONO_INST_LIST_EMPTY (&bb->ins_list))
-               return;
-
-       mono_arch_lowering_pass (cfg, bb);
-
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass_1 (cfg, bb);
-
-       mono_local_regalloc (cfg, bb);
-}
-
 static unsigned char*
 emit_float_to_int (MonoCompile *cfg, guchar *code, int dreg, int sreg, int 
size, gboolean is_signed)
 {
@@ -2522,9 +2501,6 @@
        guint last_offset = 0;
        int max_len, cpos;
 
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
-
        if (cfg->opt & MONO_OPT_LOOP) {
                int pad, align = LOOP_ALIGNMENT;
                /* set alignment depending on cpu */

Modified: trunk/mono/mono/mini/mini-arm.c
===================================================================
--- trunk/mono/mono/mini/mini-arm.c     2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-arm.c     2008-02-07 13:17:12 UTC (rev 95134)
@@ -1278,9 +1278,14 @@
 
 #define EMIT_COND_SYSTEM_EXCEPTION(cond,exc_name) 
EMIT_COND_SYSTEM_EXCEPTION_FLAGS(branch_cc_table [(cond)], (exc_name))
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
+}
+
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
+{
        MonoInst *ins, *n;
 
        MONO_INST_LIST_FOR_EACH_ENTRY_SAFE (ins, n, &bb->ins_list, node) {
@@ -1513,7 +1518,7 @@
  * represented with very simple instructions with no register
  * requirements.
  */
-static void
+void
 mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        int rot_amount, imm8, low_imm;
@@ -1667,15 +1672,6 @@
        bb->max_vreg = cfg->rs->next_vreg;
 }
 
-void
-mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
-{
-       if (MONO_INST_LIST_EMPTY (&bb->ins_list))
-               return;
-       mono_arch_lowering_pass (cfg, bb);
-       mono_local_regalloc (cfg, bb);
-}
-
 static guchar*
 emit_float_to_int (MonoCompile *cfg, guchar *code, int dreg, int sreg, int 
size, gboolean is_signed)
 {
@@ -2030,9 +2026,6 @@
        int max_len, cpos;
        int imm8, rot_amount;
 
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
-
        /* we don't align basic blocks of loops on arm */
 
        if (cfg->verbose_level > 2)

Modified: trunk/mono/mono/mini/mini-hppa.c
===================================================================
--- trunk/mono/mono/mini/mini-hppa.c    2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-hppa.c    2008-02-07 13:17:12 UTC (rev 95134)
@@ -762,9 +762,14 @@
        return call;
 }
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
+}
+
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
+{
        DEBUG_FUNC_ENTER();
        DEBUG_FUNC_EXIT();
 }
@@ -848,7 +853,7 @@
  * represented with very simple instructions with no register
  * requirements.
  */
-static void
+void
 mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *next, *temp, *temp2;
@@ -960,17 +965,6 @@
 }
 
 void
-mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
-{
-       DEBUG_FUNC_ENTER();
-       if (MONO_INST_LIST_EMPTY (&bb->ins_list))
-               return;
-       mono_arch_lowering_pass (cfg, bb);
-       mono_local_regalloc (cfg, bb);
-       DEBUG_FUNC_EXIT();
-}
-
-void
 hppa_patch (guint32 *code, const gpointer target)
 {
        guint32 ins = *code;
@@ -1231,8 +1225,6 @@
        const char *spec;
 
        DEBUG_FUNC_ENTER();
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
 
        if (cfg->verbose_level > 2)
                g_print ("[%s::%s] Basic block %d starting at offset 0x%x\n", 
cfg->method->klass->name, cfg->method->name, bb->block_num, bb->native_offset);

Modified: trunk/mono/mono/mini/mini-ia64.c
===================================================================
--- trunk/mono/mono/mini/mini-ia64.c    2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-ia64.c    2008-02-07 13:17:12 UTC (rev 95134)
@@ -1225,9 +1225,14 @@
        return call;
 }
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
+}
+
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
+{
        MonoInst *ins, *n;
 
        MONO_INST_LIST_FOR_EACH_ENTRY_SAFE (ins, n, &bb->ins_list, node) {
@@ -1325,7 +1330,7 @@
  *  Converts complex opcodes into simpler ones so that each IR instruction
  * corresponds to one machine instruction.
  */
-static void
+void
 mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *n, *next, *temp, *temp2, *temp3;
@@ -1856,17 +1861,6 @@
        bb->max_vreg = cfg->rs->next_vreg;
 }
 
-void
-mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
-{
-       if (MONO_INST_LIST_EMPTY (&bb->ins_list))
-               return;
-
-       mono_arch_lowering_pass (cfg, bb);
-
-       mono_local_regalloc (cfg, bb);
-}
-
 /*
  * emit_load_volatile_arguments:
  *
@@ -2073,9 +2067,6 @@
        guint last_offset = 0;
        int max_len, cpos;
 
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
-
        if (cfg->opt & MONO_OPT_LOOP) {
                /* FIXME: */
        }

Modified: trunk/mono/mono/mini/mini-mips.c
===================================================================
--- trunk/mono/mono/mini/mini-mips.c    2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-mips.c    2008-02-07 13:17:12 UTC (rev 95134)
@@ -1266,9 +1266,14 @@
        return call;
 }
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
+}
+
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
+{
        MonoInst *ins, *n;
 
        MONO_INST_LIST_FOR_EACH_ENTRY_SAFE (ins, n, &bb->ins_list, node) {
@@ -1480,7 +1485,7 @@
  * represented with very simple instructions with no register
  * requirements.
  */
-static void
+void
 mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *next, *temp;
@@ -1639,15 +1644,6 @@
        bb->max_vreg = cfg->rs->next_vreg;
 }
 
-void
-mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
-{
-       if (MONO_INST_LIST_EMPTY (&bb->ins_list))
-               return;
-       mono_arch_lowering_pass (cfg, bb);
-       mono_local_regalloc (cfg, bb);
-}
-
 static guchar*
 emit_float_to_int (MonoCompile *cfg, guchar *code, int dreg, int sreg, int 
size, gboolean is_signed)
 {
@@ -1689,9 +1685,6 @@
        int max_len, cpos;
        int ins_cnt = 0;
 
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
-
        /* we don't align basic blocks of loops on mips */
 
        if (cfg->verbose_level > 2)

Modified: trunk/mono/mono/mini/mini-ppc.c
===================================================================
--- trunk/mono/mono/mini/mini-ppc.c     2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-ppc.c     2008-02-07 13:17:12 UTC (rev 95134)
@@ -1421,8 +1421,8 @@
 
 #define EMIT_COND_SYSTEM_EXCEPTION(cond,exc_name) 
EMIT_COND_SYSTEM_EXCEPTION_FLAGS(branch_b0_table [(cond)], branch_b1_table 
[(cond)], (exc_name))
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *n;
 
@@ -2106,9 +2106,6 @@
        guint last_offset = 0;
        int max_len, cpos;
 
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
-
        /* we don't align basic blocks of loops on ppc */
 
        if (cfg->verbose_level > 2)

Modified: trunk/mono/mono/mini/mini-s390.c
===================================================================
--- trunk/mono/mono/mini/mini-s390.c    2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-s390.c    2008-02-07 13:17:12 UTC (rev 95134)
@@ -248,7 +248,6 @@
 static inline void add_stackParm (guint *, size_data *, ArgInfo *, gint);
 static inline void add_float (guint *, size_data *, ArgInfo *);
 static CallInfo * calculate_sizes (MonoCompile *, MonoMethodSignature *, 
size_data *, gboolean);
-static void peephole_pass (MonoCompile *, MonoBasicBlock *);
 static guchar * emit_float_to_int (MonoCompile *, guchar *, int, int, int, 
gboolean);
 gpointer mono_arch_get_lmf_addr (void);
 static guint8 * emit_load_volatile_registers(guint8 *, MonoCompile *);
@@ -2184,17 +2183,22 @@
 
 /*========================= End of Function ========================*/
 
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
+{
+}
+
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - peephole_pass                                     */
+/* Name                - mono_arch_peephole_pass                               
      */
 /*                                                                  */
 /* Function    - Form a peephole pass at the code looking for      */
 /*               simple optimizations.                             */
 /*                                                                 */
 /*------------------------------------------------------------------*/
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *n;
 
@@ -2318,24 +2322,9 @@
 
 /*========================= End of Function ========================*/
 
-/*------------------------------------------------------------------*/
-/*                                                                  */
-/* Name                - mono_arch_local_regalloc.                         */
-/*                                                                  */
-/* Function    - We first scan the list of instructions and we     */
-/*                save the liveness information of each register    */
-/*                (when the register is first used, when its value  */
-/*                is set etc.). We also reverse the list of instr-  */
-/*                uctions (in the InstList list) because assigning  */
-/*                registers backwards allows for more tricks to be  */
-/*               used.                                             */
-/*                                                                 */
-/*------------------------------------------------------------------*/
-
 void
-mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
+mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
 {
-       mono_local_regalloc(cfg, bb);
 }
 
 /*========================= End of Function ========================*/
@@ -2416,9 +2405,6 @@
        guint last_offset = 0;
        int max_len, cpos, src2;
 
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
-
        /* we don't align basic blocks of loops on s390 */
 
        if (cfg->verbose_level > 2)

Modified: trunk/mono/mono/mini/mini-s390x.c
===================================================================
--- trunk/mono/mono/mini/mini-s390x.c   2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-s390x.c   2008-02-07 13:17:12 UTC (rev 95134)
@@ -270,7 +270,6 @@
 static inline void add_stackParm (guint *, size_data *, ArgInfo *, gint);
 static inline void add_float (guint *, size_data *, ArgInfo *);
 static CallInfo * calculate_sizes (MonoCompile *, MonoMethodSignature *, 
size_data *, gboolean);
-static void peephole_pass (MonoCompile *, MonoBasicBlock *);
 static guchar * emit_float_to_int (MonoCompile *, guchar *, int, int, int, 
gboolean);
 gpointer mono_arch_get_lmf_addr (void);
 static guint8 * emit_load_volatile_registers (guint8 *, MonoCompile *);
@@ -2213,17 +2212,22 @@
 
 /*========================= End of Function ========================*/
 
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
+{
+}
+
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - peephole_pass                                     */
+/* Name                - mono_arch_peephole_pass                               
      */
 /*                                                                  */
 /* Function    - Form a peephole pass at the code looking for      */
 /*               simple optimizations.                             */
 /*                                                                 */
 /*------------------------------------------------------------------*/
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *n;
 
@@ -2329,24 +2333,9 @@
 
 /*========================= End of Function ========================*/
 
-/*------------------------------------------------------------------*/
-/*                                                                  */
-/* Name                - mono_arch_local_regalloc.                         */
-/*                                                                  */
-/* Function    - We first scan the list of instructions and we     */
-/*                save the liveness information of each register    */
-/*                (when the register is first used, when its value  */
-/*                is set etc.). We also reverse the list of instr-  */
-/*                uctions (in the InstList list) because assigning  */
-/*                registers backwards allows for more tricks to be  */
-/*               used.                                             */
-/*                                                                 */
-/*------------------------------------------------------------------*/
-
 void
-mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
+mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
 {
-       mono_local_regalloc(cfg, bb);
 }
 
 /*========================= End of Function ========================*/
@@ -2427,9 +2416,6 @@
        guint last_offset = 0;
        int max_len, cpos, src2;
 
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
-
        /* we don't align basic blocks of loops on s390 */
 
        if (cfg->verbose_level > 2)

Modified: trunk/mono/mono/mini/mini-sparc.c
===================================================================
--- trunk/mono/mono/mini/mini-sparc.c   2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-sparc.c   2008-02-07 13:17:12 UTC (rev 95134)
@@ -1482,9 +1482,14 @@
        return code;
 }
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
+}
+
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
+{
        MonoInst *ins, *n;
 
        MONO_INST_LIST_FOR_EACH_ENTRY_SAFE (ins, n, &bb->ins_list, node) {
@@ -1717,6 +1722,11 @@
        }
 }
 
+void
+mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+{
+}
+
 static int
 mono_spillvar_offset_float (MonoCompile *cfg, int spillvar)
 {
@@ -1738,12 +1748,6 @@
 
 /* FIXME: Strange loads from the stack in basic-float.cs:test_2_rem */
 
-void
-mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
-{
-       mono_local_regalloc (cfg, bb);
-}
-
 static void
 sparc_patch (guint32 *code, const gpointer target)
 {
@@ -2361,9 +2365,6 @@
        int max_len, cpos;
        const char *spec;
 
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
-
        if (cfg->verbose_level > 2)
                g_print ("Basic block %d starting at offset 0x%x\n", 
bb->block_num, bb->native_offset);
 

Modified: trunk/mono/mono/mini/mini-x86.c
===================================================================
--- trunk/mono/mono/mini/mini-x86.c     2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini-x86.c     2008-02-07 13:17:12 UTC (rev 95134)
@@ -1333,12 +1333,12 @@
 #define INST_IGNORES_CFLAGS(opcode) (!(((opcode) == OP_ADC) || ((opcode) == 
OP_IADC) || ((opcode) == OP_ADC_IMM) || ((opcode) == OP_IADC_IMM) || ((opcode) 
== OP_SBB) || ((opcode) == OP_ISBB) || ((opcode) == OP_SBB_IMM) || ((opcode) == 
OP_ISBB_IMM)))
 
 /*
- * peephole_pass_1:
+ * mono_peephole_pass_1:
  *
  *   Perform peephole opts which should/can be performed before local regalloc
  */
-static void
-peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *n;
 
@@ -1539,8 +1539,8 @@
        }
 }
 
-static void
-peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+void
+mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *n;
 
@@ -1755,6 +1755,11 @@
        }
 }
 
+void
+mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
+{
+}
+
 static const int 
 branch_cc_table [] = {
        X86_CC_EQ, X86_CC_GE, X86_CC_GT, X86_CC_LE, X86_CC_LT,
@@ -1775,15 +1780,6 @@
        FALSE, FALSE, FALSE, FALSE
 };
 
-void
-mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
-{
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass_1 (cfg, bb);
-
-       mono_local_regalloc (cfg, bb);
-}
-
 static unsigned char*
 emit_float_to_int (MonoCompile *cfg, guchar *code, int dreg, int size, 
gboolean is_signed)
 {
@@ -2093,9 +2089,6 @@
        guint8 *code = cfg->native_code + cfg->code_len;
        int max_len, cpos;
 
-       if (cfg->opt & MONO_OPT_PEEPHOLE)
-               peephole_pass (cfg, bb);
-
        if (cfg->opt & MONO_OPT_LOOP) {
                int pad, align = LOOP_ALIGNMENT;
                /* set alignment depending on cpu */

Modified: trunk/mono/mono/mini/mini.c
===================================================================
--- trunk/mono/mono/mini/mini.c 2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini.c 2008-02-07 13:17:12 UTC (rev 95134)
@@ -10959,7 +10959,16 @@
 #ifdef MONO_ARCH_ENABLE_NORMALIZE_OPCODES
                mono_normalize_opcodes (cfg, bb);
 #endif
-               mono_arch_local_regalloc (cfg, bb);
+
+               mono_arch_lowering_pass (cfg, bb);
+
+               if (cfg->opt & MONO_OPT_PEEPHOLE)
+                       mono_arch_peephole_pass_1 (cfg, bb);
+
+               mono_local_regalloc (cfg, bb);
+
+               if (cfg->opt & MONO_OPT_PEEPHOLE)
+                       mono_arch_peephole_pass_2 (cfg, bb);
        }
 
        if (cfg->prof_options & MONO_PROFILE_COVERAGE)

Modified: trunk/mono/mono/mini/mini.h
===================================================================
--- trunk/mono/mono/mini/mini.h 2008-02-07 13:15:52 UTC (rev 95133)
+++ trunk/mono/mono/mini/mini.h 2008-02-07 13:17:12 UTC (rev 95134)
@@ -1200,7 +1200,9 @@
 guint8   *mono_arch_emit_prolog                 (MonoCompile *cfg) 
MONO_INTERNAL;
 void      mono_arch_emit_epilog                 (MonoCompile *cfg) 
MONO_INTERNAL;
 void      mono_arch_emit_exceptions             (MonoCompile *cfg) 
MONO_INTERNAL;
-void      mono_arch_local_regalloc              (MonoCompile *cfg, 
MonoBasicBlock *bb) MONO_INTERNAL;
+void      mono_arch_lowering_pass               (MonoCompile *cfg, 
MonoBasicBlock *bb) MONO_INTERNAL;
+void      mono_arch_peephole_pass_1             (MonoCompile *cfg, 
MonoBasicBlock *bb) MONO_INTERNAL;
+void      mono_arch_peephole_pass_2             (MonoCompile *cfg, 
MonoBasicBlock *bb) MONO_INTERNAL;
 void      mono_arch_output_basic_block          (MonoCompile *cfg, 
MonoBasicBlock *bb) MONO_INTERNAL;
 gboolean  mono_arch_has_unwind_info             (gconstpointer addr) 
MONO_INTERNAL;
 void      mono_arch_setup_jit_tls_data          (MonoJitTlsData *tls) 
MONO_INTERNAL;

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

Reply via email to