[Project64] Get x86/x86RecompilerOps.cpp to use an base interface

This commit is contained in:
zilmar 2016-07-04 17:51:11 +10:00
parent cd0f305124
commit 778caf78f0
10 changed files with 785 additions and 553 deletions

View File

@ -282,7 +282,7 @@ bool CCheats::IsValid16BitCode(const char * CheatString)
break;
case 0x81000000:
case 0xA1000000:
case 0xD1000000:
case 0xD1000000:
case 0xD3000000:
if (((CodeEntry.Command & 0xFFFFFF) & 1) == 1)
{
@ -348,7 +348,7 @@ int CCheats::ApplyCheatEntry(CMipsMemoryVM * MMU, const CODES & CodeEntry, int C
switch (Code.Command & 0xFF000000)
{
// Gameshark / AR
case 0x50000000:
case 0x50000000:
{
if ((CurrentEntry + 1) >= (int)CodeEntry.size())
{
@ -404,22 +404,22 @@ int CCheats::ApplyCheatEntry(CMipsMemoryVM * MMU, const CODES & CodeEntry, int C
Address = 0xA0000000 | (Code.Command & 0xFFFFFF);
if (Execute) { MMU->SH_VAddr(Address, Code.Value); }
break;
case 0xD0000000:
case 0xD0000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF);
MMU->LB_VAddr(Address, bMemory);
if (bMemory != Code.Value) { Execute = false; }
return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1;
case 0xD1000000:
case 0xD1000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF);
MMU->LH_VAddr(Address, wMemory);
if (wMemory != Code.Value) { Execute = false; }
return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1;
case 0xD2000000:
case 0xD2000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF);
MMU->LB_VAddr(Address, bMemory);
if (bMemory == Code.Value) { Execute = false; }
return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1;
case 0xD3000000:
case 0xD3000000:
Address = 0x80000000 | (Code.Command & 0xFFFFFF);
MMU->LH_VAddr(Address, wMemory);
if (wMemory == Code.Value) { Execute = false; }

View File

@ -11,7 +11,7 @@
#pragma once
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include "TranslateVaddr.h"
#include <Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h>
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
#include <Project64-core/N64System/Interpreter/InterpreterOps.h>
#include <Project64-core/N64System/Mips/PifRam.h>
#include <Project64-core/N64System/Mips/FlashRam.h>
@ -57,6 +57,7 @@
* 0xAABBCCDD EEFFGGHH --> 0xDDCCBBAA HHGGFFEE
* GPR bits[63..0] b1b2b3b4 b5b6b7b8
*/
class CX86RecompilerOps;
class CMipsMemoryVM :
public CTransVaddr,
@ -130,7 +131,7 @@ private:
CMipsMemoryVM(const CMipsMemoryVM&); // Disable copy constructor
CMipsMemoryVM& operator=(const CMipsMemoryVM&); // Disable assignment
friend CRecompilerOps;
friend CX86RecompilerOps;
void Compile_LW(bool ResultSigned, bool bRecordLLbit);
void Compile_SW(bool bCheckLLbit);

View File

@ -30,7 +30,7 @@
#pragma warning(disable:4355) // Disable 'this' : used in base member initializer list
CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly) :
CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem) :
CSystemEvents(this, Plugins),
m_EndEmulation(false),
m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)),
@ -56,7 +56,8 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly) :
m_SyncCount(0),
m_thread(NULL),
m_hPauseEvent(true),
m_CheatsSlectionChanged(false)
m_CheatsSlectionChanged(false),
m_SyncCpu(SyncSystem)
{
uint32_t gameHertz = g_Settings->LoadDword(Game_ScreenHertz);
if (gameHertz == 0)
@ -66,6 +67,36 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly) :
m_Limiter.SetHertz(gameHertz);
g_Settings->SaveDword(GameRunning_ScreenHertz, gameHertz);
m_Cheats.LoadCheats(!g_Settings->LoadDword(Setting_RememberCheats), Plugins);
WriteTrace(TraceN64System, TraceDebug, "Setting up system");
CInterpreterCPU::BuildCPU();
if (!SyncSystem)
{
uint32_t CpuType = g_Settings->LoadDword(Game_CpuType);
WriteTrace(TraceN64System, TraceDebug, "CpuType = %d",CpuType);
if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled))
{
g_Settings->SaveDword(Game_CpuType, CPU_Recompiler);
CpuType = CPU_Recompiler;
}
if (CpuType == CPU_SyncCores)
{
if (g_Plugins->SyncWindow() == NULL)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
g_Notify->DisplayMessage(5, "Copy Plugins");
g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync));
m_SyncPlugins = new CPlugins(Directory_PluginSync);
m_SyncPlugins->SetRenderWindows(g_Plugins->SyncWindow(), NULL);
m_SyncCPU = new CN64System(m_SyncPlugins, true, true);
}
if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores)
{
m_Recomp = new CRecompiler(m_Reg, m_Profile, m_EndEmulation);
}
}
}
CN64System::~CN64System()
@ -88,6 +119,12 @@ CN64System::~CN64System()
delete m_SyncPlugins;
m_SyncPlugins = NULL;
}
if (m_thread != NULL)
{
WriteTrace(TraceN64System, TraceDebug, "Deleting thread object");
delete m_thread;
m_thread = NULL;
}
}
void CN64System::ExternalEvent(SystemEvent action)
@ -257,7 +294,7 @@ bool CN64System::RunFileImage(const char * FileLoc)
WriteTrace(TraceN64System, TraceDebug, "Finished Loading (GoodName: %s)", g_Settings->LoadStringVal(Game_GoodName).c_str());
g_BaseSystem = new CN64System(g_Plugins, false);
g_BaseSystem = new CN64System(g_Plugins, false, false);
if (g_BaseSystem)
{
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
@ -267,7 +304,16 @@ bool CN64System::RunFileImage(const char * FileLoc)
}
else
{
g_BaseSystem->SetActiveSystem(true);
bool bSetActive = true;
if (g_BaseSystem->m_SyncCPU != NULL)
{
bSetActive = g_BaseSystem->m_SyncCPU->SetActiveSystem(true);
}
if (bSetActive)
{
bSetActive = g_BaseSystem->SetActiveSystem(true);
}
}
}
}
@ -437,7 +483,7 @@ bool CN64System::EmulationStarting(CThread * thread)
void CN64System::StartEmulation2(bool NewThread)
{
WriteTrace(TraceN64System, TraceDebug, "Start (NewThread: %s)", NewThread ? "true" : "false");
WriteTrace(TraceN64System, TraceDebug, "Start (NewThread: %s)",NewThread ? "true" : "false");
if (NewThread)
{
if (bHaveDebugger())
@ -446,35 +492,6 @@ void CN64System::StartEmulation2(bool NewThread)
}
g_Settings->SaveDword(Game_CurrentSaveState, g_Settings->LoadDefaultDword(Game_CurrentSaveState));
WriteTrace(TraceN64System, TraceDebug, "Setting up system");
CInterpreterCPU::BuildCPU();
uint32_t CpuType = g_Settings->LoadDword(Game_CpuType);
WriteTrace(TraceN64System, TraceDebug, "CpuType = %d", CpuType);
if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled))
{
g_Settings->SaveDword(Game_CpuType, CPU_Recompiler);
CpuType = CPU_Recompiler;
}
if (CpuType == CPU_SyncCores)
{
if (g_Plugins->SyncWindow() == NULL)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
g_Notify->DisplayMessage(5, "Copy Plugins");
g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync));
m_SyncPlugins = new CPlugins(Directory_PluginSync);
m_SyncPlugins->SetRenderWindows(g_Plugins->SyncWindow(), NULL);
m_SyncCPU = new CN64System(m_SyncPlugins, true);
}
if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores)
{
m_Recomp = new CRecompiler(m_Reg, m_Profile, m_EndEmulation);
}
WriteTrace(TraceN64System, TraceDebug, "Setting system as active");
bool bSetActive = true;
if (m_SyncCPU)
@ -487,11 +504,16 @@ void CN64System::StartEmulation2(bool NewThread)
bSetActive = SetActiveSystem();
}
if (!bSetActive)
if (!m_Plugins->Reset(this) || !m_Plugins->initilized())
{
WriteTrace(TraceN64System, TraceWarning, "can not run, plugins not initlized");
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT);
}
else if (!bSetActive)
{
WriteTrace(TraceN64System, TraceWarning, "Failed to set system as active");
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT);
}
else
{
@ -953,7 +975,7 @@ void CN64System::ExecuteCPU()
default: ExecuteInterpret(); break;
}
WriteTrace(TraceN64System, TraceDebug, "CPU finished executing");
g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false);
CpuStopped();
WriteTrace(TraceN64System, TraceDebug, "Notifing plugins rom is done");
m_Plugins->RomClosed();
if (m_SyncCPU)

