typedef struct {
int nargs;
+ int lastgr;
guint32 stack_usage;
guint32 struct_ret;
ArgInfo ret;
static void mono_arch_break(void);
gpointer mono_arch_get_lmf_addr (void);
static guint8 * emit_load_volatile_registers(guint8 *, MonoCompile *);
+static void emit_sig_cookie (MonoCompile *, MonoCallInst *, CallInfo *, int);
/*========================= End of Prototypes ======================*/
static int indent_level = 0;
-static const char*const * ins_spec = s390_cpu_desc;
-
static gboolean tls_offset_inited = FALSE;
static int appdomain_tls_offset = -1,
if (csig->pinvoke)
size = mono_type_native_stack_size (csig->params [k], &align);
else
- size = mono_type_stack_size (csig->params [k], &align);
+ size = mini_type_stack_size (NULL, csig->params [k], &align);
frame_size += pad = (align - (frame_size & (align - 1))) & (align - 1);
arg_info [k].pad = pad;
enter_method (MonoMethod *method, RegParm *rParm, char *sp)
{
int i, oParm = 0, iParm = 0;
- MonoClass *class;
MonoObject *obj;
MonoMethodSignature *sig;
char *fname;
size_data sz;
void *curParm;
-
-lc++;
-if (lc > 5000000) {
-fseek(stdout, 0L, SEEK_SET);
-lc = 0;
-}
fname = mono_method_full_name (method, TRUE);
indent (1);
printf ("ENTER: %s(", fname);
/*========================= End of Function ========================*/
+
+/*
+ * Initialize architecture specific code.
+ */
+void
+mono_arch_init (void)
+{
+}
+
+/*
+ * Cleanup architecture specific code.
+ */
+void
+mono_arch_cleanup (void)
+{
+}
+
/*------------------------------------------------------------------*/
/* */
/* Name - mono_arch_cpu_optimizazions */
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:
static void inline
add_general (guint *gr, size_data *sz, ArgInfo *ainfo, gboolean simple)
{
+ int disp;
+
if (simple) {
if (*gr > S390_LAST_ARG_REG) {
sz->stack_size = S390_ALIGN(sz->stack_size, sizeof(long));
}
} else {
if (*gr > S390_LAST_ARG_REG - 1) {
+ disp = sz->stack_size;
sz->stack_size = S390_ALIGN(sz->stack_size, S390_STACK_ALIGNMENT);
+ disp = sz->stack_size - disp;
ainfo->offset = sz->stack_size;
ainfo->reg = STK_BASE;
ainfo->regtype = RegTypeBase;
sz->stack_size += sizeof(long long);
- sz->local_size += sizeof(long long);
- sz->offStruct += sizeof(long long);
+ sz->local_size += (sizeof(long long) + disp);
+ sz->offStruct += (sizeof(long long) + disp);
sz->code_size += 10;
} else {
ainfo->reg = *gr;
/* Fall through */
case MONO_TYPE_VALUETYPE: {
MonoClass *klass = mono_class_from_mono_type (sig->ret);
- if (sig->ret->data.klass->enumtype) {
- simpletype = sig->ret->data.klass->enum_basetype->type;
+ if (klass->enumtype) {
+ simpletype = klass->enum_basetype->type;
goto enum_retvalue;
}
if (sig->pinvoke)
case MONO_TYPE_VOID:
break;
default:
- g_error ("Can't handle as return value 0x%x", sig->ret->type);
+ g_error ("mini-s390: cannot handle as return value 0x%x (0x%x)", sig->ret->type,simpletype);
}
if (sig->hasthis) {
cinfo->args[nParm].size = sizeof(long long);
cinfo->args[nParm].regtype = RegTypeStructByVal;
nParm++;
- sz->local_size += sizeof(long);
+ sz->local_size += sizeof(long long);
break;
default:
add_stackParm(&gr, sz, cinfo->args+nParm, size);
cinfo->args[nParm].size = sizeof(long long);
cinfo->args[nParm].regtype = RegTypeStructByVal;
nParm++;
- sz->local_size += sizeof(long);
+ sz->local_size += sizeof(long long);
break;
default:
add_stackParm(&gr, sz, cinfo->args+nParm, size);
}
}
+ /*----------------------------------------------------------*/
+ /* Handle the case where there are no implicit arguments */
+ /*----------------------------------------------------------*/
+ if ((sig->call_convention == MONO_CALL_VARARG) &&
+ (sig->param_count == sig->sentinelpos)) {
+ gr = S390_LAST_ARG_REG + 1;
+ add_general (&gr, sz, &cinfo->sigCookie, TRUE);
+ }
+
+ cinfo->lastgr = gr;
sz->stack_size = sz->stack_size + sz->local_size + sz->parm_size +
sz->offset;
sz->stack_size = S390_ALIGN(sz->stack_size, sizeof(long));
}
if (sig->hasthis) {
- inst = cfg->varinfo [0];
+ inst = cfg->args [0];
if (inst->opcode != OP_REGVAR) {
inst->opcode = OP_REGOFFSET;
inst->inst_basereg = frame_reg;
cfg->sig_cookie += S390_MINIMAL_STACK_SIZE;
for (iParm = sArg; iParm < eArg; ++iParm) {
- inst = cfg->varinfo [curinst];
+ inst = cfg->args [curinst];
if (inst->opcode != OP_REGVAR) {
switch (cinfo->args[iParm].regtype) {
case RegTypeStructByAddr :
size = abs(cinfo->args[iParm].vtsize);
offset = S390_ALIGN(offset, sizeof(long));
inst->inst_offset = offset;
- inst->unused = cinfo->args[iParm].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->unused = cinfo->args[iParm].offset;
+ inst->backend.arg_info = cinfo->args[iParm].offset;
}
break;
case RegTypeStructByVal :
size = cinfo->args[iParm].size;
offset = S390_ALIGN(offset, size);
inst->inst_offset = offset;
- inst->unused = cinfo->args[iParm].offset;
+ inst->backend.arg_info = cinfo->args[iParm].offset;
break;
default :
if (cinfo->args[iParm].reg != STK_BASE) {
: 0);
inst->inst_offset = cinfo->args[iParm].offset +
size;
- inst->unused = 0;
+ inst->backend.arg_info = 0;
size = sizeof(long);
}
}
continue;
/*--------------------------------------------------*/
- /* inst->unused indicates native sized value types, */
+ /* inst->backend.is_pinvoke indicates native sized value types, */
/* this is used by the pinvoke wrappers when they */
/* call functions returning structure */
/*--------------------------------------------------*/
- if (inst->unused && MONO_TYPE_ISSTRUCT (inst->inst_vtype))
+ if (inst->backend.is_pinvoke && MONO_TYPE_ISSTRUCT (inst->inst_vtype))
size = mono_class_native_size (mono_class_from_mono_type(inst->inst_vtype), &align);
else
size = mono_type_size (inst->inst_vtype, &align);
MonoMethodSignature *sig;
int i, n, lParamArea;
CallInfo *cinfo;
- ArgInfo *ainfo;
+ ArgInfo *ainfo = NULL;
size_data sz;
int stackSize;
if ((sig->call_convention == MONO_CALL_VARARG) &&
(i == sig->sentinelpos)) {
- MonoInst *sigArg;
-
- cfg->disable_aot = TRUE;
- MONO_INST_NEW (cfg, sigArg, OP_ICONST);
- sigArg->inst_p0 = call->signature;
-
- MONO_INST_NEW_CALL_ARG (cfg, arg, OP_OUTARG_MEMBASE);
- arg->ins.inst_left = sigArg;
- arg->ins.inst_right = (MonoInst *) call;
- arg->size = ainfo->size;
- arg->offset = cinfo->sigCookie.offset;
- call->used_iregs |= 1 << ainfo->reg;
- arg->ins.next = call->out_args;
- call->out_args = (MonoInst *) arg;
+ emit_sig_cookie (cfg, call, cinfo, ainfo->size);
}
if (is_virtual && i == 0) {
call->out_args = (MonoInst *) arg;
arg->ins.inst_right = (MonoInst *) call;
if (ainfo->regtype == RegTypeGeneral) {
- arg->ins.unused = ainfo->reg;
+ arg->ins.backend.reg3 = ainfo->reg;
call->used_iregs |= 1 << ainfo->reg;
if (arg->ins.type == STACK_I8)
call->used_iregs |= 1 << (ainfo->reg + 1);
arg->offset = ainfo->offset;
call->used_iregs |= 1 << ainfo->reg;
} else if (ainfo->regtype == RegTypeFP) {
- arg->ins.unused = ainfo->reg;
+ arg->ins.backend.reg3 = ainfo->reg;
call->used_fregs |= 1 << ainfo->reg;
if (ainfo->size == 4)
arg->ins.opcode = OP_OUTARG_R4;
}
}
}
+
+ /*
+ * Handle the case where there are no implicit arguments
+ */
+ if ((sig->call_convention == MONO_CALL_VARARG) &&
+ (i == sig->sentinelpos)) {
+ emit_sig_cookie (cfg, call, cinfo, ainfo->size);
+ }
+
/*
* Reverse the call->out_args list.
*/
/*========================= 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 ========================*/
+
/*------------------------------------------------------------------*/
/* */
/* Name - mono_arch_instrument_mem_needs */
if (last_ins && (last_ins->opcode == OP_STOREI1_MEMBASE_REG) &&
ins->inst_basereg == last_ins->inst_destbasereg &&
ins->inst_offset == last_ins->inst_offset) {
- if (ins->dreg == last_ins->sreg1) {
- last_ins->next = ins->next;
- ins = ins->next;
- continue;
- } else {
- //static int c = 0; printf ("MATCHX %s %d\n", cfg->method->name,c++);
- ins->opcode = OP_MOVE;
- ins->sreg1 = last_ins->sreg1;
- }
+ ins->opcode = (ins->opcode == OP_LOADI1_MEMBASE) ? CEE_CONV_I1 : CEE_CONV_U1;
+ ins->sreg1 = last_ins->sreg1;
}
break;
case OP_LOADU2_MEMBASE:
if (last_ins && (last_ins->opcode == OP_STOREI2_MEMBASE_REG) &&
ins->inst_basereg == last_ins->inst_destbasereg &&
ins->inst_offset == last_ins->inst_offset) {
- if (ins->dreg == last_ins->sreg1) {
- last_ins->next = ins->next;
- ins = ins->next;
- continue;
- } else {
- ins->opcode = OP_MOVE;
- ins->sreg1 = last_ins->sreg1;
- }
+ ins->opcode = (ins->opcode == OP_LOADI2_MEMBASE) ? CEE_CONV_I2 : CEE_CONV_U2;
+ ins->sreg1 = last_ins->sreg1;
}
break;
case CEE_CONV_I4:
while (ins) {
offset = code - cfg->native_code;
- max_len = ((guint8 *)ins_spec [ins->opcode])[MONO_INST_LEN];
+ max_len = ((guint8 *)ins_get_spec (ins->opcode))[MONO_INST_LEN];
if (offset > (cfg->code_size - max_len - 16)) {
cfg->code_size *= 2;
}
}
break;
- case CEE_BREAK: {
+ case OP_BREAK: {
mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_ABS, mono_arch_break);
s390_brasl (code, s390_r14, 0);
}
}
break;
case OP_LADD: {
- short int *o[1];
s390_alr (code, s390_r0, ins->sreg1);
s390_jnc (code, 4);
s390_ahi (code, s390_r1, 1);
s390_ledbr (code, ins->dreg, ins->sreg1);
}
break;
- case CEE_JMP: {
+ case OP_JMP: {
if (cfg->method->save_lmf)
restoreLMF(code, cfg->frame_reg, cfg->stack_usage);
s390_br (code, s390_r14);
}
break;
- case CEE_THROW: {
+ case OP_THROW: {
s390_lr (code, s390_r2, ins->sreg1);
mono_add_patch_info (cfg, code-cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD,
(gpointer)"mono_arch_throw_exception");
s390_br (code, s390_r14);
}
break;
- case CEE_ENDFINALLY: {
+ case OP_ENDFINALLY: {
if (s390_is_uimm12 (ins->inst_left->inst_offset)) {
s390_l (code, s390_r14, 0, ins->inst_left->inst_basereg,
ins->inst_left->inst_offset);
ins->inst_c0 = code - cfg->native_code;
}
break;
- case CEE_BR:
+ case OP_BR:
EMIT_UNCOND_BRANCH(ins);
break;
case OP_BR_REG: {
s390_lhi (code, ins->dreg, 0);
}
break;
- case OP_FBEQ:
- EMIT_COND_BRANCH (ins, S390_CC_EQ|S390_CC_OV);
+ case OP_FBEQ: {
+ short *o;
+ s390_jo (code, 0); CODEPTR(code, o);
+ EMIT_COND_BRANCH (ins, S390_CC_EQ);
+ PTRSLOT(code, o);
+ }
break;
case OP_FBNE_UN:
EMIT_COND_BRANCH (ins, S390_CC_NE|S390_CC_OV);
break;
- case OP_FBLT:
+ case OP_FBLT: {
+ short *o;
+ s390_jo (code, 0); CODEPTR(code, o);
EMIT_COND_BRANCH (ins, S390_CC_LT);
+ PTRSLOT(code, o);
+ }
break;
case OP_FBLT_UN:
EMIT_COND_BRANCH (ins, S390_CC_LT|S390_CC_OV);
break;
- case OP_FBGT:
+ case OP_FBGT: {
+ short *o;
+ s390_jo (code, 0); CODEPTR(code, o);
EMIT_COND_BRANCH (ins, S390_CC_GT);
+ PTRSLOT(code, o);
+ }
break;
case OP_FBGT_UN:
EMIT_COND_BRANCH (ins, S390_CC_GT|S390_CC_OV);
break;
- case OP_FBGE:
+ case OP_FBGE: {
+ short *o;
+ s390_jo (code, 0); CODEPTR(code, o);
EMIT_COND_BRANCH (ins, S390_CC_GE);
+ PTRSLOT(code, o);
+ }
break;
case OP_FBGE_UN:
EMIT_COND_BRANCH (ins, S390_CC_GE|S390_CC_OV);
break;
- case OP_FBLE:
+ case OP_FBLE: {
+ short *o;
+ s390_jo (code, 0); CODEPTR(code, o);
EMIT_COND_BRANCH (ins, S390_CC_LE);
+ PTRSLOT(code, o);
+ }
break;
case OP_FBLE_UN:
EMIT_COND_BRANCH (ins, S390_CC_LE|S390_CC_OV);
break;
- case CEE_CKFINITE: {
+ case OP_CKFINITE: {
short *o;
s390_lhi (code, s390_r13, 0x7f);
s390_tcdb (code, ins->sreg1, 0, s390_r13, 0);
}
break;
case OP_S390_MOVE: {
- if (ins->unused > 0) {
- if (ins->unused <= 256) {
- s390_mvc (code, ins->unused, ins->dreg,
+ if (ins->backend.size > 0) {
+ if (ins->backend.size <= 256) {
+ 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_r1, ins->sreg2);
s390_l (code, s390_r0, 0, ins->inst_basereg, ins->inst_offset);
s390_a (code, s390_r1, 0, ins->inst_basereg, ins->inst_offset);
- s390_cs (code, s390_r0, s390_r0, ins->inst_basereg, ins->inst_offset);
+ s390_cs (code, s390_r0, s390_r1, ins->inst_basereg, ins->inst_offset);
s390_jnz (code, -7);
s390_lr (code, ins->dreg, s390_r1);
}
for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
ArgInfo *ainfo = cinfo->args + i;
- inst = cfg->varinfo [pos];
+ inst = cfg->args [pos];
if (inst->opcode == OP_REGVAR) {
if (ainfo->regtype == RegTypeGeneral)
max_offset += 6;
while (ins) {
- max_offset += ((guint8 *)ins_spec [ins->opcode])[MONO_INST_LEN];
+ max_offset += ((guint8 *)ins_get_spec (ins->opcode))[MONO_INST_LEN];
ins = ins->next;
}
}
if (cinfo->struct_ret) {
ArgInfo *ainfo = &cinfo->ret;
inst = cfg->ret;
- inst->unused = ainfo->vtsize;
+ inst->backend.size = ainfo->vtsize;
s390_st (code, ainfo->reg, 0, inst->inst_basereg, inst->inst_offset);
}
for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
ArgInfo *ainfo = cinfo->args + i;
- inst = cfg->varinfo [pos];
+ inst = cfg->args [pos];
if (inst->opcode == OP_REGVAR) {
if (ainfo->regtype == RegTypeGeneral)
iExc;
guint32 code_size;
MonoClass *exc_classes [MAX_EXC];
- guint8 *exc_throw_start [MAX_EXC],
- *exc_throw_end [MAX_EXC];
+ guint8 *exc_throw_start [MAX_EXC];
for (patch_info = cfg->patch_info;
patch_info;
break;
case OP_S390_MOVE:
printf ("[0x%lx(%d,%s),0x%lx(%s)]",
- tree->inst_offset, tree->unused,
+ tree->inst_offset, tree->backend.size,
mono_arch_regname(tree->dreg), tree->inst_imm,
mono_arch_regname(tree->sreg1));
done = 1;
break;
case OP_S390_SETF4RET:
- printf ("[f%ld,f%ld]",
- mono_arch_regname (tree->dreg),
- mono_arch_regname (tree->sreg1));
+ printf ("[%s,%s]",
+ mono_arch_fregname (tree->dreg),
+ mono_arch_fregname (tree->sreg1));
done = 1;
break;
case OP_TLS_GET:
}
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/* */
+/* Name - mono_arch_get_patch_offset */
+/* */
+/* Function - Dummy entry point until s390x supports aot. */
+/* */
+/* Returns - Offset for patch. */
+/* */
+/*------------------------------------------------------------------*/
+
+guint32
+mono_arch_get_patch_offset (guint8 *code)
+{
+ return 0;
+}
+
/*========================= End of Function ========================*/