diff options
Diffstat (limited to 'libclc')
-rw-r--r-- | libclc/CMakeLists.txt | 7 | ||||
-rw-r--r-- | libclc/clc/include/clc/math/unary_def_via_fp32.inc | 11 | ||||
-rw-r--r-- | libclc/clc/lib/amdgcn/SOURCES | 2 | ||||
-rw-r--r-- | libclc/clc/lib/generic/geometric/clc_normalize.inc | 17 | ||||
-rw-r--r-- | libclc/clc/lib/generic/math/clc_erf.cl | 26 | ||||
-rw-r--r-- | libclc/clc/lib/generic/math/clc_erfc.cl | 24 | ||||
-rw-r--r-- | libclc/clc/lib/generic/math/clc_fmax.cl | 47 | ||||
-rw-r--r-- | libclc/clc/lib/generic/math/clc_fmin.cl | 46 | ||||
-rw-r--r-- | libclc/clc/lib/generic/math/clc_tgamma.cl | 26 | ||||
-rw-r--r-- | libclc/clc/lib/r600/SOURCES | 2 | ||||
-rw-r--r-- | libclc/clc/lib/r600/math/clc_fmax.cl | 41 | ||||
-rw-r--r-- | libclc/clc/lib/r600/math/clc_fmin.cl | 42 | ||||
-rw-r--r-- | libclc/clc/lib/spirv/SOURCES | 2 | ||||
-rw-r--r-- | libclc/clc/lib/spirv/math/clc_fmax.cl (renamed from libclc/clc/lib/amdgcn/math/clc_fmax.cl) | 21 | ||||
-rw-r--r-- | libclc/clc/lib/spirv/math/clc_fmin.cl (renamed from libclc/clc/lib/amdgcn/math/clc_fmin.cl) | 20 | ||||
-rw-r--r-- | libclc/cmake/modules/AddLibclc.cmake | 26 | ||||
-rw-r--r-- | libclc/utils/CMakeLists.txt | 4 |
17 files changed, 65 insertions, 299 deletions
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index e4e9a74..328dfcf 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -42,6 +42,12 @@ set( LIBCLC_TARGETS_TO_BUILD "all" option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal support." 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 ) + if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) # Out-of-tree configuration set( LIBCLC_STANDALONE_BUILD TRUE ) @@ -463,6 +469,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) LIB_FILES ${opencl_lib_files} GEN_FILES ${opencl_gen_files} ALIASES ${${d}_aliases} + PARENT_TARGET libclc-opencl-builtins # Link in the CLC builtins and internalize their symbols INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix} ) diff --git a/libclc/clc/include/clc/math/unary_def_via_fp32.inc b/libclc/clc/include/clc/math/unary_def_via_fp32.inc deleted file mode 100644 index f109e8e..0000000 --- a/libclc/clc/include/clc/math/unary_def_via_fp32.inc +++ /dev/null @@ -1,11 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x) { - return __CLC_CONVERT_GENTYPE(FUNCTION(__CLC_CONVERT_FLOATN(x))); -} diff --git a/libclc/clc/lib/amdgcn/SOURCES b/libclc/clc/lib/amdgcn/SOURCES index 7bec174..d91f085 100644 --- a/libclc/clc/lib/amdgcn/SOURCES +++ b/libclc/clc/lib/amdgcn/SOURCES @@ -1,5 +1,3 @@ -math/clc_fmax.cl -math/clc_fmin.cl math/clc_ldexp_override.cl workitem/clc_get_global_offset.cl workitem/clc_get_global_size.cl diff --git a/libclc/clc/lib/generic/geometric/clc_normalize.inc b/libclc/clc/lib/generic/geometric/clc_normalize.inc index 8a47c6d..9b2cbc8 100644 --- a/libclc/clc/lib/generic/geometric/clc_normalize.inc +++ b/libclc/clc/lib/generic/geometric/clc_normalize.inc @@ -10,15 +10,8 @@ #if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \ __CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4) -// Until we have a native FP16 implementation, go via FP32 -#if __CLC_FPSIZE == 16 - -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) { - return __CLC_CONVERT_GENTYPE(__clc_normalize(__CLC_CONVERT_FLOATN(p))); -} - // Scalar normalize -#elif defined(__CLC_SCALAR) +#if defined(__CLC_SCALAR) _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) { return __clc_sign(p); @@ -27,7 +20,13 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) { // Vector normalize #else -#if __CLC_FPSIZE == 32 +#if __CLC_FPSIZE == 16 + +#define MIN_VAL HALF_MIN +#define MAX_SQRT 0x1.0p+8h +#define MIN_SQRT 0x1.0p-8h + +#elif __CLC_FPSIZE == 32 #define MIN_VAL FLT_MIN #define MAX_SQRT 0x1.0p+86F diff --git a/libclc/clc/lib/generic/math/clc_erf.cl b/libclc/clc/lib/generic/math/clc_erf.cl index 17fee3e..bea3924 100644 --- a/libclc/clc/lib/generic/math/clc_erf.cl +++ b/libclc/clc/lib/generic/math/clc_erf.cl @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/internal/clc.h> #include <clc/math/clc_exp.h> #include <clc/math/clc_fabs.h> @@ -211,12 +210,6 @@ _CLC_OVERLOAD _CLC_DEF float __clc_erf(float x) { return ret; } -#define __FLOAT_ONLY -#define FUNCTION __clc_erf -#define __CLC_BODY <clc/shared/unary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - #ifdef cl_khr_fp64 #pragma OPENCL EXTENSION cl_khr_fp64 : enable @@ -500,24 +493,19 @@ _CLC_OVERLOAD _CLC_DEF double __clc_erf(double y) { return y < 0.0 ? -ret : ret; } -#define __DOUBLE_ONLY -#define FUNCTION __clc_erf -#define __CLC_BODY <clc/shared/unary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - #endif #ifdef cl_khr_fp16 -#include <clc/clc_convert.h> - #pragma OPENCL EXTENSION cl_khr_fp16 : enable // Forward the half version of this builtin onto the float one -#define __HALF_ONLY -#define FUNCTION __clc_erf -#define __CLC_BODY <clc/math/unary_def_via_fp32.inc> -#include <clc/math/gentype.inc> +_CLC_OVERLOAD _CLC_DEF half __clc_erf(half x) { + return (half)__clc_erf((float)x); +} #endif + +#define FUNCTION __clc_erf +#define __CLC_BODY <clc/shared/unary_def_scalarize.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/math/clc_erfc.cl b/libclc/clc/lib/generic/math/clc_erfc.cl index 77f8959..fab6960 100644 --- a/libclc/clc/lib/generic/math/clc_erfc.cl +++ b/libclc/clc/lib/generic/math/clc_erfc.cl @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/internal/clc.h> #include <clc/math/clc_exp.h> #include <clc/math/clc_fabs.h> @@ -211,12 +210,6 @@ _CLC_OVERLOAD _CLC_DEF float __clc_erfc(float x) { return ret; } -#define __FLOAT_ONLY -#define FUNCTION __clc_erfc -#define __CLC_BODY <clc/shared/unary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - #ifdef cl_khr_fp64 #pragma OPENCL EXTENSION cl_khr_fp64 : enable @@ -509,12 +502,6 @@ _CLC_OVERLOAD _CLC_DEF double __clc_erfc(double x) { return ret; } -#define __DOUBLE_ONLY -#define FUNCTION __clc_erfc -#define __CLC_BODY <clc/shared/unary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - #endif #ifdef cl_khr_fp16 @@ -524,9 +511,12 @@ _CLC_OVERLOAD _CLC_DEF double __clc_erfc(double x) { #pragma OPENCL EXTENSION cl_khr_fp16 : enable // Forward the half version of this builtin onto the float one -#define __HALF_ONLY -#define FUNCTION __clc_erfc -#define __CLC_BODY <clc/math/unary_def_via_fp32.inc> -#include <clc/math/gentype.inc> +_CLC_OVERLOAD _CLC_DEF half __clc_erfc(half x) { + return (half)__clc_erfc((float)x); +} #endif + +#define FUNCTION __clc_erfc +#define __CLC_BODY <clc/shared/unary_def_scalarize.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/math/clc_fmax.cl b/libclc/clc/lib/generic/math/clc_fmax.cl index 5ebbf1b..b334207 100644 --- a/libclc/clc/lib/generic/math/clc_fmax.cl +++ b/libclc/clc/lib/generic/math/clc_fmax.cl @@ -6,53 +6,10 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/internal/clc.h> -#include <clc/relational/clc_isnan.h> -#define __FLOAT_ONLY -#define __CLC_MIN_VECSIZE 1 #define FUNCTION __clc_fmax -#define __IMPL_FUNCTION __builtin_fmaxf -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef __CLC_MIN_VECSIZE -#undef FUNCTION -#undef __IMPL_FUNCTION - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -#define __DOUBLE_ONLY -#define __CLC_MIN_VECSIZE 1 -#define FUNCTION __clc_fmax -#define __IMPL_FUNCTION __builtin_fmax -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef __CLC_MIN_VECSIZE -#undef FUNCTION -#undef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __builtin_elementwise_maximumnum +#define __CLC_BODY <clc/shared/binary_def.inc> -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) { - if (__clc_isnan(x)) - return y; - if (__clc_isnan(y)) - return x; - return (x < y) ? y : x; -} - -#define __HALF_ONLY -#define __CLC_SUPPORTED_VECSIZE_OR_1 2 -#define FUNCTION __clc_fmax -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> #include <clc/math/gentype.inc> -#undef FUNCTION - -#endif diff --git a/libclc/clc/lib/generic/math/clc_fmin.cl b/libclc/clc/lib/generic/math/clc_fmin.cl index 5bddbb8..d21bb8d 100644 --- a/libclc/clc/lib/generic/math/clc_fmin.cl +++ b/libclc/clc/lib/generic/math/clc_fmin.cl @@ -6,52 +6,10 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/internal/clc.h> -#include <clc/relational/clc_isnan.h> -#define __FLOAT_ONLY -#define __CLC_MIN_VECSIZE 1 #define FUNCTION __clc_fmin -#define __IMPL_FUNCTION __builtin_fminf -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef __CLC_MIN_VECSIZE -#undef FUNCTION -#undef __IMPL_FUNCTION - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -#define __DOUBLE_ONLY -#define __CLC_MIN_VECSIZE 1 -#define FUNCTION __clc_fmin -#define __IMPL_FUNCTION __builtin_fmin -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef __CLC_MIN_VECSIZE -#undef FUNCTION -#undef __IMPL_FUNCTION +#define __IMPL_FUNCTION(x) __builtin_elementwise_minimumnum +#define __CLC_BODY <clc/shared/binary_def.inc> -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) { - if (__clc_isnan(x)) - return y; - if (__clc_isnan(y)) - return x; - return (y < x) ? y : x; -} - -#define __HALF_ONLY -#define __CLC_SUPPORTED_VECSIZE_OR_1 2 -#define FUNCTION __clc_fmin -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> #include <clc/math/gentype.inc> - -#endif diff --git a/libclc/clc/lib/generic/math/clc_tgamma.cl b/libclc/clc/lib/generic/math/clc_tgamma.cl index e0fed98..83b09cc 100644 --- a/libclc/clc/lib/generic/math/clc_tgamma.cl +++ b/libclc/clc/lib/generic/math/clc_tgamma.cl @@ -6,7 +6,6 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/float/definitions.h> #include <clc/internal/clc.h> #include <clc/math/clc_exp.h> @@ -32,12 +31,6 @@ _CLC_OVERLOAD _CLC_DEF float __clc_tgamma(float x) { return g; } -#define __FLOAT_ONLY -#define FUNCTION __clc_tgamma -#define __CLC_BODY <clc/shared/unary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - #ifdef cl_khr_fp64 #pragma OPENCL EXTENSION cl_khr_fp64 : enable @@ -59,24 +52,19 @@ _CLC_OVERLOAD _CLC_DEF double __clc_tgamma(double x) { return g; } -#define __DOUBLE_ONLY -#define FUNCTION __clc_tgamma -#define __CLC_BODY <clc/shared/unary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - #endif #ifdef cl_khr_fp16 -#include <clc/clc_convert.h> - #pragma OPENCL EXTENSION cl_khr_fp16 : enable // Forward the half version of this builtin onto the float one -#define __HALF_ONLY -#define FUNCTION __clc_tgamma -#define __CLC_BODY <clc/math/unary_def_via_fp32.inc> -#include <clc/math/gentype.inc> +_CLC_OVERLOAD _CLC_DEF half __clc_tgamma(half x) { + return (half)__clc_tgamma((float)x); +} #endif + +#define FUNCTION __clc_tgamma +#define __CLC_BODY <clc/shared/unary_def_scalarize.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/r600/SOURCES b/libclc/clc/lib/r600/SOURCES index 75d32f4..8d5caf1 100644 --- a/libclc/clc/lib/r600/SOURCES +++ b/libclc/clc/lib/r600/SOURCES @@ -1,4 +1,2 @@ -math/clc_fmax.cl -math/clc_fmin.cl math/clc_native_rsqrt.cl math/clc_rsqrt_override.cl diff --git a/libclc/clc/lib/r600/math/clc_fmax.cl b/libclc/clc/lib/r600/math/clc_fmax.cl deleted file mode 100644 index 689e51a..0000000 --- a/libclc/clc/lib/r600/math/clc_fmax.cl +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include <clc/clcmacro.h> -#include <clc/internal/clc.h> -#include <clc/math/math.h> - -_CLC_DEF _CLC_OVERLOAD float __clc_fmax(float x, float y) { - // Flush denormals if not enabled. Otherwise fmax instruction flushes the - // values for comparison, but outputs original denormal - x = __clc_flush_denormal_if_not_supported(x); - y = __clc_flush_denormal_if_not_supported(y); - return __builtin_fmaxf(x, y); -} - -#define __FLOAT_ONLY -#define FUNCTION __clc_fmax -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEF _CLC_OVERLOAD double __clc_fmax(double x, double y) { - return __builtin_fmax(x, y); -} - -#define __DOUBLE_ONLY -#define FUNCTION __clc_fmax -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - -#endif diff --git a/libclc/clc/lib/r600/math/clc_fmin.cl b/libclc/clc/lib/r600/math/clc_fmin.cl deleted file mode 100644 index 22cb704..0000000 --- a/libclc/clc/lib/r600/math/clc_fmin.cl +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include <clc/clcmacro.h> -#include <clc/internal/clc.h> -#include <clc/math/math.h> - -_CLC_DEF _CLC_OVERLOAD float __clc_fmin(float x, float y) { - // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise - // fmin instruction flushes the values for comparison, but outputs original - // denormal - x = __clc_flush_denormal_if_not_supported(x); - y = __clc_flush_denormal_if_not_supported(y); - return __builtin_fminf(x, y); -} - -#define __FLOAT_ONLY -#define FUNCTION __clc_fmin -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEF _CLC_OVERLOAD double __clc_fmin(double x, double y) { - return __builtin_fmin(x, y); -} - -#define __DOUBLE_ONLY -#define FUNCTION __clc_fmin -#define __CLC_BODY <clc/shared/binary_def_scalarize.inc> -#include <clc/math/gentype.inc> -#undef FUNCTION - -#endif diff --git a/libclc/clc/lib/spirv/SOURCES b/libclc/clc/lib/spirv/SOURCES index cd6e0b2..07bc7aa 100644 --- a/libclc/clc/lib/spirv/SOURCES +++ b/libclc/clc/lib/spirv/SOURCES @@ -1 +1,3 @@ +math/clc_fmax.cl +math/clc_fmin.cl math/clc_runtime_has_hw_fma32.cl diff --git a/libclc/clc/lib/amdgcn/math/clc_fmax.cl b/libclc/clc/lib/spirv/math/clc_fmax.cl index cea90a7..be660fe 100644 --- a/libclc/clc/lib/amdgcn/math/clc_fmax.cl +++ b/libclc/clc/lib/spirv/math/clc_fmax.cl @@ -8,40 +8,23 @@ #include <clc/clcmacro.h> #include <clc/internal/clc.h> -#include <clc/relational/clc_isnan.h> _CLC_DEF _CLC_OVERLOAD float __clc_fmax(float x, float y) { - // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise - // fmax instruction flushes the values for comparison, but outputs original - // denormal - x = __builtin_canonicalizef(x); - y = __builtin_canonicalizef(y); return __builtin_fmaxf(x, y); } #ifdef cl_khr_fp64 - #pragma OPENCL EXTENSION cl_khr_fp64 : enable - _CLC_DEF _CLC_OVERLOAD double __clc_fmax(double x, double y) { - x = __builtin_canonicalize(x); - y = __builtin_canonicalize(y); return __builtin_fmax(x, y); } - #endif -#ifdef cl_khr_fp16 +#ifdef cl_khr_fp16 #pragma OPENCL EXTENSION cl_khr_fp16 : enable - _CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) { - if (__clc_isnan(x)) - return y; - if (__clc_isnan(y)) - return x; - return (y < x) ? x : y; + return __builtin_fmaxf16(x, y); } - #endif #define FUNCTION __clc_fmax diff --git a/libclc/clc/lib/amdgcn/math/clc_fmin.cl b/libclc/clc/lib/spirv/math/clc_fmin.cl index 12bb0c6..9f3fa66 100644 --- a/libclc/clc/lib/amdgcn/math/clc_fmin.cl +++ b/libclc/clc/lib/spirv/math/clc_fmin.cl @@ -8,41 +8,23 @@ #include <clc/clcmacro.h> #include <clc/internal/clc.h> -#include <clc/relational/clc_isnan.h> _CLC_DEF _CLC_OVERLOAD float __clc_fmin(float x, float y) { - // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise - // fmin instruction flushes the values for comparison, but outputs original - // denormal - x = __builtin_canonicalizef(x); - y = __builtin_canonicalizef(y); return __builtin_fminf(x, y); } #ifdef cl_khr_fp64 - #pragma OPENCL EXTENSION cl_khr_fp64 : enable - _CLC_DEF _CLC_OVERLOAD double __clc_fmin(double x, double y) { - x = __builtin_canonicalize(x); - y = __builtin_canonicalize(y); return __builtin_fmin(x, y); } - #endif #ifdef cl_khr_fp16 - #pragma OPENCL EXTENSION cl_khr_fp16 : enable - _CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) { - if (__clc_isnan(x)) - return y; - if (__clc_isnan(y)) - return x; - return (y < x) ? y : x; + return __builtin_fminf16(x, y); } - #endif #define FUNCTION __clc_fmin diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 056706e..9b0e5d9 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -207,6 +207,8 @@ endfunction() # libclc architecture/triple suffix # * TRIPLE <string> # Triple used to compile +# * PARENT_TARGET <string> +# Target into which to group the target builtins # # Optional Arguments: # * CLC_INTERNAL @@ -229,7 +231,7 @@ endfunction() function(add_libclc_builtin_set) cmake_parse_arguments(ARG "CLC_INTERNAL" - "ARCH;TRIPLE;ARCH_SUFFIX" + "ARCH;TRIPLE;ARCH_SUFFIX;PARENT_TARGET" "LIB_FILES;GEN_FILES;COMPILE_FLAGS;OPT_FLAGS;ALIASES;INTERNAL_LINK_DEPENDENCIES" ${ARGN} ) @@ -403,6 +405,9 @@ function(add_libclc_builtin_set) add_custom_target( prepare-${ARG_TRIPLE} ALL ) endif() add_dependencies( prepare-${ARG_TRIPLE} prepare-${obj_suffix} ) + # Add dependency to top-level pseudo target to ease making other + # targets dependent on libclc. + add_dependencies( ${ARG_PARENT_TARGET} prepare-${ARG_TRIPLE} ) install( FILES ${libclc_builtins_lib} @@ -425,22 +430,27 @@ function(add_libclc_builtin_set) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) endif() - if(CMAKE_HOST_UNIX OR LLVM_USE_SYMLINKS) - set(LIBCLC_LINK_OR_COPY create_symlink) - else() - set(LIBCLC_LINK_OR_COPY copy) - endif() - foreach( a IN LISTS ARG_ALIASES ) + if(CMAKE_HOST_UNIX OR LLVM_USE_SYMLINKS) + cmake_path(RELATIVE_PATH libclc_builtins_lib + BASE_DIRECTORY ${LIBCLC_OUTPUT_LIBRARY_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() + set( alias_suffix "${a}-${ARG_TRIPLE}.bc" ) add_custom_command( OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix} - COMMAND ${CMAKE_COMMAND} -E ${LIBCLC_LINK_OR_COPY} ${libclc_builtins_lib} ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix} + COMMAND ${CMAKE_COMMAND} -E ${LIBCLC_LINK_OR_COPY} ${LIBCLC_LINK_OR_COPY_SOURCE} ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix} DEPENDS prepare-${obj_suffix} ) add_custom_target( alias-${alias_suffix} ALL DEPENDS ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix} ) + add_dependencies( ${ARG_PARENT_TARGET} alias-${alias_suffix} ) set_target_properties( alias-${alias_suffix} PROPERTIES FOLDER "libclc/Device IR/Aliases" ) diff --git a/libclc/utils/CMakeLists.txt b/libclc/utils/CMakeLists.txt index ea1d9e9..6851ae1 100644 --- a/libclc/utils/CMakeLists.txt +++ b/libclc/utils/CMakeLists.txt @@ -12,8 +12,8 @@ set( LLVM_LINK_COMPONENTS if( LIBCLC_STANDALONE_BUILD ) add_llvm_executable( prepare_builtins prepare-builtins.cpp ) - set( prepare_builtins_exe prepare_builtins ) - set( prepare_builtins_target prepare_builtins ) + set( prepare_builtins_exe prepare_builtins PARENT_SCOPE ) + set( prepare_builtins_target prepare_builtins PARENT_SCOPE ) else() add_llvm_utility( prepare_builtins prepare-builtins.cpp ) setup_host_tool( prepare_builtins PREPARE_BUILTINS prepare_builtins_exe prepare_builtins_target ) |