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