pco, pygen: restructure igrp alu components into arrays

Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32258>
This commit is contained in:
Simon Perretta 2024-05-31 12:58:15 +01:00 committed by Marge Bot
parent fee1f029cc
commit 58337957ac
5 changed files with 92 additions and 104 deletions

View file

@ -48,6 +48,11 @@
#define ROGUE_ICACHE_ALIGN 8U
#define ROGUE_MAX_ALU_INPUTS 6U
#define ROGUE_ALU_INPUT_GROUP_SIZE (ROGUE_MAX_ALU_INPUTS / 2)
#define ROGUE_MAX_ALU_OUTPUTS 2U
#define ROGUE_MAX_ALU_INTERNAL_SOURCES 6U
/* MList entry stride in bytes */
#define ROGUE_MLIST_ENTRY_STRIDE 4U

View file

@ -14,6 +14,7 @@
*/
#include "compiler/spirv/nir_spirv.h"
#include "hwdef/rogue_hw_utils.h"
#include "pco.h"
#include "pco_common.h"
#include "pco_ops.h"
@ -157,27 +158,15 @@ typedef struct _pco_igrp {
} hdr;
struct {
pco_ref s0;
pco_ref s1;
pco_ref s2;
pco_ref s3;
pco_ref s4;
pco_ref s5;
pco_ref s[ROGUE_MAX_ALU_INPUTS];
} srcs;
struct {
pco_ref is0;
pco_ref is1;
pco_ref is2;
pco_ref is3;
pco_ref is4;
pco_ref is5;
pco_ref is[ROGUE_MAX_ALU_INTERNAL_SOURCES];
} iss;
struct {
pco_ref w0;
pco_ref w1;
pco_ref w[ROGUE_MAX_ALU_OUTPUTS];
} dests;
struct {
@ -1606,13 +1595,13 @@ static inline void pco_ref_xfer_mods(pco_ref *dest, pco_ref *source, bool reset)
*/
static inline bool pco_igrp_srcs_unset(pco_igrp *igrp, bool upper)
{
if (upper) {
return pco_ref_is_null(igrp->srcs.s3) && pco_ref_is_null(igrp->srcs.s4) &&
pco_ref_is_null(igrp->srcs.s5);
}
unsigned offset = upper ? ROGUE_ALU_INPUT_GROUP_SIZE : 0;
return pco_ref_is_null(igrp->srcs.s0) && pco_ref_is_null(igrp->srcs.s1) &&
pco_ref_is_null(igrp->srcs.s2);
for (unsigned u = 0; u < ROGUE_ALU_INPUT_GROUP_SIZE; ++u)
if (!pco_ref_is_null(igrp->srcs.s[u + offset]))
return false;
return true;
}
/**
@ -1624,9 +1613,11 @@ static inline bool pco_igrp_srcs_unset(pco_igrp *igrp, bool upper)
*/
static inline bool pco_igrp_iss_unset(pco_igrp *igrp)
{
return pco_ref_is_null(igrp->iss.is0) && pco_ref_is_null(igrp->iss.is1) &&
pco_ref_is_null(igrp->iss.is2) && pco_ref_is_null(igrp->iss.is3) &&
pco_ref_is_null(igrp->iss.is4) && pco_ref_is_null(igrp->iss.is5);
for (unsigned u = 0; u < ARRAY_SIZE(igrp->iss.is); ++u)
if (!pco_ref_is_null(igrp->iss.is[u]))
return false;
return true;
}
/**
@ -1638,6 +1629,10 @@ static inline bool pco_igrp_iss_unset(pco_igrp *igrp)
*/
static inline bool pco_igrp_dests_unset(pco_igrp *igrp)
{
return pco_ref_is_null(igrp->dests.w0) && pco_ref_is_null(igrp->dests.w1);
for (unsigned u = 0; u < ARRAY_SIZE(igrp->dests.w); ++u)
if (!pco_ref_is_null(igrp->dests.w[u]))
return false;
return true;
}
#endif /* PCO_INTERNAL_H */

View file

@ -133,10 +133,12 @@ static inline
enum pco_src_variant pco_igrp_src_variant(const pco_igrp *igrp,
bool is_upper)
{
pco_ref sA = is_upper ? igrp->srcs.s3 : igrp->srcs.s0;
pco_ref sB = is_upper ? igrp->srcs.s4 : igrp->srcs.s1;
pco_ref sC = is_upper ? igrp->srcs.s5 : igrp->srcs.s2;
pco_ref mux = is_upper ? pco_ref_null() : igrp->iss.is0;
unsigned offset = is_upper ? ROGUE_ALU_INPUT_GROUP_SIZE : 0;
pco_ref sA = igrp->srcs.s[0 + offset];
pco_ref sB = igrp->srcs.s[1 + offset];
pco_ref sC = igrp->srcs.s[2 + offset];
pco_ref mux = is_upper ? pco_ref_null() : igrp->iss.is[0];
bool sA_set = !pco_ref_is_null(sA);
bool sB_set = !pco_ref_is_null(sB);
@ -184,8 +186,8 @@ enum pco_iss_variant pco_igrp_iss_variant(const pco_igrp *igrp)
static inline
enum pco_dst_variant pco_igrp_dest_variant(pco_igrp *igrp)
{
pco_ref w0 = igrp->dests.w0;
pco_ref w1 = igrp->dests.w1;
pco_ref w0 = igrp->dests.w[0];
pco_ref w1 = igrp->dests.w[1];
bool w0_set = !pco_ref_is_null(w0);
bool w1_set = !pco_ref_is_null(w1);
@ -372,10 +374,12 @@ unsigned pco_instr_map_encode(uint8_t *bin, pco_igrp *igrp, enum pco_op_phase ph
static inline
unsigned pco_srcs_map_encode(uint8_t *bin, pco_igrp *igrp, bool is_upper)
{
pco_ref _sA = is_upper ? igrp->srcs.s3 : igrp->srcs.s0;
pco_ref _sB = is_upper ? igrp->srcs.s4 : igrp->srcs.s1;
pco_ref _sC = is_upper ? igrp->srcs.s5 : igrp->srcs.s2;
pco_ref _mux = is_upper ? pco_ref_null() : igrp->iss.is0;
unsigned offset = is_upper ? ROGUE_ALU_INPUT_GROUP_SIZE : 0;
pco_ref _sA = igrp->srcs.s[0 + offset];
pco_ref _sB = igrp->srcs.s[1 + offset];
pco_ref _sC = igrp->srcs.s[2 + offset];
pco_ref _mux = is_upper ? pco_ref_null() : igrp->iss.is[0];
bool sA_set = !pco_ref_is_null(_sA);
bool sB_set = !pco_ref_is_null(_sB);
@ -426,17 +430,17 @@ unsigned pco_srcs_map_encode(uint8_t *bin, pco_igrp *igrp, bool is_upper)
static inline
unsigned pco_iss_map_encode(uint8_t *bin, pco_igrp *igrp)
{
bool is5_set = !pco_ref_is_null(igrp->iss.is5);
bool is4_set = !pco_ref_is_null(igrp->iss.is4);
bool is3_set = !pco_ref_is_null(igrp->iss.is3);
bool is2_set = !pco_ref_is_null(igrp->iss.is2);
bool is1_set = !pco_ref_is_null(igrp->iss.is1);
bool is5_set = !pco_ref_is_null(igrp->iss.is[5]);
bool is4_set = !pco_ref_is_null(igrp->iss.is[4]);
bool is3_set = !pco_ref_is_null(igrp->iss.is[3]);
bool is2_set = !pco_ref_is_null(igrp->iss.is[2]);
bool is1_set = !pco_ref_is_null(igrp->iss.is[1]);
unsigned is5 = is5_set ? pco_map_io_to_is5_sel(pco_ref_get_io(igrp->iss.is5)) : 0;
unsigned is4 = is4_set ? pco_map_io_to_is4_sel(pco_ref_get_io(igrp->iss.is4)) : 0;
unsigned is3 = is3_set ? pco_map_io_to_is3_sel(pco_ref_get_io(igrp->iss.is3)) : 0;
unsigned is2 = is2_set ? pco_map_io_to_is2_sel(pco_ref_get_io(igrp->iss.is2)) : 0;
unsigned is1 = is1_set ? pco_map_io_to_is1_sel(pco_ref_get_io(igrp->iss.is1)) : 0;
unsigned is5 = is5_set ? pco_map_io_to_is5_sel(pco_ref_get_io(igrp->iss.is[5])) : 0;
unsigned is4 = is4_set ? pco_map_io_to_is4_sel(pco_ref_get_io(igrp->iss.is[4])) : 0;
unsigned is3 = is3_set ? pco_map_io_to_is3_sel(pco_ref_get_io(igrp->iss.is[3])) : 0;
unsigned is2 = is2_set ? pco_map_io_to_is2_sel(pco_ref_get_io(igrp->iss.is[2])) : 0;
unsigned is1 = is1_set ? pco_map_io_to_is1_sel(pco_ref_get_io(igrp->iss.is[1])) : 0;
assert(igrp->variant.iss == PCO_ISS_ISS);
return pco_iss_iss_encode(bin, .is5 = is5, .is4 = is4, .is3 = is3, .is2 = is2, .is1 = is1);
@ -445,8 +449,8 @@ unsigned pco_iss_map_encode(uint8_t *bin, pco_igrp *igrp)
static inline
unsigned pco_dests_map_encode(uint8_t *bin, pco_igrp *igrp)
{
pco_ref w0 = igrp->dests.w0;
pco_ref w1 = igrp->dests.w1;
pco_ref w0 = igrp->dests.w[0];
pco_ref w1 = igrp->dests.w[1];
bool w0_set = !pco_ref_is_null(w0);
bool w1_set = !pco_ref_is_null(w1);

View file

@ -332,7 +332,6 @@ def op_map(op, hdr, isa_ops, srcs=[], iss=[], dests=[]):
iss_mappings = []
for iss, _io in iss:
assert iss in IO.enum.elems.keys()
assert _io in IO.enum.elems.keys()
io = IO.enum.elems[_io]
iss_mappings.append(f'{{}}->iss.{iss} = pco_ref_io({io.cname});')
@ -382,14 +381,14 @@ op_map(O_FADD,
])
],
srcs=[
('s0', 'src[0]', 's0'),
('s1', 'src[1]', 's1'),
('s[0]', 'src[0]', 's0'),
('s[1]', 'src[1]', 's1'),
],
iss=[
('is4', 'ft0'),
('is[4]', 'ft0'),
],
dests=[
('w0', 'dest[0]', 'ft0'),
('w[0]', 'dest[0]', 'ft0'),
]
)
@ -416,14 +415,14 @@ op_map(O_FMUL,
])
],
srcs=[
('s0', 'src[0]', 's0'),
('s1', 'src[1]', 's1'),
('s[0]', 'src[0]', 's0'),
('s[1]', 'src[1]', 's1'),
],
iss=[
('is4', 'ft0'),
('is[4]', 'ft0'),
],
dests=[
('w0', 'dest[0]', 'ft0'),
('w[0]', 'dest[0]', 'ft0'),
]
)
@ -467,15 +466,15 @@ op_map(O_FMAD,
])
],
srcs=[
('s0', 'src[0]', 's0'),
('s1', 'src[1]', 's1'),
('s2', 'src[2]', 's2'),
('s[0]', 'src[0]', 's0'),
('s[1]', 'src[1]', 's1'),
('s[2]', 'src[2]', 's2'),
],
iss=[
('is4', 'ft0'),
('is[4]', 'ft0'),
],
dests=[
('w0', 'dest[0]', 'ft0'),
('w[0]', 'dest[0]', 'ft0'),
]
)
@ -504,13 +503,13 @@ op_map(O_MBYP0,
])
],
srcs=[
('s0', 'src[0]', 's0'),
('s[0]', 'src[0]', 's0'),
],
iss=[
('is4', 'ft0'),
('is[4]', 'ft0'),
],
dests=[
('w0', 'dest[0]', 'ft0'),
('w[0]', 'dest[0]', 'ft0'),
]
)
@ -536,15 +535,15 @@ op_map(O_PCK,
])
],
srcs=[
('s0', 'src[0]', 'is3'),
('s[0]', 'src[0]', 'is3'),
],
iss=[
('is0', 's0'),
('is3', 'fte'),
('is4', 'ft2'),
('is[0]', 's0'),
('is[3]', 'fte'),
('is[4]', 'ft2'),
],
dests=[
('w0', 'dest[0]', 'ft2'),
('w[0]', 'dest[0]', 'ft2'),
]
)
@ -569,11 +568,11 @@ op_map(O_UVSW_WRITE,
])
],
srcs=[
('s0', 'src[0]', 'w0'),
('s[0]', 'src[0]', 'w0'),
],
iss=[
('is0', 's0'),
('is4', 'fte'),
('is[0]', 's0'),
('is[4]', 'fte'),
]
)
@ -645,11 +644,11 @@ op_map(O_UVSW_WRITE_EMIT_ENDTASK,
])
],
srcs=[
('s0', 'src[0]', 'w0'),
('s[0]', 'src[0]', 'w0'),
],
iss=[
('is0', 's0'),
('is4', 'fte'),
('is[0]', 's0'),
('is[4]', 'fte'),
]
)
@ -676,9 +675,9 @@ op_map(O_FITRP,
])
],
srcs=[
('s0', 'src[1]', 's0'),
('s2', 'src[2]', 's2'),
('s3', 'dest[0]', 's3'),
('s[0]', 'src[1]', 's0'),
('s[2]', 'src[2]', 's2'),
('s[3]', 'dest[0]', 's3'),
]
)
@ -705,7 +704,7 @@ op_map(O_MOVI32,
], (O_BBYP0BM, ('ft0', 'dest[0]'), ('s0', 'src[0]')))
],
dests=[
('w0', 'dest[0]', 'ft1'),
('w[0]', 'dest[0]', 'ft1'),
]
)

