From 4b474e2e8a43bd53656754ea284db9c97e3bf948 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 3 Apr 2019 12:45:22 -0700 Subject: spirv: Handle instruction aliases in spirv_info_c.py Choose the first we see in the grammar file as the main one. This is needed to parse SPIR-V 1.4 because it introduced opcode aliases. Reviewed-by: Karol Herbst --- src/compiler/spirv/spirv_info_c.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/compiler/spirv') diff --git a/src/compiler/spirv/spirv_info_c.py b/src/compiler/spirv/spirv_info_c.py index 22fd675720c..b9938aedb85 100644 --- a/src/compiler/spirv/spirv_info_c.py +++ b/src/compiler/spirv/spirv_info_c.py @@ -46,11 +46,18 @@ def collect_data(spirv, kind): return (kind, values) 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"] name = x["opname"] assert name.startswith("Op") values.append(name[2:]) + seen.add(opcode) return ("Op", values) -- cgit v1.2.3