Remove warnings
[mono.git] / mono / mini / mini-s390.c
index 1275c0b5b9993648d19de415f8668757ef088bee..3168f5183a607f4dcc089b9b5e8194c1d98bbdd4 100644 (file)
 
 #define EMIT_COND_BRANCH(ins,cond)                                                     \
 {                                                                                      \
-if (ins->flags & MONO_INST_BRLABEL) {                                                  \
-        if (ins->inst_i0->inst_c0) {                                                   \
-               int displace;                                                           \
-               displace = ((cfg->native_code + ins->inst_i0->inst_c0) - code) / 2;     \
-               if (s390_is_imm16(displace)) {                                          \
-                       s390_brc (code, cond, displace);                                \
-               } else {                                                                \
-                       s390_jcl (code, cond, displace);                                \
-               }                                                                       \
-        } else {                                                                       \
-               mono_add_patch_info (cfg, code - cfg->native_code,                      \
-                                    MONO_PATCH_INFO_LABEL, ins->inst_i0);              \
-               s390_jcl (code, cond, 0);                                               \
-        }                                                                              \
-} else {                                                                               \
-        if (ins->inst_true_bb->native_offset) {                                        \
-               int displace;                                                           \
-               displace = ((cfg->native_code +                                         \
-                           ins->inst_true_bb->native_offset) - code) / 2;              \
-               if (s390_is_imm16(displace)) {                                          \
-                       s390_brc (code, cond, displace);                                \
-               } else {                                                                \
-                       s390_jcl (code, cond, displace);                                \
-               }                                                                       \
-        } else {                                                                       \
-               mono_add_patch_info (cfg, code - cfg->native_code,                      \
-                                    MONO_PATCH_INFO_BB, ins->inst_true_bb);            \
-               s390_jcl (code, cond, 0);                                               \
-        }                                                                              \
-}                                                                                      \
+if (ins->inst_true_bb->native_offset) {                                        \
+       int displace;                                                           \
+       displace = ((cfg->native_code +                                         \
+                   ins->inst_true_bb->native_offset) - code) / 2;              \
+       if (s390_is_imm16(displace)) {                                          \
+               s390_brc (code, cond, displace);                                \
+       } else {                                                                \
+               s390_jcl (code, cond, displace);                                \
+       }                                                                       \
+} else {                                                                       \
+       mono_add_patch_info (cfg, code - cfg->native_code,                      \
+                            MONO_PATCH_INFO_BB, ins->inst_true_bb);            \
+       s390_jcl (code, cond, 0);                                               \
+}                                                                              \
 }
 
 #define EMIT_UNCOND_BRANCH(ins)                                                        \
 {                                                                                      \
-if (ins->flags & MONO_INST_BRLABEL) {                                                  \
-        if (ins->inst_i0->inst_c0) {                                                   \
-               int displace;                                                           \
-               displace = ((cfg->native_code + ins->inst_i0->inst_c0) - code) / 2;     \
-               if (s390_is_imm16(displace)) {                                          \
-                       s390_brc (code, S390_CC_UN, displace);                          \
-               } else {                                                                \
-                       s390_jcl (code, S390_CC_UN, displace);                          \
-               }                                                                       \
-        } else {                                                                       \
-               mono_add_patch_info (cfg, code - cfg->native_code,                      \
-                                    MONO_PATCH_INFO_LABEL, ins->inst_i0);              \
-               s390_jcl (code, S390_CC_UN, 0);                                         \
-        }                                                                              \
-} else {                                                                               \
-        if (ins->inst_target_bb->native_offset) {                                      \
-               int displace;                                                           \
-               displace = ((cfg->native_code +                                         \
-                           ins->inst_target_bb->native_offset) - code) / 2;            \
-               if (s390_is_imm16(displace)) {                                          \
-                       s390_brc (code, S390_CC_UN, displace);                          \
-               } else {                                                                \
-                       s390_jcl (code, S390_CC_UN, displace);                          \
-               }                                                                       \
-        } else {                                                                       \
-               mono_add_patch_info (cfg, code - cfg->native_code,                      \
-                                    MONO_PATCH_INFO_BB, ins->inst_target_bb);          \
-               s390_jcl (code, S390_CC_UN, 0);                                         \
-        }                                                                              \
-}                                                                                      \
+if (ins->inst_target_bb->native_offset) {                                      \
+       int displace;                                                           \
+       displace = ((cfg->native_code +                                         \
+                   ins->inst_target_bb->native_offset) - code) / 2;            \
+       if (s390_is_imm16(displace)) {                                          \
+               s390_brc (code, S390_CC_UN, displace);                          \
+       } else {                                                                \
+               s390_jcl (code, S390_CC_UN, displace);                          \
+       }                                                                       \
+} else {                                                                       \
+       mono_add_patch_info (cfg, code - cfg->native_code,                      \
+                            MONO_PATCH_INFO_BB, ins->inst_target_bb);          \
+       s390_jcl (code, S390_CC_UN, 0);                                         \
+}                                                                              \
 }
 
 #define EMIT_COND_SYSTEM_EXCEPTION(cond,exc_name)                      \
