* src/vm/jit/emit-common.c (codegen.h): Added.
[cacao.git] / src / vm / jit / emit-common.h
1 /* src/vm/jit/emit-common.h - 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
29    $Id: emitfuncs.c 4398 2006-01-31 23:43:08Z twisti $
30
31 */
32
33
34 #ifndef _EMIT_H
35 #define _EMIT_H
36
37 #include "vm/types.h"
38
39 #include "vm/jit/jit.h"
40
41
42 /* constant range macros ******************************************************/
43
44 #if SIZEOF_VOID_P == 8
45
46 # define IS_IMM8(c) \
47     (((s8) (c) >= -128) && ((s8) (c) <= 127))
48
49 # define IS_IMM32(c) \
50     (((s8) (c) >= (-2147483647-1)) && ((s8) (c) <= 2147483647))
51
52 #else
53
54 # define IS_IMM8(c) \
55     (((s4) (c) >= -128) && ((s4) (c) <= 127))
56
57 #endif
58
59
60 /* code generation functions **************************************************/
61
62 s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
63 s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg);
64 s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg);
65 s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg);
66
67 #if SIZEOF_VOID_P == 4
68 s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
69 s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg);
70 s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg);
71 s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg);
72
73 s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
74 s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg);
75 s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg);
76 s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg);
77 #endif
78
79 void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d);
80 void emit_store_dst(jitdata *jd, instruction *iptr, s4 d);
81
82 #if SIZEOF_VOID_P == 4
83 void emit_store_low(jitdata *jd, instruction *iptr, varinfo *dst, s4 d);
84 void emit_store_high(jitdata *jd, instruction *iptr, varinfo *dst, s4 d);
85 #endif
86
87 void emit_copy(jitdata *jd, instruction *iptr, varinfo *src, varinfo *dst);
88
89 void emit_iconst(codegendata *cd, s4 d, s4 value);
90 void emit_lconst(codegendata *cd, s4 d, s8 value);
91
92 void emit_br(codegendata *cd, basicblock *target);
93 void emit_bc(codegendata *cd, basicblock *target, s4 condition);
94
95 void emit_beq(codegendata *cd, basicblock *target);
96 void emit_bne(codegendata *cd, basicblock *target);
97 void emit_blt(codegendata *cd, basicblock *target);
98 void emit_bge(codegendata *cd, basicblock *target);
99 void emit_bgt(codegendata *cd, basicblock *target);
100 void emit_ble(codegendata *cd, basicblock *target);
101
102 void emit_bnan(codegendata *cd, basicblock *target);
103
104 void emit_branch(codegendata *cd, s4 disp, s4 condition);
105
106 void emit_arithmetic_check(codegendata *cd, s4 reg);
107 void emit_arrayindexoutofbounds_check(codegendata *cd, s4 s1, s4 s2);
108 void emit_arraystore_check(codegendata *cd, s4 reg);
109 void emit_classcast_check(codegendata *cd, s4 condition, s4 reg, s4 s1);
110 void emit_nullpointer_check(codegendata *cd, s4 reg);
111 void emit_exception_check(codegendata *cd);
112
113 void emit_array_checks(codegendata *cd, instruction *iptr, s4 s1, s4 s2);
114
115 void emit_exception_stubs(jitdata *jd);
116 void emit_patcher_stubs(jitdata *jd);
117 void emit_replacement_stubs(jitdata *jd);
118
119 void emit_verbosecall_enter(jitdata *jd);
120 void emit_verbosecall_exit(jitdata *jd);
121
122 #endif /* _EMIT_H */
123
124
125 /*
126  * These are local overrides for various environment variables in Emacs.
127  * Please do not remove this and leave it at the end of the file, where
128  * Emacs will automagically detect them.
129  * ---------------------------------------------------------------------
130  * Local variables:
131  * mode: c
132  * indent-tabs-mode: t
133  * c-basic-offset: 4
134  * tab-width: 4
135  * End:
136  * vim:noexpandtab:sw=4:ts=4:
137  */