[libclc] [libclc] Route select through __clc_select (PR #123647)

2025-01-21 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck closed 
https://github.com/llvm/llvm-project/pull/123647
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] [libclc] Route select through __clc_select (PR #123647)

2025-01-20 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm approved this pull request.


https://github.com/llvm/llvm-project/pull/123647
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] [libclc] Route select through __clc_select (PR #123647)

2025-01-20 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/123647

This was missed during the introduction of select. This also unifies the 
various .inc files used for each, as they were essentially identical.

The __clc_select function is now also built for SPIR-V targets.

>From 26902128e1bfe4760791fa833e4a2940e5f28d62 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Mon, 20 Jan 2025 17:12:15 +
Subject: [PATCH] [libclc] Route select through __clc_select

This was missed during the introduction of select. This also unifies the
various .inc files used for each, as they were essentially identical.

The __clc_select function is now also built for SPIR-V targets.
---
 .../clc/include/clc/relational/clc_select.h   | 14 +++-
 .../{clc_select.inc => clc_select_decl.inc}   | 12 +++
 .../clc/relational/clc_select_impl.inc}   | 16 -
 libclc/clc/lib/clspv/SOURCES  |  1 +
 .../clc/lib/generic/relational/clc_select.cl  |  7 ++--
 libclc/clc/lib/spirv/SOURCES  |  1 +
 libclc/clc/lib/spirv64/SOURCES|  1 +
 .../generic/include/clc/relational/select.h   |  7 ++--
 .../generic/include/clc/relational/select.inc | 25 --
 libclc/generic/lib/relational/select.cl   |  8 +++--
 libclc/generic/lib/relational/select.inc  | 33 ---
 11 files changed, 38 insertions(+), 87 deletions(-)
 rename libclc/clc/include/clc/relational/{clc_select.inc => 
clc_select_decl.inc} (58%)
 rename libclc/clc/{lib/generic/relational/clc_select.inc => 
include/clc/relational/clc_select_impl.inc} (55%)
 delete mode 100644 libclc/generic/include/clc/relational/select.inc
 delete mode 100644 libclc/generic/lib/relational/select.inc

diff --git a/libclc/clc/include/clc/relational/clc_select.h 
b/libclc/clc/include/clc/relational/clc_select.h
index ddea7c528ec74a..a92f2051b577d5 100644
--- a/libclc/clc/include/clc/relational/clc_select.h
+++ b/libclc/clc/include/clc/relational/clc_select.h
@@ -1,23 +1,19 @@
 #ifndef __CLC_RELATIONAL_CLC_SELECT_H__
 #define __CLC_RELATIONAL_CLC_SELECT_H__
 
-#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
-// clspv and spir-v targets provide their own OpenCL-compatible select
-#define __clc_select select
-#else
-
 /* Duplciate these so we don't have to distribute utils.h */
 #define __CLC_CONCAT(x, y) x##y
 #define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y)
 
-#define __CLC_BODY 
+#define __CLC_SELECT_FN __clc_select
+
+#define __CLC_BODY 
 #include 
-#define __CLC_BODY 
+#define __CLC_BODY 
 #include 
 
+#undef __CLC_SELECT_FN
 #undef __CLC_CONCAT
 #undef __CLC_XCONCAT
 
-#endif
-
 #endif // __CLC_RELATIONAL_CLC_SELECT_H__
diff --git a/libclc/clc/include/clc/relational/clc_select.inc 
b/libclc/clc/include/clc/relational/clc_select_decl.inc
similarity index 58%
rename from libclc/clc/include/clc/relational/clc_select.inc
rename to libclc/clc/include/clc/relational/clc_select_decl.inc
index abf0e0fa436003..3a4f2dcb75170c 100644
--- a/libclc/clc/include/clc/relational/clc_select.inc
+++ b/libclc/clc/include/clc/relational/clc_select_decl.inc
@@ -13,12 +13,12 @@
 #define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE)
 #endif
 
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
-   __CLC_GENTYPE y,
-   __CLC_S_GENTYPE z);
-_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
-   __CLC_GENTYPE y,
-   __CLC_U_GENTYPE z);
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
+  __CLC_GENTYPE y,
+  __CLC_S_GENTYPE z);
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
+  __CLC_GENTYPE y,
+  __CLC_U_GENTYPE z);
 
 #ifdef __CLC_FPSIZE
 #undef __CLC_S_GENTYPE
diff --git a/libclc/clc/lib/generic/relational/clc_select.inc 
b/libclc/clc/include/clc/relational/clc_select_impl.inc
similarity index 55%
rename from libclc/clc/lib/generic/relational/clc_select.inc
rename to libclc/clc/include/clc/relational/clc_select_impl.inc
index 47db80672a02c2..ad53e822179fbd 100644
--- a/libclc/clc/lib/generic/relational/clc_select.inc
+++ b/libclc/clc/include/clc/relational/clc_select_impl.inc
@@ -13,16 +13,16 @@
 #define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE)
 #endif
 
-_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_select(__CLC_GENTYPE x,
-  __CLC_GENTYPE y,
-  __CLC_S_GENTYPE z) {
-  return z ? y : x;
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_SELECT_FN(__CLC_GENTYPE x,
+ __CLC_GENTYPE y,
+