diff --git a/Source/Project64-core/MemoryExceptionFilter.cpp b/Source/Project64-core/MemoryExceptionFilter.cpp index ee6df39b6..aed7ff0eb 100644 --- a/Source/Project64-core/MemoryExceptionFilter.cpp +++ b/Source/Project64-core/MemoryExceptionFilter.cpp @@ -366,7 +366,6 @@ void CMipsMemoryVM::DumpArmExceptionInfo(uint32_t MemAddress, mcontext_t & conte { WriteTrace(TraceExceptionHandler, TraceError, "GPR[%s] 0x%08X%08X", CRegName::GPR[count], g_Reg->m_GPR[count].W[1], g_Reg->m_GPR[count].W[0]); } - Flush_Recompiler_Log(); TraceFlushLog(); } diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp index 905c317ea..21befdeea 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp @@ -2,32 +2,37 @@ #if defined(__arm__) || defined(_M_ARM) #include -#include +#include #include #include #include +#include -CArmRegInfo CArmOps::m_RegWorkingSet; -bool CArmOps::m_InItBlock = false; -int CArmOps::m_ItBlockInstruction = 0; -CArmOps::ArmCompareType CArmOps::m_ItBlockCompareType; -CArmOps::ArmItMask CArmOps::m_ItBlockMask; -CArmOps::ArmReg CArmOps::m_LastStoreReg; -uint16_t CArmOps::m_PopRegisters = 0; -uint16_t CArmOps::m_PushRegisters = 0; +CArmOps::CArmOps(CCodeBlock & CodeBlock, CArmRegInfo & RegWorkingSet) : + m_CodeBlock(CodeBlock), + m_RegWorkingSet(RegWorkingSet), + m_InItBlock(false), + m_ItBlockInstruction(0), + m_ItBlockCompareType(ArmBranch_Equal), + m_ItBlockMask(ItMask_None), + m_LastStoreReg(CArmOps::Arm_Unknown), + m_PopRegisters(0), + m_PushRegisters(0) +{ +} // Logging functions void CArmOps::WriteArmComment(const char * Comment) { - CPU_Message(""); - CPU_Message(" // %s", Comment); + CodeLog(""); + CodeLog(" // %s", Comment); } void CArmOps::WriteArmLabel(const char * Label) { - CPU_Message(""); - CPU_Message(" %s:", Label); + CodeLog(""); + CodeLog(" %s:", Label); } void CArmOps::AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2) @@ -36,7 +41,7 @@ void CArmOps::AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source if (DestReg <= 7 && SourceReg1 <= 7 && SourceReg2 <= 7) { - CPU_Message(" add\t%s,%s,%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); + CodeLog(" add\t%s,%s,%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); ArmThumbOpcode op = { 0 }; op.Reg.rt = DestReg; op.Reg.rn = SourceReg1; @@ -46,7 +51,7 @@ void CArmOps::AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source } else { - CPU_Message(" add.w\t%s,%s,%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); + CodeLog(" add.w\t%s,%s,%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); Arm32Opcode op = { 0 }; op.imm5.rn = SourceReg1; op.imm5.s = 0; @@ -75,7 +80,7 @@ void CArmOps::AndConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) if (CanThumbCompressConst(Const)) { - CPU_Message(" and\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); + CodeLog(" and\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); uint16_t CompressedConst = ThumbCompressConst(Const); Arm32Opcode op = { 0 }; op.imm8_3_1.rn = SourceReg; @@ -129,7 +134,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) } else if ((Const & 0xFFFFFFF8) == 0 && DestReg <= 7 && SourceReg <= 7) { - CPU_Message(" adds\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); + CodeLog(" adds\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); ArmThumbOpcode op = { 0 }; op.Imm3.rd = DestReg; op.Imm3.rn = SourceReg; @@ -139,7 +144,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) } else if ((Const & 0xFFFFFF00) == 0 && DestReg <= 7 && DestReg == SourceReg) { - CPU_Message(" adds\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); + CodeLog(" adds\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); ArmThumbOpcode op = { 0 }; op.Imm8.imm8 = Const; op.Imm8.rdn = DestReg; @@ -148,7 +153,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) } else if ((Const & 0xFFFFFF80) == 0xFFFFFF80 && DestReg <= 7 && DestReg == SourceReg) { - CPU_Message(" sub\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (~Const) + 1); + CodeLog(" sub\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (~Const) + 1); ArmThumbOpcode op = { 0 }; op.Imm8.imm8 = ((~Const) + 1) & 0xFF; op.Imm8.rdn = DestReg; @@ -157,7 +162,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) } else if (CanThumbCompressConst(Const)) { - CPU_Message(" add.w\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); + CodeLog(" add.w\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); uint16_t CompressedConst = ThumbCompressConst(Const); Arm32Opcode op = { 0 }; op.imm8_3_1.rn = SourceReg; @@ -181,7 +186,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) } else { - CPU_Message("%s: DestReg = %X Const = %X", __FUNCTION__, DestReg, Const); + CodeLog("%s: DestReg = %X Const = %X", __FUNCTION__, DestReg, Const); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -192,7 +197,7 @@ void CArmOps::AndArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source if (DestReg <= 0x7 && SourceReg2 <= 0x7 && SourceReg1 == DestReg) { - CPU_Message(" ands\t%s, %s", ArmRegName(DestReg), ArmRegName(SourceReg2)); + CodeLog(" ands\t%s, %s", ArmRegName(DestReg), ArmRegName(SourceReg2)); ArmThumbOpcode op = { 0 }; op.Reg2.rn = DestReg; op.Reg2.rm = SourceReg2; @@ -201,7 +206,7 @@ void CArmOps::AndArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source } else { - CPU_Message(" and.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); + CodeLog(" and.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); Arm32Opcode op = { 0 }; op.imm5.rn = SourceReg1; op.imm5.s = 0; @@ -223,7 +228,7 @@ void CArmOps::ArmBreakPoint(const char * FileName, uint32_t LineNumber) m_RegWorkingSet.BeforeCallDirect(); MoveConstToArmReg(Arm_R1, LineNumber); MoveConstToArmReg(Arm_R0, (uint32_t)FileName, FileName); - CallFunction(AddressOf(&BreakPointNotification), "BreakPointNotification"); + CallFunction(AddressOf(&CArmOps::BreakPointNotification), "BreakPointNotification"); m_RegWorkingSet.AfterCallDirect(); } @@ -231,7 +236,7 @@ void CArmOps::ArmNop(void) { PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); - CPU_Message(" nop"); + CodeLog(" nop"); AddCode16(0xbf00); } @@ -239,7 +244,7 @@ void CArmOps::BranchLabel8(ArmCompareType CompareType, const char * Label) { PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); - CPU_Message(" b%s\t%s", ArmCompareSuffix(CompareType), Label); + CodeLog(" b%s\t%s", ArmCompareSuffix(CompareType), Label); ArmThumbOpcode op = { 0 }; if (CompareType == ArmBranch_Always) { @@ -259,7 +264,7 @@ void CArmOps::BranchLabel20(ArmCompareType CompareType, const char * Label) { PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); - CPU_Message(" b%s\t%s", ArmCompareSuffix(CompareType), Label); + CodeLog(" b%s\t%s", ArmCompareSuffix(CompareType), Label); Arm32Opcode op = { 0 }; op.Branch20.imm6 = 0; op.Branch20.cond = CompareType == ArmBranch_Always ? 0 : CompareType; @@ -284,7 +289,7 @@ void CArmOps::CallFunction(void * Function, const char * FunctionName) op.Branch.reserved = 0; op.Branch.rm = reg; op.Branch.opcode = 0x8F; - CPU_Message(" blx\t%s", ArmRegName(reg)); + CodeLog(" blx\t%s", ArmRegName(reg)); AddCode16(op.Hex); } @@ -317,7 +322,7 @@ void CArmOps::MoveConstToArmReg(ArmReg Reg, uint16_t value, const char * comment PreOpCheck(Arm_Unknown, true, __FILE__, __LINE__); if ((value & 0xFF00) == 0 && Reg <= 7) { - CPU_Message(" mov%s\t%s, #0x%X\t; %s", m_InItBlock ? ArmCurrentItCondition() : "s", ArmRegName(Reg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); + CodeLog(" mov%s\t%s, #0x%X\t; %s", m_InItBlock ? ArmCurrentItCondition() : "s", ArmRegName(Reg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); ArmThumbOpcode op = { 0 }; op.Imm8.imm8 = value; op.Imm8.rdn = Reg; @@ -326,7 +331,7 @@ void CArmOps::MoveConstToArmReg(ArmReg Reg, uint16_t value, const char * comment } else if (CanThumbCompressConst(value)) { - CPU_Message(" mov%s.w\t%s, #0x%X\t; %s", m_InItBlock ? ArmCurrentItCondition() : "", ArmRegName(Reg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); + CodeLog(" mov%s.w\t%s, #0x%X\t; %s", m_InItBlock ? ArmCurrentItCondition() : "", ArmRegName(Reg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); uint16_t CompressedValue = ThumbCompressConst(value); Arm32Opcode op = { 0 }; op.imm8_3_1.rn = 0xF; @@ -343,7 +348,7 @@ void CArmOps::MoveConstToArmReg(ArmReg Reg, uint16_t value, const char * comment } else { - CPU_Message(" movw%s\t%s, #0x%X\t; %s", m_InItBlock ? ArmCurrentItCondition() : "", ArmRegName(Reg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); + CodeLog(" movw%s\t%s, #0x%X\t; %s", m_InItBlock ? ArmCurrentItCondition() : "", ArmRegName(Reg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); Arm32Opcode op = { 0 }; op.imm16.opcode = ArmMOV_IMM16; @@ -367,7 +372,7 @@ void CArmOps::MoveConstToArmRegTop(ArmReg DestReg, uint16_t Const, const char * { PreOpCheck(DestReg, false, __FILE__, __LINE__); - CPU_Message(" movt\t%s, %s", ArmRegName(DestReg), comment != nullptr ? stdstr_f("#0x%X\t; %s", (uint32_t)Const, comment).c_str() : stdstr_f("#%d\t; 0x%X", (uint32_t)Const, (uint32_t)Const).c_str()); + CodeLog(" movt\t%s, %s", ArmRegName(DestReg), comment != nullptr ? stdstr_f("#0x%X\t; %s", (uint32_t)Const, comment).c_str() : stdstr_f("#%d\t; 0x%X", (uint32_t)Const, (uint32_t)Const).c_str()); Arm32Opcode op = { 0 }; op.imm16.opcode = ArmMOV_IMM16; @@ -391,7 +396,7 @@ void CArmOps::CompareArmRegToConst(ArmReg Reg, uint32_t value) if (Reg <= 0x7 && (value & 0xFFFFFF00) == 0) { - CPU_Message(" cmp\t%s, #%d\t; 0x%X", ArmRegName(Reg), value, value); + CodeLog(" cmp\t%s, #%d\t; 0x%X", ArmRegName(Reg), value, value); ArmThumbOpcode op = { 0 }; op.Imm8.imm8 = value; op.Imm8.rdn = Reg; @@ -400,7 +405,7 @@ void CArmOps::CompareArmRegToConst(ArmReg Reg, uint32_t value) } else if (CanThumbCompressConst(value)) { - CPU_Message(" cmp\t%s, #%d\t; 0x%X", ArmRegName(Reg), value, value); + CodeLog(" cmp\t%s, #%d\t; 0x%X", ArmRegName(Reg), value, value); uint16_t CompressedValue = ThumbCompressConst(value); Arm32Opcode op = { 0 }; op.imm8_3_1.rn = Reg; @@ -430,7 +435,7 @@ void CArmOps::CompareArmRegToArmReg(ArmReg Reg1, ArmReg Reg2) if (Reg1 <= 0x7 && Reg2 <= 0x7) { - CPU_Message(" cmp\t%s, %s", ArmRegName(Reg1), ArmRegName(Reg2)); + CodeLog(" cmp\t%s, %s", ArmRegName(Reg1), ArmRegName(Reg2)); ArmThumbOpcode op = { 0 }; op.Reg2.rn = Reg1; op.Reg2.rm = Reg2; @@ -439,7 +444,7 @@ void CArmOps::CompareArmRegToArmReg(ArmReg Reg1, ArmReg Reg2) } else { - CPU_Message(" cmp.w\t%s, %s", ArmRegName(Reg1), ArmRegName(Reg2)); + CodeLog(" cmp.w\t%s, %s", ArmRegName(Reg1), ArmRegName(Reg2)); Arm32Opcode op = { 0 }; op.imm5.rn = Reg1; op.imm5.s = 1; @@ -460,7 +465,7 @@ void CArmOps::IfBlock(ArmItMask mask, ArmCompareType CompareType) { PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); - CPU_Message(" it%s\t%s", ArmItMaskName(mask), ArmCompareSuffix(CompareType)); + CodeLog(" it%s\t%s", ArmItMaskName(mask), ArmCompareSuffix(CompareType)); m_InItBlock = true; m_ItBlockInstruction = 0; m_ItBlockCompareType = CompareType; @@ -490,11 +495,11 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, u { if ((offset & (~0xFFF)) != 0) { - CPU_Message(" RegPointer: %d Reg: %d Offset: 0x%X", RegPointer, DestReg, offset); + CodeLog(" RegPointer: %d Reg: %d Offset: 0x%X", RegPointer, DestReg, offset); g_Notify->BreakPoint(__FILE__, __LINE__); return; } - CPU_Message(" ldrb.w\t%s, [%s, #%d]", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)offset); + CodeLog(" ldrb.w\t%s, [%s, #%d]", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)offset); Arm32Opcode op = { 0 }; op.imm12.rt = DestReg; op.imm12.rn = RegPointer; @@ -504,7 +509,7 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, u } else { - CPU_Message(" ldrb\t%s, [%s%s%s]", ArmRegName(DestReg), ArmRegName(RegPointer), offset == 0 ? "" : ",", offset == 0 ? "" : stdstr_f("#%d", offset).c_str()); + CodeLog(" ldrb\t%s, [%s%s%s]", ArmRegName(DestReg), ArmRegName(RegPointer), offset == 0 ? "" : ",", offset == 0 ? "" : stdstr_f("#%d", offset).c_str()); ArmThumbOpcode op = { 0 }; op.Imm5.rt = DestReg; op.Imm5.rn = RegPointer; @@ -520,7 +525,7 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, A if ((DestReg > 0x7 || RegPointer > 0x7 || RegPointer2 > 0x7) && (shift & ~3) == 0) { - CPU_Message(" ldrb\t%s, [%s,%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); + CodeLog(" ldrb\t%s, [%s,%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); Arm32Opcode op = { 0 }; op.uint16.rn = RegPointer; op.uint16.opcode = 0xF81; @@ -532,7 +537,7 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, A } else if (shift == 0 && DestReg <= 0x7 && RegPointer <= 0x7 && RegPointer2 <= 0x7) { - CPU_Message(" ldrb\t%s, [%s,%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); + CodeLog(" ldrb\t%s, [%s,%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); ArmThumbOpcode op = { 0 }; op.Reg.rm = RegPointer2; op.Reg.rt = DestReg; @@ -554,11 +559,11 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, uint8 { if ((Offset & (~0xFFF)) != 0) { - CPU_Message(" RegPointer: %d Reg: %d Offset: 0x%X", RegPointer, DestReg, Offset); + CodeLog(" RegPointer: %d Reg: %d Offset: 0x%X", RegPointer, DestReg, Offset); g_Notify->BreakPoint(__FILE__, __LINE__); return; } - CPU_Message(" ldr.w\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); + CodeLog(" ldr.w\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); Arm32Opcode op = { 0 }; op.imm12.rt = DestReg; op.imm12.rn = RegPointer; @@ -568,7 +573,7 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, uint8 } else { - CPU_Message(" ldr\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); + CodeLog(" ldr\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); ArmThumbOpcode op = { 0 }; op.Imm5.rt = DestReg; op.Imm5.rn = RegPointer; @@ -590,7 +595,7 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmRe if (shift == 0 && DestReg <= 0x7 && RegPointer <= 0x7 && RegPointer2 <= 0x7) { - CPU_Message(" ldr\t%s, [%s,%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); + CodeLog(" ldr\t%s, [%s,%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); ArmThumbOpcode op = { 0 }; op.Reg.rm = RegPointer2; op.Reg.rt = DestReg; @@ -600,7 +605,7 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmRe } else { - CPU_Message(" ldr.w\t%s, [%s, %s, lsl #%d]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2), shift); + CodeLog(" ldr.w\t%s, [%s, %s, lsl #%d]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2), shift); Arm32Opcode op = { 0 }; op.imm2.rm = RegPointer2; op.imm2.imm = shift; @@ -618,11 +623,11 @@ void CArmOps::LoadArmRegPointerToFloatReg(ArmReg RegPointer, ArmFpuSingle Reg, u if (Offset != 0) { - CPU_Message(" vldr\t%s, [%s, #%d]", ArmFpuSingleName(Reg), ArmRegName(RegPointer), (uint32_t)Offset); + CodeLog(" vldr\t%s, [%s, #%d]", ArmFpuSingleName(Reg), ArmRegName(RegPointer), (uint32_t)Offset); } else { - CPU_Message(" vldr\t%s, [%s]", ArmFpuSingleName(Reg), ArmRegName(RegPointer)); + CodeLog(" vldr\t%s, [%s]", ArmFpuSingleName(Reg), ArmRegName(RegPointer)); } Arm32Opcode op = { 0 }; op.RnVdImm8.Rn = RegPointer; @@ -648,7 +653,7 @@ void CArmOps::LoadFloatingPointControlReg(ArmReg DestReg) { PreOpCheck(DestReg, false, __FILE__, __LINE__); - CPU_Message(" vmrs\t%s, fpscr", ArmRegName(DestReg)); + CodeLog(" vmrs\t%s, fpscr", ArmRegName(DestReg)); Arm32Opcode op = { 0 }; op.fpscr.opcode2 = 0xA10; op.fpscr.rt = DestReg; @@ -662,7 +667,7 @@ void CArmOps::MoveConstToArmReg(ArmReg DestReg, uint32_t value, const char * com { PreOpCheck(DestReg, false, __FILE__, __LINE__); - CPU_Message(" mov.w\t%s, #0x%X\t; %s", ArmRegName(DestReg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); + CodeLog(" mov.w\t%s, #0x%X\t; %s", ArmRegName(DestReg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); uint16_t CompressedValue = ThumbCompressConst(value); Arm32Opcode op = { 0 }; op.imm8_3_1.rn = 0xF; @@ -734,7 +739,7 @@ void CArmOps::OrArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceR g_Notify->BreakPoint(__FILE__, __LINE__); return; } - CPU_Message(" orr.w\t%s, %s, %s%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2), shift ? stdstr_f(", lsl #%d", shift).c_str() : ""); + CodeLog(" orr.w\t%s, %s, %s%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2), shift ? stdstr_f(", lsl #%d", shift).c_str() : ""); Arm32Opcode op = { 0 }; op.imm5.rn = SourceReg1; op.imm5.s = 0; @@ -762,7 +767,7 @@ void CArmOps::OrConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t value) else if (CanThumbCompressConst(value)) { uint16_t CompressedValue = ThumbCompressConst(value); - CPU_Message(" orr\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), value); + CodeLog(" orr\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), value); Arm32Opcode op = { 0 }; op.imm8_3_1.rn = SourceReg; op.imm8_3_1.s = 0; @@ -810,7 +815,7 @@ void CArmOps::MulF32(ArmFpuSingle DestReg, ArmFpuSingle SourceReg1, ArmFpuSingle { PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); - CPU_Message(" vmul.f32\t%s, %s, %s", ArmFpuSingleName(DestReg), ArmFpuSingleName(SourceReg1), ArmFpuSingleName(SourceReg2)); + CodeLog(" vmul.f32\t%s, %s, %s", ArmFpuSingleName(DestReg), ArmFpuSingleName(SourceReg1), ArmFpuSingleName(SourceReg2)); Arm32Opcode op = { 0 }; op.VnVmVd.vn = SourceReg1 >> 1; op.VnVmVd.op1 = 0x2; @@ -835,7 +840,7 @@ void CArmOps::PushArmReg(uint16_t Registers) { if (Registers == m_PopRegisters) { - CPU_Message("%s: Ignoring push/pop", __FUNCTION__); + CodeLog("%s: Ignoring push/pop", __FUNCTION__); m_PopRegisters = 0; PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); return; @@ -872,7 +877,7 @@ void CArmOps::PushArmReg(uint16_t Registers) (Registers & ArmPushPop_R11) != 0 || (Registers & ArmPushPop_R12) != 0) { - CPU_Message("%X: push\t{%s}", (int32_t)*g_RecompPos, pushed.c_str()); + CodeLog("%X: push\t{%s}", (int32_t)*g_RecompPos, pushed.c_str()); Arm32Opcode op = { 0 }; op.PushPop.register_list = Registers; @@ -881,7 +886,7 @@ void CArmOps::PushArmReg(uint16_t Registers) } else { - CPU_Message(" push\t%s", pushed.c_str()); + CodeLog(" push\t%s", pushed.c_str()); bool lr = (Registers & ArmPushPop_LR) != 0; Registers &= Registers & ~ArmPushPop_LR; @@ -905,12 +910,12 @@ void CArmOps::PopArmReg(uint16_t Registers) } if (m_PushRegisters == 0 && (Registers & ArmPushPop_PC) == 0) { - CPU_Message("%s: Setting m_PushRegisters: %X Registers: %X", __FUNCTION__, m_PushRegisters, Registers); + CodeLog("%s: Setting m_PushRegisters: %X Registers: %X", __FUNCTION__, m_PushRegisters, Registers); g_Notify->BreakPoint(__FILE__, __LINE__); } if (m_PushRegisters != Registers && (Registers & ArmPushPop_PC) == 0) { - CPU_Message("%s: Setting m_PushRegisters: %X Registers: %X", __FUNCTION__, m_PushRegisters, Registers); + CodeLog("%s: Setting m_PushRegisters: %X Registers: %X", __FUNCTION__, m_PushRegisters, Registers); g_Notify->BreakPoint(__FILE__, __LINE__); } if ((Registers & ArmPushPop_SP) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -942,7 +947,7 @@ void CArmOps::FlushPopArmReg(void) (m_PopRegisters & ArmPushPop_R11) != 0 || (m_PopRegisters & ArmPushPop_R12) != 0) { - CPU_Message("%X pop\t{%s}", (int32_t)*g_RecompPos, pushed.c_str()); + CodeLog("%X pop\t{%s}", (int32_t)*g_RecompPos, pushed.c_str()); Arm32Opcode op = { 0 }; op.PushPop.register_list = m_PopRegisters; @@ -951,7 +956,7 @@ void CArmOps::FlushPopArmReg(void) } else { - CPU_Message(" pop\t%s", pushed.c_str()); + CodeLog(" pop\t%s", pushed.c_str()); bool pc = (m_PopRegisters & ArmPushPop_PC) != 0; m_PopRegisters &= ~ArmPushPop_PC; @@ -1021,7 +1026,7 @@ void CArmOps::ShiftRightSignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shi } else if (DestReg > 0x7 || SourceReg > 0x7) { - CPU_Message(" asrs.w\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); + CodeLog(" asrs.w\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); Arm32Opcode op = { 0 }; op.imm5.rn = 0xF; op.imm5.s = 0; @@ -1037,7 +1042,7 @@ void CArmOps::ShiftRightSignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shi } else { - CPU_Message(" asrs\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); + CodeLog(" asrs\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); ArmThumbOpcode op = { 0 }; op.Imm5.rt = DestReg; @@ -1058,7 +1063,7 @@ void CArmOps::ShiftRightUnsignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t s } if (DestReg > 0x7 || SourceReg > 0x7) { - CPU_Message(" lsrs.w\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); + CodeLog(" lsrs.w\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); Arm32Opcode op = { 0 }; op.imm5.rn = 0xF; op.imm5.s = 0; @@ -1074,7 +1079,7 @@ void CArmOps::ShiftRightUnsignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t s } else { - CPU_Message(" lsrs\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); + CodeLog(" lsrs\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); ArmThumbOpcode op = { 0 }; op.Imm5.rt = DestReg; @@ -1094,7 +1099,7 @@ void CArmOps::ShiftLeftImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift) g_Notify->BreakPoint(__FILE__, __LINE__); return; } - CPU_Message(" lsls\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); + CodeLog(" lsls\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); ArmThumbOpcode op = { 0 }; op.Imm5.rt = DestReg; @@ -1108,7 +1113,7 @@ void CArmOps::SignExtendByte(ArmReg Reg) { if (Reg > 0x7) { - CPU_Message(" sxtb.w\t%s, %s", ArmRegName(Reg), ArmRegName(Reg)); + CodeLog(" sxtb.w\t%s, %s", ArmRegName(Reg), ArmRegName(Reg)); Arm32Opcode op = { 0 }; op.rotate.opcode = 0xFA4F; op.rotate.rm = Reg; @@ -1120,7 +1125,7 @@ void CArmOps::SignExtendByte(ArmReg Reg) } else { - CPU_Message(" sxtb\t%s, %s", ArmRegName(Reg), ArmRegName(Reg)); + CodeLog(" sxtb\t%s, %s", ArmRegName(Reg), ArmRegName(Reg)); ArmThumbOpcode op = { 0 }; op.Reg2.rn = Reg; op.Reg2.rm = Reg; @@ -1137,7 +1142,7 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, uint { if ((Offset & (~0xFFF)) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); return; } - CPU_Message(" str\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); + CodeLog(" str\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); Arm32Opcode op = { 0 }; op.imm12.rt = DestReg; op.imm12.rn = RegPointer; @@ -1147,7 +1152,7 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, uint } else { - CPU_Message(" str\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); + CodeLog(" str\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); ArmThumbOpcode op = { 0 }; op.Imm5.rt = DestReg; op.Imm5.rn = RegPointer; @@ -1164,7 +1169,7 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, ArmR if (DestReg > 0x7 || RegPointer > 0x7 || RegPointer2 > 0x7 || shift != 0) { - CPU_Message(" str.w\t%s, [%s, %s%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2), shift != 0 ? stdstr_f(", lsl #%d", shift).c_str() : ""); + CodeLog(" str.w\t%s, [%s, %s%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2), shift != 0 ? stdstr_f(", lsl #%d", shift).c_str() : ""); Arm32Opcode op = { 0 }; op.imm2.rm = RegPointer2; op.imm2.imm = shift; @@ -1176,7 +1181,7 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, ArmR } else { - CPU_Message(" str\t%s, [%s, %s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); + CodeLog(" str\t%s, [%s, %s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); ArmThumbOpcode op = { 0 }; op.Reg.rt = DestReg; op.Reg.rn = RegPointer; @@ -1190,7 +1195,7 @@ void CArmOps::StoreFloatingPointControlReg(ArmReg SourceReg) { PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); - CPU_Message(" vmsr\tfpscr, %s", ArmRegName(SourceReg)); + CodeLog(" vmsr\tfpscr, %s", ArmRegName(SourceReg)); Arm32Opcode op = { 0 }; op.fpscr.opcode2 = 0xA10; op.fpscr.rt = SourceReg; @@ -1204,11 +1209,11 @@ void CArmOps::StoreFloatRegToArmRegPointer(ArmFpuSingle Reg, ArmReg RegPointer, if (Offset != 0) { - CPU_Message(" vstr\t%s, [%s, #%d]", ArmFpuSingleName(Reg), ArmRegName(RegPointer), (uint32_t)Offset); + CodeLog(" vstr\t%s, [%s, #%d]", ArmFpuSingleName(Reg), ArmRegName(RegPointer), (uint32_t)Offset); } else { - CPU_Message(" vstr\t%s, [%s]", ArmFpuSingleName(Reg), ArmRegName(RegPointer)); + CodeLog(" vstr\t%s, [%s]", ArmFpuSingleName(Reg), ArmRegName(RegPointer)); } Arm32Opcode op = { 0 }; op.RnVdImm8.Rn = RegPointer; @@ -1229,7 +1234,7 @@ void CArmOps::SubArmRegFromArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Sour if (DestReg <= 7 && SourceReg1 <= 7 && SourceReg2 <= 7) { - CPU_Message(" subs\t%s,%s,%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); + CodeLog(" subs\t%s,%s,%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); ArmThumbOpcode op = { 0 }; op.Reg.rt = DestReg; op.Reg.rn = SourceReg1; @@ -1239,7 +1244,7 @@ void CArmOps::SubArmRegFromArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Sour } else { - CPU_Message(" sub.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); + CodeLog(" sub.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); Arm32Opcode op = { 0 }; op.imm5.rn = SourceReg1; op.imm5.s = 0; @@ -1261,7 +1266,7 @@ void CArmOps::SubConstFromArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Cons if (DestReg <= 7 && DestReg == SourceReg && (Const & (~0xFF)) == 0) { - CPU_Message(" subs\t%s, #0x%X", ArmRegName(DestReg), Const); + CodeLog(" subs\t%s, #0x%X", ArmRegName(DestReg), Const); ArmThumbOpcode op = { 0 }; op.Imm8.imm8 = (uint8_t)Const; op.Imm8.rdn = DestReg; @@ -1270,7 +1275,7 @@ void CArmOps::SubConstFromArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Cons } else if ((Const & (~0x7FF)) == 0) { - CPU_Message(" sub.w\t%s, %s, #0x%X", ArmRegName(DestReg), ArmRegName(SourceReg), Const); + CodeLog(" sub.w\t%s, %s, #0x%X", ArmRegName(DestReg), ArmRegName(SourceReg), Const); Arm32Opcode op = { 0 }; op.RnRdImm12.Rn = SourceReg; op.RnRdImm12.s = 0; @@ -1334,7 +1339,7 @@ void CArmOps::XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg) if (SourceReg <= 7 && DestReg <= 7) { - CPU_Message(" eors\t%s, %s", ArmRegName(DestReg), ArmRegName(SourceReg)); + CodeLog(" eors\t%s, %s", ArmRegName(DestReg), ArmRegName(SourceReg)); ArmThumbOpcode op = { 0 }; op.Reg2.rn = DestReg; op.Reg2.rm = SourceReg; @@ -1351,7 +1356,7 @@ void CArmOps::XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source { PreOpCheck(DestReg, false, __FILE__, __LINE__); - CPU_Message(" eor.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); + CodeLog(" eor.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); Arm32Opcode op = { 0 }; op.imm5.rn = SourceReg1; op.imm5.s = 0; @@ -1377,7 +1382,7 @@ void CArmOps::XorConstToArmReg(ArmReg DestReg, uint32_t value) else if (CanThumbCompressConst(value)) { uint16_t CompressedValue = ThumbCompressConst(value); - CPU_Message(" eor\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(DestReg), value); + CodeLog(" eor\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(DestReg), value); Arm32Opcode op = { 0 }; op.imm8_3_1.rn = DestReg; op.imm8_3_1.s = 0; @@ -1465,8 +1470,8 @@ uint16_t CArmOps::ThumbCompressConst(uint32_t value) return (uint16_t)(0x300 | (value & 0xFF)); } - CPU_Message("%s: value >> 24 = %X value >> 16 = %X value >> 8 = %X value = %X", __FUNCTION__, (value >> 24), (value >> 16), (value >> 8), value); - CPU_Message("%s: value = %X", __FUNCTION__, value); + CodeLog("%s: value >> 24 = %X value >> 16 = %X value >> 8 = %X value = %X", __FUNCTION__, (value >> 24), (value >> 16), (value >> 8), value); + CodeLog("%s: value = %X", __FUNCTION__, value); g_Notify->BreakPoint(__FILE__, __LINE__); return false; } @@ -1497,8 +1502,8 @@ void CArmOps::SetJump8(uint8_t * Loc, uint8_t * JumpLoc) { g_Notify->BreakPoint(__FILE__, __LINE__); } - CPU_Message("%s: pc: %X target: %X Loc: %X JumpLoc: %X immediate: %X", __FUNCTION__, pc, target, (uint32_t)Loc, (uint32_t)JumpLoc, immediate); - CPU_Message("%s: writing %d to %X", __FUNCTION__, immediate, Loc); + CodeLog("%s: pc: %X target: %X Loc: %X JumpLoc: %X immediate: %X", __FUNCTION__, pc, target, (uint32_t)Loc, (uint32_t)JumpLoc, immediate); + CodeLog("%s: writing %d to %X", __FUNCTION__, immediate, Loc); if (op->BranchImm.opcode == 0x1C) { op->BranchImm.imm = immediate; @@ -1526,7 +1531,7 @@ void CArmOps::SetJump20(uint32_t * Loc, uint32_t * JumpLoc) int32_t immediate_check = immediate & ~0xFFFFF; if (immediate_check != 0 && immediate_check != ~0xFFFFF) { - CPU_Message("%s: target %X pc %X immediate: %X", __FUNCTION__, target, pc, immediate); + CodeLog("%s: target %X pc %X immediate: %X", __FUNCTION__, target, pc, immediate); g_Notify->BreakPoint(__FILE__, __LINE__); } Arm32Opcode op = { 0 }; @@ -1558,7 +1563,7 @@ void CArmOps::SetJump20(uint32_t * Loc, uint32_t * JumpLoc) uint32_t OriginalValue = *Loc; *Loc = op.Hex; - CPU_Message("%s: OriginalValue %X New Value %X JumpLoc: %X Loc: %X immediate: %X immediate_check = %X", __FUNCTION__, OriginalValue, *Loc, JumpLoc, Loc, immediate, immediate_check); + CodeLog("%s: OriginalValue %X New Value %X JumpLoc: %X Loc: %X immediate: %X immediate_check = %X", __FUNCTION__, OriginalValue, *Loc, JumpLoc, Loc, immediate, immediate_check); } void * CArmOps::GetAddressOf(int value, ...) diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h index 6dbc0a550..61eba27d0 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h @@ -1,7 +1,13 @@ #pragma once #if defined(__arm__) || defined(_M_ARM) + +#if !defined(_MSC_VER) && !defined(_Printf_format_string_) +#define _Printf_format_string_ +#endif + #include +class CCodeBlock; class CArmRegInfo; class CArmOps : @@ -143,102 +149,106 @@ public: ItMask_EEE, }; -protected: + CArmOps(CCodeBlock & CodeBlock, CArmRegInfo & RegWorkingSet); + // Logging functions - static void WriteArmComment(const char * Comment); - static void WriteArmLabel(const char * Label); + void WriteArmComment(const char * Comment); + void WriteArmLabel(const char * Label); - static void AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); - static void AddConstToArmReg(ArmReg DestReg, uint32_t Const); - static void AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const); - static void AndConstToVariable(void *Variable, const char * VariableName, uint32_t Const); - static void AndConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const); - static void AndArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); - static void ArmBreakPoint(const char * FileName, uint32_t LineNumber); - static void ArmNop(void); - static void BranchLabel8(ArmCompareType CompareType, const char * Label); - static void BranchLabel20(ArmCompareType CompareType, const char * Label); - static void CallFunction(void * Function, const char * FunctionName); - static void CompareArmRegToConst(ArmReg Reg, uint32_t value); - static void CompareArmRegToArmReg(ArmReg Reg1, ArmReg Reg2); - static void IfBlock(ArmItMask mask, ArmCompareType CompareType); - static void LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, uint16_t offset); - static void LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmReg RegPointer2, uint8_t shift); - static void LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, uint8_t Offset, const char * comment = nullptr); - static void LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmReg RegPointer2, uint8_t shift); - static void LoadArmRegPointerToFloatReg(ArmReg RegPointer, ArmFpuSingle Reg, uint8_t Offset); - static void LoadFloatingPointControlReg(ArmReg DestReg); - static void MoveArmRegArmReg(ArmReg DestReg, ArmReg SourceReg); - static void MoveArmRegToVariable(ArmReg Reg, void * Variable, const char * VariableName); - static void MoveConstToArmReg(ArmReg DestReg, uint16_t Const, const char * comment = nullptr); - static void MoveConstToArmRegTop(ArmReg DestReg, uint16_t Const, const char * comment = nullptr); - static void MoveConstToArmReg(ArmReg DestReg, uint32_t Const, const char * comment = nullptr); - static void MoveConstToVariable(uint32_t Const, void * Variable, const char * VariableName); - static void MoveFloatRegToVariable(ArmFpuSingle reg, void * Variable, const char * VariableName); - static void MoveVariableToArmReg(void * Variable, const char * VariableName, ArmReg reg); - static void MoveVariableToFloatReg(void * Variable, const char * VariableName, ArmFpuSingle reg); - static void OrArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2, uint32_t shift); - static void OrConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t value); - static void OrConstToVariable(void * Variable, const char * VariableName, uint32_t value); - static void MulF32(ArmFpuSingle DestReg, ArmFpuSingle SourceReg1, ArmFpuSingle SourceReg2); - static void PushArmReg(uint16_t Registers); - static void PopArmReg(uint16_t Registers); - static void ShiftRightSignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift); - static void ShiftRightUnsignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift); - static void ShiftLeftImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift); - static void SignExtendByte(ArmReg Reg); - static void StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, uint8_t Offset, const char * comment = nullptr); - static void StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, ArmReg RegPointer2, uint8_t shift); - static void StoreFloatingPointControlReg(ArmReg SourceReg); - static void StoreFloatRegToArmRegPointer(ArmFpuSingle Reg, ArmReg RegPointer, uint8_t Offset); - static void SubArmRegFromArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); - static void SubConstFromArmReg(ArmReg Reg, ArmReg SourceReg, uint32_t Const); - static void SubConstFromVariable(uint32_t Const, void * Variable, const char * VariableName); - static void TestVariable(uint32_t Const, void * Variable, const char * VariableName); - static void XorConstToArmReg(ArmReg DestReg, uint32_t value); - static void XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg); - static void XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); + void AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); + void AddConstToArmReg(ArmReg DestReg, uint32_t Const); + void AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const); + void AndConstToVariable(void *Variable, const char * VariableName, uint32_t Const); + void AndConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const); + void AndArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); + void ArmBreakPoint(const char * FileName, uint32_t LineNumber); + void ArmNop(void); + void BranchLabel8(ArmCompareType CompareType, const char * Label); + void BranchLabel20(ArmCompareType CompareType, const char * Label); + void CallFunction(void * Function, const char * FunctionName); + void CompareArmRegToConst(ArmReg Reg, uint32_t value); + void CompareArmRegToArmReg(ArmReg Reg1, ArmReg Reg2); + void IfBlock(ArmItMask mask, ArmCompareType CompareType); + void LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, uint16_t offset); + void LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmReg RegPointer2, uint8_t shift); + void LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, uint8_t Offset, const char * comment = nullptr); + void LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmReg RegPointer2, uint8_t shift); + void LoadArmRegPointerToFloatReg(ArmReg RegPointer, ArmFpuSingle Reg, uint8_t Offset); + void LoadFloatingPointControlReg(ArmReg DestReg); + void MoveArmRegArmReg(ArmReg DestReg, ArmReg SourceReg); + void MoveArmRegToVariable(ArmReg Reg, void * Variable, const char * VariableName); + void MoveConstToArmReg(ArmReg DestReg, uint16_t Const, const char * comment = nullptr); + void MoveConstToArmRegTop(ArmReg DestReg, uint16_t Const, const char * comment = nullptr); + void MoveConstToArmReg(ArmReg DestReg, uint32_t Const, const char * comment = nullptr); + void MoveConstToVariable(uint32_t Const, void * Variable, const char * VariableName); + void MoveFloatRegToVariable(ArmFpuSingle reg, void * Variable, const char * VariableName); + void MoveVariableToArmReg(void * Variable, const char * VariableName, ArmReg reg); + void MoveVariableToFloatReg(void * Variable, const char * VariableName, ArmFpuSingle reg); + void OrArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2, uint32_t shift); + void OrConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t value); + void OrConstToVariable(void * Variable, const char * VariableName, uint32_t value); + void MulF32(ArmFpuSingle DestReg, ArmFpuSingle SourceReg1, ArmFpuSingle SourceReg2); + void PushArmReg(uint16_t Registers); + void PopArmReg(uint16_t Registers); + void ShiftRightSignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift); + void ShiftRightUnsignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift); + void ShiftLeftImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift); + void SignExtendByte(ArmReg Reg); + void StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, uint8_t Offset, const char * comment = nullptr); + void StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, ArmReg RegPointer2, uint8_t shift); + void StoreFloatingPointControlReg(ArmReg SourceReg); + void StoreFloatRegToArmRegPointer(ArmFpuSingle Reg, ArmReg RegPointer, uint8_t Offset); + void SubArmRegFromArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); + void SubConstFromArmReg(ArmReg Reg, ArmReg SourceReg, uint32_t Const); + void SubConstFromVariable(uint32_t Const, void * Variable, const char * VariableName); + void TestVariable(uint32_t Const, void * Variable, const char * VariableName); + void XorConstToArmReg(ArmReg DestReg, uint32_t value); + void XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg); + void XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); - static void * GetAddressOf(int32_t value, ...); - static void SetJump8(uint8_t * Loc, uint8_t * JumpLoc); - static void SetJump20(uint32_t * Loc, uint32_t * JumpLoc); - static void FlushPopArmReg(void); + void * GetAddressOf(int32_t value, ...); + void SetJump8(uint8_t * Loc, uint8_t * JumpLoc); + void SetJump20(uint32_t * Loc, uint32_t * JumpLoc); + void FlushPopArmReg(void); - static CArmRegInfo m_RegWorkingSet; - -protected: - static const char * ArmRegName(ArmReg Reg); - static uint32_t PushPopRegisterSize(uint16_t Registers); - static std::string PushPopRegisterList(uint16_t Registers); + const char * ArmRegName(ArmReg Reg); + uint32_t PushPopRegisterSize(uint16_t Registers); + std::string PushPopRegisterList(uint16_t Registers); private: - friend class CArmRegInfo; + CArmOps(void); + CArmOps(const CArmOps&); + CArmOps& operator=(const CArmOps&); - static void PreOpCheck(ArmReg DestReg, bool AllowedInItBlock, const char * FileName, uint32_t LineNumber); - static void BreakPointNotification(const char * FileName, uint32_t LineNumber); - static bool ArmCompareInverse(ArmCompareType CompareType); - static ArmCompareType ArmCompareInverseType(ArmCompareType CompareType); - static const char * ArmCompareSuffix(ArmCompareType CompareType); - static const char * ArmFpuSingleName(ArmFpuSingle Reg); - static const char * ArmItMaskName(ArmItMask mask); - static const char * ArmCurrentItCondition(); + void CodeLog(_Printf_format_string_ const char * Text, ...); - static void ProgressItBlock(void); + void PreOpCheck(ArmReg DestReg, bool AllowedInItBlock, const char * FileName, uint32_t LineNumber); + void BreakPointNotification(const char * FileName, uint32_t LineNumber); + bool ArmCompareInverse(ArmCompareType CompareType); + ArmCompareType ArmCompareInverseType(ArmCompareType CompareType); + const char * ArmCompareSuffix(ArmCompareType CompareType); + const char * ArmFpuSingleName(ArmFpuSingle Reg); + const char * ArmItMaskName(ArmItMask mask); + const char * ArmCurrentItCondition(); - static bool CanThumbCompressConst(uint32_t value); - static uint16_t ThumbCompressConst(uint32_t value); + void ProgressItBlock(void); - static void AddCode8(uint8_t value); - static void AddCode16(uint16_t value); - static void AddCode32(uint32_t value); + bool CanThumbCompressConst(uint32_t value); + uint16_t ThumbCompressConst(uint32_t value); - static bool m_InItBlock; - static int m_ItBlockInstruction; - static ArmCompareType m_ItBlockCompareType; - static ArmItMask m_ItBlockMask; - static ArmReg m_LastStoreReg; - static uint16_t m_PopRegisters; - static uint16_t m_PushRegisters; + void AddCode8(uint8_t value); + void AddCode16(uint16_t value); + void AddCode32(uint32_t value); + + CCodeBlock & m_CodeBlock; + CArmRegInfo & m_RegWorkingSet; + bool m_InItBlock; + int m_ItBlockInstruction; + ArmCompareType m_ItBlockCompareType; + ArmItMask m_ItBlockMask; + ArmReg m_LastStoreReg; + uint16_t m_PopRegisters; + uint16_t m_PushRegisters; }; #define AddressOf(Addr) CArmOps::GetAddressOf(5,(Addr)) diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp index 05fc4ee42..bb4f359f9 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp @@ -1,13 +1,17 @@ #include "stdafx.h" #if defined(__arm__) || defined(_M_ARM) + #include #include #include #include +#include #include #include -#include +#include +#include +#include #include #include #include @@ -17,33 +21,51 @@ uint32_t CArmRecompilerOps::m_TempValue = 0; +CArmRecompilerOps::CArmRecompilerOps(CMipsMemoryVM & MMU, CCodeBlock & CodeBlock) : + m_MMU(MMU), + m_CodeBlock(CodeBlock), + m_Assembler(CodeBlock, m_RegWorkingSet), + m_RegWorkingSet(CodeBlock, m_Assembler), + m_CompilePC(0), + m_Section(nullptr), + m_RegBeforeDelay(CodeBlock, m_Assembler), + m_EffectDelaySlot(false), + m_PipelineStage(PIPELINE_STAGE_NORMAL) +{ + memset(&m_Opcode, 0, sizeof(m_Opcode)); +} + +CArmRecompilerOps::~CArmRecompilerOps() +{ +} + /*uint32_t TestValue = 0; void TestFunc() { -CPU_Message("%s: %X t2: %X", __FUNCTION__,TestValue, g_Reg->m_GPR[10].UW[0]); +m_CodeBlock.Log("%s: %X t2: %X", __FUNCTION__,TestValue, g_Reg->m_GPR[10].UW[0]); }*/ void CArmRecompilerOps::PreCompileOpcode(void) { if (m_PipelineStage != PIPELINE_STAGE_DELAY_SLOT_DONE) { - CPU_Message(" %X %s", m_CompilePC, R4300iInstruction(m_CompilePC, m_Opcode.Value).NameAndParam().c_str()); + m_CodeBlock.Log(" %X %s", m_CompilePC, R4300iInstruction(m_CompilePC, m_Opcode.Value).NameAndParam().c_str()); } /*FlushPopArmReg(); ArmNop(); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R1,m_CompilePC); - MoveConstToArmReg(Arm_R2,(uint32_t)&TestValue, "TestValue"); - StoreArmRegToArmRegPointer(Arm_R1,Arm_R2,0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1,m_CompilePC); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2,(uint32_t)&TestValue, "TestValue"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R1,CArmOps::Arm_R2,0); CallFunction(AddressOf(&TestFunc), "TestFunc"); m_RegWorkingSet.AfterCallDirect();*/ /*if ((m_CompilePC == 0x8027F564 || m_CompilePC == 0x8027F574) && m_PipelineStage == PIPELINE_STAGE_NORMAL) { m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0,(uint32_t)&TestValue, "TestValue"); - StoreArmRegToArmRegPointer(Arm_R1,Arm_R0,0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0,(uint32_t)&TestValue, "TestValue"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R1,CArmOps::Arm_R0,0); CallFunction(AddressOf(&TestFunc), "TestFunc"); m_RegWorkingSet.AfterCallDirect(); @@ -55,10 +77,10 @@ void CArmRecompilerOps::PreCompileOpcode(void) if (g_SyncSystem) { m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R1, m_CompilePC); - MoveConstToArmReg(Arm_R2, (uint32_t)&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); - StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0); - MoveConstToArmReg(Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, m_CompilePC); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t)&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R1, CArmOps::Arm_R2, 0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); CallFunction(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); m_RegWorkingSet.AfterCallDirect(); } @@ -68,10 +90,10 @@ void CArmRecompilerOps::PreCompileOpcode(void) { m_RegWorkingSet.WriteBackRegisters(); UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(m_CompilePC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + m_Assembler.MoveConstToVariable(m_CompilePC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); if (g_SyncSystem) { - MoveConstToArmReg(Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); CallFunction(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } }*/ @@ -88,68 +110,57 @@ void CArmRecompilerOps::PostCompileOpcode(void) m_RegWorkingSet.ResetRegProtection(); } -CArmRecompilerOps::CArmRecompilerOps(CMipsMemoryVM & MMU) : - m_MMU(MMU), - m_PipelineStage(PIPELINE_STAGE_NORMAL) -{ - memset(&m_Opcode, 0, sizeof(m_Opcode)); -} - -CArmRecompilerOps::~CArmRecompilerOps() -{ -} - -void CArmRecompilerOps::Compile_TrapCompare(TRAP_COMPARE CompareType) +void CArmRecompilerOps::Compile_TrapCompare(RecompilerTrapCompare CompareType) { void *FunctAddress = nullptr; const char *FunctName = nullptr; switch (CompareType) { - case CompareTypeTEQ: + case RecompilerTrapCompare_TEQ: FunctAddress = (void*)R4300iOp::SPECIAL_TEQ; FunctName = "R4300iOp::SPECIAL_TEQ"; break; - case CompareTypeTNE: + case RecompilerTrapCompare_TNE: FunctAddress = (void*)R4300iOp::SPECIAL_TNE; FunctName = "R4300iOp::SPECIAL_TNE"; break; - case CompareTypeTGE: + case RecompilerTrapCompare_TGE: FunctAddress = (void*)R4300iOp::SPECIAL_TGE; FunctName = "R4300iOp::SPECIAL_TGE"; break; - case CompareTypeTGEU: + case RecompilerTrapCompare_TGEU: FunctAddress = (void*)R4300iOp::SPECIAL_TGEU; FunctName = "R4300iOp::SPECIAL_TGEU"; break; - case CompareTypeTLT: + case RecompilerTrapCompare_TLT: FunctAddress = (void*)R4300iOp::SPECIAL_TLT; FunctName = "R4300iOp::SPECIAL_TLT"; break; - case CompareTypeTLTU: + case RecompilerTrapCompare_TLTU: FunctAddress = (void*)R4300iOp::SPECIAL_TLTU; FunctName = "R4300iOp::SPECIAL_TLTU"; break; - case CompareTypeTEQI: + case RecompilerTrapCompare_TEQI: FunctAddress = (void*)R4300iOp::REGIMM_TEQI; FunctName = "R4300iOp::REGIMM_TEQI"; break; - case CompareTypeTNEI: + case RecompilerTrapCompare_TNEI: FunctAddress = (void*)R4300iOp::REGIMM_TNEI; FunctName = "R4300iOp::REGIMM_TNEI"; break; - case CompareTypeTGEI: + case RecompilerTrapCompare_TGEI: FunctAddress = (void*)R4300iOp::REGIMM_TGEI; FunctName = "R4300iOp::REGIMM_TGEI"; break; - case CompareTypeTGEIU: + case RecompilerTrapCompare_TGEIU: FunctAddress = (void*)R4300iOp::REGIMM_TGEIU; FunctName = "R4300iOp::REGIMM_TGEIU"; break; - case CompareTypeTLTI: + case RecompilerTrapCompare_TLTI: FunctAddress = (void*)R4300iOp::REGIMM_TLTI; FunctName = "R4300iOp::REGIMM_TLTI"; break; - case CompareTypeTLTIU: + case RecompilerTrapCompare_TLTIU: FunctAddress = (void*)R4300iOp::REGIMM_TLTIU; FunctName = "R4300iOp::REGIMM_TLTIU"; break; @@ -172,62 +183,55 @@ void CArmRecompilerOps::Compile_TrapCompare(TRAP_COMPARE CompareType) // Branch functions -void CArmRecompilerOps::Compile_BranchCompare(BRANCH_COMPARE CompareType) +void CArmRecompilerOps::Compile_BranchCompare(RecompilerBranchCompare CompareType) { switch (CompareType) { - case CompareTypeBEQ: BEQ_Compare(); break; - case CompareTypeBNE: BNE_Compare(); break; - case CompareTypeBLTZ: BLTZ_Compare(); break; - case CompareTypeBLEZ: BLEZ_Compare(); break; - case CompareTypeBGTZ: BGTZ_Compare(); break; - case CompareTypeBGEZ: BGEZ_Compare(); break; - case CompareTypeCOP1BCF: COP1_BCF_Compare(); break; - case CompareTypeCOP1BCT: COP1_BCT_Compare(); break; + case RecompilerBranchCompare_BEQ: BEQ_Compare(); break; + case RecompilerBranchCompare_BNE: BNE_Compare(); break; + case RecompilerBranchCompare_BLTZ: BLTZ_Compare(); break; + case RecompilerBranchCompare_BLEZ: BLEZ_Compare(); break; + case RecompilerBranchCompare_BGTZ: BGTZ_Compare(); break; + case RecompilerBranchCompare_BGEZ: BGEZ_Compare(); break; + case RecompilerBranchCompare_COP1BCF: COP1_BCF_Compare(); break; + case RecompilerBranchCompare_COP1BCT: COP1_BCT_Compare(); break; default: g_Notify->BreakPoint(__FILE__, __LINE__); } } -void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) +void CArmRecompilerOps::Compile_Branch(RecompilerBranchCompare CompareType, bool Link) { - static CRegInfo RegBeforeDelay; - static bool EffectDelaySlot; - R4300iOpcode Command = { 0 }; - if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { - if (CompareType == CompareTypeCOP1BCF || CompareType == CompareTypeCOP1BCT) + if (CompareType == RecompilerBranchCompare_COP1BCF || CompareType == RecompilerBranchCompare_COP1BCT) { CompileCop1Test(); } if (m_CompilePC + ((int16_t)m_Opcode.offset << 2) + 4 == m_CompilePC + 8) { + m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; return; } if ((m_CompilePC & 0xFFC) != 0xFFC) { R4300iOpcode DelaySlot; - if (!g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value)) - { - g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD)); - } - EffectDelaySlot = R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value); + m_EffectDelaySlot = g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) && R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value); } else { - EffectDelaySlot = true; + m_EffectDelaySlot = true; } m_Section->m_Jump.JumpPC = m_CompilePC; m_Section->m_Jump.TargetPC = m_CompilePC + ((int16_t)m_Opcode.offset << 2) + 4; if (m_Section->m_JumpSection != nullptr) { - m_Section->m_Jump.BranchLabel.Format("Section_%d", m_Section->m_JumpSection->m_SectionID); + m_Section->m_Jump.BranchLabel = stdstr_f("Section_%d", m_Section->m_JumpSection->m_SectionID); } else { - m_Section->m_Jump.BranchLabel.Format("Exit_%X_jump_%X", m_Section->m_EnterPC, m_Section->m_Jump.TargetPC); + m_Section->m_Jump.BranchLabel = stdstr_f("Exit_%X_jump_%X", m_Section->m_EnterPC, m_Section->m_Jump.TargetPC); } m_Section->m_Jump.LinkLocation = nullptr; m_Section->m_Jump.LinkLocation2 = nullptr; @@ -236,11 +240,11 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) m_Section->m_Cont.TargetPC = m_CompilePC + 8; if (m_Section->m_ContinueSection != nullptr) { - m_Section->m_Cont.BranchLabel.Format("Section_%d", m_Section->m_ContinueSection->m_SectionID); + m_Section->m_Cont.BranchLabel = stdstr_f("Section_%d", m_Section->m_ContinueSection->m_SectionID); } else { - m_Section->m_Cont.BranchLabel.Format("Exit_%X_continue_%X", m_Section->m_EnterPC, m_Section->m_Cont.TargetPC); + m_Section->m_Cont.BranchLabel = stdstr_f("Exit_%X_continue_%X", m_Section->m_EnterPC, m_Section->m_Cont.TargetPC); } m_Section->m_Cont.LinkLocation = nullptr; m_Section->m_Cont.LinkLocation2 = nullptr; @@ -261,16 +265,16 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) UnMap_GPR(31, false); if (!g_System->b32BitCore()) { - MoveConstToVariable((m_CompilePC & 0x80000000) != 0 ? 0xFFFFFFFF : 0, &_GPR[31].UW[1], CRegName::GPR_Hi[31]); + m_Assembler.MoveConstToVariable((m_CompilePC & 0x80000000) != 0 ? 0xFFFFFFFF : 0, &_GPR[31].UW[1], CRegName::GPR_Hi[31]); } - MoveConstToVariable(m_CompilePC + 8, &_GPR[31].UW[0], CRegName::GPR_Lo[31]); + m_Assembler.MoveConstToVariable(m_CompilePC + 8, &_GPR[31].UW[0], CRegName::GPR_Lo[31]); } - if (EffectDelaySlot) + if (m_EffectDelaySlot) { if ((m_CompilePC & 0xFFC) != 0xFFC) { - m_Section->m_Cont.BranchLabel = m_Section->m_ContinueSection != nullptr ? "Continue" : "ContinueExitBlock"; - m_Section->m_Jump.BranchLabel = m_Section->m_JumpSection != nullptr ? "Jump" : "JumpExitBlock"; + m_Section->m_Cont.BranchLabel = m_Section->m_ContinueSection != nullptr ? "Continue" : stdstr_f("ExitBlock_%X_Continue", m_Section->m_EnterPC); + m_Section->m_Jump.BranchLabel = m_Section->m_JumpSection != nullptr ? "Jump" : stdstr_f("ExitBlock_%X_Jump", m_Section->m_EnterPC); } else { @@ -285,15 +289,15 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) { if (m_Section->m_Jump.LinkLocation != nullptr) { - CPU_Message(""); - CPU_Message(" %s:", m_Section->m_Jump.BranchLabel.c_str()); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" %s:", m_Section->m_Jump.BranchLabel.c_str()); LinkJump(m_Section->m_Jump); m_Section->m_Jump.FallThrough = true; } else if (m_Section->m_Cont.LinkLocation != nullptr) { - CPU_Message(""); - CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" %s:", m_Section->m_Cont.BranchLabel.c_str()); LinkJump(m_Section->m_Cont); m_Section->m_Cont.FallThrough = true; } @@ -307,7 +311,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) { g_Notify->BreakPoint(__FILE__, __LINE__); } - MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); + m_Assembler.MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); } else if (m_Section->m_Cont.FallThrough) { @@ -315,49 +319,56 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) { g_Notify->BreakPoint(__FILE__, __LINE__); } - MoveConstToVariable(m_Section->m_Cont.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); + m_Assembler.MoveConstToVariable(m_Section->m_Cont.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); } if (m_Section->m_Jump.LinkLocation != nullptr || m_Section->m_Jump.LinkLocation2 != nullptr) { if (DelayLinkLocation != nullptr) { g_Notify->BreakPoint(__FILE__, __LINE__); } DelayLinkLocation = *g_RecompPos; - BranchLabel8(ArmBranch_Always, "DoDelaySlot"); + m_Assembler.BranchLabel8(CArmOps::CArmOps::ArmBranch_Always, "DoDelaySlot"); - CPU_Message(" "); - CPU_Message(" %s:", m_Section->m_Jump.BranchLabel.c_str()); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" %s:", m_Section->m_Jump.BranchLabel.c_str()); LinkJump(m_Section->m_Jump); - MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); + m_Assembler.MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); } if (m_Section->m_Cont.LinkLocation != nullptr || m_Section->m_Cont.LinkLocation2 != nullptr) { if (DelayLinkLocation != nullptr) { g_Notify->BreakPoint(__FILE__, __LINE__); } DelayLinkLocation = *g_RecompPos; - BranchLabel8(ArmBranch_Always, "DoDelaySlot"); + m_Assembler.BranchLabel8(CArmOps::CArmOps::ArmBranch_Always, "DoDelaySlot"); - CPU_Message(" "); - CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" %s:", m_Section->m_Cont.BranchLabel.c_str()); LinkJump(m_Section->m_Cont); - MoveConstToVariable(m_Section->m_Cont.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); + m_Assembler.MoveConstToVariable(m_Section->m_Cont.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); } if (DelayLinkLocation) { - CPU_Message(""); - CPU_Message(" DoDelaySlot:"); - SetJump8(DelayLinkLocation, *g_RecompPos); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" DoDelaySlot:"); + m_Assembler.SetJump8(DelayLinkLocation, *g_RecompPos); } ResetRegProtection(); OverflowDelaySlot(false); return; } ResetRegProtection(); - RegBeforeDelay = m_RegWorkingSet; + m_RegBeforeDelay = m_RegWorkingSet; } m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; } else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) { - if (EffectDelaySlot) + if (m_CompilePC + ((int16_t)m_Opcode.offset << 2) + 4 == m_CompilePC + 8) + { + m_PipelineStage = PIPELINE_STAGE_NORMAL; + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + SetCurrentPC(GetCurrentPC() + 4); + return; + } + if (m_EffectDelaySlot) { CJumpInfo * FallInfo = m_Section->m_Jump.FallThrough ? &m_Section->m_Jump : &m_Section->m_Cont; CJumpInfo * JumpInfo = m_Section->m_Jump.FallThrough ? &m_Section->m_Cont : &m_Section->m_Jump; @@ -370,7 +381,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) { if (m_Section->m_JumpSection != nullptr) { - m_Section->m_Jump.BranchLabel.Format("Section_%d", m_Section->m_JumpSection->m_SectionID); + m_Section->m_Jump.BranchLabel = stdstr_f("Section_%d", m_Section->m_JumpSection->m_SectionID); } else { @@ -378,11 +389,11 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) } if (FallInfo->TargetPC <= m_CompilePC) { - UpdateCounters(m_Section->m_Jump.RegSet, true, true); - CPU_Message("CompileSystemCheck 12"); + UpdateCounters(m_Section->m_Jump.RegSet, true, true, true); + m_CodeBlock.Log("CompileSystemCheck 12"); CompileSystemCheck(FallInfo->TargetPC, m_Section->m_Jump.RegSet); ResetRegProtection(); - FallInfo->ExitReason = ExitReason_NormalNoSysCheck; + FallInfo->Reason = ExitReason_NormalNoSysCheck; FallInfo->JumpPC = (uint32_t)-1; } } @@ -390,27 +401,27 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) { if (m_Section->m_ContinueSection != nullptr) { - m_Section->m_Cont.BranchLabel.Format("Section_%d", m_Section->m_ContinueSection->m_SectionID); + m_Section->m_Cont.BranchLabel = stdstr_f("Section_%d", m_Section->m_ContinueSection->m_SectionID); } else { - m_Section->m_Cont.BranchLabel = "ExitBlock"; + m_Section->m_Cont.BranchLabel = stdstr_f("ExitBlock_%X_Continue", m_Section->m_EnterPC); } } FallInfo->DoneDelaySlot = true; if (!JumpInfo->DoneDelaySlot) { FallInfo->FallThrough = false; - BranchLabel20(ArmBranch_Always, FallInfo->BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, FallInfo->BranchLabel.c_str()); FallInfo->LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (JumpInfo->LinkLocation != nullptr) { - CPU_Message(" %s:", JumpInfo->BranchLabel.c_str()); + m_CodeBlock.Log(" %s:", JumpInfo->BranchLabel.c_str()); LinkJump(*JumpInfo); JumpInfo->FallThrough = true; m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; - m_RegWorkingSet = RegBeforeDelay; + m_RegWorkingSet = m_RegBeforeDelay; return; } } @@ -437,7 +448,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) } if (m_Section->m_ContinueSection != nullptr) { - m_Section->m_Cont.BranchLabel.Format("Section_%d", m_Section->m_ContinueSection->m_SectionID); + m_Section->m_Cont.BranchLabel = stdstr_f("Section_%d", m_Section->m_ContinueSection->m_SectionID); } else { @@ -457,11 +468,11 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, bool Link) } } -void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link) +void CArmRecompilerOps::Compile_BranchLikely(RecompilerBranchCompare CompareType, bool Link) { if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { - if (CompareType == CompareTypeCOP1BCF || CompareType == CompareTypeCOP1BCT) + if (CompareType == RecompilerBranchCompare_COP1BCF || CompareType == RecompilerBranchCompare_COP1BCT) { CompileCop1Test(); } @@ -490,7 +501,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li if (m_Section->m_JumpSection != nullptr) { - m_Section->m_Jump.BranchLabel.Format("Section_%d", ((CCodeSection *)m_Section->m_JumpSection)->m_SectionID); + m_Section->m_Jump.BranchLabel = stdstr_f("Section_%d", ((CCodeSection *)m_Section->m_JumpSection)->m_SectionID); } else { @@ -499,7 +510,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li if (m_Section->m_ContinueSection != nullptr) { - m_Section->m_Cont.BranchLabel.Format("Section_%d", ((CCodeSection *)m_Section->m_ContinueSection)->m_SectionID); + m_Section->m_Cont.BranchLabel = stdstr_f("Section_%d", ((CCodeSection *)m_Section->m_ContinueSection)->m_SectionID); } else { @@ -512,7 +523,6 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li m_Section->m_Cont.FallThrough = false; m_Section->m_Cont.LinkLocation = nullptr; m_Section->m_Cont.LinkLocation2 = nullptr; - if (Link) { UnMap_GPR(31, false); @@ -527,6 +537,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li ResetRegProtection(); m_Section->m_Cont.RegSet = m_RegWorkingSet; + m_Section->m_Cont.RegSet.SetBlockCycleCount(m_Section->m_Cont.RegSet.GetBlockCycleCount() + g_System->CountPerOp()); if ((m_CompilePC & 0xFFC) == 0xFFC) { if (m_Section->m_Cont.FallThrough) @@ -541,10 +552,10 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li { LinkJump(m_Section->m_Jump); - MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); + m_Assembler.MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation"); OverflowDelaySlot(false); - CPU_Message(" "); - CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" %s:", m_Section->m_Cont.BranchLabel.c_str()); } else if (!m_Section->m_Cont.FallThrough) { @@ -552,7 +563,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li } LinkJump(m_Section->m_Cont); - CompileExit(m_CompilePC, m_CompilePC + 8, m_Section->m_Cont.RegSet, ExitReason_Normal); + CompileExit(m_CompilePC, m_CompilePC + 8, m_Section->m_Cont.RegSet, ExitReason_Normal, true, nullptr); return; } else @@ -563,6 +574,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li if (g_System->bLinkBlocks()) { m_Section->m_Jump.RegSet = m_RegWorkingSet; + m_Section->m_Jump.RegSet.SetBlockCycleCount(m_Section->m_Jump.RegSet.GetBlockCycleCount() + g_System->CountPerOp()); m_Section->GenerateSectionLinkage(); m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } @@ -583,6 +595,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li { ResetRegProtection(); m_Section->m_Jump.RegSet = m_RegWorkingSet; + m_Section->m_Jump.RegSet.SetBlockCycleCount(m_Section->m_Jump.RegSet.GetBlockCycleCount()); m_Section->GenerateSectionLinkage(); m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } @@ -622,61 +635,61 @@ void CArmRecompilerOps::BNE_Compare() ProtectGPR(m_Opcode.rt); if (!g_System->b32BitCore() && (Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt))) { - CompareArmRegToArmReg( - Is32Bit(m_Opcode.rs) ? Map_TempReg(Arm_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), - Is32Bit(m_Opcode.rt) ? Map_TempReg(Arm_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) + m_Assembler.CompareArmRegToArmReg( + Is32Bit(m_Opcode.rs) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), + Is32Bit(m_Opcode.rt) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) ); if (m_Section->m_Jump.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Notequal, "Continue"); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } - CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + m_Assembler.CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } else { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else { - CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + m_Assembler.CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -693,68 +706,68 @@ void CArmRecompilerOps::BNE_Compare() ProtectGPR(MappedReg); if (Is32Bit(MappedReg)) { - CompareArmRegToConst(Map_TempReg(Arm_Any, MappedReg, true), GetMipsRegHi(ConstReg)); + m_Assembler.CompareArmRegToConst(Map_TempReg(CArmOps::Arm_Any, MappedReg, true), GetMipsRegHi(ConstReg)); } else { - CompareArmRegToConst(GetMipsRegMapHi(MappedReg), GetMipsRegLo_S(ConstReg) >> 31); + m_Assembler.CompareArmRegToConst(GetMipsRegMapHi(MappedReg), GetMipsRegLo_S(ConstReg) >> 31); } } else { g_Notify->BreakPoint(__FILE__, __LINE__); - //CompareArmRegToConst(GetMipsRegMapHi(MappedReg), GetMipsRegHi(ConstReg)); + //m_Assembler.CompareArmRegToConst(GetMipsRegMapHi(MappedReg), GetMipsRegHi(ConstReg)); } if (m_Section->m_Jump.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Notequal, "Continue"); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } - CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } else { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else { - CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -770,38 +783,38 @@ void CArmRecompilerOps::BNE_Compare() ProtectGPR(KnownReg); } - ArmReg TempRegUnknown = Arm_Any; + CArmOps::ArmReg TempRegUnknown = CArmOps::Arm_Any; if (!g_System->b32BitCore()) { - TempRegUnknown = Map_TempReg(Arm_Any, UnknownReg, true); + TempRegUnknown = Map_TempReg(CArmOps::Arm_Any, UnknownReg, true); if (IsConst(KnownReg)) { if (Is32Bit(KnownReg) && IsSigned(KnownReg)) { - CompareArmRegToConst(TempRegUnknown, (GetMipsRegLo_S(KnownReg) >> 31)); + m_Assembler.CompareArmRegToConst(TempRegUnknown, (GetMipsRegLo_S(KnownReg) >> 31)); } else if (Is32Bit(KnownReg)) { - CompareArmRegToConst(TempRegUnknown, 0); + m_Assembler.CompareArmRegToConst(TempRegUnknown, 0); } else { - CompareArmRegToConst(TempRegUnknown, GetMipsRegHi(KnownReg)); + m_Assembler.CompareArmRegToConst(TempRegUnknown, GetMipsRegHi(KnownReg)); } } else { ProtectGPR(KnownReg); - CompareArmRegToArmReg(TempRegUnknown, Is32Bit(KnownReg) ? Map_TempReg(Arm_Any, KnownReg, true) : GetMipsRegMapHi(KnownReg)); + m_Assembler.CompareArmRegToArmReg(TempRegUnknown, Is32Bit(KnownReg) ? Map_TempReg(CArmOps::Arm_Any, KnownReg, true) : GetMipsRegMapHi(KnownReg)); } if (m_Section->m_Jump.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Notequal, "Continue"); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } m_RegWorkingSet.SetArmRegProtected(TempRegUnknown, false); @@ -809,17 +822,17 @@ void CArmRecompilerOps::BNE_Compare() TempRegUnknown = Map_TempReg(TempRegUnknown, UnknownReg, false); if (IsConst(KnownReg)) { - CompareArmRegToConst(TempRegUnknown, GetMipsRegLo(KnownReg)); + m_Assembler.CompareArmRegToConst(TempRegUnknown, GetMipsRegLo(KnownReg)); } else { - CompareArmRegToArmReg(TempRegUnknown, GetMipsRegMapLo(KnownReg)); + m_Assembler.CompareArmRegToArmReg(TempRegUnknown, GetMipsRegMapLo(KnownReg)); } m_RegWorkingSet.SetArmRegProtected(TempRegUnknown, false); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); if (g_System->b32BitCore()) { m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); @@ -831,15 +844,15 @@ void CArmRecompilerOps::BNE_Compare() } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (Jump) { - CPU_Message(" "); - CPU_Message(" continue:"); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_Assembler.SetJump8(Jump, *g_RecompPos); } } else @@ -848,7 +861,7 @@ void CArmRecompilerOps::BNE_Compare() CArmRecompilerOps::UnknownOpcode(); /*JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); if (g_System->b32BitCore()) { m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); @@ -863,33 +876,33 @@ void CArmRecompilerOps::BNE_Compare() { if (!g_System->b32BitCore()) { - ArmReg TempRegRs = Map_TempReg(Arm_Any, m_Opcode.rs, true); - ArmReg TempRegRt = Map_TempReg(Arm_Any, m_Opcode.rt, true); - CompareArmRegToArmReg(TempRegRs, TempRegRt); + CArmOps::ArmReg TempRegRs = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true); + CArmOps::ArmReg TempRegRt = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, true); + m_Assembler.CompareArmRegToArmReg(TempRegRs, TempRegRt); m_RegWorkingSet.SetArmRegProtected(TempRegRs, false); m_RegWorkingSet.SetArmRegProtected(TempRegRt, false); if (m_Section->m_Jump.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Notequal, "Continue"); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } - ArmReg TempRegRs = Map_TempReg(Arm_Any, m_Opcode.rs, false); - ArmReg TempRegRt = Map_TempReg(Arm_Any, m_Opcode.rt, false); - CompareArmRegToArmReg(TempRegRs, TempRegRt); + CArmOps::ArmReg TempRegRs = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + CArmOps::ArmReg TempRegRt = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, false); + m_Assembler.CompareArmRegToArmReg(TempRegRs, TempRegRt); m_RegWorkingSet.SetArmRegProtected(TempRegRs, false); m_RegWorkingSet.SetArmRegProtected(TempRegRt, false); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); if (g_System->b32BitCore()) { m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); @@ -901,13 +914,13 @@ void CArmRecompilerOps::BNE_Compare() } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (Jump) { - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } } else @@ -916,7 +929,7 @@ void CArmRecompilerOps::BNE_Compare() #ifdef tofix JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); if (g_System->b32BitCore()) { m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); @@ -960,60 +973,60 @@ void CArmRecompilerOps::BEQ_Compare() ProtectGPR(m_Opcode.rs); ProtectGPR(m_Opcode.rt); - CompareArmRegToArmReg( - Is32Bit(m_Opcode.rs) ? Map_TempReg(Arm_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), - Is32Bit(m_Opcode.rt) ? Map_TempReg(Arm_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) + m_Assembler.CompareArmRegToArmReg( + Is32Bit(m_Opcode.rs) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), + Is32Bit(m_Opcode.rt) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) ); if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Notequal, "Continue"); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } - CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + m_Assembler.CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else { - CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + m_Assembler.CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1030,67 +1043,67 @@ void CArmRecompilerOps::BEQ_Compare() if (Is32Bit(MappedReg)) { ProtectGPR(MappedReg); - CompareArmRegToConst(Map_TempReg(Arm_Any, MappedReg, true), GetMipsRegHi(ConstReg)); + m_Assembler.CompareArmRegToConst(Map_TempReg(CArmOps::Arm_Any, MappedReg, true), GetMipsRegHi(ConstReg)); } else { - CompareArmRegToConst(GetMipsRegMapHi(MappedReg), GetMipsRegLo_S(ConstReg) >> 31); + m_Assembler.CompareArmRegToConst(GetMipsRegMapHi(MappedReg), GetMipsRegLo_S(ConstReg) >> 31); } } else { - CompareArmRegToConst(GetMipsRegMapHi(MappedReg), GetMipsRegHi(ConstReg)); + m_Assembler.CompareArmRegToConst(GetMipsRegMapHi(MappedReg), GetMipsRegHi(ConstReg)); } if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Notequal, "Continue"); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } - CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else { - CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1101,38 +1114,38 @@ void CArmRecompilerOps::BEQ_Compare() uint32_t KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; uint32_t UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - ArmReg TempReg = Arm_Any; + CArmOps::ArmReg TempReg = CArmOps::Arm_Any; if (!g_System->b32BitCore()) { - TempReg = Map_TempReg(Arm_Any, UnknownReg, true); + TempReg = Map_TempReg(CArmOps::Arm_Any, UnknownReg, true); if (IsConst(KnownReg)) { if (Is32Bit(KnownReg) && IsSigned(KnownReg)) { - CompareArmRegToConst(TempReg, (GetMipsRegLo_S(KnownReg) >> 31)); + m_Assembler.CompareArmRegToConst(TempReg, (GetMipsRegLo_S(KnownReg) >> 31)); } else if (Is32Bit(KnownReg)) { - CompareArmRegToConst(TempReg, 0); + m_Assembler.CompareArmRegToConst(TempReg, 0); } else { - CompareArmRegToConst(TempReg, GetMipsRegHi(KnownReg)); + m_Assembler.CompareArmRegToConst(TempReg, GetMipsRegHi(KnownReg)); } } else { ProtectGPR(KnownReg); - CompareArmRegToArmReg(TempReg, Is32Bit(KnownReg) ? Map_TempReg(Arm_Any, KnownReg, true) : GetMipsRegMapHi(KnownReg)); + m_Assembler.CompareArmRegToArmReg(TempReg, Is32Bit(KnownReg) ? Map_TempReg(CArmOps::Arm_Any, KnownReg, true) : GetMipsRegMapHi(KnownReg)); } if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Notequal, "Continue"); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } m_RegWorkingSet.SetArmRegProtected(TempReg, false); @@ -1140,27 +1153,27 @@ void CArmRecompilerOps::BEQ_Compare() TempReg = Map_TempReg(TempReg, UnknownReg, false); if (IsConst(KnownReg)) { - CompareArmRegToConst(TempReg, GetMipsRegLo(KnownReg)); + m_Assembler.CompareArmRegToConst(TempReg, GetMipsRegLo(KnownReg)); } else { - CompareArmRegToArmReg(TempReg, GetMipsRegMapLo(KnownReg)); + m_Assembler.CompareArmRegToArmReg(TempReg, GetMipsRegMapLo(KnownReg)); } m_RegWorkingSet.SetArmRegProtected(TempReg, false); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (Jump) { - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); if (g_System->b32BitCore()) { m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); @@ -1172,9 +1185,9 @@ void CArmRecompilerOps::BEQ_Compare() } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1182,42 +1195,42 @@ void CArmRecompilerOps::BEQ_Compare() { if (!g_System->b32BitCore()) { - ArmReg TempRegRs = Map_TempReg(Arm_Any, m_Opcode.rs, true); - ArmReg TempRegRt = Map_TempReg(Arm_Any, m_Opcode.rt, true); - CompareArmRegToArmReg(TempRegRs, TempRegRt); + CArmOps::ArmReg TempRegRs = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true); + CArmOps::ArmReg TempRegRt = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, true); + m_Assembler.CompareArmRegToArmReg(TempRegRs, TempRegRt); m_RegWorkingSet.SetArmRegProtected(TempRegRs, false); m_RegWorkingSet.SetArmRegProtected(TempRegRt, false); if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Notequal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Notequal, "Continue"); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } - ArmReg TempRegRs = Map_TempReg(Arm_Any, m_Opcode.rs, false); - ArmReg TempRegRt = Map_TempReg(Arm_Any, m_Opcode.rt, false); - CompareArmRegToArmReg(TempRegRs, TempRegRt); + CArmOps::ArmReg TempRegRs = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + CArmOps::ArmReg TempRegRt = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, false); + m_Assembler.CompareArmRegToArmReg(TempRegRs, TempRegRt); m_RegWorkingSet.SetArmRegProtected(TempRegRs, false); m_RegWorkingSet.SetArmRegProtected(TempRegRt, false); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (Jump) { - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" "); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); if (g_System->b32BitCore()) { m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); @@ -1229,7 +1242,7 @@ void CArmRecompilerOps::BEQ_Compare() } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); if (g_System->b32BitCore()) { m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); @@ -1238,7 +1251,7 @@ void CArmRecompilerOps::BEQ_Compare() { m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1271,28 +1284,28 @@ void CArmRecompilerOps::BGTZ_Compare() { if (IsMapped(m_Opcode.rs)) { - CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); } else { - ArmReg TempReg = Map_TempReg(Arm_Any, m_Opcode.rs, false); - CompareArmRegToConst(TempReg, 0); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + m_Assembler.CompareArmRegToConst(TempReg, 0); } if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_LessThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_LessThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1302,65 +1315,65 @@ void CArmRecompilerOps::BGTZ_Compare() if (IsMapped(m_Opcode.rs)) { - CompareArmRegToConst(GetMipsRegMapHi(m_Opcode.rs), 0); + m_Assembler.CompareArmRegToConst(GetMipsRegMapHi(m_Opcode.rs), 0); } else { - ArmReg TempReg = Map_TempReg(Arm_Any, m_Opcode.rs, true); - CompareArmRegToConst(TempReg, 0); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true); + m_Assembler.CompareArmRegToConst(TempReg, 0); m_RegWorkingSet.SetArmRegProtected(TempReg, false); } if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); Jump = *g_RecompPos; - BranchLabel8(ArmBranch_GreaterThan, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_GreaterThan, "Continue"); } else if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_LessThan, "Continue"); - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_LessThan, "Continue"); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } if (IsMapped(m_Opcode.rs)) { - CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); } else { - ArmReg TempReg = Map_TempReg(Arm_Any, m_Opcode.rs, false); - CompareArmRegToConst(TempReg, 0); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + m_Assembler.CompareArmRegToConst(TempReg, 0); m_RegWorkingSet.SetArmRegProtected(TempReg, false); } if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } else if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } @@ -1412,22 +1425,22 @@ void CArmRecompilerOps::BLEZ_Compare() { if (Is32Bit(m_Opcode.rs)) { - CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_LessThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1435,68 +1448,68 @@ void CArmRecompilerOps::BLEZ_Compare() { uint8_t *Jump = nullptr; - ArmReg TempRegRs = Arm_Any; + CArmOps::ArmReg TempRegRs = CArmOps::Arm_Any; if (IsMapped(m_Opcode.rs)) { - CompareArmRegToConst(GetMipsRegMapHi(m_Opcode.rs), 0); + m_Assembler.CompareArmRegToConst(GetMipsRegMapHi(m_Opcode.rs), 0); } else { - TempRegRs = Map_TempReg(Arm_Any, m_Opcode.rs, true); - CompareArmRegToConst(TempRegRs, 0); + TempRegRs = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true); + m_Assembler.CompareArmRegToConst(TempRegRs, 0); m_RegWorkingSet.SetArmRegProtected(TempRegRs, false); } if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); Jump = *g_RecompPos; - BranchLabel8(ArmBranch_LessThan, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_LessThan, "Continue"); } else if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_GreaterThan, "Continue"); - BranchLabel20(ArmBranch_LessThan, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_GreaterThan, "Continue"); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_LessThan, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } if (IsMapped(m_Opcode.rs)) { - CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); } else { TempRegRs = Map_TempReg(TempRegRs, m_Opcode.rs, false); - CompareArmRegToConst(TempRegRs, 0); + m_Assembler.CompareArmRegToConst(TempRegRs, 0); m_RegWorkingSet.SetArmRegProtected(TempRegRs, false); } if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } else if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, "BranchToJump"); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, "BranchToJump"); m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } @@ -1507,81 +1520,81 @@ void CArmRecompilerOps::BLEZ_Compare() if (!g_System->b32BitCore()) { - ArmReg TempReg = Map_TempReg(Arm_Any, m_Opcode.rs, true); - CompareArmRegToConst(TempReg, 0); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true); + m_Assembler.CompareArmRegToConst(TempReg, 0); m_RegWorkingSet.SetArmRegProtected(TempReg, false); if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); Jump = *g_RecompPos; - BranchLabel8(ArmBranch_LessThan, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_LessThan, "Continue"); } else if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; - BranchLabel8(ArmBranch_GreaterThan, "Continue"); - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_GreaterThan, "Continue"); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_LessThan, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } - TempReg = Map_TempReg(Arm_Any, m_Opcode.rs, false); - CompareArmRegToConst(TempReg, 0); + TempReg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + m_Assembler.CompareArmRegToConst(TempReg, 0); m_RegWorkingSet.SetArmRegProtected(TempReg, false); if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); if (Jump) { - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } } else if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); if (Jump) { - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, "BranchToJump"); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, "BranchToJump"); m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else { - ArmReg TempReg = Map_TempReg(Arm_Any, m_Opcode.rs, false); - CompareArmRegToConst(TempReg, 0); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + m_Assembler.CompareArmRegToConst(TempReg, 0); m_RegWorkingSet.SetArmRegProtected(TempReg, false); if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_LessThanOrEqual, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThanOrEqual, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1619,22 +1632,22 @@ void CArmRecompilerOps::BLTZ_Compare() { if (Is64Bit(m_Opcode.rs) || IsSigned(m_Opcode.rs)) { - CompareArmRegToConst(Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : GetMipsRegMapLo(m_Opcode.rs), (uint32_t)0); + m_Assembler.CompareArmRegToConst(Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : GetMipsRegMapLo(m_Opcode.rs), (uint32_t)0); if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_GreaterThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_GreaterThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1646,25 +1659,25 @@ void CArmRecompilerOps::BLTZ_Compare() } else { - ArmReg TempReg1 = Map_TempReg(Arm_Any, m_Opcode.rs, !g_System->b32BitCore()); - ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempReg2, (uint32_t)0); - CompareArmRegToArmReg(TempReg1, TempReg2); + CArmOps::ArmReg TempReg1 = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, !g_System->b32BitCore()); + CArmOps::ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempReg2, (uint32_t)0); + m_Assembler.CompareArmRegToArmReg(TempReg1, TempReg2); if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_GreaterThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThanOrEqual, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1702,43 +1715,43 @@ void CArmRecompilerOps::BGEZ_Compare() { if (Is64Bit(m_Opcode.rs)) { - CompareArmRegToConst(GetMipsRegMapHi(m_Opcode.rs), 0); + m_Assembler.CompareArmRegToConst(GetMipsRegMapHi(m_Opcode.rs), 0); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_GreaterThanOrEqual, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThanOrEqual, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else if (IsSigned(m_Opcode.rs)) { - CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(m_Opcode.rs), 0); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_GreaterThanOrEqual, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThanOrEqual, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1750,23 +1763,23 @@ void CArmRecompilerOps::BGEZ_Compare() } else { - ArmReg TempReg = Map_TempReg(Arm_Any, m_Opcode.rs, !g_System->b32BitCore()); - CompareArmRegToConst(TempReg, 0); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, !g_System->b32BitCore()); + m_Assembler.CompareArmRegToConst(TempReg, 0); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_GreaterThanOrEqual, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_GreaterThanOrEqual, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_LessThan, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1774,44 +1787,44 @@ void CArmRecompilerOps::BGEZ_Compare() void CArmRecompilerOps::COP1_BCF_Compare() { - TestVariable(FPCSR_C, &_FPCR[31], "_FPCR[31]"); + m_Assembler.TestVariable(FPCSR_C, &_FPCR[31], "_FPCR[31]"); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } void CArmRecompilerOps::COP1_BCT_Compare() { - TestVariable(FPCSR_C, &_FPCR[31], "_FPCR[31]"); + m_Assembler.TestVariable(FPCSR_C, &_FPCR[31], "_FPCR[31]"); if (m_Section->m_Cont.FallThrough) { - BranchLabel20(ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - BranchLabel20(ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Notequal, m_Section->m_Cont.BranchLabel.c_str()); m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); - BranchLabel20(ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, m_Section->m_Jump.BranchLabel.c_str()); m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1824,7 +1837,7 @@ void CArmRecompilerOps::J() { if ((m_CompilePC & 0xFFC) == 0xFFC) { - MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &g_System->m_JumpToLocation, "System::m_JumpToLocation"); + m_Assembler.MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &g_System->m_JumpToLocation, "System::m_JumpToLocation"); OverflowDelaySlot(false); return; } @@ -1861,17 +1874,17 @@ void CArmRecompilerOps::JAL() if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { Map_GPR_32bit(31, true, -1); - MoveVariableToArmReg(_PROGRAM_COUNTER, "_PROGRAM_COUNTER", GetMipsRegMapLo(31)); - ArmReg TempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempReg, 0xF0000000); - AndArmRegToArmReg(GetMipsRegMapLo(31), GetMipsRegMapLo(31), TempReg); - MoveConstToArmReg(TempReg, (m_CompilePC + 8) & ~0xF0000000); - OrArmRegToArmReg(GetMipsRegMapLo(31), GetMipsRegMapLo(31), TempReg, 0); + m_Assembler.MoveVariableToArmReg(_PROGRAM_COUNTER, "_PROGRAM_COUNTER", GetMipsRegMapLo(31)); + CArmOps::ArmReg TempReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempReg, 0xF0000000); + m_Assembler.AndArmRegToArmReg(GetMipsRegMapLo(31), GetMipsRegMapLo(31), TempReg); + m_Assembler.MoveConstToArmReg(TempReg, (m_CompilePC + 8) & ~0xF0000000); + m_Assembler.OrArmRegToArmReg(GetMipsRegMapLo(31), GetMipsRegMapLo(31), TempReg, 0); m_RegWorkingSet.SetArmRegProtected(TempReg, false); if ((m_CompilePC & 0xFFC) == 0xFFC) { - MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &g_System->m_JumpToLocation, "System::m_JumpToLocation"); + m_Assembler.MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &g_System->m_JumpToLocation, "System::m_JumpToLocation"); OverflowDelaySlot(false); return; } @@ -1901,13 +1914,13 @@ void CArmRecompilerOps::JAL() { m_RegWorkingSet.WriteBackRegisters(); - MoveConstToArmReg(Arm_R0, (uint32_t)_PROGRAM_COUNTER, "_PROGRAM_COUNTER"); - LoadArmRegPointerToArmReg(Arm_R1, Arm_R0, 0); - MoveConstToArmReg(Arm_R2, 0xF0000000); - MoveConstToArmReg(Arm_R3, (uint32_t)(m_Opcode.target << 2)); - AndArmRegToArmReg(Arm_R1, Arm_R1, Arm_R2); - AddArmRegToArmReg(Arm_R1, Arm_R3, Arm_R1); - StoreArmRegToArmRegPointer(Arm_R1, Arm_R0, 0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)_PROGRAM_COUNTER, "_PROGRAM_COUNTER"); + m_Assembler.LoadArmRegPointerToArmReg(CArmOps::Arm_R1, CArmOps::Arm_R0, 0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, 0xF0000000); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R3, (uint32_t)(m_Opcode.target << 2)); + m_Assembler.AndArmRegToArmReg(CArmOps::Arm_R1, CArmOps::Arm_R1, CArmOps::Arm_R2); + m_Assembler.AddArmRegToArmReg(CArmOps::Arm_R1, CArmOps::Arm_R3, CArmOps::Arm_R1); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R1, CArmOps::Arm_R0, 0); uint32_t TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2); bool bCheck = TargetPC <= m_CompilePC; @@ -1949,12 +1962,12 @@ void CArmRecompilerOps::ADDI() { ProtectGPR(m_Opcode.rs); Map_GPR_32bit(m_Opcode.rt, true, -1); - AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rt), GetMipsRegMapLo(m_Opcode.rs), (int16_t)m_Opcode.immediate); + m_Assembler.AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rt), GetMipsRegMapLo(m_Opcode.rs), (int16_t)m_Opcode.immediate); } else { Map_GPR_32bit(m_Opcode.rt, true, m_Opcode.rs); - AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rt), (int16_t)m_Opcode.immediate); + m_Assembler.AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rt), (int16_t)m_Opcode.immediate); } if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) @@ -2052,7 +2065,7 @@ void CArmRecompilerOps::ORI() Map_GPR_32bit(m_Opcode.rt, IsSigned(m_Opcode.rs), -1); } } - OrConstToArmReg(GetMipsRegMapLo(m_Opcode.rt), GetMipsRegMapLo(m_Opcode.rs), m_Opcode.immediate); + m_Assembler.OrConstToArmReg(GetMipsRegMapLo(m_Opcode.rt), GetMipsRegMapLo(m_Opcode.rs), m_Opcode.immediate); } else { @@ -2064,7 +2077,7 @@ void CArmRecompilerOps::ORI() { Map_GPR_64bit(m_Opcode.rt, m_Opcode.rs); } - OrConstToArmReg(GetMipsRegMapLo(m_Opcode.rt), GetMipsRegMapLo(m_Opcode.rt), m_Opcode.immediate); + m_Assembler.OrConstToArmReg(GetMipsRegMapLo(m_Opcode.rt), GetMipsRegMapLo(m_Opcode.rt), m_Opcode.immediate); } if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) @@ -2181,27 +2194,27 @@ void CArmRecompilerOps::LB() ProtectGPR(m_Opcode.rt); } - ArmReg TempRegAddress; + CArmOps::ArmReg TempRegAddress; if (IsMapped(m_Opcode.base)) { ProtectGPR(m_Opcode.base); - TempRegAddress = Map_TempReg(Arm_Any, -1, false); - AddConstToArmReg(TempRegAddress, GetMipsRegMapLo(m_Opcode.base), (int16_t)m_Opcode.immediate); + TempRegAddress = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.AddConstToArmReg(TempRegAddress, GetMipsRegMapLo(m_Opcode.base), (int16_t)m_Opcode.immediate); } else { - TempRegAddress = Map_TempReg(Arm_Any, m_Opcode.base, false); - AddConstToArmReg(TempRegAddress, (int16_t)m_Opcode.immediate); + TempRegAddress = Map_TempReg(CArmOps::Arm_Any, m_Opcode.base, false); + m_Assembler.AddConstToArmReg(TempRegAddress, (int16_t)m_Opcode.immediate); } - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); - ArmReg ReadMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_READMAP); - LoadArmRegPointerToArmReg(TempReg, ReadMapReg, TempReg, 2); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); + CArmOps::ArmReg ReadMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_READMAP); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, ReadMapReg, TempReg, 2); CompileReadTLBMiss(TempRegAddress, TempReg); - XorConstToArmReg(TempRegAddress, 3); + m_Assembler.XorConstToArmReg(TempRegAddress, 3); Map_GPR_32bit(m_Opcode.rt, true, -1); - LoadArmRegPointerByteToArmReg(GetMipsRegMapLo(m_Opcode.rt), TempReg, TempRegAddress, 0); - SignExtendByte(GetMipsRegMapLo(m_Opcode.rt)); + m_Assembler.LoadArmRegPointerByteToArmReg(GetMipsRegMapLo(m_Opcode.rt), TempReg, TempRegAddress, 0); + m_Assembler.SignExtendByte(GetMipsRegMapLo(m_Opcode.rt)); } void CArmRecompilerOps::LH() @@ -2269,34 +2282,34 @@ void CArmRecompilerOps::LW(bool ResultSigned, bool bRecordLLBit) ProtectGPR(m_Opcode.rt); } - ArmReg TempRegAddress; + CArmOps::ArmReg TempRegAddress; if (IsMapped(m_Opcode.base)) { ProtectGPR(m_Opcode.base); - TempRegAddress = Map_TempReg(Arm_Any, -1, false); - AddConstToArmReg(TempRegAddress, GetMipsRegMapLo(m_Opcode.base), (int16_t)m_Opcode.immediate); + TempRegAddress = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.AddConstToArmReg(TempRegAddress, GetMipsRegMapLo(m_Opcode.base), (int16_t)m_Opcode.immediate); } else { - TempRegAddress = Map_TempReg(Arm_Any, m_Opcode.base, false); - AddConstToArmReg(TempRegAddress, (int16_t)m_Opcode.immediate); + TempRegAddress = Map_TempReg(CArmOps::Arm_Any, m_Opcode.base, false); + m_Assembler.AddConstToArmReg(TempRegAddress, (int16_t)m_Opcode.immediate); } m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - ArmReg TempRegValue = Arm_Unknown; - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); - ArmReg ReadMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_READMAP); - LoadArmRegPointerToArmReg(TempReg, ReadMapReg, TempReg, 2); + CArmOps::ArmReg TempRegValue = CArmOps::Arm_Unknown; + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); + CArmOps::ArmReg ReadMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_READMAP); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, ReadMapReg, TempReg, 2); CompileReadTLBMiss(TempRegAddress, TempReg); Map_GPR_32bit(m_Opcode.rt, ResultSigned, -1); - LoadArmRegPointerToArmReg(GetMipsRegMapLo(m_Opcode.rt), TempReg, TempRegAddress, 0); + m_Assembler.LoadArmRegPointerToArmReg(GetMipsRegMapLo(m_Opcode.rt), TempReg, TempRegAddress, 0); if (bRecordLLBit) { - MoveConstToVariable(1, _LLBit, "LLBit"); + m_Assembler.MoveConstToVariable(1, _LLBit, "LLBit"); } } if (g_System->bFastSP() && m_Opcode.rt == 29) @@ -2435,7 +2448,7 @@ void CArmRecompilerOps::SW(bool bCheckLLbit) } else { - SW_Register(Map_TempReg(Arm_Any, m_Opcode.rt, false), Address); + SW_Register(Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, false), Address); } return; } @@ -2453,27 +2466,27 @@ void CArmRecompilerOps::SW(bool bCheckLLbit) } if (IsMapped(m_Opcode.base)) { ProtectGPR(m_Opcode.base); } - ArmReg TempRegAddress = Map_TempReg(Arm_Any, IsMapped(m_Opcode.base) ? -1 : m_Opcode.base, false); + CArmOps::ArmReg TempRegAddress = Map_TempReg(CArmOps::Arm_Any, IsMapped(m_Opcode.base) ? -1 : m_Opcode.base, false); if (IsMapped(m_Opcode.base)) { - AddConstToArmReg(TempRegAddress, GetMipsRegMapLo(m_Opcode.base), (int16_t)m_Opcode.immediate); + m_Assembler.AddConstToArmReg(TempRegAddress, GetMipsRegMapLo(m_Opcode.base), (int16_t)m_Opcode.immediate); } else { - AddConstToArmReg(TempRegAddress, (int16_t)m_Opcode.immediate); + m_Assembler.AddConstToArmReg(TempRegAddress, (int16_t)m_Opcode.immediate); } - ArmReg TempRegValue = Arm_Unknown; - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); - ArmReg WriteMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_WRITEMAP); - LoadArmRegPointerToArmReg(TempReg, WriteMapReg, TempReg, 2); + CArmOps::ArmReg TempRegValue = CArmOps::Arm_Unknown; + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); + CArmOps::ArmReg WriteMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_WRITEMAP); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, WriteMapReg, TempReg, 2); CompileWriteTLBMiss(TempRegAddress, TempReg); if (bCheckLLbit) { g_Notify->BreakPoint(__FILE__, __LINE__); } - StoreArmRegToArmRegPointer(IsMapped(m_Opcode.rt) ? GetMipsRegMapLo(m_Opcode.rt) : Map_TempReg(Arm_Any, m_Opcode.rt, false), TempReg, TempRegAddress, 0); + m_Assembler.StoreArmRegToArmRegPointer(IsMapped(m_Opcode.rt) ? GetMipsRegMapLo(m_Opcode.rt) : Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, false), TempReg, TempRegAddress, 0); if (bCheckLLbit) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -2535,12 +2548,12 @@ void CArmRecompilerOps::CACHE() case 0: case 16: m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R3, (uint32_t)CRecompiler::Remove_Cache, "CRecompiler::Remove_Cache"); - MoveConstToArmReg(Arm_R2, (uint32_t)0x20); - MoveVariableToArmReg(&_GPR[m_Opcode.base].UW[0], CRegName::GPR_Lo[m_Opcode.base], Arm_R1); - MoveConstToArmReg(Arm_R0, (uint32_t)((int16_t)m_Opcode.offset)); - AddArmRegToArmReg(Arm_R1, Arm_R0, Arm_R1); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Recompiler, "g_Recompiler"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R3, (uint32_t)CRecompiler::Remove_Cache, "CRecompiler::Remove_Cache"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t)0x20); + m_Assembler.MoveVariableToArmReg(&_GPR[m_Opcode.base].UW[0], CRegName::GPR_Lo[m_Opcode.base], CArmOps::Arm_R1); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((int16_t)m_Opcode.offset)); + m_Assembler.AddArmRegToArmReg(CArmOps::Arm_R1, CArmOps::Arm_R0, CArmOps::Arm_R1); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Recompiler, "g_Recompiler"); CallFunction((void *)AddressOf(&CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); m_RegWorkingSet.AfterCallDirect(); break; @@ -2583,43 +2596,43 @@ void CArmRecompilerOps::LWC1() { uint32_t Address = GetMipsRegLo(m_Opcode.base) + (int16_t)m_Opcode.offset; - ArmReg TempRegValue = Map_TempReg(Arm_Any, -1, false); + CArmOps::ArmReg TempRegValue = Map_TempReg(CArmOps::Arm_Any, -1, false); LW_KnownAddress(TempRegValue, Address); - ArmReg FprReg = Map_Variable(CArmRegInfo::VARIABLE_FPR); - ArmReg TempRegAddress = Map_TempReg(Arm_Any, -1, false); - LoadArmRegPointerToArmReg(TempRegAddress, FprReg, (uint8_t)(m_Opcode.ft << 2)); - StoreArmRegToArmRegPointer(TempRegValue, TempRegAddress, 0); + CArmOps::ArmReg FprReg = Map_Variable(CArmRegInfo::VARIABLE_FPR); + CArmOps::ArmReg TempRegAddress = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.LoadArmRegPointerToArmReg(TempRegAddress, FprReg, (uint8_t)(m_Opcode.ft << 2)); + m_Assembler.StoreArmRegToArmRegPointer(TempRegValue, TempRegAddress, 0); return; } - ArmReg TempRegAddress; + CArmOps::ArmReg TempRegAddress; if (IsMapped(m_Opcode.base)) { ProtectGPR(m_Opcode.base); - TempRegAddress = Map_TempReg(Arm_Any, -1, false); - AddConstToArmReg(TempRegAddress, GetMipsRegMapLo(m_Opcode.base), (int16_t)m_Opcode.immediate); + TempRegAddress = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.AddConstToArmReg(TempRegAddress, GetMipsRegMapLo(m_Opcode.base), (int16_t)m_Opcode.immediate); } else { - TempRegAddress = Map_TempReg(Arm_Any, m_Opcode.base, false); - AddConstToArmReg(TempRegAddress, (int16_t)m_Opcode.immediate); + TempRegAddress = Map_TempReg(CArmOps::Arm_Any, m_Opcode.base, false); + m_Assembler.AddConstToArmReg(TempRegAddress, (int16_t)m_Opcode.immediate); } - ArmReg TempRegValue = Arm_Unknown; - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); - ArmReg ReadMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_READMAP); - LoadArmRegPointerToArmReg(TempReg, ReadMapReg, TempReg, 2); + CArmOps::ArmReg TempRegValue = CArmOps::Arm_Unknown; + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); + CArmOps::ArmReg ReadMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_READMAP); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, ReadMapReg, TempReg, 2); CompileReadTLBMiss(TempRegAddress, TempReg); //12: 4408 add r0, r1 //14: ed90 7a00 vldr s14, [r0] TempRegValue = TempReg; - LoadArmRegPointerToArmReg(TempRegValue, TempReg, TempRegAddress, 0); - ArmReg FprReg = Map_Variable(CArmRegInfo::VARIABLE_FPR); - LoadArmRegPointerToArmReg(TempRegAddress, FprReg, (uint8_t)(m_Opcode.ft << 2)); - StoreArmRegToArmRegPointer(TempRegValue, TempRegAddress, 0); + m_Assembler.LoadArmRegPointerToArmReg(TempRegValue, TempReg, TempRegAddress, 0); + CArmOps::ArmReg FprReg = Map_Variable(CArmRegInfo::VARIABLE_FPR); + m_Assembler.LoadArmRegPointerToArmReg(TempRegAddress, FprReg, (uint8_t)(m_Opcode.ft << 2)); + m_Assembler.StoreArmRegToArmRegPointer(TempRegValue, TempRegAddress, 0); } void CArmRecompilerOps::LDC1() @@ -2805,15 +2818,15 @@ void CArmRecompilerOps::SPECIAL_JR() { if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) { - MoveArmRegToVariable(GetMipsRegMapLo(m_Opcode.rs), &g_System->m_JumpToLocation, "System::m_JumpToLocation"); + m_Assembler.MoveArmRegToVariable(GetMipsRegMapLo(m_Opcode.rs), &g_System->m_JumpToLocation, "System::m_JumpToLocation"); m_RegWorkingSet.WriteBackRegisters(); } else { m_RegWorkingSet.WriteBackRegisters(); - MoveVariableToArmReg(&_GPR[m_Opcode.rs].UW[0], CRegName::GPR_Lo[m_Opcode.rs], Arm_R0); - MoveConstToArmReg(Arm_R1, (uint32_t)&g_System->m_JumpToLocation, "System::m_JumpToLocation"); - StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); + m_Assembler.MoveVariableToArmReg(&_GPR[m_Opcode.rs].UW[0], CRegName::GPR_Lo[m_Opcode.rs], CArmOps::Arm_R0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, (uint32_t)&g_System->m_JumpToLocation, "System::m_JumpToLocation"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R0, CArmOps::Arm_R1, 0); } OverflowDelaySlot(true); return; @@ -2834,20 +2847,20 @@ void CArmRecompilerOps::SPECIAL_JR() if (R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value)) { - ArmReg PCTempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(PCTempReg, (uint32_t)_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + CArmOps::ArmReg PCTempReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(PCTempReg, (uint32_t)_PROGRAM_COUNTER, "PROGRAM_COUNTER"); if (IsConst(m_Opcode.rs)) { g_Notify->BreakPoint(__FILE__, __LINE__); } else if (IsMapped(m_Opcode.rs)) { - StoreArmRegToArmRegPointer(GetMipsRegMapLo(m_Opcode.rs), PCTempReg, 0); + m_Assembler.StoreArmRegToArmRegPointer(GetMipsRegMapLo(m_Opcode.rs), PCTempReg, 0); } else { - ArmReg ValueTempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, m_Opcode.rs, false); - StoreArmRegToArmRegPointer(ValueTempReg, PCTempReg, 0); + CArmOps::ArmReg ValueTempReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + m_Assembler.StoreArmRegToArmRegPointer(ValueTempReg, PCTempReg, 0); m_RegWorkingSet.SetArmRegProtected(ValueTempReg, false); } m_RegWorkingSet.SetArmRegProtected(PCTempReg, false); @@ -2869,23 +2882,23 @@ void CArmRecompilerOps::SPECIAL_JR() else { UpdateCounters(m_RegWorkingSet, true, true); - ArmReg PCTempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(PCTempReg, (uint32_t)_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + CArmOps::ArmReg PCTempReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(PCTempReg, (uint32_t)_PROGRAM_COUNTER, "PROGRAM_COUNTER"); if (IsConst(m_Opcode.rs)) { - ArmReg ValueTempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(ValueTempReg, GetMipsRegLo(m_Opcode.rs)); - StoreArmRegToArmRegPointer(ValueTempReg, PCTempReg, 0); + CArmOps::ArmReg ValueTempReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(ValueTempReg, GetMipsRegLo(m_Opcode.rs)); + m_Assembler.StoreArmRegToArmRegPointer(ValueTempReg, PCTempReg, 0); m_RegWorkingSet.SetArmRegProtected(ValueTempReg, false); } else if (IsMapped(m_Opcode.rs)) { - StoreArmRegToArmRegPointer(GetMipsRegMapLo(m_Opcode.rs), PCTempReg, 0); + m_Assembler.StoreArmRegToArmRegPointer(GetMipsRegMapLo(m_Opcode.rs), PCTempReg, 0); } else { - ArmReg ValueTempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, m_Opcode.rs, false); - StoreArmRegToArmRegPointer(ValueTempReg, PCTempReg, 0); + CArmOps::ArmReg ValueTempReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + m_Assembler.StoreArmRegToArmRegPointer(ValueTempReg, PCTempReg, 0); m_RegWorkingSet.SetArmRegProtected(ValueTempReg, false); } m_RegWorkingSet.SetArmRegProtected(PCTempReg, false); @@ -2921,26 +2934,26 @@ void CArmRecompilerOps::SPECIAL_JALR() return; } g_Notify->BreakPoint(__FILE__, __LINE__); - MoveVariableToArmReg(&_GPR[m_Opcode.rs].UW[0], CRegName::GPR_Lo[m_Opcode.rs], Arm_R0); - MoveConstToArmReg(Arm_R1, (uint32_t)_PROGRAM_COUNTER, "PROGRAM_COUNTER"); - StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); + m_Assembler.MoveVariableToArmReg(&_GPR[m_Opcode.rs].UW[0], CRegName::GPR_Lo[m_Opcode.rs], CArmOps::Arm_R0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, (uint32_t)_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R0, CArmOps::Arm_R1, 0); } UnMap_GPR(m_Opcode.rd, false); - MoveConstToVariable(m_CompilePC + 8, &_GPR[m_Opcode.rd].UW[0], CRegName::GPR_Lo[m_Opcode.rd]); + m_Assembler.MoveConstToVariable(m_CompilePC + 8, &_GPR[m_Opcode.rd].UW[0], CRegName::GPR_Lo[m_Opcode.rd]); if ((m_CompilePC & 0xFFC) == 0xFFC) { - ArmReg TempRegVar = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempRegVar, (uint32_t)&g_System->m_JumpToLocation, "System::m_JumpToLocation"); + CArmOps::ArmReg TempRegVar = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempRegVar, (uint32_t)&g_System->m_JumpToLocation, "System::m_JumpToLocation"); - ArmReg TempRegRs = Arm_Unknown; + CArmOps::ArmReg TempRegRs = CArmOps::Arm_Unknown; if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) { - StoreArmRegToArmRegPointer(GetMipsRegMapLo(m_Opcode.rs), TempRegVar, 0); + m_Assembler.StoreArmRegToArmRegPointer(GetMipsRegMapLo(m_Opcode.rs), TempRegVar, 0); } else { - TempRegRs = m_RegWorkingSet.Map_TempReg(Arm_Any, m_Opcode.rs, false); - StoreArmRegToArmRegPointer(TempRegRs, TempRegVar, 0); + TempRegRs = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + m_Assembler.StoreArmRegToArmRegPointer(TempRegRs, TempRegVar, 0); m_RegWorkingSet.SetArmRegProtected(TempRegRs, false); } m_RegWorkingSet.SetArmRegProtected(TempRegVar, false); @@ -2973,11 +2986,11 @@ void CArmRecompilerOps::SPECIAL_JALR() else { UpdateCounters(m_RegWorkingSet, true, true); - ArmReg ArmRegRs = ArmRegRs = IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs) ? GetMipsRegMapLo(m_Opcode.rs) : m_RegWorkingSet.Map_TempReg(Arm_Any, m_Opcode.rs, false); + CArmOps::ArmReg ArmRegRs = ArmRegRs = IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs) ? GetMipsRegMapLo(m_Opcode.rs) : m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); m_RegWorkingSet.SetArmRegProtected(ArmRegRs, true); - ArmReg TempRegPC = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempRegPC, (uint32_t)_PROGRAM_COUNTER, "PROGRAM_COUNTER"); - StoreArmRegToArmRegPointer(ArmRegRs, TempRegPC, 0); + CArmOps::ArmReg TempRegPC = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempRegPC, (uint32_t)_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + m_Assembler.StoreArmRegToArmRegPointer(ArmRegRs, TempRegPC, 0); m_RegWorkingSet.SetArmRegProtected(ArmRegRs, false); m_RegWorkingSet.SetArmRegProtected(TempRegPC, false); CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, ExitReason_Normal); @@ -3265,9 +3278,9 @@ void CArmRecompilerOps::SPECIAL_SUBU() } else if (m_Opcode.rd == m_Opcode.rt) { - ArmReg Reg = Map_TempReg(Arm_Any, m_Opcode.rt, false); + CArmOps::ArmReg Reg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, false); Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rs); - SubArmRegFromArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd), Reg); + m_Assembler.SubArmRegFromArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd), Reg); } else { @@ -3275,15 +3288,15 @@ void CArmRecompilerOps::SPECIAL_SUBU() ProtectGPR(m_Opcode.rs); Map_GPR_32bit(m_Opcode.rd, true, rsMapped ? -1 : m_Opcode.rs); - ArmReg SouceReg = rsMapped ? GetMipsRegMapLo(m_Opcode.rs) : GetMipsRegMapLo(m_Opcode.rd); + CArmOps::ArmReg SouceReg = rsMapped ? GetMipsRegMapLo(m_Opcode.rs) : GetMipsRegMapLo(m_Opcode.rd); if (IsConst(m_Opcode.rt)) { - SubConstFromArmReg(GetMipsRegMapLo(m_Opcode.rd), SouceReg, GetMipsRegLo(m_Opcode.rt)); + m_Assembler.SubConstFromArmReg(GetMipsRegMapLo(m_Opcode.rd), SouceReg, GetMipsRegLo(m_Opcode.rt)); } else { - SubArmRegFromArmReg(GetMipsRegMapLo(m_Opcode.rd), SouceReg, IsMapped(m_Opcode.rt) ? GetMipsRegMapLo(m_Opcode.rt) : Map_TempReg(Arm_Any, m_Opcode.rt, false)); + m_Assembler.SubArmRegFromArmReg(GetMipsRegMapLo(m_Opcode.rd), SouceReg, IsMapped(m_Opcode.rt) ? GetMipsRegMapLo(m_Opcode.rt) : Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, false)); } } @@ -3371,22 +3384,22 @@ void CArmRecompilerOps::SPECIAL_XOR() if (m_Opcode.rt != m_Opcode.rd && m_Opcode.rs != m_Opcode.rd) { Map_GPR_64bit(m_Opcode.rd, -1); - XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), - Is32Bit(source1) ? Map_TempReg(Arm_Any, source1, true) : GetMipsRegMapHi(source1), - Is32Bit(source2) ? Map_TempReg(Arm_Any, source2, true) : GetMipsRegMapHi(source2)); - XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source1), GetMipsRegMapLo(source2)); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), + Is32Bit(source1) ? Map_TempReg(CArmOps::Arm_Any, source1, true) : GetMipsRegMapHi(source1), + Is32Bit(source2) ? Map_TempReg(CArmOps::Arm_Any, source2, true) : GetMipsRegMapHi(source2)); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source1), GetMipsRegMapLo(source2)); } else { Map_GPR_64bit(m_Opcode.rd, source1); - XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), Is32Bit(source2) ? Map_TempReg(Arm_Any, source2, true) : GetMipsRegMapHi(source2)); - XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), Is32Bit(source2) ? Map_TempReg(CArmOps::Arm_Any, source2, true) : GetMipsRegMapHi(source2)); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); } } else { Map_GPR_32bit(m_Opcode.rd, IsSigned(m_Opcode.rt) != IsSigned(m_Opcode.rs) ? true : IsSigned(m_Opcode.rt), -1); - XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source1), GetMipsRegMapLo(source2)); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source1), GetMipsRegMapLo(source2)); } } else @@ -3400,14 +3413,14 @@ void CArmRecompilerOps::SPECIAL_XOR() uint32_t ConstHi = Is32Bit(ConstReg) ? (uint32_t)(GetMipsRegLo_S(ConstReg) >> 31) : GetMipsRegHi(ConstReg); uint32_t ConstLo = GetMipsRegLo(ConstReg); Map_GPR_64bit(m_Opcode.rd, MappedReg); - if (ConstHi != 0) { XorConstToArmReg(GetMipsRegMapHi(m_Opcode.rd), ConstHi); } - if (ConstLo != 0) { XorConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), ConstLo); } + if (ConstHi != 0) { m_Assembler.XorConstToArmReg(GetMipsRegMapHi(m_Opcode.rd), ConstHi); } + if (ConstLo != 0) { m_Assembler.XorConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), ConstLo); } } else { int Value = GetMipsRegLo(ConstReg); Map_GPR_32bit(m_Opcode.rd, IsSigned(m_Opcode.rt) != IsSigned(m_Opcode.rs) ? true : IsSigned(MappedReg), MappedReg); - XorConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), Value); + m_Assembler.XorConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), Value); } } } @@ -3437,38 +3450,38 @@ void CArmRecompilerOps::SPECIAL_XOR() Value = IsSigned(KnownReg) ? GetMipsRegLo_S(KnownReg) : GetMipsRegLo(KnownReg); } uint32_t dwValue = (uint32_t)(Value & 0xFFFFFFFF); - XorConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), dwValue); + m_Assembler.XorConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), dwValue); } else { ProtectGPR(KnownReg); if (m_Opcode.rd == KnownReg) { - ArmReg TempReg = Arm_Any; + CArmOps::ArmReg TempReg = CArmOps::Arm_Any; if (Is64Bit(KnownReg)) { - TempReg = Map_TempReg(Arm_Any, UnknownReg, true); - XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), TempReg); + TempReg = Map_TempReg(CArmOps::Arm_Any, UnknownReg, true); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), TempReg); m_RegWorkingSet.SetArmRegProtected(TempReg, false); } - XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), Map_TempReg(TempReg, UnknownReg, false)); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), Map_TempReg(TempReg, UnknownReg, false)); } else { Map_GPR_64bit(m_Opcode.rd, UnknownReg); - XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), Is32Bit(KnownReg) ? Map_TempReg(Arm_Any, KnownReg, true) : GetMipsRegMapHi(KnownReg)); - XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(KnownReg)); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), Is32Bit(KnownReg) ? Map_TempReg(CArmOps::Arm_Any, KnownReg, true) : GetMipsRegMapHi(KnownReg)); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(KnownReg)); } } } else { Map_GPR_64bit(m_Opcode.rd, m_Opcode.rs == m_Opcode.rd ? m_Opcode.rs : m_Opcode.rt); - ArmReg TempReg = Map_TempReg(Arm_Any, m_Opcode.rs == m_Opcode.rd ? m_Opcode.rt : m_Opcode.rs, true); - XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), TempReg); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs == m_Opcode.rd ? m_Opcode.rt : m_Opcode.rs, true); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), TempReg); m_RegWorkingSet.SetArmRegProtected(TempReg, false); Map_TempReg(TempReg, m_Opcode.rs == m_Opcode.rd ? m_Opcode.rt : m_Opcode.rs, false); - XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempReg); + m_Assembler.XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempReg); } } @@ -3543,15 +3556,15 @@ void CArmRecompilerOps::SPECIAL_SLT() { Map_GPR_32bit(m_Opcode.rd, false, -1); } - ArmReg TempResult = useRdReg ? Arm_Unknown : Map_TempReg(Arm_Any, -1, false); - CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); - IfBlock(ItMask_E, ArmBranch_LessThan); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempResult, (uint16_t)1); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempResult, (uint16_t)0); + CArmOps::ArmReg TempResult = useRdReg ? CArmOps::Arm_Unknown : Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.CompareArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + m_Assembler.IfBlock(CArmOps::ItMask_E, CArmOps::ArmBranch_LessThan); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempResult, (uint16_t)1); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempResult, (uint16_t)0); if (!useRdReg) { Map_GPR_32bit(m_Opcode.rd, false, -1); - AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempResult, 0); + m_Assembler.AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempResult, 0); m_RegWorkingSet.SetArmRegProtected(TempResult, false); } } @@ -3562,10 +3575,10 @@ void CArmRecompilerOps::SPECIAL_SLT() ProtectGPR(MappedReg); Map_GPR_32bit(m_Opcode.rd, false, -1); - CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); - IfBlock(ItMask_E, m_Opcode.rt == MappedReg ? ArmBranch_GreaterThan : ArmBranch_LessThan); - MoveConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), (uint16_t)1); - MoveConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), (uint16_t)0); + m_Assembler.CompareArmRegToConst(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + m_Assembler.IfBlock(CArmOps::ItMask_E, m_Opcode.rt == MappedReg ? CArmOps::ArmBranch_GreaterThan : CArmOps::ArmBranch_LessThan); + m_Assembler.MoveConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), (uint16_t)1); + m_Assembler.MoveConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), (uint16_t)0); } } else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) @@ -3584,76 +3597,76 @@ void CArmRecompilerOps::SPECIAL_SLT() { Map_GPR_32bit(m_Opcode.rd, false, -1); } - ArmReg UnknownArmReg = Map_TempReg(Arm_Any, UnknownReg, true); + CArmOps::ArmReg UnknownArmReg = Map_TempReg(CArmOps::Arm_Any, UnknownReg, true); if (IsConst(KnownReg)) { - CompareArmRegToConst(UnknownArmReg, Is32Bit(KnownReg) ? (IsSigned(KnownReg) ? (GetMipsRegLo_S(KnownReg) >> 31) : 0) : GetMipsRegHi(KnownReg)); + m_Assembler.CompareArmRegToConst(UnknownArmReg, Is32Bit(KnownReg) ? (IsSigned(KnownReg) ? (GetMipsRegLo_S(KnownReg) >> 31) : 0) : GetMipsRegHi(KnownReg)); } else { - CompareArmRegToArmReg(UnknownArmReg, Is32Bit(KnownReg) ? Map_TempReg(Arm_Any, KnownReg, true) : GetMipsRegMapHi(KnownReg)); + m_Assembler.CompareArmRegToArmReg(UnknownArmReg, Is32Bit(KnownReg) ? Map_TempReg(CArmOps::Arm_Any, KnownReg, true) : GetMipsRegMapHi(KnownReg)); } uint8_t * JumpLow = *g_RecompPos; - BranchLabel8(ArmBranch_Equal, "Low Compare"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Equal, "Low Compare"); - IfBlock(ItMask_E, KnownReg == m_Opcode.rt ? ArmBranch_LessThan : ArmBranch_GreaterThan); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : UnknownArmReg, (uint16_t)1); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : UnknownArmReg, (uint16_t)0); + m_Assembler.IfBlock(CArmOps::ItMask_E, KnownReg == m_Opcode.rt ? CArmOps::ArmBranch_LessThan : CArmOps::ArmBranch_GreaterThan); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : UnknownArmReg, (uint16_t)1); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : UnknownArmReg, (uint16_t)0); uint8_t * JumpContinue = *g_RecompPos; - BranchLabel8(ArmBranch_Always, "Continue"); + m_Assembler.BranchLabel8(CArmOps::CArmOps::ArmBranch_Always, "Continue"); - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(JumpLow, *g_RecompPos); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" Low Compare:"); + m_Assembler.SetJump8(JumpLow, *g_RecompPos); m_RegWorkingSet.SetArmRegProtected(UnknownArmReg, false); Map_TempReg(UnknownArmReg, UnknownReg, false); if (IsConst(KnownReg)) { - CompareArmRegToConst(UnknownArmReg, GetMipsRegLo(KnownReg)); + m_Assembler.CompareArmRegToConst(UnknownArmReg, GetMipsRegLo(KnownReg)); } else { - CompareArmRegToArmReg(UnknownArmReg, GetMipsRegMapLo(KnownReg)); + m_Assembler.CompareArmRegToArmReg(UnknownArmReg, GetMipsRegMapLo(KnownReg)); } - IfBlock(ItMask_E, KnownReg == m_Opcode.rt ? ArmBranch_LessThan : ArmBranch_GreaterThan); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : UnknownArmReg, (uint16_t)1); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : UnknownArmReg, (uint16_t)0); + m_Assembler.IfBlock(CArmOps::ItMask_E, KnownReg == m_Opcode.rt ? CArmOps::ArmBranch_LessThan : CArmOps::ArmBranch_GreaterThan); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : UnknownArmReg, (uint16_t)1); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : UnknownArmReg, (uint16_t)0); - CPU_Message(""); - CPU_Message(" continue:"); - SetJump8(JumpContinue, *g_RecompPos); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(JumpContinue, *g_RecompPos); if (!useRdReg) { Map_GPR_32bit(m_Opcode.rd, false, -1); - AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), UnknownArmReg, 0); + m_Assembler.AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), UnknownArmReg, 0); } } else { - ArmReg TempResult = useRdReg ? Arm_Unknown : Map_TempReg(Arm_Any, -1, false); + CArmOps::ArmReg TempResult = useRdReg ? CArmOps::Arm_Unknown : Map_TempReg(CArmOps::Arm_Any, -1, false); if (useRdReg) { Map_GPR_32bit(m_Opcode.rd, false, UnknownReg); } if (IsConst(KnownReg)) { - ArmReg UnknownArmReg = useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : Map_TempReg(Arm_Any, UnknownReg, false); - CompareArmRegToConst(UnknownArmReg, GetMipsRegLo(KnownReg)); - IfBlock(ItMask_E, KnownReg == m_Opcode.rt ? ArmBranch_LessThan : ArmBranch_GreaterThan); + CArmOps::ArmReg UnknownArmReg = useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : Map_TempReg(CArmOps::Arm_Any, UnknownReg, false); + m_Assembler.CompareArmRegToConst(UnknownArmReg, GetMipsRegLo(KnownReg)); + m_Assembler.IfBlock(CArmOps::ItMask_E, KnownReg == m_Opcode.rt ? CArmOps::ArmBranch_LessThan : CArmOps::ArmBranch_GreaterThan); } else { - ArmReg UnknownArmReg = useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : Map_TempReg(Arm_Any, UnknownReg, false); - CompareArmRegToArmReg(KnownReg == m_Opcode.rs ? GetMipsRegMapLo(KnownReg) : UnknownArmReg, KnownReg == m_Opcode.rs ? UnknownArmReg : GetMipsRegMapLo(KnownReg)); - IfBlock(ItMask_E, ArmBranch_LessThan); + CArmOps::ArmReg UnknownArmReg = useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : Map_TempReg(CArmOps::Arm_Any, UnknownReg, false); + m_Assembler.CompareArmRegToArmReg(KnownReg == m_Opcode.rs ? GetMipsRegMapLo(KnownReg) : UnknownArmReg, KnownReg == m_Opcode.rs ? UnknownArmReg : GetMipsRegMapLo(KnownReg)); + m_Assembler.IfBlock(CArmOps::ItMask_E, CArmOps::ArmBranch_LessThan); } - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempResult, (uint16_t)1); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempResult, (uint16_t)0); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempResult, (uint16_t)1); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempResult, (uint16_t)0); if (!useRdReg) { Map_GPR_32bit(m_Opcode.rd, false, -1); - AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempResult, 0); + m_Assembler.AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempResult, 0); m_RegWorkingSet.SetArmRegProtected(TempResult, false); } } @@ -3664,15 +3677,15 @@ void CArmRecompilerOps::SPECIAL_SLT() { Map_GPR_32bit(m_Opcode.rd, false, m_Opcode.rt); } - ArmReg TempReg = Map_TempReg(Arm_Any, m_Opcode.rs, false); - CompareArmRegToArmReg(TempReg, useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : Map_TempReg(Arm_Any, m_Opcode.rt, false)); - IfBlock(ItMask_E, ArmBranch_LessThan); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempReg, (uint16_t)1); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempReg, (uint16_t)0); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, false); + m_Assembler.CompareArmRegToArmReg(TempReg, useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, false)); + m_Assembler.IfBlock(CArmOps::ItMask_E, CArmOps::ArmBranch_LessThan); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempReg, (uint16_t)1); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempReg, (uint16_t)0); if (!useRdReg) { Map_GPR_32bit(m_Opcode.rd, false, -1); - AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempReg, 0); + m_Assembler.AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempReg, 0); } m_RegWorkingSet.SetArmRegProtected(TempReg, false); } @@ -3682,34 +3695,34 @@ void CArmRecompilerOps::SPECIAL_SLT() { Map_GPR_32bit(m_Opcode.rd, false, -1); } - ArmReg TempRegRt = Map_TempReg(Arm_Any, m_Opcode.rt, true); - ArmReg TempRegRs = Map_TempReg(Arm_Any, m_Opcode.rs, true); - CompareArmRegToArmReg(TempRegRs, TempRegRt); + CArmOps::ArmReg TempRegRt = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, true); + CArmOps::ArmReg TempRegRs = Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true); + m_Assembler.CompareArmRegToArmReg(TempRegRs, TempRegRt); uint8_t * JumpLow = *g_RecompPos; - BranchLabel8(ArmBranch_Equal, "Low Compare"); - IfBlock(ItMask_E, ArmBranch_LessThan); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)1); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)0); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Equal, "Low Compare"); + m_Assembler.IfBlock(CArmOps::ItMask_E, CArmOps::ArmBranch_LessThan); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)1); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)0); uint8_t * JumpContinue = *g_RecompPos; - BranchLabel8(ArmBranch_Always, "Continue"); - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(JumpLow, *g_RecompPos); + m_Assembler.BranchLabel8(CArmOps::CArmOps::ArmBranch_Always, "Continue"); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" Low Compare:"); + m_Assembler.SetJump8(JumpLow, *g_RecompPos); m_RegWorkingSet.SetArmRegProtected(TempRegRt, false); Map_TempReg(TempRegRt, m_Opcode.rt, false); m_RegWorkingSet.SetArmRegProtected(TempRegRs, false); Map_TempReg(TempRegRs, m_Opcode.rs, false); - CompareArmRegToArmReg(TempRegRs, TempRegRt); - IfBlock(ItMask_E, ArmBranch_LessThan); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)1); - MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)0); - CPU_Message(""); - CPU_Message(" continue:"); - SetJump8(JumpContinue, *g_RecompPos); + m_Assembler.CompareArmRegToArmReg(TempRegRs, TempRegRt); + m_Assembler.IfBlock(CArmOps::ItMask_E, CArmOps::ArmBranch_LessThan); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)1); + m_Assembler.MoveConstToArmReg(useRdReg ? GetMipsRegMapLo(m_Opcode.rd) : TempRegRt, (uint16_t)0); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(JumpContinue, *g_RecompPos); if (!useRdReg) { Map_GPR_32bit(m_Opcode.rd, false, -1); - AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempRegRt, 0); + m_Assembler.AddConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), TempRegRt, 0); } } } @@ -3977,13 +3990,13 @@ void CArmRecompilerOps::COP0_CO_TLBWR() UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_SystemTimer, "g_SystemTimer"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_SystemTimer, "g_SystemTimer"); CallFunction((void *)AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); - MoveConstToArmReg(Arm_R2, (uint32_t)true, "true"); - MoveVariableToArmReg(&g_Reg->RANDOM_REGISTER, "RANDOM_REGISTER", Arm_R1); - AndConstToArmReg(Arm_R1, Arm_R1, 0x1F); - MoveConstToArmReg(Arm_R0, (uint32_t)g_TLB, "g_TLB"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t)true, "true"); + m_Assembler.MoveVariableToArmReg(&g_Reg->RANDOM_REGISTER, "RANDOM_REGISTER", CArmOps::Arm_R1); + m_Assembler.AndConstToArmReg(CArmOps::Arm_R1, CArmOps::Arm_R1, 0x1F); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_TLB, "g_TLB"); CallFunction((void *)AddressOf(&CTLB::WriteEntry), "CTLB::WriteEntry"); m_RegWorkingSet.AfterCallDirect(); } @@ -4157,15 +4170,15 @@ void CArmRecompilerOps::COP1_S_MUL() { CompileCop1Test(); FixRoundModel(CRegInfo::RoundDefault); - ArmReg FprReg = Map_Variable(CArmRegInfo::VARIABLE_FPR); - ArmReg TempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - LoadArmRegPointerToArmReg(TempReg, FprReg, (uint8_t)(m_Opcode.fs << 2)); - LoadArmRegPointerToFloatReg(TempReg, Arm_S14, 0); - LoadArmRegPointerToArmReg(TempReg, FprReg, (uint8_t)(m_Opcode.ft << 2)); - LoadArmRegPointerToFloatReg(TempReg, Arm_S15, 0); - MulF32(Arm_S0, Arm_S14, Arm_S15); - LoadArmRegPointerToArmReg(TempReg, FprReg, (uint8_t)(m_Opcode.fd << 2)); - StoreFloatRegToArmRegPointer(Arm_S0, TempReg, 0); + CArmOps::ArmReg FprReg = Map_Variable(CArmRegInfo::VARIABLE_FPR); + CArmOps::ArmReg TempReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, FprReg, (uint8_t)(m_Opcode.fs << 2)); + LoadArmRegPointerToFloatReg(TempReg, CArmOps::Arm_S14, 0); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, FprReg, (uint8_t)(m_Opcode.ft << 2)); + LoadArmRegPointerToFloatReg(TempReg, CArmOps::Arm_S15, 0); + MulF32(CArmOps::Arm_S0, CArmOps::Arm_S14, CArmOps::Arm_S15); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, FprReg, (uint8_t)(m_Opcode.fd << 2)); + StoreFloatRegToArmRegPointer(CArmOps::Arm_S0, TempReg, 0); } void CArmRecompilerOps::COP1_S_DIV() @@ -4706,14 +4719,14 @@ void CArmRecompilerOps::UnknownOpcode() m_RegWorkingSet.WriteBackRegisters(); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); - MoveConstToVariable(m_CompilePC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + m_Assembler.MoveConstToVariable(m_CompilePC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); if (g_SyncSystem) { - MoveConstToArmReg(Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); CallFunction(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } - MoveConstToVariable(m_Opcode.Value, &R4300iOp::m_Opcode.Value, "R4300iOp::m_Opcode.Value"); + m_Assembler.MoveConstToVariable(m_Opcode.Value, &R4300iOp::m_Opcode.Value, "R4300iOp::m_Opcode.Value"); CallFunction((void *)R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); ExitCodeBlock(); if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } @@ -4728,7 +4741,7 @@ void CArmRecompilerOps::ExitCodeBlock() { if (g_SyncSystem) { - MoveConstToArmReg(Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); CallFunction(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } PopArmReg(ArmPushPop_R2 | ArmPushPop_R3 | ArmPushPop_R4 | ArmPushPop_R5 | ArmPushPop_R6 | ArmPushPop_R7 | ArmPushPop_R8 | ArmPushPop_R9 | ArmPushPop_R10 | ArmPushPop_R11 | ArmPushPop_R12 | ArmPushPop_PC); @@ -4738,8 +4751,8 @@ void CArmRecompilerOps::CompileExitCode() { for (EXIT_LIST::iterator ExitIter = m_ExitInfo.begin(); ExitIter != m_ExitInfo.end(); ExitIter++) { - CPU_Message(""); - CPU_Message(" $Exit_%d", ExitIter->ID); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" $Exit_%d", ExitIter->ID); SetJump20(ExitIter->JumpLoc, (uint32_t *)*g_RecompPos); m_PipelineStage = ExitIter->PipelineStage; CompileExit((uint32_t)-1, ExitIter->TargetPC, ExitIter->ExitRegSet, ExitIter->reason); @@ -4751,31 +4764,31 @@ void CArmRecompilerOps::CompileCop1Test() if (m_RegWorkingSet.GetFpuBeenUsed()) return; - ArmReg TempReg1 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveVariableToArmReg(&g_Reg->STATUS_REGISTER, "STATUS_REGISTER", TempReg1); - MoveConstToArmReg(TempReg2, STATUS_CU1, "STATUS_CU1"); - AndArmRegToArmReg(TempReg1, TempReg1, TempReg2); - CompareArmRegToConst(TempReg1, 0); + CArmOps::ArmReg TempReg1 = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + CArmOps::ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveVariableToArmReg(&g_Reg->STATUS_REGISTER, "STATUS_REGISTER", TempReg1); + m_Assembler.MoveConstToArmReg(TempReg2, STATUS_CU1, "STATUS_CU1"); + m_Assembler.AndArmRegToArmReg(TempReg1, TempReg1, TempReg2); + m_Assembler.CompareArmRegToConst(TempReg1, 0); m_RegWorkingSet.SetArmRegProtected(TempReg1, false); m_RegWorkingSet.SetArmRegProtected(TempReg2, false); - CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, ExitReason_COP1Unuseable, ArmBranch_Equal); + CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, ExitReason_COP1Unuseable, CArmOps::ArmBranch_Equal); m_RegWorkingSet.SetFpuBeenUsed(true); } void CArmRecompilerOps::CompileInPermLoop(CRegInfo & RegSet, uint32_t ProgramCounter) { - MoveConstToVariable(ProgramCounter, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + m_Assembler.MoveConstToVariable(ProgramCounter, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); RegSet.WriteBackRegisters(); UpdateCounters(RegSet, false, true); CallFunction(AddressOf(CInterpreterCPU::InPermLoop), "CInterpreterCPU::InPermLoop"); - MoveConstToArmReg(Arm_R0, (uint32_t)g_SystemTimer); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_SystemTimer); CallFunction(AddressOf(&CSystemTimer::TimerDone), "CSystemTimer::TimerDone"); - CPU_Message("CompileSystemCheck 3"); + m_CodeBlock.Log("CompileSystemCheck 3"); CompileSystemCheck((uint32_t)-1, RegSet); if (g_SyncSystem) { - MoveConstToArmReg(Arm_R0, (uint32_t)g_BaseSystem); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_BaseSystem); CallFunction(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } } @@ -4808,7 +4821,7 @@ void CArmRecompilerOps::OutputRegisterState(const CRegInfo & SyncTo, const CRegI { stdstr synctoreg, currentreg; - if (SyncTo.GetArmRegMapped((ArmReg)i) == CArmRegInfo::GPR_Mapped) + if (SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::GPR_Mapped) { for (uint32_t count = 1; count < 32; count++) { @@ -4817,12 +4830,12 @@ void CArmRecompilerOps::OutputRegisterState(const CRegInfo & SyncTo, const CRegI continue; } - if (SyncTo.Is64Bit(count) && SyncTo.GetMipsRegMapHi(count) == (ArmReg)i) + if (SyncTo.Is64Bit(count) && SyncTo.GetMipsRegMapHi(count) == (CArmOps::ArmReg)i) { synctoreg = CRegName::GPR_Hi[count]; break; } - if (SyncTo.GetMipsRegMapLo(count) == (ArmReg)i) + if (SyncTo.GetMipsRegMapLo(count) == (CArmOps::ArmReg)i) { synctoreg = CRegName::GPR_Lo[count]; break; @@ -4830,7 +4843,7 @@ void CArmRecompilerOps::OutputRegisterState(const CRegInfo & SyncTo, const CRegI } } - if (CurrentSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::GPR_Mapped) + if (CurrentSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::GPR_Mapped) { for (uint32_t count = 1; count < 32; count++) { @@ -4839,12 +4852,12 @@ void CArmRecompilerOps::OutputRegisterState(const CRegInfo & SyncTo, const CRegI continue; } - if (CurrentSet.Is64Bit(count) && CurrentSet.GetMipsRegMapHi(count) == (ArmReg)i) + if (CurrentSet.Is64Bit(count) && CurrentSet.GetMipsRegMapHi(count) == (CArmOps::ArmReg)i) { currentreg = CRegName::GPR_Hi[count]; break; } - if (CurrentSet.GetMipsRegMapLo(count) == (ArmReg)i) + if (CurrentSet.GetMipsRegMapLo(count) == (CArmOps::ArmReg)i) { currentreg = CRegName::GPR_Lo[count]; break; @@ -4852,14 +4865,14 @@ void CArmRecompilerOps::OutputRegisterState(const CRegInfo & SyncTo, const CRegI } } - CPU_Message("SyncTo.GetArmRegMapped(%s) = %X%s%s CurrentSet.GetArmRegMapped(%s) = %X%s%s", - ArmRegName((ArmReg)i), - SyncTo.GetArmRegMapped((ArmReg)i), - SyncTo.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(SyncTo.GetVariableMappedTo((ArmReg)i))).c_str() : "", + m_CodeBlock.Log("SyncTo.GetArmRegMapped(%s) = %X%s%s CurrentSet.GetArmRegMapped(%s) = %X%s%s", + ArmRegName((CArmOps::ArmReg)i), + SyncTo.GetArmRegMapped((CArmOps::ArmReg)i), + SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(SyncTo.GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "", synctoreg.length() > 0 ? stdstr_f(" (%s)", synctoreg.c_str()).c_str() : "", - ArmRegName((ArmReg)i), - CurrentSet.GetArmRegMapped((ArmReg)i), - CurrentSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(CurrentSet.GetVariableMappedTo((ArmReg)i))).c_str() : "", + ArmRegName((CArmOps::ArmReg)i), + CurrentSet.GetArmRegMapped((CArmOps::ArmReg)i), + CurrentSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(CurrentSet.GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "", currentreg.length() > 0 ? stdstr_f(" (%s)", currentreg.c_str()).c_str() : "" ); } @@ -4875,34 +4888,34 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) #endif if (m_RegWorkingSet.GetRoundingModel() != SyncTo.GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } - CPU_Message("Before:"); + m_CodeBlock.Log("Before:"); OutputRegisterState(SyncTo, m_RegWorkingSet); for (uint32_t i = 0; i < 16; i++) { - if (SyncTo.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped && - m_RegWorkingSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped && - SyncTo.GetVariableMappedTo((ArmReg)i) == m_RegWorkingSet.GetVariableMappedTo((ArmReg)i)) + if (SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped && + m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped && + SyncTo.GetVariableMappedTo((CArmOps::ArmReg)i) == m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)i)) { continue; } - if (SyncTo.GetArmRegMapped((ArmReg)i) == CArmRegInfo::NotMapped || - SyncTo.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Temp_Mapped) + if (SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::NotMapped || + SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Temp_Mapped) { - m_RegWorkingSet.UnMap_ArmReg((ArmReg)i); + m_RegWorkingSet.UnMap_ArmReg((CArmOps::ArmReg)i); continue; } - if (SyncTo.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped) + if (SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped) { - if (m_RegWorkingSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::GPR_Mapped) + if (m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::GPR_Mapped) { bool moved_gpr_mapping = false; // See if mapped, if so move it for (uint32_t z = 0; z < 16; z++) { - if (SyncTo.GetArmRegMapped((ArmReg)z) != CArmRegInfo::GPR_Mapped) + if (SyncTo.GetArmRegMapped((CArmOps::ArmReg)z) != CArmRegInfo::GPR_Mapped) { continue; } @@ -4913,76 +4926,76 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) continue; } - if (SyncTo.Is64Bit(count) && SyncTo.GetMipsRegMapHi(count) == (ArmReg)i) + if (SyncTo.Is64Bit(count) && SyncTo.GetMipsRegMapHi(count) == (CArmOps::ArmReg)i) { - CPU_Message(" regcache: move %s to %s", ArmRegName((ArmReg)i), ArmRegName((ArmReg)z)); + m_CodeBlock.Log(" regcache: move %s to %s", ArmRegName((CArmOps::ArmReg)i), ArmRegName((CArmOps::ArmReg)z)); g_Notify->BreakPoint(__FILE__, __LINE__); } - if (SyncTo.GetMipsRegMapLo(count) == (ArmReg)i) + if (SyncTo.GetMipsRegMapLo(count) == (CArmOps::ArmReg)i) { - CPU_Message(" regcache: move %s to %s", ArmRegName((ArmReg)i), ArmRegName((ArmReg)z)); + m_CodeBlock.Log(" regcache: move %s to %s", ArmRegName((CArmOps::ArmReg)i), ArmRegName((CArmOps::ArmReg)z)); g_Notify->BreakPoint(__FILE__, __LINE__); } } } if (!moved_gpr_mapping) { - m_RegWorkingSet.UnMap_ArmReg((ArmReg)i); + m_RegWorkingSet.UnMap_ArmReg((CArmOps::ArmReg)i); } } bool moved = false; // See if mapped, if so move it for (uint32_t z = i + 1; z < 16; z++) { - if (m_RegWorkingSet.GetArmRegMapped((ArmReg)z) == CArmRegInfo::Variable_Mapped && - m_RegWorkingSet.GetVariableMappedTo((ArmReg)z) == SyncTo.GetVariableMappedTo((ArmReg)i)) + if (m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)z) == CArmRegInfo::Variable_Mapped && + m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)z) == SyncTo.GetVariableMappedTo((CArmOps::ArmReg)i)) { - m_RegWorkingSet.UnMap_ArmReg((ArmReg)i); + m_RegWorkingSet.UnMap_ArmReg((CArmOps::ArmReg)i); - CPU_Message(" regcache: move %s to %s for variable mapping (%s)", ArmRegName((ArmReg)z), ArmRegName((ArmReg)i), CArmRegInfo::VariableMapName(m_RegWorkingSet.GetVariableMappedTo((ArmReg)z))); - AddConstToArmReg((ArmReg)i, (ArmReg)z, 0); - m_RegWorkingSet.SetArmRegMapped((ArmReg)i, m_RegWorkingSet.GetArmRegMapped((ArmReg)z)); - m_RegWorkingSet.SetVariableMappedTo((ArmReg)i, m_RegWorkingSet.GetVariableMappedTo((ArmReg)z)); - m_RegWorkingSet.SetArmRegMapped((ArmReg)z, CArmRegInfo::NotMapped); - m_RegWorkingSet.SetVariableMappedTo((ArmReg)z, CArmRegInfo::VARIABLE_UNKNOWN); + m_CodeBlock.Log(" regcache: move %s to %s for variable mapping (%s)", ArmRegName((CArmOps::ArmReg)z), ArmRegName((CArmOps::ArmReg)i), CArmRegInfo::VariableMapName(m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)z))); + m_Assembler.AddConstToArmReg((CArmOps::ArmReg)i, (CArmOps::ArmReg)z, 0); + m_RegWorkingSet.SetArmRegMapped((CArmOps::ArmReg)i, m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)z)); + m_RegWorkingSet.SetVariableMappedTo((CArmOps::ArmReg)i, m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)z)); + m_RegWorkingSet.SetArmRegMapped((CArmOps::ArmReg)z, CArmRegInfo::NotMapped); + m_RegWorkingSet.SetVariableMappedTo((CArmOps::ArmReg)z, CArmRegInfo::VARIABLE_UNKNOWN); moved = true; } } if (!moved) { - Map_Variable(SyncTo.GetVariableMappedTo((ArmReg)i), (ArmReg)i); + Map_Variable(SyncTo.GetVariableMappedTo((CArmOps::ArmReg)i), (CArmOps::ArmReg)i); } } - if (m_RegWorkingSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped && - m_RegWorkingSet.GetVariableMappedTo((ArmReg)i) != SyncTo.GetVariableMappedTo((ArmReg)i)) + if (m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped && + m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)i) != SyncTo.GetVariableMappedTo((CArmOps::ArmReg)i)) { // See if mapped, if so move it for (uint32_t z = i + 1; z < 16; z++) { - if (SyncTo.GetArmRegMapped((ArmReg)z) != CArmRegInfo::Variable_Mapped || - SyncTo.GetVariableMappedTo((ArmReg)z) != m_RegWorkingSet.GetVariableMappedTo((ArmReg)i)) + if (SyncTo.GetArmRegMapped((CArmOps::ArmReg)z) != CArmRegInfo::Variable_Mapped || + SyncTo.GetVariableMappedTo((CArmOps::ArmReg)z) != m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)i)) { continue; } - m_RegWorkingSet.UnMap_ArmReg((ArmReg)z); + m_RegWorkingSet.UnMap_ArmReg((CArmOps::ArmReg)z); - CPU_Message(" regcache: move %s to %s for variable mapping (%s)", ArmRegName((ArmReg)i), ArmRegName((ArmReg)z), CArmRegInfo::VariableMapName(m_RegWorkingSet.GetVariableMappedTo((ArmReg)i))); - AddConstToArmReg((ArmReg)z, (ArmReg)i, 0); - m_RegWorkingSet.SetArmRegMapped((ArmReg)z, m_RegWorkingSet.GetArmRegMapped((ArmReg)i)); - m_RegWorkingSet.SetVariableMappedTo((ArmReg)z, m_RegWorkingSet.GetVariableMappedTo((ArmReg)i)); - m_RegWorkingSet.SetArmRegMapped((ArmReg)i, CArmRegInfo::NotMapped); - m_RegWorkingSet.SetVariableMappedTo((ArmReg)i, CArmRegInfo::VARIABLE_UNKNOWN); + m_CodeBlock.Log(" regcache: move %s to %s for variable mapping (%s)", ArmRegName((CArmOps::ArmReg)i), ArmRegName((CArmOps::ArmReg)z), CArmRegInfo::VariableMapName(m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)i))); + m_Assembler.AddConstToArmReg((CArmOps::ArmReg)z, (CArmOps::ArmReg)i, 0); + m_RegWorkingSet.SetArmRegMapped((CArmOps::ArmReg)z, m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)i)); + m_RegWorkingSet.SetVariableMappedTo((CArmOps::ArmReg)z, m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)i)); + m_RegWorkingSet.SetArmRegMapped((CArmOps::ArmReg)i, CArmRegInfo::NotMapped); + m_RegWorkingSet.SetVariableMappedTo((CArmOps::ArmReg)i, CArmRegInfo::VARIABLE_UNKNOWN); break; } - m_RegWorkingSet.UnMap_ArmReg((ArmReg)i); + m_RegWorkingSet.UnMap_ArmReg((CArmOps::ArmReg)i); } - if (m_RegWorkingSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped && - m_RegWorkingSet.GetVariableMappedTo((ArmReg)i) != CArmRegInfo::VARIABLE_GPR && - SyncTo.GetArmRegMapped((ArmReg)i) != CArmRegInfo::Variable_Mapped) + if (m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped && + m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)i) != CArmRegInfo::VARIABLE_GPR && + SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) != CArmRegInfo::Variable_Mapped) { - m_RegWorkingSet.UnMap_ArmReg((ArmReg)i); + m_RegWorkingSet.UnMap_ArmReg((CArmOps::ArmReg)i); } } @@ -4990,7 +5003,7 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) x86Reg MemStackReg = Get_MemoryStack(); x86Reg TargetStackReg = SyncTo.Get_MemoryStack(); - //CPU_Message("MemoryStack for Original State = %s",MemStackReg > 0?x86_Name(MemStackReg):"Not Mapped"); + //m_CodeBlock.Log("MemoryStack for Original State = %s",MemStackReg > 0?x86_Name(MemStackReg):"Not Mapped"); if (MemStackReg != TargetStackReg) { if (TargetStackReg == x86_Unknown) @@ -5000,14 +5013,14 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) else if (MemStackReg == x86_Unknown) { UnMap_X86reg(TargetStackReg); - CPU_Message(" regcache: allocate %s as memory stack", x86_Name(TargetStackReg)); + m_CodeBlock.Log(" regcache: allocate %s as memory stack", x86_Name(TargetStackReg)); m_RegWorkingSet.SetX86Mapped(TargetStackReg, CRegInfo::Stack_Mapped); MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(), "MemoryStack", TargetStackReg); } else { UnMap_X86reg(TargetStackReg); - CPU_Message(" regcache: change allocation of memory stack from %s to %s", x86_Name(MemStackReg), x86_Name(TargetStackReg)); + m_CodeBlock.Log(" regcache: change allocation of memory stack from %s to %s", x86_Name(MemStackReg), x86_Name(TargetStackReg)); m_RegWorkingSet.SetX86Mapped(TargetStackReg, CRegInfo::Stack_Mapped); m_RegWorkingSet.SetX86Mapped(MemStackReg, CRegInfo::NotMapped); MoveX86RegToX86Reg(MemStackReg, TargetStackReg); @@ -5017,9 +5030,9 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) for (uint32_t i = 1; i < 32; i++) { - CPU_Message("SyncTo.GetMipsRegState(%d: %s) = %X GetMipsRegState(%d: %s) = %X", i, CRegName::GPR[i], SyncTo.GetMipsRegState(i), i, CRegName::GPR[i], GetMipsRegState(i)); - if (IsMapped(i) && Is64Bit(i)) { CPU_Message("GetMipsRegMapHi(%d: %s) = %X", i, CRegName::GPR[i], GetMipsRegMapHi(i)); } - if (IsMapped(i)) { CPU_Message("GetMipsRegMapLo(%d: %s) = %X", i, CRegName::GPR[i], GetMipsRegMapLo(i)); } + m_CodeBlock.Log("SyncTo.GetMipsRegState(%d: %s) = %X GetMipsRegState(%d: %s) = %X", i, CRegName::GPR[i], SyncTo.GetMipsRegState(i), i, CRegName::GPR[i], GetMipsRegState(i)); + if (IsMapped(i) && Is64Bit(i)) { m_CodeBlock.Log("GetMipsRegMapHi(%d: %s) = %X", i, CRegName::GPR[i], GetMipsRegMapHi(i)); } + if (IsMapped(i)) { m_CodeBlock.Log("GetMipsRegMapLo(%d: %s) = %X", i, CRegName::GPR[i], GetMipsRegMapLo(i)); } if (GetMipsRegState(i) == SyncTo.GetMipsRegState(i) || (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN) || @@ -5050,18 +5063,18 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) case CRegInfo::STATE_CONST_32_SIGN: if (GetMipsRegLo(i) != SyncTo.GetMipsRegLo(i)) { - CPU_Message("Value of constant is different register %d (%s) Value: 0x%08X to 0x%08X", i, CRegName::GPR[i], GetMipsRegLo(i), SyncTo.GetMipsRegLo(i)); + m_CodeBlock.Log("Value of constant is different register %d (%s) Value: 0x%08X to 0x%08X", i, CRegName::GPR[i], GetMipsRegLo(i), SyncTo.GetMipsRegLo(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } continue; default: - CPU_Message("Unhandled register state %d\nin SyncRegState", GetMipsRegState(i)); + m_CodeBlock.Log("Unhandled register state %d\nin SyncRegState", GetMipsRegState(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } } changed = true; - ArmReg Reg = Arm_Unknown, RegHi = Arm_Unknown, GprReg = Arm_Unknown; + CArmOps::ArmReg Reg = CArmOps::Arm_Unknown, RegHi = CArmOps::Arm_Unknown, GprReg = CArmOps::Arm_Unknown; switch (SyncTo.GetMipsRegState(i)) { case CRegInfo::STATE_UNKNOWN: UnMap_GPR(i, true); break; @@ -5074,31 +5087,31 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) { case CRegInfo::STATE_UNKNOWN: GprReg = m_RegWorkingSet.GetVariableReg(CArmRegInfo::VARIABLE_GPR); - if (GprReg == Arm_Unknown) + if (GprReg == CArmOps::Arm_Unknown) { - MoveVariableToArmReg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); - MoveVariableToArmReg(&_GPR[i].UW[1], CRegName::GPR_Hi[i], RegHi); + m_Assembler.MoveVariableToArmReg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); + m_Assembler.MoveVariableToArmReg(&_GPR[i].UW[1], CRegName::GPR_Hi[i], RegHi); } else { - LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(i << 3), CRegName::GPR_Lo[i]); - LoadArmRegPointerToArmReg(RegHi, GprReg, (uint8_t)(i << 3) + 4, CRegName::GPR_Hi[i]); + m_Assembler.LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(i << 3), CRegName::GPR_Lo[i]); + m_Assembler.LoadArmRegPointerToArmReg(RegHi, GprReg, (uint8_t)(i << 3) + 4, CRegName::GPR_Hi[i]); } break; case CRegInfo::STATE_MAPPED_64: - AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); + m_Assembler.AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); m_RegWorkingSet.SetArmRegMapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); - AddConstToArmReg(RegHi, GetMipsRegMapHi(i), 0); + m_Assembler.AddConstToArmReg(RegHi, GetMipsRegMapHi(i), 0); m_RegWorkingSet.SetArmRegMapped(GetMipsRegMapHi(i), CRegInfo::NotMapped); break; case CRegInfo::STATE_MAPPED_32_SIGN: ShiftRightSignImmed(RegHi, GetMipsRegMapLo(i), 31); - AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); + m_Assembler.AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); m_RegWorkingSet.SetArmRegMapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); break; case CRegInfo::STATE_MAPPED_32_ZERO: - MoveConstToArmReg(RegHi, (uint32_t)0); - AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); + m_Assembler.MoveConstToArmReg(RegHi, (uint32_t)0); + m_Assembler.AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); m_RegWorkingSet.SetArmRegMapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); break; #ifdef tofix @@ -5108,11 +5121,11 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) break; #endif case CRegInfo::STATE_CONST_32_SIGN: - MoveConstToArmReg(RegHi, (uint32_t)(GetMipsRegLo_S(i) >> 31)); - MoveConstToArmReg(Reg, (uint32_t)(GetMipsRegLo(i))); + m_Assembler.MoveConstToArmReg(RegHi, (uint32_t)(GetMipsRegLo_S(i) >> 31)); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(GetMipsRegLo(i))); break; default: - CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_64\n%d", GetMipsRegState(i)); + m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_64\n%d", GetMipsRegState(i)); g_Notify->BreakPoint(__FILE__, __LINE__); continue; } @@ -5133,23 +5146,23 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) { case CRegInfo::STATE_UNKNOWN: GprReg = m_RegWorkingSet.GetVariableReg(CArmRegInfo::VARIABLE_GPR); - if (GprReg == Arm_Unknown) + if (GprReg == CArmOps::Arm_Unknown) { - MoveVariableToArmReg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); + m_Assembler.MoveVariableToArmReg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); } else { - LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(i << 3), CRegName::GPR_Lo[i]); + m_Assembler.LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(i << 3), CRegName::GPR_Lo[i]); } break; case CRegInfo::STATE_CONST_32_SIGN: - MoveConstToArmReg(Reg, GetMipsRegLo(i)); + m_Assembler.MoveConstToArmReg(Reg, GetMipsRegLo(i)); break; case CRegInfo::STATE_MAPPED_32_SIGN: case CRegInfo::STATE_MAPPED_32_ZERO: if (GetMipsRegMapLo(i) != Reg) { - AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); + m_Assembler.AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); m_RegWorkingSet.SetArmRegMapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); } break; @@ -5162,12 +5175,12 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) #endif break; case CRegInfo::STATE_CONST_64: - CPU_Message("hi %X\nLo %X", GetMipsRegHi(i), GetMipsRegLo(i)); - CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d", GetMipsRegState(i)); + m_CodeBlock.Log("hi %X\nLo %X", GetMipsRegHi(i), GetMipsRegLo(i)); + m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d", GetMipsRegState(i)); g_Notify->BreakPoint(__FILE__, __LINE__); break; default: - CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d", GetMipsRegState(i)); + m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d", GetMipsRegState(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } m_RegWorkingSet.SetMipsRegMapLo(i, Reg); @@ -5184,35 +5197,35 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) case CRegInfo::STATE_MAPPED_64: case CRegInfo::STATE_UNKNOWN: GprReg = m_RegWorkingSet.GetVariableReg(CArmRegInfo::VARIABLE_GPR); - LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(i << 3), CRegName::GPR_Lo[i]); + m_Assembler.LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(i << 3), CRegName::GPR_Lo[i]); break; case CRegInfo::STATE_MAPPED_32_ZERO: - AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); + m_Assembler.AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); m_RegWorkingSet.SetArmRegMapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); break; case CRegInfo::STATE_MAPPED_32_SIGN: if (g_System->b32BitCore()) { - AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); + m_Assembler.AddConstToArmReg(Reg, GetMipsRegMapLo(i), 0); m_RegWorkingSet.SetArmRegMapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); } else { - CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i)); + m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } break; case CRegInfo::STATE_CONST_32_SIGN: if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0) { - CPU_Message("Sign problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); - CPU_Message("%s: %X", CRegName::GPR[i], GetMipsRegLo_S(i)); + m_CodeBlock.Log("Sign problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); + m_CodeBlock.Log("%s: %X", CRegName::GPR[i], GetMipsRegLo_S(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } - MoveConstToArmReg(Reg, GetMipsRegLo(i)); + m_Assembler.MoveConstToArmReg(Reg, GetMipsRegLo(i)); break; default: - CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i)); + m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } m_RegWorkingSet.SetMipsRegMapLo(i, Reg); @@ -5222,7 +5235,7 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) m_RegWorkingSet.SetArmRegProtected(Reg, true); break; default: - CPU_Message("%d - %d reg: %s (%d)", SyncTo.GetMipsRegState(i), GetMipsRegState(i), CRegName::GPR[i], i); + m_CodeBlock.Log("%d - %d reg: %s (%d)", SyncTo.GetMipsRegState(i), GetMipsRegState(i), CRegName::GPR[i], i); g_Notify->BreakPoint(__FILE__, __LINE__); changed = false; } @@ -5230,24 +5243,24 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) for (uint32_t i = 0; i < 16; i++) { - if (m_RegWorkingSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped && - m_RegWorkingSet.GetVariableMappedTo((ArmReg)i) == CArmRegInfo::VARIABLE_GPR && - SyncTo.GetArmRegMapped((ArmReg)i) != CArmRegInfo::Variable_Mapped) + if (m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped && + m_RegWorkingSet.GetVariableMappedTo((CArmOps::ArmReg)i) == CArmRegInfo::VARIABLE_GPR && + SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) != CArmRegInfo::Variable_Mapped) { - m_RegWorkingSet.UnMap_ArmReg((ArmReg)i); + m_RegWorkingSet.UnMap_ArmReg((CArmOps::ArmReg)i); } - if (m_RegWorkingSet.GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped && SyncTo.GetArmRegMapped((ArmReg)i) != CArmRegInfo::Variable_Mapped) + if (m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped && SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) != CArmRegInfo::Variable_Mapped) { - CPU_Message("Invalid SyncTo.GetArmRegMapped(%s) = %X m_RegWorkingSet.GetArmRegMapped(%s) = %X", ArmRegName((ArmReg)i), SyncTo.GetArmRegMapped((ArmReg)i), ArmRegName((ArmReg)i), m_RegWorkingSet.GetArmRegMapped((ArmReg)i)); + m_CodeBlock.Log("Invalid SyncTo.GetArmRegMapped(%s) = %X m_RegWorkingSet.GetArmRegMapped(%s) = %X", ArmRegName((CArmOps::ArmReg)i), SyncTo.GetArmRegMapped((CArmOps::ArmReg)i), ArmRegName((CArmOps::ArmReg)i), m_RegWorkingSet.GetArmRegMapped((CArmOps::ArmReg)i)); g_Notify->BreakPoint(__FILE__, __LINE__); } } - CPU_Message("after:"); + m_CodeBlock.Log("after:"); OutputRegisterState(SyncTo, m_RegWorkingSet); for (int32_t i = 0; i < 16; i++) { - m_RegWorkingSet.SetArmRegProtected((ArmReg)i, false); + m_RegWorkingSet.SetArmRegProtected((CArmOps::ArmReg)i, false); } } @@ -5256,16 +5269,16 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo m_RegWorkingSet = ExitRegSet; for (int32_t i = 0; i < 16; i++) { - m_RegWorkingSet.SetArmRegProtected((ArmReg)i, false); + m_RegWorkingSet.SetArmRegProtected((CArmOps::ArmReg)i, false); } m_RegWorkingSet.WriteBackRegisters(); ExitRegSet = m_RegWorkingSet; if (TargetPC != (uint32_t)-1) { - MoveConstToArmReg(Arm_R1, TargetPC); - MoveConstToArmReg(Arm_R2, (uint32_t)&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); - StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, TargetPC); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t)&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R1, CArmOps::Arm_R2, 0); UpdateCounters(ExitRegSet, TargetPC <= JumpPC && JumpPC != -1, reason == ExitReason_Normal); } @@ -5284,7 +5297,7 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo { if (TargetPC <= JumpPC && reason == ExitReason_Normal) { - CPU_Message("CompileSystemCheck 1"); + m_CodeBlock.Log("CompileSystemCheck 1"); CompileSystemCheck((uint32_t)-1, ExitRegSet); } } @@ -5292,7 +5305,7 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo { if (reason == ExitReason_Normal) { - CPU_Message("CompileSystemCheck 2"); + m_CodeBlock.Log("CompileSystemCheck 2"); CompileSystemCheck((uint32_t)-1, ExitRegSet); } } @@ -5300,24 +5313,24 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo break; case ExitReason_DoSysCall: bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; - MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg); CallFunction(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException"); ExitCodeBlock(); break; case ExitReason_COP1Unuseable: bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; - MoveConstToArmReg(Arm_R2, (uint32_t)1, "1"); - MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t)1, "1"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg); CallFunction(AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException"); ExitCodeBlock(); break; case ExitReason_TLBReadMiss: bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; - MoveVariableToArmReg(g_TLBLoadAddress, "g_TLBLoadAddress", Arm_R2); - MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg); + m_Assembler.MoveVariableToArmReg(g_TLBLoadAddress, "g_TLBLoadAddress", CArmOps::Arm_R2); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg); CallFunction(AddressOf(&CRegisters::DoTLBReadMiss), "CRegisters::DoTLBReadMiss"); ExitCodeBlock(); break; @@ -5332,7 +5345,7 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason, CArmOps::ArmCompareType CompareType) { - BranchLabel20(CompareType, stdstr_f("Exit_%d", m_ExitInfo.size()).c_str()); + m_Assembler.BranchLabel20(CompareType, stdstr_f("Exit_%d", m_ExitInfo.size()).c_str()); CExitInfo ExitInfo; ExitInfo.ID = m_ExitInfo.size(); @@ -5349,50 +5362,50 @@ void CArmRecompilerOps::CompileSystemCheck(uint32_t TargetPC, const CRegInfo & R CRegInfo OriginalWorkingRegSet = GetRegWorkingSet(); SetRegWorkingSet(RegSet); - ArmReg TempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveVariableToArmReg((void *)&g_SystemEvents->DoSomething(), "g_SystemEvents->DoSomething()", TempReg); - CompareArmRegToConst(TempReg, 0); + CArmOps::ArmReg TempReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveVariableToArmReg((void *)&g_SystemEvents->DoSomething(), "g_SystemEvents->DoSomething()", TempReg); + m_Assembler.CompareArmRegToConst(TempReg, 0); m_RegWorkingSet.SetArmRegProtected(TempReg, false); - BranchLabel20(ArmBranch_Equal, "Continue_From_Interrupt_Test"); + m_Assembler.BranchLabel20(CArmOps::ArmBranch_Equal, "Continue_From_Interrupt_Test"); uint32_t * Jump = (uint32_t *)(*g_RecompPos - 4); if (TargetPC != (uint32_t)-1) { - MoveConstToVariable(TargetPC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + m_Assembler.MoveConstToVariable(TargetPC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); } m_RegWorkingSet.WriteBackRegisters(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_SystemEvents, "g_SystemEvents"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_SystemEvents, "g_SystemEvents"); CallFunction(AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents"); ExitCodeBlock(); - CPU_Message(""); - CPU_Message(" $Continue_From_Interrupt_Test:"); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" $Continue_From_Interrupt_Test:"); SetJump20(Jump, (uint32_t *)*g_RecompPos); SetRegWorkingSet(OriginalWorkingRegSet); } -void CArmRecompilerOps::CompileReadTLBMiss(ArmReg AddressReg, ArmReg LookUpReg) +void CArmRecompilerOps::CompileReadTLBMiss(CArmOps::ArmReg AddressReg, CArmOps::ArmReg LookUpReg) { m_RegWorkingSet.SetArmRegProtected(AddressReg, true); m_RegWorkingSet.SetArmRegProtected(LookUpReg, true); - ArmReg TlbLoadReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_LOAD_ADDRESS); - StoreArmRegToArmRegPointer(AddressReg, TlbLoadReg, 0); - CompareArmRegToConst(LookUpReg, 0); - CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, ExitReason_TLBReadMiss, ArmBranch_Equal); + CArmOps::ArmReg TlbLoadReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_LOAD_ADDRESS); + m_Assembler.StoreArmRegToArmRegPointer(AddressReg, TlbLoadReg, 0); + m_Assembler.CompareArmRegToConst(LookUpReg, 0); + CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, ExitReason_TLBReadMiss, CArmOps::ArmBranch_Equal); m_RegWorkingSet.SetArmRegProtected(TlbLoadReg, false); } -void CArmRecompilerOps::CompileWriteTLBMiss(ArmReg AddressReg, ArmReg LookUpReg) +void CArmRecompilerOps::CompileWriteTLBMiss(CArmOps::ArmReg AddressReg, CArmOps::ArmReg LookUpReg) { m_RegWorkingSet.SetArmRegProtected(AddressReg, true); m_RegWorkingSet.SetArmRegProtected(LookUpReg, true); - ArmReg TlbStoreReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_STORE_ADDRESS); - StoreArmRegToArmRegPointer(AddressReg, TlbStoreReg, 0); - CompareArmRegToConst(LookUpReg, 0); - CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, ExitReason_TLBWriteMiss, ArmBranch_Equal); + CArmOps::ArmReg TlbStoreReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_STORE_ADDRESS); + m_Assembler.StoreArmRegToArmRegPointer(AddressReg, TlbStoreReg, 0); + m_Assembler.CompareArmRegToConst(LookUpReg, 0); + CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, ExitReason_TLBWriteMiss, CArmOps::ArmBranch_Equal); m_RegWorkingSet.SetArmRegProtected(TlbStoreReg, false); } @@ -5551,7 +5564,7 @@ bool CArmRecompilerOps::InheritParentInfo() } if (m_Section->m_EnterPC <= JumpInfo->JumpPC) { - CPU_Message("CompileSystemCheck 10"); + m_CodeBlock.Log("CompileSystemCheck 10"); CompileSystemCheck(m_Section->m_EnterPC, GetRegWorkingSet()); } } @@ -5633,7 +5646,7 @@ bool CArmRecompilerOps::InheritParentInfo() } break; default: - CPU_Message("Unknown CPU state(%d) in InheritParentInfo", GetMipsRegState(i2)); + m_CodeBlock.Log("Unknown CPU state(%d) in InheritParentInfo", GetMipsRegState(i2)); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -5676,7 +5689,7 @@ bool CArmRecompilerOps::InheritParentInfo() } break; default: - CPU_Message("Unknown CPU state(%d) in InheritParentInfo", RegSet->GetMipsRegState(i2)); + m_CodeBlock.Log("Unknown CPU state(%d) in InheritParentInfo", RegSet->GetMipsRegState(i2)); g_Notify->BreakPoint(__FILE__, __LINE__); break; } @@ -5782,14 +5795,14 @@ bool CArmRecompilerOps::InheritParentInfo() if (NeedSync == false) { continue; } Parent = ParentList[CurrentParent].Parent; JumpInfo = ParentList[CurrentParent].JumpInfo; - BranchLabel20(ArmBranch_Always, Label.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, Label.c_str()); JumpInfo->LinkLocation = (uint32_t *)(*g_RecompPos - 4); JumpInfo->LinkLocation2 = nullptr; CurrentParent = i; Parent = ParentList[CurrentParent].Parent; JumpInfo = ParentList[CurrentParent].JumpInfo; - CPU_Message(" Section_%d (from %d):", m_Section->m_SectionID, Parent->m_SectionID); + m_CodeBlock.Log(" Section_%d (from %d):", m_Section->m_SectionID, Parent->m_SectionID); if (JumpInfo->LinkLocation != nullptr) { SetJump20(JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos); @@ -5805,7 +5818,7 @@ bool CArmRecompilerOps::InheritParentInfo() if (m_Section->m_EnterPC < JumpInfo->JumpPC) { UpdateCounters(m_RegWorkingSet, true, true); - CPU_Message("CompileSystemCheck 11"); + m_CodeBlock.Log("CompileSystemCheck 11"); CompileSystemCheck(m_Section->m_EnterPC, m_RegWorkingSet); } else @@ -5823,7 +5836,7 @@ bool CArmRecompilerOps::InheritParentInfo() LinkJump(*JumpInfo); } - CPU_Message(" Section_%d:", m_Section->m_SectionID); + m_CodeBlock.Log(" Section_%d:", m_Section->m_SectionID); m_Section->m_RegEnter.SetBlockCycleCount(0); return true; } @@ -5836,11 +5849,11 @@ void CArmRecompilerOps::LinkJump(CJumpInfo & JumpInfo, uint32_t SectionID, uint3 { if (FromSectionID != -1) { - CPU_Message(" Section_%d (from %d):", SectionID, FromSectionID); + m_CodeBlock.Log(" Section_%d (from %d):", SectionID, FromSectionID); } else { - CPU_Message(" Section_%d:", SectionID); + m_CodeBlock.Log(" Section_%d:", SectionID); } } SetJump20(JumpInfo.LinkLocation, (uint32_t *)*g_RecompPos); @@ -5855,13 +5868,13 @@ void CArmRecompilerOps::LinkJump(CJumpInfo & JumpInfo, uint32_t SectionID, uint3 void CArmRecompilerOps::JumpToSection(CCodeSection * Section) { - BranchLabel20(ArmBranch_Always, stdstr_f("Section_%d", Section->m_SectionID).c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, stdstr_f("Section_%d", Section->m_SectionID).c_str()); SetJump20(((uint32_t *)*g_RecompPos) - 1, (uint32_t *)(Section->m_CompiledLocation)); } void CArmRecompilerOps::JumpToUnknown(CJumpInfo * JumpInfo) { - BranchLabel20(ArmBranch_Always, JumpInfo->BranchLabel.c_str()); + m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, JumpInfo->BranchLabel.c_str()); JumpInfo->LinkLocation = (uint32_t*)(*g_RecompPos - 4); } @@ -5914,9 +5927,9 @@ void CArmRecompilerOps::UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles) } WriteArmComment("Updating sync CPU"); RegSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R2, Cycles); - MoveConstToArmReg(Arm_R1, (uint32_t)g_SyncSystem, "g_SyncSystem"); - MoveConstToArmReg(Arm_R0, (uint32_t)g_System); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, Cycles); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, (uint32_t)g_SyncSystem, "g_SyncSystem"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_System); CallFunction((void *)AddressOf(&CN64System::UpdateSyncCPU), "CN64System::UpdateSyncCPU"); RegSet.AfterCallDirect(); } @@ -5928,28 +5941,28 @@ void CArmRecompilerOps::UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool UpdateSyncCPU(RegSet, RegSet.GetBlockCycleCount()); WriteArmComment("Update counter"); - ArmReg NextTimerReg = RegSet.Map_Variable(CArmRegInfo::VARIABLE_NEXT_TIMER); - ArmReg TempReg = RegSet.Map_TempReg(Arm_Any, -1, false); - LoadArmRegPointerToArmReg(TempReg, NextTimerReg, 0); - SubConstFromArmReg(TempReg, TempReg, RegSet.GetBlockCycleCount()); - StoreArmRegToArmRegPointer(TempReg, NextTimerReg, 0); + CArmOps::ArmReg NextTimerReg = RegSet.Map_Variable(CArmRegInfo::VARIABLE_NEXT_TIMER); + CArmOps::ArmReg TempReg = RegSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, NextTimerReg, 0); + m_Assembler.SubConstFromArmReg(TempReg, TempReg, RegSet.GetBlockCycleCount()); + m_Assembler.StoreArmRegToArmRegPointer(TempReg, NextTimerReg, 0); if (ClearValues) { RegSet.SetBlockCycleCount(0); } if (CheckTimer) { - CompareArmRegToConst(TempReg, 0); + m_Assembler.CompareArmRegToConst(TempReg, 0); } RegSet.SetArmRegProtected(TempReg, false); RegSet.SetArmRegProtected(NextTimerReg, false); } else if (CheckTimer) { - ArmReg NextTimerReg = RegSet.Map_Variable(CArmRegInfo::VARIABLE_NEXT_TIMER); - ArmReg TempReg = RegSet.Map_TempReg(Arm_Any, -1, false); - LoadArmRegPointerToArmReg(TempReg, NextTimerReg, 0); - CompareArmRegToConst(TempReg, 0); + CArmOps::ArmReg NextTimerReg = RegSet.Map_Variable(CArmRegInfo::VARIABLE_NEXT_TIMER); + CArmOps::ArmReg TempReg = RegSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, NextTimerReg, 0); + m_Assembler.CompareArmRegToConst(TempReg, 0); RegSet.SetArmRegProtected(TempReg, false); RegSet.SetArmRegProtected(NextTimerReg, false); } @@ -5957,26 +5970,26 @@ void CArmRecompilerOps::UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool if (CheckTimer) { uint8_t * Jump = *g_RecompPos; - BranchLabel8(ArmBranch_GreaterThanOrEqual, "Continue_From_Timer_Test"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_GreaterThanOrEqual, "Continue_From_Timer_Test"); RegSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_SystemTimer, "g_SystemTimer"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_SystemTimer, "g_SystemTimer"); CallFunction(AddressOf(&CSystemTimer::TimerDone), "CSystemTimer::TimerDone"); RegSet.AfterCallDirect(); FlushPopArmReg(); - CPU_Message(""); - CPU_Message(" $Continue_From_Timer_Test:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" $Continue_From_Timer_Test:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } } void CArmRecompilerOps::CompileInterpterCall(void * Function, const char * FunctionName) { m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R1, m_Opcode.Value); - MoveConstToArmReg(Arm_R2, (uint32_t)(void *)&R4300iOp::m_Opcode.Value, "&R4300iOp::m_Opcode.Value"); - StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0); - CallFunction(Function, FunctionName); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, m_Opcode.Value); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t)(void *)&R4300iOp::m_Opcode.Value, "&R4300iOp::m_Opcode.Value"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R1, CArmOps::Arm_R2, 0); + m_Assembler.CallFunction(Function, FunctionName); m_RegWorkingSet.AfterCallDirect(); } @@ -5984,27 +5997,27 @@ void CArmRecompilerOps::OverflowDelaySlot(bool TestTimer) { m_RegWorkingSet.WriteBackRegisters(); UpdateCounters(m_RegWorkingSet, false, true); - MoveConstToVariable(m_CompilePC + 4, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + m_Assembler.MoveConstToVariable(m_CompilePC + 4, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); if (g_SyncSystem) { - MoveConstToArmReg(Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_BaseSystem, "g_BaseSystem"); CallFunction(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } - MoveConstToVariable(PIPELINE_STAGE_JUMP, &g_System->m_PipelineStage, "g_System->m_PipelineStage"); + m_Assembler.MoveConstToVariable(PIPELINE_STAGE_JUMP, &g_System->m_PipelineStage, "g_System->m_PipelineStage"); if (TestTimer) { - MoveConstToVariable(TestTimer, &R4300iOp::m_TestTimer, "R4300iOp::m_TestTimer"); + m_Assembler.MoveConstToVariable(TestTimer, &R4300iOp::m_TestTimer, "R4300iOp::m_TestTimer"); } - MoveConstToArmReg(Arm_R0, g_System->CountPerOp()); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, g_System->CountPerOp()); CallFunction((void *)CInterpreterCPU::ExecuteOps, "CInterpreterCPU::ExecuteOps"); if (g_System->bFastSP() && g_Recompiler) { - MoveConstToArmReg(Arm_R0, (uint32_t)g_Recompiler); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Recompiler); CallFunction(AddressOf(&CRecompiler::ResetMemoryStackPos), "CRecompiler::ResetMemoryStackPos"); } if (g_SyncSystem) @@ -6020,23 +6033,23 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { if (VAddr < 0x80000000 || VAddr >= 0xC0000000) { - ArmReg TempRegAddress = Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempRegAddress, VAddr); - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); - ArmReg WriteMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_WRITEMAP); - LoadArmRegPointerToArmReg(TempReg, WriteMapReg, TempReg, 2); + CArmOps::ArmReg TempRegAddress = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempRegAddress, VAddr); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); + CArmOps::ArmReg WriteMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_WRITEMAP); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, WriteMapReg, TempReg, 2); CompileWriteTLBMiss(TempRegAddress, TempReg); - ArmReg TempValueReg = Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempValueReg, Value); - StoreArmRegToArmRegPointer(TempValueReg, TempReg, TempRegAddress, 0); + CArmOps::ArmReg TempValueReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempValueReg, Value); + m_Assembler.StoreArmRegToArmRegPointer(TempValueReg, TempReg, TempRegAddress, 0); return; } uint32_t PAddr; if (!m_MMU.VAddrToPAddr(VAddr, PAddr)) { - CPU_Message("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr); + m_CodeBlock.Log("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6055,21 +6068,21 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x00500000: case 0x00600000: case 0x00700000: - MoveConstToVariable(Value, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); + m_Assembler.MoveConstToVariable(Value, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); break; case 0x03F00000: switch (PAddr) { - case 0x03F00000: MoveConstToVariable(Value, &g_Reg->RDRAM_CONFIG_REG, "RDRAM_CONFIG_REG"); break; - case 0x03F00004: MoveConstToVariable(Value, &g_Reg->RDRAM_DEVICE_ID_REG, "RDRAM_DEVICE_ID_REG"); break; - case 0x03F00008: MoveConstToVariable(Value, &g_Reg->RDRAM_DELAY_REG, "RDRAM_DELAY_REG"); break; - case 0x03F0000C: MoveConstToVariable(Value, &g_Reg->RDRAM_MODE_REG, "RDRAM_MODE_REG"); break; - case 0x03F00010: MoveConstToVariable(Value, &g_Reg->RDRAM_REF_INTERVAL_REG, "RDRAM_REF_INTERVAL_REG"); break; - case 0x03F00014: MoveConstToVariable(Value, &g_Reg->RDRAM_REF_ROW_REG, "RDRAM_REF_ROW_REG"); break; - case 0x03F00018: MoveConstToVariable(Value, &g_Reg->RDRAM_RAS_INTERVAL_REG, "RDRAM_RAS_INTERVAL_REG"); break; - case 0x03F0001C: MoveConstToVariable(Value, &g_Reg->RDRAM_MIN_INTERVAL_REG, "RDRAM_MIN_INTERVAL_REG"); break; - case 0x03F00020: MoveConstToVariable(Value, &g_Reg->RDRAM_ADDR_SELECT_REG, "RDRAM_ADDR_SELECT_REG"); break; - case 0x03F00024: MoveConstToVariable(Value, &g_Reg->RDRAM_DEVICE_MANUF_REG, "RDRAM_DEVICE_MANUF_REG"); break; + case 0x03F00000: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_CONFIG_REG, "RDRAM_CONFIG_REG"); break; + case 0x03F00004: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_DEVICE_ID_REG, "RDRAM_DEVICE_ID_REG"); break; + case 0x03F00008: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_DELAY_REG, "RDRAM_DELAY_REG"); break; + case 0x03F0000C: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_MODE_REG, "RDRAM_MODE_REG"); break; + case 0x03F00010: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_REF_INTERVAL_REG, "RDRAM_REF_INTERVAL_REG"); break; + case 0x03F00014: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_REF_ROW_REG, "RDRAM_REF_ROW_REG"); break; + case 0x03F00018: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_RAS_INTERVAL_REG, "RDRAM_RAS_INTERVAL_REG"); break; + case 0x03F0001C: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_MIN_INTERVAL_REG, "RDRAM_MIN_INTERVAL_REG"); break; + case 0x03F00020: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_ADDR_SELECT_REG, "RDRAM_ADDR_SELECT_REG"); break; + case 0x03F00024: m_Assembler.MoveConstToVariable(Value, &g_Reg->RDRAM_DEVICE_MANUF_REG, "RDRAM_DEVICE_MANUF_REG"); break; case 0x03F04004: break; case 0x03F08004: break; case 0x03F80004: break; @@ -6086,20 +6099,20 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x04000000: if (PAddr < 0x04002000) { - MoveConstToVariable(Value, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); + m_Assembler.MoveConstToVariable(Value, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); break; } switch (PAddr) { - case 0x04040000: MoveConstToVariable(Value, &g_Reg->SP_MEM_ADDR_REG, "SP_MEM_ADDR_REG"); break; - case 0x04040004: MoveConstToVariable(Value, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; + case 0x04040000: m_Assembler.MoveConstToVariable(Value, &g_Reg->SP_MEM_ADDR_REG, "SP_MEM_ADDR_REG"); break; + case 0x04040004: m_Assembler.MoveConstToVariable(Value, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; case 0x04040008: m_RegWorkingSet.BeforeCallDirect(); ArmBreakPoint(__FILE__, __LINE__); /*PushImm32(0xFFFFFFFF); PushImm32(Value); PushImm32(PAddr & 0x1FFFFFFF);*/ - MoveConstToArmReg(Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); m_RegWorkingSet.AfterCallDirect(); break; @@ -6109,16 +6122,16 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R2, Value); - MoveConstToArmReg(Arm_R1, PAddr | 0xA0000000); - MoveConstToArmReg(Arm_R0, (uint32_t)(g_MMU), "g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, Value); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, PAddr | 0xA0000000); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(g_MMU), "g_MMU"); CallFunction(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); m_RegWorkingSet.AfterCallDirect(); break; - case 0x0404001C: MoveConstToVariable(0, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); break; - case 0x04080000: MoveConstToVariable(Value & 0xFFC, &g_Reg->SP_PC_REG, "SP_PC_REG"); break; + case 0x0404001C: m_Assembler.MoveConstToVariable(0, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); break; + case 0x04080000: m_Assembler.MoveConstToVariable(Value & 0xFFC, &g_Reg->SP_PC_REG, "SP_PC_REG"); break; default: - CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); + m_CodeBlock.Log(" should be moving %X in to %08X ?", Value, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6131,9 +6144,9 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { case 0x0410000C: m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R2, Value); - MoveConstToArmReg(Arm_R1, PAddr | 0xA0000000); - MoveConstToArmReg(Arm_R0, (uint32_t)(g_MMU), "g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, Value); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, PAddr | 0xA0000000); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(g_MMU), "g_MMU"); CallFunction(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); m_RegWorkingSet.AfterCallDirect(); break; @@ -6252,7 +6265,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) } break; default: - CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); + m_CodeBlock.Log(" should be moving %X in to %08X ?", Value, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6266,69 +6279,69 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x04400000: if (g_Plugins->Gfx()->ViStatusChanged != nullptr) { - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - MoveVariableToArmReg(&g_Reg->VI_STATUS_REG, "VI_STATUS_REG", TempReg); - ArmReg TempValueReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempValueReg, Value); - CompareArmRegToArmReg(TempReg, TempValueReg); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveVariableToArmReg(&g_Reg->VI_STATUS_REG, "VI_STATUS_REG", TempReg); + CArmOps::ArmReg TempValueReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempValueReg, Value); + m_Assembler.CompareArmRegToArmReg(TempReg, TempValueReg); uint8_t * Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Equal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Equal, "Continue"); m_RegWorkingSet.BeforeCallDirect(); - ArmReg VariableReg = TempValueReg != Arm_R1 ? Arm_R1 : Arm_R2; - MoveConstToArmReg(VariableReg, (uint32_t)&g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); - StoreArmRegToArmRegPointer(TempValueReg, VariableReg, 0); + CArmOps::ArmReg VariableReg = TempValueReg != CArmOps::Arm_R1 ? CArmOps::Arm_R1 : CArmOps::Arm_R2; + m_Assembler.MoveConstToArmReg(VariableReg, (uint32_t)&g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); + m_Assembler.StoreArmRegToArmRegPointer(TempValueReg, VariableReg, 0); CallFunction((void *)g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged"); m_RegWorkingSet.AfterCallDirect(); FlushPopArmReg(); - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" Continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } break; - case 0x04400004: MoveConstToVariable((Value & 0xFFFFFF), &g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG"); break; + case 0x04400004: m_Assembler.MoveConstToVariable((Value & 0xFFFFFF), &g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG"); break; case 0x04400008: if (g_Plugins->Gfx()->ViWidthChanged != nullptr) { - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - MoveVariableToArmReg(&g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG", TempReg); - ArmReg TempValueReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempValueReg, Value); - CompareArmRegToArmReg(TempReg, TempValueReg); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveVariableToArmReg(&g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG", TempReg); + CArmOps::ArmReg TempValueReg = m_RegWorkingSet.Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempValueReg, Value); + m_Assembler.CompareArmRegToArmReg(TempReg, TempValueReg); uint8_t * Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Equal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Equal, "Continue"); - MoveArmRegToVariable(TempValueReg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); + m_Assembler.MoveArmRegToVariable(TempValueReg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); m_RegWorkingSet.BeforeCallDirect(); CallFunction((void *)g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged"); m_RegWorkingSet.AfterCallDirect(); FlushPopArmReg(); - CPU_Message(""); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } break; - case 0x0440000C: MoveConstToVariable(Value, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break; + case 0x0440000C: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break; case 0x04400010: AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_VI); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg, "g_Reg"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg, "g_Reg"); CallFunction(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); m_RegWorkingSet.AfterCallDirect(); break; - case 0x04400014: MoveConstToVariable(Value, &g_Reg->VI_BURST_REG, "VI_BURST_REG"); break; - case 0x04400018: MoveConstToVariable(Value, &g_Reg->VI_V_SYNC_REG, "VI_V_SYNC_REG"); break; - case 0x0440001C: MoveConstToVariable(Value, &g_Reg->VI_H_SYNC_REG, "VI_H_SYNC_REG"); break; - case 0x04400020: MoveConstToVariable(Value, &g_Reg->VI_LEAP_REG, "VI_LEAP_REG"); break; - case 0x04400024: MoveConstToVariable(Value, &g_Reg->VI_H_START_REG, "VI_H_START_REG"); break; - case 0x04400028: MoveConstToVariable(Value, &g_Reg->VI_V_START_REG, "VI_V_START_REG"); break; - case 0x0440002C: MoveConstToVariable(Value, &g_Reg->VI_V_BURST_REG, "VI_V_BURST_REG"); break; - case 0x04400030: MoveConstToVariable(Value, &g_Reg->VI_X_SCALE_REG, "VI_X_SCALE_REG"); break; - case 0x04400034: MoveConstToVariable(Value, &g_Reg->VI_Y_SCALE_REG, "VI_Y_SCALE_REG"); break; + case 0x04400014: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_BURST_REG, "VI_BURST_REG"); break; + case 0x04400018: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_V_SYNC_REG, "VI_V_SYNC_REG"); break; + case 0x0440001C: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_H_SYNC_REG, "VI_H_SYNC_REG"); break; + case 0x04400020: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_LEAP_REG, "VI_LEAP_REG"); break; + case 0x04400024: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_H_START_REG, "VI_H_START_REG"); break; + case 0x04400028: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_V_START_REG, "VI_V_START_REG"); break; + case 0x0440002C: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_V_BURST_REG, "VI_V_BURST_REG"); break; + case 0x04400030: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_X_SCALE_REG, "VI_X_SCALE_REG"); break; + case 0x04400034: m_Assembler.MoveConstToVariable(Value, &g_Reg->VI_Y_SCALE_REG, "VI_Y_SCALE_REG"); break; default: - CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); + m_CodeBlock.Log(" should be moving %X in to %08X ?", Value, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6339,14 +6352,14 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x04500000: // AI registers switch (PAddr) { - case 0x04500000: MoveConstToVariable(Value, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; + case 0x04500000: m_Assembler.MoveConstToVariable(Value, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; case 0x04500004: - MoveConstToVariable(Value, &g_Reg->AI_LEN_REG, "AI_LEN_REG"); + m_Assembler.MoveConstToVariable(Value, &g_Reg->AI_LEN_REG, "AI_LEN_REG"); m_RegWorkingSet.BeforeCallDirect(); if (g_System->bFixedAudio()) { ArmBreakPoint(__FILE__, __LINE__); - //MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); + //m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Audio, "g_Audio"); //CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged"); } else @@ -6355,27 +6368,27 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) } m_RegWorkingSet.AfterCallDirect(); break; - case 0x04500008: MoveConstToVariable((Value & 1), &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); break; + case 0x04500008: m_Assembler.MoveConstToVariable((Value & 1), &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); break; case 0x0450000C: // Clear interrupt AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_AI); AndConstToVariable(&g_Reg->m_AudioIntrReg, "m_AudioIntrReg", (uint32_t)~MI_INTR_AI); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg, "g_Reg"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg, "g_Reg"); CallFunction(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); m_RegWorkingSet.AfterCallDirect(); break; case 0x04500010: m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R2, Value); - MoveConstToArmReg(Arm_R1, PAddr | 0xA0000000); - MoveConstToArmReg(Arm_R0, (uint32_t)(g_MMU), "g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, Value); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, PAddr | 0xA0000000); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(g_MMU), "g_MMU"); CallFunction(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); m_RegWorkingSet.AfterCallDirect(); break; - case 0x04500014: MoveConstToVariable(Value, &g_Reg->AI_BITRATE_REG, "AI_BITRATE_REG"); break; + case 0x04500014: m_Assembler.MoveConstToVariable(Value, &g_Reg->AI_BITRATE_REG, "AI_BITRATE_REG"); break; default: - CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); + m_CodeBlock.Log(" should be moving %X in to %08X ?", Value, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6386,13 +6399,13 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x04600000: switch (PAddr) { - case 0x04600000: MoveConstToVariable(Value, &g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG"); break; - case 0x04600004: MoveConstToVariable(Value, &g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG"); break; + case 0x04600000: m_Assembler.MoveConstToVariable(Value, &g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG"); break; + case 0x04600004: m_Assembler.MoveConstToVariable(Value, &g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG"); break; case 0x04600008: ArmBreakPoint(__FILE__, __LINE__); - /*MoveConstToVariable(Value, &g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG"); + /*m_Assembler.MoveConstToVariable(Value, &g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG"); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); CallFunction(AddressOf(&CDMA::PI_DMA_READ), "CDMA::PI_DMA_READ"); m_RegWorkingSet.AfterCallDirect();*/ break; @@ -6401,9 +6414,9 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) /*m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveConstToVariable(Value, &g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG"); + m_Assembler.MoveConstToVariable(Value, &g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG"); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); CallFunction(AddressOf(&CDMA::PI_DMA_WRITE), "CDMA::PI_DMA_WRITE"); m_RegWorkingSet.AfterCallDirect();*/ break; @@ -6412,21 +6425,21 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_PI); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg, "g_Reg"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg, "g_Reg"); CallFunction(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); m_RegWorkingSet.AfterCallDirect(); } break; - case 0x04600014: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG"); break; - case 0x04600018: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG"); break; - case 0x0460001C: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG"); break; - case 0x04600020: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG"); break; - case 0x04600024: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_DOMAIN2_REG, "PI_DOMAIN2_REG"); break; - case 0x04600028: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM2_PWD_REG, "PI_BSD_DOM2_PWD_REG"); break; - case 0x0460002C: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM2_PGS_REG, "PI_BSD_DOM2_PGS_REG"); break; - case 0x04600030: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG"); break; + case 0x04600014: m_Assembler.MoveConstToVariable((Value & 0xFF), &g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG"); break; + case 0x04600018: m_Assembler.MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG"); break; + case 0x0460001C: m_Assembler.MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG"); break; + case 0x04600020: m_Assembler.MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG"); break; + case 0x04600024: m_Assembler.MoveConstToVariable((Value & 0xFF), &g_Reg->PI_DOMAIN2_REG, "PI_DOMAIN2_REG"); break; + case 0x04600028: m_Assembler.MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM2_PWD_REG, "PI_BSD_DOM2_PWD_REG"); break; + case 0x0460002C: m_Assembler.MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM2_PGS_REG, "PI_BSD_DOM2_PGS_REG"); break; + case 0x04600030: m_Assembler.MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG"); break; default: - CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); + m_CodeBlock.Log(" should be moving %X in to %08X ?", Value, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6437,12 +6450,12 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x04700000: switch (PAddr) { - case 0x04700000: MoveConstToVariable(Value, &g_Reg->RI_MODE_REG, "RI_MODE_REG"); break; - case 0x04700004: MoveConstToVariable(Value, &g_Reg->RI_CONFIG_REG, "RI_CONFIG_REG"); break; - case 0x04700008: MoveConstToVariable(Value, &g_Reg->RI_CURRENT_LOAD_REG, "RI_CURRENT_LOAD_REG"); break; - case 0x0470000C: MoveConstToVariable(Value, &g_Reg->RI_SELECT_REG, "RI_SELECT_REG"); break; + case 0x04700000: m_Assembler.MoveConstToVariable(Value, &g_Reg->RI_MODE_REG, "RI_MODE_REG"); break; + case 0x04700004: m_Assembler.MoveConstToVariable(Value, &g_Reg->RI_CONFIG_REG, "RI_CONFIG_REG"); break; + case 0x04700008: m_Assembler.MoveConstToVariable(Value, &g_Reg->RI_CURRENT_LOAD_REG, "RI_CURRENT_LOAD_REG"); break; + case 0x0470000C: m_Assembler.MoveConstToVariable(Value, &g_Reg->RI_SELECT_REG, "RI_SELECT_REG"); break; default: - CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); + m_CodeBlock.Log(" should be moving %X in to %08X ?", Value, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6453,14 +6466,14 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) case 0x04800000: switch (PAddr) { - case 0x04800000: MoveConstToVariable(Value, &g_Reg->SI_DRAM_ADDR_REG, "SI_DRAM_ADDR_REG"); break; + case 0x04800000: m_Assembler.MoveConstToVariable(Value, &g_Reg->SI_DRAM_ADDR_REG, "SI_DRAM_ADDR_REG"); break; case 0x04800004: m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveConstToVariable(Value, &g_Reg->SI_PIF_ADDR_RD64B_REG, "SI_PIF_ADDR_RD64B_REG"); + m_Assembler.MoveConstToVariable(Value, &g_Reg->SI_PIF_ADDR_RD64B_REG, "SI_PIF_ADDR_RD64B_REG"); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)((CPifRam *)g_MMU), "CPifRam *)g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((CPifRam *)g_MMU), "CPifRam *)g_MMU"); CallFunction(AddressOf(&CPifRam::SI_DMA_READ), "CPifRam::SI_DMA_READ"); m_RegWorkingSet.AfterCallDirect(); break; @@ -6468,9 +6481,9 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveConstToVariable(Value, &g_Reg->SI_PIF_ADDR_WR64B_REG, "SI_PIF_ADDR_WR64B_REG"); + m_Assembler.MoveConstToVariable(Value, &g_Reg->SI_PIF_ADDR_WR64B_REG, "SI_PIF_ADDR_WR64B_REG"); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)((CPifRam *)g_MMU), "CPifRam *)g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((CPifRam *)g_MMU), "CPifRam *)g_MMU"); CallFunction(AddressOf(&CPifRam::SI_DMA_WRITE), "CPifRam::SI_DMA_WRITE"); m_RegWorkingSet.AfterCallDirect(); break; @@ -6478,12 +6491,12 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_SI); AndConstToVariable(&g_Reg->SI_STATUS_REG, "SI_STATUS_REG", (uint32_t)~SI_STATUS_INTERRUPT); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg, "g_Reg"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg, "g_Reg"); CallFunction(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); + m_CodeBlock.Log(" should be moving %X in to %08X ?", Value, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6502,7 +6515,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); + m_CodeBlock.Log(" should be moving %X in to %08X ?", Value, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6516,14 +6529,14 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R2, Value); - MoveConstToArmReg(Arm_R1, PAddr | 0xA0000000); - MoveConstToArmReg(Arm_R0, (uint32_t)(g_MMU), "g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, Value); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, PAddr | 0xA0000000); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(g_MMU), "g_MMU"); CallFunction(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" should be moving %X in to %08X ?", Value, VAddr); + m_CodeBlock.Log(" should be moving %X in to %08X ?", Value, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6531,20 +6544,20 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) } } -void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) +void CArmRecompilerOps::SW_Register(CArmOps::ArmReg Reg, uint32_t VAddr) { if (VAddr < 0x80000000 || VAddr >= 0xC0000000) { m_RegWorkingSet.SetArmRegProtected(Reg, true); - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - ArmReg TempRegAddress = Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempRegAddress, VAddr); - ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); - ArmReg WriteMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_WRITEMAP); - LoadArmRegPointerToArmReg(TempReg, WriteMapReg, TempReg, 2); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + CArmOps::ArmReg TempRegAddress = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempRegAddress, VAddr); + m_Assembler.ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); + CArmOps::ArmReg WriteMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_WRITEMAP); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, WriteMapReg, TempReg, 2); CompileWriteTLBMiss(TempRegAddress, TempReg); - StoreArmRegToArmRegPointer(Reg, TempReg, TempRegAddress, 0); + m_Assembler.StoreArmRegToArmRegPointer(Reg, TempReg, TempRegAddress, 0); m_RegWorkingSet.SetArmRegProtected(TempReg, false); m_RegWorkingSet.SetArmRegProtected(TempRegAddress, false); return; @@ -6553,7 +6566,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) uint32_t PAddr; if (!m_MMU.VAddrToPAddr(VAddr, PAddr)) { - CPU_Message("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr); + m_CodeBlock.Log("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6571,7 +6584,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x00500000: case 0x00600000: case 0x00700000: - MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); + m_Assembler.MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); break; case 0x03F00000: switch (PAddr) @@ -6583,7 +6596,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x03F8000C: break; case 0x03F80014: break; default: - CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); + m_CodeBlock.Log(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6593,23 +6606,23 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x04000000: switch (PAddr) { - case 0x04040000: MoveArmRegToVariable(Reg, &g_Reg->SP_MEM_ADDR_REG, "SP_MEM_ADDR_REG"); break; - case 0x04040004: MoveArmRegToVariable(Reg, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; + case 0x04040000: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->SP_MEM_ADDR_REG, "SP_MEM_ADDR_REG"); break; + case 0x04040004: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; case 0x04040008: m_RegWorkingSet.BeforeCallDirect(); ArmBreakPoint(__FILE__, __LINE__); /*PushImm32(0xFFFFFFFF); Push(Reg); PushImm32(PAddr & 0x1FFFFFFF);*/ - MoveConstToArmReg(Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); m_RegWorkingSet.AfterCallDirect(); break; case 0x0404000C: ArmBreakPoint(__FILE__, __LINE__); - /*MoveArmRegToVariable(Reg, &g_Reg->SP_WR_LEN_REG, "SP_WR_LEN_REG"); + /*m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->SP_WR_LEN_REG, "SP_WR_LEN_REG"); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); CallFunction(AddressOf(&CDMA::SP_DMA_WRITE), "CDMA::SP_DMA_WRITE"); m_RegWorkingSet.AfterCallDirect();*/ break; @@ -6617,24 +6630,24 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveArmRegToVariable(Reg, &CMipsMemoryVM::RegModValue, "CMipsMemoryVM::RegModValue"); + m_Assembler.MoveArmRegToVariable(Reg, &CMipsMemoryVM::RegModValue, "CMipsMemoryVM::RegModValue"); m_RegWorkingSet.BeforeCallDirect(); CallFunction(AddressOf(&CMipsMemoryVM::ChangeSpStatus), "CMipsMemoryVM::ChangeSpStatus"); m_RegWorkingSet.AfterCallDirect(); break; - case 0x0404001C: MoveConstToVariable(0, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); break; + case 0x0404001C: m_Assembler.MoveConstToVariable(0, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); break; case 0x04080000: - MoveArmRegToVariable(Reg, &g_Reg->SP_PC_REG, "SP_PC_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->SP_PC_REG, "SP_PC_REG"); AndConstToVariable(&g_Reg->SP_PC_REG, "SP_PC_REG", 0xFFC); break; default: if (PAddr < 0x04002000) { - MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); + m_Assembler.MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); } else { - CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); + m_CodeBlock.Log(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6650,12 +6663,12 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); } m_RegWorkingSet.BeforeCallDirect(); - if (Reg != Arm_R2) + if (Reg != CArmOps::Arm_R2) { - AddConstToArmReg(Arm_R2, Reg, 0); + m_Assembler.AddConstToArmReg(CArmOps::Arm_R2, Reg, 0); } - MoveConstToArmReg(Arm_R1, PAddr | 0xA0000000); - MoveConstToArmReg(Arm_R0, (uint32_t)(g_MMU), "g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, PAddr | 0xA0000000); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(g_MMU), "g_MMU"); CallFunction(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); m_RegWorkingSet.AfterCallDirect(); break; @@ -6664,20 +6677,20 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) { case 0x04300000: ArmBreakPoint(__FILE__, __LINE__); - /*MoveArmRegToVariable(Reg, &CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]"); - MoveConstToVariable(PAddr, &CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); + /*m_Assembler.MoveArmRegToVariable(Reg, &CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]"); + m_Assembler.MoveConstToVariable(PAddr, &CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); m_RegWorkingSet.BeforeCallDirect(); CallFunction((void *)CMipsMemoryVM::Write32MIPSInterface, "CMipsMemoryVM::Write32MIPSInterface"); m_RegWorkingSet.AfterCallDirect();*/ break; case 0x0430000C: - MoveArmRegToVariable(Reg, &CMipsMemoryVM::RegModValue, "CMipsMemoryVM::RegModValue"); + m_Assembler.MoveArmRegToVariable(Reg, &CMipsMemoryVM::RegModValue, "CMipsMemoryVM::RegModValue"); m_RegWorkingSet.BeforeCallDirect(); CallFunction((void *)CMipsMemoryVM::ChangeMiIntrMask, "CMipsMemoryVM::ChangeMiIntrMask"); m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); + m_CodeBlock.Log(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6689,66 +6702,66 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x04400000: if (g_Plugins->Gfx()->ViStatusChanged != nullptr) { - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - MoveVariableToArmReg(&g_Reg->VI_STATUS_REG, "VI_STATUS_REG", TempReg); - CompareArmRegToArmReg(TempReg, Reg); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveVariableToArmReg(&g_Reg->VI_STATUS_REG, "VI_STATUS_REG", TempReg); + m_Assembler.CompareArmRegToArmReg(TempReg, Reg); uint8_t * Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Equal, "Continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Equal, "Continue"); - MoveArmRegToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); m_RegWorkingSet.BeforeCallDirect(); CallFunction((void *)g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged"); m_RegWorkingSet.AfterCallDirect(); FlushPopArmReg(); - CPU_Message(""); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } break; case 0x04400004: - MoveArmRegToVariable(Reg, &g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG"); AndConstToVariable(&g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG", 0xFFFFFF); break; case 0x04400008: if (g_Plugins->Gfx()->ViWidthChanged != nullptr) { - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - MoveVariableToArmReg(&g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG", TempReg); - CompareArmRegToArmReg(TempReg, Reg); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveVariableToArmReg(&g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG", TempReg); + m_Assembler.CompareArmRegToArmReg(TempReg, Reg); uint8_t * Jump = *g_RecompPos; - BranchLabel8(ArmBranch_Equal, "continue"); + m_Assembler.BranchLabel8(CArmOps::ArmBranch_Equal, "continue"); - MoveArmRegToVariable(Reg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); m_RegWorkingSet.BeforeCallDirect(); CallFunction((void *)g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged"); m_RegWorkingSet.AfterCallDirect(); FlushPopArmReg(); - CPU_Message(""); - CPU_Message(" continue:"); - SetJump8(Jump, *g_RecompPos); + m_CodeBlock.Log(""); + m_CodeBlock.Log(" continue:"); + m_Assembler.SetJump8(Jump, *g_RecompPos); } break; - case 0x0440000C: MoveArmRegToVariable(Reg, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break; + case 0x0440000C: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break; case 0x04400010: AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_VI); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg, "g_Reg"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg, "g_Reg"); CallFunction(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); m_RegWorkingSet.AfterCallDirect(); break; - case 0x04400014: MoveArmRegToVariable(Reg, &g_Reg->VI_BURST_REG, "VI_BURST_REG"); break; - case 0x04400018: MoveArmRegToVariable(Reg, &g_Reg->VI_V_SYNC_REG, "VI_V_SYNC_REG"); break; - case 0x0440001C: MoveArmRegToVariable(Reg, &g_Reg->VI_H_SYNC_REG, "VI_H_SYNC_REG"); break; - case 0x04400020: MoveArmRegToVariable(Reg, &g_Reg->VI_LEAP_REG, "VI_LEAP_REG"); break; - case 0x04400024: MoveArmRegToVariable(Reg, &g_Reg->VI_H_START_REG, "VI_H_START_REG"); break; - case 0x04400028: MoveArmRegToVariable(Reg, &g_Reg->VI_V_START_REG, "VI_V_START_REG"); break; - case 0x0440002C: MoveArmRegToVariable(Reg, &g_Reg->VI_V_BURST_REG, "VI_V_BURST_REG"); break; - case 0x04400030: MoveArmRegToVariable(Reg, &g_Reg->VI_X_SCALE_REG, "VI_X_SCALE_REG"); break; - case 0x04400034: MoveArmRegToVariable(Reg, &g_Reg->VI_Y_SCALE_REG, "VI_Y_SCALE_REG"); break; + case 0x04400014: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_BURST_REG, "VI_BURST_REG"); break; + case 0x04400018: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_V_SYNC_REG, "VI_V_SYNC_REG"); break; + case 0x0440001C: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_H_SYNC_REG, "VI_H_SYNC_REG"); break; + case 0x04400020: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_LEAP_REG, "VI_LEAP_REG"); break; + case 0x04400024: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_H_START_REG, "VI_H_START_REG"); break; + case 0x04400028: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_V_START_REG, "VI_V_START_REG"); break; + case 0x0440002C: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_V_BURST_REG, "VI_V_BURST_REG"); break; + case 0x04400030: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_X_SCALE_REG, "VI_X_SCALE_REG"); break; + case 0x04400034: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->VI_Y_SCALE_REG, "VI_Y_SCALE_REG"); break; default: - CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); + m_CodeBlock.Log(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6757,17 +6770,17 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) break; case 0x04500000: // AI registers switch (PAddr) { - case 0x04500000: MoveArmRegToVariable(Reg, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; + case 0x04500000: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; case 0x04500004: m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveArmRegToVariable(Reg, &g_Reg->AI_LEN_REG, "AI_LEN_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->AI_LEN_REG, "AI_LEN_REG"); m_RegWorkingSet.BeforeCallDirect(); if (g_System->bFixedAudio()) { ArmBreakPoint(__FILE__, __LINE__); - //MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); + //m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Audio, "g_Audio"); //CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged"); } else @@ -6777,31 +6790,31 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) m_RegWorkingSet.AfterCallDirect(); break; case 0x04500008: - MoveArmRegToVariable(Reg, &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); AndConstToVariable(&g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG", 1); case 0x0450000C: // Clear interrupt AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_AI); AndConstToVariable(&g_Reg->m_AudioIntrReg, "m_AudioIntrReg", (uint32_t)~MI_INTR_AI); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg, "g_Reg"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg, "g_Reg"); CallFunction(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); m_RegWorkingSet.AfterCallDirect(); break; case 0x04500010: m_RegWorkingSet.BeforeCallDirect(); - if (Reg != Arm_R2) + if (Reg != CArmOps::Arm_R2) { - AddConstToArmReg(Arm_R2, Reg, 0); + m_Assembler.AddConstToArmReg(CArmOps::Arm_R2, Reg, 0); } - MoveConstToArmReg(Arm_R1, PAddr | 0xA0000000); - MoveConstToArmReg(Arm_R0, (uint32_t)(g_MMU), "g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, PAddr | 0xA0000000); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(g_MMU), "g_MMU"); CallFunction(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); m_RegWorkingSet.AfterCallDirect(); break; - case 0x04500014: MoveArmRegToVariable(Reg, &g_Reg->AI_BITRATE_REG, "AI_BITRATE_REG"); break; + case 0x04500014: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->AI_BITRATE_REG, "AI_BITRATE_REG"); break; default: - MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); + m_Assembler.MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6811,9 +6824,9 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x04600000: switch (PAddr) { - case 0x04600000: MoveArmRegToVariable(Reg, &g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG"); break; + case 0x04600000: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG"); break; case 0x04600004: - MoveArmRegToVariable(Reg, &g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG"); if (EnableDisk()) { m_RegWorkingSet.BeforeCallDirect(); @@ -6823,9 +6836,9 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) break; case 0x04600008: ArmBreakPoint(__FILE__, __LINE__); - /*MoveArmRegToVariable(Reg, &g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG"); + /*m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG"); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); CallFunction(AddressOf(&CDMA::PI_DMA_READ), "CDMA::PI_DMA_READ"); m_RegWorkingSet.AfterCallDirect();*/ break; @@ -6834,9 +6847,9 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) /*m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveArmRegToVariable(Reg, &g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG"); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((CDMA *)g_MMU), "(CDMA *)g_MMU"); CallFunction(AddressOf(&CDMA::PI_DMA_WRITE), "CDMA::PI_DMA_WRITE"); m_RegWorkingSet.AfterCallDirect();*/ break; @@ -6847,44 +6860,44 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) } AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_PI); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg, "g_Reg"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg, "g_Reg"); CallFunction(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); m_RegWorkingSet.AfterCallDirect(); break; case 0x04600014: - MoveArmRegToVariable(Reg, &g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG"); AndConstToVariable(&g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG", 0xFF); break; case 0x04600018: - MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG"); AndConstToVariable(&g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG", 0xFF); break; case 0x0460001C: - MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG"); AndConstToVariable(&g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG", 0xFF); break; case 0x04600020: - MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG"); AndConstToVariable(&g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG", 0xFF); break; case 0x04600024: - MoveArmRegToVariable(Reg, &g_Reg->PI_DOMAIN2_REG, "PI_DOMAIN2_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_DOMAIN2_REG, "PI_DOMAIN2_REG"); AndConstToVariable(&g_Reg->PI_DOMAIN2_REG, "PI_DOMAIN2_REG", 0xFF); break; case 0x04600028: - MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM2_PWD_REG, "PI_BSD_DOM2_PWD_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM2_PWD_REG, "PI_BSD_DOM2_PWD_REG"); AndConstToVariable(&g_Reg->PI_BSD_DOM2_PWD_REG, "PI_BSD_DOM2_PWD_REG", 0xFF); break; case 0x0460002C: - MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM2_PGS_REG, "PI_BSD_DOM2_PGS_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM2_PGS_REG, "PI_BSD_DOM2_PGS_REG"); AndConstToVariable(&g_Reg->PI_BSD_DOM2_PGS_REG, "PI_BSD_DOM2_PGS_REG", 0xFF); break; case 0x04600030: - MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG"); AndConstToVariable(&g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG", 0xFF); break; default: - CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); + m_CodeBlock.Log(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6894,12 +6907,12 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x04700000: switch (PAddr) { - case 0x04700000: MoveArmRegToVariable(Reg, &g_Reg->RI_MODE_REG, "RI_MODE_REG"); break; - case 0x04700004: MoveArmRegToVariable(Reg, &g_Reg->RI_CONFIG_REG, "RI_CONFIG_REG"); break; - case 0x0470000C: MoveArmRegToVariable(Reg, &g_Reg->RI_SELECT_REG, "RI_SELECT_REG"); break; - case 0x04700010: MoveArmRegToVariable(Reg, &g_Reg->RI_REFRESH_REG, "RI_REFRESH_REG"); break; + case 0x04700000: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->RI_MODE_REG, "RI_MODE_REG"); break; + case 0x04700004: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->RI_CONFIG_REG, "RI_CONFIG_REG"); break; + case 0x0470000C: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->RI_SELECT_REG, "RI_SELECT_REG"); break; + case 0x04700010: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->RI_REFRESH_REG, "RI_REFRESH_REG"); break; default: - CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); + m_CodeBlock.Log(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6909,18 +6922,18 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) case 0x04800000: switch (PAddr) { - case 0x04800000: MoveArmRegToVariable(Reg, &g_Reg->SI_DRAM_ADDR_REG, "SI_DRAM_ADDR_REG"); break; + case 0x04800000: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->SI_DRAM_ADDR_REG, "SI_DRAM_ADDR_REG"); break; case 0x04800004: - MoveArmRegToVariable(Reg, &g_Reg->SI_PIF_ADDR_RD64B_REG, "SI_PIF_ADDR_RD64B_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->SI_PIF_ADDR_RD64B_REG, "SI_PIF_ADDR_RD64B_REG"); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)((CPifRam *)g_MMU), "CPifRam *)g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((CPifRam *)g_MMU), "CPifRam *)g_MMU"); CallFunction(AddressOf(&CPifRam::SI_DMA_READ), "CPifRam::SI_DMA_READ"); m_RegWorkingSet.AfterCallDirect(); break; case 0x04800010: - MoveArmRegToVariable(Reg, &g_Reg->SI_PIF_ADDR_WR64B_REG, "SI_PIF_ADDR_WR64B_REG"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->SI_PIF_ADDR_WR64B_REG, "SI_PIF_ADDR_WR64B_REG"); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)((CPifRam *)g_MMU), "CPifRam *)g_MMU"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)((CPifRam *)g_MMU), "CPifRam *)g_MMU"); CallFunction(AddressOf(&CPifRam::SI_DMA_WRITE), "CPifRam::SI_DMA_WRITE"); m_RegWorkingSet.AfterCallDirect(); break; @@ -6928,12 +6941,12 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) AndConstToVariable(&g_Reg->MI_INTR_REG, "MI_INTR_REG", (uint32_t)~MI_INTR_SI); AndConstToVariable(&g_Reg->SI_STATUS_REG, "SI_STATUS_REG", (uint32_t)~SI_STATUS_INTERRUPT); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg, "g_Reg"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg, "g_Reg"); CallFunction(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); m_RegWorkingSet.AfterCallDirect(); break; default: - CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); + m_CodeBlock.Log(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6946,23 +6959,23 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) { switch (PAddr) { - case 0x05000500: MoveArmRegToVariable(Reg, &g_Reg->ASIC_DATA, "ASIC_DATA"); break; + case 0x05000500: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->ASIC_DATA, "ASIC_DATA"); break; case 0x05000508: // ASIC_CMD - MoveArmRegToVariable(Reg, &g_Reg->ASIC_CMD, "ASIC_CMD"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->ASIC_CMD, "ASIC_CMD"); m_RegWorkingSet.BeforeCallDirect(); CallFunction(AddressOf(&DiskCommand), "DiskCommand"); m_RegWorkingSet.AfterCallDirect(); OrConstToVariable(&g_Reg->ASIC_STATUS, "ASIC_STATUS", (uint32_t)DD_STATUS_MECHA_INT); OrConstToVariable(&g_Reg->FAKE_CAUSE_REGISTER, "FAKE_CAUSE_REGISTER", (uint32_t)CAUSE_IP3); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg, "g_Reg"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Reg, "g_Reg"); CallFunction(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); m_RegWorkingSet.AfterCallDirect(); break; case 0x05000510: // ASIC_BM_CTL - MoveArmRegToVariable(Reg, &g_Reg->ASIC_BM_CTL, "ASIC_BM_CTL"); + m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->ASIC_BM_CTL, "ASIC_BM_CTL"); m_RegWorkingSet.BeforeCallDirect(); CallFunction(AddressOf(&DiskBMControl), "DiskBMControl"); m_RegWorkingSet.AfterCallDirect(); @@ -6974,17 +6987,17 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) CallFunction(AddressOf(&DiskReset), "DiskReset"); m_RegWorkingSet.AfterCallDirect(); break; - case 0x05000528: MoveArmRegToVariable(Reg, &g_Reg->ASIC_HOST_SECBYTE, "ASIC_HOST_SECBYTE"); break; - case 0x05000530: MoveArmRegToVariable(Reg, &g_Reg->ASIC_SEC_BYTE, "ASIC_SEC_BYTE"); break; - case 0x05000548: MoveArmRegToVariable(Reg, &g_Reg->ASIC_TEST_PIN_SEL, "ASIC_TEST_PIN_SEL"); break; + case 0x05000528: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->ASIC_HOST_SECBYTE, "ASIC_HOST_SECBYTE"); break; + case 0x05000530: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->ASIC_SEC_BYTE, "ASIC_SEC_BYTE"); break; + case 0x05000548: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->ASIC_TEST_PIN_SEL, "ASIC_TEST_PIN_SEL"); break; } break; } case 0x1FC00000: - MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); + m_Assembler.MoveArmRegToVariable(Reg, PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); break; default: - CPU_Message(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); + m_CodeBlock.Log(" should be moving %s in to %08X ?", ArmRegName(Reg), VAddr); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -6992,7 +7005,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr) } } -void CArmRecompilerOps::LB_KnownAddress(ArmReg Reg, uint32_t VAddr, bool SignExtend) +void CArmRecompilerOps::LB_KnownAddress(CArmOps::ArmReg Reg, uint32_t VAddr, bool SignExtend) { m_RegWorkingSet.SetArmRegProtected(Reg, true); @@ -7009,7 +7022,7 @@ void CArmRecompilerOps::LB_KnownAddress(ArmReg Reg, uint32_t VAddr, bool SignExt return; } - ArmReg TempReg = Arm_Unknown; + CArmOps::ArmReg TempReg = CArmOps::Arm_Unknown; switch (PAddr & 0xFFF00000) { case 0x00000000: @@ -7021,31 +7034,31 @@ void CArmRecompilerOps::LB_KnownAddress(ArmReg Reg, uint32_t VAddr, bool SignExt case 0x00600000: case 0x00700000: case 0x10000000: - TempReg = Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempReg, (uint32_t)PAddr + (uint32_t)g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); - LoadArmRegPointerByteToArmReg(Reg, TempReg, 0); - SignExtendByte(Reg); + TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempReg, (uint32_t)PAddr + (uint32_t)g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); + m_Assembler.LoadArmRegPointerByteToArmReg(Reg, TempReg, 0); + m_Assembler.SignExtendByte(Reg); break; default: - CPU_Message(" should be loading from %08X ?", VAddr); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } } -void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) +void CArmRecompilerOps::LW_KnownAddress(CArmOps::ArmReg Reg, uint32_t VAddr) { m_RegWorkingSet.SetArmRegProtected(Reg, true); if (VAddr < 0x80000000 || VAddr >= 0xC0000000) { - ArmReg TempReg = Map_TempReg(Arm_Any, -1, false); - ArmReg TempRegAddress = Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempRegAddress, VAddr); - ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); - ArmReg ReadMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_READMAP); - LoadArmRegPointerToArmReg(TempReg, ReadMapReg, TempReg, 2); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + CArmOps::ArmReg TempRegAddress = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempRegAddress, VAddr); + m_Assembler.ShiftRightUnsignImmed(TempReg, TempRegAddress, 12); + CArmOps::ArmReg ReadMapReg = Map_Variable(CArmRegInfo::VARIABLE_TLB_READMAP); + m_Assembler.LoadArmRegPointerToArmReg(TempReg, ReadMapReg, TempReg, 2); CompileReadTLBMiss(TempRegAddress, TempReg); - LoadArmRegPointerToArmReg(Reg, TempReg, TempRegAddress, 0); + m_Assembler.LoadArmRegPointerToArmReg(Reg, TempReg, TempRegAddress, 0); m_RegWorkingSet.SetArmRegProtected(TempReg, false); m_RegWorkingSet.SetArmRegProtected(TempRegAddress, false); } @@ -7057,7 +7070,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) g_Notify->BreakPoint(__FILE__, __LINE__); } - ArmReg TempReg; + CArmOps::ArmReg TempReg; switch (PAddr & 0xFFF00000) { case 0x00000000: @@ -7068,29 +7081,29 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) case 0x00500000: case 0x00600000: case 0x00700000: - TempReg = Map_TempReg(Arm_Any, -1, false); - MoveConstToArmReg(TempReg, (uint32_t)PAddr + (uint32_t)g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); - LoadArmRegPointerToArmReg(Reg, TempReg, 0); + TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); + m_Assembler.MoveConstToArmReg(TempReg, (uint32_t)PAddr + (uint32_t)g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str()); + m_Assembler.LoadArmRegPointerToArmReg(Reg, TempReg, 0); break; case 0x04000000: if (PAddr < 0x04002000) { - MoveVariableToArmReg(PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str(), Reg); + m_Assembler.MoveVariableToArmReg(PAddr + g_MMU->Rdram(), stdstr_f("RDRAM + %X", PAddr).c_str(), Reg); break; } switch (PAddr) { - case 0x04040010: MoveVariableToArmReg(&g_Reg->SP_STATUS_REG, "SP_STATUS_REG", Reg); break; - case 0x04040014: MoveVariableToArmReg(&g_Reg->SP_DMA_FULL_REG, "SP_DMA_FULL_REG", Reg); break; - case 0x04040018: MoveVariableToArmReg(&g_Reg->SP_DMA_BUSY_REG, "SP_DMA_BUSY_REG", Reg); break; + case 0x04040010: m_Assembler.MoveVariableToArmReg(&g_Reg->SP_STATUS_REG, "SP_STATUS_REG", Reg); break; + case 0x04040014: m_Assembler.MoveVariableToArmReg(&g_Reg->SP_DMA_FULL_REG, "SP_DMA_FULL_REG", Reg); break; + case 0x04040018: m_Assembler.MoveVariableToArmReg(&g_Reg->SP_DMA_BUSY_REG, "SP_DMA_BUSY_REG", Reg); break; case 0x0404001C: - MoveVariableToArmReg(&g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG", Reg); - MoveConstToVariable(1, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); + m_Assembler.MoveVariableToArmReg(&g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG", Reg); + m_Assembler.MoveConstToVariable(1, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); break; - case 0x04080000: MoveVariableToArmReg(&g_Reg->SP_PC_REG, "SP_PC_REG", Reg); break; + case 0x04080000: m_Assembler.MoveVariableToArmReg(&g_Reg->SP_PC_REG, "SP_PC_REG", Reg); break; default: - CPU_Message(" should be loading from %08X ?", VAddr); - MoveConstToArmReg(Reg, (uint32_t)0); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -7100,23 +7113,23 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) case 0x04100000: ArmBreakPoint(__FILE__, __LINE__); /*m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R1, PAddr); - MoveConstToArmReg(Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); - StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, PAddr); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R1, CArmOps::Arm_R2, 0); CallFunction((void *)CMipsMemoryVM::Load32DPCommand, "CMipsMemoryVM::Load32DPCommand"); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg);*/ + m_Assembler.MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg);*/ break; case 0x04300000: switch (PAddr) { - case 0x04300000: MoveVariableToArmReg(&g_Reg->MI_MODE_REG, "MI_MODE_REG", Reg); break; - case 0x04300004: MoveVariableToArmReg(&g_Reg->MI_VERSION_REG, "MI_VERSION_REG", Reg); break; - case 0x04300008: MoveVariableToArmReg(&g_Reg->MI_INTR_REG, "MI_INTR_REG", Reg); break; - case 0x0430000C: MoveVariableToArmReg(&g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG", Reg); break; + case 0x04300000: m_Assembler.MoveVariableToArmReg(&g_Reg->MI_MODE_REG, "MI_MODE_REG", Reg); break; + case 0x04300004: m_Assembler.MoveVariableToArmReg(&g_Reg->MI_VERSION_REG, "MI_VERSION_REG", Reg); break; + case 0x04300008: m_Assembler.MoveVariableToArmReg(&g_Reg->MI_INTR_REG, "MI_INTR_REG", Reg); break; + case 0x0430000C: m_Assembler.MoveVariableToArmReg(&g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG", Reg); break; default: - CPU_Message(" should be loading from %08X ?", VAddr); - MoveConstToArmReg(Reg, (uint32_t)0); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -7132,14 +7145,14 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_MMU); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_MMU); CallFunction(AddressOf(&CMipsMemoryVM::UpdateHalfLine), "CMipsMemoryVM::UpdateHalfLine"); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg((void *)&g_MMU->m_HalfLine, "MMU->m_HalfLine", Reg);*/ + m_Assembler.MoveVariableToArmReg((void *)&g_MMU->m_HalfLine, "MMU->m_HalfLine", Reg);*/ break; default: - CPU_Message(" should be loading from %08X ?", VAddr); - MoveConstToArmReg(Reg, (uint32_t)0); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -7157,12 +7170,12 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Audio, "g_Audio"); CallFunction(AddressOf(&CAudio::GetLength), "CAudio::GetLength"); - MoveConstToArmReg(Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); - StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R0, CArmOps::Arm_R1, 0); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg);*/ + m_Assembler.MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg);*/ } else { @@ -7170,14 +7183,14 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) { m_RegWorkingSet.BeforeCallDirect(); CallFunction((void *)g_Plugins->Audio()->AiReadLength, "AiReadLength"); - MoveConstToArmReg(Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); - StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R0, CArmOps::Arm_R1, 0); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg); + m_Assembler.MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg); } else { - MoveConstToArmReg(Reg, (uint32_t)0); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); } } break; @@ -7186,21 +7199,21 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) { ArmBreakPoint(__FILE__, __LINE__); /*m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_Audio, "g_Audio"); CallFunction(AddressOf(&CAudio::GetStatus), "CAudio::GetStatus"); - MoveConstToArmReg(Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); - StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R0, CArmOps::Arm_R1, 0); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg);*/ + m_Assembler.MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg);*/ } else { - MoveVariableToArmReg(&g_Reg->AI_STATUS_REG, "AI_STATUS_REG", Reg); + m_Assembler.MoveVariableToArmReg(&g_Reg->AI_STATUS_REG, "AI_STATUS_REG", Reg); } break; default: - CPU_Message(" should be loading from %08X ?", VAddr); - MoveConstToArmReg(Reg, (uint32_t)0); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -7210,22 +7223,22 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) case 0x04600000: switch (PAddr) { - case 0x04600000: MoveVariableToArmReg(&g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG", Reg); break; - case 0x04600004: MoveVariableToArmReg(&g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG", Reg); break; - case 0x04600008: MoveVariableToArmReg(&g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG", Reg); break; - case 0x0460000C: MoveVariableToArmReg(&g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG", Reg); break; - case 0x04600010: MoveVariableToArmReg(&g_Reg->PI_STATUS_REG, "PI_STATUS_REG", Reg); break; - case 0x04600014: MoveVariableToArmReg(&g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG", Reg); break; - case 0x04600018: MoveVariableToArmReg(&g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG", Reg); break; - case 0x0460001C: MoveVariableToArmReg(&g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG", Reg); break; - case 0x04600020: MoveVariableToArmReg(&g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG", Reg); break; - case 0x04600024: MoveVariableToArmReg(&g_Reg->PI_DOMAIN2_REG, "PI_DOMAIN2_REG", Reg); break; - case 0x04600028: MoveVariableToArmReg(&g_Reg->PI_BSD_DOM2_PWD_REG, "PI_BSD_DOM2_PWD_REG", Reg); break; - case 0x0460002C: MoveVariableToArmReg(&g_Reg->PI_BSD_DOM2_PGS_REG, "PI_BSD_DOM2_PGS_REG", Reg); break; - case 0x04600030: MoveVariableToArmReg(&g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG", Reg); break; + case 0x04600000: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG", Reg); break; + case 0x04600004: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG", Reg); break; + case 0x04600008: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG", Reg); break; + case 0x0460000C: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG", Reg); break; + case 0x04600010: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_STATUS_REG, "PI_STATUS_REG", Reg); break; + case 0x04600014: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG", Reg); break; + case 0x04600018: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG", Reg); break; + case 0x0460001C: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG", Reg); break; + case 0x04600020: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG", Reg); break; + case 0x04600024: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_DOMAIN2_REG, "PI_DOMAIN2_REG", Reg); break; + case 0x04600028: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_BSD_DOM2_PWD_REG, "PI_BSD_DOM2_PWD_REG", Reg); break; + case 0x0460002C: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_BSD_DOM2_PGS_REG, "PI_BSD_DOM2_PGS_REG", Reg); break; + case 0x04600030: m_Assembler.MoveVariableToArmReg(&g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG", Reg); break; default: - CPU_Message(" should be loading from %08X ?", VAddr); - MoveConstToArmReg(Reg, (uint32_t)0); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -7235,11 +7248,11 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) case 0x04700000: switch (PAddr) { - case 0x0470000C: MoveVariableToArmReg(&g_Reg->RI_SELECT_REG, "RI_SELECT_REG", Reg); break; - case 0x04700010: MoveVariableToArmReg(&g_Reg->RI_REFRESH_REG, "RI_REFRESH_REG", Reg); break; + case 0x0470000C: m_Assembler.MoveVariableToArmReg(&g_Reg->RI_SELECT_REG, "RI_SELECT_REG", Reg); break; + case 0x04700010: m_Assembler.MoveVariableToArmReg(&g_Reg->RI_REFRESH_REG, "RI_REFRESH_REG", Reg); break; default: - CPU_Message(" should be loading from %08X ?", VAddr); - MoveConstToArmReg(Reg, (uint32_t)0); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -7249,11 +7262,11 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) case 0x04800000: switch (PAddr) { - case 0x04800000: MoveVariableToArmReg(&g_Reg->SI_DRAM_ADDR_REG, "SI_DRAM_ADDR_REG", Reg); break; - case 0x04800018: MoveVariableToArmReg(&g_Reg->SI_STATUS_REG, "SI_STATUS_REG", Reg); break; + case 0x04800000: m_Assembler.MoveVariableToArmReg(&g_Reg->SI_DRAM_ADDR_REG, "SI_DRAM_ADDR_REG", Reg); break; + case 0x04800018: m_Assembler.MoveVariableToArmReg(&g_Reg->SI_STATUS_REG, "SI_STATUS_REG", Reg); break; default: - CPU_Message(" should be loading from %08X ?", VAddr); - MoveConstToArmReg(Reg, (uint32_t)0); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -7266,33 +7279,33 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) { switch (PAddr) { - case 0x05000500: MoveVariableToArmReg(&g_Reg->ASIC_DATA, "ASIC_DATA", Reg); break; - case 0x05000504: MoveVariableToArmReg(&g_Reg->ASIC_MISC_REG, "ASIC_MISC_REG", Reg); break; + case 0x05000500: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_DATA, "ASIC_DATA", Reg); break; + case 0x05000504: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_MISC_REG, "ASIC_MISC_REG", Reg); break; case 0x05000508: - MoveVariableToArmReg(&g_Reg->ASIC_STATUS, "ASIC_STATUS", Reg); + m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_STATUS, "ASIC_STATUS", Reg); m_RegWorkingSet.BeforeCallDirect(); CallFunction(AddressOf(&DiskGapSectorCheck), "DiskGapSectorCheck"); m_RegWorkingSet.AfterCallDirect(); break; - case 0x0500050C: MoveVariableToArmReg(&g_Reg->ASIC_CUR_TK, "ASIC_CUR_TK", Reg); break; - case 0x05000510: MoveVariableToArmReg(&g_Reg->ASIC_BM_STATUS, "ASIC_BM_STATUS", Reg); break; - case 0x05000514: MoveVariableToArmReg(&g_Reg->ASIC_ERR_SECTOR, "ASIC_ERR_SECTOR", Reg); break; - case 0x05000518: MoveVariableToArmReg(&g_Reg->ASIC_SEQ_STATUS, "ASIC_SEQ_STATUS", Reg); break; - case 0x0500051C: MoveVariableToArmReg(&g_Reg->ASIC_CUR_SECTOR, "ASIC_CUR_SECTOR", Reg); break; - case 0x05000520: MoveVariableToArmReg(&g_Reg->ASIC_HARD_RESET, "ASIC_HARD_RESET", Reg); break; - case 0x05000524: MoveVariableToArmReg(&g_Reg->ASIC_C1_S0, "ASIC_C1_S0", Reg); break; - case 0x05000528: MoveVariableToArmReg(&g_Reg->ASIC_HOST_SECBYTE, "ASIC_HOST_SECBYTE", Reg); break; - case 0x0500052C: MoveVariableToArmReg(&g_Reg->ASIC_C1_S2, "ASIC_C1_S2", Reg); break; - case 0x05000530: MoveVariableToArmReg(&g_Reg->ASIC_SEC_BYTE, "ASIC_SEC_BYTE", Reg); break; - case 0x05000534: MoveVariableToArmReg(&g_Reg->ASIC_C1_S4, "ASIC_C1_S4", Reg); break; - case 0x05000538: MoveVariableToArmReg(&g_Reg->ASIC_C1_S6, "ASIC_C1_S6", Reg); break; - case 0x0500053C: MoveVariableToArmReg(&g_Reg->ASIC_CUR_ADDR, "ASIC_CUR_ADDR", Reg); break; - case 0x05000540: MoveVariableToArmReg(&g_Reg->ASIC_ID_REG, "ASIC_ID_REG", Reg); break; - case 0x05000544: MoveVariableToArmReg(&g_Reg->ASIC_TEST_REG, "ASIC_TEST_REG", Reg); break; - case 0x05000548: MoveVariableToArmReg(&g_Reg->ASIC_TEST_PIN_SEL, "ASIC_TEST_PIN_SEL", Reg); break; + case 0x0500050C: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_CUR_TK, "ASIC_CUR_TK", Reg); break; + case 0x05000510: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_BM_STATUS, "ASIC_BM_STATUS", Reg); break; + case 0x05000514: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_ERR_SECTOR, "ASIC_ERR_SECTOR", Reg); break; + case 0x05000518: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_SEQ_STATUS, "ASIC_SEQ_STATUS", Reg); break; + case 0x0500051C: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_CUR_SECTOR, "ASIC_CUR_SECTOR", Reg); break; + case 0x05000520: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_HARD_RESET, "ASIC_HARD_RESET", Reg); break; + case 0x05000524: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_C1_S0, "ASIC_C1_S0", Reg); break; + case 0x05000528: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_HOST_SECBYTE, "ASIC_HOST_SECBYTE", Reg); break; + case 0x0500052C: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_C1_S2, "ASIC_C1_S2", Reg); break; + case 0x05000530: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_SEC_BYTE, "ASIC_SEC_BYTE", Reg); break; + case 0x05000534: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_C1_S4, "ASIC_C1_S4", Reg); break; + case 0x05000538: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_C1_S6, "ASIC_C1_S6", Reg); break; + case 0x0500053C: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_CUR_ADDR, "ASIC_CUR_ADDR", Reg); break; + case 0x05000540: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_ID_REG, "ASIC_ID_REG", Reg); break; + case 0x05000544: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_TEST_REG, "ASIC_TEST_REG", Reg); break; + case 0x05000548: m_Assembler.MoveVariableToArmReg(&g_Reg->ASIC_TEST_PIN_SEL, "ASIC_TEST_PIN_SEL", Reg); break; default: - CPU_Message(" should be loading from %08X ?", VAddr); - MoveConstToArmReg(Reg, (uint32_t)0); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -7301,28 +7314,28 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr) } else { - MoveConstToArmReg(Reg, (uint32_t)((PAddr & 0xFFFF) << 16) | (PAddr & 0xFFFF)); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)((PAddr & 0xFFFF) << 16) | (PAddr & 0xFFFF)); } break; case 0x06000000: ArmBreakPoint(__FILE__, __LINE__); /*m_RegWorkingSet.BeforeCallDirect(); - MoveConstToArmReg(Arm_R1, PAddr); - MoveConstToArmReg(Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); - StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R1, PAddr); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); + m_Assembler.StoreArmRegToArmRegPointer(CArmOps::Arm_R1, CArmOps::Arm_R2, 0); CallFunction((void *)CMipsMemoryVM::Load32CartridgeDomain1Address1, "CMipsMemoryVM::Load32CartridgeDomain1Address1"); m_RegWorkingSet.AfterCallDirect(); - MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg);*/ + m_Assembler.MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg);*/ break; default: if ((PAddr & 0xF0000000) == 0x10000000 && (PAddr - 0x10000000) < g_Rom->GetRomSize()) { uint32_t RomOffset = PAddr - 0x10000000; - MoveVariableToArmReg(RomOffset + g_Rom->GetRomAddress(), stdstr_f("ROM + %X", RomOffset).c_str(), Reg); // Read from ROM + m_Assembler.MoveVariableToArmReg(RomOffset + g_Rom->GetRomAddress(), stdstr_f("ROM + %X", RomOffset).c_str(), Reg); // Read from ROM } else { - CPU_Message(" should be loading from %08X ?", VAddr); + m_CodeBlock.Log(" should be loading from %08X ?", VAddr); if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } } diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h index 908faedbb..501c28575 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h @@ -1,27 +1,38 @@ #pragma once #if defined(__arm__) || defined(_M_ARM) + #include +#include +#include +#include #include #include -#include +#include +#include +#include +#include +#include + +class CCodeBlock; +class CCodeSection; class CArmRecompilerOps : - public CRecompilerOps, - private CArmOps, - protected CSystemRegisters, + protected R4300iOp, + protected CN64SystemSettings, + protected CRecompilerSettings, private CGameSettings { public: - CArmRecompilerOps(CMipsMemoryVM & MMU); + CArmRecompilerOps(CMipsMemoryVM & MMU, CCodeBlock & CodeBlock); ~CArmRecompilerOps(); // Trap functions - void Compile_TrapCompare(TRAP_COMPARE CompareType); + void Compile_TrapCompare(RecompilerTrapCompare CompareType); // Branch functions - void Compile_BranchCompare(BRANCH_COMPARE CompareType); - void Compile_Branch(BRANCH_COMPARE CompareType, bool Link); - void Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link); + void Compile_BranchCompare(RecompilerBranchCompare CompareType); + void Compile_Branch(RecompilerBranchCompare CompareType, bool Link); + void Compile_BranchLikely(RecompilerBranchCompare CompareType, bool Link); void BNE_Compare(); void BEQ_Compare(); void BGTZ_Compare(); @@ -191,7 +202,6 @@ public: // Other functions void UnknownOpcode(); -private: void EnterCodeBlock(); void ExitCodeBlock(); void CompileExitCode(); @@ -199,83 +209,90 @@ private: void CompileInPermLoop(CRegInfo & RegSet, uint32_t ProgramCounter); void OutputRegisterState(const CRegInfo & SyncTo, const CRegInfo & CurrentSet) const; void SyncRegState(const CRegInfo & SyncTo); - bool SetupRegisterForLoop(CCodeBlock * BlockInfo, const CRegInfo & RegSet); + bool SetupRegisterForLoop(CCodeBlock & BlockInfo, const CRegInfo & RegSet); CRegInfo & GetRegWorkingSet(void); void SetRegWorkingSet(const CRegInfo & RegInfo); bool InheritParentInfo(); void LinkJump(CJumpInfo & JumpInfo, uint32_t SectionID = -1, uint32_t FromSectionID = -1); - void JumpToSection( CCodeSection * Section); + void JumpToSection(CCodeSection * Section); void JumpToUnknown(CJumpInfo * JumpInfo); void SetCurrentPC(uint32_t ProgramCounter); uint32_t GetCurrentPC(void); void SetCurrentSection(CCodeSection * section); void SetNextStepType(PIPELINE_STAGE StepType); - PIPELINE_STAGE GetNextStepType( void ); - const R4300iOpcode & GetOpcode ( void ) const; + PIPELINE_STAGE GetNextStepType(void); + const R4300iOpcode & GetOpcode(void) const; void PreCompileOpcode(void); - void PostCompileOpcode ( void ); - void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason); + void PostCompileOpcode(void); + void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason Reason); void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason, CArmOps::ArmCompareType CompareType); - static void UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles); + + void CompileReadTLBMiss(CArmOps::ArmReg AddressReg, CArmOps::ArmReg LookUpReg); + void CompileWriteTLBMiss(CArmOps::ArmReg AddressReg, CArmOps::ArmReg LookUpReg); + void UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles); void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false, bool UpdateTimer = true); void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet); - void CompileReadTLBMiss(ArmReg AddressReg, ArmReg LookUpReg); - void CompileWriteTLBMiss(ArmReg AddressReg, ArmReg LookUpReg); void CompileExecuteBP(void); void CompileExecuteDelaySlotBP(void); + CArmOps & Assembler() { return m_Assembler; } + // Helper functions typedef CRegInfo::REG_STATE REG_STATE; - static inline REG_STATE GetMipsRegState(int32_t Reg) { return m_RegWorkingSet.GetMipsRegState(Reg); } - static inline uint64_t GetMipsReg(int32_t Reg) { return m_RegWorkingSet.GetMipsReg(Reg); } - static inline uint32_t GetMipsRegLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo(Reg); } - static inline int32_t GetMipsRegLo_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); } - static inline uint32_t GetMipsRegHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi(Reg); } - static inline int32_t GetMipsRegHi_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); } - static inline ArmReg GetMipsRegMapLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); } - static inline ArmReg GetMipsRegMapHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); } + REG_STATE GetMipsRegState(int32_t Reg) { return m_RegWorkingSet.GetMipsRegState(Reg); } + uint64_t GetMipsReg(int32_t Reg) { return m_RegWorkingSet.GetMipsReg(Reg); } + uint32_t GetMipsRegLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo(Reg); } + int32_t GetMipsRegLo_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); } + uint32_t GetMipsRegHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi(Reg); } + int32_t GetMipsRegHi_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); } + CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); } + CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); } - static inline bool IsKnown(int32_t Reg) { return m_RegWorkingSet.IsKnown(Reg); } - static inline bool IsUnknown(int32_t Reg) { return m_RegWorkingSet.IsUnknown(Reg); } - static inline bool IsMapped(int32_t Reg) { return m_RegWorkingSet.IsMapped(Reg); } - static inline bool IsConst(int32_t Reg) { return m_RegWorkingSet.IsConst(Reg); } - static inline bool IsSigned(int32_t Reg) { return m_RegWorkingSet.IsSigned(Reg); } - static inline bool IsUnsigned(int32_t Reg) { return m_RegWorkingSet.IsUnsigned(Reg); } - static inline bool Is32Bit(int32_t Reg) { return m_RegWorkingSet.Is32Bit(Reg); } - static inline bool Is64Bit(int32_t Reg) { return m_RegWorkingSet.Is64Bit(Reg); } - static inline bool Is32BitMapped(int32_t Reg) { return m_RegWorkingSet.Is32BitMapped(Reg); } - static inline bool Is64BitMapped(int32_t Reg) { return m_RegWorkingSet.Is64BitMapped(Reg); } - static inline void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad); } - static inline void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad); } - static inline void UnMap_GPR(uint32_t Reg, bool WriteBackValue){ m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue); } - static inline void WriteBack_GPR(uint32_t Reg, bool Unmapping){ m_RegWorkingSet.WriteBack_GPR(Reg, Unmapping); } - static inline ArmReg Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadHiWord) { return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord); } - static inline ArmReg Map_Variable(CArmRegInfo::VARIABLE_MAPPED variable, ArmReg Reg = Arm_Any) { return m_RegWorkingSet.Map_Variable(variable, Reg); } + bool IsKnown(int32_t Reg) { return m_RegWorkingSet.IsKnown(Reg); } + bool IsUnknown(int32_t Reg) { return m_RegWorkingSet.IsUnknown(Reg); } + bool IsMapped(int32_t Reg) { return m_RegWorkingSet.IsMapped(Reg); } + bool IsConst(int32_t Reg) { return m_RegWorkingSet.IsConst(Reg); } + bool IsSigned(int32_t Reg) { return m_RegWorkingSet.IsSigned(Reg); } + bool IsUnsigned(int32_t Reg) { return m_RegWorkingSet.IsUnsigned(Reg); } + bool Is32Bit(int32_t Reg) { return m_RegWorkingSet.Is32Bit(Reg); } + bool Is64Bit(int32_t Reg) { return m_RegWorkingSet.Is64Bit(Reg); } + bool Is32BitMapped(int32_t Reg) { return m_RegWorkingSet.Is32BitMapped(Reg); } + bool Is64BitMapped(int32_t Reg) { return m_RegWorkingSet.Is64BitMapped(Reg); } + void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad); } + void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad); } + void UnMap_GPR(uint32_t Reg, bool WriteBackValue){ m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue); } + void WriteBack_GPR(uint32_t Reg, bool Unmapping){ m_RegWorkingSet.WriteBack_GPR(Reg, Unmapping); } + CArmOps::ArmReg Map_TempReg(CArmOps::ArmReg Reg, int32_t MipsReg, bool LoadHiWord) { return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord); } + CArmOps::ArmReg Map_Variable(CArmRegInfo::VARIABLE_MAPPED variable, CArmOps::ArmReg Reg = CArmOps::Arm_Any) { return m_RegWorkingSet.Map_Variable(variable, Reg); } - static inline void ResetRegProtection() { m_RegWorkingSet.ResetRegProtection(); } - static inline void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod) { m_RegWorkingSet.FixRoundModel(RoundMethod); } + void ResetRegProtection() { m_RegWorkingSet.ResetRegProtection(); } + void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod) { m_RegWorkingSet.FixRoundModel(RoundMethod); } - static inline void ProtectGPR(uint32_t Reg) { m_RegWorkingSet.ProtectGPR(Reg); } - static inline void UnProtectGPR(uint32_t Reg) { m_RegWorkingSet.UnProtectGPR(Reg); } - static inline bool UnMap_ArmReg(ArmReg Reg) { return m_RegWorkingSet.UnMap_ArmReg(Reg); } + void ProtectGPR(uint32_t Reg) { m_RegWorkingSet.ProtectGPR(Reg); } + void UnProtectGPR(uint32_t Reg) { m_RegWorkingSet.UnProtectGPR(Reg); } + bool UnMap_ArmReg(CArmOps::ArmReg Reg) { return m_RegWorkingSet.UnMap_ArmReg(Reg); } void SW(bool bCheckLLbit); void SW_Const(uint32_t Value, uint32_t VAddr); - void SW_Register(ArmReg Reg, uint32_t VAddr); + void SW_Register(CArmOps::ArmReg Reg, uint32_t VAddr); void LW(bool ResultSigned, bool bRecordLLBit); - void LB_KnownAddress(ArmReg Reg, uint32_t VAddr, bool SignExtend); - void LW_KnownAddress(ArmReg Reg, uint32_t VAddr); + void LB_KnownAddress(CArmOps::ArmReg Reg, uint32_t VAddr, bool SignExtend); + void LW_KnownAddress(CArmOps::ArmReg Reg, uint32_t VAddr); void CompileInterpterCall (void * Function, const char * FunctionName); void OverflowDelaySlot(bool TestTimer); EXIT_LIST m_ExitInfo; CMipsMemoryVM & m_MMU; + CCodeBlock & m_CodeBlock; + CArmOps m_Assembler; PIPELINE_STAGE m_PipelineStage; uint32_t m_CompilePC; R4300iOpcode m_Opcode; + CArmRegInfo m_RegWorkingSet; CCodeSection * m_Section; - + CRegInfo m_RegBeforeDelay; + bool m_EffectDelaySlot; static uint32_t m_TempValue; }; diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp index 6edc42aa4..a4ac3615c 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp @@ -3,16 +3,18 @@ #if defined(__arm__) || defined(_M_ARM) #include #include -#include +#include #include -CArmRegInfo::CArmRegInfo() : +CArmRegInfo::CArmRegInfo(CCodeBlock & CodeBlock, CArmOps & Assembler) : + m_CodeBlock(CodeBlock), + m_Assembler(Assembler), m_InCallDirect(false) { for (int32_t i = 0; i < 32; i++) { - m_RegMapLo[i] = Arm_Unknown; - m_RegMapHi[i] = Arm_Unknown; + m_RegMapLo[i] = CArmOps::Arm_Unknown; + m_RegMapHi[i] = CArmOps::Arm_Unknown; } for (int32_t i = 0, n = sizeof(m_ArmReg_MappedTo) / sizeof(m_ArmReg_MappedTo[0]); i < n; i++) @@ -24,7 +26,9 @@ CArmRegInfo::CArmRegInfo() : } } -CArmRegInfo::CArmRegInfo(const CArmRegInfo& rhs) +CArmRegInfo::CArmRegInfo(const CArmRegInfo& rhs) : + m_CodeBlock(rhs.m_CodeBlock), + m_Assembler(rhs.m_CodeBlock.RecompilerOps()->Assembler()) { *this = rhs; } @@ -76,7 +80,7 @@ bool CArmRegInfo::operator==(const CArmRegInfo& right) const return true; } -bool CArmRegInfo::ShouldPushPopReg(ArmReg Reg) +bool CArmRegInfo::ShouldPushPopReg(CArmOps::ArmReg Reg) { if (m_ArmReg_MappedTo[Reg] == NotMapped) { @@ -93,21 +97,21 @@ void CArmRegInfo::BeforeCallDirect(void) { static uint32_t PushPopRegisterList[] = { - ArmPushPop_R0, ArmPushPop_R1, ArmPushPop_R2, ArmPushPop_R3, ArmPushPop_R4, - ArmPushPop_R5, ArmPushPop_R6, ArmPushPop_R7, ArmPushPop_R8, ArmPushPop_R9, - ArmPushPop_R10, ArmPushPop_R11, ArmPushPop_R12 + CArmOps::ArmPushPop_R0, CArmOps::ArmPushPop_R1, CArmOps::ArmPushPop_R2, CArmOps::ArmPushPop_R3, CArmOps::ArmPushPop_R4, + CArmOps::ArmPushPop_R5, CArmOps::ArmPushPop_R6, CArmOps::ArmPushPop_R7, CArmOps::ArmPushPop_R8, CArmOps::ArmPushPop_R9, + CArmOps::ArmPushPop_R10, CArmOps::ArmPushPop_R11, CArmOps::ArmPushPop_R12 }; - static ArmReg RegisterList[] = + static CArmOps::ArmReg RegisterList[] = { - Arm_R0, Arm_R1, Arm_R2, Arm_R3, Arm_R4, - Arm_R5, Arm_R6, Arm_R7, Arm_R8, Arm_R9, - Arm_R10, Arm_R11, Arm_R12 + CArmOps::Arm_R0, CArmOps::Arm_R1, CArmOps::Arm_R2, CArmOps::Arm_R3, CArmOps::Arm_R4, + CArmOps::Arm_R5, CArmOps::Arm_R6, CArmOps::Arm_R7, CArmOps::Arm_R8, CArmOps::Arm_R9, + CArmOps::Arm_R10, CArmOps::Arm_R11, CArmOps::Arm_R12 }; if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -124,7 +128,7 @@ void CArmRegInfo::BeforeCallDirect(void) return; } - if ((PushPopRegisterSize(PushPopRegisters) % 8) != 0) + if ((m_Assembler.PushPopRegisterSize(PushPopRegisters) % 8) != 0) { bool Added = false; for (int i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++) @@ -139,42 +143,42 @@ void CArmRegInfo::BeforeCallDirect(void) } if (!Added) { - ArmReg reg = FreeArmReg(false); - CPU_Message(" Freed %s", ArmRegName(reg)); + CArmOps::ArmReg reg = FreeArmReg(false); + m_CodeBlock.Log(" Freed %s", m_Assembler.ArmRegName(reg)); PushPopRegisters = 0; for (int i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++) { if (ShouldPushPopReg(RegisterList[i])) { PushPopRegisters |= PushPopRegisterList[i]; } } } - if ((PushPopRegisterSize(PushPopRegisters) % 8) != 0) + if ((m_Assembler.PushPopRegisterSize(PushPopRegisters) % 8) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); } } m_InCallDirect = true; - PushArmReg(PushPopRegisters); + m_Assembler.PushArmReg(PushPopRegisters); } void CArmRegInfo::AfterCallDirect(void) { static uint32_t PushPopRegisterList[] = { - ArmPushPop_R0, ArmPushPop_R1, ArmPushPop_R2, ArmPushPop_R3, ArmPushPop_R4, - ArmPushPop_R5, ArmPushPop_R6, ArmPushPop_R7, ArmPushPop_R8, ArmPushPop_R9, - ArmPushPop_R10, ArmPushPop_R11, ArmPushPop_R12, ArmPushPop_LR, ArmPushPop_PC + CArmOps::ArmPushPop_R0, CArmOps::ArmPushPop_R1, CArmOps::ArmPushPop_R2, CArmOps::ArmPushPop_R3, CArmOps::ArmPushPop_R4, + CArmOps::ArmPushPop_R5, CArmOps::ArmPushPop_R6, CArmOps::ArmPushPop_R7, CArmOps::ArmPushPop_R8, CArmOps::ArmPushPop_R9, + CArmOps::ArmPushPop_R10, CArmOps::ArmPushPop_R11, CArmOps::ArmPushPop_R12, CArmOps::ArmPushPop_LR, CArmOps::ArmPushPop_PC }; - static ArmReg RegisterList[] = + static CArmOps::ArmReg RegisterList[] = { - Arm_R0, Arm_R1, Arm_R2, Arm_R3, Arm_R4, - Arm_R5, Arm_R6, Arm_R7, Arm_R8, Arm_R9, - Arm_R10, Arm_R11, Arm_R12, ArmRegLR, ArmRegPC, + CArmOps::Arm_R0, CArmOps::Arm_R1, CArmOps::Arm_R2, CArmOps::Arm_R3, CArmOps::Arm_R4, + CArmOps::Arm_R5, CArmOps::Arm_R6, CArmOps::Arm_R7, CArmOps::Arm_R8, CArmOps::Arm_R9, + CArmOps::Arm_R10, CArmOps::Arm_R11, CArmOps::Arm_R12, CArmOps::ArmRegLR, CArmOps::ArmRegPC, }; if (!m_InCallDirect) { - CPU_Message("%s: Not in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: Not in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -187,7 +191,7 @@ void CArmRegInfo::AfterCallDirect(void) if (PushPopRegisters != 0) { - if ((PushPopRegisterSize(PushPopRegisters) % 8) != 0) + if ((m_Assembler.PushPopRegisterSize(PushPopRegisters) % 8) != 0) { for (int i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++) { @@ -199,7 +203,7 @@ void CArmRegInfo::AfterCallDirect(void) break; } } - PopArmReg(PushPopRegisters); + m_Assembler.PopArmReg(PushPopRegisters); } SetRoundingModel(CRegInfo::RoundUnknown); @@ -210,7 +214,7 @@ void CArmRegInfo::FixRoundModel(FPU_ROUND RoundMethod) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -219,13 +223,13 @@ void CArmRegInfo::FixRoundModel(FPU_ROUND RoundMethod) { return; } - CPU_Message(" FixRoundModel: CurrentRoundingModel: %s targetRoundModel: %s", RoundingModelName(GetRoundingModel()), RoundingModelName(RoundMethod)); + m_CodeBlock.Log(" FixRoundModel: CurrentRoundingModel: %s targetRoundModel: %s", RoundingModelName(GetRoundingModel()), RoundingModelName(RoundMethod)); if (RoundMethod == RoundDefault) { - m_RegWorkingSet.BeforeCallDirect(); - MoveVariableToArmReg(_RoundingModel, "_RoundingModel", Arm_R0); - CallFunction((void *)fesetround, "fesetround"); - m_RegWorkingSet.AfterCallDirect(); + BeforeCallDirect(); + m_Assembler.MoveVariableToArmReg(_RoundingModel, "_RoundingModel", CArmOps::Arm_R0); + m_Assembler.CallFunction((void *)fesetround, "fesetround"); + AfterCallDirect(); } else { @@ -237,12 +241,12 @@ void CArmRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } - ArmReg Reg; + CArmOps::ArmReg Reg; if (MipsReg == 0) { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -259,13 +263,13 @@ void CArmRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg return; } SetArmRegProtected(Reg, true); - CPU_Message(" regcache: allocate %s to %s", ArmRegName(Reg), CRegName::GPR[MipsReg]); + m_CodeBlock.Log(" regcache: allocate %s to %s", m_Assembler.ArmRegName(Reg), CRegName::GPR[MipsReg]); } else { if (Is64Bit(MipsReg)) { - CPU_Message(" regcache: unallocate %s from high 32-bit of %s", ArmRegName(GetMipsRegMapHi(MipsReg)), CRegName::GPR_Hi[MipsReg]); + m_CodeBlock.Log(" regcache: unallocate %s from high 32-bit of %s", m_Assembler.ArmRegName(GetMipsRegMapHi(MipsReg)), CRegName::GPR_Hi[MipsReg]); SetArmRegMapOrder(GetMipsRegMapHi(MipsReg), 0); SetArmRegMapped(GetMipsRegMapHi(MipsReg), NotMapped); SetArmRegProtected(GetMipsRegMapHi(MipsReg), false); @@ -273,12 +277,12 @@ void CArmRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg } Reg = GetMipsRegMapLo(MipsReg); } - for (int32_t count = 0; count <= Arm_R15; count++) + for (int32_t count = 0; count <= CArmOps::Arm_R15; count++) { - uint32_t Count = GetArmRegMapOrder((ArmReg)count); + uint32_t Count = GetArmRegMapOrder((CArmOps::ArmReg)count); if (Count > 0) { - SetArmRegMapOrder((ArmReg)count, Count + 1); + SetArmRegMapOrder((CArmOps::ArmReg)count, Count + 1); } } SetArmRegMapOrder(Reg, 1); @@ -287,25 +291,25 @@ void CArmRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg { if (IsUnknown(MipsRegToLoad)) { - ArmReg GprReg = Map_Variable(VARIABLE_GPR); - LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(MipsRegToLoad << 3), CRegName::GPR_Lo[MipsRegToLoad]); + CArmOps::ArmReg GprReg = Map_Variable(VARIABLE_GPR); + m_Assembler.LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(MipsRegToLoad << 3), CRegName::GPR_Lo[MipsRegToLoad]); SetArmRegProtected(GprReg, false); } else if (IsMapped(MipsRegToLoad)) { if (MipsReg != MipsRegToLoad) { - AddConstToArmReg(Reg, GetMipsRegMapLo(MipsRegToLoad), 0); + m_Assembler.AddConstToArmReg(Reg, GetMipsRegMapLo(MipsRegToLoad), 0); } } else { - MoveConstToArmReg(Reg, GetMipsRegLo(MipsRegToLoad)); + m_Assembler.MoveConstToArmReg(Reg, GetMipsRegLo(MipsRegToLoad)); } } else if (MipsRegToLoad == 0) { - MoveConstToArmReg(Reg, (uint32_t)0); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); } SetArmRegMapped(Reg, GPR_Mapped); SetArmRegProtected(Reg, true); @@ -317,12 +321,12 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } - ArmReg regHi, reglo; + CArmOps::ArmReg regHi, reglo; int32_t count; if (MipsReg == 0) @@ -353,8 +357,8 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) } SetArmRegProtected(reglo, true); - CPU_Message(" regcache: allocate %s to hi word of %s", ArmRegName(regHi), CRegName::GPR[MipsReg]); - CPU_Message(" regcache: allocate %s to low word of %s", ArmRegName(reglo), CRegName::GPR[MipsReg]); + m_CodeBlock.Log(" regcache: allocate %s to hi word of %s", m_Assembler.ArmRegName(regHi), CRegName::GPR[MipsReg]); + m_CodeBlock.Log(" regcache: allocate %s to low word of %s", m_Assembler.ArmRegName(reglo), CRegName::GPR[MipsReg]); } else { @@ -371,7 +375,7 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) } SetArmRegProtected(regHi, true); - CPU_Message(" regcache: allocate %s to hi word of %s", ArmRegName(regHi), CRegName::GPR[MipsReg]); + m_CodeBlock.Log(" regcache: allocate %s to hi word of %s", m_Assembler.ArmRegName(regHi), CRegName::GPR[MipsReg]); } else { @@ -379,12 +383,12 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) } } - for (int32_t count = 0; count <= Arm_R15; count++) + for (int32_t count = 0; count <= CArmOps::Arm_R15; count++) { - uint32_t Count = GetArmRegMapOrder((ArmReg)count); + uint32_t Count = GetArmRegMapOrder((CArmOps::ArmReg)count); if (Count > 0) { - SetArmRegMapOrder((ArmReg)count, Count + 1); + SetArmRegMapOrder((CArmOps::ArmReg)count, Count + 1); } } SetArmRegMapOrder(regHi, 1); @@ -394,9 +398,9 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) { if (IsUnknown(MipsRegToLoad)) { - ArmReg GprReg = Map_Variable(VARIABLE_GPR); - LoadArmRegPointerToArmReg(regHi, GprReg, (uint8_t)(MipsRegToLoad << 3) + 4, CRegName::GPR_Hi[MipsRegToLoad]); - LoadArmRegPointerToArmReg(reglo, GprReg, (uint8_t)(MipsRegToLoad << 3), CRegName::GPR_Lo[MipsRegToLoad]); + CArmOps::ArmReg GprReg = Map_Variable(VARIABLE_GPR); + m_Assembler.LoadArmRegPointerToArmReg(regHi, GprReg, (uint8_t)(MipsRegToLoad << 3) + 4, CRegName::GPR_Hi[MipsRegToLoad]); + m_Assembler.LoadArmRegPointerToArmReg(reglo, GprReg, (uint8_t)(MipsRegToLoad << 3), CRegName::GPR_Lo[MipsRegToLoad]); SetArmRegProtected(GprReg, false); } else if (IsMapped(MipsRegToLoad)) @@ -405,40 +409,40 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) { if (IsSigned(MipsRegToLoad)) { - ShiftRightSignImmed(regHi, GetMipsRegMapLo(MipsRegToLoad), 31); + m_Assembler.ShiftRightSignImmed(regHi, GetMipsRegMapLo(MipsRegToLoad), 31); } else { - MoveConstToArmReg(regHi, (uint32_t)0); + m_Assembler.MoveConstToArmReg(regHi, (uint32_t)0); } if (MipsReg != MipsRegToLoad) { - AddConstToArmReg(reglo, GetMipsRegMapLo(MipsRegToLoad), 0); + m_Assembler.AddConstToArmReg(reglo, GetMipsRegMapLo(MipsRegToLoad), 0); } } else if (MipsReg != MipsRegToLoad) { - AddConstToArmReg(regHi, GetMipsRegMapHi(MipsRegToLoad), 0); - AddConstToArmReg(reglo, GetMipsRegMapLo(MipsRegToLoad), 0); + m_Assembler.AddConstToArmReg(regHi, GetMipsRegMapHi(MipsRegToLoad), 0); + m_Assembler.AddConstToArmReg(reglo, GetMipsRegMapLo(MipsRegToLoad), 0); } } else { if (Is32Bit(MipsRegToLoad)) { - MoveConstToArmReg(regHi, (uint32_t)(IsSigned(MipsRegToLoad) ? GetMipsRegLo_S(MipsRegToLoad) >> 31 : 0)); + m_Assembler.MoveConstToArmReg(regHi, (uint32_t)(IsSigned(MipsRegToLoad) ? GetMipsRegLo_S(MipsRegToLoad) >> 31 : 0)); } else { - MoveConstToArmReg(regHi, GetMipsRegHi(MipsRegToLoad)); + m_Assembler.MoveConstToArmReg(regHi, GetMipsRegHi(MipsRegToLoad)); } - MoveConstToArmReg(reglo, GetMipsRegLo(MipsRegToLoad)); + m_Assembler.MoveConstToArmReg(reglo, GetMipsRegLo(MipsRegToLoad)); } } else if (MipsRegToLoad == 0) { - MoveConstToArmReg(regHi, (uint32_t)0); - MoveConstToArmReg(reglo, (uint32_t)0); + m_Assembler.MoveConstToArmReg(regHi, (uint32_t)0); + m_Assembler.MoveConstToArmReg(reglo, (uint32_t)0); } SetArmRegMapped(regHi, GPR_Mapped); SetArmRegMapped(reglo, GPR_Mapped); @@ -453,7 +457,7 @@ void CArmRegInfo::UnMap_GPR(uint32_t MipsReg, bool WriteBackValue) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -472,7 +476,7 @@ void CArmRegInfo::UnMap_GPR(uint32_t MipsReg, bool WriteBackValue) } if (IsUnknown(MipsReg)) { return; } - //CPU_Message("UnMap_GPR: State: %X\tReg: %s\tWriteBack: %s",State,CRegName::GPR[Reg],WriteBackValue?"true":"false"); + //m_CodeBlock.Log("UnMap_GPR: State: %X\tReg: %s\tWriteBack: %s",State,CRegName::GPR[Reg],WriteBackValue?"true":"false"); if (IsConst(MipsReg)) { SetMipsRegState(MipsReg, STATE_UNKNOWN); @@ -480,11 +484,11 @@ void CArmRegInfo::UnMap_GPR(uint32_t MipsReg, bool WriteBackValue) } if (Is64Bit(MipsReg)) { - CPU_Message(" regcache: unallocate %s from %s", ArmRegName(GetMipsRegMapHi(MipsReg)), CRegName::GPR_Hi[MipsReg]); + m_CodeBlock.Log(" regcache: unallocate %s from %s", m_Assembler.ArmRegName(GetMipsRegMapHi(MipsReg)), CRegName::GPR_Hi[MipsReg]); SetArmRegMapped(GetMipsRegMapHi(MipsReg), NotMapped); SetArmRegProtected(GetMipsRegMapHi(MipsReg), false); } - CPU_Message(" regcache: unallocate %s from %s", ArmRegName(GetMipsRegMapLo(MipsReg)), CRegName::GPR_Lo[MipsReg]); + m_CodeBlock.Log(" regcache: unallocate %s from %s", m_Assembler.ArmRegName(GetMipsRegMapLo(MipsReg)), CRegName::GPR_Lo[MipsReg]); SetArmRegMapped(GetMipsRegMapLo(MipsReg), NotMapped); SetArmRegProtected(GetMipsRegMapLo(MipsReg), false); SetMipsRegState(MipsReg, STATE_UNKNOWN); @@ -494,7 +498,7 @@ void CArmRegInfo::WriteBack_GPR(uint32_t MipsReg, bool Unmapping) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -512,31 +516,31 @@ void CArmRegInfo::WriteBack_GPR(uint32_t MipsReg, bool Unmapping) return; } - ArmReg GprReg = Map_Variable(VARIABLE_GPR); + CArmOps::ArmReg GprReg = Map_Variable(VARIABLE_GPR); if (IsConst(MipsReg)) { - ArmReg TempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); if (Is64Bit(MipsReg)) { - MoveConstToArmReg(TempReg, GetMipsRegHi(MipsReg)); - StoreArmRegToArmRegPointer(TempReg, GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); + m_Assembler.MoveConstToArmReg(TempReg, GetMipsRegHi(MipsReg)); + m_Assembler.StoreArmRegToArmRegPointer(TempReg, GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); } else if (!g_System->b32BitCore()) { - MoveConstToArmReg(TempReg, (GetMipsRegLo(MipsReg) & 0x80000000) != 0 ? 0xFFFFFFFF : 0); - StoreArmRegToArmRegPointer(TempReg, GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); + m_Assembler.MoveConstToArmReg(TempReg, (GetMipsRegLo(MipsReg) & 0x80000000) != 0 ? 0xFFFFFFFF : 0); + m_Assembler.StoreArmRegToArmRegPointer(TempReg, GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); } - MoveConstToArmReg(TempReg, GetMipsRegLo(MipsReg)); - StoreArmRegToArmRegPointer(TempReg, GprReg, (uint8_t)(MipsReg << 3), CRegName::GPR_Lo[MipsReg]); - m_RegWorkingSet.SetArmRegProtected(TempReg, false); + m_Assembler.MoveConstToArmReg(TempReg, GetMipsRegLo(MipsReg)); + m_Assembler.StoreArmRegToArmRegPointer(TempReg, GprReg, (uint8_t)(MipsReg << 3), CRegName::GPR_Lo[MipsReg]); + SetArmRegProtected(TempReg, false); } else { - StoreArmRegToArmRegPointer(GetMipsRegMapLo(MipsReg), GprReg, (uint8_t)(MipsReg << 3), CRegName::GPR_Lo[MipsReg]); + m_Assembler.StoreArmRegToArmRegPointer(GetMipsRegMapLo(MipsReg), GprReg, (uint8_t)(MipsReg << 3), CRegName::GPR_Lo[MipsReg]); if (Is64Bit(MipsReg)) { - StoreArmRegToArmRegPointer(GetMipsRegMapHi(MipsReg), GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); + m_Assembler.StoreArmRegToArmRegPointer(GetMipsRegMapHi(MipsReg), GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); } else if (!g_System->b32BitCore()) { @@ -544,24 +548,24 @@ void CArmRegInfo::WriteBack_GPR(uint32_t MipsReg, bool Unmapping) if (!Unmapping) { SetArmRegProtected(GetMipsRegMapLo(MipsReg), true); - ArmReg TempReg = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); + CArmOps::ArmReg TempReg = Map_TempReg(CArmOps::Arm_Any, -1, false); if (IsSigned(MipsReg)) { - ShiftRightSignImmed(TempReg, GetMipsRegMapLo(MipsReg), 31); + m_Assembler.ShiftRightSignImmed(TempReg, GetMipsRegMapLo(MipsReg), 31); } else { - MoveConstToArmReg(TempReg, (uint32_t)0); + m_Assembler.MoveConstToArmReg(TempReg, (uint32_t)0); } - StoreArmRegToArmRegPointer(TempReg, GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); - m_RegWorkingSet.SetArmRegProtected(TempReg, false); + m_Assembler.StoreArmRegToArmRegPointer(TempReg, GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); + SetArmRegProtected(TempReg, false); } else { - ShiftRightSignImmed(GetMipsRegMapLo(MipsReg), GetMipsRegMapLo(MipsReg), 31); - StoreArmRegToArmRegPointer(GetMipsRegMapLo(MipsReg), GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); + m_Assembler.ShiftRightSignImmed(GetMipsRegMapLo(MipsReg), GetMipsRegMapLo(MipsReg), 31); + m_Assembler.StoreArmRegToArmRegPointer(GetMipsRegMapLo(MipsReg), GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); } - m_RegWorkingSet.SetArmRegProtected(GetMipsRegMapLo(MipsReg), loProtected); + SetArmRegProtected(GetMipsRegMapLo(MipsReg), loProtected); } } SetArmRegProtected(GprReg, false); @@ -571,7 +575,7 @@ void CArmRegInfo::WriteBackRegisters() { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -579,8 +583,8 @@ void CArmRegInfo::WriteBackRegisters() int32_t ArmRegCount = sizeof(m_ArmReg_MappedTo) / sizeof(m_ArmReg_MappedTo[0]); for (int32_t i = 1; i < 32; i++) { UnMap_GPR(i, true); } - for (int32_t i = 0; i < ArmRegCount; i++) { UnMap_ArmReg((ArmReg)i); } - for (int32_t i = 0; i < ArmRegCount; i++) { SetArmRegProtected((ArmReg)i, false); } + for (int32_t i = 0; i < ArmRegCount; i++) { UnMap_ArmReg((CArmOps::ArmReg)i); } + for (int32_t i = 0; i < ArmRegCount; i++) { SetArmRegProtected((CArmOps::ArmReg)i, false); } for (int32_t count = 1; count < 32; count++) { @@ -597,7 +601,7 @@ void CArmRegInfo::WriteBackRegisters() g_Notify->BreakPoint(__FILE__, __LINE__); break; default: - CPU_Message("%s: Unknown state: %d reg %d (%s)", __FUNCTION__, GetMipsRegState(count), count, CRegName::GPR[count]); + m_CodeBlock.Log("%s: Unknown state: %d reg %d (%s)", __FUNCTION__, GetMipsRegState(count), count, CRegName::GPR[count]); g_Notify->BreakPoint(__FILE__, __LINE__); } } @@ -607,61 +611,61 @@ void CArmRegInfo::UnMap_AllFPRs() { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } - CPU_Message("%s", __FUNCTION__); + m_CodeBlock.Log("%s", __FUNCTION__); } CArmOps::ArmReg CArmRegInfo::UnMap_TempReg(bool TempMapping) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } - ArmReg Reg = Arm_Unknown; + CArmOps::ArmReg Reg = CArmOps::Arm_Unknown; - if (GetArmRegMapped(Arm_R7) == Temp_Mapped && !GetArmRegProtected(Arm_R7)) { return Arm_R7; } - if (GetArmRegMapped(Arm_R6) == Temp_Mapped && !GetArmRegProtected(Arm_R6)) { return Arm_R6; } - if (GetArmRegMapped(Arm_R5) == Temp_Mapped && !GetArmRegProtected(Arm_R5)) { return Arm_R5; } - if (GetArmRegMapped(Arm_R4) == Temp_Mapped && !GetArmRegProtected(Arm_R4)) { return Arm_R4; } - if (GetArmRegMapped(Arm_R3) == Temp_Mapped && !GetArmRegProtected(Arm_R3)) { return Arm_R3; } - if (GetArmRegMapped(Arm_R2) == Temp_Mapped && !GetArmRegProtected(Arm_R2)) { return Arm_R2; } - if (GetArmRegMapped(Arm_R1) == Temp_Mapped && !GetArmRegProtected(Arm_R1)) { return Arm_R1; } - if (GetArmRegMapped(Arm_R0) == Temp_Mapped && !GetArmRegProtected(Arm_R0)) { return Arm_R0; } + if (GetArmRegMapped( CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R7)) { return CArmOps::Arm_R7; } + if (GetArmRegMapped( CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R6)) { return CArmOps::Arm_R6; } + if (GetArmRegMapped( CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R5)) { return CArmOps::Arm_R5; } + if (GetArmRegMapped( CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R4)) { return CArmOps::Arm_R4; } + if (GetArmRegMapped( CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R3)) { return CArmOps::Arm_R3; } + if (GetArmRegMapped( CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R2)) { return CArmOps::Arm_R2; } + if (GetArmRegMapped( CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R1)) { return CArmOps::Arm_R1; } + if (GetArmRegMapped( CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R0)) { return CArmOps::Arm_R0; } if (TempMapping) { - if (GetArmRegMapped(Arm_R11) == Temp_Mapped && !GetArmRegProtected(Arm_R11)) { return Arm_R11; } - if (GetArmRegMapped(Arm_R10) == Temp_Mapped && !GetArmRegProtected(Arm_R10)) { return Arm_R10; } + if (GetArmRegMapped( CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R11)) { return CArmOps::Arm_R11; } + if (GetArmRegMapped( CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R10)) { return CArmOps::Arm_R10; } } - if (GetArmRegMapped(Arm_R9) == Temp_Mapped && !GetArmRegProtected(Arm_R9)) { return Arm_R9; } - if (GetArmRegMapped(Arm_R8) == Temp_Mapped && !GetArmRegProtected(Arm_R8)) { return Arm_R8; } + if (GetArmRegMapped( CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R9)) { return CArmOps::Arm_R9; } + if (GetArmRegMapped( CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R8)) { return CArmOps::Arm_R8; } - if (Reg != Arm_Unknown) + if (Reg != CArmOps::Arm_Unknown) { if (GetArmRegMapped(Reg) == Temp_Mapped) { - CPU_Message(" regcache: unallocate %s from temp storage", ArmRegName(Reg)); + m_CodeBlock.Log(" regcache: unallocate %s from temp storage", m_Assembler.ArmRegName(Reg)); } SetArmRegMapped(Reg, NotMapped); } return Reg; } -bool CArmRegInfo::UnMap_ArmReg(ArmReg Reg) +bool CArmRegInfo::UnMap_ArmReg(CArmOps::ArmReg Reg) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return false; } if (GetArmRegProtected(Reg)) { - CPU_Message("%s: %s is protected", __FUNCTION__, ArmRegName(Reg)); + m_CodeBlock.Log("%s: %s is protected", __FUNCTION__, m_Assembler.ArmRegName(Reg)); g_Notify->BreakPoint(__FILE__, __LINE__); return false; } @@ -701,13 +705,13 @@ bool CArmRegInfo::UnMap_ArmReg(ArmReg Reg) } else if (GetArmRegMapped(Reg) == Temp_Mapped) { - CPU_Message(" regcache: unallocate %s from temporary storage", ArmRegName(Reg)); + m_CodeBlock.Log(" regcache: unallocate %s from temporary storage", m_Assembler.ArmRegName(Reg)); SetArmRegMapped(Reg, NotMapped); return true; } else if (GetArmRegMapped(Reg) == Variable_Mapped) { - CPU_Message(" regcache: unallocate %s from variable mapping (%s)", ArmRegName(Reg), VariableMapName(GetVariableMappedTo(Reg))); + m_CodeBlock.Log(" regcache: unallocate %s from variable mapping (%s)", m_Assembler.ArmRegName(Reg), VariableMapName(GetVariableMappedTo(Reg))); SetArmRegMapped(Reg, NotMapped); m_Variable_MappedTo[Reg] = VARIABLE_UNKNOWN; return true; @@ -720,13 +724,13 @@ void CArmRegInfo::ResetRegProtection() { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } for (uint32_t i = 0, n = sizeof(m_ArmReg_Protected) / sizeof(m_ArmReg_Protected[0]); i < n; i++) { - SetArmRegProtected((ArmReg)i, false); + SetArmRegProtected((CArmOps::ArmReg)i, false); } } @@ -734,38 +738,38 @@ CArmOps::ArmReg CArmRegInfo::FreeArmReg(bool TempMapping) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } - if ((GetArmRegMapped(Arm_R7) == NotMapped || GetArmRegMapped(Arm_R7) == Temp_Mapped) && !GetArmRegProtected(Arm_R7)) { return Arm_R7; } - if ((GetArmRegMapped(Arm_R6) == NotMapped || GetArmRegMapped(Arm_R6) == Temp_Mapped) && !GetArmRegProtected(Arm_R6)) { return Arm_R6; } - if ((GetArmRegMapped(Arm_R5) == NotMapped || GetArmRegMapped(Arm_R5) == Temp_Mapped) && !GetArmRegProtected(Arm_R5)) { return Arm_R5; } - if ((GetArmRegMapped(Arm_R4) == NotMapped || GetArmRegMapped(Arm_R4) == Temp_Mapped) && !GetArmRegProtected(Arm_R4)) { return Arm_R4; } - if ((GetArmRegMapped(Arm_R3) == NotMapped || GetArmRegMapped(Arm_R3) == Temp_Mapped) && !GetArmRegProtected(Arm_R3)) { return Arm_R3; } - if ((GetArmRegMapped(Arm_R2) == NotMapped || GetArmRegMapped(Arm_R2) == Temp_Mapped) && !GetArmRegProtected(Arm_R2)) { return Arm_R2; } - if ((GetArmRegMapped(Arm_R1) == NotMapped || GetArmRegMapped(Arm_R1) == Temp_Mapped) && !GetArmRegProtected(Arm_R1)) { return Arm_R1; } - if ((GetArmRegMapped(Arm_R0) == NotMapped || GetArmRegMapped(Arm_R0) == Temp_Mapped) && !GetArmRegProtected(Arm_R0)) { return Arm_R0; } + if ((GetArmRegMapped( CArmOps::Arm_R7) == NotMapped || GetArmRegMapped( CArmOps::Arm_R7) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R7)) { return CArmOps::Arm_R7; } + if ((GetArmRegMapped( CArmOps::Arm_R6) == NotMapped || GetArmRegMapped( CArmOps::Arm_R6) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R6)) { return CArmOps::Arm_R6; } + if ((GetArmRegMapped( CArmOps::Arm_R5) == NotMapped || GetArmRegMapped( CArmOps::Arm_R5) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R5)) { return CArmOps::Arm_R5; } + if ((GetArmRegMapped( CArmOps::Arm_R4) == NotMapped || GetArmRegMapped( CArmOps::Arm_R4) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R4)) { return CArmOps::Arm_R4; } + if ((GetArmRegMapped( CArmOps::Arm_R3) == NotMapped || GetArmRegMapped( CArmOps::Arm_R3) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R3)) { return CArmOps::Arm_R3; } + if ((GetArmRegMapped( CArmOps::Arm_R2) == NotMapped || GetArmRegMapped( CArmOps::Arm_R2) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R2)) { return CArmOps::Arm_R2; } + if ((GetArmRegMapped( CArmOps::Arm_R1) == NotMapped || GetArmRegMapped( CArmOps::Arm_R1) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R1)) { return CArmOps::Arm_R1; } + if ((GetArmRegMapped( CArmOps::Arm_R0) == NotMapped || GetArmRegMapped( CArmOps::Arm_R0) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R0)) { return CArmOps::Arm_R0; } if (TempMapping) { - if ((GetArmRegMapped(Arm_R11) == NotMapped || GetArmRegMapped(Arm_R11) == Temp_Mapped) && !GetArmRegProtected(Arm_R11)) { return Arm_R11; } - if ((GetArmRegMapped(Arm_R10) == NotMapped || GetArmRegMapped(Arm_R10) == Temp_Mapped) && !GetArmRegProtected(Arm_R10)) { return Arm_R10; } + if ((GetArmRegMapped( CArmOps::Arm_R11) == NotMapped || GetArmRegMapped( CArmOps::Arm_R11) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R11)) { return CArmOps::Arm_R11; } + if ((GetArmRegMapped( CArmOps::Arm_R10) == NotMapped || GetArmRegMapped( CArmOps::Arm_R10) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R10)) { return CArmOps::Arm_R10; } } - if ((GetArmRegMapped(Arm_R9) == NotMapped || GetArmRegMapped(Arm_R9) == Temp_Mapped) && !GetArmRegProtected(Arm_R9)) { return Arm_R9; } - if ((GetArmRegMapped(Arm_R8) == NotMapped || GetArmRegMapped(Arm_R8) == Temp_Mapped) && !GetArmRegProtected(Arm_R8)) { return Arm_R8; } + if ((GetArmRegMapped( CArmOps::Arm_R9) == NotMapped || GetArmRegMapped( CArmOps::Arm_R9) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R9)) { return CArmOps::Arm_R9; } + if ((GetArmRegMapped( CArmOps::Arm_R8) == NotMapped || GetArmRegMapped( CArmOps::Arm_R8) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R8)) { return CArmOps::Arm_R8; } - ArmReg Reg = UnMap_TempReg(TempMapping); - if (Reg != Arm_Unknown) { return Reg; } + CArmOps::ArmReg Reg = UnMap_TempReg(TempMapping); + if (Reg != CArmOps::Arm_Unknown) { return Reg; } - int32_t MapCount[Arm_R12]; - ArmReg MapReg[Arm_R12]; + int32_t MapCount[ CArmOps::Arm_R12]; + CArmOps::ArmReg MapReg[ CArmOps::Arm_R12]; - for (int32_t i = 0, n = TempMapping ? Arm_R12 : Arm_R10; i < n; i++) + for (int32_t i = 0, n = TempMapping ? CArmOps::Arm_R12 : CArmOps::Arm_R10; i < n; i++) { - MapCount[i] = GetArmRegMapOrder((ArmReg)i); - MapReg[i] = (ArmReg)i; + MapCount[i] = GetArmRegMapOrder((CArmOps::ArmReg)i); + MapReg[i] = (CArmOps::ArmReg)i; } - for (int32_t i = 0, n = TempMapping ? Arm_R12 : Arm_R10; i < n; i++) + for (int32_t i = 0, n = TempMapping ? CArmOps::Arm_R12 : CArmOps::Arm_R10; i < n; i++) { bool changed = false; for (int32_t z = 0; z < n - 1; z++) @@ -777,7 +781,7 @@ CArmOps::ArmReg CArmRegInfo::FreeArmReg(bool TempMapping) uint32_t temp = MapCount[z]; MapCount[z] = MapCount[z + 1]; MapCount[z + 1] = temp; - ArmReg tempReg = MapReg[z]; + CArmOps::ArmReg tempReg = MapReg[z]; MapReg[z] = MapReg[z + 1]; MapReg[z + 1] = tempReg; changed = true; @@ -788,20 +792,20 @@ CArmOps::ArmReg CArmRegInfo::FreeArmReg(bool TempMapping) } } - for (int32_t i = 0, n = TempMapping ? Arm_R12 : Arm_R10; i < n; i++) + for (int32_t i = 0, n = TempMapping ? CArmOps::Arm_R12 : CArmOps::Arm_R10; i < n; i++) { - if (((MapCount[i] > 0 && GetArmRegMapped(MapReg[i]) == GPR_Mapped) || GetArmRegMapped(MapReg[i]) == Variable_Mapped) && !GetArmRegProtected((ArmReg)MapReg[i])) + if (((MapCount[i] > 0 && GetArmRegMapped(MapReg[i]) == GPR_Mapped) || GetArmRegMapped(MapReg[i]) == Variable_Mapped) && !GetArmRegProtected((CArmOps::ArmReg)MapReg[i])) { - if (UnMap_ArmReg((ArmReg)MapReg[i])) + if (UnMap_ArmReg((CArmOps::ArmReg)MapReg[i])) { - return (ArmReg)MapReg[i]; + return (CArmOps::ArmReg)MapReg[i]; } } } LogRegisterState(); g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } void CArmRegInfo::LogRegisterState(void) @@ -815,7 +819,7 @@ void CArmRegInfo::LogRegisterState(void) { stdstr regname; - if (GetArmRegMapped((ArmReg)i) == CArmRegInfo::GPR_Mapped) + if (GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::GPR_Mapped) { for (uint32_t count = 1; count < 32; count++) { @@ -824,12 +828,12 @@ void CArmRegInfo::LogRegisterState(void) continue; } - if (Is64Bit(count) && GetMipsRegMapHi(count) == (ArmReg)i) + if (Is64Bit(count) && GetMipsRegMapHi(count) == (CArmOps::ArmReg)i) { regname = CRegName::GPR_Hi[count]; break; } - if (GetMipsRegMapLo(count) == (ArmReg)i) + if (GetMipsRegMapLo(count) == (CArmOps::ArmReg)i) { regname = CRegName::GPR_Lo[count]; break; @@ -837,50 +841,50 @@ void CArmRegInfo::LogRegisterState(void) } } - CPU_Message("GetArmRegMapped(%s) = %X%s%s Protected: %s MapOrder: %d", - ArmRegName((ArmReg)i), - GetArmRegMapped((ArmReg)i), - GetArmRegMapped((ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(GetVariableMappedTo((ArmReg)i))).c_str() : "", + m_CodeBlock.Log("GetArmRegMapped(%s) = %X%s%s Protected: %s MapOrder: %d", + m_Assembler.ArmRegName((CArmOps::ArmReg)i), + GetArmRegMapped((CArmOps::ArmReg)i), + GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "", regname.length() > 0 ? stdstr_f(" (%s)", regname.c_str()).c_str() : "", - GetArmRegProtected((ArmReg)i) ? "true" : "false", - GetArmRegMapOrder((ArmReg)i) + GetArmRegProtected((CArmOps::ArmReg)i) ? "true" : "false", + GetArmRegMapOrder((CArmOps::ArmReg)i) ); } } -CArmOps::ArmReg CArmRegInfo::Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadHiWord) +CArmOps::ArmReg CArmRegInfo::Map_TempReg(CArmOps::ArmReg Reg, int32_t MipsReg, bool LoadHiWord) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } - ArmReg GprReg = MipsReg >= 0 ? Map_Variable(VARIABLE_GPR) : Arm_Unknown; + CArmOps::ArmReg GprReg = MipsReg >= 0 ? Map_Variable(VARIABLE_GPR) : CArmOps::Arm_Unknown; if (Reg == CArmOps::Arm_Any) { - if (GetArmRegMapped(Arm_R7) == Temp_Mapped && !GetArmRegProtected(Arm_R7)) { Reg = Arm_R7; } - else if (GetArmRegMapped(Arm_R6) == Temp_Mapped && !GetArmRegProtected(Arm_R6)) { Reg = Arm_R6; } - else if (GetArmRegMapped(Arm_R5) == Temp_Mapped && !GetArmRegProtected(Arm_R5)) { Reg = Arm_R5; } - else if (GetArmRegMapped(Arm_R4) == Temp_Mapped && !GetArmRegProtected(Arm_R4)) { Reg = Arm_R4; } - else if (GetArmRegMapped(Arm_R3) == Temp_Mapped && !GetArmRegProtected(Arm_R3)) { Reg = Arm_R3; } - else if (GetArmRegMapped(Arm_R2) == Temp_Mapped && !GetArmRegProtected(Arm_R2)) { Reg = Arm_R2; } - else if (GetArmRegMapped(Arm_R1) == Temp_Mapped && !GetArmRegProtected(Arm_R1)) { Reg = Arm_R1; } - else if (GetArmRegMapped(Arm_R0) == Temp_Mapped && !GetArmRegProtected(Arm_R0)) { Reg = Arm_R0; } - else if (GetArmRegMapped(Arm_R11) == Temp_Mapped && !GetArmRegProtected(Arm_R11)) { Reg = Arm_R11; } - else if (GetArmRegMapped(Arm_R10) == Temp_Mapped && !GetArmRegProtected(Arm_R10)) { Reg = Arm_R10; } - else if (GetArmRegMapped(Arm_R9) == Temp_Mapped && !GetArmRegProtected(Arm_R9)) { Reg = Arm_R9; } - else if (GetArmRegMapped(Arm_R8) == Temp_Mapped && !GetArmRegProtected(Arm_R8)) { Reg = Arm_R8; } + if (GetArmRegMapped( CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R7)) { Reg = CArmOps::Arm_R7; } + else if (GetArmRegMapped( CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R6)) { Reg = CArmOps::Arm_R6; } + else if (GetArmRegMapped( CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R5)) { Reg = CArmOps::Arm_R5; } + else if (GetArmRegMapped( CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R4)) { Reg = CArmOps::Arm_R4; } + else if (GetArmRegMapped( CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R3)) { Reg = CArmOps::Arm_R3; } + else if (GetArmRegMapped( CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R2)) { Reg = CArmOps::Arm_R2; } + else if (GetArmRegMapped( CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R1)) { Reg = CArmOps::Arm_R1; } + else if (GetArmRegMapped( CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R0)) { Reg = CArmOps::Arm_R0; } + else if (GetArmRegMapped( CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R11)) { Reg = CArmOps::Arm_R11; } + else if (GetArmRegMapped( CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R10)) { Reg = CArmOps::Arm_R10; } + else if (GetArmRegMapped( CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R9)) { Reg = CArmOps::Arm_R9; } + else if (GetArmRegMapped( CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R8)) { Reg = CArmOps::Arm_R8; } - if (Reg == Arm_Any) + if (Reg == CArmOps::Arm_Any) { Reg = FreeArmReg(true); - if (Reg == Arm_Unknown) + if (Reg == CArmOps::Arm_Unknown) { WriteTrace(TraceRegisterCache, TraceError, "Failed to find a free register"); g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } } } @@ -901,12 +905,12 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadH } if (MipsReg < 0) { - CPU_Message(" regcache: allocate %s as temporary storage", ArmRegName(Reg)); + m_CodeBlock.Log(" regcache: allocate %s as temporary storage", m_Assembler.ArmRegName(Reg)); } else { - CPU_Message(" regcache: allocate %s as temporary storage (%s)", ArmRegName(Reg), LoadHiWord ? CRegName::GPR_Hi[MipsReg] : CRegName::GPR_Lo[MipsReg]); - if (GprReg == Arm_Unknown) + m_CodeBlock.Log(" regcache: allocate %s as temporary storage (%s)", m_Assembler.ArmRegName(Reg), LoadHiWord ? CRegName::GPR_Hi[MipsReg] : CRegName::GPR_Lo[MipsReg]); + if (GprReg == CArmOps::Arm_Unknown) { g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -914,7 +918,7 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadH { if (IsUnknown(MipsReg)) { - LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); + m_Assembler.LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(MipsReg << 3) + 4, CRegName::GPR_Hi[MipsReg]); } else if (IsMapped(MipsReg)) { @@ -925,11 +929,11 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadH } else if (IsSigned(MipsReg)) { - ShiftRightSignImmed(Reg, GetMipsRegMapLo(MipsReg), 31); + m_Assembler.ShiftRightSignImmed(Reg, GetMipsRegMapLo(MipsReg), 31); } else { - MoveConstToArmReg(Reg, (uint32_t)0); + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)0); } } else @@ -937,12 +941,12 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadH if (Is64Bit(MipsReg)) { g_Notify->BreakPoint(__FILE__, __LINE__); - //MoveConstToArmReg(Reg, GetMipsRegHi(MipsReg)); + //m_Assembler.MoveConstToArmReg(Reg, GetMipsRegHi(MipsReg)); } else { g_Notify->BreakPoint(__FILE__, __LINE__); - //MoveConstToArmReg(Reg, GetMipsRegLo_S(MipsReg) >> 31); + //m_Assembler.MoveConstToArmReg(Reg, GetMipsRegLo_S(MipsReg) >> 31); } } } @@ -950,15 +954,15 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadH { if (IsUnknown(MipsReg)) { - LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(MipsReg << 3), CRegName::GPR_Lo[MipsReg]); + m_Assembler.LoadArmRegPointerToArmReg(Reg, GprReg, (uint8_t)(MipsReg << 3), CRegName::GPR_Lo[MipsReg]); } else if (IsMapped(MipsReg)) { - AddConstToArmReg(Reg, GetMipsRegMapLo(MipsReg), 0); + m_Assembler.AddConstToArmReg(Reg, GetMipsRegMapLo(MipsReg), 0); } else { - MoveConstToArmReg(Reg, GetMipsRegLo(MipsReg)); + m_Assembler.MoveConstToArmReg(Reg, GetMipsRegLo(MipsReg)); } } } @@ -966,10 +970,10 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadH SetArmRegProtected(Reg, true); for (int32_t i = 0, n = sizeof(m_ArmReg_MappedTo) / sizeof(m_ArmReg_MappedTo[0]); i < n; i++) { - int32_t MapOrder = GetArmRegMapOrder((ArmReg)i); + int32_t MapOrder = GetArmRegMapOrder((CArmOps::ArmReg)i); if (MapOrder > 0) { - SetArmRegMapOrder((ArmReg)i, MapOrder + 1); + SetArmRegMapOrder((CArmOps::ArmReg)i, MapOrder + 1); } } SetArmRegMapOrder(Reg, 1); @@ -977,44 +981,44 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadH return Reg; } -CArmOps::ArmReg CArmRegInfo::Map_Variable(VARIABLE_MAPPED variable, ArmReg Reg) +CArmOps::ArmReg CArmRegInfo::Map_Variable(VARIABLE_MAPPED variable, CArmOps::ArmReg Reg) { - CPU_Message("%s: variable: %s Reg: %d", __FUNCTION__, VariableMapName(variable), Reg); + m_CodeBlock.Log("%s: variable: %s Reg: %d", __FUNCTION__, VariableMapName(variable), Reg); if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } - if (Reg == Arm_Unknown) + if (Reg == CArmOps::Arm_Unknown) { g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } - if (variable == VARIABLE_GPR && Reg != Arm_Any && Reg != Arm_R12) + if (variable == VARIABLE_GPR && Reg != CArmOps::Arm_Any && Reg != CArmOps::Arm_R12) { g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } - if (Reg == Arm_Any) + if (Reg == CArmOps::Arm_Any) { Reg = GetVariableReg(variable); - if (Reg != Arm_Unknown) + if (Reg != CArmOps::Arm_Unknown) { SetArmRegProtected(Reg, true); return Reg; } - Reg = variable == VARIABLE_GPR ? Arm_R12 : FreeArmReg(false); - if (Reg == Arm_Unknown) + Reg = variable == VARIABLE_GPR ? CArmOps::Arm_R12 : FreeArmReg(false); + if (Reg == CArmOps::Arm_Unknown) { WriteTrace(TraceRegisterCache, TraceError, "Failed to find a free register"); g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } } else if (GetArmRegMapped(Reg) == Variable_Mapped && m_Variable_MappedTo[Reg] == variable) @@ -1029,19 +1033,19 @@ CArmOps::ArmReg CArmRegInfo::Map_Variable(VARIABLE_MAPPED variable, ArmReg Reg) SetArmRegMapped(Reg, Variable_Mapped); SetArmRegProtected(Reg, true); - CPU_Message(" regcache: allocate %s as pointer to %s", ArmRegName(Reg), VariableMapName(variable)); + m_CodeBlock.Log(" regcache: allocate %s as pointer to %s", m_Assembler.ArmRegName(Reg), VariableMapName(variable)); m_Variable_MappedTo[Reg] = variable; - if (variable == VARIABLE_GPR) { MoveConstToArmReg(Reg, (uint32_t)_GPR, "_GPR"); } - else if (variable == VARIABLE_FPR) { MoveConstToArmReg(Reg, (uint32_t)_FPR_S, "_FPR_S"); } - else if (variable == VARIABLE_TLB_READMAP) { MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_ReadMap), "MMU->TLB_ReadMap"); } - else if (variable == VARIABLE_TLB_WRITEMAP) { MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_WriteMap), "MMU->m_TLB_WriteMap"); } - else if (variable == VARIABLE_TLB_LOAD_ADDRESS) { MoveConstToArmReg(Reg, (uint32_t)(g_TLBLoadAddress), "g_TLBLoadAddress"); } - else if (variable == VARIABLE_TLB_STORE_ADDRESS) { MoveConstToArmReg(Reg, (uint32_t)(g_TLBStoreAddress), "g_TLBStoreAddress"); } - else if (variable == VARIABLE_NEXT_TIMER) { MoveConstToArmReg(Reg, (uint32_t)(g_NextTimer), "g_NextTimer"); } + if (variable == VARIABLE_GPR) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_GPR, "_GPR"); } + else if (variable == VARIABLE_FPR) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_FPR_S, "_FPR_S"); } + else if (variable == VARIABLE_TLB_READMAP) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_ReadMap), "MMU->TLB_ReadMap"); } + else if (variable == VARIABLE_TLB_WRITEMAP) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_WriteMap), "MMU->m_TLB_WriteMap"); } + else if (variable == VARIABLE_TLB_LOAD_ADDRESS) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBLoadAddress), "g_TLBLoadAddress"); } + else if (variable == VARIABLE_TLB_STORE_ADDRESS) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBStoreAddress), "g_TLBStoreAddress"); } + else if (variable == VARIABLE_NEXT_TIMER) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_NextTimer), "g_NextTimer"); } else { g_Notify->BreakPoint(__FILE__, __LINE__); - return Arm_Unknown; + return CArmOps::Arm_Unknown; } return Reg; } @@ -1052,17 +1056,17 @@ CArmOps::ArmReg CArmRegInfo::GetVariableReg(VARIABLE_MAPPED variable) const { if (m_ArmReg_MappedTo[i] == Variable_Mapped && m_Variable_MappedTo[i] == variable) { - return (ArmReg)i; + return (CArmOps::ArmReg)i; } } - return Arm_Unknown; + return CArmOps::Arm_Unknown; } void CArmRegInfo::ProtectGPR(uint32_t Reg) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -1081,7 +1085,7 @@ void CArmRegInfo::UnProtectGPR(uint32_t Reg) { if (m_InCallDirect) { - CPU_Message("%s: in CallDirect", __FUNCTION__); + m_CodeBlock.Log("%s: in CallDirect", __FUNCTION__); g_Notify->BreakPoint(__FILE__, __LINE__); return; } diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h index 97ffba7d4..1c100b842 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h @@ -6,7 +6,7 @@ class CArmRegInfo : public CRegBase, - public CArmOps, + private CDebugSettings, private CSystemRegisters { public: @@ -31,7 +31,7 @@ public: VARIABLE_NEXT_TIMER = 7, }; - CArmRegInfo(); + CArmRegInfo(CCodeBlock & CodeBlock, CArmOps & Assembler); CArmRegInfo(const CArmRegInfo&); ~CArmRegInfo(); @@ -46,45 +46,50 @@ public: void FixRoundModel(FPU_ROUND RoundMethod); void Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad); void Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad); - ArmReg FreeArmReg(bool TempMapping); + CArmOps::ArmReg FreeArmReg(bool TempMapping); void WriteBackRegisters(); - ArmReg Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadHiWord); - ArmReg Map_Variable(VARIABLE_MAPPED variable, ArmReg Reg = Arm_Any); - ArmReg GetVariableReg(VARIABLE_MAPPED variable) const; + CArmOps::ArmReg Map_TempReg(CArmOps::ArmReg Reg, int32_t MipsReg, bool LoadHiWord); + CArmOps::ArmReg Map_Variable(VARIABLE_MAPPED variable, CArmOps::ArmReg Reg = CArmOps::Arm_Any); + CArmOps::ArmReg GetVariableReg(VARIABLE_MAPPED variable) const; void ProtectGPR(uint32_t Reg); void UnProtectGPR(uint32_t Reg); void UnMap_AllFPRs(); - ArmReg UnMap_TempReg(bool TempMapping); + CArmOps::ArmReg UnMap_TempReg(bool TempMapping); void UnMap_GPR(uint32_t Reg, bool WriteBackValue); void WriteBack_GPR(uint32_t MipsReg, bool Unmapping); - bool UnMap_ArmReg(ArmReg Reg); + bool UnMap_ArmReg(CArmOps::ArmReg Reg); void ResetRegProtection(); - inline ArmReg GetMipsRegMapLo(int32_t Reg) const { return m_RegMapLo[Reg]; } - inline ArmReg GetMipsRegMapHi(int32_t Reg) const { return m_RegMapHi[Reg]; } - inline void SetMipsRegMapLo(int32_t GetMipsReg, ArmReg Reg) { m_RegMapLo[GetMipsReg] = Reg; } - inline void SetMipsRegMapHi(int32_t GetMipsReg, ArmReg Reg) { m_RegMapHi[GetMipsReg] = Reg; } + inline CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg) const { return m_RegMapLo[Reg]; } + inline CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg) const { return m_RegMapHi[Reg]; } + inline void SetMipsRegMapLo(int32_t GetMipsReg, CArmOps::ArmReg Reg) { m_RegMapLo[GetMipsReg] = Reg; } + inline void SetMipsRegMapHi(int32_t GetMipsReg, CArmOps::ArmReg Reg) { m_RegMapHi[GetMipsReg] = Reg; } - inline uint32_t GetArmRegMapOrder(ArmReg Reg) const { return m_ArmReg_MapOrder[Reg]; } - inline bool GetArmRegProtected(ArmReg Reg) const { return m_ArmReg_Protected[Reg]; } - inline REG_MAPPED GetArmRegMapped(ArmReg Reg) const { return m_ArmReg_MappedTo[Reg]; } + inline uint32_t GetArmRegMapOrder(CArmOps::ArmReg Reg) const { return m_ArmReg_MapOrder[Reg]; } + inline bool GetArmRegProtected(CArmOps::ArmReg Reg) const { return m_ArmReg_Protected[Reg]; } + inline REG_MAPPED GetArmRegMapped(CArmOps::ArmReg Reg) const { return m_ArmReg_MappedTo[Reg]; } - inline void SetArmRegMapOrder(ArmReg Reg, uint32_t Order) { m_ArmReg_MapOrder[Reg] = Order; } - inline void SetArmRegProtected(ArmReg Reg, bool Protected) { m_ArmReg_Protected[Reg] = Protected; } - inline void SetArmRegMapped(ArmReg Reg, REG_MAPPED Mapping) { m_ArmReg_MappedTo[Reg] = Mapping; } + inline void SetArmRegMapOrder(CArmOps::ArmReg Reg, uint32_t Order) { m_ArmReg_MapOrder[Reg] = Order; } + inline void SetArmRegProtected(CArmOps::ArmReg Reg, bool Protected) { m_ArmReg_Protected[Reg] = Protected; } + inline void SetArmRegMapped(CArmOps::ArmReg Reg, REG_MAPPED Mapping) { m_ArmReg_MappedTo[Reg] = Mapping; } - inline VARIABLE_MAPPED GetVariableMappedTo(ArmReg Reg) const { return m_Variable_MappedTo[Reg]; } - inline void SetVariableMappedTo(ArmReg Reg, VARIABLE_MAPPED variable) { m_Variable_MappedTo[Reg] = variable; } + inline VARIABLE_MAPPED GetVariableMappedTo(CArmOps::ArmReg Reg) const { return m_Variable_MappedTo[Reg]; } + inline void SetVariableMappedTo(CArmOps::ArmReg Reg, VARIABLE_MAPPED variable) { m_Variable_MappedTo[Reg] = variable; } static const char * VariableMapName(VARIABLE_MAPPED variable); void LogRegisterState(void); private: - bool ShouldPushPopReg (ArmReg Reg); + CArmRegInfo(); - ArmReg m_RegMapHi[32]; - ArmReg m_RegMapLo[32]; + CCodeBlock & m_CodeBlock; + CArmOps & m_Assembler; + + bool ShouldPushPopReg (CArmOps::ArmReg Reg); + + CArmOps::ArmReg m_RegMapHi[32]; + CArmOps::ArmReg m_RegMapLo[32]; uint32_t m_ArmReg_MapOrder[16]; bool m_ArmReg_Protected[16]; REG_MAPPED m_ArmReg_MappedTo[16]; diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp index 673e4aa39..529dbbd28 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp @@ -32,7 +32,7 @@ CCodeBlock::CCodeBlock(CMipsMemoryVM & MMU, uint32_t VAddrEnter, uint8_t * Compi #if defined(__i386__) || defined(_M_IX86) m_RecompilerOps = new CX86RecompilerOps(MMU, *this); #elif defined(__arm__) || defined(_M_ARM) - m_RecompilerOps = new CArmRecompilerOps(MMU); + m_RecompilerOps = new CArmRecompilerOps(MMU, *this); #else g_Notify->BreakPoint(__FILE__, __LINE__); #endif diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.h b/Source/Project64-core/N64System/Recompiler/CodeBlock.h index 319264cec..36afeda57 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.h +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.h @@ -3,6 +3,10 @@ #include #include +#if !defined(_MSC_VER) && !defined(_Printf_format_string_) +#define _Printf_format_string_ +#endif + class CMipsMemoryVM; class CCodeBlock diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerOps.h b/Source/Project64-core/N64System/Recompiler/RecompilerOps.h index 4b4809d40..74490862d 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/RecompilerOps.h @@ -46,6 +46,6 @@ typedef CX86RecompilerOps CRecompilerOps; #elif defined(__arm__) || defined(_M_ARM) #include -typedef CX86RecompilerOps CArmRecompilerOps; +typedef CArmRecompilerOps CRecompilerOps; #endif diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86ops.h b/Source/Project64-core/N64System/Recompiler/x86/x86ops.h index bd23edd55..030976e21 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86ops.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86ops.h @@ -1,6 +1,10 @@ #pragma once #if defined(__i386__) || defined(_M_IX86) +#if !defined(_MSC_VER) && !defined(_Printf_format_string_) +#define _Printf_format_string_ +#endif + class CCodeBlock; class CX86Ops