Added some missing vim modelines.
[cacao.git] / src / vm / jit / s390 / md-abi.c
index ea839e5c25119df0d7e5dd1f196f6b3615f5f98b..52bb25a722300cb546284407851b87b6028cfef6 100644 (file)
@@ -1,9 +1,7 @@
-/* src/vm/jit/x86_64/md-abi.c - functions for x86_64 Linux ABI
+/* src/vm/jit/s390/md-abi.c - s390 Linux ABI
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: md-abi.c 7918 2007-05-20 20:42:18Z michi $
-
 */
 
 
 #include "config.h"
+
+#include "vm/descriptor.hpp"
+#include "vm/global.h"
 #include "vm/types.h"
 
+#include "vm/jit/jit.hpp"
+#include "vm/jit/stack.h"
+
 #include "vm/jit/s390/md-abi.h"
 
-#include "vmcore/descriptor.h"
-#include "vm/global.h"
-#include "vm/jit/jit.h"
+#include <assert.h>
 
 
 /* register descripton array **************************************************/
 
 s4 nregdescint[] = {
-       /*   r0,   itmp1,      a0,      a1,      a2,      a3,      a4,      s0, */
-       REG_TMP, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_SAV,
-       /*   s1,      s2,      s3,      s4,   itmp2,    pv,  ra/itmp3,      sp */
-       REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_RES, REG_RES, REG_RES, REG_RES,
+       /*itmp3,   itmp1,      a0,      a1,      a2,      a3,      a4,      s0, */
+       REG_RES, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_SAV,
+       /*   s1,      s2,      s3,      s4,      s5,    pv,  ra/itmp2,      sp */
+       REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_RES, REG_RES, REG_RES,
     REG_END
 };
 
@@ -73,11 +67,12 @@ const s4 abi_registers_integer_saved[] = {
        8,  /* r8/s1 */
        9,  /* r9/s2 */
        10, /* r10/s3 */
-       11  /* r11/s4 */
+       11, /* r11/s4 */
+       12  /* r12/s5 */
 };
 
 const s4 abi_registers_integer_temporary[] = {
-       0, /* r0 */
+       -1 /* none */
 };
 
 s4 nregdescfloat[] = {
@@ -92,8 +87,7 @@ const s4 abi_registers_float_argument[] = {
 };
 
 const s4 abi_registers_float_saved[] = {
-       /* nothing */
-       -1
+       -1 /* none */
 };
 
 const s4 abi_registers_float_temporary[] = {
@@ -111,13 +105,20 @@ const s4 abi_registers_float_temporary[] = {
        15  /* f15/ft11 */
 };
 
-/* md_param_alloc **************************************************************
+/* md_param_alloc_intern *******************************************************
 
-   XXX
+   Allocates parameters to registers or stackslots for both native and java
+   methods.
+
+   --- 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
+   stackoff: offset on stack frame where to start placing arguments
 
 *******************************************************************************/
 
-void md_param_alloc(methoddesc *md)
+static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2w, s4 stackoff)
 {
        paramdesc *pd;
        s4         i;
@@ -142,12 +143,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;
-                               stacksize++;
+                               pd->regoff    = (stacksize * slot) + stackoff;
+                               pd->index     = stacksize;
+                               stacksize += slots1w;
                        }
                        break;
 
@@ -158,14 +161,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;
+                               pd->regoff    = (stacksize * slot) + stackoff;
+                               pd->index     = stacksize;
                                iarg          = INT_ARG_CNT;
-                               stacksize    += 2;
+                               stacksize    += slots2w;
                        }
                        break;
 
@@ -173,12 +178,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;
-                               stacksize++;
+                               pd->regoff    = (stacksize * slot) + stackoff;
+                               pd->index     = stacksize;
+                               stacksize += slots1w;
                        }
                        break;
 
@@ -186,13 +193,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;
-                               stacksize    += 2;
+                               pd->regoff    = (stacksize * slot) + stackoff;
+                               pd->index     = stacksize;
+                               stacksize    += slots2w;
                        }
                        break;
 
@@ -222,12 +231,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, 0);
+}
 
-       md_param_alloc(md);
+void md_param_alloc_native(methoddesc *md)
+{
+       md_param_alloc_intern(md, 4, 1, 2, 96);
 }
 
 
@@ -252,16 +263,18 @@ void md_param_alloc_native(methoddesc *md)
 
 *******************************************************************************/
 
-void md_return_alloc(jitdata *jd, stackptr stackslot)
+void md_return_alloc(jitdata *jd, stackelement_t* stackslot)
 {
        methodinfo   *m;
+       codeinfo     *code;
        registerdata *rd;
        methoddesc   *md;
 
        /* get required compiler data */
 
-       m  = jd->m;
-       rd = jd->rd;
+       m    = jd->m;
+       code = jd->code;
+       rd   = jd->rd;
 
        md = m->parseddesc;
 
@@ -269,7 +282,7 @@ void md_return_alloc(jitdata *jd, stackptr stackslot)
           their argument register -> so leafmethods with paramcount > 0
           could already use R3 == a00! */
 
-       if (!jd->isleafmethod || (md->paramcount == 0)) {
+       if (!code_is_leafmethod(code) || (md->paramcount == 0)) {
                /* Only precolor the stackslot, if it is not a SAVEDVAR <->
                   has not to survive method invokations. */
 
@@ -312,4 +325,5 @@ void md_return_alloc(jitdata *jd, stackptr stackslot)
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */