spirv-val: Update VUIDs for 308 header (#5990)
[KhronosGroup/SPIRV-Tools.git] / Android.mk
blob1414b52497c310617bb615e09981706583f3d306
1 LOCAL_PATH := $(call my-dir)
2 SPVTOOLS_OUT_PATH=$(if $(call host-path-is-absolute,$(TARGET_OUT)),$(TARGET_OUT),$(abspath $(TARGET_OUT)))
4 ifeq ($(SPVHEADERS_LOCAL_PATH),)
5 SPVHEADERS_LOCAL_PATH := $(LOCAL_PATH)/external/spirv-headers
6 endif
8 SPVTOOLS_SRC_FILES := \
9 source/assembly_grammar.cpp \
10 source/binary.cpp \
11 source/diagnostic.cpp \
12 source/disassemble.cpp \
13 source/ext_inst.cpp \
14 source/enum_string_mapping.cpp \
15 source/extensions.cpp \
16 source/libspirv.cpp \
17 source/name_mapper.cpp \
18 source/opcode.cpp \
19 source/operand.cpp \
20 source/parsed_operand.cpp \
21 source/print.cpp \
22 source/software_version.cpp \
23 source/spirv_endian.cpp \
24 source/spirv_optimizer_options.cpp \
25 source/spirv_target_env.cpp \
26 source/spirv_validator_options.cpp \
27 source/table.cpp \
28 source/text.cpp \
29 source/text_handler.cpp \
30 source/to_string.cpp \
31 source/util/bit_vector.cpp \
32 source/util/parse_number.cpp \
33 source/util/string_utils.cpp \
34 source/util/timer.cpp \
35 source/val/basic_block.cpp \
36 source/val/construct.cpp \
37 source/val/function.cpp \
38 source/val/instruction.cpp \
39 source/val/validation_state.cpp \
40 source/val/validate.cpp \
41 source/val/validate_adjacency.cpp \
42 source/val/validate_annotation.cpp \
43 source/val/validate_arithmetics.cpp \
44 source/val/validate_atomics.cpp \
45 source/val/validate_barriers.cpp \
46 source/val/validate_bitwise.cpp \
47 source/val/validate_builtins.cpp \
48 source/val/validate_capability.cpp \
49 source/val/validate_cfg.cpp \
50 source/val/validate_composites.cpp \
51 source/val/validate_constants.cpp \
52 source/val/validate_conversion.cpp \
53 source/val/validate_debug.cpp \
54 source/val/validate_decorations.cpp \
55 source/val/validate_derivatives.cpp \
56 source/val/validate_extensions.cpp \
57 source/val/validate_execution_limitations.cpp \
58 source/val/validate_function.cpp \
59 source/val/validate_id.cpp \
60 source/val/validate_image.cpp \
61 source/val/validate_interfaces.cpp \
62 source/val/validate_instruction.cpp \
63 source/val/validate_memory.cpp \
64 source/val/validate_memory_semantics.cpp \
65 source/val/validate_mesh_shading.cpp \
66 source/val/validate_misc.cpp \
67 source/val/validate_mode_setting.cpp \
68 source/val/validate_layout.cpp \
69 source/val/validate_literals.cpp \
70 source/val/validate_logicals.cpp \
71 source/val/validate_non_uniform.cpp \
72 source/val/validate_primitives.cpp \
73 source/val/validate_ray_query.cpp \
74 source/val/validate_ray_tracing.cpp \
75 source/val/validate_ray_tracing_reorder.cpp \
76 source/val/validate_scopes.cpp \
77 source/val/validate_small_type_uses.cpp \
78 source/val/validate_tensor_layout.cpp \
79 source/val/validate_type.cpp
81 SPVTOOLS_OPT_SRC_FILES := \
82 source/opt/aggressive_dead_code_elim_pass.cpp \
83 source/opt/amd_ext_to_khr.cpp \
84 source/opt/analyze_live_input_pass.cpp \
85 source/opt/basic_block.cpp \
86 source/opt/block_merge_pass.cpp \
87 source/opt/block_merge_util.cpp \
88 source/opt/build_module.cpp \
89 source/opt/cfg.cpp \
90 source/opt/cfg_cleanup_pass.cpp \
91 source/opt/ccp_pass.cpp \
92 source/opt/code_sink.cpp \
93 source/opt/combine_access_chains.cpp \
94 source/opt/compact_ids_pass.cpp \
95 source/opt/composite.cpp \
96 source/opt/const_folding_rules.cpp \
97 source/opt/constants.cpp \
98 source/opt/control_dependence.cpp \
99 source/opt/convert_to_sampled_image_pass.cpp \
100 source/opt/convert_to_half_pass.cpp \
101 source/opt/copy_prop_arrays.cpp \
102 source/opt/dataflow.cpp \
103 source/opt/dead_branch_elim_pass.cpp \
104 source/opt/dead_insert_elim_pass.cpp \
105 source/opt/dead_variable_elimination.cpp \
106 source/opt/decoration_manager.cpp \
107 source/opt/debug_info_manager.cpp \
108 source/opt/def_use_manager.cpp \
109 source/opt/desc_sroa.cpp \
110 source/opt/desc_sroa_util.cpp \
111 source/opt/dominator_analysis.cpp \
112 source/opt/dominator_tree.cpp \
113 source/opt/eliminate_dead_constant_pass.cpp \
114 source/opt/eliminate_dead_functions_pass.cpp \
115 source/opt/eliminate_dead_functions_util.cpp \
116 source/opt/eliminate_dead_io_components_pass.cpp \
117 source/opt/eliminate_dead_members_pass.cpp \
118 source/opt/eliminate_dead_output_stores_pass.cpp \
119 source/opt/feature_manager.cpp \
120 source/opt/fix_func_call_arguments.cpp \
121 source/opt/fix_storage_class.cpp \
122 source/opt/flatten_decoration_pass.cpp \
123 source/opt/fold.cpp \
124 source/opt/folding_rules.cpp \
125 source/opt/fold_spec_constant_op_and_composite_pass.cpp \
126 source/opt/freeze_spec_constant_value_pass.cpp \
127 source/opt/function.cpp \
128 source/opt/graphics_robust_access_pass.cpp \
129 source/opt/if_conversion.cpp \
130 source/opt/inline_pass.cpp \
131 source/opt/inline_exhaustive_pass.cpp \
132 source/opt/inline_opaque_pass.cpp \
133 source/opt/instruction.cpp \
134 source/opt/instruction_list.cpp \
135 source/opt/interface_var_sroa.cpp \
136 source/opt/interp_fixup_pass.cpp \
137 source/opt/invocation_interlock_placement_pass.cpp \
138 source/opt/ir_context.cpp \
139 source/opt/ir_loader.cpp \
140 source/opt/licm_pass.cpp \
141 source/opt/liveness.cpp \
142 source/opt/local_access_chain_convert_pass.cpp \
143 source/opt/local_redundancy_elimination.cpp \
144 source/opt/local_single_block_elim_pass.cpp \
145 source/opt/local_single_store_elim_pass.cpp \
146 source/opt/loop_dependence.cpp \
147 source/opt/loop_dependence_helpers.cpp \
148 source/opt/loop_descriptor.cpp \
149 source/opt/loop_fission.cpp \
150 source/opt/loop_fusion.cpp \
151 source/opt/loop_fusion_pass.cpp \
152 source/opt/loop_peeling.cpp \
153 source/opt/loop_unroller.cpp \
154 source/opt/loop_unswitch_pass.cpp \
155 source/opt/loop_utils.cpp \
156 source/opt/mem_pass.cpp \
157 source/opt/merge_return_pass.cpp \
158 source/opt/modify_maximal_reconvergence.cpp \
159 source/opt/module.cpp \
160 source/opt/opextinst_forward_ref_fixup_pass.cpp \
161 source/opt/optimizer.cpp \
162 source/opt/pass.cpp \
163 source/opt/pass_manager.cpp \
164 source/opt/private_to_local_pass.cpp \
165 source/opt/propagator.cpp \
166 source/opt/reduce_load_size.cpp \
167 source/opt/redundancy_elimination.cpp \
168 source/opt/register_pressure.cpp \
169 source/opt/relax_float_ops_pass.cpp \
170 source/opt/remove_dontinline_pass.cpp \
171 source/opt/remove_duplicates_pass.cpp \
172 source/opt/remove_unused_interface_variables_pass.cpp \
173 source/opt/replace_desc_array_access_using_var_index.cpp \
174 source/opt/replace_invalid_opc.cpp \
175 source/opt/scalar_analysis.cpp \
176 source/opt/scalar_analysis_simplification.cpp \
177 source/opt/scalar_replacement_pass.cpp \
178 source/opt/set_spec_constant_default_value_pass.cpp \
179 source/opt/simplification_pass.cpp \
180 source/opt/spread_volatile_semantics.cpp \
181 source/opt/ssa_rewrite_pass.cpp \
182 source/opt/strength_reduction_pass.cpp \
183 source/opt/strip_debug_info_pass.cpp \
184 source/opt/strip_nonsemantic_info_pass.cpp \
185 source/opt/struct_cfg_analysis.cpp \
186 source/opt/struct_packing_pass.cpp \
187 source/opt/switch_descriptorset_pass.cpp \
188 source/opt/trim_capabilities_pass.cpp \
189 source/opt/type_manager.cpp \
190 source/opt/types.cpp \
191 source/opt/unify_const_pass.cpp \
192 source/opt/upgrade_memory_model.cpp \
193 source/opt/value_number_table.cpp \
194 source/opt/vector_dce.cpp \
195 source/opt/workaround1209.cpp \
196 source/opt/wrap_opkill.cpp
198 # Locations of grammar files.
200 SPV_COREUNIFIED1_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/spirv.core.grammar.json
201 SPV_GLSL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.glsl.std.450.grammar.json
202 SPV_OPENCL_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.opencl.std.100.grammar.json
203 SPV_DEBUGINFO_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.debuginfo.grammar.json
204 SPV_CLDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json
205 SPV_VKDEBUGINFO100_GRAMMAR=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.nonsemantic.shader.debuginfo.100.grammar.json
207 define gen_spvtools_grammar_tables
208 $(call generate-file-dir,$(1)/core.insts-unified1.inc)
209 $(1)/core.insts-unified1.inc $(1)/operand.kinds-unified1.inc \
210 $(1)/glsl.std.450.insts.inc \
211 $(1)/opencl.std.insts.inc \
213 $(LOCAL_PATH)/utils/generate_grammar_tables.py \
214 $(SPV_COREUNIFIED1_GRAMMAR) \
215 $(SPV_GLSL_GRAMMAR) \
216 $(SPV_OpenCL_GRAMMAR) \
217 $(SPV_DEBUGINFO_GRAMMAR) \
218 $(SPV_CLDEBUGINFO100_GRAMMAR)
219 @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
220 --spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
221 --extinst-glsl-grammar=$(SPV_GLSL_GRAMMAR) \
222 --extinst-opencl-grammar=$(SPV_OPENCL_GRAMMAR) \
223 --extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
224 --extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
225 --core-insts-output=$(1)/core.insts-unified1.inc \
226 --glsl-insts-output=$(1)/glsl.std.450.insts.inc \
227 --opencl-insts-output=$(1)/opencl.std.insts.inc \
228 --operand-kinds-output=$(1)/operand.kinds-unified1.inc \
229 --output-language=c++
230 @echo "[$(TARGET_ARCH_ABI)] Grammar (from unified1) : instructions & operands <= grammar JSON files"
231 $(LOCAL_PATH)/source/opcode.cpp: $(1)/core.insts-unified1.inc
232 $(LOCAL_PATH)/source/operand.cpp: $(1)/operand.kinds-unified1.inc
233 $(LOCAL_PATH)/source/ext_inst.cpp: \
234 $(1)/glsl.std.450.insts.inc \
235 $(1)/opencl.std.insts.inc \
236 $(1)/debuginfo.insts.inc \
237 $(1)/opencl.debuginfo.100.insts.inc \
238 $(1)/nonsemantic.shader.debuginfo.100.insts.inc \
239 $(1)/spv-amd-gcn-shader.insts.inc \
240 $(1)/spv-amd-shader-ballot.insts.inc \
241 $(1)/spv-amd-shader-explicit-vertex-parameter.insts.inc \
242 $(1)/spv-amd-shader-trinary-minmax.insts.inc
243 $(LOCAL_PATH)/source/opt/amd_ext_to_khr.cpp: \
244 $(1)/spv-amd-shader-ballot.insts.inc
245 endef
246 $(eval $(call gen_spvtools_grammar_tables,$(SPVTOOLS_OUT_PATH)))
249 define gen_spvtools_lang_headers
250 # Generate language-specific headers. So far we only generate C headers
251 # $1 is the output directory.
252 # $2 is the base name of the header file, e.g. "DebugInfo".
253 # $3 is the grammar file containing token definitions.
254 $(call generate-file-dir,$(1)/$(2).h)
255 $(1)/$(2).h : \
256 $(LOCAL_PATH)/utils/generate_language_headers.py \
257 $(3)
258 @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_language_headers.py \
259 --extinst-grammar=$(3) \
260 --extinst-output-path=$(1)/$(2).h
261 @echo "[$(TARGET_ARCH_ABI)] Generate language specific header for $(2): headers <= grammar"
262 $(foreach F,$(SPVTOOLS_SRC_FILES) $(SPVTOOLS_OPT_SRC_FILES),$(LOCAL_PATH)/$F ) \
263 : $(1)/$(2).h
264 endef
265 # We generate language-specific headers for DebugInfo and OpenCL.DebugInfo.100
266 $(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),DebugInfo,$(SPV_DEBUGINFO_GRAMMAR)))
267 $(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),OpenCLDebugInfo100,$(SPV_CLDEBUGINFO100_GRAMMAR)))
268 $(eval $(call gen_spvtools_lang_headers,$(SPVTOOLS_OUT_PATH),NonSemanticShaderDebugInfo100,$(SPV_VKDEBUGINFO100_GRAMMAR)))
271 define gen_spvtools_vendor_tables
272 $(call generate-file-dir,$(1)/$(2).insts.inc)
273 $(1)/$(2).insts.inc : \
274 $(LOCAL_PATH)/utils/generate_grammar_tables.py \
275 $(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.$(2).grammar.json
276 @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
277 --extinst-vendor-grammar=$(SPVHEADERS_LOCAL_PATH)/include/spirv/unified1/extinst.$(2).grammar.json \
278 --vendor-insts-output=$(1)/$(2).insts.inc \
279 --vendor-operand-kind-prefix=$(3)
280 @echo "[$(TARGET_ARCH_ABI)] Vendor extended instruction set: $(2) tables <= grammar"
281 $(LOCAL_PATH)/source/ext_inst.cpp: $(1)/$(2).insts.inc
282 endef
283 # Vendor and debug extended instruction sets, with grammars from SPIRV-Tools source tree.
284 $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),debuginfo,""))
285 $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),opencl.debuginfo.100,"CLDEBUG100_"))
286 $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.shader.debuginfo.100,"SHDEBUG100_"))
287 $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-gcn-shader,""))
288 $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-ballot,""))
289 $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-explicit-vertex-parameter,""))
290 $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),spv-amd-shader-trinary-minmax,""))
291 $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.clspvreflection,""))
292 $(eval $(call gen_spvtools_vendor_tables,$(SPVTOOLS_OUT_PATH),nonsemantic.vkspreflection,""))
294 define gen_spvtools_enum_string_mapping
295 $(call generate-file-dir,$(1)/extension_enum.inc.inc)
296 $(1)/extension_enum.inc $(1)/enum_string_mapping.inc: \
297 $(LOCAL_PATH)/utils/generate_grammar_tables.py \
298 $(SPV_COREUNIFIED1_GRAMMAR)
299 @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_grammar_tables.py \
300 --spirv-core-grammar=$(SPV_COREUNIFIED1_GRAMMAR) \
301 --extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
302 --extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
303 --extension-enum-output=$(1)/extension_enum.inc \
304 --enum-string-mapping-output=$(1)/enum_string_mapping.inc \
305 --output-language=c++
306 @echo "[$(TARGET_ARCH_ABI)] Generate enum<->string mapping <= grammar JSON files"
307 # Generated header extension_enum.inc is transitively included by table.h, which is
308 # used pervasively. Capture the pervasive dependency.
309 $(foreach F,$(SPVTOOLS_SRC_FILES) $(SPVTOOLS_OPT_SRC_FILES),$(LOCAL_PATH)/$F ) \
310 : $(1)/extension_enum.inc
311 $(LOCAL_PATH)/source/enum_string_mapping.cpp: $(1)/enum_string_mapping.inc
312 endef
313 $(eval $(call gen_spvtools_enum_string_mapping,$(SPVTOOLS_OUT_PATH)))
315 define gen_spvtools_build_version_inc
316 $(call generate-file-dir,$(1)/dummy_filename)
317 $(1)/build-version.inc: \
318 $(LOCAL_PATH)/utils/update_build_version.py \
319 $(LOCAL_PATH)/CHANGES
320 @$(HOST_PYTHON) $(LOCAL_PATH)/utils/update_build_version.py \
321 $(LOCAL_PATH)/CHANGES $(1)/build-version.inc
322 @echo "[$(TARGET_ARCH_ABI)] Generate : build-version.inc <= CHANGES"
323 $(LOCAL_PATH)/source/software_version.cpp: $(1)/build-version.inc
324 endef
325 $(eval $(call gen_spvtools_build_version_inc,$(SPVTOOLS_OUT_PATH)))
327 define gen_spvtools_generators_inc
328 $(call generate-file-dir,$(1)/dummy_filename)
329 $(1)/generators.inc: \
330 $(LOCAL_PATH)/utils/generate_registry_tables.py \
331 $(SPVHEADERS_LOCAL_PATH)/include/spirv/spir-v.xml
332 @$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_registry_tables.py \
333 --xml=$(SPVHEADERS_LOCAL_PATH)/include/spirv/spir-v.xml \
334 --generator-output=$(1)/generators.inc
335 @echo "[$(TARGET_ARCH_ABI)] Generate : generators.inc <= spir-v.xml"
336 $(LOCAL_PATH)/source/opcode.cpp: $(1)/generators.inc
337 endef
338 $(eval $(call gen_spvtools_generators_inc,$(SPVTOOLS_OUT_PATH)))
340 include $(CLEAR_VARS)
341 LOCAL_MODULE := SPIRV-Tools
342 LOCAL_C_INCLUDES := \
343 $(LOCAL_PATH)/include \
344 $(SPVHEADERS_LOCAL_PATH)/include \
345 $(SPVTOOLS_OUT_PATH)
346 LOCAL_EXPORT_C_INCLUDES := \
347 $(LOCAL_PATH)/include
348 LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror
349 LOCAL_SRC_FILES:= $(SPVTOOLS_SRC_FILES)
350 include $(BUILD_STATIC_LIBRARY)
352 include $(CLEAR_VARS)
353 LOCAL_MODULE := SPIRV-Tools-opt
354 LOCAL_C_INCLUDES := \
355 $(LOCAL_PATH)/include \
356 $(LOCAL_PATH)/source \
357 $(SPVHEADERS_LOCAL_PATH)/include \
358 $(SPVTOOLS_OUT_PATH)
359 LOCAL_CXXFLAGS:=-std=c++17 -fno-exceptions -fno-rtti -Werror
360 LOCAL_STATIC_LIBRARIES:=SPIRV-Tools
361 LOCAL_SRC_FILES:= $(SPVTOOLS_OPT_SRC_FILES)
362 include $(BUILD_STATIC_LIBRARY)