1 /* src/vm/jit/mips/md-abi.c - functions for MIPS 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
29 Changes: Christian Ullrich
31 $Id: md-abi.c 4357 2006-01-22 23:33:38Z twisti $
39 #include "vm/jit/mips/md-abi.h"
41 #include "vm/descriptor.h"
42 #include "vm/global.h"
45 /* register descripton array **************************************************/
47 #if SIZEOF_VOID_P == 8
52 REG_RES, REG_RES, REG_RET, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
53 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
54 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
55 REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
59 s4 nregdescfloat[] = {
60 /* fv0, ftmp1, ftmp2, ftmp3, ft0, ft1, ft2, ft3, */
61 REG_RET, REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
63 /* ft4, ft5, ft6, ft7, fa0, fa1, fa2, fa3, */
64 REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
66 /* fa4, fa5, fa6, fa7, ft8, ft9, ft10, ft11, */
67 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
69 /* fs0, ft12, fs1, ft13, fs2, ft14, fs3 ft15 */
70 REG_SAV, REG_TMP, REG_SAV, REG_TMP, REG_SAV, REG_TMP, REG_SAV, REG_TMP,
75 #else /* SIZEOF_VOID_P == 8 */
80 /* zero, itmp1, v0, v1, a0, a1, a2, a3, */
81 REG_RES, REG_RES, REG_RET, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
83 /* t0, t1, t2, t3, t4, t5, t6, t7, */
84 REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
86 /* s0, s1, s2, s3, s4, s5, s6, s7, */
87 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
89 /*itmp2, itmp3, k0(sys), k1(sys), gp, sp, pv, ra */
90 REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
95 #if !defined(ENABLE_SOFT_FLOAT)
97 s4 nregdescfloat[] = {
98 /* fv0, ftmp1, ftmp2, ftmp3, */
99 REG_RET, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
101 /* ft0, ft1, fa0, fa1, */
102 REG_TMP, REG_RES, REG_TMP, REG_RES, REG_ARG, REG_RES, REG_ARG, REG_RES,
104 /* ft2, ft3, fs0, fs1, */
105 REG_TMP, REG_RES, REG_TMP, REG_RES, REG_SAV, REG_RES, REG_SAV, REG_RES,
107 /* fs2, fs3, fs4, fs5 */
108 REG_SAV, REG_RES, REG_SAV, REG_RES, REG_SAV, REG_RES, REG_SAV, REG_RES,
113 #else /* !defined(ENABLE_SOFT_FLOAT) */
115 s4 nregdescfloat[] = {
119 #endif /* !defined(ENABLE_SOFT_FLOAT) */
121 #endif /* SIZEOF_VOID_P == 8 */
124 /* md_param_alloc **************************************************************
128 *******************************************************************************/
130 void md_param_alloc(methoddesc *md)
137 /* set default values */
142 /* get params field of methoddesc */
146 for (i = 0; i < md->paramcount; i++, pd++) {
147 switch (md->paramtypes[i].type) {
151 if (i < INT_ARG_CNT) {
152 pd->inmemory = false;
155 md->argintreguse = reguse;
158 pd->regoff = stacksize;
164 if (i < FLT_ARG_CNT) {
165 pd->inmemory = false;
168 md->argfltreguse = reguse;
171 pd->regoff = stacksize;
178 /* fill register and stack usage */
180 md->memuse = stacksize;
183 /* md_return_alloc *************************************************************
185 Precolor the Java Stackelement containing the Return Value. Since mips
186 has a dedicated return register (not an reused arg or reserved reg), this
187 is striaghtforward possible, as long, as this stackelement does not have to
188 survive a method invokation (SAVEDVAR)
191 m: Methodinfo of current method
192 return_type: Return Type of the Method (TYPE_INT.. TYPE_ADR)
193 TYPE_VOID is not allowed!
194 stackslot: Java Stackslot to contain the Return Value
197 if precoloring was possible:
198 stackslot->varkind =ARGVAR
201 ->regoff =[REG_RESULT, REG_FRESULT]
204 *******************************************************************************/
205 void md_return_alloc(methodinfo *m, registerdata *rd, s4 return_type,
206 stackptr stackslot) {
207 /* Only precolor the stackslot, if it is not a SAVEDVAR <-> has not */
208 /* to survive method invokations */
209 if (!(stackslot->flags & SAVEDVAR)) {
210 stackslot->varkind = ARGVAR;
211 stackslot->varnum = -1;
212 stackslot->flags = 0;
213 if ( IS_INT_LNG_TYPE(return_type) ) {
214 stackslot->regoff = REG_RESULT;
215 } else { /* float/double */
216 stackslot->regoff = REG_FRESULT;
222 * These are local overrides for various environment variables in Emacs.
223 * Please do not remove this and leave it at the end of the file, where
224 * Emacs will automagically detect them.
225 * ---------------------------------------------------------------------
228 * indent-tabs-mode: t