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

Support float16 #2667

Merged
merged 1 commit into from
Dec 11, 2023
Merged

Support float16 #2667

merged 1 commit into from
Dec 11, 2023

Conversation

sagudev
Copy link
Contributor

@sagudev sagudev commented Oct 20, 2023

This is done by defining pub struct __BindgenFloat16(pub u16);. Clang has half (__fp16; storage type, casted to float for calculations) and float16 (__Float16) types, both have same binary representations, and this PR handles both as same.
More about half types here: https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point.

When rust implements f16 we could use those if appropriate target rust is used.
Rust f16 RFC: https://github.com/rust-lang/rfcs/blob/master/text/3453-f16-and-f128.md#f16-type (contains some clang details)

Fixes #2500.

@@ -0,0 +1,7 @@

static _Float16 global;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static _Float16 global = 1.0; is not supported

@novafacing
Copy link

This PR solves my issue of _Float16 definition, works great for me!

@sagudev
Copy link
Contributor Author

sagudev commented Nov 24, 2023

ping @emilio

@nicoburns
Copy link

Tracking issue for rustc support for f16 rust-lang/rust#116909

@emilio emilio merged commit d77e53e into rust-lang:main Dec 11, 2023
32 checks passed
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.

_Float16 _Complex leads to panic (such as when including immintrin.h on clang 16)
4 participants