22 |
|
#include "memory.h" |
23 |
|
#include "readcpu.h" |
24 |
|
#include "newcpu.h" |
25 |
+ |
#include "compiler/compemu.h" |
26 |
|
#include "fpu/fpu.h" |
27 |
|
|
28 |
|
#if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS) |
34 |
|
#include "mon_disass.h" |
35 |
|
#endif |
36 |
|
|
37 |
< |
int quit_program = 0; |
37 |
< |
const int debugging = 0; |
37 |
> |
bool quit_program = false; |
38 |
|
struct flag_struct regflags; |
39 |
|
|
40 |
|
/* Opcode of faulting instruction */ |
53 |
|
|
54 |
|
cpuop_func *cpufunctbl[65536]; |
55 |
|
|
56 |
– |
#define FLIGHT_RECORDER 0 |
57 |
– |
|
56 |
|
#if FLIGHT_RECORDER |
57 |
|
struct rec_step { |
58 |
|
uae_u32 d[8]; |
70 |
|
return name ? name : "log.68k"; |
71 |
|
} |
72 |
|
|
73 |
< |
static void record_step(uaecptr pc) |
73 |
> |
void m68k_record_step(uaecptr pc) |
74 |
|
{ |
75 |
|
for (int i = 0; i < 8; i++) { |
76 |
|
log[log_ptr].d[i] = m68k_dreg(regs, i); |
800 |
|
switch (regno) { |
801 |
|
case 0: regs.sfc = *regp & 7; break; |
802 |
|
case 1: regs.dfc = *regp & 7; break; |
803 |
< |
case 2: cacr = *regp & (CPUType < 4 ? 0x3 : 0x80008000); break; |
803 |
> |
case 2: |
804 |
> |
cacr = *regp & (CPUType < 4 ? 0x3 : 0x80008000); |
805 |
> |
#if USE_JIT |
806 |
> |
if (CPUType < 4) { |
807 |
> |
set_cache_state(cacr&1); |
808 |
> |
if (*regp & 0x08) |
809 |
> |
flush_icache(1); |
810 |
> |
} |
811 |
> |
else { |
812 |
> |
set_cache_state((cacr&0x8000) || 0); |
813 |
> |
// FIXME: The User Manual claims bit 3 of CACR is undefined |
814 |
> |
if (*regp & 0x08) |
815 |
> |
flush_icache(2); |
816 |
> |
} |
817 |
> |
#endif |
818 |
> |
break; |
819 |
|
case 3: tc = *regp & 0xc000; break; |
820 |
|
case 4: itt0 = *regp & 0xffffe364; break; |
821 |
|
case 5: itt1 = *regp & 0xffffe364; break; |
1166 |
|
void m68k_emulop_return(void) |
1167 |
|
{ |
1168 |
|
SPCFLAGS_SET( SPCFLAG_BRK ); |
1169 |
< |
quit_program = 1; |
1169 |
> |
quit_program = true; |
1170 |
|
} |
1171 |
|
|
1172 |
|
void m68k_emulop(uae_u32 opcode) |
1204 |
|
} |
1205 |
|
|
1206 |
|
write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc); |
1207 |
+ |
#if USE_JIT && JIT_DEBUG |
1208 |
+ |
compiler_dumpstate(); |
1209 |
+ |
#endif |
1210 |
|
|
1211 |
|
Exception (4,0); |
1212 |
|
cpuop_return(CFLOW_TRAP); |
1264 |
|
|
1265 |
|
int m68k_do_specialties (void) |
1266 |
|
{ |
1267 |
+ |
#if USE_JIT |
1268 |
+ |
// Block was compiled |
1269 |
+ |
SPCFLAGS_CLEAR( SPCFLAG_JIT_END_COMPILE ); |
1270 |
+ |
|
1271 |
+ |
// Retain the request to get out of compiled code until |
1272 |
+ |
// we reached the toplevel execution, i.e. the one that |
1273 |
+ |
// can compile then run compiled code. This also means |
1274 |
+ |
// we processed all (nested) EmulOps |
1275 |
+ |
if ((m68k_execute_depth == 0) && SPCFLAGS_TEST( SPCFLAG_JIT_EXEC_RETURN )) |
1276 |
+ |
SPCFLAGS_CLEAR( SPCFLAG_JIT_EXEC_RETURN ); |
1277 |
+ |
#endif |
1278 |
+ |
|
1279 |
|
if (SPCFLAGS_TEST( SPCFLAG_DOTRACE )) { |
1280 |
|
Exception (9,last_trace_ad); |
1281 |
|
} |
1317 |
|
for (;;) { |
1318 |
|
uae_u32 opcode = GET_OPCODE; |
1319 |
|
#if FLIGHT_RECORDER |
1320 |
< |
record_step(m68k_getpc()); |
1320 |
> |
m68k_record_step(m68k_getpc()); |
1321 |
|
#endif |
1294 |
– |
#ifdef X86_ASSEMBLY |
1295 |
– |
__asm__ __volatile__("\tpushl %%ebp\n\tcall *%%ebx\n\tpopl %%ebp" /* FIXME */ |
1296 |
– |
: : "b" (cpufunctbl[opcode]), "a" (opcode) |
1297 |
– |
: "%edx", "%ecx", "%esi", "%edi", "%ebp", "memory", "cc"); |
1298 |
– |
#else |
1322 |
|
(*cpufunctbl[opcode])(opcode); |
1323 |
< |
#endif |
1324 |
< |
if (SPCFLAGS_TEST(SPCFLAG_ALL_BUT_EXEC_RETURN)) { |
1302 |
< |
if (m68k_do_specialties()) |
1323 |
> |
if (SPCFLAGS_TEST(SPCFLAG_ALL_BUT_EXEC_RETURN)) { |
1324 |
> |
if (m68k_do_specialties()) |
1325 |
|
return; |
1326 |
|
} |
1327 |
|
} |
1328 |
|
} |
1329 |
|
|
1330 |
+ |
#if USE_JIT && !defined(X86_ASSEMBLY) |
1331 |
+ |
void m68k_compile_execute (void) |
1332 |
+ |
{ |
1333 |
+ |
for (;;) { |
1334 |
+ |
if (quit_program) |
1335 |
+ |
break; |
1336 |
+ |
m68k_do_compile_execute(); |
1337 |
+ |
} |
1338 |
+ |
} |
1339 |
+ |
#endif |
1340 |
+ |
|
1341 |
|
void m68k_execute (void) |
1342 |
|
{ |
1343 |
+ |
#if USE_JIT |
1344 |
+ |
++m68k_execute_depth; |
1345 |
+ |
#endif |
1346 |
|
for (;;) { |
1347 |
< |
if (quit_program > 0) { |
1312 |
< |
if (quit_program == 1) |
1347 |
> |
if (quit_program) |
1348 |
|
break; |
1349 |
< |
quit_program = 0; |
1315 |
< |
m68k_reset (); |
1316 |
< |
} |
1317 |
< |
m68k_do_execute(); |
1349 |
> |
m68k_do_execute(); |
1350 |
|
} |
1351 |
< |
if (debugging) { |
1352 |
< |
uaecptr nextpc; |
1353 |
< |
m68k_dumpstate(&nextpc); |
1322 |
< |
exit(1); |
1323 |
< |
} |
1351 |
> |
#if USE_JIT |
1352 |
> |
--m68k_execute_depth; |
1353 |
> |
#endif |
1354 |
|
} |
1355 |
|
|
1356 |
|
static void m68k_verify (uaecptr addr, uaecptr *nextpc) |