* src/vm/jit/powerpc64/linux/md-abi.c (md_param_alloc): Began
authortbfg <none@none>
Mon, 13 Nov 2006 21:43:41 +0000 (21:43 +0000)
committertbfg <none@none>
Mon, 13 Nov 2006 21:43:41 +0000 (21:43 +0000)
fixing ABI issues. It is not correct now, but fptest runs now.
Remaining issues in java<->native mainly stack offsets.

* src/vm/jit/powerpc64/emit.c (emit_load): Removed M_ILD case.
(emit_store): Removed M_FST case. There is no M_FST expect for
accessing c structs, internally everything is done using M_DLD
and M_DST, M_FST would convert the values.

* src/vm/jit/powerpc64/codegen.c (codegen): Removed all M_FST and
M_FLD.

* src/vm/jit/powerpc64/asmpart.S (asm_vm_call_method): Fixed
argument passing on stack.

src/vm/jit/powerpc64/asmpart.S
src/vm/jit/powerpc64/codegen.c
src/vm/jit/powerpc64/emit.c
src/vm/jit/powerpc64/linux/md-abi.c

index ff0d14f137bd2af60ef2e1f54dabd890cf95c60e..374ad30fabff0d8a24be3d2396e43b45ceb0d5cf 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Christian Thalinger
             Edwin Steiner
 
-   $Id: asmpart.S 5940 2006-11-09 09:59:28Z tbfg $
+   $Id: asmpart.S 5978 2006-11-13 21:43:41Z tbfg $
 
 */
 
@@ -306,7 +306,7 @@ L_register_copy_done:
        mr      itmp1,t5                  /* restore argument block pointer       */
 
        slwi    t4,itmp3,3                /* XXX use 8-bytes slots for now        */
-       addi    t4,t4,LA_SIZE             /* add size of linkage area             */
+       addi    t4,t4,LA_SIZE+PA_SIZE     /* add size of linkage area             */
 
 #if defined(__DARWIN__)
        slwi    t5,t7,2                   /* add stack space for arguments        */
@@ -362,13 +362,13 @@ L_stack_handle_float:
        bne     L_stack_handle_double
 
        lfs     ftmp3,offvmargdata(itmp1) /* get float argument                   */
-       stfs    ftmp3,4(t6)               /* and store it on the stack            */
+       stfd    ftmp3,64(t6)              /* and store it on the stack, 56: first 8 slots reserved for r3-r10 */
        addi    t6,t6,8                   /* increase temporary sp by 1 slot      */
        b       L_stack_copy_loop
 
 L_stack_handle_double:
        lfd     ftmp3,offvmargdata(itmp1) /* get double argument                  */
-       stfd    ftmp3,0(t6)               /* and store it on the stack            */
+       stfd    ftmp3,64(t6)               /* and store it on the stack, 56: first 8 slots reserved for r3-r10 */
        addi    t6,t6,8                   /* increase temporary sp by 1 slots     */
        b       L_stack_copy_loop
 
@@ -410,8 +410,8 @@ L_asm_vm_call_method_return:
        ld      pv,11*8(sp)               /* save PV register                     */
 
        ld      itmp3,12*8(sp)
-       lfd     ftmp1,14*8(sp)            /* registers f14-f31 are callee saved   */
-       lfd     ftmp2,16*8(sp)
+       lfd     ftmp1,13*8(sp)            /* registers f14-f31 are callee saved   */
+       lfd     ftmp2,14*8(sp)
 
 #if defined(__DARWIN__)
        lwz     t1,18*4(r1)
@@ -429,7 +429,7 @@ L_asm_vm_call_method_return:
        lfd     ft4,34*4(r1)
        lfd     ft5,36*4(r1)
 #else
-       RESTORE_TEMPORARY_REGISTERS(18)   /* the offset has to be even            */
+       RESTORE_TEMPORARY_REGISTERS(15)   /* the offset has to be even            */
 #endif
 
        ld     r0,40*8+LA_LR_OFFSET(r1)
index e1f003812f61ed935f6156e3d868ca3431c3bad2..58cde8997b1a08dd1aadda28992f10197a2c8a39 100644 (file)
@@ -32,7 +32,7 @@
             Edwin Steiner
            Roland Lezuo
 
-   $Id: codegen.c 5957 2006-11-12 12:57:59Z twisti $
+   $Id: codegen.c 5978 2006-11-13 21:43:41Z tbfg $
 
 */
 
