]>
Commit | Line | Data |
---|---|---|
3ef693a0 FB |
1 | /* |
2 | * i386 execution defines | |
3 | * | |
4 | * Copyright (c) 2003 Fabrice Bellard | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; either | |
9 | * version 2 of the License, or (at your option) any later version. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
17 | * License along with this library; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | */ | |
7d13299d FB |
20 | typedef unsigned char uint8_t; |
21 | typedef unsigned short uint16_t; | |
22 | typedef unsigned int uint32_t; | |
23 | typedef unsigned long long uint64_t; | |
24 | ||
25 | typedef signed char int8_t; | |
26 | typedef signed short int16_t; | |
27 | typedef signed int int32_t; | |
28 | typedef signed long long int64_t; | |
29 | ||
30 | #define bswap32(x) \ | |
31 | ({ \ | |
32 | uint32_t __x = (x); \ | |
33 | ((uint32_t)( \ | |
34 | (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ | |
35 | (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ | |
36 | (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ | |
37 | (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ | |
38 | }) | |
39 | ||
40 | #define NULL 0 | |
41 | #include <fenv.h> | |
42 | ||
43 | typedef struct FILE FILE; | |
44 | extern FILE *logfile; | |
45 | extern int loglevel; | |
46 | extern int fprintf(FILE *, const char *, ...); | |
6dbad63e | 47 | extern int printf(const char *, ...); |
7d13299d FB |
48 | |
49 | #ifdef __i386__ | |
50 | register unsigned int T0 asm("ebx"); | |
51 | register unsigned int T1 asm("esi"); | |
52 | register unsigned int A0 asm("edi"); | |
53 | register struct CPUX86State *env asm("ebp"); | |
54 | #endif | |
55 | #ifdef __powerpc__ | |
04369ff2 FB |
56 | register unsigned int EAX asm("r16"); |
57 | register unsigned int ECX asm("r17"); | |
58 | register unsigned int EDX asm("r18"); | |
59 | register unsigned int EBX asm("r19"); | |
60 | register unsigned int ESP asm("r20"); | |
61 | register unsigned int EBP asm("r21"); | |
62 | register unsigned int ESI asm("r22"); | |
63 | register unsigned int EDI asm("r23"); | |
7d13299d FB |
64 | register unsigned int T0 asm("r24"); |
65 | register unsigned int T1 asm("r25"); | |
66 | register unsigned int A0 asm("r26"); | |
67 | register struct CPUX86State *env asm("r27"); | |
04369ff2 | 68 | #define USE_INT_TO_FLOAT_HELPERS |
d03cda59 | 69 | #define BUGGY_GCC_DIV64 |
04369ff2 FB |
70 | #define reg_EAX |
71 | #define reg_ECX | |
72 | #define reg_EDX | |
73 | #define reg_EBX | |
74 | #define reg_ESP | |
75 | #define reg_EBP | |
76 | #define reg_ESI | |
77 | #define reg_EDI | |
7d13299d FB |
78 | #endif |
79 | #ifdef __arm__ | |
80 | register unsigned int T0 asm("r4"); | |
81 | register unsigned int T1 asm("r5"); | |
82 | register unsigned int A0 asm("r6"); | |
83 | register struct CPUX86State *env asm("r7"); | |
84 | #endif | |
85 | #ifdef __mips__ | |
86 | register unsigned int T0 asm("s0"); | |
87 | register unsigned int T1 asm("s1"); | |
88 | register unsigned int A0 asm("s2"); | |
89 | register struct CPUX86State *env asm("s3"); | |
90 | #endif | |
91 | #ifdef __sparc__ | |
ae228531 FB |
92 | register unsigned int EAX asm("l0"); |
93 | register unsigned int ECX asm("l1"); | |
94 | register unsigned int EDX asm("l2"); | |
95 | register unsigned int EBX asm("l3"); | |
96 | register unsigned int ESP asm("l4"); | |
97 | register unsigned int EBP asm("l5"); | |
98 | register unsigned int ESI asm("l6"); | |
99 | register unsigned int EDI asm("l7"); | |
100 | register unsigned int T0 asm("g1"); | |
101 | register unsigned int T1 asm("g2"); | |
102 | register unsigned int A0 asm("g3"); | |
103 | register struct CPUX86State *env asm("g6"); | |
d014c98c | 104 | #define USE_FP_CONVERT |
ae228531 FB |
105 | #define reg_EAX |
106 | #define reg_ECX | |
107 | #define reg_EDX | |
108 | #define reg_EBX | |
109 | #define reg_ESP | |
110 | #define reg_EBP | |
111 | #define reg_ESI | |
112 | #define reg_EDI | |
7d13299d | 113 | #endif |
fb3e5849 FB |
114 | #ifdef __s390__ |
115 | register unsigned int T0 asm("r7"); | |
116 | register unsigned int T1 asm("r8"); | |
117 | register unsigned int A0 asm("r9"); | |
118 | register struct CPUX86State *env asm("r10"); | |
119 | #endif | |
d03cda59 FB |
120 | #ifdef __alpha__ |
121 | register unsigned int T0 asm("$9"); | |
122 | register unsigned int T1 asm("$10"); | |
123 | register unsigned int A0 asm("$11"); | |
74c95119 FB |
124 | register unsigned int EAX asm("$12"); |
125 | register unsigned int ESP asm("$13"); | |
126 | register unsigned int EBP asm("$14"); | |
127 | register struct CPUX86State *env asm("$15"); | |
128 | #define reg_EAX | |
129 | #define reg_ESP | |
130 | #define reg_EBP | |
d03cda59 | 131 | #endif |
0d330196 FB |
132 | #ifdef __ia64__ |
133 | register unsigned int T0 asm("r24"); | |
134 | register unsigned int T1 asm("r25"); | |
135 | register unsigned int A0 asm("r26"); | |
136 | register struct CPUX86State *env asm("r27"); | |
137 | #endif | |
7d13299d FB |
138 | |
139 | /* force GCC to generate only one epilog at the end of the function */ | |
140 | #define FORCE_RET() asm volatile (""); | |
141 | ||
142 | #ifndef OPPROTO | |
143 | #define OPPROTO | |
144 | #endif | |
145 | ||
146 | #define xglue(x, y) x ## y | |
147 | #define glue(x, y) xglue(x, y) | |
148 | ||
04369ff2 | 149 | #ifndef reg_EAX |
7d13299d | 150 | #define EAX (env->regs[R_EAX]) |
04369ff2 FB |
151 | #endif |
152 | #ifndef reg_ECX | |
7d13299d | 153 | #define ECX (env->regs[R_ECX]) |
04369ff2 FB |
154 | #endif |
155 | #ifndef reg_EDX | |
7d13299d | 156 | #define EDX (env->regs[R_EDX]) |
04369ff2 FB |
157 | #endif |
158 | #ifndef reg_EBX | |
7d13299d | 159 | #define EBX (env->regs[R_EBX]) |
04369ff2 FB |
160 | #endif |
161 | #ifndef reg_ESP | |
7d13299d | 162 | #define ESP (env->regs[R_ESP]) |
04369ff2 FB |
163 | #endif |
164 | #ifndef reg_EBP | |
7d13299d | 165 | #define EBP (env->regs[R_EBP]) |
04369ff2 FB |
166 | #endif |
167 | #ifndef reg_ESI | |
7d13299d | 168 | #define ESI (env->regs[R_ESI]) |
04369ff2 FB |
169 | #endif |
170 | #ifndef reg_EDI | |
7d13299d | 171 | #define EDI (env->regs[R_EDI]) |
04369ff2 | 172 | #endif |
dab2ed99 | 173 | #define EIP (env->eip) |
7d13299d FB |
174 | #define DF (env->df) |
175 | ||
176 | #define CC_SRC (env->cc_src) | |
177 | #define CC_DST (env->cc_dst) | |
178 | #define CC_OP (env->cc_op) | |
179 | ||
180 | /* float macros */ | |
181 | #define FT0 (env->ft0) | |
182 | #define ST0 (env->fpregs[env->fpstt]) | |
183 | #define ST(n) (env->fpregs[(env->fpstt + (n)) & 7]) | |
184 | #define ST1 ST(1) | |
185 | ||
d014c98c FB |
186 | #ifdef USE_FP_CONVERT |
187 | #define FP_CONVERT (env->fp_convert) | |
188 | #endif | |
189 | ||
74c95119 FB |
190 | #ifdef __alpha__ |
191 | /* Suggested by Richard Henderson. This will result in code like | |
192 | ldah $0,__op_param1($29) !gprelhigh | |
193 | lda $0,__op_param1($0) !gprellow | |
194 | We can then conveniently change $29 to $31 and adapt the offsets to | |
195 | emit the appropriate constant. */ | |
196 | extern int __op_param1 __attribute__((visibility("hidden"))); | |
197 | extern int __op_param2 __attribute__((visibility("hidden"))); | |
198 | extern int __op_param3 __attribute__((visibility("hidden"))); | |
199 | #define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; }) | |
200 | #define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; }) | |
201 | #define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; }) | |
202 | #else | |
7d13299d FB |
203 | extern int __op_param1, __op_param2, __op_param3; |
204 | #define PARAM1 ((long)(&__op_param1)) | |
205 | #define PARAM2 ((long)(&__op_param2)) | |
206 | #define PARAM3 ((long)(&__op_param3)) | |
74c95119 | 207 | #endif |
7d13299d FB |
208 | |
209 | #include "cpu-i386.h" | |
210 | ||
211 | typedef struct CCTable { | |
212 | int (*compute_all)(void); /* return all the flags */ | |
213 | int (*compute_c)(void); /* return the C flag */ | |
214 | } CCTable; | |
215 | ||
216 | extern CCTable cc_table[]; | |
6dbad63e FB |
217 | |
218 | void load_seg(int seg_reg, int selector); | |
1b6b029e FB |
219 | void cpu_lock(void); |
220 | void cpu_unlock(void); | |
455b7619 | 221 | void raise_exception_err(int exception_index, int error_code); |
9de5e440 FB |
222 | void raise_exception(int exception_index); |
223 | ||
224 | void OPPROTO op_movl_eflags_T0(void); | |
225 | void OPPROTO op_movl_T0_eflags(void); |