Author: zoltan
Date: 2006-01-13 18:19:20 -0500 (Fri, 13 Jan 2006)
New Revision: 55561

Modified:
   branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c
   branches/vargaz/mini-linear-il/mono/mono/mini/mini.c
   branches/vargaz/mini-linear-il/mono/mono/mini/mini.h
Log:
Get rid of compute_vreg_to_inst

Modified: branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c        
2006-01-13 23:07:10 UTC (rev 55560)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c        
2006-01-13 23:19:20 UTC (rev 55561)
@@ -200,6 +200,12 @@
        return alloc_preg (cfg);
 }
 
+guint32
+mono_alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
+{
+       return alloc_dreg (cfg, stack_type);
+}
+
 static guint
 mono_type_to_regstore (MonoType *type)
 {
@@ -8732,84 +8738,6 @@
 }
 
 /**
- * compute_vreg_to_inst:
- *
- *  Fill out cfg->vreg_to_inst
- */
-static void
-compute_vreg_to_inst (MonoCompile *cfg)
-{
-       int i;
-
-       /* FIXME: Do this in mono_create_var */
-
-       cfg->vreg_to_inst ['i'] = mono_mempool_alloc0 (cfg->mempool, sizeof 
(MonoInst*) * cfg->next_vireg);
-       cfg->vreg_to_inst_len ['i'] = cfg->next_vireg;
-       
-       cfg->vreg_to_inst ['f'] = mono_mempool_alloc0 (cfg->mempool, sizeof 
(MonoInst*) * cfg->next_vfreg);
-       cfg->vreg_to_inst_len ['f'] = cfg->next_vfreg;
-
-       cfg->vreg_to_inst ['l'] = mono_mempool_alloc0 (cfg->mempool, sizeof 
(MonoInst*) * cfg->next_vireg);
-       cfg->vreg_to_inst_len ['l'] = cfg->next_vireg;
-
-       for (i = 0; i < cfg->num_varinfo; i++) {
-               MonoInst *ins = cfg->varinfo [i];
-
-               switch (ins->type) {
-               case STACK_I4:
-               case STACK_PTR:
-               case STACK_MP:
-               case STACK_OBJ:
-                       g_assert (ins->dreg != -1);
-                       cfg->vreg_to_inst ['i'][ins->dreg] = ins;
-                       break;
-               case STACK_R8:
-                       g_assert (ins->dreg != -1);
-                       cfg->vreg_to_inst ['f'][ins->dreg] = ins;
-                       break;
-               case STACK_VTYPE:
-                       break;
-               case STACK_I8: {
-#if SIZEOF_VOID_P == 8
-                       g_assert (ins->dreg != -1);
-                       cfg->vreg_to_inst ['i'][ins->dreg] = ins;
-#else
-                       MonoInst *tree;
-
-                       g_assert (ins->dreg != -1);
-                       cfg->vreg_to_inst ['l'][ins->dreg] = ins;
-
-                       g_assert (ins->dreg != -1);
-
-                       /* FIXME: Clean this up */
-
-                       /* Allocate a dummy MonoInst for the first vreg */
-                       MONO_INST_NEW (cfg, tree, OP_LOCAL);
-                       tree->dreg = ins->dreg;
-                       tree->type = STACK_I4;
-                       tree->inst_vtype = 
&mono_defaults.int32_class->byval_arg;
-                       tree->klass = mono_class_from_mono_type 
(tree->inst_vtype);
-
-                       cfg->vreg_to_inst ['i'][ins->dreg] = tree;
-
-                       /* Allocate a dummy MonoInst for the second vreg */
-                       MONO_INST_NEW (cfg, tree, OP_LOCAL);
-                       tree->dreg = ins->dreg + 1;
-                       tree->type = STACK_I4;
-                       tree->inst_vtype = 
&mono_defaults.int32_class->byval_arg;
-                       tree->klass = mono_class_from_mono_type 
(tree->inst_vtype);
-
-                       cfg->vreg_to_inst ['i'][ins->dreg + 1] = tree;
-#endif
-                       break;
-               }
-               default:
-                       NOT_IMPLEMENTED;
-               }
-       }
-}
-
-/**
  * mono_handle_global_vregs:
  *
  *   Make vregs used in more than one bblock 'global', i.e. allocate a variable
@@ -8821,8 +8749,6 @@
        MonoBasicBlock ***vreg_to_bb;
        MonoBasicBlock *bb;
 
-       compute_vreg_to_inst (cfg);
-
        vreg_to_bb = g_new0 (MonoBasicBlock**, 256);
        vreg_to_bb ['i'] = g_new0 (MonoBasicBlock*, cfg->next_vireg);
        vreg_to_bb ['l'] = g_new0 (MonoBasicBlock*, cfg->next_vireg);
@@ -8876,11 +8802,13 @@
                                         * and some references the two 
component vregs, it is quite hard
                                         * to determine when it needs to be 
global. So be conservative.
                                         */
