1 /* src/vm/jit/arm/md-abi.c - functions for arm ABI
3 Copyright (C) 1996-2005, 2006, 2007 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.c 7259 2007-01-30 13:58:35Z twisti $
33 #include "vm/jit/arm/md-abi.h"
35 #include "vm/global.h"
37 #include "vm/jit/abi.h"
39 #include "vmcore/descriptor.h"
42 /* register descripton array **************************************************/
45 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
46 REG_SAV, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
50 #if defined(ENABLE_SOFTFLOAT)
51 s4 nregdescfloat[] = {
52 REG_RES, REG_RES, REG_RES, REG_RES,
53 REG_RES, REG_RES, REG_RES, REG_RES,
57 /* TODO: FPA register usage conventions */
58 s4 nregdescfloat[] = {
59 REG_TMP, REG_TMP, REG_TMP, REG_TMP,
60 REG_TMP, REG_TMP, REG_RES, REG_RES,
63 #endif /* defined(ENABLE_SOFTFLOAT) */
66 /* md_param_alloc **************************************************************
68 Allocate Arguments to Stackslots according the Calling Conventions
71 md->paramcount: Number of arguments for this method
72 md->paramtypes[].type: Argument types
75 md->params[].inmemory: Argument spilled on stack
76 md->params[].regoff: Stack offset or rd->arg[int|flt]regs index
77 md->memuse: Stackslots needed for argument spilling
78 md->argintreguse: max number of integer arguments used
79 md->argfltreguse: max number of float arguments used
81 *******************************************************************************/
83 void md_param_alloc(methoddesc *md)
90 /* set default values */
94 /* get params field of methoddesc */
97 for (i = 0; i < md->paramcount; i++, pd++) {
98 switch (md->paramtypes[i].type) {
102 if (reguse < INT_ARG_CNT) {
103 pd->inmemory = false;
109 pd->regoff = stacksize;
116 if (reguse+1 < INT_ARG_CNT) {
117 pd->inmemory = false;
118 #if defined(__ARMEL__)
119 pd->regoff = PACK_REGS(reguse, reguse+1);
121 pd->regoff = PACK_REGS(reguse+1, reguse);
125 else if (reguse < INT_ARG_CNT) {
126 pd->inmemory = false;
127 #if defined(__ARMEL__)
128 pd->regoff = PACK_REGS(reguse, INT_ARG_CNT);
130 pd->regoff = PACK_REGS(INT_ARG_CNT, reguse);
137 pd->regoff = stacksize;
144 /* Since R0/R1 (==A0/A1) are used for passing return values, this
145 argument register usage has to be regarded, too. */
147 if (md->returntype.type != TYPE_VOID) {
148 if (!IS_2_WORD_TYPE(md->returntype.type)) {
158 /* fill register and stack usage */
160 md->argintreguse = reguse;
161 md->argfltreguse = 0;
162 md->memuse = stacksize;
166 /* md_return_alloc *************************************************************
168 Precolor the Java Stackelement containing the Return Value, if possible.
171 m: Methodinfo of current method
172 return_type: Return Type of the Method (TYPE_INT.. TYPE_ADR)
173 TYPE_VOID is not allowed!
174 stackslot: Java Stackslot to contain the Return Value
177 if precoloring was possible:
178 VAR(stackslot->varnum)->flags = PREALLOC
179 VAR(stackslot->varnum)->vv.regoff = [REG_RESULT, (REG_RESULT2/REG_RESULT), REG_FRESULT]
180 rd->arg[flt|int]reguse set to a value according the register usage
182 *******************************************************************************/
184 void md_return_alloc(jitdata *jd, stackptr stackslot)
190 /* get required compiler data */
197 /* In Leafmethods Local Vars holding parameters are precolored to
198 their argument register -> so leafmethods with paramcount > 0
199 could already use R0 == a00! */
201 if (!jd->isleafmethod || (md->paramcount == 0)) {
202 /* Only precolor the stackslot, if it is not a SAVEDVAR <->
203 has not to survive method invokations. */
205 if (!(stackslot->flags & SAVEDVAR)) {
206 #if !defined(ENABLE_SOFTFLOAT)
207 /* Stackelements containing float or double values
208 (TYPE_FLT | TYPE_DBL) cannot be precolored, because we
209 use integer register to pass return values. (floats:
210 R0, doubles: R0/R1) */
212 if (!IS_FLT_DBL_TYPE(md->returntype.type)) {
215 VAR(stackslot->varnum)->flags = PREALLOC;
217 if (!IS_2_WORD_TYPE(md->returntype.type)) {
218 if (rd->argintreguse < 1)
219 rd->argintreguse = 1;
221 VAR(stackslot->varnum)->vv.regoff = REG_RESULT;
224 if (rd->argintreguse < 2)
225 rd->argintreguse = 2;
227 VAR(stackslot->varnum)->vv.regoff = REG_RESULT_PACKED;
230 #if !defined(ENABLE_SOFTFLOAT)
239 * These are local overrides for various environment variables in Emacs.
240 * Please do not remove this and leave it at the end of the file, where
241 * Emacs will automagically detect them.
242 * ---------------------------------------------------------------------
245 * indent-tabs-mode: t