[Project64] Rename RegInfo.cpp to x86/x86/x86RegInfo.cpp

This commit is contained in:
zilmar 2016-06-27 21:49:15 +10:00
parent 53e5ec1866
commit b2bc2245d7
10 changed files with 273 additions and 253 deletions

View File

@ -43,6 +43,7 @@ LOCAL_SRC_FILES := \
$(SRCDIR)/N64System/Mips/TLBclass.cpp \
$(SRCDIR)/N64System/Recompiler/x86/x86RecompilerOps.cpp \
$(SRCDIR)/N64System/Recompiler/x86/x86ops.cpp \
$(SRCDIR)/N64System/Recompiler/x86/x86RegInfo.cpp \
$(SRCDIR)/N64System/Recompiler/LoopAnalysis.cpp \
$(SRCDIR)/N64System/Recompiler/CodeBlock.cpp \
$(SRCDIR)/N64System/Recompiler/SectionInfo.cpp \
@ -52,7 +53,6 @@ LOCAL_SRC_FILES := \
$(SRCDIR)/N64System/Recompiler/RecompilerCodeLog.cpp \
$(SRCDIR)/N64System/Recompiler/RecompilerMemory.cpp \
$(SRCDIR)/N64System/Recompiler/CodeSection.cpp \
$(SRCDIR)/N64System/Recompiler/RegInfo.cpp \
$(SRCDIR)/N64System/CheatClass.cpp \
$(SRCDIR)/N64System/FramePerSecondClass.cpp \
$(SRCDIR)/N64System/N64Class.cpp \

View File

@ -11,7 +11,8 @@
#include "stdafx.h"
#include <string.h>
#include <Project64-core/N64System/Recompiler/CodeBlock.h>
#include "RecompilerCodeLog.h"
#include <Project64-core/N64System/Recompiler/RecompilerCodeLog.h>
#include <Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/N64System/Mips/TranslateVaddr.h>
#include <Project64-core/N64System/N64Class.h>
@ -19,11 +20,11 @@
bool DelaySlotEffectsCompare (uint32_t PC, uint32_t Reg1, uint32_t Reg2);
CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos) :
CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * CompiledLocation) :
m_VAddrEnter(VAddrEnter),
m_VAddrFirst(VAddrEnter),
m_VAddrLast(VAddrEnter),
m_CompiledLocation(RecompPos),
m_CompiledLocation(CompiledLocation),
m_EnterSection(NULL),
m_Test(1)
{
@ -45,7 +46,6 @@ CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos) :
g_Notify->BreakPoint(__FILE__, __LINE__);
}
baseSection->m_ContinueSection = m_EnterSection;
m_EnterSection->AddParent(baseSection);
m_Sections.push_back(m_EnterSection);
m_SectionMap.insert(SectionMap::value_type(VAddrEnter,m_EnterSection));
@ -61,6 +61,7 @@ CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos) :
memset(m_MemLocation,0,sizeof(m_MemLocation));
memset(m_MemContents,0,sizeof(m_MemContents));
}
AnalyseBlock();
}
@ -726,11 +727,11 @@ bool CCodeBlock::Compile()
if (g_System->bLinkBlocks())
{
while (m_EnterSection->GenerateX86Code(NextTest()));
while (m_EnterSection->GenerateNativeCode(NextTest()));
}
else
{
if (!m_EnterSection->GenerateX86Code(NextTest()))
if (!m_EnterSection->GenerateNativeCode(NextTest()))
{
return false;
}

View File

@ -648,7 +648,7 @@ void CCodeSection::GenerateSectionLinkage()
for (i = 0; i < 2; i++)
{
if (JumpInfo[i]->FallThrough && !TargetSection[i]->GenerateX86Code(m_BlockInfo->NextTest()))
if (JumpInfo[i]->FallThrough && !TargetSection[i]->GenerateNativeCode(m_BlockInfo->NextTest()))
{
JumpInfo[i]->FallThrough = false;
JmpLabel32(JumpInfo[i]->BranchLabel.c_str(), 0);
@ -679,7 +679,7 @@ void CCodeSection::GenerateSectionLinkage()
}
if (TargetSection[i]->m_CompiledLocation == NULL)
{
TargetSection[i]->GenerateX86Code(m_BlockInfo->NextTest());
TargetSection[i]->GenerateNativeCode(m_BlockInfo->NextTest());
}
else
{
@ -1001,7 +1001,7 @@ g_Notify->BreakPoint(__FILE__, __LINE__);
}
}*/
bool CCodeSection::GenerateX86Code(uint32_t Test)
bool CCodeSection::GenerateNativeCode(uint32_t Test)
{
if (this == NULL) { return false; }
@ -1012,8 +1012,8 @@ bool CCodeSection::GenerateX86Code(uint32_t Test)
return false;
}
m_Test = Test;
if (m_ContinueSection->GenerateX86Code(Test)) { return true; }
if (m_JumpSection->GenerateX86Code(Test)) { return true; }
if (m_ContinueSection->GenerateNativeCode(Test)) { return true; }
if (m_JumpSection->GenerateNativeCode(Test)) { return true; }
return false;
}

