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