1 /* src/vm/jit/alpha/md-abi.c - functions for Alpha ABI
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 #include "vm/jit/alpha/md-abi.h"
31 #include "vm/descriptor.h"
32 #include "vm/global.h"
34 #include "vm/jit/abi.h"
37 /* register descripton array **************************************************/
40 /* v0, t0, t1, t2, t3, t4, t5, t6, */
41 REG_RET, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
43 /* t7, s0, s1, s2, s3, s4, s5, s6, */
44 REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
46 /* a0, a1, a2, a3, a4, a5, t8, t9, */
47 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
49 /* t10, itmp1, ra, pv, at, itmp3, sp, zero, */
50 REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
55 const char *abi_registers_integer_name[] = {
56 "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
57 "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6",
58 "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
59 "t10", "t11", "ra", "pv", "at", "gp", "sp", "zero"
62 const s4 abi_registers_integer_argument[] = {
71 const s4 abi_registers_integer_saved[] = {
81 const s4 abi_registers_integer_temporary[] = {
96 s4 nregdescfloat[] = {
97 REG_RET, REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
98 REG_SAV, REG_SAV, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
99 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
100 REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES,
105 const s4 abi_registers_float_argument[] = {
114 const s4 abi_registers_float_saved[] = {
125 const s4 abi_registers_float_temporary[] = {
142 /* md_param_alloc **************************************************************
144 Allocate the parameters of the given method descriptor according to the
145 calling convention of the platform.
147 *******************************************************************************/
149 void md_param_alloc(methoddesc *md)
156 /* set default values */
161 /* get params field of methoddesc */
165 for (i = 0; i < md->paramcount; i++, pd++) {
166 switch (md->paramtypes[i].type) {
170 if (i < INT_ARG_CNT) {
171 pd->inmemory = false;
173 pd->regoff = abi_registers_integer_argument[reguse];
175 md->argintreguse = reguse;
179 pd->index = stacksize;
180 pd->regoff = stacksize * 8;
187 if (i < FLT_ARG_CNT) {
188 pd->inmemory = false;
190 pd->regoff = abi_registers_float_argument[reguse];
192 md->argfltreguse = reguse;
196 pd->index = stacksize;
197 pd->regoff = stacksize * 8;
204 /* fill register and stack usage */
206 md->memuse = stacksize;
210 /* md_param_alloc_native *******************************************************
212 Pre-allocate arguments according to the native ABI.
214 *******************************************************************************/
216 void md_param_alloc_native(methoddesc *md)
218 /* On Alpha we use the same ABI for JIT method calls as for native
225 /* md_return_alloc *************************************************************
227 Precolor the Java Stackelement containing the Return Value. Since
228 alpha has a dedicated return register (not an reused arg or
229 reserved reg), this is striaghtforward possible, as long, as this
230 stackelement does not have to survive a method invokation
234 jd: jitdata of the current method
235 stackslot: Java Stackslot to contain the Return Value
238 if precoloring was possible:
239 VAR(stackslot->varnum)->flags = PREALLOC
240 ->vv.regoff = [REG_RESULT|REG_FRESULT]
241 rd->arg[flt|int]reguse set to a value according the register usage
243 NOTE: Do not pass a LOCALVAR in stackslot->varnum.
244 *******************************************************************************/
246 void md_return_alloc(jitdata *jd, stackelement_t *stackslot)
251 /* get required compiler data */
257 /* Only precolor the stackslot, if it is not a SAVEDVAR <-> has
258 not to survive method invokations. */
260 if (!(stackslot->flags & SAVEDVAR)) {
262 VAR(stackslot->varnum)->flags = PREALLOC;
264 if (IS_INT_LNG_TYPE(md->returntype.type))
265 VAR(stackslot->varnum)->vv.regoff = REG_RESULT;
267 VAR(stackslot->varnum)->vv.regoff = REG_FRESULT;
273 * These are local overrides for various environment variables in Emacs.
274 * Please do not remove this and leave it at the end of the file, where
275 * Emacs will automagically detect them.
276 * ---------------------------------------------------------------------
279 * indent-tabs-mode: t