@@ -242,12 +242,20 @@ bool codegen(jitdata *jd)
                                if (!IS_INMEMORY(var->flags)) {      /* reg arg -> register   */
                                        M_FLTMOVE(s2, var->vv.regoff);
                                } else {                                         /* reg arg -> spilled    */
-                                       M_DST(s2, REG_SP, var->vv.regoff * 8);
+                                       if (IS_2_WORD_TYPE(t)) {
+                                               M_DST(s2, REG_SP, var->vv.regoff * 8);
+                                       } else {
+                                               M_DST(s2, REG_SP, var->vv.regoff * 8);  /*  F XXX */
+                                       }
                                }
 
                        } else {                                 /* stack arguments       */
                                if (!(var->flags & INMEMORY)) {      /* stack-arg -> register */
-                                       M_DLD(var->vv.regoff, REG_SP, (cd->stackframesize + s1) * 8);
+                                       if (IS_2_WORD_TYPE(t)) {
+                                               M_DLD(var->vv.regoff, REG_SP, (cd->stackframesize + s1) * 8);
+                                       } else {
+                                               M_DLD(var->vv.regoff, REG_SP, (cd->stackframesize + s1) * 8);
+                                       }
                                } else {                             /* stack-arg -> spilled  */
                                        var->vv.regoff = cd->stackframesize + s1;
                                }
@@ -2125,7 +2133,6 @@ nowperformreturn:
                        goto gen_method;
 
                case ICMD_INVOKESTATIC: /* ..., [arg1, [arg2 ...]] ==> ...            */
-
                case ICMD_INVOKESPECIAL:/* ..., objectref, [arg1, [arg2 ...]] ==> ... */
                case ICMD_INVOKEVIRTUAL:/* op1 = arg count, val.a = method pointer    */
                case ICMD_INVOKEINTERFACE:
@@ -2171,7 +2178,7 @@ gen_method:
                                                if (IS_2_WORD_TYPE(var->type))
                                                        M_DST(d, REG_SP, md->params[s3].regoff * 8);
                                                else
-                                                       M_FST(d, REG_SP, md->params[s3].regoff * 8);
+                                                       M_DST(d, REG_SP, md->params[s3].regoff * 8);    /* F XXX */
                                        }
                                }
                        } /* end of for */
@@ -3048,7 +3055,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                nmd->paramcount  + 
                nmd->memuse;
 
-       cd->stackframesize = (cd->stackframesize + 3) & ~3; /* keep stack 16-byte aligned */
+/*     cd->stackframesize = (cd->stackframesize + 3) & ~3;*/ /* keep stack 16-byte aligned */
 
        /* create method header */
 
@@ -3095,7 +3102,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                if (IS_INT_LNG_TYPE(t)) {
                        if (!md->params[i].inmemory) {
                                s1 = md->params[i].regoff;
-                               M_LST(rd->argintregs[s1], REG_SP, LA_SIZE + PA_SIZE + 4 * 8 + j * 8);
+                               M_LST(rd->argintregs[s1], REG_SP, LA_SIZE + PA_SIZE + 4*8 + j * 8);
                                j++;
                        }
                }
@@ -3105,7 +3112,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
                        if (!md->params[i].inmemory) {
                                s1 = md->params[i].regoff;
-                               M_DST(rd->argfltregs[s1], REG_SP, LA_SIZE + PA_SIZE + 4 * 8 + j * 8);
+                               M_DST(rd->argfltregs[s1], REG_SP, LA_SIZE + PA_SIZE + 4*8 + j * 8);
                                j++;
                        }
                }
@@ -3183,13 +3190,12 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                                s1 = md->params[i].regoff + cd->stackframesize;
                                s2 = nmd->params[j].regoff;
 
-                               if (IS_2_WORD_TYPE(t)) {
-                                       M_DLD(REG_FTMP1, REG_SP, s1 * 8);
-                                       M_DST(REG_FTMP1, REG_SP, s2 * 8);
+                               M_DLD(REG_FTMP1, REG_SP, s1 * 8);
 
+                               if (IS_2_WORD_TYPE(t)) {        
+                                       M_DST(REG_FTMP1, REG_SP, s2 * 8);
                                } else {
-                                       M_FLD(REG_FTMP1, REG_SP, s1 * 8);
-                                       M_FST(REG_FTMP1, REG_SP, s2 * 8);
+                                       M_FST(REG_FTMP1, REG_SP, s2 * 8 + 4);
                                }
                        }
                }
@@ -3225,10 +3231,11 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                        M_LST(REG_RESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);
                }
                else {
-                       if (IS_2_WORD_TYPE(md->returntype.type))
+/*                     if (IS_2_WORD_TYPE(md->returntype.type)) */
                                M_DST(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);
-                       else
-                               M_FST(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);  /* FIXME, needed ?*/
+/*                     else
+                               M_FST(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);  */ /* FIXME, needed F XXX?*/
+                       
                }
        }
 
@@ -3255,10 +3262,11 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                        M_LLD(REG_RESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);
                }
                else {
-                       if (IS_2_WORD_TYPE(md->returntype.type))
+/*                     if (IS_2_WORD_TYPE(md->returntype.type)) */
                                M_DLD(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);
-                       else
-                               M_FLD(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8);
+/*                     else
+                               M_FLD(REG_FRESULT, REG_SP, LA_SIZE + PA_SIZE + 1 * 8); F XXX
+                               */
                }
        }
 
index 47db1bc6f42c1559beee77cb46dfeb75b7e353ee..7e46743ae911d68ded581348a2642be68ea244e7 100644 (file)
@@ -75,11 +75,6 @@ s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
                                M_FLD(tempreg, REG_SP, disp);
                }
                else {
-               /*      if (IS_2_WORD_TYPE(src->type))
-                               M_LLD(tempreg, REG_SP, disp);
-                       else
-                               M_ILD(tempreg, REG_SP, disp);
-               */
                        M_LLD(tempreg, REG_SP, disp);
                }
 
@@ -110,10 +105,10 @@ void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
                COUNT_SPILLS;
 
                if (IS_FLT_DBL_TYPE(dst->type)) {
-                       if (IS_2_WORD_TYPE(dst->type))
+/*                     if (IS_2_WORD_TYPE(dst->type))*/
                                M_DST(d, REG_SP, dst->vv.regoff * 8);
-                       else
-                               M_FST(d, REG_SP, dst->vv.regoff * 8);
+/*                     else
+                               M_DST(d, REG_SP, dst->vv.regoff * 8); F XXX */
                }
                else {
                        M_LST(d, REG_SP, dst->vv.regoff * 8);
index 6e8c68272b7bda3068bce80a5beb023ba066bd6a..a48a332e9ad18bc49ce7b89a64520a982d001281 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: 
 
-   $Id: md-abi.c 5940 2006-11-09 09:59:28Z tbfg $
+   $Id: md-abi.c 5978 2006-11-13 21:43:41Z tbfg $
 
 */
 
@@ -41,6 +41,7 @@
 #include "vm/descriptor.h"
 #include "vm/global.h"
 #include "vm/jit/abi.h"
+#include <assert.h>
 
 
 #define CACAO_ALIGN(a)    do { if ((a) & 1) (a)++; } while (0)
@@ -49,7 +50,7 @@
 /* register descripton array **************************************************/
 
 s4 nregdescint[] = {
-       /* zero,      sp,     TOC,   a0/v0,   a0/v1,      a2,      a3,      a4,   */
+       /* zero,      sp,     TOC,   a0/v0,   a1/v1,      a2,      a3,      a4,   */
        REG_RES, REG_RES, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
 
        /*   a5,      a6,      a7,   itmp1,   itmp2, NO(SYS),      pv,      s0,   */
@@ -112,13 +113,17 @@ void md_param_alloc(methoddesc *md)
        s4         i;
        s4         iarg;
        s4         farg;
-       s4         stacksize;
+       s4         arg;
+       s4         stacksize, stackcount;
+
 
        /* set default values */
 
        iarg = 0;
        farg = 0;
+       arg = 0;
        stacksize = LA_SIZE_IN_POINTERS + PA_SIZE_IN_POINTERS;
+       stackcount = 0;
 
        /* get params field of methoddesc */
 
@@ -129,43 +134,39 @@ void md_param_alloc(methoddesc *md)
                case TYPE_LNG:
                case TYPE_INT:
                case TYPE_ADR:
-                       if (iarg < INT_ARG_CNT) {
+                       if (arg < INT_ARG_CNT) {
                                pd->inmemory = false;
                                pd->regoff = iarg;
                                iarg++;
                        } else {
                                pd->inmemory = true;
-                               pd->regoff = stacksize;
-                               stacksize++;
+                               pd->regoff = stacksize + stackcount;
+                               stackcount++;
                        }
                        break;
                case TYPE_FLT:
-                       if (farg < FLT_ARG_CNT) {
-                               pd->inmemory = false;
-                               pd->regoff = farg;
-                               farg++;
-                       } else {
-                               pd->inmemory = true;
-                               pd->regoff = stacksize;
-                               stacksize++;
-                       }
-                       break;
                case TYPE_DBL:
                        if (farg < FLT_ARG_CNT) {
                                pd->inmemory = false;
                                pd->regoff = farg;
                                farg++;
+                               if (arg < INT_ARG_CNT) {
+                                       iarg++;         /* yes, that is true, floating arguments take int register slots away */
+                                       stackcount++;
+                               }
                        } else {
-                               CACAO_ALIGN(stacksize);
                                pd->inmemory = true;
-                               pd->regoff = stacksize;
-                               stacksize += 2;
+                               pd->regoff = stacksize + stackcount + 1;
+                               stackcount++;
                        }
                        break;
+               default:
+                       assert(0);
                }
+               arg++;
        }
 
-       /* Since R3/R4, F1 (==A0/A1, A0) are used for passing return values, this */
+       /* Since R3, F1 (==A0, A0) are used for passing return values, this */
        /* argument register usage has to be regarded, too                        */
        if (IS_INT_LNG_TYPE(md->returntype.type)) {
                if (iarg < 1)
@@ -179,7 +180,7 @@ void md_param_alloc(methoddesc *md)
 
        md->argintreguse = iarg;
        md->argfltreguse = farg;
-       md->memuse = stacksize;
+       md->memuse = stacksize + stackcount;
 }