1 /* src/vm/jit/parse.h - parser header
3 Copyright (C) 1996-2005 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
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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Author: Christian Thalinger
31 $Id: parse.h 4316 2006-01-19 23:40:46Z edwin $
42 #include "vm/global.h"
43 #include "vm/jit/codegen-common.h"
44 #include "vm/jit/inline/inline.h"
47 /* intermediate code generating macros ****************************************/
49 #define PINC iptr++;ipc++
51 #define LOADCONST_I(v) \
52 iptr->opc = ICMD_ICONST; \
54 iptr->line = currentline; \
55 iptr->method = inline_env->method; \
58 #define LOADCONST_L(v) \
59 iptr->opc = ICMD_LCONST; \
61 iptr->line = currentline; \
62 iptr->method = inline_env->method; \
65 #define LOADCONST_F(v) \
66 iptr->opc = ICMD_FCONST; \
68 iptr->line = currentline; \
69 iptr->method = inline_env->method; \
72 #define LOADCONST_D(v) \
73 iptr->opc = ICMD_DCONST; \
75 iptr->line = currentline; \
76 iptr->method = inline_env->method; \
79 #define LOADCONST_A(v) \
80 iptr->opc = ICMD_ACONST; \
82 iptr->line = currentline; \
83 iptr->method = inline_env->method; \
86 #define LOADCONST_A_CLASS(v,t) \
87 iptr->opc = ICMD_ACONST; \
90 iptr->line = currentline; \
91 iptr->method = inline_env->method; \
94 /* ACONST instructions generated as arguments for builtin functions
95 * have op1 set to non-zero. This is used for stack overflow checking
97 #define LOADCONST_A_BUILTIN(v,t) \
98 iptr->opc = ICMD_ACONST; \
101 iptr->target = (t); \
102 iptr->line = currentline; \
103 iptr->method = inline_env->method; \
108 iptr->line = currentline; \
109 iptr->method = inline_env->method; \
115 iptr->line = currentline; \
116 iptr->method = inline_env->method; \
119 #define OP2I(o,o1,v) \
123 iptr->line = currentline; \
124 iptr->method = inline_env->method; \
127 #define OP2A_NOINC(o,o1,v,l) \
132 iptr->method = inline_env->method
134 #define OP2A(o,o1,v,l) \
135 OP2A_NOINC(o,o1,v,l); \
138 #define OP2AT(o,o1,v,t,l) \
139 OP2A_NOINC(o,o1,v,l); \
140 iptr->target = (t); \
143 #define BUILTIN(v,o1,t,l) \
144 inline_env->method->isleafmethod = false; \
145 iptr->opc = ICMD_BUILTIN; \
148 iptr->target = (t); \
150 iptr->method = inline_env->method; \
154 /* We have to check local variables indices here because they are
155 * used in stack.c to index the locals array. */
157 #define INDEX_ONEWORD(num) \
159 if ((num) < 0 || (num) >= inline_env->cumlocals) { \
161 new_verifyerror(inline_env->method, "Illegal local variable number"); \
166 #define INDEX_TWOWORD(num) \
168 if ((num) < 0 || ((num) + 1) >= inline_env->cumlocals) { \
170 new_verifyerror(inline_env->method, "Illegal local variable number"); \
175 #define OP1LOAD(o,o1) \
176 do {if (o == ICMD_LLOAD || o == ICMD_DLOAD) \
182 #define OP1STORE(o,o1) \
183 do {if (o == ICMD_LSTORE || o == ICMD_DSTORE) \
189 /* block generating and checking macros */
191 #define block_insert(i) \
193 if (!(m->basicblockindex[(i)] & 1)) { \
195 m->basicblockindex[(i)] |= 1; \
200 /* FIXME really use cumjcodelength for the bound_checkers ? */
202 #define bound_check(i) \
204 if (i < 0 || i >= inline_env->cumjcodelength) { \
205 /* if (i < 0 || i >= m->jcodelength) { */ \
207 new_verifyerror(inline_env->method, "Illegal target of jump or branch"); \
212 /* bound_check1 is used for the inclusive ends of exception handler ranges */
213 #define bound_check1(i) \
215 if (i < 0 || i > inline_env->cumjcodelength) { \
216 /* if (i < 0 || i > m->jcodelength) { */ \
218 new_verifyerror(inline_env->method, "Illegal target of jump or branch"); \
224 /* macros for byte code fetching ***********************************************
226 fetch a byte code of given size from position p in code array jcode
228 *******************************************************************************/
230 #define code_get_u1(p,m) m->jcode[p]
231 #define code_get_s1(p,m) ((s1)m->jcode[p])
232 #define code_get_u2(p,m) ((((u2)m->jcode[p]) << 8) + m->jcode[p + 1])
233 #define code_get_s2(p,m) ((s2)((((u2)m->jcode[p]) << 8) + m->jcode[p + 1]))
234 #define code_get_u4(p,m) ((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
235 +(((u4)m->jcode[p + 2]) << 8) + m->jcode[p + 3])
236 #define code_get_s4(p,m) ((s4)((((u4)m->jcode[p]) << 24) + (((u4)m->jcode[p + 1]) << 16) \
237 +(((u4)m->jcode[p + 2]) << 8) + m->jcode[p + 3]))
240 /* function prototypes ********************************************************/
242 void compiler_addinitclass(classinfo *c);
243 methodinfo *parse(methodinfo *m, codegendata *cd, t_inlining_globals *inline_env);
245 #endif /* _PARSE_H */
249 * These are local overrides for various environment variables in Emacs.
250 * Please do not remove this and leave it at the end of the file, where
251 * Emacs will automagically detect them.
252 * ---------------------------------------------------------------------
255 * indent-tabs-mode: t
259 * vim:noexpandtab:sw=4:ts=4: