diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d9ddeac9..fc3506a56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 --- diff --git a/build.sh b/build.sh index 60978589d..367f5981d 100755 --- a/build.sh +++ b/build.sh @@ -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" diff --git a/core/build.h b/core/build.h index eccc0a7c2..b35b61be8 100755 --- a/core/build.h +++ b/core/build.h @@ -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 diff --git a/core/emulator.cpp b/core/emulator.cpp index 5a3ffc574..905aa4151 100644 --- a/core/emulator.cpp +++ b/core/emulator.cpp @@ -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(); diff --git a/core/hw/sh4/interpr/sh4_interpreter.cpp b/core/hw/sh4/interpr/sh4_interpreter.cpp index f338bc5be..bad2a42e4 100644 --- a/core/hw/sh4/interpr/sh4_interpreter.cpp +++ b/core/hw/sh4/interpr/sh4_interpreter.cpp @@ -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 diff --git a/core/hw/sh4/sh4_if.h b/core/hw/sh4/sh4_if.h index 330513607..fd4c2d938 100644 --- a/core/hw/sh4/sh4_if.h +++ b/core/hw/sh4/sh4_if.h @@ -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 diff --git a/tests/src/Sh4InterpreterTest.cpp b/tests/src/Sh4InterpreterTest.cpp index edab61c8a..fd8842717 100644 --- a/tests/src/Sh4InterpreterTest.cpp +++ b/tests/src/Sh4InterpreterTest.cpp @@ -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 { diff --git a/tests/test.sh b/tests/test.sh index 3387521b2..29f0d8631 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -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 \