From 0ccfe741b106efea2f2c5d526d50f4bce61d701e Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 10 Apr 2019 10:04:05 -0700 Subject: [PATCH] spirv: Add more to_string helpers Also, use a set to identify repeated values. The previous arrangement worked when the repetitions were one after another, but in some of the new cases they are not. Reviewed-by: Karol Herbst --- src/compiler/spirv/spirv_info.h | 6 ++++++ src/compiler/spirv/spirv_info_c.py | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/compiler/spirv/spirv_info.h b/src/compiler/spirv/spirv_info.h index a03c2ef..e4eac9e 100644 --- a/src/compiler/spirv/spirv_info.h +++ b/src/compiler/spirv/spirv_info.h @@ -26,9 +26,15 @@ #include "spirv.h" +const char *spirv_addressingmodel_to_string(SpvAddressingModel model); +const char *spirv_builtin_to_string(SpvBuiltIn builtin); const char *spirv_capability_to_string(SpvCapability cap); const char *spirv_decoration_to_string(SpvDecoration dec); +const char *spirv_dim_to_string(SpvDim dim); const char *spirv_executionmode_to_string(SpvExecutionMode mode); +const char *spirv_executionmodel_to_string(SpvExecutionModel model); +const char *spirv_imageformat_to_string(SpvImageFormat format); const char *spirv_op_to_string(SpvOp op); +const char *spirv_storageclass_to_string(SpvStorageClass sc); #endif /* SPIRV_INFO_H */ diff --git a/src/compiler/spirv/spirv_info_c.py b/src/compiler/spirv/spirv_info_c.py index 6880d3e..22fd675 100644 --- a/src/compiler/spirv/spirv_info_c.py +++ b/src/compiler/spirv/spirv_info_c.py @@ -36,11 +36,11 @@ def collect_data(spirv, kind): # There are some duplicate values in some of the tables (thanks guys!), so # filter them out. - last_value = -1 + seen = set() values = [] for x in operands["enumerants"]: - if x["value"] != last_value: - last_value = x["value"] + if x["value"] not in seen: + seen.add(x["value"]) values.append(x["enumerant"]) return (kind, values) @@ -88,9 +88,15 @@ if __name__ == "__main__": spirv_info = json.JSONDecoder().decode(open(pargs.json, "r").read()) info = [ + collect_data(spirv_info, "AddressingModel"), + collect_data(spirv_info, "BuiltIn"), collect_data(spirv_info, "Capability"), collect_data(spirv_info, "Decoration"), + collect_data(spirv_info, "Dim"), collect_data(spirv_info, "ExecutionMode"), + collect_data(spirv_info, "ExecutionModel"), + collect_data(spirv_info, "ImageFormat"), + collect_data(spirv_info, "StorageClass"), collect_opcodes(spirv_info), ] -- 2.7.4