Author: zoltan
Date: 2005-11-25 16:27:38 -0500 (Fri, 25 Nov 2005)
New Revision: 53485

Modified:
   branches/vargaz/mini-linear-il/mono/mono/mini/cpu-pentium.md
   branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c
   branches/vargaz/mini-linear-il/mono/mono/mini/mini-codegen.c
   branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.c
   branches/vargaz/mini-linear-il/mono/mono/mini/mini.c
   branches/vargaz/mini-linear-il/mono/mono/mini/mini.h
Log:
Ongoing work.


Modified: branches/vargaz/mini-linear-il/mono/mono/mini/cpu-pentium.md
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/cpu-pentium.md        
2005-11-25 19:20:55 UTC (rev 53484)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/cpu-pentium.md        
2005-11-25 21:27:38 UTC (rev 53485)
@@ -127,6 +127,7 @@
 localloc: dest:i src1:i len:120
 compare: src1:i src2:i len:2
 compare_imm: src1:i len:6
+icompare_imm: src1:i len:6
 fcompare: src1:f src2:f clob:a len:9
 oparglist: src1:b len:10
 outarg: src1:i len:1

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        
2005-11-25 19:20:55 UTC (rev 53484)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c        
2005-11-25 21:27:38 UTC (rev 53485)
@@ -118,13 +118,13 @@
 static inline guint32
 alloc_ireg (MonoCompile *cfg)
 {
-       return cfg->next_ivreg ++;
+       return cfg->next_vireg ++;
 }
 
 static inline guint32
 alloc_freg (MonoCompile *cfg)
 {
-       return cfg->next_fvreg ++;
+       return cfg->next_vfreg ++;
 }
 
 static inline guint32
@@ -284,7 +284,6 @@
                (dest)->inst_c0 = (val);        \
                (dest)->type = STACK_I4;        \
                (dest)->dreg = alloc_dreg ((cfg), STACK_I4);    \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
        } while (0)
 
 #define NEW_PCONST(cfg,dest,val) do {  \
@@ -293,10 +292,22 @@
                (dest)->inst_p0 = (val);        \
                (dest)->type = STACK_PTR;       \
                (dest)->dreg = alloc_dreg ((cfg), STACK_PTR);   \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
        } while (0)
 
+#define NEW_STORE_MEMBASE(cfg,dest,op,base,offset,sr) do { \
+        MONO_INST_NEW ((cfg), (dest), (op)); \
+        (dest)->sreg1 = sr; \
+        (dest)->inst_destbasereg = base; \
+        (dest)->inst_offset = offset; \
+       } while (0)
 
+#define NEW_LOAD_MEMBASE(cfg,dest,op,dr,base,offset) do { \
+        MONO_INST_NEW ((cfg), (dest), (op)); \
+        (dest)->dreg = (dr); \
+        (dest)->inst_basereg = (base); \
+        (dest)->inst_offset = (offset); \
+       } while (0)
+
 #ifdef MONO_ARCH_NEED_GOT_VAR
 
 #define NEW_PATCH_INFO(cfg,dest,el1,el2) do {  \
@@ -322,7 +333,6 @@
                }                                                       \
                (dest)->type = STACK_PTR;                               \
                (dest)->dreg = alloc_dreg ((cfg), STACK_PTR);   \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
        } while (0)
 
 #define NEW_AOTCONST_TOKEN(cfg,dest,patch_type,image,token,stack_type) do { \
@@ -337,7 +347,6 @@
                (dest)->inst_p1 = group;                                \
                (dest)->type = (stack_type);                            \
                (dest)->dreg = alloc_dreg ((cfg), (stack_type));        \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
        } while (0)
 
 #else
@@ -349,7 +358,6 @@
                (dest)->inst_i1 = (gpointer)(patch_type); \
                (dest)->type = STACK_PTR;       \
                (dest)->dreg = alloc_dreg ((cfg), STACK_PTR);   \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
     } while (0)
 
 #define NEW_AOTCONST_TOKEN(cfg,dest,patch_type,image,token,stack_type) do {    
\
@@ -359,7 +367,6 @@
                (dest)->inst_p1 = (gpointer)(patch_type); \
                (dest)->type = (stack_type);    \
                (dest)->dreg = alloc_dreg ((cfg), (stack_type));        \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
     } while (0)
 
 #endif
