[Project64] Move Round model to RegBase
This commit is contained in:
parent
64a6cec068
commit
b04a170f0e
|
@ -13,7 +13,8 @@
|
|||
|
||||
CRegBase::CRegBase() :
|
||||
m_CycleCount(0),
|
||||
m_Fpu_Used(false)
|
||||
m_Fpu_Used(false),
|
||||
m_RoundingModel(RoundUnknown)
|
||||
{
|
||||
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));
|
||||
m_CycleCount = right.m_CycleCount;
|
||||
m_Fpu_Used = right.m_Fpu_Used;
|
||||
m_RoundingModel = right.m_RoundingModel;
|
||||
#ifdef _DEBUG
|
||||
if (*this != right)
|
||||
{
|
||||
|
@ -63,4 +65,18 @@ CRegBase& CRegBase::operator=(const CRegBase& right)
|
|||
}
|
||||
#endif
|
||||
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
|
||||
};
|
||||
|
||||
void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) { m_MIPS_RegState[GetMipsReg] = State; }
|
||||
REG_STATE GetMipsRegState(int32_t Reg) const { return m_MIPS_RegState[Reg]; }
|
||||
enum FPU_ROUND
|
||||
{
|
||||
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); }
|
||||
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); }
|
||||
inline void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) { m_MIPS_RegState[GetMipsReg] = State; }
|
||||
inline REG_STATE GetMipsRegState(int32_t Reg) const { return m_MIPS_RegState[Reg]; }
|
||||
|
||||
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); }
|
||||
inline bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); }
|
||||
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)); }
|
||||
bool IsUnsigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); }
|
||||
inline bool IsMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
|
||||
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)); }
|
||||
bool Is64Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); }
|
||||
inline bool IsSigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); }
|
||||
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)); }
|
||||
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 Is32Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); }
|
||||
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; }
|
||||
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]; }
|
||||
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)); }
|
||||
inline bool Is64BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); }
|
||||
|
||||
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 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; }
|
||||
inline uint64_t GetMipsReg(int32_t Reg) const { return m_MIPS_RegVal[Reg].UDW; }
|
||||
inline int64_t GetMipsReg_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].DW; }
|
||||
inline uint32_t GetMipsRegLo(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[0]; }
|
||||
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; }
|
||||
uint32_t GetBlockCycleCount() const { return m_CycleCount; }
|
||||
inline void SetMipsRegLo(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[0] = Value; }
|
||||
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; }
|
||||
bool GetFpuBeenUsed() const { return m_Fpu_Used; }
|
||||
inline void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; }
|
||||
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&);
|
||||
|
||||
|
@ -78,8 +91,11 @@ public:
|
|||
bool operator!=(const CRegBase& right) const;
|
||||
|
||||
protected:
|
||||
const char * RoundingModelName(FPU_ROUND RoundType);
|
||||
|
||||
REG_STATE m_MIPS_RegState[32];
|
||||
MIPS_DWORD m_MIPS_RegVal[32];
|
||||
uint32_t m_CycleCount;
|
||||
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" };
|
||||
|
||||
CX86RegInfo::CX86RegInfo() :
|
||||
m_Stack_TopPos(0),
|
||||
m_RoundingModel(RoundUnknown)
|
||||
m_Stack_TopPos(0)
|
||||
{
|
||||
m_RegMapLo[0] = x86_Unknown;
|
||||
m_RegMapHi[0] = x86_Unknown;
|
||||
|
||||
for (int32_t i = 1; i < 32; i++)
|
||||
for (int32_t i = 0; i < 32; i++)
|
||||
{
|
||||
m_RegMapLo[i] = x86_Unknown;
|
||||
m_RegMapHi[i] = x86_Unknown;
|
||||
|
@ -65,7 +61,6 @@ CX86RegInfo& CX86RegInfo::operator=(const CX86RegInfo& right)
|
|||
{
|
||||
CRegBase::operator=(right);
|
||||
m_Stack_TopPos = right.m_Stack_TopPos;
|
||||
m_RoundingModel = right.m_RoundingModel;
|
||||
|
||||
memcpy(&m_RegMapLo, &right.m_RegMapLo, sizeof(m_RegMapLo));
|
||||
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
|
|
@ -42,16 +42,6 @@ public:
|
|||
FPU_Double = 4,
|
||||
};
|
||||
|
||||
enum FPU_ROUND
|
||||
{
|
||||
RoundUnknown = -1,
|
||||
RoundDefault = 0,
|
||||
RoundTruncate = 1,
|
||||
RoundNearest = 2,
|
||||
RoundDown = 3,
|
||||
RoundUp = 4,
|
||||
};
|
||||
|
||||
public:
|
||||
CX86RegInfo();
|
||||
CX86RegInfo(const CX86RegInfo&);
|
||||
|
@ -109,11 +99,7 @@ public:
|
|||
FPU_STATE & FpuState(int32_t Reg) { return m_x86fpu_State[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:
|
||||
const char * RoundingModelName(FPU_ROUND RoundType);
|
||||
x86Reg UnMap_8BitTempReg();
|
||||
|
||||
//r4k
|
||||
|
@ -131,8 +117,6 @@ private:
|
|||
bool m_x86fpu_StateChanged[8];
|
||||
FPU_ROUND m_x86fpu_RoundingModel[8];
|
||||
|
||||
FPU_ROUND m_RoundingModel;
|
||||
|
||||
static uint32_t m_fpuControl;
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue