2007-08-30 Jonathan Chambers <joncham@gmail.com>
[mono.git] / mono / mini / mini-ia64.c
index 4c5e0d8caf26d3be94ca07ad295445d6d9b53b40..e59aac9bcb7a652e989dec623b56e1c6c8b9ec5b 100644 (file)
@@ -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);
@@ -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: