https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/145458
>From 0cbf5c96077bce977168497670e3ffae9e70e5d5 Mon Sep 17 00:00:00 2001 From: Wenju He <wenju...@intel.com> Date: Tue, 24 Jun 2025 06:59:27 +0200 Subject: [PATCH 1/3] [NFC][libclc] Replace and delete _CLC_DEFINE_UNARY/BINARY/TERNARY_BUILTIN macros Also delete unused _CLC_DEFINE_BINARY_BUILTIN_WITH_SCALAR_SECOND_ARG, _CLC_DEFINE_UNARY_BUILTIN_FP16 and _CLC_DEFINE_BINARY_BUILTIN_FP16. llvm-diff shows no change to nvptx64--nvidiacl.bc and amdgcn--amdhsa.bc --- libclc/clc/include/clc/clcmacro.h | 105 ------------------ .../shared/binary_def_with_int_second_arg.inc | 17 +++ libclc/clc/lib/generic/math/clc_copysign.cl | 28 +---- libclc/opencl/lib/clspv/math/fma.cl | 8 +- libclc/opencl/lib/generic/common/degrees.cl | 18 +-- libclc/opencl/lib/generic/common/radians.cl | 18 +-- libclc/opencl/lib/generic/math/fma.cl | 18 +-- libclc/opencl/lib/generic/math/ldexp.cl | 21 +--- libclc/opencl/lib/generic/math/mad.cl | 18 +-- libclc/opencl/lib/generic/math/nextafter.cl | 24 +--- libclc/opencl/lib/spirv/math/fma.cl | 8 +- 11 files changed, 53 insertions(+), 230 deletions(-) create mode 100644 libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc diff --git a/libclc/clc/include/clc/clcmacro.h b/libclc/clc/include/clc/clcmacro.h index de7b977021f8b..b712fe5cf326c 100644 --- a/libclc/clc/include/clc/clcmacro.h +++ b/libclc/clc/include/clc/clcmacro.h @@ -179,109 +179,4 @@ _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, RET_TYPE, FUNCTION, ARG1_TYPE, \ ARG2_TYPE) -// FIXME: Make _CLC_DEFINE_BINARY_BUILTIN avoid scalarization by default, and -// introduce an explicit scalarizing version. -#define _CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(RET_TYPE, FUNCTION, BUILTIN, \ - ARG1_TYPE, ARG2_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \ - return BUILTIN(x, y); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, \ - ARG2_TYPE##2 y) { \ - return BUILTIN(x, y); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, \ - ARG2_TYPE##3 y) { \ - return BUILTIN(x, y); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, \ - ARG2_TYPE##4 y) { \ - return BUILTIN(x, y); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, \ - ARG2_TYPE##8 y) { \ - return BUILTIN(x, y); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x, \ - ARG2_TYPE##16 y) { \ - return BUILTIN(x, y); \ - } - -#define _CLC_DEFINE_BINARY_BUILTIN_WITH_SCALAR_SECOND_ARG( \ - RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE, ARG2_TYPE) \ - _CLC_DEFINE_BINARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE, \ - ARG2_TYPE) \ - _CLC_BINARY_VECTORIZE_SCALAR_SECOND_ARG(_CLC_OVERLOAD _CLC_DEF, RET_TYPE, \ - FUNCTION, ARG1_TYPE, ARG2_TYPE) - -#define _CLC_DEFINE_UNARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x) { return BUILTIN(x); } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x) { \ - return BUILTIN(x); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x) { \ - return BUILTIN(x); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x) { \ - return BUILTIN(x); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x) { \ - return BUILTIN(x); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x) { \ - return BUILTIN(x); \ - } - -#define _CLC_DEFINE_TERNARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE, \ - ARG2_TYPE, ARG3_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y, \ - ARG3_TYPE z) { \ - return BUILTIN(x, y, z); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ARG2_TYPE##2 y, \ - ARG3_TYPE##2 z) { \ - return BUILTIN(x, y, z); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, ARG2_TYPE##3 y, \ - ARG3_TYPE##3 z) { \ - return BUILTIN(x, y, z); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, ARG2_TYPE##4 y, \ - ARG3_TYPE##4 z) { \ - return BUILTIN(x, y, z); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, ARG2_TYPE##8 y, \ - ARG3_TYPE##8 z) { \ - return BUILTIN(x, y, z); \ - } \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE##16 FUNCTION( \ - ARG1_TYPE##16 x, ARG2_TYPE##16 y, ARG3_TYPE##16 z) { \ - return BUILTIN(x, y, z); \ - } - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -#define _CLC_DEFINE_UNARY_BUILTIN_FP16(FUNCTION) \ - _CLC_DEF _CLC_OVERLOAD half FUNCTION(half x) { \ - return (half)FUNCTION((float)x); \ - } \ - _CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, FUNCTION, half) - -#define _CLC_DEFINE_BINARY_BUILTIN_FP16(FUNCTION) \ - _CLC_DEF _CLC_OVERLOAD half FUNCTION(half x, half y) { \ - return (half)FUNCTION((float)x, (float)y); \ - } \ - _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, FUNCTION, half, half) - -#pragma OPENCL EXTENSION cl_khr_fp16 : disable - -#else - -#define _CLC_DEFINE_UNARY_BUILTIN_FP16(FUNCTION) -#define _CLC_DEFINE_BINARY_BUILTIN_FP16(FUNCTION) - -#endif - #endif // __CLC_CLCMACRO_H__ diff --git a/libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc b/libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc new file mode 100644 index 0000000000000..45b4382d865bc --- /dev/null +++ b/libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/utils.h> + +#ifndef __CLC_FUNCTION +#define __CLC_FUNCTION(x) __CLC_CONCAT(__clc_, x) +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a, __CLC_INTN b) { + return __CLC_FUNCTION(FUNCTION)(a, b); +} diff --git a/libclc/clc/lib/generic/math/clc_copysign.cl b/libclc/clc/lib/generic/math/clc_copysign.cl index d336985ebf967..b066c14bcf3f5 100644 --- a/libclc/clc/lib/generic/math/clc_copysign.cl +++ b/libclc/clc/lib/generic/math/clc_copysign.cl @@ -6,30 +6,10 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/internal/clc.h> -_CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(float, __clc_copysign, - __builtin_elementwise_copysign, float, - float) - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(double, __clc_copysign, - __builtin_elementwise_copysign, double, - double) - -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(half, __clc_copysign, - __builtin_elementwise_copysign, half, - half) - -#endif +#define FUNCTION __clc_copysign +#define __CLC_FUNCTION(x) __builtin_elementwise_copysign +#define __CLC_BODY <clc/shared/binary_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/clspv/math/fma.cl b/libclc/opencl/lib/clspv/math/fma.cl index 2722018121224..0f3141a0e09ee 100644 --- a/libclc/opencl/lib/clspv/math/fma.cl +++ b/libclc/opencl/lib/clspv/math/fma.cl @@ -6,8 +6,12 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/internal/math/clc_sw_fma.h> #include <clc/opencl/clc.h> -_CLC_DEFINE_TERNARY_BUILTIN(float, fma, __clc_sw_fma, float, float, float) +#define __FLOAT_ONLY +#define FUNCTION fma +#define __CLC_FUNCTION(x) __clc_sw_fma +#define __CLC_BODY <clc/shared/ternary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/common/degrees.cl b/libclc/opencl/lib/generic/common/degrees.cl index 8b17fe4321297..a86003c170bff 100644 --- a/libclc/opencl/lib/generic/common/degrees.cl +++ b/libclc/opencl/lib/generic/common/degrees.cl @@ -6,22 +6,10 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/common/clc_degrees.h> #include <clc/opencl/clc.h> -_CLC_DEFINE_UNARY_BUILTIN(float, degrees, __clc_degrees, float) +#define FUNCTION degrees +#define __CLC_BODY <clc/shared/unary_def.inc> -#ifdef cl_khr_fp64 -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEFINE_UNARY_BUILTIN(double, degrees, __clc_degrees, double) - -#endif - -#ifdef cl_khr_fp16 -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_UNARY_BUILTIN(half, degrees, __clc_degrees, half) - -#endif +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/common/radians.cl b/libclc/opencl/lib/generic/common/radians.cl index 1c58c6c4da6f3..b45653be2e782 100644 --- a/libclc/opencl/lib/generic/common/radians.cl +++ b/libclc/opencl/lib/generic/common/radians.cl @@ -6,22 +6,10 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/common/clc_radians.h> #include <clc/opencl/clc.h> -_CLC_DEFINE_UNARY_BUILTIN(float, radians, __clc_radians, float) +#define FUNCTION radians +#define __CLC_BODY <clc/shared/unary_def.inc> -#ifdef cl_khr_fp64 -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEFINE_UNARY_BUILTIN(double, radians, __clc_radians, double) - -#endif - -#ifdef cl_khr_fp16 -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_UNARY_BUILTIN(half, radians, __clc_radians, half) - -#endif +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/math/fma.cl b/libclc/opencl/lib/generic/math/fma.cl index ee3395bb2c648..c077357a44f0d 100644 --- a/libclc/opencl/lib/generic/math/fma.cl +++ b/libclc/opencl/lib/generic/math/fma.cl @@ -6,23 +6,11 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/math/clc_fma.h> #include <clc/math/math.h> #include <clc/opencl/clc.h> -_CLC_DEFINE_TERNARY_BUILTIN(float, fma, __clc_fma, float, float, float) +#define FUNCTION fma +#define __CLC_BODY <clc/shared/ternary_def.inc> -#ifdef cl_khr_fp64 -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEFINE_TERNARY_BUILTIN(double, fma, __clc_fma, double, double, double) - -#endif - -#ifdef cl_khr_fp16 -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_TERNARY_BUILTIN(half, fma, __clc_fma, half, half, half) - -#endif +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/math/ldexp.cl b/libclc/opencl/lib/generic/math/ldexp.cl index e3b9b2b3f1363..069ba8251feba 100644 --- a/libclc/opencl/lib/generic/math/ldexp.cl +++ b/libclc/opencl/lib/generic/math/ldexp.cl @@ -6,27 +6,14 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/math/clc_ldexp.h> #include <clc/opencl/clc.h> -_CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(float, ldexp, __clc_ldexp, float, int) +#define FUNCTION ldexp +#define __CLC_FUNCTION(x) __clc_ldexp +#define __CLC_BODY <clc/shared/binary_def_with_int_second_arg.inc> -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(double, ldexp, __clc_ldexp, double, int) - -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(half, ldexp, __clc_ldexp, half, int) - -#endif +#include <clc/math/gentype.inc> // This defines all the ldexp(GENTYPE, int) variants #define __CLC_BODY <ldexp.inc> diff --git a/libclc/opencl/lib/generic/math/mad.cl b/libclc/opencl/lib/generic/math/mad.cl index 20e6903094454..39aa8e884cc03 100644 --- a/libclc/opencl/lib/generic/math/mad.cl +++ b/libclc/opencl/lib/generic/math/mad.cl @@ -6,22 +6,10 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/math/clc_mad.h> #include <clc/opencl/clc.h> -_CLC_DEFINE_TERNARY_BUILTIN(float, mad, __clc_mad, float, float, float) +#define FUNCTION mad +#define __CLC_BODY <clc/shared/ternary_def.inc> -#ifdef cl_khr_fp64 -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEFINE_TERNARY_BUILTIN(double, mad, __clc_mad, double, double, double) - -#endif - -#ifdef cl_khr_fp16 -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_TERNARY_BUILTIN(half, mad, __clc_mad, half, half, half) - -#endif +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/math/nextafter.cl b/libclc/opencl/lib/generic/math/nextafter.cl index ecb187c53069e..6a5a745f82526 100644 --- a/libclc/opencl/lib/generic/math/nextafter.cl +++ b/libclc/opencl/lib/generic/math/nextafter.cl @@ -6,27 +6,11 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/math/clc_nextafter.h> #include <clc/opencl/clc.h> -_CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(float, nextafter, __clc_nextafter, - float, float) +#define FUNCTION nextafter +#define __CLC_FUNCTION(x) __clc_nextafter +#define __CLC_BODY <clc/shared/binary_def.inc> -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(double, nextafter, __clc_nextafter, - double, double) - -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_BINARY_BUILTIN_NO_SCALARIZE(half, nextafter, __clc_nextafter, half, - half) - -#endif +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/spirv/math/fma.cl b/libclc/opencl/lib/spirv/math/fma.cl index 2722018121224..2d826632b8e52 100644 --- a/libclc/opencl/lib/spirv/math/fma.cl +++ b/libclc/opencl/lib/spirv/math/fma.cl @@ -6,8 +6,12 @@ // //===----------------------------------------------------------------------===// -#include <clc/clcmacro.h> #include <clc/internal/math/clc_sw_fma.h> #include <clc/opencl/clc.h> -_CLC_DEFINE_TERNARY_BUILTIN(float, fma, __clc_sw_fma, float, float, float) +#define FUNCTION fma +#define __CLC_FUNCTION(x) __clc_sw_fma +#define __CLC_BODY <clc/shared/ternary_def.inc> + +#define __FLOAT_ONLY +#include <clc/math/gentype.inc> >From e6e6d0a671cdde02e4965198d716a1b7fb43bcc9 Mon Sep 17 00:00:00 2001 From: Wenju He <wenju...@intel.com> Date: Tue, 24 Jun 2025 11:34:25 +0200 Subject: [PATCH 2/3] move binary_def_with_int_second_arg.inc from math to shared folder --- .../clc/math/binary_def_with_int_second_arg.inc | 17 ----------------- libclc/clc/include/clc/math/clc_pown.h | 2 +- libclc/clc/include/clc/math/clc_rootn.h | 2 +- .../binary_decl_with_int_second_arg.inc | 0 .../shared/binary_def_with_int_second_arg.inc | 4 ++-- libclc/opencl/include/clc/opencl/math/ldexp.h | 5 +++++ libclc/opencl/include/clc/opencl/math/ldexp.inc | 4 +--- libclc/opencl/include/clc/opencl/math/pown.h | 2 +- libclc/opencl/include/clc/opencl/math/rootn.h | 2 +- libclc/opencl/lib/generic/math/pown.cl | 2 +- libclc/opencl/lib/generic/math/rootn.cl | 2 +- 11 files changed, 14 insertions(+), 28 deletions(-) delete mode 100644 libclc/clc/include/clc/math/binary_def_with_int_second_arg.inc rename libclc/clc/include/clc/{math => shared}/binary_decl_with_int_second_arg.inc (100%) diff --git a/libclc/clc/include/clc/math/binary_def_with_int_second_arg.inc b/libclc/clc/include/clc/math/binary_def_with_int_second_arg.inc deleted file mode 100644 index 756bce6538ab4..0000000000000 --- a/libclc/clc/include/clc/math/binary_def_with_int_second_arg.inc +++ /dev/null @@ -1,17 +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/utils.h> - -#ifndef __CLC_FUNCTION -#define __CLC_FUNCTION(x) __CLC_CONCAT(__clc_, x) -#endif - -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_INTN y) { - return __CLC_FUNCTION(FUNCTION)(x, y); -} diff --git a/libclc/clc/include/clc/math/clc_pown.h b/libclc/clc/include/clc/math/clc_pown.h index 67475503f92b7..30628efb19001 100644 --- a/libclc/clc/include/clc/math/clc_pown.h +++ b/libclc/clc/include/clc/math/clc_pown.h @@ -9,7 +9,7 @@ #ifndef __CLC_MATH_CLC_POWN_H__ #define __CLC_MATH_CLC_POWN_H__ -#define __CLC_BODY <clc/math/binary_decl_with_int_second_arg.inc> +#define __CLC_BODY <clc/shared/binary_decl_with_int_second_arg.inc> #define __CLC_FUNCTION __clc_pown #include <clc/math/gentype.inc> diff --git a/libclc/clc/include/clc/math/clc_rootn.h b/libclc/clc/include/clc/math/clc_rootn.h index bf9dd5413c3de..90a25ad52d867 100644 --- a/libclc/clc/include/clc/math/clc_rootn.h +++ b/libclc/clc/include/clc/math/clc_rootn.h @@ -9,7 +9,7 @@ #ifndef __CLC_MATH_CLC_ROOTN_H__ #define __CLC_MATH_CLC_ROOTN_H__ -#define __CLC_BODY <clc/math/binary_decl_with_int_second_arg.inc> +#define __CLC_BODY <clc/shared/binary_decl_with_int_second_arg.inc> #define __CLC_FUNCTION __clc_rootn #include <clc/math/gentype.inc> diff --git a/libclc/clc/include/clc/math/binary_decl_with_int_second_arg.inc b/libclc/clc/include/clc/shared/binary_decl_with_int_second_arg.inc similarity index 100% rename from libclc/clc/include/clc/math/binary_decl_with_int_second_arg.inc rename to libclc/clc/include/clc/shared/binary_decl_with_int_second_arg.inc diff --git a/libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc b/libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc index 45b4382d865bc..756bce6538ab4 100644 --- a/libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc +++ b/libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc @@ -12,6 +12,6 @@ #define __CLC_FUNCTION(x) __CLC_CONCAT(__clc_, x) #endif -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a, __CLC_INTN b) { - return __CLC_FUNCTION(FUNCTION)(a, b); +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_INTN y) { + return __CLC_FUNCTION(FUNCTION)(x, y); } diff --git a/libclc/opencl/include/clc/opencl/math/ldexp.h b/libclc/opencl/include/clc/opencl/math/ldexp.h index 6dcd2a9548d09..ca50ae6a98312 100644 --- a/libclc/opencl/include/clc/opencl/math/ldexp.h +++ b/libclc/opencl/include/clc/opencl/math/ldexp.h @@ -6,5 +6,10 @@ // //===----------------------------------------------------------------------===// +#define __CLC_FUNCTION ldexp +#define __CLC_BODY <clc/shared/binary_decl_with_int_second_arg.inc> +#include <clc/math/gentype.inc> +#undef __CLC_FUNCTION + #define __CLC_BODY <clc/opencl/math/ldexp.inc> #include <clc/math/gentype.inc> diff --git a/libclc/opencl/include/clc/opencl/math/ldexp.inc b/libclc/opencl/include/clc/opencl/math/ldexp.inc index 116acdff41d37..b5a5cfcafdd53 100644 --- a/libclc/opencl/include/clc/opencl/math/ldexp.inc +++ b/libclc/opencl/include/clc/opencl/math/ldexp.inc @@ -6,10 +6,8 @@ // //===----------------------------------------------------------------------===// -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE ldexp(__CLC_GENTYPE x, int n); - #ifndef __CLC_SCALAR -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE ldexp(__CLC_GENTYPE x, __CLC_INTN n); +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE ldexp(__CLC_GENTYPE x, int n); #endif diff --git a/libclc/opencl/include/clc/opencl/math/pown.h b/libclc/opencl/include/clc/opencl/math/pown.h index 1d38c68947ba1..bbdf8f8b6e91e 100644 --- a/libclc/opencl/include/clc/opencl/math/pown.h +++ b/libclc/opencl/include/clc/opencl/math/pown.h @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #define __CLC_FUNCTION pown -#define __CLC_BODY <clc/math/binary_decl_with_int_second_arg.inc> +#define __CLC_BODY <clc/shared/binary_decl_with_int_second_arg.inc> #include <clc/math/gentype.inc> diff --git a/libclc/opencl/include/clc/opencl/math/rootn.h b/libclc/opencl/include/clc/opencl/math/rootn.h index 789f31596d1cd..669aeefb273a9 100644 --- a/libclc/opencl/include/clc/opencl/math/rootn.h +++ b/libclc/opencl/include/clc/opencl/math/rootn.h @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#define __CLC_BODY <clc/math/binary_decl_with_int_second_arg.inc> +#define __CLC_BODY <clc/shared/binary_decl_with_int_second_arg.inc> #define __CLC_FUNCTION rootn #include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/math/pown.cl b/libclc/opencl/lib/generic/math/pown.cl index a2ed523a41f74..115bae3406f0e 100644 --- a/libclc/opencl/lib/generic/math/pown.cl +++ b/libclc/opencl/lib/generic/math/pown.cl @@ -10,5 +10,5 @@ #include <clc/opencl/clc.h> #define FUNCTION pown -#define __CLC_BODY <clc/math/binary_def_with_int_second_arg.inc> +#define __CLC_BODY <clc/shared/binary_def_with_int_second_arg.inc> #include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/math/rootn.cl b/libclc/opencl/lib/generic/math/rootn.cl index 9f737151b3903..0e1acc95470df 100644 --- a/libclc/opencl/lib/generic/math/rootn.cl +++ b/libclc/opencl/lib/generic/math/rootn.cl @@ -10,5 +10,5 @@ #include <clc/opencl/clc.h> #define FUNCTION rootn -#define __CLC_BODY <clc/math/binary_def_with_int_second_arg.inc> +#define __CLC_BODY <clc/shared/binary_def_with_int_second_arg.inc> #include <clc/math/gentype.inc> >From 316248c95faa1c445311244b6ec497f3d64b9929 Mon Sep 17 00:00:00 2001 From: Wenju He <wenju...@intel.com> Date: Tue, 24 Jun 2025 11:49:45 +0200 Subject: [PATCH 3/3] move __FLOAT_ONLY to beginning, the same as in libclc/opencl/lib/clspv/math/fma.cl --- libclc/opencl/lib/spirv/math/fma.cl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libclc/opencl/lib/spirv/math/fma.cl b/libclc/opencl/lib/spirv/math/fma.cl index 2d826632b8e52..0f3141a0e09ee 100644 --- a/libclc/opencl/lib/spirv/math/fma.cl +++ b/libclc/opencl/lib/spirv/math/fma.cl @@ -9,9 +9,9 @@ #include <clc/internal/math/clc_sw_fma.h> #include <clc/opencl/clc.h> +#define __FLOAT_ONLY #define FUNCTION fma #define __CLC_FUNCTION(x) __clc_sw_fma #define __CLC_BODY <clc/shared/ternary_def.inc> -#define __FLOAT_ONLY #include <clc/math/gentype.inc> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits