[libc-commits] [libc] [libc][stdfix] Add support for fixed point types in the testing infrastructure. (PR #81819)
via libc-commits
libc-commits at lists.llvm.org
Fri Feb 16 11:36:59 PST 2024
================
@@ -10,144 +10,245 @@
#define LLVM_LIBC_SRC___SUPPORT_FIXEDPOINT_FXREP_H
#include "include/llvm-libc-macros/stdfix-macros.h"
+#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR
+#include <stdint.h>
+
#ifdef LIBC_COMPILER_HAS_FIXED_POINT
namespace LIBC_NAMESPACE::fixed_point {
+namespace internal {
+
+template <int Bits> struct Storage {
+ static_assert(Bits > 0 && Bits <= 64, "Bits has to be between 1 and 64.");
+ using Type = typename cpp::conditional_t<
+ (Bits <= 8), uint8_t,
+ typename cpp::conditional_t<
+ (Bits <= 16 && Bits > 8), uint16_t,
+ typename cpp::conditional_t<(Bits <= 32 && Bits > 16), uint32_t,
+ uint64_t>>>;
+};
----------------
lntue wrote:
We might have to replicate this logic in C, probably inside `include/llvm-libc-types/stdfix_types.h` in order to add definitions for `int_*_t` and `uint_*_t` as specified in the standard (section 7.18a.2). Then probably we can remove this conditional template and use those instead.
https://github.com/llvm/llvm-project/pull/81819
More information about the libc-commits
mailing list