2007-08-30 Jonathan Chambers <joncham@gmail.com>
[mono.git] / mono / mini / mini-ia64.c
index d6a92d4c744d651c20fb6201486e717226bd41d6..e59aac9bcb7a652e989dec623b56e1c6c8b9ec5b 100644 (file)
@@ -598,7 +598,7 @@ mono_arch_get_allocatable_int_vars (MonoCompile *cfg)
        cinfo = get_call_info (sig, FALSE);
 
        for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
-               MonoInst *ins = cfg->varinfo [i];
+               MonoInst *ins = cfg->args [i];
 
                ArgInfo *ainfo = &cinfo->args [i];
 
@@ -848,7 +848,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        }
 
        for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
-               inst = cfg->varinfo [i];
+               inst = cfg->args [i];
                if (inst->opcode != OP_REGVAR) {
                        ArgInfo *ainfo = &cinfo->args [i];
                        gboolean inreg = TRUE;
@@ -1490,6 +1490,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
                case OP_IXOR_IMM:
                case OP_AND_IMM:
                case OP_SHL_IMM:
+               case OP_SHR_IMM:
                case OP_ISHL_IMM:
                case OP_LSHL_IMM:
                case OP_ISHR_IMM:
@@ -1527,6 +1528,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
                                switched = TRUE;
                                break;
                        case OP_SHL_IMM:
+                       case OP_SHR_IMM:
                        case OP_ISHL_IMM:
                        case OP_LSHL_IMM:
                        case OP_ISHR_IMM:
@@ -1579,6 +1581,9 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
                        case OP_SHL_IMM:
                                ins->opcode = OP_LSHL;
                                break;
+                       case OP_SHR_IMM:
+                               ins->opcode = OP_LSHR;
+                               break;
                        case OP_LSHL_IMM:
                                ins->opcode = OP_LSHL;
                                break;
@@ -1606,30 +1611,20 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
                case OP_ICOMPARE_IMM: {
                        /* Instead of compare+b<cond>, ia64 has compare<cond>+br */
                        gboolean imm;
+                       CompRelation cond;
 
                        /* 
                         * The compare_imm instructions have switched up arguments, and 
                         * some of them take an imm between -127 and 128.
                         */
                        next = ins->next;
-                       switch (next->opcode) {
-                       case CEE_BGE:
-                       case CEE_BLT:
-                       case OP_COND_EXC_LT:
-                       case OP_IBGE:
-                       case OP_IBLT:
+                       cond = mono_opcode_to_cond (next->opcode);
+                       if ((cond == CMP_LT) || (cond == CMP_GE))
                                imm = ia64_is_imm8 (ins->inst_imm - 1);
-                               break;
-                       case OP_IBGE_UN:
-                       case OP_IBLT_UN:
-                       case CEE_BGE_UN:
-                       case CEE_BLT_UN:
+                       else if ((cond == CMP_LT_UN) || (cond == CMP_GE_UN))
                                imm = ia64_is_imm8 (ins->inst_imm - 1) && (ins->inst_imm > 0);
-                               break;
-                       default:
+                       else
                                imm = ia64_is_imm8 (ins->inst_imm);
-                               break;
-                       }
 
                        if (imm) {
                                ins->opcode = opcode_to_ia64_cmp_imm (next->opcode, ins->opcode);
@@ -1922,7 +1917,7 @@ emit_load_volatile_arguments (MonoCompile *cfg, Ia64CodegenState code)
                ArgInfo *ainfo = cinfo->args + i;
                gint32 stack_offset;
                MonoType *arg_type;
-               ins = cfg->varinfo [i];
+               ins = cfg->args [i];
 
                if (sig->hasthis && (i == 0))
                        arg_type = &mono_defaults.object_class->byval_arg;
@@ -2329,10 +2324,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                case OP_LSHL_IMM:
                        ia64_shl_imm (code, ins->dreg, ins->sreg1, ins->inst_imm);
                        break;
-               case OP_LSHR_IMM:
-                       ia64_shr_imm (code, ins->dreg, ins->sreg1, ins->inst_imm);
-                       break;
+               case OP_SHR_IMM:
                case OP_ISHR_IMM:
+               case OP_LSHR_IMM:
                        ia64_shr_imm (code, ins->dreg, ins->sreg1, ins->inst_imm);
                        break;
                case OP_ISHR_UN_IMM:
@@ -2633,8 +2627,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        break;
                case CEE_CONV_I8:
                case CEE_CONV_I:
-                       /* FIXME: Sign extend ? */
-                       ia64_mov (code, ins->dreg, ins->sreg1);
+                       ia64_sxt4 (code, ins->dreg, ins->sreg1);
                        break;
                case CEE_CONV_U8:
                case CEE_CONV_U:
@@ -3875,7 +3868,7 @@ mono_arch_emit_prolog (MonoCompile *cfg)
                ArgInfo *ainfo = cinfo->args + i;
                gint32 stack_offset;
                MonoType *arg_type;
-               inst = cfg->varinfo [i];
+               inst = cfg->args [i];
 
                if (sig->hasthis && (i == 0))
                        arg_type = &mono_defaults.object_class->byval_arg;
@@ -4266,7 +4259,7 @@ mono_arch_instrument_prolog (MonoCompile *cfg, void *func, void *p, gboolean ena
 
                        /* Save arguments to the stack */
                        for (i = 0; i < n; ++i) {
-                               ins = cfg->varinfo [i];
+                               ins = cfg->args [i];
 
                                if (ins->opcode == OP_REGVAR) {
                                        ia64_movl (code, GP_SCRATCH_REG, (i * 8));