https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/177888
>From 593d8560888c925d2ce680c5d8c83017788cbc1d Mon Sep 17 00:00:00 2001 From: Wenju He <[email protected]> Date: Mon, 26 Jan 2026 01:15:28 +0100 Subject: [PATCH 1/2] [libclc][NFC] Fix build warning typedef-redefinition Fix downstream build warning: redefinition of typedef 'ushort8' is a C11 feature [-Wtypedef-redefinition] clctypes.h re-defines typedef from opencl-c-base.h. Both files are included in libclc/opencl folder. --- libclc/clc/include/clc/clctypes.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libclc/clc/include/clc/clctypes.h b/libclc/clc/include/clc/clctypes.h index 2187c2535963b..7f3e14e6d4acd 100644 --- a/libclc/clc/include/clc/clctypes.h +++ b/libclc/clc/include/clc/clctypes.h @@ -9,6 +9,8 @@ #ifndef __CLC_CLCTYPES_H_ #define __CLC_CLCTYPES_H_ +#ifndef _OPENCL_BASE_H_ + /* 6.1.1 Built-in Scalar Data Types */ typedef unsigned char uchar; @@ -105,4 +107,6 @@ typedef __attribute__((ext_vector_type(8))) half half8; typedef __attribute__((ext_vector_type(16))) half half16; #endif +#endif // _OPENCL_BASE_H_ + #endif // __CLC_CLCTYPES_H_ >From 3e3f3189d6a77156a4ebcff5e1076e1d91725203 Mon Sep 17 00:00:00 2001 From: Wenju He <[email protected]> Date: Wed, 28 Jan 2026 13:11:55 +0100 Subject: [PATCH 2/2] delete clctypes.h, include opencl-c-base.h for CLC and OpenCL libraries --- libclc/CMakeLists.txt | 3 +- libclc/clc/include/clc/clctypes.h | 112 ------------------ libclc/clc/include/clc/float/definitions.h | 78 ------------ libclc/clc/include/clc/integer/clc_upsample.h | 1 - libclc/clc/include/clc/integer/definitions.h | 12 -- libclc/clc/include/clc/integer/gentype.inc | 1 - libclc/clc/include/clc/integer/gentype24.inc | 1 - libclc/clc/include/clc/internal/clc.h | 1 - libclc/clc/include/clc/math/gentype.inc | 1 - libclc/clc/include/clc/math/tables.h | 2 - libclc/clc/include/clc/relational/clc_all.h | 1 - libclc/clc/include/clc/relational/clc_any.h | 1 - .../clc/include/clc/relational/clc_isequal.h | 1 - libclc/clc/include/clc/relational/clc_isinf.h | 1 - libclc/clc/include/clc/relational/clc_isnan.h | 1 - libclc/cmake/modules/AddLibclc.cmake | 4 +- .../opencl/include/clc/opencl/opencl-base.h | 1 - 17 files changed, 3 insertions(+), 219 deletions(-) delete mode 100644 libclc/clc/include/clc/clctypes.h diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 88a32797d5915..828f6f37a5320 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -409,6 +409,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) -D${CLC_TARGET_DEFINE} # All libclc builtin libraries see CLC headers -I${CMAKE_CURRENT_SOURCE_DIR}/clc/include + -include opencl-c-base.h # Error on undefined macros -Werror=undef -fdiscard-value-names @@ -454,7 +455,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) ) list( APPEND build_flags - -Xclang -fdeclare-opencl-builtins -Xclang -finclude-default-header + -Xclang -fdeclare-opencl-builtins -I${CMAKE_CURRENT_SOURCE_DIR}/opencl/include ) diff --git a/libclc/clc/include/clc/clctypes.h b/libclc/clc/include/clc/clctypes.h deleted file mode 100644 index 7f3e14e6d4acd..0000000000000 --- a/libclc/clc/include/clc/clctypes.h +++ /dev/null @@ -1,112 +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 -// -//===----------------------------------------------------------------------===// - -#ifndef __CLC_CLCTYPES_H_ -#define __CLC_CLCTYPES_H_ - -#ifndef _OPENCL_BASE_H_ - -/* 6.1.1 Built-in Scalar Data Types */ - -typedef unsigned char uchar; -typedef unsigned short ushort; -typedef unsigned int uint; -typedef unsigned long ulong; - -typedef __SIZE_TYPE__ size_t; -typedef __PTRDIFF_TYPE__ ptrdiff_t; - -#define __stdint_join3(a, b, c) a##b##c - -#define __intn_t(n) __stdint_join3(__INT, n, _TYPE__) -#define __uintn_t(n) __stdint_join3(unsigned __INT, n, _TYPE__) - -typedef __intn_t(__INTPTR_WIDTH__) intptr_t; -typedef __uintn_t(__INTPTR_WIDTH__) uintptr_t; - -#undef __uintn_t -#undef __intn_t -#undef __stdint_join3 - -/* 6.1.2 Built-in Vector Data Types */ - -typedef __attribute__((ext_vector_type(2))) char char2; -typedef __attribute__((ext_vector_type(3))) char char3; -typedef __attribute__((ext_vector_type(4))) char char4; -typedef __attribute__((ext_vector_type(8))) char char8; -typedef __attribute__((ext_vector_type(16))) char char16; - -typedef __attribute__((ext_vector_type(2))) uchar uchar2; -typedef __attribute__((ext_vector_type(3))) uchar uchar3; -typedef __attribute__((ext_vector_type(4))) uchar uchar4; -typedef __attribute__((ext_vector_type(8))) uchar uchar8; -typedef __attribute__((ext_vector_type(16))) uchar uchar16; - -typedef __attribute__((ext_vector_type(2))) short short2; -typedef __attribute__((ext_vector_type(3))) short short3; -typedef __attribute__((ext_vector_type(4))) short short4; -typedef __attribute__((ext_vector_type(8))) short short8; -typedef __attribute__((ext_vector_type(16))) short short16; - -typedef __attribute__((ext_vector_type(2))) ushort ushort2; -typedef __attribute__((ext_vector_type(3))) ushort ushort3; -typedef __attribute__((ext_vector_type(4))) ushort ushort4; -typedef __attribute__((ext_vector_type(8))) ushort ushort8; -typedef __attribute__((ext_vector_type(16))) ushort ushort16; - -typedef __attribute__((ext_vector_type(2))) int int2; -typedef __attribute__((ext_vector_type(3))) int int3; -typedef __attribute__((ext_vector_type(4))) int int4; -typedef __attribute__((ext_vector_type(8))) int int8; -typedef __attribute__((ext_vector_type(16))) int int16; - -typedef __attribute__((ext_vector_type(2))) uint uint2; -typedef __attribute__((ext_vector_type(3))) uint uint3; -typedef __attribute__((ext_vector_type(4))) uint uint4; -typedef __attribute__((ext_vector_type(8))) uint uint8; -typedef __attribute__((ext_vector_type(16))) uint uint16; - -typedef __attribute__((ext_vector_type(2))) long long2; -typedef __attribute__((ext_vector_type(3))) long long3; -typedef __attribute__((ext_vector_type(4))) long long4; -typedef __attribute__((ext_vector_type(8))) long long8; -typedef __attribute__((ext_vector_type(16))) long long16; - -typedef __attribute__((ext_vector_type(2))) ulong ulong2; -typedef __attribute__((ext_vector_type(3))) ulong ulong3; -typedef __attribute__((ext_vector_type(4))) ulong ulong4; -typedef __attribute__((ext_vector_type(8))) ulong ulong8; -typedef __attribute__((ext_vector_type(16))) ulong ulong16; - -typedef __attribute__((ext_vector_type(2))) float float2; -typedef __attribute__((ext_vector_type(3))) float float3; -typedef __attribute__((ext_vector_type(4))) float float4; -typedef __attribute__((ext_vector_type(8))) float float8; -typedef __attribute__((ext_vector_type(16))) float float16; - -/* 9.3 Double Precision Floating-Point */ - -#ifdef cl_khr_fp64 -typedef __attribute__((ext_vector_type(2))) double double2; -typedef __attribute__((ext_vector_type(3))) double double3; -typedef __attribute__((ext_vector_type(4))) double double4; -typedef __attribute__((ext_vector_type(8))) double double8; -typedef __attribute__((ext_vector_type(16))) double double16; -#endif - -#ifdef cl_khr_fp16 -typedef __attribute__((ext_vector_type(2))) half half2; -typedef __attribute__((ext_vector_type(3))) half half3; -typedef __attribute__((ext_vector_type(4))) half half4; -typedef __attribute__((ext_vector_type(8))) half half8; -typedef __attribute__((ext_vector_type(16))) half half16; -#endif - -#endif // _OPENCL_BASE_H_ - -#endif // __CLC_CLCTYPES_H_ diff --git a/libclc/clc/include/clc/float/definitions.h b/libclc/clc/include/clc/float/definitions.h index 0317bf1bfc091..25f35a4ef68ec 100644 --- a/libclc/clc/include/clc/float/definitions.h +++ b/libclc/clc/include/clc/float/definitions.h @@ -6,16 +6,6 @@ // //===----------------------------------------------------------------------===// -#ifndef MAXFLOAT -#define MAXFLOAT 0x1.fffffep127f -#endif -#ifndef HUGE_VALF -#define HUGE_VALF __builtin_huge_valf() -#endif -#ifndef INFINITY -#define INFINITY __builtin_inff() -#endif - #define FLT_DIG 6 #define FLT_MANT_DIG 24 #define FLT_MAX_10_EXP +38 @@ -23,68 +13,14 @@ #define FLT_MIN_10_EXP -37 #define FLT_MIN_EXP -125 #define FLT_RADIX 2 -#ifndef FLT_MAX -#define FLT_MAX MAXFLOAT -#endif #define FLT_MIN 0x1.0p-126f #define FLT_EPSILON 0x1.0p-23f #define FLT_NAN __builtin_nanf("") -#ifndef FP_ILOGB0 -#define FP_ILOGB0 (-2147483647 - 1) -#endif -#ifndef FP_ILOGBNAN -#define FP_ILOGBNAN 2147483647 -#endif - -#ifndef M_E_F -#define M_E_F 0x1.5bf0a8p+1f -#endif -#ifndef M_LOG2E_F -#define M_LOG2E_F 0x1.715476p+0f -#endif -#ifndef M_LOG10E_F -#define M_LOG10E_F 0x1.bcb7b2p-2f -#endif -#ifndef M_LN2_F -#define M_LN2_F 0x1.62e430p-1f -#endif -#ifndef M_LN10_F -#define M_LN10_F 0x1.26bb1cp+1f -#endif -#ifndef M_PI_F -#define M_PI_F 0x1.921fb6p+1f -#endif -#ifndef M_PI_2_F -#define M_PI_2_F 0x1.921fb6p+0f -#endif -#ifndef M_PI_4_F -#define M_PI_4_F 0x1.921fb6p-1f -#endif -#ifndef M_1_PI_F -#define M_1_PI_F 0x1.45f306p-2f -#endif -#ifndef M_2_PI_F -#define M_2_PI_F 0x1.45f306p-1f -#endif -#ifndef M_2_SQRTPI_F -#define M_2_SQRTPI_F 0x1.20dd76p+0f -#endif -#ifndef M_SQRT2_F -#define M_SQRT2_F 0x1.6a09e6p+0f -#endif -#ifndef M_SQRT1_2_F -#define M_SQRT1_2_F 0x1.6a09e6p-1f -#endif - #define M_LOG210_F 0x1.a934f0p+1f #ifdef cl_khr_fp64 -#ifndef HUGE_VAL -#define HUGE_VAL __builtin_huge_val() -#endif - #define DBL_DIG 15 #define DBL_MANT_DIG 53 #define DBL_MAX_10_EXP +308 @@ -120,21 +56,7 @@ #define HALF_MAX_EXP +16 #define HALF_MIN_10_EXP -4 #define HALF_MIN_EXP -13 - #define HALF_RADIX 2 -#ifndef HALF_MAX -#define HALF_MAX 0x1.ffcp15h -#endif -#ifndef HALF_MIN -#define HALF_MIN 0x1.0p-14h -#endif -#ifndef HALF_EPSILON -#define HALF_EPSILON 0x1.0p-10h -#endif #define HALF_NAN __builtin_nanf16("") -#ifndef M_LOG2E_H -#define M_LOG2E_H 0x1.714p+0h -#endif - #endif diff --git a/libclc/clc/include/clc/integer/clc_upsample.h b/libclc/clc/include/clc/integer/clc_upsample.h index 51728dfd6e938..ca3b8a9102991 100644 --- a/libclc/clc/include/clc/integer/clc_upsample.h +++ b/libclc/clc/include/clc/integer/clc_upsample.h @@ -10,7 +10,6 @@ #define __CLC_INTEGER_CLC_UPSAMPLE_H__ #include <clc/clcfunc.h> -#include <clc/clctypes.h> #define __CLC_UPSAMPLE_DECL(BGENTYPE, GENTYPE, UGENTYPE) \ _CLC_OVERLOAD _CLC_DECL BGENTYPE __clc_upsample(GENTYPE hi, UGENTYPE lo); diff --git a/libclc/clc/include/clc/integer/definitions.h b/libclc/clc/include/clc/integer/definitions.h index 3b9d57f208535..3ef8ad27d7c3b 100644 --- a/libclc/clc/include/clc/integer/definitions.h +++ b/libclc/clc/include/clc/integer/definitions.h @@ -11,23 +11,11 @@ #define CHAR_BIT 8 #define INT_MAX 2147483647 -#ifndef INT_MIN -#define INT_MIN (-2147483647 - 1) -#endif #define LONG_MAX 0x7fffffffffffffffL -#ifndef LONG_MIN -#define LONG_MIN (-0x7fffffffffffffffL - 1) -#endif #define CHAR_MAX SCHAR_MAX #define CHAR_MIN SCHAR_MIN #define SCHAR_MAX 127 -#ifndef SCHAR_MIN -#define SCHAR_MIN (-127 - 1) -#endif #define SHRT_MAX 32767 -#ifndef SHRT_MIN -#define SHRT_MIN (-32767 - 1) -#endif #define UCHAR_MAX 255 #define UCHAR_MIN 0 #define USHRT_MAX 65535 diff --git a/libclc/clc/include/clc/integer/gentype.inc b/libclc/clc/include/clc/integer/gentype.inc index acca8632de32a..36d7ae95d1742 100644 --- a/libclc/clc/include/clc/integer/gentype.inc +++ b/libclc/clc/include/clc/integer/gentype.inc @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include <clc/clcfunc.h> -#include <clc/clctypes.h> #include <clc/utils.h> #define __CLC_AS_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_GENTYPE) diff --git a/libclc/clc/include/clc/integer/gentype24.inc b/libclc/clc/include/clc/integer/gentype24.inc index b787f25a3d6e1..c74ce0c3bab47 100644 --- a/libclc/clc/include/clc/integer/gentype24.inc +++ b/libclc/clc/include/clc/integer/gentype24.inc @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include <clc/clcfunc.h> -#include <clc/clctypes.h> #define __CLC_GENSIZE 32 #undef __CLC_SCALAR_GENTYPE diff --git a/libclc/clc/include/clc/internal/clc.h b/libclc/clc/include/clc/internal/clc.h index d9fb48128067d..fcfb223d5a12d 100644 --- a/libclc/clc/include/clc/internal/clc.h +++ b/libclc/clc/include/clc/internal/clc.h @@ -27,7 +27,6 @@ #include <clc/clcfunc.h> /* 6.1 Supported Data Types */ -#include <clc/clctypes.h> /* 6.2.4.2 Reinterpreting Types Using __clc_as_type() and __clc_as_typen() */ #include <clc/clc_as_type.h> diff --git a/libclc/clc/include/clc/math/gentype.inc b/libclc/clc/include/clc/math/gentype.inc index 3373f5fa50024..59626d6785b8e 100644 --- a/libclc/clc/include/clc/math/gentype.inc +++ b/libclc/clc/include/clc/math/gentype.inc @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include <clc/clcfunc.h> -#include <clc/clctypes.h> #include <clc/utils.h> // Define some useful macros for type conversions. diff --git a/libclc/clc/include/clc/math/tables.h b/libclc/clc/include/clc/math/tables.h index ad4b0547f8c69..12361a30357ac 100644 --- a/libclc/clc/include/clc/math/tables.h +++ b/libclc/clc/include/clc/math/tables.h @@ -9,8 +9,6 @@ #ifndef __CLC_MATH_TABLES_H__ #define __CLC_MATH_TABLES_H__ -#include <clc/clctypes.h> - #define __CLC_TABLE_SPACE __constant #define __CLC_TABLE_MANGLE(NAME) __clc_##NAME diff --git a/libclc/clc/include/clc/relational/clc_all.h b/libclc/clc/include/clc/relational/clc_all.h index 272d879e08cd5..a99e2ae172d5c 100644 --- a/libclc/clc/include/clc/relational/clc_all.h +++ b/libclc/clc/include/clc/relational/clc_all.h @@ -10,7 +10,6 @@ #define __CLC_RELATIONAL_CLC_ALL_H__ #include <clc/clcfunc.h> -#include <clc/clctypes.h> #define _CLC_ALL_DECL(TYPE) \ _CLC_OVERLOAD _CLC_CONST _CLC_DECL int __clc_all(TYPE v); diff --git a/libclc/clc/include/clc/relational/clc_any.h b/libclc/clc/include/clc/relational/clc_any.h index 82d08c0129e91..5e52be4563f36 100644 --- a/libclc/clc/include/clc/relational/clc_any.h +++ b/libclc/clc/include/clc/relational/clc_any.h @@ -10,7 +10,6 @@ #define __CLC_RELATIONAL_CLC_ANY_H__ #include <clc/clcfunc.h> -#include <clc/clctypes.h> #define _CLC_ANY_DECL(TYPE) \ _CLC_OVERLOAD _CLC_CONST _CLC_DECL int __clc_any(TYPE v); diff --git a/libclc/clc/include/clc/relational/clc_isequal.h b/libclc/clc/include/clc/relational/clc_isequal.h index 2585dbdaf3cfe..18e05387759e3 100644 --- a/libclc/clc/include/clc/relational/clc_isequal.h +++ b/libclc/clc/include/clc/relational/clc_isequal.h @@ -10,7 +10,6 @@ #define __CLC_RELATIONAL_CLC_ISEQUAL_H__ #include <clc/clcfunc.h> -#include <clc/clctypes.h> #define _CLC_ISEQUAL_DECL(TYPE, RETTYPE) \ _CLC_OVERLOAD _CLC_CONST _CLC_DECL RETTYPE __clc_isequal(TYPE x, TYPE y); diff --git a/libclc/clc/include/clc/relational/clc_isinf.h b/libclc/clc/include/clc/relational/clc_isinf.h index fcd87e94c6ee2..a64b18bd564d3 100644 --- a/libclc/clc/include/clc/relational/clc_isinf.h +++ b/libclc/clc/include/clc/relational/clc_isinf.h @@ -10,7 +10,6 @@ #define __CLC_RELATIONAL_CLC_ISINF_H__ #include <clc/clcfunc.h> -#include <clc/clctypes.h> #define _CLC_ISINF_DECL(RET_TYPE, ARG_TYPE) \ _CLC_OVERLOAD _CLC_CONST _CLC_DECL RET_TYPE __clc_isinf(ARG_TYPE); diff --git a/libclc/clc/include/clc/relational/clc_isnan.h b/libclc/clc/include/clc/relational/clc_isnan.h index 779e6cc94b91b..48cfa7f7fbb8e 100644 --- a/libclc/clc/include/clc/relational/clc_isnan.h +++ b/libclc/clc/include/clc/relational/clc_isnan.h @@ -10,7 +10,6 @@ #define __CLC_RELATIONAL_CLC_ISNAN_H__ #include <clc/clcfunc.h> -#include <clc/clctypes.h> #define _CLC_ISNAN_DECL(RET_TYPE, ARG_TYPE) \ _CLC_OVERLOAD _CLC_CONST _CLC_DECL RET_TYPE __clc_isnan(ARG_TYPE); diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 1ba53a9528f82..2d7a12b8d0aaf 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -33,9 +33,7 @@ function(compile_to_bc) else() set( PP_OPTS -E;-P ) set( TMP_SUFFIX .tmp ) - string( REPLACE "-Xclang;-fdeclare-opencl-builtins;-Xclang;-finclude-default-header" - "" EXTRA_OPTS "${ARG_EXTRA_OPTS}" - ) + string( REPLACE "-include;opencl-c-base.h" "" EXTRA_OPTS "${ARG_EXTRA_OPTS}") endif() set( TARGET_ARG ) diff --git a/libclc/opencl/include/clc/opencl/opencl-base.h b/libclc/opencl/include/clc/opencl/opencl-base.h index ac0dd0f129707..78fb9588d289d 100644 --- a/libclc/opencl/include/clc/opencl/opencl-base.h +++ b/libclc/opencl/include/clc/opencl/opencl-base.h @@ -21,6 +21,5 @@ #include <clc/clcfunc.h> /* 6.1 Supported Data Types */ -#include <clc/clctypes.h> #endif // __CLC_OPENCL_OPENCL_BASE_H__ _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
