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 5634 2006-10-02 14:18:04Z edwin $
39 #include "vm/jit/x86_64/md-abi.h"
41 #include "vm/descriptor.h"
42 #include "vm/global.h"
45 /* register descripton array **************************************************/
48 REG_RET, REG_ARG, REG_ARG, REG_TMP, REG_RES, REG_SAV, REG_ARG, REG_ARG,
49 REG_ARG, REG_ARG, REG_RES, REG_RES, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
54 s4 nregdescfloat[] = {
55 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
56 REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
61 /* md_param_alloc **************************************************************
65 *******************************************************************************/
67 void md_param_alloc(methoddesc *md)
75 /* set default values */
81 /* get params field of methoddesc */
85 for (i = 0; i < md->paramcount; i++, pd++) {
86 switch (md->paramtypes[i].type) {
90 if (iarg < INT_ARG_CNT) {
96 pd->regoff = stacksize;
98 if (iarg < INT_ARG_CNT)
106 if (farg < FLT_ARG_CNT) {
107 pd->inmemory = false;
112 pd->regoff = stacksize;
114 if (farg < FLT_ARG_CNT)
122 /* Since XMM0 (==A0) is used for passing return values, this
123 argument register usage has to be regarded, too. */
125 if (IS_FLT_DBL_TYPE(md->returntype.type))
129 /* fill register and stack usage */
131 md->argintreguse = iarg;
132 md->argfltreguse = farg;
133 md->memuse = stacksize;
137 /* md_return_alloc *************************************************************
139 Precolor the Java Stackelement containing the Return Value. Only
140 for float/ double types straight forward possible, since INT_LNG
141 types use "reserved" registers Float/Double values use a00 as
145 jd: jitdata of the current method
146 stackslot: Java Stackslot to contain the Return Value
149 if precoloring was possible:
150 VAR(stackslot->varnum)->flags = PREALLOC
151 ->vv.regoff = [REG_RESULT|REG_FRESULT]
152 rd->arg[flt|int]reguse set to a value according the register usage
154 NOTE: Do not pass a LOCALVAR in stackslot->varnum.
156 *******************************************************************************/
158 void md_return_alloc(jitdata *jd, stackptr stackslot)
164 /* get required compiler data */
171 /* precoloring only straightforward possible with flt/dbl types
172 For Address/Integer/Long REG_RESULT == rax == REG_ITMP1 and so
173 could be destroyed if the return value Stack Slot "lives too
176 if (IS_FLT_DBL_TYPE(md->returntype.type)) {
177 /* In Leafmethods Local Vars holding parameters are precolored
178 to their argument register -> so leafmethods with
179 paramcount > 0 could already use a00! */
181 if (!jd->isleafmethod || (md->paramcount == 0)) {
182 /* Only precolor the stackslot, if it is not a SAVEDVAR
183 <-> has not to survive method invokations */
185 if (!(stackslot->flags & SAVEDVAR)) {
187 VAR(stackslot->varnum)->flags = PREALLOC;
190 if (rd->argfltreguse < 1)
191 rd->argfltreguse = 1;
193 VAR(stackslot->varnum)->vv.regoff = REG_FRESULT;
201 * These are local overrides for various environment variables in Emacs.
202 * Please do not remove this and leave it at the end of the file, where
203 * Emacs will automagically detect them.
204 * ---------------------------------------------------------------------
207 * indent-tabs-mode: t