From 4546cbb9b95ab43a2e194a5597fa336fc75529b6 Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Tue, 12 Sep 2023 12:32:04 -0700 Subject: [PATCH 1/2] [libc] Move long double table option to new config 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/src/stdio/CMakeLists.txt | 3 +++ libc/src/stdio/printf_core/CMakeLists.txt | 1 - 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libc/config/baremetal/config.json b/libc/config/baremetal/config.json index a65eaa8911e6c..53f232e31cc8a 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 cd68b81028bff..134cf06a73b3a 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/src/stdio/CMakeLists.txt b/libc/src/stdio/CMakeLists.txt index 740ec106da2e4..de28b5c02071b 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 0b3766b55e8d4..7087d28ede66e 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} ) From 9ee9cc4a52a257e4afd0969fab1de32ad2ee05ba Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Wed, 13 Sep 2023 10:25:40 -0700 Subject: [PATCH 2/2] Auto-update configure.rst --- libc/docs/configure.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/libc/docs/configure.rst b/libc/docs/configure.rst index 9b4d603412935..a667316bd3991 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.