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

Add minimal syntactic support for type _Float16 #525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xavierleroy
Copy link
Contributor

@xavierleroy xavierleroy commented Oct 4, 2024

Appendix H of ISO C 2023 makes provisions for built-in binary floating-point types _FloatN, where N is the bit size of the type.

Some C compilers and math libraries already make use of type _Float16 to denote half-precision FP numbers. That's the case for XCode 16 on macOS, which declares _Float16 functions in <math.h> without guarding them with a #ifdef, e.g.

extern _Float16 __fabsf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));

With the current CompCert, any C source code that includes <math.h> causes a syntax error on these declarations.

This PR proposes to add minimal syntactic support for type _Float16. It is kept as a distinct FP type during elaboration, then rejected during conversion to CompCert C. This way, _Float16 functions declared in header files but not used in the C source file are silently ignored. If these functions are used, an "unsupported feature" error is reported.

The verified part of CompCert is unchanged.

This is part of C23 appendix H, and is starting to be used in system
header files.

`_Float16` is kept as a distinct FP type during elaboration, then rejected
during conversion to CompCert C.

The verified part of CompCert is unchanged.
@xavierleroy xavierleroy changed the title Add minimal syntactic support for types _Float16, _Float32 and _Float64 Add minimal syntactic support for type _Float16 Oct 4, 2024
@xavierleroy
Copy link
Contributor Author

xavierleroy commented Oct 4, 2024

A first cut of this PR also added _Float32 and _Float64 as synonymous for float and double, but this causes problems with Glibc header files, and is not needed.

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.

1 participant