[project64] Make RecompPos a global
This commit is contained in:
parent
2e0cc5d5bc
commit
519ac09711
|
@ -1462,14 +1462,14 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr)
|
|||
{
|
||||
CompConstToVariable(Value, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG");
|
||||
JeLabel8("Continue", 0);
|
||||
Jump = m_RecompPos - 1;
|
||||
Jump = *g_RecompPos - 1;
|
||||
MoveConstToVariable(Value, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG");
|
||||
BeforeCallDirect(m_RegWorkingSet);
|
||||
Call_Direct((void *)g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged");
|
||||
AfterCallDirect(m_RegWorkingSet);
|
||||
CPU_Message("");
|
||||
CPU_Message(" Continue:");
|
||||
SetJump8(Jump, m_RecompPos);
|
||||
SetJump8(Jump, *g_RecompPos);
|
||||
}
|
||||
break;
|
||||
case 0x04400004: MoveConstToVariable((Value & 0xFFFFFF), &g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG"); break;
|
||||
|
@ -1478,14 +1478,14 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr)
|
|||
{
|
||||
CompConstToVariable(Value, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG");
|
||||
JeLabel8("Continue", 0);
|
||||
Jump = m_RecompPos - 1;
|
||||
Jump = *g_RecompPos - 1;
|
||||
MoveConstToVariable(Value, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG");
|
||||
BeforeCallDirect(m_RegWorkingSet);
|
||||
Call_Direct((void *)g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged");
|
||||
AfterCallDirect(m_RegWorkingSet);
|
||||
CPU_Message("");
|
||||
CPU_Message(" Continue:");
|
||||
SetJump8(Jump, m_RecompPos);
|
||||
SetJump8(Jump, *g_RecompPos);
|
||||
}
|
||||
break;
|
||||
case 0x0440000C: MoveConstToVariable(Value, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break;
|
||||
|
@ -1821,14 +1821,14 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr)
|
|||
{
|
||||
CompX86regToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG");
|
||||
JeLabel8("Continue", 0);
|
||||
Jump = m_RecompPos - 1;
|
||||
Jump = *g_RecompPos - 1;
|
||||
MoveX86regToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG");
|
||||
BeforeCallDirect(m_RegWorkingSet);
|
||||
Call_Direct((void *)g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged");
|
||||
AfterCallDirect(m_RegWorkingSet);
|
||||
CPU_Message("");
|
||||
CPU_Message(" Continue:");
|
||||
SetJump8(Jump, m_RecompPos);
|
||||
SetJump8(Jump, *g_RecompPos);
|
||||
}
|
||||
break;
|
||||
case 0x04400004:
|
||||
|
@ -1840,14 +1840,14 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr)
|
|||
{
|
||||
CompX86regToVariable(Reg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG");
|
||||
JeLabel8("Continue", 0);
|
||||
Jump = m_RecompPos - 1;
|
||||
Jump = *g_RecompPos - 1;
|
||||
MoveX86regToVariable(Reg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG");
|
||||
BeforeCallDirect(m_RegWorkingSet);
|
||||
Call_Direct((void *)g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged");
|
||||
AfterCallDirect(m_RegWorkingSet);
|
||||
CPU_Message("");
|
||||
CPU_Message(" Continue:");
|
||||
SetJump8(Jump, m_RecompPos);
|
||||
SetJump8(Jump, *g_RecompPos);
|
||||
}
|
||||
break;
|
||||
case 0x0440000C: MoveX86regToVariable(Reg, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break;
|
||||
|
@ -3701,7 +3701,7 @@ void CMipsMemoryVM::Compile_SW(bool bCheckLLbit)
|
|||
{
|
||||
CompConstToVariable(1, _LLBit, "_LLBit");
|
||||
JneLabel8("LLBit_Continue", 0);
|
||||
Jump = m_RecompPos - 1;
|
||||
Jump = *g_RecompPos - 1;
|
||||
}
|
||||
if (IsConst(Opcode.rt))
|
||||
{
|
||||
|
@ -3719,7 +3719,7 @@ void CMipsMemoryVM::Compile_SW(bool bCheckLLbit)
|
|||
{
|
||||
CPU_Message(" ");
|
||||
CPU_Message(" LLBit_Continue:");
|
||||
SetJump8(Jump, m_RecompPos);
|
||||
SetJump8(Jump, *g_RecompPos);
|
||||
Map_GPR_32bit(Opcode.rt, false, -1);
|
||||
MoveVariableToX86reg(_LLBit, "_LLBit", GetMipsRegMapLo(Opcode.rt));
|
||||
}
|
||||
|
@ -4056,18 +4056,18 @@ void CMipsMemoryVM::Compile_StoreInstructClean(x86Reg AddressReg, int32_t Length
|
|||
Call_Direct(AddressOf(&CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt");
|
||||
AfterCallDirect(m_RegWorkingSet);
|
||||
/*JmpLabel8("MemCheckDone",0);
|
||||
uint8_t * MemCheckDone = m_RecompPos - 1;
|
||||
uint8_t * MemCheckDone = *g_RecompPos - 1;
|
||||
|
||||
CPU_Message(" ");
|
||||
CPU_Message(" NotDelaySlot:");
|
||||
SetJump8(NotDelaySlotJump,m_RecompPos);
|
||||
SetJump8(NotDelaySlotJump,*g_RecompPos);
|
||||
|
||||
MoveX86RegToX86Reg(AddressReg, StoreTemp1);
|
||||
ShiftRightUnsignImmed(StoreTemp1,12);
|
||||
LeaRegReg(StoreTemp1,StoreTemp1,(uint32_t)&(g_Recompiler->FunctionTable()[0]),Multip_x4);
|
||||
CompConstToX86regPointer(StoreTemp1,0);
|
||||
JeLabel8("MemCheckDone",0);
|
||||
uint8_t * MemCheckDone2 = m_RecompPos - 1;
|
||||
uint8_t * MemCheckDone2 = *g_RecompPos - 1;
|
||||
|
||||
BeforeCallDirect(m_RegWorkingSet);
|
||||
PushImm32("CRecompiler::Remove_StoreInstruc",CRecompiler::Remove_StoreInstruc);
|
||||
|
@ -4079,8 +4079,8 @@ void CMipsMemoryVM::Compile_StoreInstructClean(x86Reg AddressReg, int32_t Length
|
|||
|
||||
CPU_Message(" ");
|
||||
CPU_Message(" MemCheckDone:");
|
||||
SetJump8(MemCheckDone,m_RecompPos);
|
||||
SetJump8(MemCheckDone2,m_RecompPos);
|
||||
SetJump8(MemCheckDone,*g_RecompPos);
|
||||
SetJump8(MemCheckDone2,*g_RecompPos);
|
||||
|
||||
X86Protected(StoreTemp1) = false;*/
|
||||
}
|
||||
|
|
|
@ -683,6 +683,7 @@ bool CN64System::SetActiveSystem(bool bActive)
|
|||
g_Plugins = m_Plugins;
|
||||
g_TLBLoadAddress = &m_TLBLoadAddress;
|
||||
g_TLBStoreAddress = &m_TLBStoreAddress;
|
||||
g_RecompPos = m_Recomp ? m_Recomp->RecompPos() : NULL;
|
||||
R4300iOp::m_TestTimer = m_TestTimer;
|
||||
R4300iOp::m_NextInstruction = m_NextInstruction;
|
||||
R4300iOp::m_JumpToLocation = m_JumpToLocation;
|
||||
|
|
|
@ -33,6 +33,7 @@ CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * CompiledLocation) :
|
|||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
m_Sections.push_back(baseSection);
|
||||
baseSection->AddParent(NULL);
|
||||
baseSection->m_CompiledLocation = (uint8_t *)-1;
|
||||
|
@ -714,17 +715,7 @@ bool CCodeBlock::Compile()
|
|||
CPU_Message("No of Sections: %d",NoOfSections() );
|
||||
CPU_Message("====== recompiled code ======");
|
||||
|
||||
EnterCodeBlock();
|
||||
|
||||
if (g_SyncSystem)
|
||||
{
|
||||
//if ((uint32_t)BlockInfo.CompiledLocation == 0x60A7B73B)
|
||||
//{
|
||||
// X86BreakPoint(__FILEW__,__LINE__);
|
||||
//}
|
||||
//MoveConstToVariable((uint32_t)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock");
|
||||
}
|
||||
|
||||
m_EnterSection->EnterCodeBlock();
|
||||
if (g_System->bLinkBlocks())
|
||||
{
|
||||
while (m_EnterSection->GenerateNativeCode(NextTest()));
|
||||
|
@ -736,7 +727,7 @@ bool CCodeBlock::Compile()
|
|||
return false;
|
||||
}
|
||||
}
|
||||
CompileExitCode();
|
||||
m_EnterSection->CompileExitCode();
|
||||
|
||||
uint32_t PAddr;
|
||||
g_TransVaddr->TranslateVaddr(VAddrFirst(),PAddr);
|
||||
|
@ -745,18 +736,6 @@ bool CCodeBlock::Compile()
|
|||
return true;
|
||||
}
|
||||
|
||||
void CCodeBlock::CompileExitCode()
|
||||
{
|
||||
for (EXIT_LIST::iterator ExitIter = m_ExitInfo.begin(); ExitIter != m_ExitInfo.end(); ExitIter++)
|
||||
{
|
||||
CPU_Message("");
|
||||
CPU_Message(" $Exit_%d",ExitIter->ID);
|
||||
SetJump32(ExitIter->JumpLoc,(uint32_t *)m_RecompPos);
|
||||
m_NextInstruction = ExitIter->NextInstruction;
|
||||
m_EnterSection->CompileExit((uint32_t)-1, ExitIter->TargetPC,ExitIter->ExitRegSet,ExitIter->reason,true,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CCodeBlock::NextTest()
|
||||
{
|
||||
uint32_t next_test = m_Test;
|
||||
|
|
|
@ -11,14 +11,12 @@
|
|||
#pragma once
|
||||
#include <Common/md5.h>
|
||||
#include <Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h>
|
||||
#include <Project64-core/N64System/Recompiler/ExitInfo.h>
|
||||
#include <Project64-core/N64System/Recompiler/CodeSection.h>
|
||||
|
||||
class CCodeBlock :
|
||||
private CRecompilerOps
|
||||
class CCodeBlock
|
||||
{
|
||||
public:
|
||||
CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos );
|
||||
CCodeBlock(uint32_t VAddrEnter, uint8_t * CompiledLocation );
|
||||
~CCodeBlock();
|
||||
|
||||
bool Compile();
|
||||
|
@ -27,10 +25,10 @@ public:
|
|||
uint32_t VAddrFirst() const { return m_VAddrFirst; }
|
||||
uint32_t VAddrLast() const { return m_VAddrLast; }
|
||||
uint8_t * CompiledLocation() const { return m_CompiledLocation; }
|
||||
int32_t NoOfSections() const { return m_Sections.size(); }
|
||||
int32_t NoOfSections() const { return m_Sections.size() - 1;}
|
||||
const CCodeSection & EnterSection() const { return *m_EnterSection; }
|
||||
const MD5Digest & Hash() const { return m_Hash; }
|
||||
|
||||
CRecompilerOps * RecompilerOps() { return m_EnterSection; }
|
||||
void SetVAddrFirst(uint32_t VAddr) { m_VAddrFirst = VAddr; }
|
||||
void SetVAddrLast(uint32_t VAddr) { m_VAddrLast = VAddr; }
|
||||
|
||||
|
@ -42,15 +40,12 @@ public:
|
|||
|
||||
uint32_t NextTest();
|
||||
|
||||
EXIT_LIST m_ExitInfo;
|
||||
|
||||
private:
|
||||
CCodeBlock(); // Disable default constructor
|
||||
CCodeBlock(const CCodeBlock&); // Disable copy constructor
|
||||
CCodeBlock& operator=(const CCodeBlock&); // Disable assignment
|
||||
|
||||
bool AnalyseBlock();
|
||||
void CompileExitCode();
|
||||
|
||||
bool CreateBlockLinkage ( CCodeSection * EnterSection );
|
||||
void DetermineLoops ();
|
||||
|
@ -67,11 +62,11 @@ private:
|
|||
typedef std::map<uint32_t,CCodeSection *> SectionMap;
|
||||
typedef std::list<CCodeSection *> SectionList;
|
||||
|
||||
SectionMap m_SectionMap;
|
||||
SectionList m_Sections;
|
||||
CCodeSection * m_EnterSection;
|
||||
int32_t m_Test;
|
||||
MD5Digest m_Hash;
|
||||
uint64_t m_MemContents[2];
|
||||
uint64_t * m_MemLocation[2];
|
||||
SectionMap m_SectionMap;
|
||||
SectionList m_Sections;
|
||||
CCodeSection * m_EnterSection;
|
||||
int32_t m_Test;
|
||||
MD5Digest m_Hash;
|
||||
uint64_t m_MemContents[2];
|
||||
uint64_t * m_MemLocation[2];
|
||||
};
|
||||
|
|
|
@ -131,259 +131,6 @@ CCodeSection::~CCodeSection()
|
|||
{
|
||||
}
|
||||
|
||||
void CCodeSection::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value))
|
||||
{
|
||||
if (!CompileNow)
|
||||
{
|
||||
char String[100];
|
||||
sprintf(String, "Exit_%d", m_BlockInfo->m_ExitInfo.size());
|
||||
if (x86Jmp == NULL)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
x86Jmp(String, 0);
|
||||
|
||||
CExitInfo ExitInfo;
|
||||
ExitInfo.ID = m_BlockInfo->m_ExitInfo.size();
|
||||
ExitInfo.TargetPC = TargetPC;
|
||||
ExitInfo.ExitRegSet = ExitRegSet;
|
||||
ExitInfo.reason = reason;
|
||||
ExitInfo.NextInstruction = m_NextInstruction;
|
||||
ExitInfo.JumpLoc = (uint32_t *)(m_RecompPos - 4);
|
||||
m_BlockInfo->m_ExitInfo.push_back(ExitInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
//CPU_Message("CompileExit: %d",reason);
|
||||
ExitRegSet.WriteBackRegisters();
|
||||
|
||||
if (TargetPC != (uint32_t)-1)
|
||||
{
|
||||
MoveConstToVariable(TargetPC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER");
|
||||
UpdateCounters(ExitRegSet, TargetPC <= JumpPC && JumpPC != -1, reason == CExitInfo::Normal);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateCounters(ExitRegSet, false, reason == CExitInfo::Normal);
|
||||
}
|
||||
|
||||
switch (reason)
|
||||
{
|
||||
case CExitInfo::Normal: case CExitInfo::Normal_NoSysCheck:
|
||||
ExitRegSet.SetBlockCycleCount(0);
|
||||
if (TargetPC != (uint32_t)-1)
|
||||
{
|
||||
if (TargetPC <= JumpPC && reason == CExitInfo::Normal)
|
||||
{
|
||||
CPU_Message("CompileSystemCheck 1");
|
||||
CompileSystemCheck((uint32_t)-1, ExitRegSet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reason == CExitInfo::Normal)
|
||||
{
|
||||
CPU_Message("CompileSystemCheck 2");
|
||||
CompileSystemCheck((uint32_t)-1, ExitRegSet);
|
||||
}
|
||||
}
|
||||
if (g_SyncSystem)
|
||||
{
|
||||
MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
|
||||
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
|
||||
}
|
||||
#ifdef LinkBlocks
|
||||
if (bSMM_ValidFunc == false)
|
||||
{
|
||||
if (LookUpMode() == FuncFind_ChangeMemory)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
// uint8_t * Jump, * Jump2;
|
||||
// if (TargetPC >= 0x80000000 && TargetPC < 0xC0000000) {
|
||||
// uint32_t pAddr = TargetPC & 0x1FFFFFFF;
|
||||
//
|
||||
// MoveVariableToX86reg((uint8_t *)RDRAM + pAddr,"RDRAM + pAddr",x86_EAX);
|
||||
// Jump2 = NULL;
|
||||
// } else {
|
||||
// MoveConstToX86reg((TargetPC >> 12),x86_ECX);
|
||||
// MoveConstToX86reg(TargetPC,x86_EBX);
|
||||
// MoveVariableDispToX86Reg(TLB_ReadMap,"TLB_ReadMap",x86_ECX,x86_ECX,4);
|
||||
// TestX86RegToX86Reg(x86_ECX,x86_ECX);
|
||||
// JeLabel8("NoTlbEntry",0);
|
||||
// Jump2 = m_RecompPos - 1;
|
||||
// MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_EAX);
|
||||
// }
|
||||
// MoveX86RegToX86Reg(x86_EAX,x86_ECX);
|
||||
// AndConstToX86Reg(x86_ECX,0xFFFF0000);
|
||||
// CompConstToX86reg(x86_ECX,0x7C7C0000);
|
||||
// JneLabel8("NoCode",0);
|
||||
// Jump = m_RecompPos - 1;
|
||||
// AndConstToX86Reg(x86_EAX,0xFFFF);
|
||||
// ShiftLeftSignImmed(x86_EAX,4);
|
||||
// AddConstToX86Reg(x86_EAX,0xC);
|
||||
// MoveVariableDispToX86Reg(OrigMem,"OrigMem",x86_ECX,x86_EAX,1);
|
||||
// JmpDirectReg(x86_ECX);
|
||||
// CPU_Message(" NoCode:");
|
||||
// *((uint8_t *)(Jump))=(uint8_t)(m_RecompPos - Jump - 1);
|
||||
// if (Jump2 != NULL) {
|
||||
// CPU_Message(" NoTlbEntry:");
|
||||
// *((uint8_t *)(Jump2))=(uint8_t)(m_RecompPos - Jump2 - 1);
|
||||
// }
|
||||
}
|
||||
else if (LookUpMode() == FuncFind_VirtualLookup)
|
||||
{
|
||||
MoveConstToX86reg(TargetPC,x86_EDX);
|
||||
MoveConstToX86reg((uint32_t)&m_Functions,x86_ECX);
|
||||
Call_Direct(AddressOf(&CFunctionMap::CompilerFindFunction), "CFunctionMap::CompilerFindFunction");
|
||||
MoveX86RegToX86Reg(x86_EAX,x86_ECX);
|
||||
JecxzLabel8("NullPointer",0);
|
||||
uint8_t * Jump = m_RecompPos - 1;
|
||||
MoveX86PointerToX86regDisp(x86_EBX,x86_ECX,0xC);
|
||||
JmpDirectReg(x86_EBX);
|
||||
CPU_Message(" NullPointer:");
|
||||
*((uint8_t *)(Jump))=(uint8_t)(m_RecompPos - Jump - 1);
|
||||
}
|
||||
else if (LookUpMode() == FuncFind_PhysicalLookup)
|
||||
{
|
||||
uint8_t * Jump2 = NULL;
|
||||
if (TargetPC >= 0x80000000 && TargetPC < 0x90000000)
|
||||
{
|
||||
uint32_t pAddr = TargetPC & 0x1FFFFFFF;
|
||||
MoveVariableToX86reg((uint8_t *)JumpTable + pAddr,"JumpTable + pAddr",x86_ECX);
|
||||
}
|
||||
else if (TargetPC >= 0x90000000 && TargetPC < 0xC0000000)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveConstToX86reg((TargetPC >> 12),x86_ECX);
|
||||
MoveConstToX86reg(TargetPC,x86_EBX);
|
||||
MoveVariableDispToX86Reg(TLB_ReadMap,"TLB_ReadMap",x86_ECX,x86_ECX,4);
|
||||
TestX86RegToX86Reg(x86_ECX,x86_ECX);
|
||||
JeLabel8("NoTlbEntry",0);
|
||||
Jump2 = m_RecompPos - 1;
|
||||
AddConstToX86Reg(x86_ECX,(uint32_t)JumpTable - (uint32_t)RDRAM);
|
||||
MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_ECX);
|
||||
}
|
||||
if (TargetPC < 0x90000000 || TargetPC >= 0xC0000000)
|
||||
{
|
||||
JecxzLabel8("NullPointer",0);
|
||||
uint8_t * Jump = m_RecompPos - 1;
|
||||
MoveX86PointerToX86regDisp(x86_EAX,x86_ECX,0xC);
|
||||
JmpDirectReg(x86_EAX);
|
||||
CPU_Message(" NullPointer:");
|
||||
*((uint8_t *)(Jump))=(uint8_t)(m_RecompPos - Jump - 1);
|
||||
if (Jump2 != NULL)
|
||||
{
|
||||
CPU_Message(" NoTlbEntry:");
|
||||
*((uint8_t *)(Jump2))=(uint8_t)(m_RecompPos - Jump2 - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ExitCodeBlock();
|
||||
#else
|
||||
ExitCodeBlock();
|
||||
#endif
|
||||
break;
|
||||
case CExitInfo::DoCPU_Action:
|
||||
MoveConstToX86reg((uint32_t)g_SystemEvents, x86_ECX);
|
||||
Call_Direct(AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents");
|
||||
if (g_SyncSystem)
|
||||
{
|
||||
MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
|
||||
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
|
||||
}
|
||||
//g_System->SyncCPU(g_SyncSystem);
|
||||
ExitCodeBlock();
|
||||
break;
|
||||
case CExitInfo::DoSysCall:
|
||||
{
|
||||
bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT;
|
||||
PushImm32(bDelay ? "true" : "false", bDelay);
|
||||
MoveConstToX86reg((uint32_t)g_Reg, x86_ECX);
|
||||
Call_Direct(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException");
|
||||
if (g_SyncSystem)
|
||||
{
|
||||
MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
|
||||
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
|
||||
}
|
||||
ExitCodeBlock();
|
||||
}
|
||||
break;
|
||||
case CExitInfo::COP1_Unuseable:
|
||||
{
|
||||
bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT;
|
||||
PushImm32("1", 1);
|
||||
PushImm32(bDelay ? "true" : "false", bDelay);
|
||||
MoveConstToX86reg((uint32_t)g_Reg, x86_ECX);
|
||||
Call_Direct(AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException");
|
||||
if (g_SyncSystem)
|
||||
{
|
||||
MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
|
||||
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
|
||||
}
|
||||
ExitCodeBlock();
|
||||
}
|
||||
break;
|
||||
case CExitInfo::ExitResetRecompCode:
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
#ifdef legacycode
|
||||
if (m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT)
|
||||
{
|
||||
X86BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
if (g_SyncSystem)
|
||||
{
|
||||
MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX);
|
||||
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
|
||||
}
|
||||
X86BreakPoint(__FILEW__,__LINE__);
|
||||
MoveVariableToX86reg(this,"this",x86_ECX);
|
||||
Call_Direct(AddressOf(ResetRecompCode), "ResetRecompCode");
|
||||
#endif
|
||||
ExitCodeBlock();
|
||||
break;
|
||||
case CExitInfo::TLBReadMiss:
|
||||
MoveVariableToX86reg(g_TLBLoadAddress, "g_TLBLoadAddress", x86_EDX);
|
||||
Push(x86_EDX);
|
||||
PushImm32(m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT);
|
||||
MoveConstToX86reg((uint32_t)g_Reg, x86_ECX);
|
||||
Call_Direct(AddressOf(&CRegisters::DoTLBReadMiss), "CRegisters::DoTLBReadMiss");
|
||||
if (g_SyncSystem)
|
||||
{
|
||||
MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
|
||||
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
|
||||
}
|
||||
ExitCodeBlock();
|
||||
break;
|
||||
case CExitInfo::TLBWriteMiss:
|
||||
X86BreakPoint(__FILE__, __LINE__);
|
||||
ExitCodeBlock();
|
||||
break;
|
||||
case CExitInfo::DivByZero:
|
||||
AddConstToVariable(4, _PROGRAM_COUNTER, "PROGRAM_COUNTER");
|
||||
if (!g_System->b32BitCore())
|
||||
{
|
||||
MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]");
|
||||
MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]");
|
||||
}
|
||||
MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]");
|
||||
MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]");
|
||||
if (g_SyncSystem)
|
||||
{
|
||||
MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
|
||||
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
|
||||
}
|
||||
ExitCodeBlock();
|
||||
break;
|
||||
default:
|
||||
WriteTrace(TraceRecompiler, TraceError, "how did you want to exit on reason (%d) ???", reason);
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeSection::GenerateSectionLinkage()
|
||||
{
|
||||
CCodeSection * TargetSection[] = { m_ContinueSection, m_JumpSection };
|
||||
|
@ -411,18 +158,18 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
JumpInfo[i]->FallThrough = false;
|
||||
if (JumpInfo[i]->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
PushImm32(stdstr_f("0x%08X",JumpInfo[i]->TargetPC).c_str(),JumpInfo[i]->TargetPC);
|
||||
if (JumpInfo[(i + 1) & 1]->LinkLocation == NULL) { break; }
|
||||
JmpLabel8("FinishBlock",0);
|
||||
Jump = m_RecompPos - 1;
|
||||
Jump = *g_RecompPos - 1;
|
||||
}
|
||||
for (i = 0; i < 2; i ++)
|
||||
{
|
||||
|
@ -430,23 +177,23 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
JumpInfo[i]->FallThrough = false;
|
||||
if (JumpInfo[i]->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
PushImm32(stdstr_f("0x%08X",JumpInfo[i]->TargetPC).c_str(),JumpInfo[i]->TargetPC);
|
||||
if (JumpInfo[(i + 1) & 1]->LinkLocation == NULL) { break; }
|
||||
JmpLabel8("FinishBlock",0);
|
||||
Jump = m_RecompPos - 1;
|
||||
Jump = *g_RecompPos - 1;
|
||||
}
|
||||
if (Jump != NULL)
|
||||
{
|
||||
CPU_Message(" $FinishBlock:");
|
||||
SetJump8(Jump,m_RecompPos);
|
||||
SetJump8(Jump,*g_RecompPos);
|
||||
}
|
||||
//MoveConstToVariable(CompilePC() + 4,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
|
||||
m_RegWorkingSet.WriteBackRegisters();
|
||||
|
@ -500,11 +247,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
{
|
||||
if (JumpInfo[i]->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -517,11 +264,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC) { continue; }
|
||||
if (JumpInfo[i]->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -554,11 +301,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
JumpInfo[i]->FallThrough = false;
|
||||
if (JumpInfo[i]->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +345,7 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
m_RegWorkingSet = JumpInfo[i]->RegSet;
|
||||
SyncRegState(TargetSection[i]->m_RegEnter);
|
||||
JmpLabel32(Label, 0);
|
||||
SetJump32((uint32_t *)m_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation));
|
||||
SetJump32((uint32_t *)*g_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -626,7 +373,7 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
{
|
||||
JumpInfo[i]->FallThrough = false;
|
||||
JmpLabel32(JumpInfo[i]->BranchLabel.c_str(), 0);
|
||||
JumpInfo[i]->LinkLocation = (uint32_t*)(m_RecompPos - 4);
|
||||
JumpInfo[i]->LinkLocation = (uint32_t*)(*g_RecompPos - 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -652,7 +399,7 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
{
|
||||
JumpInfo[i]->FallThrough = false;
|
||||
JmpLabel32(JumpInfo[i]->BranchLabel.c_str(), 0);
|
||||
JumpInfo[i]->LinkLocation = (uint32_t *)(m_RecompPos - 4);
|
||||
JumpInfo[i]->LinkLocation = (uint32_t *)(*g_RecompPos - 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -663,11 +410,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
if (TargetSection[i] == NULL)
|
||||
{
|
||||
CPU_Message("ExitBlock (from %d):", m_SectionID);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
CompileExit(JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet, JumpInfo[i]->ExitReason, true, NULL);
|
||||
|
@ -686,11 +433,11 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
stdstr_f Label("Section_%d (from %d):", TargetSection[i]->m_SectionID, m_SectionID);
|
||||
|
||||
CPU_Message(Label.c_str());
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation = NULL;
|
||||
if (JumpInfo[i]->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo[i]->LinkLocation2 = NULL;
|
||||
}
|
||||
m_RegWorkingSet = JumpInfo[i]->RegSet;
|
||||
|
@ -718,7 +465,7 @@ void CCodeSection::GenerateSectionLinkage()
|
|||
m_RegWorkingSet = JumpInfo[i]->RegSet;
|
||||
SyncRegState(TargetSection[i]->m_RegEnter);
|
||||
JmpLabel32(Label.c_str(), 0);
|
||||
SetJump32((uint32_t *)m_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation));
|
||||
SetJump32((uint32_t *)*g_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1021,7 +768,7 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
m_CompiledLocation = m_RecompPos;
|
||||
m_CompiledLocation = *g_RecompPos;
|
||||
m_RegWorkingSet = m_RegEnter;
|
||||
m_CompilePC = m_EnterPC;
|
||||
m_NextInstruction = m_DelaySlot ? JUMP : NORMAL;
|
||||
|
@ -1778,7 +1525,7 @@ bool CCodeSection::InheritParentInfo()
|
|||
{
|
||||
if (m_CompiledLocation == NULL)
|
||||
{
|
||||
m_CompiledLocation = m_RecompPos;
|
||||
m_CompiledLocation = *g_RecompPos;
|
||||
DisplaySectionInformation();
|
||||
m_CompiledLocation = NULL;
|
||||
}
|
||||
|
@ -1806,10 +1553,10 @@ bool CCodeSection::InheritParentInfo()
|
|||
if (JumpInfo->LinkLocation != NULL)
|
||||
{
|
||||
CPU_Message(" Section_%d:", m_SectionID);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos);
|
||||
if (JumpInfo->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)*g_RecompPos);
|
||||
}
|
||||
}
|
||||
m_RegWorkingSet = m_RegEnter;
|
||||
|
@ -1899,11 +1646,11 @@ bool CCodeSection::InheritParentInfo()
|
|||
if (JumpInfo->LinkLocation != NULL)
|
||||
{
|
||||
CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo->LinkLocation = NULL;
|
||||
if (JumpInfo->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2157,7 +1904,7 @@ bool CCodeSection::InheritParentInfo()
|
|||
Parent = ParentList[CurrentParent].Parent;
|
||||
JumpInfo = ParentList[CurrentParent].JumpInfo;
|
||||
JmpLabel32(Label.c_str(), 0);
|
||||
JumpInfo->LinkLocation = (uint32_t *)(m_RecompPos - 4);
|
||||
JumpInfo->LinkLocation = (uint32_t *)(*g_RecompPos - 4);
|
||||
JumpInfo->LinkLocation2 = NULL;
|
||||
|
||||
CurrentParent = i;
|
||||
|
@ -2166,11 +1913,11 @@ bool CCodeSection::InheritParentInfo()
|
|||
CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID);
|
||||
if (JumpInfo->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo->LinkLocation = NULL;
|
||||
if (JumpInfo->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2200,11 +1947,11 @@ bool CCodeSection::InheritParentInfo()
|
|||
|
||||
if (JumpInfo->LinkLocation != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo->LinkLocation = NULL;
|
||||
if (JumpInfo->LinkLocation2 != NULL)
|
||||
{
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos);
|
||||
SetJump32(JumpInfo->LinkLocation2, (uint32_t *)*g_RecompPos);
|
||||
JumpInfo->LinkLocation2 = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
class CCodeBlock;
|
||||
|
||||
class CCodeSection :
|
||||
private CRecompilerOps
|
||||
public CRecompilerOps
|
||||
{
|
||||
public:
|
||||
typedef std::list<CCodeSection *> SECTION_LIST;
|
||||
|
@ -29,7 +29,6 @@ public:
|
|||
void CompileCop1Test();
|
||||
bool GenerateNativeCode(uint32_t Test);
|
||||
void GenerateSectionLinkage();
|
||||
void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value));
|
||||
void DetermineLoop(uint32_t Test, uint32_t Test2, uint32_t TestID);
|
||||
bool FixConstants(uint32_t Test);
|
||||
CCodeSection * ExistingSection(uint32_t Addr, uint32_t Test);
|
||||
|
|
|
@ -937,7 +937,7 @@ CCompiledFunc * CRecompiler::CompilerCode()
|
|||
//uint32_t StartTime = timeGetTime();
|
||||
WriteTrace(TraceRecompiler, TraceDebug, ": Compile Block-Start: Program Counter: %X pAddr: %X", PROGRAM_COUNTER, pAddr);
|
||||
|
||||
CCodeBlock CodeBlock(PROGRAM_COUNTER, RecompPos());
|
||||
CCodeBlock CodeBlock(PROGRAM_COUNTER, *g_RecompPos);
|
||||
if (!CodeBlock.Compile())
|
||||
{
|
||||
return NULL;
|
||||
|
|
|
@ -18,7 +18,7 @@ class CRecompiler :
|
|||
protected CDebugSettings,
|
||||
public CRecompilerSettings,
|
||||
public CFunctionMap,
|
||||
private CRecompMemory,
|
||||
public CRecompMemory,
|
||||
private CSystemRegisters
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -33,7 +33,9 @@ CRecompMemory::~CRecompMemory()
|
|||
|
||||
bool CRecompMemory::AllocateMemory()
|
||||
{
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "Start");
|
||||
uint8_t * RecompCodeBase = (uint8_t *)AllocateAddressSpace(MaxCompileBufferSize + 4);
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "RecompCodeBase = %X", RecompCodeBase);
|
||||
if (RecompCodeBase == NULL)
|
||||
{
|
||||
WriteTrace(TraceRecompiler, TraceError, "failed to allocate RecompCodeBase");
|
||||
|
@ -52,6 +54,7 @@ bool CRecompMemory::AllocateMemory()
|
|||
m_RecompSize = InitialCompileBufferSize;
|
||||
m_RecompPos = m_RecompCode;
|
||||
memset(m_RecompCode, 0, InitialCompileBufferSize);
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "Done");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
#pragma once
|
||||
#include <Project64-core/N64System/Recompiler/x86/x86ops.h>
|
||||
|
||||
class CRecompMemory :
|
||||
protected CX86Ops
|
||||
class CRecompMemory
|
||||
{
|
||||
protected:
|
||||
CRecompMemory();
|
||||
|
@ -23,7 +22,8 @@ protected:
|
|||
void Reset();
|
||||
void ShowMemUsed();
|
||||
|
||||
uint8_t* RecompPos() const { return m_RecompPos; }
|
||||
public:
|
||||
uint8_t** RecompPos() { return &m_RecompPos; }
|
||||
|
||||
private:
|
||||
CRecompMemory(const CRecompMemory&); // Disable copy constructor
|
||||
|
@ -31,6 +31,7 @@ private:
|
|||
|
||||
uint8_t * m_RecompCode;
|
||||
uint32_t m_RecompSize;
|
||||
uint8_t * m_RecompPos;
|
||||
|
||||
enum { MaxCompileBufferSize = 0x03C00000 };
|
||||
enum { InitialCompileBufferSize = 0x00500000 };
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
||||
#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/x86/x86ops.h>
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
|
@ -27,7 +28,7 @@ class CRecompilerOps :
|
|||
protected CN64SystemSettings,
|
||||
protected CRecompilerSettings
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
enum BRANCH_TYPE
|
||||
{
|
||||
BranchTypeCop1, BranchTypeRs, BranchTypeRsRt
|
||||
|
@ -36,8 +37,8 @@ protected:
|
|||
typedef void ( * BranchFunction )();
|
||||
|
||||
/************************** Branch functions ************************/
|
||||
static void Compile_Branch ( BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link);
|
||||
static void Compile_BranchLikely ( BranchFunction CompareFunc, bool Link);
|
||||
void Compile_Branch ( BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link);
|
||||
void Compile_BranchLikely ( BranchFunction CompareFunc, bool Link);
|
||||
static void BNE_Compare();
|
||||
static void BEQ_Compare();
|
||||
static void BGTZ_Compare();
|
||||
|
@ -49,7 +50,7 @@ protected:
|
|||
|
||||
/************************* OpCode functions *************************/
|
||||
static void J ();
|
||||
static void JAL ();
|
||||
void JAL ();
|
||||
static void ADDI ();
|
||||
static void ADDIU ();
|
||||
static void SLTI ();
|
||||
|
@ -93,9 +94,9 @@ protected:
|
|||
static void SPECIAL_SLLV ();
|
||||
static void SPECIAL_SRLV ();
|
||||
static void SPECIAL_SRAV ();
|
||||
static void SPECIAL_JR ();
|
||||
static void SPECIAL_JALR ();
|
||||
static void SPECIAL_SYSCALL();
|
||||
void SPECIAL_JR ();
|
||||
void SPECIAL_JALR ();
|
||||
void SPECIAL_SYSCALL();
|
||||
static void SPECIAL_MFLO ();
|
||||
static void SPECIAL_MTLO ();
|
||||
static void SPECIAL_MFHI ();
|
||||
|
@ -105,7 +106,7 @@ protected:
|
|||
static void SPECIAL_DSRAV ();
|
||||
static void SPECIAL_MULT ();
|
||||
static void SPECIAL_MULTU ();
|
||||
static void SPECIAL_DIV ();
|
||||
void SPECIAL_DIV ();
|
||||
static void SPECIAL_DIVU ();
|
||||
static void SPECIAL_DMULT ();
|
||||
static void SPECIAL_DMULTU ();
|
||||
|
@ -141,7 +142,7 @@ protected:
|
|||
static void COP0_CO_TLBWI ();
|
||||
static void COP0_CO_TLBWR ();
|
||||
static void COP0_CO_TLBP ();
|
||||
static void COP0_CO_ERET ();
|
||||
void COP0_CO_ERET ();
|
||||
|
||||
/************************** COP1 functions **************************/
|
||||
static void COP1_MF ();
|
||||
|
@ -206,13 +207,14 @@ protected:
|
|||
/************************** Other functions **************************/
|
||||
static void UnknownOpcode ();
|
||||
|
||||
void CompileExitCode();
|
||||
static void BeforeCallDirect(CRegInfo & RegSet);
|
||||
static void AfterCallDirect(CRegInfo & RegSet);
|
||||
static void EnterCodeBlock();
|
||||
static void ExitCodeBlock();
|
||||
static void CompileReadTLBMiss(uint32_t VirtualAddress, x86Reg LookUpReg);
|
||||
static void CompileReadTLBMiss(x86Reg AddressReg, x86Reg LookUpReg);
|
||||
static void CompileWriteTLBMiss(x86Reg AddressReg, x86Reg LookUpReg);
|
||||
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);
|
||||
|
@ -334,4 +336,7 @@ protected:
|
|||
|
||||
public:
|
||||
static uint32_t CompilePC() { return m_CompilePC; }
|
||||
|
||||
void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value));
|
||||
EXIT_LIST m_ExitInfo;
|
||||
};
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
#include <Project64-core/N64System/Recompiler/x86/x86ops.h>
|
||||
#include <Project64-core/N64System/Recompiler/RecompilerCodeLog.h>
|
||||
|
||||
uint8_t * CX86Ops::m_RecompPos;
|
||||
|
||||
char CX86Ops::m_fpupop[2][2] =
|
||||
{
|
||||
"", "p"
|
||||
|
@ -216,7 +214,7 @@ void CX86Ops::Call_Direct(void * FunctAddress, const char * FunctName)
|
|||
{
|
||||
CPU_Message(" call offset %s", FunctName);
|
||||
AddCode8(0xE8);
|
||||
AddCode32((uint32_t)FunctAddress - (uint32_t)*m_RecompPos - 4);
|
||||
AddCode32((uint32_t)FunctAddress - (uint32_t)*g_RecompPos - 4);
|
||||
}
|
||||
|
||||
void CX86Ops::Call_Indirect(void * FunctAddress, const char * FunctName)
|
||||
|
@ -4294,18 +4292,36 @@ void * CX86Ops::GetAddressOf(int value, ...)
|
|||
|
||||
void CX86Ops::AddCode8(uint8_t value)
|
||||
{
|
||||
(*((uint8_t *)(m_RecompPos)) = (uint8_t)(value));
|
||||
m_RecompPos += 1;
|
||||
#ifdef _DEBUG
|
||||
if (g_RecompPos == NULL)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
#endif
|
||||
(*((uint8_t *)(*g_RecompPos))=(uint8_t)(value));
|
||||
*g_RecompPos += 1;
|
||||
}
|
||||
|
||||
void CX86Ops::AddCode16(uint16_t value)
|
||||
{
|
||||
(*((uint16_t *)(m_RecompPos)) = (uint16_t)(value));
|
||||
m_RecompPos += 2;
|
||||
#ifdef _DEBUG
|
||||
if (g_RecompPos == NULL)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
#endif
|
||||
(*((uint16_t *)(*g_RecompPos))=(uint16_t)(value));
|
||||
*g_RecompPos += 2;
|
||||
}
|
||||
|
||||
void CX86Ops::AddCode32(uint32_t value)
|
||||
{
|
||||
(*((uint32_t *)(m_RecompPos)) = (uint32_t)(value));
|
||||
m_RecompPos += 4;
|
||||
#ifdef _DEBUG
|
||||
if (g_RecompPos == NULL)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__,__LINE__);
|
||||
}
|
||||
#endif
|
||||
(*((uint32_t *)(*g_RecompPos))=(uint32_t)(value));
|
||||
*g_RecompPos += 4;
|
||||
}
|
||||
|
|
|
@ -290,7 +290,6 @@ protected:
|
|||
|
||||
static bool Is8BitReg(x86Reg Reg);
|
||||
static uint8_t CalcMultiplyCode(Multipler Multiply);
|
||||
static uint8_t * m_RecompPos;
|
||||
|
||||
static void * GetAddressOf(int32_t value, ...);
|
||||
static void SetJump32(uint32_t * Loc, uint32_t * JumpLoc);
|
||||
|
|
|
@ -30,5 +30,6 @@ CSystemEvents * g_SystemEvents = NULL;
|
|||
uint32_t * g_TLBLoadAddress = NULL;
|
||||
uint32_t * g_TLBStoreAddress = NULL;
|
||||
CDebugger * g_Debugger = NULL;
|
||||
uint8_t ** g_RecompPos = NULL;
|
||||
|
||||
int * g_NextTimer;
|
|
@ -58,3 +58,5 @@ extern uint32_t * g_TLBStoreAddress;
|
|||
|
||||
__interface CDebugger;
|
||||
extern CDebugger * g_Debugger;
|
||||
|
||||
extern uint8_t ** g_RecompPos;
|
||||
|
|
Loading…
Reference in New Issue