mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-12 01:30:03 +00:00
Optimize generated code to NQD & CheckLoad functions. They don't call into
68k or MacOS code, so they don't need to be a termination point. i.e. don't split into two basic blocks and thus avoid a full hash search. Also add missing NQD_unknown_hook NativeOp from previous commit.
This commit is contained in:
parent
26a71e5417
commit
757f849ad0
@ -336,6 +336,7 @@ int sheepshaver_cpu::compile1(codegen_context_t & cg_context)
|
|||||||
status = COMPILE_CODE_OK;
|
status = COMPILE_CODE_OK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
case NATIVE_CHECK_LOAD_INVOC:
|
case NATIVE_CHECK_LOAD_INVOC:
|
||||||
dg.gen_load_T0_GPR(3);
|
dg.gen_load_T0_GPR(3);
|
||||||
dg.gen_load_T1_GPR(4);
|
dg.gen_load_T1_GPR(4);
|
||||||
@ -351,7 +352,30 @@ int sheepshaver_cpu::compile1(codegen_context_t & cg_context)
|
|||||||
dg.gen_invoke_T0_T1_T2((void (*)(uint32, uint32, uint32))named_check_load_invoc);
|
dg.gen_invoke_T0_T1_T2((void (*)(uint32, uint32, uint32))named_check_load_invoc);
|
||||||
status = COMPILE_CODE_OK;
|
status = COMPILE_CODE_OK;
|
||||||
break;
|
break;
|
||||||
#endif
|
case NATIVE_NQD_SYNC_HOOK:
|
||||||
|
dg.gen_load_T0_GPR(3);
|
||||||
|
dg.gen_invoke_T0_ret_T0((uint32 (*)(uint32))NQD_sync_hook);
|
||||||
|
dg.gen_store_T0_GPR(3);
|
||||||
|
status = COMPILE_CODE_OK;
|
||||||
|
break;
|
||||||
|
case NATIVE_NQD_BITBLT_HOOK:
|
||||||
|
dg.gen_load_T0_GPR(3);
|
||||||
|
dg.gen_invoke_T0_ret_T0((uint32 (*)(uint32))NQD_bitblt_hook);
|
||||||
|
dg.gen_store_T0_GPR(3);
|
||||||
|
status = COMPILE_CODE_OK;
|
||||||
|
break;
|
||||||
|
case NATIVE_NQD_FILLRECT_HOOK:
|
||||||
|
dg.gen_load_T0_GPR(3);
|
||||||
|
dg.gen_invoke_T0_ret_T0((uint32 (*)(uint32))NQD_fillrect_hook);
|
||||||
|
dg.gen_store_T0_GPR(3);
|
||||||
|
status = COMPILE_CODE_OK;
|
||||||
|
break;
|
||||||
|
case NATIVE_NQD_UNKNOWN_HOOK:
|
||||||
|
dg.gen_load_T0_GPR(3);
|
||||||
|
dg.gen_invoke_T0_ret_T0((uint32 (*)(uint32))NQD_unknown_hook);
|
||||||
|
dg.gen_store_T0_GPR(3);
|
||||||
|
status = COMPILE_CODE_OK;
|
||||||
|
break;
|
||||||
case NATIVE_NQD_BITBLT:
|
case NATIVE_NQD_BITBLT:
|
||||||
dg.gen_load_T0_GPR(3);
|
dg.gen_load_T0_GPR(3);
|
||||||
dg.gen_invoke_T0((void (*)(uint32))NQD_bitblt);
|
dg.gen_invoke_T0((void (*)(uint32))NQD_bitblt);
|
||||||
@ -1036,6 +1060,9 @@ void sheepshaver_cpu::execute_native_op(uint32 selector)
|
|||||||
case NATIVE_NQD_SYNC_HOOK:
|
case NATIVE_NQD_SYNC_HOOK:
|
||||||
gpr(3) = NQD_sync_hook(gpr(3));
|
gpr(3) = NQD_sync_hook(gpr(3));
|
||||||
break;
|
break;
|
||||||
|
case NATIVE_NQD_UNKNOWN_HOOK:
|
||||||
|
gpr(3) = NQD_unknown_hook(gpr(3));
|
||||||
|
break;
|
||||||
case NATIVE_NQD_BITBLT_HOOK:
|
case NATIVE_NQD_BITBLT_HOOK:
|
||||||
gpr(3) = NQD_bitblt_hook(gpr(3));
|
gpr(3) = NQD_bitblt_hook(gpr(3));
|
||||||
break;
|
break;
|
||||||
|
@ -414,6 +414,11 @@ DEFINE_OP(op_invoke_T0_T1_T2, {
|
|||||||
CALL(reg_A0,(T0, T1, T2));
|
CALL(reg_A0,(T0, T1, T2));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
DEFINE_OP(op_invoke_T0_ret_T0, {
|
||||||
|
typedef uint32 (*func_t)(uint32);
|
||||||
|
T0 = CALL(reg_A0,(T0));
|
||||||
|
});
|
||||||
|
|
||||||
DEFINE_OP(op_invoke_im, {
|
DEFINE_OP(op_invoke_im, {
|
||||||
typedef void (*func_t)(uint32);
|
typedef void (*func_t)(uint32);
|
||||||
CALL(reg_A0,(PARAM1));
|
CALL(reg_A0,(PARAM1));
|
||||||
@ -459,6 +464,11 @@ DEFINE_OP(op_invoke_direct_T0_T1_T2, {
|
|||||||
CALL(PARAM1,(T0, T1, T2));
|
CALL(PARAM1,(T0, T1, T2));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
DEFINE_OP(op_invoke_direct_T0_ret_T0, {
|
||||||
|
typedef uint32 (*func_t)(uint32);
|
||||||
|
T0 = CALL(PARAM1,(T0));
|
||||||
|
});
|
||||||
|
|
||||||
DEFINE_OP(op_invoke_direct_im, {
|
DEFINE_OP(op_invoke_direct_im, {
|
||||||
typedef void (*func_t)(uint32);
|
typedef void (*func_t)(uint32);
|
||||||
CALL(PARAM1,(PARAM2));
|
CALL(PARAM1,(PARAM2));
|
||||||
|
@ -89,6 +89,17 @@ basic_dyngen::gen_invoke_T0_T1_T2(void (*func)(uint32, uint32, uint32))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
basic_dyngen::gen_invoke_T0_ret_T0(uint32 (*func)(uint32))
|
||||||
|
{
|
||||||
|
if (direct_call_possible((uintptr)func))
|
||||||
|
gen_op_invoke_direct_T0_ret_T0((uintptr)func);
|
||||||
|
else {
|
||||||
|
gen_op_mov_ad_A0_im((uintptr)func);
|
||||||
|
gen_op_invoke_T0_ret_T0();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
basic_dyngen::gen_invoke_im(void (*func)(uint32), uint32 value)
|
basic_dyngen::gen_invoke_im(void (*func)(uint32), uint32 value)
|
||||||
{
|
{
|
||||||
|
@ -105,6 +105,7 @@ public:
|
|||||||
void gen_invoke_T0(void (*func)(uint32));
|
void gen_invoke_T0(void (*func)(uint32));
|
||||||
void gen_invoke_T0_T1(void (*func)(uint32, uint32));
|
void gen_invoke_T0_T1(void (*func)(uint32, uint32));
|
||||||
void gen_invoke_T0_T1_T2(void (*func)(uint32, uint32, uint32));
|
void gen_invoke_T0_T1_T2(void (*func)(uint32, uint32, uint32));
|
||||||
|
void gen_invoke_T0_ret_T0(uint32 (*func)(uint32));
|
||||||
void gen_invoke_im(void (*func)(uint32), uint32 value);
|
void gen_invoke_im(void (*func)(uint32), uint32 value);
|
||||||
void gen_invoke_CPU(void (*func)(dyngen_cpu_base));
|
void gen_invoke_CPU(void (*func)(dyngen_cpu_base));
|
||||||
void gen_invoke_CPU_T0(void (*func)(dyngen_cpu_base, uint32));
|
void gen_invoke_CPU_T0(void (*func)(dyngen_cpu_base, uint32));
|
||||||
|
@ -57,6 +57,13 @@ uint32 NativeOpcode(int selector)
|
|||||||
switch (selector) {
|
switch (selector) {
|
||||||
case NATIVE_CHECK_LOAD_INVOC:
|
case NATIVE_CHECK_LOAD_INVOC:
|
||||||
case NATIVE_NAMED_CHECK_LOAD_INVOC:
|
case NATIVE_NAMED_CHECK_LOAD_INVOC:
|
||||||
|
case NATIVE_NQD_SYNC_HOOK:
|
||||||
|
case NATIVE_NQD_BITBLT_HOOK:
|
||||||
|
case NATIVE_NQD_FILLRECT_HOOK:
|
||||||
|
case NATIVE_NQD_UNKNOWN_HOOK:
|
||||||
|
case NATIVE_NQD_BITBLT:
|
||||||
|
case NATIVE_NQD_INVRECT:
|
||||||
|
case NATIVE_NQD_FILLRECT:
|
||||||
opcode = POWERPC_NATIVE_OP(0, selector);
|
opcode = POWERPC_NATIVE_OP(0, selector);
|
||||||
break;
|
break;
|
||||||
case NATIVE_PATCH_NAME_REGISTRY:
|
case NATIVE_PATCH_NAME_REGISTRY:
|
||||||
@ -89,13 +96,6 @@ uint32 NativeOpcode(int selector)
|
|||||||
case NATIVE_GET_NAMED_RESOURCE:
|
case NATIVE_GET_NAMED_RESOURCE:
|
||||||
case NATIVE_GET_1_NAMED_RESOURCE:
|
case NATIVE_GET_1_NAMED_RESOURCE:
|
||||||
case NATIVE_MAKE_EXECUTABLE:
|
case NATIVE_MAKE_EXECUTABLE:
|
||||||
case NATIVE_NQD_SYNC_HOOK:
|
|
||||||
case NATIVE_NQD_BITBLT_HOOK:
|
|
||||||
case NATIVE_NQD_FILLRECT_HOOK:
|
|
||||||
case NATIVE_NQD_UNKNOWN_HOOK:
|
|
||||||
case NATIVE_NQD_BITBLT:
|
|
||||||
case NATIVE_NQD_INVRECT:
|
|
||||||
case NATIVE_NQD_FILLRECT:
|
|
||||||
opcode = POWERPC_NATIVE_OP(1, selector);
|
opcode = POWERPC_NATIVE_OP(1, selector);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -262,10 +262,11 @@ bool ThunksInit(void)
|
|||||||
{
|
{
|
||||||
#if EMULATED_PPC
|
#if EMULATED_PPC
|
||||||
for (int i = 0; i < NATIVE_OP_MAX; i++) {
|
for (int i = 0; i < NATIVE_OP_MAX; i++) {
|
||||||
uintptr base = SheepMem::Reserve(12);
|
uintptr base = SheepMem::Reserve(16);
|
||||||
WriteMacInt32(base + 0, base + 8);
|
WriteMacInt32(base + 0, base + 8);
|
||||||
WriteMacInt32(base + 4, 0); // Fake TVECT
|
WriteMacInt32(base + 4, 0); // Fake TVECT
|
||||||
WriteMacInt32(base + 8, NativeOpcode(i));
|
WriteMacInt32(base + 8, NativeOpcode(i));
|
||||||
|
WriteMacInt32(base + 12, POWERPC_BLR);
|
||||||
native_op[i].tvect = base;
|
native_op[i].tvect = base;
|
||||||
native_op[i].func = base + 8;
|
native_op[i].func = base + 8;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user