Debian Codegraph @

third_party/spirv-tools/Android.mk

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