https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/137656
We had two ways of achieving the same thing. This commit removes unary_builtin.inc in favour of the approach combining gentype.inc with unary_def.inc. There is no change to the codegen for any target. >From 2ab6a2860341935fa6b6a7b6a2819c82d2c5eaa1 Mon Sep 17 00:00:00 2001 From: Fraser Cormack <fra...@codeplay.com> Date: Mon, 28 Apr 2025 16:50:51 +0100 Subject: [PATCH] [libclc][NFC] Remove unary_builtin.inc We had two ways of achieving the same thing. This commit removes unary_builtin.inc in favour of the approach combining gentype.inc with unary_def.inc. There is no change to the codegen for any target. --- libclc/clc/include/clc/math/unary_builtin.inc | 32 ------------------- libclc/clc/lib/generic/math/clc_ceil.cl | 9 +++--- libclc/clc/lib/generic/math/clc_fabs.cl | 9 +++--- libclc/clc/lib/generic/math/clc_floor.cl | 9 +++--- libclc/clc/lib/generic/math/clc_rint.cl | 9 +++--- libclc/clc/lib/generic/math/clc_round.cl | 9 +++--- libclc/clc/lib/generic/math/clc_trunc.cl | 9 +++--- libclc/generic/lib/math/acos.cl | 8 ++--- libclc/generic/lib/math/acosh.cl | 7 ++-- libclc/generic/lib/math/acospi.cl | 6 ++-- libclc/generic/lib/math/asin.cl | 8 ++--- libclc/generic/lib/math/asinh.cl | 7 ++-- libclc/generic/lib/math/asinpi.cl | 7 ++-- libclc/generic/lib/math/atan.cl | 8 ++--- libclc/generic/lib/math/atanh.cl | 7 ++-- libclc/generic/lib/math/atanpi.cl | 7 ++-- libclc/generic/lib/math/ceil.cl | 8 ++--- libclc/generic/lib/math/fabs.cl | 8 ++--- libclc/generic/lib/math/floor.cl | 8 ++--- libclc/generic/lib/math/log1p.cl | 7 ++-- libclc/generic/lib/math/rint.cl | 7 ++-- libclc/generic/lib/math/round.cl | 8 ++--- libclc/generic/lib/math/trunc.cl | 7 ++-- 23 files changed, 93 insertions(+), 111 deletions(-) delete mode 100644 libclc/clc/include/clc/math/unary_builtin.inc diff --git a/libclc/clc/include/clc/math/unary_builtin.inc b/libclc/clc/include/clc/math/unary_builtin.inc deleted file mode 100644 index 790eaec5341d5..0000000000000 --- a/libclc/clc/include/clc/math/unary_builtin.inc +++ /dev/null @@ -1,32 +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/utils.h> - -#ifndef __CLC_BUILTIN -#define __CLC_BUILTIN __CLC_XCONCAT(__clc_, __CLC_FUNCTION) -#endif - -_CLC_DEFINE_UNARY_BUILTIN(float, __CLC_FUNCTION, __CLC_BUILTIN, float) - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEFINE_UNARY_BUILTIN(double, __CLC_FUNCTION, __CLC_BUILTIN, double) - -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_UNARY_BUILTIN(half, __CLC_FUNCTION, __CLC_BUILTIN, half) - -#endif diff --git a/libclc/clc/lib/generic/math/clc_ceil.cl b/libclc/clc/lib/generic/math/clc_ceil.cl index 975b51185d58c..c4df638d5ce26 100644 --- a/libclc/clc/lib/generic/math/clc_ceil.cl +++ b/libclc/clc/lib/generic/math/clc_ceil.cl @@ -8,7 +8,8 @@ #include <clc/internal/clc.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_ceil -#define __CLC_BUILTIN __builtin_elementwise_ceil -#include <clc/math/unary_builtin.inc> +#define FUNCTION __clc_ceil +#define __CLC_FUNCTION(x) __builtin_elementwise_ceil +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/math/clc_fabs.cl b/libclc/clc/lib/generic/math/clc_fabs.cl index 90841afefdfb9..f684c1e76bbbd 100644 --- a/libclc/clc/lib/generic/math/clc_fabs.cl +++ b/libclc/clc/lib/generic/math/clc_fabs.cl @@ -8,7 +8,8 @@ #include <clc/internal/clc.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_fabs -#define __CLC_BUILTIN __builtin_elementwise_abs -#include <clc/math/unary_builtin.inc> +#define FUNCTION __clc_fabs +#define __CLC_FUNCTION(x) __builtin_elementwise_abs +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/math/clc_floor.cl b/libclc/clc/lib/generic/math/clc_floor.cl index 2b80e5b3a178e..0626ba36f3ea8 100644 --- a/libclc/clc/lib/generic/math/clc_floor.cl +++ b/libclc/clc/lib/generic/math/clc_floor.cl @@ -8,7 +8,8 @@ #include <clc/internal/clc.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_floor -#define __CLC_BUILTIN __builtin_elementwise_floor -#include <clc/math/unary_builtin.inc> +#define FUNCTION __clc_floor +#define __CLC_FUNCTION(x) __builtin_elementwise_floor +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/math/clc_rint.cl b/libclc/clc/lib/generic/math/clc_rint.cl index d0852bcf77163..2188a7d901f01 100644 --- a/libclc/clc/lib/generic/math/clc_rint.cl +++ b/libclc/clc/lib/generic/math/clc_rint.cl @@ -8,7 +8,8 @@ #include <clc/internal/clc.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_rint -#define __CLC_BUILTIN __builtin_elementwise_rint -#include <clc/math/unary_builtin.inc> +#define FUNCTION __clc_rint +#define __CLC_FUNCTION(x) __builtin_elementwise_rint +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/math/clc_round.cl b/libclc/clc/lib/generic/math/clc_round.cl index 981949090c694..e784dbeaf3fab 100644 --- a/libclc/clc/lib/generic/math/clc_round.cl +++ b/libclc/clc/lib/generic/math/clc_round.cl @@ -8,7 +8,8 @@ #include <clc/internal/clc.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_round -#define __CLC_BUILTIN __builtin_elementwise_round -#include <clc/math/unary_builtin.inc> +#define FUNCTION __clc_round +#define __CLC_FUNCTION(x) __builtin_elementwise_round +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/math/clc_trunc.cl b/libclc/clc/lib/generic/math/clc_trunc.cl index 3aa47eaddfe7a..0bf2bc44c26f8 100644 --- a/libclc/clc/lib/generic/math/clc_trunc.cl +++ b/libclc/clc/lib/generic/math/clc_trunc.cl @@ -8,7 +8,8 @@ #include <clc/internal/clc.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_trunc -#define __CLC_BUILTIN __builtin_elementwise_trunc -#include <clc/math/unary_builtin.inc> +#define FUNCTION __clc_trunc +#define __CLC_FUNCTION(x) __builtin_elementwise_trunc +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/acos.cl b/libclc/generic/lib/math/acos.cl index 1efe5eb438deb..85119b437b4cd 100644 --- a/libclc/generic/lib/math/acos.cl +++ b/libclc/generic/lib/math/acos.cl @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include <clc/clc.h> -#include <clc/clcmacro.h> #include <clc/math/clc_acos.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION acos -#include <clc/math/unary_builtin.inc> +#define FUNCTION acos +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/acosh.cl b/libclc/generic/lib/math/acosh.cl index 2accecd59de7f..7df6b87703f5f 100644 --- a/libclc/generic/lib/math/acosh.cl +++ b/libclc/generic/lib/math/acosh.cl @@ -9,6 +9,7 @@ #include <clc/clc.h> #include <clc/math/clc_acosh.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION acosh -#include <clc/math/unary_builtin.inc> +#define FUNCTION acosh +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/acospi.cl b/libclc/generic/lib/math/acospi.cl index 844e0aa2f0a19..d8e774481d412 100644 --- a/libclc/generic/lib/math/acospi.cl +++ b/libclc/generic/lib/math/acospi.cl @@ -9,7 +9,7 @@ #include <clc/clc.h> #include <clc/math/clc_acospi.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION acospi -#include <clc/math/unary_builtin.inc> +#define FUNCTION acospi +#define __CLC_BODY <clc/shared/unary_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/asin.cl b/libclc/generic/lib/math/asin.cl index 360951c45eda5..58e4b7440d6f3 100644 --- a/libclc/generic/lib/math/asin.cl +++ b/libclc/generic/lib/math/asin.cl @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include <clc/clc.h> -#include <clc/clcmacro.h> #include <clc/math/clc_asin.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION asin -#include <clc/math/unary_builtin.inc> +#define FUNCTION asin +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/asinh.cl b/libclc/generic/lib/math/asinh.cl index 2e2eb57d148ab..84ba61d052b8f 100644 --- a/libclc/generic/lib/math/asinh.cl +++ b/libclc/generic/lib/math/asinh.cl @@ -9,6 +9,7 @@ #include <clc/clc.h> #include <clc/math/clc_asinh.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION asinh -#include <clc/math/unary_builtin.inc> +#define FUNCTION asinh +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/asinpi.cl b/libclc/generic/lib/math/asinpi.cl index 7e109e8bb8dbb..bf232ef89e606 100644 --- a/libclc/generic/lib/math/asinpi.cl +++ b/libclc/generic/lib/math/asinpi.cl @@ -9,6 +9,7 @@ #include <clc/clc.h> #include <clc/math/clc_asinpi.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION asinpi -#include <clc/math/unary_builtin.inc> +#define FUNCTION asinpi +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/atan.cl b/libclc/generic/lib/math/atan.cl index b7d1516ae641b..b0a466aee5e14 100644 --- a/libclc/generic/lib/math/atan.cl +++ b/libclc/generic/lib/math/atan.cl @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include <clc/clc.h> -#include <clc/clcmacro.h> #include <clc/math/clc_atan.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION atan -#include <clc/math/unary_builtin.inc> +#define FUNCTION atan +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/atanh.cl b/libclc/generic/lib/math/atanh.cl index d6f6cf7046261..5d92cdbd2adf6 100644 --- a/libclc/generic/lib/math/atanh.cl +++ b/libclc/generic/lib/math/atanh.cl @@ -9,6 +9,7 @@ #include <clc/clc.h> #include <clc/math/clc_atanh.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION atanh -#include <clc/math/unary_builtin.inc> +#define FUNCTION atanh +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/atanpi.cl b/libclc/generic/lib/math/atanpi.cl index 2c67eb9592b77..4337bdf3f660c 100644 --- a/libclc/generic/lib/math/atanpi.cl +++ b/libclc/generic/lib/math/atanpi.cl @@ -9,6 +9,7 @@ #include <clc/clc.h> #include <clc/math/clc_atanpi.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION atanpi -#include <clc/math/unary_builtin.inc> +#define FUNCTION atanpi +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/ceil.cl b/libclc/generic/lib/math/ceil.cl index e58172a962017..00635dcb5507a 100644 --- a/libclc/generic/lib/math/ceil.cl +++ b/libclc/generic/lib/math/ceil.cl @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include <clc/clc.h> -#include <clc/clcmacro.h> #include <clc/math/clc_ceil.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION ceil -#include <clc/math/unary_builtin.inc> +#define FUNCTION ceil +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/fabs.cl b/libclc/generic/lib/math/fabs.cl index 6fad7de4beceb..2723fae8b05c5 100644 --- a/libclc/generic/lib/math/fabs.cl +++ b/libclc/generic/lib/math/fabs.cl @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include <clc/clc.h> -#include <clc/clcmacro.h> #include <clc/math/clc_fabs.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION fabs -#include <clc/math/unary_builtin.inc> +#define FUNCTION fabs +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/floor.cl b/libclc/generic/lib/math/floor.cl index 4448e54392f03..d74a50d3a22ac 100644 --- a/libclc/generic/lib/math/floor.cl +++ b/libclc/generic/lib/math/floor.cl @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include <clc/clc.h> -#include <clc/clcmacro.h> #include <clc/math/clc_floor.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION floor -#include <clc/math/unary_builtin.inc> +#define FUNCTION floor +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/log1p.cl b/libclc/generic/lib/math/log1p.cl index 8db8c3c1950c5..47245d1178a58 100644 --- a/libclc/generic/lib/math/log1p.cl +++ b/libclc/generic/lib/math/log1p.cl @@ -9,6 +9,7 @@ #include <clc/clc.h> #include <clc/math/clc_log1p.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION log1p -#include <clc/math/unary_builtin.inc> +#define FUNCTION log1p +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/rint.cl b/libclc/generic/lib/math/rint.cl index a33ff91482fd4..b84438067a9c7 100644 --- a/libclc/generic/lib/math/rint.cl +++ b/libclc/generic/lib/math/rint.cl @@ -9,6 +9,7 @@ #include <clc/clc.h> #include <clc/math/clc_rint.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION rint -#include <clc/math/unary_builtin.inc> +#define FUNCTION rint +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/round.cl b/libclc/generic/lib/math/round.cl index a1495fad78b4f..bf1ced1e8abc9 100644 --- a/libclc/generic/lib/math/round.cl +++ b/libclc/generic/lib/math/round.cl @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include <clc/clc.h> -#include <clc/clcmacro.h> #include <clc/math/clc_round.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION round -#include <clc/math/unary_builtin.inc> +#define FUNCTION round +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/trunc.cl b/libclc/generic/lib/math/trunc.cl index 36ae4c7ca5d19..d668f39f23341 100644 --- a/libclc/generic/lib/math/trunc.cl +++ b/libclc/generic/lib/math/trunc.cl @@ -9,6 +9,7 @@ #include <clc/clc.h> #include <clc/math/clc_trunc.h> -#undef __CLC_FUNCTION -#define __CLC_FUNCTION trunc -#include <clc/math/unary_builtin.inc> +#define FUNCTION trunc +#define __CLC_BODY <clc/shared/unary_def.inc> + +#include <clc/math/gentype.inc> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits