[libc-commits] [libc] [libc][stdfix] Add support for fixed point types in the testing infrastructure. (PR #81819)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Fri Feb 16 08:33:35 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>>>;
+};
----------------
nickdesaulniers wrote:
This is blowing my mind right now. :exploding_head:
https://github.com/llvm/llvm-project/pull/81819
More information about the libc-commits
mailing list