2007-02-03 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / mini-sparc.c
index cfd23a8e0fbf9a3ca29be4dae80b650d64aa06d0..cd4547e1c3341702940d22de18b42f72418f3fa0 100644 (file)
@@ -690,41 +690,6 @@ get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke)
        return cinfo;
 }
 
-static gboolean
-is_regsize_var (MonoType *t) {
-       if (t->byref)
-               return TRUE;
-       switch (mono_type_get_underlying_type (t)->type) {
-       case MONO_TYPE_BOOLEAN:
-       case MONO_TYPE_CHAR:
-       case MONO_TYPE_I1:
-       case MONO_TYPE_U1:
-       case MONO_TYPE_I2:
-       case MONO_TYPE_U2:
-       case MONO_TYPE_I4:
-       case MONO_TYPE_U4:
-       case MONO_TYPE_I:
-       case MONO_TYPE_U:
-       case MONO_TYPE_PTR:
-       case MONO_TYPE_FNPTR:
-               return TRUE;
-       case MONO_TYPE_OBJECT:
-       case MONO_TYPE_STRING:
-       case MONO_TYPE_CLASS:
-       case MONO_TYPE_SZARRAY:
-       case MONO_TYPE_ARRAY:
-               return TRUE;
-       case MONO_TYPE_VALUETYPE:
-               return FALSE;
-#ifdef SPARCV9
-       case MONO_TYPE_I8:
-       case MONO_TYPE_U8:
-               return TRUE;
-#endif
-       }
-       return FALSE;
-}
-
 GList *
 mono_arch_get_allocatable_int_vars (MonoCompile *cfg)
 {
@@ -748,7 +713,7 @@ mono_arch_get_allocatable_int_vars (MonoCompile *cfg)
                if (ins->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT) || (ins->opcode == OP_REGVAR) || (ins->opcode == OP_ARG))
                        continue;
 
-               if (is_regsize_var (ins->inst_vtype)) {
+               if (mono_is_regsize_var (ins->inst_vtype)) {
                        g_assert (MONO_VARINFO (cfg, i)->reg == -1);
                        g_assert (i == vmv->idx);
 
@@ -1596,7 +1561,6 @@ peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
                        }
                        break;
 #endif
-               case OP_LOADU1_MEMBASE:
                case OP_LOADI1_MEMBASE:
                        if (last_ins && (last_ins->opcode == OP_STOREI1_MEMBASE_REG) &&
                                        ins->inst_basereg == last_ins->inst_destbasereg &&
@@ -1612,7 +1576,6 @@ peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
                                }
                        }
                        break;
-               case OP_LOADU2_MEMBASE:
                case OP_LOADI2_MEMBASE:
                        if (last_ins && (last_ins->opcode == OP_STOREI2_MEMBASE_REG) &&
                                        ins->inst_basereg == last_ins->inst_destbasereg &&
@@ -1752,17 +1715,6 @@ peephole_pass (MonoCompile *cfg, MonoBasicBlock *bb)
        bb->last_ins = last_ins;
 }
 
-static const char*const * ins_spec = sparc_desc;
-
-static inline const char*
-get_ins_spec (int opcode)
-{
-       if (ins_spec [opcode])
-               return ins_spec [opcode];
-       else
-               return ins_spec [CEE_ADD];
-}
-
 static int
 mono_spillvar_offset_float (MonoCompile *cfg, int spillvar)
 {
@@ -2309,9 +2261,10 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 
                offset = (guint8*)code - cfg->native_code;
 
-               spec = ins_spec [ins->opcode];
-               if (!spec)
-                       spec = ins_spec [CEE_ADD];
+               spec = ins_get_spec (ins->opcode);
+               /* I kept this, but this looks a workaround for a bug */
+               if (spec == MONO_ARCH_CPU_SPEC)
+                       spec = ins_get_spec (CEE_ADD);
 
                max_len = ((guint8 *)spec)[MONO_INST_LEN];
 
@@ -2764,7 +2717,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        EMIT_COND_SYSTEM_EXCEPTION_GENERAL (ins, sparc_bne, "OverflowException", TRUE, sparc_icc_short);
                        break;
                case OP_ICONST:
-               case OP_SETREGIMM:
                        sparc_set (code, ins->inst_c0, ins->dreg);
                        break;
                case OP_I8CONST:
@@ -2777,7 +2729,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                case CEE_CONV_I4:
                case CEE_CONV_U4:
                case OP_MOVE:
-               case OP_SETREG:
                        if (ins->sreg1 != ins->dreg)
                                sparc_mov_reg_reg (code, ins->sreg1, ins->dreg);
                        break;
@@ -2893,8 +2844,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 #endif
 
                        /* Keep alignment */
-                       sparc_add_imm (code, FALSE, ins->sreg1, MONO_ARCH_FRAME_ALIGNMENT - 1, ins->dreg);
-                       sparc_set (code, ~(MONO_ARCH_FRAME_ALIGNMENT - 1), sparc_o7);
+                       sparc_add_imm (code, FALSE, ins->sreg1, MONO_ARCH_LOCALLOC_ALIGNMENT - 1, ins->dreg);
+                       sparc_set (code, ~(MONO_ARCH_LOCALLOC_ALIGNMENT - 1), sparc_o7);
                        sparc_and (code, FALSE, ins->dreg, sparc_o7, ins->dreg);
 
                        if ((ins->flags & MONO_INST_INIT) && (ins->sreg1 == ins->dreg)) {
@@ -2947,7 +2898,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        NOT_IMPLEMENTED;
 #endif
 
-                       offset = ALIGN_TO (offset, MONO_ARCH_FRAME_ALIGNMENT);
+                       offset = ALIGN_TO (offset, MONO_ARCH_LOCALLOC_ALIGNMENT);
                        if (sparc_is_imm13 (offset))
                                sparc_sub_imm (code, FALSE, sparc_sp, offset, sparc_sp);
                        else {
@@ -4281,7 +4232,7 @@ mono_arch_emit_this_vret_args (MonoCompile *cfg, MonoCallInst *call, int this_re
        if (vt_reg != -1) {
 #ifdef SPARCV9
                MonoInst *ins;
-               MONO_INST_NEW (cfg, ins, OP_SETREG);
+               MONO_INST_NEW (cfg, ins, OP_MOVE);
                ins->sreg1 = vt_reg;
                ins->dreg = mono_regstate_next_int (cfg->rs);
                mono_bblock_add_inst (cfg->cbb, ins);
@@ -4298,7 +4249,7 @@ mono_arch_emit_this_vret_args (MonoCompile *cfg, MonoCallInst *call, int this_re
        /* add the this argument */
        if (this_reg != -1) {
                MonoInst *this;
-               MONO_INST_NEW (cfg, this, OP_SETREG);
+               MONO_INST_NEW (cfg, this, OP_MOVE);
                this->type = this_type;
                this->sreg1 = this_reg;
                this->dreg = mono_regstate_next_int (cfg->rs);