From fc05727538085adc88314b35876cc50b335f5967 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 11 Jan 2019 23:52:20 +0100 Subject: [PATCH] dynarecs clean-up move GetRegPtr and ngen_FailedToFindBlock to sh4/dyna --- core/hw/sh4/dyna/driver.cpp | 6 ++++ core/hw/sh4/dyna/shil.h | 5 +--- core/hw/sh4/interpr/sh4_interpreter.cpp | 6 ++-- core/hw/sh4/sh4_core_regs.cpp | 5 ++++ core/hw/sh4/sh4_if.h | 2 ++ core/rec-ARM/rec_arm.cpp | 12 ++------ core/rec-ARM64/rec_arm64.cpp | 37 +++---------------------- core/rec-cpp/rec_cpp.cpp | 13 +-------- core/rec-x64/rec_x64.cpp | 15 +--------- core/rec-x86/rec_x86_asm.cpp | 2 -- core/rec-x86/rec_x86_driver.cpp | 7 ++--- 11 files changed, 29 insertions(+), 81 deletions(-) diff --git a/core/hw/sh4/dyna/driver.cpp b/core/hw/sh4/dyna/driver.cpp index 24c4ca2f8..ec63d013b 100644 --- a/core/hw/sh4/dyna/driver.cpp +++ b/core/hw/sh4/dyna/driver.cpp @@ -252,6 +252,12 @@ DynarecCodeEntryPtr DYNACALL rdv_FailedToFindBlock(u32 pc) return rdv_CompilePC(); } +static void ngen_FailedToFindBlock_internal() { + rdv_FailedToFindBlock(Sh4cntx.pc); +} + +void (*ngen_FailedToFindBlock)() = &ngen_FailedToFindBlock_internal; + extern u32 rebuild_counter; diff --git a/core/hw/sh4/dyna/shil.h b/core/hw/sh4/dyna/shil.h index 651aad592..c85b6ce87 100644 --- a/core/hw/sh4/dyna/shil.h +++ b/core/hw/sh4/dyna/shil.h @@ -35,9 +35,6 @@ enum shil_param_type #define SHIL_MODE 0 #include "shil_canonical.h" -//this should be really removed ... -u32* GetRegPtr(u32 reg); - struct shil_param { shil_param() @@ -160,4 +157,4 @@ struct shil_opcode const char* shil_opcode_name(int op); -string name_reg(u32 reg); \ No newline at end of file +string name_reg(u32 reg); diff --git a/core/hw/sh4/interpr/sh4_interpreter.cpp b/core/hw/sh4/interpr/sh4_interpreter.cpp index d4dd59820..83358ae71 100644 --- a/core/hw/sh4/interpr/sh4_interpreter.cpp +++ b/core/hw/sh4/interpr/sh4_interpreter.cpp @@ -254,8 +254,10 @@ int UpdateSystem() int UpdateSystem_INTC() { - UpdateSystem(); - return UpdateINTC(); + if (UpdateSystem()) + return UpdateINTC(); + else + return 0; } void sh4_int_resetcache() { } diff --git a/core/hw/sh4/sh4_core_regs.cpp b/core/hw/sh4/sh4_core_regs.cpp index b3ac644dc..5bbfff5c7 100644 --- a/core/hw/sh4/sh4_core_regs.cpp +++ b/core/hw/sh4/sh4_core_regs.cpp @@ -260,3 +260,8 @@ u32 sh4context_offset_regtype(Sh4RegType sh4_reg) { return sh4context_offset_u32(sh4_reg); } + +u32* GetRegPtr(u32 reg) +{ + return Sh4_int_GetRegisterPtr((Sh4RegType)reg); +} diff --git a/core/hw/sh4/sh4_if.h b/core/hw/sh4/sh4_if.h index 332fb85be..968efb317 100644 --- a/core/hw/sh4/sh4_if.h +++ b/core/hw/sh4/sh4_if.h @@ -354,3 +354,5 @@ s32 rcb_poffs(T* ptr) //Get an interface to sh4 interpreter void Get_Sh4Interpreter(sh4_if* cpu); void Get_Sh4Recompiler(sh4_if* cpu); + +u32* GetRegPtr(u32 reg); diff --git a/core/rec-ARM/rec_arm.cpp b/core/rec-ARM/rec_arm.cpp index 242d41b77..7d62d410a 100644 --- a/core/rec-ARM/rec_arm.cpp +++ b/core/rec-ARM/rec_arm.cpp @@ -197,13 +197,6 @@ typedef void BinaryOP (eReg Rd, eReg Rn, eReg Rm, ConditionCode CC); typedef void BinaryOPImm (eReg Rd, eReg Rn, s32 sImm8, ConditionCode CC); typedef void UnaryOP (eReg Rd, eReg Rs); - -u32* GetRegPtr(u32 reg) -{ - return Sh4_int_GetRegisterPtr((Sh4RegType)reg); -} - - // you pick reg, loads Base with reg addr, no reg. mapping yet ! void LoadSh4Reg_mem(eReg Rt, u32 Sh4_Reg, eCC CC=CC_AL) { @@ -343,7 +336,6 @@ extern "C" void ngen_LinkBlock_cond_Branch_stub(); extern "C" void ngen_LinkBlock_cond_Next_stub(); extern "C" void ngen_FailedToFindBlock_(); -void (*ngen_FailedToFindBlock)()=&ngen_FailedToFindBlock_; // in asm #include @@ -2258,7 +2250,9 @@ void ngen_init() verify(FPCB_OFFSET == -0x2100000 || FPCB_OFFSET == -0x4100000); verify(rcb_noffs(p_sh4rcb->fpcb) == FPCB_OFFSET); - for (int s=0;s<6;s++) + ngen_FailedToFindBlock = &ngen_FailedToFindBlock_; + + for (int s=0;s<6;s++) { void* fn=s==0?(void*)_vmem_ReadMem8SX32: s==1?(void*)_vmem_ReadMem16SX32: diff --git a/core/rec-ARM64/rec_arm64.cpp b/core/rec-ARM64/rec_arm64.cpp index 8e8e16c1d..3fa0c33ec 100644 --- a/core/rec-ARM64/rec_arm64.cpp +++ b/core/rec-ARM64/rec_arm64.cpp @@ -92,27 +92,6 @@ static void CacheFlush(void* start, void* end) #endif } -static void ngen_FailedToFindBlock_internal() { - rdv_FailedToFindBlock(Sh4cntx.pc); -} - -void(*ngen_FailedToFindBlock)() = &ngen_FailedToFindBlock_internal; - -extern "C" { - -void *bm_GetCodeInternal(u32 pc) -{ - return (void*)bm_GetCode(pc); -} - -void UpdateSystemInternal(u32 pc) -{ - if (UpdateSystem()) - rdv_DoInterrupts_pc(pc); -} - -} - void ngen_mainloop(void* v_cntx) { Sh4RCB* ctx = (Sh4RCB*)((u8*)v_cntx - sizeof(Sh4RCB)); @@ -140,14 +119,13 @@ void ngen_mainloop(void* v_cntx) "slice_loop: \n\t" "ldr w0, [x28, %1] \n\t" // pc - "bl bm_GetCodeInternal \n\t" + "bl bm_GetCode2 \n\t" "blr x0 \n\t" "cmp w27, #0 \n\t" "b.gt slice_loop \n\t" "add w27, w27, %2 \n\t" // SH4_TIMESLICE - "ldr w0, [x28, %1] \n\t" // pc - "bl UpdateSystemInternal \n\t" + "bl UpdateSystem_INTC \n\t" "b run_loop \n\t" "end_run_loop: \n\t" @@ -188,12 +166,7 @@ RuntimeBlockInfo* ngen_AllocateBlock() return new DynaRBI(); } -u32* GetRegPtr(u32 reg) -{ - return Sh4_int_GetRegisterPtr((Sh4RegType)reg); -} - -void ngen_blockcheckfail(u32 pc) { +static void ngen_blockcheckfail(u32 pc) { printf("arm64 JIT: SMC invalidation at %08X\n", pc); rdv_BlockCheckFail(pc); } @@ -722,14 +695,12 @@ public: if (CCN_MMUCR.AT) { - Mov(x9, reinterpret_cast(&do_sqw_mmu)); + Ldr(x9, reinterpret_cast(&do_sqw_mmu)); } else { - verify(offsetof(Sh4RCB, cntx) - offsetof(Sh4RCB, do_sqw_nommu) > 0); Sub(x9, x28, offsetof(Sh4RCB, cntx) - offsetof(Sh4RCB, do_sqw_nommu)); Ldr(x9, MemOperand(x9)); - verify(offsetof(Sh4RCB, cntx) - offsetof(Sh4RCB, sq_buffer) > 0); Sub(x1, x28, offsetof(Sh4RCB, cntx) - offsetof(Sh4RCB, sq_buffer)); } if (!frame_reg_saved) diff --git a/core/rec-cpp/rec_cpp.cpp b/core/rec-cpp/rec_cpp.cpp index d5419e55a..c2232fbba 100644 --- a/core/rec-cpp/rec_cpp.cpp +++ b/core/rec-cpp/rec_cpp.cpp @@ -37,12 +37,6 @@ struct DynaRBI : RuntimeBlockInfo int cycle_counter; extern int mips_counter; -void ngen_FailedToFindBlock_internal() { - rdv_FailedToFindBlock(Sh4cntx.pc); -} - -void(*ngen_FailedToFindBlock)() = &ngen_FailedToFindBlock_internal; - void ngen_mainloop(void* v_cntx) { Sh4RCB* ctx = (Sh4RCB*)((u8*)v_cntx - sizeof(Sh4RCB)); @@ -81,12 +75,7 @@ RuntimeBlockInfo* ngen_AllocateBlock() return new DynaRBI(); } -u32* GetRegPtr(u32 reg) -{ - return Sh4_int_GetRegisterPtr((Sh4RegType)reg); -} - -void ngen_blockcheckfail(u32 pc) { +static void ngen_blockcheckfail(u32 pc) { printf("REC CPP: SMC invalidation at %08X\n", pc); rdv_BlockCheckFail(pc); } diff --git a/core/rec-x64/rec_x64.cpp b/core/rec-x64/rec_x64.cpp index 1b3a13c11..040264cf2 100644 --- a/core/rec-x64/rec_x64.cpp +++ b/core/rec-x64/rec_x64.cpp @@ -28,16 +28,8 @@ struct DynaRBI : RuntimeBlockInfo } }; - - int cycle_counter; -void ngen_FailedToFindBlock_internal() { - rdv_FailedToFindBlock(Sh4cntx.pc); -} - -void(*ngen_FailedToFindBlock)() = &ngen_FailedToFindBlock_internal; - void ngen_mainloop(void* v_cntx) { Sh4RCB* ctx = (Sh4RCB*)((u8*)v_cntx - sizeof(Sh4RCB)); @@ -77,12 +69,7 @@ RuntimeBlockInfo* ngen_AllocateBlock() return new DynaRBI(); } -u32* GetRegPtr(u32 reg) -{ - return Sh4_int_GetRegisterPtr((Sh4RegType)reg); -} - -void ngen_blockcheckfail(u32 pc) { +static void ngen_blockcheckfail(u32 pc) { printf("X64 JIT: SMC invalidation at %08X\n", pc); rdv_BlockCheckFail(pc); } diff --git a/core/rec-x86/rec_x86_asm.cpp b/core/rec-x86/rec_x86_asm.cpp index 2572b7f3f..74ba494f5 100644 --- a/core/rec-x86/rec_x86_asm.cpp +++ b/core/rec-x86/rec_x86_asm.cpp @@ -62,7 +62,6 @@ naked void ngen_FailedToFindBlock_() const u32 cpurun_offset=offsetof(Sh4RCB,cntx.CpuRunning); const u32 nextpc_offset=offsetof(Sh4RCB,cntx.pc); -void (*ngen_FailedToFindBlock)()=&ngen_FailedToFindBlock_; naked void ngen_mainloop(void* cntx) { __asm @@ -138,6 +137,5 @@ naked void DYNACALL ngen_blockcheckfail2(u32 addr) u32 gas_offs=offsetof(Sh4RCB,cntx.jdyn); u32 cpurun_offset=offsetof(Sh4RCB,cntx.CpuRunning); u32 nextpc_offset=offsetof(Sh4RCB,cntx.pc); - void (*ngen_FailedToFindBlock)()=&ngen_FailedToFindBlock_; #endif #endif diff --git a/core/rec-x86/rec_x86_driver.cpp b/core/rec-x86/rec_x86_driver.cpp index bcddb280f..acb138266 100644 --- a/core/rec-x86/rec_x86_driver.cpp +++ b/core/rec-x86/rec_x86_driver.cpp @@ -257,11 +257,6 @@ void DYNACALL PrintBlock(u32 pc) printf("\n"); } -u32* GetRegPtr(u32 reg) -{ - return Sh4_int_GetRegisterPtr((Sh4RegType)reg); -} - u32 cvld; u32 rdmt[6]; extern u32 memops_t,memops_l; @@ -763,6 +758,8 @@ void* mem_code[3][2][5]; void ngen_init() { + ngen_FailedToFindBlock = &ngen_FailedToFindBlock_; + //Setup emitter x86e = new x86_block(); x86e->Init(0,0);