* src/vm/jit/alpha/emit.c (vm/options.h): Added.
[cacao.git] / src / vm / jit / emit-common.c
1 /* src/vm/jit/emit-common.c - common code emitter functions
2
3    Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    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             Edwin Steiner
29
30    $Id: emitfuncs.c 4398 2006-01-31 23:43:08Z twisti $
31
32 */
33
34
35 #include "config.h"
36
37 #include <assert.h>
38
39 #include "vm/types.h"
40
41 #include "vm/jit/emit-common.h"
42 #include "vm/jit/jit.h"
43
44
45 /* emit_load_s1 ****************************************************************
46
47    Emits a possible load of the first source operand.
48
49 *******************************************************************************/
50
51 s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg)
52 {
53         varinfo *src;
54         s4       reg;
55
56         src = VAROP(iptr->s1);
57
58         reg = emit_load(jd, iptr, src, tempreg);
59
60         return reg;
61 }
62
63
64 /* emit_load_s2 ****************************************************************
65
66    Emits a possible load of the second source operand.
67
68 *******************************************************************************/
69
70 s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg)
71 {
72         varinfo *src;
73         s4       reg;
74
75         src = VAROP(iptr->sx.s23.s2);
76
77         reg = emit_load(jd, iptr, src, tempreg);
78
79         return reg;
80 }
81
82
83 /* emit_load_s3 ****************************************************************
84
85    Emits a possible load of the third source operand.
86
87 *******************************************************************************/
88
89 s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg)
90 {
91         varinfo *src;
92         s4       reg;
93
94         src = VAROP(iptr->sx.s23.s3);
95
96         reg = emit_load(jd, iptr, src, tempreg);
97
98         return reg;
99 }
100
101
102 /* emit_load_s1_low ************************************************************
103
104    Emits a possible load of the low 32-bits of the first long source
105    operand.
106
107 *******************************************************************************/
108
109 #if SIZEOF_VOID_P == 4
110 s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg)
111 {
112         varinfo *src;
113         s4       reg;
114
115         src = VAROP(iptr->s1);
116
117         reg = emit_load_low(jd, iptr, src, tempreg);
118
119         return reg;
120 }
121 #endif
122
123
124 /* emit_load_s2_low ************************************************************
125
126    Emits a possible load of the low 32-bits of the second long source
127    operand.
128
129 *******************************************************************************/
130
131 #if SIZEOF_VOID_P == 4
132 s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg)
133 {
134         varinfo *src;
135         s4       reg;
136
137         src = VAROP(iptr->sx.s23.s2);
138
139         reg = emit_load_low(jd, iptr, src, tempreg);
140
141         return reg;
142 }
143 #endif
144
145
146 /* emit_load_s3_low ************************************************************
147
148    Emits a possible load of the low 32-bits of the third long source
149    operand.
150
151 *******************************************************************************/
152
153 #if SIZEOF_VOID_P == 4
154 s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg)
155 {
156         varinfo *src;
157         s4       reg;
158
159         src = VAROP(iptr->sx.s23.s3);
160
161         reg = emit_load_low(jd, iptr, src, tempreg);
162
163         return reg;
164 }
165 #endif
166
167
168 /* emit_load_s1_high ***********************************************************
169
170    Emits a possible load of the high 32-bits of the first long source
171    operand.
172
173 *******************************************************************************/
174
175 #if SIZEOF_VOID_P == 4
176 s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg)
177 {
178         varinfo *src;
179         s4       reg;
180
181         src = VAROP(iptr->s1);
182
183         reg = emit_load_high(jd, iptr, src, tempreg);
184
185         return reg;
186 }
187 #endif
188
189
190 /* emit_load_s2_high ***********************************************************
191
192    Emits a possible load of the high 32-bits of the second long source
193    operand.
194
195 *******************************************************************************/
196
197 #if SIZEOF_VOID_P == 4
198 s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg)
199 {
200         varinfo *src;
201         s4       reg;
202
203         src = VAROP(iptr->sx.s23.s2);
204
205         reg = emit_load_high(jd, iptr, src, tempreg);
206
207         return reg;
208 }
209 #endif
210
211
212 /* emit_load_s3_high ***********************************************************
213
214    Emits a possible load of the high 32-bits of the third long source
215    operand.
216
217 *******************************************************************************/
218
219 #if SIZEOF_VOID_P == 4
220 s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg)
221 {
222         varinfo *src;
223         s4       reg;
224
225         src = VAROP(iptr->sx.s23.s3);
226
227         reg = emit_load_high(jd, iptr, src, tempreg);
228
229         return reg;
230 }
231 #endif
232
233
234 /* emit_store_dst **************************************************************
235
236    This function generates the code to store the result of an
237    operation back into a spilled pseudo-variable.  If the
238    pseudo-variable has not been spilled in the first place, this
239    function will generate nothing.
240     
241 *******************************************************************************/
242
243 void emit_store_dst(jitdata *jd, instruction *iptr, s4 d)
244 {
245         emit_store(jd, iptr, VAROP(iptr->dst), d);
246 }
247
248
249 /* emit_array_checks ***********************************************************
250
251    Emit exception checks for array accesses, if they need to be
252    emitted.
253
254 *******************************************************************************/
255
256 #if defined(__ALPHA__) || defined(__POWERPC__)
257 void emit_array_checks(codegendata *cd, instruction *iptr, s4 s1, s4 s2)
258 {
259         if (INSTRUCTION_MUST_CHECK(iptr)) {
260                 emit_nullpointer_check(cd, s1);
261                 emit_arrayindexoutofbounds_check(cd, s1, s2);
262         }
263 }
264 #endif
265
266
267 /*
268  * These are local overrides for various environment variables in Emacs.
269  * Please do not remove this and leave it at the end of the file, where
270  * Emacs will automagically detect them.
271  * ---------------------------------------------------------------------
272  * Local variables:
273  * mode: c
274  * indent-tabs-mode: t
275  * c-basic-offset: 4
276  * tab-width: 4
277  * End:
278  * vim:noexpandtab:sw=4:ts=4:
279  */