View File

@ -47,7 +47,7 @@ class CN64System :
protected CDebugSettings
{
public:
CN64System(CPlugins * Plugins, bool SavesReadOnly);
CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem);
virtual ~CN64System(void);
CProfiling m_Profile;
@ -154,6 +154,7 @@ private:
uint32_t m_TLBLoadAddress;
uint32_t m_TLBStoreAddress;
uint32_t m_SyncCount;
bool m_SyncCpu;
bool m_CheatsSlectionChanged;
//When Syncing cores this is the PC where it last Sync'ed correctly

View File

@ -18,27 +18,27 @@
#include <Project64-core/N64System/N64Class.h>
#include <Project64-core/N64System/Mips/OpcodeName.h>
bool DelaySlotEffectsCompare (uint32_t PC, uint32_t Reg1, uint32_t Reg2);
bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2);
CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * CompiledLocation) :
m_VAddrEnter(VAddrEnter),
m_VAddrFirst(VAddrEnter),
m_VAddrLast(VAddrEnter),
m_CompiledLocation(CompiledLocation),
m_EnterSection(NULL),
m_RecompilerOps(NULL),
m_Test(1)
m_VAddrEnter(VAddrEnter),
m_VAddrFirst(VAddrEnter),
m_VAddrLast(VAddrEnter),
m_CompiledLocation(CompiledLocation),
m_EnterSection(NULL),
m_RecompilerOps(NULL),
m_Test(1)
{
memset(m_MemContents, 0, sizeof(m_MemContents));
memset(m_MemLocation, 0, sizeof(m_MemLocation));
CCodeSection * baseSection = new CCodeSection(this, VAddrEnter, 0, false);
if (baseSection == NULL)
m_RecompilerOps = new CX86RecompilerOps;
if (m_RecompilerOps == NULL)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
m_RecompilerOps = new CRecompilerOps;
if (m_RecompilerOps == NULL)
CCodeSection * baseSection = new CCodeSection(this, VAddrEnter, 0, false);
if (baseSection == NULL)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
@ -58,9 +58,9 @@ CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * CompiledLocation) :
baseSection->m_ContinueSection = m_EnterSection;
m_EnterSection->AddParent(baseSection);
m_Sections.push_back(m_EnterSection);
m_SectionMap.insert(SectionMap::value_type(VAddrEnter,m_EnterSection));
m_SectionMap.insert(SectionMap::value_type(VAddrEnter, m_EnterSection));
if (g_TransVaddr->VAddrToRealAddr(VAddrEnter,*(reinterpret_cast<void **>(&m_MemLocation[0]))))
if (g_TransVaddr->VAddrToRealAddr(VAddrEnter, *(reinterpret_cast<void **>(&m_MemLocation[0]))))
{
m_MemLocation[1] = m_MemLocation[0] + 1;
m_MemContents[0] = *m_MemLocation[0];
@ -68,8 +68,8 @@ CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * CompiledLocation) :
}
else
{
memset(m_MemLocation,0,sizeof(m_MemLocation));
memset(m_MemContents,0,sizeof(m_MemContents));
memset(m_MemLocation, 0, sizeof(m_MemLocation));
memset(m_MemContents, 0, sizeof(m_MemContents));
}
AnalyseBlock();
@ -91,7 +91,7 @@ CCodeBlock::~CCodeBlock()
}
}
bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC )
bool CCodeBlock::SetSection(CCodeSection * & Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC)
{
if (Section != NULL)
{
@ -124,7 +124,7 @@ bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSe
if (Section == NULL)
{
Section = new CCodeSection(this,TargetPC,m_Sections.size(),LinkAllowed);
Section = new CCodeSection(this, TargetPC, m_Sections.size(), LinkAllowed);
if (Section == NULL)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
@ -133,7 +133,7 @@ bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSe
m_Sections.push_back(Section);
if (LinkAllowed)
{
m_SectionMap.insert(SectionMap::value_type(TargetPC,Section));
m_SectionMap.insert(SectionMap::value_type(TargetPC, Section));
}
Section->AddParent(CurrentSection);
if (TargetPC <= CurrentPC && TargetPC != m_VAddrEnter)
@ -160,30 +160,30 @@ bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSe
CPU_Message("%s: Split Section: %d with section: %d", __FUNCTION__, SplitSection->m_SectionID, Section->m_SectionID);
CCodeSection * BaseSection = Section;
BaseSection->m_EndPC = SplitSection->m_EndPC;
BaseSection->SetJumpAddress(SplitSection->m_Jump.JumpPC, SplitSection->m_Jump.TargetPC,SplitSection->m_Jump.PermLoop);
BaseSection->SetJumpAddress(SplitSection->m_Jump.JumpPC, SplitSection->m_Jump.TargetPC, SplitSection->m_Jump.PermLoop);
BaseSection->m_JumpSection = SplitSection->m_JumpSection;
BaseSection->SetContinueAddress(SplitSection->m_Cont.JumpPC,SplitSection->m_Cont.TargetPC);
BaseSection->SetContinueAddress(SplitSection->m_Cont.JumpPC, SplitSection->m_Cont.TargetPC);
BaseSection->m_ContinueSection = SplitSection->m_ContinueSection;
BaseSection->m_JumpSection->SwitchParent(SplitSection,BaseSection);
BaseSection->m_ContinueSection->SwitchParent(SplitSection,BaseSection);
BaseSection->m_JumpSection->SwitchParent(SplitSection, BaseSection);
BaseSection->m_ContinueSection->SwitchParent(SplitSection, BaseSection);
BaseSection->AddParent(SplitSection);
SplitSection->m_EndPC = TargetPC - 4;
SplitSection->m_JumpSection = NULL;
SplitSection->m_ContinueSection = BaseSection;
SplitSection->SetContinueAddress(TargetPC - 4, TargetPC);
SplitSection->SetJumpAddress((uint32_t)-1,(uint32_t)-1,false);
SplitSection->SetJumpAddress((uint32_t)-1, (uint32_t)-1, false);
}
}
}
return true;
}
bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
bool CCodeBlock::CreateBlockLinkage(CCodeSection * EnterSection)
{
CCodeSection * CurrentSection = EnterSection;
CPU_Message("Section %d",CurrentSection->m_SectionID);
CPU_Message("Section %d", CurrentSection->m_SectionID);
for (uint32_t TestPC = EnterSection->m_EnterPC, EndPC = ((EnterSection->m_EnterPC + 0x1000) & 0xFFFFF000); TestPC <= EndPC; TestPC += 4)
{
if (TestPC != EndPC)
@ -198,13 +198,13 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
}
if (CurrentSection->m_ContinueSection == NULL)
{
SetSection(CurrentSection->m_ContinueSection, CurrentSection, TestPC,true,TestPC);
SetSection(CurrentSection->m_ContinueSection, CurrentSection, TestPC, true, TestPC);
CurrentSection->SetContinueAddress(TestPC - 4, TestPC);
}
CurrentSection->m_EndPC = TestPC - 4;
CurrentSection = itr->second;
CPU_Message("Section %d",CurrentSection->m_SectionID);
CPU_Message("Section %d", CurrentSection->m_SectionID);
if (EnterSection != m_EnterSection)
{
if (CurrentSection->m_JumpSection != NULL ||
@ -257,9 +257,9 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
if (ContinuePC != (uint32_t)-1)
{
CPU_Message("%s: SetContinueAddress TestPC = %X ContinuePC = %X", __FUNCTION__,TestPC,ContinuePC);
CPU_Message("%s: SetContinueAddress TestPC = %X ContinuePC = %X", __FUNCTION__, TestPC, ContinuePC);
CurrentSection->SetContinueAddress(TestPC, ContinuePC);
if (!SetSection(CurrentSection->m_ContinueSection, CurrentSection, ContinuePC,true,TestPC))
if (!SetSection(CurrentSection->m_ContinueSection, CurrentSection, ContinuePC, true, TestPC))
{
ContinuePC = (uint32_t)-1;
}
@ -267,9 +267,9 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
if (LikelyBranch)
{
CPU_Message("%s: SetJumpAddress TestPC = %X Target = %X", __FUNCTION__,TestPC,TestPC + 4);
CurrentSection->SetJumpAddress(TestPC, TestPC + 4,false);
if (SetSection(CurrentSection->m_JumpSection, CurrentSection, TestPC + 4,false,TestPC))
CPU_Message("%s: SetJumpAddress TestPC = %X Target = %X", __FUNCTION__, TestPC, TestPC + 4);
CurrentSection->SetJumpAddress(TestPC, TestPC + 4, false);
if (SetSection(CurrentSection->m_JumpSection, CurrentSection, TestPC + 4, false, TestPC))
{
bool BranchLikelyBranch, BranchEndBlock, BranchIncludeDelaySlot, BranchPermLoop;
uint32_t BranchTargetPC, BranchContinuePC;
@ -296,10 +296,10 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
}
else
{
JumpSection->SetJumpAddress(TestPC, TargetPC,false);
JumpSection->SetJumpAddress(TestPC, TargetPC, false);
}
JumpSection->SetDelaySlot();
SetSection(JumpSection->m_JumpSection,JumpSection,TargetPC,true,TestPC);
SetSection(JumpSection->m_JumpSection, JumpSection, TargetPC, true, TestPC);
}
else
{
@ -308,9 +308,9 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
}
else if (TargetPC != ((uint32_t)-1))
{
CPU_Message("%s: SetJumpAddress TestPC = %X Target = %X", __FUNCTION__,TestPC,TargetPC);
CurrentSection->SetJumpAddress(TestPC, TargetPC,PermLoop);
if (PermLoop || !SetSection(CurrentSection->m_JumpSection, CurrentSection, TargetPC,true,TestPC))
CPU_Message("%s: SetJumpAddress TestPC = %X Target = %X", __FUNCTION__, TestPC, TargetPC);
CurrentSection->SetJumpAddress(TestPC, TargetPC, PermLoop);
if (PermLoop || !SetSection(CurrentSection->m_JumpSection, CurrentSection, TargetPC, true, TestPC))
{
if (ContinuePC == (uint32_t)-1)
{
@ -350,7 +350,7 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
break;
}
TestPC = CurrentSection->m_EnterPC;
CPU_Message("a. Section %d",CurrentSection->m_SectionID);
CPU_Message("a. Section %d", CurrentSection->m_SectionID);
TestPC -= 4;
}
@ -383,7 +383,7 @@ void CCodeBlock::DetermineLoops()
CCodeSection * Section = itr->second;
uint32_t Test = NextTest();
Section->DetermineLoop(Test,Test,Section->m_SectionID);
Section->DetermineLoop(Test, Test, Section->m_SectionID);
}
}
@ -411,7 +411,7 @@ bool CCodeBlock::AnalyseBlock()
return true;
}
bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot, bool & EndBlock, bool & PermLoop )
bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot, bool & EndBlock, bool & PermLoop)
{
TargetPC = (uint32_t)-1;
ContinuePC = (uint32_t)-1;
@ -428,8 +428,8 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
}
#ifdef _DEBUG
const char * Name = R4300iOpcodeName(Command.Hex,PC);
CPU_Message(" 0x%08X %s",PC,Name);
const char * Name = R4300iOpcodeName(Command.Hex, PC);
CPU_Message(" 0x%08X %s", PC, Name);
#endif
switch (Command.op)
{
@ -477,7 +477,7 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
}
else
{
if (TargetPC == PC && !DelaySlotEffectsCompare(PC,Command.rs,0))
if (TargetPC == PC && !DelaySlotEffectsCompare(PC, Command.rs, 0))
{
PermLoop = true;
}
@ -503,7 +503,7 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
}
else
{
if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
if (!DelaySlotEffectsCompare(PC, Command.rs, Command.rt))
{
PermLoop = true;
}
@ -521,7 +521,7 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
if (TargetPC == PC)
{
if (!DelaySlotEffectsCompare(PC,Command.rs,0))
if (!DelaySlotEffectsCompare(PC, Command.rs, 0))
{
PermLoop = true;
}
@ -565,7 +565,7 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
ContinuePC = PC + 8;
}
if (TargetPC == PC && !DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
if (TargetPC == PC && !DelaySlotEffectsCompare(PC, Command.rs, Command.rt))
{
PermLoop = true;
}
@ -584,7 +584,7 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
{
if (TargetPC == PC)
{
if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
if (!DelaySlotEffectsCompare(PC, Command.rs, Command.rt))
{
PermLoop = true;
}
@ -599,9 +599,9 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
case R4300i_COP0_MT: case R4300i_COP0_MF:
break;
default:
if ( (Command.rs & 0x10 ) != 0 )
if ((Command.rs & 0x10) != 0)
{
switch ( Command.funct )
switch (Command.funct)
{
case R4300i_COP0_CO_TLBR: case R4300i_COP0_CO_TLBWI:
case R4300i_COP0_CO_TLBWR: case R4300i_COP0_CO_TLBP:
@ -682,7 +682,7 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
if (TargetPC == PC)
{
if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
if (!DelaySlotEffectsCompare(PC, Command.rs, Command.rt))
{
PermLoop = true;
}
@ -701,7 +701,7 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
ContinuePC = PC + 8;
if (TargetPC == PC)
{
if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
if (!DelaySlotEffectsCompare(PC, Command.rs, Command.rt))
{
PermLoop = true;
}
@ -725,9 +725,9 @@ bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t
bool CCodeBlock::Compile()
{
CPU_Message("====== Code Block ======");
CPU_Message("x86 code at: %X",CompiledLocation());
CPU_Message("Start of Block: %X",VAddrEnter() );
CPU_Message("No of Sections: %d",NoOfSections() );
CPU_Message("x86 code at: %X", CompiledLocation());
CPU_Message("Start of Block: %X", VAddrEnter());
CPU_Message("No of Sections: %d", NoOfSections());
CPU_Message("====== recompiled code ======");
m_RecompilerOps->EnterCodeBlock();
@ -745,8 +745,8 @@ bool CCodeBlock::Compile()
m_RecompilerOps->CompileExitCode();
uint32_t PAddr;
g_TransVaddr->TranslateVaddr(VAddrFirst(),PAddr);
MD5(g_MMU->Rdram() + PAddr,(VAddrLast() - VAddrFirst()) + 4).get_digest(m_Hash);
g_TransVaddr->TranslateVaddr(VAddrFirst(), PAddr);
MD5(g_MMU->Rdram() + PAddr, (VAddrLast() - VAddrFirst()) + 4).get_digest(m_Hash);
return true;
}
@ -756,4 +756,4 @@ uint32_t CCodeBlock::NextTest()
uint32_t next_test = m_Test;
m_Test += 1;
return next_test;
}
}

View File

@ -10,7 +10,7 @@
****************************************************************************/
#pragma once
#include <Common/md5.h>
#include <Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h>
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
#include <Project64-core/N64System/Recompiler/CodeSection.h>
class CCodeBlock

View File

@ -10,7 +10,7 @@
****************************************************************************/
#pragma once
#include "JumpInfo.h"
#include <Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h>
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
class CCodeBlock;

View File

@ -0,0 +1,225 @@
/****************************************************************************
* *
* 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
#include <Project64-core/N64System/Recompiler/RegInfo.h>
#include <Project64-core/N64System/Recompiler/JumpInfo.h>
#include <Project64-core/N64System/Mips/OpCode.h>
class CCodeSection;
class CRecompilerOps
{
public:
enum BRANCH_TYPE
{
BranchTypeCop1,
BranchTypeRs,
BranchTypeRsRt
};
enum BRANCH_COMPARE
{
CompareTypeBEQ,
CompareTypeBNE,
CompareTypeBLTZ,
CompareTypeBLEZ,
CompareTypeBGTZ,
CompareTypeBGEZ,
CompareTypeCOP1BCF,
CompareTypeCOP1BCT,
};
/************************** Branch functions ************************/
virtual void Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE BranchType, bool Link) = 0;
virtual void Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link) = 0;
/************************* OpCode functions *************************/
virtual void J() = 0;
virtual void JAL() = 0;
virtual void ADDI() = 0;
virtual void ADDIU() = 0;
virtual void SLTI() = 0;
virtual void SLTIU() = 0;
virtual void ANDI() = 0;
virtual void ORI() = 0;
virtual void XORI() = 0;
virtual void LUI() = 0;
virtual void DADDIU() = 0;
virtual void LDL() = 0;
virtual void LDR() = 0;
virtual void LB() = 0;
virtual void LH() = 0;
virtual void LWL() = 0;
virtual void LW() = 0;
virtual void LBU() = 0;
virtual void LHU() = 0;
virtual void LWR() = 0;
virtual void LWU() = 0;
virtual void SB() = 0;
virtual void SH() = 0;
virtual void SWL() = 0;
virtual void SW() = 0;
virtual void SWR() = 0;
virtual void SDL() = 0;
virtual void SDR() = 0;
virtual void CACHE() = 0;
virtual void LL() = 0;
virtual void LWC1() = 0;
virtual void LDC1() = 0;
virtual void LD() = 0;
virtual void SC() = 0;
virtual void SWC1() = 0;
virtual void SDC1() = 0;
virtual void SD() = 0;
/********************** R4300i OpCodes: Special **********************/
virtual void SPECIAL_SLL() = 0;
virtual void SPECIAL_SRL() = 0;
virtual void SPECIAL_SRA() = 0;
virtual void SPECIAL_SLLV() = 0;
virtual void SPECIAL_SRLV() = 0;
virtual void SPECIAL_SRAV() = 0;
virtual void SPECIAL_JR() = 0;
virtual void SPECIAL_JALR() = 0;
virtual void SPECIAL_SYSCALL() = 0;
virtual void SPECIAL_MFLO() = 0;
virtual void SPECIAL_MTLO() = 0;
virtual void SPECIAL_MFHI() = 0;
virtual void SPECIAL_MTHI() = 0;
virtual void SPECIAL_DSLLV() = 0;
virtual void SPECIAL_DSRLV() = 0;
virtual void SPECIAL_DSRAV() = 0;
virtual void SPECIAL_MULT() = 0;
virtual void SPECIAL_MULTU() = 0;
virtual void SPECIAL_DIV() = 0;
virtual void SPECIAL_DIVU() = 0;
virtual void SPECIAL_DMULT() = 0;
virtual void SPECIAL_DMULTU() = 0;
virtual void SPECIAL_DDIV() = 0;
virtual void SPECIAL_DDIVU() = 0;
virtual void SPECIAL_ADD() = 0;
virtual void SPECIAL_ADDU() = 0;
virtual void SPECIAL_SUB() = 0;
virtual void SPECIAL_SUBU() = 0;
virtual void SPECIAL_AND() = 0;
virtual void SPECIAL_OR() = 0;
virtual void SPECIAL_XOR() = 0;
virtual void SPECIAL_NOR() = 0;
virtual void SPECIAL_SLT() = 0;
virtual void SPECIAL_SLTU() = 0;
virtual void SPECIAL_DADD() = 0;
virtual void SPECIAL_DADDU() = 0;
virtual void SPECIAL_DSUB() = 0;
virtual void SPECIAL_DSUBU() = 0;
virtual void SPECIAL_DSLL() = 0;
virtual void SPECIAL_DSRL() = 0;
virtual void SPECIAL_DSRA() = 0;
virtual void SPECIAL_DSLL32() = 0;
virtual void SPECIAL_DSRL32() = 0;
virtual void SPECIAL_DSRA32() = 0;
/************************** COP0 functions **************************/
virtual void COP0_MF() = 0;
virtual void COP0_MT() = 0;
/************************** COP0 CO functions ***********************/
virtual void COP0_CO_TLBR() = 0;
virtual void COP0_CO_TLBWI() = 0;
virtual void COP0_CO_TLBWR() = 0;
virtual void COP0_CO_TLBP() = 0;
virtual void COP0_CO_ERET() = 0;
/************************** COP1 functions **************************/
virtual void COP1_MF() = 0;
virtual void COP1_DMF() = 0;
virtual void COP1_CF() = 0;
virtual void COP1_MT() = 0;
virtual void COP1_DMT() = 0;
virtual void COP1_CT() = 0;
/************************** COP1: S functions ************************/
virtual void COP1_S_ADD() = 0;
virtual void COP1_S_SUB() = 0;
virtual void COP1_S_MUL() = 0;
virtual void COP1_S_DIV() = 0;
virtual void COP1_S_ABS() = 0;
virtual void COP1_S_NEG() = 0;
virtual void COP1_S_SQRT() = 0;
virtual void COP1_S_MOV() = 0;
virtual void COP1_S_ROUND_L() = 0;
virtual void COP1_S_TRUNC_L() = 0;
virtual void COP1_S_CEIL_L() = 0;
virtual void COP1_S_FLOOR_L() = 0;
virtual void COP1_S_ROUND_W() = 0;
virtual void COP1_S_TRUNC_W() = 0;
virtual void COP1_S_CEIL_W() = 0;
virtual void COP1_S_FLOOR_W() = 0;
virtual void COP1_S_CVT_D() = 0;
virtual void COP1_S_CVT_W() = 0;
virtual void COP1_S_CVT_L() = 0;
virtual void COP1_S_CMP() = 0;
/************************** COP1: D functions ************************/
virtual void COP1_D_ADD() = 0;
virtual void COP1_D_SUB() = 0;
virtual void COP1_D_MUL() = 0;
virtual void COP1_D_DIV() = 0;
virtual void COP1_D_ABS() = 0;
virtual void COP1_D_NEG() = 0;
virtual void COP1_D_SQRT() = 0;
virtual void COP1_D_MOV() = 0;
virtual void COP1_D_ROUND_L() = 0;
virtual void COP1_D_TRUNC_L() = 0;
virtual void COP1_D_CEIL_L() = 0;
virtual void COP1_D_FLOOR_L() = 0;
virtual void COP1_D_ROUND_W() = 0;
virtual void COP1_D_TRUNC_W() = 0;
virtual void COP1_D_CEIL_W() = 0;
virtual void COP1_D_FLOOR_W() = 0;
virtual void COP1_D_CVT_S() = 0;
virtual void COP1_D_CVT_W() = 0;
virtual void COP1_D_CVT_L() = 0;
virtual void COP1_D_CMP() = 0;
/************************** COP1: W functions ************************/
virtual void COP1_W_CVT_S() = 0;
virtual void COP1_W_CVT_D() = 0;
/************************** COP1: L functions ************************/
virtual void COP1_L_CVT_S() = 0;
virtual void COP1_L_CVT_D() = 0;
/************************** Other functions **************************/
virtual void UnknownOpcode() = 0;
virtual void EnterCodeBlock() = 0;
virtual void ExitCodeBlock() = 0;
virtual void CompileExitCode() = 0;
virtual void CompileCop1Test() = 0;
virtual void CompileInPermLoop(CRegInfo & RegSet, uint32_t ProgramCounter) = 0;
virtual void SyncRegState(const CRegInfo & SyncTo) = 0;
virtual void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow) = 0;
virtual void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet) = 0;
virtual CRegInfo & GetRegWorkingSet(void) = 0;
virtual void SetRegWorkingSet(const CRegInfo & RegInfo) = 0;
virtual bool InheritParentInfo() = 0;
virtual void LinkJump(CJumpInfo & JumpInfo, uint32_t SectionID = -1, uint32_t FromSectionID = -1) = 0;
virtual void JumpToSection(CCodeSection * Section) = 0;
virtual void JumpToUnknown(CJumpInfo * JumpInfo) = 0;
virtual void SetCurrentPC(uint32_t ProgramCounter) = 0;
virtual uint32_t GetCurrentPC(void) = 0;
virtual void SetCurrentSection(CCodeSection * section) = 0;
virtual void SetNextStepType(STEP_TYPE StepType) = 0;
virtual STEP_TYPE GetNextStepType(void) = 0;
virtual const OPCODE & GetOpcode(void) const = 0;
virtual void PreCompileOpcode(void) = 0;
virtual void PostCompileOpcode(void) = 0;
virtual void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false) = 0;
};

