From 7d1bd565a6c52bb546067a2cea3e68d3d86a9616 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 21 Dec 2020 09:22:06 -0500 Subject: DSP: Eliminate most global state An unfortunately large single commit that deglobalizes the DSP code. (which I'm very sorry about). This would have otherwise been extremely difficult to separate due to extensive use of the globals in very coupling ways that would result in more scaffolding to work around than is worth it. Aside from the video code, I believe only the DSP code is the hairiest to deal with in terms of globals, so I guess it's best to get this dealt with right off the bat. A summary of what this commit does: - Turns the DSPInterpreter into its own class This is the most involved portion of this change. The bulk of the changes are turning non-member functions into member functions that would be situated into the Interpreter class. - Eliminates all usages to globals within DSPCore. This generally involves turning a lot of non-member functions into member functions that are either situated within SDSP or DSPCore. - Discards DSPDebugInterface (it wasn't hooked up to anything, and for the sake of eliminating global state, I'd rather get rid of it than think up ways for this class to be integrated with everything else. - Readjusts the DSP JIT to handle calling out to member functions. In most cases, this just means wrapping respective member function calles into thunk functions. Surprisingly, this doesn't even make use of the introduced System class. It was possible all along to do this without it. We can house everything within the DSPLLE class, which is quite nice =) --- Source/Core/Common/x64Emitter.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/x64Emitter.h b/Source/Core/Common/x64Emitter.h index 6e675e2958..97874dd72c 100644 --- a/Source/Core/Common/x64Emitter.h +++ b/Source/Core/Common/x64Emitter.h @@ -1096,6 +1096,13 @@ public: ABI_CallFunction(func); } + template + void ABI_CallFunctionP(FunctionPointer func, const void* param1) + { + MOV(64, R(ABI_PARAM1), Imm64(reinterpret_cast(param1))); + ABI_CallFunction(func); + } + template void ABI_CallFunctionPC(FunctionPointer func, const void* param1, u32 param2) { @@ -1122,6 +1129,15 @@ public: ABI_CallFunction(func); } + // Pass a pointer and register as a parameter. + template + void ABI_CallFunctionPR(FunctionPointer func, const void* ptr, X64Reg reg1) + { + MOV(64, R(ABI_PARAM2), R(reg1)); + MOV(64, R(ABI_PARAM1), Imm64(reinterpret_cast(ptr))); + ABI_CallFunction(func); + } + // Pass two registers as parameters. template void ABI_CallFunctionRR(FunctionPointer func, X64Reg reg1, X64Reg reg2) @@ -1130,6 +1146,15 @@ public: ABI_CallFunction(func); } + // Pass a pointer and two registers as parameters. + template + void ABI_CallFunctionPRR(FunctionPointer func, const void* ptr, X64Reg reg1, X64Reg reg2) + { + MOVTwo(64, ABI_PARAM2, reg1, 0, ABI_PARAM3, reg2); + MOV(64, R(ABI_PARAM1), Imm64(reinterpret_cast(ptr))); + ABI_CallFunction(func); + } + template void ABI_CallFunctionAC(int bits, FunctionPointer func, const Gen::OpArg& arg1, u32 param2) { -- cgit v1.2.3