llvm/libc/src/__support/integer_literals.h

//===-- User literal for unsigned integers ----------------------*- 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
//
//===----------------------------------------------------------------------===//
// This set of user defined literals allows uniform constructions of constants
// up to 256 bits and also help with unit tests (EXPECT_EQ requires the same
// type for LHS and RHS).
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC___SUPPORT_INTEGER_LITERALS_H
#define LLVM_LIBC_SRC___SUPPORT_INTEGER_LITERALS_H

#include "src/__support/CPP/limits.h"        // CHAR_BIT
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h"
#include "src/__support/uint128.h"           // UInt128
#include <stddef.h>                          // size_t
#include <stdint.h>                          // uintxx_t

namespace LIBC_NAMESPACE_DECL {

LIBC_INLINE constexpr uint8_t operator""_u8(unsigned long long value) {}

LIBC_INLINE constexpr uint16_t operator""_u16(unsigned long long value) {}

LIBC_INLINE constexpr uint32_t operator""_u32(unsigned long long value) {}

LIBC_INLINE constexpr uint64_t operator""_u64(unsigned long long value) {}

namespace internal {

// Creates a T by reading digits from an array.
template <typename T>
LIBC_INLINE constexpr T accumulate(int base, const uint8_t *digits,
                                   size_t size) {}

// A static buffer to hold the digits for a T.
template <typename T, int base> struct DigitBuffer {};

// Generic implementation for native types (including __uint128_t or ExtInt
// where available).
template <typename T> struct Parser {};

// Specialization for UInt<N>.
// Because this code runs at compile time we try to make it efficient. For
// binary and hexadecimal formats we read digits by chunks of 64 bits and
// produce the BigInt internal representation direcly. For decimal numbers we
// go the slow path and use slower BigInt arithmetic.
Parser<__llvm_libc_20_0_0_git::UInt<N>>;

// Detects the base of the number and dispatches to the right implementation.
template <typename T>
LIBC_INLINE constexpr T parse_with_prefix(const char *ptr) {}

} // namespace internal

LIBC_INLINE constexpr UInt128 operator""_u128(const char *x) {}

LIBC_INLINE constexpr auto operator""_u256(const char *x) {}

template <typename T> LIBC_INLINE constexpr T parse_bigint(const char *ptr) {}

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_INTEGER_LITERALS_H