View File

@ -14,6 +14,7 @@
#include <Project64-core/N64System/Mips/OpCode.h>
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
#include <Project64-core/N64System/Recompiler/RegInfo.h>
#include <Project64-core/N64System/Recompiler/RecompilerOps.h>
#include <Project64-core/N64System/Recompiler/x86/x86ops.h>
#include <Project64-core/N64System/Recompiler/JumpInfo.h>
#include <Project64-core/Settings/DebugSettings.h>
@ -23,7 +24,8 @@
class CCodeBlock;
class CCodeSection;
class CRecompilerOps :
class CX86RecompilerOps :
public CRecompilerOps,
protected CDebugSettings,
protected CX86Ops,
protected CSystemRegisters,
@ -31,24 +33,6 @@ class CRecompilerOps :
protected CRecompilerSettings
{
public:
enum BRANCH_TYPE
{
BranchTypeCop1,
BranchTypeRs,
BranchTypeRsRt
};
enum BRANCH_COMPARE
{
CompareTypeBEQ,
CompareTypeBNE,
CompareTypeBLTZ,
CompareTypeBLEZ,
CompareTypeBGTZ,
CompareTypeBGEZ,
CompareTypeCOP1BCF,
CompareTypeCOP1BCT,
};
/************************** Branch functions ************************/
void Compile_BranchCompare(BRANCH_COMPARE CompareType);
void Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE BranchType, bool Link);
@ -63,166 +47,166 @@ public:
void COP1_BCT_Compare();
/************************* OpCode functions *************************/
void J ();
void JAL ();
void ADDI ();
void ADDIU ();
void SLTI ();
void SLTIU ();
void ANDI ();
void ORI ();
void XORI ();
void LUI ();
void DADDIU ();
void LDL ();
void LDR ();
void LB ();
void LH ();
void LWL ();
void LW ();
void LBU ();
void LHU ();
void LWR ();
void LWU ();
void SB ();
void SH ();
void SWL ();
void SW ();
void SWR ();
void SDL ();
void SDR ();
void CACHE ();
void LL ();
void LWC1 ();
void LDC1 ();
void LD ();
void SC ();
void SWC1 ();
void SDC1 ();
void SD ();
void J();
void JAL();
void ADDI();
void ADDIU();
void SLTI();
void SLTIU();
void ANDI();
void ORI();
void XORI();
void LUI();
void DADDIU();
void LDL();
void LDR();
void LB();
void LH();
void LWL();
void LW();
void LBU();
void LHU();
void LWR();
void LWU();
void SB();
void SH();
void SWL();
void SW();
void SWR();
void SDL();
void SDR();
void CACHE();
void LL();
void LWC1();
void LDC1();
void LD();
void SC();
void SWC1();
void SDC1();
void SD();
/********************** R4300i OpCodes: Special **********************/
void SPECIAL_SLL ();
void SPECIAL_SRL ();
void SPECIAL_SRA ();
void SPECIAL_SLLV ();
void SPECIAL_SRLV ();
void SPECIAL_SRAV ();
void SPECIAL_JR ();
void SPECIAL_JALR ();
void SPECIAL_SLL();
void SPECIAL_SRL();
void SPECIAL_SRA();
void SPECIAL_SLLV();
void SPECIAL_SRLV();
void SPECIAL_SRAV();
void SPECIAL_JR();
void SPECIAL_JALR();
void SPECIAL_SYSCALL();
void SPECIAL_MFLO ();
void SPECIAL_MTLO ();
void SPECIAL_MFHI ();
void SPECIAL_MTHI ();
void SPECIAL_DSLLV ();
void SPECIAL_DSRLV ();
void SPECIAL_DSRAV ();
void SPECIAL_MULT ();
void SPECIAL_MULTU ();
void SPECIAL_DIV ();
void SPECIAL_DIVU ();
void SPECIAL_DMULT ();
void SPECIAL_DMULTU ();
void SPECIAL_DDIV ();
void SPECIAL_DDIVU ();
void SPECIAL_ADD ();
void SPECIAL_ADDU ();
void SPECIAL_SUB ();
void SPECIAL_SUBU ();
void SPECIAL_AND ();
void SPECIAL_OR ();
void SPECIAL_XOR ();
void SPECIAL_NOR ();
void SPECIAL_SLT ();
void SPECIAL_SLTU ();
void SPECIAL_DADD ();
void SPECIAL_DADDU ();
void SPECIAL_DSUB ();
void SPECIAL_DSUBU ();
void SPECIAL_DSLL ();
void SPECIAL_DSRL ();
void SPECIAL_DSRA ();
void SPECIAL_DSLL32 ();
void SPECIAL_DSRL32 ();
void SPECIAL_DSRA32 ();
void SPECIAL_MFLO();
void SPECIAL_MTLO();
void SPECIAL_MFHI();
void SPECIAL_MTHI();
void SPECIAL_DSLLV();
void SPECIAL_DSRLV();
void SPECIAL_DSRAV();
void SPECIAL_MULT();
void SPECIAL_MULTU();
void SPECIAL_DIV();
void SPECIAL_DIVU();
void SPECIAL_DMULT();
void SPECIAL_DMULTU();
void SPECIAL_DDIV();
void SPECIAL_DDIVU();
void SPECIAL_ADD();
void SPECIAL_ADDU();
void SPECIAL_SUB();
void SPECIAL_SUBU();
void SPECIAL_AND();
void SPECIAL_OR();
void SPECIAL_XOR();
void SPECIAL_NOR();
void SPECIAL_SLT();
void SPECIAL_SLTU();
void SPECIAL_DADD();
void SPECIAL_DADDU();
void SPECIAL_DSUB();
void SPECIAL_DSUBU();
void SPECIAL_DSLL();
void SPECIAL_DSRL();
void SPECIAL_DSRA();
void SPECIAL_DSLL32();
void SPECIAL_DSRL32();
void SPECIAL_DSRA32();
/************************** COP0 functions **************************/
void COP0_MF ();
void COP0_MT ();
void COP0_MF();
void COP0_MT();
/************************** COP0 CO functions ***********************/
void COP0_CO_TLBR ();
void COP0_CO_TLBWI ();
void COP0_CO_TLBWR ();
void COP0_CO_TLBP ();
void COP0_CO_ERET ();
void COP0_CO_TLBR();
void COP0_CO_TLBWI();
void COP0_CO_TLBWR();
void COP0_CO_TLBP();
void COP0_CO_ERET();
/************************** COP1 functions **************************/
void COP1_MF ();
void COP1_DMF ();
void COP1_CF ();
void COP1_MT ();
void COP1_DMT ();
void COP1_CT ();
void COP1_MF();
void COP1_DMF();
void COP1_CF();
void COP1_MT();
void COP1_DMT();
void COP1_CT();
/************************** COP1: S functions ************************/
void COP1_S_ADD ();
void COP1_S_SUB ();
void COP1_S_MUL ();
void COP1_S_DIV ();
void COP1_S_ABS ();
void COP1_S_NEG ();
void COP1_S_SQRT ();
void COP1_S_MOV ();
void COP1_S_ROUND_L ();
void COP1_S_TRUNC_L ();
void COP1_S_CEIL_L ();
void COP1_S_FLOOR_L ();
void COP1_S_ROUND_W ();
void COP1_S_TRUNC_W ();
void COP1_S_CEIL_W ();
void COP1_S_FLOOR_W ();
void COP1_S_CVT_D ();
void COP1_S_CVT_W ();
void COP1_S_CVT_L ();
void COP1_S_CMP ();
void COP1_S_ADD();
void COP1_S_SUB();
void COP1_S_MUL();
void COP1_S_DIV();
void COP1_S_ABS();
void COP1_S_NEG();
void COP1_S_SQRT();
void COP1_S_MOV();
void COP1_S_ROUND_L();
void COP1_S_TRUNC_L();
void COP1_S_CEIL_L();
void COP1_S_FLOOR_L();
void COP1_S_ROUND_W();
void COP1_S_TRUNC_W();
void COP1_S_CEIL_W();
void COP1_S_FLOOR_W();
void COP1_S_CVT_D();
void COP1_S_CVT_W();
void COP1_S_CVT_L();
void COP1_S_CMP();
/************************** COP1: D functions ************************/
void COP1_D_ADD ();
void COP1_D_SUB ();
void COP1_D_MUL ();
void COP1_D_DIV ();
void COP1_D_ABS ();
void COP1_D_NEG ();
void COP1_D_SQRT ();
void COP1_D_MOV ();
void COP1_D_ROUND_L ();
void COP1_D_TRUNC_L ();
void COP1_D_CEIL_L ();
void COP1_D_FLOOR_L ();
void COP1_D_ROUND_W ();
void COP1_D_TRUNC_W ();
void COP1_D_CEIL_W ();
void COP1_D_FLOOR_W ();
void COP1_D_CVT_S ();
void COP1_D_CVT_W ();
void COP1_D_CVT_L ();
void COP1_D_CMP ();
void COP1_D_ADD();
void COP1_D_SUB();
void COP1_D_MUL();
void COP1_D_DIV();
void COP1_D_ABS();
void COP1_D_NEG();
void COP1_D_SQRT();
void COP1_D_MOV();
void COP1_D_ROUND_L();
void COP1_D_TRUNC_L();
void COP1_D_CEIL_L();
void COP1_D_FLOOR_L();
void COP1_D_ROUND_W();
void COP1_D_TRUNC_W();
void COP1_D_CEIL_W();
void COP1_D_FLOOR_W();
void COP1_D_CVT_S();
void COP1_D_CVT_W();
void COP1_D_CVT_L();
void COP1_D_CMP();
/************************** COP1: W functions ************************/
void COP1_W_CVT_S ();
void COP1_W_CVT_D ();
void COP1_W_CVT_S();
void COP1_W_CVT_D();
/************************** COP1: L functions ************************/
void COP1_L_CVT_S ();
void COP1_L_CVT_D ();
void COP1_L_CVT_S();
void COP1_L_CVT_D();
/************************** Other functions **************************/
void UnknownOpcode ();
void UnknownOpcode();
static void EnterCodeBlock();
static void ExitCodeBlock();
void EnterCodeBlock();
void ExitCodeBlock();
void CompileExitCode();
void CompileCop1Test();
void CompileInPermLoop(CRegInfo & RegSet, uint32_t ProgramCounter);
@ -240,63 +224,62 @@ public:
uint32_t GetCurrentPC(void);
void SetCurrentSection(CCodeSection * section);
void SetNextStepType(STEP_TYPE StepType);
STEP_TYPE GetNextStepType( void );
const OPCODE & GetOpcode ( void ) const;
STEP_TYPE GetNextStepType(void);
const OPCODE & GetOpcode(void) const;
void PreCompileOpcode(void);
void PostCompileOpcode ( void );
void PostCompileOpcode(void);
void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow);
void CompileReadTLBMiss(uint32_t VirtualAddress, x86Reg LookUpReg);
void CompileReadTLBMiss(x86Reg AddressReg, x86Reg LookUpReg);
void CompileWriteTLBMiss(x86Reg AddressReg, x86Reg LookUpReg);
static void UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles);
static void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false);
static void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet);
void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false);
void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet);
static void ChangeDefaultRoundingModel();
static void OverflowDelaySlot(bool TestTimer);
void OverflowDelaySlot(bool TestTimer);
/********* Helper Functions *********/
typedef CRegInfo::REG_STATE REG_STATE;
static REG_STATE GetMipsRegState ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegState(Reg); }
static uint64_t GetMipsReg ( int32_t Reg ) { return m_RegWorkingSet.GetMipsReg(Reg); }
static int64_t GetMipsReg_S ( int32_t Reg ) { return m_RegWorkingSet.GetMipsReg_S(Reg); }
static uint32_t GetMipsRegLo ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegLo(Reg); }
static int32_t GetMipsRegLo_S ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); }
static uint32_t GetMipsRegHi ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegHi(Reg); }
static int32_t GetMipsRegHi_S ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); }
static CX86Ops::x86Reg GetMipsRegMapLo ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); }
static CX86Ops::x86Reg GetMipsRegMapHi ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); }
static REG_STATE GetMipsRegState(int32_t Reg) { return m_RegWorkingSet.GetMipsRegState(Reg); }
static uint64_t GetMipsReg(int32_t Reg) { return m_RegWorkingSet.GetMipsReg(Reg); }
static int64_t GetMipsReg_S(int32_t Reg) { return m_RegWorkingSet.GetMipsReg_S(Reg); }
static uint32_t GetMipsRegLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo(Reg); }
static int32_t GetMipsRegLo_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); }
static uint32_t GetMipsRegHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi(Reg); }
static int32_t GetMipsRegHi_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); }
static CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); }
static CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); }
static bool IsKnown ( int32_t Reg ) { return m_RegWorkingSet.IsKnown(Reg); }
static bool IsUnknown ( int32_t Reg ) { return m_RegWorkingSet.IsUnknown(Reg); }
static bool IsMapped ( int32_t Reg ) { return m_RegWorkingSet.IsMapped(Reg); }
static bool IsConst ( int32_t Reg ) { return m_RegWorkingSet.IsConst(Reg); }
static bool IsSigned ( int32_t Reg ) { return m_RegWorkingSet.IsSigned(Reg); }
static bool IsUnsigned ( int32_t Reg ) { return m_RegWorkingSet.IsUnsigned(Reg); }
static bool Is32Bit ( int32_t Reg ) { return m_RegWorkingSet.Is32Bit(Reg); }
static bool Is64Bit ( int32_t Reg ) { return m_RegWorkingSet.Is64Bit(Reg); }
static bool Is32BitMapped ( int32_t Reg ) { return m_RegWorkingSet.Is32BitMapped(Reg); }
static bool Is64BitMapped ( int32_t Reg ) { return m_RegWorkingSet.Is64BitMapped(Reg); }
static bool IsKnown(int32_t Reg) { return m_RegWorkingSet.IsKnown(Reg); }
static bool IsUnknown(int32_t Reg) { return m_RegWorkingSet.IsUnknown(Reg); }
static bool IsMapped(int32_t Reg) { return m_RegWorkingSet.IsMapped(Reg); }
static bool IsConst(int32_t Reg) { return m_RegWorkingSet.IsConst(Reg); }
static bool IsSigned(int32_t Reg) { return m_RegWorkingSet.IsSigned(Reg); }
static bool IsUnsigned(int32_t Reg) { return m_RegWorkingSet.IsUnsigned(Reg); }
static bool Is32Bit(int32_t Reg) { return m_RegWorkingSet.Is32Bit(Reg); }
static bool Is64Bit(int32_t Reg) { return m_RegWorkingSet.Is64Bit(Reg); }
static bool Is32BitMapped(int32_t Reg) { return m_RegWorkingSet.Is32BitMapped(Reg); }
static bool Is64BitMapped(int32_t Reg) { return m_RegWorkingSet.Is64BitMapped(Reg); }
static void FixRoundModel ( CRegInfo::FPU_ROUND RoundMethod )
static void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod)
{
m_RegWorkingSet.FixRoundModel(RoundMethod);
}
static void ChangeFPURegFormat ( int32_t Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel )
static void ChangeFPURegFormat(int32_t Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel)
{
m_RegWorkingSet.ChangeFPURegFormat(Reg,OldFormat,NewFormat,RoundingModel);
m_RegWorkingSet.ChangeFPURegFormat(Reg, OldFormat, NewFormat, RoundingModel);
}
static void Load_FPR_ToTop ( int32_t Reg, int32_t RegToLoad, CRegInfo::FPU_STATE Format)
static void Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, CRegInfo::FPU_STATE Format)
{
m_RegWorkingSet.Load_FPR_ToTop(Reg,RegToLoad,Format);
m_RegWorkingSet.Load_FPR_ToTop(Reg, RegToLoad, Format);
}
static bool RegInStack ( int32_t Reg, CRegInfo::FPU_STATE Format )
static bool RegInStack(int32_t Reg, CRegInfo::FPU_STATE Format)
{
return m_RegWorkingSet.RegInStack(Reg,Format);
return m_RegWorkingSet.RegInStack(Reg, Format);
}
static x86FpuValues StackPosition ( int32_t Reg )
static x86FpuValues StackPosition(int32_t Reg)
{
return m_RegWorkingSet.StackPosition(Reg);
}
@ -304,9 +287,9 @@ public:
{
m_RegWorkingSet.UnMap_AllFPRs();
}
static void UnMap_FPR ( uint32_t Reg, bool WriteBackValue )
static void UnMap_FPR(uint32_t Reg, bool WriteBackValue)
{
m_RegWorkingSet.UnMap_FPR(Reg,WriteBackValue);
m_RegWorkingSet.UnMap_FPR(Reg, WriteBackValue);
}
static x86Reg FreeX86Reg()
@ -317,31 +300,31 @@ public:
{
return m_RegWorkingSet.Free8BitX86Reg();
}
static void Map_GPR_32bit ( int32_t Reg, bool SignValue, int32_t MipsRegToLoad )
static void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad)
{
m_RegWorkingSet.Map_GPR_32bit(Reg,SignValue,MipsRegToLoad);
m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad);
}
static void Map_GPR_64bit ( int32_t Reg, int32_t MipsRegToLoad )
static void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad)
{
m_RegWorkingSet.Map_GPR_64bit(Reg,MipsRegToLoad);
m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad);
}
static x86Reg Get_MemoryStack()
{
return m_RegWorkingSet.Get_MemoryStack();
}
static x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true )
static x86Reg Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool LoadValue = true)
{
return m_RegWorkingSet.Map_MemoryStack(Reg,bMapRegister,LoadValue);
return m_RegWorkingSet.Map_MemoryStack(Reg, bMapRegister, LoadValue);
}
static x86Reg Map_TempReg ( x86Reg Reg, int32_t MipsReg, bool LoadHiWord )
static x86Reg Map_TempReg(x86Reg Reg, int32_t MipsReg, bool LoadHiWord)
{
return m_RegWorkingSet.Map_TempReg(Reg,MipsReg,LoadHiWord);
return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord);
}
static void ProtectGPR ( uint32_t Reg )
static void ProtectGPR(uint32_t Reg)
{
m_RegWorkingSet.ProtectGPR(Reg);
}
static void UnProtectGPR ( uint32_t Reg )
static void UnProtectGPR(uint32_t Reg)
{
m_RegWorkingSet.UnProtectGPR(Reg);
}
@ -353,11 +336,11 @@ public:
{
return m_RegWorkingSet.UnMap_TempReg();
}
static void UnMap_GPR ( uint32_t Reg, bool WriteBackValue )
static void UnMap_GPR(uint32_t Reg, bool WriteBackValue)
{
m_RegWorkingSet.UnMap_GPR(Reg,WriteBackValue);
m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue);
}
static bool UnMap_X86reg ( x86Reg Reg )
static bool UnMap_X86reg(x86Reg Reg)
{
return m_RegWorkingSet.UnMap_X86reg(Reg);
}