pan/bi: Support automatic register format

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7636>
This commit is contained in:
Boris Brezillon 2020-11-12 19:19:04 +01:00
parent d0cd8bf2a5
commit aa2156f949
1 changed files with 10 additions and 1 deletions

View File

@ -181,10 +181,16 @@ def pack_register_format(mod, opts, body, pack_exprs):
body.append('unsigned {}_temp = 0;'.format(mod))
first = True
auto = None
for i, op in enumerate(opts):
if op is None or op == 'reserved':
continue
if op == 'auto':
assert(auto == None)
auto = i
continue
t_else = 'else ' if not first else ''
first = False
nir_type = REGISTER_FORMATS.get(op)
@ -193,7 +199,10 @@ def pack_register_format(mod, opts, body, pack_exprs):
body.append('{}if (ins->format == {}) {}_temp = {};'.format(t_else, nir_type, mod, i))
assert not first
body.append('else unreachable("Could not pattern match register format");')
if auto is None:
body.append('else unreachable("Could not pattern match register format");')
else:
body.append('else {}_temp = {};'.format(mod, auto))
return mod + '_temp'
def pack_seg(mod, opts, body, pack_exprs):