start to add back dynarec

This commit is contained in:
Joseph Mattiello 2025-07-03 15:36:00 -04:00
parent e0fe1ed3db
commit 150aef8cc8
8 changed files with 46 additions and 20 deletions

View File

@ -2081,9 +2081,9 @@ if(${CMAKE_GENERATOR} MATCHES "^Xcode.*|^Visual Studio.*")
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SRC_FILES})
endif()
option(ENABLE_SH4_IR "Enable cached IR SH4 interpreter (no JIT)" ON)
option(ENABLE_SH4_CACHED_IR "Enable cached IR SH4 interpreter (no JIT)" ON)
if(ENABLE_SH4_IR)
if(ENABLE_SH4_CACHED_IR)
target_sources(${PROJECT_NAME} PRIVATE
core/hw/sh4/ir/ir_defs.h
core/hw/sh4/ir/ir_emitter.h
@ -2097,7 +2097,7 @@ if(ENABLE_SH4_IR)
core/hw/sh4/ir/ir_blockmanager_stubs.cpp)
# Ensure dynamic recompiler code paths are fully disabled when using the IR interpreter
# These macros are checked in core/build.h to set FEAT_SHREC/FEAT_AREC/DSP rec to DYNAREC_NONE
target_compile_definitions(${PROJECT_NAME} PRIVATE ENABLE_SH4_IR TARGET_NO_REC NO_JIT)
target_compile_definitions(${PROJECT_NAME} PRIVATE ENABLE_SH4_CACHED_IR TARGET_NO_REC NO_JIT)
endif()
# --- Jitless Dynarec Backend ---

View File

@ -171,7 +171,7 @@ CMAKE_CMD="cmake -B ${BUILD_DIR} \
-DCMAKE_CXX_FLAGS=\"${CXX_FLAGS}\" \
-DIOS=${IOS} \
-DCMAKE_SYSTEM_NAME=${SYSTEM_NAME} \
-DENABLE_SH4_IR=ON \
-DENABLE_SH4_CACHED_IR=ON \
-DNO_JIT=ON \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5"

View File

@ -5,8 +5,6 @@
#define USE_WINCE_HACK
#endif
#define ENABLE_SH4_IR 1
#define DC_PLATFORM_DREAMCAST 0
#define DC_PLATFORM_DEV_UNIT 1
#define DC_PLATFORM_NAOMI 2

View File

@ -487,10 +487,27 @@ void Emulator::init()
reios_init();
// the recompiler may start generating code at this point and needs a fully configured machine
// Always use the new IR interpreter regardless of build flags.
sh4::ir::Get_Sh4Interpreter(&sh4_cpu);
sh4_cpu.Init();
INFO_LOG(INTERPRETER, "Using IR Interpreter (forced)");
#if FEAT_SHREC != DYNAREC_NONE
Get_Sh4Recompiler(&sh4_cpu);
sh4_cpu.Init(); // Also initialize the interpreter
if(config::DynarecEnabled)
{
INFO_LOG(DYNAREC, "Using Recompiler");
}
else
#endif // FEAT_SHREC != DYNAREC_NONE
{
#ifdef ENABLE_SH4_CACHED_IR
INFO_LOG(INTERPRETER, "Using new Cached Interpreter");
sh4::ir::Get_Sh4Interpreter(&sh4_cpu);
sh4_cpu.Init();
#else
Get_Sh4Interpreter(&sh4_cpu);
sh4_cpu.Init();
INFO_LOG(INTERPRETER, "Using Interpreter");
#endif // ENABLE_SH4_CACHED_IR
}
state = Init;
}
@ -921,16 +938,23 @@ void Emulator::start()
if (config::GGPOEnable && config::ThreadedRendering)
// Not supported with GGPO
config::EmulateFramebuffer.override(false);
#if defined(ENABLE_SH4_JITLESS)
#if FEAT_SHREC != DYNAREC_NONE
if (config::DynarecEnabled)
{
Get_Sh4Recompiler(&sh4_cpu);
INFO_LOG(DYNAREC, "Using JITLESS Dynarec Backend");
#elif defined(ENABLE_SH4_IR)
INFO_LOG(DYNAREC, "Using Recompiler");
}
else
#endif // FEAT_SHREC != DYNAREC_NONE
{
#if defined(ENABLE_SH4_CACHED_IR)
sh4::ir::Get_Sh4Interpreter(&sh4_cpu);
INFO_LOG(DYNAREC, "Using NEW Interpreter");
INFO_LOG(DYNAREC, "Using NEW Cached Interpreter");
#else
Get_Sh4Interpreter(&sh4_cpu);
INFO_LOG(DYNAREC, "Using LEGACY Interpreter");
#endif
#endif // ENABLE_SH4_CACHED_IR
}
setupPtyPipe();
memwatch::protect();

View File

@ -206,7 +206,7 @@ static void Sh4_int_Term()
INFO_LOG(INTERPRETER, "Sh4 Term");
}
#ifndef ENABLE_SH4_IR
#ifndef ENABLE_SH4_CACHED_IR
void Get_Sh4Interpreter(sh4_if* cpu)
{
fprintf(stderr, "[LEGACY-INT] Get_Sh4Interpreter called — linking legacy interpreter!\n");
@ -221,4 +221,4 @@ void Get_Sh4Interpreter(sh4_if* cpu)
cpu->ResetCache = sh4_int_resetcache;
}
#endif // ENABLE_SH4_IR
#endif // ENABLE_SH4_CACHED_IR

View File

@ -316,7 +316,7 @@ static inline void sh4_sr_SetFull(u32 value)
#define sh4rcb (*p_sh4rcb)
#define Sh4cntx (sh4rcb.cntx)
#ifdef ENABLE_SH4_IR
#ifdef ENABLE_SH4_CACHED_IR
namespace sh4 { namespace ir { void Get_Sh4Interpreter(sh4_if* cpu); } }
#endif

View File

@ -31,7 +31,11 @@ protected:
mem_map_default();
dc_reset(true);
ctx = &p_sh4rcb->cntx;
::sh4::ir::Get_Sh4Interpreter(&this->sh4);
#ifdef ENABLE_SH4_CACHED_IR
::sh4::ir::Get_Sh4Interpreter(&this->sh4);
#else
::Get_Sh4Interpreter(&this->sh4);
#endif
}
void PrepareOp(u16 op, u16 op2 = 0, u16 op3 = 0) override
{

View File

@ -76,7 +76,7 @@ fi
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DENABLE_SH4_IR=ON \
-DENABLE_SH4_CACHED_IR=ON \
-DBUILD_TESTING=ON \
-DENABLE_OPENMP=OFF \
-DUSE_JIT=OFF \