Skip to content

Commit 33c6261

Browse files
author
Wooyoung Kim
authored
Merge branch 'KhronosGroup:main' into SPV_QCOM_tile_shading
2 parents 144d63c + e8864ed commit 33c6261

30 files changed

+718
-856
lines changed

Android.mk

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -199,44 +199,49 @@ SPVTOOLS_OPT_SRC_FILES := \
199199
source/opt/wrap_opkill.cpp
200200

201201
# Locations of grammar files.
202-
#
203-
SPV_COREUNIFIED1_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/spirv.core.grammar.json
204-
SPV_DEBUGINFO_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.debuginfo.grammar.json
205-
SPV_CLDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json
206-
SPV_VKDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json
202+
GRAMMAR_DIR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1
207203

208204
define gen_spvtools_grammar_tables
205+
# $1 is the output directory, which is unique per ABI.
206+
# Rules for creating grammar tables. They are statically compiled
207+
# into the SPIRV-Tools code.
209208
$(call generate-file-dir,$(1)/core_tables_body.inc)
210209
$(1)/core_tables_body.inc \
211210
$(1)/core_tables_header.inc \
212211
: \
213-
$(LOCAL_PATH)/utils/generate_grammar_tables.py \
214-
$(SPV_COREUNIFIED1_GRAMMAR) \
215-
$(SPV_DEBUGINFO_GRAMMAR) \
216-
$(SPV_CLDEBUGINFO100_GRAMMAR)
217-
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/ggt.py \
218-
--spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
219-
--extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
220-
--extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
221-
--core-tables-body-output=$(1)/core_tables_body.inc \
222-
--core-tables-header-output=$(1)/core_tables_header.inc
223-
@echo "[$(TARGET_ARCH_ABI)] Grammar from unified1) : instructions & operands <= grammar JSON files"
212+
$(LOCAL_PATH)/utils/ggt.py \
213+
$(GRAMMAR_DIR)/extinst.debuginfo.grammar.json \
214+
$(GRAMMAR_DIR)/extinst.glsl.std.450.grammar.json \
215+
$(GRAMMAR_DIR)/extinst.nonsemantic.clspvreflection.grammar.json \
216+
$(GRAMMAR_DIR)/extinst.nonsemantic.shader.debuginfo.100.grammar.json \
217+
$(GRAMMAR_DIR)/extinst.nonsemantic.vkspreflection.grammar.json \
218+
$(GRAMMAR_DIR)/extinst.opencl.debuginfo.100.grammar.json \
219+
$(GRAMMAR_DIR)/extinst.opencl.std.100.grammar.json \
220+
$(GRAMMAR_DIR)/extinst.spv-amd-gcn-shader.grammar.json \
221+
$(GRAMMAR_DIR)/extinst.spv-amd-shader-ballot.grammar.json \
222+
$(GRAMMAR_DIR)/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json \
223+
$(GRAMMAR_DIR)/extinst.spv-amd-shader-trinary-minmax.grammar.json \
224+
$(GRAMMAR_DIR)/spirv.core.grammar.json
225+
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/ggt.py \
226+
--core-tables-body-output=$(1)/core_tables_body.inc \
227+
--core-tables-header-output=$(1)/core_tables_header.inc \
228+
--spirv-core-grammar=$(GRAMMAR_DIR)/spirv.core.grammar.json \
229+
--extinst=,$(GRAMMAR_DIR)/extinst.debuginfo.grammar.json \
230+
--extinst=,$(GRAMMAR_DIR)/extinst.glsl.std.450.grammar.json \
231+
--extinst=,$(GRAMMAR_DIR)/extinst.nonsemantic.clspvreflection.grammar.json \
232+
--extinst=SHDEBUG100_,$(GRAMMAR_DIR)/extinst.nonsemantic.shader.debuginfo.100.grammar.json \
233+
--extinst=,$(GRAMMAR_DIR)/extinst.nonsemantic.vkspreflection.grammar.json \
234+
--extinst=CLDEBUG100_,$(GRAMMAR_DIR)/extinst.opencl.debuginfo.100.grammar.json \
235+
--extinst=,$(GRAMMAR_DIR)/extinst.opencl.std.100.grammar.json \
236+
--extinst=,$(GRAMMAR_DIR)/extinst.spv-amd-gcn-shader.grammar.json \
237+
--extinst=,$(GRAMMAR_DIR)/extinst.spv-amd-shader-ballot.grammar.json \
238+
--extinst=,$(GRAMMAR_DIR)/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json \
239+
--extinst=,$(GRAMMAR_DIR)/extinst.spv-amd-shader-trinary-minmax.grammar.json
240+
@echo "[$(TARGET_ARCH_ABI)] Grammar tables <= grammar JSON files"
224241
# Make all source files depend on the generated core tables
225242
$(foreach F,$(SPVTOOLS_SRC_FILES) $(SPVTOOLS_OPT_SRC_FILES),$(LOCAL_PATH)/$F ) \
226243
: $(1)/core_tables_body.inc \
227244
$(1)/core_tables_header.inc
228-
$(LOCAL_PATH)/source/ext_inst.cpp: \
229-
$(1)/glsl.std.450.insts.inc \
230-
$(1)/opencl.std.100.insts.inc \
231-
$(1)/debuginfo.insts.inc \
232-
$(1)/opencl.debuginfo.100.insts.inc \
233-
$(1)/nonsemantic.shader.debuginfo.100.insts.inc \
234-
$(1)/spv-amd-gcn-shader.insts.inc \
235-
$(1)/spv-amd-shader-ballot.insts.inc \
236-
$(1)/spv-amd-shader-explicit-vertex-parameter.insts.inc \
237-
$(1)/spv-amd-shader-trinary-minmax.insts.inc
238-
$(LOCAL_PATH)/source/opt/amd_ext_to_khr.cpp: \
239-
$(1)/spv-amd-shader-ballot.insts.inc
240245
endef
241246
$(eval $(call gen_spvtools_grammar_tables,$(SPVTOOLS_OUT_PATH)))
242247

