xref: /freebsd/contrib/llvm-project/libc/src/__support/macros/properties/types.h (revision bb722a7d0f1642bff6487f943ad0427799a6e5bf)
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 "hdr/float_macros.h"                        // LDBL_MANT_DIG
14 #include "include/llvm-libc-macros/float16-macros.h" // LIBC_TYPES_HAS_FLOAT16
15 #include "include/llvm-libc-types/float128.h"        // float128
16 #include "src/__support/macros/config.h"             // LIBC_NAMESPACE_DECL
17 #include "src/__support/macros/properties/architectures.h"
18 #include "src/__support/macros/properties/compiler.h"
19 #include "src/__support/macros/properties/cpu_features.h"
20 #include "src/__support/macros/properties/os.h"
21 
22 #include <stdint.h> // UINT64_MAX, __SIZEOF_INT128__
23 
24 // 'long double' properties.
25 #if (LDBL_MANT_DIG == 53)
26 #define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64
27 #elif (LDBL_MANT_DIG == 64)
28 #define LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
29 #elif (LDBL_MANT_DIG == 113)
30 #define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128
31 #elif (LDBL_MANT_DIG == 106)
32 #define LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
33 #endif
34 
35 #if defined(LIBC_TYPES_HAS_FLOAT128) &&                                        \
36     !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128)
37 #define LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
38 #endif
39 
40 // int64 / uint64 support
41 #if defined(UINT64_MAX)
42 #define LIBC_TYPES_HAS_INT64
43 #endif // UINT64_MAX
44 
45 // int128 / uint128 support
46 #if defined(__SIZEOF_INT128__) && !defined(LIBC_TARGET_OS_IS_WINDOWS)
47 #define LIBC_TYPES_HAS_INT128
48 #endif // defined(__SIZEOF_INT128__)
49 
50 // -- float16 support ---------------------------------------------------------
51 // LIBC_TYPES_HAS_FLOAT16 is provided by
52 // "include/llvm-libc-macros/float16-macros.h"
53 #ifdef LIBC_TYPES_HAS_FLOAT16
54 // Type alias for internal use.
55 using float16 = _Float16;
56 #endif // LIBC_TYPES_HAS_FLOAT16
57 
58 // -- float128 support --------------------------------------------------------
59 // LIBC_TYPES_HAS_FLOAT128 and 'float128' type are provided by
60 // "include/llvm-libc-types/float128.h"
61 
62 // -- bfloat16 support ---------------------------------------------------------
63 
64 namespace LIBC_NAMESPACE_DECL {
65 namespace fputil {
66 struct BFloat16;
67 }
68 } // namespace LIBC_NAMESPACE_DECL
69 
70 using bfloat16 = LIBC_NAMESPACE::fputil::BFloat16;
71 
72 #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H
73