1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-01-31 12:31:45 +01:00

SPU analyser: internal spu_itype optimization

Use only 1 byte for instruction type.
Flags are transformed into range comparisons.
This commit is contained in:
Nekotekina 2019-05-02 19:25:00 +03:00
parent 15bd3b8724
commit 54dc617f39

View File

@ -3,20 +3,16 @@
// SPU Instruction Type // SPU Instruction Type
struct spu_itype struct spu_itype
{ {
enum static constexpr struct memory_tag{} memory{}; // Memory Load/Store Instructions
{ static constexpr struct constant_tag{} constant{}; // Constant Formation Instructions
memory = 1 << 8, // Memory Load/Store Instructions static constexpr struct integer_tag{} integer{}; // Integer and Logical Instructions
constant = 1 << 9, // Constant Formation Instructions static constexpr struct shiftrot_tag{} shiftrot{}; // Shift and Rotate Instructions
integer = 1 << 10, // Integer and Logical Instructions static constexpr struct compare_tag{} compare{}; // Compare Instructions
shiftrot = 1 << 11, // Shift and Rotate Instructions static constexpr struct branch_tag{} branch{}; // Branch Instructions
compare = 1 << 12, // Compare Instructions static constexpr struct floating_tag{} floating{}; // Floating-Point Instructions
branch = 1 << 13, // Branch Instructions static constexpr struct quadrop_tag{} _quadrop{}; // 4-op Instructions
floating = 1 << 14, // Floating-Point Instructions
_quadrop = 1 << 15, // 4-op Instructions enum type : unsigned char
};
enum type
{ {
UNK = 0, UNK = 0,
@ -43,16 +39,33 @@ struct spu_itype
RCHCNT, RCHCNT,
WRCH, WRCH,
LQD = memory, BR, // branch_tag first
BRA,
BRNZ,
BRZ,
BRHNZ,
BRHZ,
BRSL,
BRASL,
IRET,
BI,
BISLED,
BISL,
BIZ,
BINZ,
BIHZ,
BIHNZ, // branch_tag last
LQD, // memory_tag first
LQX, LQX,
LQA, LQA,
LQR, LQR,
STQD, STQD,
STQX, STQX,
STQA, STQA,
STQR, STQR, // memory_tag last
CBD = constant, CBD, // constant_tag first
CBX, CBX,
CHD, CHD,
CHX, CHX,
@ -65,9 +78,9 @@ struct spu_itype
IL, IL,
ILA, ILA,
IOHL, IOHL,
FSMBI, FSMBI, // constant_tag last
AH = integer, AH, // integer_tag first
AHI, AHI,
A, A,
AI, AI,
@ -124,79 +137,15 @@ struct spu_itype
NOR, NOR,
EQV, EQV,
MPYA = integer | _quadrop, MPYA, // quadrop_tag first
SELB, SELB,
SHUFB, SHUFB, // integer_tag last
SHLH = shiftrot, FMA, // floating_tag first
SHLHI, FNMS,
SHL, FMS, // quadrop_tag last
SHLI,
SHLQBI,
SHLQBII,
SHLQBY,
SHLQBYI,
SHLQBYBI,
ROTH,
ROTHI,
ROT,
ROTI,
ROTQBY,
ROTQBYI,
ROTQBYBI,
ROTQBI,
ROTQBII,
ROTHM,
ROTHMI,
ROTM,
ROTMI,
ROTQMBY,
ROTQMBYI,
ROTQMBYBI,
ROTQMBI,
ROTQMBII,
ROTMAH,
ROTMAHI,
ROTMA,
ROTMAI,
CEQB = compare, FA,
CEQBI,
CEQH,
CEQHI,
CEQ,
CEQI,
CGTB,
CGTBI,
CGTH,
CGTHI,
CGT,
CGTI,
CLGTB,
CLGTBI,
CLGTH,
CLGTHI,
CLGT,
CLGTI,
BR = branch,
BRA,
BRSL,
BRASL,
BI,
IRET,
BISLED,
BISL,
BRNZ,
BRZ,
BRHNZ,
BRHZ,
BIZ,
BINZ,
BIHZ,
BIHNZ,
FA = floating,
DFA, DFA,
FS, FS,
DFS, DFS,
@ -226,11 +175,58 @@ struct spu_itype
DFCMEQ, DFCMEQ,
DFCGT, DFCGT,
DFCMGT, DFCMGT,
DFTSV, DFTSV, // floating_tag last
FMA = floating | _quadrop, SHLH, // shiftrot_tag first
FNMS, SHLHI,
FMS, SHL,
SHLI,
SHLQBI,
SHLQBII,
SHLQBY,
SHLQBYI,
SHLQBYBI,
ROTH,
ROTHI,
ROT,
ROTI,
ROTQBY,
ROTQBYI,
ROTQBYBI,
ROTQBI,
ROTQBII,
ROTHM,
ROTHMI,
ROTM,
ROTMI,
ROTQMBY,
ROTQMBYI,
ROTQMBYBI,
ROTQMBI,
ROTQMBII,
ROTMAH,
ROTMAHI,
ROTMA,
ROTMAI, // shiftrot_tag last
CEQB, // compare_tag first
CEQBI,
CEQH,
CEQHI,
CEQ,
CEQI,
CGTB,
CGTBI,
CGTH,
CGTHI,
CGT,
CGTI,
CLGTB,
CLGTBI,
CLGTH,
CLGTHI,
CLGT,
CLGTI, // compare_tag last
}; };
// Enable address-of operator for spu_decoder<> // Enable address-of operator for spu_decoder<>
@ -238,6 +234,24 @@ struct spu_itype
{ {
return value; return value;
} }
// Test for branch instruction
friend constexpr bool operator &(type value, branch_tag)
{
return value >= BR && value <= BIHNZ;
}
// Test for floating point instruction
friend constexpr bool operator &(type value, floating_tag)
{
return value >= FMA && value <= DFTSV;
}
// Test for 4-op instruction
friend constexpr bool operator &(type value, quadrop_tag)
{
return value >= MPYA && value <= FMS;
}
}; };
struct spu_iflag struct spu_iflag