Skip to content

[libclc] Move 'half' builtins to CLC library #139563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025

Conversation

frasercrmck
Copy link
Contributor

There are no changes to the generated bytecode.

There are no changes to the generated bytecode.
@frasercrmck frasercrmck requested a review from arsenm May 12, 2025 15:30
@frasercrmck frasercrmck added the libclc libclc OpenCL library label May 12, 2025
@llvmbot
Copy link
Member

llvmbot commented May 12, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Fraser Cormack (frasercrmck)

Changes

There are no changes to the generated bytecode.


Patch is 43.97 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/139563.diff

60 Files Affected:

  • (modified) libclc/CMakeLists.txt (-1)
  • (removed) libclc/amdgpu/lib/SOURCES (-9)
  • (added) libclc/clc/include/clc/math/clc_half_cos.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_divide.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_exp.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_exp10.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_exp2.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_log.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_log10.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_log2.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_powr.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_recip.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_rsqrt.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_sin.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_sqrt.h (+21)
  • (added) libclc/clc/include/clc/math/clc_half_tan.h (+21)
  • (modified) libclc/clc/lib/amdgpu/SOURCES (+9)
  • (renamed) libclc/clc/lib/amdgpu/math/clc_half_exp.cl (+2-2)
  • (renamed) libclc/clc/lib/amdgpu/math/clc_half_exp10.cl (+2-2)
  • (added) libclc/clc/lib/amdgpu/math/clc_half_exp2.cl (+15)
  • (renamed) libclc/clc/lib/amdgpu/math/clc_half_log.cl (+2-2)
  • (renamed) libclc/clc/lib/amdgpu/math/clc_half_log10.cl (+2-2)
  • (renamed) libclc/clc/lib/amdgpu/math/clc_half_log2.cl (+2-2)
  • (renamed) libclc/clc/lib/amdgpu/math/clc_half_native_unary.inc (+5-4)
  • (renamed) libclc/clc/lib/amdgpu/math/clc_half_recip.cl (+2-2)
  • (renamed) libclc/clc/lib/amdgpu/math/clc_half_rsqrt.cl (+2-2)
  • (renamed) libclc/clc/lib/amdgpu/math/clc_half_sqrt.cl (+2-2)
  • (modified) libclc/clc/lib/generic/SOURCES (+14)
  • (added) libclc/clc/lib/generic/math/clc_half_cos.cl (+16)
  • (renamed) libclc/clc/lib/generic/math/clc_half_divide.cl (+4-4)
  • (added) libclc/clc/lib/generic/math/clc_half_divide.inc (+12)
  • (added) libclc/clc/lib/generic/math/clc_half_exp.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_exp10.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_exp2.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_log.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_log10.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_log2.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_powr.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_recip.cl (+12)
  • (added) libclc/clc/lib/generic/math/clc_half_recip.inc (+11)
  • (added) libclc/clc/lib/generic/math/clc_half_rsqrt.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_sin.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_sqrt.cl (+16)
  • (added) libclc/clc/lib/generic/math/clc_half_tan.cl (+16)
  • (removed) libclc/generic/lib/math/half_binary.inc (-17)
  • (modified) libclc/generic/lib/math/half_cos.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_divide.cl (+4-5)
  • (modified) libclc/generic/lib/math/half_exp.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_exp10.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_exp2.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_log.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_log10.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_log2.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_powr.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_recip.cl (+4-6)
  • (modified) libclc/generic/lib/math/half_rsqrt.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_sin.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_sqrt.cl (+4-2)
  • (modified) libclc/generic/lib/math/half_tan.cl (+4-2)
  • (removed) libclc/generic/lib/math/half_unary.inc (-17)
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 50ddfc3930cd3..b0e7aac6f8f36 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -20,7 +20,6 @@ include( GNUInstallDirs )
 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
   amdgcn-amdhsa/lib/SOURCES;
   amdgcn/lib/SOURCES;
-  amdgpu/lib/SOURCES;
   clspv/lib/SOURCES;
   generic/lib/SOURCES;
   ptx-nvidiacl/lib/SOURCES;
