Support OpenCL.DebugInfo.100 extended instruction set (#3080)

* Clone opencl.debuginfo.100 grammar from debuginfo grammar

Update version number to 200 revision 2

* Apply content from OpenCL.DebugInfo.100 extension text

* Rename grammar file

* Support OpenCL.DebugInfo.100 extended instructions

Add support for prefixing operand type names, to disambiguate
them between different instruction sets.

* Add tests for OpenCL.DebugInfo.100

* Support lookup of OpenCL.DebugInfo.100 extinst

* Add tests for enum values

* Recognize 2017-2019 as copyright date range

* Android.mk: support OpenCL.DebugInfo.100 extended instruction set

Also, stop generating core instruction tables for non-unified1 versions
of the grammar.

* Imported entity operand type is concrete

* Bazel: Suppoort OpenCL.DebugInfo.100

* BUILD.gn: Support OpenCL.DebugInfo.100
This commit is contained in:
David Neto 2019-12-19 17:16:26 -05:00 committed by GitHub
parent e01bc6d4e8
commit 64f36ea529
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 1923 additions and 121 deletions

View File

@ -178,73 +178,43 @@ SPVTOOLS_OPT_SRC_FILES := \
# Locations of grammar files. # Locations of grammar files.
# #
# TODO(dneto): Build a single set of tables that embeds versioning differences on
# a per-item basis. That must happen before SPIR-V 1.4, etc.
# https://github.com/KhronosGroup/SPIRV-Tools/issues/1195
SPV_CORE10_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.0/spirv.core.grammar.json
SPV_CORE11_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.1/spirv.core.grammar.json
SPV_CORE12_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.2/spirv.core.grammar.json
SPV_COREUNIFIED1_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/spirv.core.grammar.json SPV_COREUNIFIED1_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/spirv.core.grammar.json
SPV_CORELATEST_GRAMMAR=$(SPV_COREUNIFIED1_GRAMMAR)
SPV_GLSL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.2/extinst.glsl.std.450.grammar.json SPV_GLSL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.2/extinst.glsl.std.450.grammar.json
SPV_OPENCL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.2/extinst.opencl.std.100.grammar.json SPV_OPENCL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/1.2/extinst.opencl.std.100.grammar.json
# TODO(dneto): I expect the DebugInfo grammar file to eventually migrate to SPIRV-Headers # TODO(dneto): I expect the DebugInfo grammar file to eventually migrate to SPIRV-Headers
SPV_DEBUGINFO_GRAMMAR=$(LOCAL_PATH)/source/extinst.debuginfo.grammar.json SPV_DEBUGINFO_GRAMMAR=$(LOCAL_PATH)/source/extinst.debuginfo.grammar.json
SPV_CLDEBUGINFO100_GRAMMAR=$(LOCAL_PATH)/source/extinst.opencl.debuginfo.100.grammar.json
define gen_spvtools_grammar_tables define gen_spvtools_grammar_tables
$(call generate-file-dir,$(1)/core.insts-1.0.inc) $(call generate-file-dir,$(1)/core.insts-unified1.inc)
$(1)/core.insts-1.0.inc $(1)/operand.kinds-1.0.inc $(1)/glsl.std.450.insts.inc $(1)/opencl.std.insts.inc: \ $(1)/core.insts-unified1.inc $(1)/operand.kinds-unified1.inc \
$(1)/glsl.std.450.insts.inc \
$(1)/opencl.std.insts.inc \
: \
$(LOCAL_PATH)/utils/generate_grammar_tables.py \ $(LOCAL_PATH)/utils/generate_grammar_tables.py \
$(SPV_CORE10_GRAMMAR) \ $(SPV_COREUNIFIED1_GRAMMAR) \
$(SPV_GLSL_GRAMMAR) \ $(SPV_GLSL_GRAMMAR) \
$(SPV_OPENCL_GRAMMAR) \ $(SPV_OpenCL_GRAMMAR) \
$(SPV_DEBUGINFO_GRAMMAR) $(SPV_DEBUGINFO_GRAMMAR) \
$(SPV_CLDEBUGINFO100_GRAMMAR)
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \ @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
--spirv-core-grammar=$(SPV_CORE10_GRAMMAR) \ --spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
--extinst-glsl-grammar=$(SPV_GLSL_GRAMMAR) \ --extinst-glsl-grammar=$(SPV_GLSL_GRAMMAR) \
--extinst-opencl-grammar=$(SPV_OPENCL_GRAMMAR) \ --extinst-opencl-grammar=$(SPV_OPENCL_GRAMMAR) \
--extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \ --extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
--core-insts-output=$(1)/core.insts-1.0.inc \ --extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
--core-insts-output=$(1)/core.insts-unified1.inc \
--glsl-insts-output=$(1)/glsl.std.450.insts.inc \ --glsl-insts-output=$(1)/glsl.std.450.insts.inc \
--opencl-insts-output=$(1)/opencl.std.insts.inc \ --opencl-insts-output=$(1)/opencl.std.insts.inc \
--operand-kinds-output=$(1)/operand.kinds-1.0.inc
@echo "[$(TARGET_ARCH_ABI)] Grammar v1.0 : instructions & operands <= grammar JSON files"
$(1)/core.insts-1.1.inc $(1)/operand.kinds-1.1.inc: \
$(LOCAL_PATH)/utils/generate_grammar_tables.py \
$(SPV_CORE11_GRAMMAR) \
$(SPV_DEBUGINFO_GRAMMAR)
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
--spirv-core-grammar=$(SPV_CORE11_GRAMMAR) \
--extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
--core-insts-output=$(1)/core.insts-1.1.inc \
--operand-kinds-output=$(1)/operand.kinds-1.1.inc
@echo "[$(TARGET_ARCH_ABI)] Grammar v1.1 : instructions & operands <= grammar JSON files"
$(1)/core.insts-1.2.inc $(1)/operand.kinds-1.2.inc: \
$(LOCAL_PATH)/utils/generate_grammar_tables.py \
$(SPV_CORE12_GRAMMAR) \
$(SPV_DEBUGINFO_GRAMMAR)
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
--spirv-core-grammar=$(SPV_CORE12_GRAMMAR) \
--extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
--core-insts-output=$(1)/core.insts-1.2.inc \
--operand-kinds-output=$(1)/operand.kinds-1.2.inc
@echo "[$(TARGET_ARCH_ABI)] Grammar v1.2 : instructions & operands <= grammar JSON files"
$(1)/core.insts-unified1.inc $(1)/operand.kinds-unified1.inc: \
$(LOCAL_PATH)/utils/generate_grammar_tables.py \
$(SPV_COREUNIFIED1_GRAMMAR) \
$(SPV_DEBUGINFO_GRAMMAR)
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
--spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
--extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
--core-insts-output=$(1)/core.insts-unified1.inc \
--operand-kinds-output=$(1)/operand.kinds-unified1.inc --operand-kinds-output=$(1)/operand.kinds-unified1.inc
@echo "[$(TARGET_ARCH_ABI)] Grammar v1.3 (from unified1) : instructions & operands <= grammar JSON files" @echo "[$(TARGET_ARCH_ABI)] Grammar (from unified1) : instructions & operands <= grammar JSON files"
$(LOCAL_PATH)/source/opcode.cpp: $(1)/core.insts-1.0.inc $(1)/core.insts-1.1.inc $(1)/core.insts-1.2.inc $(1)/core.insts-unified1.inc $(LOCAL_PATH)/source/opcode.cpp: $(1)/core.insts-unified1.inc
$(LOCAL_PATH)/source/operand.cpp: $(1)/operand.kinds-1.0.inc $(1)/operand.kinds-1.1.inc $(1)/operand.kinds-1.2.inc $(1)/operand.kinds-unified1.inc $(LOCAL_PATH)/source/operand.cpp: $(1)/operand.kinds-unified1.inc
$(LOCAL_PATH)/source/ext_inst.cpp: \ $(LOCAL_PATH)/source/ext_inst.cpp: \
$(1)/glsl.std.450.insts.inc \ $(1)/glsl.std.450.insts.inc \
$(1)/opencl.std.insts.inc \ $(1)/opencl.std.insts.inc \
$(1)/debuginfo.insts.inc \ $(1)/debuginfo.insts.inc \
$(1)/opencl.debuginfo.100.insts.inc \
$(1)/spv-amd-gcn-shader.insts.inc \ $(1)/spv-amd-gcn-shader.insts.inc \
$(1)/spv-amd-shader-ballot.insts.inc \ $(1)/spv-amd-shader-ballot.insts.inc \
$(1)/spv-amd-shader-explicit-vertex-parameter.insts.inc \ $(1)/spv-amd-shader-explicit-vertex-parameter.insts.inc \
@ -271,8 +241,9 @@ $(1)/$(2).h : \
@echo "[$(TARGET_ARCH_ABI)] Generate language specific header for $(2): headers <= grammar" @echo "[$(TARGET_ARCH_ABI)] Generate language specific header for $(2): headers <= grammar"
$(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).h $(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).h
endef endef
# We generate language-specific headers for DebugInfo # We generate language-specific headers for DebugInfo and OpenCL.DebugInfo.100
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),DebugInfo,$(SPV_DEBUGINFO_GRAMMAR))) $(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),DebugInfo,$(SPV_DEBUGINFO_GRAMMAR)))
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),OpenCLDebugInfo100,$(SPV_CLDEBUGINFO100_GRAMMAR)))
define gen_spvtools_vendor_tables define gen_spvtools_vendor_tables
@ -282,22 +253,28 @@ $(1)/$(2).insts.inc : \
$(LOCAL_PATH)/source/extinst.$(2).grammar.json $(LOCAL_PATH)/source/extinst.$(2).grammar.json
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \ @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
--extinst-vendor-grammar=$(LOCAL_PATH)/source/extinst.$(2).grammar.json \ --extinst-vendor-grammar=$(LOCAL_PATH)/source/extinst.$(2).grammar.json \
--vendor-insts-output=$(1)/$(2).insts.inc --vendor-insts-output=$(1)/$(2).insts.inc \
--vendor-operand-kind-prefix=$(3)
@echo "[$(TARGET_ARCH_ABI)] Vendor extended instruction set: $(2) tables <= grammar" @echo "[$(TARGET_ARCH_ABI)] Vendor extended instruction set: $(2) tables <= grammar"
$(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).insts.inc $(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).insts.inc
endef endef
# Vendor extended instruction sets, with grammars from SPIRV-Tools source tree. # Vendor and debug extended instruction sets, with grammars from SPIRV-Tools source tree.
SPV_NONSTANDARD_EXTINST_GRAMMARS=$(foreach F,$(wildcard $(LOCAL_PATH)/source/extinst.*.grammar.json),$(patsubst extinst.%.grammar.json,%,$(notdir $F))) $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),debuginfo,""))
$(foreach E,$(SPV_NONSTANDARD_EXTINST_GRAMMARS),$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),$E))) $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),opencl.debuginfo.100,"CLDEBUG100_"))
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-gcn-shader,""))
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-ballot,""))
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-explicit-vertex-parameter,""))
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-trinary-minmax,""))
define gen_spvtools_enum_string_mapping define gen_spvtools_enum_string_mapping
$(call generate-file-dir,$(1)/extension_enum.inc.inc) $(call generate-file-dir,$(1)/extension_enum.inc.inc)
$(1)/extension_enum.inc $(1)/enum_string_mapping.inc: \ $(1)/extension_enum.inc $(1)/enum_string_mapping.inc: \
$(LOCAL_PATH)/utils/generate_grammar_tables.py \ $(LOCAL_PATH)/utils/generate_grammar_tables.py \
$(SPV_CORELATEST_GRAMMAR) $(SPV_COREUNIFIED1_GRAMMAR)
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \ @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
--spirv-core-grammar=$(SPV_CORELATEST_GRAMMAR) \ --spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
--extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \ --extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
--extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
--extension-enum-output=$(1)/extension_enum.inc \ --extension-enum-output=$(1)/extension_enum.inc \
--enum-string-mapping-output=$(1)/enum_string_mapping.inc --enum-string-mapping-output=$(1)/enum_string_mapping.inc
@echo "[$(TARGET_ARCH_ABI)] Generate enum<->string mapping <= grammar JSON files" @echo "[$(TARGET_ARCH_ABI)] Generate enum<->string mapping <= grammar JSON files"