View File

@ -27,7 +27,7 @@ public:
void SetJumpAddress(uint32_t JumpPC, uint32_t TargetPC, bool PermLoop);
void SetContinueAddress(uint32_t JumpPC, uint32_t TargetPC);
void CompileCop1Test();
bool GenerateX86Code(uint32_t Test);
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);

View File

@ -9,178 +9,7 @@
* *
****************************************************************************/
#pragma once
#include <Project64-core/Settings/DebugSettings.h>
#include <Project64-core/N64System/Mips/RegisterClass.h>
#include <Project64-core/N64System/Recompiler/x86/x86ops.h>
class CRegInfo :
private CDebugSettings,
private CX86Ops,
private CSystemRegisters
{
public:
//enums
enum REG_STATE
{
STATE_UNKNOWN = 0x00,
STATE_KNOWN_VALUE = 0x01,
STATE_X86_MAPPED = 0x02,
STATE_SIGN = 0x04,
STATE_32BIT = 0x08,
STATE_MODIFIED = 0x10,
#include <Project64-core/N64System/Recompiler/x86/x86RegInfo.h>
STATE_MAPPED_64 = (STATE_KNOWN_VALUE | STATE_X86_MAPPED), // = 3
STATE_MAPPED_32_ZERO = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT), // = 11
STATE_MAPPED_32_SIGN = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT | STATE_SIGN), // = 15
STATE_CONST_32_ZERO = (STATE_KNOWN_VALUE | STATE_32BIT), // = 9
STATE_CONST_32_SIGN = (STATE_KNOWN_VALUE | STATE_32BIT | STATE_SIGN), // = 13
STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1
};
enum REG_MAPPED
{
NotMapped = 0,
GPR_Mapped = 1,
Temp_Mapped = 2,
Stack_Mapped = 3,
};
enum FPU_STATE
{
FPU_Any = -1,
FPU_Unknown = 0,
FPU_Dword = 1,
FPU_Qword = 2,
FPU_Float = 3,
FPU_Double = 4,
};
enum FPU_ROUND
{
RoundUnknown = -1,
RoundDefault = 0,
RoundTruncate = 1,
RoundNearest = 2,
RoundDown = 3,
RoundUp = 4,
};
public:
CRegInfo();
CRegInfo(const CRegInfo&);
~CRegInfo();
CRegInfo& operator=(const CRegInfo&);
bool operator==(const CRegInfo& right) const;
bool operator!=(const CRegInfo& right) const;
static REG_STATE ConstantsType(int64_t Value);
void FixRoundModel(FPU_ROUND RoundMethod);
void ChangeFPURegFormat(int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel);
void Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Format);
bool RegInStack(int32_t Reg, FPU_STATE Format);
void UnMap_AllFPRs();
void UnMap_FPR(int32_t Reg, bool WriteBackValue);
x86FpuValues StackPosition(int32_t Reg);
x86Reg FreeX86Reg();
x86Reg Free8BitX86Reg();
void Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad);
void Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad);
x86Reg Get_MemoryStack() const;
x86Reg Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool LoadValue = true);
x86Reg Map_TempReg(x86Reg Reg, int32_t MipsReg, bool LoadHiWord);
void ProtectGPR(uint32_t Reg);
void UnProtectGPR(uint32_t Reg);
void ResetX86Protection();
x86Reg UnMap_TempReg();
void UnMap_GPR(uint32_t Reg, bool WriteBackValue);
bool UnMap_X86reg(x86Reg Reg);
void WriteBackRegisters();
bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); }
bool IsUnknown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); }
bool IsModified(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); }
bool IsMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
bool IsConst(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); }
bool IsSigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); }
bool IsUnsigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); }
bool Is32Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); }
bool Is64Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); }
bool Is32BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)); }
bool Is64BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
REG_STATE GetMipsRegState(int32_t Reg) const { return m_MIPS_RegState[Reg]; }
uint64_t GetMipsReg(int32_t Reg) const { return m_MIPS_RegVal[Reg].UDW; }
int64_t GetMipsReg_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].DW; }
uint32_t GetMipsRegLo(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[0]; }
int32_t GetMipsRegLo_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[0]; }
uint32_t GetMipsRegHi(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[1]; }
int32_t GetMipsRegHi_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[1]; }
CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg) const { return m_RegMapLo[Reg]; }
CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) const { return m_RegMapHi[Reg]; }
uint32_t GetX86MapOrder(x86Reg Reg) const { return m_x86reg_MapOrder[Reg]; }
bool GetX86Protected(x86Reg Reg) const { return m_x86reg_Protected[Reg]; }
REG_MAPPED GetX86Mapped(x86Reg Reg) const { return m_x86reg_MappedTo[Reg]; }
uint32_t GetBlockCycleCount() const { return m_CycleCount; }
void SetMipsReg(int32_t Reg, uint64_t Value) { m_MIPS_RegVal[Reg].UDW = Value; }
void SetMipsReg_S(int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; }
void SetMipsRegLo(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[0] = Value; }
void SetMipsRegHi(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[1] = Value; }
void SetMipsRegMapLo(int32_t GetMipsReg, x86Reg Reg) { m_RegMapLo[GetMipsReg] = Reg; }
void SetMipsRegMapHi(int32_t GetMipsReg, x86Reg Reg) { m_RegMapHi[GetMipsReg] = Reg; }
void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) { m_MIPS_RegState[GetMipsReg] = State; }
void SetX86MapOrder(x86Reg Reg, uint32_t Order) { m_x86reg_MapOrder[Reg] = Order; }
void SetX86Protected(x86Reg Reg, bool Protected) { m_x86reg_Protected[Reg] = Protected; }
void SetX86Mapped(x86Reg Reg, REG_MAPPED Mapping) { m_x86reg_MappedTo[Reg] = Mapping; }
void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; }
int32_t & StackTopPos() { return m_Stack_TopPos; }
int32_t & FpuMappedTo(int32_t Reg) { return m_x86fpu_MappedTo[Reg]; }
FPU_STATE & FpuState(int32_t Reg) { return m_x86fpu_State[Reg]; }
FPU_ROUND & FpuRoundingModel(int32_t Reg) { return m_x86fpu_RoundingModel[Reg]; }
bool & FpuBeenUsed() { return m_Fpu_Used; }
FPU_ROUND GetRoundingModel() const { return m_RoundingModel; }
void SetRoundingModel(FPU_ROUND RoundingModel) { m_RoundingModel = RoundingModel; }
private:
const char * RoundingModelName(FPU_ROUND RoundType);
x86Reg UnMap_8BitTempReg();
//r4k
REG_STATE m_MIPS_RegState[32];
MIPS_DWORD m_MIPS_RegVal[32];
x86Reg m_RegMapHi[32];
x86Reg m_RegMapLo[32];
REG_MAPPED m_x86reg_MappedTo[10];
uint32_t m_x86reg_MapOrder[10];
bool m_x86reg_Protected[10];
uint32_t m_CycleCount;
//FPU
int32_t m_Stack_TopPos;
int32_t m_x86fpu_MappedTo[8];
FPU_STATE m_x86fpu_State[8];
bool m_x86fpu_StateChanged[8];
FPU_ROUND m_x86fpu_RoundingModel[8];
bool m_Fpu_Used;
FPU_ROUND m_RoundingModel;
static uint32_t m_fpuControl;
};
typedef CX86RegInfo CRegInfo;

