2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project 64 - 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
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
class CRecompiler :
|
2012-09-28 20:07:45 +00:00
|
|
|
protected CDebugSettings,
|
2010-05-25 09:15:19 +00:00
|
|
|
public CRecompilerSettings,
|
2010-06-16 07:31:47 +00:00
|
|
|
public CFunctionMap,
|
2010-05-25 09:15:19 +00:00
|
|
|
private CRecompMemory,
|
2010-06-04 06:25:07 +00:00
|
|
|
private CSystemRegisters
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum REMOVE_REASON {
|
|
|
|
Remove_InitialCode,
|
|
|
|
Remove_Cache,
|
|
|
|
Remove_ProtectedMem,
|
|
|
|
Remove_ValidateFunc,
|
|
|
|
Remove_TLB,
|
|
|
|
Remove_DMA,
|
2010-06-16 07:31:47 +00:00
|
|
|
Remove_StoreInstruc,
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
typedef void (*DelayFunc)();
|
2010-06-07 02:23:58 +00:00
|
|
|
|
2010-05-25 09:15:19 +00:00
|
|
|
public:
|
2015-04-28 22:19:02 +00:00
|
|
|
CRecompiler(CRegisters & Registers, CProfiling & Profile, bool & EndEmulation);
|
|
|
|
~CRecompiler();
|
2010-05-25 09:15:19 +00:00
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
void Run();
|
|
|
|
void Reset();
|
|
|
|
void ResetRecompCode(bool bAllocate);
|
2010-05-25 09:15:19 +00:00
|
|
|
|
2010-05-30 01:54:42 +00:00
|
|
|
bool GenerateX86Code (CCodeBlock & BlockInfo, CCodeSection * Section, DWORD Test );
|
2010-05-25 09:15:19 +00:00
|
|
|
|
|
|
|
//Self modifying code methods
|
2010-06-04 06:25:07 +00:00
|
|
|
void ClearRecompCode_Virt ( DWORD VirtualAddress, int length, REMOVE_REASON Reason );
|
2010-06-22 20:36:28 +00:00
|
|
|
void ClearRecompCode_Phys ( DWORD PhysicalAddress, int length, REMOVE_REASON Reason );
|
2010-07-23 10:45:35 +00:00
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
void ResetMemoryStackPos();
|
2010-07-23 10:45:35 +00:00
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
DWORD& MemoryStackPos() { return m_MemoryStack; }
|
2010-05-25 09:15:19 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
private:
|
2015-04-28 22:19:02 +00:00
|
|
|
CRecompiler(); // Disable default constructor
|
|
|
|
CRecompiler(const CRecompiler&); // Disable copy constructor
|
|
|
|
CRecompiler& operator=(const CRecompiler&); // Disable assignment
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-04-28 22:19:02 +00:00
|
|
|
CCompiledFunc * CompilerCode();
|
2010-05-25 09:15:19 +00:00
|
|
|
bool Compiler4300iBlock ( CCompiledFunc * info );
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
// Compiling code
|
2010-05-25 09:15:19 +00:00
|
|
|
bool CreateSectionLinkage ( CCodeSection * Section );
|
|
|
|
bool DisplaySectionInformation (CCodeSection * Section, DWORD ID, DWORD Test);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
// Main loops for the different look up methods
|
2015-04-28 22:19:02 +00:00
|
|
|
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();
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-25 09:15:19 +00:00
|
|
|
void RemoveFunction (CCompiledFunc * FunInfo, bool DelaySlot, REMOVE_REASON Reason );
|
2013-01-03 08:51:00 +00:00
|
|
|
|
|
|
|
CCompiledFuncList m_Functions;
|
|
|
|
CRegisters & m_Registers;
|
|
|
|
CProfiling & m_Profile;
|
|
|
|
bool & m_EndEmulation;
|
|
|
|
DWORD m_MemoryStack;
|
|
|
|
|
|
|
|
//Quick access to registers
|
|
|
|
DWORD & PROGRAM_COUNTER;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|