[Project64] Move Round model to RegBase
This commit is contained in:
parent
64a6cec068
commit
b04a170f0e
|
@ -13,7 +13,8 @@
|
||||||
|
|
||||||
CRegBase::CRegBase() :
|
CRegBase::CRegBase() :
|
||||||
m_CycleCount(0),
|
m_CycleCount(0),
|
||||||
m_Fpu_Used(false)
|
m_Fpu_Used(false),
|
||||||
|
m_RoundingModel(RoundUnknown)
|
||||||
{
|
{
|
||||||
for (int32_t i = 0; i < 32; i++)
|
for (int32_t i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
|
@ -56,6 +57,7 @@ CRegBase& CRegBase::operator=(const CRegBase& right)
|
||||||
memcpy(&m_MIPS_RegVal, &right.m_MIPS_RegVal, sizeof(m_MIPS_RegVal));
|
memcpy(&m_MIPS_RegVal, &right.m_MIPS_RegVal, sizeof(m_MIPS_RegVal));
|
||||||
m_CycleCount = right.m_CycleCount;
|
m_CycleCount = right.m_CycleCount;
|
||||||
m_Fpu_Used = right.m_Fpu_Used;
|
m_Fpu_Used = right.m_Fpu_Used;
|
||||||
|
m_RoundingModel = right.m_RoundingModel;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (*this != right)
|
if (*this != right)
|
||||||
{
|
{
|
||||||
|
@ -64,3 +66,17 @@ CRegBase& CRegBase::operator=(const CRegBase& right)
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char * CRegBase::RoundingModelName(FPU_ROUND RoundType)
|
||||||
|
{
|
||||||
|
switch (RoundType)
|
||||||
|
{
|
||||||
|
case RoundUnknown: return "RoundUnknown";
|
||||||
|
case RoundDefault: return "RoundDefault";
|
||||||
|
case RoundTruncate: return "RoundTruncate";
|
||||||
|
case RoundNearest: return "RoundNearest";
|
||||||
|
case RoundDown: return "RoundDown";
|
||||||
|
case RoundUp: return "RoundUp";
|
||||||
|
}
|
||||||
|
return "** Invalid **";
|
||||||
|
}
|
||||||
|
|
|
@ -35,42 +35,55 @@ public:
|
||||||
STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1
|
STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) { m_MIPS_RegState[GetMipsReg] = State; }
|
enum FPU_ROUND
|
||||||
REG_STATE GetMipsRegState(int32_t Reg) const { return m_MIPS_RegState[Reg]; }
|
{
|
||||||
|
RoundUnknown = -1,
|
||||||
|
RoundDefault = 0,
|
||||||
|
RoundTruncate = 1,
|
||||||
|
RoundNearest = 2,
|
||||||
|
RoundDown = 3,
|
||||||
|
RoundUp = 4,
|
||||||
|
};
|
||||||
|
|
||||||
bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); }
|
inline void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) { m_MIPS_RegState[GetMipsReg] = State; }
|
||||||
bool IsUnknown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); }
|
inline REG_STATE GetMipsRegState(int32_t Reg) const { return m_MIPS_RegState[Reg]; }
|
||||||
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)); }
|
inline bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); }
|
||||||
bool IsConst(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); }
|
inline bool IsUnknown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); }
|
||||||
|
inline bool IsModified(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); }
|
||||||
|
|
||||||
bool IsSigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); }
|
inline bool IsMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
|
||||||
bool IsUnsigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); }
|
inline bool IsConst(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); }
|
||||||
|
|
||||||
bool Is32Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); }
|
inline bool IsSigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); }
|
||||||
bool Is64Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); }
|
inline bool IsUnsigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == 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)); }
|
inline bool Is32Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); }
|
||||||
bool Is64BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
|
inline bool Is64Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); }
|
||||||
|
|
||||||
uint64_t GetMipsReg(int32_t Reg) const { return m_MIPS_RegVal[Reg].UDW; }
|
inline 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)); }
|
||||||
int64_t GetMipsReg_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].DW; }
|
inline bool Is64BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
|
||||||
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]; }
|
|
||||||
|
|
||||||
void SetMipsRegLo(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[0] = Value; }
|
inline uint64_t GetMipsReg(int32_t Reg) const { return m_MIPS_RegVal[Reg].UDW; }
|
||||||
void SetMipsRegHi(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[1] = Value; }
|
inline int64_t GetMipsReg_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].DW; }
|
||||||
void SetMipsReg(int32_t Reg, uint64_t Value) { m_MIPS_RegVal[Reg].UDW = Value; }
|
inline uint32_t GetMipsRegLo(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[0]; }
|
||||||
void SetMipsReg_S(int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; }
|
inline int32_t GetMipsRegLo_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[0]; }
|
||||||
|
inline uint32_t GetMipsRegHi(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[1]; }
|
||||||
|
inline int32_t GetMipsRegHi_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[1]; }
|
||||||
|
|
||||||
void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; }
|
inline void SetMipsRegLo(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[0] = Value; }
|
||||||
uint32_t GetBlockCycleCount() const { return m_CycleCount; }
|
inline void SetMipsRegHi(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[1] = Value; }
|
||||||
|
inline void SetMipsReg(int32_t Reg, uint64_t Value) { m_MIPS_RegVal[Reg].UDW = Value; }
|
||||||
|
inline void SetMipsReg_S(int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; }
|
||||||
|
|
||||||
void SetFpuBeenUsed(bool FpuUsed) { m_Fpu_Used = FpuUsed; }
|
inline void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; }
|
||||||
bool GetFpuBeenUsed() const { return m_Fpu_Used; }
|
inline uint32_t GetBlockCycleCount() const { return m_CycleCount; }
|
||||||
|
|
||||||
|
inline void SetFpuBeenUsed(bool FpuUsed) { m_Fpu_Used = FpuUsed; }
|
||||||
|
inline bool GetFpuBeenUsed() const { return m_Fpu_Used; }
|
||||||
|
|
||||||
|
inline FPU_ROUND GetRoundingModel() const { return m_RoundingModel; }
|
||||||
|
inline void SetRoundingModel(FPU_ROUND RoundingModel) { m_RoundingModel = RoundingModel; }
|
||||||
|
|
||||||
CRegBase& operator=(const CRegBase&);
|
CRegBase& operator=(const CRegBase&);
|
||||||
|
|
||||||
|
@ -78,8 +91,11 @@ public:
|
||||||
bool operator!=(const CRegBase& right) const;
|
bool operator!=(const CRegBase& right) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
const char * RoundingModelName(FPU_ROUND RoundType);
|
||||||
|
|
||||||
REG_STATE m_MIPS_RegState[32];
|
REG_STATE m_MIPS_RegState[32];
|
||||||
MIPS_DWORD m_MIPS_RegVal[32];
|
MIPS_DWORD m_MIPS_RegVal[32];
|
||||||
uint32_t m_CycleCount;
|
uint32_t m_CycleCount;
|
||||||
bool m_Fpu_Used;
|
bool m_Fpu_Used;
|
||||||
|
FPU_ROUND m_RoundingModel;
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,13 +26,9 @@ uint32_t CX86RegInfo::m_fpuControl = 0;
|
||||||
const char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" };
|
const char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" };
|
||||||
|
|
||||||
CX86RegInfo::CX86RegInfo() :
|
CX86RegInfo::CX86RegInfo() :
|
||||||
m_Stack_TopPos(0),
|
m_Stack_TopPos(0)
|
||||||
m_RoundingModel(RoundUnknown)
|
|
||||||
{
|
{
|
||||||
m_RegMapLo[0] = x86_Unknown;
|
for (int32_t i = 0; i < 32; i++)
|
||||||
m_RegMapHi[0] = x86_Unknown;
|
|
||||||
|
|
||||||
for (int32_t i = 1; i < 32; i++)
|
|
||||||
{
|
{
|
||||||
m_RegMapLo[i] = x86_Unknown;
|
m_RegMapLo[i] = x86_Unknown;
|
||||||
m_RegMapHi[i] = x86_Unknown;
|
m_RegMapHi[i] = x86_Unknown;
|
||||||
|
@ -65,7 +61,6 @@ CX86RegInfo& CX86RegInfo::operator=(const CX86RegInfo& right)
|
||||||
{
|
{
|
||||||
CRegBase::operator=(right);
|
CRegBase::operator=(right);
|
||||||
m_Stack_TopPos = right.m_Stack_TopPos;
|
m_Stack_TopPos = right.m_Stack_TopPos;
|
||||||
m_RoundingModel = right.m_RoundingModel;
|
|
||||||
|
|
||||||
memcpy(&m_RegMapLo, &right.m_RegMapLo, sizeof(m_RegMapLo));
|
memcpy(&m_RegMapLo, &right.m_RegMapLo, sizeof(m_RegMapLo));
|
||||||
memcpy(&m_RegMapHi, &right.m_RegMapHi, sizeof(m_RegMapHi));
|
memcpy(&m_RegMapHi, &right.m_RegMapHi, sizeof(m_RegMapHi));
|
||||||
|
@ -1461,18 +1456,4 @@ void CX86RegInfo::WriteBackRegisters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * CX86RegInfo::RoundingModelName(FPU_ROUND RoundType)
|
|
||||||
{
|
|
||||||
switch (RoundType)
|
|
||||||
{
|
|
||||||
case RoundUnknown: return "RoundUnknown";
|
|
||||||
case RoundDefault: return "RoundDefault";
|
|
||||||
case RoundTruncate: return "RoundTruncate";
|
|
||||||
case RoundNearest: return "RoundNearest";
|
|
||||||
case RoundDown: return "RoundDown";
|
|
||||||
case RoundUp: return "RoundUp";
|
|
||||||
}
|
|
||||||
return "** Invalid **";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -42,16 +42,6 @@ public:
|
||||||
FPU_Double = 4,
|
FPU_Double = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FPU_ROUND
|
|
||||||
{
|
|
||||||
RoundUnknown = -1,
|
|
||||||
RoundDefault = 0,
|
|
||||||
RoundTruncate = 1,
|
|
||||||
RoundNearest = 2,
|
|
||||||
RoundDown = 3,
|
|
||||||
RoundUp = 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CX86RegInfo();
|
CX86RegInfo();
|
||||||
CX86RegInfo(const CX86RegInfo&);
|
CX86RegInfo(const CX86RegInfo&);
|
||||||
|
@ -109,11 +99,7 @@ public:
|
||||||
FPU_STATE & FpuState(int32_t Reg) { return m_x86fpu_State[Reg]; }
|
FPU_STATE & FpuState(int32_t Reg) { return m_x86fpu_State[Reg]; }
|
||||||
FPU_ROUND & FpuRoundingModel(int32_t Reg) { return m_x86fpu_RoundingModel[Reg]; }
|
FPU_ROUND & FpuRoundingModel(int32_t Reg) { return m_x86fpu_RoundingModel[Reg]; }
|
||||||
|
|
||||||
FPU_ROUND GetRoundingModel() const { return m_RoundingModel; }
|
|
||||||
void SetRoundingModel(FPU_ROUND RoundingModel) { m_RoundingModel = RoundingModel; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char * RoundingModelName(FPU_ROUND RoundType);
|
|
||||||
x86Reg UnMap_8BitTempReg();
|
x86Reg UnMap_8BitTempReg();
|
||||||
|
|
||||||
//r4k
|
//r4k
|
||||||
|
@ -131,8 +117,6 @@ private:
|
||||||
bool m_x86fpu_StateChanged[8];
|
bool m_x86fpu_StateChanged[8];
|
||||||
FPU_ROUND m_x86fpu_RoundingModel[8];
|
FPU_ROUND m_x86fpu_RoundingModel[8];
|
||||||
|
|
||||||
FPU_ROUND m_RoundingModel;
|
|
||||||
|
|
||||||
static uint32_t m_fpuControl;
|
static uint32_t m_fpuControl;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue