1 /* src/vm/jit/powerpc/darwin/md-abi.c - functions for PowerPC Darwin ABI
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
29 Changes: Christian Ullrich
31 $Id: md-abi.c 2811 2005-06-23 14:19:18Z christian $
36 #include "vm/jit/powerpc/types.h"
37 #include "vm/jit/powerpc/darwin/md-abi.h"
39 #include "vm/descriptor.h"
40 #include "vm/global.h"
43 /* md_param_alloc **************************************************************
45 Allocate Arguments to Stackslots according the Calling Conventions
48 md->paramcount: Number of arguments for this method
49 md->paramtypes[].type: Argument types
52 md->params[].inmemory: Argument spilled on stack
53 md->params[].regoff: Stack offset or rd->arg[int|flt]regs index
54 md->memuse: Stackslots needed for argument spilling
55 md->argintreguse: max number of integer arguments used
56 md->argfltreguse: max number of float arguments used
58 *******************************************************************************/
60 void md_param_alloc(methoddesc *md)
68 /* set default values */
72 stacksize = LA_WORD_SIZE;
74 /* get params field of methoddesc */
78 for (i = 0; i < md->paramcount; i++, pd++) {
79 switch (md->paramtypes[i].type) {
82 if (iarg < INT_ARG_CNT) {
84 pd->regoff = iarg; /* rd->arg[int|flt]regs index !! */
88 pd->regoff = stacksize;
93 if (iarg < INT_ARG_CNT - 1) {
95 /* rd->arg[int|flt]regs index !! */
96 pd->regoff = PACK_REGS(iarg + 1, iarg);
100 pd->regoff = stacksize;
106 if (farg < FLT_ARG_CNT) {
107 pd->inmemory = false;
108 pd->regoff = farg; /* rd->arg[int|flt]regs index !! */
109 iarg++; /* skip 1 integer argument register */
113 pd->regoff = stacksize;
118 if (farg < FLT_ARG_CNT) {
119 pd->inmemory = false;
120 pd->regoff = farg; /* rd->arg[int|flt]regs index !! */
121 iarg += 2; /* skip 2 integer argument registers */
125 pd->regoff = stacksize;
133 /* Since R3/R4 (==A0/A1) are used for passing return values, this */
134 /* argument register usage has to be regarded, too */
135 if (IS_INT_LNG_TYPE(md->returntype.type))
136 if (iarg < (IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1))
137 iarg = IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1;
139 /* fill register and stack usage */
140 md->argintreguse = iarg;
141 md->argfltreguse = farg;
142 md->memuse = stacksize;
147 * These are local overrides for various environment variables in Emacs.
148 * Please do not remove this and leave it at the end of the file, where
149 * Emacs will automagically detect them.
150 * ---------------------------------------------------------------------
153 * indent-tabs-mode: t