@@ -422,7 +429,6 @@
                (dest)->klass = (cfg)->varinfo [locals_offset + (num)]->klass;  
\
                (dest)->sreg1 = (cfg)->varinfo [locals_offset + (num)]->dreg;   
\
         (dest)->dreg = alloc_dreg ((cfg), (dest)->type); \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
        } while (0)
 
 #define NEW_LOCLOADA(cfg,dest,num) do {        \
@@ -471,7 +477,6 @@
                (dest)->klass = (cfg)->varinfo [(num)]->klass;  \
                (dest)->sreg1 = (cfg)->varinfo [(num)]->dreg;   \
         (dest)->dreg = alloc_dreg ((cfg), (dest)->type); \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
        } while (0)
 
 #define NEW_TEMPLOADA(cfg,dest,num) do {       \
@@ -513,7 +518,6 @@
                (dest)->klass = (cfg)->varinfo [(num)]->klass;  \
         (dest)->sreg1 = (inst)->dreg; \
                (dest)->dreg = (cfg)->varinfo [(num)]->dreg;   \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
        } while (0)
 
 #define NEW_LOCSTORE(cfg,dest,num,inst) do {   \
@@ -523,7 +527,6 @@
                (dest)->klass = (cfg)->varinfo [locals_offset + (num)]->klass;  
\
         (dest)->sreg1 = (inst)->dreg; \
                (dest)->dreg = (cfg)->varinfo [locals_offset + (num)]->dreg;   \
-               mono_bblock_add_inst ((cfg)->cbb, (dest)); \
        } while (0)
 
 #define NEW_ARGSTORE(cfg,dest,num,inst) do {   \
@@ -3520,6 +3523,7 @@
                        NEW_LOCLOAD (cfg, ins, n);
                        ins->cil_code = ip++;
                        *sp++ = ins;
+                       MONO_ADD_INS (bblock, ins);
                        break;
                case CEE_STLOC_0:
                case CEE_STLOC_1:
@@ -3531,6 +3535,7 @@
                        --sp;
                        handle_loaded_temps (cfg, bblock, stack_start, sp);
                        NEW_LOCSTORE (cfg, ins, n, *sp);
+                       MONO_ADD_INS (bblock, ins);
                        ins->cil_code = ip;
                        if (ins->opcode == CEE_STOBJ) {
                                NOT_IMPLEMENTED;
@@ -3612,6 +3617,7 @@
                case CEE_LDNULL:
                        CHECK_STACK_OVF (1);
                        NEW_PCONST (cfg, ins, NULL);
+                       MONO_ADD_INS (bblock, ins);
                        ins->cil_code = ip;
                        ins->type = STACK_OBJ;
                        ++ip;
@@ -3620,6 +3626,7 @@
                case CEE_LDC_I4_M1:
                        CHECK_STACK_OVF (1);
                        NEW_ICONST (cfg, ins, -1);
+                       MONO_ADD_INS (bblock, ins);
                        ins->cil_code = ip;
                        ++ip;
                        *sp++ = ins;
@@ -3635,6 +3642,7 @@
                case CEE_LDC_I4_8:
                        CHECK_STACK_OVF (1);
                        NEW_ICONST (cfg, ins, (*ip) - CEE_LDC_I4_0);
+                       MONO_ADD_INS (bblock, ins);
                        ins->cil_code = ip;
                        ++ip;
                        *sp++ = ins;
@@ -3644,6 +3652,7 @@
                        CHECK_STACK_OVF (1);
                        ++ip;
                        NEW_ICONST (cfg, ins, *((signed char*)ip));
+                       MONO_ADD_INS (bblock, ins);
                        ins->cil_code = ip;
                        ++ip;
                        *sp++ = ins;
@@ -3652,6 +3661,7 @@
                        CHECK_OPSIZE (5);
                        CHECK_STACK_OVF (1);
                        NEW_ICONST (cfg, ins, (gint32)read32 (ip + 1));
+                       MONO_ADD_INS (bblock, ins);
                        ins->cil_code = ip;
                        ip += 5;
                        *sp++ = ins;
@@ -6572,30 +6582,36 @@
                                t = ptype->data.klass->enum_basetype->type;
                        if (ptype->byref) {
                                NEW_PCONST (cfg, ins, NULL);
+                               MONO_ADD_INS (init_localsbb, ins);
                                NEW_LOCSTORE (cfg, store, i, ins);
                                MONO_ADD_INS (init_localsbb, store);
                        } else if (t >= MONO_TYPE_BOOLEAN && t <= MONO_TYPE_U4) 
{
                                NEW_ICONST (cfg, ins, 0);
+                               MONO_ADD_INS (init_localsbb, ins);
                                NEW_LOCSTORE (cfg, store, i, ins);
                                MONO_ADD_INS (init_localsbb, store);
                        } else if (t == MONO_TYPE_I8 || t == MONO_TYPE_U8) {
                                MONO_INST_NEW (cfg, ins, OP_I8CONST);
                                ins->type = STACK_I8;
                                ins->inst_l = 0;
+                               MONO_ADD_INS (init_localsbb, ins);
                                NEW_LOCSTORE (cfg, store, i, ins);
                                MONO_ADD_INS (init_localsbb, store);
                        } else if (t == MONO_TYPE_R4 || t == MONO_TYPE_R8) {
                                MONO_INST_NEW (cfg, ins, OP_R8CONST);
                                ins->type = STACK_R8;
                                ins->inst_p0 = (void*)&r8_0;
+                               MONO_ADD_INS (init_localsbb, ins);
                                NEW_LOCSTORE (cfg, store, i, ins);
                                MONO_ADD_INS (init_localsbb, store);
                        } else if ((t == MONO_TYPE_VALUETYPE) || (t == 
MONO_TYPE_TYPEDBYREF) ||
                                   ((t == MONO_TYPE_GENERICINST) && 
mono_metadata_generic_class_is_valuetype (ptype->data.generic_class))) {
+                               NOT_IMPLEMENTED;
                                NEW_LOCLOADA (cfg, ins, i);
                                handle_initobj (cfg, init_localsbb, ins, NULL, 
mono_class_from_mono_type (ptype), NULL, NULL);
                        } else {
                                NEW_PCONST (cfg, ins, NULL);
+                               MONO_ADD_INS (init_localsbb, ins);
                                NEW_LOCSTORE (cfg, store, i, ins);
                                MONO_ADD_INS (init_localsbb, store);
                        }
@@ -6659,132 +6675,117 @@
        return -1;
 }
 
+/**
+ * mono_spill_global_vars:
+ *
+ *   Generate spill code for variables which are not allocated to registers.
+ */
 void
