spirv: Better handle duplicated enums in the JSON parser
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Iván Briano <ivan.briano@intel.com> Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28905>
This commit is contained in:

committed by
Marge Bot

parent
182877342f
commit
74b17b8d25
@@ -34,16 +34,16 @@ def collect_data(spirv, kind):
|
|||||||
operands = x
|
operands = x
|
||||||
break
|
break
|
||||||
|
|
||||||
# There are some duplicate values in some of the tables (thanks guys!), so
|
values = {}
|
||||||
# filter them out.
|
|
||||||
seen = set()
|
|
||||||
values = []
|
|
||||||
for x in operands["enumerants"]:
|
for x in operands["enumerants"]:
|
||||||
if x["value"] not in seen:
|
name = x["enumerant"]
|
||||||
seen.add(x["value"])
|
val = x["value"]
|
||||||
values.append(x["enumerant"])
|
if val not in values:
|
||||||
|
values[val] = [name]
|
||||||
|
else:
|
||||||
|
values[val].append(name)
|
||||||
|
|
||||||
return (kind, values, operands["category"])
|
return (kind, list(values.values()), operands["category"])
|
||||||
|
|
||||||
def collect_opcodes(spirv):
|
def collect_opcodes(spirv):
|
||||||
seen = set()
|
seen = set()
|
||||||
@@ -56,7 +56,7 @@ def collect_opcodes(spirv):
|
|||||||
opcode = x["opcode"]
|
opcode = x["opcode"]
|
||||||
name = x["opname"]
|
name = x["opname"]
|
||||||
assert name.startswith("Op")
|
assert name.startswith("Op")
|
||||||
values.append(name[2:])
|
values.append([name[2:]])
|
||||||
seen.add(opcode)
|
seen.add(opcode)
|
||||||
|
|
||||||
return ("Op", values, None)
|
return ("Op", values, None)
|
||||||
@@ -101,11 +101,11 @@ const char *
|
|||||||
spirv_${kind.lower()}_to_string(Spv${kind}Mask v)
|
spirv_${kind.lower()}_to_string(Spv${kind}Mask v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
% for name in values:
|
% for names in values:
|
||||||
%if name != "None":
|
%if names[0] != "None":
|
||||||
case Spv${kind}${name}Mask: return "Spv${kind}${name}";
|
case Spv${kind}${names[0]}Mask: return "Spv${kind}${names[0]}";
|
||||||
% else:
|
% else:
|
||||||
case Spv${kind}MaskNone: return "Spv${kind}${name}";
|
case Spv${kind}MaskNone: return "Spv${kind}${names[0]}";
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
@@ -117,8 +117,8 @@ const char *
|
|||||||
spirv_${kind.lower()}_to_string(Spv${kind} v)
|
spirv_${kind.lower()}_to_string(Spv${kind} v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
% for name in values:
|
% for names in values:
|
||||||
case Spv${kind}${name}: return "Spv${kind}${name}";
|
case Spv${kind}${names[0]}: return "Spv${kind}${names[0]}";
|
||||||
% endfor
|
% endfor
|
||||||
case Spv${kind}Max: break; /* silence warnings about unhandled enums. */
|
case Spv${kind}Max: break; /* silence warnings about unhandled enums. */
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user