1 /* src/vm/jit/powerpc/linux/md-abi.c - functions for PowerPC Linux 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 3797 2005-11-26 15:56:07Z twisti $
39 #include "vm/jit/powerpc/linux/md-abi.h"
41 #include "vm/descriptor.h"
42 #include "vm/global.h"
45 #define _ALIGN(a) do { if ((a) & 1) (a)++; } while (0)
48 /* md_param_alloc **************************************************************
50 Allocate Arguments to Stackslots according the Calling Conventions
53 md->paramcount: Number of arguments for this method
54 md->paramtypes[].type: Argument types
57 md->params[].inmemory: Argument spilled on stack
58 md->params[].regoff: Stack offset or rd->arg[int|flt]regs index
59 md->memuse: Stackslots needed for argument spilling
60 md->argintreguse: max number of integer arguments used
61 md->argfltreguse: max number of float arguments used
63 *******************************************************************************/
65 void md_param_alloc(methoddesc *md)
73 /* set default values */
77 stacksize = LA_WORD_SIZE;
79 /* get params field of methoddesc */
83 for (i = 0; i < md->paramcount; i++, pd++) {
84 switch (md->paramtypes[i].type) {
87 if (iarg < INT_ARG_CNT) {
93 pd->regoff = stacksize;
98 if (iarg < INT_ARG_CNT - 1) {
100 pd->inmemory = false;
101 /* rd->arg[int|flt]regs index !! */
102 pd->regoff = PACK_REGS(iarg + 1, iarg);
107 pd->regoff = stacksize;
113 if (farg < FLT_ARG_CNT) {
114 pd->inmemory = false;
119 pd->regoff = stacksize;
124 if (farg < FLT_ARG_CNT) {
125 pd->inmemory = false;
131 pd->regoff = stacksize;
138 /* Since R3/R4, F1 (==A0/A1, A0) are used for passing return values, this */
139 /* argument register usage has to be regarded, too */
140 if (IS_INT_LNG_TYPE(md->returntype.type)) {
141 if (iarg < (IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1))
142 iarg = IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1;
144 if (IS_FLT_DBL_TYPE(md->returntype.type))
149 /* fill register and stack usage */
151 md->argintreguse = iarg;
152 md->argfltreguse = farg;
153 md->memuse = stacksize;
157 /* md_return_alloc *************************************************************
159 Precolor the Java Stackelement containing the Return Value, if
160 possible. (R3==a00 for int/adr, R4/R3 == a01/a00 for long, F1==a00
164 m: Methodinfo of current method
165 return_type: Return Type of the Method (TYPE_INT.. TYPE_ADR)
166 TYPE_VOID is not allowed!
167 stackslot: Java Stackslot to contain the Return Value
170 if precoloring was possible:
171 stackslot->varkind =ARGVAR
174 ->regoff =[REG_RESULT, (REG_RESULT2/REG_RESULT), REG_FRESULT]
175 rd->arg[flt|int]reguse set to a value according the register usage
177 *******************************************************************************/
179 void md_return_alloc(methodinfo *m, registerdata *rd, s4 return_type,
182 /* In Leafmethods Local Vars holding parameters are precolored to their */
183 /* argument register -> so leafmethods with paramcount > 0 could already */
186 if (!m->isleafmethod || (m->paramcount == 0)) {
187 /* Only precolor the stackslot, if it is not a SAVEDVAR <-> has not */
188 /* to survive method invokations */
190 if (!(stackslot->flags & SAVEDVAR)) {
191 stackslot->varkind = ARGVAR;
192 stackslot->varnum = -1;
193 stackslot->flags = 0;
195 if ( IS_INT_LNG_TYPE(return_type) ) {
196 if (!IS_2_WORD_TYPE(return_type)) {
197 if (rd->argintreguse < 1)
198 rd->argintreguse = 1;
200 stackslot->regoff = REG_RESULT;
203 if (rd->argintreguse < 2)
204 rd->argintreguse = 2;
206 stackslot->regoff = PACK_REGS(REG_RESULT2, REG_RESULT);
209 } else { /* float/double */
210 if (rd->argfltreguse < 1)
211 rd->argfltreguse = 1;
213 stackslot->regoff = REG_FRESULT;
221 * These are local overrides for various environment variables in Emacs.
222 * Please do not remove this and leave it at the end of the file, where
223 * Emacs will automagically detect them.
224 * ---------------------------------------------------------------------
227 * indent-tabs-mode: t