View file

@ -586,22 +586,17 @@ static void pco_print_igrp_phases(pco_print_state *state, pco_igrp *igrp)
static void
pco_print_igrp_srcs(pco_print_state *state, pco_igrp *igrp, bool upper)
{
unsigned offset = upper ? 3 : 0;
const pco_ref *srcs[] = {
&igrp->srcs.s0, &igrp->srcs.s1, &igrp->srcs.s2,
&igrp->srcs.s3, &igrp->srcs.s4, &igrp->srcs.s5,
};
unsigned offset = upper ? ROGUE_ALU_INPUT_GROUP_SIZE : 0;
bool printed = false;
for (unsigned s = 0; s < ARRAY_SIZE(srcs) / 2; ++s) {
const pco_ref *src = srcs[s + offset];
for (unsigned u = 0; u < ROGUE_ALU_INPUT_GROUP_SIZE; ++u) {
const pco_ref *src = &igrp->srcs.s[u + offset];
if (pco_ref_is_null(*src))
continue;
if (printed)
pco_printf(state, ", ");
pco_printf(state, "s%u = ", s + offset);
pco_printf(state, "s%u = ", u + offset);
pco_print_ref(state, *src);
printed = true;
}
@ -615,21 +610,16 @@ pco_print_igrp_srcs(pco_print_state *state, pco_igrp *igrp, bool upper)
*/
static void pco_print_igrp_iss(pco_print_state *state, pco_igrp *igrp)
{
const pco_ref *isss[] = {
&igrp->iss.is0, &igrp->iss.is1, &igrp->iss.is2,
&igrp->iss.is3, &igrp->iss.is4, &igrp->iss.is5,
};
bool printed = false;
for (unsigned i = 0; i < ARRAY_SIZE(isss); ++i) {
const pco_ref *iss = isss[i];
for (unsigned u = 0; u < ROGUE_MAX_ALU_INTERNAL_SOURCES; ++u) {
const pco_ref *iss = &igrp->iss.is[u];
if (pco_ref_is_null(*iss))
continue;
if (printed)
pco_printf(state, ", ");
pco_printf(state, "is%u = ", i);
pco_printf(state, "is%u = ", u);
pco_print_ref(state, *iss);
printed = true;
}
@ -643,21 +633,16 @@ static void pco_print_igrp_iss(pco_print_state *state, pco_igrp *igrp)
*/
static void pco_print_igrp_dests(pco_print_state *state, pco_igrp *igrp)
{
const pco_ref *dests[] = {
&igrp->dests.w0,
&igrp->dests.w1,
};
bool printed = false;
for (unsigned d = 0; d < ARRAY_SIZE(dests); ++d) {
const pco_ref *dest = dests[d];
for (unsigned u = 0; u < ROGUE_MAX_ALU_OUTPUTS; ++u) {
const pco_ref *dest = &igrp->dests.w[u];
if (pco_ref_is_null(*dest))
continue;
if (printed)
pco_printf(state, ", ");
pco_printf(state, "w%u = ", d);
pco_printf(state, "w%u = ", u);
pco_print_ref(state, *dest);
printed = true;
}