* src/vm/jit/powerpc/linux/md-abi.c: Use VAR and VAROP macros.
[cacao.git] / src / vm / jit / alpha / md-abi.c
1 /* src/vm/jit/alpha/md-abi.c - functions for Alpha ABI
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    Changes: Christian Ullrich
30
31    $Id: md-abi.c 5595 2006-09-30 23:06:36Z edwin $
32
33 */
34
35
36 #include "config.h"
37 #include "vm/types.h"
38
39 #include "vm/jit/alpha/md-abi.h"
40
41 #include "vm/descriptor.h"
42 #include "vm/global.h"
43 #include "vm/jit/abi.h"
44
45
46 /* register descripton array **************************************************/
47
48 s4 nregdescint[] = {
49         /*   v0,      t0,      t1,      t2,      t3,      t4,      t5,      t6,   */
50         REG_RET, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, 
51
52         /*   t7,      s0,      s1,      s2,      s3,      s4,      s5,      s6,   */
53         REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, 
54
55         /*   a0,      a1,      a2,      a3,      a4,      a5,      t8,      t9,   */
56         REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
57
58         /*  t10,   itmp1,      ra,      pv,      at,   itmp3,      sp,    zero,   */
59         REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES,
60
61         REG_END
62 };
63
64 s4 nregdescfloat[] = {
65         REG_RET, REG_TMP, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV, REG_SAV,
66         REG_SAV, REG_SAV, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, 
67         REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_TMP, REG_TMP,
68         REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_RES,
69         REG_END
70 };
71
72
73 /* md_param_alloc **************************************************************
74
75    Allocate the parameters of the given method descriptor according to the
76    calling convention of the platform.
77
78 *******************************************************************************/
79
80 void md_param_alloc(methoddesc *md)
81 {
82         paramdesc *pd;
83         s4         i;
84         s4         reguse;
85         s4         stacksize;
86
87         /* set default values */
88
89         reguse = 0;
90         stacksize = 0;
91
92         /* get params field of methoddesc */
93
94         pd = md->params;
95
96         for (i = 0; i < md->paramcount; i++, pd++) {
97                 switch (md->paramtypes[i].type) {
98                 case TYPE_INT:
99                 case TYPE_ADR:
100                 case TYPE_LNG:
101                         if (i < INT_ARG_CNT) {
102                                 pd->inmemory = false;
103                                 pd->regoff = reguse;
104                                 reguse++;
105                                 md->argintreguse = reguse;
106                         }
107                         else {
108                                 pd->inmemory = true;
109                                 pd->regoff = stacksize;
110                                 stacksize++;
111                         }
112                         break;
113
114                 case TYPE_FLT:
115                 case TYPE_DBL:
116                         if (i < FLT_ARG_CNT) {
117                                 pd->inmemory = false;
118                                 pd->regoff = reguse;
119                                 reguse++;
120                                 md->argfltreguse = reguse;
121                         }
122                         else {
123                                 pd->inmemory = true;
124                                 pd->regoff = stacksize;
125                                 stacksize++;
126                         }
127                         break;
128                 }
129         }
130
131         /* fill register and stack usage */
132
133         md->memuse = stacksize;
134 }
135
136
137 /* md_return_alloc *************************************************************
138
139    Precolor the Java Stackelement containing the Return Value. Since
140    alpha has a dedicated return register (not an reused arg or
141    reserved reg), this is striaghtforward possible, as long, as this
142    stackelement does not have to survive a method invokation
143    (SAVEDVAR)
144
145    --- in
146    m:                       Methodinfo of current method
147    return_type:             Return Type of the Method (TYPE_INT.. TYPE_ADR)
148                                                         TYPE_VOID is not allowed!
149    stackslot:               Java Stackslot to contain the Return Value
150    
151    --- out
152    if precoloring was possible:
153    jd->var[stackslot->varnum]->flags       = PREALLOC
154                                          ->regoff      =[REG_RESULT|REG_FRESULT]
155    rd->arg[flt|int]reguse   set to a value according the register usage
156
157    NOTE: Do not pass a LOCALVAR in stackslot->varnum.
158 *******************************************************************************/
159
160 void md_return_alloc(jitdata *jd, stackptr stackslot)
161 {
162         methodinfo *m;
163         methoddesc *md;
164
165         /* get required compiler data */
166
167         return;
168
169         m = jd->m;
170
171         md = m->parseddesc;
172
173         /* Only precolor the stackslot, if it is not a SAVEDVAR <-> has
174            not to survive method invokations. */
175
176         if (!(stackslot->flags & SAVEDVAR)) {
177 /*              stackslot->varkind = ARGVAR; */
178 /*              stackslot->varnum  = -1; */
179 /*              stackslot->flags   = 0; */
180
181                 VAR(stackslot->varnum)->flags = PREALLOC;
182
183                 if (IS_INT_LNG_TYPE(md->returntype.type))
184 /*                      stackslot->regoff = REG_RESULT; */
185                         VAR(stackslot->varnum)->vv.regoff = REG_RESULT;
186                 else
187 /*                      stackslot->regoff = REG_FRESULT; */
188                         VAR(stackslot->varnum)->vv.regoff = REG_FRESULT;
189         }
190 }
191
192
193 /*
194  * These are local overrides for various environment variables in Emacs.
195  * Please do not remove this and leave it at the end of the file, where
196  * Emacs will automagically detect them.
197  * ---------------------------------------------------------------------
198  * Local variables:
199  * mode: c
200  * indent-tabs-mode: t
201  * c-basic-offset: 4
202  * tab-width: 4
203  * End:
204  */