2016-01-27 09:11:59 +00:00
|
|
|
#pragma once
|
2016-07-06 20:14:12 +00:00
|
|
|
|
2017-04-27 22:14:55 +00:00
|
|
|
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
2022-10-10 00:22:17 +00:00
|
|
|
#include <Project64-core/N64System/Mips/Register.h>
|
|
|
|
#include <Project64-core/N64System/Profiling.h>
|
2021-04-14 05:34:15 +00:00
|
|
|
#include <Project64-core/N64System/Recompiler/FunctionMap.h>
|
2016-01-27 09:11:59 +00:00
|
|
|
#include <Project64-core/N64System/Recompiler/RecompilerMemory.h>
|
2016-07-06 20:14:12 +00:00
|
|
|
#include <Project64-core/Settings/DebugSettings.h>
|
2022-10-10 00:22:17 +00:00
|
|
|
#include <Project64-core/Settings/RecompilerSettings.h>
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2022-08-08 10:52:51 +00:00
|
|
|
class CLog;
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
class CRecompiler :
|
|
|
|
protected CDebugSettings,
|
|
|
|
public CRecompilerSettings,
|
|
|
|
public CFunctionMap,
|
2016-06-28 11:22:30 +00:00
|
|
|
public CRecompMemory,
|
2016-01-27 09:11:59 +00:00
|
|
|
private CSystemRegisters
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum REMOVE_REASON
|
|
|
|
{
|
|
|
|
Remove_InitialCode,
|
|
|
|
Remove_Cache,
|
|
|
|
Remove_ProtectedMem,
|
|
|
|
Remove_ValidateFunc,
|
|
|
|
Remove_TLB,
|
|
|
|
Remove_DMA,
|
|
|
|
Remove_StoreInstruc,
|
2017-06-30 11:11:56 +00:00
|
|
|
Remove_Cheats,
|
2018-02-19 07:17:35 +00:00
|
|
|
Remove_MemViewer,
|
2016-01-27 09:11:59 +00:00
|
|
|
};
|
|
|
|
|
2022-10-10 00:22:17 +00:00
|
|
|
typedef void (*DelayFunc)();
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
public:
|
2017-04-27 22:14:55 +00:00
|
|
|
CRecompiler(CMipsMemoryVM & MMU, CRegisters & Registers, bool & EndEmulation);
|
2016-01-27 09:11:59 +00:00
|
|
|
~CRecompiler();
|
|
|
|
|
|
|
|
void Run();
|
|
|
|
void Reset();
|
|
|
|
void ResetRecompCode(bool bAllocate);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Self-modifying code methods
|
2016-01-27 09:11:59 +00:00
|
|
|
void ClearRecompCode_Virt(uint32_t VirtualAddress, int32_t length, REMOVE_REASON Reason);
|
|
|
|
void ClearRecompCode_Phys(uint32_t PhysicalAddress, int32_t length, REMOVE_REASON Reason);
|
|
|
|
|
2022-08-08 10:52:51 +00:00
|
|
|
void ResetLog();
|
2016-01-27 09:11:59 +00:00
|
|
|
void ResetMemoryStackPos();
|
2016-10-02 21:46:05 +00:00
|
|
|
void ResetFunctionTimes();
|
|
|
|
void DumpFunctionTimes();
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2023-04-02 23:38:43 +00:00
|
|
|
uint8_t *& MemoryStackPos()
|
2022-10-10 00:22:17 +00:00
|
|
|
{
|
|
|
|
return m_MemoryStack;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
private:
|
2021-04-13 00:07:11 +00:00
|
|
|
CRecompiler();
|
2022-10-10 00:22:17 +00:00
|
|
|
CRecompiler(const CRecompiler &);
|
|
|
|
CRecompiler & operator=(const CRecompiler &);
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2016-08-07 06:48:33 +00:00
|
|
|
CCompiledFunc * CompileCode();
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2016-10-02 21:46:05 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t Address;
|
|
|
|
uint64_t TimeTaken;
|
|
|
|
} FUNCTION_PROFILE_DATA;
|
|
|
|
|
2022-10-10 00:22:17 +00:00
|
|
|
typedef std::map<CCompiledFunc::Func, FUNCTION_PROFILE_DATA> FUNCTION_PROFILE;
|
2016-10-02 21:46:05 +00:00
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
void RecompilerMain_VirtualTable();
|
|
|
|
void RecompilerMain_VirtualTable_validate();
|
|
|
|
void RecompilerMain_ChangeMemory();
|
|
|
|
void RecompilerMain_Lookup();
|
|
|
|
void RecompilerMain_Lookup_validate();
|
|
|
|
|
2022-08-08 10:52:51 +00:00
|
|
|
void StartLog();
|
|
|
|
void StopLog();
|
|
|
|
void LogCodeBlock(const CCodeBlock & CodeBlock);
|
|
|
|
|
2022-10-10 00:22:17 +00:00
|
|
|
CCompiledFuncList m_Functions;
|
2022-01-10 07:16:01 +00:00
|
|
|
CMipsMemoryVM & m_MMU;
|
|
|
|
CRegisters & m_Registers;
|
|
|
|
bool & m_EndEmulation;
|
2023-04-02 23:38:43 +00:00
|
|
|
uint8_t * m_MemoryStack;
|
2016-10-02 21:46:05 +00:00
|
|
|
FUNCTION_PROFILE m_BlockProfile;
|
2022-01-10 07:16:01 +00:00
|
|
|
uint32_t & PROGRAM_COUNTER;
|
2022-08-08 10:52:51 +00:00
|
|
|
CLog * m_LogFile;
|
2016-01-27 09:11:59 +00:00
|
|
|
};
|