View File

@ -2,6 +2,7 @@ load(
":build_defs.bzl", ":build_defs.bzl",
"COMMON_COPTS", "COMMON_COPTS",
"DEBUGINFO_GRAMMAR_JSON_FILE", "DEBUGINFO_GRAMMAR_JSON_FILE",
"CLDEBUGINFO100_GRAMMAR_JSON_FILE",
"TEST_COPTS", "TEST_COPTS",
"base_test", "base_test",
"generate_core_tables", "generate_core_tables",
@ -38,12 +39,6 @@ py_binary(
srcs = ["utils/generate_language_headers.py"], srcs = ["utils/generate_language_headers.py"],
) )
generate_core_tables("1.0")
generate_core_tables("1.1")
generate_core_tables("1.2")
generate_core_tables("unified1") generate_core_tables("unified1")
generate_enum_string_mapping("unified1") generate_enum_string_mapping("unified1")
@ -62,8 +57,12 @@ generate_vendor_tables("spv-amd-shader-ballot")
generate_vendor_tables("debuginfo") generate_vendor_tables("debuginfo")
generate_vendor_tables("opencl.debuginfo.100", "CLDEBUG100_")
generate_extinst_lang_headers("DebugInfo", DEBUGINFO_GRAMMAR_JSON_FILE) generate_extinst_lang_headers("DebugInfo", DEBUGINFO_GRAMMAR_JSON_FILE)
generate_extinst_lang_headers("OpenCLDebugInfo100", CLDEBUGINFO100_GRAMMAR_JSON_FILE)
py_binary( py_binary(
name = "generate_registry_tables", name = "generate_registry_tables",
srcs = ["utils/generate_registry_tables.py"], srcs = ["utils/generate_registry_tables.py"],
@ -96,16 +95,15 @@ cc_library(
name = "generated_headers", name = "generated_headers",
hdrs = [ hdrs = [
":gen_build_version", ":gen_build_version",
":gen_core_tables_1.0",
":gen_core_tables_1.1",
":gen_core_tables_1.2",
":gen_core_tables_unified1", ":gen_core_tables_unified1",
":gen_enum_string_mapping", ":gen_enum_string_mapping",
":gen_extinst_lang_headers_DebugInfo", ":gen_extinst_lang_headers_DebugInfo",
":gen_extinst_lang_headers_OpenCLDebugInfo100",
":gen_glsl_tables_unified1", ":gen_glsl_tables_unified1",
":gen_opencl_tables_unified1", ":gen_opencl_tables_unified1",
":gen_registry_tables", ":gen_registry_tables",
":gen_vendor_tables_debuginfo", ":gen_vendor_tables_debuginfo",
":gen_vendor_tables_opencl_debuginfo_100",
":gen_vendor_tables_spv_amd_gcn_shader", ":gen_vendor_tables_spv_amd_gcn_shader",
":gen_vendor_tables_spv_amd_shader_ballot", ":gen_vendor_tables_spv_amd_shader_ballot",
":gen_vendor_tables_spv_amd_shader_explicit_vertex_parameter", ":gen_vendor_tables_spv_amd_shader_explicit_vertex_parameter",

View File

@ -32,7 +32,8 @@ template("spvtools_core_tables") {
"${spirv_headers}/include/spirv/$version/spirv.core.grammar.json" "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json"
core_insts_file = "${target_gen_dir}/core.insts-$version.inc" core_insts_file = "${target_gen_dir}/core.insts-$version.inc"
operand_kinds_file = "${target_gen_dir}/operand.kinds-$version.inc" operand_kinds_file = "${target_gen_dir}/operand.kinds-$version.inc"
extinst_file = "source/extinst.debuginfo.grammar.json" debuginfo_insts_file = "source/extinst.debuginfo.grammar.json"
cldebuginfo100_insts_file = "source/extinst.opencl.debuginfo.100.grammar.json"
sources = [ sources = [
core_json_file, core_json_file,
@ -47,7 +48,9 @@ template("spvtools_core_tables") {
"--core-insts-output", "--core-insts-output",
rebase_path(core_insts_file, root_build_dir), rebase_path(core_insts_file, root_build_dir),
"--extinst-debuginfo-grammar", "--extinst-debuginfo-grammar",
rebase_path(extinst_file, root_build_dir), rebase_path(debuginfo_insts_file, root_build_dir),
"--extinst-cldebuginfo100-grammar",
rebase_path(cldebuginfo100_insts_file, root_build_dir),
"--operand-kinds-output", "--operand-kinds-output",
rebase_path(operand_kinds_file, root_build_dir), rebase_path(operand_kinds_file, root_build_dir),
] ]
@ -64,7 +67,8 @@ template("spvtools_core_enums") {
core_json_file = core_json_file =
"${spirv_headers}/include/spirv/$version/spirv.core.grammar.json" "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json"
debug_insts_file = "source/extinst.debuginfo.grammar.json" debuginfo_insts_file = "source/extinst.debuginfo.grammar.json"
cldebuginfo100_insts_file = "source/extinst.opencl.debuginfo.100.grammar.json"
extension_enum_file = "${target_gen_dir}/extension_enum.inc" extension_enum_file = "${target_gen_dir}/extension_enum.inc"
extension_map_file = "${target_gen_dir}/enum_string_mapping.inc" extension_map_file = "${target_gen_dir}/enum_string_mapping.inc"
@ -72,7 +76,9 @@ template("spvtools_core_enums") {
"--spirv-core-grammar", "--spirv-core-grammar",
rebase_path(core_json_file, root_build_dir), rebase_path(core_json_file, root_build_dir),
"--extinst-debuginfo-grammar", "--extinst-debuginfo-grammar",
rebase_path(debug_insts_file, root_build_dir), rebase_path(debuginfo_insts_file, root_build_dir),
"--extinst-cldebuginfo100-grammar",
rebase_path(cldebuginfo100_insts_file, root_build_dir),
"--extension-enum-output", "--extension-enum-output",
rebase_path(extension_enum_file, root_build_dir), rebase_path(extension_enum_file, root_build_dir),
"--enum-string-mapping-output", "--enum-string-mapping-output",
@ -100,7 +106,6 @@ template("spvtools_glsl_tables") {
"${spirv_headers}/include/spirv/$version/spirv.core.grammar.json" "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json"
glsl_json_file = "${spirv_headers}/include/spirv/${version}/extinst.glsl.std.450.grammar.json" glsl_json_file = "${spirv_headers}/include/spirv/${version}/extinst.glsl.std.450.grammar.json"
glsl_insts_file = "${target_gen_dir}/glsl.std.450.insts.inc" glsl_insts_file = "${target_gen_dir}/glsl.std.450.insts.inc"
debug_insts_file = "source/extinst.debuginfo.grammar.json"
args = [ args = [
"--spirv-core-grammar", "--spirv-core-grammar",
@ -109,8 +114,6 @@ template("spvtools_glsl_tables") {
rebase_path(glsl_json_file, root_build_dir), rebase_path(glsl_json_file, root_build_dir),
"--glsl-insts-output", "--glsl-insts-output",
rebase_path(glsl_insts_file, root_build_dir), rebase_path(glsl_insts_file, root_build_dir),
"--extinst-debuginfo-grammar",
rebase_path(debug_insts_file, root_build_dir),
] ]
inputs = [ inputs = [
core_json_file, core_json_file,
@ -134,7 +137,6 @@ template("spvtools_opencl_tables") {
"${spirv_headers}/include/spirv/$version/spirv.core.grammar.json" "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json"
opengl_json_file = "${spirv_headers}/include/spirv/${version}/extinst.opencl.std.100.grammar.json" opengl_json_file = "${spirv_headers}/include/spirv/${version}/extinst.opencl.std.100.grammar.json"
opencl_insts_file = "${target_gen_dir}/opencl.std.insts.inc" opencl_insts_file = "${target_gen_dir}/opencl.std.insts.inc"
debug_insts_file = "source/extinst.debuginfo.grammar.json"
args = [ args = [
"--spirv-core-grammar", "--spirv-core-grammar",
@ -143,8 +145,6 @@ template("spvtools_opencl_tables") {
rebase_path(opengl_json_file, root_build_dir), rebase_path(opengl_json_file, root_build_dir),
"--opencl-insts-output", "--opencl-insts-output",
rebase_path(opencl_insts_file, root_build_dir), rebase_path(opencl_insts_file, root_build_dir),
"--extinst-debuginfo-grammar",
rebase_path(debug_insts_file, root_build_dir),
] ]
inputs = [ inputs = [
core_json_file, core_json_file,
@ -164,13 +164,12 @@ template("spvtools_language_header") {
name = invoker.name name = invoker.name
extinst_output_base = "${target_gen_dir}/${name}" extinst_output_base = "${target_gen_dir}/${name}"
debug_insts_file = "source/extinst.debuginfo.grammar.json"
args = [ args = [
"--extinst-name", "--extinst-name",
"${name}", "${name}",
"--extinst-grammar", "--extinst-grammar",
rebase_path(debug_insts_file, root_build_dir), rebase_path(invoker.grammar_file, root_build_dir),
"--extinst-output-base", "--extinst-output-base",
rebase_path(extinst_output_base, root_build_dir), rebase_path(extinst_output_base, root_build_dir),
] ]
@ -198,6 +197,8 @@ template("spvtools_vendor_table") {
rebase_path(extinst_vendor_grammar, root_build_dir), rebase_path(extinst_vendor_grammar, root_build_dir),
"--vendor-insts-output", "--vendor-insts-output",
rebase_path(extinst_file, root_build_dir), rebase_path(extinst_file, root_build_dir),
"--vendor-operand-kind-prefix",
invoker.operand_kind_prefix
] ]
inputs = [ inputs = [
extinst_vendor_grammar, extinst_vendor_grammar,
@ -256,21 +257,28 @@ spvtools_glsl_tables("glsl1-0") {
spvtools_opencl_tables("opencl1-0") { spvtools_opencl_tables("opencl1-0") {
version = "1.0" version = "1.0"
} }
spvtools_language_header("unified1") { spvtools_language_header("debuginfo") {
name = "DebugInfo" name = "DebugInfo"
grammar_file = "source/extinst.debuginfo.grammar.json"
}
spvtools_language_header("cldebuginfo100") {
name = "OpenCLDebugInfo100"
grammar_file = "source/extinst.opencl.debuginfo.100.grammar.json"
} }
spvtools_vendor_tables = [ spvtools_vendor_tables = [
"spv-amd-shader-explicit-vertex-parameter", ["spv-amd-shader-explicit-vertex-parameter", ""],
"spv-amd-shader-trinary-minmax", ["spv-amd-shader-trinary-minmax", ""],
"spv-amd-gcn-shader", ["spv-amd-gcn-shader", ""],
"spv-amd-shader-ballot", ["spv-amd-shader-ballot", ""],
"debuginfo", ["debuginfo", ""],
["opencl.debuginfo.100", "CLDEBUG100_"],
] ]
foreach(table, spvtools_vendor_tables) { foreach(table_def, spvtools_vendor_tables) {
spvtools_vendor_table(table) { spvtools_vendor_table(table) {
name = table name = table_def[0]
operand_kind_prefix = table_def[1]
} }
} }
@ -320,10 +328,12 @@ static_library("spvtools") {
":spvtools_core_tables_unified1", ":spvtools_core_tables_unified1",
":spvtools_generators_inc", ":spvtools_generators_inc",
":spvtools_glsl_tables_glsl1-0", ":spvtools_glsl_tables_glsl1-0",
":spvtools_language_header_unified1", ":spvtools_language_header_debuginfo",
":spvtools_language_header_cldebuginfo100",
":spvtools_opencl_tables_opencl1-0", ":spvtools_opencl_tables_opencl1-0",
] ]
foreach(target_name, spvtools_vendor_tables) { foreach(table_def, spvtools_vendor_tables) {
target_name = table_def[0]
deps += [ ":spvtools_vendor_tables_$target_name" ] deps += [ ":spvtools_vendor_tables_$target_name" ]
} }
@ -818,6 +828,7 @@ if (build_with_chromium) {
"test/ext_inst.debuginfo_test.cpp", "test/ext_inst.debuginfo_test.cpp",
"test/ext_inst.glsl_test.cpp", "test/ext_inst.glsl_test.cpp",
"test/ext_inst.opencl_test.cpp", "test/ext_inst.opencl_test.cpp",
"test/ext_inst.cldebug100_test.cpp",
"test/fix_word_test.cpp", "test/fix_word_test.cpp",
"test/generator_magic_number_test.cpp", "test/generator_magic_number_test.cpp",
"test/hex_float_test.cpp", "test/hex_float_test.cpp",
@ -864,7 +875,8 @@ if (build_with_chromium) {
deps = [ deps = [
":spvtools", ":spvtools",
":spvtools_language_header_unified1", ":spvtools_language_header_debuginfo",
":spvtools_language_header_cldebuginfo100",
":spvtools_val", ":spvtools_val",
"//testing/gmock", "//testing/gmock",
"//testing/gtest", "//testing/gtest",

View File

@ -40,6 +40,7 @@ TEST_COPTS = COMMON_COPTS + select({
}) })
DEBUGINFO_GRAMMAR_JSON_FILE = "source/extinst.debuginfo.grammar.json" DEBUGINFO_GRAMMAR_JSON_FILE = "source/extinst.debuginfo.grammar.json"
CLDEBUGINFO100_GRAMMAR_JSON_FILE = "source/extinst.opencl.debuginfo.100.grammar.json"
def generate_core_tables(version = None): def generate_core_tables(version = None):
if not version: if not version:
@ -47,6 +48,7 @@ def generate_core_tables(version = None):
grammars = [ grammars = [
"@spirv_headers//:spirv_core_grammar_" + version, "@spirv_headers//:spirv_core_grammar_" + version,
DEBUGINFO_GRAMMAR_JSON_FILE, DEBUGINFO_GRAMMAR_JSON_FILE,
CLDEBUGINFO100_GRAMMAR_JSON_FILE,
] ]
outs = [ outs = [
"core.insts-{}.inc".format(version), "core.insts-{}.inc".format(version),
@ -61,8 +63,9 @@ def generate_core_tables(version = None):
"$(location :generate_grammar_tables) " + "$(location :generate_grammar_tables) " +
"--spirv-core-grammar=$(location {0}) " + "--spirv-core-grammar=$(location {0}) " +
"--extinst-debuginfo-grammar=$(location {1}) " + "--extinst-debuginfo-grammar=$(location {1}) " +
"--core-insts-output=$(location {2}) " + "--extinst-cldebuginfo100-grammar=$(location {2}) " +
"--operand-kinds-output=$(location {3})" "--core-insts-output=$(location {3}) " +
"--operand-kinds-output=$(location {4})"
).format(*fmtargs), ).format(*fmtargs),
tools = [":generate_grammar_tables"], tools = [":generate_grammar_tables"],
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
@ -74,6 +77,7 @@ def generate_enum_string_mapping(version = None):
grammars = [ grammars = [
"@spirv_headers//:spirv_core_grammar_" + version, "@spirv_headers//:spirv_core_grammar_" + version,
DEBUGINFO_GRAMMAR_JSON_FILE, DEBUGINFO_GRAMMAR_JSON_FILE,
CLDEBUGINFO100_GRAMMAR_JSON_FILE,
] ]
outs = [ outs = [
"extension_enum.inc", "extension_enum.inc",
@ -88,8 +92,9 @@ def generate_enum_string_mapping(version = None):
"$(location :generate_grammar_tables) " + "$(location :generate_grammar_tables) " +
"--spirv-core-grammar=$(location {0}) " + "--spirv-core-grammar=$(location {0}) " +
"--extinst-debuginfo-grammar=$(location {1}) " + "--extinst-debuginfo-grammar=$(location {1}) " +
"--extension-enum-output=$(location {2}) " + "--extinst-cldebuginfo100-grammar=$(location {2}) " +
"--enum-string-mapping-output=$(location {3})" "--extension-enum-output=$(location {3}) " +
"--enum-string-mapping-output=$(location {4})"
).format(*fmtargs), ).format(*fmtargs),
tools = [":generate_grammar_tables"], tools = [":generate_grammar_tables"],
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
@ -137,13 +142,14 @@ def generate_glsl_tables(version = None):
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
) )
def generate_vendor_tables(extension = None): def generate_vendor_tables(extension, operand_kind_prefix = ""):
if not extension: if not extension:
fail("Must specify extension", "extension") fail("Must specify extension", "extension")
extension_rule = extension.replace("-", "_") extension_rule = extension.replace("-", "_").replace(".", "_")
grammars = ["source/extinst.{}.grammar.json".format(extension)] grammars = ["source/extinst.{}.grammar.json".format(extension)]
outs = ["{}.insts.inc".format(extension)] outs = ["{}.insts.inc".format(extension)]
fmtargs = grammars + outs prefices = [operand_kind_prefix]
fmtargs = grammars + outs + prefices
native.genrule( native.genrule(
name = "gen_vendor_tables_" + extension_rule, name = "gen_vendor_tables_" + extension_rule,
srcs = grammars, srcs = grammars,
@ -151,7 +157,8 @@ def generate_vendor_tables(extension = None):
cmd = ( cmd = (
"$(location :generate_grammar_tables) " + "$(location :generate_grammar_tables) " +
"--extinst-vendor-grammar=$(location {0}) " + "--extinst-vendor-grammar=$(location {0}) " +
"--vendor-insts-output=$(location {1})" "--vendor-insts-output=$(location {1}) " +
"--vendor-operand-kind-prefix={2}"
).format(*fmtargs), ).format(*fmtargs),
tools = [":generate_grammar_tables"], tools = [":generate_grammar_tables"],
visibility = ["//visibility:private"], visibility = ["//visibility:private"],

View File

@ -225,13 +225,23 @@ typedef enum spv_operand_type_t {
// A sequence of zero or more pairs of (Id, Literal integer) // A sequence of zero or more pairs of (Id, Literal integer)
LAST_VARIABLE(SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER), LAST_VARIABLE(SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER),
// The following are concrete enum types. // The following are concrete enum types from the DebugInfo extended
// instruction set.
SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS, // DebugInfo Sec 3.2. A mask. SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS, // DebugInfo Sec 3.2. A mask.
SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING, // DebugInfo Sec 3.3 SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING, // DebugInfo Sec 3.3
SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE, // DebugInfo Sec 3.4 SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE, // DebugInfo Sec 3.4
SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER, // DebugInfo Sec 3.5 SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER, // DebugInfo Sec 3.5
SPV_OPERAND_TYPE_DEBUG_OPERATION, // DebugInfo Sec 3.6 SPV_OPERAND_TYPE_DEBUG_OPERATION, // DebugInfo Sec 3.6
// The following are concrete enum types from the OpenCL.DebugInfo.100
// extended instruction set.
SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS, // Sec 3.2. A Mask
SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING, // Sec 3.3
SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_COMPOSITE_TYPE, // Sec 3.4
SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_TYPE_QUALIFIER, // Sec 3.5
SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION, // Sec 3.6
SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY, // Sec 3.7
// This is a sentinel value, and does not represent an operand type. // This is a sentinel value, and does not represent an operand type.
// It should come last. // It should come last.
SPV_OPERAND_TYPE_NUM_OPERAND_TYPES, SPV_OPERAND_TYPE_NUM_OPERAND_TYPES,
@ -248,6 +258,7 @@ typedef enum spv_ext_inst_type_t {
SPV_EXT_INST_TYPE_SPV_AMD_GCN_SHADER, SPV_EXT_INST_TYPE_SPV_AMD_GCN_SHADER,
SPV_EXT_INST_TYPE_SPV_AMD_SHADER_BALLOT, SPV_EXT_INST_TYPE_SPV_AMD_SHADER_BALLOT,
SPV_EXT_INST_TYPE_DEBUGINFO, SPV_EXT_INST_TYPE_DEBUGINFO,
SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100,
// Multiple distinct extended instruction set types could return this // Multiple distinct extended instruction set types could return this
// value, if they are prefixed with NonSemantic. and are otherwise // value, if they are prefixed with NonSemantic. and are otherwise

View File

@ -20,6 +20,7 @@ set(LANG_HEADER_PROCESSING_SCRIPT "${spirv-tools_SOURCE_DIR}/utils/generate_lang
# For now, assume the DebugInfo grammar file is in the current directory. # For now, assume the DebugInfo grammar file is in the current directory.
# It might migrate to SPIRV-Headers. # It might migrate to SPIRV-Headers.
set(DEBUGINFO_GRAMMAR_JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/extinst.debuginfo.grammar.json") set(DEBUGINFO_GRAMMAR_JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/extinst.debuginfo.grammar.json")
set(CLDEBUGINFO100_GRAMMAR_JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/extinst.opencl.debuginfo.100.grammar.json")
# macro() definitions are used in the following because we need to append .inc # macro() definitions are used in the following because we need to append .inc
# file paths into some global lists (*_CPP_DEPENDS). And those global lists are # file paths into some global lists (*_CPP_DEPENDS). And those global lists are
@ -33,9 +34,13 @@ macro(spvtools_core_tables CONFIG_VERSION)
COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
--spirv-core-grammar=${GRAMMAR_JSON_FILE} --spirv-core-grammar=${GRAMMAR_JSON_FILE}
--extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE} --extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE}
--extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
--core-insts-output=${GRAMMAR_INSTS_INC_FILE} --core-insts-output=${GRAMMAR_INSTS_INC_FILE}
--operand-kinds-output=${GRAMMAR_KINDS_INC_FILE} --operand-kinds-output=${GRAMMAR_KINDS_INC_FILE}
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${GRAMMAR_JSON_FILE} ${DEBUGINFO_GRAMMAR_JSON_FILE} DEPENDS ${GRAMMAR_PROCESSING_SCRIPT}
${GRAMMAR_JSON_FILE}
${DEBUGINFO_GRAMMAR_JSON_FILE}
${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
COMMENT "Generate info tables for SPIR-V v${CONFIG_VERSION} core instructions and operands.") COMMENT "Generate info tables for SPIR-V v${CONFIG_VERSION} core instructions and operands.")
list(APPEND OPCODE_CPP_DEPENDS ${GRAMMAR_INSTS_INC_FILE}) list(APPEND OPCODE_CPP_DEPENDS ${GRAMMAR_INSTS_INC_FILE})
list(APPEND OPERAND_CPP_DEPENDS ${GRAMMAR_KINDS_INC_FILE}) list(APPEND OPERAND_CPP_DEPENDS ${GRAMMAR_KINDS_INC_FILE})
@ -50,9 +55,13 @@ macro(spvtools_enum_string_mapping CONFIG_VERSION)
COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
--spirv-core-grammar=${GRAMMAR_JSON_FILE} --spirv-core-grammar=${GRAMMAR_JSON_FILE}
--extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE} --extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE}
--extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
--extension-enum-output=${GRAMMAR_EXTENSION_ENUM_INC_FILE} --extension-enum-output=${GRAMMAR_EXTENSION_ENUM_INC_FILE}
--enum-string-mapping-output=${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE} --enum-string-mapping-output=${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE}
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${GRAMMAR_JSON_FILE} ${DEBUGINFO_GRAMMAR_JSON_FILE} DEPENDS ${GRAMMAR_PROCESSING_SCRIPT}
${GRAMMAR_JSON_FILE}
${DEBUGINFO_GRAMMAR_JSON_FILE}
${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
COMMENT "Generate enum-string mapping for SPIR-V v${CONFIG_VERSION}.") COMMENT "Generate enum-string mapping for SPIR-V v${CONFIG_VERSION}.")
list(APPEND EXTENSION_H_DEPENDS ${GRAMMAR_EXTENSION_ENUM_INC_FILE}) list(APPEND EXTENSION_H_DEPENDS ${GRAMMAR_EXTENSION_ENUM_INC_FILE})
list(APPEND ENUM_STRING_MAPPING_CPP_DEPENDS ${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE}) list(APPEND ENUM_STRING_MAPPING_CPP_DEPENDS ${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE})
@ -101,13 +110,14 @@ macro(spvtools_opencl_tables CONFIG_VERSION)
list(APPEND EXTINST_CPP_DEPENDS ${GRAMMAR_INC_FILE}) list(APPEND EXTINST_CPP_DEPENDS ${GRAMMAR_INC_FILE})
endmacro(spvtools_opencl_tables) endmacro(spvtools_opencl_tables)
macro(spvtools_vendor_tables VENDOR_TABLE SHORT_NAME) macro(spvtools_vendor_tables VENDOR_TABLE SHORT_NAME OPERAND_KIND_PREFIX)
set(INSTS_FILE "${spirv-tools_BINARY_DIR}/${VENDOR_TABLE}.insts.inc") set(INSTS_FILE "${spirv-tools_BINARY_DIR}/${VENDOR_TABLE}.insts.inc")
set(GRAMMAR_FILE "${spirv-tools_SOURCE_DIR}/source/extinst.${VENDOR_TABLE}.grammar.json") set(GRAMMAR_FILE "${spirv-tools_SOURCE_DIR}/source/extinst.${VENDOR_TABLE}.grammar.json")
add_custom_command(OUTPUT ${INSTS_FILE} add_custom_command(OUTPUT ${INSTS_FILE}
COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT} COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
--extinst-vendor-grammar=${GRAMMAR_FILE} --extinst-vendor-grammar=${GRAMMAR_FILE}
--vendor-insts-output=${INSTS_FILE} --vendor-insts-output=${INSTS_FILE}
--vendor-operand-kind-prefix=${OPERAND_KIND_PREFIX}
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${GRAMMAR_FILE} DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${GRAMMAR_FILE}
COMMENT "Generate extended instruction tables for ${VENDOR_TABLE}.") COMMENT "Generate extended instruction tables for ${VENDOR_TABLE}.")
add_custom_target(spv-tools-${SHORT_NAME} DEPENDS ${INSTS_FILE}) add_custom_target(spv-tools-${SHORT_NAME} DEPENDS ${INSTS_FILE})
@ -134,12 +144,14 @@ spvtools_core_tables("unified1")
spvtools_enum_string_mapping("unified1") spvtools_enum_string_mapping("unified1")
spvtools_opencl_tables("unified1") spvtools_opencl_tables("unified1")
spvtools_glsl_tables("unified1") spvtools_glsl_tables("unified1")
spvtools_vendor_tables("spv-amd-shader-explicit-vertex-parameter" "spv-amd-sevp") spvtools_vendor_tables("spv-amd-shader-explicit-vertex-parameter" "spv-amd-sevp" "")
spvtools_vendor_tables("spv-amd-shader-trinary-minmax" "spv-amd-stm") spvtools_vendor_tables("spv-amd-shader-trinary-minmax" "spv-amd-stm" "")
spvtools_vendor_tables("spv-amd-gcn-shader" "spv-amd-gs") spvtools_vendor_tables("spv-amd-gcn-shader" "spv-amd-gs" "")
spvtools_vendor_tables("spv-amd-shader-ballot" "spv-amd-sb") spvtools_vendor_tables("spv-amd-shader-ballot" "spv-amd-sb" "")
spvtools_vendor_tables("debuginfo" "debuginfo") spvtools_vendor_tables("debuginfo" "debuginfo" "")
spvtools_vendor_tables("opencl.debuginfo.100" "cldi100" "CLDEBUG100_")
spvtools_extinst_lang_headers("DebugInfo" ${DEBUGINFO_GRAMMAR_JSON_FILE}) spvtools_extinst_lang_headers("DebugInfo" ${DEBUGINFO_GRAMMAR_JSON_FILE})
spvtools_extinst_lang_headers("OpenCLDebugInfo100" ${CLDEBUGINFO100_GRAMMAR_JSON_FILE})
spvtools_vimsyntax("unified1" "1.0") spvtools_vimsyntax("unified1" "1.0")
add_custom_target(spirv-tools-vimsyntax DEPENDS ${VIMSYNTAX_FILE}) add_custom_target(spirv-tools-vimsyntax DEPENDS ${VIMSYNTAX_FILE})

View File

@ -636,7 +636,12 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
case SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING: case SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING:
case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE: case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE:
case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER: case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER:
case SPV_OPERAND_TYPE_DEBUG_OPERATION: { case SPV_OPERAND_TYPE_DEBUG_OPERATION:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_COMPOSITE_TYPE:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_TYPE_QUALIFIER:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY: {
// A single word that is a plain enum value. // A single word that is a plain enum value.
// Map an optional operand type to its corresponding concrete type. // Map an optional operand type to its corresponding concrete type.
@ -660,6 +665,7 @@ spv_result_t Parser::parseOperand(size_t inst_offset,
case SPV_OPERAND_TYPE_OPTIONAL_IMAGE: case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS: case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
case SPV_OPERAND_TYPE_SELECTION_CONTROL: case SPV_OPERAND_TYPE_SELECTION_CONTROL:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: { case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: {
// This operand is a mask. // This operand is a mask.

View File

@ -280,7 +280,12 @@ void Disassembler::EmitOperand(const spv_parsed_instruction_t& inst,
case SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING: case SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING:
case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE: case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE:
case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER: case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER:
case SPV_OPERAND_TYPE_DEBUG_OPERATION: { case SPV_OPERAND_TYPE_DEBUG_OPERATION:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_COMPOSITE_TYPE:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_TYPE_QUALIFIER:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY: {
spv_operand_desc entry; spv_operand_desc entry;
if (grammar_.lookupOperand(operand.type, word, &entry)) if (grammar_.lookupOperand(operand.type, word, &entry))
assert(false && "should have caught this earlier"); assert(false && "should have caught this earlier");
@ -293,6 +298,7 @@ void Disassembler::EmitOperand(const spv_parsed_instruction_t& inst,
case SPV_OPERAND_TYPE_MEMORY_ACCESS: case SPV_OPERAND_TYPE_MEMORY_ACCESS:
case SPV_OPERAND_TYPE_SELECTION_CONTROL: case SPV_OPERAND_TYPE_SELECTION_CONTROL:
case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS:
EmitMaskOperand(operand.type, word); EmitMaskOperand(operand.type, word);
break; break;
default: default:

View File

@ -28,6 +28,7 @@
#include "debuginfo.insts.inc" #include "debuginfo.insts.inc"
#include "glsl.std.450.insts.inc" #include "glsl.std.450.insts.inc"
#include "opencl.debuginfo.100.insts.inc"
#include "opencl.std.insts.inc" #include "opencl.std.insts.inc"
#include "spirv-tools/libspirv.h" #include "spirv-tools/libspirv.h"
@ -51,6 +52,8 @@ static const spv_ext_inst_group_t kGroups_1_0[] = {
ARRAY_SIZE(spv_amd_shader_ballot_entries), spv_amd_shader_ballot_entries}, ARRAY_SIZE(spv_amd_shader_ballot_entries), spv_amd_shader_ballot_entries},
{SPV_EXT_INST_TYPE_DEBUGINFO, ARRAY_SIZE(debuginfo_entries), {SPV_EXT_INST_TYPE_DEBUGINFO, ARRAY_SIZE(debuginfo_entries),
debuginfo_entries}, debuginfo_entries},
{SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100,
ARRAY_SIZE(opencl_debuginfo_100_entries), opencl_debuginfo_100_entries},
}; };
static const spv_ext_inst_table_t kTable_1_0 = {ARRAY_SIZE(kGroups_1_0), static const spv_ext_inst_table_t kTable_1_0 = {ARRAY_SIZE(kGroups_1_0),
@ -116,6 +119,9 @@ spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) {
if (!strcmp("DebugInfo", name)) { if (!strcmp("DebugInfo", name)) {
return SPV_EXT_INST_TYPE_DEBUGINFO; return SPV_EXT_INST_TYPE_DEBUGINFO;
} }
if (!strcmp("OpenCL.DebugInfo.100", name)) {
return SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100;
}
// ensure to add any known non-semantic extended instruction sets // ensure to add any known non-semantic extended instruction sets
// above this point, and update spvExtInstIsNonSemantic() // above this point, and update spvExtInstIsNonSemantic()
if (!strncmp("NonSemantic.", name, 12)) { if (!strncmp("NonSemantic.", name, 12)) {

View File

@ -0,0 +1,632 @@
{
"copyright" : [
"Copyright (c) 2018 The Khronos Group Inc.",
"",
"Permission is hereby granted, free of charge, to any person obtaining a copy",
"of this software and/or associated documentation files (the \"Materials\"),",
"to deal in the Materials without restriction, including without limitation",
"the rights to use, copy, modify, merge, publish, distribute, sublicense,",
"and/or sell copies of the Materials, and to permit persons to whom the",
"Materials are furnished to do so, subject to the following conditions:",
"",
"The above copyright notice and this permission notice shall be included in",
"all copies or substantial portions of the Materials.",
"",
"MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS",
"STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND",
"HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ",
"",
"THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS",
"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL",
"THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING",
"FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS",
"IN THE MATERIALS."
],
"version" : 200,
"revision" : 2,
"instructions" : [
{
"opname" : "DebugInfoNone",
"opcode" : 0
},
{
"opname" : "DebugCompilationUnit",
"opcode" : 1,
"operands" : [
{ "kind" : "LiteralInteger", "name" : "'Version'" },
{ "kind" : "LiteralInteger", "name" : "'DWARF Version'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "SourceLanguage", "name" : "'Language'" }
]
},
{
"opname" : "DebugTypeBasic",
"opcode" : 2,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "DebugBaseTypeAttributeEncoding", "name" : "'Encoding'" }
]
},
{
"opname" : "DebugTypePointer",
"opcode" : 3,
"operands" : [
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "StorageClass", "name" : "'Storage Class'" },
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" }
]
},
{
"opname" : "DebugTypeQualifier",
"opcode" : 4,
"operands" : [
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "DebugTypeQualifier", "name" : "'Type Qualifier'" }
]
},
{
"opname" : "DebugTypeArray",
"opcode" : 5,
"operands" : [
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "IdRef", "name" : "'Component Counts'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeVector",
"opcode" : 6,
"operands" : [
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "LiteralInteger", "name" : "'Component Count'" }
]
},
{
"opname" : "DebugTypedef",
"opcode" : 7,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Base Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" }
]
},
{
"opname" : "DebugTypeFunction",
"opcode" : 8,
"operands" : [
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Return Type'" },
{ "kind" : "IdRef", "name" : "'Parameter Types'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeEnum",
"opcode" : 9,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Underlying Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" },
{ "kind" : "PairIdRefIdRef", "name" : "'Value, Name, Value, Name, ...'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeComposite",
"opcode" : 10,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "DebugCompositeType", "name" : "'Tag'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Linkage Name'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Members'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeMember",
"opcode" : 11,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Offset'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Value'", "quantifier" : "?" }
]
},
{
"opname" : "DebugTypeInheritance",
"opcode" : 12,
"operands" : [
{ "kind" : "IdRef", "name" : "'Child'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Offset'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" }
]
},
{
"opname" : "DebugTypePtrToMember",
"opcode" : 13,
"operands" : [
{ "kind" : "IdRef", "name" : "'Member Type'" },
{ "kind" : "IdRef", "name" : "'Parent'" }
]
},
{
"opname" : "DebugTypeTemplate",
"opcode" : 14,
"operands" : [
{ "kind" : "IdRef", "name" : "'Target'" },
{ "kind" : "IdRef", "name" : "'Parameters'", "quantifier" : "*" }
]
},
{
"opname" : "DebugTypeTemplateParameter",
"opcode" : 15,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Actual Type'" },
{ "kind" : "IdRef", "name" : "'Value'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" }
]
},
{
"opname" : "DebugTypeTemplateTemplateParameter",
"opcode" : 16,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Template Name'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" }
]
},
{
"opname" : "DebugTypeTemplateParameterPack",
"opcode" : 17,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Template Parameters'", "quantifier" : "*" }
]
},
{
"opname" : "DebugGlobalVariable",
"opcode" : 18,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Linkage Name'" },
{ "kind" : "IdRef", "name" : "'Variable'" },
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" },
{ "kind" : "IdRef", "name" : "'Static Member Declaration'", "quantifier" : "?" }
]
},
{
"opname" : "DebugFunctionDeclaration",
"opcode" : 19,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Linkage Name'" },
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" }
]
},
{
"opname" : "DebugFunction",
"opcode" : 20,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Linkage Name'" },
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" },
{ "kind" : "LiteralInteger", "name" : "'Scope Line'" },
{ "kind" : "IdRef", "name" : "'Function'" },
{ "kind" : "IdRef", "name" : "'Declaration'", "quantifier" : "?" }
]
},
{
"opname" : "DebugLexicalBlock",
"opcode" : 21,
"operands" : [
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "IdRef", "name" : "'Name'", "quantifier" : "?" }
]
},
{
"opname" : "DebugLexicalBlockDiscriminator",
"opcode" : 22,
"operands" : [
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Discriminator'" },
{ "kind" : "IdRef", "name" : "'Parent'" }
]
},
{
"opname" : "DebugScope",
"opcode" : 23,
"operands" : [
{ "kind" : "IdRef", "name" : "'Scope'" },
{ "kind" : "IdRef", "name" : "'Inlined At'", "quantifier" : "?" }
]
},
{
"opname" : "DebugNoScope",
"opcode" : 24
},
{
"opname" : "DebugInlinedAt",
"opcode" : 25,
"operands" : [
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Scope'" },
{ "kind" : "IdRef", "name" : "'Inlined'", "quantifier" : "?" }
]
},
{
"opname" : "DebugLocalVariable",
"opcode" : 26,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Type'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" },
{ "kind" : "DebugInfoFlags", "name" : "'Flags'" },
{ "kind" : "LiteralInteger", "name" : "'Arg Number'", "quantifier" : "?" }
]
},
{
"opname" : "DebugInlinedVariable",
"opcode" : 27,
"operands" : [
{ "kind" : "IdRef", "name" : "'Variable'" },
{ "kind" : "IdRef", "name" : "'Inlined'" }
]
},
{
"opname" : "DebugDeclare",
"opcode" : 28,
"operands" : [
{ "kind" : "IdRef", "name" : "'Local Variable'" },
{ "kind" : "IdRef", "name" : "'Variable'" },
{ "kind" : "IdRef", "name" : "'Expression'" }
]
},
{
"opname" : "DebugValue",
"opcode" : 29,
"operands" : [
{ "kind" : "IdRef", "name" : "'Local Variable'" },
{ "kind" : "IdRef", "name" : "'Value'" },
{ "kind" : "IdRef", "name" : "'Expression'" },
{ "kind" : "IdRef", "name" : "'Indexes'", "quantifier" : "*" }
]
},
{
"opname" : "DebugOperation",
"opcode" : 30,
"operands" : [
{ "kind" : "DebugOperation", "name" : "'OpCode'" },
{ "kind" : "LiteralInteger", "name" : "'Operands ...'", "quantifier" : "*" }
]
},
{
"opname" : "DebugExpression",
"opcode" : 31,
"operands" : [
{ "kind" : "IdRef", "name" : "'Operands ...'", "quantifier" : "*" }
]
},
{
"opname" : "DebugMacroDef",
"opcode" : 32,
"operands" : [
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "IdRef", "name" : "'Value'", "quantifier" : "?" }
]
},
{
"opname" : "DebugMacroUndef",
"opcode" : 33,
"operands" : [
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "IdRef", "name" : "'Macro'" }
]
},
{
"opname" : "DebugImportedEntity",
"opcode" : 34,
"operands" : [
{ "kind" : "IdRef", "name" : "'Name'" },
{ "kind" : "DebugImportedEntity", "name" : "'Tag'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Entity'" },
{ "kind" : "LiteralInteger", "name" : "'Line'" },
{ "kind" : "LiteralInteger", "name" : "'Column'" },
{ "kind" : "IdRef", "name" : "'Parent'" }
]
},
{
"opname" : "DebugSource",
"opcode" : 35,
"operands" : [
{ "kind" : "IdRef", "name" : "'File'" },
{ "kind" : "IdRef", "name" : "'Text'", "quantifier" : "?" }
]
}
],
"operand_kinds" : [
{
"category" : "BitEnum",
"kind" : "DebugInfoFlags",
"enumerants" : [
{
"enumerant" : "FlagIsProtected",
"value" : "0x01"
},
{
"enumerant" : "FlagIsPrivate",
"value" : "0x02"
},
{
"enumerant" : "FlagIsPublic",
"value" : "0x03"
},
{
"enumerant" : "FlagIsLocal",
"value" : "0x04"
},
{
"enumerant" : "FlagIsDefinition",
"value" : "0x08"
},
{
"enumerant" : "FlagFwdDecl",
"value" : "0x10"
},
{
"enumerant" : "FlagArtificial",
"value" : "0x20"
},
{
"enumerant" : "FlagExplicit",
"value" : "0x40"
},
{
"enumerant" : "FlagPrototyped",
"value" : "0x80"
},
{
"enumerant" : "FlagObjectPointer",
"value" : "0x100"
},
{
"enumerant" : "FlagStaticMember",
"value" : "0x200"
},
{
"enumerant" : "FlagIndirectVariable",
"value" : "0x400"
},
{
"enumerant" : "FlagLValueReference",
"value" : "0x800"
},
{
"enumerant" : "FlagRValueReference",
"value" : "0x1000"
},
{
"enumerant" : "FlagIsOptimized",
"value" : "0x2000"
},
{
"enumerant" : "FlagIsEnumClass",
"value" : "0x4000"
},
{
"enumerant" : "FlagTypePassByValue",
"value" : "0x8000"
},
{
"enumerant" : "FlagTypePassByReference",
"value" : "0x10000"
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugBaseTypeAttributeEncoding",
"enumerants" : [
{
"enumerant" : "Unspecified",
"value" : "0"
},
{
"enumerant" : "Address",
"value" : "1"
},
{
"enumerant" : "Boolean",
"value" : "2"
},
{
"enumerant" : "Float",
"value" : "3"
},
{
"enumerant" : "Signed",
"value" : "4"
},
{
"enumerant" : "SignedChar",
"value" : "5"
},
{
"enumerant" : "Unsigned",
"value" : "6"
},
{
"enumerant" : "UnsignedChar",
"value" : "7"
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugCompositeType",
"enumerants" : [
{
"enumerant" : "Class",
"value" : "0"
},
{
"enumerant" : "Structure",
"value" : "1"
},
{
"enumerant" : "Union",
"value" : "2"
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugTypeQualifier",
"enumerants" : [
{
"enumerant" : "ConstType",
"value" : "0"
},
{
"enumerant" : "VolatileType",
"value" : "1"
},
{
"enumerant" : "RestrictType",
"value" : "2"
},
{
"enumerant" : "AtomicType",
"value" : "3"
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugOperation",
"enumerants" : [
{
"enumerant" : "Deref",
"value" : "0"
},
{
"enumerant" : "Plus",
"value" : "1"
},
{
"enumerant" : "Minus",
"value" : "2"
},
{
"enumerant" : "PlusUconst",
"value" : "3",
"parameters" : [
{ "kind" : "LiteralInteger" }
]
},
{
"enumerant" : "BitPiece",
"value" : "4",
"parameters" : [
{ "kind" : "LiteralInteger" },
{ "kind" : "LiteralInteger" }
]
},
{
"enumerant" : "Swap",
"value" : "5"
},
{
"enumerant" : "Xderef",
"value" : "6"
},
{
"enumerant" : "StackValue",
"value" : "7"
},
{
"enumerant" : "Constu",
"value" : "8",
"parameters" : [
{ "kind" : "LiteralInteger" }
]
},
{
"enumerant" : "Fragment",
"value" : "9",
"parameters" : [
{ "kind" : "LiteralInteger" },
{ "kind" : "LiteralInteger" }
]
}
]
},
{
"category" : "ValueEnum",
"kind" : "DebugImportedEntity",
"enumerants" : [
{
"enumerant" : "ImportedModule",
"value" : "0"
},
{
"enumerant" : "ImportedDeclaration",
"value" : "1"
}
]
}
]
}

View File

@ -29,6 +29,7 @@
// per-item basis. https://github.com/KhronosGroup/SPIRV-Tools/issues/1195 // per-item basis. https://github.com/KhronosGroup/SPIRV-Tools/issues/1195
#include "operand.kinds-unified1.inc" #include "operand.kinds-unified1.inc"
#include "spirv-tools/libspirv.h"
static const spv_operand_table_t kOperandTable = { static const spv_operand_table_t kOperandTable = {
ARRAY_SIZE(pygen_variable_OperandInfoTable), ARRAY_SIZE(pygen_variable_OperandInfoTable),
@ -228,6 +229,18 @@ const char* spvOperandTypeStr(spv_operand_type_t type) {
return "debug type qualifier"; return "debug type qualifier";
case SPV_OPERAND_TYPE_DEBUG_OPERATION: case SPV_OPERAND_TYPE_DEBUG_OPERATION:
return "debug operation"; return "debug operation";
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS:
return "OpenCL.DebugInfo.100 debug info flags";
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING:
return "OpenCL.DebugInfo.100 debug base type encoding";
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_COMPOSITE_TYPE:
return "OpenCL.DebugInfo.100 debug composite type";
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_TYPE_QUALIFIER:
return "OpenCL.DebugInfo.100 debug type qualifier";
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION:
return "OpenCL.DebugInfo.100 debug operation";
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY:
return "OpenCL.DebugInfo.100 debug imported entity";
// The next values are for values returned from an instruction, not actually // The next values are for values returned from an instruction, not actually
// an operand. So the specific strings don't matter. But let's add them // an operand. So the specific strings don't matter. But let's add them
@ -312,6 +325,11 @@ bool spvOperandIsConcrete(spv_operand_type_t type) {
case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE: case SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE:
case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER: case SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER:
case SPV_OPERAND_TYPE_DEBUG_OPERATION: case SPV_OPERAND_TYPE_DEBUG_OPERATION:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_COMPOSITE_TYPE:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_TYPE_QUALIFIER:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY:
return true; return true;
default: default:
break; break;
@ -328,6 +346,7 @@ bool spvOperandIsConcreteMask(spv_operand_type_t type) {
case SPV_OPERAND_TYPE_FUNCTION_CONTROL: case SPV_OPERAND_TYPE_FUNCTION_CONTROL:
case SPV_OPERAND_TYPE_MEMORY_ACCESS: case SPV_OPERAND_TYPE_MEMORY_ACCESS:
case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS:
return true; return true;
default: default:
break; break;

View File

@ -400,7 +400,8 @@ spv_result_t spvTextEncodeOperand(const spvtools::AssemblyGrammar& grammar,
case SPV_OPERAND_TYPE_OPTIONAL_IMAGE: case SPV_OPERAND_TYPE_OPTIONAL_IMAGE:
case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS: case SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS:
case SPV_OPERAND_TYPE_SELECTION_CONTROL: case SPV_OPERAND_TYPE_SELECTION_CONTROL:
case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: { case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS:
case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: {
uint32_t value; uint32_t value;
if (grammar.parseMaskOperand(type, textValue, &value)) { if (grammar.parseMaskOperand(type, textValue, &value)) {
return context->diagnostic() << "Invalid " << spvOperandTypeStr(type) return context->diagnostic() << "Invalid " << spvOperandTypeStr(type)

View File

@ -100,6 +100,7 @@ set(TEST_SOURCES
diagnostic_test.cpp diagnostic_test.cpp
enum_string_mapping_test.cpp enum_string_mapping_test.cpp
enum_set_test.cpp enum_set_test.cpp
ext_inst.cldebug100_test.cpp
ext_inst.debuginfo_test.cpp ext_inst.debuginfo_test.cpp
ext_inst.glsl_test.cpp ext_inst.glsl_test.cpp
ext_inst.non_semantic_test.cpp ext_inst.non_semantic_test.cpp

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@ AUTHORS = ['The Khronos Group Inc.',
'Samsung Inc'] 'Samsung Inc']
CURRENT_YEAR='2019' CURRENT_YEAR='2019'
YEARS = '(2014-2016|2015-2016|2016|2016-2017|2017|2018|2019)' YEARS = '(2014-2016|2015-2016|2016|2016-2017|2017|2017-2019|2018|2019)'
COPYRIGHT_RE = re.compile( COPYRIGHT_RE = re.compile(
'Copyright \(c\) {} ({})'.format(YEARS, '|'.join(AUTHORS))) 'Copyright \(c\) {} ({})'.format(YEARS, '|'.join(AUTHORS)))

View File

@ -360,14 +360,22 @@ def generate_instruction_table(inst_table):
return '{}\n\n{}\n\n{}'.format(caps_arrays, exts_arrays, '\n'.join(insts)) return '{}\n\n{}\n\n{}'.format(caps_arrays, exts_arrays, '\n'.join(insts))
def generate_extended_instruction_table(inst_table, set_name): def generate_extended_instruction_table(json_grammar, set_name, operand_kind_prefix=""):
"""Returns the info table containing all SPIR-V extended instructions, """Returns the info table containing all SPIR-V extended instructions,
sorted by opcode, and prefixed by capability arrays. sorted by opcode, and prefixed by capability arrays.
Arguments: Arguments:
- inst_table: a list containing all SPIR-V instructions. - inst_table: a list containing all SPIR-V instructions.
- set_name: the name of the extended instruction set. - set_name: the name of the extended instruction set.
- operand_kind_prefix: the prefix, if any, to add to the front
of operand kind names.
""" """
if operand_kind_prefix:
prefix_operand_kind_names(operand_kind_prefix, json_grammar)
inst_table = json_grammar["instructions"]
set_name = set_name.replace(".", "_")
inst_table = sorted(inst_table, key=lambda k: k['opcode']) inst_table = sorted(inst_table, key=lambda k: k['opcode'])
caps = [inst.get('capabilities', []) for inst in inst_table] caps = [inst.get('capabilities', []) for inst in inst_table]
caps_arrays = generate_capability_arrays(caps) caps_arrays = generate_capability_arrays(caps)
@ -452,6 +460,7 @@ def generate_enum_operand_kind_entry(entry, extension_map):
def generate_enum_operand_kind(enum, synthetic_exts_list): def generate_enum_operand_kind(enum, synthetic_exts_list):
"""Returns the C definition for the given operand kind. """Returns the C definition for the given operand kind.
It's a static const named array of spv_operand_desc_t.
Also appends to |synthetic_exts_list| a list of extension lists Also appends to |synthetic_exts_list| a list of extension lists
used. used.
@ -681,6 +690,26 @@ def precondition_operand_kinds(operand_kinds):
return operand_kinds return operand_kinds
def prefix_operand_kind_names(prefix, json_dict):
"""Modifies json_dict, by prefixing all the operand kind names
with the given prefix. Also modifies their uses in the instructions
to match.
"""
old_to_new = {}
for operand_kind in json_dict["operand_kinds"]:
old_name = operand_kind["kind"]
new_name = prefix + old_name
operand_kind["kind"] = new_name
old_to_new[old_name] = new_name
for instruction in json_dict["instructions"]:
for operand in instruction.get("operands", []):
replacement = old_to_new.get(operand["kind"])
if replacement is not None:
operand["kind"] = replacement
def main(): def main():
import argparse import argparse
parser = argparse.ArgumentParser(description='Generate SPIR-V info tables') parser = argparse.ArgumentParser(description='Generate SPIR-V info tables')
@ -693,6 +722,10 @@ def main():
type=str, required=False, default=None, type=str, required=False, default=None,
help='input JSON grammar file for DebugInfo extended ' help='input JSON grammar file for DebugInfo extended '
'instruction set') 'instruction set')
parser.add_argument('--extinst-cldebuginfo100-grammar', metavar='<path>',
type=str, required=False, default=None,
help='input JSON grammar file for OpenCL.DebugInfo.100 '
'extended instruction set')
parser.add_argument('--extinst-glsl-grammar', metavar='<path>', parser.add_argument('--extinst-glsl-grammar', metavar='<path>',
type=str, required=False, default=None, type=str, required=False, default=None,
help='input JSON grammar file for GLSL extended ' help='input JSON grammar file for GLSL extended '
@ -727,6 +760,9 @@ def main():
parser.add_argument('--vendor-insts-output', metavar='<path>', parser.add_argument('--vendor-insts-output', metavar='<path>',
type=str, required=False, default=None, type=str, required=False, default=None,
help='output file for vendor extended instruction set') help='output file for vendor extended instruction set')
parser.add_argument('--vendor-operand-kind-prefix', metavar='<string>',
type=str, required=False, default=None,
help='prefix for operand kinds (to disambiguate operand type enums)')
args = parser.parse_args() args = parser.parse_args()
if (args.core_insts_output is None) != \ if (args.core_insts_output is None) != \
@ -734,9 +770,12 @@ def main():
print('error: --core-insts-output and --operand-kinds-output ' print('error: --core-insts-output and --operand-kinds-output '
'should be specified together.') 'should be specified together.')
exit(1) exit(1)
if args.operand_kinds_output and not (args.spirv_core_grammar and args.extinst_debuginfo_grammar): if args.operand_kinds_output and not (args.spirv_core_grammar and
args.extinst_debuginfo_grammar and
args.extinst_cldebuginfo100_grammar):
print('error: --operand-kinds-output requires --spirv-core-grammar ' print('error: --operand-kinds-output requires --spirv-core-grammar '
'and --exinst-debuginfo-grammar') 'and --exinst-debuginfo-grammar '
'and --exinst-cldebuginfo100-grammar')
exit(1) exit(1)
if (args.glsl_insts_output is None) != \ if (args.glsl_insts_output is None) != \
(args.extinst_glsl_grammar is None): (args.extinst_glsl_grammar is None):
@ -767,14 +806,19 @@ def main():
core_grammar = json.loads(json_file.read()) core_grammar = json.loads(json_file.read())
with open(args.extinst_debuginfo_grammar) as debuginfo_json_file: with open(args.extinst_debuginfo_grammar) as debuginfo_json_file:
debuginfo_grammar = json.loads(debuginfo_json_file.read()) debuginfo_grammar = json.loads(debuginfo_json_file.read())
instructions = [] with open(args.extinst_cldebuginfo100_grammar) as cldebuginfo100_json_file:
instructions.extend(core_grammar['instructions']) cldebuginfo100_grammar = json.loads(cldebuginfo100_json_file.read())
instructions.extend(debuginfo_grammar['instructions']) prefix_operand_kind_names("CLDEBUG100_", cldebuginfo100_grammar)
operand_kinds = [] instructions = []
operand_kinds.extend(core_grammar['operand_kinds']) instructions.extend(core_grammar['instructions'])
operand_kinds.extend(debuginfo_grammar['operand_kinds']) instructions.extend(debuginfo_grammar['instructions'])
extensions = get_extension_list(instructions, operand_kinds) instructions.extend(cldebuginfo100_grammar['instructions'])
operand_kinds = precondition_operand_kinds(operand_kinds) operand_kinds = []
operand_kinds.extend(core_grammar['operand_kinds'])
operand_kinds.extend(debuginfo_grammar['operand_kinds'])
operand_kinds.extend(cldebuginfo100_grammar['operand_kinds'])
extensions = get_extension_list(instructions, operand_kinds)
operand_kinds = precondition_operand_kinds(operand_kinds)
if args.core_insts_output is not None: if args.core_insts_output is not None:
make_path_to_file(args.core_insts_output) make_path_to_file(args.core_insts_output)
make_path_to_file(args.operand_kinds_output) make_path_to_file(args.operand_kinds_output)
@ -799,7 +843,7 @@ def main():
make_path_to_file(args.glsl_insts_output) make_path_to_file(args.glsl_insts_output)
with open(args.glsl_insts_output, 'w') as f: with open(args.glsl_insts_output, 'w') as f:
f.write(generate_extended_instruction_table( f.write(generate_extended_instruction_table(
grammar['instructions'], 'glsl')) grammar, 'glsl'))
if args.extinst_opencl_grammar is not None: if args.extinst_opencl_grammar is not None:
with open(args.extinst_opencl_grammar) as json_file: with open(args.extinst_opencl_grammar) as json_file:
@ -807,7 +851,7 @@ def main():
make_path_to_file(args.opencl_insts_output) make_path_to_file(args.opencl_insts_output)
with open(args.opencl_insts_output, 'w') as f: with open(args.opencl_insts_output, 'w') as f:
f.write(generate_extended_instruction_table( f.write(generate_extended_instruction_table(
grammar['instructions'], 'opencl')) grammar, 'opencl'))
if args.extinst_vendor_grammar is not None: if args.extinst_vendor_grammar is not None:
with open(args.extinst_vendor_grammar) as json_file: with open(args.extinst_vendor_grammar) as json_file:
@ -818,7 +862,7 @@ def main():
name = name[start:-len('.grammar.json')].replace('-', '_') name = name[start:-len('.grammar.json')].replace('-', '_')
with open(args.vendor_insts_output, 'w') as f: with open(args.vendor_insts_output, 'w') as f:
f.write(generate_extended_instruction_table( f.write(generate_extended_instruction_table(
grammar['instructions'], name)) grammar, name, args.vendor_operand_kind_prefix))
if __name__ == '__main__': if __name__ == '__main__':