root / dyngen-exec.h @ 215cf0be
History | View | Annotate | Download (6.9 kB)
1 | 79638566 | bellard | /*
|
---|---|---|---|
2 | 79638566 | bellard | * dyngen defines for micro operation code
|
3 | 79638566 | bellard | *
|
4 | 79638566 | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | 79638566 | bellard | *
|
6 | 79638566 | bellard | * This library is free software; you can redistribute it and/or
|
7 | 79638566 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 79638566 | bellard | * License as published by the Free Software Foundation; either
|
9 | 79638566 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 79638566 | bellard | *
|
11 | 79638566 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 79638566 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 79638566 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 79638566 | bellard | * Lesser General Public License for more details.
|
15 | 79638566 | bellard | *
|
16 | 79638566 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 79638566 | bellard | * License along with this library; if not, write to the Free Software
|
18 | 79638566 | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 79638566 | bellard | */
|
20 | 67867308 | bellard | #if !defined(__DYNGEN_EXEC_H__)
|
21 | 67867308 | bellard | #define __DYNGEN_EXEC_H__
|
22 | 67867308 | bellard | |
23 | ec530c81 | bellard | /* prevent Solaris from trying to typedef FILE in gcc's
|
24 | ec530c81 | bellard | include/floatingpoint.h which will conflict with the
|
25 | ec530c81 | bellard | definition down below */
|
26 | ec530c81 | bellard | #ifdef __sun__
|
27 | ec530c81 | bellard | #define _FILEDEFED
|
28 | ec530c81 | bellard | #endif
|
29 | ec530c81 | bellard | |
30 | 1e6cae95 | bellard | /* NOTE: standard headers should be used with special care at this
|
31 | 1e6cae95 | bellard | point because host CPU registers are used as global variables. Some
|
32 | 1e6cae95 | bellard | host headers do not allow that. */
|
33 | 513b500f | bellard | #include <stddef.h> |
34 | 513b500f | bellard | |
35 | 79638566 | bellard | typedef unsigned char uint8_t; |
36 | 79638566 | bellard | typedef unsigned short uint16_t; |
37 | 79638566 | bellard | typedef unsigned int uint32_t; |
38 | 4f2ac237 | bellard | /* XXX may be done for all 64 bits targets ? */
|
39 | b8076a74 | bellard | #if defined (__x86_64__) || defined(__ia64)
|
40 | 4f2ac237 | bellard | typedef unsigned long uint64_t; |
41 | 4f2ac237 | bellard | #else
|
42 | 79638566 | bellard | typedef unsigned long long uint64_t; |
43 | 4f2ac237 | bellard | #endif
|
44 | 79638566 | bellard | |
45 | ec530c81 | bellard | /* if Solaris/__sun__, don't typedef int8_t, as it will be typedef'd
|
46 | ec530c81 | bellard | prior to this and will cause an error in compliation, conflicting
|
47 | ec530c81 | bellard | with /usr/include/sys/int_types.h, line 75 */
|
48 | ec530c81 | bellard | #ifndef __sun__
|
49 | 79638566 | bellard | typedef signed char int8_t; |
50 | ec530c81 | bellard | #endif
|
51 | 79638566 | bellard | typedef signed short int16_t; |
52 | 79638566 | bellard | typedef signed int int32_t; |
53 | b8076a74 | bellard | #if defined (__x86_64__) || defined(__ia64)
|
54 | 4f2ac237 | bellard | typedef signed long int64_t; |
55 | 4f2ac237 | bellard | #else
|
56 | 79638566 | bellard | typedef signed long long int64_t; |
57 | 4f2ac237 | bellard | #endif
|
58 | 79638566 | bellard | |
59 | 67867308 | bellard | #define INT8_MIN (-128) |
60 | 67867308 | bellard | #define INT16_MIN (-32767-1) |
61 | 67867308 | bellard | #define INT32_MIN (-2147483647-1) |
62 | 67867308 | bellard | #define INT64_MIN (-(int64_t)(9223372036854775807)-1) |
63 | 67867308 | bellard | #define INT8_MAX (127) |
64 | 67867308 | bellard | #define INT16_MAX (32767) |
65 | 67867308 | bellard | #define INT32_MAX (2147483647) |
66 | 67867308 | bellard | #define INT64_MAX ((int64_t)(9223372036854775807)) |
67 | 67867308 | bellard | #define UINT8_MAX (255) |
68 | 67867308 | bellard | #define UINT16_MAX (65535) |
69 | 67867308 | bellard | #define UINT32_MAX (4294967295U) |
70 | 67867308 | bellard | #define UINT64_MAX ((uint64_t)(18446744073709551615)) |
71 | 67867308 | bellard | |
72 | 79638566 | bellard | typedef struct FILE FILE; |
73 | 79638566 | bellard | extern int fprintf(FILE *, const char *, ...); |
74 | 79638566 | bellard | extern int printf(const char *, ...); |
75 | 513b500f | bellard | #undef NULL |
76 | 79638566 | bellard | #define NULL 0 |
77 | 79638566 | bellard | |
78 | 79638566 | bellard | #ifdef __i386__
|
79 | 79638566 | bellard | #define AREG0 "ebp" |
80 | 79638566 | bellard | #define AREG1 "ebx" |
81 | 79638566 | bellard | #define AREG2 "esi" |
82 | 79638566 | bellard | #define AREG3 "edi" |
83 | 79638566 | bellard | #endif
|
84 | bc51c5c9 | bellard | #ifdef __x86_64__
|
85 | bc51c5c9 | bellard | #define AREG0 "rbp" |
86 | bc51c5c9 | bellard | #define AREG1 "rbx" |
87 | bc51c5c9 | bellard | #define AREG2 "r12" |
88 | bc51c5c9 | bellard | #define AREG3 "r13" |
89 | dff293e7 | bellard | //#define AREG4 "r14"
|
90 | dff293e7 | bellard | //#define AREG5 "r15"
|
91 | bc51c5c9 | bellard | #endif
|
92 | 79638566 | bellard | #ifdef __powerpc__
|
93 | 79638566 | bellard | #define AREG0 "r27" |
94 | 79638566 | bellard | #define AREG1 "r24" |
95 | 79638566 | bellard | #define AREG2 "r25" |
96 | 79638566 | bellard | #define AREG3 "r26" |
97 | bf71c9d9 | bellard | /* XXX: suppress this hack */
|
98 | bf71c9d9 | bellard | #if defined(CONFIG_USER_ONLY)
|
99 | 79638566 | bellard | #define AREG4 "r16" |
100 | 79638566 | bellard | #define AREG5 "r17" |
101 | 79638566 | bellard | #define AREG6 "r18" |
102 | 79638566 | bellard | #define AREG7 "r19" |
103 | 79638566 | bellard | #define AREG8 "r20" |
104 | 79638566 | bellard | #define AREG9 "r21" |
105 | 79638566 | bellard | #define AREG10 "r22" |
106 | 79638566 | bellard | #define AREG11 "r23" |
107 | bf71c9d9 | bellard | #endif
|
108 | 79638566 | bellard | #define USE_INT_TO_FLOAT_HELPERS
|
109 | 79638566 | bellard | #define BUGGY_GCC_DIV64
|
110 | 79638566 | bellard | #endif
|
111 | 79638566 | bellard | #ifdef __arm__
|
112 | 79638566 | bellard | #define AREG0 "r7" |
113 | 79638566 | bellard | #define AREG1 "r4" |
114 | 79638566 | bellard | #define AREG2 "r5" |
115 | 79638566 | bellard | #define AREG3 "r6" |
116 | 79638566 | bellard | #endif
|
117 | 79638566 | bellard | #ifdef __mips__
|
118 | 79638566 | bellard | #define AREG0 "s3" |
119 | 79638566 | bellard | #define AREG1 "s0" |
120 | 79638566 | bellard | #define AREG2 "s1" |
121 | 79638566 | bellard | #define AREG3 "s2" |
122 | 79638566 | bellard | #endif
|
123 | 79638566 | bellard | #ifdef __sparc__
|
124 | 79638566 | bellard | #define AREG0 "g6" |
125 | 79638566 | bellard | #define AREG1 "g1" |
126 | 79638566 | bellard | #define AREG2 "g2" |
127 | 79638566 | bellard | #define AREG3 "g3" |
128 | 79638566 | bellard | #define AREG4 "l0" |
129 | 79638566 | bellard | #define AREG5 "l1" |
130 | 79638566 | bellard | #define AREG6 "l2" |
131 | 79638566 | bellard | #define AREG7 "l3" |
132 | 79638566 | bellard | #define AREG8 "l4" |
133 | 79638566 | bellard | #define AREG9 "l5" |
134 | 79638566 | bellard | #define AREG10 "l6" |
135 | 79638566 | bellard | #define AREG11 "l7" |
136 | 79638566 | bellard | #define USE_FP_CONVERT
|
137 | 79638566 | bellard | #endif
|
138 | 79638566 | bellard | #ifdef __s390__
|
139 | 79638566 | bellard | #define AREG0 "r10" |
140 | 79638566 | bellard | #define AREG1 "r7" |
141 | 79638566 | bellard | #define AREG2 "r8" |
142 | 79638566 | bellard | #define AREG3 "r9" |
143 | 79638566 | bellard | #endif
|
144 | 79638566 | bellard | #ifdef __alpha__
|
145 | 79638566 | bellard | /* Note $15 is the frame pointer, so anything in op-i386.c that would
|
146 | 79638566 | bellard | require a frame pointer, like alloca, would probably loose. */
|
147 | 79638566 | bellard | #define AREG0 "$15" |
148 | 79638566 | bellard | #define AREG1 "$9" |
149 | 79638566 | bellard | #define AREG2 "$10" |
150 | 79638566 | bellard | #define AREG3 "$11" |
151 | 79638566 | bellard | #define AREG4 "$12" |
152 | 79638566 | bellard | #define AREG5 "$13" |
153 | 79638566 | bellard | #define AREG6 "$14" |
154 | 79638566 | bellard | #endif
|
155 | 38e584a0 | bellard | #ifdef __mc68000
|
156 | 38e584a0 | bellard | #define AREG0 "%a5" |
157 | 38e584a0 | bellard | #define AREG1 "%a4" |
158 | 38e584a0 | bellard | #define AREG2 "%d7" |
159 | 38e584a0 | bellard | #define AREG3 "%d6" |
160 | 38e584a0 | bellard | #define AREG4 "%d5" |
161 | 38e584a0 | bellard | #endif
|
162 | 79638566 | bellard | #ifdef __ia64__
|
163 | b8076a74 | bellard | #define AREG0 "r7" |
164 | b8076a74 | bellard | #define AREG1 "r4" |
165 | b8076a74 | bellard | #define AREG2 "r5" |
166 | b8076a74 | bellard | #define AREG3 "r6" |
167 | 79638566 | bellard | #endif
|
168 | 79638566 | bellard | |
169 | 79638566 | bellard | /* force GCC to generate only one epilog at the end of the function */
|
170 | 79638566 | bellard | #define FORCE_RET() asm volatile (""); |
171 | 79638566 | bellard | |
172 | 79638566 | bellard | #ifndef OPPROTO
|
173 | 79638566 | bellard | #define OPPROTO
|
174 | 79638566 | bellard | #endif
|
175 | 79638566 | bellard | |
176 | 79638566 | bellard | #define xglue(x, y) x ## y |
177 | 79638566 | bellard | #define glue(x, y) xglue(x, y)
|
178 | 9621339d | bellard | #define stringify(s) tostring(s)
|
179 | 9621339d | bellard | #define tostring(s) #s |
180 | 79638566 | bellard | |
181 | 79638566 | bellard | #ifdef __alpha__
|
182 | 79638566 | bellard | /* the symbols are considered non exported so a br immediate is generated */
|
183 | 79638566 | bellard | #define __hidden __attribute__((visibility("hidden"))) |
184 | 79638566 | bellard | #else
|
185 | 79638566 | bellard | #define __hidden
|
186 | 79638566 | bellard | #endif
|
187 | 79638566 | bellard | |
188 | cab84d98 | bellard | #if defined(__alpha__)
|
189 | 79638566 | bellard | /* Suggested by Richard Henderson. This will result in code like
|
190 | 79638566 | bellard | ldah $0,__op_param1($29) !gprelhigh
|
191 | 79638566 | bellard | lda $0,__op_param1($0) !gprellow
|
192 | 79638566 | bellard | We can then conveniently change $29 to $31 and adapt the offsets to
|
193 | 79638566 | bellard | emit the appropriate constant. */
|
194 | 79638566 | bellard | extern int __op_param1 __hidden; |
195 | 79638566 | bellard | extern int __op_param2 __hidden; |
196 | 79638566 | bellard | extern int __op_param3 __hidden; |
197 | 79638566 | bellard | #define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; }) |
198 | 79638566 | bellard | #define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; }) |
199 | 79638566 | bellard | #define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; }) |
200 | 79638566 | bellard | #else
|
201 | cab84d98 | bellard | #if defined(__APPLE__)
|
202 | cab84d98 | bellard | static int __op_param1, __op_param2, __op_param3; |
203 | cab84d98 | bellard | #else
|
204 | 79638566 | bellard | extern int __op_param1, __op_param2, __op_param3; |
205 | cab84d98 | bellard | #endif
|
206 | 79638566 | bellard | #define PARAM1 ((long)(&__op_param1)) |
207 | 79638566 | bellard | #define PARAM2 ((long)(&__op_param2)) |
208 | 79638566 | bellard | #define PARAM3 ((long)(&__op_param3)) |
209 | cab84d98 | bellard | #endif /* !defined(__alpha__) */ |
210 | 79638566 | bellard | |
211 | c106152d | bellard | extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3; |
212 | 9621339d | bellard | |
213 | 9191d4d1 | bellard | #if defined(_WIN32) || defined(__APPLE__)
|
214 | 9df8aa4a | bellard | #define ASM_NAME(x) "_" #x |
215 | 9df8aa4a | bellard | #else
|
216 | 9df8aa4a | bellard | #define ASM_NAME(x) #x |
217 | 9df8aa4a | bellard | #endif
|
218 | 9df8aa4a | bellard | |
219 | 9621339d | bellard | #ifdef __i386__
|
220 | 9621339d | bellard | #define EXIT_TB() asm volatile ("ret") |
221 | 9df8aa4a | bellard | #define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n) |
222 | 9621339d | bellard | #endif
|
223 | bc51c5c9 | bellard | #ifdef __x86_64__
|
224 | bc51c5c9 | bellard | #define EXIT_TB() asm volatile ("ret") |
225 | d785e6be | bellard | #define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n) |
226 | bc51c5c9 | bellard | #endif
|
227 | 9621339d | bellard | #ifdef __powerpc__
|
228 | 9621339d | bellard | #define EXIT_TB() asm volatile ("blr") |
229 | 9df8aa4a | bellard | #define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n) |
230 | 9621339d | bellard | #endif
|
231 | 9621339d | bellard | #ifdef __s390__
|
232 | 9621339d | bellard | #define EXIT_TB() asm volatile ("br %r14") |
233 | 90cb9493 | bellard | #define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n) |
234 | 9621339d | bellard | #endif
|
235 | 9621339d | bellard | #ifdef __alpha__
|
236 | 9621339d | bellard | #define EXIT_TB() asm volatile ("ret") |
237 | 9621339d | bellard | #endif
|
238 | 9621339d | bellard | #ifdef __ia64__
|
239 | 9621339d | bellard | #define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;") |
240 | b8076a74 | bellard | #define GOTO_LABEL_PARAM(n) asm volatile ("br.sptk.many " \ |
241 | b8076a74 | bellard | ASM_NAME(__op_gen_label) #n)
|
242 | 9621339d | bellard | #endif
|
243 | 9621339d | bellard | #ifdef __sparc__
|
244 | a96fc003 | bellard | #define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0\n" \ |
245 | 9621339d | bellard | "nop")
|
246 | ec530c81 | bellard | #define GOTO_LABEL_PARAM(n) asm volatile ( \ |
247 | ec530c81 | bellard | "set " ASM_NAME(__op_gen_label) #n ", %g1; jmp %g1; nop") |
248 | 9621339d | bellard | #endif
|
249 | 9621339d | bellard | #ifdef __arm__
|
250 | 9621339d | bellard | #define EXIT_TB() asm volatile ("b exec_loop") |
251 | ae200d10 | bellard | #define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n) |
252 | 9621339d | bellard | #endif
|
253 | 38e584a0 | bellard | #ifdef __mc68000
|
254 | 38e584a0 | bellard | #define EXIT_TB() asm volatile ("rts") |
255 | 38e584a0 | bellard | #endif
|
256 | 67867308 | bellard | |
257 | 67867308 | bellard | #endif /* !defined(__DYNGEN_EXEC_H__) */ |