[libclc] [libclc] Remove clspv-specific clc conversions (PR #128500)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 24 03:53:37 PST 2025


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

The clc and clc+clspv modes produced the same conversions code, so this patch simplifies the process. It further simplifies the internal checks the script makes by assuming the mutual exclusivity.

>From ced04ef08d986082155aa601c1be203f742e6ec9 Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Mon, 24 Feb 2025 11:50:06 +0000
Subject: [PATCH] [libclc] Remove clspv-specific clc conversions

The clc and clc+clspv modes produced the same conversions code, so this
patch simplifies the process. It further simplifies the internal checks
the script makes by assuming the mutual exclusivity.
---
 libclc/CMakeLists.txt             | 14 +-------------
 libclc/generic/lib/gen_convert.py | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 2a2ebec66f6a9..22c3075801785 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -258,13 +258,6 @@ if ( clspv-- IN_LIST LIBCLC_TARGETS_TO_BUILD OR clspv64-- IN_LIST LIBCLC_TARGETS
     DEPENDS ${script_loc} )
   add_custom_target( generate-clspv-convert.cl DEPENDS clspv-convert.cl )
   set_target_properties( generate-clspv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )
-
-  add_custom_command(
-    OUTPUT clc-clspv-convert.cl
-    COMMAND ${Python3_EXECUTABLE} ${script_loc} --clc --clspv > clc-clspv-convert.cl
-    DEPENDS ${script_loc} )
-  add_custom_target( generate-clc-clspv-convert.cl DEPENDS clc-clspv-convert.cl )
-  set_target_properties( generate-clc-clspv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )
 endif()
 
 enable_testing()
@@ -314,12 +307,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
   endif()
 
   set( clc_lib_files )
-
-  if( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
-    set( clc_gen_files clc-clspv-convert.cl )
-  else()
-    set( clc_gen_files clc-convert.cl )
-  endif()
+  set( clc_gen_files clc-convert.cl )
 
   libclc_configure_lib_source(
     clc_lib_files
diff --git a/libclc/generic/lib/gen_convert.py b/libclc/generic/lib/gen_convert.py
index d2d5b7975275c..3359102224060 100644
--- a/libclc/generic/lib/gen_convert.py
+++ b/libclc/generic/lib/gen_convert.py
@@ -28,6 +28,7 @@
 # convert_<destTypen><_sat><_roundingMode>(<sourceTypen>)
 
 import argparse
+from sys import stderr
 
 parser = argparse.ArgumentParser()
 parser.add_argument(
@@ -41,6 +42,14 @@
 clc = args.clc
 clspv = args.clspv
 
+
+# We don't generate clspv-specific code for clc conversions - don't allow this
+# accidentally (later checks rely on mutual exclusivity)
+if clc and clspv:
+    print("Error: clc and clspv conversions are mutually exclusive", file=stderr)
+    exit(1)
+
+
 types = [
     "char",
     "uchar",
@@ -308,7 +317,7 @@ def generate_default_conversion(src, dst, mode):
 
 # Do not generate user-facing default conversions for clspv as they are handled
 # natively
-if clc or not clspv:
+if not clspv:
     for src in types:
         for dst in types:
             generate_default_conversion(src, dst, "")
@@ -318,7 +327,7 @@ def generate_default_conversion(src, dst, mode):
         for mode in rounding_modes:
             # Do not generate user-facing "_rte" conversions for clspv as they
             # are handled natively
-            if clspv and not clc and mode == "_rte":
+            if clspv and mode == "_rte":
                 continue
             generate_default_conversion(src, dst, mode)
 
@@ -560,6 +569,6 @@ def generate_float_conversion(src, dst, size, mode, sat):
             for mode in rounding_modes:
                 # Do not generate user-facing "_rte" conversions for clspv as
                 # they are handled natively
-                if clspv and not clc and mode == "_rte":
+                if clspv and mode == "_rte":
                     continue
                 generate_float_conversion(src, dst, size, mode, "")



More information about the cfe-commits mailing list