Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / libomptarget / plugins-nextgen / CMakeLists.txt
blob9b4f4a5866e7987835734205a26129861270da46
1 ##===----------------------------------------------------------------------===##
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 ##===----------------------------------------------------------------------===##
9 # Build plugins for the user system if available.
11 ##===----------------------------------------------------------------------===##
13 add_subdirectory(common)
15 # void build_generic_elf64(string tmachine, string tmachine_name, string tmachine_libname, string elf_machine_id);
16 # - build a plugin for an ELF based generic 64-bit target based on libffi.
17 # - tmachine: name of the machine processor as used in the cmake build system.
18 # - tmachine_name: name of the machine to be printed with the debug messages.
19 # - tmachine_libname: machine name to be appended to the plugin library name.
20 macro(build_generic_elf64 tmachine tmachine_name tmachine_libname tmachine_triple elf_machine_id)
21 if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
22   if(LIBOMPTARGET_DEP_LIBFFI_FOUND)
24     libomptarget_say("Building ${tmachine_name} NextGen offloading plugin.")
26     # Define macro to be used as prefix of the runtime messages for this target.
27     add_definitions("-DTARGET_NAME=${tmachine_name}")
29     # Define debug prefix. TODO: This should be automatized in the Debug.h but
30     # it requires changing the original plugins.
31     add_definitions(-DDEBUG_PREFIX="TARGET ${tmachine_name} RTL")
33     # Define macro with the ELF ID for this target.
34     add_definitions("-DTARGET_ELF_ID=${elf_machine_id}")
36     # Define target regiple
37     add_definitions("-DLIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE=${tmachine}")
39     add_llvm_library("omptarget.rtl.${tmachine_libname}"
40       SHARED
42       ${CMAKE_CURRENT_SOURCE_DIR}/../generic-elf-64bit/src/rtl.cpp
44       ADDITIONAL_HEADER_DIRS
45       ${LIBOMPTARGET_INCLUDE_DIR}
46       ${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR}
48         LINK_LIBS
49         PRIVATE
50         elf_common
51         MemoryManager
52         PluginInterface
53         ${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
54         ${OPENMP_PTHREAD_LIB}
56       NO_INSTALL_RPATH
57     )
59     if ((OMPT_TARGET_DEFAULT) AND (LIBOMPTARGET_OMPT_SUPPORT))
60       target_link_libraries("omptarget.rtl.${tmachine_libname}" PRIVATE OMPT)
61     endif()
63     if (LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
64       target_link_libraries("omptarget.rtl.${tmachine_libname}" PRIVATE
65         "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports")
66     endif()
68     # Install plugin under the lib destination folder.
69     install(TARGETS "omptarget.rtl.${tmachine_libname}"
70       LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
71     set_target_properties("omptarget.rtl.${tmachine_libname}" PROPERTIES
72       INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.."
73       CXX_VISIBILITY_PRESET protected)
75     target_include_directories( "omptarget.rtl.${tmachine_libname}" PRIVATE
76       ${LIBOMPTARGET_INCLUDE_DIR}
77       ${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR})
79     list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.${tmachine_libname}")
80     set(LIBOMPTARGET_TESTED_PLUGINS
81         "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)
82     set(LIBOMPTARGET_SYSTEM_TARGETS 
83         "${LIBOMPTARGET_SYSTEM_TARGETS} ${tmachine_triple} ${tmachine_triple}-LTO" PARENT_SCOPE)
85   else(LIBOMPTARGET_DEP_LIBFFI_FOUND)
86     libomptarget_say("Not building ${tmachine_name} NextGen offloading plugin: libffi dependency not found.")
87   endif(LIBOMPTARGET_DEP_LIBFFI_FOUND)
88 else()
89   libomptarget_say("Not building ${tmachine_name} NextGen offloading plugin: machine not found in the system.")
90 endif()
91 endmacro()
93 add_subdirectory(aarch64)
94 add_subdirectory(amdgpu)
95 add_subdirectory(cuda)
96 add_subdirectory(ppc64)
97 add_subdirectory(ppc64le)
98 add_subdirectory(x86_64)
100 # Make sure the parent scope can see the plugins that will be created.
101 set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE)
102 set(LIBOMPTARGET_TESTED_PLUGINS "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)