2016-08-11 11:09:21 +00:00
|
|
|
#pragma once
|
|
|
|
#if defined(__arm__) || defined(_M_ARM)
|
2021-06-28 01:57:35 +00:00
|
|
|
#include <Project64-core/N64System/Mips/Register.h>
|
2016-08-11 11:09:21 +00:00
|
|
|
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
|
|
|
|
#include <Project64-core/N64System/Recompiler/Arm/ArmOps.h>
|
2022-01-03 23:37:52 +00:00
|
|
|
#include <Project64-core\Settings\GameSettings.h>
|
2016-08-11 11:09:21 +00:00
|
|
|
|
|
|
|
class CArmRecompilerOps :
|
|
|
|
public CRecompilerOps,
|
|
|
|
private CArmOps,
|
2022-01-03 23:37:52 +00:00
|
|
|
protected CSystemRegisters,
|
|
|
|
private CGameSettings
|
2016-08-11 11:09:21 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-06-06 10:19:44 +00:00
|
|
|
CArmRecompilerOps(CMipsMemoryVM & MMU);
|
|
|
|
~CArmRecompilerOps();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Trap functions
|
2019-12-17 15:08:15 +00:00
|
|
|
void Compile_TrapCompare(TRAP_COMPARE CompareType);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Branch functions
|
2016-08-11 11:09:21 +00:00
|
|
|
void Compile_BranchCompare(BRANCH_COMPARE CompareType);
|
2022-07-25 08:22:44 +00:00
|
|
|
void Compile_Branch(BRANCH_COMPARE CompareType, bool Link);
|
2016-08-11 11:09:21 +00:00
|
|
|
void Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link);
|
|
|
|
void BNE_Compare();
|
|
|
|
void BEQ_Compare();
|
|
|
|
void BGTZ_Compare();
|
|
|
|
void BLEZ_Compare();
|
|
|
|
void BLTZ_Compare();
|
|
|
|
void BGEZ_Compare();
|
|
|
|
void COP1_BCF_Compare();
|
|
|
|
void COP1_BCT_Compare();
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Opcode functions
|
2022-01-03 23:37:52 +00:00
|
|
|
void J();
|
|
|
|
void JAL();
|
|
|
|
void ADDI();
|
|
|
|
void ADDIU();
|
|
|
|
void SLTI();
|
|
|
|
void SLTIU();
|
|
|
|
void ANDI();
|
|
|
|
void ORI();
|
|
|
|
void XORI();
|
|
|
|
void LUI();
|
2022-08-15 00:35:16 +00:00
|
|
|
void DADDI();
|
2022-01-03 23:37:52 +00:00
|
|
|
void DADDIU();
|
|
|
|
void LDL();
|
|
|
|
void LDR();
|
|
|
|
void LB();
|
|
|
|
void LH();
|
|
|
|
void LWL();
|
|
|
|
void LW();
|
|
|
|
void LBU();
|
|
|
|
void LHU();
|
|
|
|
void LWR();
|
|
|
|
void LWU();
|
|
|
|
void SB();
|
|
|
|
void SH();
|
|
|
|
void SWL();
|
|
|
|
void SW();
|
|
|
|
void SWR();
|
|
|
|
void SDL();
|
|
|
|
void SDR();
|
|
|
|
void CACHE();
|
|
|
|
void LL();
|
|
|
|
void LWC1();
|
|
|
|
void LDC1();
|
|
|
|
void LD();
|
|
|
|
void SC();
|
|
|
|
void SWC1();
|
|
|
|
void SDC1();
|
|
|
|
void SD();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// R4300i opcodes: Special
|
2022-01-03 23:37:52 +00:00
|
|
|
void SPECIAL_SLL();
|
|
|
|
void SPECIAL_SRL();
|
|
|
|
void SPECIAL_SRA();
|
|
|
|
void SPECIAL_SLLV();
|
|
|
|
void SPECIAL_SRLV();
|
|
|
|
void SPECIAL_SRAV();
|
|
|
|
void SPECIAL_JR();
|
|
|
|
void SPECIAL_JALR();
|
2016-08-11 11:09:21 +00:00
|
|
|
void SPECIAL_SYSCALL();
|
2022-01-03 23:37:52 +00:00
|
|
|
void SPECIAL_MFLO();
|
|
|
|
void SPECIAL_MTLO();
|
|
|
|
void SPECIAL_MFHI();
|
|
|
|
void SPECIAL_MTHI();
|
|
|
|
void SPECIAL_DSLLV();
|
|
|
|
void SPECIAL_DSRLV();
|
|
|
|
void SPECIAL_DSRAV();
|
|
|
|
void SPECIAL_MULT();
|
|
|
|
void SPECIAL_MULTU();
|
|
|
|
void SPECIAL_DIV();
|
|
|
|
void SPECIAL_DIVU();
|
|
|
|
void SPECIAL_DMULT();
|
|
|
|
void SPECIAL_DMULTU();
|
|
|
|
void SPECIAL_DDIV();
|
|
|
|
void SPECIAL_DDIVU();
|
|
|
|
void SPECIAL_ADD();
|
|
|
|
void SPECIAL_ADDU();
|
|
|
|
void SPECIAL_SUB();
|
|
|
|
void SPECIAL_SUBU();
|
|
|
|
void SPECIAL_AND();
|
|
|
|
void SPECIAL_OR();
|
|
|
|
void SPECIAL_XOR();
|
|
|
|
void SPECIAL_NOR();
|
|
|
|
void SPECIAL_SLT();
|
|
|
|
void SPECIAL_SLTU();
|
|
|
|
void SPECIAL_DADD();
|
|
|
|
void SPECIAL_DADDU();
|
|
|
|
void SPECIAL_DSUB();
|
|
|
|
void SPECIAL_DSUBU();
|
|
|
|
void SPECIAL_DSLL();
|
|
|
|
void SPECIAL_DSRL();
|
|
|
|
void SPECIAL_DSRA();
|
|
|
|
void SPECIAL_DSLL32();
|
|
|
|
void SPECIAL_DSRL32();
|
|
|
|
void SPECIAL_DSRA32();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// COP0 functions
|
2022-01-03 23:37:52 +00:00
|
|
|
void COP0_MF();
|
|
|
|
void COP0_MT();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// COP0 CO functions
|
2022-01-03 23:37:52 +00:00
|
|
|
void COP0_CO_TLBR();
|
|
|
|
void COP0_CO_TLBWI();
|
|
|
|
void COP0_CO_TLBWR();
|
|
|
|
void COP0_CO_TLBP();
|
|
|
|
void COP0_CO_ERET();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// COP1 functions
|
2022-01-03 23:37:52 +00:00
|
|
|
void COP1_MF();
|
|
|
|
void COP1_DMF();
|
|
|
|
void COP1_CF();
|
|
|
|
void COP1_MT();
|
|
|
|
void COP1_DMT();
|
|
|
|
void COP1_CT();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// COP1: S functions
|
2022-01-03 23:37:52 +00:00
|
|
|
void COP1_S_ADD();
|
|
|
|
void COP1_S_SUB();
|
|
|
|
void COP1_S_MUL();
|
|
|
|
void COP1_S_DIV();
|
|
|
|
void COP1_S_ABS();
|
|
|
|
void COP1_S_NEG();
|
|
|
|
void COP1_S_SQRT();
|
|
|
|
void COP1_S_MOV();
|
|
|
|
void COP1_S_ROUND_L();
|
|
|
|
void COP1_S_TRUNC_L();
|
|
|
|
void COP1_S_CEIL_L();
|
|
|
|
void COP1_S_FLOOR_L();
|
|
|
|
void COP1_S_ROUND_W();
|
|
|
|
void COP1_S_TRUNC_W();
|
|
|
|
void COP1_S_CEIL_W();
|
|
|
|
void COP1_S_FLOOR_W();
|
|
|
|
void COP1_S_CVT_D();
|
|
|
|
void COP1_S_CVT_W();
|
|
|
|
void COP1_S_CVT_L();
|
|
|
|
void COP1_S_CMP();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// COP1: D functions
|
2022-01-03 23:37:52 +00:00
|
|
|
void COP1_D_ADD();
|
|
|
|
void COP1_D_SUB();
|
|
|
|
void COP1_D_MUL();
|
|
|
|
void COP1_D_DIV();
|
|
|
|
void COP1_D_ABS();
|
|
|
|
void COP1_D_NEG();
|
|
|
|
void COP1_D_SQRT();
|
|
|
|
void COP1_D_MOV();
|
|
|
|
void COP1_D_ROUND_L();
|
|
|
|
void COP1_D_TRUNC_L();
|
|
|
|
void COP1_D_CEIL_L();
|
|
|
|
void COP1_D_FLOOR_L();
|
|
|
|
void COP1_D_ROUND_W();
|
|
|
|
void COP1_D_TRUNC_W();
|
|
|
|
void COP1_D_CEIL_W();
|
|
|
|
void COP1_D_FLOOR_W();
|
|
|
|
void COP1_D_CVT_S();
|
|
|
|
void COP1_D_CVT_W();
|
|
|
|
void COP1_D_CVT_L();
|
|
|
|
void COP1_D_CMP();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// COP1: W functions
|
2022-01-03 23:37:52 +00:00
|
|
|
void COP1_W_CVT_S();
|
|
|
|
void COP1_W_CVT_D();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// COP1: L functions
|
2022-01-03 23:37:52 +00:00
|
|
|
void COP1_L_CVT_S();
|
|
|
|
void COP1_L_CVT_D();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Other functions
|
2022-01-03 23:37:52 +00:00
|
|
|
void UnknownOpcode();
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2016-11-22 22:03:40 +00:00
|
|
|
private:
|
2016-08-11 11:09:21 +00:00
|
|
|
void EnterCodeBlock();
|
|
|
|
void ExitCodeBlock();
|
|
|
|
void CompileExitCode();
|
|
|
|
void CompileCop1Test();
|
|
|
|
void CompileInPermLoop(CRegInfo & RegSet, uint32_t ProgramCounter);
|
2016-11-23 07:58:22 +00:00
|
|
|
void OutputRegisterState(const CRegInfo & SyncTo, const CRegInfo & CurrentSet) const;
|
2016-08-11 11:09:21 +00:00
|
|
|
void SyncRegState(const CRegInfo & SyncTo);
|
2016-11-23 07:58:22 +00:00
|
|
|
bool SetupRegisterForLoop(CCodeBlock * BlockInfo, const CRegInfo & RegSet);
|
2016-08-11 11:09:21 +00:00
|
|
|
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 JumpToUnknown(CJumpInfo * JumpInfo);
|
|
|
|
void SetCurrentPC(uint32_t ProgramCounter);
|
|
|
|
uint32_t GetCurrentPC(void);
|
|
|
|
void SetCurrentSection(CCodeSection * section);
|
2022-06-06 10:19:44 +00:00
|
|
|
void SetNextStepType(PIPELINE_STAGE StepType);
|
|
|
|
PIPELINE_STAGE GetNextStepType( void );
|
2022-07-18 08:31:00 +00:00
|
|
|
const R4300iOpcode & GetOpcode ( void ) const;
|
2016-08-11 11:09:21 +00:00
|
|
|
void PreCompileOpcode(void);
|
|
|
|
void PostCompileOpcode ( void );
|
|
|
|
void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason);
|
2016-11-22 06:41:46 +00:00
|
|
|
void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, CArmOps::ArmCompareType CompareType);
|
2016-08-11 11:09:21 +00:00
|
|
|
static void UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles);
|
2022-04-18 11:27:59 +00:00
|
|
|
void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false, bool UpdateTimer = true);
|
2016-08-11 11:09:21 +00:00
|
|
|
void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet);
|
2016-10-01 20:22:10 +00:00
|
|
|
void CompileReadTLBMiss(ArmReg AddressReg, ArmReg LookUpReg);
|
2016-11-23 07:00:35 +00:00
|
|
|
void CompileWriteTLBMiss(ArmReg AddressReg, ArmReg LookUpReg);
|
2018-01-20 23:18:52 +00:00
|
|
|
void CompileExecuteBP(void);
|
2018-07-29 20:07:45 +00:00
|
|
|
void CompileExecuteDelaySlotBP(void);
|
2016-08-11 11:09:21 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Helper functions
|
2016-11-23 07:58:22 +00:00
|
|
|
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); }
|
2016-10-01 08:12:46 +00:00
|
|
|
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); }
|
2016-11-23 07:58:22 +00:00
|
|
|
static inline int32_t GetMipsRegHi_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); }
|
2016-10-01 08:12:46 +00:00
|
|
|
static inline ArmReg GetMipsRegMapLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); }
|
|
|
|
static inline ArmReg GetMipsRegMapHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); }
|
|
|
|
|
|
|
|
static inline bool IsKnown(int32_t Reg) { return m_RegWorkingSet.IsKnown(Reg); }
|
2016-10-01 08:27:02 +00:00
|
|
|
static inline bool IsUnknown(int32_t Reg) { return m_RegWorkingSet.IsUnknown(Reg); }
|
2016-10-01 08:12:46 +00:00
|
|
|
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); }
|
2016-11-23 07:58:22 +00:00
|
|
|
static inline bool IsUnsigned(int32_t Reg) { return m_RegWorkingSet.IsUnsigned(Reg); }
|
2016-10-01 08:12:46 +00:00
|
|
|
static inline bool Is32Bit(int32_t Reg) { return m_RegWorkingSet.Is32Bit(Reg); }
|
|
|
|
static inline bool Is64Bit(int32_t Reg) { return m_RegWorkingSet.Is64Bit(Reg); }
|
2016-11-23 07:58:22 +00:00
|
|
|
static inline bool Is32BitMapped(int32_t Reg) { return m_RegWorkingSet.Is32BitMapped(Reg); }
|
|
|
|
static inline bool Is64BitMapped(int32_t Reg) { return m_RegWorkingSet.Is64BitMapped(Reg); }
|
2016-10-01 10:24:42 +00:00
|
|
|
static inline void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad); }
|
2016-10-01 20:22:10 +00:00
|
|
|
static inline void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad); }
|
2016-10-01 08:12:46 +00:00
|
|
|
static inline void UnMap_GPR(uint32_t Reg, bool WriteBackValue){ m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue); }
|
2016-11-22 11:39:24 +00:00
|
|
|
static inline void WriteBack_GPR(uint32_t Reg, bool Unmapping){ m_RegWorkingSet.WriteBack_GPR(Reg, Unmapping); }
|
2016-10-01 08:12:46 +00:00
|
|
|
static inline ArmReg Map_TempReg(ArmReg Reg, int32_t MipsReg, bool LoadHiWord) { return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord); }
|
2016-11-23 07:58:22 +00:00
|
|
|
static inline ArmReg Map_Variable(CArmRegInfo::VARIABLE_MAPPED variable, ArmReg Reg = Arm_Any) { return m_RegWorkingSet.Map_Variable(variable, Reg); }
|
2016-10-01 08:12:46 +00:00
|
|
|
|
|
|
|
static inline void ResetRegProtection() { m_RegWorkingSet.ResetRegProtection(); }
|
2016-10-01 20:22:10 +00:00
|
|
|
static inline void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod) { m_RegWorkingSet.FixRoundModel(RoundMethod); }
|
|
|
|
|
2016-10-01 08:12:46 +00:00
|
|
|
static inline void ProtectGPR(uint32_t Reg) { m_RegWorkingSet.ProtectGPR(Reg); }
|
2016-11-23 07:00:35 +00:00
|
|
|
static inline void UnProtectGPR(uint32_t Reg) { m_RegWorkingSet.UnProtectGPR(Reg); }
|
2016-11-23 07:58:22 +00:00
|
|
|
static inline bool UnMap_ArmReg(ArmReg Reg) { return m_RegWorkingSet.UnMap_ArmReg(Reg); }
|
2016-10-01 08:12:46 +00:00
|
|
|
|
2016-11-23 07:00:35 +00:00
|
|
|
void SW(bool bCheckLLbit);
|
|
|
|
void SW_Const(uint32_t Value, uint32_t VAddr);
|
|
|
|
void SW_Register(ArmReg Reg, uint32_t VAddr);
|
2016-11-22 22:18:23 +00:00
|
|
|
void LW(bool ResultSigned, bool bRecordLLBit);
|
2016-11-22 22:10:15 +00:00
|
|
|
void LB_KnownAddress(ArmReg Reg, uint32_t VAddr, bool SignExtend);
|
2016-11-22 22:18:23 +00:00
|
|
|
void LW_KnownAddress(ArmReg Reg, uint32_t VAddr);
|
2016-08-11 11:09:21 +00:00
|
|
|
void CompileInterpterCall (void * Function, const char * FunctionName);
|
|
|
|
void OverflowDelaySlot(bool TestTimer);
|
|
|
|
|
|
|
|
EXIT_LIST m_ExitInfo;
|
2022-06-06 10:19:44 +00:00
|
|
|
CMipsMemoryVM & m_MMU;
|
|
|
|
PIPELINE_STAGE m_PipelineStage;
|
2016-08-11 11:09:21 +00:00
|
|
|
uint32_t m_CompilePC;
|
2022-07-18 08:31:00 +00:00
|
|
|
R4300iOpcode m_Opcode;
|
2016-08-11 11:09:21 +00:00
|
|
|
CCodeSection * m_Section;
|
2016-11-22 22:18:23 +00:00
|
|
|
|
|
|
|
static uint32_t m_TempValue;
|
2016-08-11 11:09:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|