/
Recompiler.h
92 lines (76 loc) · 2.31 KB
/
Recompiler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include <Project64-core/N64System/Mips/Register.h>
#include <Project64-core/N64System/Profiling.h>
#include <Project64-core/N64System/Recompiler/FunctionMap.h>
#include <Project64-core/N64System/Recompiler/RecompilerMemory.h>
#include <Project64-core/Settings/DebugSettings.h>
#include <Project64-core/Settings/RecompilerSettings.h>
class CLog;
class CRecompiler :
protected CDebugSettings,
public CRecompilerSettings,
public CFunctionMap,
public CRecompMemory
{
public:
enum REMOVE_REASON
{
Remove_InitialCode,
Remove_Cache,
Remove_ProtectedMem,
Remove_ValidateFunc,
Remove_TLB,
Remove_DMA,
Remove_StoreInstruc,
Remove_Cheats,
Remove_MemViewer,
};
typedef void (*DelayFunc)();
public:
CRecompiler(CN64System & System, bool & EndEmulation);
~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 ResetLog();
void ResetMemoryStackPos();
void ResetFunctionTimes();
void DumpFunctionTimes();
uint8_t *& MemoryStackPos()
{
return m_MemoryStack;
}
private:
CRecompiler();
CRecompiler(const CRecompiler &);
CRecompiler & operator=(const CRecompiler &);
CCompiledFunc * CompileCode();
typedef struct
{
uint32_t Address;
uint64_t TimeTaken;
} FUNCTION_PROFILE_DATA;
typedef std::map<CCompiledFunc::Func, FUNCTION_PROFILE_DATA> FUNCTION_PROFILE;
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);
CCompiledFuncList m_Functions;
CN64System & m_System;
CMipsMemoryVM & m_MMU;
CRegisters & m_Reg;
CTLB & m_TLB;
bool & m_EndEmulation;
uint8_t * m_MemoryStack;
FUNCTION_PROFILE m_BlockProfile;
uint32_t & PROGRAM_COUNTER;
CLog * m_LogFile;
};