spirv: Update SPIR-V grammar to use aliases

For enumerants and instruction names, instead of duplicating the values
now the grammar will use an aliases field to list the alternative names.
Update the Python scripts for that.

The new SPIR-V files correspond to d92cf88c371424591115a87499009dfad41b669c
("Add "aliases" fields to the grammar and remove duplicated (#447)")
in https://github.com/KhronosGroup/SPIRV-Headers.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31369>
This commit is contained in:
Caio Oliveira
2024-09-25 09:01:08 -07:00
committed by Marge Bot
parent d43fec5da9
commit c06a55fd39
5 changed files with 162 additions and 780 deletions

View File

@@ -36,12 +36,12 @@ def collect_data(spirv, kind):
values = {}
for x in operands["enumerants"]:
name = x["enumerant"]
val = x["value"]
if val not in values:
values[val] = [name]
else:
values[val].append(name)
assert(val not in values)
names = [x["enumerant"]]
if "aliases" in x:
names.extend(x["aliases"])
values[val] = names
return (kind, list(values.values()), operands["category"])
@@ -49,15 +49,13 @@ def collect_opcodes(spirv):
seen = set()
values = []
for x in spirv["instructions"]:
# Handle aliases by choosing the first one in the grammar.
# E.g. OpDecorateString and OpDecorateStringGOOGLE share same opcode.
if x["opcode"] in seen:
continue
opcode = x["opcode"]
assert(opcode not in seen)
seen.add(opcode)
name = x["opname"]
assert name.startswith("Op")
values.append([name[2:]])
seen.add(opcode)
return ("Op", values, None)