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/global.h"
33 #include "vm/jit/abi.h"
35 #include "vmcore/descriptor.h"
38 /* register descripton array **************************************************/
41 /* v0, t0, t1, t2, t3, t4, t5, t6, */
42 REG_RET, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
44 /* t7, s0, s1, s2, s3, s4, s5, s6, */
45 REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
47 /* a0, a1, a2, a3, a4, a5, t8, t9, */
48 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
50 /* t10, itmp1, ra, pv, at, itmp3, sp, zero, */
51 REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
56 const char *abi_registers_integer_name[] = {
57 "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
58 "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6",
59 "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
60 "t10", "t11", "ra", "pv", "at", "gp", "sp", "zero"
63 const s4 abi_registers_integer_argument[] = {
72 const s4 abi_registers_integer_saved[] = {
82 const s4 abi_registers_integer_temporary[] = {
97 s4 nregdescfloat[] = {
98 REG_RET, REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
99 REG_SAV, REG_SAV, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
100 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
101 REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES,
106 const s4 abi_registers_float_argument[] = {
115 const s4 abi_registers_float_saved[] = {
126 const s4 abi_registers_float_temporary[] = {
143 /* md_param_alloc **************************************************************
145 Allocate the parameters of the given method descriptor according to the
146 calling convention of the platform.
148 *******************************************************************************/
150 void md_param_alloc(methoddesc *md)
157 /* set default values */
162 /* get params field of methoddesc */
166 for (i = 0; i < md->paramcount; i++, pd++) {
167 switch (md->paramtypes[i].type) {
171 if (i < INT_ARG_CNT) {
172 pd->inmemory = false;
174 pd->regoff = abi_registers_integer_argument[reguse];
176 md->argintreguse = reguse;
180 pd->index = stacksize;
181 pd->regoff = stacksize * 8;
188 if (i < FLT_ARG_CNT) {
189 pd->inmemory = false;
191 pd->regoff = abi_registers_float_argument[reguse];
193 md->argfltreguse = reguse;
197 pd->index = stacksize;
198 pd->regoff = stacksize * 8;
205 /* fill register and stack usage */
207 md->memuse = stacksize;
211 /* md_param_alloc_native *******************************************************
213 Pre-allocate arguments according to the native ABI.
215 *******************************************************************************/
217 void md_param_alloc_native(methoddesc *md)
219 /* On Alpha we use the same ABI for JIT method calls as for native
226 /* md_return_alloc *************************************************************
228 Precolor the Java Stackelement containing the Return Value. Since
229 alpha has a dedicated return register (not an reused arg or
230 reserved reg), this is striaghtforward possible, as long, as this
231 stackelement does not have to survive a method invokation
235 jd: jitdata of the current method
236 stackslot: Java Stackslot to contain the Return Value
239 if precoloring was possible:
240 VAR(stackslot->varnum)->flags = PREALLOC
241 ->vv.regoff = [REG_RESULT|REG_FRESULT]
242 rd->arg[flt|int]reguse set to a value according the register usage
244 NOTE: Do not pass a LOCALVAR in stackslot->varnum.
245 *******************************************************************************/
247 void md_return_alloc(jitdata *jd, stackelement_t *stackslot)
252 /* get required compiler data */
258 /* Only precolor the stackslot, if it is not a SAVEDVAR <-> has
259 not to survive method invokations. */
261 if (!(stackslot->flags & SAVEDVAR)) {
263 VAR(stackslot->varnum)->flags = PREALLOC;
265 if (IS_INT_LNG_TYPE(md->returntype.type))
266 VAR(stackslot->varnum)->vv.regoff = REG_RESULT;
268 VAR(stackslot->varnum)->vv.regoff = REG_FRESULT;
274 * These are local overrides for various environment variables in Emacs.
275 * Please do not remove this and leave it at the end of the file, where
276 * Emacs will automagically detect them.
277 * ---------------------------------------------------------------------
280 * indent-tabs-mode: t