root / dyngen-exec.h @ 3e11db9a
History | View | Annotate | Download (6 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 | 1e6cae95 | bellard | /* NOTE: standard headers should be used with special care at this
|
24 | 1e6cae95 | bellard | point because host CPU registers are used as global variables. Some
|
25 | 1e6cae95 | bellard | host headers do not allow that. */
|
26 | 513b500f | bellard | #include <stddef.h> |
27 | 513b500f | bellard | |
28 | 79638566 | bellard | typedef unsigned char uint8_t; |
29 | 79638566 | bellard | typedef unsigned short uint16_t; |
30 | 79638566 | bellard | typedef unsigned int uint32_t; |
31 | 4f2ac237 | bellard | /* XXX may be done for all 64 bits targets ? */
|
32 | 4f2ac237 | bellard | #if defined (__x86_64__)
|
33 | 4f2ac237 | bellard | typedef unsigned long uint64_t; |
34 | 4f2ac237 | bellard | #else
|
35 | 79638566 | bellard | typedef unsigned long long uint64_t; |
36 | 4f2ac237 | bellard | #endif
|
37 | 79638566 | bellard | |
38 | 79638566 | bellard | typedef signed char int8_t; |
39 | 79638566 | bellard | typedef signed short int16_t; |
40 | 79638566 | bellard | typedef signed int int32_t; |
41 | 4f2ac237 | bellard | #if defined (__x86_64__)
|
42 | 4f2ac237 | bellard | typedef signed long int64_t; |
43 | 4f2ac237 | bellard | #else
|
44 | 79638566 | bellard | typedef signed long long int64_t; |
45 | 4f2ac237 | bellard | #endif
|
46 | 79638566 | bellard | |
47 | 67867308 | bellard | #define INT8_MIN (-128) |
48 | 67867308 | bellard | #define INT16_MIN (-32767-1) |
49 | 67867308 | bellard | #define INT32_MIN (-2147483647-1) |
50 | 67867308 | bellard | #define INT64_MIN (-(int64_t)(9223372036854775807)-1) |
51 | 67867308 | bellard | #define INT8_MAX (127) |
52 | 67867308 | bellard | #define INT16_MAX (32767) |
53 | 67867308 | bellard | #define INT32_MAX (2147483647) |
54 | 67867308 | bellard | #define INT64_MAX ((int64_t)(9223372036854775807)) |
55 | 67867308 | bellard | #define UINT8_MAX (255) |
56 | 67867308 | bellard | #define UINT16_MAX (65535) |
57 | 67867308 | bellard | #define UINT32_MAX (4294967295U) |
58 | 67867308 | bellard | #define UINT64_MAX ((uint64_t)(18446744073709551615)) |
59 | 67867308 | bellard | |
60 | 79638566 | bellard | typedef struct FILE FILE; |
61 | 79638566 | bellard | extern int fprintf(FILE *, const char *, ...); |
62 | 79638566 | bellard | extern int printf(const char *, ...); |
63 | 513b500f | bellard | #undef NULL |
64 | 79638566 | bellard | #define NULL 0 |
65 | 83fb7adf | bellard | #if defined(_BSD) && !defined(__APPLE__)
|
66 | 7d3505c5 | bellard | #include <ieeefp.h> |
67 | 83fb7adf | bellard | |
68 | 83fb7adf | bellard | #define FE_TONEAREST FP_RN
|
69 | 83fb7adf | bellard | #define FE_DOWNWARD FP_RM
|
70 | 83fb7adf | bellard | #define FE_UPWARD FP_RP
|
71 | 83fb7adf | bellard | #define FE_TOWARDZERO FP_RZ
|
72 | 83fb7adf | bellard | #define fesetround(x) fpsetround(x)
|
73 | 7d3505c5 | bellard | #else
|
74 | 79638566 | bellard | #include <fenv.h> |
75 | 7d3505c5 | bellard | #endif
|
76 | 79638566 | bellard | |
77 | 79638566 | bellard | #ifdef __i386__
|
78 | 79638566 | bellard | #define AREG0 "ebp" |
79 | 79638566 | bellard | #define AREG1 "ebx" |
80 | 79638566 | bellard | #define AREG2 "esi" |
81 | 79638566 | bellard | #define AREG3 "edi" |
82 | 79638566 | bellard | #endif
|
83 | bc51c5c9 | bellard | #ifdef __x86_64__
|
84 | bc51c5c9 | bellard | #define AREG0 "rbp" |
85 | bc51c5c9 | bellard | #define AREG1 "rbx" |
86 | bc51c5c9 | bellard | #define AREG2 "r12" |
87 | bc51c5c9 | bellard | #define AREG3 "r13" |
88 | bc51c5c9 | bellard | #define AREG4 "r14" |
89 | bc51c5c9 | bellard | #define AREG5 "r15" |
90 | bc51c5c9 | bellard | #endif
|
91 | 79638566 | bellard | #ifdef __powerpc__
|
92 | 79638566 | bellard | #define AREG0 "r27" |
93 | 79638566 | bellard | #define AREG1 "r24" |
94 | 79638566 | bellard | #define AREG2 "r25" |
95 | 79638566 | bellard | #define AREG3 "r26" |
96 | c970a162 | bellard | /* XXX: suppress this hack */
|
97 | c970a162 | bellard | #if defined(CONFIG_USER_ONLY)
|
98 | 79638566 | bellard | #define AREG4 "r16" |
99 | 79638566 | bellard | #define AREG5 "r17" |
100 | 79638566 | bellard | #define AREG6 "r18" |
101 | 79638566 | bellard | #define AREG7 "r19" |
102 | 79638566 | bellard | #define AREG8 "r20" |
103 | 79638566 | bellard | #define AREG9 "r21" |
104 | 79638566 | bellard | #define AREG10 "r22" |
105 | 79638566 | bellard | #define AREG11 "r23" |
106 | c970a162 | bellard | #endif
|
107 | 79638566 | bellard | #define USE_INT_TO_FLOAT_HELPERS
|
108 | 79638566 | bellard | #define BUGGY_GCC_DIV64
|
109 | 79638566 | bellard | #endif
|
110 | 79638566 | bellard | #ifdef __arm__
|
111 | 79638566 | bellard | #define AREG0 "r7" |
112 | 79638566 | bellard | #define AREG1 "r4" |
113 | 79638566 | bellard | #define AREG2 "r5" |
114 | 79638566 | bellard | #define AREG3 "r6" |
115 | 79638566 | bellard | #endif
|
116 | 79638566 | bellard | #ifdef __mips__
|
117 | 79638566 | bellard | #define AREG0 "s3" |
118 | 79638566 | bellard | #define AREG1 "s0" |
119 | 79638566 | bellard | #define AREG2 "s1" |
120 | 79638566 | bellard | #define AREG3 "s2" |
121 | 79638566 | bellard | #endif
|
122 | 79638566 | bellard | #ifdef __sparc__
|
123 | 79638566 | bellard | #define AREG0 "g6" |
124 | 79638566 | bellard | #define AREG1 "g1" |
125 | 79638566 | bellard | #define AREG2 "g2" |
126 | 79638566 | bellard | #define AREG3 "g3" |
127 | 79638566 | bellard | #define AREG4 "l0" |
128 | 79638566 | bellard | #define AREG5 "l1" |
129 | 79638566 | bellard | #define AREG6 "l2" |
130 | 79638566 | bellard | #define AREG7 "l3" |
131 | 79638566 | bellard | #define AREG8 "l4" |
132 | 79638566 | bellard | #define AREG9 "l5" |
133 | 79638566 | bellard | #define AREG10 "l6" |
134 | 79638566 | bellard | #define AREG11 "l7" |
135 | 79638566 | bellard | #define USE_FP_CONVERT
|
136 | 79638566 | bellard | #endif
|
137 | 79638566 | bellard | #ifdef __s390__
|
138 | 79638566 | bellard | #define AREG0 "r10" |
139 | 79638566 | bellard | #define AREG1 "r7" |
140 | 79638566 | bellard | #define AREG2 "r8" |
141 | 79638566 | bellard | #define AREG3 "r9" |
142 | 79638566 | bellard | #endif
|
143 | 79638566 | bellard | #ifdef __alpha__
|
144 | 79638566 | bellard | /* Note $15 is the frame pointer, so anything in op-i386.c that would
|
145 | 79638566 | bellard | require a frame pointer, like alloca, would probably loose. */
|
146 | 79638566 | bellard | #define AREG0 "$15" |
147 | 79638566 | bellard | #define AREG1 "$9" |
148 | 79638566 | bellard | #define AREG2 "$10" |
149 | 79638566 | bellard | #define AREG3 "$11" |
150 | 79638566 | bellard | #define AREG4 "$12" |
151 | 79638566 | bellard | #define AREG5 "$13" |
152 | 79638566 | bellard | #define AREG6 "$14" |
153 | 79638566 | bellard | #endif
|
154 | 38e584a0 | bellard | #ifdef __mc68000
|
155 | 38e584a0 | bellard | #define AREG0 "%a5" |
156 | 38e584a0 | bellard | #define AREG1 "%a4" |
157 | 38e584a0 | bellard | #define AREG2 "%d7" |
158 | 38e584a0 | bellard | #define AREG3 "%d6" |
159 | 38e584a0 | bellard | #define AREG4 "%d5" |
160 | 38e584a0 | bellard | #endif
|
161 | 79638566 | bellard | #ifdef __ia64__
|
162 | 79638566 | bellard | #define AREG0 "r27" |
163 | 79638566 | bellard | #define AREG1 "r24" |
164 | 79638566 | bellard | #define AREG2 "r25" |
165 | 79638566 | bellard | #define AREG3 "r26" |
166 | 79638566 | bellard | #endif
|
167 | 79638566 | bellard | |
168 | 79638566 | bellard | /* force GCC to generate only one epilog at the end of the function */
|
169 | 79638566 | bellard | #define FORCE_RET() asm volatile (""); |
170 | 79638566 | bellard | |
171 | 79638566 | bellard | #ifndef OPPROTO
|
172 | 79638566 | bellard | #define OPPROTO
|
173 | 79638566 | bellard | #endif
|
174 | 79638566 | bellard | |
175 | 79638566 | bellard | #define xglue(x, y) x ## y |
176 | 79638566 | bellard | #define glue(x, y) xglue(x, y)
|
177 | 9621339d | bellard | #define stringify(s) tostring(s)
|
178 | 9621339d | bellard | #define tostring(s) #s |
179 | 79638566 | bellard | |
180 | 79638566 | bellard | #ifdef __alpha__
|
181 | 79638566 | bellard | /* the symbols are considered non exported so a br immediate is generated */
|
182 | 79638566 | bellard | #define __hidden __attribute__((visibility("hidden"))) |
183 | 79638566 | bellard | #else
|
184 | 79638566 | bellard | #define __hidden
|
185 | 79638566 | bellard | #endif
|
186 | 79638566 | bellard | |
187 | cab84d98 | bellard | #if defined(__alpha__)
|
188 | 79638566 | bellard | /* Suggested by Richard Henderson. This will result in code like
|
189 | 79638566 | bellard | ldah $0,__op_param1($29) !gprelhigh
|
190 | 79638566 | bellard | lda $0,__op_param1($0) !gprellow
|
191 | 79638566 | bellard | We can then conveniently change $29 to $31 and adapt the offsets to
|
192 | 79638566 | bellard | emit the appropriate constant. */
|
193 | 79638566 | bellard | extern int __op_param1 __hidden; |
194 | 79638566 | bellard | extern int __op_param2 __hidden; |
195 | 79638566 | bellard | extern int __op_param3 __hidden; |
196 | 79638566 | bellard | #define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; }) |
197 | 79638566 | bellard | #define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; }) |
198 | 79638566 | bellard | #define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; }) |
199 | 79638566 | bellard | #else
|
200 | cab84d98 | bellard | #if defined(__APPLE__)
|
201 | cab84d98 | bellard | static int __op_param1, __op_param2, __op_param3; |
202 | cab84d98 | bellard | #else
|
203 | 79638566 | bellard | extern int __op_param1, __op_param2, __op_param3; |
204 | cab84d98 | bellard | #endif
|
205 | 79638566 | bellard | #define PARAM1 ((long)(&__op_param1)) |
206 | 79638566 | bellard | #define PARAM2 ((long)(&__op_param2)) |
207 | 79638566 | bellard | #define PARAM3 ((long)(&__op_param3)) |
208 | cab84d98 | bellard | #endif /* !defined(__alpha__) */ |
209 | 79638566 | bellard | |
210 | c106152d | bellard | extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3; |
211 | 9621339d | bellard | |
212 | 9621339d | bellard | #ifdef __i386__
|
213 | 9621339d | bellard | #define EXIT_TB() asm volatile ("ret") |
214 | 9621339d | bellard | #endif
|
215 | bc51c5c9 | bellard | #ifdef __x86_64__
|
216 | bc51c5c9 | bellard | #define EXIT_TB() asm volatile ("ret") |
217 | bc51c5c9 | bellard | #endif
|
218 | 9621339d | bellard | #ifdef __powerpc__
|
219 | 9621339d | bellard | #define EXIT_TB() asm volatile ("blr") |
220 | 9621339d | bellard | #endif
|
221 | 9621339d | bellard | #ifdef __s390__
|
222 | 9621339d | bellard | #define EXIT_TB() asm volatile ("br %r14") |
223 | 9621339d | bellard | #endif
|
224 | 9621339d | bellard | #ifdef __alpha__
|
225 | 9621339d | bellard | #define EXIT_TB() asm volatile ("ret") |
226 | 9621339d | bellard | #endif
|
227 | 9621339d | bellard | #ifdef __ia64__
|
228 | 9621339d | bellard | #define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;") |
229 | 9621339d | bellard | #endif
|
230 | 9621339d | bellard | #ifdef __sparc__
|
231 | a96fc003 | bellard | #define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0\n" \ |
232 | 9621339d | bellard | "nop")
|
233 | 9621339d | bellard | #endif
|
234 | 9621339d | bellard | #ifdef __arm__
|
235 | 9621339d | bellard | #define EXIT_TB() asm volatile ("b exec_loop") |
236 | 9621339d | bellard | #endif
|
237 | 38e584a0 | bellard | #ifdef __mc68000
|
238 | 38e584a0 | bellard | #define EXIT_TB() asm volatile ("rts") |
239 | 38e584a0 | bellard | #endif
|
240 | 67867308 | bellard | |
241 | 67867308 | bellard | #endif /* !defined(__DYNGEN_EXEC_H__) */ |