1 /* src/vm/jit/sparc64/md-abi.c - functions for Sparc ABI
3 Copyright (C) 1996-2005, 2006, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 #include "vm/jit/sparc64/md-abi.h"
31 #include "vm/descriptor.hpp"
32 #include "vm/global.h"
34 #include "vm/jit/abi.h"
35 #include "vm/jit/stack.h"
38 #include "mm/memory.hpp"
42 /* register descripton array **************************************************/
44 /* callee point-of-view, after SAVE has been called. */
46 /* zero itmp1/g1 itmp2/g2 itmp3/g3 temp/g4 temp/g5 sys/g6 sys/g7 */
47 REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
49 /* o0 o1 o2 o3 o4 pv/o5 sp/o6 ra/o7 */
50 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_RES, REG_RES, REG_RES,
52 /* l0 l1 l2 l3 l4 l5 l6 l7 */
53 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
55 /* i0 i1 i2 i3 i4 pv/i5 fp/i6 ra/i7 */
56 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_RES, REG_RES, REG_RES,
60 const char *abi_registers_integer_name[] = {
61 "zero", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
62 "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",
63 "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
64 "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7"
67 const s4 abi_registers_integer_argument[] = {
75 const s4 abi_registers_integer_saved[] = {
93 s4 nregdescfloat[] = {
94 REG_RET, REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
95 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP, REG_TMP,
100 const s4 abi_registers_float_argument[] = {
108 const s4 abi_registers_float_temporary[] = {
118 s4 nat_argintregs[] = {
119 REG_OUT0, REG_OUT1, REG_OUT2, REG_OUT3, REG_OUT4, REG_OUT5
123 /* md_param_alloc **************************************************************
125 Allocate Arguments to Stackslots according the Calling Conventions
128 md->paramcount: Number of arguments for this method
129 md->paramtypes[].type: Argument types
132 md->params[].inmemory: Argument spilled on stack
133 md->params[].regoff: Stack offset or rd->arg[int|flt]regs index
134 md->memuse: Stackslots needed for argument spilling
135 md->argintreguse: max number of integer arguments used
136 md->argfltreguse: max number of float arguments used
138 *******************************************************************************/
140 void md_param_alloc(methoddesc *md)
147 /* set default values */
152 /* get params field of methoddesc */
156 for (i = 0; i < md->paramcount; i++, pd++) {
157 switch (md->paramtypes[i].type) {
161 if (i < INT_ARG_CNT) {
162 pd->inmemory = false;
164 pd->regoff = abi_registers_integer_argument[reguse];
166 md->argintreguse = reguse;
170 pd->index = stacksize;
171 pd->regoff = stacksize * 8;
178 if (i < FLT_ARG_CNT) {
179 pd->inmemory = false;
181 pd->regoff = abi_registers_float_argument[reguse];
183 md->argfltreguse = reguse;
187 pd->index = stacksize;
188 pd->regoff = stacksize * 8;
193 assert(pd->regoff != 26);
196 /* Since O0 is used for passing return values, this */
197 /* argument register usage has to be regarded, too */
198 if (IS_INT_LNG_TYPE(md->returntype.type)) {
200 md->argintreguse = 1;
203 /* fill register and stack usage */
205 md->memuse = stacksize;
209 /* md_param_alloc_native *******************************************************
211 * Pre-allocate arguments according to the native ABI.
213 * *******************************************************************************/
215 void md_param_alloc_native(methoddesc *md)
223 /* Note: regoff will be set relative to a stack base of $sp+16 */
225 /* set default values */
227 stacksize = 6; /* abi params: allocated, but not used */
229 /* when we are above this, we have to increase the stacksize with every */
230 /* single argument to create the proper argument array */
231 min_nat_regs = MIN(INT_NATARG_CNT, FLT_NATARG_CNT);
233 /* get params field of methoddesc */
237 for (i = 0; i < md->paramcount; i++, pd++) {
238 switch (md->paramtypes[i].type) {
242 if (i < INT_NATARG_CNT) {
243 pd->inmemory = false;
244 pd->regoff = nat_argintregs[reguse];
246 md->argintreguse = reguse;
250 pd->regoff = reguse * 8;
256 if (i < FLT_NATARG_CNT) {
257 pd->inmemory = false;
260 md->argfltreguse = reguse;
263 pd->regoff = reguse * 8;
270 if (i >= min_nat_regs)
274 /* Since O0 is used for passing return values, this */
275 /* argument register usage has to be regarded, too */
276 if (IS_INT_LNG_TYPE(md->returntype.type)) {
278 md->argintreguse = 1;
281 /* fill register and stack usage */
283 md->memuse = stacksize;
286 /* md_return_alloc *************************************************************
290 *******************************************************************************/
292 void md_return_alloc(jitdata *jd, stackelement_t* stackslot)
299 * These are local overrides for various environment variables in Emacs.
300 * Please do not remove this and leave it at the end of the file, where
301 * Emacs will automagically detect them.
302 * ---------------------------------------------------------------------
305 * indent-tabs-mode: t
309 * vim:noexpandtab:sw=4:ts=4: