pco, pygen: add bitset support for op mods

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-23 16:43:22 +01:00 committed by Marge Bot
parent 7c57e25550
commit 561098cf7d
3 changed files with 13 additions and 5 deletions

View file

@ -55,6 +55,7 @@ const struct pco_op_mod_info pco_op_mod_info[_PCO_OP_MOD_COUNT] = {
.print_early = ${str(op_mod.t.print_early).lower()},
.type = ${op_mod.ctype},
% if op_mod.t.base_type == BaseType.enum:
.is_bitset = ${str(op_mod.t.enum.is_bitset).lower()},
.strs = (const char * []){
% for elem in op_mod.t.enum.elems.values():
[${elem.cname}] = "${elem.string}",

View file

@ -354,6 +354,7 @@ extern const struct pco_op_info pco_op_info[_PCO_OP_COUNT];
/** Op mod info. */
struct pco_op_mod_info {
bool print_early : 1; /** Set if printed before the op. */
bool is_bitset : 1; /** Set if type is an enum bitset. */
enum pco_mod_type type; /** Datatype. */
union {
const char *str; /** Mod name. */

View file

@ -370,11 +370,17 @@ static void pco_print_instr_mods(pco_print_state *state,
break;
case PCO_MOD_TYPE_ENUM:
if (strlen(mod_info->strs[val])) {
if (print_early)
pco_printf(state, "%s ", mod_info->strs[val]);
else
pco_printf(state, ".%s", mod_info->strs[val]);
if (mod_info->is_bitset) {
u_foreach_bit (bit, val) {
pco_printf(state, ".%s", mod_info->strs[1U << bit]);
}
} else {
if (strlen(mod_info->strs[val])) {
if (print_early)
pco_printf(state, "%s ", mod_info->strs[val]);
else
pco_printf(state, ".%s", mod_info->strs[val]);
}
}
break;