This module generates MIPS machine code for a sequence of
intermediate code commands (ICMDs).
- $Id: codegen.c 4654 2006-03-19 19:46:11Z edwin $
+ $Id: codegen.c 4744 2006-04-06 12:51:53Z twisti $
*/
*******************************************************************************/
-bool codegen(methodinfo *m, codegendata *cd, registerdata *rd)
+bool codegen(jitdata *jd)
{
+ methodinfo *m;
+ codegendata *cd;
+ registerdata *rd;
s4 len, s1, s2, s3, d, disp;
ptrint a;
s4 parentargs_base;
methoddesc *md;
rplpoint *replacementpoint;
+ /* get required compiler data */
+
+ m = jd->m;
+ cd = jd->cd;
+ rd = jd->rd;
+
{
s4 i, p, t, l;
s4 savedregs_num;
/* end of header generation */
- replacementpoint = cd->code->rplpoints;
+ replacementpoint = jd->code->rplpoints;
/* walk through all basic blocks */
while (src != NULL) {
len--;
if ((len == 0) && (bptr->type != BBTYPE_STD)) {
- d = reg_of_var(rd, src, REG_ITMP1);
+ d = codegen_reg_of_var(rd, 0, src, REG_ITMP1);
M_INTMOVE(REG_ITMP1, d);
store_reg_to_var_int(src, d);
} else {
- d = reg_of_var(rd, src, REG_IFTMP);
+ d = codegen_reg_of_var(rd, 0, src, REG_IFTMP);
if ((src->varkind != STACKVAR)) {
s2 = src->type;
if (IS_FLT_DBL_TYPE(s2)) {
case ICMD_ICONST: /* ... ==> ..., constant */
/* op1 = 0, val.i = constant */
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
ICONST(d, iptr->val.i);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_LCONST: /* ... ==> ..., constant */
/* op1 = 0, val.l = constant */
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
LCONST(d, iptr->val.l);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_FCONST: /* ... ==> ..., constant */
/* op1 = 0, val.f = constant */
- d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
disp = dseg_addfloat(cd, iptr->val.f);
M_FLD(d, REG_PV, disp);
store_reg_to_var_flt(iptr->dst, d);
case ICMD_DCONST: /* ... ==> ..., constant */
/* op1 = 0, val.d = constant */
- d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
disp = dseg_adddouble(cd, iptr->val.d);
M_DLD(d, REG_PV, disp);
store_reg_to_var_flt (iptr->dst, d);
case ICMD_ACONST: /* ... ==> ..., constant */
/* op1 = 0, val.a = constant */
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
if ((iptr->target != NULL) && (iptr->val.a == NULL)) {
disp = dseg_addaddress(cd, iptr->val.a);
case ICMD_LLOAD: /* op1 = local variable */
case ICMD_ALOAD:
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
if ((iptr->dst->varkind == LOCALVAR) &&
(iptr->dst->varnum == iptr->op1))
break;
case ICMD_FLOAD: /* ... ==> ..., content of local variable */
case ICMD_DLOAD: /* op1 = local variable */
- d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
if ((iptr->dst->varkind == LOCALVAR) &&
(iptr->dst->varnum == iptr->op1))
break;
case ICMD_INEG: /* ..., value ==> ..., - value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ISUB(REG_ZERO, s1, d);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_LNEG: /* ..., value ==> ..., - value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSUB(REG_ZERO, s1, d);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_I2L: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_INTMOVE(s1, d);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_L2I: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ISLL_IMM(s1, 0, d );
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_INT2BYTE: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSLL_IMM(s1, 56, d);
M_LSRA_IMM( d, 56, d);
store_reg_to_var_int(iptr->dst, d);
case ICMD_INT2CHAR: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_CZEXT(s1, d);
store_reg_to_var_int(iptr->dst, d);
break;
case ICMD_INT2SHORT: /* ..., value ==> ..., value */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSLL_IMM(s1, 48, d);
M_LSRA_IMM( d, 48, d);
store_reg_to_var_int(iptr->dst, d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_IADD(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.i >= -32768) && (iptr->val.i <= 32767)) {
M_IADD_IMM(s1, iptr->val.i, d);
} else {
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LADD(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.l >= -32768) && (iptr->val.l <= 32767)) {
M_LADD_IMM(s1, iptr->val.l, d);
} else {
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ISUB(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.i >= -32767) && (iptr->val.i <= 32768)) {
M_IADD_IMM(s1, -iptr->val.i, d);
} else {
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSUB(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.l >= -32767) && (iptr->val.l <= 32768)) {
M_LADD_IMM(s1, -iptr->val.l, d);
} else {
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_IMUL(s1, s2);
M_MFLO(d);
M_NOP;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
ICONST(REG_ITMP2, iptr->val.i);
M_IMUL(s1, REG_ITMP2);
M_MFLO(d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LMUL(s1, s2);
M_MFLO(d);
M_NOP;
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
LCONST(REG_ITMP2, iptr->val.l);
M_LMUL(s1, REG_ITMP2);
M_MFLO(d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
gen_div_check(s2);
M_IDIV(s1, s2);
M_MFLO(d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
gen_div_check(s2);
M_LDIV(s1, s2);
M_MFLO(d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
gen_div_check(s2);
M_IDIV(s1, s2);
M_MFHI(d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
gen_div_check(s2);
M_LDIV(s1, s2);
M_MFHI(d);
case ICMD_LDIVPOW2: /* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSRA_IMM(s1, 63, REG_ITMP2);
M_LSRL_IMM(REG_ITMP2, 64 - iptr->val.i, REG_ITMP2);
M_LADD(s1, REG_ITMP2, REG_ITMP2);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ISLL(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ISLL_IMM(s1, iptr->val.i, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ISRA(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ISRA_IMM(s1, iptr->val.i, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ISRL(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ISRL_IMM(s1, iptr->val.i, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSLL(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSLL_IMM(s1, iptr->val.i, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSRA(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSRA_IMM(s1, iptr->val.i, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSRL(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LSRL_IMM(s1, iptr->val.i, d);
store_reg_to_var_int(iptr->dst, d);
break;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_AND(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.i >= 0) && (iptr->val.i <= 0xffff)) {
M_AND_IMM(s1, iptr->val.i, d);
} else {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if (s1 == d) {
M_MOV(s1, REG_ITMP1);
s1 = REG_ITMP1;
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.l >= 0) && (iptr->val.l <= 0xffff)) {
M_AND_IMM(s1, iptr->val.l, d);
} else {
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if (s1 == d) {
M_MOV(s1, REG_ITMP1);
s1 = REG_ITMP1;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_OR(s1,s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.i >= 0) && (iptr->val.i <= 0xffff)) {
M_OR_IMM(s1, iptr->val.i, d);
} else {
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.l >= 0) && (iptr->val.l <= 0xffff)) {
M_OR_IMM(s1, iptr->val.l, d);
} else {
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_XOR(s1, s2, d);
store_reg_to_var_int(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.i >= 0) && (iptr->val.i <= 0xffff)) {
M_XOR_IMM(s1, iptr->val.i, d);
} else {
/* val.l = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if ((iptr->val.l >= 0) && (iptr->val.l <= 0xffff)) {
M_XOR_IMM(s1, iptr->val.l, d);
} else {
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_CMPLT(s1, s2, REG_ITMP3);
M_CMPLT(s2, s1, REG_ITMP1);
M_LSUB(REG_ITMP1, REG_ITMP3, d);
case ICMD_FNEG: /* ..., value ==> ..., - value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_FNEG(s1, d);
store_reg_to_var_flt(iptr->dst, d);
break;
case ICMD_DNEG: /* ..., value ==> ..., - value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_DNEG(s1, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_FADD(s1, s2, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_DADD(s1, s2, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_FSUB(s1, s2, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_DSUB(s1, s2, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_FMUL(s1, s2, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_DMUL(s1, s2, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_FDIV(s1, s2, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_DDIV(s1, s2, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP3);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
M_FDIV(s1,s2, REG_FTMP3);
M_FLOORFL(REG_FTMP3, REG_FTMP3);
M_CVTLF(REG_FTMP3, REG_FTMP3);
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP3);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3);
M_DDIV(s1,s2, REG_FTMP3);
M_FLOORDL(REG_FTMP3, REG_FTMP3);
M_CVTLD(REG_FTMP3, REG_FTMP3);
case ICMD_I2F: /* ..., value ==> ..., (float) value */
case ICMD_L2F:
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_MOVLD(s1, d);
M_CVTLF(d, d);
store_reg_to_var_flt(iptr->dst, d);
case ICMD_I2D: /* ..., value ==> ..., (double) value */
case ICMD_L2D:
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_MOVLD(s1, d);
M_CVTLD(d, d);
store_reg_to_var_flt(iptr->dst, d);
case ICMD_F2I: /* ..., (float) value ==> ..., (int) value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_TRUNCFI(s1, REG_FTMP1);
M_MOVDI(REG_FTMP1, d);
M_NOP;
case ICMD_D2I: /* ..., (double) value ==> ..., (int) value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
M_TRUNCDI(s1, REG_FTMP1);
M_MOVDI(REG_FTMP1, d);
M_NOP;
case ICMD_F2L: /* ..., (float) value ==> ..., (long) value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
M_TRUNCFL(s1, REG_FTMP1);
M_MOVDL(REG_FTMP1, d);
M_NOP;
case ICMD_D2L: /* ..., (double) value ==> ..., (long) value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
M_TRUNCDL(s1, REG_FTMP1);
M_MOVDL(REG_FTMP1, d);
M_NOP;
case ICMD_F2D: /* ..., value ==> ..., (double) value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_CVTFD(s1, d);
store_reg_to_var_flt(iptr->dst, d);
break;
case ICMD_D2F: /* ..., value ==> ..., (double) value */
var_to_reg_flt(s1, src, REG_FTMP1);
- d = reg_of_var(rd, iptr->dst, REG_FTMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2);
M_CVTDF(s1, d);
store_reg_to_var_flt(iptr->dst, d);
break;
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
M_FCMPULEF(s1, s2);
M_FBT(3);
M_LADD_IMM(REG_ZERO, 1, d);
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
M_FCMPULED(s1, s2);
M_FBT(3);
M_LADD_IMM(REG_ZERO, 1, d);
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
M_FCMPOLTF(s1, s2);
M_FBF(3);
M_LSUB_IMM(REG_ZERO, 1, d);
var_to_reg_flt(s1, src->prev, REG_FTMP1);
var_to_reg_flt(s2, src, REG_FTMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1);
M_FCMPOLTD(s1, s2);
M_FBF(3);
M_LSUB_IMM(REG_ZERO, 1, d);
case ICMD_ARRAYLENGTH: /* ..., arrayref ==> ..., length */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
gen_nullptr_check(s1);
M_ILD(d, s1, OFFSET(java_arrayheader, size));
store_reg_to_var_int(iptr->dst, d);
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
var_to_reg_int(s1, src->prev, REG_ITMP1);
var_to_reg_int(s2, src, REG_ITMP2);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if (iptr->op1 == 0) {
gen_nullptr_check(s1);
gen_bound_check;
M_ALD(REG_ITMP1, REG_PV, disp);
switch (iptr->op1) {
case TYPE_INT:
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ILD_INTERN(d, REG_ITMP1, 0);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_LNG:
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LLD_INTERN(d, REG_ITMP1, 0);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_ADR:
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ALD_INTERN(d, REG_ITMP1, 0);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_FLT:
- d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
M_FLD_INTERN(d, REG_ITMP1, 0);
store_reg_to_var_flt(iptr->dst, d);
break;
case TYPE_DBL:
- d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
M_DLD_INTERN(d, REG_ITMP1, 0);
store_reg_to_var_flt(iptr->dst, d);
break;
switch (iptr->op1) {
case TYPE_INT:
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ILD(d, s1, a);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_LNG:
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_LLD(d, s1, a);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_ADR:
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
M_ALD(d, s1, a);
store_reg_to_var_int(iptr->dst, d);
break;
case TYPE_FLT:
- d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
M_FLD(d, s1, a);
store_reg_to_var_flt(iptr->dst, d);
break;
case TYPE_DBL:
- d = reg_of_var(rd, iptr->dst, REG_FTMP1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1);
M_DLD(d, s1, a);
store_reg_to_var_flt(iptr->dst, d);
break;
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
s3 = iptr->val.i;
if (iptr[1].opc == ICMD_ELSE_ICONST) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
s3 = iptr->val.i;
if (iptr[1].opc == ICMD_ELSE_ICONST) {
if ((s3 == 0) && (iptr[1].val.i == 1)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
s3 = iptr->val.i;
if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
s3 = iptr->val.i;
if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
s3 = iptr->val.i;
if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
/* val.i = constant */
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
s3 = iptr->val.i;
if ((iptr[1].opc == ICMD_ELSE_ICONST)) {
if ((s3 == 1) && (iptr[1].val.i == 0)) {
if (d != TYPE_VOID) {
if (IS_INT_LNG_TYPE(iptr->dst->type)) {
- s1 = reg_of_var(rd, iptr->dst, REG_RESULT);
+ s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT);
M_INTMOVE(REG_RESULT, s1);
store_reg_to_var_int(iptr->dst, s1);
} else {
- s1 = reg_of_var(rd, iptr->dst, REG_FRESULT);
+ s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FRESULT);
M_TFLTMOVE(iptr->dst->type, REG_FRESULT, s1);
store_reg_to_var_flt(iptr->dst, s1);
}
codegen_add_classcastexception_ref(cd, mcodeptr);
M_NOP;
}
- d = reg_of_var(rd, iptr->dst, s1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, s1);
} else {
var_to_reg_int(s1, src, rd->argintregs[0]);
M_NOP;
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, s1);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, s1);
}
M_INTMOVE(s1, d);
store_reg_to_var_int(iptr->dst, d);
#endif
var_to_reg_int(s1, src, REG_ITMP1);
- d = reg_of_var(rd, iptr->dst, REG_ITMP2);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2);
if (s1 == d) {
M_MOV(s1, REG_ITMP1);
s1 = REG_ITMP1;
codegen_add_fillinstacktrace_ref(cd, mcodeptr);
M_NOP;
- d = reg_of_var(rd, iptr->dst, REG_RESULT);
+ d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT);
M_INTMOVE(REG_RESULT, d);
store_reg_to_var_int(iptr->dst, d);
break;
dseg_createlinenumbertable(cd);
-#if 0
- {
- s4 *xcodeptr;
- branchref *bref;
-
- /* generate ArithmeticException stubs */
-
- xcodeptr = NULL;
-
- for (bref = cd->xdivrefs; bref != NULL; bref = bref->next) {
- gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
- bref->branchpos,
- (u1 *) mcodeptr - cd->mcodebase);
-
- MCODECHECK(100);
-
- if (xcodeptr != NULL) {
- M_BR(xcodeptr - mcodeptr);
- M_AADD_IMM(REG_PV, bref->branchpos - 4, REG_ITMP2_XPC); /* delay */
-
- } else {
- M_AADD_IMM(REG_PV, bref->branchpos - 4, REG_ITMP2_XPC);
-
- xcodeptr = mcodeptr;
-
- M_MOV(REG_PV, rd->argintregs[0]);
- M_MOV(REG_SP, rd->argintregs[1]);
-
- if (m->isleafmethod)
- M_MOV(REG_RA, rd->argintregs[2]);
- else
- M_ALD(rd->argintregs[2],
- REG_SP, parentargs_base * 8 - SIZEOF_VOID_P);
-
- M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-
- M_ASUB_IMM(REG_SP, 2 * 8, REG_SP);
- M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
- if (m->isleafmethod)
- M_AST(REG_RA, REG_SP, 1 * 8);
-
- a = dseg_addaddress(cd, stacktrace_inline_arithmeticexception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JSR(REG_RA, REG_ITMP3);
- M_NOP;
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- if (m->isleafmethod)
- M_ALD(REG_RA, REG_SP, 1 * 8);
-
- M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
- M_AADD_IMM(REG_SP, 2 * 8, REG_SP);
-
- a = dseg_addaddress(cd, asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JMP(REG_ITMP3);
- M_NOP;
- }
- }
-
- /* generate ArrayIndexOutOfBoundsException stubs */
-
- xcodeptr = NULL;
-
- for (bref = cd->xboundrefs; bref != NULL; bref = bref->next) {
- gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
- bref->branchpos,
- (u1 *) mcodeptr - cd->mcodebase);
-
- MCODECHECK(100);
-
- /* move index register into REG_ITMP1 */
-
- M_MOV(bref->reg, REG_ITMP1);
- M_AADD_IMM(REG_PV, bref->branchpos - 4, REG_ITMP2_XPC);
-
- if (xcodeptr != NULL) {
- M_BR(xcodeptr - mcodeptr);
- M_NOP;
-
- } else {
- xcodeptr = mcodeptr;
-
- M_MOV(REG_PV, rd->argintregs[0]);
- M_MOV(REG_SP, rd->argintregs[1]);
-
- if (m->isleafmethod)
- M_MOV(REG_RA, rd->argintregs[2]);
- else
- M_ALD(rd->argintregs[2],
- REG_SP, parentargs_base * 8 - SIZEOF_VOID_P);
-
- M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
- M_MOV(REG_ITMP1, rd->argintregs[4]);
-
- M_ASUB_IMM(REG_SP, 2 * 8, REG_SP);
- M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
- if (m->isleafmethod)
- M_AST(REG_RA, REG_SP, 1 * 8);
-
- a = dseg_addaddress(cd, stacktrace_inline_arrayindexoutofboundsexception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JSR(REG_RA, REG_ITMP3);
- M_NOP;
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- if (m->isleafmethod)
- M_ALD(REG_RA, REG_SP, 1 * 8);
-
- M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
- M_AADD_IMM(REG_SP, 2 * 8, REG_SP);
-
- a = dseg_addaddress(cd, asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JMP(REG_ITMP3);
- M_NOP;
- }
- }
-
- /* generate ArrayStoreException stubs */
-
- xcodeptr = NULL;
-
- for (bref = cd->xstorerefs; bref != NULL; bref = bref->next) {
- gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
- bref->branchpos,
- (u1 *) mcodeptr - cd->mcodebase);
-
- MCODECHECK(100);
-
- M_AADD_IMM(REG_PV, bref->branchpos - 4, REG_ITMP2_XPC);
-
- if (xcodeptr != NULL) {
- M_BR(xcodeptr - mcodeptr);
- M_NOP;
-
- } else {
- xcodeptr = mcodeptr;
-
- M_MOV(REG_PV, rd->argintregs[0]);
- M_MOV(REG_SP, rd->argintregs[1]);
- M_ALD(rd->argintregs[2],
- REG_SP, parentargs_base * 8 - SIZEOF_VOID_P);
- M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-
- M_ASUB_IMM(REG_SP, 1 * 8, REG_SP);
- M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
- a = dseg_addaddress(cd, stacktrace_inline_arraystoreexception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JSR(REG_RA, REG_ITMP3);
- M_NOP;
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
- M_AADD_IMM(REG_SP, 1 * 8, REG_SP);
-
- a = dseg_addaddress(cd, asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JMP(REG_ITMP3);
- M_NOP;
- }
- }
-
- /* generate ClassCastException stubs */
-
- xcodeptr = NULL;
-
- for (bref = cd->xcastrefs; bref != NULL; bref = bref->next) {
- gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
- bref->branchpos,
- (u1 *) mcodeptr - cd->mcodebase);
-
- MCODECHECK(100);
-
- M_AADD_IMM(REG_PV, bref->branchpos - 4, REG_ITMP2_XPC);
-
- if (xcodeptr != NULL) {
- M_BR(xcodeptr - mcodeptr);
- M_NOP;
-
- } else {
- xcodeptr = mcodeptr;
-
- M_MOV(REG_PV, rd->argintregs[0]);
- M_MOV(REG_SP, rd->argintregs[1]);
-
- if (m->isleafmethod)
- M_MOV(REG_RA, rd->argintregs[2]);
- else
- M_ALD(rd->argintregs[2],
- REG_SP, parentargs_base * 8 - SIZEOF_VOID_P);
-
- M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-
- M_ASUB_IMM(REG_SP, 2 * 8, REG_SP);
- M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
- if (m->isleafmethod)
- M_AST(REG_RA, REG_SP, 1 * 8);
-
- a = dseg_addaddress(cd, stacktrace_inline_classcastexception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JSR(REG_RA, REG_ITMP3);
- M_NOP;
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- if (m->isleafmethod)
- M_ALD(REG_RA, REG_SP, 1 * 8);
-
- M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
- M_AADD_IMM(REG_SP, 2 * 8, REG_SP);
-
- a = dseg_addaddress(cd, asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JMP(REG_ITMP3);
- M_NOP;
- }
- }
-
- /* generate NullPointerException stubs */
-
- xcodeptr = NULL;
-
- for (bref = cd->xnullrefs; bref != NULL; bref = bref->next) {
- gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
- bref->branchpos,
- (u1 *) mcodeptr - cd->mcodebase);
-
- MCODECHECK(100);
-
- M_AADD_IMM(REG_PV, bref->branchpos - 4, REG_ITMP2_XPC);
-
- if (xcodeptr != NULL) {
- M_BR(xcodeptr - mcodeptr);
- M_NOP;
-
- } else {
- xcodeptr = mcodeptr;
-
- M_MOV(REG_PV, rd->argintregs[0]);
- M_MOV(REG_SP, rd->argintregs[1]);
-
- if (m->isleafmethod)
- M_MOV(REG_RA, rd->argintregs[2]);
- else
- M_ALD(rd->argintregs[2],
- REG_SP, parentargs_base * 8 - SIZEOF_VOID_P);
-
- M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-
- M_ASUB_IMM(REG_SP, 2 * 8, REG_SP);
- M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
- if (m->isleafmethod)
- M_AST(REG_RA, REG_SP, 1 * 8);
-
- a = dseg_addaddress(cd, stacktrace_inline_nullpointerexception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JSR(REG_RA, REG_ITMP3);
- M_NOP;
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- if (m->isleafmethod)
- M_ALD(REG_RA, REG_SP, 1 * 8);
-
- M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
- M_AADD_IMM(REG_SP, 2 * 8, REG_SP);
-
- a = dseg_addaddress(cd, asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JMP(REG_ITMP3);
- M_NOP;
- }
- }
-
- /* generate exception check stubs */
-
- xcodeptr = NULL;
-
- for (bref = cd->xexceptionrefs; bref != NULL; bref = bref->next) {
- gen_resolvebranch((u1 *) cd->mcodebase + bref->branchpos,
- bref->branchpos,
- (u1 *) mcodeptr - cd->mcodebase);
-
- MCODECHECK(100);
-
- if (xcodeptr != NULL) {
- M_BR(xcodeptr - mcodeptr);
- M_AADD_IMM(REG_PV, bref->branchpos - 4, REG_ITMP2_XPC); /* delay */
-
- } else {
- M_AADD_IMM(REG_PV, bref->branchpos - 4, REG_ITMP2_XPC);
-
- xcodeptr = mcodeptr;
-
- M_MOV(REG_PV, rd->argintregs[0]);
- M_MOV(REG_SP, rd->argintregs[1]);
- M_ALD(rd->argintregs[2],
- REG_SP, parentargs_base * 8 - SIZEOF_VOID_P);
- M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-
- M_ASUB_IMM(REG_SP, 1 * 8, REG_SP);
- M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
- a = dseg_addaddress(cd, stacktrace_inline_fillInStackTrace);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JSR(REG_RA, REG_ITMP3);
- M_NOP;
- M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
- M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
- M_AADD_IMM(REG_SP, 1 * 8, REG_SP);
-
- a = dseg_addaddress(cd, asm_handle_exception);
- M_ALD(REG_ITMP3, REG_PV, a);
- M_JMP(REG_ITMP3);
- M_NOP;
- }
- }
-#endif
-
/* generate exception and patcher stubs */
{
int i;
- replacementpoint = cd->code->rplpoints;
- for (i=0; i<cd->code->rplpointcount; ++i, ++replacementpoint) {
+ replacementpoint = jd->code->rplpoints;
+
+ for (i = 0; i < jd->code->rplpointcount; ++i, ++replacementpoint) {
/* check code segment size */
MCODECHECK(100);
}
}
- codegen_finish(m, cd, (s4) ((u1 *) mcodeptr - cd->mcodebase));
-
- docacheflush((void *) cd->code->entrypoint, ((u1 *) mcodeptr - cd->mcodebase));
+ codegen_finish(jd, (s4) ((u1 *) mcodeptr - cd->mcodebase));
/* everything's ok */
M_JMP(REG_PV);
M_NOP;
- (void) docacheflush((void *) s, (char *) mcodeptr - (char *) s);
+ md_cacheflush(s, (s4) ((u1 *) mcodeptr - s));
#if defined(ENABLE_STATISTICS)
if (opt_stat)
*******************************************************************************/
-u1 *createnativestub(functionptr f, methodinfo *m, codegendata *cd,
- registerdata *rd, methoddesc *nmd)
+u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
{
- s4 *mcodeptr; /* code generation pointer */
- s4 stackframesize; /* size of stackframe if needed */
- methoddesc *md;
- s4 nativeparams;
- s4 i, j; /* count variables */
- s4 t;
- s4 s1, s2, disp;
- s4 funcdisp; /* displacement of the function */
-
+ methodinfo *m;
+ codegendata *cd;
+ registerdata *rd;
+ s4 *mcodeptr; /* code generation pointer */
+ s4 stackframesize; /* size of stackframe if needed */
+ methoddesc *md;
+ s4 nativeparams;
+ s4 i, j; /* count variables */
+ s4 t;
+ s4 s1, s2, disp;
+ s4 funcdisp; /* displacement of the function */
+
+ /* get required compiler data */
+
+ m = jd->m;
+ cd = jd->cd;
+ rd = jd->rd;
/* initialize variables */
md = m->parseddesc;
nativeparams = (m->flags & ACC_STATIC) ? 2 : 1;
-
/* calculate stack frame size */
stackframesize =
1 + /* for saving return address */
nmd->memuse;
-
/* create method header */
#if SIZEOF_VOID_P == 4
mcodeptr = (s4 *) cd->mcodeptr;
-
/* generate stub code */
M_LDA(REG_SP, REG_SP, -stackframesize * 8); /* build up stackframe */
M_AST(REG_RA, REG_SP, stackframesize * 8 - SIZEOF_VOID_P); /* store ra */
-
/* call trace function */
if (opt_verbosecall) {
M_LDA(REG_SP, REG_SP, (1 + INT_ARG_CNT + FLT_ARG_CNT) * 8);
}
-
/* get function address (this must happen before the stackframeinfo) */
funcdisp = dseg_addaddress(cd, f);
}
}
- codegen_finish(m, cd, (s4) ((u1 *) mcodeptr - cd->mcodebase));
-
- docacheflush((void *) cd->code->entrypoint, ((u1 *) mcodeptr - cd->mcodebase));
+ codegen_finish(jd, (s4) ((u1 *) mcodeptr - cd->mcodebase));
- return cd->code->entrypoint;
+ return jd->code->entrypoint;
}