* Removed all Id tags.
[cacao.git] / src / vm / jit / s390 / md-abi.c
index 71627d623b9139cc7320bbac91748c6d1b112445..916ba099b9222edeeeac841f78af74445926deea 100644 (file)
@@ -28,8 +28,6 @@
 
    Changes:
 
-   $Id: md-abi.c 8115 2007-06-20 19:14:05Z michi $
-
 */
 
 
@@ -81,7 +79,7 @@ const s4 abi_registers_integer_temporary[] = {
 };
 
 s4 nregdescfloat[] = {
-       REG_ARG, REG_TMP, REG_ARG, REG_TMP, REG_RES, REG_TMP, REG_RES, REG_TMP,
+       REG_ARG, REG_TMP, REG_ARG, REG_TMP, REG_SAV, REG_TMP, REG_SAV, REG_TMP,
        REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
     REG_END
 };
@@ -92,8 +90,8 @@ const s4 abi_registers_float_argument[] = {
 };
 
 const s4 abi_registers_float_saved[] = {
-       /* nothing */
-       -1
+       4, /* f4 */
+       6  /* f6 */
 };
 
 const s4 abi_registers_float_temporary[] = {
@@ -111,13 +109,19 @@ const s4 abi_registers_float_temporary[] = {
        15  /* f15/ft11 */
 };
 
-/* md_param_alloc **************************************************************
+/* md_param_alloc_intern *******************************************************
+
+   Allocates parameters to registers or stackslots for both native and java
+   methods.
 
-   XXX
+   --- in:
+   slot: size in bytes of a stack slot
+   slots1w: number of stack slots used by a 1 word type parameter
+   slots2w: number of stack slots used by a 2 word type parameter
 
 *******************************************************************************/
 
-void md_param_alloc(methoddesc *md)
+static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2w)
 {
        paramdesc *pd;
        s4         i;
@@ -142,12 +146,14 @@ void md_param_alloc(methoddesc *md)
                        if (iarg < INT_ARG_CNT) {
                                pd->inmemory  = false;
                                pd->regoff    = abi_registers_integer_argument[iarg]; 
+                               pd->index     = iarg;
                                iarg++;
                        }
                        else {
                                pd->inmemory  = true;
-                               pd->regoff    = stacksize * 4;
-                               stacksize++;
+                               pd->regoff    = stacksize * slot;
+                               pd->index     = stacksize;
+                               stacksize += slots1w;
                        }
                        break;
 
@@ -158,14 +164,16 @@ void md_param_alloc(methoddesc *md)
                                pd->regoff    = 
                                        PACK_REGS(abi_registers_integer_argument[iarg + 1], 
                                                          abi_registers_integer_argument[iarg]); 
+                               pd->index     = PACK_REGS(iarg + 1, iarg);
                                iarg += 2;
                        }
                        else {
                                /* _ALIGN(stacksize); */
                                pd->inmemory  = true;
-                               pd->regoff    = stacksize * 4;
+                               pd->regoff    = stacksize * slot;
+                               pd->index     = stacksize;
                                iarg          = INT_ARG_CNT;
-                               stacksize    += 2;
+                               stacksize    += slots2w;
                        }
                        break;
 
@@ -173,12 +181,14 @@ void md_param_alloc(methoddesc *md)
                        if (farg < FLT_ARG_CNT) {
                                pd->inmemory  = false;
                                pd->regoff    = abi_registers_float_argument[farg]; 
+                               pd->index     = farg;
                                farg++;
                        }
                        else {
                                pd->inmemory  = true;
-                               pd->regoff    = stacksize * 4;
-                               stacksize++;
+                               pd->regoff    = stacksize * slot;
+                               pd->index     = stacksize;
+                               stacksize += slots1w;
                        }
                        break;
 
@@ -186,13 +196,15 @@ void md_param_alloc(methoddesc *md)
                        if (farg < FLT_ARG_CNT) {
                                pd->inmemory  = false;
                                pd->regoff    = abi_registers_float_argument[farg]; 
+                               pd->index     = farg;
                                farg++;
                        }
                        else {
                                /* _ALIGN(stacksize); */
                                pd->inmemory  = true;
-                               pd->regoff    = stacksize * 4;
-                               stacksize    += 2;
+                               pd->regoff    = stacksize * slot;
+                               pd->index     = stacksize;
+                               stacksize    += slots2w;
                        }
                        break;
 
@@ -222,12 +234,14 @@ void md_param_alloc(methoddesc *md)
        md->memuse = stacksize;
 }
 
-void md_param_alloc_native(methoddesc *md)
+void md_param_alloc(methoddesc *md)
 {
-       /* On PowerPC we use the same ABI for JIT method calls as for
-        *        native method calls. */
+       md_param_alloc_intern(md, 8, 1, 1);
+}
 
-       md_param_alloc(md);
+void md_param_alloc_native(methoddesc *md)
+{
+       md_param_alloc_intern(md, 4, 1, 2);
 }