Android.mk 14 KB

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