From 380eb46b13175aef5f98f0613bcc9207021efce0 Mon Sep 17 00:00:00 2001 From: michaelrj-google <71531609+michaelrj-google@users.noreply.github.com> Date: Wed, 13 Sep 2023 10:43:05 -0700 Subject: [PATCH] [libc] Move long double table option to new config (#66151) This patch adds the long double table option for printf into the new configuration scheme. This allows it to be set for most targets but unset for baremetal. --- libc/config/baremetal/config.json | 3 +++ libc/config/config.json | 4 ++++ libc/docs/configure.rst | 1 + libc/src/stdio/CMakeLists.txt | 3 +++ libc/src/stdio/printf_core/CMakeLists.txt | 1 - 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libc/config/baremetal/config.json b/libc/config/baremetal/config.json index a65eaa8911e6..53f232e31cc8 100644 --- a/libc/config/baremetal/config.json +++ b/libc/config/baremetal/config.json @@ -8,6 +8,9 @@ }, "LIBC_CONF_PRINTF_DISABLE_WRITE_INT": { "value": true + }, + "LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE": { + "value": false } } } diff --git a/libc/config/config.json b/libc/config/config.json index cd68b81028bf..134cf06a73b3 100644 --- a/libc/config/config.json +++ b/libc/config/config.json @@ -11,6 +11,10 @@ "LIBC_CONF_PRINTF_DISABLE_WRITE_INT": { "value": false, "doc": "Disable handling of %n in printf format string." + }, + "LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE": { + "value": true, + "doc": "Use large table for better printf long double performance." } } } diff --git a/libc/docs/configure.rst b/libc/docs/configure.rst index 9b4d60341293..a667316bd399 100644 --- a/libc/docs/configure.rst +++ b/libc/docs/configure.rst @@ -29,3 +29,4 @@ to learn about the defaults for your platform and target. - ``LIBC_CONF_PRINTF_DISABLE_FLOAT``: Disable printing floating point values in printf and friends. - ``LIBC_CONF_PRINTF_DISABLE_INDEX_MODE``: Disable index mode in the printf format string. - ``LIBC_CONF_PRINTF_DISABLE_WRITE_INT``: Disable handling of %n in printf format string. + - ``LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE``: Use large table for better printf long double performance. diff --git a/libc/src/stdio/CMakeLists.txt b/libc/src/stdio/CMakeLists.txt index 740ec106da2e..de28b5c02071 100644 --- a/libc/src/stdio/CMakeLists.txt +++ b/libc/src/stdio/CMakeLists.txt @@ -363,6 +363,9 @@ endif() if(LIBC_CONF_PRINTF_DISABLE_WRITE_INT) list(APPEND printf_copts "-DLIBC_COPT_PRINTF_DISABLE_WRITE_INT") endif() +if(LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE) + list(APPEND printf_copts "-DLIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE") +endif() if(LLVM_LIBC_FULL_BUILD) list(APPEND printf_deps diff --git a/libc/src/stdio/printf_core/CMakeLists.txt b/libc/src/stdio/printf_core/CMakeLists.txt index 0b3766b55e8d..7087d28ede66 100644 --- a/libc/src/stdio/printf_core/CMakeLists.txt +++ b/libc/src/stdio/printf_core/CMakeLists.txt @@ -92,7 +92,6 @@ add_object_library( libc.src.__support.integer_to_string libc.src.__support.float_to_string COMPILE_OPTIONS - -DLIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE ${printf_copts} )