From bceb4792ed9309f17e82f8b2f9faa05d7e203376 Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 23 Nov 2016 18:34:32 +1100 Subject: [PATCH] [Project64] Add pre op check before an op --- .../N64System/Recompiler/Arm/ArmOps.cpp | 123 +++++++++++------- .../N64System/Recompiler/Arm/ArmOps.h | 3 + 2 files changed, 76 insertions(+), 50 deletions(-) diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp index b9e5e1aaf..1c5699a26 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp @@ -22,6 +22,7 @@ bool CArmOps::mInItBlock = false; int CArmOps::mItBlockInstruction = 0; CArmOps::ArmCompareType CArmOps::mItBlockCompareType; CArmOps::ArmItMask CArmOps::mItBlockMask; +CArmOps::ArmReg CArmOps::mLastStoreReg; /************************************************************************** * Logging Functions * @@ -40,7 +41,7 @@ void CArmOps::WriteArmLabel(const char * Label) void CArmOps::AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (DestReg <= 7 && SourceReg1 <=7 && SourceReg2 <= 7) { @@ -72,16 +73,16 @@ void CArmOps::AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source void CArmOps::AddConstToArmReg(ArmReg DestReg, uint32_t Const) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); AddConstToArmReg(DestReg, DestReg, Const); } void CArmOps::AndConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__, __LINE__); } + PreOpCheck(false,__FILE__,__LINE__); - else if (CanThumbCompressConst(Const)) + if (CanThumbCompressConst(Const)) { CPU_Message(" and\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); uint16_t CompressedConst = ThumbCompressConst(Const); @@ -109,7 +110,7 @@ void CArmOps::AndConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) void CArmOps::AndConstToVariable(void *Variable, const char * VariableName, uint32_t Const) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__, __LINE__); } + PreOpCheck(false,__FILE__,__LINE__); ArmReg TempReg1 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); @@ -129,7 +130,7 @@ void CArmOps::AndConstToVariable(void *Variable, const char * VariableName, uint void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (DestReg == SourceReg && Const == 0) { @@ -196,7 +197,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) void CArmOps::AndArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (DestReg <= 0x7 && SourceReg2 <= 0x7 && SourceReg1 == DestReg) { @@ -235,9 +236,17 @@ void CArmOps::ArmBreakPoint(const char * FileName, uint32_t LineNumber) m_RegWorkingSet.AfterCallDirect(); } +void CArmOps::ArmNop(void) +{ + PreOpCheck(false,__FILE__,__LINE__); + + CPU_Message(" nop"); + AddCode16(0xbf00); +} + void CArmOps::BranchLabel8(ArmCompareType CompareType, const char * Label) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); CPU_Message(" b%s\t%s", ArmCompareSuffix(CompareType),Label); ArmThumbOpcode op = {0}; @@ -257,7 +266,7 @@ void CArmOps::BranchLabel8(ArmCompareType CompareType, const char * Label) void CArmOps::BranchLabel20(ArmCompareType CompareType, const char * Label) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); CPU_Message(" b%s\t%s", ArmCompareSuffix(CompareType),Label); Arm32Opcode op = {0}; @@ -275,7 +284,7 @@ void CArmOps::BranchLabel20(ArmCompareType CompareType, const char * Label) void CArmOps::CallFunction(void * Function, const char * FunctionName) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); ArmReg reg = Arm_R4; MoveConstToArmReg(reg,(uint32_t)Function,FunctionName); @@ -290,7 +299,7 @@ void CArmOps::CallFunction(void * Function, const char * FunctionName) void CArmOps::MoveArmRegToVariable(ArmReg Reg, void * Variable, const char * VariableName) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__, __LINE__); } + PreOpCheck(false,__FILE__,__LINE__); bool WasRegProtected = m_RegWorkingSet.GetArmRegProtected(Reg); if (!WasRegProtected) { @@ -310,6 +319,12 @@ void CArmOps::MoveArmRegToVariable(ArmReg Reg, void * Variable, const char * Var void CArmOps::MoveConstToArmReg(ArmReg Reg, uint16_t value, const char * comment) { + if (Reg == mLastStoreReg) + { + ArmNop(); + } + PreOpCheck(true,__FILE__,__LINE__); + if (mInItBlock) { if ((value & 0xF0) == 0 && Reg <= 7) @@ -373,7 +388,7 @@ void CArmOps::MoveConstToArmReg(ArmReg Reg, uint16_t value, const char * comment void CArmOps::MoveConstToArmRegTop(ArmReg DestReg, uint16_t Const, const char * comment) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); CPU_Message(" movt\t%s, %s", ArmRegName(DestReg), comment != NULL ? 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()); @@ -391,7 +406,7 @@ void CArmOps::MoveConstToArmRegTop(ArmReg DestReg, uint16_t Const, const char * void CArmOps::CompareArmRegToConst(ArmReg Reg, uint32_t value) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (Reg <= 0x7 && (value & 0xFFFFFF00) == 0) { @@ -430,7 +445,7 @@ void CArmOps::CompareArmRegToConst(ArmReg Reg, uint32_t value) void CArmOps::CompareArmRegToArmReg(ArmReg Reg1, ArmReg Reg2) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (Reg1 <= 0x7 && Reg2 <= 0x7 ) { @@ -462,7 +477,7 @@ void CArmOps::CompareArmRegToArmReg(ArmReg Reg1, ArmReg Reg2) void CArmOps::IfBlock(ArmItMask mask, ArmCompareType CompareType) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); CPU_Message(" it%s\t%s", ArmItMaskName(mask), ArmCompareSuffix(CompareType)); mInItBlock = true; @@ -488,7 +503,7 @@ void CArmOps::IfBlock(ArmItMask mask, ArmCompareType CompareType) void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, uint16_t offset) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if ((DestReg > 0x7 || RegPointer > 0x7 || (offset & ~0x1f) != 0)) { @@ -520,7 +535,7 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, u void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmReg RegPointer2, uint8_t shift) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if ((DestReg > 0x7 || RegPointer > 0x7 || RegPointer2 > 0x7) && (shift & ~3) == 0) { @@ -552,7 +567,7 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, A void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, uint8_t Offset, const char * comment) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (DestReg > 0x7 || RegPointer > 0x7 || (Offset & (~0x7C)) != 0) { @@ -584,7 +599,7 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, uint8 void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmReg RegPointer2, uint8_t shift) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if ((shift & ~3) != 0) { @@ -618,7 +633,7 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmRe void CArmOps::LoadArmRegPointerToFloatReg(ArmReg RegPointer, ArmFpuSingle Reg, uint8_t Offset) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (Offset != 0) { @@ -643,14 +658,14 @@ void CArmOps::LoadArmRegPointerToFloatReg(ArmReg RegPointer, ArmFpuSingle Reg, u void CArmOps::MoveArmRegArmReg(ArmReg DestReg, ArmReg SourceReg) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); g_Notify->BreakPoint(__FILE__,__LINE__); } void CArmOps::LoadFloatingPointControlReg(ArmReg DestReg) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); CPU_Message(" vmrs\t%s, fpscr", ArmRegName(DestReg)); Arm32Opcode op = {0}; @@ -662,10 +677,10 @@ void CArmOps::LoadFloatingPointControlReg(ArmReg DestReg) void CArmOps::MoveConstToArmReg(ArmReg DestReg, uint32_t value, const char * comment) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } - if (CanThumbCompressConst(value)) { + PreOpCheck(false, __FILE__, __LINE__); + CPU_Message(" mov.w\t%s, #0x%X\t; %s", ArmRegName(DestReg), (uint32_t)value, comment != NULL ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); uint16_t CompressedValue = ThumbCompressConst(value); Arm32Opcode op = { 0 }; @@ -694,7 +709,7 @@ void CArmOps::MoveConstToArmReg(ArmReg DestReg, uint32_t value, const char * com void CArmOps::MoveConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); ArmReg TempReg1 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); @@ -709,7 +724,7 @@ void CArmOps::MoveConstToVariable(uint32_t Const, void * Variable, const char * void CArmOps::MoveFloatRegToVariable(ArmFpuSingle reg, void * Variable, const char * VariableName) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); MoveConstToArmReg(Arm_R0,(uint32_t)Variable,VariableName); StoreFloatRegToArmRegPointer(reg,Arm_R0,0); @@ -717,15 +732,13 @@ void CArmOps::MoveFloatRegToVariable(ArmFpuSingle reg, void * Variable, const ch void CArmOps::MoveVariableToArmReg(void * Variable, const char * VariableName, ArmReg reg) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } - MoveConstToArmReg(reg,(uint32_t)Variable,VariableName); LoadArmRegPointerToArmReg(reg,reg,0); } void CArmOps::MoveVariableToFloatReg(void * Variable, const char * VariableName, ArmFpuSingle reg) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); MoveConstToArmReg(Arm_R0,(uint32_t)Variable,VariableName); LoadArmRegPointerToFloatReg(Arm_R0,reg,0); @@ -733,7 +746,7 @@ void CArmOps::MoveVariableToFloatReg(void * Variable, const char * VariableName, void CArmOps::OrArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2, uint32_t shift) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (shift == 0 && SourceReg1 == SourceReg2 && SourceReg1 <= 7 && SourceReg2 <= 7) { @@ -758,7 +771,7 @@ void CArmOps::OrArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceR void CArmOps::OrConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t value) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__, __LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (value == 0) { @@ -793,7 +806,7 @@ void CArmOps::OrConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t value) void CArmOps::OrConstToVariable(void * Variable, const char * VariableName, uint32_t value) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__, __LINE__); } + PreOpCheck(false,__FILE__,__LINE__); ArmReg TempReg1 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); @@ -814,7 +827,7 @@ void CArmOps::OrConstToVariable(void * Variable, const char * VariableName, uint void CArmOps::MulF32(ArmFpuSingle DestReg, ArmFpuSingle SourceReg1, ArmFpuSingle SourceReg2) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); CPU_Message(" vmul.f32\t%s, %s, %s", ArmFpuSingleName(DestReg), ArmFpuSingleName(SourceReg1), ArmFpuSingleName(SourceReg2)); Arm32Opcode op = {0}; @@ -837,7 +850,7 @@ void CArmOps::MulF32(ArmFpuSingle DestReg, ArmFpuSingle SourceReg1, ArmFpuSingle void CArmOps::PushArmReg(uint16_t Registers) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false,__FILE__,__LINE__); if (Registers == 0) { @@ -891,8 +904,8 @@ void CArmOps::PushArmReg(uint16_t Registers) void CArmOps::PopArmReg(uint16_t Registers) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } - + PreOpCheck(false, __FILE__, __LINE__); + if (Registers == 0) { return; @@ -945,7 +958,7 @@ void CArmOps::PopArmReg(uint16_t Registers) void CArmOps::ShiftRightSignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if ((shift & (~0x1F)) != 0) { @@ -982,7 +995,7 @@ void CArmOps::ShiftRightSignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shi void CArmOps::ShiftRightUnsignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if ((shift & (~0x1F)) != 0) { @@ -1019,7 +1032,7 @@ void CArmOps::ShiftRightUnsignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t s void CArmOps::ShiftLeftImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if (DestReg > 0x7 || SourceReg > 0x7 || (shift & (~0x1F)) != 0) { @@ -1063,7 +1076,7 @@ void CArmOps::SignExtendByte(ArmReg Reg) void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, uint8_t Offset, const char * comment) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if (DestReg > 0x7 || RegPointer > 0x7 || (Offset & (~0x7C)) != 0) { @@ -1087,11 +1100,12 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, uint op.Imm5.opcode = ArmSTR_ThumbImm; AddCode16(op.Hex); } + mLastStoreReg = DestReg; } void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, ArmReg RegPointer2, uint8_t shift) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__, __LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if (DestReg > 0x7 || RegPointer > 0x7 || RegPointer2 > 0x7 || shift != 0) { @@ -1119,7 +1133,7 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, ArmR void CArmOps::StoreFloatingPointControlReg(ArmReg SourceReg) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); CPU_Message(" vmsr\tfpscr, %s", ArmRegName(SourceReg)); Arm32Opcode op = {0}; @@ -1131,7 +1145,7 @@ void CArmOps::StoreFloatingPointControlReg(ArmReg SourceReg) void CArmOps::StoreFloatRegToArmRegPointer(ArmFpuSingle Reg, ArmReg RegPointer, uint8_t Offset) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if (Offset != 0) { @@ -1156,7 +1170,7 @@ void CArmOps::StoreFloatRegToArmRegPointer(ArmFpuSingle Reg, ArmReg RegPointer, void CArmOps::SubArmRegFromArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if (DestReg <= 7 && SourceReg1 <= 7 && SourceReg2 <= 7) { @@ -1188,7 +1202,7 @@ void CArmOps::SubArmRegFromArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Sour void CArmOps::SubConstFromArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if (DestReg <= 7 && DestReg == SourceReg && (Const & (~0xFF)) == 0) { @@ -1225,7 +1239,7 @@ void CArmOps::SubConstFromArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Cons void CArmOps::SubConstFromVariable(uint32_t Const, void * Variable, const char * VariableName) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); ArmReg TempReg1 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); @@ -1245,7 +1259,7 @@ void CArmOps::SubConstFromVariable(uint32_t Const, void * Variable, const char * void CArmOps::TestVariable(uint32_t Const, void * Variable, const char * VariableName) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); ArmReg TempReg1 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); ArmReg TempReg2 = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); @@ -1261,7 +1275,7 @@ void CArmOps::TestVariable(uint32_t Const, void * Variable, const char * Variabl void CArmOps::XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if (SourceReg <= 7 && DestReg <= 7) { @@ -1280,7 +1294,7 @@ void CArmOps::XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg) void CArmOps::XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); CPU_Message(" eor.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); Arm32Opcode op = {0}; @@ -1299,7 +1313,7 @@ void CArmOps::XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source void CArmOps::XorConstToArmReg(ArmReg DestReg, uint32_t value) { - if (mInItBlock) { g_Notify->BreakPoint(__FILE__,__LINE__); } + PreOpCheck(false, __FILE__, __LINE__); if (value == 0) { @@ -1488,6 +1502,15 @@ void * CArmOps::GetAddressOf(int value, ...) return Address; } +void CArmOps::PreOpCheck(bool AllowedInItBlock, const char * FileName, uint32_t LineNumber) +{ + if (!AllowedInItBlock && mInItBlock) + { + g_Notify->BreakPoint(FileName, LineNumber); + } + mLastStoreReg = Arm_Unknown; +} + void CArmOps::BreakPointNotification(const char * FileName, uint32_t LineNumber) { g_Notify->BreakPoint(FileName, LineNumber); diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h index 83458e9f8..1f97c658d 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h @@ -165,6 +165,7 @@ protected: 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); @@ -220,6 +221,7 @@ protected: private: friend CArmRegInfo; + static void PreOpCheck(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); @@ -241,6 +243,7 @@ private: static int mItBlockInstruction; static ArmCompareType mItBlockCompareType; static ArmItMask mItBlockMask; + static ArmReg mLastStoreReg; }; #define AddressOf(Addr) CArmOps::GetAddressOf(5,(Addr))