panfrost: bi_builder.h.py: stop generating unneeded parentheses

Generate typecheck condition later to be able to know whether extra
parentheses are needed.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34812>
This commit is contained in:
Romaric Jodin
2025-05-22 13:17:42 +02:00
committed by Marge Bot
parent 8547f8b557
commit 67ca56d7ad
+9 -8
View File
@@ -62,16 +62,9 @@ def nirtypes(opcode):
def condition(opcode, typecheck, sizecheck):
cond = ''
if typecheck == True:
cond += '('
types = nirtypes(opcode)
assert types != None
for T in types:
cond += "{}type == {}".format(' || ' if cond[-1] != '(' else '', T)
cond += ')'
if sizecheck == True:
cond += "{}bitsize == {}".format(' && ' if cond != '' else '', typesize(opcode))
cond += "bitsize == {}".format(typesize(opcode))
cmpf_mods = ops[opcode]["modifiers"]["cmpf"] if "cmpf" in ops[opcode]["modifiers"] else None
if "cmpf" in ops[opcode]["modifiers"]:
@@ -81,6 +74,14 @@ def condition(opcode, typecheck, sizecheck):
cond += "{}cmpf == BI_CMPF_{}".format(' || ' if cond[-1] != '(' else '', cmpf.upper())
cond += ')'
if typecheck == True:
types = nirtypes(opcode)
assert types != None
typecheck_cond = ' || '.join(map(lambda T: "type == {}".format(T), types))
if cond != '':
typecheck_cond = '(' + typecheck_cond + ') && '
cond = typecheck_cond + cond
return 'true' if cond == '' else cond
def to_suffix(op):