Skip to content

Commit

Permalink
PPCRec: Handle edge case for x86 shift instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Exzap committed Oct 29, 2024
1 parent e332726 commit a05b655
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Cafe/HW/Espresso/Recompiler/BackendX64/BackendX64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,14 @@ bool PPCRecompilerX64Gen_imlInstruction_r_r_r(PPCRecFunction_t* PPCRecFunction,
}
else
{
cemu_assert_debug(rRegResult != rRegOperand2);
cemu_assert_debug(rRegResult != X86_REG_RCX);
cemu_assert_debug(rRegOperand2 == X86_REG_RCX);
cemu_assert_debug(rRegOperand2 == X86_REG_ECX);
bool useTempReg = rRegResult == X86_REG_ECX && rRegOperand1 != X86_REG_ECX;
auto origRegResult = rRegResult;
if(useTempReg)
{
x64GenContext->emitter->MOV_dd(REG_RESV_TEMP, rRegOperand1);
rRegResult = REG_RESV_TEMP;
}
if(rRegOperand1 != rRegResult)
x64Gen_mov_reg64_reg64(x64GenContext, rRegResult, rRegOperand1);
if (imlInstruction->operation == PPCREC_IML_OP_RIGHT_SHIFT_S)
Expand All @@ -839,6 +844,8 @@ bool PPCRecompilerX64Gen_imlInstruction_r_r_r(PPCRecFunction_t* PPCRecFunction,
x64GenContext->emitter->SHR_d_CL(rRegResult);
else if (imlInstruction->operation == PPCREC_IML_OP_LEFT_SHIFT)
x64GenContext->emitter->SHL_d_CL(rRegResult);
if(useTempReg)
x64GenContext->emitter->MOV_dd(origRegResult, REG_RESV_TEMP);
}
}
else if( imlInstruction->operation == PPCREC_IML_OP_DIVIDE_SIGNED || imlInstruction->operation == PPCREC_IML_OP_DIVIDE_UNSIGNED )
Expand Down

0 comments on commit a05b655

Please sign in to comment.