diff --git a/libclc/amdgpu/lib/SOURCES b/libclc/amdgpu/lib/SOURCES
deleted file mode 100644
index ab5da40711aa4..0000000000000
--- a/libclc/amdgpu/lib/SOURCES
+++ /dev/null
@@ -1,9 +0,0 @@
-math/half_exp.cl
-math/half_exp10.cl
-math/half_exp2.cl
-math/half_log.cl
-math/half_log10.cl
-math/half_log2.cl
-math/half_recip.cl
-math/half_rsqrt.cl
-math/half_sqrt.cl
diff --git a/libclc/clc/include/clc/math/clc_half_cos.h b/libclc/clc/include/clc/math/clc_half_cos.h
new file mode 100644
index 0000000000000..d0efc45793af9
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_cos.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_COS_H__
+#define __CLC_MATH_CLC_HALF_COS_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_cos
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_COS_H__
diff --git a/libclc/clc/include/clc/math/clc_half_divide.h b/libclc/clc/include/clc/math/clc_half_divide.h
new file mode 100644
index 0000000000000..5d1e7b9e33e39
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_divide.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_DIVIDE_H__
+#define __CLC_MATH_CLC_HALF_DIVIDE_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_divide
+#define __CLC_BODY <clc/shared/binary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_DIVIDE_H__
diff --git a/libclc/clc/include/clc/math/clc_half_exp.h b/libclc/clc/include/clc/math/clc_half_exp.h
new file mode 100644
index 0000000000000..e95f3d42085c8
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_exp.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_EXP_H__
+#define __CLC_MATH_CLC_HALF_EXP_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_exp
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_EXP_H__
diff --git a/libclc/clc/include/clc/math/clc_half_exp10.h b/libclc/clc/include/clc/math/clc_half_exp10.h
new file mode 100644
index 0000000000000..e4cce6e63bf7a
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_exp10.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_EXP10_H__
+#define __CLC_MATH_CLC_HALF_EXP10_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_exp10
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_EXP10_H__
diff --git a/libclc/clc/include/clc/math/clc_half_exp2.h b/libclc/clc/include/clc/math/clc_half_exp2.h
new file mode 100644
index 0000000000000..6fc99735f0928
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_exp2.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_EXP2_H__
+#define __CLC_MATH_CLC_HALF_EXP2_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_exp2
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_EXP2_H__
diff --git a/libclc/clc/include/clc/math/clc_half_log.h b/libclc/clc/include/clc/math/clc_half_log.h
new file mode 100644
index 0000000000000..e44e686499663
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_log.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_LOG_H__
+#define __CLC_MATH_CLC_HALF_LOG_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_log
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_LOG_H__
diff --git a/libclc/clc/include/clc/math/clc_half_log10.h b/libclc/clc/include/clc/math/clc_half_log10.h
new file mode 100644
index 0000000000000..23e0ba116c728
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_log10.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_LOG10_H__
+#define __CLC_MATH_CLC_HALF_LOG10_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_log10
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_LOG10_H__
diff --git a/libclc/clc/include/clc/math/clc_half_log2.h b/libclc/clc/include/clc/math/clc_half_log2.h
new file mode 100644
index 0000000000000..8ea2439eb3db6
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_log2.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_LOG2_H__
+#define __CLC_MATH_CLC_HALF_LOG2_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_log2
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_LOG2_H__
diff --git a/libclc/clc/include/clc/math/clc_half_powr.h b/libclc/clc/include/clc/math/clc_half_powr.h
new file mode 100644
index 0000000000000..252bfcd785043
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_powr.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_POWR_H__
+#define __CLC_MATH_CLC_HALF_POWR_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_powr
+#define __CLC_BODY <clc/shared/binary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_POWR_H__
diff --git a/libclc/clc/include/clc/math/clc_half_recip.h b/libclc/clc/include/clc/math/clc_half_recip.h
new file mode 100644
index 0000000000000..1adb0bbe249cc
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_recip.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_RECIP_H__
+#define __CLC_MATH_CLC_HALF_RECIP_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_recip
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_RECIP_H__
diff --git a/libclc/clc/include/clc/math/clc_half_rsqrt.h b/libclc/clc/include/clc/math/clc_half_rsqrt.h
new file mode 100644
index 0000000000000..6342739ed6f20
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_rsqrt.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_RSQRT_H__
+#define __CLC_MATH_CLC_HALF_RSQRT_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_rsqrt
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_RSQRT_H__
diff --git a/libclc/clc/include/clc/math/clc_half_sin.h b/libclc/clc/include/clc/math/clc_half_sin.h
new file mode 100644
index 0000000000000..31378d290fecc
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_sin.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_SIN_H__
+#define __CLC_MATH_CLC_HALF_SIN_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_sin
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_SIN_H__
diff --git a/libclc/clc/include/clc/math/clc_half_sqrt.h b/libclc/clc/include/clc/math/clc_half_sqrt.h
new file mode 100644
index 0000000000000..0e765fb3e7731
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_sqrt.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_SQRT_H__
+#define __CLC_MATH_CLC_HALF_SQRT_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_sqrt
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_SQRT_H__
diff --git a/libclc/clc/include/clc/math/clc_half_tan.h b/libclc/clc/include/clc/math/clc_half_tan.h
new file mode 100644
index 0000000000000..6c890a952522c
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_half_tan.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MATH_CLC_HALF_TAN_H__
+#define __CLC_MATH_CLC_HALF_TAN_H__
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_half_tan
+#define __CLC_BODY <clc/shared/unary_decl.inc>
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY
+
+#endif // __CLC_MATH_CLC_HALF_TAN_H__
diff --git a/libclc/clc/lib/amdgpu/SOURCES b/libclc/clc/lib/amdgpu/SOURCES
index 31e07b608c4cc..83b13bad9a4f0 100644
--- a/libclc/clc/lib/amdgpu/SOURCES
+++ b/libclc/clc/lib/amdgpu/SOURCES
@@ -1,3 +1,12 @@
+math/clc_half_exp10.cl
+math/clc_half_exp2.cl
+math/clc_half_exp.cl
+math/clc_half_log10.cl
+math/clc_half_log2.cl
+math/clc_half_log.cl
+math/clc_half_recip.cl
+math/clc_half_rsqrt.cl
+math/clc_half_sqrt.cl
 math/clc_native_exp2.cl
 math/clc_native_exp.cl
 math/clc_native_log10.cl
diff --git a/libclc/amdgpu/lib/math/half_exp.cl b/libclc/clc/lib/amdgpu/math/clc_half_exp.cl
similarity index 84%
rename from libclc/amdgpu/lib/math/half_exp.cl
rename to libclc/clc/lib/amdgpu/math/clc_half_exp.cl
index 4cc2b36bb132f..97ca412339016 100644
--- a/libclc/amdgpu/lib/math/half_exp.cl
+++ b/libclc/clc/lib/amdgpu/math/clc_half_exp.cl
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <clc/clc.h>
+#include <clc/math/clc_native_exp.h>
  
 #define __CLC_FUNC exp
 #define __FLOAT_ONLY
-#define __CLC_BODY <half_native_unary.inc>
+#define __CLC_BODY <clc_half_native_unary.inc>
 #include <clc/math/gentype.inc>
diff --git a/libclc/amdgpu/lib/math/half_exp10.cl b/libclc/clc/lib/amdgpu/math/clc_half_exp10.cl
similarity index 83%
rename from libclc/amdgpu/lib/math/half_exp10.cl
rename to libclc/clc/lib/amdgpu/math/clc_half_exp10.cl
index 3bcdd2455ef31..b92eb76561765 100644
--- a/libclc/amdgpu/lib/math/half_exp10.cl
+++ b/libclc/clc/lib/amdgpu/math/clc_half_exp10.cl
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <clc/clc.h>
+#include <clc/math/clc_native_exp10.h>
  
 #define __CLC_FUNC exp10
 #define __FLOAT_ONLY
-#define __CLC_BODY <half_native_unary.inc>
+#define __CLC_BODY <clc_half_native_unary.inc>
 #include <clc/math/gentype.inc>
diff --git a/libclc/clc/lib/amdgpu/math/clc_half_exp2.cl b/libclc/clc/lib/amdgpu/math/clc_half_exp2.cl
new file mode 100644
index 0000000000000..9750d5008986b
--- /dev/null
+++ b/libclc/clc/lib/amdgpu/math/clc_half_exp2.cl
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/internal/clc.h>
+#include <clc/math/clc_native_exp2.h>
+
+#define __CLC_FUNC exp2
+#define __FLOAT_ONLY
+#define __CLC_BODY <clc_half_native_unary.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/amdgpu/lib/math/half_log.cl b/libclc/clc/lib/amdgpu/math/clc_half_log.cl
similarity index 84%
rename from libclc/amdgpu/lib/math/half_log.cl
rename to libclc/clc/lib/amdgpu/math/clc_half_log.cl
index d0e924ca97207..302f901158a61 100644
--- a/libclc/amdgpu/lib/math/half_log.cl
+++ b/libclc/clc/lib/amdgpu/math/clc_half_log.cl
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <clc/clc.h>
+#include <clc/math/clc_native_log.h>
  
 #define __CLC_FUNC log
 #define __FLOAT_ONLY
-#define __CLC_BODY <half_native_unary.inc>
+#define __CLC_BODY <clc_half_native_unary.inc>
 #include <clc/math/gentype.inc>