@@ -257,36 +262,13 @@ $(1)/$(2).h : \
257262
$(foreach F,$(SPVTOOLS_SRC_FILES) $(SPVTOOLS_OPT_SRC_FILES),$(LOCAL_PATH)/$F ) \
258263
: $(1)/$(2).h
259264
endef
260-
# We generate language-specific headers for DebugInfo and OpenCL.DebugInfo.100
261-
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),DebugInfo,$(SPV_DEBUGINFO_GRAMMAR)))
262-
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),OpenCLDebugInfo100,$(SPV_CLDEBUGINFO100_GRAMMAR)))
263-
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),NonSemanticShaderDebugInfo100,$(SPV_VKDEBUGINFO100_GRAMMAR)))
264265

265266

266-
define gen_spvtools_vendor_tables
267-
$(call generate-file-dir,$(1)/$(2).insts.inc)
268-
$(1)/$(2).insts.inc : \
269-
$(LOCAL_PATH)/utils/generate_grammar_tables.py \
270-
$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.$(2).grammar.json
271-
@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
272-
--extinst-vendor-grammar=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.$(2).grammar.json \
273-
--vendor-insts-output=$(1)/$(2).insts.inc \
274-
--vendor-operand-kind-prefix=$(3)
275-
@echo "[$(TARGET_ARCH_ABI)] Extended instruction set: $(2) tables <= grammar"
276-
$(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).insts.inc
277-
endef
278-
# Vendor and debug extended instruction sets, with grammars from SPIRV-Headers source tree.
279-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),glsl.std.450,""))
280-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),opencl.std.100,""))
281-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),debuginfo,""))
282-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),opencl.debuginfo.100,"CLDEBUG100_"))
283-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.shader.debuginfo.100,"SHDEBUG100_"))
284-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-gcn-shader,""))
285-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-ballot,""))
286-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-explicit-vertex-parameter,""))
287-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-trinary-minmax,""))
288-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.clspvreflection,""))
289-
$(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.vkspreflection,""))
267+
# Generate C++ headers for some extended instruction sets.
268+
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),DebugInfo,$(GRAMMAR_DIR)/extinst.debuginfo.grammar.json))
269+
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),OpenCLDebugInfo100,$(GRAMMAR_DIR)/extinst.opencl.debuginfo.100.grammar.json))
270+
$(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),NonSemanticShaderDebugInfo100,$(GRAMMAR_DIR)/extinst.nonsemantic.shader.debuginfo.100.grammar.json))
271+
290272

291273
define gen_spvtools_build_version_inc
292274
$(call generate-file-dir,$(1)/dummy_filename)

BUILD.bazel

