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
|
|
|
};
|
|
|
|
|
2010-06-07 02:23:58 +00:00
|
|
|
typedef void (* DelayFunc)(void);
|
|
|
|
|
2010-05-25 09:15:19 +00:00
|
|
|
public:
|
2013-01-03 08:51:00 +00:00
|
|
|
CRecompiler (CRegisters & Registers, CProfiling & Profile, bool & EndEmulation );
|
2010-05-25 09:15:19 +00:00
|
|
|
~CRecompiler (void);
|
|
|
|
|
|
|
|
void Run ( void );
|
2012-09-22 05:53:39 +00:00
|
|
|
void Reset ( void );
|
2013-01-03 08:51:00 +00:00
|
|
|
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
|
|
|
|
|
|
|
void ResetMemoryStackPos ( void );
|
|
|
|
|
|
|
|
inline DWORD & MemoryStackPos ( void ) { return m_MemoryStack; }
|
2010-05-25 09:15:19 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
private:
|
2013-01-03 08:51:00 +00:00
|
|
|
CRecompiler(void); // Disable default constructor
|
|
|
|
CRecompiler(const CRecompiler&); // Disable copy constructor
|
|
|
|
CRecompiler& operator=(const CRecompiler&); // Disable assignment
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-25 09:15:19 +00:00
|
|
|
CCompiledFunc * CompilerCode ( void );
|
|
|
|
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
|
|
|
|
void RecompilerMain_VirtualTable ( void );
|
|
|
|
void RecompilerMain_VirtualTable_validate ( void );
|
2012-09-24 22:07:51 +00:00
|
|
|
void RecompilerMain_ChangeMemory ( void );
|
|
|
|
void RecompilerMain_Lookup ( void );
|
|
|
|
void RecompilerMain_Lookup_TLB ( void );
|
|
|
|
void RecompilerMain_Lookup_validate ( void );
|
|
|
|
void RecompilerMain_Lookup_validate_TLB ( void );
|
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
|
|
|
};
|