- Notifications
You must be signed in to change notification settings - Fork14.1k
Description
This is a tracking issue for the RFC 3453 (rust-lang/rfcs#3453).
The feature gate for the issue is#![feature(f16_and_f128)].
From the RFC:
This RFC proposes adding new IEEE-compliant floating point types
f16andf128into the core language and standard library. We will provide a soft float implementation for all targets, and use hardware support where possible.
About tracking issues
Tracking issues are used to record the overall progress of implementation. They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. A tracking issue is howevernot meant for large scale discussion, questions, or bug reports about a feature. Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
- Implement the RFC (see the below section for details)
- Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved questions
- Do any new target features need to be marked as "forbidden" since they affect ABI? The logichere looks like that may be the case.
Implementation history and Future Steps
- Add basic support stubs to IR and backend interfaces:Add stubs in IR and ABI for
f16andf128#121728 - Add AST support and intrinsics:
f16andf128step 2: intrinsics #121841 (comment) - Connect the frontend, add the feature gate:
f16andf128step 3: compiler support & feature gate #121926 - Add the most basic traits that
rustcmore or less expects for primitivesAdd basic trait impls forf16andf128#123085 - Finish support in rustdocAdd
f16andf128to rustdoc'sPrimitiveType#123581 - Add library support.
Some parts are blocked on const eval, compiler builtins updates, and LLVM lowering bugs.hooray, this part is done!f16andf128step 4: basic library support #122470- Add a
Debugimpl and some basic functions tof16andf128#123783 - Add constants for f16 and f128 #123850
- Add more constants, functions, and tests for
f16andf128#126608 - Add classify and related methods for f16 and f128 #127020
- Add
f16andf128math functions #127027
- Add needed functions to compiler-builtins. Unfortunately this one will block almost everything else on the list.
- Add builtins for
f16/f128float conversions compiler-builtins#593 - Add addition, subtraction, multiplication, and compare operations for
f128compiler-builtins#606 - Add
f128float to integer conversion functions compiler-builtins#613 - Add f128 int to float conversions compiler-builtins#624
- Add
__divtf3compiler-builtins#622 - Add
__powitf2symbol forf128integer exponentiation compiler-builtins#614 - Others
- Add builtins for
- Figure out parsing and printing
- Migrate the tester to accept more typesRewrite
test-float-parsein Rust #127510 - Add
f16, which should be straightforwardAddf16formatting and parsing #127013 - Figure out
f128which will not be straightforward. Our current implementations are prettyu64-dependent so they can't fit af128mantissa. We could make them generic but probably want to instead use an implementation that is slower but better for size.
- Migrate the tester to accept more typesRewrite
- Update const eval
- Basic arithmeticAdd
f16andf128const eval for binary and unary operationations #126429 - CastingEnable const casting for
f16andf128#127032 - Miri shims
- Basic arithmeticAdd
- Figure out mangling
Add encoding forAdd v0 symbol mangling forf16andf128#122106f16andf128#123816 Ensure known demanglers get updated or at least have issues for adding the new typesunneeded with the forward-compatible demangling- Add SIMD operations that can make use of these typesAdd SIMD operations that use f16 and f128 #125440
- Implement AVX512_FP16 stdarch#1605
- NVPTX: Add f16 SIMD intrinsics stdarch#1626
- others (help welcome)
- Enable assembly registers where it makes senseEnable
f16andf128in assembly on platforms that support it #125398 - Make sure the GCC and Clif backends handle these types gracefully
- Support
f16andf128rustc_codegen_gcc#461 - Support
f16andf128rustc_codegen_cranelift#1461 - Migrate float intrinsics to have a fallback (changes fromWishlist: allow adding intrinsics in a way that doesn't break every backend #93145)
- Support
- Make sure all relevant
unimplementeds andFIXMEs are removed from tools that need library support - Make use of new diagnostic attributes:
f16_nanAddf16andf128toinvalid_nan_comparison#132439f16_epsilonfor Clippy (needs to be added)
- Figure out ABI & platform-specific problems (thanks@beetrees for just about all of these)
- f16 ABI bugs in compiler-rt
f16generates code that uses the incorrect ABI for compiler-rt #123885 - 32-bit ABI bugs from LLVM[clang] missing support for _Float128 (C23) llvm/llvm-project#80195 (comment)
- f16 miscompilations from LLVM (affects T2 and T3 targets)LLVM miscompiles consecutive
halfoperations by using too much precision on several backends llvm/llvm-project#97975LLVM miscompiles passing/returninghalfon several backends by using lossy conversions llvm/llvm-project#97981 - f16 abs and neg quieten signalling NaNs on emulated targets[X86] LLVM >= 18 folding bitcast -> and -> bitcast to
@llvm.fabs.f16generates call to__extendhfsf2llvm/llvm-project#104915 (comment) - x86-32 "f16" ABI needs SSE, incompatible with i586 targets #131819
- Tier 1 MinGW f16/f128 incompatibilities from GCChttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054
- Tier2 PowerPC BE precision issues
f128symbols on powerpc64 give inaccurate results #125109 - Tier2 Power9 possible ABI issues
f128from_bits/to_bitssometimes gets reversed on ppc #125102 - Tier2 PowerPC LE
f128 as f16casting bugLLVM f128 -> f16 conversion selection failure on powerpc64le llvm/llvm-project#92866 - Tier 2 PowerPC f16<->f128 sometimes uses the wrong symbol namesPowerPC
fp128->halfuses__trunctfhf2but should be__trunckfhf2llvm/llvm-project#98126 - Tier 2 Loongarch failure to selectloongarch64 half (f16) failure to select with
+fand+dllvm/llvm-project#93894 (fixed upstream) - Tier 2 arm64ec does not support these typesCan't pass or return
halforfp128onarm64ecllvm/llvm-project#94434 (f16 supported since[Arm64EC] Add support forhalfllvm/llvm-project#152843) - Tier 2 aarch64-*-softfloat has crashes with f16[AArch64]
-fp-armv8crash usingselectwithhalfllvm/llvm-project#129394 - Tier 2 s390x-unknown-linux-gnu doesn't support f16:SystemZ Backend: Add support for operations such as FP16_TO_FP and FP_TO_FP16 llvm/llvm-project#50374
- Tier 2 wasm32 correctness bugOn
wasm32,halfoperation results aren't correctly rounded between each operation llvm/llvm-project#96437 - Tier 2 nvptx64-nvidia-cuda doesn't support f128:
fp128causes compilation failures when compiling fornvptx64-nvidia-cudallvm/llvm-project#95471 - Tier 3 mips LLVM crashes with
f128Compiler crash when targetingmips64when returningfp128after calling a function returning{ i8, i128 }llvm/llvm-project#96432 - Tier 3 sparc-unknown-linux-gnu doesn't support passing f128 directly (error message SPARCv8 does not handle f128 in calls; pass indirectly):Passing long double args on 32-bit SPARC violates ABI llvm/llvm-project#41838
- Tier 3
powerpc64-ibm-aixdoesn't currently supportf128arguments:fp128arguments cause a compiler error onpowerpc64-ibm-aixllvm/llvm-project#101545 - Generally go throughThe ABI of float types can be changed by
-Ctarget-feature#116344 (and in particularFigure out which target features are required/incompatible for which ABI #131799) for all targets; those issues are mostly focusing on f32 and f64 so there might be more target features we have to worry about for f16/f128 (seef16 and f128 have non-trivial ABI requirements on some targets #138616) - Intrinsics for
minimumandmaximumdon't work on x86 and aarch64[aarch64]Cannot select: constant:i128<0>forllvm.maximum.f128llvm/llvm-project#139380[x86]: Cannot select:constant:i128<0>forllvm.maximum.f128llvm/llvm-project#139381 (nonblocking as we are using the fallback for now)
- f16 ABI bugs in compiler-rt
- Other misc miscompilations or bugs
- LLVM does
fma.f16incorrectlyllvm.fma.f16intrinsic is expanded incorrectly on targets without nativehalfFMA support llvm/llvm-project#98389 powi.f16constant folding returns incorrect valuesMisoptimization:EarlyCSEPassuses replacespowi.f16withfloatresult llvm/llvm-project#98665
- LLVM does
- Implement an internal
cfgthat lets us gate tests based on backend supportImplement the internal featurecfg_target_has_reliable_f16_f128#140323 - Eventually, stabilization
Note thatunimplemented!("f16_f128") and// FIXME(f16_f128) is being used where relevant, to make the todo list easily greppable.
Nice to have changes:
- Better debuginfo for MSVCImprove MSVC debug info for f16 and f128 #121837
- A bit of ecosystem support
- Rust-analyzerAdd
f16andf128support (add toFloatTy) rust-analyzer#17451 - BytemuckSupport
f16andf128under a nightly flag Lokathor/bytemuck#250 - ZerocopyAdd support for the unstable f16 and f128 types google/zerocopy#2042
- Serdeadd f16 and f128 support serde-rs/serde#2941
- numAdd f16, f128 rust-num/num-traits#333
- rughttps://gitlab.com/tspiteri/rug/-/issues/68
- syntax highlighters
- Rust-analyzerAdd