1 /* src/vm/jit/sparc64/md-abi.c - functions for Sparc ABI
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 $Id: md-abi.h 4357 2006-01-22 23:33:38Z twisti $
33 #include "vm/jit/sparc64/md-abi.h"
35 #include "vm/global.h"
37 #include "vm/jit/abi.h"
39 #include "vmcore/descriptor.h"
42 #include "mm/memory.h"
45 /* helper macros for allocation methods ***************************************/
46 #define MIN(a,b) (((a) <= (b)) ? (a) : (b))
48 /* register descripton array **************************************************/
50 /* callee point-of-view, after SAVE has been called. */
52 /* zero itmp1/g1 itmp2/g2 itmp3/g3 temp/g4 temp/g5 sys/g6 sys/g7 */
53 REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
55 /* o0 o1 o2 o3 o4 pv/o5 sp/o6 ra/o7 */
56 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_RES, REG_RES, REG_RES,
58 /* l0 l1 l2 l3 l4 l5 l6 l7 */
59 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
61 /* i0 i1 i2 i3 i4 pv/i5 fp/i6 ra/i7 */
62 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_RES, REG_RES, REG_RES,
66 const char *abi_registers_integer_name[] = {
67 "zero", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
68 "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",
69 "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
70 "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7"
73 const s4 abi_registers_integer_argument[] = {
81 const s4 abi_registers_integer_saved[] = {
99 s4 nregdescfloat[] = {
100 REG_RET, REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
101 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP, REG_TMP,
106 const s4 abi_registers_float_argument[] = {
114 const s4 abi_registers_float_temporary[] = {
124 s4 nat_argintregs[] = {
125 REG_OUT0, REG_OUT1, REG_OUT2, REG_OUT3, REG_OUT4, REG_OUT5
129 /* md_param_alloc **************************************************************
131 Allocate Arguments to Stackslots according the Calling Conventions
134 md->paramcount: Number of arguments for this method
135 md->paramtypes[].type: Argument types
138 md->params[].inmemory: Argument spilled on stack
139 md->params[].regoff: Stack offset or rd->arg[int|flt]regs index
140 md->memuse: Stackslots needed for argument spilling
141 md->argintreguse: max number of integer arguments used
142 md->argfltreguse: max number of float arguments used
144 *******************************************************************************/
146 void md_param_alloc(methoddesc *md)
153 /* set default values */
158 /* get params field of methoddesc */
162 for (i = 0; i < md->paramcount; i++, pd++) {
163 switch (md->paramtypes[i].type) {
167 if (i < INT_ARG_CNT) {
168 pd->inmemory = false;
170 pd->regoff = abi_registers_integer_argument[reguse];
172 md->argintreguse = reguse;
176 pd->index = stacksize;
177 pd->regoff = stacksize * 8;
184 if (i < FLT_ARG_CNT) {
185 pd->inmemory = false;
187 pd->regoff = abi_registers_float_argument[reguse];
189 md->argfltreguse = reguse;
193 pd->index = stacksize;
194 pd->regoff = stacksize * 8;
201 /* Since O0 is used for passing return values, this */
202 /* argument register usage has to be regarded, too */
203 if (IS_INT_LNG_TYPE(md->returntype.type)) {
205 md->argintreguse = 1;
208 /* fill register and stack usage */
210 md->memuse = stacksize;
214 /* md_param_alloc_native *******************************************************
216 * Pre-allocate arguments according to the native ABI.
218 * *******************************************************************************/
220 void md_param_alloc_native(methoddesc *md)
228 /* set default values */
233 /* when we are above this, we have to increase the stacksize with every */
234 /* single argument to create the proper argument array */
235 min_nat_regs = MIN(INT_NATARG_CNT, FLT_NATARG_CNT);
237 /* get params field of methoddesc */
241 for (i = 0; i < md->paramcount; i++, pd++) {
242 switch (md->paramtypes[i].type) {
246 if (i < INT_NATARG_CNT) {
247 pd->inmemory = false;
250 md->argintreguse = reguse;
258 if (i >= min_nat_regs)
263 if (i < FLT_NATARG_CNT) {
264 pd->inmemory = false;
267 md->argfltreguse = reguse;
274 if (i >= min_nat_regs)
280 /* Since O0 is used for passing return values, this */
281 /* argument register usage has to be regarded, too */
282 if (IS_INT_LNG_TYPE(md->returntype.type)) {
284 md->argintreguse = 1;
287 /* fill register and stack usage */
289 md->memuse = stacksize;
292 /* md_return_alloc *************************************************************
296 *******************************************************************************/
298 void md_return_alloc(jitdata *jd, stackptr stackslot)
305 * These are local overrides for various environment variables in Emacs.
306 * Please do not remove this and leave it at the end of the file, where
307 * Emacs will automagically detect them.
308 * ---------------------------------------------------------------------
311 * indent-tabs-mode: t