diff --git a/src/Cafe/HW/Espresso/Recompiler/BackendX64/BackendX64.cpp b/src/Cafe/HW/Espresso/Recompiler/BackendX64/BackendX64.cpp index af0dffcb..44a2c78e 100644 --- a/src/Cafe/HW/Espresso/Recompiler/BackendX64/BackendX64.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/BackendX64/BackendX64.cpp @@ -1964,8 +1964,8 @@ bool PPCRecompilerX64Gen_imlInstruction_conditionalJump(PPCRecFunction_t* PPCRec { // deprecated (jump to jumpmark) __debugbreak(); // deprecated - PPCRecompilerX64Gen_rememberRelocatableOffset(x64GenContext, X64_RELOC_LINK_TO_PPC, (void*)(size_t)imlInstruction->op_conditionalJump.jumpmarkAddress); - x64Gen_jmp_imm32(x64GenContext, 0); + //PPCRecompilerX64Gen_rememberRelocatableOffset(x64GenContext, X64_RELOC_LINK_TO_PPC, (void*)(size_t)imlInstruction->op_conditionalJump.jumpmarkAddress); + //x64Gen_jmp_imm32(x64GenContext, 0); } } else @@ -2135,12 +2135,6 @@ bool PPCRecompilerX64Gen_imlInstruction_cr(PPCRecFunction_t* PPCRecFunction, ppc return false; } - -void PPCRecompilerX64Gen_imlInstruction_ppcEnter(PPCRecFunction_t* PPCRecFunction, ppcImlGenContext_t* ppcImlGenContext, x64GenContext_t* x64GenContext, IMLInstruction* imlInstruction) -{ - imlInstruction->op_ppcEnter.x64Offset = x64GenContext->codeBufferIndex; -} - void PPCRecompilerX64Gen_imlInstruction_r_name(PPCRecFunction_t* PPCRecFunction, ppcImlGenContext_t* ppcImlGenContext, x64GenContext_t* x64GenContext, IMLInstruction* imlInstruction) { uint32 name = imlInstruction->op_r_name.name; @@ -2346,10 +2340,6 @@ bool PPCRecompiler_generateX64Code(PPCRecFunction_t* PPCRecFunction, ppcImlGenCo { // no op } - else if( imlInstruction->type == PPCREC_IML_TYPE_PPC_ENTER ) - { - PPCRecompilerX64Gen_imlInstruction_ppcEnter(PPCRecFunction, ppcImlGenContext, &x64GenContext, imlInstruction); - } else if( imlInstruction->type == PPCREC_IML_TYPE_FPR_R_NAME ) { PPCRecompilerX64Gen_imlInstruction_fpr_r_name(PPCRecFunction, ppcImlGenContext, &x64GenContext, imlInstruction); diff --git a/src/Cafe/HW/Espresso/Recompiler/IML/IMLDebug.cpp b/src/Cafe/HW/Espresso/Recompiler/IML/IMLDebug.cpp index 675329a6..d52192d8 100644 --- a/src/Cafe/HW/Espresso/Recompiler/IML/IMLDebug.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/IML/IMLDebug.cpp @@ -240,10 +240,6 @@ void IMLDebug_DumpSegment(ppcImlGenContext_t* ctx, IMLSegment* imlSegment, bool { strOutput.addFmt("jm_{:08x}:", inst.op_jumpmark.address); } - else if (inst.type == PPCREC_IML_TYPE_PPC_ENTER) - { - strOutput.addFmt("ppcEnter_{:08x}:", inst.op_ppcEnter.ppcAddress); - } else if (inst.type == PPCREC_IML_TYPE_LOAD || inst.type == PPCREC_IML_TYPE_STORE || inst.type == PPCREC_IML_TYPE_LOAD_INDEXED || inst.type == PPCREC_IML_TYPE_STORE_INDEXED) { @@ -286,7 +282,7 @@ void IMLDebug_DumpSegment(ppcImlGenContext_t* ctx, IMLSegment* imlSegment, bool strOutput.add("JALW"); // jump always else cemu_assert_unimplemented(); - strOutput.addFmt(" jm_{:08x} (cr{})", inst.op_conditionalJump.jumpmarkAddress, inst.crRegister); + strOutput.addFmt(" (cr{})", inst.crRegister); } else if (inst.type == PPCREC_IML_TYPE_NO_OP) { diff --git a/src/Cafe/HW/Espresso/Recompiler/IML/IMLInstruction.cpp b/src/Cafe/HW/Espresso/Recompiler/IML/IMLInstruction.cpp index 449e01c5..cd5c1ade 100644 --- a/src/Cafe/HW/Espresso/Recompiler/IML/IMLInstruction.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/IML/IMLInstruction.cpp @@ -177,10 +177,6 @@ void IMLInstruction::CheckRegisterUsage(IMLUsedRegisters* registersUsed) const { // no effect on registers } - else if (type == PPCREC_IML_TYPE_PPC_ENTER) - { - // no op - } else if (type == PPCREC_IML_TYPE_FPR_R_NAME) { // fpr operation @@ -535,10 +531,6 @@ void IMLInstruction::ReplaceGPR(sint32 gprRegisterSearched[4], sint32 gprRegiste { // no effect on registers } - else if (type == PPCREC_IML_TYPE_PPC_ENTER) - { - // no op - } else if (type == PPCREC_IML_TYPE_FPR_R_NAME) { @@ -679,10 +671,6 @@ void IMLInstruction::ReplaceFPRs(sint32 fprRegisterSearched[4], sint32 fprRegist { // no effect on registers } - else if (type == PPCREC_IML_TYPE_PPC_ENTER) - { - // no op - } else if (type == PPCREC_IML_TYPE_FPR_R_NAME) { op_r_name.registerIndex = replaceRegisterMultiple(op_r_name.registerIndex, fprRegisterSearched, fprRegisterReplaced); @@ -797,10 +785,6 @@ void IMLInstruction::ReplaceFPR(sint32 fprRegisterSearched, sint32 fprRegisterRe { // no effect on registers } - else if (type == PPCREC_IML_TYPE_PPC_ENTER) - { - // no op - } else if (type == PPCREC_IML_TYPE_FPR_R_NAME) { op_r_name.registerIndex = replaceRegister(op_r_name.registerIndex, fprRegisterSearched, fprRegisterReplaced); diff --git a/src/Cafe/HW/Espresso/Recompiler/IML/IMLInstruction.h b/src/Cafe/HW/Espresso/Recompiler/IML/IMLInstruction.h index 32177e51..a883bf91 100644 --- a/src/Cafe/HW/Espresso/Recompiler/IML/IMLInstruction.h +++ b/src/Cafe/HW/Espresso/Recompiler/IML/IMLInstruction.h @@ -151,7 +151,6 @@ enum PPCREC_IML_TYPE_MACRO, PPCREC_IML_TYPE_CJUMP, // conditional jump PPCREC_IML_TYPE_CJUMP_CYCLE_CHECK, // jumps only if remaining thread cycles < 0 - PPCREC_IML_TYPE_PPC_ENTER, // used to mark locations that should be written to recompilerCallTable PPCREC_IML_TYPE_CR, // condition register specific operations (one or more operands) // conditional PPCREC_IML_TYPE_CONDITIONAL_R_S32, @@ -270,7 +269,6 @@ struct IMLInstruction uint8 crRegister; // set to 0xFF if not set, not all IML instruction types support cr. uint8 crMode; // only used when crRegister is valid, used to differentiate between various forms of condition flag set/clear behavior uint32 crIgnoreMask; // bit set for every respective CR bit that doesn't need to be updated - uint32 associatedPPCAddress; // ppc address that is associated with this instruction union { struct @@ -322,7 +320,6 @@ struct IMLInstruction }op_macro; struct { - uint32 jumpmarkAddress; bool jumpAccordingToSegment; //IMLSegment* destinationSegment; // if set, this replaces jumpmarkAddress uint8 condition; // only used when crRegisterIndex is 8 or above (update: Apparently only used to mark jumps without a condition? -> Cleanup) uint8 crRegisterIndex; @@ -402,7 +399,6 @@ struct IMLInstruction type == PPCREC_IML_TYPE_MACRO && operation == PPCREC_IML_MACRO_LEAVE || type == PPCREC_IML_TYPE_MACRO && operation == PPCREC_IML_MACRO_HLE || type == PPCREC_IML_TYPE_MACRO && operation == PPCREC_IML_MACRO_MFTB || - type == PPCREC_IML_TYPE_PPC_ENTER || type == PPCREC_IML_TYPE_CJUMP || type == PPCREC_IML_TYPE_CJUMP_CYCLE_CHECK) return true; @@ -430,14 +426,11 @@ struct IMLInstruction op_macro.paramU16 = paramU16; } - void make_ppcEnter(uint32 ppcAddress) + void make_cjump_cycle_check() { - cemu_assert_suspicious(); // removed - type = PPCREC_IML_TYPE_PPC_ENTER; + type = PPCREC_IML_TYPE_CJUMP_CYCLE_CHECK; operation = 0; - op_ppcEnter.ppcAddress = ppcAddress; - op_ppcEnter.x64Offset = 0; - associatedPPCAddress = 0; + crRegister = PPC_REC_INVALID_REGISTER; } void CheckRegisterUsage(IMLUsedRegisters* registersUsed) const; diff --git a/src/Cafe/HW/Espresso/Recompiler/IML/IMLOptimizer.cpp b/src/Cafe/HW/Espresso/Recompiler/IML/IMLOptimizer.cpp index cd0f07c0..3ded8c79 100644 --- a/src/Cafe/HW/Espresso/Recompiler/IML/IMLOptimizer.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/IML/IMLOptimizer.cpp @@ -123,7 +123,6 @@ bool PPCRecompiler_reduceNumberOfFPRRegisters(ppcImlGenContext_t* ppcImlGenConte { // convert to NO-OP instruction imlInstructionItr.type = PPCREC_IML_TYPE_NO_OP; - imlInstructionItr.associatedPPCAddress = 0; } } imlIndex++; diff --git a/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerImlGen.cpp b/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerImlGen.cpp index 6e927fc4..652a7b9e 100644 --- a/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerImlGen.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerImlGen.cpp @@ -157,19 +157,19 @@ void PPCRecompilerImlGen_generateNewInstruction_jump(ppcImlGenContext_t* ppcImlG { __debugbreak(); - // jump - if (imlInstruction == NULL) - imlInstruction = PPCRecompilerImlGen_generateNewEmptyInstruction(ppcImlGenContext); - else - memset(imlInstruction, 0, sizeof(IMLInstruction)); - imlInstruction->type = PPCREC_IML_TYPE_CJUMP; - imlInstruction->crRegister = PPC_REC_INVALID_REGISTER; - imlInstruction->op_conditionalJump.jumpmarkAddress = jumpmarkAddress; - imlInstruction->op_conditionalJump.jumpAccordingToSegment = false; - imlInstruction->op_conditionalJump.condition = PPCREC_JUMP_CONDITION_NONE; - imlInstruction->op_conditionalJump.crRegisterIndex = 0; - imlInstruction->op_conditionalJump.crBitIndex = 0; - imlInstruction->op_conditionalJump.bitMustBeSet = false; + //// jump + //if (imlInstruction == NULL) + // imlInstruction = PPCRecompilerImlGen_generateNewEmptyInstruction(ppcImlGenContext); + //else + // memset(imlInstruction, 0, sizeof(IMLInstruction)); + //imlInstruction->type = PPCREC_IML_TYPE_CJUMP; + //imlInstruction->crRegister = PPC_REC_INVALID_REGISTER; + //imlInstruction->op_conditionalJump.jumpmarkAddress = jumpmarkAddress; + //imlInstruction->op_conditionalJump.jumpAccordingToSegment = false; + //imlInstruction->op_conditionalJump.condition = PPCREC_JUMP_CONDITION_NONE; + //imlInstruction->op_conditionalJump.crRegisterIndex = 0; + //imlInstruction->op_conditionalJump.crBitIndex = 0; + //imlInstruction->op_conditionalJump.bitMustBeSet = false; } // jump based on segment branches @@ -178,10 +178,8 @@ void PPCRecompilerImlGen_generateNewInstruction_jumpSegment(ppcImlGenContext_t* // jump if (imlInstruction == NULL) imlInstruction = PPCRecompilerImlGen_generateNewEmptyInstruction(ppcImlGenContext); - imlInstruction->associatedPPCAddress = 0; imlInstruction->type = PPCREC_IML_TYPE_CJUMP; imlInstruction->crRegister = PPC_REC_INVALID_REGISTER; - imlInstruction->op_conditionalJump.jumpmarkAddress = 0; imlInstruction->op_conditionalJump.jumpAccordingToSegment = true; imlInstruction->op_conditionalJump.condition = PPCREC_JUMP_CONDITION_NONE; imlInstruction->op_conditionalJump.crRegisterIndex = 0; @@ -218,16 +216,16 @@ void PPCRecompilerImlGen_generateNewInstruction_conditionalJump(ppcImlGenContext { __debugbreak(); - // conditional jump - IMLInstruction* imlInstruction = PPCRecompilerImlGen_generateNewEmptyInstruction(ppcImlGenContext); - imlInstruction->type = PPCREC_IML_TYPE_CJUMP; - imlInstruction->crRegister = PPC_REC_INVALID_REGISTER; - imlInstruction->op_conditionalJump.jumpAccordingToSegment = false; - imlInstruction->op_conditionalJump.jumpmarkAddress = jumpmarkAddress; - imlInstruction->op_conditionalJump.condition = jumpCondition; - imlInstruction->op_conditionalJump.crRegisterIndex = crRegisterIndex; - imlInstruction->op_conditionalJump.crBitIndex = crBitIndex; - imlInstruction->op_conditionalJump.bitMustBeSet = bitMustBeSet; + //// conditional jump + //IMLInstruction* imlInstruction = PPCRecompilerImlGen_generateNewEmptyInstruction(ppcImlGenContext); + //imlInstruction->type = PPCREC_IML_TYPE_CJUMP; + //imlInstruction->crRegister = PPC_REC_INVALID_REGISTER; + //imlInstruction->op_conditionalJump.jumpAccordingToSegment = false; + //imlInstruction->op_conditionalJump.jumpmarkAddress = jumpmarkAddress; + //imlInstruction->op_conditionalJump.condition = jumpCondition; + //imlInstruction->op_conditionalJump.crRegisterIndex = crRegisterIndex; + //imlInstruction->op_conditionalJump.crBitIndex = crBitIndex; + //imlInstruction->op_conditionalJump.bitMustBeSet = bitMustBeSet; } void PPCRecompilerImlGen_generateNewInstruction_conditionalJumpSegment(ppcImlGenContext_t* ppcImlGenContext, uint32 jumpCondition, uint32 crRegisterIndex, uint32 crBitIndex, bool bitMustBeSet) @@ -4073,26 +4071,12 @@ void PPCRecompiler_HandleCycleCheckCount(ppcImlGenContext_t& ppcImlGenContext, P // exclude non-infinite tight loops if (IMLAnalyzer_IsTightFiniteLoop(imlSegment)) return; - // potential loop segment found, split this segment into four: - // P0: This segment checks if the remaining cycles counter is still above zero. If yes, it jumps to segment P2 (it's also the jump destination for other segments) - // P1: This segment contains the ppc_leave instruction - // P2: This segment contains the iml instructions of the original segment - // PEntry: This segment is used to enter the function, it jumps to P0 - // All segments are considered to be part of the same PPC instruction range - // The first segment also retains the jump destination and enterable properties from the original segment. - //debug_printf("--- Insert cycle counter check ---\n"); - // make the segment enterable so execution can return after checking + // make the segment enterable so execution can return after passing a check basicBlockInfo.GetFirstSegmentInChain()->SetEnterable(basicBlockInfo.startAddress); IMLSegment* splitSeg = PPCIMLGen_CreateSplitSegmentAtEnd(ppcImlGenContext, basicBlockInfo); - - IMLInstruction* inst = splitSeg->AppendInstruction(); - inst->type = PPCREC_IML_TYPE_CJUMP_CYCLE_CHECK; - inst->operation = 0; - inst->crRegister = PPC_REC_INVALID_REGISTER; - inst->op_conditionalJump.jumpmarkAddress = 0xFFFFFFFF; - inst->associatedPPCAddress = 0xFFFFFFFF; + splitSeg->AppendInstruction()->make_cjump_cycle_check(); IMLSegment* exitSegment = ppcImlGenContext.NewSegment(); splitSeg->SetLinkBranchTaken(exitSegment);