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 5634 2006-10-02 14:18:04Z edwin $
39 #include "vm/jit/mips/md-abi.h"
41 #include "vm/descriptor.h"
42 #include "vm/global.h"
43 #include "vm/jit/abi.h"
46 /* register descripton array **************************************************/
48 #if SIZEOF_VOID_P == 8
53 REG_RES, REG_RES, REG_RET, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
54 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
55 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
56 REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
60 s4 nregdescfloat[] = {
61 /* fv0, ftmp1, ftmp2, ftmp3, ft0, ft1, ft2, ft3, */
62 REG_RET, REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
64 /* ft4, ft5, ft6, ft7, fa0, fa1, fa2, fa3, */
65 REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
67 /* fa4, fa5, fa6, fa7, ft8, ft9, ft10, ft11, */
68 REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
70 /* fs0, ft12, fs1, ft13, fs2, ft14, fs3 ft15 */
71 REG_SAV, REG_TMP, REG_SAV, REG_TMP, REG_SAV, REG_TMP, REG_SAV, REG_TMP,
76 #else /* SIZEOF_VOID_P == 8 */
81 /* zero, itmp1, v0, v1, a0, a1, a2, a3, */
82 REG_RES, REG_RES, REG_RET, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
84 /* t0, t1, t2, t3, t4, t5, t6, t7, */
85 REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP,
87 /* s0, s1, s2, s3, s4, s5, s6, s7, */
88 REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
90 /*itmp2, itmp3, k0(sys), k1(sys), gp, sp, pv, ra */
91 REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
96 #if !defined(ENABLE_SOFT_FLOAT)
98 s4 nregdescfloat[] = {
99 /* fv0, ftmp1, ftmp2, ftmp3, */
100 REG_RET, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
102 /* ft0, ft1, fa0, fa1, */
103 REG_TMP, REG_RES, REG_TMP, REG_RES, REG_ARG, REG_RES, REG_ARG, REG_RES,
105 /* ft2, ft3, fs0, fs1, */
106 REG_TMP, REG_RES, REG_TMP, REG_RES, REG_SAV, REG_RES, REG_SAV, REG_RES,
108 /* fs2, fs3, fs4, fs5 */
109 REG_SAV, REG_RES, REG_SAV, REG_RES, REG_SAV, REG_RES, REG_SAV, REG_RES,
114 #else /* !defined(ENABLE_SOFT_FLOAT) */
116 s4 nregdescfloat[] = {
120 #endif /* !defined(ENABLE_SOFT_FLOAT) */
122 #endif /* SIZEOF_VOID_P == 8 */
125 /* md_param_alloc **************************************************************
129 *******************************************************************************/
131 void md_param_alloc(methoddesc *md)
138 /* set default values */
143 /* get params field of methoddesc */
147 for (i = 0; i < md->paramcount; i++, pd++) {
148 switch (md->paramtypes[i].type) {
152 if (i < INT_ARG_CNT) {
153 pd->inmemory = false;
156 md->argintreguse = reguse;
159 pd->regoff = stacksize;
165 if (i < FLT_ARG_CNT) {
166 pd->inmemory = false;
169 md->argfltreguse = reguse;
172 pd->regoff = stacksize;
179 /* fill register and stack usage */
181 md->memuse = stacksize;
185 /* md_return_alloc *************************************************************
187 Precolor the Java Stackelement containing the Return Value. Since
188 mips has a dedicated return register (not an reused arg or reserved
189 reg), this is striaghtforward possible, as long, as this
190 stackelement does not have to survive a method invokation
194 jd: jitdata of the current method
195 stackslot: Java Stackslot to contain the Return Value
198 if precoloring was possible:
199 VAR(stackslot->varnum)->flags = PREALLOC
200 ->regoff = [REG_RESULT|REG_FRESULT]
202 *******************************************************************************/
204 void md_return_alloc(jitdata *jd, stackptr stackslot)
209 /* get required compiler data */
215 /* Only precolor the stackslot, if it is not a SAVEDVAR <-> has
216 not to survive method invokations. */
218 if (!(stackslot->flags & SAVEDVAR)) {
220 VAR(stackslot->varnum)->flags = PREALLOC;
222 if (IS_INT_LNG_TYPE(md->returntype.type))
223 VAR(stackslot->varnum)->vv.regoff = REG_RESULT;
225 VAR(stackslot->varnum)->vv.regoff = REG_FRESULT;
231 * These are local overrides for various environment variables in Emacs.
232 * Please do not remove this and leave it at the end of the file, where
233 * Emacs will automagically detect them.
234 * ---------------------------------------------------------------------
237 * indent-tabs-mode: t