-                                       if (!cfg->vreg_to_inst ['l'][vreg]) {
+                                       if (!get_vreg_to_inst (cfg, 'l', vreg)) 
{
                                                MonoInst *tree;
 
-                                               cfg->vreg_to_inst ['l'][vreg] = 
mono_compile_create_var_for_vreg (cfg, &mono_defaults.int64_class->byval_arg, 
OP_LOCAL, 'l', vreg);
+                                               NOT_IMPLEMENTED;
 
+                                               
mono_compile_create_var_for_vreg (cfg, &mono_defaults.int64_class->byval_arg, 
OP_LOCAL, 'l', vreg);
+
                                                if (cfg->verbose_level > 0)
                                                        printf ("LONG VREG R%d 
made global.\n", vreg);
 
@@ -8905,7 +8833,7 @@
                                        }
                                }
 
-                               if ((vreg != -1) && (vreg < 
cfg->vreg_to_inst_len [regtype]) && !cfg->vreg_to_inst [regtype][vreg]) {
+                               if ((vreg != -1) && !get_vreg_to_inst (cfg, 
regtype, vreg)) {
                                        if (vreg_to_bb [regtype][vreg] == NULL) 
{
                                                vreg_to_bb [regtype][vreg] = bb;
                                        } else if (vreg_to_bb [regtype][vreg] 
!= bb) {
@@ -8916,10 +8844,10 @@
                                                // FIXME:
                                                switch (regtype) {
                                                case 'i':
-                                                       cfg->vreg_to_inst 
[regtype][vreg] = mono_compile_create_var_for_vreg (cfg, 
&mono_defaults.int_class->byval_arg, OP_LOCAL, 'i', vreg);
+                                                       
mono_compile_create_var_for_vreg (cfg, &mono_defaults.int_class->byval_arg, 
OP_LOCAL, 'i', vreg);
                                                        break;
                                                case 'f':
-                                                       cfg->vreg_to_inst 
[regtype][vreg] = mono_compile_create_var_for_vreg (cfg, 
&mono_defaults.double_class->byval_arg, OP_LOCAL, 'f', vreg);
+                                                       
mono_compile_create_var_for_vreg (cfg, &mono_defaults.double_class->byval_arg, 
OP_LOCAL, 'f', vreg);
                                                        break;
                                                default:
                                                        NOT_IMPLEMENTED;

Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini.c
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini.c        2006-01-13 
23:07:10 UTC (rev 55560)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini.c        2006-01-13 
23:19:20 UTC (rev 55561)
@@ -90,10 +90,6 @@
                   int locals_offset, MonoInst *return_var, GList *dont_inline, 
MonoInst **inline_args, 
                   guint inline_offset, gboolean is_virtual_call);
 
-void mono_spill_global_vars (MonoCompile *cfg);
-void mono_decompose_long_opts (MonoCompile *cfg);
-void mono_handle_global_vregs (MonoCompile *cfg);
-
 static int mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, 
MonoBasicBlock *start_bblock, MonoBasicBlock *end_bblock, 
                   int locals_offset, MonoInst *return_var, GList *dont_inline, 
MonoInst **inline_args, 
                   guint inline_offset, gboolean is_virtual_call);
@@ -1676,6 +1672,44 @@
 #endif
 }
 
+static void
+set_vreg_to_inst (MonoCompile *cfg, int regtype, int vreg, MonoInst *inst)
+{
+       if (vreg >= cfg->vreg_to_inst_len [regtype]) {
+               MonoInst **tmp = cfg->vreg_to_inst [regtype];
+               int size = cfg->vreg_to_inst_len [regtype];
+
+               while (vreg >= cfg->vreg_to_inst_len [regtype])
+                       cfg->vreg_to_inst_len [regtype] = cfg->vreg_to_inst_len 
[regtype] ? cfg->vreg_to_inst_len [regtype] * 2 : 16;
+               cfg->vreg_to_inst [regtype] = g_malloc0 (sizeof (MonoInst*) * 
cfg->vreg_to_inst_len [regtype]);
+               if (size)
+                       memcpy (cfg->vreg_to_inst [regtype], tmp, size * sizeof 
(MonoInst*));
+       }
+       cfg->vreg_to_inst [regtype][vreg] = inst;
+}
+
+static inline int
+stack_type_to_regtype (MonoStackType stack_type)
+{
+       switch (stack_type) {
+       case STACK_I4:
+       case STACK_OBJ:
+       case STACK_PTR:
+       case STACK_MP:
+               return 'i';
+       case STACK_R8:
+               return 'f';
+       case STACK_I8:
+#if SIZEOF_VOID_P == 8
+               return 'i';
+#else
+               return 'l';
+#endif
+       default:
+               return ' ';
+       }
+}
+
 MonoInst*
 mono_compile_create_var_for_vreg (MonoCompile *cfg, MonoType *type, int 
opcode, int regtype, int vreg)
 {
@@ -1705,6 +1739,12 @@
        cfg->vars [num] = mono_mempool_alloc0 (cfg->mempool, sizeof 
(MonoMethodVar));
        MONO_INIT_VARINFO (cfg->vars [num], num);
 
+       if (vreg != -1)
+               set_vreg_to_inst (cfg, regtype, vreg, inst);
+
+       if (regtype == 'l')
+               NOT_IMPLEMENTED;
+
        cfg->num_varinfo++;
        //g_print ("created temp %d of type %s\n", num, mono_type_get_name 
(type));
        return inst;
@@ -1719,34 +1759,8 @@
 
        type_to_eval_stack_type (type, &dummy);
 
-       switch (dummy.type) {
-       case STACK_I4:
-       case STACK_OBJ:
-       case STACK_PTR:
-       case STACK_MP:
-               dreg = cfg->next_vireg ++;
-               regtype = 'i';
-               break;
-       case STACK_R8:
-               dreg = cfg->next_vfreg ++;
-               regtype = 'f';
-               break;
-       case STACK_I8:
-#if SIZEOF_VOID_P == 8
-               dreg = cfg->next_vireg ++;
-               regtype = 'i';
-#else
-               /* Use a pair of vregs */
-               dreg = cfg->next_vireg ++;
-               cfg->next_vireg ++;
-               regtype = 'l';
-#endif
-               break;
-       default:
-               dreg = -1;
-               regtype = ' ';
-               break;
-       }
+       dreg = mono_alloc_dreg (cfg, dummy.type);
+       regtype = stack_type_to_regtype (dummy.type);
 
        return mono_compile_create_var_for_vreg (cfg, type, opcode, regtype, 
dreg);
 }

Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini.h
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini.h        2006-01-13 
23:07:10 UTC (rev 55560)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini.h        2006-01-13 
23:19:20 UTC (rev 55561)
@@ -529,6 +529,8 @@
 
 #define MONO_BBLOCK_IS_IN_REGION(bblock, regtype) (((bblock)->region & (0xf << 
4)) == (regtype))
 
+#define get_vreg_to_inst(cfg, regtype, vreg) ((vreg) < (cfg)->vreg_to_inst_len 
[(regtype)] ? (cfg)->vreg_to_inst [(regtype)][vreg] : NULL)
+
 /*
  * Control Flow Graph and compilation unit information
  */
@@ -941,6 +943,10 @@
 MonoInst         *mono_branch_optimize_exception_target (MonoCompile *cfg, 
MonoBasicBlock *bb, const char * exname);             
 void              mini_emit_memcpy2 (MonoCompile *cfg, int destreg, int 
doffset, int srcreg, int soffset, int size, int align);
 
+void              mono_decompose_long_opts (MonoCompile *cfg);
+void              mono_handle_global_vregs (MonoCompile *cfg);
+void              mono_spill_global_vars (MonoCompile *cfg);
+
 /* methods that must be provided by the arch-specific port */
 void      mono_arch_cpu_init                    (void);
 guint32   mono_arch_cpu_optimizazions           (guint32 *exclude_mask);

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

Reply via email to