Skip to content

Commit a52e39d

Browse files
committed
PPCRec: Code cleanup
1 parent 126a682 commit a52e39d

File tree

10 files changed

+185
-523
lines changed

10 files changed

+185
-523
lines changed

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

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,6 @@ void* ATTR_MS_ABI PPCRecompiler_virtualHLE(PPCInterpreter_t* hCPU, uint32 hleFun
172172
return PPCInterpreter_getCurrentInstance();
173173
}
174174

175-
void ATTR_MS_ABI PPCRecompiler_getTBL(PPCInterpreter_t* hCPU, uint32 gprIndex)
176-
{
177-
uint64 coreTime = coreinit::coreinit_getTimerTick();
178-
hCPU->gpr[gprIndex] = (uint32)(coreTime&0xFFFFFFFF);
179-
}
180-
181-
void ATTR_MS_ABI PPCRecompiler_getTBU(PPCInterpreter_t* hCPU, uint32 gprIndex)
182-
{
183-
uint64 coreTime = coreinit::coreinit_getTimerTick();
184-
hCPU->gpr[gprIndex] = (uint32)((coreTime>>32)&0xFFFFFFFF);
185-
}
186-
187175
bool PPCRecompilerX64Gen_imlInstruction_macro(PPCRecFunction_t* PPCRecFunction, ppcImlGenContext_t* ppcImlGenContext, x64GenContext_t* x64GenContext, IMLInstruction* imlInstruction)
188176
{
189177
if (imlInstruction->operation == PPCREC_IML_MACRO_B_TO_REG)
@@ -340,43 +328,6 @@ bool PPCRecompilerX64Gen_imlInstruction_macro(PPCRecFunction_t* PPCRecFunction,
340328
x64Gen_jmp_memReg64(x64GenContext, X86_REG_RAX, (uint32)offsetof(PPCRecompilerInstanceData_t, ppcRecompilerDirectJumpTable));
341329
return true;
342330
}
343-
else if( imlInstruction->operation == PPCREC_IML_MACRO_MFTB )
344-
{
345-
// according to MS ABI the caller needs to save:
346-
// RAX, RCX, RDX, R8, R9, R10, R11
347-
348-
uint32 ppcAddress = imlInstruction->op_macro.param;
349-
uint32 sprId = imlInstruction->op_macro.param2&0xFFFF;
350-
uint32 gprIndex = (imlInstruction->op_macro.param2>>16)&0x1F;
351-
// update instruction pointer
352-
x64Gen_mov_mem32Reg64_imm32(x64GenContext, X86_REG_RSP, offsetof(PPCInterpreter_t, instructionPointer), ppcAddress);
353-
// set parameters
354-
x64Gen_mov_reg64_reg64(x64GenContext, X86_REG_RCX, X86_REG_RSP);
355-
x64Gen_mov_reg64_imm64(x64GenContext, X86_REG_RDX, gprIndex);
356-
// restore stackpointer to original RSP
357-
x64Emit_mov_reg64_mem64(x64GenContext, X86_REG_RSP, REG_RESV_HCPU, offsetof(PPCInterpreter_t, rspTemp));
358-
// push hCPU on stack
359-
x64Gen_push_reg64(x64GenContext, X86_REG_RCX);
360-
// reserve space on stack for call parameters
361-
x64Gen_sub_reg64_imm32(x64GenContext, X86_REG_RSP, 8*11 + 8);
362-
x64Gen_mov_reg64_imm64(x64GenContext, X86_REG_RBP, 0);
363-
// call function
364-
if( sprId == SPR_TBL )
365-
x64Gen_mov_reg64_imm64(x64GenContext, X86_REG_RAX, (uint64)PPCRecompiler_getTBL);
366-
else if( sprId == SPR_TBU )
367-
x64Gen_mov_reg64_imm64(x64GenContext, X86_REG_RAX, (uint64)PPCRecompiler_getTBU);
368-
else
369-
assert_dbg();
370-
x64Gen_call_reg64(x64GenContext, X86_REG_RAX);
371-
// restore hCPU from stack
372-
x64Gen_add_reg64_imm32(x64GenContext, X86_REG_RSP, 8 * 11 + 8);
373-
x64Gen_pop_reg64(x64GenContext, X86_REG_RSP);
374-
// MOV R15, ppcRecompilerInstanceData
375-
x64Gen_mov_reg64_imm64(x64GenContext, X86_REG_R15, (uint64)ppcRecompilerInstanceData);
376-
// MOV R13, memory_base
377-
x64Gen_mov_reg64_imm64(x64GenContext, X86_REG_R13, (uint64)memory_base);
378-
return true;
379-
}
380331
else
381332
{
382333
debug_printf("Unknown recompiler macro operation %d\n", imlInstruction->operation);

src/Cafe/HW/Espresso/Recompiler/IML/IMLDebug.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,23 @@ void IMLDebug_PrintLivenessRangeInfo(StringBuf& currentLineText, IMLSegment* iml
9797
raLivenessRange* subrangeItr = imlSegment->raInfo.linkedList_allSubranges;
9898
while (subrangeItr)
9999
{
100-
if (subrangeItr->interval2.start.GetInstructionIndexEx() == offset)
100+
if (subrangeItr->interval.start.GetInstructionIndexEx() == offset)
101101
{
102-
if(subrangeItr->interval2.start.IsInstructionIndex() && !subrangeItr->interval2.start.IsOnInputEdge())
102+
if(subrangeItr->interval.start.IsInstructionIndex() && !subrangeItr->interval.start.IsOnInputEdge())
103103
currentLineText.add(".");
104104
else
105105
currentLineText.add("|");
106106

107107
currentLineText.addFmt("{:<4}", subrangeItr->GetVirtualRegister());
108108
}
109-
else if (subrangeItr->interval2.end.GetInstructionIndexEx() == offset)
109+
else if (subrangeItr->interval.end.GetInstructionIndexEx() == offset)
110110
{
111-
if(subrangeItr->interval2.end.IsInstructionIndex() && !subrangeItr->interval2.end.IsOnOutputEdge())
111+
if(subrangeItr->interval.end.IsInstructionIndex() && !subrangeItr->interval.end.IsOnOutputEdge())
112112
currentLineText.add("* ");
113113
else
114114
currentLineText.add("| ");
115115
}
116-
else if (subrangeItr->interval2.ContainsInstructionIndexEx(offset))
116+
else if (subrangeItr->interval.ContainsInstructionIndexEx(offset))
117117
{
118118
currentLineText.add("| ");
119119
}
@@ -374,10 +374,6 @@ void IMLDebug_DisassembleInstruction(const IMLInstruction& inst, std::string& di
374374
{
375375
strOutput.addFmt("MACRO HLE ppcAddr: 0x{:08x} funcId: 0x{:08x}", inst.op_macro.param, inst.op_macro.param2);
376376
}
377-
else if (inst.operation == PPCREC_IML_MACRO_MFTB)
378-
{
379-
strOutput.addFmt("MACRO MFTB ppcAddr: 0x{:08x} sprId: 0x{:08x}", inst.op_macro.param, inst.op_macro.param2);
380-
}
381377
else if (inst.operation == PPCREC_IML_MACRO_COUNT_CYCLES)
382378
{
383379
strOutput.addFmt("MACRO COUNT_CYCLES cycles: {}", inst.op_macro.param);

0 commit comments

Comments
 (0)