[libc-commits] [PATCH] D158435: [libc] Configure the 'printf' implementation for the GPU

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Aug 21 09:21:53 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, lntue, michaelrj, sivachandra.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
jhuber6 requested review of this revision.

The GPU build is attempt to build with `printf` support. Currently with
D158246 <https://reviews.llvm.org/D158246> we can compile `snprintf` and run it. However, this introduces
problems with the long double table and backtracking. This patch adds
the necessary configs to disable the long double table and support for
`%n`.

The size of the generated binaries is much smaller with this applied so
it's a good first step. We also will want `%n` disabled for out handling
of `printf` as it required backtracking.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158435

Files:
  libc/src/stdio/printf_core/CMakeLists.txt


Index: libc/src/stdio/printf_core/CMakeLists.txt
===================================================================
--- libc/src/stdio/printf_core/CMakeLists.txt
+++ libc/src/stdio/printf_core/CMakeLists.txt
@@ -1,3 +1,10 @@
+set(printf_config "")
+if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+  list(APPEND printf_config -DLIBC_COPT_PRINTF_DISABLE_WRITE_INT)
+  list(APPEND printf_config -DLIBC_COPT_PRINTF_DISABLE_INDEX_MODE)
+else()
+  list(APPEND printf_config -DLIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE)
+endif()
 
 add_header_library(
   core_structs
@@ -24,6 +31,8 @@
     libc.src.__support.CPP.string_view
     libc.src.__support.CPP.type_traits
     libc.src.__support.common
+  COMPILE_OPTIONS
+    ${target_config}
 )
 
 add_object_library(
@@ -92,7 +101,7 @@
     libc.src.__support.integer_to_string
     libc.src.__support.float_to_string
   COMPILE_OPTIONS
-    -DLIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE
+    ${target_config}
 )
 
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158435.552050.patch
Type: text/x-patch
Size: 961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230821/6832b905/attachment.bin>


More information about the libc-commits mailing list