Skip to content

Commit de54241

Browse files
authored
PPCRec: Rework floating point instructions (#1554)
1 parent 33d5c6d commit de54241

22 files changed

+1408
-2859
lines changed

src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ add_subdirectory(audio)
4949
add_subdirectory(util)
5050
add_subdirectory(imgui)
5151
add_subdirectory(resource)
52-
add_subdirectory(asm)
5352

5453
add_executable(CemuBin
5554
main.cpp

src/Cafe/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ else()
548548
endif()
549549

550550
target_link_libraries(CemuCafe PRIVATE
551-
CemuAsm
552551
CemuAudio
553552
CemuCommon
554553
CemuComponents

src/Cafe/HW/Espresso/EspressoISA.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ namespace Espresso
1010
CR_BIT_INDEX_SO = 3,
1111
};
1212

13+
enum class PSQ_LOAD_TYPE
14+
{
15+
TYPE_F32 = 0,
16+
TYPE_UNUSED1 = 1,
17+
TYPE_UNUSED2 = 2,
18+
TYPE_UNUSED3 = 3,
19+
TYPE_U8 = 4,
20+
TYPE_U16 = 5,
21+
TYPE_S8 = 6,
22+
TYPE_S16 = 7,
23+
};
24+
1325
enum class PrimaryOpcode
1426
{
1527
// underscore at the end of the name means that this instruction always updates CR0 (as if RC bit is set)

src/Cafe/HW/Espresso/PPCTimer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "Cafe/HW/Espresso/Const.h"
2-
#include "asm/x64util.h"
32
#include "config/ActiveSettings.h"
43
#include "util/helpers/fspinlock.h"
54
#include "util/highresolutiontimer/HighResolutionTimer.h"

src/Cafe/HW/Espresso/Recompiler/BackendX64/BackendX64.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ bool PPCRecompilerX64Gen_imlInstruction_r_r(PPCRecFunction_t* PPCRecFunction, pp
609609
}
610610
else
611611
{
612-
debug_printf("PPCRecompilerX64Gen_imlInstruction_r_r(): Unsupported operation 0x%x\n", imlInstruction->operation);
612+
cemuLog_logDebug(LogType::Force, "PPCRecompilerX64Gen_imlInstruction_r_r(): Unsupported operation 0x%x\n", imlInstruction->operation);
613613
return false;
614614
}
615615
return true;
@@ -635,7 +635,7 @@ bool PPCRecompilerX64Gen_imlInstruction_r_s32(PPCRecFunction_t* PPCRecFunction,
635635
}
636636
else
637637
{
638-
debug_printf("PPCRecompilerX64Gen_imlInstruction_r_s32(): Unsupported operation 0x%x\n", imlInstruction->operation);
638+
cemuLog_logDebug(LogType::Force, "PPCRecompilerX64Gen_imlInstruction_r_s32(): Unsupported operation 0x%x\n", imlInstruction->operation);
639639
return false;
640640
}
641641
return true;
@@ -894,7 +894,7 @@ bool PPCRecompilerX64Gen_imlInstruction_r_r_r(PPCRecFunction_t* PPCRecFunction,
894894
}
895895
else
896896
{
897-
debug_printf("PPCRecompilerX64Gen_imlInstruction_r_r_r(): Unsupported operation 0x%x\n", imlInstruction->operation);
897+
cemuLog_logDebug(LogType::Force, "PPCRecompilerX64Gen_imlInstruction_r_r_r(): Unsupported operation 0x%x\n", imlInstruction->operation);
898898
return false;
899899
}
900900
return true;
@@ -1204,9 +1204,11 @@ void PPCRecompilerX64Gen_imlInstruction_r_name(PPCRecFunction_t* PPCRecFunction,
12041204
else if (imlInstruction->op_r_name.regR.GetBaseFormat() == IMLRegFormat::F64)
12051205
{
12061206
auto regR = _regF64(imlInstruction->op_r_name.regR);
1207-
if (name >= PPCREC_NAME_FPR0 && name < (PPCREC_NAME_FPR0 + 32))
1207+
if (name >= PPCREC_NAME_FPR_HALF && name < (PPCREC_NAME_FPR_HALF + 64))
12081208
{
1209-
x64Gen_movupd_xmmReg_memReg128(x64GenContext, regR, REG_RESV_HCPU, offsetof(PPCInterpreter_t, fpr) + sizeof(FPR_t) * (name - PPCREC_NAME_FPR0));
1209+
sint32 regIndex = (name - PPCREC_NAME_FPR_HALF) / 2;
1210+
sint32 pairIndex = (name - PPCREC_NAME_FPR_HALF) % 2;
1211+
x64Gen_movsd_xmmReg_memReg64(x64GenContext, regR, REG_RESV_HCPU, offsetof(PPCInterpreter_t, fpr) + sizeof(FPR_t) * regIndex + pairIndex * sizeof(double));
12101212
}
12111213
else if (name >= PPCREC_NAME_TEMPORARY_FPR0 || name < (PPCREC_NAME_TEMPORARY_FPR0 + 8))
12121214
{
@@ -1281,9 +1283,11 @@ void PPCRecompilerX64Gen_imlInstruction_name_r(PPCRecFunction_t* PPCRecFunction,
12811283
{
12821284
auto regR = _regF64(imlInstruction->op_r_name.regR);
12831285
uint32 name = imlInstruction->op_r_name.name;
1284-
if (name >= PPCREC_NAME_FPR0 && name < (PPCREC_NAME_FPR0 + 32))
1286+
if (name >= PPCREC_NAME_FPR_HALF && name < (PPCREC_NAME_FPR_HALF + 64))
12851287
{
1286-
x64Gen_movupd_memReg128_xmmReg(x64GenContext, regR, REG_RESV_HCPU, offsetof(PPCInterpreter_t, fpr) + sizeof(FPR_t) * (name - PPCREC_NAME_FPR0));
1288+
sint32 regIndex = (name - PPCREC_NAME_FPR_HALF) / 2;
1289+
sint32 pairIndex = (name - PPCREC_NAME_FPR_HALF) % 2;
1290+
x64Gen_movsd_memReg64_xmmReg(x64GenContext, regR, REG_RESV_HCPU, offsetof(PPCInterpreter_t, fpr) + sizeof(FPR_t) * regIndex + (pairIndex ? sizeof(double) : 0));
12871291
}
12881292
else if (name >= PPCREC_NAME_TEMPORARY_FPR0 && name < (PPCREC_NAME_TEMPORARY_FPR0 + 8))
12891293
{

src/Cafe/HW/Espresso/Recompiler/BackendX64/BackendX64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ void x64Gen_movddup_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegi
205205
void x64Gen_movhlps_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, sint32 xmmRegisterSrc);
206206
void x64Gen_movsd_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, sint32 xmmRegisterSrc);
207207
void x64Gen_movsd_memReg64_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegister, sint32 memRegister, uint32 memImmU32);
208+
void x64Gen_movsd_xmmReg_memReg64(x64GenContext_t* x64GenContext, sint32 xmmRegister, sint32 memRegister, uint32 memImmU32);
208209
void x64Gen_movlpd_xmmReg_memReg64(x64GenContext_t* x64GenContext, sint32 xmmRegister, sint32 memRegister, uint32 memImmU32);
209210
void x64Gen_unpcklpd_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, sint32 xmmRegisterSrc);
210211
void x64Gen_unpckhpd_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, sint32 xmmRegisterSrc);
@@ -230,6 +231,7 @@ void x64Gen_andps_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegist
230231
void x64Gen_pcmpeqd_xmmReg_mem128Reg64(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, uint32 memReg, uint32 memImmS32);
231232
void x64Gen_cvttpd2dq_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, sint32 xmmRegisterSrc);
232233
void x64Gen_cvttsd2si_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 registerDest, sint32 xmmRegisterSrc);
234+
void x64Gen_cvtsi2sd_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, sint32 registerSrc);
233235
void x64Gen_cvtsd2ss_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, sint32 xmmRegisterSrc);
234236
void x64Gen_cvtpd2ps_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, sint32 xmmRegisterSrc);
235237
void x64Gen_cvtss2sd_xmmReg_xmmReg(x64GenContext_t* x64GenContext, sint32 xmmRegisterDest, sint32 xmmRegisterSrc);

0 commit comments

Comments
 (0)