Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dfpir types #70127

Closed
wants to merge 4 commits into from
Closed

Dfpir types #70127

wants to merge 4 commits into from

Conversation

zahiraam
Copy link
Contributor

No description provided.

tahonermann and others added 4 commits September 24, 2023 19:40
…ng point types.

This change adds basic type representation support for the decimal
floating point types defined by ISO/IEC TS 18661-2 and adopted for C23.
These types will also serve as the underlying native types for the
library types defined by ISO/IEC TR 24733 and as implemented in
libstdcxx. This change does not include representation support in
LLVM IR, in debugging information, or in C++ mangling for the MS ABI;
such support will be added in later patches.
Though the ISO/IEC TS 18661-2:2015 decimal floating-point (DFP)
extension has been adopted for the upcoming C23 standard, it will
remain necessary to be able to explicitly enable and disable support
for the extension for the foreseeable future for use with previous
C standards and with C++. This change adds a driver and cc1 option
to enable language support. Since support for the feature is not yet
complete, the option name explicitly reflects its status as
experimental and only serves to enable testing at this point.

No target considerations have been implemented yet. The option only
serves to enable the _Decimal32, _Decimal64, and _Decimal128 keywords
to be used as DFP type specifiers in C; these keywords are not enabled
for C++ since, per ISO/IEC TR 24733:2011 and the gcc implementation,
DFP support in C++ is provided via standard library types (that are
expected to wrap a builtin type exposed by other means).

The C23 standard specifies that the __STDC_IEC_60559_DFP__ macro be
predefined when the DFP extensions are available. This change adds
that macro with a placeholder value for use in testing.
…mal floating-point types.

Current proposals for supporting decimal floating-point (DFP) types in
C++, e.g., ISO/IEC TR 24733:2011, do not specify keywords to be used as
type specifiers. Rather, DFP types are specified as standard library
types that, in practice, wrap a builtin type that is not otherwise
exposed with a simple name. Gcc enables builtin DFP types to be
declared using the GNU mode attribute as follows:
  float __attribute__((mode(SD))) // _Decimal32
  float __attribute__((mode(DD))) // _Decimal64
  float __attribute__((mode(TD))) // _Decimal128
This change implements support for these additional machine modes.

This change also extends several of the clang::Type AST node attributes
to include DFP types in addition to other floating-point types. These
extensions match extensions to terms of the same name made in C23. The
directly affected predicates includes:
  Type::isRealFloatingType()
  Type::isFloatingType()
  Type::isRealType()
  Type::isArithmeticType()
The following new predicate can be used to differentiate DFP types
where needed.
  Type::isDecimalFloatingType()

The existing DFP specifications, including C23, do not include support
for complex DFP types. Gcc does not provide such support either. These
changes follow that existing precedent and do not enable support for
complex DFP types as well. However, vector types are allowed to have
DFP types as their element type.
@zahiraam zahiraam closed this Oct 24, 2023
@zahiraam zahiraam deleted the DFPIRTypes branch October 24, 2023 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants