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 Contact: cacao@cacaojvm.org
27 Authors: Alexander Jordan
31 $Id: md-abi.h 4357 2006-01-22 23:33:38Z twisti $
39 #include "vm/jit/sparc64/md-abi.h"
41 #include "vm/descriptor.h"
42 #include "vm/global.h"
43 #include "vm/jit/abi.h"
46 #include "mm/memory.h"
50 /* register descripton array **************************************************/
52 /* callee point-of-view, after SAVE has been called. */
54 /* zero itmp1/g1 itmp2/g2 itmp3/g3 temp/g4 temp/g5 sys/g6 sys/g7 */
55 REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
57 /* o0 o1 o2 o3 o4 pv/o5 sp/o6 ra/o7 */
58 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_RES, REG_RES, REG_RES,
60 /* l0 l1 l2 l3 l4 l5 l6 l7 */
61 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
63 /* i0/v0 i1 i2 i3 i4 pv/i5 fp/i6 ra/i7 */
64 REG_RET, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_RES, REG_RES, REG_RES,
70 s4 nregdescfloat[] = {
71 REG_RET, REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
72 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
77 /* md_param_alloc **************************************************************
79 Allocate Arguments to Stackslots according the Calling Conventions
82 md->paramcount: Number of arguments for this method
83 md->paramtypes[].type: Argument types
86 md->params[].inmemory: Argument spilled on stack
87 md->params[].regoff: Stack offset or rd->arg[int|flt]regs index
88 md->memuse: Stackslots needed for argument spilling
89 md->argintreguse: max number of integer arguments used
90 md->argfltreguse: max number of float arguments used
92 *******************************************************************************/
94 void md_param_alloc(methoddesc *md)
101 /* set default values */
106 /* get params field of methoddesc */
110 for (i = 0; i < md->paramcount; i++, pd++) {
111 switch (md->paramtypes[i].type) {
115 if (i < INT_ARG_CNT) {
116 pd->inmemory = false;
119 md->argintreguse = reguse;
123 pd->regoff = stacksize;
129 if (i < FLT_ARG_CNT) {
130 pd->inmemory = false;
133 md->argfltreguse = reguse;
136 pd->regoff = stacksize;
143 /* Since O0 is used for passing return values, this */
144 /* argument register usage has to be regarded, too */
145 if (IS_INT_LNG_TYPE(md->returntype.type)) {
147 md->argintreguse = 1;
150 /* fill register and stack usage */
152 md->memuse = stacksize;
155 /* md_native_param_alloc **************************************************************
159 *******************************************************************************/
161 void md_native_param_alloc(methoddesc *md)
168 /* set default values */
173 /* get params field of methoddesc */
177 for (i = 0; i < md->paramcount; i++, pd++) {
178 switch (md->paramtypes[i].type) {
182 if (i < INT_NATARG_CNT) {
183 pd->inmemory = false;
186 md->argintreguse = reguse;
197 if (i < FLT_NATARG_CNT) {
198 pd->inmemory = false;
201 md->argfltreguse = reguse;
212 /* Since O0 is used for passing return values, this */
213 /* argument register usage has to be regarded, too */
214 if (IS_INT_LNG_TYPE(md->returntype.type)) {
216 md->argintreguse = 1;
219 /* fill register and stack usage */
221 md->memuse = stacksize;
224 /* reg_setup *******************************************************************
228 *******************************************************************************/
230 void md_native_reg_setup(jitdata *jd)
236 /* get required compiler data */
241 /* setup the integer register table */
244 rd->argintregs = DMNEW(s4, INT_NATARG_CNT);
245 rd->argintreguse = 0;
247 for (rd->argintreguse = 0, i = 8; rd->argintreguse < INT_NATARG_CNT; i++) {
248 rd->argintregs[rd->argintreguse++] = i;
251 assert(rd->argintreguse == INT_NATARG_CNT);
253 /* setup the float register table */
255 rd->argfltregs = DMNEW(s4, FLT_NATARG_CNT);
257 rd->argfltreguse = 0;
260 for (rd->argfltreguse = 0, i = 0; rd->argfltreguse < FLT_NATARG_CNT; i++) {
261 rd->argfltregs[rd->argfltreguse++] = i;
263 assert(rd->argfltreguse == FLT_NATARG_CNT);
267 /* md_return_alloc *************************************************************
271 *******************************************************************************/
273 void md_return_alloc(jitdata *jd, stackptr stackslot)
280 * These are local overrides for various environment variables in Emacs.
281 * Please do not remove this and leave it at the end of the file, where
282 * Emacs will automagically detect them.
283 * ---------------------------------------------------------------------
286 * indent-tabs-mode: t