https://github.com/jhuber6 created 
https://github.com/llvm/llvm-project/pull/182125

Summary:
Right now these just define globals while are linked in and consumed by
a helper function. Instead, we could just define the function to return
true or false.

This changes this file to now live next to `libclc.bc`. I don't know if
this is desired or how it was used before. Previoulsy the `.ll` was
'generic' and only needed the one file.


>From a79260f3a9ec88136e02c16ce66b9567a8cd4459 Mon Sep 17 00:00:00 2001
From: Joseph Huber <[email protected]>
Date: Wed, 18 Feb 2026 13:58:04 -0600
Subject: [PATCH] [libclc] Remove .ll IR files for handling denormals

Summary:
Right now these just define globals while are linked in and consumed by
a helper function. Instead, we could just define the function to return
true or false.

This changes this file to now live next to `libclc.bc`. I don't know if
this is desired or how it was used before. Previoulsy the `.ll` was
'generic' and only needed the one file.
---
 libclc/CMakeLists.txt                         | 40 ++++++++++++-------
 libclc/opencl/lib/generic/SOURCES             |  1 -
 .../opencl/lib/generic/subnormal_disable.cl   |  9 +++++
 .../opencl/lib/generic/subnormal_disable.ll   |  9 -----
 .../lib/generic/subnormal_helper_func.ll      | 16 --------
 .../lib/generic/subnormal_use_default.cl      |  9 +++++
 .../lib/generic/subnormal_use_default.ll      |  9 -----
 7 files changed, 44 insertions(+), 49 deletions(-)
 create mode 100644 libclc/opencl/lib/generic/subnormal_disable.cl
 delete mode 100644 libclc/opencl/lib/generic/subnormal_disable.ll
 delete mode 100644 libclc/opencl/lib/generic/subnormal_helper_func.ll
 create mode 100644 libclc/opencl/lib/generic/subnormal_use_default.cl
 delete mode 100644 libclc/opencl/lib/generic/subnormal_use_default.ll

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 77c3dca51d3d5..e5a629f938494 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -216,19 +216,6 @@ set( cayman_aliases aruba )
 configure_file( libclc.pc.in libclc.pc @ONLY )
 install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION 
"${CMAKE_INSTALL_DATADIR}/pkgconfig" )
 
-if( ENABLE_RUNTIME_SUBNORMAL )
-  foreach( file IN ITEMS subnormal_use_default subnormal_disable )
-    link_bc(
-       TARGET ${file}
-       INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/${file}.ll
-    )
-    install(
-      FILES $<TARGET_PROPERTY:${file},TARGET_FILE>
-      DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
-    )
-  endforeach()
-endif()
-
 set_source_files_properties(
   # CLC builtins
   ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_cos.cl
@@ -329,7 +316,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
   if( NOT ARCH STREQUAL spirv AND NOT ARCH STREQUAL spirv64 AND
       NOT ARCH STREQUAL clspv AND NOT ARCH STREQUAL clspv64 AND
       NOT ENABLE_RUNTIME_SUBNORMAL )
-    list( APPEND opencl_lib_files opencl/lib/generic/subnormal_use_default.ll )
+    list( APPEND opencl_lib_files opencl/lib/generic/subnormal_use_default.cl )
   endif()
 
   libclc_configure_lib_source(
@@ -450,5 +437,30 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
       # Link in the CLC builtins and internalize their symbols
       INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix}
     )
+
+    if( ENABLE_RUNTIME_SUBNORMAL AND
+        NOT ARCH STREQUAL spirv AND NOT ARCH STREQUAL spirv64 AND
+        NOT ARCH STREQUAL clspv AND NOT ARCH STREQUAL clspv64 )
+      foreach( file IN ITEMS subnormal_use_default subnormal_disable )
+        set( subnormal_obj_file "${LIBCLC_ARCH_OBJFILE_DIR}/${file}.bc" )
+        compile_to_bc(
+          TRIPLE ${clang_triple}
+          INPUT ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/${file}.cl
+          OUTPUT ${subnormal_obj_file}
+          EXTRA_OPTS -nostdlib
+        )
+        add_custom_target( ${file}.${arch_suffix} ALL
+          DEPENDS ${subnormal_obj_file}
+        )
+        set_target_properties( ${file}.${arch_suffix} PROPERTIES
+          TARGET_FILE ${subnormal_obj_file}
+          FOLDER "libclc/Device IR/Subnormal"
+        )
+        install(
+          FILES ${subnormal_obj_file}
+          DESTINATION "${LIBCLC_INSTALL_DIR}/${clang_triple}"
+        )
+      endforeach()
+    endif()
   endforeach( d )
 endforeach( t )
diff --git a/libclc/opencl/lib/generic/SOURCES 
b/libclc/opencl/lib/generic/SOURCES
index a2c6af8b9252c..c820c6c3c0c06 100644
--- a/libclc/opencl/lib/generic/SOURCES
+++ b/libclc/opencl/lib/generic/SOURCES
@@ -1,5 +1,4 @@
 subnormal_config.cl
-subnormal_helper_func.ll
 async/async_work_group_copy.cl
 async/async_work_group_strided_copy.cl
 async/prefetch.cl
diff --git a/libclc/opencl/lib/generic/subnormal_disable.cl 
b/libclc/opencl/lib/generic/subnormal_disable.cl
new file mode 100644
index 0000000000000..9eb3efddddc81
--- /dev/null
+++ b/libclc/opencl/lib/generic/subnormal_disable.cl
@@ -0,0 +1,9 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+bool __clc_subnormals_disabled(void) { return true; }
diff --git a/libclc/opencl/lib/generic/subnormal_disable.ll 
b/libclc/opencl/lib/generic/subnormal_disable.ll
deleted file mode 100644
index 732d09ff09ab4..0000000000000
--- a/libclc/opencl/lib/generic/subnormal_disable.ll
+++ /dev/null
@@ -1,9 +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
-;
-;;===----------------------------------------------------------------------===;;
-
-@__CLC_SUBNORMAL_DISABLE = unnamed_addr constant i1 true
diff --git a/libclc/opencl/lib/generic/subnormal_helper_func.ll 
b/libclc/opencl/lib/generic/subnormal_helper_func.ll
deleted file mode 100644
index 03beecf979260..0000000000000
--- a/libclc/opencl/lib/generic/subnormal_helper_func.ll
+++ /dev/null
@@ -1,16 +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
-;
-;;===----------------------------------------------------------------------===;;
-
-@__CLC_SUBNORMAL_DISABLE = external global i1
-
-define i1 @__clc_subnormals_disabled() #0 {
-  %disable = load i1, i1* @__CLC_SUBNORMAL_DISABLE
-  ret i1 %disable
-}
-
-attributes #0 = { alwaysinline }
diff --git a/libclc/opencl/lib/generic/subnormal_use_default.cl 
b/libclc/opencl/lib/generic/subnormal_use_default.cl
new file mode 100644
index 0000000000000..9797640f889b7
--- /dev/null
+++ b/libclc/opencl/lib/generic/subnormal_use_default.cl
@@ -0,0 +1,9 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+bool __clc_subnormals_disabled(void) { return false; }
diff --git a/libclc/opencl/lib/generic/subnormal_use_default.ll 
b/libclc/opencl/lib/generic/subnormal_use_default.ll
deleted file mode 100644
index c648cc0a8aded..0000000000000
--- a/libclc/opencl/lib/generic/subnormal_use_default.ll
+++ /dev/null
@@ -1,9 +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
-;
-;;===----------------------------------------------------------------------===;;
-
-@__CLC_SUBNORMAL_DISABLE = unnamed_addr constant i1 false

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to