2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project 64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2010-05-30 01:54:42 +00:00
|
|
|
#include "stdafx.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
CJumpInfo::CJumpInfo()
|
|
|
|
{
|
|
|
|
TargetPC = (DWORD)-1;
|
2010-10-23 18:53:01 +00:00
|
|
|
JumpPC = (DWORD)-1;
|
2008-09-18 03:15:49 +00:00
|
|
|
BranchLabel = "";
|
|
|
|
LinkLocation = NULL;
|
|
|
|
LinkLocation2 = NULL;
|
|
|
|
FallThrough = false;
|
|
|
|
PermLoop = false;
|
|
|
|
DoneDelaySlot = false;
|
|
|
|
}
|
|
|
|
|
2010-05-30 01:54:42 +00:00
|
|
|
#ifdef tofix
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-25 09:15:19 +00:00
|
|
|
bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, DWORD Test)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
if (IgnoreIfCompiled && Parent->CompiledLocation != NULL) { return true; }
|
|
|
|
if (!InLoop) { return false; }
|
|
|
|
if (!Parent->InLoop) { return false; }
|
|
|
|
if (Parent->ParentSection.empty()) { return false; }
|
|
|
|
if (this == Parent) { return true; }
|
|
|
|
if (Parent->Test == Test) { return true; }
|
|
|
|
Parent->Test = Test;
|
|
|
|
|
|
|
|
for (SECTION_LIST::iterator iter = Parent->ParentSection.begin(); iter != Parent->ParentSection.end(); iter++)
|
|
|
|
{
|
2010-05-25 09:15:19 +00:00
|
|
|
CCodeSection * ParentSection = *iter;
|
2008-09-18 03:15:49 +00:00
|
|
|
if (!IsAllParentLoops(ParentSection,IgnoreIfCompiled,Test)) { return false; }
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-25 09:15:19 +00:00
|
|
|
void CCodeSection::UnlinkParent( CCodeSection * Parent, bool AllowDelete, bool ContinueSection )
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
if (this == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION_LIST::iterator iter = ParentSection.begin();
|
|
|
|
while ( iter != ParentSection.end())
|
|
|
|
{
|
2010-05-25 09:15:19 +00:00
|
|
|
CCodeSection * ParentIter = *iter;
|
2008-09-18 03:15:49 +00:00
|
|
|
if (ParentIter == Parent && (Parent->ContinueSection != this || Parent->JumpSection != this))
|
|
|
|
{
|
|
|
|
ParentSection.erase(iter);
|
|
|
|
iter = ParentSection.begin();
|
|
|
|
} else {
|
|
|
|
iter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (Parent->ContinueSection != Parent->JumpSection)
|
|
|
|
// {
|
|
|
|
// if (!ContinueSection && Parent->ContinueSection == this)
|
|
|
|
// {
|
2012-11-17 00:58:31 +00:00
|
|
|
// g_Notify->BreakPoint(__FILE__,__LINE__);
|
2008-09-18 03:15:49 +00:00
|
|
|
// }
|
|
|
|
// }
|
|
|
|
if (ContinueSection && Parent->ContinueSection == this)
|
|
|
|
{
|
|
|
|
Parent->ContinueSection = NULL;
|
|
|
|
}
|
|
|
|
// if (Parent->ContinueSection != Parent->JumpSection)
|
|
|
|
// {
|
|
|
|
// if (ContinueSection && Parent->JumpSection == this)
|
|
|
|
// {
|
2012-11-17 00:58:31 +00:00
|
|
|
// g_Notify->BreakPoint(__FILE__,__LINE__);
|
2008-09-18 03:15:49 +00:00
|
|
|
// }
|
|
|
|
// }
|
|
|
|
if (!ContinueSection && Parent->JumpSection == this)
|
|
|
|
{
|
|
|
|
Parent->JumpSection = NULL;
|
|
|
|
}
|
|
|
|
if (AllowDelete)
|
|
|
|
{
|
|
|
|
bool KillMe = true;
|
|
|
|
for (SECTION_LIST::iterator iter = ParentSection.begin(); iter != ParentSection.end(); iter++)
|
|
|
|
{
|
|
|
|
if (!IsAllParentLoops(*iter,false,GetNewTestValue()))
|
|
|
|
{
|
|
|
|
KillMe = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (KillMe)
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-25 09:15:19 +00:00
|
|
|
CCodeSection::~CCodeSection ( void )
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
while (ParentSection.size() > 0)
|
|
|
|
{
|
2010-05-25 09:15:19 +00:00
|
|
|
CCodeSection * Parent = *ParentSection.begin();
|
2008-09-18 03:15:49 +00:00
|
|
|
if (Parent->ContinueSection == this) { UnlinkParent(Parent, false, true); }
|
|
|
|
if (Parent->JumpSection == this) { UnlinkParent(Parent, false, false); }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ContinueSection)
|
|
|
|
{
|
|
|
|
ContinueSection->UnlinkParent(this, true, true);
|
|
|
|
if (ContinueSection)
|
|
|
|
{
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->BreakPoint(__FILE__,__LINE__);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
ContinueSection = NULL;
|
|
|
|
}
|
|
|
|
if (JumpSection)
|
|
|
|
{
|
|
|
|
JumpSection->UnlinkParent(this, true, false);
|
|
|
|
if (JumpSection)
|
|
|
|
{
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->BreakPoint(__FILE__,__LINE__);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
JumpSection = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-25 09:15:19 +00:00
|
|
|
DWORD CCodeSection::GetNewTestValue(void)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
static DWORD LastTest = 0;
|
|
|
|
if (LastTest == 0xFFFFFFFF) { LastTest = 0; }
|
|
|
|
LastTest += 1;
|
|
|
|
return LastTest;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CRegInfo::Initilize ( void )
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
|
|
|
MIPS_RegState[0] = STATE_CONST_32;
|
|
|
|
MIPS_RegVal[0].DW = 0;
|
|
|
|
for (count = 1; count < 32; count ++ ) {
|
|
|
|
MIPS_RegState[count] = STATE_UNKNOWN;
|
|
|
|
MIPS_RegVal[count].DW = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
for (count = 0; count < 10; count ++ ) {
|
|
|
|
x86reg_MappedTo[count] = NotMapped;
|
|
|
|
x86reg_Protected[count] = false;
|
|
|
|
x86reg_MapOrder[count] = 0;
|
|
|
|
}
|
|
|
|
CycleCount = 0;
|
|
|
|
RandomModifier = 0;
|
|
|
|
|
|
|
|
Stack_TopPos = 0;
|
|
|
|
for (count = 0; count < 8; count ++ ) {
|
|
|
|
x86fpu_MappedTo[count] = -1;
|
|
|
|
x86fpu_State[count] = FPU_Unkown;
|
|
|
|
x86fpu_RoundingModel[count] = RoundDefault;
|
|
|
|
}
|
|
|
|
Fpu_Used = false;
|
|
|
|
RoundingModel = RoundUnknown;
|
|
|
|
}
|
|
|
|
|
2010-05-30 01:54:42 +00:00
|
|
|
#endif
|
|
|
|
|