diff --git a/libclc/amdgpu/lib/math/half_log10.cl b/libclc/clc/lib/amdgpu/math/clc_half_log10.cl
similarity index 83%
rename from libclc/amdgpu/lib/math/half_log10.cl
rename to libclc/clc/lib/amdgpu/math/clc_half_log10.cl
index 2f3b26e1084ad..a02ea064eaa7e 100644
--- a/libclc/amdgpu/lib/math/half_log10.cl
+++ b/libclc/clc/lib/amdgpu/math/clc_half_log10.cl
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <clc/clc.h>
+#include <clc/math/clc_native_log10.h>
  
 #define __CLC_FUNC log10
 #define __FLOAT_ONLY
-#define __CLC_BODY <half_native_unary.inc>
+#define __CLC_BODY <clc_half_native_unary.inc>
 #include <clc/math/gentype.inc>
diff --git a/libclc/amdgpu/lib/math/half_log2.cl b/libclc/clc/lib/amdgpu/math/clc_half_log2.cl
similarity index 84%
rename from libclc/amdgpu/lib/math/half_log2.cl
rename to libclc/clc/lib/amdgpu/math/clc_half_log2.cl
index 9b417fb474ae6..bf6dee986ab56 100644
--- a/libclc/amdgpu/lib/math/half_log2.cl
+++ b/libclc/clc/lib/amdgpu/math/clc_half_log2.cl
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <clc/clc.h>
+#include <clc/math/clc_native_log2.h>
  
 #define __CLC_FUNC log2
 #define __FLOAT_ONLY
-#define __CLC_BODY <half_native_unary.inc>
+#define __CLC_BODY <clc_half_native_unary.inc>
 #include <clc/math/gentype.inc>
diff --git a/libclc/amdgpu/lib/math/half_native_unary.inc b/libclc/clc/lib/amdgpu/math/clc_half_native_unary.inc
similarity index 64%
rename from libclc/amdgpu/lib/math/half_native_unary.inc
rename to libclc/clc/lib/amdgpu/math/clc_half_native_unary.inc
index 6ecad7eb483c0..d62343400f2c4 100644
--- a/libclc/amdgpu/lib/math/half_native_unary.inc
+++ b/libclc/clc/lib/amdgpu/math/clc_half_native_unary.inc
@@ -8,11 +8,12 @@
 
 #include <clc/utils.h>
 
-#define __CLC_HALF_FUNC(x) __CLC_CONCAT(half_, x)
-#define __CLC_NATIVE_FUNC(x) __CLC_CONCAT(native_, x)
+#define __CLC_HALF_FUNC(x) __CLC_CONCAT(__clc_half_, x)
+#define __CLC_NATIVE_FUNC(x) __CLC_CONCAT(__clc_native_, x)
 
-_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_HALF_FUNC(__CLC_FUNC)(__CLC_GENTYPE val) {
-	return __CLC_NATIVE_FUNC(__CLC_FUNC)(val);
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE
+__CLC_HALF_FUNC(__CLC_FUNC)(__CLC_GENTYPE val) {
+  return __CLC_NATIVE_FUNC(__CLC_FUNC)(val);
 }
 
 #undef __CLC_NATIVE_FUNC
diff --git a/libclc/amdgpu/lib/math/half_recip.cl b/libclc/clc/lib/amdgpu/math/clc_half_recip.cl
similarity index 83%
rename from libclc/amdgpu/lib/math/half_recip.cl
rename to libclc/clc/lib/amdgpu/math/clc_half_recip.cl
index 87d56c8fbafcb..c47efd343db13 100644
--- a/libclc/amdgpu/lib/math/half_recip.cl
+++ b/libclc/clc/lib/amdgpu/math/clc_half_recip.cl
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <clc/clc.h>
+#include <clc/math/clc_native_recip.h>
  
 #define __CLC_FUNC recip
 #define __FLOAT_ONLY
-#define __CLC_BODY <half_native_unary.inc>
+#define __CLC_BODY <clc_half_native_unary.inc>
 #include <clc/math/gentype.inc>
diff --git a/libclc/amdgpu/lib/math/half_rsqrt.cl b/libclc/clc/lib/amdgpu/math/clc_half_rsqrt.cl
similarity index 83%
rename from libclc/amdgpu/lib/math/half_rsqrt.cl
rename to libclc/clc/lib/amdgpu/math/clc_half_rsqrt.cl
index 099363a913071..c...
[truncated]

Copy link

github-actions bot commented May 12, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@frasercrmck frasercrmck merged commit dd89af7 into llvm:main May 12, 2025
9 checks passed
@frasercrmck frasercrmck deleted the libclc-clc-half-builtins branch May 12, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU libclc libclc OpenCL library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants