pan/va: Allow forcing enums for 1-bit modifiers

Ocassionally the 0 value has a meaningful value that's not meaningfully default,
so we want an enum to encode both possible states.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15182>
This commit is contained in:
Alyssa Rosenzweig 2022-02-25 11:51:56 -05:00 committed by Marge Bot
parent 20fce28dfd
commit 142ba9fea6
2 changed files with 8 additions and 7 deletions

View File

@ -134,11 +134,11 @@ va_disasm_instr(FILE *fp, uint64_t instr)
% endif
fputs("${op.name}", fp);
% for mod in op.modifiers:
% if mod.name not in ["left", "staging_register_count"]:
% if mod.size == 1:
if (instr & BIT(${mod.start})) fputs(".${mod.name}", fp);
% else:
% if mod.name not in ["left", "staging_register_count", "staging_register_write_count"]:
% if mod.is_enum:
fputs(valhall_${safe_name(mod.name)}[(instr >> ${mod.start}) & ${hex((1 << mod.size) - 1)}], fp);
% else:
if (instr & BIT(${mod.start})) fputs(".${mod.name}", fp);
% endif
% endif
% endfor

View File

@ -73,17 +73,18 @@ def build_enum(el):
return Enum(el.attrib['name'], values)
class Modifier:
def __init__(self, name, start, size, implied = False):
def __init__(self, name, start, size, implied = False, force_enum = None):
self.name = name
self.start = start
self.size = size
self.implied = implied
self.is_enum = (force_enum is not None) or size > 1
if size == 1:
if not self.is_enum:
self.bare_values = ['', name]
self.default = 0
else:
enum = enums[name]
enum = enums[force_enum or name]
self.bare_values = [x.value for x in enum.values]
defaults = [x for x in enum.values if x.default]
assert(len(defaults) <= 1)