-/* 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 7403 2007-02-25 21:31:58Z pm $
-
*/
#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 <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
};
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
};
const s4 abi_registers_float_argument[] = {
0, /* f0/fa0 */
- 1 /* f2/fa2 */
+ 2 /* f2/fa2 */
};
const s4 abi_registers_float_saved[] = {
- 4, /* f4/fs0 */
- 6 /* f6/fs0 */
+ -1 /* none */
};
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;
switch (md->paramtypes[i].type) {
case TYPE_INT:
case TYPE_ADR:
- case TYPE_LNG:
if (iarg < INT_ARG_CNT) {
- pd->inmemory = false;
- pd->regoff = iarg;
+ pd->inmemory = false;
+ pd->regoff = abi_registers_integer_argument[iarg];
+ pd->index = iarg;
+ iarg++;
}
else {
- pd->inmemory = true;
- pd->regoff = stacksize;
+ pd->inmemory = true;
+ pd->regoff = (stacksize * slot) + stackoff;
+ pd->index = stacksize;
+ stacksize += slots1w;
+ }
+ break;
+
+ case TYPE_LNG:
+ if (iarg < INT_ARG_CNT - 1) {
+ /* _ALIGN(iarg); */
+ pd->inmemory = false;
+ 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 * slot) + stackoff;
+ pd->index = stacksize;
+ iarg = INT_ARG_CNT;
+ stacksize += slots2w;
}
- if (iarg < INT_ARG_CNT)
- iarg++;
- else
- stacksize++;
break;
case TYPE_FLT:
- case TYPE_DBL:
if (farg < FLT_ARG_CNT) {
- pd->inmemory = false;
- pd->regoff = farg;
+ pd->inmemory = false;
+ pd->regoff = abi_registers_float_argument[farg];
+ pd->index = farg;
+ farg++;
}
else {
- pd->inmemory = true;
- pd->regoff = stacksize;
+ pd->inmemory = true;
+ pd->regoff = (stacksize * slot) + stackoff;
+ pd->index = stacksize;
+ stacksize += slots1w;
}
- if (farg < FLT_ARG_CNT)
+ break;
+
+ case TYPE_DBL:
+ if (farg < FLT_ARG_CNT) {
+ pd->inmemory = false;
+ pd->regoff = abi_registers_float_argument[farg];
+ pd->index = farg;
farg++;
- else
- stacksize++;
+ }
+ else {
+ /* _ALIGN(stacksize); */
+ pd->inmemory = true;
+ pd->regoff = (stacksize * slot) + stackoff;
+ pd->index = stacksize;
+ stacksize += slots2w;
+ }
break;
+
+ default:
+ assert(0);
}
}
- /* Since XMM0 (==A0) is used for passing return values, this
- argument register usage has to be regarded, too. */
+ /* Since A0+A1/FA0 are used for passing return
+ values, this argument register usage has to be regarded,
+ too. */
- if (IS_FLT_DBL_TYPE(md->returntype.type))
- if (farg < 1)
- farg = 1;
+ if (IS_INT_LNG_TYPE(md->returntype.type)) {
+ if (iarg < (IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1))
+ iarg = IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1;
+ }
+ else {
+ if (IS_FLT_DBL_TYPE(md->returntype.type))
+ if (farg < 1)
+ farg = 1;
+ }
/* fill register and stack usage */
md->argintreguse = iarg;
md->argfltreguse = farg;
- md->memuse = stacksize;
+ 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);
}
*******************************************************************************/
-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;
- /* precoloring only straightforward possible with flt/dbl types
- For Address/Integer/Long REG_RESULT == rax == REG_ITMP1 and so
- could be destroyed if the return value Stack Slot "lives too
- long" */
+ /* In Leafmethods Local Vars holding parameters are precolored to
+ their argument register -> so leafmethods with paramcount > 0
+ could already use R3 == a00! */
- if (IS_FLT_DBL_TYPE(md->returntype.type)) {
- /* In Leafmethods Local Vars holding parameters are precolored
- to their argument register -> so leafmethods with
- paramcount > 0 could already use a00! */
+ if (!code_is_leafmethod(code) || (md->paramcount == 0)) {
+ /* Only precolor the stackslot, if it is not a SAVEDVAR <->
+ has not to survive method invokations. */
- if (!jd->isleafmethod || (md->paramcount == 0)) {
- /* Only precolor the stackslot, if it is not a SAVEDVAR
- <-> has not to survive method invokations */
+ if (!(stackslot->flags & SAVEDVAR)) {
+ VAR(stackslot->varnum)->flags = PREALLOC;
- if (!(stackslot->flags & SAVEDVAR)) {
+ if (IS_INT_LNG_TYPE(md->returntype.type)) {
+ if (!IS_2_WORD_TYPE(md->returntype.type)) {
+ if (rd->argintreguse < 1)
+ rd->argintreguse = 1;
- VAR(stackslot->varnum)->flags = PREALLOC;
+ VAR(stackslot->varnum)->vv.regoff = REG_RESULT;
+ }
+ else {
+ if (rd->argintreguse < 2)
+ rd->argintreguse = 2;
- /* float/double */
+ VAR(stackslot->varnum)->vv.regoff = REG_RESULT_PACKED;
+ }
+ }
+ else { /* float/double */
if (rd->argfltreguse < 1)
rd->argfltreguse = 1;
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/