1 |
gbeauche |
1.5 |
/* |
2 |
|
|
* compiler/compemu.h - Public interface and definitions |
3 |
|
|
* |
4 |
|
|
* Original 68040 JIT compiler for UAE, copyright 2000-2002 Bernd Meyer |
5 |
|
|
* |
6 |
gbeauche |
1.12 |
* Adaptation for Basilisk II and improvements, copyright 2000-2005 |
7 |
gbeauche |
1.5 |
* Gwenole Beauchesne |
8 |
|
|
* |
9 |
gbeauche |
1.16 |
* Basilisk II (C) 1997-2008 Christian Bauer |
10 |
gbeauche |
1.5 |
* |
11 |
|
|
* This program is free software; you can redistribute it and/or modify |
12 |
|
|
* it under the terms of the GNU General Public License as published by |
13 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
14 |
|
|
* (at your option) any later version. |
15 |
|
|
* |
16 |
|
|
* This program is distributed in the hope that it will be useful, |
17 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
|
|
* GNU General Public License for more details. |
20 |
|
|
* |
21 |
|
|
* You should have received a copy of the GNU General Public License |
22 |
|
|
* along with this program; if not, write to the Free Software |
23 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
|
|
*/ |
25 |
|
|
|
26 |
gbeauche |
1.1 |
#ifndef COMPEMU_H |
27 |
|
|
#define COMPEMU_H |
28 |
|
|
|
29 |
|
|
#include "newcpu.h" |
30 |
|
|
|
31 |
|
|
#if USE_JIT |
32 |
|
|
|
33 |
gbeauche |
1.15 |
#if defined __i386__ || defined __x86_64__ |
34 |
|
|
#include "flags_x86.h" |
35 |
|
|
#else |
36 |
|
|
#error "Unsupported JIT compiler for this architecture" |
37 |
|
|
#endif |
38 |
|
|
|
39 |
gbeauche |
1.1 |
#if JIT_DEBUG |
40 |
|
|
/* dump some information (m68k block, x86 block addresses) about the compiler state */ |
41 |
|
|
extern void compiler_dumpstate(void); |
42 |
|
|
#endif |
43 |
|
|
|
44 |
|
|
/* Now that we do block chaining, and also have linked lists on each tag, |
45 |
|
|
TAGMASK can be much smaller and still do its job. Saves several megs |
46 |
|
|
of memory! */ |
47 |
|
|
#define TAGMASK 0x0000ffff |
48 |
|
|
#define TAGSIZE (TAGMASK+1) |
49 |
|
|
#define MAXRUN 1024 |
50 |
gbeauche |
1.10 |
#define cacheline(x) (((uintptr)x)&TAGMASK) |
51 |
gbeauche |
1.1 |
|
52 |
|
|
extern uae_u8* start_pc_p; |
53 |
|
|
extern uae_u32 start_pc; |
54 |
|
|
|
55 |
|
|
struct blockinfo_t; |
56 |
|
|
|
57 |
|
|
struct cpu_history { |
58 |
|
|
uae_u16 * location; |
59 |
|
|
}; |
60 |
|
|
|
61 |
|
|
union cacheline { |
62 |
|
|
cpuop_func * handler; |
63 |
|
|
blockinfo_t * bi; |
64 |
|
|
}; |
65 |
|
|
|
66 |
gbeauche |
1.7 |
/* Use new spill/reload strategy when calling external functions */ |
67 |
|
|
#define USE_OPTIMIZED_CALLS 0 |
68 |
|
|
#if USE_OPTIMIZED_CALLS |
69 |
|
|
#error implementation in progress |
70 |
|
|
#endif |
71 |
|
|
|
72 |
gbeauche |
1.1 |
/* (gb) When on, this option can save save up to 30% compilation time |
73 |
|
|
* when many lazy flushes occur (e.g. apps in MacOS 8.x). |
74 |
|
|
*/ |
75 |
|
|
#define USE_SEPARATE_BIA 1 |
76 |
|
|
|
77 |
gbeauche |
1.2 |
/* Use chain of checksum_info_t to compute the block checksum */ |
78 |
gbeauche |
1.4 |
#define USE_CHECKSUM_INFO 1 |
79 |
gbeauche |
1.2 |
|
80 |
gbeauche |
1.3 |
/* Use code inlining, aka follow-up of constant jumps */ |
81 |
gbeauche |
1.4 |
#define USE_INLINING 1 |
82 |
|
|
|
83 |
|
|
/* Inlining requires the chained checksuming information */ |
84 |
|
|
#if USE_INLINING |
85 |
|
|
#undef USE_CHECKSUM_INFO |
86 |
|
|
#define USE_CHECKSUM_INFO 1 |
87 |
|
|
#endif |
88 |
gbeauche |
1.3 |
|
89 |
gbeauche |
1.8 |
/* Does flush_icache_range() only check for blocks falling in the requested range? */ |
90 |
|
|
#define LAZY_FLUSH_ICACHE_RANGE 0 |
91 |
|
|
|
92 |
gbeauche |
1.1 |
#define USE_F_ALIAS 1 |
93 |
|
|
#define USE_OFFSET 1 |
94 |
|
|
#define COMP_DEBUG 1 |
95 |
|
|
|
96 |
|
|
#if COMP_DEBUG |
97 |
|
|
#define Dif(x) if (x) |
98 |
|
|
#else |
99 |
|
|
#define Dif(x) if (0) |
100 |
|
|
#endif |
101 |
|
|
|
102 |
|
|
#define SCALE 2 |
103 |
|
|
|
104 |
|
|
#define BYTES_PER_INST 10240 /* paranoid ;-) */ |
105 |
|
|
#define LONGEST_68K_INST 16 /* The number of bytes the longest possible |
106 |
|
|
68k instruction takes */ |
107 |
|
|
#define MAX_CHECKSUM_LEN 2048 /* The maximum size we calculate checksums |
108 |
|
|
for. Anything larger will be flushed |
109 |
|
|
unconditionally even with SOFT_FLUSH */ |
110 |
|
|
#define MAX_HOLD_BI 3 /* One for the current block, and up to two |
111 |
|
|
for jump targets */ |
112 |
|
|
|
113 |
|
|
#define INDIVIDUAL_INST 0 |
114 |
|
|
#if 1 |
115 |
|
|
// gb-- my format from readcpu.cpp is not the same |
116 |
|
|
#define FLAG_X 0x0010 |
117 |
|
|
#define FLAG_N 0x0008 |
118 |
|
|
#define FLAG_Z 0x0004 |
119 |
|
|
#define FLAG_V 0x0002 |
120 |
|
|
#define FLAG_C 0x0001 |
121 |
|
|
#else |
122 |
|
|
#define FLAG_C 0x0010 |
123 |
|
|
#define FLAG_V 0x0008 |
124 |
|
|
#define FLAG_Z 0x0004 |
125 |
|
|
#define FLAG_N 0x0002 |
126 |
|
|
#define FLAG_X 0x0001 |
127 |
|
|
#endif |
128 |
|
|
#define FLAG_CZNV (FLAG_C | FLAG_Z | FLAG_N | FLAG_V) |
129 |
|
|
#define FLAG_ZNV (FLAG_Z | FLAG_N | FLAG_V) |
130 |
|
|
|
131 |
|
|
#define KILLTHERAT 1 /* Set to 1 to avoid some partial_rat_stalls */ |
132 |
|
|
|
133 |
gbeauche |
1.10 |
#if defined(__x86_64__) |
134 |
|
|
#define N_REGS 16 /* really only 15, but they are numbered 0-3,5-15 */ |
135 |
|
|
#else |
136 |
gbeauche |
1.1 |
#define N_REGS 8 /* really only 7, but they are numbered 0,1,2,3,5,6,7 */ |
137 |
gbeauche |
1.10 |
#endif |
138 |
gbeauche |
1.1 |
#define N_FREGS 6 /* That leaves us two positions on the stack to play with */ |
139 |
|
|
|
140 |
|
|
/* Functions exposed to newcpu, or to what was moved from newcpu.c to |
141 |
|
|
* compemu_support.c */ |
142 |
|
|
extern void compiler_init(void); |
143 |
|
|
extern void compiler_exit(void); |
144 |
|
|
extern bool compiler_use_jit(void); |
145 |
|
|
extern void init_comp(void); |
146 |
|
|
extern void flush(int save_regs); |
147 |
|
|
extern void small_flush(int save_regs); |
148 |
|
|
extern void set_target(uae_u8* t); |
149 |
|
|
extern uae_u8* get_target(void); |
150 |
|
|
extern void freescratch(void); |
151 |
|
|
extern void build_comp(void); |
152 |
|
|
extern void set_cache_state(int enabled); |
153 |
|
|
extern int get_cache_state(void); |
154 |
|
|
extern uae_u32 get_jitted_size(void); |
155 |
|
|
extern void (*flush_icache)(int n); |
156 |
|
|
extern void alloc_cache(void); |
157 |
|
|
extern int check_for_cache_miss(void); |
158 |
|
|
|
159 |
|
|
/* JIT FPU compilation */ |
160 |
|
|
extern void comp_fpp_opp (uae_u32 opcode, uae_u16 extra); |
161 |
|
|
extern void comp_fbcc_opp (uae_u32 opcode); |
162 |
|
|
extern void comp_fscc_opp (uae_u32 opcode, uae_u16 extra); |
163 |
|
|
|
164 |
|
|
extern uae_u32 needed_flags; |
165 |
|
|
extern cacheline cache_tags[]; |
166 |
|
|
extern uae_u8* comp_pc_p; |
167 |
|
|
extern void* pushall_call_handler; |
168 |
|
|
|
169 |
|
|
#define VREGS 32 |
170 |
|
|
#define VFREGS 16 |
171 |
|
|
|
172 |
|
|
#define INMEM 1 |
173 |
|
|
#define CLEAN 2 |
174 |
|
|
#define DIRTY 3 |
175 |
|
|
#define UNDEF 4 |
176 |
|
|
#define ISCONST 5 |
177 |
|
|
|
178 |
|
|
typedef struct { |
179 |
|
|
uae_u32* mem; |
180 |
|
|
uae_u32 val; |
181 |
|
|
uae_u8 is_swapped; |
182 |
|
|
uae_u8 status; |
183 |
|
|
uae_s8 realreg; /* gb-- realreg can hold -1 */ |
184 |
|
|
uae_u8 realind; /* The index in the holds[] array */ |
185 |
|
|
uae_u8 needflush; |
186 |
|
|
uae_u8 validsize; |
187 |
|
|
uae_u8 dirtysize; |
188 |
|
|
uae_u8 dummy; |
189 |
|
|
} reg_status; |
190 |
|
|
|
191 |
|
|
typedef struct { |
192 |
|
|
uae_u32* mem; |
193 |
|
|
double val; |
194 |
|
|
uae_u8 status; |
195 |
|
|
uae_s8 realreg; /* gb-- realreg can hold -1 */ |
196 |
|
|
uae_u8 realind; |
197 |
|
|
uae_u8 needflush; |
198 |
|
|
} freg_status; |
199 |
|
|
|
200 |
|
|
#define PC_P 16 |
201 |
|
|
#define FLAGX 17 |
202 |
|
|
#define FLAGTMP 18 |
203 |
|
|
#define NEXT_HANDLER 19 |
204 |
|
|
#define S1 20 |
205 |
|
|
#define S2 21 |
206 |
|
|
#define S3 22 |
207 |
|
|
#define S4 23 |
208 |
|
|
#define S5 24 |
209 |
|
|
#define S6 25 |
210 |
|
|
#define S7 26 |
211 |
|
|
#define S8 27 |
212 |
|
|
#define S9 28 |
213 |
|
|
#define S10 29 |
214 |
|
|
#define S11 30 |
215 |
|
|
#define S12 31 |
216 |
|
|
|
217 |
|
|
#define FP_RESULT 8 |
218 |
|
|
#define FS1 9 |
219 |
|
|
#define FS2 10 |
220 |
|
|
#define FS3 11 |
221 |
|
|
|
222 |
|
|
typedef struct { |
223 |
|
|
uae_u32 touched; |
224 |
|
|
uae_s8 holds[VREGS]; |
225 |
|
|
uae_u8 nholds; |
226 |
|
|
uae_u8 canbyte; |
227 |
|
|
uae_u8 canword; |
228 |
|
|
uae_u8 locked; |
229 |
|
|
} n_status; |
230 |
|
|
|
231 |
|
|
typedef struct { |
232 |
|
|
uae_u32 touched; |
233 |
|
|
uae_s8 holds[VFREGS]; |
234 |
|
|
uae_u8 nholds; |
235 |
|
|
uae_u8 locked; |
236 |
|
|
} fn_status; |
237 |
|
|
|
238 |
|
|
/* For flag handling */ |
239 |
|
|
#define NADA 1 |
240 |
|
|
#define TRASH 2 |
241 |
|
|
#define VALID 3 |
242 |
|
|
|
243 |
|
|
/* needflush values */ |
244 |
|
|
#define NF_SCRATCH 0 |
245 |
|
|
#define NF_TOMEM 1 |
246 |
|
|
#define NF_HANDLER 2 |
247 |
|
|
|
248 |
|
|
typedef struct { |
249 |
|
|
/* Integer part */ |
250 |
|
|
reg_status state[VREGS]; |
251 |
|
|
n_status nat[N_REGS]; |
252 |
|
|
uae_u32 flags_on_stack; |
253 |
|
|
uae_u32 flags_in_flags; |
254 |
|
|
uae_u32 flags_are_important; |
255 |
|
|
/* FPU part */ |
256 |
|
|
freg_status fate[VFREGS]; |
257 |
|
|
fn_status fat[N_FREGS]; |
258 |
|
|
|
259 |
|
|
/* x86 FPU part */ |
260 |
|
|
uae_s8 spos[N_FREGS]; |
261 |
|
|
uae_s8 onstack[6]; |
262 |
|
|
uae_s8 tos; |
263 |
|
|
} bigstate; |
264 |
|
|
|
265 |
|
|
typedef struct { |
266 |
|
|
/* Integer part */ |
267 |
|
|
char virt[VREGS]; |
268 |
|
|
char nat[N_REGS]; |
269 |
|
|
} smallstate; |
270 |
|
|
|
271 |
|
|
extern bigstate live; |
272 |
|
|
extern int touchcnt; |
273 |
|
|
|
274 |
|
|
|
275 |
|
|
#define IMM uae_s32 |
276 |
|
|
#define R1 uae_u32 |
277 |
|
|
#define R2 uae_u32 |
278 |
|
|
#define R4 uae_u32 |
279 |
|
|
#define W1 uae_u32 |
280 |
|
|
#define W2 uae_u32 |
281 |
|
|
#define W4 uae_u32 |
282 |
|
|
#define RW1 uae_u32 |
283 |
|
|
#define RW2 uae_u32 |
284 |
|
|
#define RW4 uae_u32 |
285 |
|
|
#define MEMR uae_u32 |
286 |
|
|
#define MEMW uae_u32 |
287 |
|
|
#define MEMRW uae_u32 |
288 |
|
|
|
289 |
|
|
#define FW uae_u32 |
290 |
|
|
#define FR uae_u32 |
291 |
|
|
#define FRW uae_u32 |
292 |
|
|
|
293 |
|
|
#define MIDFUNC(nargs,func,args) void func args |
294 |
|
|
#define MENDFUNC(nargs,func,args) |
295 |
|
|
#define COMPCALL(func) func |
296 |
|
|
|
297 |
|
|
#define LOWFUNC(flags,mem,nargs,func,args) static __inline__ void func args |
298 |
|
|
#define LENDFUNC(flags,mem,nargs,func,args) |
299 |
|
|
|
300 |
|
|
/* What we expose to the outside */ |
301 |
|
|
#define DECLARE_MIDFUNC(func) extern void func |
302 |
|
|
DECLARE_MIDFUNC(bt_l_ri(R4 r, IMM i)); |
303 |
|
|
DECLARE_MIDFUNC(bt_l_rr(R4 r, R4 b)); |
304 |
|
|
DECLARE_MIDFUNC(btc_l_ri(RW4 r, IMM i)); |
305 |
|
|
DECLARE_MIDFUNC(btc_l_rr(RW4 r, R4 b)); |
306 |
|
|
DECLARE_MIDFUNC(bts_l_ri(RW4 r, IMM i)); |
307 |
|
|
DECLARE_MIDFUNC(bts_l_rr(RW4 r, R4 b)); |
308 |
|
|
DECLARE_MIDFUNC(btr_l_ri(RW4 r, IMM i)); |
309 |
|
|
DECLARE_MIDFUNC(btr_l_rr(RW4 r, R4 b)); |
310 |
|
|
DECLARE_MIDFUNC(mov_l_rm(W4 d, IMM s)); |
311 |
|
|
DECLARE_MIDFUNC(call_r(R4 r)); |
312 |
|
|
DECLARE_MIDFUNC(sub_l_mi(IMM d, IMM s)); |
313 |
|
|
DECLARE_MIDFUNC(mov_l_mi(IMM d, IMM s)); |
314 |
|
|
DECLARE_MIDFUNC(mov_w_mi(IMM d, IMM s)); |
315 |
|
|
DECLARE_MIDFUNC(mov_b_mi(IMM d, IMM s)); |
316 |
|
|
DECLARE_MIDFUNC(rol_b_ri(RW1 r, IMM i)); |
317 |
|
|
DECLARE_MIDFUNC(rol_w_ri(RW2 r, IMM i)); |
318 |
|
|
DECLARE_MIDFUNC(rol_l_ri(RW4 r, IMM i)); |
319 |
|
|
DECLARE_MIDFUNC(rol_l_rr(RW4 d, R1 r)); |
320 |
|
|
DECLARE_MIDFUNC(rol_w_rr(RW2 d, R1 r)); |
321 |
|
|
DECLARE_MIDFUNC(rol_b_rr(RW1 d, R1 r)); |
322 |
|
|
DECLARE_MIDFUNC(shll_l_rr(RW4 d, R1 r)); |
323 |
|
|
DECLARE_MIDFUNC(shll_w_rr(RW2 d, R1 r)); |
324 |
|
|
DECLARE_MIDFUNC(shll_b_rr(RW1 d, R1 r)); |
325 |
|
|
DECLARE_MIDFUNC(ror_b_ri(R1 r, IMM i)); |
326 |
|
|
DECLARE_MIDFUNC(ror_w_ri(R2 r, IMM i)); |
327 |
|
|
DECLARE_MIDFUNC(ror_l_ri(R4 r, IMM i)); |
328 |
|
|
DECLARE_MIDFUNC(ror_l_rr(R4 d, R1 r)); |
329 |
|
|
DECLARE_MIDFUNC(ror_w_rr(R2 d, R1 r)); |
330 |
|
|
DECLARE_MIDFUNC(ror_b_rr(R1 d, R1 r)); |
331 |
|
|
DECLARE_MIDFUNC(shrl_l_rr(RW4 d, R1 r)); |
332 |
|
|
DECLARE_MIDFUNC(shrl_w_rr(RW2 d, R1 r)); |
333 |
|
|
DECLARE_MIDFUNC(shrl_b_rr(RW1 d, R1 r)); |
334 |
|
|
DECLARE_MIDFUNC(shra_l_rr(RW4 d, R1 r)); |
335 |
|
|
DECLARE_MIDFUNC(shra_w_rr(RW2 d, R1 r)); |
336 |
|
|
DECLARE_MIDFUNC(shra_b_rr(RW1 d, R1 r)); |
337 |
|
|
DECLARE_MIDFUNC(shll_l_ri(RW4 r, IMM i)); |
338 |
|
|
DECLARE_MIDFUNC(shll_w_ri(RW2 r, IMM i)); |
339 |
|
|
DECLARE_MIDFUNC(shll_b_ri(RW1 r, IMM i)); |
340 |
|
|
DECLARE_MIDFUNC(shrl_l_ri(RW4 r, IMM i)); |
341 |
|
|
DECLARE_MIDFUNC(shrl_w_ri(RW2 r, IMM i)); |
342 |
|
|
DECLARE_MIDFUNC(shrl_b_ri(RW1 r, IMM i)); |
343 |
|
|
DECLARE_MIDFUNC(shra_l_ri(RW4 r, IMM i)); |
344 |
|
|
DECLARE_MIDFUNC(shra_w_ri(RW2 r, IMM i)); |
345 |
|
|
DECLARE_MIDFUNC(shra_b_ri(RW1 r, IMM i)); |
346 |
|
|
DECLARE_MIDFUNC(setcc(W1 d, IMM cc)); |
347 |
|
|
DECLARE_MIDFUNC(setcc_m(IMM d, IMM cc)); |
348 |
gbeauche |
1.14 |
DECLARE_MIDFUNC(cmov_b_rr(RW1 d, R1 s, IMM cc)); |
349 |
|
|
DECLARE_MIDFUNC(cmov_w_rr(RW2 d, R2 s, IMM cc)); |
350 |
gbeauche |
1.1 |
DECLARE_MIDFUNC(cmov_l_rr(RW4 d, R4 s, IMM cc)); |
351 |
|
|
DECLARE_MIDFUNC(cmov_l_rm(RW4 d, IMM s, IMM cc)); |
352 |
gbeauche |
1.11 |
DECLARE_MIDFUNC(bsf_l_rr(W4 d, R4 s)); |
353 |
gbeauche |
1.1 |
DECLARE_MIDFUNC(pop_m(IMM d)); |
354 |
|
|
DECLARE_MIDFUNC(push_m(IMM d)); |
355 |
|
|
DECLARE_MIDFUNC(pop_l(W4 d)); |
356 |
|
|
DECLARE_MIDFUNC(push_l_i(IMM i)); |
357 |
|
|
DECLARE_MIDFUNC(push_l(R4 s)); |
358 |
|
|
DECLARE_MIDFUNC(clear_16(RW4 r)); |
359 |
|
|
DECLARE_MIDFUNC(clear_8(RW4 r)); |
360 |
|
|
DECLARE_MIDFUNC(sign_extend_16_rr(W4 d, R2 s)); |
361 |
|
|
DECLARE_MIDFUNC(sign_extend_8_rr(W4 d, R1 s)); |
362 |
|
|
DECLARE_MIDFUNC(zero_extend_16_rr(W4 d, R2 s)); |
363 |
|
|
DECLARE_MIDFUNC(zero_extend_8_rr(W4 d, R1 s)); |
364 |
|
|
DECLARE_MIDFUNC(imul_64_32(RW4 d, RW4 s)); |
365 |
|
|
DECLARE_MIDFUNC(mul_64_32(RW4 d, RW4 s)); |
366 |
|
|
DECLARE_MIDFUNC(imul_32_32(RW4 d, R4 s)); |
367 |
|
|
DECLARE_MIDFUNC(mul_32_32(RW4 d, R4 s)); |
368 |
|
|
DECLARE_MIDFUNC(mov_b_rr(W1 d, R1 s)); |
369 |
|
|
DECLARE_MIDFUNC(mov_w_rr(W2 d, R2 s)); |
370 |
|
|
DECLARE_MIDFUNC(mov_l_rrm_indexed(W4 d,R4 baser, R4 index, IMM factor)); |
371 |
|
|
DECLARE_MIDFUNC(mov_w_rrm_indexed(W2 d, R4 baser, R4 index, IMM factor)); |
372 |
|
|
DECLARE_MIDFUNC(mov_b_rrm_indexed(W1 d, R4 baser, R4 index, IMM factor)); |
373 |
|
|
DECLARE_MIDFUNC(mov_l_mrr_indexed(R4 baser, R4 index, IMM factor, R4 s)); |
374 |
|
|
DECLARE_MIDFUNC(mov_w_mrr_indexed(R4 baser, R4 index, IMM factor, R2 s)); |
375 |
|
|
DECLARE_MIDFUNC(mov_b_mrr_indexed(R4 baser, R4 index, IMM factor, R1 s)); |
376 |
|
|
DECLARE_MIDFUNC(mov_l_bmrr_indexed(IMM base, R4 baser, R4 index, IMM factor, R4 s)); |
377 |
|
|
DECLARE_MIDFUNC(mov_w_bmrr_indexed(IMM base, R4 baser, R4 index, IMM factor, R2 s)); |
378 |
|
|
DECLARE_MIDFUNC(mov_b_bmrr_indexed(IMM base, R4 baser, R4 index, IMM factor, R1 s)); |
379 |
|
|
DECLARE_MIDFUNC(mov_l_brrm_indexed(W4 d, IMM base, R4 baser, R4 index, IMM factor)); |
380 |
|
|
DECLARE_MIDFUNC(mov_w_brrm_indexed(W2 d, IMM base, R4 baser, R4 index, IMM factor)); |
381 |
|
|
DECLARE_MIDFUNC(mov_b_brrm_indexed(W1 d, IMM base, R4 baser, R4 index, IMM factor)); |
382 |
|
|
DECLARE_MIDFUNC(mov_l_rm_indexed(W4 d, IMM base, R4 index, IMM factor)); |
383 |
|
|
DECLARE_MIDFUNC(mov_l_rR(W4 d, R4 s, IMM offset)); |
384 |
|
|
DECLARE_MIDFUNC(mov_w_rR(W2 d, R4 s, IMM offset)); |
385 |
|
|
DECLARE_MIDFUNC(mov_b_rR(W1 d, R4 s, IMM offset)); |
386 |
|
|
DECLARE_MIDFUNC(mov_l_brR(W4 d, R4 s, IMM offset)); |
387 |
|
|
DECLARE_MIDFUNC(mov_w_brR(W2 d, R4 s, IMM offset)); |
388 |
|
|
DECLARE_MIDFUNC(mov_b_brR(W1 d, R4 s, IMM offset)); |
389 |
|
|
DECLARE_MIDFUNC(mov_l_Ri(R4 d, IMM i, IMM offset)); |
390 |
|
|
DECLARE_MIDFUNC(mov_w_Ri(R4 d, IMM i, IMM offset)); |
391 |
|
|
DECLARE_MIDFUNC(mov_b_Ri(R4 d, IMM i, IMM offset)); |
392 |
|
|
DECLARE_MIDFUNC(mov_l_Rr(R4 d, R4 s, IMM offset)); |
393 |
|
|
DECLARE_MIDFUNC(mov_w_Rr(R4 d, R2 s, IMM offset)); |
394 |
|
|
DECLARE_MIDFUNC(mov_b_Rr(R4 d, R1 s, IMM offset)); |
395 |
|
|
DECLARE_MIDFUNC(lea_l_brr(W4 d, R4 s, IMM offset)); |
396 |
|
|
DECLARE_MIDFUNC(lea_l_brr_indexed(W4 d, R4 s, R4 index, IMM factor, IMM offset)); |
397 |
|
|
DECLARE_MIDFUNC(lea_l_rr_indexed(W4 d, R4 s, R4 index, IMM factor)); |
398 |
|
|
DECLARE_MIDFUNC(mov_l_bRr(R4 d, R4 s, IMM offset)); |
399 |
|
|
DECLARE_MIDFUNC(mov_w_bRr(R4 d, R2 s, IMM offset)); |
400 |
|
|
DECLARE_MIDFUNC(mov_b_bRr(R4 d, R1 s, IMM offset)); |
401 |
|
|
DECLARE_MIDFUNC(bswap_32(RW4 r)); |
402 |
|
|
DECLARE_MIDFUNC(bswap_16(RW2 r)); |
403 |
|
|
DECLARE_MIDFUNC(mov_l_rr(W4 d, R4 s)); |
404 |
|
|
DECLARE_MIDFUNC(mov_l_mr(IMM d, R4 s)); |
405 |
|
|
DECLARE_MIDFUNC(mov_w_mr(IMM d, R2 s)); |
406 |
|
|
DECLARE_MIDFUNC(mov_w_rm(W2 d, IMM s)); |
407 |
|
|
DECLARE_MIDFUNC(mov_b_mr(IMM d, R1 s)); |
408 |
|
|
DECLARE_MIDFUNC(mov_b_rm(W1 d, IMM s)); |
409 |
|
|
DECLARE_MIDFUNC(mov_l_ri(W4 d, IMM s)); |
410 |
|
|
DECLARE_MIDFUNC(mov_w_ri(W2 d, IMM s)); |
411 |
|
|
DECLARE_MIDFUNC(mov_b_ri(W1 d, IMM s)); |
412 |
|
|
DECLARE_MIDFUNC(add_l_mi(IMM d, IMM s) ); |
413 |
|
|
DECLARE_MIDFUNC(add_w_mi(IMM d, IMM s) ); |
414 |
|
|
DECLARE_MIDFUNC(add_b_mi(IMM d, IMM s) ); |
415 |
|
|
DECLARE_MIDFUNC(test_l_ri(R4 d, IMM i)); |
416 |
|
|
DECLARE_MIDFUNC(test_l_rr(R4 d, R4 s)); |
417 |
|
|
DECLARE_MIDFUNC(test_w_rr(R2 d, R2 s)); |
418 |
|
|
DECLARE_MIDFUNC(test_b_rr(R1 d, R1 s)); |
419 |
|
|
DECLARE_MIDFUNC(and_l_ri(RW4 d, IMM i)); |
420 |
|
|
DECLARE_MIDFUNC(and_l(RW4 d, R4 s)); |
421 |
|
|
DECLARE_MIDFUNC(and_w(RW2 d, R2 s)); |
422 |
|
|
DECLARE_MIDFUNC(and_b(RW1 d, R1 s)); |
423 |
|
|
DECLARE_MIDFUNC(or_l_rm(RW4 d, IMM s)); |
424 |
|
|
DECLARE_MIDFUNC(or_l_ri(RW4 d, IMM i)); |
425 |
|
|
DECLARE_MIDFUNC(or_l(RW4 d, R4 s)); |
426 |
|
|
DECLARE_MIDFUNC(or_w(RW2 d, R2 s)); |
427 |
|
|
DECLARE_MIDFUNC(or_b(RW1 d, R1 s)); |
428 |
|
|
DECLARE_MIDFUNC(adc_l(RW4 d, R4 s)); |
429 |
|
|
DECLARE_MIDFUNC(adc_w(RW2 d, R2 s)); |
430 |
|
|
DECLARE_MIDFUNC(adc_b(RW1 d, R1 s)); |
431 |
|
|
DECLARE_MIDFUNC(add_l(RW4 d, R4 s)); |
432 |
|
|
DECLARE_MIDFUNC(add_w(RW2 d, R2 s)); |
433 |
|
|
DECLARE_MIDFUNC(add_b(RW1 d, R1 s)); |
434 |
|
|
DECLARE_MIDFUNC(sub_l_ri(RW4 d, IMM i)); |
435 |
|
|
DECLARE_MIDFUNC(sub_w_ri(RW2 d, IMM i)); |
436 |
|
|
DECLARE_MIDFUNC(sub_b_ri(RW1 d, IMM i)); |
437 |
|
|
DECLARE_MIDFUNC(add_l_ri(RW4 d, IMM i)); |
438 |
|
|
DECLARE_MIDFUNC(add_w_ri(RW2 d, IMM i)); |
439 |
|
|
DECLARE_MIDFUNC(add_b_ri(RW1 d, IMM i)); |
440 |
|
|
DECLARE_MIDFUNC(sbb_l(RW4 d, R4 s)); |
441 |
|
|
DECLARE_MIDFUNC(sbb_w(RW2 d, R2 s)); |
442 |
|
|
DECLARE_MIDFUNC(sbb_b(RW1 d, R1 s)); |
443 |
|
|
DECLARE_MIDFUNC(sub_l(RW4 d, R4 s)); |
444 |
|
|
DECLARE_MIDFUNC(sub_w(RW2 d, R2 s)); |
445 |
|
|
DECLARE_MIDFUNC(sub_b(RW1 d, R1 s)); |
446 |
|
|
DECLARE_MIDFUNC(cmp_l(R4 d, R4 s)); |
447 |
|
|
DECLARE_MIDFUNC(cmp_l_ri(R4 r, IMM i)); |
448 |
|
|
DECLARE_MIDFUNC(cmp_w(R2 d, R2 s)); |
449 |
|
|
DECLARE_MIDFUNC(cmp_b(R1 d, R1 s)); |
450 |
|
|
DECLARE_MIDFUNC(xor_l(RW4 d, R4 s)); |
451 |
|
|
DECLARE_MIDFUNC(xor_w(RW2 d, R2 s)); |
452 |
|
|
DECLARE_MIDFUNC(xor_b(RW1 d, R1 s)); |
453 |
|
|
DECLARE_MIDFUNC(live_flags(void)); |
454 |
|
|
DECLARE_MIDFUNC(dont_care_flags(void)); |
455 |
|
|
DECLARE_MIDFUNC(duplicate_carry(void)); |
456 |
|
|
DECLARE_MIDFUNC(restore_carry(void)); |
457 |
|
|
DECLARE_MIDFUNC(start_needflags(void)); |
458 |
|
|
DECLARE_MIDFUNC(end_needflags(void)); |
459 |
|
|
DECLARE_MIDFUNC(make_flags_live(void)); |
460 |
|
|
DECLARE_MIDFUNC(call_r_11(R4 r, W4 out1, R4 in1, IMM osize, IMM isize)); |
461 |
|
|
DECLARE_MIDFUNC(call_r_02(R4 r, R4 in1, R4 in2, IMM isize1, IMM isize2)); |
462 |
|
|
DECLARE_MIDFUNC(forget_about(W4 r)); |
463 |
|
|
DECLARE_MIDFUNC(nop(void)); |
464 |
|
|
|
465 |
|
|
DECLARE_MIDFUNC(f_forget_about(FW r)); |
466 |
|
|
DECLARE_MIDFUNC(fmov_pi(FW r)); |
467 |
|
|
DECLARE_MIDFUNC(fmov_log10_2(FW r)); |
468 |
|
|
DECLARE_MIDFUNC(fmov_log2_e(FW r)); |
469 |
|
|
DECLARE_MIDFUNC(fmov_loge_2(FW r)); |
470 |
|
|
DECLARE_MIDFUNC(fmov_1(FW r)); |
471 |
|
|
DECLARE_MIDFUNC(fmov_0(FW r)); |
472 |
|
|
DECLARE_MIDFUNC(fmov_rm(FW r, MEMR m)); |
473 |
|
|
DECLARE_MIDFUNC(fmovi_rm(FW r, MEMR m)); |
474 |
|
|
DECLARE_MIDFUNC(fmovi_mr(MEMW m, FR r)); |
475 |
|
|
DECLARE_MIDFUNC(fmovs_rm(FW r, MEMR m)); |
476 |
|
|
DECLARE_MIDFUNC(fmovs_mr(MEMW m, FR r)); |
477 |
|
|
DECLARE_MIDFUNC(fmov_mr(MEMW m, FR r)); |
478 |
|
|
DECLARE_MIDFUNC(fmov_ext_mr(MEMW m, FR r)); |
479 |
|
|
DECLARE_MIDFUNC(fmov_ext_rm(FW r, MEMR m)); |
480 |
|
|
DECLARE_MIDFUNC(fmov_rr(FW d, FR s)); |
481 |
|
|
DECLARE_MIDFUNC(fldcw_m_indexed(R4 index, IMM base)); |
482 |
|
|
DECLARE_MIDFUNC(ftst_r(FR r)); |
483 |
|
|
DECLARE_MIDFUNC(dont_care_fflags(void)); |
484 |
|
|
DECLARE_MIDFUNC(fsqrt_rr(FW d, FR s)); |
485 |
|
|
DECLARE_MIDFUNC(fabs_rr(FW d, FR s)); |
486 |
|
|
DECLARE_MIDFUNC(frndint_rr(FW d, FR s)); |
487 |
|
|
DECLARE_MIDFUNC(fsin_rr(FW d, FR s)); |
488 |
|
|
DECLARE_MIDFUNC(fcos_rr(FW d, FR s)); |
489 |
|
|
DECLARE_MIDFUNC(ftwotox_rr(FW d, FR s)); |
490 |
|
|
DECLARE_MIDFUNC(fetox_rr(FW d, FR s)); |
491 |
|
|
DECLARE_MIDFUNC(flog2_rr(FW d, FR s)); |
492 |
|
|
DECLARE_MIDFUNC(fneg_rr(FW d, FR s)); |
493 |
|
|
DECLARE_MIDFUNC(fadd_rr(FRW d, FR s)); |
494 |
|
|
DECLARE_MIDFUNC(fsub_rr(FRW d, FR s)); |
495 |
|
|
DECLARE_MIDFUNC(fmul_rr(FRW d, FR s)); |
496 |
|
|
DECLARE_MIDFUNC(frem_rr(FRW d, FR s)); |
497 |
|
|
DECLARE_MIDFUNC(frem1_rr(FRW d, FR s)); |
498 |
|
|
DECLARE_MIDFUNC(fdiv_rr(FRW d, FR s)); |
499 |
|
|
DECLARE_MIDFUNC(fcmp_rr(FR d, FR s)); |
500 |
|
|
DECLARE_MIDFUNC(fflags_into_flags(W2 tmp)); |
501 |
|
|
#undef DECLARE_MIDFUNC |
502 |
|
|
|
503 |
|
|
extern int failure; |
504 |
|
|
#define FAIL(x) do { failure|=x; } while (0) |
505 |
|
|
|
506 |
|
|
/* Convenience functions exposed to gencomp */ |
507 |
|
|
extern uae_u32 m68k_pc_offset; |
508 |
|
|
extern void readbyte(int address, int dest, int tmp); |
509 |
|
|
extern void readword(int address, int dest, int tmp); |
510 |
|
|
extern void readlong(int address, int dest, int tmp); |
511 |
|
|
extern void writebyte(int address, int source, int tmp); |
512 |
|
|
extern void writeword(int address, int source, int tmp); |
513 |
|
|
extern void writelong(int address, int source, int tmp); |
514 |
|
|
extern void writeword_clobber(int address, int source, int tmp); |
515 |
|
|
extern void writelong_clobber(int address, int source, int tmp); |
516 |
|
|
extern void get_n_addr(int address, int dest, int tmp); |
517 |
|
|
extern void get_n_addr_jmp(int address, int dest, int tmp); |
518 |
|
|
extern void calc_disp_ea_020(int base, uae_u32 dp, int target, int tmp); |
519 |
gbeauche |
1.11 |
/* Set native Z flag only if register is zero */ |
520 |
|
|
extern void set_zero(int r, int tmp); |
521 |
gbeauche |
1.1 |
extern int kill_rodent(int r); |
522 |
|
|
extern void sync_m68k_pc(void); |
523 |
|
|
extern uae_u32 get_const(int r); |
524 |
|
|
extern int is_const(int r); |
525 |
|
|
extern void register_branch(uae_u32 not_taken, uae_u32 taken, uae_u8 cond); |
526 |
|
|
|
527 |
|
|
#define comp_get_ibyte(o) do_get_mem_byte((uae_u8 *)(comp_pc_p + (o) + 1)) |
528 |
|
|
#define comp_get_iword(o) do_get_mem_word((uae_u16 *)(comp_pc_p + (o))) |
529 |
|
|
#define comp_get_ilong(o) do_get_mem_long((uae_u32 *)(comp_pc_p + (o))) |
530 |
|
|
|
531 |
|
|
struct blockinfo_t; |
532 |
|
|
|
533 |
|
|
typedef struct dep_t { |
534 |
gbeauche |
1.10 |
uae_u32* jmp_off; |
535 |
gbeauche |
1.1 |
struct blockinfo_t* target; |
536 |
|
|
struct blockinfo_t* source; |
537 |
|
|
struct dep_t** prev_p; |
538 |
|
|
struct dep_t* next; |
539 |
|
|
} dependency; |
540 |
|
|
|
541 |
gbeauche |
1.2 |
typedef struct checksum_info_t { |
542 |
|
|
uae_u8 *start_p; |
543 |
|
|
uae_u32 length; |
544 |
|
|
struct checksum_info_t *next; |
545 |
|
|
} checksum_info; |
546 |
|
|
|
547 |
gbeauche |
1.1 |
typedef struct blockinfo_t { |
548 |
|
|
uae_s32 count; |
549 |
|
|
cpuop_func* direct_handler_to_use; |
550 |
|
|
cpuop_func* handler_to_use; |
551 |
|
|
/* The direct handler does not check for the correct address */ |
552 |
|
|
|
553 |
|
|
cpuop_func* handler; |
554 |
|
|
cpuop_func* direct_handler; |
555 |
|
|
|
556 |
|
|
cpuop_func* direct_pen; |
557 |
|
|
cpuop_func* direct_pcc; |
558 |
|
|
|
559 |
|
|
uae_u8* pc_p; |
560 |
|
|
|
561 |
gbeauche |
1.3 |
uae_u32 c1; |
562 |
|
|
uae_u32 c2; |
563 |
gbeauche |
1.2 |
#if USE_CHECKSUM_INFO |
564 |
|
|
checksum_info *csi; |
565 |
|
|
#else |
566 |
gbeauche |
1.1 |
uae_u32 len; |
567 |
gbeauche |
1.2 |
uae_u32 min_pcp; |
568 |
|
|
#endif |
569 |
gbeauche |
1.1 |
|
570 |
|
|
struct blockinfo_t* next_same_cl; |
571 |
|
|
struct blockinfo_t** prev_same_cl_p; |
572 |
|
|
struct blockinfo_t* next; |
573 |
|
|
struct blockinfo_t** prev_p; |
574 |
|
|
|
575 |
|
|
uae_u8 optlevel; |
576 |
|
|
uae_u8 needed_flags; |
577 |
|
|
uae_u8 status; |
578 |
|
|
uae_u8 havestate; |
579 |
|
|
|
580 |
|
|
dependency dep[2]; /* Holds things we depend on */ |
581 |
|
|
dependency* deplist; /* List of things that depend on this */ |
582 |
|
|
smallstate env; |
583 |
|
|
|
584 |
|
|
#if JIT_DEBUG |
585 |
|
|
/* (gb) size of the compiled block (direct handler) */ |
586 |
|
|
uae_u32 direct_handler_size; |
587 |
|
|
#endif |
588 |
|
|
} blockinfo; |
589 |
|
|
|
590 |
|
|
#define BI_INVALID 0 |
591 |
|
|
#define BI_ACTIVE 1 |
592 |
|
|
#define BI_NEED_RECOMP 2 |
593 |
|
|
#define BI_NEED_CHECK 3 |
594 |
|
|
#define BI_CHECKING 4 |
595 |
|
|
#define BI_COMPILING 5 |
596 |
|
|
#define BI_FINALIZING 6 |
597 |
|
|
|
598 |
|
|
void execute_normal(void); |
599 |
|
|
void exec_nostats(void); |
600 |
|
|
void do_nothing(void); |
601 |
|
|
|
602 |
|
|
#else |
603 |
|
|
|
604 |
|
|
static __inline__ void flush_icache(int) { } |
605 |
|
|
static __inline__ void build_comp() { } |
606 |
|
|
|
607 |
|
|
#endif /* !USE_JIT */ |
608 |
|
|
|
609 |
|
|
#endif /* COMPEMU_H */ |