Lines changed: 20 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ load(
55
"DEBUGINFO_GRAMMAR_JSON_FILE",
66
"SHDEBUGINFO100_GRAMMAR_JSON_FILE",
77
"TEST_COPTS",
8-
"generate_compressed_tables",
8+
"create_grammar_tables_target",
9+
"ExtInst",
910
"generate_extinst_lang_headers",
10-
"generate_vendor_tables",
1111
"incompatible_with",
1212
)
1313

@@ -54,40 +54,23 @@ py_binary(
5454
srcs = ["utils/generate_language_headers.py"],
5555
)
5656

57-
generate_compressed_tables()
58-
59-
generate_vendor_tables(
60-
extension = "glsl.std.450",
61-
target = "spirv_glsl_grammar_unified1"
62-
)
63-
64-
generate_vendor_tables(
65-
extension = "opencl.std.100",
66-
target = "spirv_opencl_grammar_unified1"
67-
)
68-
69-
generate_vendor_tables(extension = "spv-amd-shader-explicit-vertex-parameter")
70-
71-
generate_vendor_tables(extension = "spv-amd-shader-trinary-minmax")
72-
73-
generate_vendor_tables(extension = "spv-amd-gcn-shader")
74-
75-
generate_vendor_tables(extension = "spv-amd-shader-ballot")
76-
77-
generate_vendor_tables(extension = "debuginfo")
78-
79-
generate_vendor_tables(extension = "nonsemantic.clspvreflection")
80-
81-
generate_vendor_tables(extension = "nonsemantic.vkspreflection")
82-
83-
generate_vendor_tables(
84-
extension = "opencl.debuginfo.100",
85-
operand_kind_prefix = "CLDEBUG100_",
86-
)
87-
88-
generate_vendor_tables(
89-
extension = "nonsemantic.shader.debuginfo.100",
90-
operand_kind_prefix = "SHDEBUG100_",
57+
create_grammar_tables_target(
58+
name="core", # unused
59+
extinsts = [
60+
ExtInst("glsl.std.450", target="spirv_glsl_grammar_unified1"),
61+
ExtInst("opencl.std.100", target="spirv_opencl_grammar_unified1"),
62+
ExtInst("opencl.debuginfo.100", prefix="CLDEBUG100_"),
63+
ExtInst("nonsemantic.shader.debuginfo.100", prefix="SHDEBUG100_"),
64+
] + [ExtInst(e) for e in [
65+
"spv-amd-shader-explicit-vertex-parameter",
66+
"spv-amd-shader-trinary-minmax",
67+
"spv-amd-gcn-shader",
68+
"spv-amd-shader-ballot",
69+
"debuginfo",
70+
"nonsemantic.clspvreflection",
71+
"nonsemantic.vkspreflection",
72+
]
73+
]
9174
)
9275

9376
generate_extinst_lang_headers(
@@ -162,17 +145,6 @@ cc_library(
162145
":gen_extinst_lang_headers_DebugInfo",
163146
":gen_extinst_lang_headers_NonSemanticShaderDebugInfo100",
164147
":gen_extinst_lang_headers_OpenCLDebugInfo100",
165-
":gen_vendor_tables_spirv_glsl_grammar_unified1",
166-
":gen_vendor_tables_spirv_opencl_grammar_unified1",
167-
":gen_vendor_tables_debuginfo",
168-
":gen_vendor_tables_nonsemantic_clspvreflection",
169-
":gen_vendor_tables_nonsemantic_vkspreflection",
170-
":gen_vendor_tables_nonsemantic_shader_debuginfo_100",
171-
":gen_vendor_tables_opencl_debuginfo_100",
172-
":gen_vendor_tables_spv_amd_gcn_shader",
173-
":gen_vendor_tables_spv_amd_shader_ballot",
174-
":gen_vendor_tables_spv_amd_shader_explicit_vertex_parameter",
175-
":gen_vendor_tables_spv_amd_shader_trinary_minmax",
176148
":generators_inc",
177149
],
178150
hdrs = [
@@ -210,9 +182,7 @@ cc_library(
210182

211183
cc_library(
212184
name = "spirv_tools_opt_internal",
213-
srcs = glob(["source/opt/*.cpp"]) + [
214-
":gen_vendor_tables_spv_amd_shader_ballot",
215-
],
185+
srcs = glob(["source/opt/*.cpp"]),
216186
hdrs = glob(["source/opt/*.h"]) + [
217187
"include/spirv-tools/optimizer.hpp",
218188
],

0 commit comments

Comments
 (0)