2016-01-27 09:11:59 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
#pragma once
|
2016-07-06 20:14:12 +00:00
|
|
|
|
|
|
|
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
2017-04-27 22:14:55 +00:00
|
|
|
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
2016-01-27 09:11:59 +00:00
|
|
|
#include <Project64-core/N64System/Recompiler/FunctionMapClass.h>
|
|
|
|
#include <Project64-core/N64System/Recompiler/RecompilerMemory.h>
|
|
|
|
#include <Project64-core/N64System/ProfilingClass.h>
|
2016-07-06 20:14:12 +00:00
|
|
|
#include <Project64-core/Settings/RecompilerSettings.h>
|
|
|
|
#include <Project64-core/Settings/DebugSettings.h>
|
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
|
|
|
};
|
|
|
|
|
|
|
|
typedef void(*DelayFunc)();
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
//Self modifying code methods
|
|
|
|
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 ResetMemoryStackPos();
|
2016-10-02 21:46:05 +00:00
|
|
|
void ResetFunctionTimes();
|
|
|
|
void DumpFunctionTimes();
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
uint32_t& MemoryStackPos() { return m_MemoryStack; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
CRecompiler(); // Disable default constructor
|
|
|
|
CRecompiler(const CRecompiler&); // Disable copy constructor
|
|
|
|
CRecompiler& operator=(const CRecompiler&); // Disable assignment
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
typedef std::map <CCompiledFunc::Func, FUNCTION_PROFILE_DATA> FUNCTION_PROFILE;
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
// Main loops for the different look up methods
|
|
|
|
void RecompilerMain_VirtualTable();
|
|
|
|
void RecompilerMain_VirtualTable_validate();
|
|
|
|
void RecompilerMain_ChangeMemory();
|
|
|
|
void RecompilerMain_Lookup();
|
|
|
|
void RecompilerMain_Lookup_TLB();
|
|
|
|
void RecompilerMain_Lookup_validate();
|
|
|
|
void RecompilerMain_Lookup_validate_TLB();
|
|
|
|
|
|
|
|
CCompiledFuncList m_Functions;
|
2017-04-27 22:14:55 +00:00
|
|
|
CMipsMemoryVM & m_MMU;
|
2016-01-27 09:11:59 +00:00
|
|
|
CRegisters & m_Registers;
|
|
|
|
bool & m_EndEmulation;
|
|
|
|
uint32_t m_MemoryStack;
|
2016-10-02 21:46:05 +00:00
|
|
|
FUNCTION_PROFILE m_BlockProfile;
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
//Quick access to registers
|
|
|
|
uint32_t & PROGRAM_COUNTER;
|
|
|
|
};
|