-mono_print_tree2 (MonoInst *tree) {
-       int arity;
+mono_spill_global_vars (MonoCompile *cfg)
+{
+       int i, num_vireg;
+       MonoInst **vireg_to_inst;
+       MonoBasicBlock *bb;
 
-       if (!tree)
-               return;
+       /* FIXME: Move this to mini.c */
 
-       arity = mono_burg_arity [tree->opcode];
+       /* Collect the vregs which belong to a variable */
+       num_vireg = cfg->next_vireg;
+       vireg_to_inst = g_new0 (MonoInst*, num_vireg);
+       for (i = 0; i < cfg->num_varinfo; i++) {
+               MonoInst *ins = cfg->varinfo [i];
 
-       printf (" %s%s", arity?"(":"",  mono_inst_name (tree->opcode));
+               if (ins->opcode != OP_REGVAR) {
+                       g_assert (ins->dreg != -1);
 
-       switch (tree->opcode) {
-       case OP_ICONST:
-               printf ("[%d]", (int)tree->inst_c0);
-               break;
-       case OP_I8CONST:
-               printf ("[%lld]", (long long)tree->inst_l);
-               break;
-       case OP_R8CONST:
-               printf ("[%f]", *(double*)tree->inst_p0);
-               break;
-       case OP_R4CONST:
-               printf ("[%f]", *(float*)tree->inst_p0);
-               break;
-       case OP_ARG:
-       case OP_LOCAL:
-               printf ("[%d]", (int)tree->inst_c0);
-               break;
-       case OP_REGOFFSET:
-               if (tree->inst_offset < 0)
-                       printf ("[-0x%x(%s)]", (int)(-tree->inst_offset), 
mono_arch_regname (tree->inst_basereg));
-               else
-                       printf ("[0x%x(%s)]", (int)(tree->inst_offset), 
mono_arch_regname (tree->inst_basereg));
-               break;
-       case OP_REGVAR:
-               printf ("[%s]", mono_arch_regname (tree->dreg));
-               break;
-       case CEE_NEWARR:
-               printf ("[%s]",  tree->inst_newa_class->name);
-               mono_print_tree (tree->inst_newa_len);
-               break;
-       case CEE_CALL:
-       case CEE_CALLVIRT:
-       case OP_FCALL:
-       case OP_FCALLVIRT:
-       case OP_LCALL:
-       case OP_LCALLVIRT:
-       case OP_VCALL:
-       case OP_VCALLVIRT:
-       case OP_VOIDCALL:
-       case OP_VOIDCALLVIRT: {
-               MonoCallInst *call = (MonoCallInst*)tree;
-               if (call->method)
-                       printf ("[%s]", call->method->name);
-               else if (call->fptr) {
-                       MonoJitICallInfo *info = mono_find_jit_icall_by_addr 
(call->fptr);
-                       if (info)
-                               printf ("[%s]", info->name);
+                       switch (ins->type) {
+                       case STACK_I4:
+                       case STACK_I8:
+                       case STACK_PTR:
+                       case STACK_MP:
+                       case STACK_OBJ:
+                               vireg_to_inst [ins->dreg] = ins;
+                               break;
+                       default:
+                               NOT_IMPLEMENTED;
+                       }
                }
-               break;
        }
-       case OP_PHI: {
-               int i;
-               printf ("[%d (", (int)tree->inst_c0);
-               for (i = 0; i < tree->inst_phi_args [0]; i++) {
-                       if (i)
-                               printf (", ");
-                       printf ("%d", tree->inst_phi_args [i + 1]);
-               }
-               printf (")]");
-               break;
-       }
-       case OP_RENAME:
-       case OP_RETARG:
-       case CEE_NOP:
-       case CEE_JMP:
-       case CEE_BREAK:
-               break;
-       case OP_LOAD_MEMBASE:
-       case OP_LOADI4_MEMBASE:
-       case OP_LOADU4_MEMBASE:
-       case OP_LOADU1_MEMBASE:
-       case OP_LOADI1_MEMBASE:
-       case OP_LOADU2_MEMBASE:
-       case OP_LOADI2_MEMBASE:
-               printf ("[%s] <- [%s + 0x%x]", mono_arch_regname (tree->dreg), 
mono_arch_regname (tree->inst_basereg), (int)tree->inst_offset);
-               break;
-       case CEE_BR:
-       case OP_CALL_HANDLER:
-               printf ("[B%d]", tree->inst_target_bb->block_num);
-               break;
-       case CEE_SWITCH:
-       case CEE_ISINST:
-       case CEE_CASTCLASS:
-       case OP_OUTARG:
-       case OP_CALL_REG:
-       case OP_FCALL_REG:
-       case OP_LCALL_REG:
-       case OP_VCALL_REG:
-       case OP_VOIDCALL_REG:
-               mono_print_tree (tree->inst_left);
-               break;
-       case CEE_BNE_UN:
-       case CEE_BEQ:
-       case CEE_BLT:
-       case CEE_BLT_UN:
-       case CEE_BGT:
-       case CEE_BGT_UN:
-       case CEE_BGE:
-       case CEE_BGE_UN:
-       case CEE_BLE:
-       case CEE_BLE_UN:
-               printf ("[B%dB%d]", tree->inst_true_bb->block_num, 
tree->inst_false_bb->block_num);
-               mono_print_tree (tree->inst_left);
-               break;
-       default:
-               if (!mono_arch_print_tree(tree, arity)) {
-                       if (arity) {
-                               mono_print_tree (tree->inst_left);
-                               if (arity > 1)
-                                       mono_print_tree (tree->inst_right);
+
+       /* FIXME: Use instructions metadata to determine src and dest reg types 
*/
+       /* FIXME: widening and truncation */
+
+       /* Add spill loads/stores */
+       for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
+               MonoInst *tree = bb->code;      
+               MonoInst *prev = NULL;
+
+               cfg->cbb = bb;
+               for (; tree; tree = tree->next) {
+                       /* DREG */
+                       if ((tree->dreg != -1) && (tree->dreg < num_vireg) && 
(vireg_to_inst [tree->dreg])) {
+                               MonoInst *ins = vireg_to_inst [tree->dreg];
+                               MonoInst *store_ins;
+
+                               g_assert (ins->opcode == OP_REGOFFSET);
+
+                               tree->dreg = alloc_dreg (cfg, STACK_PTR);
+
+                               /* Create a store instruction */                
                        
+                               NEW_STORE_MEMBASE (cfg, store_ins, 
mono_type_to_store_membase (ins->inst_vtype), ins->inst_basereg, 
ins->inst_offset, tree->dreg);
+                               
+                               /* Insert it after the instruction */
+                               store_ins->next = tree->next;
+                               tree->next = store_ins;
+                               if (bb->last_ins == tree)
+                                       bb->last_ins = store_ins;
                        }
+
+                       /* SREG1 */
+                       if ((tree->sreg1 != -1) && (tree->sreg1 < num_vireg) && 
(vireg_to_inst [tree->sreg1])) {
+                               MonoInst *ins = vireg_to_inst [tree->sreg1];
+                               MonoInst *load_ins;
+
+                               g_assert (ins->opcode == OP_REGOFFSET);
+
+                               tree->sreg1 = alloc_dreg (cfg, STACK_PTR);
+
+                               /* Create a load instruction */                 
                
+                               NEW_LOAD_MEMBASE (cfg, load_ins, 
mono_type_to_load_membase (ins->inst_vtype), tree->sreg1, ins->inst_basereg, 
ins->inst_offset);
+                               
+                               /* Insert it before the instruction */
+                               if (prev)
+                                       prev->next = load_ins;
+                               else
+                                       bb->code = load_ins;
+
+                               load_ins->next = tree;
+                       }
+
+                       /* SREG2 */
+                       if ((tree->sreg2 != -1) && (tree->sreg2 < num_vireg) && 
(vireg_to_inst [tree->sreg2])) {
+                               MonoInst *ins = vireg_to_inst [tree->sreg2];
+                               MonoInst *load_ins;
+
+                               g_assert (ins->opcode == OP_REGOFFSET);
+
+                               tree->sreg2 = alloc_dreg (cfg, STACK_PTR);
+
+                               /* Create a load instruction */                 
                
+                               NEW_LOAD_MEMBASE (cfg, load_ins, 
mono_type_to_load_membase (ins->inst_vtype), tree->sreg2, ins->inst_basereg, 
ins->inst_offset);
+                               
+                               /* Insert it before the instruction */
+                               if (prev)
+                                       prev->next = load_ins;
+                               else
+                                       bb->code = load_ins;
+
+                               load_ins->next = tree;
+                       }
+
+                       prev = tree;
                }
-               break;
        }
 
-       if (arity)
-               printf (")");
+       /* FIXME: Use NEW/EMIT macros correctly */
 }

Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini-codegen.c
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini-codegen.c        
2005-11-25 19:20:55 UTC (rev 53484)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini-codegen.c        
2005-11-25 21:27:38 UTC (rev 53485)
@@ -217,11 +217,14 @@
        regmask_t preferred_mask; /* the hreg where the register should be 
allocated, or 0 */
 } RegTrack;
 
-static void
-print_ins (int i, MonoInst *ins)
+void
+mono_print_ins_index (int i, MonoInst *ins)
 {
        const char *spec = ins_spec [ins->opcode];
-       g_print ("\t%-2d %s", i, mono_inst_name (ins->opcode));
+       if (i != -1)
+               g_print ("\t%-2d %s", i, mono_inst_name (ins->opcode));
+       else
+               g_print (" %s", mono_inst_name (ins->opcode));
        if (!spec)
                g_error ("Unknown opcode: %s\n", mono_inst_name (ins->opcode));
 
@@ -262,9 +265,82 @@
        }
        if (spec [MONO_INST_CLOB])
                g_print (" clobbers: %c", spec [MONO_INST_CLOB]);
+
+       switch (ins->opcode) {
+       case OP_ICONST:
+       case OP_ICOMPARE_IMM:
+               g_print (" [%d]", (int)ins->inst_c0);
+               break;
+       case OP_I8CONST:
+               g_print (" [%lld]", (long long)ins->inst_l);
+               break;
+       case OP_R8CONST:
+               g_print (" [%f]", *(double*)ins->inst_p0);
+               break;
+       case OP_R4CONST:
+               g_print (" [%f]", *(float*)ins->inst_p0);
+               break;
+       case CEE_CALL:
+       case CEE_CALLVIRT:
+       case OP_FCALL:
+       case OP_FCALLVIRT:
+       case OP_LCALL:
+       case OP_LCALLVIRT:
+       case OP_VCALL:
+       case OP_VCALLVIRT:
+       case OP_VOIDCALL:
+       case OP_VOIDCALLVIRT: {
+               MonoCallInst *call = (MonoCallInst*)ins;
+               if (call->method)
+                       g_print (" [%s]", call->method->name);
+               else if (call->fptr) {
+                       MonoJitICallInfo *info = mono_find_jit_icall_by_addr 
(call->fptr);
+                       if (info)
+                               g_print (" [%s]", info->name);
+               }
+               break;
+       }
+       case OP_PHI: {
+               int i;
+               g_print (" [%d (", (int)ins->inst_c0);
+               for (i = 0; i < ins->inst_phi_args [0]; i++) {
+                       if (i)
+                               g_print (", ");
+                       g_print ("%d", ins->inst_phi_args [i + 1]);
+               }
+               g_print (")]");
+               break;
+       }
+       case CEE_BR:
+       case OP_CALL_HANDLER:
+               g_print (" [B%d]", ins->inst_target_bb->block_num);
+               break;
+       case CEE_BNE_UN:
+       case CEE_BEQ:
+       case CEE_BLT:
+       case CEE_BLT_UN:
+       case CEE_BGT:
+       case CEE_BGT_UN:
+       case CEE_BGE:
+       case CEE_BGE_UN:
+       case CEE_BLE:
+       case CEE_BLE_UN:
+               if (!(ins->flags & MONO_INST_BRLABEL))
+                       g_print (" [B%dB%d]", ins->inst_true_bb->block_num, 
ins->inst_false_bb->block_num);
+               break;
+       default:
+               break;
+       }
+
        g_print ("\n");
 }
 
+void
+mono_print_ins (MonoInst *ins)
+{
+       mono_print_ins_index (-1, ins);
+}
+
 static void
 print_regtrack (RegTrack *t, int num)
 {
@@ -671,7 +747,7 @@
                        g_error ("Opcode '%s' missing from machine description 
file.", mono_inst_name (ins->opcode));
                }
                
-               DEBUG (print_ins (i, ins));
+               DEBUG (mono_print_ins_index (i, ins));
 
                /*
                 * TRACK FP STACK
@@ -853,7 +929,7 @@
                sreg2_mask = sreg2_is_fp (ins) ? MONO_ARCH_CALLEE_FREGS : 
MONO_ARCH_CALLEE_REGS;
 
                DEBUG (g_print ("processing:"));
-               DEBUG (print_ins (i, ins));
+               DEBUG (mono_print_ins_index (i, ins));
 
                ip = ins->cil_code;
 
@@ -1487,7 +1563,7 @@
                        mono_regstate_free_int (rs, ins->sreg2);
                }*/
        
-               DEBUG (print_ins (i, ins));
+               DEBUG (mono_print_ins_index (i, ins));
                /* this may result from a insert_before call */
                if (!tmp->next)
                        bb->code = tmp->data;

Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.c
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.c    2005-11-25 
19:20:55 UTC (rev 53484)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.c    2005-11-25 
21:27:38 UTC (rev 53485)
@@ -1245,6 +1245,7 @@
                        }
                        break;
                case OP_COMPARE_IMM:
+               case OP_ICOMPARE_IMM:
                        /* OP_COMPARE_IMM (reg, 0) 
                         * --> 
                         * OP_X86_TEST_NULL (reg) 
@@ -1793,6 +1794,7 @@
                        x86_alu_reg_reg (code, X86_CMP, ins->sreg1, ins->sreg2);
                        break;
                case OP_COMPARE_IMM:
+               case OP_ICOMPARE_IMM:
                        x86_alu_reg_imm (code, X86_CMP, ins->sreg1, 
ins->inst_imm);
                        break;
                case OP_X86_COMPARE_MEMBASE_REG:

Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini.c
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini.c        2005-11-25 
19:20:55 UTC (rev 53484)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini.c        2005-11-25 
21:27:38 UTC (rev 53485)
@@ -90,6 +90,8 @@
                   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);
+
 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);
@@ -1101,6 +1103,119 @@
        return -1;
 }
 
+guint
+mono_type_to_store_membase (MonoType *type)
+{
+       if (type->byref)
+               return OP_STORE_MEMBASE_REG;
+
+handle_enum:
+       switch (type->type) {
+       case MONO_TYPE_I1:
+       case MONO_TYPE_U1:
+       case MONO_TYPE_BOOLEAN:
+               return OP_STOREI1_MEMBASE_REG;
+       case MONO_TYPE_I2:
+       case MONO_TYPE_U2:
+       case MONO_TYPE_CHAR:
+               return OP_STOREI2_MEMBASE_REG;
+       case MONO_TYPE_I4:
+       case MONO_TYPE_U4:
+               return OP_STOREI4_MEMBASE_REG;
+       case MONO_TYPE_I:
+       case MONO_TYPE_U:
+       case MONO_TYPE_PTR:
+       case MONO_TYPE_FNPTR:
+               return OP_STORE_MEMBASE_REG;
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_STRING:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_SZARRAY:
+       case MONO_TYPE_ARRAY:    
+               return OP_STORE_MEMBASE_REG;
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8:
+               return OP_STOREI8_MEMBASE_REG;
+       case MONO_TYPE_R4:
+               return OP_STORER4_MEMBASE_REG;
+       case MONO_TYPE_R8:
+               return OP_STORER8_MEMBASE_REG;
+       case MONO_TYPE_VALUETYPE:
+               if (type->data.klass->enumtype) {
+                       type = type->data.klass->enum_basetype;
+                       goto handle_enum;
+               }
+               return CEE_STOBJ;
+       case MONO_TYPE_TYPEDBYREF:
+               return CEE_STOBJ;
+       case MONO_TYPE_GENERICINST:
+               type = &type->data.generic_class->container_class->byval_arg;
+               goto handle_enum;
+       default:
+               g_error ("unknown type 0x%02x in type_to_store_membase", 
type->type);
+       }
+       return -1;
+}
+
+guint
+mono_type_to_load_membase (MonoType *type)
+{
+       if (type->byref)
+               return OP_LOAD_MEMBASE;
+
+handle_enum:
+       switch (type->type) {
+       case MONO_TYPE_I1:
+               return OP_LOADI1_MEMBASE;
+       case MONO_TYPE_U1:
+       case MONO_TYPE_BOOLEAN:
+               return OP_LOADU1_MEMBASE;
+       case MONO_TYPE_I2:
+               return OP_LOADI2_MEMBASE;
+       case MONO_TYPE_U2:
+       case MONO_TYPE_CHAR:
+               return OP_LOADU2_MEMBASE;
+       case MONO_TYPE_I4:
+               return OP_LOADI4_MEMBASE;
+       case MONO_TYPE_U4:
+               return OP_LOADU4_MEMBASE;
+       case MONO_TYPE_I:
+       case MONO_TYPE_U:
+       case MONO_TYPE_PTR:
+       case MONO_TYPE_FNPTR:
+               return OP_LOAD_MEMBASE;
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_STRING:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_SZARRAY:
+       case MONO_TYPE_ARRAY:    
+               return OP_LOAD_MEMBASE;
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8:
+               return OP_LOADI8_MEMBASE;
+       case MONO_TYPE_R4:
+               return OP_LOADR4_MEMBASE;
+       case MONO_TYPE_R8:
+               return OP_LOADR8_MEMBASE;
+       case MONO_TYPE_VALUETYPE:
+               if (type->data.klass->enumtype) {
+                       type = type->data.klass->enum_basetype;
+                       goto handle_enum;
+               }
+               g_assert_not_reached ();
+               return CEE_LDOBJ;
+       case MONO_TYPE_TYPEDBYREF:
+               g_assert_not_reached ();
+               return CEE_STOBJ;
+       case MONO_TYPE_GENERICINST:
+               type = &type->data.generic_class->container_class->byval_arg;
+               goto handle_enum;
+       default:
+               g_error ("unknown type 0x%02x in type_to_load_membase", 
type->type);
+       }
+       return -1;
+}
+
 /*
  * Returns the type used in the eval stack when @type is loaded.
  * FIXME: return a MonoType/MonoClass for the byref and VALUETYPE cases.
@@ -1587,6 +1702,7 @@
        inst->inst_c0 = num;
        inst->inst_vtype = type;
        inst->klass = mono_class_from_mono_type (type);
+       type_to_eval_stack_type (type, inst);
        /* if set to 1 the variable is native */
        inst->unused = 0;
 
@@ -1610,7 +1726,7 @@
                case MONO_TYPE_SZARRAY:
                case MONO_TYPE_ARRAY:    
                        /* FIXME: call alloc_dreg */
-                       inst->dreg = cfg->next_ivreg ++;
+                       inst->dreg = cfg->next_vireg ++;
                        break;
                default:
                        NOT_IMPLEMENTED;
@@ -9233,8 +9349,8 @@
 
        if (cfg->new_ir) {
                cfg->rs = mono_regstate_new ();
-               cfg->next_ivreg = cfg->rs->next_vireg;
-               cfg->next_fvreg = cfg->rs->next_vfreg;
+               cfg->next_vireg = cfg->rs->next_vireg;
+               cfg->next_vfreg = cfg->rs->next_vfreg;
        }
 
        /*
@@ -9445,6 +9561,19 @@
        if (cfg->new_ir) {
                MonoBasicBlock *bb;
 
+               mono_spill_global_vars (cfg);
+
+               if (cfg->verbose_level >= 4) {
+                       for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
+                               MonoInst *tree = bb->code;      
+                               g_print ("DUMP BLOCK %d:\n", bb->block_num);
+                               if (!tree)
+                                       continue;
+                               for (; tree; tree = tree->next) {
+                                       mono_print_ins_index (-1, tree);
+                               }
+                       }
+               }
                /* FIXME: branch inverting */   
 
                /* FIXME: */

Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini.h
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini.h        2005-11-25 
19:20:55 UTC (rev 53484)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini.h        2005-11-25 
21:27:38 UTC (rev 53485)
@@ -280,7 +280,7 @@
        gboolean virtual;
        regmask_t used_iregs;
        regmask_t used_fregs;
-#if defined(MONO_ARCH_HAS_XP_LOCAL_REGALLOC) || defined(__x86_64__)
+#if defined(MONO_ARCH_HAS_XP_LOCAL_REGALLOC)
        GSList *out_ireg_args;
        GSList *out_freg_args;
 #endif
@@ -562,7 +562,7 @@
        MonoDomain      *domain;
 
        /* The current virtual register numbers */
-       guint32 next_ivreg, next_lvreg, next_fvreg;
+       guint32 next_vireg, next_vlreg, next_vfreg;
 
        unsigned char   *native_code;
        guint            code_size;
@@ -794,6 +794,8 @@
 void      mono_blockset_print               (MonoCompile *cfg, MonoBitSet 
*set, const char *name, guint idom);
 void      mono_print_tree                   (MonoInst *tree);
 void      mono_print_tree_nl                (MonoInst *tree);
+void      mono_print_ins_index              (int i, MonoInst *ins);
+void      mono_print_ins                    (MonoInst *ins);
 void      mono_print_code                   (MonoCompile *cfg);
 void      mono_print_method_from_ip         (void *ip);
 char     *mono_pmip                         (void *ip);
@@ -803,6 +805,8 @@
 void      mono_disassemble_code             (MonoCompile *cfg, guint8 *code, 
int size, char *id);
 guint     mono_type_to_ldind                (MonoType *t);
 guint     mono_type_to_stind                (MonoType *t);
+guint     mono_type_to_load_membase         (MonoType *type);
+guint     mono_type_to_store_membase        (MonoType *type);
 void      mono_add_patch_info               (MonoCompile *cfg, int ip, 
MonoJumpInfoType type, gconstpointer target);
 void      mono_remove_patch_info            (MonoCompile *cfg, int ip);
 gpointer  mono_resolve_patch_target         (MonoMethod *method, MonoDomain 
*domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors);

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

Reply via email to