Android.mk 15 KB

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