[libclc] [libclc] Move round to CLC library (PR #128721)
Fraser Cormack via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 25 06:44:55 PST 2025
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/128721
None
>From f8a607fc8842d101e54648e3970cfa9aff81e6aa Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Tue, 25 Feb 2025 13:13:09 +0000
Subject: [PATCH] [libclc] Move round to CLC library
---
libclc/clc/include/clc/math/clc_round.h | 12 ++++++++++++
libclc/clc/lib/generic/SOURCES | 1 +
libclc/clc/lib/generic/math/clc_round.cl | 6 ++++++
libclc/generic/lib/math/round.cl | 7 ++-----
4 files changed, 21 insertions(+), 5 deletions(-)
create mode 100644 libclc/clc/include/clc/math/clc_round.h
create mode 100644 libclc/clc/lib/generic/math/clc_round.cl
diff --git a/libclc/clc/include/clc/math/clc_round.h b/libclc/clc/include/clc/math/clc_round.h
new file mode 100644
index 0000000000000..1402625ed7795
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_round.h
@@ -0,0 +1,12 @@
+#ifndef __CLC_MATH_CLC_ROUND_H__
+#define __CLC_MATH_CLC_ROUND_H__
+
+#define __CLC_BODY <clc/math/unary_decl.inc>
+#define __CLC_FUNCTION __clc_round
+
+#include <clc/math/gentype.inc>
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ROUND_H__
diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index 13667cebe02b9..dbf3c1bd31a0d 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -31,6 +31,7 @@ math/clc_modf.cl
math/clc_nan.cl
math/clc_nextafter.cl
math/clc_rint.cl
+math/clc_round.cl
math/clc_sw_fma.cl
math/clc_trunc.cl
relational/clc_all.cl
diff --git a/libclc/clc/lib/generic/math/clc_round.cl b/libclc/clc/lib/generic/math/clc_round.cl
new file mode 100644
index 0000000000000..dfb3ee6631480
--- /dev/null
+++ b/libclc/clc/lib/generic/math/clc_round.cl
@@ -0,0 +1,6 @@
+#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>
diff --git a/libclc/generic/lib/math/round.cl b/libclc/generic/lib/math/round.cl
index 6344051820c79..46f8cf6396abb 100644
--- a/libclc/generic/lib/math/round.cl
+++ b/libclc/generic/lib/math/round.cl
@@ -1,9 +1,6 @@
#include <clc/clc.h>
-
-// Map the llvm intrinsic to an OpenCL function.
-#define __CLC_FUNCTION __clc_round
-#define __CLC_INTRINSIC "llvm.round"
-#include <clc/math/unary_intrin.inc>
+#include <clc/clcmacro.h>
+#include <clc/math/clc_round.h>
#undef __CLC_FUNCTION
#define __CLC_FUNCTION round
More information about the cfe-commits
mailing list