1//===-- Types support -------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8// Types detection and support.
9
10#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H
11#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H
12
13#include "include/llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG
14#include "include/llvm-libc-types/float128.h" // float128
15#include "src/__support/macros/properties/architectures.h"
16#include "src/__support/macros/properties/compiler.h"
17#include "src/__support/macros/properties/cpu_features.h"
18#include "src/__support/macros/properties/os.h"
19
20#include <stdint.h> // UINT64_MAX, __SIZEOF_INT128__
21
22// 'long double' properties.
23#if (LDBL_MANT_DIG == 53)
24#define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64
25#elif (LDBL_MANT_DIG == 64)
26#define LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
27#elif (LDBL_MANT_DIG == 113)
28#define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128
29#endif
30
31// int64 / uint64 support
32#if defined(UINT64_MAX)
33#define LIBC_TYPES_HAS_INT64
34#endif // UINT64_MAX
35
36// int128 / uint128 support
37#if defined(__SIZEOF_INT128__)
38#define LIBC_TYPES_HAS_INT128
39#endif // defined(__SIZEOF_INT128__)
40
41// -- float16 support ---------------------------------------------------------
42// TODO: move this logic to "llvm-libc-types/float16.h"
43#if defined(LIBC_TARGET_ARCH_IS_X86_64) && defined(LIBC_TARGET_CPU_HAS_SSE2)
44#if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 1500)) || \
45 (defined(LIBC_COMPILER_GCC_VER) && (LIBC_COMPILER_GCC_VER >= 1201))
46#define LIBC_TYPES_HAS_FLOAT16
47using float16 = _Float16;
48#endif
49#endif
50#if defined(LIBC_TARGET_ARCH_IS_AARCH64)
51#if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 900)) || \
52 (defined(LIBC_COMPILER_GCC_VER) && (LIBC_COMPILER_GCC_VER >= 1301))
53#define LIBC_TYPES_HAS_FLOAT16
54using float16 = _Float16;
55#endif
56#endif
57#if defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
58#if (defined(LIBC_COMPILER_CLANG_VER) && (LIBC_COMPILER_CLANG_VER >= 1300)) || \
59 (defined(LIBC_COMPILER_GCC_VER) && (LIBC_COMPILER_GCC_VER >= 1301))
60#define LIBC_TYPES_HAS_FLOAT16
61using float16 = _Float16;
62#endif
63#endif
64
65// -- float128 support --------------------------------------------------------
66// LIBC_TYPES_HAS_FLOAT128 and 'float128' type are provided by
67// "include/llvm-libc-types/float128.h"
68
69#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H
70

source code of libc/src/__support/macros/properties/types.h