Change the QGR union over to a BitField union.
Makes it easier to generate a QGR in my unit test, cleaner overall of course.
This commit is contained in:
parent
9f2d4ee53e
commit
9d7598266f
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Common/BitField.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
|
||||||
// --- Gekko Instruction ---
|
// --- Gekko Instruction ---
|
||||||
|
@ -300,25 +301,28 @@ union UGeckoInstruction
|
||||||
// --- Gekko Special Registers ---
|
// --- Gekko Special Registers ---
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// quantize types
|
||||||
|
enum EQuantizeType : u32
|
||||||
|
{
|
||||||
|
QUANTIZE_FLOAT = 0,
|
||||||
|
QUANTIZE_U8 = 4,
|
||||||
|
QUANTIZE_U16 = 5,
|
||||||
|
QUANTIZE_S8 = 6,
|
||||||
|
QUANTIZE_S16 = 7,
|
||||||
|
};
|
||||||
|
|
||||||
// GQR Register
|
// GQR Register
|
||||||
union UGQR
|
union UGQR
|
||||||
{
|
{
|
||||||
|
BitField< 0, 3, EQuantizeType> st_type;
|
||||||
|
BitField< 8, 6, u32> st_scale;
|
||||||
|
BitField<16, 3, EQuantizeType> ld_type;
|
||||||
|
BitField<24, 6, u32> ld_scale;
|
||||||
|
|
||||||
u32 Hex;
|
u32 Hex;
|
||||||
struct
|
|
||||||
{
|
|
||||||
u32 ST_TYPE : 3;
|
|
||||||
u32 : 5;
|
|
||||||
u32 ST_SCALE : 6;
|
|
||||||
u32 : 2;
|
|
||||||
u32 LD_TYPE : 3;
|
|
||||||
u32 : 5;
|
|
||||||
u32 LD_SCALE : 6;
|
|
||||||
u32 : 2;
|
|
||||||
};
|
|
||||||
|
|
||||||
UGQR(u32 _hex) { Hex = _hex; }
|
UGQR(u32 _hex) { Hex = _hex; }
|
||||||
UGQR() {Hex = 0; }
|
UGQR() { Hex = 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// FPU Register
|
// FPU Register
|
||||||
|
@ -721,17 +725,6 @@ union UReg_PTE
|
||||||
// --- Gekko Types and Defs ---
|
// --- Gekko Types and Defs ---
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
// quantize types
|
|
||||||
enum EQuantizeType
|
|
||||||
{
|
|
||||||
QUANTIZE_FLOAT = 0,
|
|
||||||
QUANTIZE_U8 = 4,
|
|
||||||
QUANTIZE_U16 = 5,
|
|
||||||
QUANTIZE_S8 = 6,
|
|
||||||
QUANTIZE_S16 = 7,
|
|
||||||
};
|
|
||||||
|
|
||||||
// branches
|
// branches
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,10 +136,11 @@ float Interpreter::Helper_Dequantize(const u32 _Addr, const EQuantizeType _quant
|
||||||
void Interpreter::psq_l(UGeckoInstruction _inst)
|
void Interpreter::psq_l(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
|
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
|
||||||
const EQuantizeType ldType = static_cast<EQuantizeType>(gqr.LD_TYPE);
|
const EQuantizeType ldType = gqr.ld_type;
|
||||||
const unsigned int ldScale = gqr.LD_SCALE;
|
const unsigned int ldScale = gqr.ld_scale;
|
||||||
const u32 EA = _inst.RA ?
|
const u32 EA = _inst.RA ?
|
||||||
(m_GPR[_inst.RA] + _inst.SIMM_12) : (u32)_inst.SIMM_12;
|
(m_GPR[_inst.RA] + _inst.SIMM_12) : (u32)_inst.SIMM_12;
|
||||||
|
printf("psq_l at offset %d\n", _inst.SIMM_12);
|
||||||
|
|
||||||
int c = 4;
|
int c = 4;
|
||||||
if (ldType == QUANTIZE_U8 || ldType == QUANTIZE_S8)
|
if (ldType == QUANTIZE_U8 || ldType == QUANTIZE_S8)
|
||||||
|
@ -173,8 +174,8 @@ void Interpreter::psq_l(UGeckoInstruction _inst)
|
||||||
void Interpreter::psq_lu(UGeckoInstruction _inst)
|
void Interpreter::psq_lu(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
|
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
|
||||||
const EQuantizeType ldType = static_cast<EQuantizeType>(gqr.LD_TYPE);
|
const EQuantizeType ldType = gqr.ld_type;
|
||||||
const unsigned int ldScale = gqr.LD_SCALE;
|
const unsigned int ldScale = gqr.ld_scale;
|
||||||
const u32 EA = m_GPR[_inst.RA] + _inst.SIMM_12;
|
const u32 EA = m_GPR[_inst.RA] + _inst.SIMM_12;
|
||||||
|
|
||||||
int c = 4;
|
int c = 4;
|
||||||
|
@ -210,8 +211,8 @@ void Interpreter::psq_lu(UGeckoInstruction _inst)
|
||||||
void Interpreter::psq_st(UGeckoInstruction _inst)
|
void Interpreter::psq_st(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
|
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
|
||||||
const EQuantizeType stType = static_cast<EQuantizeType>(gqr.ST_TYPE);
|
const EQuantizeType stType = gqr.st_type;
|
||||||
const unsigned int stScale = gqr.ST_SCALE;
|
const unsigned int stScale = gqr.st_scale;
|
||||||
const u32 EA = _inst.RA ?
|
const u32 EA = _inst.RA ?
|
||||||
(m_GPR[_inst.RA] + _inst.SIMM_12) : (u32)_inst.SIMM_12;
|
(m_GPR[_inst.RA] + _inst.SIMM_12) : (u32)_inst.SIMM_12;
|
||||||
|
|
||||||
|
@ -235,8 +236,8 @@ void Interpreter::psq_st(UGeckoInstruction _inst)
|
||||||
void Interpreter::psq_stu(UGeckoInstruction _inst)
|
void Interpreter::psq_stu(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
|
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
|
||||||
const EQuantizeType stType = static_cast<EQuantizeType>(gqr.ST_TYPE);
|
const EQuantizeType stType = gqr.st_type;
|
||||||
const unsigned int stScale = gqr.ST_SCALE;
|
const unsigned int stScale = gqr.st_scale;
|
||||||
const u32 EA = m_GPR[_inst.RA] + _inst.SIMM_12;
|
const u32 EA = m_GPR[_inst.RA] + _inst.SIMM_12;
|
||||||
|
|
||||||
int c = 4;
|
int c = 4;
|
||||||
|
@ -264,8 +265,8 @@ void Interpreter::psq_stu(UGeckoInstruction _inst)
|
||||||
void Interpreter::psq_lx(UGeckoInstruction _inst)
|
void Interpreter::psq_lx(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
|
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
|
||||||
const EQuantizeType ldType = static_cast<EQuantizeType>(gqr.LD_TYPE);
|
const EQuantizeType ldType = gqr.ld_type;
|
||||||
const unsigned int ldScale = gqr.LD_SCALE;
|
const unsigned int ldScale = gqr.ld_scale;
|
||||||
const u32 EA = _inst.RA ? (m_GPR[_inst.RA] + m_GPR[_inst.RB]) : m_GPR[_inst.RB];
|
const u32 EA = _inst.RA ? (m_GPR[_inst.RA] + m_GPR[_inst.RB]) : m_GPR[_inst.RB];
|
||||||
|
|
||||||
int c = 4;
|
int c = 4;
|
||||||
|
@ -305,8 +306,8 @@ void Interpreter::psq_lx(UGeckoInstruction _inst)
|
||||||
void Interpreter::psq_stx(UGeckoInstruction _inst)
|
void Interpreter::psq_stx(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
|
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
|
||||||
const EQuantizeType stType = static_cast<EQuantizeType>(gqr.ST_TYPE);
|
const EQuantizeType stType = gqr.st_type;
|
||||||
const unsigned int stScale = gqr.ST_SCALE;
|
const unsigned int stScale = gqr.st_scale;
|
||||||
const u32 EA = _inst.RA ? (m_GPR[_inst.RA] + m_GPR[_inst.RB]) : m_GPR[_inst.RB];
|
const u32 EA = _inst.RA ? (m_GPR[_inst.RA] + m_GPR[_inst.RB]) : m_GPR[_inst.RB];
|
||||||
|
|
||||||
int c = 4;
|
int c = 4;
|
||||||
|
@ -329,8 +330,8 @@ void Interpreter::psq_stx(UGeckoInstruction _inst)
|
||||||
void Interpreter::psq_lux(UGeckoInstruction _inst)
|
void Interpreter::psq_lux(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
|
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
|
||||||
const EQuantizeType ldType = static_cast<EQuantizeType>(gqr.LD_TYPE);
|
const EQuantizeType ldType = gqr.ld_type;
|
||||||
const unsigned int ldScale = gqr.LD_SCALE;
|
const unsigned int ldScale = gqr.ld_scale;
|
||||||
const u32 EA = m_GPR[_inst.RA] + m_GPR[_inst.RB];
|
const u32 EA = m_GPR[_inst.RA] + m_GPR[_inst.RB];
|
||||||
|
|
||||||
int c = 4;
|
int c = 4;
|
||||||
|
@ -366,8 +367,8 @@ void Interpreter::psq_lux(UGeckoInstruction _inst)
|
||||||
void Interpreter::psq_stux(UGeckoInstruction _inst)
|
void Interpreter::psq_stux(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
|
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
|
||||||
const EQuantizeType stType = static_cast<EQuantizeType>(gqr.ST_TYPE);
|
const EQuantizeType stType = gqr.st_type;
|
||||||
const unsigned int stScale = gqr.ST_SCALE;
|
const unsigned int stScale = gqr.st_scale;
|
||||||
const u32 EA = m_GPR[_inst.RA] + m_GPR[_inst.RB];
|
const u32 EA = m_GPR[_inst.RA] + m_GPR[_inst.RB];
|
||||||
|
|
||||||
int c = 4;
|
int c = 4;
|
||||||
|
|
Loading…
Reference in New Issue