Added some missing vim modelines.
[cacao.git] / src / vm / jit / s390 / md-abi.c
index 916ba099b9222edeeeac841f78af74445926deea..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:
-
 */
 
 
 #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
 };
 
@@ -71,15 +67,16 @@ 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[] = {
-       REG_ARG, REG_TMP, REG_ARG, REG_TMP, REG_SAV, REG_TMP, REG_SAV, REG_TMP,
+       REG_ARG, REG_TMP, REG_ARG, REG_TMP, REG_RES, REG_TMP, REG_RES, REG_TMP,
        REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
     REG_END
 };
@@ -90,8 +87,7 @@ const s4 abi_registers_float_argument[] = {
 };
 
 const s4 abi_registers_float_saved[] = {
-       4, /* f4 */
-       6  /* f6 */
+       -1 /* none */
 };
 
 const s4 abi_registers_float_temporary[] = {
@@ -118,10 +114,11 @@ const s4 abi_registers_float_temporary[] = {
    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
 
 *******************************************************************************/
 
-static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2w)
+static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2w, s4 stackoff)
 {
        paramdesc *pd;
        s4         i;
@@ -151,7 +148,7 @@ static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2
                        }
                        else {
                                pd->inmemory  = true;
-                               pd->regoff    = stacksize * slot;
+                               pd->regoff    = (stacksize * slot) + stackoff;
                                pd->index     = stacksize;
                                stacksize += slots1w;
                        }
@@ -170,7 +167,7 @@ static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2
                        else {
                                /* _ALIGN(stacksize); */
                                pd->inmemory  = true;
-                               pd->regoff    = stacksize * slot;
+                               pd->regoff    = (stacksize * slot) + stackoff;
                                pd->index     = stacksize;
                                iarg          = INT_ARG_CNT;
                                stacksize    += slots2w;
@@ -186,7 +183,7 @@ static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2
                        }
                        else {
                                pd->inmemory  = true;
-                               pd->regoff    = stacksize * slot;
+                               pd->regoff    = (stacksize * slot) + stackoff;
                                pd->index     = stacksize;
                                stacksize += slots1w;
                        }
@@ -202,7 +199,7 @@ static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2
                        else {
                                /* _ALIGN(stacksize); */
                                pd->inmemory  = true;
-                               pd->regoff    = stacksize * slot;
+                               pd->regoff    = (stacksize * slot) + stackoff;
                                pd->index     = stacksize;
                                stacksize    += slots2w;
                        }
@@ -236,12 +233,12 @@ static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2
 
 void md_param_alloc(methoddesc *md)
 {
-       md_param_alloc_intern(md, 8, 1, 1);
+       md_param_alloc_intern(md, 8, 1, 1, 0);
 }
 
 void md_param_alloc_native(methoddesc *md)
 {
-       md_param_alloc_intern(md, 4, 1, 2);
+       md_param_alloc_intern(md, 4, 1, 2, 96);
 }
 
 
@@ -266,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;
 
@@ -283,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. */
 
@@ -326,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:
  */