Skip to content

Enable f16 and f128 in assembly on platforms that support it #125398

Closed

Description

@tgross35

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:

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=pwr9 seems to have f128 support via instructions like xsaddqp

Tracking issue: #116909

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 22, 2024
  2. tgross35 commented on May 22, 2024

    @tgross35
    MemberAuthor

    I'm adding E-Easy because a PR that just enables support for aarch64 should be pretty easy, start around

    ty::Float(FloatTy::F32) => Some(InlineAsmType::F32),
    ty::Float(FloatTy::F64) => Some(InlineAsmType::F64),
    and massage the new types in. Actually figuring out rules for the rest of the platforms will be harder, but that can come later.

    Sample for reference: https://rust.godbolt.org/z/zK4qha1qo

    @rustbot label +T-compiler +E-Easy +F-f16_and_f128 +A-inline-assembly -needs-triage

  3. added
    A-inline-assemblyArea: Inline assembly (`asm!(…)`)
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    F-f16_and_f128`#![feature(f16)]`, `#![feature(f128)]`
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 22, 2024
  4. lengrongfu commented on Jun 6, 2024

    @lengrongfu
    Contributor

    @tgross35 I can try to submit a PR, can you give me some guidance?

  5. tgross35 commented on Jun 6, 2024

    @tgross35
    MemberAuthor

    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 F16 to InlineAsmType and 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.

  6. changed the title [-]Enable `f16` in assembly on platforms that support it[/-] [+]Enable `f16` and `f128` in assembly on platforms that support it[/+] on Jun 7, 2024
  7. added a commit that references this issue on Jun 7, 2024
  8. added 2 commits that reference this issue on Jun 15, 2024
  9. added a commit that references this issue on Jun 15, 2024
  10. added a commit that references this issue on Jun 22, 2024
  11. 43 remaining items

  12. added 2 commits that reference this issue on Sep 22, 2026
  13. added a commit that references this issue on Sep 23, 2026
  14. folkertdev commented on Sep 23, 2026

    @folkertdev
    Contributor

    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?

  15. tgross35 commented on Sep 23, 2026

    @tgross35
    MemberAuthor

    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.

  16. beetrees commented on Sep 23, 2026

    @beetrees
    Contributor

    All rustc targets 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 ASM f16 to SPIR-V, but I think apart from that this is complete.

  17. added 2 commits that reference this issue on Oct 1, 2026
    cd365c0
    d0052d5
  18. added a commit that references this issue on Oct 1, 2026
    77bd2a9
  19. added a commit that references this issue on Oct 2, 2026
    ee449d2
  20. added a commit that references this issue on Oct 6, 2026
    89bc0fb
  21. added a commit that references this issue on Oct 12, 2026
    6923e48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-inline-assemblyArea: Inline assembly (`asm!(…)`)E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.F-f16_and_f128`#![feature(f16)]`, `#![feature(f128)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions