1 /* src/vm/jit/x86_64/md-abi.c - functions for x86_64 Linux 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: Christian Thalinger
31 $Id: md-abi.c 7219 2007-01-16 22:18:57Z pm $
39 #include "vm/jit/s390/md-abi.h"
41 #include "vm/descriptor.h"
42 #include "vm/global.h"
45 /* register descripton array **************************************************/
49 REG_RET, REG_ARG, REG_ARG, REG_TMP, REG_RES, REG_SAV, REG_ARG, REG_ARG,
50 REG_ARG, REG_ARG, REG_RES, REG_RES, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
52 REG_TMP, REG_TMP, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_SAV,
53 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_RES, REG_TMP, REG_RES,
58 s4 nregdescfloat[] = {
60 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
61 REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
63 REG_ARG, REG_TMP, REG_ARG, REG_TMP, REG_SAV, REG_TMP, REG_SAV, REG_TMP,
64 REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
69 /* md_param_alloc **************************************************************
73 *******************************************************************************/
75 void md_param_alloc(methoddesc *md)
83 /* set default values */
89 /* get params field of methoddesc */
93 for (i = 0; i < md->paramcount; i++, pd++) {
94 switch (md->paramtypes[i].type) {
98 if (iarg < INT_ARG_CNT) {
104 pd->regoff = stacksize;
106 if (iarg < INT_ARG_CNT)
114 if (farg < FLT_ARG_CNT) {
115 pd->inmemory = false;
120 pd->regoff = stacksize;
122 if (farg < FLT_ARG_CNT)
130 /* Since XMM0 (==A0) is used for passing return values, this
131 argument register usage has to be regarded, too. */
133 if (IS_FLT_DBL_TYPE(md->returntype.type))
137 /* fill register and stack usage */
139 md->argintreguse = iarg;
140 md->argfltreguse = farg;
141 md->memuse = stacksize;
145 /* md_return_alloc *************************************************************
147 Precolor the Java Stackelement containing the Return Value. Only
148 for float/ double types straight forward possible, since INT_LNG
149 types use "reserved" registers Float/Double values use a00 as
153 jd: jitdata of the current method
154 stackslot: Java Stackslot to contain the Return Value
157 if precoloring was possible:
158 VAR(stackslot->varnum)->flags = PREALLOC
159 ->vv.regoff = [REG_RESULT|REG_FRESULT]
160 rd->arg[flt|int]reguse set to a value according the register usage
162 NOTE: Do not pass a LOCALVAR in stackslot->varnum.
164 *******************************************************************************/
166 void md_return_alloc(jitdata *jd, stackptr stackslot)
172 /* get required compiler data */
179 /* precoloring only straightforward possible with flt/dbl types
180 For Address/Integer/Long REG_RESULT == rax == REG_ITMP1 and so
181 could be destroyed if the return value Stack Slot "lives too
184 if (IS_FLT_DBL_TYPE(md->returntype.type)) {
185 /* In Leafmethods Local Vars holding parameters are precolored
186 to their argument register -> so leafmethods with
187 paramcount > 0 could already use a00! */
189 if (!jd->isleafmethod || (md->paramcount == 0)) {
190 /* Only precolor the stackslot, if it is not a SAVEDVAR
191 <-> has not to survive method invokations */
193 if (!(stackslot->flags & SAVEDVAR)) {
195 VAR(stackslot->varnum)->flags = PREALLOC;
198 if (rd->argfltreguse < 1)
199 rd->argfltreguse = 1;
201 VAR(stackslot->varnum)->vv.regoff = REG_FRESULT;
209 * These are local overrides for various environment variables in Emacs.
210 * Please do not remove this and leave it at the end of the file, where
211 * Emacs will automagically detect them.
212 * ---------------------------------------------------------------------
215 * indent-tabs-mode: t