Skip to content

Commit 5c5afb9

Browse files
aus-inteligcbot
authored andcommitted
Move linux backend plugin code to separate file
1 parent ad26df0 commit 5c5afb9

File tree

3 files changed

+71
-46
lines changed

3 files changed

+71
-46
lines changed

IGC/VectorCompiler/lib/BackendPlugin/CMakeLists.txt

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,8 @@
2222
#
2323
#============================ end_copyright_notice =============================
2424

25-
set(BACKEND_PLUGIN_SOURCES
26-
BackendPlugin.cpp
27-
)
2825

29-
add_library(VCBackendPlugin
30-
MODULE
31-
${BACKEND_PLUGIN_SOURCES}
32-
)
33-
34-
# Hack to avoid transitive LLVM dependencies that will break
35-
# plugin because of duplicate global variables.
36-
# 'CODEGEN_LIBS' will consist of 'VCCodeGen' and all its direct dependencies.
37-
# This should be enough for now. In case of indirect dependencies on VectorCompiler
38-
# libraries, searching algorithm needs to be improved.
39-
# 'CODEGEN_LIBS_FILES' will be expanded to plain library names so cmake
40-
# will not add any transitive dependencies when target is linked against them.
41-
get_target_property(CODEGEN_LIBS VCCodeGen LINK_LIBRARIES)
42-
set(CODEGEN_LIBS VCCodeGen ${CODEGEN_LIBS})
43-
foreach(target ${CODEGEN_LIBS})
44-
# Filter out interface libraries -- these will not produce any files.
45-
set(tgt_type "$<TARGET_PROPERTY:${target},TYPE>")
46-
set(is_iface "$<STREQUAL:${tgt_type},INTERFACE_LIBRARY>")
47-
set(not_iface "$<NOT:${is_iface}>")
48-
49-
set(tgt_file "$<TARGET_FILE:${target}>")
50-
set(whole_gen "$<${not_iface}:${tgt_file}>")
51-
list(APPEND CODEGEN_LIBS_FILES ${whole_gen})
52-
endforeach()
53-
54-
# Cmake also does not add any dependencies for libraries
55-
# that are linked this way.
56-
add_dependencies(VCBackendPlugin
57-
${CODEGEN_LIBS}
58-
)
59-
60-
target_link_libraries(VCBackendPlugin
61-
PRIVATE
62-
VCHeaders
63-
${CODEGEN_LIBS_FILES}
64-
# GenX_IR actually should be linked to LLVMGenXCodeGen.
65-
GenX_IR
66-
)
26+
if(LLVM_ON_UNIX)
27+
include(./Linux.cmake)
28+
return()
29+
endif()
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#=========================== begin_copyright_notice ============================
2+
#
3+
# Copyright (c) 2021 Intel Corporation
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"),
7+
# to deal in the Software without restriction, including without limitation
8+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
9+
# and/or sell copies of the Software, and to permit persons to whom
10+
# the Software is furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included
13+
# in all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21+
# IN THE SOFTWARE.
22+
#
23+
#============================ end_copyright_notice =============================
24+
25+
set(BACKEND_PLUGIN_SOURCES
26+
BackendPlugin.cpp
27+
)
28+
29+
add_library(VCBackendPlugin
30+
MODULE
31+
${BACKEND_PLUGIN_SOURCES}
32+
)
33+
34+
# Hack to avoid transitive LLVM dependencies that will break
35+
# plugin because of duplicate global variables.
36+
# 'CODEGEN_LIBS' will consist of 'VCCodeGen' and all its direct dependencies.
37+
# This should be enough for now. In case of indirect dependencies on VectorCompiler
38+
# libraries, searching algorithm needs to be improved.
39+
# 'CODEGEN_LIBS_FILES' will be expanded to plain library names so cmake
40+
# will not add any transitive dependencies when target is linked against them.
41+
get_target_property(CODEGEN_LIBS VCCodeGen LINK_LIBRARIES)
42+
set(CODEGEN_LIBS VCCodeGen ${CODEGEN_LIBS})
43+
foreach(target ${CODEGEN_LIBS})
44+
# Filter out interface libraries -- these will not produce any files.
45+
set(tgt_type "$<TARGET_PROPERTY:${target},TYPE>")
46+
set(is_iface "$<STREQUAL:${tgt_type},INTERFACE_LIBRARY>")
47+
set(not_iface "$<NOT:${is_iface}>")
48+
49+
set(tgt_file "$<TARGET_FILE:${target}>")
50+
set(whole_gen "$<${not_iface}:${tgt_file}>")
51+
list(APPEND CODEGEN_LIBS_FILES ${whole_gen})
52+
endforeach()
53+
54+
# Cmake also does not add any dependencies for libraries
55+
# that are linked this way.
56+
add_dependencies(VCBackendPlugin
57+
${CODEGEN_LIBS}
58+
)
59+
60+
target_link_libraries(VCBackendPlugin
61+
PRIVATE
62+
VCHeaders
63+
${CODEGEN_LIBS_FILES}
64+
# GenX_IR actually should be linked to LLVMGenXCodeGen.
65+
GenX_IR
66+
)

IGC/VectorCompiler/lib/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,4 @@ add_subdirectory(Support)
2828
add_subdirectory(BiF)
2929
add_subdirectory(Driver)
3030

31-
# Plugin support.
32-
# Only for linux.
33-
if(LLVM_ON_UNIX)
34-
add_subdirectory(BackendPlugin)
35-
endif()
31+
add_subdirectory(BackendPlugin)

0 commit comments

Comments
 (0)