-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc][complex] Added support for CFP16 and CFP128 (#112594)
Fixes: #112217
- Loading branch information
1 parent
761fa58
commit 7be4ab0
Showing
9 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//===-- Definition of cfloat128 type --------------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_TYPES_CFLOAT128_H | ||
#define LLVM_LIBC_TYPES_CFLOAT128_H | ||
|
||
#include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG | ||
|
||
// Currently, the complex variant of C23 `_Float128` type is only defined as a | ||
// built-in type in GCC 7 or later, and only for C. For C++, or for clang, | ||
// the complex variant of `__float128` is defined instead, and only on x86-64 | ||
// targets. | ||
// | ||
// TODO: Update the complex variant of C23 `_Float128` type detection again when | ||
// clang supports it. | ||
// https://github.com/llvm/llvm-project/issues/80195 | ||
#if defined(__STDC_IEC_60559_COMPLEX__) && !defined(__clang__) && \ | ||
!defined(__cplusplus) | ||
#define LIBC_TYPES_HAS_CFLOAT128 | ||
typedef _Complex _Float128 cfloat128; | ||
#elif defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) | ||
// Use _Complex __float128 type. gcc and clang sometime use __SIZEOF_FLOAT128__ | ||
// to notify the availability of __float128. clang also uses __FLOAT128__ macro | ||
// to notify the availability of __float128 type: | ||
// https://reviews.llvm.org/D15120 | ||
#define LIBC_TYPES_HAS_CFLOAT128 | ||
typedef _Complex __float128 cfloat128; | ||
#elif (LDBL_MANT_DIG == 113) | ||
#define LIBC_TYPES_HAS_CFLOAT128 | ||
typedef _Complex long double cfloat128; | ||
#endif | ||
|
||
#endif // LLVM_LIBC_TYPES_CFLOAT128_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- Definition of cfloat16 type ---------------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_TYPES_CFLOAT16_H | ||
#define LLVM_LIBC_TYPES_CFLOAT16_H | ||
|
||
#if defined(__FLT16_MANT_DIG__) && \ | ||
(!defined(__GNUC__) || __GNUC__ >= 13 || defined(__clang__)) && \ | ||
!defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \ | ||
!defined(_WIN32) | ||
#define LIBC_TYPES_HAS_CFLOAT16 | ||
typedef _Complex _Float16 cfloat16; | ||
#endif | ||
|
||
#endif // LLVM_LIBC_TYPES_CFLOAT16_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//===-- Complex Types support -----------------------------------*- 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// Complex Types detection and support. | ||
|
||
#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H | ||
#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H | ||
|
||
#include "include/llvm-libc-types/cfloat128.h" | ||
#include "include/llvm-libc-types/cfloat16.h" | ||
#include "types.h" | ||
|
||
// -- cfloat16 support -------------------------------------------------------- | ||
// LIBC_TYPES_HAS_CFLOAT16 and 'cfloat16' type is provided by | ||
// "include/llvm-libc-types/cfloat16.h" | ||
|
||
// -- cfloat128 support ------------------------------------------------------- | ||
// LIBC_TYPES_HAS_CFLOAT128 and 'cfloat128' type are provided by | ||
// "include/llvm-libc-types/cfloat128.h" | ||
|
||
#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters