ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/compiler/compemu.h
Revision: 1.2
Committed: 2002-10-01T16:22:36Z (22 years, 1 month ago) by gbeauche
Content type: text/plain
Branch: MAIN
Changes since 1.1: +22 -2 lines
Log Message:
- Rewrite blockinfo allocator et al. Use a template class so that this
  can work with other types related to blockinfos.
- Add new method to compute checksums. This should permit code inlining
  and follow-ups of const_jumps without breaking the lazy cache invalidator.
  aka. chain infos for checksuming. TODO: Incomplete support thus disabled.

File Contents

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