View File

@ -222,7 +222,7 @@ protected:
static STEP_TYPE m_NextInstruction;
static uint32_t m_CompilePC;
static OPCODE m_Opcode;
static CRegInfo m_RegWorkingSet;
static CX86RegInfo m_RegWorkingSet;
static uint32_t m_BranchCompare;
static CCodeSection * m_Section;

View File

@ -12,18 +12,18 @@
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/N64System/N64Class.h>
#include <Project64-core/N64System/Recompiler/RecompilerClass.h>
#include <Project64-core/N64System/Recompiler/RegInfo.h>
#include <Project64-core/N64System/Recompiler/RecompilerCodeLog.h>
#include <Project64-core/N64System/Recompiler/x86/x86RegInfo.h>
#include <stdio.h>
#include <string.h>
#include <float.h>
#include "RecompilerCodeLog.h"
uint32_t CRegInfo::m_fpuControl = 0;
uint32_t CX86RegInfo::m_fpuControl = 0;
const char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" };
CRegInfo::CRegInfo() :
CX86RegInfo::CX86RegInfo() :
m_CycleCount(0),
m_Stack_TopPos(0),
m_Fpu_Used(false),
@ -56,16 +56,16 @@ m_RoundingModel(RoundUnknown)
}
}
CRegInfo::CRegInfo(const CRegInfo& rhs)
CX86RegInfo::CX86RegInfo(const CX86RegInfo& rhs)
{
*this = rhs;
}
CRegInfo::~CRegInfo()
CX86RegInfo::~CX86RegInfo()
{
}
CRegInfo& CRegInfo::operator=(const CRegInfo& right)
CX86RegInfo& CX86RegInfo::operator=(const CX86RegInfo& right)
{
m_CycleCount = right.m_CycleCount;
m_Stack_TopPos = right.m_Stack_TopPos;
@ -94,7 +94,7 @@ CRegInfo& CRegInfo::operator=(const CRegInfo& right)
return *this;
}
bool CRegInfo::operator==(const CRegInfo& right) const
bool CX86RegInfo::operator==(const CX86RegInfo& right) const
{
int32_t count;
@ -133,19 +133,19 @@ bool CRegInfo::operator==(const CRegInfo& right) const
return true;
}
bool CRegInfo::operator!=(const CRegInfo& right) const
bool CX86RegInfo::operator!=(const CX86RegInfo& right) const
{
return !(right == *this);
}
CRegInfo::REG_STATE CRegInfo::ConstantsType(int64_t Value)
CX86RegInfo::REG_STATE CX86RegInfo::ConstantsType(int64_t Value)
{
if (((Value >> 32) == -1) && ((Value & 0x80000000) != 0)) { return STATE_CONST_32_SIGN; }
if (((Value >> 32) == 0) && ((Value & 0x80000000) == 0)) { return STATE_CONST_32_SIGN; }
return STATE_CONST_64;
}
void CRegInfo::FixRoundModel(FPU_ROUND RoundMethod)
void CX86RegInfo::FixRoundModel(FPU_ROUND RoundMethod)
{
if (GetRoundingModel() == RoundMethod)
{
@ -195,7 +195,7 @@ void CRegInfo::FixRoundModel(FPU_ROUND RoundMethod)
SetRoundingModel(RoundMethod);
}
void CRegInfo::ChangeFPURegFormat(int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel)
void CX86RegInfo::ChangeFPURegFormat(int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel)
{
for (uint32_t i = 0; i < 8; i++)
{
@ -224,7 +224,7 @@ void CRegInfo::ChangeFPURegFormat(int32_t Reg, FPU_STATE OldFormat, FPU_STATE Ne
}
}
void CRegInfo::Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Format)
void CX86RegInfo::Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Format)
{
if (GetRoundingModel() != RoundDefault)
{
@ -405,7 +405,7 @@ void CRegInfo::Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Format)
}
}
CRegInfo::x86FpuValues CRegInfo::StackPosition(int32_t Reg)
CX86RegInfo::x86FpuValues CX86RegInfo::StackPosition(int32_t Reg)
{
int32_t i;
@ -419,7 +419,7 @@ CRegInfo::x86FpuValues CRegInfo::StackPosition(int32_t Reg)
return x86_ST_Unknown;
}
CX86Ops::x86Reg CRegInfo::FreeX86Reg()
CX86Ops::x86Reg CX86RegInfo::FreeX86Reg()
{
if (GetX86Mapped(x86_EDI) == NotMapped && !GetX86Protected(x86_EDI)) { return x86_EDI; }
if (GetX86Mapped(x86_ESI) == NotMapped && !GetX86Protected(x86_ESI)) { return x86_ESI; }
@ -481,7 +481,7 @@ CX86Ops::x86Reg CRegInfo::FreeX86Reg()
return x86_Unknown;
}
CX86Ops::x86Reg CRegInfo::Free8BitX86Reg()
CX86Ops::x86Reg CX86RegInfo::Free8BitX86Reg()
{
if (GetX86Mapped(x86_EBX) == NotMapped && !GetX86Protected(x86_EBX)) { return x86_EBX; }
if (GetX86Mapped(x86_EAX) == NotMapped && !GetX86Protected(x86_EAX)) { return x86_EAX; }
@ -530,7 +530,7 @@ CX86Ops::x86Reg CRegInfo::Free8BitX86Reg()
return x86_Unknown;
}
CX86Ops::x86Reg CRegInfo::UnMap_8BitTempReg()
CX86Ops::x86Reg CX86RegInfo::UnMap_8BitTempReg()
{
int32_t count;
@ -542,7 +542,7 @@ CX86Ops::x86Reg CRegInfo::UnMap_8BitTempReg()
if (GetX86Protected((x86Reg)count) == false)
{
CPU_Message(" regcache: unallocate %s from temp storage", x86_Name((x86Reg)count));
SetX86Mapped((x86Reg)count, CRegInfo::NotMapped);
SetX86Mapped((x86Reg)count, CX86RegInfo::NotMapped);
return (x86Reg)count;
}
}
@ -550,7 +550,7 @@ CX86Ops::x86Reg CRegInfo::UnMap_8BitTempReg()
return x86_Unknown;
}
CRegInfo::x86Reg CRegInfo::Get_MemoryStack() const
CX86RegInfo::x86Reg CX86RegInfo::Get_MemoryStack() const
{
for (int32_t i = 0, n = sizeof(x86_Registers) / sizeof(x86_Registers[0]); i < n; i++)
{
@ -562,7 +562,7 @@ CRegInfo::x86Reg CRegInfo::Get_MemoryStack() const
return x86_Unknown;
}
CRegInfo::x86Reg CRegInfo::Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool LoadValue)
CX86RegInfo::x86Reg CX86RegInfo::Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool LoadValue)
{
x86Reg CurrentMap = Get_MemoryStack();
if (!bMapRegister)
@ -589,7 +589,7 @@ CRegInfo::x86Reg CRegInfo::Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool L
g_Notify->DisplayError("Map_MemoryStack\n\nOut of registers");
g_Notify->BreakPoint(__FILE__, __LINE__);
}
SetX86Mapped(Reg, CRegInfo::Stack_Mapped);
SetX86Mapped(Reg, CX86RegInfo::Stack_Mapped);
CPU_Message(" regcache: allocate %s as Memory Stack", x86_Name(Reg));
if (LoadValue)
{
@ -603,13 +603,13 @@ CRegInfo::x86Reg CRegInfo::Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool L
if (CurrentMap != x86_Unknown)
{
CPU_Message(" regcache: change allocation of Memory Stack from %s to %s", x86_Name(CurrentMap), x86_Name(Reg));
SetX86Mapped(Reg, CRegInfo::Stack_Mapped);
SetX86Mapped(CurrentMap, CRegInfo::NotMapped);
SetX86Mapped(Reg, CX86RegInfo::Stack_Mapped);
SetX86Mapped(CurrentMap, CX86RegInfo::NotMapped);
MoveX86RegToX86Reg(CurrentMap, Reg);
}
else
{
SetX86Mapped(Reg, CRegInfo::Stack_Mapped);
SetX86Mapped(Reg, CX86RegInfo::Stack_Mapped);
CPU_Message(" regcache: allocate %s as Memory Stack", x86_Name(Reg));
if (LoadValue)
{
@ -619,7 +619,7 @@ CRegInfo::x86Reg CRegInfo::Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool L
return Reg;
}
void CRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad)
void CX86RegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad)
{
int32_t count;
@ -691,7 +691,7 @@ void CRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsRegToL
SetMipsRegState(MipsReg, SignValue ? STATE_MAPPED_32_SIGN : STATE_MAPPED_32_ZERO);
}
void CRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad)
void CX86RegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad)
{
x86Reg x86Hi, x86lo;
int32_t count;
@ -820,7 +820,7 @@ void CRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad)
SetMipsRegState(MipsReg, STATE_MAPPED_64);
}
CX86Ops::x86Reg CRegInfo::Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, bool LoadHiWord)
CX86Ops::x86Reg CX86RegInfo::Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, bool LoadHiWord)
{
int32_t count;
@ -991,7 +991,7 @@ CX86Ops::x86Reg CRegInfo::Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, bool
return Reg;
}
void CRegInfo::ProtectGPR(uint32_t Reg)
void CX86RegInfo::ProtectGPR(uint32_t Reg)
{
if (IsUnknown(Reg) || IsConst(Reg))
{
@ -1004,7 +1004,7 @@ void CRegInfo::ProtectGPR(uint32_t Reg)
SetX86Protected(GetMipsRegMapLo(Reg), true);
}
void CRegInfo::UnProtectGPR(uint32_t Reg)
void CX86RegInfo::UnProtectGPR(uint32_t Reg)
{
if (IsUnknown(Reg) || IsConst(Reg))
{
@ -1017,7 +1017,7 @@ void CRegInfo::UnProtectGPR(uint32_t Reg)
SetX86Protected(GetMipsRegMapLo(Reg), false);
}
void CRegInfo::ResetX86Protection()
void CX86RegInfo::ResetX86Protection()
{
for (int32_t count = 0; count < 10; count++)
{
@ -1025,7 +1025,7 @@ void CRegInfo::ResetX86Protection()
}
}
bool CRegInfo::RegInStack(int32_t Reg, FPU_STATE Format)
bool CX86RegInfo::RegInStack(int32_t Reg, FPU_STATE Format)
{
for (int32_t i = 0; i < 8; i++)
{
@ -1041,7 +1041,7 @@ bool CRegInfo::RegInStack(int32_t Reg, FPU_STATE Format)
return false;
}
void CRegInfo::UnMap_AllFPRs()
void CX86RegInfo::UnMap_AllFPRs()
{
for (;;)
{
@ -1062,7 +1062,7 @@ void CRegInfo::UnMap_AllFPRs()
}
}
void CRegInfo::UnMap_FPR(int32_t Reg, bool WriteBackValue)
void CX86RegInfo::UnMap_FPR(int32_t Reg, bool WriteBackValue)
{
char Name[50];
int32_t i;
@ -1084,7 +1084,7 @@ void CRegInfo::UnMap_FPR(int32_t Reg, bool WriteBackValue)
}
else
{
CRegInfo::FPU_ROUND RoundingModel = FpuRoundingModel(StackTopPos());
CX86RegInfo::FPU_ROUND RoundingModel = FpuRoundingModel(StackTopPos());
FPU_STATE RegState = m_x86fpu_State[StackTopPos()];
bool Changed = m_x86fpu_StateChanged[StackTopPos()];
uint32_t MappedTo = m_x86fpu_MappedTo[StackTopPos()];
@ -1150,7 +1150,7 @@ void CRegInfo::UnMap_FPR(int32_t Reg, bool WriteBackValue)
}
}
void CRegInfo::UnMap_GPR(uint32_t Reg, bool WriteBackValue)
void CX86RegInfo::UnMap_GPR(uint32_t Reg, bool WriteBackValue)
{
if (Reg == 0)
{
@ -1229,7 +1229,7 @@ void CRegInfo::UnMap_GPR(uint32_t Reg, bool WriteBackValue)
SetMipsRegState(Reg, STATE_UNKNOWN);
}
CX86Ops::x86Reg CRegInfo::UnMap_TempReg()
CX86Ops::x86Reg CX86RegInfo::UnMap_TempReg()
{
CX86Ops::x86Reg Reg = x86_Unknown;
@ -1253,7 +1253,7 @@ CX86Ops::x86Reg CRegInfo::UnMap_TempReg()
return Reg;
}
bool CRegInfo::UnMap_X86reg(CX86Ops::x86Reg Reg)
bool CX86RegInfo::UnMap_X86reg(CX86Ops::x86Reg Reg)
{
int32_t count;
@ -1264,7 +1264,7 @@ bool CRegInfo::UnMap_X86reg(CX86Ops::x86Reg Reg)
return true;
}
}
else if (GetX86Mapped(Reg) == CRegInfo::GPR_Mapped)
else if (GetX86Mapped(Reg) == CX86RegInfo::GPR_Mapped)
{
for (count = 1; count < 32; count++)
{
@ -1293,7 +1293,7 @@ bool CRegInfo::UnMap_X86reg(CX86Ops::x86Reg Reg)
}
}
}
else if (GetX86Mapped(Reg) == CRegInfo::Temp_Mapped)
else if (GetX86Mapped(Reg) == CX86RegInfo::Temp_Mapped)
{
if (!GetX86Protected(Reg))
{
@ -1302,7 +1302,7 @@ bool CRegInfo::UnMap_X86reg(CX86Ops::x86Reg Reg)
return true;
}
}
else if (GetX86Mapped(Reg) == CRegInfo::Stack_Mapped)
else if (GetX86Mapped(Reg) == CX86RegInfo::Stack_Mapped)
{
CPU_Message(" regcache: unallocate %s from Memory Stack", x86_Name(Reg));
MoveX86regToVariable(Reg, &(g_Recompiler->MemoryStackPos()), "MemoryStack");
@ -1313,7 +1313,7 @@ bool CRegInfo::UnMap_X86reg(CX86Ops::x86Reg Reg)
return false;
}
void CRegInfo::WriteBackRegisters()
void CX86RegInfo::WriteBackRegisters()
{
UnMap_AllFPRs();
@ -1331,8 +1331,8 @@ void CRegInfo::WriteBackRegisters()
{
switch (GetMipsRegState(count))
{
case CRegInfo::STATE_UNKNOWN: break;
case CRegInfo::STATE_CONST_32_SIGN:
case CX86RegInfo::STATE_UNKNOWN: break;
case CX86RegInfo::STATE_CONST_32_SIGN:
if (!g_System->b32BitCore())
{
if (!bEdiZero && (!GetMipsRegLo(count) || !(GetMipsRegLo(count) & 0x80000000)))
@ -1384,9 +1384,9 @@ void CRegInfo::WriteBackRegisters()
MoveConstToVariable(GetMipsRegLo(count), &_GPR[count].UW[0], CRegName::GPR_Lo[count]);
}
SetMipsRegState(count, CRegInfo::STATE_UNKNOWN);
SetMipsRegState(count, CX86RegInfo::STATE_UNKNOWN);
break;
case CRegInfo::STATE_CONST_32_ZERO:
case CX86RegInfo::STATE_CONST_32_ZERO:
if (!g_System->b32BitCore())
{
if (!bEdiZero)
@ -1413,9 +1413,9 @@ void CRegInfo::WriteBackRegisters()
{
MoveConstToVariable(GetMipsRegLo(count), &_GPR[count].UW[0], CRegName::GPR_Lo[count]);
}
SetMipsRegState(count, CRegInfo::STATE_UNKNOWN);
SetMipsRegState(count, CX86RegInfo::STATE_UNKNOWN);
break;
case CRegInfo::STATE_CONST_64:
case CX86RegInfo::STATE_CONST_64:
if (GetMipsRegLo(count) == 0 || GetMipsRegHi(count) == 0)
{
XorX86RegToX86Reg(x86_EDI, x86_EDI);
@ -1452,7 +1452,7 @@ void CRegInfo::WriteBackRegisters()
{
MoveConstToVariable(GetMipsRegLo(count), &_GPR[count].UW[0], CRegName::GPR_Lo[count]);
}
SetMipsRegState(count, CRegInfo::STATE_UNKNOWN);
SetMipsRegState(count, CX86RegInfo::STATE_UNKNOWN);
break;
default:
CPU_Message("%s: Unknown State: %d reg %d (%s)", __FUNCTION__, GetMipsRegState(count), count, CRegName::GPR[count]);
@ -1461,7 +1461,7 @@ void CRegInfo::WriteBackRegisters()
}
}
const char * CRegInfo::RoundingModelName(FPU_ROUND RoundType)
const char * CX86RegInfo::RoundingModelName(FPU_ROUND RoundType)
{
switch (RoundType)
{

View File

@ -0,0 +1,186 @@
/****************************************************************************
* *
* 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/Settings/DebugSettings.h>
#include <Project64-core/N64System/Mips/RegisterClass.h>
#include <Project64-core/N64System/Recompiler/x86/x86ops.h>
class CX86RegInfo :
private CDebugSettings,
private CX86Ops,
private CSystemRegisters
{
public:
//enums
enum REG_STATE
{
STATE_UNKNOWN = 0x00,
STATE_KNOWN_VALUE = 0x01,
STATE_X86_MAPPED = 0x02,
STATE_SIGN = 0x04,
STATE_32BIT = 0x08,
STATE_MODIFIED = 0x10,
STATE_MAPPED_64 = (STATE_KNOWN_VALUE | STATE_X86_MAPPED), // = 3
STATE_MAPPED_32_ZERO = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT), // = 11
STATE_MAPPED_32_SIGN = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT | STATE_SIGN), // = 15
STATE_CONST_32_ZERO = (STATE_KNOWN_VALUE | STATE_32BIT), // = 9
STATE_CONST_32_SIGN = (STATE_KNOWN_VALUE | STATE_32BIT | STATE_SIGN), // = 13
STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1
};
enum REG_MAPPED
{
NotMapped = 0,
GPR_Mapped = 1,
Temp_Mapped = 2,
Stack_Mapped = 3,
};
enum FPU_STATE
{
FPU_Any = -1,
FPU_Unknown = 0,
FPU_Dword = 1,
FPU_Qword = 2,
FPU_Float = 3,
FPU_Double = 4,
};
enum FPU_ROUND
{
RoundUnknown = -1,
RoundDefault = 0,
RoundTruncate = 1,
RoundNearest = 2,
RoundDown = 3,
RoundUp = 4,
};
public:
CX86RegInfo();
CX86RegInfo(const CX86RegInfo&);
~CX86RegInfo();
CX86RegInfo& operator=(const CX86RegInfo&);
bool operator==(const CX86RegInfo& right) const;
bool operator!=(const CX86RegInfo& right) const;
static REG_STATE ConstantsType(int64_t Value);
void FixRoundModel(FPU_ROUND RoundMethod);
void ChangeFPURegFormat(int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel);
void Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Format);
bool RegInStack(int32_t Reg, FPU_STATE Format);
void UnMap_AllFPRs();
void UnMap_FPR(int32_t Reg, bool WriteBackValue);
x86FpuValues StackPosition(int32_t Reg);
x86Reg FreeX86Reg();
x86Reg Free8BitX86Reg();
void Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad);
void Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad);
x86Reg Get_MemoryStack() const;
x86Reg Map_MemoryStack(x86Reg Reg, bool bMapRegister, bool LoadValue = true);
x86Reg Map_TempReg(x86Reg Reg, int32_t MipsReg, bool LoadHiWord);
void ProtectGPR(uint32_t Reg);
void UnProtectGPR(uint32_t Reg);
void ResetX86Protection();
x86Reg UnMap_TempReg();
void UnMap_GPR(uint32_t Reg, bool WriteBackValue);
bool UnMap_X86reg(x86Reg Reg);
void WriteBackRegisters();
bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); }
bool IsUnknown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); }
bool IsModified(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); }
bool IsMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
bool IsConst(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); }
bool IsSigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); }
bool IsUnsigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); }
bool Is32Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); }
bool Is64Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); }
bool Is32BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)); }
bool Is64BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
REG_STATE GetMipsRegState(int32_t Reg) const { return m_MIPS_RegState[Reg]; }
uint64_t GetMipsReg(int32_t Reg) const { return m_MIPS_RegVal[Reg].UDW; }
int64_t GetMipsReg_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].DW; }
uint32_t GetMipsRegLo(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[0]; }
int32_t GetMipsRegLo_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[0]; }
uint32_t GetMipsRegHi(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[1]; }
int32_t GetMipsRegHi_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[1]; }
CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg) const { return m_RegMapLo[Reg]; }
CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) const { return m_RegMapHi[Reg]; }
uint32_t GetX86MapOrder(x86Reg Reg) const { return m_x86reg_MapOrder[Reg]; }
bool GetX86Protected(x86Reg Reg) const { return m_x86reg_Protected[Reg]; }
REG_MAPPED GetX86Mapped(x86Reg Reg) const { return m_x86reg_MappedTo[Reg]; }
uint32_t GetBlockCycleCount() const { return m_CycleCount; }
void SetMipsReg(int32_t Reg, uint64_t Value) { m_MIPS_RegVal[Reg].UDW = Value; }
void SetMipsReg_S(int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; }
void SetMipsRegLo(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[0] = Value; }
void SetMipsRegHi(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[1] = Value; }
void SetMipsRegMapLo(int32_t GetMipsReg, x86Reg Reg) { m_RegMapLo[GetMipsReg] = Reg; }
void SetMipsRegMapHi(int32_t GetMipsReg, x86Reg Reg) { m_RegMapHi[GetMipsReg] = Reg; }
void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) { m_MIPS_RegState[GetMipsReg] = State; }
void SetX86MapOrder(x86Reg Reg, uint32_t Order) { m_x86reg_MapOrder[Reg] = Order; }
void SetX86Protected(x86Reg Reg, bool Protected) { m_x86reg_Protected[Reg] = Protected; }
void SetX86Mapped(x86Reg Reg, REG_MAPPED Mapping) { m_x86reg_MappedTo[Reg] = Mapping; }
void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; }
int32_t & StackTopPos() { return m_Stack_TopPos; }
int32_t & FpuMappedTo(int32_t Reg) { return m_x86fpu_MappedTo[Reg]; }
FPU_STATE & FpuState(int32_t Reg) { return m_x86fpu_State[Reg]; }
FPU_ROUND & FpuRoundingModel(int32_t Reg) { return m_x86fpu_RoundingModel[Reg]; }
bool & FpuBeenUsed() { return m_Fpu_Used; }
FPU_ROUND GetRoundingModel() const { return m_RoundingModel; }
void SetRoundingModel(FPU_ROUND RoundingModel) { m_RoundingModel = RoundingModel; }
private:
const char * RoundingModelName(FPU_ROUND RoundType);
x86Reg UnMap_8BitTempReg();
//r4k
REG_STATE m_MIPS_RegState[32];
MIPS_DWORD m_MIPS_RegVal[32];
x86Reg m_RegMapHi[32];
x86Reg m_RegMapLo[32];
REG_MAPPED m_x86reg_MappedTo[10];
uint32_t m_x86reg_MapOrder[10];
bool m_x86reg_Protected[10];
uint32_t m_CycleCount;
//FPU
int32_t m_Stack_TopPos;
int32_t m_x86fpu_MappedTo[8];
FPU_STATE m_x86fpu_State[8];
bool m_x86fpu_StateChanged[8];
FPU_ROUND m_x86fpu_RoundingModel[8];
bool m_Fpu_Used;
FPU_ROUND m_RoundingModel;
static uint32_t m_fpuControl;
};

View File

@ -74,10 +74,10 @@
<ClCompile Include="N64System\Recompiler\RecompilerClass.cpp" />
<ClCompile Include="N64System\Recompiler\RecompilerCodeLog.cpp" />
<ClCompile Include="N64System\Recompiler\RecompilerMemory.cpp" />
<ClCompile Include="N64System\Recompiler\RegInfo.cpp" />
<ClCompile Include="N64System\Recompiler\SectionInfo.cpp" />
<ClCompile Include="N64System\Recompiler\x86\x86ops.cpp" />
<ClCompile Include="N64System\Recompiler\x86\x86RecompilerOps.cpp" />
<ClCompile Include="N64System\Recompiler\x86\x86RegInfo.cpp" />
<ClCompile Include="N64System\SpeedLimiterClass.cpp" />
<ClCompile Include="N64System\SystemGlobals.cpp" />
<ClCompile Include="Plugins\AudioPlugin.cpp" />
@ -174,6 +174,7 @@
<ClInclude Include="N64System\Recompiler\X86ops.h" />
<ClInclude Include="N64System\Recompiler\x86\x86ops.h" />
<ClInclude Include="N64System\Recompiler\x86\x86RecompilerOps.h" />
<ClInclude Include="N64System\Recompiler\x86\x86RegInfo.h" />
<ClInclude Include="N64System\SpeedLimiterClass.h" />
<ClInclude Include="N64System\SystemGlobals.h" />
<ClInclude Include="Notification.h" />

View File

@ -237,9 +237,6 @@
<ClCompile Include="N64System\Recompiler\RecompilerMemory.cpp">
<Filter>Source Files\N64 System\Recompiler</Filter>
</ClCompile>
<ClCompile Include="N64System\Recompiler\RegInfo.cpp">
<Filter>Source Files\N64 System\Recompiler</Filter>
</ClCompile>
<ClCompile Include="N64System\Recompiler\SectionInfo.cpp">
<Filter>Source Files\N64 System\Recompiler</Filter>
</ClCompile>
@ -324,6 +321,9 @@
<ClCompile Include="N64System\Recompiler\x86\x86ops.cpp">
<Filter>Source Files\N64 System\Recompiler\x86</Filter>
</ClCompile>
<ClCompile Include="N64System\Recompiler\x86\x86RegInfo.cpp">
<Filter>Source Files\N64 System\Recompiler\x86</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@ -623,5 +623,8 @@
<ClInclude Include="N64System\Recompiler\x86\x86ops.h">
<Filter>Header Files\N64 System\Recompiler\x86</Filter>
</ClInclude>
<ClInclude Include="N64System\Recompiler\x86\x86RegInfo.h">
<Filter>Header Files\N64 System\Recompiler\x86</Filter>
</ClInclude>
</ItemGroup>
</Project>