1 /* src/vm/jit/arm/md-abi.c - functions for arm 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: Michael Starzinger
29 Changes: Christian Thalinger
31 $Id: md-abi.c 6548 2006-10-01 22:18:38Z edwin $
39 #include "vm/jit/arm/md-abi.h"
41 #include "vm/descriptor.h"
42 #include "vm/global.h"
43 #include "vm/jit/abi.h"
46 /* register descripton array **************************************************/
49 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
50 REG_SAV, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
54 #if defined(ENABLE_SOFTFLOAT)
55 s4 nregdescfloat[] = {
56 REG_RES, REG_RES, REG_RES, REG_RES,
57 REG_RES, REG_RES, REG_RES, REG_RES,
61 /* TODO: FPA register usage conventions */
62 s4 nregdescfloat[] = {
63 REG_TMP, REG_TMP, REG_TMP, REG_TMP,
64 REG_TMP, REG_TMP, REG_RES, REG_RES,
67 #endif /* defined(ENABLE_SOFTFLOAT) */
70 /* md_param_alloc **************************************************************
72 Allocate Arguments to Stackslots according the Calling Conventions
75 md->paramcount: Number of arguments for this method
76 md->paramtypes[].type: Argument types
79 md->params[].inmemory: Argument spilled on stack
80 md->params[].regoff: Stack offset or rd->arg[int|flt]regs index
81 md->memuse: Stackslots needed for argument spilling
82 md->argintreguse: max number of integer arguments used
83 md->argfltreguse: max number of float arguments used
85 *******************************************************************************/
87 void md_param_alloc(methoddesc *md)
94 /* set default values */
98 /* get params field of methoddesc */
101 for (i = 0; i < md->paramcount; i++, pd++) {
102 switch (md->paramtypes[i].type) {
106 if (reguse < INT_ARG_CNT) {
107 pd->inmemory = false;
113 pd->regoff = stacksize;
120 if (reguse+1 < INT_ARG_CNT) {
121 pd->inmemory = false;
122 #if defined(__ARMEL__)
123 pd->regoff = PACK_REGS(reguse, reguse+1);
125 pd->regoff = PACK_REGS(reguse+1, reguse);
129 else if (reguse < INT_ARG_CNT) {
130 pd->inmemory = false;
131 #if defined(__ARMEL__)
132 pd->regoff = PACK_REGS(reguse, INT_ARG_CNT);
134 pd->regoff = PACK_REGS(INT_ARG_CNT, reguse);
141 pd->regoff = stacksize;
148 /* Since R0/R1 (==A0/A1) are used for passing return values, this
149 argument register usage has to be regarded, too. */
151 if (md->returntype.type != TYPE_VOID) {
152 if (!IS_2_WORD_TYPE(md->returntype.type)) {
162 /* fill register and stack usage */
164 md->argintreguse = reguse;
165 md->argfltreguse = 0;
166 md->memuse = stacksize;
170 /* md_return_alloc *************************************************************
172 Precolor the Java Stackelement containing the Return Value, if possible.
175 m: Methodinfo of current method
176 return_type: Return Type of the Method (TYPE_INT.. TYPE_ADR)
177 TYPE_VOID is not allowed!
178 stackslot: Java Stackslot to contain the Return Value
181 if precoloring was possible:
182 VAR(stackslot->varnum)->flags = PREALLOC
183 VAR(stackslot->varnum)->vv.regoff = [REG_RESULT, (REG_RESULT2/REG_RESULT), REG_FRESULT]
184 rd->arg[flt|int]reguse set to a value according the register usage
186 *******************************************************************************/
188 void md_return_alloc(jitdata *jd, stackptr stackslot)
194 /* get required compiler data */
201 /* In Leafmethods Local Vars holding parameters are precolored to
202 their argument register -> so leafmethods with paramcount > 0
203 could already use R0 == a00! */
205 if (!jd->isleafmethod || (md->paramcount == 0)) {
206 /* Only precolor the stackslot, if it is not a SAVEDVAR <->
207 has not to survive method invokations. */
209 if (!(stackslot->flags & SAVEDVAR)) {
210 #if !defined(ENABLE_SOFTFLOAT)
211 /* Stackelements containing float or double values
212 (TYPE_FLT | TYPE_DBL) cannot be precolored, because we
213 use integer register to pass return values. (floats:
214 R0, doubles: R0/R1) */
216 if (!IS_FLT_DBL_TYPE(md->returntype.type)) {
219 VAR(stackslot->varnum)->flags = PREALLOC;
221 if (!IS_2_WORD_TYPE(md->returntype.type)) {
222 if (rd->argintreguse < 1)
223 rd->argintreguse = 1;
225 VAR(stackslot->varnum)->vv.regoff = REG_RESULT;
228 if (rd->argintreguse < 2)
229 rd->argintreguse = 2;
231 VAR(stackslot->varnum)->vv.regoff = REG_RESULT_PACKED;
234 #if !defined(ENABLE_SOFTFLOAT)
243 * These are local overrides for various environment variables in Emacs.
244 * Please do not remove this and leave it at the end of the file, where
245 * Emacs will automagically detect them.
246 * ---------------------------------------------------------------------
249 * indent-tabs-mode: t