rust-lang / rust-lang/rustc_codegen_gcc

Support f16 on targets where GCC doesn't support it

Open
#825 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
1.2k
Forks
105
Avg merge
8h 20m
Merged PRs (30d)
14

Description

@tgross35 mentioned we could support it the following way:

1. Treat it as a u16 in ABI (calling convention, alignment, etc)
2. To extend: call `__extendhfsf2` for f16->f32, `__extendhfdf2` for f16->f64
3. To trunc: call `__truncsfhf2` for f32->f16, `__truncdfhf2` for f64->f16
4. For arithmetic: extend to `f32`, perform the op, truncate back to `f16`
5. For casts to/from int: go via f32
6. For math ops: if I get https://github.com/rust-lang/rust/pull/150946 over the line then this won't be needed in most cases, but anything else can go via f32

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests; begin by locating existing f16 handling in the Rust GCC codegen backend and the ABI, conversion, arithmetic, cast, and math entry points. Use the listed helper symbols and rust-lang/rust pull request 150946 as context, and consider the work done when all six cases operate on targets where GCC lacks native f16 support.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.