From libc-commits at lists.llvm.org Sat Feb 1 05:09:35 2025 From: libc-commits at lists.llvm.org (Krishna Pandey via libc-commits) Date: Sat, 01 Feb 2025 05:09:35 -0800 (PST) Subject: [libc-commits] [libc] [libc] Fix all imports of src/string/memory_utils (PR #114939) In-Reply-To: Message-ID: <679e1d0f.170a0220.209913.e35b@mx.google.com> https://github.com/krishna2803 updated https://github.com/llvm/llvm-project/pull/114939 >From 67a499ddef02a33fd03d3a42082c7985a069d9f2 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Fri, 31 Jan 2025 19:16:54 +0530 Subject: [PATCH 1/6] fix: change `endian.h` to `endian_internal.h` --- libc/src/string/memory_utils/inline_bcmp.h | 2 +- libc/src/string/memory_utils/inline_bzero.h | 2 +- libc/src/string/memory_utils/inline_memmove.h | 2 +- libc/src/string/memory_utils/inline_strcmp.h | 2 +- libc/src/string/memory_utils/inline_strstr.h | 2 +- libc/src/string/memory_utils/op_aarch64.h | 2 +- libc/src/string/memory_utils/op_builtin.h | 2 +- libc/src/string/memory_utils/op_generic.h | 3 ++- libc/src/string/memory_utils/op_riscv.h | 2 +- libc/src/string/memory_utils/op_x86.h | 2 +- 10 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libc/src/string/memory_utils/inline_bcmp.h b/libc/src/string/memory_utils/inline_bcmp.h index 14cf16ebb6b69f..84470dac76fd6d 100644 --- a/libc/src/string/memory_utils/inline_bcmp.h +++ b/libc/src/string/memory_utils/inline_bcmp.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_BCMP_H #include "src/__support/common.h" -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_ #include // size_t diff --git a/libc/src/string/memory_utils/inline_bzero.h b/libc/src/string/memory_utils/inline_bzero.h index 4a92e8b57a68e2..03bd29ab623c60 100644 --- a/libc/src/string/memory_utils/inline_bzero.h +++ b/libc/src/string/memory_utils/inline_bzero.h @@ -10,7 +10,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_BZERO_H #include "src/__support/common.h" -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include "src/string/memory_utils/inline_memset.h" #include // size_t diff --git a/libc/src/string/memory_utils/inline_memmove.h b/libc/src/string/memory_utils/inline_memmove.h index 85d0159701ece6..721f6f80e0f286 100644 --- a/libc/src/string/memory_utils/inline_memmove.h +++ b/libc/src/string/memory_utils/inline_memmove.h @@ -9,7 +9,7 @@ #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMMOVE_H #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMMOVE_H -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include // size_t, ptrdiff_t #if defined(LIBC_TARGET_ARCH_IS_X86) diff --git a/libc/src/string/memory_utils/inline_strcmp.h b/libc/src/string/memory_utils/inline_strcmp.h index 281d5b14c6cbac..0c3e9cf14c8234 100644 --- a/libc/src/string/memory_utils/inline_strcmp.h +++ b/libc/src/string/memory_utils/inline_strcmp.h @@ -9,7 +9,7 @@ #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRCMP_H #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRCMP_H -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include namespace LIBC_NAMESPACE_DECL { diff --git a/libc/src/string/memory_utils/inline_strstr.h b/libc/src/string/memory_utils/inline_strstr.h index 9c99e920b4b570..1ff9a56e288780 100644 --- a/libc/src/string/memory_utils/inline_strstr.h +++ b/libc/src/string/memory_utils/inline_strstr.h @@ -9,7 +9,7 @@ #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include "src/string/memory_utils/inline_memmem.h" #include "src/string/string_utils.h" #include diff --git a/libc/src/string/memory_utils/op_aarch64.h b/libc/src/string/memory_utils/op_aarch64.h index 1090ea2617f096..3be7f6006cb8c7 100644 --- a/libc/src/string/memory_utils/op_aarch64.h +++ b/libc/src/string/memory_utils/op_aarch64.h @@ -13,7 +13,7 @@ #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_AARCH64_H #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_AARCH64_H -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include "src/__support/macros/properties/architectures.h" #if defined(LIBC_TARGET_ARCH_IS_AARCH64) diff --git a/libc/src/string/memory_utils/op_builtin.h b/libc/src/string/memory_utils/op_builtin.h index d7c1b1f870115a..a4d5f6d3f38f97 100644 --- a/libc/src/string/memory_utils/op_builtin.h +++ b/libc/src/string/memory_utils/op_builtin.h @@ -16,7 +16,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_BUILTIN_H #include "src/__support/CPP/type_traits.h" -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include "src/string/memory_utils/utils.h" namespace LIBC_NAMESPACE_DECL { diff --git a/libc/src/string/memory_utils/op_generic.h b/libc/src/string/memory_utils/op_generic.h index da20a84dede4d1..cb17680a67d035 100644 --- a/libc/src/string/memory_utils/op_generic.h +++ b/libc/src/string/memory_utils/op_generic.h @@ -27,7 +27,8 @@ #include "src/__support/CPP/type_traits.h" #include "src/__support/common.h" #include "src/__support/endian_internal.h" -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/optimization.h" #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT64 #include "src/string/memory_utils/op_builtin.h" diff --git a/libc/src/string/memory_utils/op_riscv.h b/libc/src/string/memory_utils/op_riscv.h index 2d211de0facfc9..b6349505f976e0 100644 --- a/libc/src/string/memory_utils/op_riscv.h +++ b/libc/src/string/memory_utils/op_riscv.h @@ -12,7 +12,7 @@ #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_RISCV_H #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_RISCV_H -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include "src/__support/macros/properties/architectures.h" #if defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) diff --git a/libc/src/string/memory_utils/op_x86.h b/libc/src/string/memory_utils/op_x86.h index 309610e4ad6307..90094b4cca197d 100644 --- a/libc/src/string/memory_utils/op_x86.h +++ b/libc/src/string/memory_utils/op_x86.h @@ -12,7 +12,7 @@ #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_X86_H #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_X86_H -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include "src/__support/macros/properties/architectures.h" #if defined(LIBC_TARGET_ARCH_IS_X86) >From 58400f735ce5bf159d8a7141a87453744ca74d1c Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Fri, 31 Jan 2025 19:18:28 +0530 Subject: [PATCH 2/6] fix: change CMakeLists.txt --- libc/src/__support/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt index 0e0556f4eecfd6..17f03a6b6c4a08 100644 --- a/libc/src/__support/CMakeLists.txt +++ b/libc/src/__support/CMakeLists.txt @@ -87,7 +87,7 @@ add_header_library( endian_internal.h macros/properties/architectures.h macros/attributes.h - macros/properties/cpu_features.h + macros/config.h ) add_header_library( >From 7feecec7ab8b4741111442e9bcc4f0c2a5bbed88 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Sat, 9 Nov 2024 04:15:12 +0530 Subject: [PATCH 3/6] Fix more imports --- libc/src/string/allocating_string_utils.h | 2 +- libc/src/string/memory_utils/aarch64/inline_bcmp.h | 1 - libc/src/string/memory_utils/aarch64/inline_memset.h | 1 - libc/src/string/memory_utils/generic/builtin.h | 1 - libc/src/string/memory_utils/inline_memmem.h | 1 - libc/src/string/memory_utils/riscv/inline_bcmp.h | 1 - libc/src/string/memory_utils/riscv/inline_memcmp.h | 1 - libc/src/string/memory_utils/riscv/inline_memcpy.h | 1 - libc/src/string/memory_utils/riscv/inline_memmove.h | 1 - libc/src/string/memory_utils/riscv/inline_memset.h | 1 - libc/src/string/memory_utils/utils.h | 1 - libc/src/string/memory_utils/x86_64/inline_bcmp.h | 1 - libc/src/string/memory_utils/x86_64/inline_memset.h | 1 - 13 files changed, 1 insertion(+), 13 deletions(-) diff --git a/libc/src/string/allocating_string_utils.h b/libc/src/string/allocating_string_utils.h index b3a8663c2f477c..af279db7120d6d 100644 --- a/libc/src/string/allocating_string_utils.h +++ b/libc/src/string/allocating_string_utils.h @@ -11,7 +11,7 @@ #include "src/__support/CPP/new.h" #include "src/__support/CPP/optional.h" -#include "src/__support/macros/config.h" +#include "src/__support/macros/attributes.h" #include "src/string/memory_utils/inline_memcpy.h" #include "src/string/string_utils.h" diff --git a/libc/src/string/memory_utils/aarch64/inline_bcmp.h b/libc/src/string/memory_utils/aarch64/inline_bcmp.h index 93196415f26625..12ea15dfdc6383 100644 --- a/libc/src/string/memory_utils/aarch64/inline_bcmp.h +++ b/libc/src/string/memory_utils/aarch64/inline_bcmp.h @@ -9,7 +9,6 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_BCMP_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY #include "src/string/memory_utils/op_aarch64.h" #include "src/string/memory_utils/op_generic.h" diff --git a/libc/src/string/memory_utils/aarch64/inline_memset.h b/libc/src/string/memory_utils/aarch64/inline_memset.h index a2c05534aa330e..6ec17e9cf6cecc 100644 --- a/libc/src/string/memory_utils/aarch64/inline_memset.h +++ b/libc/src/string/memory_utils/aarch64/inline_memset.h @@ -9,7 +9,6 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_MEMSET_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/string/memory_utils/op_aarch64.h" #include "src/string/memory_utils/op_generic.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/generic/builtin.h b/libc/src/string/memory_utils/generic/builtin.h index 5670a4e610565b..274e8e52a1dbb4 100644 --- a/libc/src/string/memory_utils/generic/builtin.h +++ b/libc/src/string/memory_utils/generic/builtin.h @@ -10,7 +10,6 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr #include // size_t diff --git a/libc/src/string/memory_utils/inline_memmem.h b/libc/src/string/memory_utils/inline_memmem.h index 15e3d633985d61..6f62d4a10e2c79 100644 --- a/libc/src/string/memory_utils/inline_memmem.h +++ b/libc/src/string/memory_utils/inline_memmem.h @@ -10,7 +10,6 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMMEM_H #include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" #include diff --git a/libc/src/string/memory_utils/riscv/inline_bcmp.h b/libc/src/string/memory_utils/riscv/inline_bcmp.h index 4bdde27cd16be2..1838e8c4229d9a 100644 --- a/libc/src/string/memory_utils/riscv/inline_bcmp.h +++ b/libc/src/string/memory_utils/riscv/inline_bcmp.h @@ -9,7 +9,6 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_BCMP_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/aligned_access.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/riscv/inline_memcmp.h b/libc/src/string/memory_utils/riscv/inline_memcmp.h index ca834952d331ea..9bafb45f6d3397 100644 --- a/libc/src/string/memory_utils/riscv/inline_memcmp.h +++ b/libc/src/string/memory_utils/riscv/inline_memcmp.h @@ -9,7 +9,6 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_MEMCMP_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/aligned_access.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/riscv/inline_memcpy.h b/libc/src/string/memory_utils/riscv/inline_memcpy.h index 8eb87e0f38ce5a..4da835acfbfa02 100644 --- a/libc/src/string/memory_utils/riscv/inline_memcpy.h +++ b/libc/src/string/memory_utils/riscv/inline_memcpy.h @@ -9,7 +9,6 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_MEMCPY_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/aligned_access.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/riscv/inline_memmove.h b/libc/src/string/memory_utils/riscv/inline_memmove.h index 28de4c240260d4..d6e2e4ebd5fd80 100644 --- a/libc/src/string/memory_utils/riscv/inline_memmove.h +++ b/libc/src/string/memory_utils/riscv/inline_memmove.h @@ -9,7 +9,6 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_MEMMOVE_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/byte_per_byte.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/riscv/inline_memset.h b/libc/src/string/memory_utils/riscv/inline_memset.h index d6ab523f164144..279c3bfef7a1a7 100644 --- a/libc/src/string/memory_utils/riscv/inline_memset.h +++ b/libc/src/string/memory_utils/riscv/inline_memset.h @@ -9,7 +9,6 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_MEMSET_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/aligned_access.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/utils.h b/libc/src/string/memory_utils/utils.h index cae65bddd92f6e..6680eaa0961daa 100644 --- a/libc/src/string/memory_utils/utils.h +++ b/libc/src/string/memory_utils/utils.h @@ -14,7 +14,6 @@ #include "src/__support/CPP/type_traits.h" #include "src/__support/endian_internal.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" #include // size_t diff --git a/libc/src/string/memory_utils/x86_64/inline_bcmp.h b/libc/src/string/memory_utils/x86_64/inline_bcmp.h index cc54c4140ee6e6..ad75d57dfc43ef 100644 --- a/libc/src/string/memory_utils/x86_64/inline_bcmp.h +++ b/libc/src/string/memory_utils/x86_64/inline_bcmp.h @@ -9,7 +9,6 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_X86_64_INLINE_BCMP_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/string/memory_utils/op_generic.h" #include "src/string/memory_utils/op_x86.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/x86_64/inline_memset.h b/libc/src/string/memory_utils/x86_64/inline_memset.h index 9f8e584d2bbb45..fd8d7f35d97f46 100644 --- a/libc/src/string/memory_utils/x86_64/inline_memset.h +++ b/libc/src/string/memory_utils/x86_64/inline_memset.h @@ -9,7 +9,6 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_X86_64_INLINE_MEMSET_H #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" #include "src/string/memory_utils/op_generic.h" #include "src/string/memory_utils/op_x86.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr >From 6dff9cdfb6c78a8acd697f5b706a8225233cea05 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Fri, 31 Jan 2025 19:19:32 +0530 Subject: [PATCH 4/6] chore: add LIBC_NAMESPACE_DECL --- libc/src/dirent/readdir.h | 2 +- libc/src/string/allocating_string_utils.h | 2 +- libc/src/string/memory_utils/aarch64/inline_bcmp.h | 2 +- libc/src/string/memory_utils/aarch64/inline_memset.h | 1 + libc/src/string/memory_utils/generic/builtin.h | 1 + libc/src/string/memory_utils/inline_bcmp.h | 1 + libc/src/string/memory_utils/inline_bzero.h | 1 + libc/src/string/memory_utils/inline_memmem.h | 3 ++- libc/src/string/memory_utils/inline_memmove.h | 1 + libc/src/string/memory_utils/inline_strcmp.h | 1 + libc/src/string/memory_utils/inline_strstr.h | 1 + libc/src/string/memory_utils/op_aarch64.h | 1 + libc/src/string/memory_utils/op_builtin.h | 1 + libc/src/string/memory_utils/op_generic.h | 2 +- libc/src/string/memory_utils/op_riscv.h | 1 + libc/src/string/memory_utils/op_x86.h | 1 + libc/src/string/memory_utils/riscv/inline_bcmp.h | 1 + libc/src/string/memory_utils/riscv/inline_memcmp.h | 1 + libc/src/string/memory_utils/riscv/inline_memcpy.h | 1 + libc/src/string/memory_utils/riscv/inline_memmove.h | 1 + libc/src/string/memory_utils/riscv/inline_memset.h | 1 + libc/src/string/memory_utils/utils.h | 1 + libc/src/string/memory_utils/x86_64/inline_bcmp.h | 1 + libc/src/string/memory_utils/x86_64/inline_memset.h | 3 ++- 24 files changed, 26 insertions(+), 6 deletions(-) diff --git a/libc/src/dirent/readdir.h b/libc/src/dirent/readdir.h index 2dcf5360ebd35c..bc46a1bbfbf4a0 100644 --- a/libc/src/dirent/readdir.h +++ b/libc/src/dirent/readdir.h @@ -9,7 +9,7 @@ #ifndef LLVM_LIBC_SRC_DIRENT_READDIR_H #define LLVM_LIBC_SRC_DIRENT_READDIR_H -#include "src/__support/macros/config.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include namespace LIBC_NAMESPACE_DECL { diff --git a/libc/src/string/allocating_string_utils.h b/libc/src/string/allocating_string_utils.h index af279db7120d6d..1dece510e79694 100644 --- a/libc/src/string/allocating_string_utils.h +++ b/libc/src/string/allocating_string_utils.h @@ -11,7 +11,7 @@ #include "src/__support/CPP/new.h" #include "src/__support/CPP/optional.h" -#include "src/__support/macros/attributes.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/string/memory_utils/inline_memcpy.h" #include "src/string/string_utils.h" diff --git a/libc/src/string/memory_utils/aarch64/inline_bcmp.h b/libc/src/string/memory_utils/aarch64/inline_bcmp.h index 12ea15dfdc6383..11c51b251a6e86 100644 --- a/libc/src/string/memory_utils/aarch64/inline_bcmp.h +++ b/libc/src/string/memory_utils/aarch64/inline_bcmp.h @@ -8,7 +8,7 @@ #ifndef LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_BCMP_H #define LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_BCMP_H -#include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY #include "src/string/memory_utils/op_aarch64.h" #include "src/string/memory_utils/op_generic.h" diff --git a/libc/src/string/memory_utils/aarch64/inline_memset.h b/libc/src/string/memory_utils/aarch64/inline_memset.h index 6ec17e9cf6cecc..efcbfd07059833 100644 --- a/libc/src/string/memory_utils/aarch64/inline_memset.h +++ b/libc/src/string/memory_utils/aarch64/inline_memset.h @@ -9,6 +9,7 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_MEMSET_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/string/memory_utils/op_aarch64.h" #include "src/string/memory_utils/op_generic.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/generic/builtin.h b/libc/src/string/memory_utils/generic/builtin.h index 274e8e52a1dbb4..2b9ecc0c046eb6 100644 --- a/libc/src/string/memory_utils/generic/builtin.h +++ b/libc/src/string/memory_utils/generic/builtin.h @@ -10,6 +10,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/string/memory_utils/utils.h" // Ptr, CPtr #include // size_t diff --git a/libc/src/string/memory_utils/inline_bcmp.h b/libc/src/string/memory_utils/inline_bcmp.h index 84470dac76fd6d..52c738d3a4ce27 100644 --- a/libc/src/string/memory_utils/inline_bcmp.h +++ b/libc/src/string/memory_utils/inline_bcmp.h @@ -11,6 +11,7 @@ #include "src/__support/common.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_ #include // size_t diff --git a/libc/src/string/memory_utils/inline_bzero.h b/libc/src/string/memory_utils/inline_bzero.h index 03bd29ab623c60..a131b68725de71 100644 --- a/libc/src/string/memory_utils/inline_bzero.h +++ b/libc/src/string/memory_utils/inline_bzero.h @@ -11,6 +11,7 @@ #include "src/__support/common.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/string/memory_utils/inline_memset.h" #include // size_t diff --git a/libc/src/string/memory_utils/inline_memmem.h b/libc/src/string/memory_utils/inline_memmem.h index 6f62d4a10e2c79..1e9649c6e65e34 100644 --- a/libc/src/string/memory_utils/inline_memmem.h +++ b/libc/src/string/memory_utils/inline_memmem.h @@ -9,7 +9,8 @@ #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMMEM_H #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMMEM_H -#include "src/__support/macros/attributes.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include diff --git a/libc/src/string/memory_utils/inline_memmove.h b/libc/src/string/memory_utils/inline_memmove.h index 721f6f80e0f286..84671c5c1797e2 100644 --- a/libc/src/string/memory_utils/inline_memmove.h +++ b/libc/src/string/memory_utils/inline_memmove.h @@ -10,6 +10,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_MEMMOVE_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include // size_t, ptrdiff_t #if defined(LIBC_TARGET_ARCH_IS_X86) diff --git a/libc/src/string/memory_utils/inline_strcmp.h b/libc/src/string/memory_utils/inline_strcmp.h index 0c3e9cf14c8234..6758e79ae9ca39 100644 --- a/libc/src/string/memory_utils/inline_strcmp.h +++ b/libc/src/string/memory_utils/inline_strcmp.h @@ -10,6 +10,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRCMP_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include namespace LIBC_NAMESPACE_DECL { diff --git a/libc/src/string/memory_utils/inline_strstr.h b/libc/src/string/memory_utils/inline_strstr.h index 1ff9a56e288780..5495cc4803ec94 100644 --- a/libc/src/string/memory_utils/inline_strstr.h +++ b/libc/src/string/memory_utils/inline_strstr.h @@ -10,6 +10,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/string/memory_utils/inline_memmem.h" #include "src/string/string_utils.h" #include diff --git a/libc/src/string/memory_utils/op_aarch64.h b/libc/src/string/memory_utils/op_aarch64.h index 3be7f6006cb8c7..868c64474c0b43 100644 --- a/libc/src/string/memory_utils/op_aarch64.h +++ b/libc/src/string/memory_utils/op_aarch64.h @@ -14,6 +14,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_AARCH64_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" #if defined(LIBC_TARGET_ARCH_IS_AARCH64) diff --git a/libc/src/string/memory_utils/op_builtin.h b/libc/src/string/memory_utils/op_builtin.h index a4d5f6d3f38f97..27b621d97f01a0 100644 --- a/libc/src/string/memory_utils/op_builtin.h +++ b/libc/src/string/memory_utils/op_builtin.h @@ -17,6 +17,7 @@ #include "src/__support/CPP/type_traits.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/string/memory_utils/utils.h" namespace LIBC_NAMESPACE_DECL { diff --git a/libc/src/string/memory_utils/op_generic.h b/libc/src/string/memory_utils/op_generic.h index cb17680a67d035..9349cfdd1d0201 100644 --- a/libc/src/string/memory_utils/op_generic.h +++ b/libc/src/string/memory_utils/op_generic.h @@ -28,7 +28,7 @@ #include "src/__support/common.h" #include "src/__support/endian_internal.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/optimization.h" #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT64 #include "src/string/memory_utils/op_builtin.h" diff --git a/libc/src/string/memory_utils/op_riscv.h b/libc/src/string/memory_utils/op_riscv.h index b6349505f976e0..4292d7a627a54a 100644 --- a/libc/src/string/memory_utils/op_riscv.h +++ b/libc/src/string/memory_utils/op_riscv.h @@ -13,6 +13,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_RISCV_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" #if defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) diff --git a/libc/src/string/memory_utils/op_x86.h b/libc/src/string/memory_utils/op_x86.h index 90094b4cca197d..8bd84120c4ffaa 100644 --- a/libc/src/string/memory_utils/op_x86.h +++ b/libc/src/string/memory_utils/op_x86.h @@ -13,6 +13,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_X86_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" #if defined(LIBC_TARGET_ARCH_IS_X86) diff --git a/libc/src/string/memory_utils/riscv/inline_bcmp.h b/libc/src/string/memory_utils/riscv/inline_bcmp.h index 1838e8c4229d9a..666ad6382412e5 100644 --- a/libc/src/string/memory_utils/riscv/inline_bcmp.h +++ b/libc/src/string/memory_utils/riscv/inline_bcmp.h @@ -9,6 +9,7 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_BCMP_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/aligned_access.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/riscv/inline_memcmp.h b/libc/src/string/memory_utils/riscv/inline_memcmp.h index 9bafb45f6d3397..c49e8d0a4ff2f3 100644 --- a/libc/src/string/memory_utils/riscv/inline_memcmp.h +++ b/libc/src/string/memory_utils/riscv/inline_memcmp.h @@ -9,6 +9,7 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_MEMCMP_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/aligned_access.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/riscv/inline_memcpy.h b/libc/src/string/memory_utils/riscv/inline_memcpy.h index 4da835acfbfa02..e907ae4c079e03 100644 --- a/libc/src/string/memory_utils/riscv/inline_memcpy.h +++ b/libc/src/string/memory_utils/riscv/inline_memcpy.h @@ -9,6 +9,7 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_MEMCPY_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/aligned_access.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/riscv/inline_memmove.h b/libc/src/string/memory_utils/riscv/inline_memmove.h index d6e2e4ebd5fd80..01a9fa5c4bbdcc 100644 --- a/libc/src/string/memory_utils/riscv/inline_memmove.h +++ b/libc/src/string/memory_utils/riscv/inline_memmove.h @@ -9,6 +9,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_MEMMOVE_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/byte_per_byte.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/riscv/inline_memset.h b/libc/src/string/memory_utils/riscv/inline_memset.h index 279c3bfef7a1a7..09a7a765e4cb6c 100644 --- a/libc/src/string/memory_utils/riscv/inline_memset.h +++ b/libc/src/string/memory_utils/riscv/inline_memset.h @@ -9,6 +9,7 @@ #define LIBC_SRC_STRING_MEMORY_UTILS_RISCV_INLINE_MEMSET_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" // LIBC_TARGET_ARCH_IS_RISCV64 #include "src/string/memory_utils/generic/aligned_access.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/utils.h b/libc/src/string/memory_utils/utils.h index 6680eaa0961daa..5c9bc72208f85c 100644 --- a/libc/src/string/memory_utils/utils.h +++ b/libc/src/string/memory_utils/utils.h @@ -14,6 +14,7 @@ #include "src/__support/CPP/type_traits.h" #include "src/__support/endian_internal.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/properties/architectures.h" #include // size_t diff --git a/libc/src/string/memory_utils/x86_64/inline_bcmp.h b/libc/src/string/memory_utils/x86_64/inline_bcmp.h index ad75d57dfc43ef..8be391b4289105 100644 --- a/libc/src/string/memory_utils/x86_64/inline_bcmp.h +++ b/libc/src/string/memory_utils/x86_64/inline_bcmp.h @@ -9,6 +9,7 @@ #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_X86_64_INLINE_BCMP_H #include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/string/memory_utils/op_generic.h" #include "src/string/memory_utils/op_x86.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr diff --git a/libc/src/string/memory_utils/x86_64/inline_memset.h b/libc/src/string/memory_utils/x86_64/inline_memset.h index fd8d7f35d97f46..cd24d02363b72b 100644 --- a/libc/src/string/memory_utils/x86_64/inline_memset.h +++ b/libc/src/string/memory_utils/x86_64/inline_memset.h @@ -8,7 +8,8 @@ #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_X86_64_INLINE_MEMSET_H #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_X86_64_INLINE_MEMSET_H -#include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/attributes.h" // LIBC_INLINE_VAR +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/string/memory_utils/op_generic.h" #include "src/string/memory_utils/op_x86.h" #include "src/string/memory_utils/utils.h" // Ptr, CPtr >From 9c7f5811290327aa01c606626fba9d00930f9ed9 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Sun, 26 Jan 2025 19:53:38 +0530 Subject: [PATCH 5/6] add: comments for `LIBC_INLINE` --- libc/src/string/memory_utils/aarch64/inline_bcmp.h | 2 +- libc/src/string/memory_utils/x86_64/inline_memset.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/src/string/memory_utils/aarch64/inline_bcmp.h b/libc/src/string/memory_utils/aarch64/inline_bcmp.h index 11c51b251a6e86..351a172c0b8753 100644 --- a/libc/src/string/memory_utils/aarch64/inline_bcmp.h +++ b/libc/src/string/memory_utils/aarch64/inline_bcmp.h @@ -8,7 +8,7 @@ #ifndef LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_BCMP_H #define LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_BCMP_H -#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL +#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_NAMESPACE_DECL #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY #include "src/string/memory_utils/op_aarch64.h" #include "src/string/memory_utils/op_generic.h" diff --git a/libc/src/string/memory_utils/x86_64/inline_memset.h b/libc/src/string/memory_utils/x86_64/inline_memset.h index cd24d02363b72b..35719a89fa6004 100644 --- a/libc/src/string/memory_utils/x86_64/inline_memset.h +++ b/libc/src/string/memory_utils/x86_64/inline_memset.h @@ -8,7 +8,7 @@ #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_X86_64_INLINE_MEMSET_H #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_X86_64_INLINE_MEMSET_H -#include "src/__support/macros/attributes.h" // LIBC_INLINE_VAR +#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/string/memory_utils/op_generic.h" #include "src/string/memory_utils/op_x86.h" >From 327c70d9fdd74abf729bb156c84fabd1d558af85 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Fri, 31 Jan 2025 19:23:52 +0530 Subject: [PATCH 6/6] chore: formatting --- libc/src/string/memory_utils/aarch64/inline_bcmp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/src/string/memory_utils/aarch64/inline_bcmp.h b/libc/src/string/memory_utils/aarch64/inline_bcmp.h index 351a172c0b8753..14081e083cd5bd 100644 --- a/libc/src/string/memory_utils/aarch64/inline_bcmp.h +++ b/libc/src/string/memory_utils/aarch64/inline_bcmp.h @@ -8,7 +8,7 @@ #ifndef LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_BCMP_H #define LIBC_SRC_STRING_MEMORY_UTILS_AARCH64_INLINE_BCMP_H -#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_NAMESPACE_DECL +#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_NAMESPACE_DECL #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY #include "src/string/memory_utils/op_aarch64.h" #include "src/string/memory_utils/op_generic.h" From libc-commits at lists.llvm.org Sat Feb 1 11:59:02 2025 From: libc-commits at lists.llvm.org (Krishna Pandey via libc-commits) Date: Sat, 01 Feb 2025 11:59:02 -0800 (PST) Subject: [libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356) Message-ID: https://github.com/krishna2803 created https://github.com/llvm/llvm-project/pull/125356 fixes #113357 >From cbb321f8ee1fdbede3da46ce9bba71ecf60d49c2 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Sun, 2 Feb 2025 01:02:44 +0530 Subject: [PATCH 1/7] feat: implement template meta `countls` --- libc/src/__support/fixed_point/fx_bits.h | 35 +++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/libc/src/__support/fixed_point/fx_bits.h b/libc/src/__support/fixed_point/fx_bits.h index 225ea417760a031..a955ee67745c256 100644 --- a/libc/src/__support/fixed_point/fx_bits.h +++ b/libc/src/__support/fixed_point/fx_bits.h @@ -12,8 +12,9 @@ #include "include/llvm-libc-macros/stdfix-macros.h" #include "src/__support/CPP/bit.h" #include "src/__support/CPP/type_traits.h" +#include "src/__support/CPP/limits.h" // numeric_limits #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY #include "src/__support/math_extras.h" @@ -50,6 +51,12 @@ template struct FXBits { static constexpr StorageType SIGN_MASK = (fx_rep::SIGN_LEN == 0 ? 0 : StorageType(1) << SIGN_OFFSET); + // mask for + static constexpr StorageType VALUE_MASK = INTEGRAL_MASK | FRACTION_MASK; + + // mask for + static constexpr StorageType TOTAL_MASK = SIGN_MASK | VALUE_MASK; + public: LIBC_INLINE constexpr FXBits() = default; @@ -74,6 +81,12 @@ template struct FXBits { return (value & INTEGRAL_MASK) >> INTEGRAL_OFFSET; } + // returns complete bitstring representation the fixed point number + // the bitstring is of the form: padding | sign | integral | fraction + LIBC_INLINE constexpr StorageType get_bits() { + return (value & TOTAL_MASK) >> FRACTION_OFFSET; + } + // TODO: replace bool with Sign LIBC_INLINE constexpr bool get_sign() { return static_cast((value & SIGN_MASK) >> SIGN_OFFSET); @@ -163,6 +176,26 @@ template LIBC_INLINE constexpr T round(T x, int n) { return bit_and((x + round_bit), rounding_mask); } +// count leading zeros +template +LIBC_INLINE constexpr cpp::enable_if_t, int> +countls(T f) { + using FXRep = FXRep; + using BitType = typename FXRep::StorageType; + using FXBits = FXBits; + + constexpr int CONTAIN_LEN = cpp::numeric_limits::digits; + constexpr int PADDING_LEN = CONTAIN_LEN - (FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN); + + if constexpr (FXRep::SIGN_LEN != 0) { + if (x < 0) + x = bit_not(x); + } + + BitType value_bits = FXBits(x)::get_bits(); + return cpp::countl_zero(value_bits) - PADDING_LEN; +} + } // namespace fixed_point } // namespace LIBC_NAMESPACE_DECL >From cddf53e4c4951d8368c645c8250188afcf061085 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Sun, 2 Feb 2025 01:04:11 +0530 Subject: [PATCH 2/7] chore: add `limits.h` header to CmakeLists.txt --- libc/src/__support/fixed_point/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/libc/src/__support/fixed_point/CMakeLists.txt b/libc/src/__support/fixed_point/CMakeLists.txt index 3b744081765e4fa..b415e2c00c488c8 100644 --- a/libc/src/__support/fixed_point/CMakeLists.txt +++ b/libc/src/__support/fixed_point/CMakeLists.txt @@ -19,6 +19,7 @@ add_header_library( libc.src.__support.macros.optimization libc.src.__support.CPP.type_traits libc.src.__support.CPP.bit + libc.src.__support.CPP.limits libc.src.__support.math_extras ) >From bcccd52d31589f230cbd309239daca9235792341 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Sun, 2 Feb 2025 01:15:23 +0530 Subject: [PATCH 3/7] add: `countlsfx` functions --- libc/src/stdfix/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ libc/src/stdfix/countlshk.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlshk.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlshr.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlshr.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlsk.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlsk.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlslk.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlslk.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlslr.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlslr.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlsr.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlsr.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlsuhk.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlsuhk.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlsuhr.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlsuhr.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlsuk.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlsuk.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlsulk.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlsulk.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlsulr.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlsulr.h | 21 +++++++++++++++++++++ libc/src/stdfix/countlsur.cpp | 20 ++++++++++++++++++++ libc/src/stdfix/countlsur.h | 21 +++++++++++++++++++++ 25 files changed, 522 insertions(+) create mode 100644 libc/src/stdfix/countlshk.cpp create mode 100644 libc/src/stdfix/countlshk.h create mode 100644 libc/src/stdfix/countlshr.cpp create mode 100644 libc/src/stdfix/countlshr.h create mode 100644 libc/src/stdfix/countlsk.cpp create mode 100644 libc/src/stdfix/countlsk.h create mode 100644 libc/src/stdfix/countlslk.cpp create mode 100644 libc/src/stdfix/countlslk.h create mode 100644 libc/src/stdfix/countlslr.cpp create mode 100644 libc/src/stdfix/countlslr.h create mode 100644 libc/src/stdfix/countlsr.cpp create mode 100644 libc/src/stdfix/countlsr.h create mode 100644 libc/src/stdfix/countlsuhk.cpp create mode 100644 libc/src/stdfix/countlsuhk.h create mode 100644 libc/src/stdfix/countlsuhr.cpp create mode 100644 libc/src/stdfix/countlsuhr.h create mode 100644 libc/src/stdfix/countlsuk.cpp create mode 100644 libc/src/stdfix/countlsuk.h create mode 100644 libc/src/stdfix/countlsulk.cpp create mode 100644 libc/src/stdfix/countlsulk.h create mode 100644 libc/src/stdfix/countlsulr.cpp create mode 100644 libc/src/stdfix/countlsulr.h create mode 100644 libc/src/stdfix/countlsur.cpp create mode 100644 libc/src/stdfix/countlsur.h diff --git a/libc/src/stdfix/CMakeLists.txt b/libc/src/stdfix/CMakeLists.txt index 815f739d23efa40..ac5b31320a1050f 100644 --- a/libc/src/stdfix/CMakeLists.txt +++ b/libc/src/stdfix/CMakeLists.txt @@ -104,3 +104,33 @@ add_entrypoint_object( libc.src.__support.fixed_point.fx_rep libc.src.__support.CPP.bit ) + + +foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk) + add_entrypoint_object( + countls${suffix} + HDRS + countls${suffix}.h + SRCS + countls${suffix}.cpp + COMPILE_OPTIONS + ${libc_opt_high_flag} + DEPENDS + libc.src.__support.fixed_point.fx_bits + ) + if(LIBC_COMPILER_HAS_PADDING_ON_UNSIGNED_FIXED_POINT) + add_entrypoint_object( + countls${suffix}_padding_on_unsigned_fixed_point + HDRS + countls${suffix}.h + SRCS + countls${suffix}.cpp + COMPILE_OPTIONS + ${libc_opt_high_flag} + -Xclang=-fpadding-on-unsigned-fixed-point + DEPENDS + libc.src.__support.fixed_point.fx_bits + ) + endif() + +endforeach() diff --git a/libc/src/stdfix/countlshk.cpp b/libc/src/stdfix/countlshk.cpp new file mode 100644 index 000000000000000..65230dd688a7cab --- /dev/null +++ b/libc/src/stdfix/countlshk.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlshk function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlshk.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlshk, (short accum f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlshk.h b/libc/src/stdfix/countlshk.h new file mode 100644 index 000000000000000..ecbc9075dcedf5e --- /dev/null +++ b/libc/src/stdfix/countlshk.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlshk function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSHK_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSHK_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlshk(short accum f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSHK_H diff --git a/libc/src/stdfix/countlshr.cpp b/libc/src/stdfix/countlshr.cpp new file mode 100644 index 000000000000000..d07bab8c4a1cd5a --- /dev/null +++ b/libc/src/stdfix/countlshr.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlshr function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlshr.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlshr, (short fract f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlshr.h b/libc/src/stdfix/countlshr.h new file mode 100644 index 000000000000000..728b6873159184a --- /dev/null +++ b/libc/src/stdfix/countlshr.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlshr function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSHR_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSHR_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlshr(short fract f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSHR_H diff --git a/libc/src/stdfix/countlsk.cpp b/libc/src/stdfix/countlsk.cpp new file mode 100644 index 000000000000000..87c009aba0cb5b2 --- /dev/null +++ b/libc/src/stdfix/countlsk.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlsk function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlsk.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlsk, (accum f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsk.h b/libc/src/stdfix/countlsk.h new file mode 100644 index 000000000000000..b7012da95a9c923 --- /dev/null +++ b/libc/src/stdfix/countlsk.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlsk function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSK_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSK_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlsk(accum f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSK_H diff --git a/libc/src/stdfix/countlslk.cpp b/libc/src/stdfix/countlslk.cpp new file mode 100644 index 000000000000000..16120b2f55a11df --- /dev/null +++ b/libc/src/stdfix/countlslk.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlslk function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlslk.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlslk, (long accum f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlslk.h b/libc/src/stdfix/countlslk.h new file mode 100644 index 000000000000000..90a2ccc33ce6414 --- /dev/null +++ b/libc/src/stdfix/countlslk.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlslk function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSLK_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSLK_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlslk(long accum f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSLK_H diff --git a/libc/src/stdfix/countlslr.cpp b/libc/src/stdfix/countlslr.cpp new file mode 100644 index 000000000000000..9e0369db3b4a0df --- /dev/null +++ b/libc/src/stdfix/countlslr.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlslr function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlslr.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlslr, (long fract f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlslr.h b/libc/src/stdfix/countlslr.h new file mode 100644 index 000000000000000..b1565b7024e7c11 --- /dev/null +++ b/libc/src/stdfix/countlslr.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlslr function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSLR_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSLR_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlslr(long fract f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSLR_H diff --git a/libc/src/stdfix/countlsr.cpp b/libc/src/stdfix/countlsr.cpp new file mode 100644 index 000000000000000..d18e673a3066dc5 --- /dev/null +++ b/libc/src/stdfix/countlsr.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlsr function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlsr.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlsr, (fract f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsr.h b/libc/src/stdfix/countlsr.h new file mode 100644 index 000000000000000..c50bd0a773e577f --- /dev/null +++ b/libc/src/stdfix/countlsr.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlsr function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSR_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSR_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlsr(fract f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSR_H diff --git a/libc/src/stdfix/countlsuhk.cpp b/libc/src/stdfix/countlsuhk.cpp new file mode 100644 index 000000000000000..8a24508b83bcbbe --- /dev/null +++ b/libc/src/stdfix/countlsuhk.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlsuhk function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlsuhk.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlsuhk, (unsigned short accum f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsuhk.h b/libc/src/stdfix/countlsuhk.h new file mode 100644 index 000000000000000..fcb2fec3500d4c0 --- /dev/null +++ b/libc/src/stdfix/countlsuhk.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlsuhk function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSUHK_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSUHK_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlsuhk(unsigned short accum f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSUHK_H diff --git a/libc/src/stdfix/countlsuhr.cpp b/libc/src/stdfix/countlsuhr.cpp new file mode 100644 index 000000000000000..6dec26c788cd905 --- /dev/null +++ b/libc/src/stdfix/countlsuhr.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlsuhr function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlsuhr.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlsuhr, (unsigned short fract f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsuhr.h b/libc/src/stdfix/countlsuhr.h new file mode 100644 index 000000000000000..c6ce001d38b1108 --- /dev/null +++ b/libc/src/stdfix/countlsuhr.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlsuhr function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSUHR_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSUHR_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlsuhr(unsigned long fract f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSUHR_H diff --git a/libc/src/stdfix/countlsuk.cpp b/libc/src/stdfix/countlsuk.cpp new file mode 100644 index 000000000000000..98ebf096940e465 --- /dev/null +++ b/libc/src/stdfix/countlsuk.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlsuhk function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlsuhk.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlsuhk, (unsigned accum f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsuk.h b/libc/src/stdfix/countlsuk.h new file mode 100644 index 000000000000000..b912e75fb900285 --- /dev/null +++ b/libc/src/stdfix/countlsuk.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlsuk function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSUK_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSUK_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlsuk(unsigned accum f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSUK_H diff --git a/libc/src/stdfix/countlsulk.cpp b/libc/src/stdfix/countlsulk.cpp new file mode 100644 index 000000000000000..043c919a653eafc --- /dev/null +++ b/libc/src/stdfix/countlsulk.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlsulk function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlsulk.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlsulk, (unsigned long accum f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsulk.h b/libc/src/stdfix/countlsulk.h new file mode 100644 index 000000000000000..55ca9d2e20ff0fc --- /dev/null +++ b/libc/src/stdfix/countlsulk.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlsulk function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSULK_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSULK_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlsulk(unsigned long accum f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSULK_H diff --git a/libc/src/stdfix/countlsulr.cpp b/libc/src/stdfix/countlsulr.cpp new file mode 100644 index 000000000000000..a77eaeabce69f3c --- /dev/null +++ b/libc/src/stdfix/countlsulr.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlsulr function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlsulr.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlsulr, (unsigned long fract f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsulr.h b/libc/src/stdfix/countlsulr.h new file mode 100644 index 000000000000000..59e7d726d01b924 --- /dev/null +++ b/libc/src/stdfix/countlsulr.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlsulr function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSULR_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSULR_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlsulr(unsigned long fract f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSULR_H diff --git a/libc/src/stdfix/countlsur.cpp b/libc/src/stdfix/countlsur.cpp new file mode 100644 index 000000000000000..6dcb54bdca4424c --- /dev/null +++ b/libc/src/stdfix/countlsur.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlsur function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlsur.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlsur, (unsigned fract f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsur.h b/libc/src/stdfix/countlsur.h new file mode 100644 index 000000000000000..85dec93bbcd5c50 --- /dev/null +++ b/libc/src/stdfix/countlsur.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlsur function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSUR_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSUR_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlsur(unsigned fract f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSUR_H >From 647a16c06f5d275a5683b5e7a12cb6e8af16d22f Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Sun, 2 Feb 2025 01:17:14 +0530 Subject: [PATCH 4/7] chore: add `padding_on_unsigned_fixed_point` --- .../cmake/modules/CheckCompilerFeatures.cmake | 5 ++ .../check_padding_on_unsigned_fixed_point.cpp | 5 ++ libc/include/stdfix.yaml | 84 +++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp diff --git a/libc/cmake/modules/CheckCompilerFeatures.cmake b/libc/cmake/modules/CheckCompilerFeatures.cmake index a5ea66a5935b7bf..ccb0e4bfc509764 100644 --- a/libc/cmake/modules/CheckCompilerFeatures.cmake +++ b/libc/cmake/modules/CheckCompilerFeatures.cmake @@ -15,6 +15,7 @@ set( "fixed_point" "cfloat16" "cfloat128" + "padding_on_unsigned_fixed_point" ) # Making sure ALL_COMPILER_FEATURES is sorted. @@ -64,6 +65,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) set(link_options "") if(${feature} STREQUAL "fixed_point") list(APPEND compile_options "-ffixed-point") + elseif(${feature} STREQUAL "padding_on_unsigned_fixed_point") + list(APPEND compile_options "-ffixed-point -Xclang=-fpadding-on-unsigned-fixed-point") elseif(${feature} MATCHES "^builtin_" OR ${feature} STREQUAL "float16_conversion") set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT}) @@ -112,6 +115,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) set(LIBC_TYPES_HAS_FLOAT128 TRUE) elseif(${feature} STREQUAL "fixed_point") set(LIBC_COMPILER_HAS_FIXED_POINT TRUE) + elseif(${feature} STREQUAL "padding_on_unsigned_fixed_point") + set(LIBC_COMPILER_HAS_PADDING_ON_UNSIGNED_FIXED_POINT TRUE) elseif(${feature} STREQUAL "cfloat16") set(LIBC_TYPES_HAS_CFLOAT16 TRUE) elseif(${feature} STREQUAL "cfloat128") diff --git a/libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp b/libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp new file mode 100644 index 000000000000000..40b4da8c79621d5 --- /dev/null +++ b/libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp @@ -0,0 +1,5 @@ +#include "include/llvm-libc-macros/stdfix-macros.h" + +#ifndef LIBC_COMPILER_HAS_PADDING_ON_UNSIGNED_FIXED_POINT +#error unsupported +#endif diff --git a/libc/include/stdfix.yaml b/libc/include/stdfix.yaml index 9663ac0c7df4dce..0abf2f3a9b3b6de 100644 --- a/libc/include/stdfix.yaml +++ b/libc/include/stdfix.yaml @@ -306,3 +306,87 @@ functions: arguments: - type: unsigned int guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlshr + standards: + - stdc_ext + return_type: int + arguments: + - type: short fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsr + standards: + - stdc_ext + return_type: int + arguments: + - type: fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlslr + standards: + - stdc_ext + return_type: int + arguments: + - type: long fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlshk + standards: + - stdc_ext + return_type: int + arguments: + - type: short accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsk + standards: + - stdc_ext + return_type: int + arguments: + - type: accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlslk + standards: + - stdc_ext + return_type: int + arguments: + - type: long accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsuhr + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned short fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsur + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsulr + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned long fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsuhk + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned short accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsuk + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsulk + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned long accum + guard: LIBC_COMPILER_HAS_FIXED_POINT >From ca4d5325bc1cb45620b166a809661ad701e3bdc2 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Sun, 2 Feb 2025 01:18:16 +0530 Subject: [PATCH 5/7] chore: add entrypoints --- libc/config/baremetal/arm/entrypoints.txt | 12 ++++++++++++ libc/config/baremetal/riscv/entrypoints.txt | 12 ++++++++++++ libc/config/linux/riscv/entrypoints.txt | 12 ++++++++++++ libc/config/linux/x86_64/entrypoints.txt | 12 ++++++++++++ 4 files changed, 48 insertions(+) diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt index 694cd7b1993ca22..351f727389e3abb 100644 --- a/libc/config/baremetal/arm/entrypoints.txt +++ b/libc/config/baremetal/arm/entrypoints.txt @@ -469,6 +469,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT) libc.src.stdfix.ukbits libc.src.stdfix.lkbits libc.src.stdfix.ulkbits + libc.src.stdfix.countlshr + libc.src.stdfix.countlsr + libc.src.stdfix.countlslr + libc.src.stdfix.countlshk + libc.src.stdfix.countlsk + libc.src.stdfix.countlslk + libc.src.stdfix.countlsuhr + libc.src.stdfix.countlsur + libc.src.stdfix.countlsulr + libc.src.stdfix.countlsuhk + libc.src.stdfix.countlsuk + libc.src.stdfix.countlsulk ) endif() diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt index 667ab40dca99985..39c70a22a21e0eb 100644 --- a/libc/config/baremetal/riscv/entrypoints.txt +++ b/libc/config/baremetal/riscv/entrypoints.txt @@ -464,6 +464,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT) libc.src.stdfix.ukbits libc.src.stdfix.lkbits libc.src.stdfix.ulkbits + libc.src.stdfix.countlshr + libc.src.stdfix.countlsr + libc.src.stdfix.countlslr + libc.src.stdfix.countlshk + libc.src.stdfix.countlsk + libc.src.stdfix.countlslk + libc.src.stdfix.countlsuhr + libc.src.stdfix.countlsur + libc.src.stdfix.countlsulr + libc.src.stdfix.countlsuhk + libc.src.stdfix.countlsuk + libc.src.stdfix.countlsulk ) endif() diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index 14a05a2f3fbf2a8..cb68fb077a869cb 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -744,6 +744,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT) # TODO: https://github.com/llvm/llvm-project/issues/115778 libc.src.stdfix.lkbits libc.src.stdfix.ulkbits + libc.src.stdfix.countlshr + libc.src.stdfix.countlsr + libc.src.stdfix.countlslr + libc.src.stdfix.countlshk + libc.src.stdfix.countlsk + libc.src.stdfix.countlslk + libc.src.stdfix.countlsuhr + libc.src.stdfix.countlsur + libc.src.stdfix.countlsulr + libc.src.stdfix.countlsuhk + libc.src.stdfix.countlsuk + libc.src.stdfix.countlsulk ) endif() diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 366e4d34294d15e..ea276f3c963867a 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -869,6 +869,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT) libc.src.stdfix.ukbits libc.src.stdfix.lkbits libc.src.stdfix.ulkbits + libc.src.stdfix.countlshr + libc.src.stdfix.countlsr + libc.src.stdfix.countlslr + libc.src.stdfix.countlshk + libc.src.stdfix.countlsk + libc.src.stdfix.countlslk + libc.src.stdfix.countlsuhr + libc.src.stdfix.countlsur + libc.src.stdfix.countlsulr + libc.src.stdfix.countlsuhk + libc.src.stdfix.countlsuk + libc.src.stdfix.countlsulk ) endif() >From 5c2894f6ef1e47aa75933f40f27bb244326dcd35 Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Sun, 2 Feb 2025 01:18:52 +0530 Subject: [PATCH 6/7] add: unit tests for `countlsfx` functions --- libc/test/src/stdfix/CMakeLists.txt | 35 +++++++++++++ libc/test/src/stdfix/CountlsTest.h | 63 ++++++++++++++++++++++++ libc/test/src/stdfix/countlshk_test.cpp | 13 +++++ libc/test/src/stdfix/countlshr_test.cpp | 13 +++++ libc/test/src/stdfix/countlsk_test.cpp | 13 +++++ libc/test/src/stdfix/countlslk_test.cpp | 13 +++++ libc/test/src/stdfix/countlslr_test.cpp | 13 +++++ libc/test/src/stdfix/countlsr_test.cpp | 13 +++++ libc/test/src/stdfix/countlsuhk_test.cpp | 13 +++++ libc/test/src/stdfix/countlsuhr_test.cpp | 13 +++++ libc/test/src/stdfix/countlsuk_test.cpp | 13 +++++ libc/test/src/stdfix/countlsulk_test.cpp | 13 +++++ libc/test/src/stdfix/countlsulr_test.cpp | 13 +++++ libc/test/src/stdfix/countlsur_test.cpp | 13 +++++ 14 files changed, 254 insertions(+) create mode 100644 libc/test/src/stdfix/CountlsTest.h create mode 100644 libc/test/src/stdfix/countlshk_test.cpp create mode 100644 libc/test/src/stdfix/countlshr_test.cpp create mode 100644 libc/test/src/stdfix/countlsk_test.cpp create mode 100644 libc/test/src/stdfix/countlslk_test.cpp create mode 100644 libc/test/src/stdfix/countlslr_test.cpp create mode 100644 libc/test/src/stdfix/countlsr_test.cpp create mode 100644 libc/test/src/stdfix/countlsuhk_test.cpp create mode 100644 libc/test/src/stdfix/countlsuhr_test.cpp create mode 100644 libc/test/src/stdfix/countlsuk_test.cpp create mode 100644 libc/test/src/stdfix/countlsulk_test.cpp create mode 100644 libc/test/src/stdfix/countlsulr_test.cpp create mode 100644 libc/test/src/stdfix/countlsur_test.cpp diff --git a/libc/test/src/stdfix/CMakeLists.txt b/libc/test/src/stdfix/CMakeLists.txt index 90d20438edb4bec..6d111038be5b17b 100644 --- a/libc/test/src/stdfix/CMakeLists.txt +++ b/libc/test/src/stdfix/CMakeLists.txt @@ -73,6 +73,41 @@ foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk) libc.src.__support.CPP.bit libc.src.__support.fixed_point.fx_bits ) + + add_libc_test( + countls${suffix}_test + SUITE + libc-stdfix-tests + HDRS + CountlsTest.h + SRCS + countls${suffix}_test.cpp + COMPILE_OPTIONS + -O3 + DEPENDS + libc.src.stdfix.countls${suffix} + libc.src.__support.fixed_point.fx_rep + libc.src.__support.fixed_point.fx_bits + + if(LIBC_COMPILER_HAS_PADDING_ON_UNSIGNED_FIXED_POINT) + add_libc_test( + countls${suffix}_padding_on_unsigned_fixed_point_test + SUITE + libc-stdfix-tests + HDRS + CountlsTest.h + SRCS + countls${suffix}_test.cpp + COMPILE_OPTIONS + -O3 + -Xclang=-fpadding-on-unsigned-fixed-point + DEPENDS + libc.src.stdfix.countls${suffix}_padding_on_unsigned_fixed_point + libc.src.__support.fixed_point.fx_rep + libc.src.__support.fixed_point.fx_bits + ) + endif() + ) endforeach() add_libc_test( diff --git a/libc/test/src/stdfix/CountlsTest.h b/libc/test/src/stdfix/CountlsTest.h new file mode 100644 index 000000000000000..d4a4083591730dd --- /dev/null +++ b/libc/test/src/stdfix/CountlsTest.h @@ -0,0 +1,63 @@ +//===-- Utility class to test countls -------------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "test/UnitTest/Test.h" + +#include "src/__support/fixed_point/fx_rep.h" + +template class CountlsTest : public LIBC_NAMESPACE::testing::Test { + + using FXRep = LIBC_NAMESPACE::fixed_point::FXRep; + static constexpr T zero = FXRep::ZERO(); + static constexpr T max = FXRep::MAX(); + static constexpr T min = FXRep::MIN(); + static constexpr T one_half = FXRep::ONE_HALF(); + static constexpr T one_fourth = FXRep::ONE_FOURTH(); + static constexpr T eps = FXRep::EPS(); + + static constexpr auto value_len = + FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN; + +public: + typedef int (*CountlsFunc)(T); + + void testSpecialNumbers(CountlsFunc func) { + constexpr bool is_signed = (FXRep::SIGN_LEN > 0); + + EXPECT_EQ(FXRep::INTEGRAL_LEN, func(one_half)); + EXPECT_EQ(FXRep::INTEGRAL_LEN + 1, func(one_fourth)); + EXPECT_EQ(value_len, func(zero)); + EXPECT_EQ(value_len - 1, func(eps)); + EXPECT_EQ(0, func(max)); + // If signed, left shifting the minimum value will overflow, so countls = 0. + // If unsigned, the minimum value is zero, so countls is the number of value + // bits according to ISO/IEC TR 18037. + EXPECT_EQ(is_signed ? 0 : value_len, func(min)); + + if (10 <= static_cast(max)) { + EXPECT_EQ(FXRep::INTEGRAL_LEN - 4, func(10)); + } + + if (static_cast(min) <= -10) { + EXPECT_EQ(FXRep::INTEGRAL_LEN - 4, func(-10)); + } + + if constexpr (is_signed) { + EXPECT_EQ(value_len, func(-eps)); + EXPECT_EQ(FXRep::INTEGRAL_LEN + 1, func(-one_half)); + if (FXRep::FRACTION_LEN >= 2) { + EXPECT_EQ(FXRep::INTEGRAL_LEN + 2, func(-one_fourth)); + } + } + } +}; + +#define LIST_COUNTLS_TESTS(T, func) \ + using LlvmLibcCountlsTest = CountlsTest; \ + TEST_F(LlvmLibcCountlsTest, SpecialNumbers) { testSpecialNumbers(&func); } \ + static_assert(true, "Require semicolon.") \ No newline at end of file diff --git a/libc/test/src/stdfix/countlshk_test.cpp b/libc/test/src/stdfix/countlshk_test.cpp new file mode 100644 index 000000000000000..d5654981f91b7b4 --- /dev/null +++ b/libc/test/src/stdfix/countlshk_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlshk ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlshk.h" + +LIST_COUNTLS_TESTS(short accum, LIBC_NAMESPACE::countlshk); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlshr_test.cpp b/libc/test/src/stdfix/countlshr_test.cpp new file mode 100644 index 000000000000000..2021553be7e6cb9 --- /dev/null +++ b/libc/test/src/stdfix/countlshr_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlshr ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlshr.h" + +LIST_COUNTLS_TESTS(short fract, LIBC_NAMESPACE::countlshr); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlsk_test.cpp b/libc/test/src/stdfix/countlsk_test.cpp new file mode 100644 index 000000000000000..e7c71add68fa6ba --- /dev/null +++ b/libc/test/src/stdfix/countlsk_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlsk ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlsk.h" + +LIST_COUNTLS_TESTS(accum, LIBC_NAMESPACE::countlsk); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlslk_test.cpp b/libc/test/src/stdfix/countlslk_test.cpp new file mode 100644 index 000000000000000..4c7f2970733ea02 --- /dev/null +++ b/libc/test/src/stdfix/countlslk_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlslk ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlslk.h" + +LIST_COUNTLS_TESTS(long accum, LIBC_NAMESPACE::countlslk); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlslr_test.cpp b/libc/test/src/stdfix/countlslr_test.cpp new file mode 100644 index 000000000000000..93b33597b944287 --- /dev/null +++ b/libc/test/src/stdfix/countlslr_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlslr ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlslr.h" + +LIST_COUNTLS_TESTS(long fract, LIBC_NAMESPACE::countlslr); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlsr_test.cpp b/libc/test/src/stdfix/countlsr_test.cpp new file mode 100644 index 000000000000000..d465c2e1eae011b --- /dev/null +++ b/libc/test/src/stdfix/countlsr_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlsr ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlsr.h" + +LIST_COUNTLS_TESTS(fract, LIBC_NAMESPACE::countlsr); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlsuhk_test.cpp b/libc/test/src/stdfix/countlsuhk_test.cpp new file mode 100644 index 000000000000000..b72328b5b1a90a4 --- /dev/null +++ b/libc/test/src/stdfix/countlsuhk_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlsuhk ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlsuhk.h" + +LIST_COUNTLS_TESTS(unsigned short accum, LIBC_NAMESPACE::countlsuhk); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlsuhr_test.cpp b/libc/test/src/stdfix/countlsuhr_test.cpp new file mode 100644 index 000000000000000..b82e10501733062 --- /dev/null +++ b/libc/test/src/stdfix/countlsuhr_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlsuhr ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlsuhr.h" + +LIST_COUNTLS_TESTS(unsigned short fract, LIBC_NAMESPACE::countlsuhr); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlsuk_test.cpp b/libc/test/src/stdfix/countlsuk_test.cpp new file mode 100644 index 000000000000000..5ca66822fe6fbbb --- /dev/null +++ b/libc/test/src/stdfix/countlsuk_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlsuk ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlsuk.h" + +LIST_COUNTLS_TESTS(unsigned accum, LIBC_NAMESPACE::countlsuk); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlsulk_test.cpp b/libc/test/src/stdfix/countlsulk_test.cpp new file mode 100644 index 000000000000000..762d4924bac4896 --- /dev/null +++ b/libc/test/src/stdfix/countlsulk_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlsulk ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlsulk.h" + +LIST_COUNTLS_TESTS(unsigned long accum, LIBC_NAMESPACE::countlsulk); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlsulr_test.cpp b/libc/test/src/stdfix/countlsulr_test.cpp new file mode 100644 index 000000000000000..62c06b233e674ac --- /dev/null +++ b/libc/test/src/stdfix/countlsulr_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlsulr ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlsulr.h" + +LIST_COUNTLS_TESTS(unsigned long fract, LIBC_NAMESPACE::countlsulr); \ No newline at end of file diff --git a/libc/test/src/stdfix/countlsur_test.cpp b/libc/test/src/stdfix/countlsur_test.cpp new file mode 100644 index 000000000000000..49236db25d40a88 --- /dev/null +++ b/libc/test/src/stdfix/countlsur_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for countlsur ----------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "CountlsTest.h" + +#include "src/stdfix/countlsur.h" + +LIST_COUNTLS_TESTS(unsigned fract, LIBC_NAMESPACE::countlsur); \ No newline at end of file >From 519ae5df684c9f850688048aa80abfaccc1ddaac Mon Sep 17 00:00:00 2001 From: krishna2803 Date: Sun, 2 Feb 2025 01:19:06 +0530 Subject: [PATCH 7/7] chore: documentation update --- libc/docs/headers/math/stdfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/docs/headers/math/stdfix.rst b/libc/docs/headers/math/stdfix.rst index 58052f000995cd9..4507f2b608bf1f8 100644 --- a/libc/docs/headers/math/stdfix.rst +++ b/libc/docs/headers/math/stdfix.rst @@ -73,7 +73,7 @@ The following functions are included in the ISO/IEC TR 18037:2008 standard. +---------------+----------------+-------------+---------------+------------+----------------+-------------+----------------+-------------+---------------+------------+----------------+-------------+ | \*bits | | | | | | | | | | | | | +---------------+----------------+-------------+---------------+------------+----------------+-------------+----------------+-------------+---------------+------------+----------------+-------------+ -| countls | | | | | | | | | | | | | +| countls | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | +---------------+----------------+-------------+---------------+------------+----------------+-------------+----------------+-------------+---------------+------------+----------------+-------------+ | divi | | | | | | | | | | | | | +---------------+----------------+-------------+---------------+------------+----------------+-------------+----------------+-------------+---------------+------------+----------------+-------------+ From libc-commits at lists.llvm.org Sat Feb 1 11:59:16 2025 From: libc-commits at lists.llvm.org (via libc-commits) Date: Sat, 01 Feb 2025 11:59:16 -0800 (PST) Subject: [libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356) In-Reply-To: Message-ID: <679e7d14.050a0220.262698.2e88@mx.google.com> github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/125356 From libc-commits at lists.llvm.org Sat Feb 1 11:59:51 2025 From: libc-commits at lists.llvm.org (via libc-commits) Date: Sat, 01 Feb 2025 11:59:51 -0800 (PST) Subject: [libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356) In-Reply-To: Message-ID: <679e7d37.050a0220.c2623.186a@mx.google.com> llvmbot wrote: @llvm/pr-subscribers-libc Author: Krishna Pandey (krishna2803)
Changes fixes #113357 --- Patch is 47.47 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/125356.diff 49 Files Affected: - (modified) libc/cmake/modules/CheckCompilerFeatures.cmake (+5) - (added) libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp (+5) - (modified) libc/config/baremetal/arm/entrypoints.txt (+12) - (modified) libc/config/baremetal/riscv/entrypoints.txt (+12) - (modified) libc/config/linux/riscv/entrypoints.txt (+12) - (modified) libc/config/linux/x86_64/entrypoints.txt (+12) - (modified) libc/docs/headers/math/stdfix.rst (+1-1) - (modified) libc/include/stdfix.yaml (+84) - (modified) libc/src/__support/fixed_point/CMakeLists.txt (+1) - (modified) libc/src/__support/fixed_point/fx_bits.h (+34-1) - (modified) libc/src/stdfix/CMakeLists.txt (+30) - (added) libc/src/stdfix/countlshk.cpp (+20) - (added) libc/src/stdfix/countlshk.h (+21) - (added) libc/src/stdfix/countlshr.cpp (+20) - (added) libc/src/stdfix/countlshr.h (+21) - (added) libc/src/stdfix/countlsk.cpp (+20) - (added) libc/src/stdfix/countlsk.h (+21) - (added) libc/src/stdfix/countlslk.cpp (+20) - (added) libc/src/stdfix/countlslk.h (+21) - (added) libc/src/stdfix/countlslr.cpp (+20) - (added) libc/src/stdfix/countlslr.h (+21) - (added) libc/src/stdfix/countlsr.cpp (+20) - (added) libc/src/stdfix/countlsr.h (+21) - (added) libc/src/stdfix/countlsuhk.cpp (+20) - (added) libc/src/stdfix/countlsuhk.h (+21) - (added) libc/src/stdfix/countlsuhr.cpp (+20) - (added) libc/src/stdfix/countlsuhr.h (+21) - (added) libc/src/stdfix/countlsuk.cpp (+20) - (added) libc/src/stdfix/countlsuk.h (+21) - (added) libc/src/stdfix/countlsulk.cpp (+20) - (added) libc/src/stdfix/countlsulk.h (+21) - (added) libc/src/stdfix/countlsulr.cpp (+20) - (added) libc/src/stdfix/countlsulr.h (+21) - (added) libc/src/stdfix/countlsur.cpp (+20) - (added) libc/src/stdfix/countlsur.h (+21) - (modified) libc/test/src/stdfix/CMakeLists.txt (+35) - (added) libc/test/src/stdfix/CountlsTest.h (+63) - (added) libc/test/src/stdfix/countlshk_test.cpp (+13) - (added) libc/test/src/stdfix/countlshr_test.cpp (+13) - (added) libc/test/src/stdfix/countlsk_test.cpp (+13) - (added) libc/test/src/stdfix/countlslk_test.cpp (+13) - (added) libc/test/src/stdfix/countlslr_test.cpp (+13) - (added) libc/test/src/stdfix/countlsr_test.cpp (+13) - (added) libc/test/src/stdfix/countlsuhk_test.cpp (+13) - (added) libc/test/src/stdfix/countlsuhr_test.cpp (+13) - (added) libc/test/src/stdfix/countlsuk_test.cpp (+13) - (added) libc/test/src/stdfix/countlsulk_test.cpp (+13) - (added) libc/test/src/stdfix/countlsulr_test.cpp (+13) - (added) libc/test/src/stdfix/countlsur_test.cpp (+13) ``````````diff diff --git a/libc/cmake/modules/CheckCompilerFeatures.cmake b/libc/cmake/modules/CheckCompilerFeatures.cmake index a5ea66a5935b7b..ccb0e4bfc50976 100644 --- a/libc/cmake/modules/CheckCompilerFeatures.cmake +++ b/libc/cmake/modules/CheckCompilerFeatures.cmake @@ -15,6 +15,7 @@ set( "fixed_point" "cfloat16" "cfloat128" + "padding_on_unsigned_fixed_point" ) # Making sure ALL_COMPILER_FEATURES is sorted. @@ -64,6 +65,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) set(link_options "") if(${feature} STREQUAL "fixed_point") list(APPEND compile_options "-ffixed-point") + elseif(${feature} STREQUAL "padding_on_unsigned_fixed_point") + list(APPEND compile_options "-ffixed-point -Xclang=-fpadding-on-unsigned-fixed-point") elseif(${feature} MATCHES "^builtin_" OR ${feature} STREQUAL "float16_conversion") set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT}) @@ -112,6 +115,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) set(LIBC_TYPES_HAS_FLOAT128 TRUE) elseif(${feature} STREQUAL "fixed_point") set(LIBC_COMPILER_HAS_FIXED_POINT TRUE) + elseif(${feature} STREQUAL "padding_on_unsigned_fixed_point") + set(LIBC_COMPILER_HAS_PADDING_ON_UNSIGNED_FIXED_POINT TRUE) elseif(${feature} STREQUAL "cfloat16") set(LIBC_TYPES_HAS_CFLOAT16 TRUE) elseif(${feature} STREQUAL "cfloat128") diff --git a/libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp b/libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp new file mode 100644 index 00000000000000..40b4da8c79621d --- /dev/null +++ b/libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp @@ -0,0 +1,5 @@ +#include "include/llvm-libc-macros/stdfix-macros.h" + +#ifndef LIBC_COMPILER_HAS_PADDING_ON_UNSIGNED_FIXED_POINT +#error unsupported +#endif diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt index 694cd7b1993ca2..351f727389e3ab 100644 --- a/libc/config/baremetal/arm/entrypoints.txt +++ b/libc/config/baremetal/arm/entrypoints.txt @@ -469,6 +469,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT) libc.src.stdfix.ukbits libc.src.stdfix.lkbits libc.src.stdfix.ulkbits + libc.src.stdfix.countlshr + libc.src.stdfix.countlsr + libc.src.stdfix.countlslr + libc.src.stdfix.countlshk + libc.src.stdfix.countlsk + libc.src.stdfix.countlslk + libc.src.stdfix.countlsuhr + libc.src.stdfix.countlsur + libc.src.stdfix.countlsulr + libc.src.stdfix.countlsuhk + libc.src.stdfix.countlsuk + libc.src.stdfix.countlsulk ) endif() diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt index 667ab40dca9998..39c70a22a21e0e 100644 --- a/libc/config/baremetal/riscv/entrypoints.txt +++ b/libc/config/baremetal/riscv/entrypoints.txt @@ -464,6 +464,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT) libc.src.stdfix.ukbits libc.src.stdfix.lkbits libc.src.stdfix.ulkbits + libc.src.stdfix.countlshr + libc.src.stdfix.countlsr + libc.src.stdfix.countlslr + libc.src.stdfix.countlshk + libc.src.stdfix.countlsk + libc.src.stdfix.countlslk + libc.src.stdfix.countlsuhr + libc.src.stdfix.countlsur + libc.src.stdfix.countlsulr + libc.src.stdfix.countlsuhk + libc.src.stdfix.countlsuk + libc.src.stdfix.countlsulk ) endif() diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index 14a05a2f3fbf2a..cb68fb077a869c 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -744,6 +744,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT) # TODO: https://github.com/llvm/llvm-project/issues/115778 libc.src.stdfix.lkbits libc.src.stdfix.ulkbits + libc.src.stdfix.countlshr + libc.src.stdfix.countlsr + libc.src.stdfix.countlslr + libc.src.stdfix.countlshk + libc.src.stdfix.countlsk + libc.src.stdfix.countlslk + libc.src.stdfix.countlsuhr + libc.src.stdfix.countlsur + libc.src.stdfix.countlsulr + libc.src.stdfix.countlsuhk + libc.src.stdfix.countlsuk + libc.src.stdfix.countlsulk ) endif() diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 366e4d34294d15..ea276f3c963867 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -869,6 +869,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT) libc.src.stdfix.ukbits libc.src.stdfix.lkbits libc.src.stdfix.ulkbits + libc.src.stdfix.countlshr + libc.src.stdfix.countlsr + libc.src.stdfix.countlslr + libc.src.stdfix.countlshk + libc.src.stdfix.countlsk + libc.src.stdfix.countlslk + libc.src.stdfix.countlsuhr + libc.src.stdfix.countlsur + libc.src.stdfix.countlsulr + libc.src.stdfix.countlsuhk + libc.src.stdfix.countlsuk + libc.src.stdfix.countlsulk ) endif() diff --git a/libc/docs/headers/math/stdfix.rst b/libc/docs/headers/math/stdfix.rst index 58052f000995cd..4507f2b608bf1f 100644 --- a/libc/docs/headers/math/stdfix.rst +++ b/libc/docs/headers/math/stdfix.rst @@ -73,7 +73,7 @@ The following functions are included in the ISO/IEC TR 18037:2008 standard. +---------------+----------------+-------------+---------------+------------+----------------+-------------+----------------+-------------+---------------+------------+----------------+-------------+ | \*bits | | | | | | | | | | | | | +---------------+----------------+-------------+---------------+------------+----------------+-------------+----------------+-------------+---------------+------------+----------------+-------------+ -| countls | | | | | | | | | | | | | +| countls | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | |check| | +---------------+----------------+-------------+---------------+------------+----------------+-------------+----------------+-------------+---------------+------------+----------------+-------------+ | divi | | | | | | | | | | | | | +---------------+----------------+-------------+---------------+------------+----------------+-------------+----------------+-------------+---------------+------------+----------------+-------------+ diff --git a/libc/include/stdfix.yaml b/libc/include/stdfix.yaml index 9663ac0c7df4dc..0abf2f3a9b3b6d 100644 --- a/libc/include/stdfix.yaml +++ b/libc/include/stdfix.yaml @@ -306,3 +306,87 @@ functions: arguments: - type: unsigned int guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlshr + standards: + - stdc_ext + return_type: int + arguments: + - type: short fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsr + standards: + - stdc_ext + return_type: int + arguments: + - type: fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlslr + standards: + - stdc_ext + return_type: int + arguments: + - type: long fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlshk + standards: + - stdc_ext + return_type: int + arguments: + - type: short accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsk + standards: + - stdc_ext + return_type: int + arguments: + - type: accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlslk + standards: + - stdc_ext + return_type: int + arguments: + - type: long accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsuhr + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned short fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsur + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsulr + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned long fract + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsuhk + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned short accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsuk + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned accum + guard: LIBC_COMPILER_HAS_FIXED_POINT + - name: countlsulk + standards: + - stdc_ext + return_type: int + arguments: + - type: unsigned long accum + guard: LIBC_COMPILER_HAS_FIXED_POINT diff --git a/libc/src/__support/fixed_point/CMakeLists.txt b/libc/src/__support/fixed_point/CMakeLists.txt index 3b744081765e4f..b415e2c00c488c 100644 --- a/libc/src/__support/fixed_point/CMakeLists.txt +++ b/libc/src/__support/fixed_point/CMakeLists.txt @@ -19,6 +19,7 @@ add_header_library( libc.src.__support.macros.optimization libc.src.__support.CPP.type_traits libc.src.__support.CPP.bit + libc.src.__support.CPP.limits libc.src.__support.math_extras ) diff --git a/libc/src/__support/fixed_point/fx_bits.h b/libc/src/__support/fixed_point/fx_bits.h index 225ea417760a03..a955ee67745c25 100644 --- a/libc/src/__support/fixed_point/fx_bits.h +++ b/libc/src/__support/fixed_point/fx_bits.h @@ -12,8 +12,9 @@ #include "include/llvm-libc-macros/stdfix-macros.h" #include "src/__support/CPP/bit.h" #include "src/__support/CPP/type_traits.h" +#include "src/__support/CPP/limits.h" // numeric_limits #include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY #include "src/__support/math_extras.h" @@ -50,6 +51,12 @@ template struct FXBits { static constexpr StorageType SIGN_MASK = (fx_rep::SIGN_LEN == 0 ? 0 : StorageType(1) << SIGN_OFFSET); + // mask for + static constexpr StorageType VALUE_MASK = INTEGRAL_MASK | FRACTION_MASK; + + // mask for + static constexpr StorageType TOTAL_MASK = SIGN_MASK | VALUE_MASK; + public: LIBC_INLINE constexpr FXBits() = default; @@ -74,6 +81,12 @@ template struct FXBits { return (value & INTEGRAL_MASK) >> INTEGRAL_OFFSET; } + // returns complete bitstring representation the fixed point number + // the bitstring is of the form: padding | sign | integral | fraction + LIBC_INLINE constexpr StorageType get_bits() { + return (value & TOTAL_MASK) >> FRACTION_OFFSET; + } + // TODO: replace bool with Sign LIBC_INLINE constexpr bool get_sign() { return static_cast((value & SIGN_MASK) >> SIGN_OFFSET); @@ -163,6 +176,26 @@ template LIBC_INLINE constexpr T round(T x, int n) { return bit_and((x + round_bit), rounding_mask); } +// count leading zeros +template +LIBC_INLINE constexpr cpp::enable_if_t, int> +countls(T f) { + using FXRep = FXRep; + using BitType = typename FXRep::StorageType; + using FXBits = FXBits; + + constexpr int CONTAIN_LEN = cpp::numeric_limits::digits; + constexpr int PADDING_LEN = CONTAIN_LEN - (FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN); + + if constexpr (FXRep::SIGN_LEN != 0) { + if (x < 0) + x = bit_not(x); + } + + BitType value_bits = FXBits(x)::get_bits(); + return cpp::countl_zero(value_bits) - PADDING_LEN; +} + } // namespace fixed_point } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/CMakeLists.txt b/libc/src/stdfix/CMakeLists.txt index 815f739d23efa4..ac5b31320a1050 100644 --- a/libc/src/stdfix/CMakeLists.txt +++ b/libc/src/stdfix/CMakeLists.txt @@ -104,3 +104,33 @@ add_entrypoint_object( libc.src.__support.fixed_point.fx_rep libc.src.__support.CPP.bit ) + + +foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk) + add_entrypoint_object( + countls${suffix} + HDRS + countls${suffix}.h + SRCS + countls${suffix}.cpp + COMPILE_OPTIONS + ${libc_opt_high_flag} + DEPENDS + libc.src.__support.fixed_point.fx_bits + ) + if(LIBC_COMPILER_HAS_PADDING_ON_UNSIGNED_FIXED_POINT) + add_entrypoint_object( + countls${suffix}_padding_on_unsigned_fixed_point + HDRS + countls${suffix}.h + SRCS + countls${suffix}.cpp + COMPILE_OPTIONS + ${libc_opt_high_flag} + -Xclang=-fpadding-on-unsigned-fixed-point + DEPENDS + libc.src.__support.fixed_point.fx_bits + ) + endif() + +endforeach() diff --git a/libc/src/stdfix/countlshk.cpp b/libc/src/stdfix/countlshk.cpp new file mode 100644 index 00000000000000..65230dd688a7ca --- /dev/null +++ b/libc/src/stdfix/countlshk.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlshk function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlshk.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlshk, (short accum f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlshk.h b/libc/src/stdfix/countlshk.h new file mode 100644 index 00000000000000..ecbc9075dcedf5 --- /dev/null +++ b/libc/src/stdfix/countlshk.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlshk function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSHK_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSHK_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlshk(short accum f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSHK_H diff --git a/libc/src/stdfix/countlshr.cpp b/libc/src/stdfix/countlshr.cpp new file mode 100644 index 00000000000000..d07bab8c4a1cd5 --- /dev/null +++ b/libc/src/stdfix/countlshr.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlshr function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlshr.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlshr, (short fract f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlshr.h b/libc/src/stdfix/countlshr.h new file mode 100644 index 00000000000000..728b6873159184 --- /dev/null +++ b/libc/src/stdfix/countlshr.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlshr function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSHR_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSHR_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlshr(short fract f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSHR_H diff --git a/libc/src/stdfix/countlsk.cpp b/libc/src/stdfix/countlsk.cpp new file mode 100644 index 00000000000000..87c009aba0cb5b --- /dev/null +++ b/libc/src/stdfix/countlsk.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlsk function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlsk.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlsk, (accum f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsk.h b/libc/src/stdfix/countlsk.h new file mode 100644 index 00000000000000..b7012da95a9c92 --- /dev/null +++ b/libc/src/stdfix/countlsk.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlsk function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSK_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSK_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlsk(accum f); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_STDFIX_COUNTLSK_H diff --git a/libc/src/stdfix/countlslk.cpp b/libc/src/stdfix/countlslk.cpp new file mode 100644 index 00000000000000..16120b2f55a11d --- /dev/null +++ b/libc/src/stdfix/countlslk.cpp @@ -0,0 +1,20 @@ +//===-- Implementation for countlslk function --------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "countlslk.h" +#include "src/__support/common.h" +#include "src/__support/fixed_point/fx_bits.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, countlslk, (long accum f)) { + return fixed_point::countls(f); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlslk.h b/libc/src/stdfix/countlslk.h new file mode 100644 index 00000000000000..90a2ccc33ce641 --- /dev/null +++ b/libc/src/stdfix/countlslk.h @@ -0,0 +1,21 @@ +//===-- Implementation header for countlslk function -----------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_STDFIX_COUNTLSLK_H +#define LLVM_LIBC_SRC_STDFIX_COUNTLSLK_H + +#include "include/llvm-libc-macros/stdfix-macros.h" +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL + +namespace LIBC_NAMESPACE_DECL { + +int countlslk(long accum f); + +} // namespace... [truncated] ``````````
https://github.com/llvm/llvm-project/pull/125356 From libc-commits at lists.llvm.org Sat Feb 1 12:01:48 2025 From: libc-commits at lists.llvm.org (Joseph Huber via libc-commits) Date: Sat, 01 Feb 2025 12:01:48 -0800 (PST) Subject: [libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356) In-Reply-To: Message-ID: <679e7dac.170a0220.e4abf.ed59@mx.google.com> ================ @@ -64,6 +65,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) set(link_options "") if(${feature} STREQUAL "fixed_point") list(APPEND compile_options "-ffixed-point") + elseif(${feature} STREQUAL "padding_on_unsigned_fixed_point") + list(APPEND compile_options "-ffixed-point -Xclang=-fpadding-on-unsigned-fixed-point") ---------------- jhuber6 wrote: We need to be able to support GCC right? And in general, using `-Xclang` options is a little dubious. https://github.com/llvm/llvm-project/pull/125356 From libc-commits at lists.llvm.org Sat Feb 1 17:33:24 2025 From: libc-commits at lists.llvm.org (Roland McGrath via libc-commits) Date: Sat, 01 Feb 2025 17:33:24 -0800 (PST) Subject: [libc-commits] [libc] [libc] Build with -Wdeprecated, fix some warnings (PR #125373) Message-ID: https://github.com/frobtech created https://github.com/llvm/llvm-project/pull/125373 While GCC's -Wdeprecated is on by default and doesn't do much, Clang's -Wdeprecated enables many more things. More apply in C++20, so switch a test file that tickled one to using that. In future, C++20 should probably be made the baseline for compiling all the libc code. >From e299436c490f00b2c252290f9b5ea08c83e3997d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 1 Feb 2025 17:30:36 -0800 Subject: [PATCH] [libc] Build with -Wdeprecated, fix some warnings While GCC's -Wdeprecated is on by default and doesn't do much, Clang's -Wdeprecated enables many more things. More apply in C++20, so switch a test file that tickled one to using that. In future, C++20 should probably be made the baseline for compiling all the libc code. --- libc/cmake/modules/LLVMLibCCompileOptionRules.cmake | 3 ++- libc/src/__support/CPP/span.h | 2 ++ libc/test/src/setjmp/CMakeLists.txt | 2 ++ libc/test/src/setjmp/setjmp_test.cpp | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake index 12420db331961b..0facb0b9be0c13 100644 --- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake +++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake @@ -179,8 +179,9 @@ function(_get_common_compile_options output_var flags) endif() list(APPEND compile_options "-Wconversion") list(APPEND compile_options "-Wno-sign-conversion") - # Silence this warning because _Complex is a part of C99. + list(APPEND compile_options "-Wdeprecated") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # Silence this warning because _Complex is a part of C99. list(APPEND compile_options "-fext-numeric-literals") else() list(APPEND compile_options "-Wno-c99-extensions") diff --git a/libc/src/__support/CPP/span.h b/libc/src/__support/CPP/span.h index e9e3dbf169ce02..e5073bd3c9d871 100644 --- a/libc/src/__support/CPP/span.h +++ b/libc/src/__support/CPP/span.h @@ -52,6 +52,8 @@ template class span { LIBC_INLINE constexpr span() : span_data(nullptr), span_size(0) {} + LIBC_INLINE constexpr span(const span&) = default; + LIBC_INLINE constexpr span(pointer first, size_type count) : span_data(first), span_size(count) {} diff --git a/libc/test/src/setjmp/CMakeLists.txt b/libc/test/src/setjmp/CMakeLists.txt index 049df89ba39a6f..392230784bd993 100644 --- a/libc/test/src/setjmp/CMakeLists.txt +++ b/libc/test/src/setjmp/CMakeLists.txt @@ -11,6 +11,8 @@ add_libc_unittest( libc_setjmp_unittests SRCS setjmp_test.cpp + CXX_STANDARD + 20 DEPENDS libc.src.setjmp.longjmp libc.src.setjmp.setjmp diff --git a/libc/test/src/setjmp/setjmp_test.cpp b/libc/test/src/setjmp/setjmp_test.cpp index 9e5f74a1734b35..27113cd6e06311 100644 --- a/libc/test/src/setjmp/setjmp_test.cpp +++ b/libc/test/src/setjmp/setjmp_test.cpp @@ -27,7 +27,7 @@ TEST(LlvmLibcSetJmpTest, SetAndJumpBack) { // The first time setjmp is called, it should return 0. // Subsequent calls will return the value passed to jump_back below. if (LIBC_NAMESPACE::setjmp(buf) <= MAX_LOOP) { - ++n; + n = n + 1; jump_back(buf, n); } ASSERT_EQ(longjmp_called, n); From libc-commits at lists.llvm.org Sat Feb 1 17:34:17 2025 From: libc-commits at lists.llvm.org (Roland McGrath via libc-commits) Date: Sat, 01 Feb 2025 17:34:17 -0800 (PST) Subject: [libc-commits] [libc] [libc] Build with -Wdeprecated, fix some warnings (PR #125373) In-Reply-To: Message-ID: <679ecb99.170a0220.237fc3.07f7@mx.google.com> https://github.com/frobtech ready_for_review https://github.com/llvm/llvm-project/pull/125373 From libc-commits at lists.llvm.org Sat Feb 1 17:34:52 2025 From: libc-commits at lists.llvm.org (via libc-commits) Date: Sat, 01 Feb 2025 17:34:52 -0800 (PST) Subject: [libc-commits] [libc] [libc] Build with -Wdeprecated, fix some warnings (PR #125373) In-Reply-To: Message-ID: <679ecbbc.170a0220.1a6f03.0304@mx.google.com> llvmbot wrote: @llvm/pr-subscribers-libc Author: Roland McGrath (frobtech)
Changes While GCC's -Wdeprecated is on by default and doesn't do much, Clang's -Wdeprecated enables many more things. More apply in C++20, so switch a test file that tickled one to using that. In future, C++20 should probably be made the baseline for compiling all the libc code. --- Full diff: https://github.com/llvm/llvm-project/pull/125373.diff 4 Files Affected: - (modified) libc/cmake/modules/LLVMLibCCompileOptionRules.cmake (+2-1) - (modified) libc/src/__support/CPP/span.h (+2) - (modified) libc/test/src/setjmp/CMakeLists.txt (+2) - (modified) libc/test/src/setjmp/setjmp_test.cpp (+1-1) ``````````diff diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake index 12420db331961bf..0facb0b9be0c134 100644 --- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake +++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake @@ -179,8 +179,9 @@ function(_get_common_compile_options output_var flags) endif() list(APPEND compile_options "-Wconversion") list(APPEND compile_options "-Wno-sign-conversion") - # Silence this warning because _Complex is a part of C99. + list(APPEND compile_options "-Wdeprecated") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # Silence this warning because _Complex is a part of C99. list(APPEND compile_options "-fext-numeric-literals") else() list(APPEND compile_options "-Wno-c99-extensions") diff --git a/libc/src/__support/CPP/span.h b/libc/src/__support/CPP/span.h index e9e3dbf169ce027..e5073bd3c9d871a 100644 --- a/libc/src/__support/CPP/span.h +++ b/libc/src/__support/CPP/span.h @@ -52,6 +52,8 @@ template class span { LIBC_INLINE constexpr span() : span_data(nullptr), span_size(0) {} + LIBC_INLINE constexpr span(const span&) = default; + LIBC_INLINE constexpr span(pointer first, size_type count) : span_data(first), span_size(count) {} diff --git a/libc/test/src/setjmp/CMakeLists.txt b/libc/test/src/setjmp/CMakeLists.txt index 049df89ba39a6f7..392230784bd993d 100644 --- a/libc/test/src/setjmp/CMakeLists.txt +++ b/libc/test/src/setjmp/CMakeLists.txt @@ -11,6 +11,8 @@ add_libc_unittest( libc_setjmp_unittests SRCS setjmp_test.cpp + CXX_STANDARD + 20 DEPENDS libc.src.setjmp.longjmp libc.src.setjmp.setjmp diff --git a/libc/test/src/setjmp/setjmp_test.cpp b/libc/test/src/setjmp/setjmp_test.cpp index 9e5f74a1734b353..27113cd6e06311b 100644 --- a/libc/test/src/setjmp/setjmp_test.cpp +++ b/libc/test/src/setjmp/setjmp_test.cpp @@ -27,7 +27,7 @@ TEST(LlvmLibcSetJmpTest, SetAndJumpBack) { // The first time setjmp is called, it should return 0. // Subsequent calls will return the value passed to jump_back below. if (LIBC_NAMESPACE::setjmp(buf) <= MAX_LOOP) { - ++n; + n = n + 1; jump_back(buf, n); } ASSERT_EQ(longjmp_called, n); ``````````
https://github.com/llvm/llvm-project/pull/125373 From libc-commits at lists.llvm.org Sat Feb 1 17:37:30 2025 From: libc-commits at lists.llvm.org (via libc-commits) Date: Sat, 01 Feb 2025 17:37:30 -0800 (PST) Subject: [libc-commits] [libc] [libc] Build with -Wdeprecated, fix some warnings (PR #125373) In-Reply-To: Message-ID: <679ecc5a.170a0220.e6e1e.0d28@mx.google.com> github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning:
You can test this locally with the following command: ``````````bash git-clang-format --diff 312055d1da169f043e65b35fcd62d6d685700114 e299436c490f00b2c252290f9b5ea08c83e3997d --extensions cpp,h -- libc/src/__support/CPP/span.h libc/test/src/setjmp/setjmp_test.cpp ``````````
View the diff from clang-format here. ``````````diff diff --git a/libc/src/__support/CPP/span.h b/libc/src/__support/CPP/span.h index e5073bd3c9..a524e228c1 100644 --- a/libc/src/__support/CPP/span.h +++ b/libc/src/__support/CPP/span.h @@ -52,7 +52,7 @@ public: LIBC_INLINE constexpr span() : span_data(nullptr), span_size(0) {} - LIBC_INLINE constexpr span(const span&) = default; + LIBC_INLINE constexpr span(const span &) = default; LIBC_INLINE constexpr span(pointer first, size_type count) : span_data(first), span_size(count) {} ``````````
https://github.com/llvm/llvm-project/pull/125373 From libc-commits at lists.llvm.org Sat Feb 1 17:47:58 2025 From: libc-commits at lists.llvm.org (Roland McGrath via libc-commits) Date: Sat, 01 Feb 2025 17:47:58 -0800 (PST) Subject: [libc-commits] [libc] [libc] Build with -Wdeprecated, fix some warnings (PR #125373) In-Reply-To: Message-ID: <679ecece.170a0220.24e8e0.5213@mx.google.com> https://github.com/frobtech updated https://github.com/llvm/llvm-project/pull/125373 >From e299436c490f00b2c252290f9b5ea08c83e3997d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 1 Feb 2025 17:30:36 -0800 Subject: [PATCH 1/2] [libc] Build with -Wdeprecated, fix some warnings While GCC's -Wdeprecated is on by default and doesn't do much, Clang's -Wdeprecated enables many more things. More apply in C++20, so switch a test file that tickled one to using that. In future, C++20 should probably be made the baseline for compiling all the libc code. --- libc/cmake/modules/LLVMLibCCompileOptionRules.cmake | 3 ++- libc/src/__support/CPP/span.h | 2 ++ libc/test/src/setjmp/CMakeLists.txt | 2 ++ libc/test/src/setjmp/setjmp_test.cpp | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake index 12420db331961b..0facb0b9be0c13 100644 --- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake +++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake @@ -179,8 +179,9 @@ function(_get_common_compile_options output_var flags) endif() list(APPEND compile_options "-Wconversion") list(APPEND compile_options "-Wno-sign-conversion") - # Silence this warning because _Complex is a part of C99. + list(APPEND compile_options "-Wdeprecated") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # Silence this warning because _Complex is a part of C99. list(APPEND compile_options "-fext-numeric-literals") else() list(APPEND compile_options "-Wno-c99-extensions") diff --git a/libc/src/__support/CPP/span.h b/libc/src/__support/CPP/span.h index e9e3dbf169ce02..e5073bd3c9d871 100644 --- a/libc/src/__support/CPP/span.h +++ b/libc/src/__support/CPP/span.h @@ -52,6 +52,8 @@ template class span { LIBC_INLINE constexpr span() : span_data(nullptr), span_size(0) {} + LIBC_INLINE constexpr span(const span&) = default; + LIBC_INLINE constexpr span(pointer first, size_type count) : span_data(first), span_size(count) {} diff --git a/libc/test/src/setjmp/CMakeLists.txt b/libc/test/src/setjmp/CMakeLists.txt index 049df89ba39a6f..392230784bd993 100644 --- a/libc/test/src/setjmp/CMakeLists.txt +++ b/libc/test/src/setjmp/CMakeLists.txt @@ -11,6 +11,8 @@ add_libc_unittest( libc_setjmp_unittests SRCS setjmp_test.cpp + CXX_STANDARD + 20 DEPENDS libc.src.setjmp.longjmp libc.src.setjmp.setjmp diff --git a/libc/test/src/setjmp/setjmp_test.cpp b/libc/test/src/setjmp/setjmp_test.cpp index 9e5f74a1734b35..27113cd6e06311 100644 --- a/libc/test/src/setjmp/setjmp_test.cpp +++ b/libc/test/src/setjmp/setjmp_test.cpp @@ -27,7 +27,7 @@ TEST(LlvmLibcSetJmpTest, SetAndJumpBack) { // The first time setjmp is called, it should return 0. // Subsequent calls will return the value passed to jump_back below. if (LIBC_NAMESPACE::setjmp(buf) <= MAX_LOOP) { - ++n; + n = n + 1; jump_back(buf, n); } ASSERT_EQ(longjmp_called, n); >From 7ef574fee9bf984748528ac36431fc65c79ffbf3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 1 Feb 2025 17:47:28 -0800 Subject: [PATCH 2/2] clang-format --- libc/src/__support/CPP/span.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/src/__support/CPP/span.h b/libc/src/__support/CPP/span.h index e5073bd3c9d871..a41c9b744e3702 100644 --- a/libc/src/__support/CPP/span.h +++ b/libc/src/__support/CPP/span.h @@ -10,7 +10,7 @@ #include // For size_t -#include "array.h" // For array +#include "array.h" // For array #include "src/__support/macros/config.h" #include "type_traits.h" // For remove_cv_t, enable_if_t, is_same_v, is_const_v @@ -52,7 +52,7 @@ template class span { LIBC_INLINE constexpr span() : span_data(nullptr), span_size(0) {} - LIBC_INLINE constexpr span(const span&) = default; + LIBC_INLINE constexpr span(const span &) = default; LIBC_INLINE constexpr span(pointer first, size_type count) : span_data(first), span_size(count) {} From libc-commits at lists.llvm.org Sat Feb 1 17:49:30 2025 From: libc-commits at lists.llvm.org (Petr Hosek via libc-commits) Date: Sat, 01 Feb 2025 17:49:30 -0800 (PST) Subject: [libc-commits] [libc] [libc] Build with -Wdeprecated, fix some warnings (PR #125373) In-Reply-To: Message-ID: <679ecf2a.170a0220.31619f.fcd4@mx.google.com> https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/125373 From libc-commits at lists.llvm.org Sat Feb 1 18:22:21 2025 From: libc-commits at lists.llvm.org (via libc-commits) Date: Sat, 01 Feb 2025 18:22:21 -0800 (PST) Subject: [libc-commits] [libc] 648981f - [libc] Build with -Wdeprecated, fix some warnings (#125373) Message-ID: <679ed6dd.050a0220.379e13.2c11@mx.google.com> Author: Roland McGrath Date: 2025-02-01T18:22:18-08:00 New Revision: 648981f913431749c4656268ed670677a88511f6 URL: https://github.com/llvm/llvm-project/commit/648981f913431749c4656268ed670677a88511f6 DIFF: https://github.com/llvm/llvm-project/commit/648981f913431749c4656268ed670677a88511f6.diff LOG: [libc] Build with -Wdeprecated, fix some warnings (#125373) While GCC's -Wdeprecated is on by default and doesn't do much, Clang's -Wdeprecated enables many more things. More apply in C++20, so switch a test file that tickled one to using that. In future, C++20 should probably be made the baseline for compiling all the libc code. Added: Modified: libc/cmake/modules/LLVMLibCCompileOptionRules.cmake libc/src/__support/CPP/span.h libc/test/src/setjmp/CMakeLists.txt libc/test/src/setjmp/setjmp_test.cpp Removed: ################################################################################ diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake index 12420db331961b..0facb0b9be0c13 100644 --- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake +++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake @@ -179,8 +179,9 @@ function(_get_common_compile_options output_var flags) endif() list(APPEND compile_options "-Wconversion") list(APPEND compile_options "-Wno-sign-conversion") - # Silence this warning because _Complex is a part of C99. + list(APPEND compile_options "-Wdeprecated") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # Silence this warning because _Complex is a part of C99. list(APPEND compile_options "-fext-numeric-literals") else() list(APPEND compile_options "-Wno-c99-extensions") diff --git a/libc/src/__support/CPP/span.h b/libc/src/__support/CPP/span.h index e9e3dbf169ce02..a41c9b744e3702 100644 --- a/libc/src/__support/CPP/span.h +++ b/libc/src/__support/CPP/span.h @@ -10,7 +10,7 @@ #include // For size_t -#include "array.h" // For array +#include "array.h" // For array #include "src/__support/macros/config.h" #include "type_traits.h" // For remove_cv_t, enable_if_t, is_same_v, is_const_v @@ -52,6 +52,8 @@ template class span { LIBC_INLINE constexpr span() : span_data(nullptr), span_size(0) {} + LIBC_INLINE constexpr span(const span &) = default; + LIBC_INLINE constexpr span(pointer first, size_type count) : span_data(first), span_size(count) {} diff --git a/libc/test/src/setjmp/CMakeLists.txt b/libc/test/src/setjmp/CMakeLists.txt index 049df89ba39a6f..392230784bd993 100644 --- a/libc/test/src/setjmp/CMakeLists.txt +++ b/libc/test/src/setjmp/CMakeLists.txt @@ -11,6 +11,8 @@ add_libc_unittest( libc_setjmp_unittests SRCS setjmp_test.cpp + CXX_STANDARD + 20 DEPENDS libc.src.setjmp.longjmp libc.src.setjmp.setjmp diff --git a/libc/test/src/setjmp/setjmp_test.cpp b/libc/test/src/setjmp/setjmp_test.cpp index 9e5f74a1734b35..27113cd6e06311 100644 --- a/libc/test/src/setjmp/setjmp_test.cpp +++ b/libc/test/src/setjmp/setjmp_test.cpp @@ -27,7 +27,7 @@ TEST(LlvmLibcSetJmpTest, SetAndJumpBack) { // The first time setjmp is called, it should return 0. // Subsequent calls will return the value passed to jump_back below. if (LIBC_NAMESPACE::setjmp(buf) <= MAX_LOOP) { - ++n; + n = n + 1; jump_back(buf, n); } ASSERT_EQ(longjmp_called, n); From libc-commits at lists.llvm.org Sat Feb 1 18:22:25 2025 From: libc-commits at lists.llvm.org (Roland McGrath via libc-commits) Date: Sat, 01 Feb 2025 18:22:25 -0800 (PST) Subject: [libc-commits] [libc] [libc] Build with -Wdeprecated, fix some warnings (PR #125373) In-Reply-To: Message-ID: <679ed6e1.050a0220.118909.0f2c@mx.google.com> https://github.com/frobtech closed https://github.com/llvm/llvm-project/pull/125373 From libc-commits at lists.llvm.org Sat Feb 1 19:31:44 2025 From: libc-commits at lists.llvm.org (LLVM Continuous Integration via libc-commits) Date: Sat, 01 Feb 2025 19:31:44 -0800 (PST) Subject: [libc-commits] [libc] [libc] Build with -Wdeprecated, fix some warnings (PR #125373) In-Reply-To: Message-ID: <679ee720.650a0220.21dfc7.b68e@mx.google.com> llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `openmp-offload-libc-amdgpu-runtime` running on `omp-vega20-1` while building `libc` at step 7 "Add check check-offload". Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/12875
Here is the relevant piece of the build log for the reference ``` Step 7 (Add check check-offload) failure: test (failure) ******************** TEST 'libomptarget :: amdgcn-amd-amdhsa :: mapping/declare_mapper_nested_mappers.cpp' FAILED ******************** Exit Code: 2 Command Output (stdout): -- # RUN: at line 1 /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang++ -fopenmp -I /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test -I /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -nogpulib -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -fopenmp-targets=amdgcn-amd-amdhsa /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/mapping/declare_mapper_nested_mappers.cpp -o /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/mapping/Output/declare_mapper_nested_mappers.cpp.tmp -Xoffload-linker -lc -Xoffload-linker -lm /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a && /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/mapping/Output/declare_mapper_nested_mappers.cpp.tmp | /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/mapping/declare_mapper_nested_mappers.cpp # executed command: /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang++ -fopenmp -I /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test -I /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -nogpulib -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -fopenmp-targets=amdgcn-amd-amdhsa /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/mapping/declare_mapper_nested_mappers.cpp -o /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/mapping/Output/declare_mapper_nested_mappers.cpp.tmp -Xoffload-linker -lc -Xoffload-linker -lm /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a # executed command: /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/mapping/Output/declare_mapper_nested_mappers.cpp.tmp # note: command had no output on stdout or stderr # error: command failed with exit status: -11 # executed command: /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/mapping/declare_mapper_nested_mappers.cpp # .---command stderr------------ # | FileCheck error: '' is empty. # | FileCheck command line: /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/mapping/declare_mapper_nested_mappers.cpp # `----------------------------- # error: command failed with exit status: 2 -- ******************** ```
https://github.com/llvm/llvm-project/pull/125373 From libc-commits at lists.llvm.org Sun Feb 2 10:11:31 2025 From: libc-commits at lists.llvm.org (Krishna Pandey via libc-commits) Date: Sun, 02 Feb 2025 10:11:31 -0800 (PST) Subject: [libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356) In-Reply-To: Message-ID: <679fb553.630a0220.308506.3c5b@mx.google.com> ================ @@ -64,6 +65,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) set(link_options "") if(${feature} STREQUAL "fixed_point") list(APPEND compile_options "-ffixed-point") + elseif(${feature} STREQUAL "padding_on_unsigned_fixed_point") + list(APPEND compile_options "-ffixed-point -Xclang=-fpadding-on-unsigned-fixed-point") ---------------- krishna2803 wrote: hi! i'm having a tough time finding an alternative that would support GCC too, can you please provide some guidance? https://github.com/llvm/llvm-project/pull/125356 From libc-commits at lists.llvm.org Sun Feb 2 10:26:41 2025 From: libc-commits at lists.llvm.org (Krishna Pandey via libc-commits) Date: Sun, 02 Feb 2025 10:26:41 -0800 (PST) Subject: [libc-commits] [libc] [libc] Fix all imports of src/string/memory_utils (PR #114939) In-Reply-To: Message-ID: <679fb8e1.a70a0220.3d34f5.401c@mx.google.com> ================ @@ -54,11 +54,9 @@ add_header_library( add_header_library( common HDRS - common.h - endian.h macros/properties/architectures.h macros/attributes.h - macros/properties/cpu_features.h ---------------- krishna2803 wrote: can you please provide some guidance on what exactly needs to be done here? https://github.com/llvm/llvm-project/pull/114939 From libc-commits at lists.llvm.org Sun Feb 2 11:41:11 2025 From: libc-commits at lists.llvm.org (Joseph Huber via libc-commits) Date: Sun, 02 Feb 2025 11:41:11 -0800 (PST) Subject: [libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356) In-Reply-To: Message-ID: <679fca57.170a0220.3c0053.614c@mx.google.com> ================ @@ -64,6 +65,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES) set(link_options "") if(${feature} STREQUAL "fixed_point") list(APPEND compile_options "-ffixed-point") + elseif(${feature} STREQUAL "padding_on_unsigned_fixed_point") + list(APPEND compile_options "-ffixed-point -Xclang=-fpadding-on-unsigned-fixed-point") ---------------- jhuber6 wrote: This option confuses me, it's a language option but it's not enabled by anything but this `-cc1` option. Forcing the user to go through `-Xclang` for anything but hacking on the compiler internals is generally bad. My assumption is that this flag should be promoted to a marshalling driver flag. I don't know what the equivalent in GCC would be, nor why this flag is necessary. https://github.com/llvm/llvm-project/pull/125356 From libc-commits at lists.llvm.org Sun Feb 2 11:45:45 2025 From: libc-commits at lists.llvm.org (via libc-commits) Date: Sun, 02 Feb 2025 11:45:45 -0800 (PST) Subject: [libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356) In-Reply-To: Message-ID: <679fcb69.170a0220.304988.2951@mx.google.com> github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning:
You can test this locally with the following command: ``````````bash git-clang-format --diff c1163b843b63f775817b84f124cdcf33f25c28f6 519ae5df684c9f850688048aa80abfaccc1ddaac --extensions cpp,h -- libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp libc/src/stdfix/countlshk.cpp libc/src/stdfix/countlshk.h libc/src/stdfix/countlshr.cpp libc/src/stdfix/countlshr.h libc/src/stdfix/countlsk.cpp libc/src/stdfix/countlsk.h libc/src/stdfix/countlslk.cpp libc/src/stdfix/countlslk.h libc/src/stdfix/countlslr.cpp libc/src/stdfix/countlslr.h libc/src/stdfix/countlsr.cpp libc/src/stdfix/countlsr.h libc/src/stdfix/countlsuhk.cpp libc/src/stdfix/countlsuhk.h libc/src/stdfix/countlsuhr.cpp libc/src/stdfix/countlsuhr.h libc/src/stdfix/countlsuk.cpp libc/src/stdfix/countlsuk.h libc/src/stdfix/countlsulk.cpp libc/src/stdfix/countlsulk.h libc/src/stdfix/countlsulr.cpp libc/src/stdfix/countlsulr.h libc/src/stdfix/countlsur.cpp libc/src/stdfix/countlsur.h libc/test/src/stdfix/CountlsTest.h libc/test/src/stdfix/countlshk_test.cpp libc/test/src/stdfix/countlshr_test.cpp libc/test/src/stdfix/countlsk_test.cpp libc/test/src/stdfix/countlslk_test.cpp libc/test/src/stdfix/countlslr_test.cpp libc/test/src/stdfix/countlsr_test.cpp libc/test/src/stdfix/countlsuhk_test.cpp libc/test/src/stdfix/countlsuhr_test.cpp libc/test/src/stdfix/countlsuk_test.cpp libc/test/src/stdfix/countlsulk_test.cpp libc/test/src/stdfix/countlsulr_test.cpp libc/test/src/stdfix/countlsur_test.cpp libc/src/__support/fixed_point/fx_bits.h ``````````
View the diff from clang-format here. ``````````diff diff --git a/libc/src/__support/fixed_point/fx_bits.h b/libc/src/__support/fixed_point/fx_bits.h index a955ee6774..59e9610216 100644 --- a/libc/src/__support/fixed_point/fx_bits.h +++ b/libc/src/__support/fixed_point/fx_bits.h @@ -11,10 +11,10 @@ #include "include/llvm-libc-macros/stdfix-macros.h" #include "src/__support/CPP/bit.h" -#include "src/__support/CPP/type_traits.h" #include "src/__support/CPP/limits.h" // numeric_limits -#include "src/__support/macros/attributes.h" // LIBC_INLINE -#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL +#include "src/__support/CPP/type_traits.h" +#include "src/__support/macros/attributes.h" // LIBC_INLINE +#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY #include "src/__support/math_extras.h" @@ -185,7 +185,8 @@ countls(T f) { using FXBits = FXBits; constexpr int CONTAIN_LEN = cpp::numeric_limits::digits; - constexpr int PADDING_LEN = CONTAIN_LEN - (FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN); + constexpr int PADDING_LEN = + CONTAIN_LEN - (FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN); if constexpr (FXRep::SIGN_LEN != 0) { if (x < 0) diff --git a/libc/src/stdfix/countlshk.cpp b/libc/src/stdfix/countlshk.cpp index 65230dd688..065b5a44ea 100644 --- a/libc/src/stdfix/countlshk.cpp +++ b/libc/src/stdfix/countlshk.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlshk function --------------------------------===// +//===-- Implementation for countlshk function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/stdfix/countlshr.cpp b/libc/src/stdfix/countlshr.cpp index d07bab8c4a..86c9f9ad00 100644 --- a/libc/src/stdfix/countlshr.cpp +++ b/libc/src/stdfix/countlshr.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlshr function --------------------------------===// +//===-- Implementation for countlshr function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/stdfix/countlsk.cpp b/libc/src/stdfix/countlsk.cpp index 87c009aba0..6512730559 100644 --- a/libc/src/stdfix/countlsk.cpp +++ b/libc/src/stdfix/countlsk.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlsk function --------------------------------===// +//===-- Implementation for countlsk function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -13,8 +14,6 @@ namespace LIBC_NAMESPACE_DECL { -LLVM_LIBC_FUNCTION(int, countlsk, (accum f)) { - return fixed_point::countls(f); -} +LLVM_LIBC_FUNCTION(int, countlsk, (accum f)) { return fixed_point::countls(f); } } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlslk.cpp b/libc/src/stdfix/countlslk.cpp index 16120b2f55..771c3ba344 100644 --- a/libc/src/stdfix/countlslk.cpp +++ b/libc/src/stdfix/countlslk.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlslk function --------------------------------===// +//===-- Implementation for countlslk function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/stdfix/countlslr.cpp b/libc/src/stdfix/countlslr.cpp index 9e0369db3b..00634c90de 100644 --- a/libc/src/stdfix/countlslr.cpp +++ b/libc/src/stdfix/countlslr.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlslr function --------------------------------===// +//===-- Implementation for countlslr function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/stdfix/countlsr.cpp b/libc/src/stdfix/countlsr.cpp index d18e673a30..ec5d7e832a 100644 --- a/libc/src/stdfix/countlsr.cpp +++ b/libc/src/stdfix/countlsr.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlsr function --------------------------------===// +//===-- Implementation for countlsr function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -13,8 +14,6 @@ namespace LIBC_NAMESPACE_DECL { -LLVM_LIBC_FUNCTION(int, countlsr, (fract f)) { - return fixed_point::countls(f); -} +LLVM_LIBC_FUNCTION(int, countlsr, (fract f)) { return fixed_point::countls(f); } } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/countlsuhk.cpp b/libc/src/stdfix/countlsuhk.cpp index 8a24508b83..56764aa911 100644 --- a/libc/src/stdfix/countlsuhk.cpp +++ b/libc/src/stdfix/countlsuhk.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlsuhk function --------------------------------===// +//===-- Implementation for countlsuhk function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/stdfix/countlsuhr.cpp b/libc/src/stdfix/countlsuhr.cpp index 6dec26c788..8ddb14a6aa 100644 --- a/libc/src/stdfix/countlsuhr.cpp +++ b/libc/src/stdfix/countlsuhr.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlsuhr function --------------------------------===// +//===-- Implementation for countlsuhr function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/stdfix/countlsuk.cpp b/libc/src/stdfix/countlsuk.cpp index 98ebf09694..6ae93f0dad 100644 --- a/libc/src/stdfix/countlsuk.cpp +++ b/libc/src/stdfix/countlsuk.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlsuhk function --------------------------------===// +//===-- Implementation for countlsuhk function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/stdfix/countlsulk.cpp b/libc/src/stdfix/countlsulk.cpp index 043c919a65..075d485238 100644 --- a/libc/src/stdfix/countlsulk.cpp +++ b/libc/src/stdfix/countlsulk.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlsulk function --------------------------------===// +//===-- Implementation for countlsulk function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/stdfix/countlsulr.cpp b/libc/src/stdfix/countlsulr.cpp index a77eaeabce..a1efb67673 100644 --- a/libc/src/stdfix/countlsulr.cpp +++ b/libc/src/stdfix/countlsulr.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlsulr function --------------------------------===// +//===-- Implementation for countlsulr function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/src/stdfix/countlsur.cpp b/libc/src/stdfix/countlsur.cpp index 6dcb54bdca..aedd545b26 100644 --- a/libc/src/stdfix/countlsur.cpp +++ b/libc/src/stdfix/countlsur.cpp @@ -1,4 +1,5 @@ -//===-- Implementation for countlsur function --------------------------------===// +//===-- Implementation for countlsur function +//--------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/CountlsTest.h b/libc/test/src/stdfix/CountlsTest.h index d4a4083591..a216b5f5c4 100644 --- a/libc/test/src/stdfix/CountlsTest.h +++ b/libc/test/src/stdfix/CountlsTest.h @@ -20,8 +20,7 @@ template class CountlsTest : public LIBC_NAMESPACE::testing::Test { static constexpr T one_fourth = FXRep::ONE_FOURTH(); static constexpr T eps = FXRep::EPS(); - static constexpr auto value_len = - FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN; + static constexpr auto value_len = FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN; public: typedef int (*CountlsFunc)(T); diff --git a/libc/test/src/stdfix/countlshk_test.cpp b/libc/test/src/stdfix/countlshk_test.cpp index d5654981f9..f46316d42b 100644 --- a/libc/test/src/stdfix/countlshk_test.cpp +++ b/libc/test/src/stdfix/countlshk_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlshk ----------------------------------------------===// +//===-- Unittests for countlshk +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlshr_test.cpp b/libc/test/src/stdfix/countlshr_test.cpp index 2021553be7..038e116824 100644 --- a/libc/test/src/stdfix/countlshr_test.cpp +++ b/libc/test/src/stdfix/countlshr_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlshr ----------------------------------------------===// +//===-- Unittests for countlshr +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlsk_test.cpp b/libc/test/src/stdfix/countlsk_test.cpp index e7c71add68..691d6e3c39 100644 --- a/libc/test/src/stdfix/countlsk_test.cpp +++ b/libc/test/src/stdfix/countlsk_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlsk ----------------------------------------------===// +//===-- Unittests for countlsk +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlslk_test.cpp b/libc/test/src/stdfix/countlslk_test.cpp index 4c7f297073..af3d8b4b5c 100644 --- a/libc/test/src/stdfix/countlslk_test.cpp +++ b/libc/test/src/stdfix/countlslk_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlslk ----------------------------------------------===// +//===-- Unittests for countlslk +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlslr_test.cpp b/libc/test/src/stdfix/countlslr_test.cpp index 93b33597b9..cabb63eddc 100644 --- a/libc/test/src/stdfix/countlslr_test.cpp +++ b/libc/test/src/stdfix/countlslr_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlslr ----------------------------------------------===// +//===-- Unittests for countlslr +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlsr_test.cpp b/libc/test/src/stdfix/countlsr_test.cpp index d465c2e1ea..bad60a6e33 100644 --- a/libc/test/src/stdfix/countlsr_test.cpp +++ b/libc/test/src/stdfix/countlsr_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlsr ----------------------------------------------===// +//===-- Unittests for countlsr +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlsuhk_test.cpp b/libc/test/src/stdfix/countlsuhk_test.cpp index b72328b5b1..354359d914 100644 --- a/libc/test/src/stdfix/countlsuhk_test.cpp +++ b/libc/test/src/stdfix/countlsuhk_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlsuhk ----------------------------------------------===// +//===-- Unittests for countlsuhk +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlsuhr_test.cpp b/libc/test/src/stdfix/countlsuhr_test.cpp index b82e105017..523323c156 100644 --- a/libc/test/src/stdfix/countlsuhr_test.cpp +++ b/libc/test/src/stdfix/countlsuhr_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlsuhr ----------------------------------------------===// +//===-- Unittests for countlsuhr +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlsuk_test.cpp b/libc/test/src/stdfix/countlsuk_test.cpp index 5ca66822fe..129437a3a9 100644 --- a/libc/test/src/stdfix/countlsuk_test.cpp +++ b/libc/test/src/stdfix/countlsuk_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlsuk ----------------------------------------------===// +//===-- Unittests for countlsuk +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlsulk_test.cpp b/libc/test/src/stdfix/countlsulk_test.cpp index 762d4924ba..73c8916c66 100644 --- a/libc/test/src/stdfix/countlsulk_test.cpp +++ b/libc/test/src/stdfix/countlsulk_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlsulk ----------------------------------------------===// +//===-- Unittests for countlsulk +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlsulr_test.cpp b/libc/test/src/stdfix/countlsulr_test.cpp index 62c06b233e..65b5fff4f6 100644 --- a/libc/test/src/stdfix/countlsulr_test.cpp +++ b/libc/test/src/stdfix/countlsulr_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlsulr ----------------------------------------------===// +//===-- Unittests for countlsulr +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/libc/test/src/stdfix/countlsur_test.cpp b/libc/test/src/stdfix/countlsur_test.cpp index 49236db25d..694476a1bb 100644 --- a/libc/test/src/stdfix/countlsur_test.cpp +++ b/libc/test/src/stdfix/countlsur_test.cpp @@ -1,4 +1,5 @@ -//===-- Unittests for countlsur ----------------------------------------------===// +//===-- Unittests for countlsur +//----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. ``````````
https://github.com/llvm/llvm-project/pull/125356