• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2018 Google LLC
2
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14set(SPIRV_TOOLS_REDUCE_SOURCES
15        change_operand_reduction_opportunity.h
16        change_operand_to_undef_reduction_opportunity.h
17        conditional_branch_to_simple_conditional_branch_opportunity_finder.h
18        conditional_branch_to_simple_conditional_branch_reduction_opportunity.h
19        merge_blocks_reduction_opportunity.h
20        merge_blocks_reduction_opportunity_finder.h
21        operand_to_const_reduction_opportunity_finder.h
22        operand_to_undef_reduction_opportunity_finder.h
23        operand_to_dominating_id_reduction_opportunity_finder.h
24        reducer.h
25        reduction_opportunity.h
26        reduction_opportunity_finder.h
27        reduction_pass.h
28        reduction_util.h
29        remove_block_reduction_opportunity.h
30        remove_block_reduction_opportunity_finder.h
31        remove_function_reduction_opportunity.h
32        remove_function_reduction_opportunity_finder.h
33        remove_instruction_reduction_opportunity.h
34        remove_selection_reduction_opportunity.h
35        remove_selection_reduction_opportunity_finder.h
36        remove_struct_member_reduction_opportunity.h
37        remove_unused_instruction_reduction_opportunity_finder.h
38        remove_unused_struct_member_reduction_opportunity_finder.h
39        simple_conditional_branch_to_branch_opportunity_finder.h
40        simple_conditional_branch_to_branch_reduction_opportunity.h
41        structured_construct_to_block_reduction_opportunity.h
42        structured_construct_to_block_reduction_opportunity_finder.h
43        structured_loop_to_selection_reduction_opportunity.h
44        structured_loop_to_selection_reduction_opportunity_finder.h
45
46        change_operand_reduction_opportunity.cpp
47        change_operand_to_undef_reduction_opportunity.cpp
48        conditional_branch_to_simple_conditional_branch_opportunity_finder.cpp
49        conditional_branch_to_simple_conditional_branch_reduction_opportunity.cpp
50        merge_blocks_reduction_opportunity.cpp
51        merge_blocks_reduction_opportunity_finder.cpp
52        operand_to_const_reduction_opportunity_finder.cpp
53        operand_to_undef_reduction_opportunity_finder.cpp
54        operand_to_dominating_id_reduction_opportunity_finder.cpp
55        reducer.cpp
56        reduction_opportunity.cpp
57        reduction_opportunity_finder.cpp
58        reduction_pass.cpp
59        reduction_util.cpp
60        remove_block_reduction_opportunity.cpp
61        remove_block_reduction_opportunity_finder.cpp
62        remove_function_reduction_opportunity.cpp
63        remove_function_reduction_opportunity_finder.cpp
64        remove_instruction_reduction_opportunity.cpp
65        remove_selection_reduction_opportunity.cpp
66        remove_selection_reduction_opportunity_finder.cpp
67        remove_struct_member_reduction_opportunity.cpp
68        remove_unused_instruction_reduction_opportunity_finder.cpp
69        remove_unused_struct_member_reduction_opportunity_finder.cpp
70        simple_conditional_branch_to_branch_opportunity_finder.cpp
71        simple_conditional_branch_to_branch_reduction_opportunity.cpp
72        structured_construct_to_block_reduction_opportunity.cpp
73        structured_construct_to_block_reduction_opportunity_finder.cpp
74        structured_loop_to_selection_reduction_opportunity.cpp
75        structured_loop_to_selection_reduction_opportunity_finder.cpp
76)
77
78if(MSVC AND (NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")))
79  # Enable parallel builds across four cores for this lib
80  add_definitions(/MP4)
81endif()
82
83spvtools_pch(SPIRV_TOOLS_REDUCE_SOURCES pch_source_reduce)
84
85add_library(SPIRV-Tools-reduce ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_TOOLS_REDUCE_SOURCES})
86
87spvtools_default_compile_options(SPIRV-Tools-reduce)
88target_include_directories(SPIRV-Tools-reduce
89  PUBLIC
90	$<BUILD_INTERFACE:${spirv-tools_SOURCE_DIR}/include>
91	$<BUILD_INTERFACE:${SPIRV_HEADER_INCLUDE_DIR}>
92	$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
93  PRIVATE ${spirv-tools_BINARY_DIR}
94)
95# The reducer reuses a lot of functionality from the SPIRV-Tools library.
96target_link_libraries(SPIRV-Tools-reduce
97  PUBLIC ${SPIRV_TOOLS_FULL_VISIBILITY}
98  PUBLIC SPIRV-Tools-opt)
99
100set_property(TARGET SPIRV-Tools-reduce PROPERTY FOLDER "SPIRV-Tools libraries")
101spvtools_check_symbol_exports(SPIRV-Tools-reduce)
102
103if(ENABLE_SPIRV_TOOLS_INSTALL)
104  install(TARGETS SPIRV-Tools-reduce EXPORT SPIRV-Tools-reduceTargets
105    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
106    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
107    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
108  export(EXPORT SPIRV-Tools-reduceTargets FILE SPIRV-Tools-reduceTarget.cmake)
109
110  spvtools_config_package_dir(SPIRV-Tools-reduce PACKAGE_DIR)
111  install(EXPORT SPIRV-Tools-reduceTargets FILE SPIRV-Tools-reduceTarget.cmake
112  	DESTINATION ${PACKAGE_DIR})
113
114  spvtools_generate_config_file(SPIRV-Tools-reduce)
115  install(FILES ${CMAKE_BINARY_DIR}/SPIRV-Tools-reduceConfig.cmake DESTINATION ${PACKAGE_DIR})
116endif(ENABLE_SPIRV_TOOLS_INSTALL)
117