Merge pull request #10064 from lioncash/regs

Gekko: Migrate register structs over to Common::BitField
This commit is contained in:
Léo Lam 2021-08-30 23:19:17 +02:00 committed by GitHub
commit 271612f328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 221 additions and 256 deletions

View File

@ -350,16 +350,14 @@ union UGQR
// XER // XER
union UReg_XER union UReg_XER
{ {
struct BitField<0, 7, u32> BYTE_COUNT;
{ BitField<7, 1, u32> reserved_1;
u32 BYTE_COUNT : 7; BitField<8, 8, u32> BYTE_CMP;
u32 : 1; BitField<16, 13, u32> reserved_2;
u32 BYTE_CMP : 8; BitField<29, 1, u32> CA;
u32 : 13; BitField<30, 1, u32> OV;
u32 CA : 1; BitField<31, 1, u32> SO;
u32 OV : 1;
u32 SO : 1;
};
u32 Hex = 0; u32 Hex = 0;
UReg_XER() = default; UReg_XER() = default;
@ -369,29 +367,27 @@ union UReg_XER
// Machine State Register // Machine State Register
union UReg_MSR union UReg_MSR
{ {
struct BitField<0, 1, u32> LE;
{ BitField<1, 1, u32> RI;
u32 LE : 1; BitField<2, 1, u32> PM;
u32 RI : 1; BitField<3, 1, u32> reserved_1;
u32 PM : 1; BitField<4, 1, u32> DR;
u32 : 1; // res28 BitField<5, 1, u32> IR;
u32 DR : 1; BitField<6, 1, u32> IP;
u32 IR : 1; BitField<7, 1, u32> reserved_2;
u32 IP : 1; BitField<8, 1, u32> FE1;
u32 : 1; // res24 BitField<9, 1, u32> BE;
u32 FE1 : 1; BitField<10, 1, u32> SE;
u32 BE : 1; BitField<11, 1, u32> FE0;
u32 SE : 1; BitField<12, 1, u32> MCHECK;
u32 FE0 : 1; BitField<13, 1, u32> FP;
u32 MCHECK : 1; BitField<14, 1, u32> PR;
u32 FP : 1; BitField<15, 1, u32> EE;
u32 PR : 1; BitField<16, 1, u32> ILE;
u32 EE : 1; BitField<17, 1, u32> reserved_3;
u32 ILE : 1; BitField<18, 1, u32> POW;
u32 : 1; // res14 BitField<19, 13, u32> reserved_4;
u32 POW : 1;
u32 res : 13;
};
u32 Hex = 0; u32 Hex = 0;
UReg_MSR() = default; UReg_MSR() = default;
@ -433,64 +429,62 @@ enum FPSCRExceptionFlag : u32
// Floating Point Status and Control Register // Floating Point Status and Control Register
union UReg_FPSCR union UReg_FPSCR
{ {
struct // Rounding mode (towards: nearest, zero, +inf, -inf)
{ BitField<0, 2, FPURoundMode::RoundMode> RN;
// Rounding mode (towards: nearest, zero, +inf, -inf) // Non-IEEE mode enable (aka flush-to-zero)
FPURoundMode::RoundMode RN : 2; BitField<2, 1, u32> NI;
// Non-IEEE mode enable (aka flush-to-zero) // Inexact exception enable
u32 NI : 1; BitField<3, 1, u32> XE;
// Inexact exception enable // IEEE division by zero exception enable
u32 XE : 1; BitField<4, 1, u32> ZE;
// IEEE division by zero exception enable // IEEE underflow exception enable
u32 ZE : 1; BitField<5, 1, u32> UE;
// IEEE underflow exception enable // IEEE overflow exception enable
u32 UE : 1; BitField<6, 1, u32> OE;
// IEEE overflow exception enable // Invalid operation exception enable
u32 OE : 1; BitField<7, 1, u32> VE;
// Invalid operation exception enable // Invalid operation exception for integer conversion (sticky)
u32 VE : 1; BitField<8, 1, u32> VXCVI;
// Invalid operation exception for integer conversion (sticky) // Invalid operation exception for square root (sticky)
u32 VXCVI : 1; BitField<9, 1, u32> VXSQRT;
// Invalid operation exception for square root (sticky) // Invalid operation exception for software request (sticky)
u32 VXSQRT : 1; BitField<10, 1, u32> VXSOFT;
// Invalid operation exception for software request (sticky) // reserved
u32 VXSOFT : 1; BitField<11, 1, u32> reserved;
// reserved // Floating point result flags (includes FPCC) (not sticky)
u32 : 1; // from more to less significand: class, <, >, =, ?
// Floating point result flags (includes FPCC) (not sticky) BitField<12, 5, u32> FPRF;
// from more to less significand: class, <, >, =, ? // Fraction inexact (not sticky)
u32 FPRF : 5; BitField<17, 1, u32> FI;
// Fraction inexact (not sticky) // Fraction rounded (not sticky)
u32 FI : 1; BitField<18, 1, u32> FR;
// Fraction rounded (not sticky) // Invalid operation exception for invalid comparison (sticky)
u32 FR : 1; BitField<19, 1, u32> VXVC;
// Invalid operation exception for invalid comparison (sticky) // Invalid operation exception for inf * 0 (sticky)
u32 VXVC : 1; BitField<20, 1, u32> VXIMZ;
// Invalid operation exception for inf * 0 (sticky) // Invalid operation exception for 0 / 0 (sticky)
u32 VXIMZ : 1; BitField<21, 1, u32> VXZDZ;
// Invalid operation exception for 0 / 0 (sticky) // Invalid operation exception for inf / inf (sticky)
u32 VXZDZ : 1; BitField<22, 1, u32> VXIDI;
// Invalid operation exception for inf / inf (sticky) // Invalid operation exception for inf - inf (sticky)
u32 VXIDI : 1; BitField<23, 1, u32> VXISI;
// Invalid operation exception for inf - inf (sticky) // Invalid operation exception for SNaN (sticky)
u32 VXISI : 1; BitField<24, 1, u32> VXSNAN;
// Invalid operation exception for SNaN (sticky) // Inexact exception (sticky)
u32 VXSNAN : 1; BitField<25, 1, u32> XX;
// Inexact exception (sticky) // Division by zero exception (sticky)
u32 XX : 1; BitField<26, 1, u32> ZX;
// Division by zero exception (sticky) // Underflow exception (sticky)
u32 ZX : 1; BitField<27, 1, u32> UX;
// Underflow exception (sticky) // Overflow exception (sticky)
u32 UX : 1; BitField<28, 1, u32> OX;
// Overflow exception (sticky) // Invalid operation exception summary (not sticky)
u32 OX : 1; BitField<29, 1, u32> VX;
// Invalid operation exception summary (not sticky) // Enabled exception summary (not sticky)
u32 VX : 1; BitField<30, 1, u32> FEX;
// Enabled exception summary (not sticky) // Exception summary (sticky)
u32 FEX : 1; BitField<31, 1, u32> FX;
// Exception summary (sticky)
u32 FX : 1;
};
u32 Hex = 0; u32 Hex = 0;
// The FPSCR's 20th bit (11th from a little endian perspective) // The FPSCR's 20th bit (11th from a little endian perspective)
@ -535,62 +529,58 @@ union UReg_FPSCR
// Hardware Implementation-Dependent Register 0 // Hardware Implementation-Dependent Register 0
union UReg_HID0 union UReg_HID0
{ {
struct BitField<0, 1, u32> NOOPTI;
{ BitField<1, 1, u32> reserved_1;
u32 NOOPTI : 1; BitField<2, 1, u32> BHT;
u32 : 1; BitField<3, 1, u32> ABE;
u32 BHT : 1; BitField<4, 1, u32> reserved_2;
u32 ABE : 1; BitField<5, 1, u32> BTIC;
u32 : 1; BitField<6, 1, u32> DCFA;
u32 BTIC : 1; BitField<7, 1, u32> SGE;
u32 DCFA : 1; BitField<8, 1, u32> IFEM;
u32 SGE : 1; BitField<9, 1, u32> SPD;
u32 IFEM : 1; BitField<10, 1, u32> DCFI;
u32 SPD : 1; BitField<11, 1, u32> ICFI;
u32 DCFI : 1; BitField<12, 1, u32> DLOCK;
u32 ICFI : 1; BitField<13, 1, u32> ILOCK;
u32 DLOCK : 1; BitField<14, 1, u32> DCE;
u32 ILOCK : 1; BitField<15, 1, u32> ICE;
u32 DCE : 1; BitField<16, 1, u32> NHR;
u32 ICE : 1; BitField<17, 3, u32> reserved_3;
u32 NHR : 1; BitField<20, 1, u32> DPM;
u32 : 3; BitField<21, 1, u32> SLEEP;
u32 DPM : 1; BitField<22, 1, u32> NAP;
u32 SLEEP : 1; BitField<23, 1, u32> DOZE;
u32 NAP : 1; BitField<24, 1, u32> PAR;
u32 DOZE : 1; BitField<25, 1, u32> ECLK;
u32 PAR : 1; BitField<26, 1, u32> reserved_4;
u32 ECLK : 1; BitField<27, 1, u32> BCLK;
u32 : 1; BitField<28, 1, u32> EBD;
u32 BCLK : 1; BitField<29, 1, u32> EBA;
u32 EBD : 1; BitField<30, 1, u32> DBP;
u32 EBA : 1; BitField<31, 1, u32> EMCP;
u32 DBP : 1;
u32 EMCP : 1;
};
u32 Hex = 0; u32 Hex = 0;
}; };
// Hardware Implementation-Dependent Register 2 // Hardware Implementation-Dependent Register 2
union UReg_HID2 union UReg_HID2
{ {
struct BitField<0, 16, u32> reserved;
{ BitField<16, 1, u32> DQOEE;
u32 : 16; BitField<17, 1, u32> DCMEE;
u32 DQOEE : 1; BitField<18, 1, u32> DNCEE;
u32 DCMEE : 1; BitField<19, 1, u32> DCHEE;
u32 DNCEE : 1; BitField<20, 1, u32> DQOERR;
u32 DCHEE : 1; BitField<21, 1, u32> DCMERR;
u32 DQOERR : 1; BitField<22, 1, u32> DNCERR;
u32 DCMERR : 1; BitField<23, 1, u32> DCHERR;
u32 DNCERR : 1; BitField<24, 4, u32> DMAQL;
u32 DCHERR : 1; BitField<28, 1, u32> LCE;
u32 DMAQL : 4; BitField<29, 1, u32> PSE;
u32 LCE : 1; BitField<30, 1, u32> WPE;
u32 PSE : 1; BitField<31, 1, u32> LSQE;
u32 WPE : 1;
u32 LSQE : 1;
};
u32 Hex = 0; u32 Hex = 0;
UReg_HID2() = default; UReg_HID2() = default;
@ -600,83 +590,73 @@ union UReg_HID2
// Hardware Implementation-Dependent Register 4 // Hardware Implementation-Dependent Register 4
union UReg_HID4 union UReg_HID4
{ {
struct BitField<0, 20, u32> reserved_1;
{ BitField<20, 1, u32> L2CFI;
u32 : 20; BitField<21, 1, u32> L2MUM;
u32 L2CFI : 1; BitField<22, 1, u32> DBP;
u32 L2MUM : 1; BitField<23, 1, u32> LPE;
u32 DBP : 1; BitField<24, 1, u32> ST0;
u32 LPE : 1; BitField<25, 1, u32> SBE;
u32 ST0 : 1; BitField<26, 1, u32> reserved_2;
u32 SBE : 1; BitField<27, 2, u32> BPD;
u32 : 1; BitField<29, 2, u32> L2FM;
u32 BPD : 2; BitField<31, 1, u32> reserved_3;
u32 L2FM : 2;
u32 : 1;
};
u32 Hex = 0; u32 Hex = 0;
UReg_HID4() = default; UReg_HID4() = default;
explicit UReg_HID4(u32 hex_) : Hex{hex_} {} explicit UReg_HID4(u32 hex_) : Hex{hex_} {}
}; };
// SPR1 - Page Table format // SDR1 - Page Table format
union UReg_SPR1 union UReg_SDR1
{ {
u32 Hex; BitField<0, 16, u32> htaborg;
struct BitField<16, 7, u32> reserved;
{ BitField<23, 9, u32> htabmask;
u32 htaborg : 16;
u32 : 7; u32 Hex = 0;
u32 htabmask : 9;
};
}; };
// MMCR0 - Monitor Mode Control Register 0 format // MMCR0 - Monitor Mode Control Register 0 format
union UReg_MMCR0 union UReg_MMCR0
{ {
u32 Hex; BitField<0, 6, u32> PMC2SELECT;
struct BitField<6, 7, u32> PMC1SELECT;
{ BitField<13, 1, u32> PMCTRIGGER;
u32 PMC2SELECT : 6; BitField<14, 1, u32> PMCINTCONTROL;
u32 PMC1SELECT : 7; BitField<15, 1, u32> PMC1INTCONTROL;
u32 PMCTRIGGER : 1; BitField<16, 6, u32> THRESHOLD;
u32 PMCINTCONTROL : 1; BitField<22, 1, u32> INTONBITTRANS;
u32 PMC1INTCONTROL : 1; BitField<23, 2, u32> RTCSELECT;
u32 THRESHOLD : 6; BitField<25, 1, u32> DISCOUNT;
u32 INTONBITTRANS : 1; BitField<26, 1, u32> ENINT;
u32 RTCSELECT : 2; BitField<27, 1, u32> DMR;
u32 DISCOUNT : 1; BitField<28, 1, u32> DMS;
u32 ENINT : 1; BitField<29, 1, u32> DU;
u32 DMR : 1; BitField<30, 1, u32> DP;
u32 DMS : 1; BitField<31, 1, u32> DIS;
u32 DU : 1;
u32 DP : 1; u32 Hex = 0;
u32 DIS : 1;
};
}; };
// MMCR1 - Monitor Mode Control Register 1 format // MMCR1 - Monitor Mode Control Register 1 format
union UReg_MMCR1 union UReg_MMCR1
{ {
u32 Hex; BitField<0, 22, u32> reserved;
struct BitField<22, 5, u32> PMC4SELECT;
{ BitField<27, 5, u32> PMC3SELECT;
u32 : 22;
u32 PMC4SELECT : 5; u32 Hex = 0;
u32 PMC3SELECT : 5;
};
}; };
// Write Pipe Address Register // Write Pipe Address Register
union UReg_WPAR union UReg_WPAR
{ {
struct BitField<0, 1, u32> BNE;
{ BitField<1, 4, u32> reserved;
u32 BNE : 1; BitField<5, 27, u32> GB_ADDR;
u32 : 4;
u32 GB_ADDR : 27;
};
u32 Hex = 0; u32 Hex = 0;
UReg_WPAR() = default; UReg_WPAR() = default;
@ -686,11 +666,9 @@ union UReg_WPAR
// Direct Memory Access Upper register // Direct Memory Access Upper register
union UReg_DMAU union UReg_DMAU
{ {
struct BitField<0, 5, u32> DMA_LEN_U;
{ BitField<5, 27, u32> MEM_ADDR;
u32 DMA_LEN_U : 5;
u32 MEM_ADDR : 27;
};
u32 Hex = 0; u32 Hex = 0;
UReg_DMAU() = default; UReg_DMAU() = default;
@ -700,14 +678,12 @@ union UReg_DMAU
// Direct Memory Access Lower (DMAL) register // Direct Memory Access Lower (DMAL) register
union UReg_DMAL union UReg_DMAL
{ {
struct BitField<0, 1, u32> DMA_F;
{ BitField<1, 1, u32> DMA_T;
u32 DMA_F : 1; BitField<2, 2, u32> DMA_LEN_L;
u32 DMA_T : 1; BitField<4, 1, u32> DMA_LD;
u32 DMA_LEN_L : 2; BitField<5, 27, u32> LC_ADDR;
u32 DMA_LD : 1;
u32 LC_ADDR : 27;
};
u32 Hex = 0; u32 Hex = 0;
UReg_DMAL() = default; UReg_DMAL() = default;
@ -716,14 +692,12 @@ union UReg_DMAL
union UReg_BAT_Up union UReg_BAT_Up
{ {
struct BitField<0, 1, u32> VP;
{ BitField<1, 1, u32> VS;
u32 VP : 1; BitField<2, 11, u32> BL; // Block length (aka block size mask)
u32 VS : 1; BitField<13, 4, u32> reserved;
u32 BL : 11; // Block length (aka block size mask) BitField<17, 15, u32> BEPI;
u32 : 4;
u32 BEPI : 15;
};
u32 Hex = 0; u32 Hex = 0;
UReg_BAT_Up() = default; UReg_BAT_Up() = default;
@ -732,14 +706,12 @@ union UReg_BAT_Up
union UReg_BAT_Lo union UReg_BAT_Lo
{ {
struct BitField<0, 2, u32> PP;
{ BitField<2, 1, u32> reserved_1;
u32 PP : 2; BitField<3, 4, u32> WIMG;
u32 : 1; BitField<7, 10, u32> reserved_2;
u32 WIMG : 4; BitField<17, 15, u32> BRPN; // Physical Block Number
u32 : 10;
u32 BRPN : 15; // Physical Block Number
};
u32 Hex = 0; u32 Hex = 0;
UReg_BAT_Lo() = default; UReg_BAT_Lo() = default;
@ -748,16 +720,14 @@ union UReg_BAT_Lo
union UReg_THRM12 union UReg_THRM12
{ {
struct BitField<0, 1, u32> V; // Valid
{ BitField<1, 1, u32> TIE; // Thermal Interrupt Enable
u32 V : 1; // Valid BitField<2, 1, u32> TID; // Thermal Interrupt Direction
u32 TIE : 1; // Thermal Interrupt Enable BitField<3, 20, u32> reserved;
u32 TID : 1; // Thermal Interrupt Direction BitField<23, 7, u32> THRESHOLD; // Temperature Threshold, 0-127°C
u32 : 20; BitField<30, 1, u32> TIV; // Thermal Interrupt Valid
u32 THRESHOLD : 7; // Temperature Threshold, 0-127°C BitField<31, 1, u32> TIN; // Thermal Interrupt
u32 TIV : 1; // Thermal Interrupt Valid
u32 TIN : 1; // Thermal Interrupt
};
u32 Hex = 0; u32 Hex = 0;
UReg_THRM12() = default; UReg_THRM12() = default;
@ -766,12 +736,10 @@ union UReg_THRM12
union UReg_THRM3 union UReg_THRM3
{ {
struct BitField<0, 1, u32> E; // Enable
{ BitField<1, 13, u32> SITV; // Sample Interval Timer Value
u32 E : 1; // Enable BitField<14, 18, u32> reserved;
u32 SITV : 13; // Sample Interval Timer Value
u32 : 18;
};
u32 Hex = 0; u32 Hex = 0;
UReg_THRM3() = default; UReg_THRM3() = default;
@ -780,20 +748,17 @@ union UReg_THRM3
union UReg_PTE union UReg_PTE
{ {
struct BitField<0, 6, u64> API;
{ BitField<6, 1, u64> H;
u64 API : 6; BitField<7, 24, u64> VSID;
u64 H : 1; BitField<31, 1, u64> V;
u64 VSID : 24; BitField<32, 2, u64> PP;
u64 V : 1; BitField<34, 1, u64> reserved_1;
u64 PP : 2; BitField<35, 4, u64> WIMG;
u64 : 1; BitField<39, 1, u64> C;
u64 WIMG : 4; BitField<40, 1, u64> R;
u64 C : 1; BitField<41, 3, u64> reserved_2;
u64 R : 1; BitField<44, 20, u64> RPN;
u64 : 3;
u64 RPN : 20;
};
u64 Hex = 0; u64 Hex = 0;
u32 Hex32[2]; u32 Hex32[2];

View File

@ -226,7 +226,7 @@ void Interpreter::fcmpu(UGeckoInstruction inst)
void Interpreter::fctiwx(UGeckoInstruction inst) void Interpreter::fctiwx(UGeckoInstruction inst)
{ {
ConvertToInteger(inst, static_cast<RoundingMode>(FPSCR.RN)); ConvertToInteger(inst, static_cast<RoundingMode>(FPSCR.RN.Value()));
} }
void Interpreter::fctiwzx(UGeckoInstruction inst) void Interpreter::fctiwzx(UGeckoInstruction inst)