[Project64] get Code Block.cpp to use standard types
This commit is contained in:
parent
e85c1665b1
commit
a6d1722122
|
@ -12,7 +12,7 @@
|
|||
|
||||
bool DelaySlotEffectsCompare (uint32_t PC, uint32_t Reg1, uint32_t Reg2);
|
||||
|
||||
CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) :
|
||||
CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos) :
|
||||
m_VAddrEnter(VAddrEnter),
|
||||
m_VAddrFirst(VAddrEnter),
|
||||
m_VAddrLast(VAddrEnter),
|
||||
|
@ -27,7 +27,7 @@ CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) :
|
|||
}
|
||||
m_Sections.push_back(baseSection);
|
||||
baseSection->AddParent(NULL);
|
||||
baseSection->m_CompiledLocation = (BYTE *)-1;
|
||||
baseSection->m_CompiledLocation = (uint8_t *)-1;
|
||||
baseSection->m_Cont.JumpPC = VAddrEnter;
|
||||
baseSection->m_Cont.FallThrough = true;
|
||||
baseSection->m_Cont.RegSet = baseSection->m_RegEnter;
|
||||
|
@ -67,7 +67,7 @@ CCodeBlock::~CCodeBlock()
|
|||
m_Sections.clear();
|
||||
}
|
||||
|
||||
bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, DWORD TargetPC, bool LinkAllowed, DWORD CurrentPC )
|
||||
bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC )
|
||||
{
|
||||
if (Section != NULL)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSe
|
|||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
if (SplitSection->m_EndPC == (DWORD)-1)
|
||||
if (SplitSection->m_EndPC == (uint32_t)-1)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSe
|
|||
SplitSection->m_JumpSection = NULL;
|
||||
SplitSection->m_ContinueSection = BaseSection;
|
||||
SplitSection->SetContinueAddress(TargetPC - 4, TargetPC);
|
||||
SplitSection->SetJumpAddress((DWORD)-1,(DWORD)-1,false);
|
||||
SplitSection->SetJumpAddress((uint32_t)-1,(uint32_t)-1,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
|
|||
CCodeSection * CurrentSection = EnterSection;
|
||||
|
||||
CPU_Message("Section %d",CurrentSection->m_SectionID);
|
||||
for (DWORD TestPC = EnterSection->m_EnterPC, EndPC = ((EnterSection->m_EnterPC + 0x1000) & 0xFFFFF000); TestPC <= EndPC; TestPC += 4)
|
||||
for (uint32_t TestPC = EnterSection->m_EnterPC, EndPC = ((EnterSection->m_EnterPC + 0x1000) & 0xFFFFF000); TestPC <= EndPC; TestPC += 4)
|
||||
{
|
||||
if (TestPC != EndPC)
|
||||
{
|
||||
|
@ -199,7 +199,7 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
|
|||
}
|
||||
|
||||
bool LikelyBranch, EndBlock, IncludeDelaySlot, PermLoop;
|
||||
DWORD TargetPC, ContinuePC;
|
||||
uint32_t TargetPC, ContinuePC;
|
||||
|
||||
CurrentSection->m_EndPC = TestPC;
|
||||
if (!AnalyzeInstruction(TestPC, TargetPC, ContinuePC, LikelyBranch, IncludeDelaySlot, EndBlock, PermLoop))
|
||||
|
@ -210,13 +210,13 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
|
|||
|
||||
if (TestPC + 4 == EndPC && IncludeDelaySlot)
|
||||
{
|
||||
TargetPC = (DWORD)-1;
|
||||
ContinuePC = (DWORD)-1;
|
||||
TargetPC = (uint32_t)-1;
|
||||
ContinuePC = (uint32_t)-1;
|
||||
EndBlock = true;
|
||||
}
|
||||
if (TargetPC == (DWORD)-1 && !EndBlock)
|
||||
if (TargetPC == (uint32_t)-1 && !EndBlock)
|
||||
{
|
||||
if (ContinuePC != (DWORD)-1)
|
||||
if (ContinuePC != (uint32_t)-1)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
|
@ -231,13 +231,13 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
|
|||
break;
|
||||
}
|
||||
|
||||
if (ContinuePC != (DWORD)-1)
|
||||
if (ContinuePC != (uint32_t)-1)
|
||||
{
|
||||
CPU_Message(__FUNCTION__ ": SetContinueAddress TestPC = %X ContinuePC = %X",TestPC,ContinuePC);
|
||||
CurrentSection->SetContinueAddress(TestPC, ContinuePC);
|
||||
if (!SetSection(CurrentSection->m_ContinueSection, CurrentSection, ContinuePC,true,TestPC))
|
||||
{
|
||||
ContinuePC = (DWORD)-1;
|
||||
ContinuePC = (uint32_t)-1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
|
|||
if (SetSection(CurrentSection->m_JumpSection, CurrentSection, TestPC + 4,false,TestPC))
|
||||
{
|
||||
bool BranchLikelyBranch, BranchEndBlock, BranchIncludeDelaySlot, BranchPermLoop;
|
||||
DWORD BranchTargetPC, BranchContinuePC;
|
||||
uint32_t BranchTargetPC, BranchContinuePC;
|
||||
|
||||
CCodeSection * JumpSection = CurrentSection->m_JumpSection;
|
||||
if (!AnalyzeInstruction(JumpSection->m_EnterPC, BranchTargetPC, BranchContinuePC, BranchLikelyBranch, BranchIncludeDelaySlot, BranchEndBlock, BranchPermLoop))
|
||||
|
@ -268,7 +268,7 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
|
|||
{
|
||||
CPU_Message(__FUNCTION__ ": Jump End Block");
|
||||
JumpSection->m_EndSection = true;
|
||||
TargetPC = (DWORD)-1;
|
||||
TargetPC = (uint32_t)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -282,13 +282,13 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
|
|||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
}
|
||||
else if (TargetPC != ((DWORD)-1))
|
||||
else if (TargetPC != ((uint32_t)-1))
|
||||
{
|
||||
CPU_Message(__FUNCTION__ ": SetJumpAddress TestPC = %X Target = %X",TestPC,TargetPC);
|
||||
CurrentSection->SetJumpAddress(TestPC, TargetPC,PermLoop);
|
||||
if (PermLoop || !SetSection(CurrentSection->m_JumpSection, CurrentSection, TargetPC,true,TestPC))
|
||||
{
|
||||
if (ContinuePC == (DWORD)-1)
|
||||
if (ContinuePC == (uint32_t)-1)
|
||||
{
|
||||
CurrentSection->m_EndSection = true;
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (CurrentSection->m_EndPC == (DWORD)-1)
|
||||
if (CurrentSection->m_EndPC == (uint32_t)-1)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ void CCodeBlock::DetermineLoops()
|
|||
{
|
||||
CCodeSection * Section = itr->second;
|
||||
|
||||
DWORD Test = NextTest();
|
||||
uint32_t Test = NextTest();
|
||||
Section->DetermineLoop(Test,Test,Section->m_SectionID);
|
||||
}
|
||||
}
|
||||
|
@ -387,10 +387,10 @@ bool CCodeBlock::AnalyseBlock()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & 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 = (DWORD)-1;
|
||||
ContinuePC = (DWORD)-1;
|
||||
TargetPC = (uint32_t)-1;
|
||||
ContinuePC = (uint32_t)-1;
|
||||
LikelyBranch = false;
|
||||
IncludeDelaySlot = false;
|
||||
EndBlock = false;
|
||||
|
@ -404,7 +404,7 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
char * Name = R4300iOpcodeName(Command.Hex,PC);
|
||||
const char * Name = R4300iOpcodeName(Command.Hex,PC);
|
||||
CPU_Message(" 0x%08X %s",PC,Name);
|
||||
#endif
|
||||
switch (Command.op)
|
||||
|
@ -446,10 +446,10 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
{
|
||||
case R4300i_REGIMM_BLTZ:
|
||||
case R4300i_REGIMM_BLTZAL:
|
||||
TargetPC = PC + ((short)Command.offset << 2) + 4;
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
if (TargetPC == PC + 8)
|
||||
{
|
||||
TargetPC = (DWORD)-1;
|
||||
TargetPC = (uint32_t)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -463,10 +463,10 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
break;
|
||||
case R4300i_REGIMM_BGEZ:
|
||||
case R4300i_REGIMM_BGEZAL:
|
||||
TargetPC = PC + ((short)Command.offset << 2) + 4;
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
if (TargetPC == PC + 8)
|
||||
{
|
||||
TargetPC = (DWORD)-1;
|
||||
TargetPC = (uint32_t)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -474,7 +474,7 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
{
|
||||
if (Command.rs == 0)
|
||||
{
|
||||
TargetPC = (DWORD)-1;
|
||||
TargetPC = (uint32_t)-1;
|
||||
EndBlock = true;
|
||||
}
|
||||
else
|
||||
|
@ -494,7 +494,7 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
break;
|
||||
case R4300i_REGIMM_BLTZL:
|
||||
case R4300i_REGIMM_BGEZL:
|
||||
TargetPC = PC + ((short)Command.offset << 2) + 4;
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
if (TargetPC == PC)
|
||||
{
|
||||
if (!DelaySlotEffectsCompare(PC,Command.rs,0))
|
||||
|
@ -529,10 +529,10 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
IncludeDelaySlot = true;
|
||||
break;
|
||||
case R4300i_BEQ:
|
||||
TargetPC = PC + ((short)Command.offset << 2) + 4;
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
if (TargetPC == PC + 8)
|
||||
{
|
||||
TargetPC = (DWORD)-1;
|
||||
TargetPC = (uint32_t)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -551,10 +551,10 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
case R4300i_BNE:
|
||||
case R4300i_BLEZ:
|
||||
case R4300i_BGTZ:
|
||||
TargetPC = PC + ((short)Command.offset << 2) + 4;
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
if (TargetPC == PC + 8)
|
||||
{
|
||||
TargetPC = (DWORD)-1;
|
||||
TargetPC = (uint32_t)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -609,10 +609,10 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
switch (Command.ft) {
|
||||
case R4300i_COP1_BC_BCF:
|
||||
case R4300i_COP1_BC_BCT:
|
||||
TargetPC = PC + ((short)Command.offset << 2) + 4;
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
if (TargetPC == PC + 8)
|
||||
{
|
||||
TargetPC = (DWORD)-1;
|
||||
TargetPC = (uint32_t)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -626,7 +626,7 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
break;
|
||||
case R4300i_COP1_BC_BCFL:
|
||||
case R4300i_COP1_BC_BCTL:
|
||||
TargetPC = PC + ((short)Command.offset << 2) + 4;
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
if (TargetPC == PC)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
|
@ -655,7 +655,7 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
case R4300i_SC: case R4300i_SWC1: case R4300i_SDC1: case R4300i_SD:
|
||||
break;
|
||||
case R4300i_BEQL:
|
||||
TargetPC = PC + ((short)Command.offset << 2) + 4;
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
if (TargetPC == PC)
|
||||
{
|
||||
if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
|
||||
|
@ -673,7 +673,7 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
|
|||
case R4300i_BNEL:
|
||||
case R4300i_BLEZL:
|
||||
case R4300i_BGTZL:
|
||||
TargetPC = PC + ((short)Command.offset << 2) + 4;
|
||||
TargetPC = PC + ((int16_t)Command.offset << 2) + 4;
|
||||
ContinuePC = PC + 8;
|
||||
if (TargetPC == PC)
|
||||
{
|
||||
|
@ -710,11 +710,11 @@ bool CCodeBlock::Compile()
|
|||
|
||||
if (g_SyncSystem)
|
||||
{
|
||||
//if ((DWORD)BlockInfo.CompiledLocation == 0x60A7B73B)
|
||||
//if ((uint32_t)BlockInfo.CompiledLocation == 0x60A7B73B)
|
||||
//{
|
||||
// X86BreakPoint(__FILEW__,__LINE__);
|
||||
//}
|
||||
//MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock");
|
||||
//MoveConstToVariable((uint32_t)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock");
|
||||
}
|
||||
|
||||
if (g_System->bLinkBlocks())
|
||||
|
@ -737,7 +737,6 @@ bool CCodeBlock::Compile()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CCodeBlock::CompileExitCode()
|
||||
{
|
||||
for (EXIT_LIST::iterator ExitIter = m_ExitInfo.begin(); ExitIter != m_ExitInfo.end(); ExitIter++)
|
||||
|
@ -746,11 +745,13 @@ void CCodeBlock::CompileExitCode()
|
|||
CPU_Message(" $Exit_%d",ExitIter->ID);
|
||||
SetJump32(ExitIter->JumpLoc,(DWORD *)m_RecompPos);
|
||||
m_NextInstruction = ExitIter->NextInstruction;
|
||||
m_EnterSection->CompileExit((DWORD)-1, ExitIter->TargetPC,ExitIter->ExitRegSet,ExitIter->reason,true,NULL);
|
||||
m_EnterSection->CompileExit((uint32_t)-1, ExitIter->TargetPC,ExitIter->ExitRegSet,ExitIter->reason,true,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CCodeBlock::NextTest()
|
||||
uint32_t CCodeBlock::NextTest()
|
||||
{
|
||||
return InterlockedIncrement(&m_Test);
|
||||
uint32_t next_test = m_Test;
|
||||
m_Test += 1;
|
||||
return next_test;
|
||||
}
|
||||
|
|
|
@ -14,29 +14,29 @@ class CCodeBlock :
|
|||
private CRecompilerOps
|
||||
{
|
||||
public:
|
||||
CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos );
|
||||
CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos );
|
||||
~CCodeBlock();
|
||||
|
||||
bool Compile();
|
||||
|
||||
DWORD VAddrEnter() const { return m_VAddrEnter; }
|
||||
DWORD VAddrFirst() const { return m_VAddrFirst; }
|
||||
DWORD VAddrLast() const { return m_VAddrLast; }
|
||||
BYTE * CompiledLocation() const { return m_CompiledLocation; }
|
||||
int NoOfSections() const { return m_Sections.size(); }
|
||||
uint32_t VAddrEnter() const { return m_VAddrEnter; }
|
||||
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(); }
|
||||
const CCodeSection & EnterSection() const { return *m_EnterSection; }
|
||||
const MD5Digest & Hash() const { return m_Hash; }
|
||||
|
||||
void SetVAddrFirst(DWORD VAddr) { m_VAddrFirst = VAddr; }
|
||||
void SetVAddrLast(DWORD VAddr) { m_VAddrLast = VAddr; }
|
||||
void SetVAddrFirst(uint32_t VAddr) { m_VAddrFirst = VAddr; }
|
||||
void SetVAddrLast(uint32_t VAddr) { m_VAddrLast = VAddr; }
|
||||
|
||||
CCodeSection * ExistingSection(DWORD Addr) { return m_EnterSection->ExistingSection(Addr, NextTest()); }
|
||||
bool SectionAccessible(DWORD m_SectionID) { return m_EnterSection->SectionAccessible(m_SectionID, NextTest()); }
|
||||
CCodeSection * ExistingSection(uint32_t Addr) { return m_EnterSection->ExistingSection(Addr, NextTest()); }
|
||||
bool SectionAccessible(uint32_t m_SectionID) { return m_EnterSection->SectionAccessible(m_SectionID, NextTest()); }
|
||||
|
||||
QWORD MemContents(int i) const { return m_MemContents[i]; }
|
||||
QWORD * MemLocation(int i) const { return m_MemLocation[i]; }
|
||||
uint64_t MemContents(int32_t i) const { return m_MemContents[i]; }
|
||||
uint64_t * MemLocation(int32_t i) const { return m_MemLocation[i]; }
|
||||
|
||||
DWORD NextTest();
|
||||
uint32_t NextTest();
|
||||
|
||||
EXIT_LIST m_ExitInfo;
|
||||
|
||||
|
@ -51,23 +51,23 @@ private:
|
|||
bool CreateBlockLinkage ( CCodeSection * EnterSection );
|
||||
void DetermineLoops ();
|
||||
void LogSectionInfo ();
|
||||
bool SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, DWORD TargetPC, bool LinkAllowed, DWORD CurrentPC );
|
||||
bool AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot,
|
||||
bool SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC );
|
||||
bool AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot,
|
||||
bool & EndBlock, bool & PermLoop );
|
||||
|
||||
DWORD m_VAddrEnter;
|
||||
DWORD m_VAddrFirst; // the address of the first opcode in the block
|
||||
DWORD m_VAddrLast; // the address of the first opcode in the block
|
||||
BYTE* m_CompiledLocation; // What address is this compiled at
|
||||
uint32_t m_VAddrEnter;
|
||||
uint32_t m_VAddrFirst; // the address of the first opcode in the block
|
||||
uint32_t m_VAddrLast; // the address of the first opcode in the block
|
||||
uint8_t* m_CompiledLocation; // What address is this compiled at
|
||||
|
||||
typedef std::map<DWORD,CCodeSection *> SectionMap;
|
||||
typedef std::map<uint32_t,CCodeSection *> SectionMap;
|
||||
typedef std::list<CCodeSection *> SectionList;
|
||||
|
||||
SectionMap m_SectionMap;
|
||||
SectionList m_Sections;
|
||||
CCodeSection * m_EnterSection;
|
||||
long m_Test;
|
||||
int32_t m_Test;
|
||||
MD5Digest m_Hash;
|
||||
QWORD m_MemContents[2];
|
||||
QWORD * m_MemLocation[2];
|
||||
uint64_t m_MemContents[2];
|
||||
uint64_t * m_MemLocation[2];
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue