[Project64] Get Reg Info.cpp to use standard types

This commit is contained in:
zilmar 2015-11-10 05:39:57 +11:00
parent d461ff34d9
commit c33e7e7958
2 changed files with 1408 additions and 1240 deletions

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,8 @@ class CRegInfo :
{ {
public: public:
//enums //enums
enum REG_STATE { enum REG_STATE
{
STATE_UNKNOWN = 0x00, STATE_UNKNOWN = 0x00,
STATE_KNOWN_VALUE = 0x01, STATE_KNOWN_VALUE = 0x01,
STATE_X86_MAPPED = 0x02, STATE_X86_MAPPED = 0x02,
@ -34,14 +35,16 @@ public:
STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1 STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1
}; };
enum REG_MAPPED { enum REG_MAPPED
{
NotMapped = 0, NotMapped = 0,
GPR_Mapped = 1, GPR_Mapped = 1,
Temp_Mapped = 2, Temp_Mapped = 2,
Stack_Mapped = 3, Stack_Mapped = 3,
}; };
enum FPU_STATE { enum FPU_STATE
{
FPU_Any = -1, FPU_Any = -1,
FPU_Unknown = 0, FPU_Unknown = 0,
FPU_Dword = 1, FPU_Dword = 1,
@ -50,7 +53,8 @@ public:
FPU_Double = 4, FPU_Double = 4,
}; };
enum FPU_ROUND { enum FPU_ROUND
{
RoundUnknown = -1, RoundUnknown = -1,
RoundDefault = 0, RoundDefault = 0,
RoundTruncate = 1, RoundTruncate = 1,
@ -58,6 +62,7 @@ public:
RoundDown = 3, RoundDown = 3,
RoundUp = 4, RoundUp = 4,
}; };
public: public:
CRegInfo(); CRegInfo();
CRegInfo(const CRegInfo&); CRegInfo(const CRegInfo&);
@ -68,82 +73,81 @@ public:
bool operator==(const CRegInfo& right) const; bool operator==(const CRegInfo& right) const;
bool operator!=(const CRegInfo& right) const; bool operator!=(const CRegInfo& right) const;
static REG_STATE ConstantsType ( __int64 Value ); static REG_STATE ConstantsType ( int64_t Value );
void FixRoundModel ( FPU_ROUND RoundMethod ); void FixRoundModel ( FPU_ROUND RoundMethod );
void ChangeFPURegFormat ( int Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel ); void ChangeFPURegFormat ( int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel );
void Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format); void Load_FPR_ToTop ( int32_t Reg, int32_t RegToLoad, FPU_STATE Format);
bool RegInStack ( int Reg, FPU_STATE Format ); bool RegInStack ( int32_t Reg, FPU_STATE Format );
void UnMap_AllFPRs (); void UnMap_AllFPRs ();
void UnMap_FPR ( int Reg, int WriteBackValue ); void UnMap_FPR ( int32_t Reg, bool WriteBackValue );
x86FpuValues StackPosition( int Reg ); x86FpuValues StackPosition( int32_t Reg );
x86Reg FreeX86Reg (); x86Reg FreeX86Reg ();
x86Reg Free8BitX86Reg (); x86Reg Free8BitX86Reg ();
void Map_GPR_32bit ( int MipsReg, bool SignValue, int MipsRegToLoad ); void Map_GPR_32bit ( int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad );
void Map_GPR_64bit ( int MipsReg, int MipsRegToLoad ); void Map_GPR_64bit ( int32_t MipsReg, int32_t MipsRegToLoad );
x86Reg Get_MemoryStack () const; x86Reg Get_MemoryStack () const;
x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true ); x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true );
x86Reg Map_TempReg ( x86Reg Reg, int MipsReg, bool LoadHiWord ); x86Reg Map_TempReg ( x86Reg Reg, int32_t MipsReg, bool LoadHiWord );
void ProtectGPR ( DWORD Reg ); void ProtectGPR ( uint32_t Reg );
void UnProtectGPR ( DWORD Reg ); void UnProtectGPR ( uint32_t Reg );
void ResetX86Protection (); void ResetX86Protection ();
x86Reg UnMap_TempReg (); x86Reg UnMap_TempReg ();
void UnMap_GPR ( DWORD Reg, bool WriteBackValue ); void UnMap_GPR ( uint32_t Reg, bool WriteBackValue );
bool UnMap_X86reg ( x86Reg Reg ); bool UnMap_X86reg ( x86Reg Reg );
void WriteBackRegisters (); void WriteBackRegisters ();
bool IsKnown(int Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); } bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); }
bool IsUnknown(int Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); } bool IsUnknown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); }
bool IsModified(int Reg) const { return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); } bool IsModified(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); }
bool IsMapped(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); } bool IsMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
bool IsConst(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); } bool IsConst(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); }
bool IsSigned(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); } bool IsSigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); }
bool IsUnsigned(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); } bool IsUnsigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); }
bool Is32Bit(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); } bool Is32Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); }
bool Is64Bit(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); } bool Is64Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); }
bool Is32BitMapped(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)); } 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(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | 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 ( int Reg ) const { return m_MIPS_RegState[Reg]; } REG_STATE GetMipsRegState ( int32_t Reg ) const { return m_MIPS_RegState[Reg]; }
unsigned __int64 GetMipsReg ( int Reg ) const { return m_MIPS_RegVal[Reg].UDW; } uint64_t GetMipsReg ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].UDW; }
__int64 GetMipsReg_S ( int Reg ) const { return m_MIPS_RegVal[Reg].DW; } int64_t GetMipsReg_S ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].DW; }
DWORD GetMipsRegLo ( int Reg ) const { return m_MIPS_RegVal[Reg].UW[0]; } uint32_t GetMipsRegLo ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].UW[0]; }
long GetMipsRegLo_S ( int Reg ) const { return m_MIPS_RegVal[Reg].W[0]; } int32_t GetMipsRegLo_S ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].W[0]; }
DWORD GetMipsRegHi ( int Reg ) const { return m_MIPS_RegVal[Reg].UW[1]; } uint32_t GetMipsRegHi ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].UW[1]; }
long GetMipsRegHi_S ( int Reg ) const { return m_MIPS_RegVal[Reg].W[1]; } int32_t GetMipsRegHi_S ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].W[1]; }
CX86Ops::x86Reg GetMipsRegMapLo ( int Reg ) const { return m_RegMapLo[Reg]; } CX86Ops::x86Reg GetMipsRegMapLo ( int32_t Reg ) const { return m_RegMapLo[Reg]; }
CX86Ops::x86Reg GetMipsRegMapHi ( int Reg ) const { return m_RegMapHi[Reg]; } CX86Ops::x86Reg GetMipsRegMapHi ( int32_t Reg ) const { return m_RegMapHi[Reg]; }
DWORD GetX86MapOrder ( x86Reg Reg ) const { return m_x86reg_MapOrder[Reg]; } uint32_t GetX86MapOrder ( x86Reg Reg ) const { return m_x86reg_MapOrder[Reg]; }
bool GetX86Protected ( x86Reg Reg ) const { return m_x86reg_Protected[Reg]; } bool GetX86Protected ( x86Reg Reg ) const { return m_x86reg_Protected[Reg]; }
REG_MAPPED GetX86Mapped ( x86Reg Reg ) const { return m_x86reg_MappedTo[Reg]; } REG_MAPPED GetX86Mapped ( x86Reg Reg ) const { return m_x86reg_MappedTo[Reg]; }
DWORD GetBlockCycleCount() const { return m_CycleCount; } uint32_t GetBlockCycleCount() const { return m_CycleCount; }
void SetMipsReg ( int Reg, unsigned __int64 Value ) { m_MIPS_RegVal[Reg].UDW = Value; } void SetMipsReg ( int32_t Reg, uint64_t Value ) { m_MIPS_RegVal[Reg].UDW = Value; }
void SetMipsReg_S ( int Reg, __int64 Value) { m_MIPS_RegVal[Reg].DW = Value; } void SetMipsReg_S ( int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; }
void SetMipsRegLo ( int Reg, DWORD Value ) { m_MIPS_RegVal[Reg].UW[0] = Value; } void SetMipsRegLo ( int32_t Reg, uint32_t Value ) { m_MIPS_RegVal[Reg].UW[0] = Value; }
void SetMipsRegHi ( int Reg, DWORD Value ) { m_MIPS_RegVal[Reg].UW[1] = Value; } void SetMipsRegHi ( int32_t Reg, uint32_t Value ) { m_MIPS_RegVal[Reg].UW[1] = Value; }
void SetMipsRegMapLo ( int GetMipsReg, x86Reg Reg ) { m_RegMapLo[GetMipsReg] = Reg; } void SetMipsRegMapLo ( int32_t GetMipsReg, x86Reg Reg ) { m_RegMapLo[GetMipsReg] = Reg; }
void SetMipsRegMapHi ( int GetMipsReg, x86Reg Reg ) { m_RegMapHi[GetMipsReg] = Reg; } void SetMipsRegMapHi ( int32_t GetMipsReg, x86Reg Reg ) { m_RegMapHi[GetMipsReg] = Reg; }
void SetMipsRegState ( int GetMipsReg, REG_STATE State ) { m_MIPS_RegState[GetMipsReg] = State; } void SetMipsRegState ( int32_t GetMipsReg, REG_STATE State ) { m_MIPS_RegState[GetMipsReg] = State; }
void SetX86MapOrder ( x86Reg Reg, DWORD Order ) { m_x86reg_MapOrder[Reg] = Order; } void SetX86MapOrder ( x86Reg Reg, uint32_t Order ) { m_x86reg_MapOrder[Reg] = Order; }
void SetX86Protected ( x86Reg Reg, bool Protected ) { m_x86reg_Protected[Reg] = Protected; } void SetX86Protected ( x86Reg Reg, bool Protected ) { m_x86reg_Protected[Reg] = Protected; }
void SetX86Mapped ( x86Reg Reg, REG_MAPPED Mapping ) { m_x86reg_MappedTo[Reg] = Mapping; } void SetX86Mapped ( x86Reg Reg, REG_MAPPED Mapping ) { m_x86reg_MappedTo[Reg] = Mapping; }
void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; }
void SetBlockCycleCount(DWORD CyleCount) { m_CycleCount = CyleCount; } int32_t & StackTopPos() { return m_Stack_TopPos; }
int32_t & FpuMappedTo(int32_t Reg) { return m_x86fpu_MappedTo[Reg]; }
int & StackTopPos() { return m_Stack_TopPos; } FPU_STATE & FpuState(int32_t Reg) { return m_x86fpu_State[Reg]; }
int & FpuMappedTo(int Reg) { return x86fpu_MappedTo[Reg]; } FPU_ROUND & FpuRoundingModel(int32_t Reg) { return m_x86fpu_RoundingModel[Reg]; }
FPU_STATE & FpuState(int Reg) { return x86fpu_State[Reg]; }
FPU_ROUND & FpuRoundingModel(int Reg) { return x86fpu_RoundingModel[Reg]; }
bool & FpuBeenUsed() { return m_Fpu_Used; } bool & FpuBeenUsed() { return m_Fpu_Used; }
FPU_ROUND GetRoundingModel() const { return m_RoundingModel; } FPU_ROUND GetRoundingModel() const { return m_RoundingModel; }
@ -160,20 +164,20 @@ private:
x86Reg m_RegMapLo[32]; x86Reg m_RegMapLo[32];
REG_MAPPED m_x86reg_MappedTo[10]; REG_MAPPED m_x86reg_MappedTo[10];
DWORD m_x86reg_MapOrder[10]; uint32_t m_x86reg_MapOrder[10];
bool m_x86reg_Protected[10]; bool m_x86reg_Protected[10];
DWORD m_CycleCount; uint32_t m_CycleCount;
//FPU //FPU
int m_Stack_TopPos; int32_t m_Stack_TopPos;
int x86fpu_MappedTo[8]; int32_t m_x86fpu_MappedTo[8];
FPU_STATE x86fpu_State[8]; FPU_STATE m_x86fpu_State[8];
bool x86fpu_StateChanged[8]; bool m_x86fpu_StateChanged[8];
FPU_ROUND x86fpu_RoundingModel[8]; FPU_ROUND m_x86fpu_RoundingModel[8];
bool m_Fpu_Used; bool m_Fpu_Used;
FPU_ROUND m_RoundingModel; FPU_ROUND m_RoundingModel;
static unsigned int m_fpuControl; static uint32_t m_fpuControl;
}; };