CACAO
md-abi.cpp
Go to the documentation of this file.
1 /* src/vm/jit/alpha/md-abi.cpp - functions for Alpha ABI
2 
3  Copyright (C) 1996-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 
26 #include "config.h"
27 #include "vm/types.hpp"
28 
29 #include "vm/jit/alpha/md-abi.hpp"
30 
31 #include "vm/descriptor.hpp"
32 #include "vm/global.hpp"
33 #include "vm/method.hpp"
34 
35 #include "vm/jit/abi.hpp"
36 #include "vm/jit/code.hpp"
37 
38 
39 /* register descripton array **************************************************/
40 
42  /* v0, t0, t1, t2, t3, t4, t5, t6, */
44 
45  /* t7, s0, s1, s2, s3, s4, s5, s6, */
47 
48  /* a0, a1, a2, a3, a4, a5, t8, t9, */
50 
51  /* t10, itmp1, ra, pv, at, itmp3, sp, zero, */
53 
54  REG_END
55 };
56 
57 const char *abi_registers_integer_name[] = {
58  "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
59  "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6",
60  "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9",
61  "t10", "t11", "ra", "pv", "at", "gp", "sp", "zero"
62 };
63 
65  16, /* a0 */
66  17, /* a1 */
67  18, /* a2 */
68  19, /* a3 */
69  20, /* a4 */
70  21, /* a5 */
71 };
72 
74  9, /* s0 */
75  10, /* s1 */
76  11, /* s2 */
77  12, /* s3 */
78  13, /* s4 */
79  14, /* s5 */
80  15, /* s6 */
81 };
82 
84  1, /* t0 */
85  2, /* t1 */
86  3, /* t2 */
87  4, /* t3 */
88  5, /* t4 */
89  6, /* t5 */
90  7, /* t6 */
91  8, /* t7 */
92  22, /* t8 */
93  23, /* t9 */
94  24, /* t10 */
95 };
96 
97 
103  REG_END
104 };
105 
106 
108  16, /* fa0 */
109  17, /* fa1 */
110  18, /* fa2 */
111  19, /* fa3 */
112  20, /* fa4 */
113  21, /* fa5 */
114 };
115 
117  2, /* fs0 */
118  3, /* fs1 */
119  4, /* fs2 */
120  5, /* fs3 */
121  6, /* fs4 */
122  7, /* fs5 */
123  8, /* fs6 */
124  9, /* fs7 */
125 };
126 
128  1, /* ft0 */
129  10, /* ft1 */
130  11, /* ft2 */
131  12, /* ft3 */
132  13, /* ft4 */
133  14, /* ft5 */
134  15, /* ft6 */
135  22, /* ft7 */
136  23, /* ft8 */
137  24, /* ft9 */
138  25, /* ft10 */
139  26, /* ft11 */
140  27, /* ft12 */
141 };
142 
143 
144 /* md_param_alloc **************************************************************
145 
146  Allocate the parameters of the given method descriptor according to the
147  calling convention of the platform.
148 
149 *******************************************************************************/
150 
152 {
153  paramdesc *pd;
154  s4 i;
155  s4 reguse;
156  s4 stacksize;
157 
158  /* set default values */
159 
160  reguse = 0;
161  stacksize = 0;
162 
163  /* get params field of methoddesc */
164 
165  pd = md->params;
166 
167  for (i = 0; i < md->paramcount; i++, pd++) {
168  switch (md->paramtypes[i].type) {
169  case TYPE_INT:
170  case TYPE_ADR:
171  case TYPE_LNG:
172  if (i < INT_ARG_CNT) {
173  pd->inmemory = false;
174  pd->index = reguse;
176  reguse++;
177  md->argintreguse = reguse;
178  }
179  else {
180  pd->inmemory = true;
181  pd->index = stacksize;
182  pd->regoff = stacksize * 8;
183  stacksize++;
184  }
185  break;
186 
187  case TYPE_FLT:
188  case TYPE_DBL:
189  if (i < FLT_ARG_CNT) {
190  pd->inmemory = false;
191  pd->index = reguse;
192  pd->regoff = abi_registers_float_argument[reguse];
193  reguse++;
194  md->argfltreguse = reguse;
195  }
196  else {
197  pd->inmemory = true;
198  pd->index = stacksize;
199  pd->regoff = stacksize * 8;
200  stacksize++;
201  }
202  break;
203  default:
204  assert(false);
205  break;
206  }
207  }
208 
209  /* fill register and stack usage */
210 
211  md->memuse = stacksize;
212 }
213 
214 
215 /* md_param_alloc_native *******************************************************
216 
217  Pre-allocate arguments according to the native ABI.
218 
219 *******************************************************************************/
220 
222 {
223  /* On Alpha we use the same ABI for JIT method calls as for native
224  method calls. */
225 
226  md_param_alloc(md);
227 }
228 
229 
230 /* md_return_alloc *************************************************************
231 
232  Precolor the Java Stackelement containing the Return Value. Since
233  alpha has a dedicated return register (not an reused arg or
234  reserved reg), this is striaghtforward possible, as long, as this
235  stackelement does not have to survive a method invokation
236  (SAVEDVAR)
237 
238  --- in
239  jd: jitdata of the current method
240  stackslot: Java Stackslot to contain the Return Value
241 
242  --- out
243  if precoloring was possible:
244  VAR(stackslot->varnum)->flags = PREALLOC
245  ->vv.regoff = [REG_RESULT|REG_FRESULT]
246  rd->arg[flt|int]reguse set to a value according the register usage
247 
248  NOTE: Do not pass a LOCALVAR in stackslot->varnum.
249 *******************************************************************************/
250 
252 {
253  methodinfo *m;
254  methoddesc *md;
255 
256  /* get required compiler data */
257 
258  m = jd->m;
259 
260  md = m->parseddesc;
261 
262  /* Only precolor the stackslot, if it is not a SAVEDVAR <-> has
263  not to survive method invokations. */
264 
265  if (!(stackslot->flags & SAVEDVAR)) {
266 
267  VAR(stackslot->varnum)->flags = PREALLOC;
268 
270  VAR(stackslot->varnum)->vv.regoff = REG_RESULT;
271  else
272  VAR(stackslot->varnum)->vv.regoff = REG_FRESULT;
273  }
274 }
275 
276 
277 /*
278  * These are local overrides for various environment variables in Emacs.
279  * Please do not remove this and leave it at the end of the file, where
280  * Emacs will automagically detect them.
281  * ---------------------------------------------------------------------
282  * Local variables:
283  * mode: c++
284  * indent-tabs-mode: t
285  * c-basic-offset: 4
286  * tab-width: 4
287  * End:
288  * vim:noexpandtab:sw=4:ts=4:
289  */
const s4 abi_registers_float_argument[]
Definition: md-abi.cpp:107
void md_return_alloc(jitdata *jd, stackelement_t *stackslot)
Definition: md-abi.cpp:250
Definition: jit.hpp:126
paramdesc * params
Definition: descriptor.hpp:164
#define REG_SAV
Definition: jit.hpp:442
#define IS_INT_LNG_TYPE(a)
Definition: global.hpp:130
const s4 abi_registers_integer_argument[]
Definition: md-abi.cpp:64
s4 nregdescint[]
Definition: md-abi.cpp:41
#define REG_FRESULT
Definition: md-abi.hpp:59
#define REG_END
Definition: jit.hpp:446
int32_t flags
Definition: stack.hpp:67
#define REG_RES
Definition: jit.hpp:439
const s4 abi_registers_integer_saved[]
Definition: md-abi.cpp:75
uint32_t index
Definition: descriptor.hpp:152
const s4 abi_registers_float_temporary[]
Definition: md-abi.cpp:129
#define VAR(i)
Definition: jit.hpp:252
typedesc paramtypes[1]
Definition: descriptor.hpp:167
#define REG_RET
Definition: jit.hpp:440
const s4 abi_registers_float_saved[]
Definition: md-abi.cpp:118
#define INT_ARG_CNT
Definition: md-abi.hpp:74
const s4 abi_registers_integer_temporary[]
Definition: md-abi.cpp:88
MIIterator i
typedesc returntype
Definition: descriptor.hpp:166
int32_t s4
Definition: types.hpp:45
void md_param_alloc(methoddesc *md)
Definition: md-abi.cpp:153
bool inmemory
Definition: descriptor.hpp:151
const char * abi_registers_integer_name[]
Definition: md-abi.cpp:57
void md_param_alloc_native(methoddesc *md)
Definition: md-abi.cpp:224
methoddesc * parseddesc
Definition: method.hpp:78
methodinfo * m
Definition: jit.hpp:127
#define FLT_ARG_CNT
Definition: md-abi.hpp:81
#define REG_ARG
Definition: jit.hpp:444
#define REG_TMP
Definition: jit.hpp:443
s4 nregdescfloat[]
Definition: md-abi.cpp:98
int32_t varnum
Definition: stack.hpp:69
uint32_t regoff
Definition: descriptor.hpp:153
#define REG_RESULT
Definition: md-abi.hpp:33