[libclc] [libclc] Use custom CMake handling to overhaul libclc compilation (PR #185247)
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 8 16:46:03 PDT 2026
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/185247
>From e707abca4e38afdcff3f77d6cecbcefdea37181e Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Sat, 7 Mar 2026 15:16:52 -0600
Subject: [PATCH 1/2] [libclc] Use custom CMake handling to overhaul libclc
compilation
Summary:
This PR uses https://github.com/llvm/llvm-project/pull/185243 to
overhaul compilation of libclc. This brings libclc to the same kind of
compilation flow that the other GPU libraries use (compiler-rt, libc,
libc++, openmp, flang-rt).
The main brunt of this change is simply changing the SOURCES files to
CMake variables and altering the compilation. Now that these are
standard CMake libraries we do not need to bother redefining custom
library handling and targets.
This builds as a static library, which we then consume with `llvm-link`
which converts it into a single `.bc` bitcode file similarly to before.
The final result is then optimized all together.
Hopefully this doesn't break anything.
Comments
cleanup and comments
Simplify functions and add helper
---
libclc/CMakeLists.txt | 492 +++++++-------
libclc/clc/lib/amdgcn/CMakeLists.txt | 22 +
libclc/clc/lib/amdgcn/SOURCES | 19 -
libclc/clc/lib/amdgpu/CMakeLists.txt | 16 +
libclc/clc/lib/amdgpu/SOURCES | 13 -
libclc/clc/lib/clspv/CMakeLists.txt | 5 +
libclc/clc/lib/clspv/SOURCES | 2 -
libclc/clc/lib/generic/CMakeLists.txt | 190 ++++++
libclc/clc/lib/generic/SOURCES | 187 ------
libclc/clc/lib/ptx-nvidiacl/CMakeLists.txt | 18 +
libclc/clc/lib/ptx-nvidiacl/SOURCES | 15 -
libclc/clc/lib/spirv/CMakeLists.txt | 5 +
libclc/clc/lib/spirv/SOURCES | 2 -
libclc/cmake/modules/AddLibclc.cmake | 600 ++----------------
libclc/opencl/lib/amdgcn/CMakeLists.txt | 5 +
libclc/opencl/lib/amdgcn/SOURCES | 2 -
libclc/opencl/lib/clspv/CMakeLists.txt | 89 +++
libclc/opencl/lib/clspv/SOURCES | 77 ---
libclc/opencl/lib/generic/CMakeLists.txt | 223 +++++++
libclc/opencl/lib/generic/SOURCES | 220 -------
libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt | 1 +
libclc/opencl/lib/spirv/CMakeLists.txt | 78 +++
libclc/opencl/lib/spirv/SOURCES | 71 ---
23 files changed, 928 insertions(+), 1424 deletions(-)
create mode 100644 libclc/clc/lib/amdgcn/CMakeLists.txt
delete mode 100644 libclc/clc/lib/amdgcn/SOURCES
create mode 100644 libclc/clc/lib/amdgpu/CMakeLists.txt
delete mode 100644 libclc/clc/lib/amdgpu/SOURCES
create mode 100644 libclc/clc/lib/clspv/CMakeLists.txt
delete mode 100644 libclc/clc/lib/clspv/SOURCES
create mode 100644 libclc/clc/lib/generic/CMakeLists.txt
delete mode 100644 libclc/clc/lib/generic/SOURCES
create mode 100644 libclc/clc/lib/ptx-nvidiacl/CMakeLists.txt
delete mode 100644 libclc/clc/lib/ptx-nvidiacl/SOURCES
create mode 100644 libclc/clc/lib/spirv/CMakeLists.txt
delete mode 100644 libclc/clc/lib/spirv/SOURCES
create mode 100644 libclc/opencl/lib/amdgcn/CMakeLists.txt
delete mode 100644 libclc/opencl/lib/amdgcn/SOURCES
create mode 100644 libclc/opencl/lib/clspv/CMakeLists.txt
delete mode 100644 libclc/opencl/lib/clspv/SOURCES
create mode 100644 libclc/opencl/lib/generic/CMakeLists.txt
delete mode 100644 libclc/opencl/lib/generic/SOURCES
create mode 100644 libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt
create mode 100644 libclc/opencl/lib/spirv/CMakeLists.txt
delete mode 100644 libclc/opencl/lib/spirv/SOURCES
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 6448bb8b3df5b..56ca808818e86 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -12,29 +12,12 @@ list( INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
enable_language( CLC )
-set( LIBCLC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
-set( LIBCLC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
-set( LIBCLC_OBJFILE_DIR ${LIBCLC_BINARY_DIR}/obj.libclc.dir )
-
include( AddLibclc )
include( GNUInstallDirs )
-set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
- # OpenCL libraries
- opencl/lib/amdgcn-amdhsa/SOURCES;
- opencl/lib/amdgcn/SOURCES;
- opencl/lib/clspv/SOURCES;
- opencl/lib/generic/SOURCES;
- opencl/lib/ptx-nvidiacl/SOURCES;
- opencl/lib/spirv/SOURCES;
- # CLC internal libraries
- clc/lib/generic/SOURCES;
- clc/lib/amdgcn/SOURCES;
- clc/lib/amdgpu/SOURCES;
- clc/lib/clspv/SOURCES;
- clc/lib/ptx-nvidiacl/SOURCES;
- clc/lib/spirv/SOURCES;
-)
+
+set( LIBCLC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
+set( LIBCLC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
# A runtimes cross-build should only use the requested target.
set( LIBCLC_DEFAULT_TARGET "all" )
@@ -48,14 +31,19 @@ option(
LIBCLC_USE_SPIRV_BACKEND "Build SPIR-V targets with the SPIR-V backend." OFF
)
-# Top level target used to build all Libclc libraries.
-add_custom_target( libclc ALL )
-
-add_custom_target( libclc-opencl-builtins COMMENT "Build libclc OpenCL builtins" )
-add_dependencies( libclc libclc-opencl-builtins )
+# List of all supported targets.
+set( LIBCLC_TARGETS_ALL
+ amdgcn--
+ amdgcn-amd-amdhsa-llvm
+ amdgcn-mesa-mesa3d
+ clspv--
+ clspv64--
+ nvptx64--
+ nvptx64--nvidiacl
+ nvptx64-nvidia-cuda
+)
if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
- # Out-of-tree configuration
set( LIBCLC_STANDALONE_BUILD TRUE )
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
@@ -63,20 +51,16 @@ if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DI
message( STATUS "libclc LLVM version: ${LLVM_PACKAGE_VERSION}" )
- # Import required tools
- if( NOT EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
- foreach( tool IN ITEMS clang llvm-as llvm-link opt )
- find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
- set( ${tool}_exe ${LLVM_TOOL_${tool}} )
- set( ${tool}_target )
- endforeach()
- endif()
+ foreach( tool IN ITEMS llvm-link opt )
+ find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
+ set( ${tool}_exe ${LLVM_TOOL_${tool}} )
+ set( ${tool}_target )
+ endforeach()
# Setup the paths where libclc runtimes should be stored.
set( LIBCLC_OUTPUT_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
set( LIBCLC_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/clc )
else()
- # In-tree configuration
set( LIBCLC_STANDALONE_BUILD FALSE )
if( NOT LLVM_PACKAGE_VERSION )
@@ -91,12 +75,8 @@ else()
message(FATAL_ERROR "Clang is not enabled, but is required to build libclc in-tree")
endif()
- if( NOT EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
- get_host_tool_path( clang CLANG clang_exe clang_target )
- get_host_tool_path( llvm-as LLVM_AS llvm-as_exe llvm-as_target )
- get_host_tool_path( llvm-link LLVM_LINK llvm-link_exe llvm-link_target )
- get_host_tool_path( opt OPT opt_exe opt_target )
- endif()
+ get_host_tool_path( llvm-link LLVM_LINK llvm-link_exe llvm-link_target )
+ get_host_tool_path( opt OPT opt_exe opt_target )
# Setup the paths where libclc runtimes should be stored. By default, in an
# in-tree build we place the libraries in clang's resource driectory.
@@ -108,28 +88,6 @@ else()
cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_INSTALL_DIR} )
endif()
-if( EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
- message( WARNING "Using custom LLVM tools to build libclc: "
- "${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR}, "
- " ensure the tools are up to date." )
- # Note - use a differently named variable than LLVM_TOOL_${tool} as above, as
- # the variable name is used to cache the result of find_program. If we used
- # the same name, a user wouldn't be able to switch a build between default
- # and custom tools.
- foreach( tool IN ITEMS clang llvm-as llvm-link opt )
- find_program( LLVM_CUSTOM_TOOL_${tool} ${tool}
- PATHS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
- set( ${tool}_exe ${LLVM_CUSTOM_TOOL_${tool}} )
- set( ${tool}_target )
- endforeach()
-endif()
-
-foreach( tool IN ITEMS clang opt llvm-as llvm-link )
- if( NOT EXISTS "${${tool}_exe}" AND "${${tool}_target}" STREQUAL "" )
- message( FATAL_ERROR "libclc toolchain incomplete - missing tool ${tool}!" )
- endif()
-endforeach()
-
if( NOT LIBCLC_USE_SPIRV_BACKEND )
# llvm-spirv is an optional dependency, used to build spirv-* targets when
# the SPIR-V backend hasn't been requested. It may be provided in-tree or
@@ -143,80 +101,44 @@ if( NOT LIBCLC_USE_SPIRV_BACKEND )
endif()
endif()
-# List of all targets. Note that some are added dynamically below.
-set( LIBCLC_TARGETS_ALL
- amdgcn--
- amdgcn-amd-amdhsa-llvm
- clspv--
- clspv64--
- nvptx64--
- nvptx64--nvidiacl
- nvptx64-nvidia-cuda
-)
-
-# The mesa3d environment is only available since LLVM 4.0
-if( LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 4.0.0 )
- list( APPEND LIBCLC_TARGETS_ALL amdgcn-mesa-mesa3d )
-endif()
-
-# The spirv-mesa3d and spirv64-mesa3d targets are optional and can be built
-# with either the LLVM SPIR-V backend or the external llvm-spirv tool.
if( LIBCLC_USE_SPIRV_BACKEND OR llvm-spirv_exe )
list( APPEND LIBCLC_TARGETS_ALL spirv-mesa3d- spirv64-mesa3d- )
endif()
-# Verify that the user hasn't requested mesa3d targets without an available
-# llvm-spirv tool.
-if( spirv-mesa3d- IN_LIST LIBCLC_TARGETS_TO_BUILD
- OR spirv64-mesa3d- IN_LIST LIBCLC_TARGETS_TO_BUILD )
- if( NOT LIBCLC_USE_SPIRV_BACKEND AND NOT llvm-spirv_exe )
- message( FATAL_ERROR "SPIR-V targets requested, but spirv-tools is not "
- "installed and the SPIR-V backend has not been requested." )
- endif()
-endif()
-
if( LIBCLC_TARGETS_TO_BUILD STREQUAL "all" )
set( LIBCLC_TARGETS_TO_BUILD ${LIBCLC_TARGETS_ALL} )
else()
foreach(TARGET_TO_BUILD ${LIBCLC_TARGETS_TO_BUILD})
if (NOT ${TARGET_TO_BUILD} IN_LIST LIBCLC_TARGETS_ALL)
- message ( FATAL_ERROR "Unknown target in LIBCLC_TARGETS_TO_BUILD: \"${TARGET_TO_BUILD}\"\n"
- "Valid targets are: ${LIBCLC_TARGETS_ALL}\n")
+ message( FATAL_ERROR
+ "Unknown target in LIBCLC_TARGETS_TO_BUILD: \"${TARGET_TO_BUILD}\"\n"
+ "Valid targets are: ${LIBCLC_TARGETS_ALL}\n")
endif()
endforeach()
endif()
list( SORT LIBCLC_TARGETS_TO_BUILD )
-# This needs to be set before any target that needs it
-# We need to use LLVM_INCLUDE_DIRS here, because if we are linking to an
-# llvm build directory, this includes $src/llvm/include which is where all the
-# headers are not $build/include/ which is what LLVM_INCLUDE_DIR is set to.
-include_directories( ${LLVM_INCLUDE_DIRS} )
-
-# Setup arch devices
-set( amdgcn--_devices none )
-set( amdgcn-mesa-mesa3d_devices none )
-set( amdgcn-amd-amdhsa-llvm_devices none )
-set( clspv--_devices none )
-set( clspv64--_devices none )
-set( nvptx64--_devices none )
-set( nvptx64--nvidiacl_devices none )
-set( nvptx64-nvidia-cuda_devices none )
-set( spirv-mesa3d-_devices none )
-set( spirv64-mesa3d-_devices none )
-
-# Setup aliases
-set( cedar_aliases palm sumo sumo2 redwood juniper )
-set( cypress_aliases hemlock )
-set( barts_aliases turks caicos )
-set( cayman_aliases aruba )
-
-# pkg-config file
-configure_file( libclc.pc.in libclc.pc @ONLY )
-install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig" )
+foreach( tool IN ITEMS opt llvm-link )
+ if( NOT EXISTS "${${tool}_exe}" AND "${${tool}_target}" STREQUAL "" )
+ message( FATAL_ERROR "libclc toolchain incomplete - missing tool ${tool}!" )
+ endif()
+endforeach()
+
+add_subdirectory(clc/lib/generic)
+add_subdirectory(clc/lib/amdgcn)
+add_subdirectory(clc/lib/amdgpu)
+add_subdirectory(clc/lib/ptx-nvidiacl)
+add_subdirectory(clc/lib/spirv)
+add_subdirectory(clc/lib/clspv)
+
+add_subdirectory(opencl/lib/generic)
+add_subdirectory(opencl/lib/amdgcn)
+add_subdirectory(opencl/lib/ptx-nvidiacl)
+add_subdirectory(opencl/lib/clspv)
+add_subdirectory(opencl/lib/spirv)
-set_source_files_properties(
+set_property(SOURCE
# CLC builtins
${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_cos.cl
${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_divide.cl
@@ -251,9 +173,18 @@ set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sin.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sqrt.cl
${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_tan.cl
- PROPERTIES COMPILE_OPTIONS -fapprox-func
+ APPEND PROPERTY COMPILE_OPTIONS -fapprox-func
)
+add_custom_target( libclc ALL )
+
+add_custom_target( libclc-opencl-builtins COMMENT "Build libclc OpenCL builtins" )
+add_dependencies( libclc libclc-opencl-builtins )
+
+configure_file( libclc.pc.in libclc.pc @ONLY )
+install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig" )
+
enable_testing()
foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
@@ -263,13 +194,58 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
list( GET TRIPLE 1 VENDOR )
list( GET TRIPLE 2 OS )
- set( opencl_dirs )
+ # Determine the clang target triple.
+ set(clang_triple ${t})
+ if(ARCH STREQUAL spirv AND LIBCLC_USE_SPIRV_BACKEND)
+ set(clang_triple spirv32--)
+ elseif(ARCH STREQUAL spirv64 AND LIBCLC_USE_SPIRV_BACKEND)
+ set(clang_triple spirv64--)
+ elseif(ARCH STREQUAL spirv OR ARCH STREQUAL clspv)
+ set(clang_triple spir--)
+ elseif(ARCH STREQUAL spirv64 OR ARCH STREQUAL clspv64)
+ set(clang_triple spir64--)
+ endif()
- if( ${ARCH} STREQUAL amdgcn )
- list( APPEND opencl_dirs amdgpu )
+ # Determine the preprocessor identifier for this target.
+ set(MACRO_ARCH ${ARCH})
+ if(ARCH STREQUAL spirv)
+ set(MACRO_ARCH SPIRV32)
+ elseif(ARCH STREQUAL spirv64)
+ set(MACRO_ARCH SPIRV64)
+ elseif(ARCH STREQUAL clspv)
+ set(MACRO_ARCH CLSPV32)
+ elseif(ARCH STREQUAL clspv64)
+ set(MACRO_ARCH CLSPV64)
endif()
+ string(TOUPPER "CLC_${MACRO_ARCH}" target_define)
- # Some targets' directories alias others
+ # Address space values.
+ set(private_addrspace_val 0)
+ set(generic_addrspace_val 0)
+ if(ARCH STREQUAL amdgcn)
+ set(private_addrspace_val 5)
+ endif()
+ if(ARCH STREQUAL spirv OR ARCH STREQUAL spirv64)
+ set(generic_addrspace_val 4)
+ endif()
+
+ # Target-specific compile flags and defines.
+ set(target_compile_flags)
+ set(target_extra_defines)
+ set(opt_flags -O3)
+
+ if(ARCH STREQUAL spirv OR ARCH STREQUAL spirv64)
+ list(APPEND target_compile_flags -O0 -finline-hint-functions)
+ list(APPEND target_extra_defines CLC_SPIRV)
+ set(opt_flags)
+ elseif(ARCH STREQUAL clspv OR ARCH STREQUAL clspv64)
+ list(APPEND target_compile_flags -Wno-unknown-assumption)
+ list(APPEND target_extra_defines CLC_CLSPV)
+ elseif(ARCH STREQUAL amdgcn)
+ list(APPEND target_compile_flags "SHELL:-Xclang -mcode-object-version=none")
+ endif()
+
+ # Identify which source directory to search through for this target.
if( ${ARCH} STREQUAL nvptx64 )
set( DARCH ptx )
elseif( ${ARCH} STREQUAL clspv OR ${ARCH} STREQUAL clspv64 )
@@ -285,155 +261,147 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
set( OS nvidiacl )
endif()
- # Append a variety of target- and triple-based directories to search,
- # increasing in specificity.
- list( APPEND opencl_dirs ${DARCH} ${DARCH}-${OS} ${DARCH}-${VENDOR}-${OS} )
-
- # The 'generic' directory contains all of the generic implementations of the
- # builtins. It is included first so it has the lowest search priority,
- # allowing targets to override builtins based on file names found later in
- # the list of search directories.
- # CLC builds all builtins for all targets, so unconditionally prepend the
- # 'generic' directory.
- set( clc_dirs generic ${opencl_dirs} )
- # Some OpenCL targets don't build all builtins, in which case they don't want
- # the 'generic' directory. Otherwise, prepend the 'generic' directory.
- if ( NOT ARCH STREQUAL spirv AND NOT ARCH STREQUAL spirv64 AND
- NOT ARCH STREQUAL clspv AND NOT ARCH STREQUAL clspv64)
- list( PREPEND opencl_dirs generic )
+ # Collect CLC sources, target specific sources will override the generic ones
+ # if present in the list.
+ set(_clc_overrides)
+ if(ARCH STREQUAL amdgcn)
+ list(APPEND _clc_overrides ${CLC_AMDGPU_SOURCES} ${CLC_AMDGCN_SOURCES})
+ elseif(DARCH STREQUAL ptx AND OS STREQUAL nvidiacl)
+ list(APPEND _clc_overrides ${CLC_PTX_NVIDIACL_SOURCES})
+ elseif(DARCH STREQUAL spirv)
+ list(APPEND _clc_overrides ${CLC_SPIRV_SOURCES})
+ elseif(DARCH STREQUAL clspv)
+ list(APPEND _clc_overrides ${CLC_CLSPV_SOURCES})
+ endif()
+ libclc_merge_sources(clc_sources ${CLC_GENERIC_SOURCES} ${_clc_overrides})
+
+ # Collect OpenCL sources. SPIR-V and Clspv targets use self-contained
+ # subsets while others merge with target-specific overrides.
+ if(ARCH STREQUAL spirv OR ARCH STREQUAL spirv64)
+ set(opencl_sources ${OPENCL_SPIRV_SOURCES})
+ elseif(ARCH STREQUAL clspv OR ARCH STREQUAL clspv64)
+ set(opencl_sources ${OPENCL_CLSPV_SOURCES})
+ else()
+ set(_opencl_overrides)
+ if(ARCH STREQUAL amdgcn)
+ list(APPEND _opencl_overrides ${OPENCL_AMDGCN_SOURCES})
+ elseif(DARCH STREQUAL ptx AND OS STREQUAL nvidiacl)
+ list(APPEND _opencl_overrides ${OPENCL_PTX_NVIDIACL_SOURCES})
+ endif()
+ libclc_merge_sources(opencl_sources
+ ${OPENCL_GENERIC_SOURCES} ${_opencl_overrides})
endif()
- set( clc_lib_files )
-
- libclc_configure_lib_source(
- clc_lib_files
- LIB_ROOT_DIR clc
- DIRS ${clc_dirs}
+ # Common compile options shared by CLC and OpenCL libraries.
+ set(compile_flags
+ -flto
+ --target=${clang_triple}
+ -nostdlib
+ -nostdlibinc
+ -cl-no-stdinc
+ -cl-std=CL3.0
+ -include opencl-c-base.h
+ -Werror=undef
+ -Wall
+ -Wextra
+ -fdiscard-value-names
+ -ffp-contract=fast-honor-pragmas
+ -fdenormal-fp-math=dynamic
+ ${target_compile_flags}
)
- set( opencl_lib_files )
+ set(_common_defs
+ ${target_define}
+ ${target_extra_defines}
+ __CLC_PRIVATE_ADDRSPACE_VAL=${private_addrspace_val}
+ __CLC_GENERIC_ADDRSPACE_VAL=${generic_addrspace_val}
+ )
- libclc_configure_lib_source(
- opencl_lib_files
- LIB_ROOT_DIR opencl
- DIRS ${opencl_dirs}
+ # Build the CLC internal builtins library.
+ string(REPLACE "-" "_" lib_suffix ${t})
+ set(clc_lib clc_builtins_${lib_suffix})
+ add_libclc_builtin_library(${clc_lib}
+ SOURCES ${clc_sources}
+ COMPILE_OPTIONS ${compile_flags}
+ INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/clc/include
+ COMPILE_DEFINITIONS ${_common_defs}
+ FOLDER "libclc/Device IR/CLC"
)
- foreach( d ${${t}_devices} )
- get_libclc_device_info(
- TRIPLE ${t}
- DEVICE ${d}
- CPU cpu
- ARCH_SUFFIX arch_suffix
- CLANG_TRIPLE clang_triple
- )
+ # Build the OpenCL builtins library.
+ set(opencl_lib opencl_builtins_${lib_suffix})
+ add_libclc_builtin_library(${opencl_lib}
+ SOURCES ${opencl_sources}
+ COMPILE_OPTIONS ${compile_flags} "SHELL:-Xclang -fdeclare-opencl-builtins"
+ INCLUDE_DIRS
+ ${CMAKE_CURRENT_SOURCE_DIR}/clc/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/opencl/include
+ COMPILE_DEFINITIONS ${_common_defs}
+ FOLDER "libclc/Device IR/OpenCL"
+ )
- message( STATUS " device: ${d} ( ${${d}_aliases} )" )
-
- set( MACRO_ARCH ${ARCH} )
- if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
- set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
- set( opt_flags )
- set( spvflags --spirv-max-version=1.1 )
- set( MACRO_ARCH SPIRV32 )
- if( ARCH STREQUAL spirv64 )
- set( MACRO_ARCH SPIRV64 )
- endif()
- elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
- set( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
- set( opt_flags -O3 )
- set( MACRO_ARCH CLSPV32 )
- if( ARCH STREQUAL clspv64 )
- set( MACRO_ARCH CLSPV64 )
- endif()
- elseif( ARCH STREQUAL amdgcn )
- set( build_flags "-Xclang" "-mcode-object-version=none" )
- set( opt_flags -O3 )
- else()
- set( build_flags )
- set( opt_flags -O3 )
- endif()
+ # Link the final library.
+ set(library_dir ${LIBCLC_OUTPUT_LIBRARY_DIR}/${clang_triple})
+ file(MAKE_DIRECTORY ${library_dir})
- set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" )
- file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
-
- # Build for OpenCL 3.0 independently of the target or device.
- list( APPEND build_flags -cl-std=CL3.0 )
-
- string( TOUPPER "CLC_${MACRO_ARCH}" CLC_TARGET_DEFINE )
-
- list( APPEND build_flags
- -D${CLC_TARGET_DEFINE}
- # All libclc builtin libraries see CLC headers
- -I${CMAKE_CURRENT_SOURCE_DIR}/clc/include
- -include opencl-c-base.h
- # Error on undefined macros
- -Werror=undef
- -Wall
- -Wextra
- -fdiscard-value-names
- -ffp-contract=fast-honor-pragmas
- -fdenormal-fp-math=dynamic
- )
+ set(linked_bc ${CMAKE_CURRENT_BINARY_DIR}/${t}.linked.bc)
- if( NOT "${cpu}" STREQUAL "" )
- list( APPEND build_flags -mcpu=${cpu} )
- endif()
+ add_custom_command(OUTPUT ${linked_bc}
+ COMMAND ${llvm-link_exe}
+ $<TARGET_FILE:${opencl_lib}>
+ --internalize --only-needed
+ $<TARGET_FILE:${clc_lib}>
+ -o ${linked_bc}
+ DEPENDS ${llvm-link_target} ${opencl_lib} ${clc_lib}
+ )
- # Generic address space support.
- # Note: when declaring builtins, we must consider that even if a target
- # formally/nominally supports the generic address space, in practice that
- # target may map it to the same target address space as another address
- # space (often the private one). In such cases we must be careful not to
- # multiply-define a builtin in a single target address space, as it would
- # result in a mangling clash.
- # For this reason we must consider the target support of the generic
- # address space separately from the *implementation* decision about whether
- # to declare certain builtins in that address space.
- # Note: we assume that if there is no distinct generic address space, it
- # maps to the private address space.
- set ( private_addrspace_val 0 )
- set ( generic_addrspace_val 0 )
- if( ARCH STREQUAL amdgcn )
- set ( private_addrspace_val 5 )
- endif()
- if( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64)
- set ( generic_addrspace_val 4 )
+ if(ARCH STREQUAL spirv OR ARCH STREQUAL spirv64)
+ # SPIR-V targets produce a .spv file from the linked bitcode.
+ set(builtins_lib ${library_dir}/libclc.spv)
+ if(LIBCLC_USE_SPIRV_BACKEND)
+ add_custom_command(OUTPUT ${builtins_lib}
+ COMMAND ${CMAKE_CLC_COMPILER} -c --target=${clang_triple}
+ -mllvm --spirv-ext=+SPV_KHR_fma
+ -x ir -o ${builtins_lib} ${linked_bc}
+ DEPENDS ${linked_bc}
+ )
+ else()
+ add_custom_command(OUTPUT ${builtins_lib}
+ COMMAND ${llvm-spirv_exe}
+ --spirv-max-version=1.1
+ --spirv-ext=+SPV_KHR_fma
+ -o ${builtins_lib} ${linked_bc}
+ DEPENDS ${llvm-spirv_target} ${linked_bc}
+ )
endif()
- list( APPEND build_flags
- -D__CLC_PRIVATE_ADDRSPACE_VAL=${private_addrspace_val}
- -D__CLC_GENERIC_ADDRSPACE_VAL=${generic_addrspace_val}
+ else()
+ # All other targets produce an optimized .bc file.
+ set(builtins_lib ${library_dir}/libclc.bc)
+ add_custom_command(OUTPUT ${builtins_lib}
+ COMMAND ${opt_exe} ${opt_flags} -o ${builtins_lib} ${linked_bc}
+ DEPENDS ${opt_target} ${linked_bc}
)
+ endif()
- add_libclc_builtin_set(
- CLC_INTERNAL
- ARCH ${ARCH}
- DEVICE ${d}
- ARCH_SUFFIX clc-${arch_suffix}
- TRIPLE ${clang_triple}
- COMPILE_FLAGS ${build_flags}
- OPT_FLAGS ${opt_flags}
- LIB_FILES ${clc_lib_files}
- )
+ # Target to build this library.
+ set(builtins_tgt libclc-${t})
+ add_custom_target(${builtins_tgt} ALL DEPENDS ${builtins_lib})
+ set_target_properties(${builtins_tgt} PROPERTIES
+ TARGET_FILE ${builtins_lib}
+ FOLDER "libclc/Device IR/Library"
+ )
+ add_dependencies(libclc-opencl-builtins ${builtins_tgt})
- list( APPEND build_flags
- -Xclang -fdeclare-opencl-builtins
- -I${CMAKE_CURRENT_SOURCE_DIR}/opencl/include
- )
+ install(FILES ${builtins_lib}
+ DESTINATION ${LIBCLC_INSTALL_DIR}/${clang_triple}
+ COMPONENT libclc-opencl-builtins
+ )
- add_libclc_builtin_set(
- ARCH ${ARCH}
- DEVICE ${d}
- ARCH_SUFFIX ${arch_suffix}
- TRIPLE ${clang_triple}
- COMPILE_FLAGS ${build_flags}
- OPT_FLAGS ${opt_flags}
- LIB_FILES ${opencl_lib_files}
- ALIASES ${${d}_aliases}
- OUTPUT_FILENAME libclc
- PARENT_TARGET libclc-opencl-builtins
- # Link in the CLC builtins and internalize their symbols
- INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix}
- )
- endforeach( d )
-endforeach( t )
+ # Verify there are no unresolved external functions in the library.
+ if(NOT ARCH MATCHES "^(nvptx|clspv)(64)?$" AND
+ NOT ARCH MATCHES "^spirv(64)?$")
+ add_test(NAME external-funcs-${t}
+ COMMAND ./check_external_funcs.sh ${builtins_lib} ${LLVM_TOOLS_BINARY_DIR}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ endif()
+endforeach()
diff --git a/libclc/clc/lib/amdgcn/CMakeLists.txt b/libclc/clc/lib/amdgcn/CMakeLists.txt
new file mode 100644
index 0000000000000..12bbba2d6566d
--- /dev/null
+++ b/libclc/clc/lib/amdgcn/CMakeLists.txt
@@ -0,0 +1,22 @@
+libclc_configure_source_list(CLC_AMDGCN_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ address_space/qualifier.cl
+ math/clc_ldexp.cl
+ mem_fence/clc_mem_fence.cl
+ subgroup/subgroup.cl
+ subgroup/sub_group_broadcast.cl
+ synchronization/clc_sub_group_barrier.cl
+ synchronization/clc_work_group_barrier.cl
+ workitem/clc_get_enqueued_local_size.cl
+ workitem/clc_get_global_offset.cl
+ workitem/clc_get_global_size.cl
+ workitem/clc_get_group_id.cl
+ workitem/clc_get_local_id.cl
+ workitem/clc_get_local_size.cl
+ workitem/clc_get_max_sub_group_size.cl
+ workitem/clc_get_num_groups.cl
+ workitem/clc_get_num_sub_groups.cl
+ workitem/clc_get_sub_group_id.cl
+ workitem/clc_get_sub_group_size.cl
+ workitem/clc_get_work_dim.cl
+)
diff --git a/libclc/clc/lib/amdgcn/SOURCES b/libclc/clc/lib/amdgcn/SOURCES
deleted file mode 100644
index a0b6c168b207e..0000000000000
--- a/libclc/clc/lib/amdgcn/SOURCES
+++ /dev/null
@@ -1,19 +0,0 @@
-address_space/qualifier.cl
-math/clc_ldexp.cl
-mem_fence/clc_mem_fence.cl
-subgroup/subgroup.cl
-subgroup/sub_group_broadcast.cl
-synchronization/clc_sub_group_barrier.cl
-synchronization/clc_work_group_barrier.cl
-workitem/clc_get_enqueued_local_size.cl
-workitem/clc_get_global_offset.cl
-workitem/clc_get_global_size.cl
-workitem/clc_get_group_id.cl
-workitem/clc_get_local_id.cl
-workitem/clc_get_local_size.cl
-workitem/clc_get_max_sub_group_size.cl
-workitem/clc_get_num_groups.cl
-workitem/clc_get_num_sub_groups.cl
-workitem/clc_get_sub_group_id.cl
-workitem/clc_get_sub_group_size.cl
-workitem/clc_get_work_dim.cl
diff --git a/libclc/clc/lib/amdgpu/CMakeLists.txt b/libclc/clc/lib/amdgpu/CMakeLists.txt
new file mode 100644
index 0000000000000..9851fa2d13d19
--- /dev/null
+++ b/libclc/clc/lib/amdgpu/CMakeLists.txt
@@ -0,0 +1,16 @@
+libclc_configure_source_list(CLC_AMDGPU_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ math/clc_half_exp.cl
+ math/clc_half_exp2.cl
+ math/clc_half_exp10.cl
+ math/clc_half_log.cl
+ math/clc_half_log2.cl
+ math/clc_half_log10.cl
+ math/clc_half_recip.cl
+ math/clc_half_rsqrt.cl
+ math/clc_half_sqrt.cl
+ math/clc_native_exp.cl
+ math/clc_native_exp2.cl
+ math/clc_native_log10.cl
+ math/clc_sqrt.cl
+)
diff --git a/libclc/clc/lib/amdgpu/SOURCES b/libclc/clc/lib/amdgpu/SOURCES
deleted file mode 100644
index dfa1a2b540077..0000000000000
--- a/libclc/clc/lib/amdgpu/SOURCES
+++ /dev/null
@@ -1,13 +0,0 @@
-math/clc_half_exp10.cl
-math/clc_half_exp2.cl
-math/clc_half_exp.cl
-math/clc_half_log10.cl
-math/clc_half_log2.cl
-math/clc_half_log.cl
-math/clc_half_recip.cl
-math/clc_half_rsqrt.cl
-math/clc_half_sqrt.cl
-math/clc_native_exp2.cl
-math/clc_native_exp.cl
-math/clc_native_log10.cl
-math/clc_sqrt.cl
diff --git a/libclc/clc/lib/clspv/CMakeLists.txt b/libclc/clc/lib/clspv/CMakeLists.txt
new file mode 100644
index 0000000000000..e54fccb10c3b7
--- /dev/null
+++ b/libclc/clc/lib/clspv/CMakeLists.txt
@@ -0,0 +1,5 @@
+libclc_configure_source_list(CLC_CLSPV_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ integer/clc_mul_hi.cl
+ math/clc_sw_fma.cl
+)
diff --git a/libclc/clc/lib/clspv/SOURCES b/libclc/clc/lib/clspv/SOURCES
deleted file mode 100644
index b91b0e70a397d..0000000000000
--- a/libclc/clc/lib/clspv/SOURCES
+++ /dev/null
@@ -1,2 +0,0 @@
-math/clc_sw_fma.cl
-integer/clc_mul_hi.cl
diff --git a/libclc/clc/lib/generic/CMakeLists.txt b/libclc/clc/lib/generic/CMakeLists.txt
new file mode 100644
index 0000000000000..b8adbc1393de3
--- /dev/null
+++ b/libclc/clc/lib/generic/CMakeLists.txt
@@ -0,0 +1,190 @@
+libclc_configure_source_list(CLC_GENERIC_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ async/clc_prefetch.cl
+ atomic/clc_atomic_compare_exchange.cl
+ atomic/clc_atomic_dec.cl
+ atomic/clc_atomic_exchange.cl
+ atomic/clc_atomic_fetch_add.cl
+ atomic/clc_atomic_fetch_and.cl
+ atomic/clc_atomic_fetch_max.cl
+ atomic/clc_atomic_fetch_min.cl
+ atomic/clc_atomic_fetch_or.cl
+ atomic/clc_atomic_fetch_sub.cl
+ atomic/clc_atomic_fetch_xor.cl
+ atomic/clc_atomic_flag_clear.cl
+ atomic/clc_atomic_flag_test_and_set.cl
+ atomic/clc_atomic_inc.cl
+ atomic/clc_atomic_load.cl
+ atomic/clc_atomic_store.cl
+ collective/clc_work_group_any_all.cl
+ collective/clc_work_group_broadcast.cl
+ common/clc_degrees.cl
+ common/clc_radians.cl
+ common/clc_sign.cl
+ common/clc_smoothstep.cl
+ common/clc_step.cl
+ conversion/clc_convert_float2float.cl
+ conversion/clc_convert_float2int.cl
+ conversion/clc_convert_int2float.cl
+ conversion/clc_convert_integer.cl
+ geometric/clc_cross.cl
+ geometric/clc_distance.cl
+ geometric/clc_dot.cl
+ geometric/clc_fast_distance.cl
+ geometric/clc_fast_length.cl
+ geometric/clc_fast_normalize.cl
+ geometric/clc_length.cl
+ geometric/clc_normalize.cl
+ integer/clc_abs.cl
+ integer/clc_abs_diff.cl
+ integer/clc_add_sat.cl
+ integer/clc_bit_reverse.cl
+ integer/clc_bitfield_extract_signed.cl
+ integer/clc_bitfield_extract_unsigned.cl
+ integer/clc_bitfield_insert.cl
+ integer/clc_clz.cl
+ integer/clc_ctz.cl
+ integer/clc_hadd.cl
+ integer/clc_mad24.cl
+ integer/clc_mad_sat.cl
+ integer/clc_mul24.cl
+ integer/clc_mul_hi.cl
+ integer/clc_popcount.cl
+ integer/clc_rhadd.cl
+ integer/clc_rotate.cl
+ integer/clc_sub_sat.cl
+ integer/clc_upsample.cl
+ math/clc_acos.cl
+ math/clc_acosh.cl
+ math/clc_acospi.cl
+ math/clc_asin.cl
+ math/clc_asinh.cl
+ math/clc_asinpi.cl
+ math/clc_atan.cl
+ math/clc_atan2.cl
+ math/clc_atan2pi.cl
+ math/clc_atanh.cl
+ math/clc_atanpi.cl
+ math/clc_cbrt.cl
+ math/clc_ceil.cl
+ math/clc_copysign.cl
+ math/clc_cos.cl
+ math/clc_cosh.cl
+ math/clc_cospi.cl
+ math/clc_ep_log.cl
+ math/clc_erf.cl
+ math/clc_erfc.cl
+ math/clc_exp.cl
+ math/clc_exp2.cl
+ math/clc_exp10.cl
+ math/clc_exp_helper.cl
+ math/clc_expm1.cl
+ math/clc_fabs.cl
+ math/clc_fdim.cl
+ math/clc_floor.cl
+ math/clc_fma.cl
+ math/clc_fmax.cl
+ math/clc_fmin.cl
+ math/clc_fmod.cl
+ math/clc_fract.cl
+ math/clc_frexp.cl
+ math/clc_half_cos.cl
+ math/clc_half_divide.cl
+ math/clc_half_exp.cl
+ math/clc_half_exp2.cl
+ math/clc_half_exp10.cl
+ math/clc_half_log.cl
+ math/clc_half_log2.cl
+ math/clc_half_log10.cl
+ math/clc_half_powr.cl
+ math/clc_half_recip.cl
+ math/clc_half_rsqrt.cl
+ math/clc_half_sin.cl
+ math/clc_half_sqrt.cl
+ math/clc_half_tan.cl
+ math/clc_hypot.cl
+ math/clc_ilogb.cl
+ math/clc_ldexp.cl
+ math/clc_lgamma.cl
+ math/clc_lgamma_r.cl
+ math/clc_log.cl
+ math/clc_log2.cl
+ math/clc_log10.cl
+ math/clc_log1p.cl
+ math/clc_logb.cl
+ math/clc_mad.cl
+ math/clc_maxmag.cl
+ math/clc_minmag.cl
+ math/clc_modf.cl
+ math/clc_nan.cl
+ math/clc_native_cos.cl
+ math/clc_native_divide.cl
+ math/clc_native_exp.cl
+ math/clc_native_exp2.cl
+ math/clc_native_exp10.cl
+ math/clc_native_log.cl
+ math/clc_native_log2.cl
+ math/clc_native_log10.cl
+ math/clc_native_powr.cl
+ math/clc_native_recip.cl
+ math/clc_native_rsqrt.cl
+ math/clc_native_sin.cl
+ math/clc_native_sqrt.cl
+ math/clc_native_tan.cl
+ math/clc_nextafter.cl
+ math/clc_pow.cl
+ math/clc_pown.cl
+ math/clc_powr.cl
+ math/clc_remainder.cl
+ math/clc_remquo.cl
+ math/clc_rint.cl
+ math/clc_rootn.cl
+ math/clc_round.cl
+ math/clc_rsqrt.cl
+ math/clc_sin.cl
+ math/clc_sincos.cl
+ math/clc_sincos_helpers.cl
+ math/clc_sinh.cl
+ math/clc_sinpi.cl
+ math/clc_sqrt.cl
+ math/clc_tables.cl
+ math/clc_tan.cl
+ math/clc_tanh.cl
+ math/clc_tanpi.cl
+ math/clc_tgamma.cl
+ math/clc_trunc.cl
+ misc/clc_shuffle.cl
+ misc/clc_shuffle2.cl
+ relational/clc_all.cl
+ relational/clc_any.cl
+ relational/clc_bitselect.cl
+ relational/clc_isequal.cl
+ relational/clc_isfinite.cl
+ relational/clc_isgreater.cl
+ relational/clc_isgreaterequal.cl
+ relational/clc_isinf.cl
+ relational/clc_isless.cl
+ relational/clc_islessequal.cl
+ relational/clc_islessgreater.cl
+ relational/clc_isnan.cl
+ relational/clc_isnormal.cl
+ relational/clc_isnotequal.cl
+ relational/clc_isordered.cl
+ relational/clc_issubnormal.cl
+ relational/clc_isunordered.cl
+ relational/clc_select.cl
+ relational/clc_signbit.cl
+ shared/clc_clamp.cl
+ shared/clc_max.cl
+ shared/clc_min.cl
+ shared/clc_qualifier.cl
+ shared/clc_vload.cl
+ shared/clc_vstore.cl
+ subgroup/sub_group_barrier.cl
+ workitem/clc_get_global_id.cl
+ workitem/clc_get_global_linear_id.cl
+ workitem/clc_get_local_linear_id.cl
+ workitem/clc_get_num_sub_groups.cl
+ workitem/clc_get_sub_group_id.cl
+ workitem/clc_get_sub_group_size.cl
+)
diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
deleted file mode 100644
index 05ea37869bbf8..0000000000000
--- a/libclc/clc/lib/generic/SOURCES
+++ /dev/null
@@ -1,187 +0,0 @@
-async/clc_prefetch.cl
-atomic/clc_atomic_compare_exchange.cl
-atomic/clc_atomic_dec.cl
-atomic/clc_atomic_exchange.cl
-atomic/clc_atomic_fetch_add.cl
-atomic/clc_atomic_fetch_and.cl
-atomic/clc_atomic_fetch_max.cl
-atomic/clc_atomic_fetch_min.cl
-atomic/clc_atomic_fetch_or.cl
-atomic/clc_atomic_fetch_sub.cl
-atomic/clc_atomic_fetch_xor.cl
-atomic/clc_atomic_flag_clear.cl
-atomic/clc_atomic_flag_test_and_set.cl
-atomic/clc_atomic_inc.cl
-atomic/clc_atomic_load.cl
-atomic/clc_atomic_store.cl
-collective/clc_work_group_any_all.cl
-collective/clc_work_group_broadcast.cl
-common/clc_degrees.cl
-common/clc_radians.cl
-common/clc_sign.cl
-common/clc_smoothstep.cl
-common/clc_step.cl
-conversion/clc_convert_float2float.cl
-conversion/clc_convert_float2int.cl
-conversion/clc_convert_int2float.cl
-conversion/clc_convert_integer.cl
-geometric/clc_cross.cl
-geometric/clc_distance.cl
-geometric/clc_dot.cl
-geometric/clc_fast_distance.cl
-geometric/clc_fast_length.cl
-geometric/clc_fast_normalize.cl
-geometric/clc_length.cl
-geometric/clc_normalize.cl
-integer/clc_abs.cl
-integer/clc_abs_diff.cl
-integer/clc_add_sat.cl
-integer/clc_bitfield_extract_signed.cl
-integer/clc_bitfield_extract_unsigned.cl
-integer/clc_bitfield_insert.cl
-integer/clc_bit_reverse.cl
-integer/clc_clz.cl
-integer/clc_ctz.cl
-integer/clc_hadd.cl
-integer/clc_mad24.cl
-integer/clc_mad_sat.cl
-integer/clc_mul24.cl
-integer/clc_mul_hi.cl
-integer/clc_popcount.cl
-integer/clc_rhadd.cl
-integer/clc_rotate.cl
-integer/clc_sub_sat.cl
-integer/clc_upsample.cl
-math/clc_acos.cl
-math/clc_acosh.cl
-math/clc_acospi.cl
-math/clc_asin.cl
-math/clc_asinh.cl
-math/clc_asinpi.cl
-math/clc_atan.cl
-math/clc_atan2.cl
-math/clc_atan2pi.cl
-math/clc_atanh.cl
-math/clc_atanpi.cl
-math/clc_cbrt.cl
-math/clc_ceil.cl
-math/clc_copysign.cl
-math/clc_cos.cl
-math/clc_cosh.cl
-math/clc_cospi.cl
-math/clc_ep_log.cl
-math/clc_erf.cl
-math/clc_erfc.cl
-math/clc_exp.cl
-math/clc_exp10.cl
-math/clc_exp2.cl
-math/clc_expm1.cl
-math/clc_exp_helper.cl
-math/clc_fabs.cl
-math/clc_fdim.cl
-math/clc_fma.cl
-math/clc_fmax.cl
-math/clc_fmin.cl
-math/clc_floor.cl
-math/clc_fmod.cl
-math/clc_fract.cl
-math/clc_frexp.cl
-math/clc_half_cos.cl
-math/clc_half_divide.cl
-math/clc_half_exp.cl
-math/clc_half_exp10.cl
-math/clc_half_exp2.cl
-math/clc_half_log.cl
-math/clc_half_log10.cl
-math/clc_half_log2.cl
-math/clc_half_powr.cl
-math/clc_half_rsqrt.cl
-math/clc_half_recip.cl
-math/clc_half_sin.cl
-math/clc_half_sqrt.cl
-math/clc_half_tan.cl
-math/clc_hypot.cl
-math/clc_ilogb.cl
-math/clc_ldexp.cl
-math/clc_lgamma.cl
-math/clc_lgamma_r.cl
-math/clc_log.cl
-math/clc_log10.cl
-math/clc_log1p.cl
-math/clc_log2.cl
-math/clc_logb.cl
-math/clc_mad.cl
-math/clc_maxmag.cl
-math/clc_minmag.cl
-math/clc_modf.cl
-math/clc_nan.cl
-math/clc_native_cos.cl
-math/clc_native_divide.cl
-math/clc_native_exp.cl
-math/clc_native_exp10.cl
-math/clc_native_exp2.cl
-math/clc_native_log.cl
-math/clc_native_log10.cl
-math/clc_native_log2.cl
-math/clc_native_powr.cl
-math/clc_native_rsqrt.cl
-math/clc_native_recip.cl
-math/clc_native_sin.cl
-math/clc_native_sqrt.cl
-math/clc_native_tan.cl
-math/clc_nextafter.cl
-math/clc_pow.cl
-math/clc_pown.cl
-math/clc_powr.cl
-math/clc_remainder.cl
-math/clc_remquo.cl
-math/clc_rint.cl
-math/clc_rootn.cl
-math/clc_round.cl
-math/clc_rsqrt.cl
-math/clc_sin.cl
-math/clc_sincos.cl
-math/clc_sincos_helpers.cl
-math/clc_sinh.cl
-math/clc_sinpi.cl
-math/clc_sqrt.cl
-math/clc_tables.cl
-math/clc_tan.cl
-math/clc_tanh.cl
-math/clc_tanpi.cl
-math/clc_tgamma.cl
-math/clc_trunc.cl
-misc/clc_shuffle.cl
-misc/clc_shuffle2.cl
-relational/clc_all.cl
-relational/clc_any.cl
-relational/clc_bitselect.cl
-relational/clc_isequal.cl
-relational/clc_isfinite.cl
-relational/clc_isgreater.cl
-relational/clc_isgreaterequal.cl
-relational/clc_isinf.cl
-relational/clc_isless.cl
-relational/clc_islessequal.cl
-relational/clc_islessgreater.cl
-relational/clc_isnan.cl
-relational/clc_isnormal.cl
-relational/clc_isnotequal.cl
-relational/clc_isordered.cl
-relational/clc_issubnormal.cl
-relational/clc_isunordered.cl
-relational/clc_select.cl
-relational/clc_signbit.cl
-shared/clc_clamp.cl
-shared/clc_max.cl
-shared/clc_min.cl
-shared/clc_qualifier.cl
-shared/clc_vload.cl
-shared/clc_vstore.cl
-subgroup/sub_group_barrier.cl
-workitem/clc_get_global_id.cl
-workitem/clc_get_global_linear_id.cl
-workitem/clc_get_local_linear_id.cl
-workitem/clc_get_num_sub_groups.cl
-workitem/clc_get_sub_group_id.cl
-workitem/clc_get_sub_group_size.cl
diff --git a/libclc/clc/lib/ptx-nvidiacl/CMakeLists.txt b/libclc/clc/lib/ptx-nvidiacl/CMakeLists.txt
new file mode 100644
index 0000000000000..f345007e852e2
--- /dev/null
+++ b/libclc/clc/lib/ptx-nvidiacl/CMakeLists.txt
@@ -0,0 +1,18 @@
+libclc_configure_source_list(CLC_PTX_NVIDIACL_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ math/clc_log.cl
+ math/clc_rsqrt.cl
+ math/clc_sinpi.cl
+ math/clc_sqrt.cl
+ mem_fence/clc_mem_fence.cl
+ relational/clc_isinf.cl
+ synchronization/clc_work_group_barrier.cl
+ workitem/clc_get_global_id.cl
+ workitem/clc_get_global_size.cl
+ workitem/clc_get_group_id.cl
+ workitem/clc_get_local_id.cl
+ workitem/clc_get_local_size.cl
+ workitem/clc_get_max_sub_group_size.cl
+ workitem/clc_get_num_groups.cl
+ workitem/clc_get_sub_group_local_id.cl
+)
diff --git a/libclc/clc/lib/ptx-nvidiacl/SOURCES b/libclc/clc/lib/ptx-nvidiacl/SOURCES
deleted file mode 100644
index 9ed25c71a3f35..0000000000000
--- a/libclc/clc/lib/ptx-nvidiacl/SOURCES
+++ /dev/null
@@ -1,15 +0,0 @@
-math/clc_log.cl
-math/clc_rsqrt.cl
-math/clc_sinpi.cl
-math/clc_sqrt.cl
-mem_fence/clc_mem_fence.cl
-synchronization/clc_work_group_barrier.cl
-workitem/clc_get_global_id.cl
-workitem/clc_get_global_size.cl
-workitem/clc_get_group_id.cl
-workitem/clc_get_local_id.cl
-workitem/clc_get_local_size.cl
-workitem/clc_get_max_sub_group_size.cl
-workitem/clc_get_num_groups.cl
-workitem/clc_get_sub_group_local_id.cl
-relational/clc_isinf.cl
diff --git a/libclc/clc/lib/spirv/CMakeLists.txt b/libclc/clc/lib/spirv/CMakeLists.txt
new file mode 100644
index 0000000000000..8bf5c29be8da3
--- /dev/null
+++ b/libclc/clc/lib/spirv/CMakeLists.txt
@@ -0,0 +1,5 @@
+libclc_configure_source_list(CLC_SPIRV_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ math/clc_fmax.cl
+ math/clc_fmin.cl
+)
diff --git a/libclc/clc/lib/spirv/SOURCES b/libclc/clc/lib/spirv/SOURCES
deleted file mode 100644
index ed63fe6b7c529..0000000000000
--- a/libclc/clc/lib/spirv/SOURCES
+++ /dev/null
@@ -1,2 +0,0 @@
-math/clc_fmax.cl
-math/clc_fmin.cl
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index f47f9782e119a..919c325dea479 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -1,567 +1,59 @@
-# Compiles an OpenCL C - or assembles an LL file - to bytecode
-#
-# Arguments:
-# * TRIPLE <string>
-# Target triple for which to compile the bytecode file.
-# * INPUT <string>
-# File to compile/assemble to bytecode
-# * OUTPUT <string>
-# Bytecode file to generate
-# * EXTRA_OPTS <string> ...
-# List of compiler options to use. Note that some are added by default.
-# * DEPENDENCIES <string> ...
-# List of extra dependencies to inject
-#
-# Depends on the clang, llvm-as, and llvm-link targets for compiling,
-# assembling, and linking, respectively.
-function(compile_to_bc)
- cmake_parse_arguments(ARG
- ""
- "TRIPLE;INPUT;OUTPUT"
- "EXTRA_OPTS;DEPENDENCIES"
- ${ARGN}
- )
-
- # If this is an LLVM IR file (identified solely by its file suffix),
- # pre-process it with clang to a temp file, then assemble that to bytecode.
- set( TMP_SUFFIX )
- get_filename_component( FILE_EXT ${ARG_INPUT} EXT )
- if( NOT ${FILE_EXT} STREQUAL ".ll" )
- # Pass '-c' when not running the preprocessor
- set( PP_OPTS -c )
- set( EXTRA_OPTS ${ARG_EXTRA_OPTS} )
- else()
- set( PP_OPTS -E;-P )
- set( TMP_SUFFIX .tmp )
- string( REPLACE "-include;opencl-c-base.h" "" EXTRA_OPTS "${ARG_EXTRA_OPTS}")
- endif()
-
- set( TARGET_ARG )
- if( ARG_TRIPLE )
- set( TARGET_ARG "-target" ${ARG_TRIPLE} )
- endif()
-
- # Ensure the directory we are told to output to exists
- get_filename_component( ARG_OUTPUT_DIR ${ARG_OUTPUT} DIRECTORY )
- file( MAKE_DIRECTORY ${ARG_OUTPUT_DIR} )
-
- add_custom_command(
- OUTPUT ${ARG_OUTPUT}${TMP_SUFFIX}
- COMMAND ${clang_exe}
- ${TARGET_ARG}
- ${PP_OPTS}
- ${EXTRA_OPTS}
- -MD -MF ${ARG_OUTPUT}.d -MT ${ARG_OUTPUT}${TMP_SUFFIX}
- # LLVM 13 enables standard includes by default - we don't want
- # those when pre-processing IR. We disable it unconditionally.
- $<$<VERSION_GREATER_EQUAL:${LLVM_PACKAGE_VERSION},13.0.0>:-cl-no-stdinc>
- -emit-llvm
- -o ${ARG_OUTPUT}${TMP_SUFFIX}
- -x cl
- ${ARG_INPUT}
- DEPENDS
- ${clang_target}
- ${ARG_INPUT}
- ${ARG_DEPENDENCIES}
- DEPFILE ${ARG_OUTPUT}.d
- )
-
- if( ${FILE_EXT} STREQUAL ".ll" )
- add_custom_command(
- OUTPUT ${ARG_OUTPUT}
- COMMAND ${llvm-as_exe} -o ${ARG_OUTPUT} ${ARG_OUTPUT}${TMP_SUFFIX}
- DEPENDS ${llvm-as_target} ${ARG_OUTPUT}${TMP_SUFFIX}
- )
- endif()
-endfunction()
-
-# Links together one or more bytecode files
-#
-# Arguments:
-# * INTERNALIZE
-# Set if -internalize flag should be passed when linking
-# * TARGET <string>
-# Custom target to create
-# * INPUT <string> ...
-# List of bytecode files to link together
-# * DEPENDENCIES <string> ...
-# List of extra dependencies to inject
-function(link_bc)
- cmake_parse_arguments(ARG
- "INTERNALIZE"
- "TARGET"
- "INPUTS;DEPENDENCIES"
- ${ARGN}
- )
-
- set( LINK_INPUT_ARG ${ARG_INPUTS} )
- if( WIN32 OR CYGWIN )
- # Create a response file in case the number of inputs exceeds command-line
- # character limits on certain platforms.
- file( TO_CMAKE_PATH ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.rsp RSP_FILE )
- # Turn it into a space-separate list of input files
- list( JOIN ARG_INPUTS " " RSP_INPUT )
- file( GENERATE OUTPUT ${RSP_FILE} CONTENT ${RSP_INPUT} )
- # Ensure that if this file is removed, we re-run CMake
- set_property( DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
- ${RSP_FILE}
- )
- set( LINK_INPUT_ARG "@${RSP_FILE}" )
- endif()
-
- if( ARG_INTERNALIZE )
- set( link_flags --internalize --only-needed )
- endif()
-
- add_custom_command(
- OUTPUT ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.bc
- COMMAND ${llvm-link_exe} ${link_flags} -o ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.bc ${LINK_INPUT_ARG}
- DEPENDS ${llvm-link_target} ${ARG_DEPENDENCIES} ${ARG_INPUTS} ${RSP_FILE}
- )
-
- add_custom_target( ${ARG_TARGET} ALL DEPENDS ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.bc )
- set_target_properties( ${ARG_TARGET} PROPERTIES
- TARGET_FILE ${LIBCLC_ARCH_OBJFILE_DIR}/${ARG_TARGET}.bc
- FOLDER "libclc/Device IR/Linking"
- )
-endfunction()
-
-# Create a custom target for each bitcode file, which is the output of a custom
-# command. This is required for parallel compilation of the custom commands that
-# generate the bitcode files when using the CMake MSVC generator on Windows.
-#
-# Arguments:
-# * compile_tgts
-# Output list of compile targets
-# * ARCH_SUFFIX <string>
-# libclc architecture/triple suffix
-# * FILES <string> ...
-# List of bitcode files
-function(create_compile_targets compile_tgts)
- cmake_parse_arguments( ARG "" "ARCH_SUFFIX" "FILES" ${ARGN} )
-
- if( NOT ARG_ARCH_SUFFIX OR NOT ARG_FILES )
- message( FATAL_ERROR "Must provide ARCH_SUFFIX, and FILES" )
- endif()
-
- set( tgts )
- foreach( file IN LISTS ARG_FILES )
- cmake_path( GET file STEM stem )
- cmake_path( GET file PARENT_PATH parent_path )
- cmake_path( GET parent_path STEM parent_path_stem )
- set( tgt compile-${ARG_ARCH_SUFFIX}-${parent_path_stem}-${stem} )
- add_custom_target( ${tgt} DEPENDS ${file} )
- list( APPEND tgts ${tgt} )
+# Converts a list of relative source paths to absolute paths and exports
+# it to the parent scope.
+macro(libclc_configure_source_list variable path)
+ set(${variable} ${ARGN})
+ list(TRANSFORM ${variable} PREPEND "${path}/")
+ set(${variable} ${${variable}} PARENT_SCOPE)
+endmacro()
+
+# Merges OpenCL C source file lists with priority deduplication.
+#
+# All arguments after the output variable name are treated as source file
+# paths. When multiple files share the same basename, the last occurrence
+# wins. This allows target-specific files to automatically override generic
+# ones.
+function(libclc_merge_sources output)
+ set(all_sources ${ARGN})
+ set(result)
+ set(seen_names)
+
+ list(REVERSE all_sources)
+ foreach(f ${all_sources})
+ get_filename_component(name "${f}" NAME)
+ if(NOT name IN_LIST seen_names)
+ list(APPEND seen_names "${name}")
+ list(PREPEND result "${f}")
+ endif()
endforeach()
- set( compile_tgts ${tgts} PARENT_SCOPE )
+ set(${output} ${result} PARENT_SCOPE)
endfunction()
-# Decomposes and returns variables based on a libclc triple and architecture
-# combination. Returns data via one or more optional output variables.
-#
-# Arguments:
-# * TRIPLE <string>
-# libclc target triple to query
-# * DEVICE <string>
-# libclc device to query
-#
-# Optional Arguments:
-# * CPU <var>
-# Variable name to be set to the target CPU
-# * ARCH_SUFFIX <var>
-# Variable name to be set to the triple/architecture suffix
-# * CLANG_TRIPLE <var>
-# Variable name to be set to the normalized clang triple
-function(get_libclc_device_info)
+# Creates a static library target for libclc builtins. Derives include
+# directories to locate `.inc` files in the same directory.
+function(add_libclc_builtin_library target_name)
cmake_parse_arguments(ARG
""
- "TRIPLE;DEVICE;CPU;ARCH_SUFFIX;CLANG_TRIPLE"
- ""
+ "FOLDER"
+ "SOURCES;COMPILE_OPTIONS;INCLUDE_DIRS;COMPILE_DEFINITIONS"
${ARGN}
)
- if( NOT ARG_TRIPLE OR NOT ARG_DEVICE )
- message( FATAL_ERROR "Must provide both TRIPLE and DEVICE" )
- endif()
-
- string( REPLACE "-" ";" TRIPLE ${ARG_TRIPLE} )
- list( GET TRIPLE 0 ARCH )
-
- # Some targets don't have a specific device architecture to target
- if( ARG_DEVICE STREQUAL none
- OR ((ARCH STREQUAL spirv OR ARCH STREQUAL spirv64)
- AND NOT LIBCLC_USE_SPIRV_BACKEND) )
- set( cpu )
- set( arch_suffix "${ARG_TRIPLE}" )
- else()
- set( cpu "${ARG_DEVICE}" )
- set( arch_suffix "${ARG_DEVICE}-${ARG_TRIPLE}" )
- endif()
-
- if( ARG_CPU )
- set( ${ARG_CPU} ${cpu} PARENT_SCOPE )
- endif()
-
- if( ARG_ARCH_SUFFIX )
- set( ${ARG_ARCH_SUFFIX} ${arch_suffix} PARENT_SCOPE )
- endif()
-
- # Some libclc targets are not real clang triples: return their canonical
- # triples.
- if( ARCH STREQUAL spirv AND LIBCLC_USE_SPIRV_BACKEND )
- set( ARG_TRIPLE "spirv32--" )
- elseif( ARCH STREQUAL spirv64 AND LIBCLC_USE_SPIRV_BACKEND )
- set( ARG_TRIPLE "spirv64--" )
- elseif( ARCH STREQUAL spirv OR ARCH STREQUAL clspv )
- set( ARG_TRIPLE "spir--" )
- elseif( ARCH STREQUAL spirv64 OR ARCH STREQUAL clspv64 )
- set( ARG_TRIPLE "spir64--" )
- endif()
-
- if( ARG_CLANG_TRIPLE )
- set( ${ARG_CLANG_TRIPLE} ${ARG_TRIPLE} PARENT_SCOPE )
- endif()
-endfunction()
-
-# Compiles a list of library source files (provided by LIB_FILES) and compiles
-# them to LLVM bytecode (or SPIR-V), links them together and optimizes them.
-#
-# For bytecode libraries, a list of ALIASES may optionally be provided to
-# produce additional symlinks.
-#
-# Arguments:
-# * ARCH <string>
-# libclc architecture being built
-# * DEVICE <string>
-# libclc microarchitecture being built
-# * ARCH_SUFFIX <string>
-# libclc architecture/triple suffix
-# * TRIPLE <string>
-# Triple used to compile
-# * OUTPUT_FILENAME <string>
-# libclc output library name
-# * PARENT_TARGET <string>
-# Target into which to group the target builtins
-#
-# Optional Arguments:
-# * CLC_INTERNAL
-# Pass if compiling the internal CLC builtin libraries, which are not
-# optimized and do not have aliases created.
-# * LIB_FILES <string> ...
-# List of files that should be built for this library
-# * COMPILE_FLAGS <string> ...
-# Compilation options (for clang)
-# * OPT_FLAGS <string> ...
-# Optimization options (for opt)
-# * ALIASES <string> ...
-# List of aliases
-# * INTERNAL_LINK_DEPENDENCIES <target> ...
-# A list of extra bytecode file's targets. The bitcode files will be linked
-# into the builtin library. Symbols from these link dependencies will be
-# internalized during linking.
-function(add_libclc_builtin_set)
- cmake_parse_arguments(ARG
- "CLC_INTERNAL"
- "ARCH;DEVICE;TRIPLE;ARCH_SUFFIX;OUTPUT_FILENAME;PARENT_TARGET"
- "LIB_FILES;COMPILE_FLAGS;OPT_FLAGS;ALIASES;INTERNAL_LINK_DEPENDENCIES"
- ${ARGN}
- )
-
- if( NOT ARG_ARCH OR NOT ARG_ARCH_SUFFIX OR NOT ARG_TRIPLE )
- message( FATAL_ERROR "Must provide ARCH, ARCH_SUFFIX, and TRIPLE" )
- endif()
-
- set( bytecode_files )
- set( bytecode_ir_files )
- foreach( file IN LISTS ARG_LIB_FILES )
- # Files are originally relative to each SOURCE file, which are then make
- # relative to the libclc root directory. We must normalize the path
- # (e.g., ironing out any ".."), then make it relative to the root directory
- # again, and use that relative path component for the binary path.
- get_filename_component( abs_path ${file} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
- file( RELATIVE_PATH root_rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${abs_path} )
- set( input_file ${CMAKE_CURRENT_SOURCE_DIR}/${file} )
- set( output_file "${LIBCLC_ARCH_OBJFILE_DIR}/${root_rel_path}.bc" )
-
- get_filename_component( file_dir ${file} DIRECTORY )
-
- set( file_specific_compile_options )
- get_source_file_property( compile_opts ${file} COMPILE_OPTIONS)
- if( compile_opts )
- set( file_specific_compile_options "${compile_opts}" )
- endif()
-
- compile_to_bc(
- TRIPLE ${ARG_TRIPLE}
- INPUT ${input_file}
- OUTPUT ${output_file}
- EXTRA_OPTS -nostdlib -nostdlibinc "${ARG_COMPILE_FLAGS}"
- "${file_specific_compile_options}"
- -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
- )
-
- # Collect all files originating in LLVM IR separately
- get_filename_component( file_ext ${file} EXT )
- if( ${file_ext} STREQUAL ".ll" )
- list( APPEND bytecode_ir_files ${output_file} )
- else()
- list( APPEND bytecode_files ${output_file} )
- endif()
+ set(_inc_dirs)
+ foreach(f ${ARG_SOURCES})
+ get_filename_component(dir ${f} DIRECTORY)
+ list(APPEND _inc_dirs ${dir})
endforeach()
+ list(REMOVE_DUPLICATES _inc_dirs)
- set( builtins_comp_lib_tgt builtins.comp.${ARG_ARCH_SUFFIX} )
- if ( CMAKE_GENERATOR MATCHES "Visual Studio" )
- # Don't put commands in one custom target to avoid serialized compilation.
- create_compile_targets( compile_tgts
- ARCH_SUFFIX ${ARG_ARCH_SUFFIX}
- FILES ${bytecode_files}
- )
- add_custom_target( ${builtins_comp_lib_tgt} DEPENDS ${bytecode_ir_files} )
- add_dependencies( ${builtins_comp_lib_tgt} ${compile_tgts} )
- else()
- add_custom_target( ${builtins_comp_lib_tgt}
- DEPENDS ${bytecode_files} ${bytecode_ir_files}
- )
- endif()
- set_target_properties( ${builtins_comp_lib_tgt} PROPERTIES FOLDER "libclc/Device IR/Comp" )
-
- # Prepend all LLVM IR files to the list so they are linked into the final
- # bytecode modules first. This helps to suppress unnecessary warnings
- # regarding different data layouts while linking. Any LLVM IR files without a
- # data layout will (silently) be given the first data layout the linking
- # process comes across.
- list( PREPEND bytecode_files ${bytecode_ir_files} )
-
- if( NOT bytecode_files )
- message(FATAL_ERROR "Cannot create an empty builtins library for ${ARG_ARCH_SUFFIX}")
- endif()
-
- set( builtins_link_lib_tgt builtins.link.${ARG_ARCH_SUFFIX} )
-
- if( NOT ARG_INTERNAL_LINK_DEPENDENCIES )
- link_bc(
- TARGET ${builtins_link_lib_tgt}
- INPUTS ${bytecode_files}
- DEPENDENCIES ${builtins_comp_lib_tgt}
- )
- else()
- # If we have libraries to link while internalizing their symbols, we need
- # two separate link steps; the --internalize flag applies to all link
- # inputs but the first.
- set( builtins_link_lib_tmp_tgt builtins.link.pre-deps.${ARG_ARCH_SUFFIX} )
- link_bc(
- TARGET ${builtins_link_lib_tmp_tgt}
- INPUTS ${bytecode_files}
- DEPENDENCIES ${builtins_comp_lib_tgt}
- )
- set( internal_link_depend_files )
- foreach( tgt ${ARG_INTERNAL_LINK_DEPENDENCIES} )
- list( APPEND internal_link_depend_files $<TARGET_PROPERTY:${tgt},TARGET_FILE> )
- endforeach()
- link_bc(
- INTERNALIZE
- TARGET ${builtins_link_lib_tgt}
- INPUTS $<TARGET_PROPERTY:${builtins_link_lib_tmp_tgt},TARGET_FILE>
- ${internal_link_depend_files}
- DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES}
- )
- endif()
-
- # For the CLC internal builtins, exit here - we only optimize the targets'
- # entry points once we've linked the CLC buitins into them
- if( ARG_CLC_INTERNAL )
- return()
- endif()
-
- if (NOT DEFINED ARG_PARENT_TARGET OR ARG_PARENT_TARGET STREQUAL "")
- message(FATAL_ERROR "PARENT_TARGET parameter is required and must be non-empty.")
- endif()
-
- if (NOT DEFINED ARG_OUTPUT_FILENAME OR ARG_OUTPUT_FILENAME STREQUAL "")
- message(FATAL_ERROR "OUTPUT_FILENAME parameter is required and must be non-empty.")
- endif()
- set( LIBCLC_OUTPUT_FILENAME ${ARG_OUTPUT_FILENAME} )
- set( builtins_link_lib $<TARGET_PROPERTY:${builtins_link_lib_tgt},TARGET_FILE> )
-
- # We store the library according to its triple and cpu if present.
- if (NOT "${ARG_DEVICE}" STREQUAL "none")
- set (library_dir ${LIBCLC_OUTPUT_LIBRARY_DIR}/${ARG_TRIPLE}/${ARG_DEVICE})
- else()
- set (library_dir ${LIBCLC_OUTPUT_LIBRARY_DIR}/${ARG_TRIPLE})
- endif()
- file( MAKE_DIRECTORY ${library_dir} )
-
- # For SPIR-V targets we diverage at this point and generate SPIR-V using the
- # llvm-spirv tool.
- if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
- set( libclc_builtins_lib ${library_dir}/${LIBCLC_OUTPUT_FILENAME}.spv )
- if ( LIBCLC_USE_SPIRV_BACKEND )
- add_custom_command( OUTPUT ${libclc_builtins_lib}
- COMMAND ${clang_exe} -c --target=${ARG_TRIPLE}
- -mllvm --spirv-ext=+SPV_KHR_fma
- -x ir -o ${libclc_builtins_lib} ${builtins_link_lib}
- DEPENDS ${clang_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
- )
- else()
- add_custom_command( OUTPUT ${libclc_builtins_lib}
- COMMAND ${llvm-spirv_exe} ${spvflags} --spirv-ext=+SPV_KHR_fma
- -o ${libclc_builtins_lib} ${builtins_link_lib}
- DEPENDS ${llvm-spirv_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
- )
- endif()
- else()
- # Non-SPIR-V targets add an extra step to optimize the bytecode
- set( libclc_builtins_lib ${library_dir}/${LIBCLC_OUTPUT_FILENAME}.bc )
-
- add_custom_command( OUTPUT ${libclc_builtins_lib}
- COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${libclc_builtins_lib}
- ${builtins_link_lib}
- DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
- )
- endif()
-
- # Add a 'library' target
- add_custom_target( library-${ARG_ARCH_SUFFIX} ALL DEPENDS ${libclc_builtins_lib} )
- set_target_properties( "library-${ARG_ARCH_SUFFIX}" PROPERTIES
- TARGET_FILE ${libclc_builtins_lib}
- FOLDER "libclc/Device IR/Library"
- )
-
- # Also add a 'libclc' target for the triple. Since a triple may have
- # multiple devices, ensure we only try to create the triple target once. The
- # triple's target will build all of the bytecode for its constituent devices.
- if( NOT TARGET libclc-${ARG_TRIPLE} )
- add_custom_target( libclc-${ARG_TRIPLE} ALL )
- endif()
- add_dependencies( libclc-${ARG_TRIPLE} library-${ARG_ARCH_SUFFIX} )
- # Add dependency to top-level pseudo target to ease making other
- # targets dependent on libclc.
- add_dependencies( ${ARG_PARENT_TARGET} libclc-${ARG_TRIPLE} )
-
- # Install the created library.
- install(
- FILES ${libclc_builtins_lib}
- DESTINATION ${LIBCLC_INSTALL_DIR}/${ARG_TRIPLE}
- COMPONENT ${ARG_PARENT_TARGET}
+ add_library(${target_name} STATIC ${ARG_SOURCES})
+ target_compile_options(${target_name} PRIVATE ${ARG_COMPILE_OPTIONS})
+ target_include_directories(${target_name} PRIVATE
+ ${ARG_INCLUDE_DIRS} ${_inc_dirs}
)
-
- # SPIR-V targets can exit early here
- if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
- return()
- endif()
-
- # Add a test for whether or not the libraries contain unresolved functions
- # which would usually indicate a build problem. Note that we don't perform
- # this test for all libclc targets:
- # * nvptx64-- targets don't include workitem builtins
- # * clspv targets don't include all OpenCL builtins
- if( NOT ARG_ARCH MATCHES "^(nvptx|clspv)(64)?$" )
- add_test( NAME external-funcs-${ARG_ARCH_SUFFIX}
- COMMAND ./check_external_funcs.sh ${libclc_builtins_lib} ${LLVM_TOOLS_BINARY_DIR}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
- endif()
-
- foreach( a IN LISTS ARG_ALIASES )
- set(target_output_dir ${LIBCLC_OUTPUT_LIBRARY_DIR}/${ARG_TRIPLE}/${a})
-
- if(CMAKE_HOST_UNIX OR LLVM_USE_SYMLINKS)
- cmake_path(RELATIVE_PATH libclc_builtins_lib
- BASE_DIRECTORY ${target_output_dir}
- OUTPUT_VARIABLE LIBCLC_LINK_OR_COPY_SOURCE)
- set(LIBCLC_LINK_OR_COPY create_symlink)
- else()
- set(LIBCLC_LINK_OR_COPY_SOURCE ${libclc_builtins_lib})
- set(LIBCLC_LINK_OR_COPY copy)
- endif()
-
- file( MAKE_DIRECTORY ${target_output_dir} )
- set( libclc_alias_lib ${target_output_dir}/${LIBCLC_OUTPUT_FILENAME}.bc )
-
- add_custom_command(
- OUTPUT ${libclc_alias_lib}
- COMMAND ${CMAKE_COMMAND} -E ${LIBCLC_LINK_OR_COPY} ${LIBCLC_LINK_OR_COPY_SOURCE} ${libclc_alias_lib}
- DEPENDS library-${ARG_ARCH_SUFFIX}
- )
- add_custom_target( alias-${a}-${ARG_TRIPLE} ALL
- DEPENDS ${libclc_alias_lib}
- )
- add_dependencies( ${ARG_PARENT_TARGET} alias-${a}-${ARG_TRIPLE} )
- set_target_properties( alias-${a}-${ARG_TRIPLE}
- PROPERTIES FOLDER "libclc/Device IR/Aliases"
- )
-
- # Install the library
- install(
- FILES ${libclc_alias_lib}
- DESTINATION ${LIBCLC_INSTALL_DIR}/${ARG_TRIPLE}/${a}
- COMPONENT ${ARG_PARENT_TARGET}
- )
- endforeach( a )
-endfunction(add_libclc_builtin_set)
-
-# Produces a list of libclc source files by walking over SOURCES files in a
-# given directory. Outputs the list of files in LIB_FILE_LIST.
-#
-# LIB_FILE_LIST may be pre-populated and is appended to.
-#
-# Arguments:
-# * LIB_ROOT_DIR <string>
-# Root directory containing target's lib files, relative to libclc root
-# directory. If not provided, is set to '.'.
-# * DIRS <string> ...
-# List of directories under LIB_ROOT_DIR to walk over searching for SOURCES
-# files. Directories earlier in the list have lower priority than
-# subsequent ones.
-function(libclc_configure_lib_source LIB_FILE_LIST)
- cmake_parse_arguments(ARG
- ""
- "LIB_ROOT_DIR"
- "DIRS"
- ${ARGN}
+ target_compile_definitions(${target_name} PRIVATE ${ARG_COMPILE_DEFINITIONS})
+ set_target_properties(${target_name} PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ FOLDER ${ARG_FOLDER}
)
-
- if( NOT ARG_LIB_ROOT_DIR )
- set(ARG_LIB_ROOT_DIR ".")
- endif()
-
- # Enumerate SOURCES* files
- set( source_list )
- foreach( l IN LISTS ARG_DIRS )
- foreach( s "SOURCES" "SOURCES_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}" )
- file( TO_CMAKE_PATH ${ARG_LIB_ROOT_DIR}/lib/${l}/${s} file_loc )
- file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${file_loc} loc )
- # Prepend the location to give higher priority to the specialized
- # implementation
- if( EXISTS ${loc} )
- list( PREPEND source_list ${file_loc} )
- endif()
- endforeach()
- endforeach()
-
- ## Add the generated convert files here to prevent adding the ones listed in
- ## SOURCES
- set( rel_files ${${LIB_FILE_LIST}} ) # Source directory input files, relative to the root dir
- # A "set" of already-added input files
- set( objects )
- foreach( f ${${LIB_FILE_LIST}} )
- get_filename_component( name ${f} NAME )
- list( APPEND objects ${name} )
- endforeach()
-
- foreach( l ${source_list} )
- file( READ ${l} file_list )
- string( REPLACE "\n" ";" file_list ${file_list} )
- get_filename_component( dir ${l} DIRECTORY )
- foreach( f ${file_list} )
- get_filename_component( name ${f} NAME )
- # Only add each file once, so that targets can 'specialize' builtins
- if( NOT ${name} IN_LIST objects )
- list( APPEND objects ${name} )
- list( APPEND rel_files ${dir}/${f} )
- endif()
- endforeach()
- endforeach()
-
- set( ${LIB_FILE_LIST} ${rel_files} PARENT_SCOPE )
-endfunction(libclc_configure_lib_source LIB_FILE_LIST)
+endfunction()
diff --git a/libclc/opencl/lib/amdgcn/CMakeLists.txt b/libclc/opencl/lib/amdgcn/CMakeLists.txt
new file mode 100644
index 0000000000000..a42f2751906bf
--- /dev/null
+++ b/libclc/opencl/lib/amdgcn/CMakeLists.txt
@@ -0,0 +1,5 @@
+libclc_configure_source_list(OPENCL_AMDGCN_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ async/wait_group_events.cl
+ printf/__printf_alloc.cl
+)
diff --git a/libclc/opencl/lib/amdgcn/SOURCES b/libclc/opencl/lib/amdgcn/SOURCES
deleted file mode 100644
index 78877425504d6..0000000000000
--- a/libclc/opencl/lib/amdgcn/SOURCES
+++ /dev/null
@@ -1,2 +0,0 @@
-async/wait_group_events.cl
-printf/__printf_alloc.cl
diff --git a/libclc/opencl/lib/clspv/CMakeLists.txt b/libclc/opencl/lib/clspv/CMakeLists.txt
new file mode 100644
index 0000000000000..3094433e16272
--- /dev/null
+++ b/libclc/opencl/lib/clspv/CMakeLists.txt
@@ -0,0 +1,89 @@
+set(_gen ${CMAKE_CURRENT_SOURCE_DIR}/../generic)
+
+# CLSPV uses a curated subset of generic builtins plus its own overrides,
+# so this list is self-contained rather than merged with the generic set.
+libclc_configure_source_list(_clspv_sources
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ conversion/convert_float2float.cl
+ conversion/convert_float2int.cl
+ conversion/convert_int2float.cl
+ conversion/convert_integer.cl
+ math/fma.cl
+ shared/vstore_half.cl
+)
+
+libclc_configure_source_list(_gen_sources
+ ${_gen}
+ geometric/distance.cl
+ geometric/length.cl
+ math/acos.cl
+ math/acosh.cl
+ math/acospi.cl
+ math/asin.cl
+ math/asinh.cl
+ math/asinpi.cl
+ math/atan.cl
+ math/atan2.cl
+ math/atan2pi.cl
+ math/atanh.cl
+ math/atanpi.cl
+ math/cbrt.cl
+ math/cos.cl
+ math/cosh.cl
+ math/cospi.cl
+ math/erf.cl
+ math/erfc.cl
+ math/exp.cl
+ math/exp2.cl
+ math/exp10.cl
+ math/expm1.cl
+ math/fdim.cl
+ math/fmod.cl
+ math/fract.cl
+ math/frexp.cl
+ math/half_cos.cl
+ math/half_divide.cl
+ math/half_exp.cl
+ math/half_exp2.cl
+ math/half_exp10.cl
+ math/half_log.cl
+ math/half_log2.cl
+ math/half_log10.cl
+ math/half_powr.cl
+ math/half_recip.cl
+ math/half_sin.cl
+ math/half_sqrt.cl
+ math/half_tan.cl
+ math/hypot.cl
+ math/ilogb.cl
+ math/ldexp.cl
+ math/lgamma.cl
+ math/lgamma_r.cl
+ math/log.cl
+ math/log2.cl
+ math/log10.cl
+ math/log1p.cl
+ math/logb.cl
+ math/maxmag.cl
+ math/minmag.cl
+ math/modf.cl
+ math/nan.cl
+ math/nextafter.cl
+ math/pow.cl
+ math/pown.cl
+ math/powr.cl
+ math/remainder.cl
+ math/remquo.cl
+ math/rootn.cl
+ math/sin.cl
+ math/sincos.cl
+ math/sinh.cl
+ math/sinpi.cl
+ math/tan.cl
+ math/tanh.cl
+ math/tanpi.cl
+ math/tgamma.cl
+ subnormal_config.cl
+)
+
+set(OPENCL_CLSPV_SOURCES ${_clspv_sources} ${_gen_sources} PARENT_SCOPE)
diff --git a/libclc/opencl/lib/clspv/SOURCES b/libclc/opencl/lib/clspv/SOURCES
deleted file mode 100644
index 0dec7e4fc86d0..0000000000000
--- a/libclc/opencl/lib/clspv/SOURCES
+++ /dev/null
@@ -1,77 +0,0 @@
-conversion/convert_float2float.cl
-conversion/convert_float2int.cl
-conversion/convert_int2float.cl
-conversion/convert_integer.cl
-math/fma.cl
-shared/vstore_half.cl
-../generic/geometric/distance.cl
-../generic/geometric/length.cl
-../generic/math/acos.cl
-../generic/math/acosh.cl
-../generic/math/asinh.cl
-../generic/math/acospi.cl
-../generic/math/asin.cl
-../generic/math/atan.cl
-../generic/math/asinh.cl
-../generic/math/asinpi.cl
-../generic/math/atan2.cl
-../generic/math/atan2pi.cl
-../generic/math/atanh.cl
-../generic/math/atanpi.cl
-../generic/math/cbrt.cl
-../generic/math/cos.cl
-../generic/math/cosh.cl
-../generic/math/cospi.cl
-../generic/math/erf.cl
-../generic/math/erfc.cl
-../generic/math/exp.cl
-../generic/math/exp10.cl
-../generic/math/exp2.cl
-../generic/math/expm1.cl
-../generic/math/fdim.cl
-../generic/math/fmod.cl
-../generic/math/fract.cl
-../generic/math/frexp.cl
-../generic/math/half_cos.cl
-../generic/math/half_divide.cl
-../generic/math/half_exp.cl
-../generic/math/half_exp10.cl
-../generic/math/half_exp2.cl
-../generic/math/half_log.cl
-../generic/math/half_log10.cl
-../generic/math/half_log2.cl
-../generic/math/half_powr.cl
-../generic/math/half_recip.cl
-../generic/math/half_sin.cl
-../generic/math/half_sqrt.cl
-../generic/math/half_tan.cl
-../generic/math/hypot.cl
-../generic/math/ilogb.cl
-../generic/math/ldexp.cl
-../generic/math/lgamma.cl
-../generic/math/lgamma_r.cl
-../generic/math/log.cl
-../generic/math/log10.cl
-../generic/math/log1p.cl
-../generic/math/log2.cl
-../generic/math/logb.cl
-../generic/math/maxmag.cl
-../generic/math/minmag.cl
-../generic/math/modf.cl
-../generic/math/nan.cl
-../generic/math/nextafter.cl
-../generic/math/pow.cl
-../generic/math/pown.cl
-../generic/math/powr.cl
-../generic/math/remainder.cl
-../generic/math/remquo.cl
-../generic/math/rootn.cl
-../generic/math/sin.cl
-../generic/math/sincos.cl
-../generic/math/sinh.cl
-../generic/math/sinpi.cl
-../generic/math/tan.cl
-../generic/math/tanh.cl
-../generic/math/tanpi.cl
-../generic/math/tgamma.cl
-../generic/subnormal_config.cl
diff --git a/libclc/opencl/lib/generic/CMakeLists.txt b/libclc/opencl/lib/generic/CMakeLists.txt
new file mode 100644
index 0000000000000..32ccff46e95b7
--- /dev/null
+++ b/libclc/opencl/lib/generic/CMakeLists.txt
@@ -0,0 +1,223 @@
+libclc_configure_source_list(OPENCL_GENERIC_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ address_space/qualifier.cl
+ async/async_work_group_copy.cl
+ async/async_work_group_strided_copy.cl
+ async/prefetch.cl
+ async/wait_group_events.cl
+ atomic/atom_add.cl
+ atomic/atom_and.cl
+ atomic/atom_cmpxchg.cl
+ atomic/atom_dec.cl
+ atomic/atom_inc.cl
+ atomic/atom_max.cl
+ atomic/atom_min.cl
+ atomic/atom_or.cl
+ atomic/atom_sub.cl
+ atomic/atom_xchg.cl
+ atomic/atom_xor.cl
+ atomic/atomic_add.cl
+ atomic/atomic_and.cl
+ atomic/atomic_cmpxchg.cl
+ atomic/atomic_compare_exchange_strong.cl
+ atomic/atomic_compare_exchange_weak.cl
+ atomic/atomic_dec.cl
+ atomic/atomic_exchange.cl
+ atomic/atomic_fetch_add.cl
+ atomic/atomic_fetch_and.cl
+ atomic/atomic_fetch_max.cl
+ atomic/atomic_fetch_min.cl
+ atomic/atomic_fetch_or.cl
+ atomic/atomic_fetch_sub.cl
+ atomic/atomic_fetch_xor.cl
+ atomic/atomic_flag_clear.cl
+ atomic/atomic_flag_test_and_set.cl
+ atomic/atomic_inc.cl
+ atomic/atomic_init.cl
+ atomic/atomic_load.cl
+ atomic/atomic_max.cl
+ atomic/atomic_min.cl
+ atomic/atomic_or.cl
+ atomic/atomic_store.cl
+ atomic/atomic_sub.cl
+ atomic/atomic_xchg.cl
+ atomic/atomic_xor.cl
+ atomic/atomic_work_item_fence.cl
+ collective/work_group_any_all.cl
+ collective/work_group_broadcast.cl
+ common/degrees.cl
+ common/mix.cl
+ common/radians.cl
+ common/sign.cl
+ common/smoothstep.cl
+ common/step.cl
+ conversion/convert_float2float.cl
+ conversion/convert_float2int.cl
+ conversion/convert_int2float.cl
+ conversion/convert_integer.cl
+ geometric/cross.cl
+ geometric/distance.cl
+ geometric/dot.cl
+ geometric/fast_distance.cl
+ geometric/fast_length.cl
+ geometric/fast_normalize.cl
+ geometric/length.cl
+ geometric/normalize.cl
+ integer/abs.cl
+ integer/abs_diff.cl
+ integer/add_sat.cl
+ integer/bit_reverse.cl
+ integer/bitfield_extract_signed.cl
+ integer/bitfield_extract_unsigned.cl
+ integer/bitfield_insert.cl
+ integer/clz.cl
+ integer/ctz.cl
+ integer/hadd.cl
+ integer/mad24.cl
+ integer/mad_hi.cl
+ integer/mad_sat.cl
+ integer/mul24.cl
+ integer/mul_hi.cl
+ integer/popcount.cl
+ integer/rhadd.cl
+ integer/rotate.cl
+ integer/sub_sat.cl
+ integer/upsample.cl
+ math/acos.cl
+ math/acosh.cl
+ math/acospi.cl
+ math/asin.cl
+ math/asinh.cl
+ math/asinpi.cl
+ math/atan.cl
+ math/atan2.cl
+ math/atan2pi.cl
+ math/atanh.cl
+ math/atanpi.cl
+ math/cbrt.cl
+ math/ceil.cl
+ math/copysign.cl
+ math/cos.cl
+ math/cosh.cl
+ math/cospi.cl
+ math/erf.cl
+ math/erfc.cl
+ math/exp.cl
+ math/exp2.cl
+ math/exp10.cl
+ math/expm1.cl
+ math/fabs.cl
+ math/fdim.cl
+ math/floor.cl
+ math/fma.cl
+ math/fmax.cl
+ math/fmin.cl
+ math/fmod.cl
+ math/fract.cl
+ math/frexp.cl
+ math/half_cos.cl
+ math/half_divide.cl
+ math/half_exp.cl
+ math/half_exp2.cl
+ math/half_exp10.cl
+ math/half_log.cl
+ math/half_log2.cl
+ math/half_log10.cl
+ math/half_powr.cl
+ math/half_recip.cl
+ math/half_rsqrt.cl
+ math/half_sin.cl
+ math/half_sqrt.cl
+ math/half_tan.cl
+ math/hypot.cl
+ math/ilogb.cl
+ math/ldexp.cl
+ math/lgamma.cl
+ math/lgamma_r.cl
+ math/log.cl
+ math/log2.cl
+ math/log10.cl
+ math/log1p.cl
+ math/logb.cl
+ math/mad.cl
+ math/maxmag.cl
+ math/minmag.cl
+ math/modf.cl
+ math/nan.cl
+ math/native_cos.cl
+ math/native_divide.cl
+ math/native_exp.cl
+ math/native_exp2.cl
+ math/native_exp10.cl
+ math/native_log.cl
+ math/native_log2.cl
+ math/native_log10.cl
+ math/native_powr.cl
+ math/native_recip.cl
+ math/native_rsqrt.cl
+ math/native_sin.cl
+ math/native_sqrt.cl
+ math/native_tan.cl
+ math/nextafter.cl
+ math/pow.cl
+ math/pown.cl
+ math/powr.cl
+ math/remainder.cl
+ math/remquo.cl
+ math/rint.cl
+ math/rootn.cl
+ math/round.cl
+ math/rsqrt.cl
+ math/sin.cl
+ math/sincos.cl
+ math/sinh.cl
+ math/sinpi.cl
+ math/sqrt.cl
+ math/tan.cl
+ math/tanh.cl
+ math/tanpi.cl
+ math/tgamma.cl
+ math/trunc.cl
+ mem_fence/fence.cl
+ misc/shuffle.cl
+ misc/shuffle2.cl
+ relational/all.cl
+ relational/any.cl
+ relational/bitselect.cl
+ relational/isequal.cl
+ relational/isfinite.cl
+ relational/isgreater.cl
+ relational/isgreaterequal.cl
+ relational/isinf.cl
+ relational/isless.cl
+ relational/islessequal.cl
+ relational/islessgreater.cl
+ relational/isnan.cl
+ relational/isnormal.cl
+ relational/isnotequal.cl
+ relational/isordered.cl
+ relational/isunordered.cl
+ relational/select.cl
+ relational/signbit.cl
+ shared/clamp.cl
+ shared/max.cl
+ shared/min.cl
+ shared/vload.cl
+ shared/vstore.cl
+ subgroup/sub_group_broadcast.cl
+ subgroup/subgroup.cl
+ subnormal_config.cl
+ synchronization/sub_group_barrier.cl
+ synchronization/work_group_barrier.cl
+ workitem/get_enqueued_local_size.cl
+ workitem/get_global_id.cl
+ workitem/get_global_linear_id.cl
+ workitem/get_global_offset.cl
+ workitem/get_global_size.cl
+ workitem/get_group_id.cl
+ workitem/get_local_id.cl
+ workitem/get_local_linear_id.cl
+ workitem/get_local_size.cl
+ workitem/get_num_groups.cl
+ workitem/get_work_dim.cl
+)
diff --git a/libclc/opencl/lib/generic/SOURCES b/libclc/opencl/lib/generic/SOURCES
deleted file mode 100644
index 0afbb67ebe1e4..0000000000000
--- a/libclc/opencl/lib/generic/SOURCES
+++ /dev/null
@@ -1,220 +0,0 @@
-address_space/qualifier.cl
-subnormal_config.cl
-async/async_work_group_copy.cl
-async/async_work_group_strided_copy.cl
-async/prefetch.cl
-async/wait_group_events.cl
-atomic/atom_add.cl
-atomic/atom_and.cl
-atomic/atom_cmpxchg.cl
-atomic/atom_dec.cl
-atomic/atomic_add.cl
-atomic/atomic_and.cl
-atomic/atomic_cmpxchg.cl
-atomic/atomic_compare_exchange_strong.cl
-atomic/atomic_compare_exchange_weak.cl
-atomic/atomic_dec.cl
-atomic/atomic_exchange.cl
-atomic/atomic_fetch_add.cl
-atomic/atomic_fetch_and.cl
-atomic/atomic_fetch_max.cl
-atomic/atomic_fetch_min.cl
-atomic/atomic_fetch_or.cl
-atomic/atomic_fetch_sub.cl
-atomic/atomic_fetch_xor.cl
-atomic/atomic_flag_clear.cl
-atomic/atomic_flag_test_and_set.cl
-atomic/atomic_inc.cl
-atomic/atomic_init.cl
-atomic/atomic_load.cl
-atomic/atomic_max.cl
-atomic/atomic_min.cl
-atomic/atomic_or.cl
-atomic/atomic_store.cl
-atomic/atomic_sub.cl
-atomic/atomic_xchg.cl
-atomic/atomic_xor.cl
-atomic/atom_inc.cl
-atomic/atom_max.cl
-atomic/atom_min.cl
-atomic/atom_or.cl
-atomic/atom_sub.cl
-atomic/atom_xchg.cl
-atomic/atom_xor.cl
-atomic/atomic_work_item_fence.cl
-collective/work_group_any_all.cl
-collective/work_group_broadcast.cl
-common/degrees.cl
-common/mix.cl
-common/radians.cl
-common/sign.cl
-common/smoothstep.cl
-common/step.cl
-conversion/convert_float2float.cl
-conversion/convert_float2int.cl
-conversion/convert_int2float.cl
-conversion/convert_integer.cl
-geometric/cross.cl
-geometric/distance.cl
-geometric/dot.cl
-geometric/fast_distance.cl
-geometric/fast_length.cl
-geometric/fast_normalize.cl
-geometric/length.cl
-geometric/normalize.cl
-integer/abs.cl
-integer/abs_diff.cl
-integer/add_sat.cl
-integer/bitfield_extract_signed.cl
-integer/bitfield_extract_unsigned.cl
-integer/bitfield_insert.cl
-integer/bit_reverse.cl
-integer/clz.cl
-integer/ctz.cl
-integer/hadd.cl
-integer/mad24.cl
-integer/mad_hi.cl
-integer/mad_sat.cl
-integer/mul24.cl
-integer/mul_hi.cl
-integer/popcount.cl
-integer/rhadd.cl
-integer/rotate.cl
-integer/sub_sat.cl
-integer/upsample.cl
-math/acos.cl
-math/acosh.cl
-math/acospi.cl
-math/asin.cl
-math/asinh.cl
-math/asinpi.cl
-math/atan.cl
-math/atan2.cl
-math/atan2pi.cl
-math/atanh.cl
-math/atanpi.cl
-math/cbrt.cl
-math/ceil.cl
-math/copysign.cl
-math/cos.cl
-math/cosh.cl
-math/cospi.cl
-math/erf.cl
-math/erfc.cl
-math/exp.cl
-math/expm1.cl
-math/exp2.cl
-math/exp10.cl
-math/fabs.cl
-math/fdim.cl
-math/floor.cl
-math/fma.cl
-math/fmax.cl
-math/fmin.cl
-math/fmod.cl
-math/fract.cl
-math/frexp.cl
-math/half_cos.cl
-math/half_divide.cl
-math/half_exp.cl
-math/half_exp10.cl
-math/half_exp2.cl
-math/half_log.cl
-math/half_log10.cl
-math/half_log2.cl
-math/half_powr.cl
-math/half_recip.cl
-math/half_rsqrt.cl
-math/half_sin.cl
-math/half_sqrt.cl
-math/half_tan.cl
-math/hypot.cl
-math/ilogb.cl
-math/ldexp.cl
-math/lgamma.cl
-math/lgamma_r.cl
-math/log.cl
-math/log10.cl
-math/log1p.cl
-math/log2.cl
-math/logb.cl
-math/mad.cl
-math/maxmag.cl
-math/minmag.cl
-math/modf.cl
-math/nan.cl
-math/native_cos.cl
-math/native_divide.cl
-math/native_exp.cl
-math/native_exp10.cl
-math/native_exp2.cl
-math/native_log.cl
-math/native_log10.cl
-math/native_log2.cl
-math/native_powr.cl
-math/native_recip.cl
-math/native_rsqrt.cl
-math/native_sin.cl
-math/native_sqrt.cl
-math/native_tan.cl
-math/nextafter.cl
-math/pow.cl
-math/pown.cl
-math/powr.cl
-math/remainder.cl
-math/remquo.cl
-math/rint.cl
-math/rootn.cl
-math/round.cl
-math/rsqrt.cl
-math/sin.cl
-math/sincos.cl
-math/sinh.cl
-math/sinpi.cl
-math/sqrt.cl
-math/tan.cl
-math/tanh.cl
-math/tanpi.cl
-math/tgamma.cl
-math/trunc.cl
-mem_fence/fence.cl
-misc/shuffle.cl
-misc/shuffle2.cl
-relational/all.cl
-relational/any.cl
-relational/bitselect.cl
-relational/isequal.cl
-relational/isfinite.cl
-relational/isgreater.cl
-relational/isgreaterequal.cl
-relational/isinf.cl
-relational/isless.cl
-relational/islessequal.cl
-relational/islessgreater.cl
-relational/isnan.cl
-relational/isnormal.cl
-relational/isnotequal.cl
-relational/isordered.cl
-relational/isunordered.cl
-relational/select.cl
-relational/signbit.cl
-shared/clamp.cl
-shared/max.cl
-shared/min.cl
-shared/vload.cl
-shared/vstore.cl
-subgroup/subgroup.cl
-subgroup/sub_group_broadcast.cl
-synchronization/sub_group_barrier.cl
-synchronization/work_group_barrier.cl
-workitem/get_enqueued_local_size.cl
-workitem/get_global_id.cl
-workitem/get_global_linear_id.cl
-workitem/get_global_size.cl
-workitem/get_local_id.cl
-workitem/get_local_linear_id.cl
-workitem/get_local_size.cl
-workitem/get_num_groups.cl
-workitem/get_global_offset.cl
-workitem/get_group_id.cl
-workitem/get_work_dim.cl
diff --git a/libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt b/libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt
new file mode 100644
index 0000000000000..9754a7973e563
--- /dev/null
+++ b/libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt
@@ -0,0 +1 @@
+set(OPENCL_PTX_NVIDIACL_SOURCES PARENT_SCOPE)
diff --git a/libclc/opencl/lib/spirv/CMakeLists.txt b/libclc/opencl/lib/spirv/CMakeLists.txt
new file mode 100644
index 0000000000000..b2bd20cfbccd4
--- /dev/null
+++ b/libclc/opencl/lib/spirv/CMakeLists.txt
@@ -0,0 +1,78 @@
+set(_gen ${CMAKE_CURRENT_SOURCE_DIR}/../generic)
+
+# SPIR-V uses a curated subset of generic builtins, so this list is
+# self-contained rather than merged with the generic set.
+libclc_configure_source_list(OPENCL_SPIRV_SOURCES
+ ${_gen}
+ async/async_work_group_strided_copy.cl
+ async/wait_group_events.cl
+ common/degrees.cl
+ common/mix.cl
+ common/radians.cl
+ common/sign.cl
+ common/smoothstep.cl
+ common/step.cl
+ geometric/cross.cl
+ geometric/distance.cl
+ geometric/dot.cl
+ geometric/fast_distance.cl
+ geometric/fast_length.cl
+ geometric/fast_normalize.cl
+ geometric/length.cl
+ geometric/normalize.cl
+ integer/mad_sat.cl
+ integer/rotate.cl
+ math/acos.cl
+ math/acosh.cl
+ math/acospi.cl
+ math/asin.cl
+ math/asinh.cl
+ math/asinpi.cl
+ math/atan.cl
+ math/atan2.cl
+ math/atan2pi.cl
+ math/atanh.cl
+ math/atanpi.cl
+ math/cbrt.cl
+ math/cos.cl
+ math/cosh.cl
+ math/cospi.cl
+ math/erf.cl
+ math/erfc.cl
+ math/exp.cl
+ math/exp2.cl
+ math/exp10.cl
+ math/expm1.cl
+ math/fmod.cl
+ math/fract.cl
+ math/frexp.cl
+ math/half_rsqrt.cl
+ math/half_sqrt.cl
+ math/hypot.cl
+ math/ilogb.cl
+ math/ldexp.cl
+ math/lgamma.cl
+ math/lgamma_r.cl
+ math/log.cl
+ math/log2.cl
+ math/log10.cl
+ math/log1p.cl
+ math/logb.cl
+ math/modf.cl
+ math/pow.cl
+ math/pown.cl
+ math/powr.cl
+ math/remainder.cl
+ math/remquo.cl
+ math/rootn.cl
+ math/sin.cl
+ math/sincos.cl
+ math/sinh.cl
+ math/sinpi.cl
+ math/tan.cl
+ math/tanh.cl
+ math/tanpi.cl
+ math/tgamma.cl
+ shared/vload.cl
+ shared/vstore.cl
+)
diff --git a/libclc/opencl/lib/spirv/SOURCES b/libclc/opencl/lib/spirv/SOURCES
deleted file mode 100644
index ea5f9dee9f64d..0000000000000
--- a/libclc/opencl/lib/spirv/SOURCES
+++ /dev/null
@@ -1,71 +0,0 @@
-../generic/async/async_work_group_strided_copy.cl
-../generic/async/wait_group_events.cl
-../generic/common/degrees.cl
-../generic/common/mix.cl
-../generic/common/radians.cl
-../generic/common/sign.cl
-../generic/common/smoothstep.cl
-../generic/common/step.cl
-../generic/geometric/cross.cl
-../generic/geometric/distance.cl
-../generic/geometric/dot.cl
-../generic/geometric/fast_distance.cl
-../generic/geometric/fast_length.cl
-../generic/geometric/fast_normalize.cl
-../generic/geometric/length.cl
-../generic/geometric/normalize.cl
-../generic/integer/rotate.cl
-../generic/integer/mad_sat.cl
-../generic/math/acos.cl
-../generic/math/acosh.cl
-../generic/math/acospi.cl
-../generic/math/asin.cl
-../generic/math/asinh.cl
-../generic/math/asinpi.cl
-../generic/math/atan.cl
-../generic/math/atan2.cl
-../generic/math/atan2pi.cl
-../generic/math/atanh.cl
-../generic/math/atanpi.cl
-../generic/math/cbrt.cl
-../generic/math/cos.cl
-../generic/math/cosh.cl
-../generic/math/cospi.cl
-../generic/math/erf.cl
-../generic/math/erfc.cl
-../generic/math/exp.cl
-../generic/math/expm1.cl
-../generic/math/exp2.cl
-../generic/math/exp10.cl
-../generic/math/fmod.cl
-../generic/math/fract.cl
-../generic/math/frexp.cl
-../generic/math/half_rsqrt.cl
-../generic/math/half_sqrt.cl
-../generic/math/hypot.cl
-../generic/math/ilogb.cl
-../generic/math/ldexp.cl
-../generic/math/lgamma.cl
-../generic/math/lgamma_r.cl
-../generic/math/log.cl
-../generic/math/log10.cl
-../generic/math/log1p.cl
-../generic/math/log2.cl
-../generic/math/logb.cl
-../generic/math/modf.cl
-../generic/math/pow.cl
-../generic/math/pown.cl
-../generic/math/powr.cl
-../generic/math/remainder.cl
-../generic/math/remquo.cl
-../generic/math/rootn.cl
-../generic/math/sin.cl
-../generic/math/sincos.cl
-../generic/math/sinh.cl
-../generic/math/sinpi.cl
-../generic/math/tan.cl
-../generic/math/tanh.cl
-../generic/math/tanpi.cl
-../generic/math/tgamma.cl
-../generic/shared/vload.cl
-../generic/shared/vstore.cl
>From dfdb1a359ff60318a1eb1f468fcfa18e0639b55c Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Sun, 8 Mar 2026 18:45:48 -0500
Subject: [PATCH 2/2] cleanup
---
libclc/CMakeLists.txt | 67 ++-----------------
libclc/clc/lib/amdgpu/CMakeLists.txt | 6 ++
libclc/clc/lib/generic/CMakeLists.txt | 17 +++++
libclc/cmake/modules/AddLibclc.cmake | 11 +++
libclc/opencl/lib/generic/CMakeLists.txt | 17 +++++
libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt | 1 -
6 files changed, 55 insertions(+), 64 deletions(-)
delete mode 100644 libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 56ca808818e86..6b26be8181301 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -17,7 +17,6 @@ include( AddLibclc )
include( GNUInstallDirs )
set( LIBCLC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
-set( LIBCLC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
# A runtimes cross-build should only use the requested target.
set( LIBCLC_DEFAULT_TARGET "all" )
@@ -134,48 +133,9 @@ add_subdirectory(clc/lib/clspv)
add_subdirectory(opencl/lib/generic)
add_subdirectory(opencl/lib/amdgcn)
-add_subdirectory(opencl/lib/ptx-nvidiacl)
add_subdirectory(opencl/lib/clspv)
add_subdirectory(opencl/lib/spirv)
-set_property(SOURCE
- # CLC builtins
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_cos.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_divide.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_exp10.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_exp2.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_exp.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_log10.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_log2.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_log.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_powr.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_recip.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_rsqrt.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_sin.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_sqrt.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_tan.cl
- # Target-specific CLC builtins
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_exp2.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_exp.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_log10.cl
- # OpenCL builtins
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_cos.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_divide.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp10.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_exp2.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log10.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_log2.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_powr.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_recip.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_rsqrt.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sin.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sqrt.cl
- ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_tan.cl
- APPEND PROPERTY COMPILE_OPTIONS -fapprox-func
-)
-
add_custom_target( libclc ALL )
add_custom_target( libclc-opencl-builtins COMMENT "Build libclc OpenCL builtins" )
@@ -245,32 +205,15 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
list(APPEND target_compile_flags "SHELL:-Xclang -mcode-object-version=none")
endif()
- # Identify which source directory to search through for this target.
- if( ${ARCH} STREQUAL nvptx64 )
- set( DARCH ptx )
- elseif( ${ARCH} STREQUAL clspv OR ${ARCH} STREQUAL clspv64 )
- set( DARCH clspv )
- elseif( ${ARCH} STREQUAL spirv OR ${ARCH} STREQUAL spirv64 )
- set( DARCH spirv )
- elseif( ${ARCH} STREQUAL amdgcn-mesa3d )
- set( DARCH amdgcn-amdhsa )
- else()
- set( DARCH ${ARCH} )
- endif()
- if ( "${OS}" STREQUAL cuda )
- set( OS nvidiacl )
- endif()
-
- # Collect CLC sources, target specific sources will override the generic ones
- # if present in the list.
+ # Collect CLC sources; target-specific sources override generic ones by basename.
set(_clc_overrides)
if(ARCH STREQUAL amdgcn)
list(APPEND _clc_overrides ${CLC_AMDGPU_SOURCES} ${CLC_AMDGCN_SOURCES})
- elseif(DARCH STREQUAL ptx AND OS STREQUAL nvidiacl)
+ elseif(ARCH STREQUAL nvptx64 AND (OS STREQUAL nvidiacl OR OS STREQUAL cuda))
list(APPEND _clc_overrides ${CLC_PTX_NVIDIACL_SOURCES})
- elseif(DARCH STREQUAL spirv)
+ elseif(ARCH STREQUAL spirv OR ARCH STREQUAL spirv64)
list(APPEND _clc_overrides ${CLC_SPIRV_SOURCES})
- elseif(DARCH STREQUAL clspv)
+ elseif(ARCH STREQUAL clspv OR ARCH STREQUAL clspv64)
list(APPEND _clc_overrides ${CLC_CLSPV_SOURCES})
endif()
libclc_merge_sources(clc_sources ${CLC_GENERIC_SOURCES} ${_clc_overrides})
@@ -285,8 +228,6 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
set(_opencl_overrides)
if(ARCH STREQUAL amdgcn)
list(APPEND _opencl_overrides ${OPENCL_AMDGCN_SOURCES})
- elseif(DARCH STREQUAL ptx AND OS STREQUAL nvidiacl)
- list(APPEND _opencl_overrides ${OPENCL_PTX_NVIDIACL_SOURCES})
endif()
libclc_merge_sources(opencl_sources
${OPENCL_GENERIC_SOURCES} ${_opencl_overrides})
diff --git a/libclc/clc/lib/amdgpu/CMakeLists.txt b/libclc/clc/lib/amdgpu/CMakeLists.txt
index 9851fa2d13d19..b44bd1085312f 100644
--- a/libclc/clc/lib/amdgpu/CMakeLists.txt
+++ b/libclc/clc/lib/amdgpu/CMakeLists.txt
@@ -14,3 +14,9 @@ libclc_configure_source_list(CLC_AMDGPU_SOURCES
math/clc_native_log10.cl
math/clc_sqrt.cl
)
+
+libclc_configure_source_options(${CMAKE_CURRENT_SOURCE_DIR} -fapprox-func
+ math/clc_native_exp.cl
+ math/clc_native_exp2.cl
+ math/clc_native_log10.cl
+)
diff --git a/libclc/clc/lib/generic/CMakeLists.txt b/libclc/clc/lib/generic/CMakeLists.txt
index b8adbc1393de3..ac4799c035f73 100644
--- a/libclc/clc/lib/generic/CMakeLists.txt
+++ b/libclc/clc/lib/generic/CMakeLists.txt
@@ -188,3 +188,20 @@ libclc_configure_source_list(CLC_GENERIC_SOURCES
workitem/clc_get_sub_group_id.cl
workitem/clc_get_sub_group_size.cl
)
+
+libclc_configure_source_options(${CMAKE_CURRENT_SOURCE_DIR} -fapprox-func
+ math/clc_native_cos.cl
+ math/clc_native_divide.cl
+ math/clc_native_exp.cl
+ math/clc_native_exp2.cl
+ math/clc_native_exp10.cl
+ math/clc_native_log.cl
+ math/clc_native_log2.cl
+ math/clc_native_log10.cl
+ math/clc_native_powr.cl
+ math/clc_native_recip.cl
+ math/clc_native_rsqrt.cl
+ math/clc_native_sin.cl
+ math/clc_native_sqrt.cl
+ math/clc_native_tan.cl
+)
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index 919c325dea479..b7eda06a85ffa 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -6,6 +6,17 @@ macro(libclc_configure_source_list variable path)
set(${variable} ${${variable}} PARENT_SCOPE)
endmacro()
+# Appends a compile option to the given source files. Paths are relative
+# to `path` and the property is set in the top-level libclc directory scope.
+macro(libclc_configure_source_options path option)
+ set(_option_srcs ${ARGN})
+ list(TRANSFORM _option_srcs PREPEND "${path}/")
+ set_property(SOURCE ${_option_srcs}
+ DIRECTORY ${LIBCLC_SOURCE_DIR}
+ APPEND PROPERTY COMPILE_OPTIONS ${option}
+ )
+endmacro()
+
# Merges OpenCL C source file lists with priority deduplication.
#
# All arguments after the output variable name are treated as source file
diff --git a/libclc/opencl/lib/generic/CMakeLists.txt b/libclc/opencl/lib/generic/CMakeLists.txt
index 32ccff46e95b7..ea36c741f3fee 100644
--- a/libclc/opencl/lib/generic/CMakeLists.txt
+++ b/libclc/opencl/lib/generic/CMakeLists.txt
@@ -221,3 +221,20 @@ libclc_configure_source_list(OPENCL_GENERIC_SOURCES
workitem/get_num_groups.cl
workitem/get_work_dim.cl
)
+
+libclc_configure_source_options(${CMAKE_CURRENT_SOURCE_DIR} -fapprox-func
+ math/native_cos.cl
+ math/native_divide.cl
+ math/native_exp.cl
+ math/native_exp2.cl
+ math/native_exp10.cl
+ math/native_log.cl
+ math/native_log2.cl
+ math/native_log10.cl
+ math/native_powr.cl
+ math/native_recip.cl
+ math/native_rsqrt.cl
+ math/native_sin.cl
+ math/native_sqrt.cl
+ math/native_tan.cl
+)
diff --git a/libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt b/libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt
deleted file mode 100644
index 9754a7973e563..0000000000000
--- a/libclc/opencl/lib/ptx-nvidiacl/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-set(OPENCL_PTX_NVIDIACL_SOURCES PARENT_SCOPE)
More information about the cfe-commits
mailing list