-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Add f16 and f128
#114607
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 f16 and f128
#114607
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| // num.parse().ok() | ||
| // } | ||
|
|
||
| // FIXME: bootstrap `f16` parsing via `f32` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // FIXME: bootstrap `f16` parsing via `f32` | |
| // FIXME: bootstrap `f128` parsing via `f64` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please don't remove this until both cg_clif and cg_gcc support the new types. Otherwise they can't bootstrap rustc anymore.
library/core/src/fmt/float.rs
Outdated
| #[cfg(not(bootstrap))] | ||
| floating! { f16 } | ||
| #[cfg(not(bootstrap))] | ||
| floating! { f128 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods are not #[inline] so they will completely break building the standard library with cg_gcc and cg_clif until these backends support f16 and f128.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the correct way to fix this? I have also just been using unimplemented!() in clif and gcc to make things compiile, I guess those should just throw errors instead?
(down the line of course, I'm still on the very first stage of getting this to work)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[inline] functions are only codegened when actually used. So making them #[inline] at least temporarily would be an option.
I guess those should just throw errors instead?
That would replace an ICE with an error when compiling libcore. Both prevent successful compilation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cg_clif and cg_gcc don't yet have CI tests yet right? Could turn them on while I'm working on this if so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try cherry-picking #112701 and then remove https://github.com/rust-lang/rust/pull/112701/files#diff-8479eab02701e686aedb15b567dc8fc31220c6e4efb9565ccc9d662b7fee2214R3057-R3063 Once that is done if you set codegen-backends in config.toml to include llvm and cranelift (llvm first to avoid building rustc itself with cranelift), you can test it with ./x.py test compiler/rustc_codegen_cranelift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these mini_core errors usually show up in CI? I don't think I'm getting them on local https://github.com/rust-lang/rust/actions/runs/5806522313/job/15739585197?pr=114607#step:24:3221
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because #112701 hasn't landed yet it is possible for PR's in this repo to break cg_clif's testsuite. I fixed that issue just today in bjorn3/rustc_codegen_cranelift@3deb6c6. Opened #114666 to sync it back to this repo.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@rustbot label -A-testsuite -T-bootstrap -T-infra |
|
Work is in progress elsewhere, not much sense in keeping this open |
Preliminary implementation of rust-lang/rfcs#3453 (still a work in progress)
This introduces four new features:
f16: lang feature, basic support for 16-bit floating point numbersf128: same as above for 128-bitf16_math: libs feature, gates math that relies on intrinsicsf128_math: libs feature, same as aboveThe math features are gated separately because it seems like LLVM has some bugs with the intrinsics. F16 should work but f128 is completely unusable llvm/llvm-project#44744.
I have found this calculator helpful if anyone is validating the data: http://weitz.de/ieee/
Tracking issue: #116909
Edit: I have started merging this in portions, see #116909 (comment)
r? ghost
@rustbot label +T-lang +T-libs-api