project64/Source/Project64-core/N64System/Recompiler/Recompiler.h

92 lines
2.3 KiB
C
Raw Normal View History

2016-01-27 09:11:59 +00:00
#pragma once
#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>
#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
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,
Remove_Cheats,
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:
CRecompiler(CMipsMemoryVM & MMU, CRegisters & Registers, bool & EndEmulation);
2016-01-27 09:11:59 +00:00
~CRecompiler();
void Run();
void Reset();
void ResetRecompCode(bool bAllocate);
// 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);
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
uint8_t *& MemoryStackPos()
2022-10-10 00:22:17 +00:00
{
return m_MemoryStack;
}
2016-01-27 09:11:59 +00:00
private:
CRecompiler();
2022-10-10 00:22:17 +00:00
CRecompiler(const CRecompiler &);
CRecompiler & operator=(const CRecompiler &);
2016-01-27 09:11:59 +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();
void StartLog();
void StopLog();
void LogCodeBlock(const CCodeBlock & CodeBlock);
2022-10-10 00:22:17 +00:00
CCompiledFuncList m_Functions;
CMipsMemoryVM & m_MMU;
CRegisters & m_Registers;
bool & m_EndEmulation;
uint8_t * m_MemoryStack;
2016-10-02 21:46:05 +00:00
FUNCTION_PROFILE m_BlockProfile;
uint32_t & PROGRAM_COUNTER;
CLog * m_LogFile;
2016-01-27 09:11:59 +00:00
};