[libclc][NFC] Remove unary_builtin.inc (#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.
This commit is contained in:
Fraser Cormack
2025-04-29 14:17:17 +01:00
committed by GitHub
parent 1e31f4b5eb
commit 837d5a740f
23 changed files with 93 additions and 111 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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