[libclc] 13a9b86 - [NFC][libclc] Replace and delete _CLC_DEFINE_UNARY/BINARY/TERNARY_BUILTIN macros (#145458)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 24 22:48:56 PDT 2025


Author: Wenju He
Date: 2025-06-25T13:48:53+08:00
New Revision: 13a9b86f627934ccf898e85f86e2a0a0df5f85da

URL: https://github.com/llvm/llvm-project/commit/13a9b86f627934ccf898e85f86e2a0a0df5f85da
DIFF: https://github.com/llvm/llvm-project/commit/13a9b86f627934ccf898e85f86e2a0a0df5f85da.diff

LOG: [NFC][libclc] Replace and delete _CLC_DEFINE_UNARY/BINARY/TERNARY_BUILTIN macros (#145458)

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

Added: 
    libclc/clc/include/clc/shared/binary_decl_with_int_second_arg.inc
    libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc

Modified: 
    libclc/clc/include/clc/clcmacro.h
    libclc/clc/include/clc/math/clc_pown.h
    libclc/clc/include/clc/math/clc_rootn.h
    libclc/clc/lib/generic/math/clc_copysign.cl
    libclc/opencl/include/clc/opencl/math/ldexp.h
    libclc/opencl/include/clc/opencl/math/ldexp.inc
    libclc/opencl/include/clc/opencl/math/pown.h
    libclc/opencl/include/clc/opencl/math/rootn.h
    libclc/opencl/lib/clspv/math/fma.cl
    libclc/opencl/lib/generic/common/degrees.cl
    libclc/opencl/lib/generic/common/radians.cl
    libclc/opencl/lib/generic/math/fma.cl
    libclc/opencl/lib/generic/math/ldexp.cl
    libclc/opencl/lib/generic/math/mad.cl
    libclc/opencl/lib/generic/math/nextafter.cl
    libclc/opencl/lib/generic/math/pown.cl
    libclc/opencl/lib/generic/math/rootn.cl
    libclc/opencl/lib/spirv/math/fma.cl

Removed: 
    libclc/clc/include/clc/math/binary_decl_with_int_second_arg.inc
    libclc/clc/include/clc/math/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/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/math/binary_def_with_int_second_arg.inc b/libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc
similarity index 100%
rename from libclc/clc/include/clc/math/binary_def_with_int_second_arg.inc
rename to libclc/clc/include/clc/shared/binary_def_with_int_second_arg.inc

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/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/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/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>

diff  --git a/libclc/opencl/lib/spirv/math/fma.cl b/libclc/opencl/lib/spirv/math/fma.cl
index 2722018121224..0f3141a0e09ee 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 __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>


        


More information about the cfe-commits mailing list