@@ -135,25 +103,22 @@ if (ins->flags & MONO_INST_BRLABEL) {                                                     \
                s390_ldr (code, ins->dreg, ins->sreg1);                 \
        }
 
-#define MONO_EMIT_NEW_MOVE2(cfg,dest,offset,src,imm,size) do {                         \
+#define MONO_EMIT_NEW_MOVE(cfg,dest,offset,src,imm,size) do {                  \
                 MonoInst *inst;                                                \
                int tmpr = 0;                                                   \
                int sReg, dReg;                                                 \
-               MONO_INST_NEW (cfg, inst, OP_NOP);                                                              \
+               MONO_INST_NEW (cfg, inst, OP_NOP);                              \
                if (size > 256) {                                               \
-                       tmpr = mono_alloc_preg (cfg); \
-                       MONO_EMIT_NEW_ICONST(cfg,tmpr,size);                    \
                        inst->dreg        = dest;                               \
                        inst->inst_offset = offset;                             \
                        inst->sreg1       = src;                                \
                        inst->inst_imm    = imm;                                \
-                       inst->sreg2       = tmpr;                               \
                } else {                                                        \
                        if (s390_is_uimm12(offset)) {                           \
                                inst->dreg        = dest;                       \
                                inst->inst_offset = offset;                     \
                        } else {                                                \
-                               dReg = mono_alloc_preg (cfg); \
+                               dReg = mono_alloc_preg (cfg);                   \
                                MONO_EMIT_NEW_BIALU_IMM(cfg, OP_ADD_IMM,        \
                                        dReg, dest, offset);                    \
                                inst->dreg        = dReg;                       \
@@ -163,19 +128,19 @@ if (ins->flags & MONO_INST_BRLABEL) {                                                     \
                                inst->sreg1       = src;                        \
                                inst->inst_imm    = imm;                        \
                        } else {                                                \
-                               sReg = mono_alloc_preg (cfg); \
+                               sReg = mono_alloc_preg (cfg);                   \
                                MONO_EMIT_NEW_BIALU_IMM(cfg, OP_ADD_IMM,        \
                                        sReg, src, imm);                        \
                                inst->sreg1       = sReg;                       \
                                inst->inst_imm    = 0;                          \
                        }                                                       \
                }                                                               \
-                inst->opcode     = OP_S390_MOVE;                               \
-               inst->backend.size        = size;                                       \
-        MONO_ADD_INS (cfg->cbb, inst); \
+                inst->opcode           = OP_S390_MOVE;                         \
+               inst->backend.size      = size;                                 \
+        MONO_ADD_INS (cfg->cbb, inst);                                                 \
        } while (0)
 
-#define MONO_OUTPUT_VTR2(cfg, size, dr, sr, so) do {                           \
+#define MONO_OUTPUT_VTR(cfg, size, dr, sr, so) do {                            \
        int reg = mono_alloc_preg (cfg); \
        switch (size) {                                                         \
                case 0:                                                         \
@@ -209,7 +174,7 @@ if (ins->flags & MONO_INST_BRLABEL) {                                                       \
        }                                                                       \
 } while (0)
 
-#define MONO_OUTPUT_VTS2(cfg, size, dr, dx, sr, so) do {                               \
+#define MONO_OUTPUT_VTS(cfg, size, dr, dx, sr, so) do {                                \
        int tmpr;                                                               \
        switch (size) {                                                         \
                case 0:                                                         \
@@ -234,7 +199,7 @@ if (ins->flags & MONO_INST_BRLABEL) {                                                       \
                break;                                                          \
                case 4:                                                         \
                case 8:                                                         \
-                       MONO_EMIT_NEW_MOVE2 (cfg, dr, dx, sr, so, size);                \
+                       MONO_EMIT_NEW_MOVE (cfg, dr, dx, sr, so, size);         \
                break;                                                          \
        }                                                                       \
 } while (0)
@@ -265,6 +230,7 @@ if (ins->flags & MONO_INST_BRLABEL) {                                                       \
 #include "mini-s390.h"
 #include "cpu-s390.h"
 #include "jit-icalls.h"
+#include "ir-emit.h"
 
 /*========================= End of Includes ========================*/
 
@@ -357,7 +323,7 @@ static CallInfo * get_call_info (MonoCompile *, MonoMemPool *, MonoMethodSignatu
 static guchar * emit_float_to_int (MonoCompile *, guchar *, int, int, int, gboolean);
 gpointer mono_arch_get_lmf_addr (void);
 static guint8 * emit_load_volatile_registers(guint8 *, MonoCompile *);
-static void emit_sig_cookie (MonoCompile *, MonoCallInst *, CallInfo *, int);
+static void emit_sig_cookie (MonoCompile *, MonoCallInst *, CallInfo *);
 
 /*========================= End of Prototypes ======================*/
 
@@ -694,7 +660,7 @@ enum_parmtype:
                                MonoMarshalType *info;
 
                                if (type->data.klass->enumtype) {
-                                       simpleType = type->data.klass->enum_basetype->type;
+                                       simpleType = mono_class_enum_basetype (type->data.klass)->type;
                                        printf("{VALUETYPE} - ");
                                        goto enum_parmtype;
                                }
@@ -999,7 +965,7 @@ handle_enum:
        case MONO_TYPE_VALUETYPE: {
                MonoMarshalType *info;
                if (type->data.klass->enumtype) {
-                       type = type->data.klass->enum_basetype;
+                       type = mono_class_enum_basetype (type->data.klass);
                        goto handle_enum;
                } else {
                        guint8 *p = va_arg (ap, gpointer);
@@ -1161,7 +1127,7 @@ is_regsize_var (MonoType *t) {
                return FALSE;
        case MONO_TYPE_VALUETYPE:
                if (t->data.klass->enumtype)
-                       return is_regsize_var (t->data.klass->enum_basetype);
+                       return is_regsize_var (mono_class_enum_basetype (t->data.klass));
                return FALSE;
        }
        return FALSE;
@@ -1223,7 +1189,7 @@ mono_arch_get_global_int_regs (MonoCompile *cfg)
        MonoMethodHeader *header;
        int i, top = 13;
 
-       header = mono_method_get_header (cfg->method);
+       header = cfg->header;
        if ((cfg->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
                cfg->frame_reg = s390_r11;
 
@@ -1467,7 +1433,7 @@ enum_retvalue:
                        sz->code_size += 4;
                        break;
                case MONO_TYPE_GENERICINST:
-                       if (!mono_type_generic_inst_is_valuetype (sig->ret)) {
+                       if (!mono_type_generic_inst_is_valuetype (ret_type)) {
                                cinfo->ret.reg = s390_r2;
                                sz->code_size += 4;
                                break;
@@ -1476,7 +1442,7 @@ enum_retvalue:
                case MONO_TYPE_VALUETYPE: {
                        MonoClass *klass = mono_class_from_mono_type (sig->ret);
                        if (klass->enumtype) {
-                               simpletype = klass->enum_basetype->type;
+                               simpletype = mono_class_enum_basetype (klass)->type;
                                goto enum_retvalue;
                        }
                        if (sig->pinvoke)
@@ -1591,7 +1557,7 @@ enum_retvalue:
                        nParm++;
                        break;
                case MONO_TYPE_GENERICINST:
-                       if (!mono_type_generic_inst_is_valuetype (sig->params [i])) {
+                       if (!mono_type_generic_inst_is_valuetype (ptype)) {
                                cinfo->args[nParm].size = sizeof(gpointer);
                                add_general (&gr, sz, cinfo->args+nParm, TRUE);
                                nParm++;
@@ -1759,7 +1725,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        int frame_reg = STK_BASE;
        int sArg, eArg;
 
-       header  = mono_method_get_header (cfg->method);
+       header  = cfg->header;
 
        cfg->flags |= MONO_CFG_HAS_SPILLUP;
 
@@ -1791,12 +1757,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        
        cinfo   = get_call_info (cfg, cfg->mempool, sig, sig->pinvoke);
 
-       if (cinfo->struct_ret) {
-               if (!cfg->new_ir) {
-                       cfg->vret_addr->opcode = OP_REGVAR;
-                       cfg->vret_addr->inst_c0 = s390_r2;
-               }
-       } else {
+       if (!cinfo->struct_ret) {
                switch (mono_type_get_underlying_type (sig->ret)->type) {
                case MONO_TYPE_VOID:
                        break;
@@ -1823,9 +1784,6 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                inst->opcode       = OP_REGOFFSET;
                inst->inst_basereg = frame_reg;
                offset            += sizeof(gpointer);
-               if (!cfg->new_ir && (sig->call_convention == MONO_CALL_VARARG) &&
-                   (!retFitsInReg (cinfo->ret.size)))
-                       cfg->sig_cookie += cinfo->ret.size;
                if (G_UNLIKELY (cfg->verbose_level > 1)) {
                        printf ("vret_addr =");
                        mono_print_ins (cfg->vret_addr);
@@ -1855,113 +1813,65 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                inst = cfg->args [curinst];
                if (inst->opcode != OP_REGVAR) {
                        switch (cinfo->args[iParm].regtype) {
-                               case RegTypeStructByAddr :
-                                       if (cfg->new_ir) {
-                                               MonoInst *indir;
-
-                                               size = sizeof (gpointer);
-
-                                               if (cinfo->args [iParm].reg == STK_BASE) {
-                                                       cfg->arch.bkchain_reg = s390_r12;
-                                                       cfg->used_int_regs |= 1 << cfg->arch.bkchain_reg;
-
-                                                       inst->opcode       = OP_REGOFFSET;
-                                                       inst->inst_basereg = cfg->arch.bkchain_reg;
-                                                       inst->inst_offset  = cinfo->args [iParm].offset;
-                                               } else {
-                                                       inst->opcode = OP_REGOFFSET;
-                                                       inst->inst_basereg = frame_reg;
-                                                       inst->inst_offset = S390_ALIGN(offset, sizeof (gpointer));
-                                               }
-
-                                               /* Add a level of indirection */
-                                               MONO_INST_NEW (cfg, indir, 0);
-                                               *indir = *inst;
-                                               inst->opcode = OP_VTARG_ADDR;
-                                               inst->inst_left = indir;
+                           case RegTypeStructByAddr : {
+                                       MonoInst *indir;
+
+                                       size = sizeof (gpointer);
+
+                                       if (cinfo->args [iParm].reg == STK_BASE) {
+                                               cfg->arch.bkchain_reg = s390_r12;
+                                               cfg->used_int_regs |= 1 << cfg->arch.bkchain_reg;
+
+                                               inst->opcode       = OP_REGOFFSET;
+                                               inst->inst_basereg = cfg->arch.bkchain_reg;
+                                               inst->inst_offset  = cinfo->args [iParm].offset;
                                        } else {
-                                               if (cinfo->args[iParm].reg == STK_BASE) {
-                                                       inst->opcode       = OP_S390_LOADARG;
-                                                       inst->inst_basereg = frame_reg;
-                                                       size               = abs(cinfo->args[iParm].vtsize);
-                                                       offset             = S390_ALIGN(offset, sizeof(long));
-                                                       inst->inst_offset  = offset; 
-                                                       inst->backend.arg_info       = cinfo->args[iParm].offset;
-                                               } else {
-                                                       inst->opcode       = OP_S390_ARGREG;
-                                                       inst->inst_basereg = frame_reg;
-                                                       size               = sizeof(gpointer);
-                                                       offset             = S390_ALIGN(offset, size);
-                                                       inst->inst_offset  = offset;
-                                                       inst->backend.arg_info       = cinfo->args[iParm].offset;
-                                               }
+                                               inst->opcode = OP_REGOFFSET;
+                                               inst->inst_basereg = frame_reg;
+                                               inst->inst_offset = S390_ALIGN(offset, sizeof (gpointer));
                                        }
+
+                                       /* Add a level of indirection */
+                                       MONO_INST_NEW (cfg, indir, 0);
+                                       *indir = *inst;
+                                       inst->opcode = OP_VTARG_ADDR;
+                                       inst->inst_left = indir;
+                               }
                                        break;
                                case RegTypeStructByVal :
-                                       if (cfg->new_ir) {
-                                               size               = cinfo->args[iParm].size;
-                                               offset             = S390_ALIGN(offset, size);
-                                               inst->opcode = OP_REGOFFSET;
-                                               inst->inst_basereg = frame_reg;
-                                               inst->inst_offset = S390_ALIGN (offset, size);
+                                       size               = cinfo->args[iParm].size;
+                                       offset             = S390_ALIGN(offset, size);
+                                       inst->opcode = OP_REGOFFSET;
+                                       inst->inst_basereg = frame_reg;
+                                       inst->inst_offset = S390_ALIGN (offset, size);
+                                       break;
+                               default :
+                                       if (cinfo->args [iParm].reg == STK_BASE) {
+                                               /*
+                                                * These arguments are in the previous frame, so we can't 
+                                                * compute their offset from the current frame pointer right
+                                                * now, since cfg->stack_offset is not yet known, so dedicate a 
+                                                * register holding the previous frame pointer.
+                                                */
+                                               cfg->arch.bkchain_reg = s390_r12;
+                                               cfg->used_int_regs |= 1 << cfg->arch.bkchain_reg;
+
+                                               inst->opcode       = OP_REGOFFSET;
+                                               inst->inst_basereg = cfg->arch.bkchain_reg;
+                                               size               = (cinfo->args[iParm].size < 4
+                                                                                 ? 4 - cinfo->args[iParm].size
+                                                                                 : 0);
+                                               inst->inst_offset  = cinfo->args [iParm].offset + size;
+                                               size = sizeof (long);
                                        } else {
-                                               inst->opcode       = OP_S390_ARGPTR;
+                                               inst->opcode       = OP_REGOFFSET;
                                                inst->inst_basereg = frame_reg;
-                                               size               = cinfo->args[iParm].size;
+                                               size               = (cinfo->args[iParm].size < 8
+                                                                                 ? sizeof(long)  
+                                                                                 : sizeof(long long));
                                                offset             = S390_ALIGN(offset, size);
                                                inst->inst_offset  = offset;
-                                               inst->backend.arg_info       = cinfo->args[iParm].offset;
                                        }
-                                       break;
-                               default :
-                                       if (cfg->new_ir) {
-                                               if (cinfo->args [iParm].reg == STK_BASE) {
-                                                       /*
-                                                        * These arguments are in the previous frame, so we can't 
-                                                        * compute their offset from the current frame pointer right
-                                                        * now, since cfg->stack_offset is not yet known, so dedicate a 
-                                                        * register holding the previous frame pointer.
-                                                        */
-                                                       cfg->arch.bkchain_reg = s390_r12;
-                                                       cfg->used_int_regs |= 1 << cfg->arch.bkchain_reg;
-
-                                                       inst->opcode       = OP_REGOFFSET;
-                                                       inst->inst_basereg = cfg->arch.bkchain_reg;
-                                                       size               = (cinfo->args[iParm].size < 4
-                                                                                         ? 4 - cinfo->args[iParm].size
-                                                                                         : 0);
-                                                       inst->inst_offset  = cinfo->args [iParm].offset + size;
-                                                       size = sizeof (long);
-                                               } else {
-                                                       inst->opcode       = OP_REGOFFSET;
-                                                       inst->inst_basereg = frame_reg;
-                                                       size               = (cinfo->args[iParm].size < 8
-                                                                                         ? sizeof(long)  
-                                                                                         : sizeof(long long));
-                                                       offset             = S390_ALIGN(offset, size);
-                                                       inst->inst_offset  = offset;
-                                               }
-                                       } else {
-                                               if (cinfo->args[iParm].reg != STK_BASE) {
-                                                       inst->opcode       = OP_REGOFFSET;
-                                                       inst->inst_basereg = frame_reg;
-                                                       size               = (cinfo->args[iParm].size < 8
-                                                                                         ? sizeof(long)  
-                                                                                         : sizeof(long long));
-                                                       offset             = S390_ALIGN(offset, size);
-                                                       inst->inst_offset  = offset;
-                                               } else {
-                                                       inst->opcode       = OP_S390_STKARG;
-                                                       inst->inst_basereg = frame_reg;
-                                                       size               = (cinfo->args[iParm].size < 4
-                                                                                         ? 4 - cinfo->args[iParm].size
-                                                                                         : 0);
-                                                       inst->inst_offset  = cinfo->args[iParm].offset + 
-                                                               size;
-                                                       inst->backend.arg_info       = 0;
-                                                       size               = sizeof(long);
-                                               }
-                               } 
                        }
                        if ((sig->call_convention == MONO_CALL_VARARG) && 
                            (cinfo->args[iParm].regtype != RegTypeGeneral) &&
@@ -2017,14 +1927,12 @@ mono_arch_allocate_vars (MonoCompile *cfg)
        cfg->stack_offset = S390_ALIGN(offset, S390_STACK_ALIGNMENT);
 
        /* Fix up offsets for arguments whose value is in the parent frame */
-       if (cfg->new_ir) {
-               for (iParm = sArg; iParm < eArg; ++iParm) {
-                       inst = cfg->args [iParm];
+       for (iParm = sArg; iParm < eArg; ++iParm) {
+               inst = cfg->args [iParm];
 
-                       if (inst->opcode == OP_S390_STKARG) {
-                               inst->opcode = OP_REGOFFSET;
-                               inst->inst_offset += cfg->stack_offset;
-                       }
+               if (inst->opcode == OP_S390_STKARG) {
+                       inst->opcode = OP_REGOFFSET;
+                       inst->inst_offset += cfg->stack_offset;
                }
        }
 }
@@ -2091,7 +1999,7 @@ add_outarg_reg2 (MonoCompile *cfg, MonoCallInst *call, ArgStorage storage, int r
 }
 
 static void
-emit_sig_cookie2 (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo)
+emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo)
 {
        MonoMethodSignature *tmpSig;
        MonoInst *sig_arg;
@@ -2172,7 +2080,7 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
 
                if ((sig->call_convention == MONO_CALL_VARARG) &&
                    (i == sig->sentinelpos)) {
-                       emit_sig_cookie2 (cfg, call, cinfo);
+                       emit_sig_cookie (cfg, call, cinfo);
                }
 
                switch (ainfo->regtype) {
@@ -2301,7 +2209,7 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
         */
        if ((sig->call_convention == MONO_CALL_VARARG) &&
            (i == sig->sentinelpos)) {
-               emit_sig_cookie2 (cfg, call, cinfo);
+               emit_sig_cookie (cfg, call, cinfo);
        }
 }
 
@@ -2329,9 +2237,9 @@ mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src)
                                arg->offPrm     = ainfo->offparm + cinfo->sz.offStruct;
                */
                if (ainfo->reg != STK_BASE) {
-                       MONO_OUTPUT_VTR2 (cfg, size, ainfo->reg, src->dreg, 0);
+                       MONO_OUTPUT_VTR (cfg, size, ainfo->reg, src->dreg, 0);
                } else {
-                       MONO_OUTPUT_VTS2 (cfg, size, ainfo->reg, ainfo->offset,
+                       MONO_OUTPUT_VTS (cfg, size, ainfo->reg, ainfo->offset,
                                                          src->dreg, 0);
                }       
        } else if (ainfo->regtype == RegTypeStructByValInFP) {
@@ -2348,7 +2256,7 @@ mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src)
 
                mono_call_inst_add_outarg_reg (cfg, call, dreg, ainfo->reg, TRUE);
        } else {
-               MONO_EMIT_NEW_MOVE2 (cfg, STK_BASE, ainfo->offparm,
+               MONO_EMIT_NEW_MOVE (cfg, STK_BASE, ainfo->offparm,
                                                         src->dreg, 0, size);
        }
 }
@@ -2381,53 +2289,6 @@ mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val)
        MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg, val->dreg);
 }
 
-/*========================= End of Function ========================*/
-   
-/*------------------------------------------------------------------*/
-/*                                                                  */
-/* Name                - emit_sig_cookie.                                  */
-/*                                                                  */
-/* Function    - For variable length parameter lists construct a   */
-/*               signature cookie and emit it.                     */
-/*                                                                 */
-/*------------------------------------------------------------------*/
-
-static void
-emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, 
-                CallInfo *cinfo, int argSize)
-{
-       MonoCallArgParm *arg;
-       MonoMethodSignature *tmpSig;
-       MonoInst *sigArg;
-                       
-       cfg->disable_aot = TRUE;
-
-       /*----------------------------------------------------------*/
-       /* mono_ArgIterator_Setup assumes the signature cookie is   */
-       /* passed first and all the arguments which were before it  */
-       /* passed on the stack after the signature. So compensate   */
-       /* by passing a different signature.                        */
-       /*----------------------------------------------------------*/
-       tmpSig = mono_metadata_signature_dup (call->signature);
-       tmpSig->param_count -= call->signature->sentinelpos;
-       tmpSig->sentinelpos  = 0;
-       if (tmpSig->param_count > 0)
-               memcpy (tmpSig->params, 
-                       call->signature->params + call->signature->sentinelpos, 
-                       tmpSig->param_count * sizeof(MonoType *));
-
-       MONO_INST_NEW (cfg, sigArg, OP_ICONST);
-       sigArg->inst_p0 = tmpSig;
-
-       MONO_INST_NEW_CALL_ARG (cfg, arg, OP_OUTARG_MEMBASE);
-       arg->ins.inst_left   = sigArg;
-       arg->ins.inst_right  = (MonoInst *) call;
-       arg->size            = argSize;
-       arg->offset          = cinfo->sigCookie.offset;
-       arg->ins.next        = call->out_args;
-       call->out_args       = (MonoInst *) arg;
-}
-
 /*========================= End of Function ========================*/
 
 /*------------------------------------------------------------------*/
@@ -2517,7 +2378,7 @@ mono_arch_instrument_prolog (MonoCompile *cfg, void *func, void *p,
 /*------------------------------------------------------------------*/
 
 void*
-mono_arch_instrument_epilog (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments)
+mono_arch_instrument_epilog_full (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments, gboolean preserve_argument_registers)
 {
        guchar     *code = p;
        int        save_mode = SAVE_NONE,
@@ -2550,7 +2411,7 @@ handle_enum:
                break;
        case MONO_TYPE_VALUETYPE:
                if (mono_method_signature (method)->ret->data.klass->enumtype) {
-                       rtype = mono_method_signature (method)->ret->data.klass->enum_basetype->type;
+                       rtype = mono_class_enum_basetype (mono_method_signature (method)->ret->data.klass)->type;
                        goto handle_enum;
                }
                save_mode = SAVE_STRUCT;
@@ -2658,9 +2519,6 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
 {
        MonoInst *ins, *next;
 
-       if (bb->max_vreg > cfg->rs->next_vreg)
-               cfg->rs->next_vreg = bb->max_vreg;
-
        MONO_BB_FOR_EACH_INS_SAFE (bb, next, ins) {
                switch (ins->opcode) {
                case OP_DIV_IMM:
@@ -2676,6 +2534,8 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
                        break;
                }
        }
+
+       bb->max_vreg = cfg->next_vreg;
 }
 
 /*========================= End of Function ========================*/
@@ -3795,9 +3655,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                                s390_ldebr (code, s390_f0, s390_f0);
                }
                        break;
-               case OP_OUTARG: 
-                       g_assert_not_reached ();
-                       break;
                case OP_LOCALLOC: {
                        /*------------------------------------------*/
                        /* To allocate space on the stack we have   */
@@ -3918,6 +3775,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        mono_add_patch_info (cfg, code-cfg->native_code, 
                                             MONO_PATCH_INFO_BB, ins->inst_target_bb);
                        s390_brasl (code, s390_r14, 0);
+                       mono_cfg_add_try_hole (cfg, ins->inst_eh_block, code, bb);
                }
                        break;
                case OP_LABEL: {
@@ -4333,34 +4191,39 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                                        s390_mvc  (code, ins->backend.size, ins->dreg, 
                                                   ins->inst_offset, ins->sreg1, ins->inst_imm);
                                } else {
-                                       s390_lr   (code, s390_r0, ins->dreg);
+                                       s390_lr  (code, s390_r0, ins->dreg);
                                        if (s390_is_imm16 (ins->inst_offset)) {
                                                s390_ahi  (code, s390_r0, ins->inst_offset);
                                        } else {
                                                s390_basr (code, s390_r13, 0);
-                                               s390_j    (code, 4);
-                                               s390_word (code, ins->inst_offset);
+                                               s390_j    (code, 6);
+                                               s390_long (code, ins->inst_offset);
                                                s390_a    (code, s390_r0, 0, s390_r13, 4);
                                        }
-                                       s390_lr   (code, s390_r14, s390_r12);
-                                       s390_lr   (code, s390_r12, ins->sreg1);
+                                       s390_lr  (code, s390_r12, ins->sreg1);
                                        if (s390_is_imm16 (ins->inst_imm)) {
                                                s390_ahi  (code, s390_r12, ins->inst_imm);
                                        } else {
                                                s390_basr (code, s390_r13, 0);
-                                               s390_j    (code, 4);
-                                               s390_word (code, ins->inst_imm);
+                                               s390_j    (code, 6);
+                                               s390_long (code, ins->inst_imm);
                                                s390_a    (code, s390_r12, 0, s390_r13, 4);
                                        }
-                                       s390_lr   (code, s390_r1, ins->sreg1);
+                                       if (s390_is_imm16 (ins->backend.size)) {
+                                               s390x_lhi (code, s390_r1, ins->backend.size);
+                                       } else {
+                                               s390_basr (code, s390_r13, 0);
+                                               s390_j    (code, 6);
+                                               s390_long (code, ins->backend.size);
+                                               s390_l    (code, s390_r1, 0, s390_r13, 4);
+                                       }
+                                       s390_lr   (code, s390_r1, ins->backend.size);
                                        s390_lr   (code, s390_r13, s390_r1);
                                        s390_mvcle(code, s390_r0, s390_r12, 0, 0);
                                        s390_jo   (code, -2);
-                                       s390_lr   (code, s390_r12, s390_r14);
                                }
                        }
                }
-                       break;
                case OP_ATOMIC_ADD_I4: {
                        s390_lr  (code, s390_r1, ins->sreg2);
                        s390_l   (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
@@ -5118,7 +4981,7 @@ mono_arch_free_jit_tls_data (MonoJitTlsData *tls)
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_emit_inst_for_method                        */
+/* Name                - mono_arch_emit_inst_for_method                    */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
@@ -5130,6 +4993,12 @@ mono_arch_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMetho
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_decompose_opts                          */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
 void
 mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins)
 {
@@ -5155,7 +5024,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins)
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* Name                - mono_arch_decompose_long_opts                         */
+/* Name                - mono_arch_decompose_long_opts                     */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 
@@ -5344,31 +5213,6 @@ mono_arch_get_domain_intrinsic (MonoCompile* cfg)
 
 /*========================= End of Function ========================*/
 
-/*------------------------------------------------------------------*/
-/*                                                                  */
-/* Name                - mono_arch_get_thread_intrinsic                    */
-/*                                                                  */
-/* Function    -                                                   */
-/*                                                                 */
-/* Returns     -                                                   */
-/*                                                                  */
-/*------------------------------------------------------------------*/
-
-MonoInst * 
-mono_arch_get_thread_intrinsic (MonoCompile* cfg)
-{
-       MonoInst *ins;
-
-       if (thread_tls_offset == -1)
-               return NULL;
-       
-       MONO_INST_NEW (cfg, ins, OP_TLS_GET);
-       ins->inst_offset = thread_tls_offset;
-       return (ins);
-}
-
-/*========================= End of Function ========================*/
-
 /*------------------------------------------------------------------*/
 /*                                                                  */
 /* Name                - mono_arch_flush_register_windows                  */
@@ -5423,6 +5267,16 @@ mono_arch_get_patch_offset (guint8 *code)
 
 /*========================= End of Function ========================*/
 
+/*------------------------------------------------------------------*/
+/*                                                                  */
+/* Name                - mono_arch_context_get_int_reg.                    */
+/*                                                                  */
+/* Function    - Dummy entry point until s390x supports aot.       */
+/*                                                                 */
+/* Returns     - Pointer to intreg.                                */
+/*                                                                  */
+/*------------------------------------------------------------------*/
+
 gpointer
 mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
 {
@@ -5430,3 +5284,5 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
        g_assert_not_reached ();
        return NULL;
 }
+
+/*========================= End of Function ========================*/