rust-lang / rust-lang/rust

x86 softfloat target: no way to get LLVM to make local use of the FPU or SIMD registers

Open
#136,540 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-floating-point A-LLVM A-SIMD C-bug C-external-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Some softfloat targets are used in environments where an FPU and SIMD registers are present, but should not be used by default -- in particular, this is fairly common in kernels. It should be possible to still locally enable the use of these CPU features; this just adds a precondition to the function to make FPU and SIMD ready for use by the kernel before invoking this code.

This works fine on arm-32 by picking a softfloat ABI (i.e., a *eabi target) and then enabling the right target features on a function-by-function basis. However, for x86 (32bit and 64bit), this does not work: there is no dedicated ABI flag supported by LLVM here; instead, our soft-float targets work by setting target features to something like -x87,-mmx,-sse,+soft-float. When both the soft-float and the sse2 target feature are set, soft-float takes priority (example). We cannot let people disable soft-float on a per-function basis as that would change the ABI.

Ultimately this is caused by the fact that LLVM doesn't have a proper float ABI designation for x86; instead, the float ABI is inferred from target features such as soft-float. If we could set the float ABI directly like we can on arm-32, we could let people disable soft-float on a per-function basis (probably via a hard-float target feature, no need to make this a negative feature) and thus LLVM could generate code making proper use of the FPU.

Cc @nikic @workingjubilee @briansmith

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

Start by reviewing the x86 soft-float target-feature handling described in the issue and compare it with the arm-32 *eabi behavior. Investigate how LLVM infers the x86 float ABI and how per-function features interact with soft-float. Done means local FPU and SIMD use can be enabled without changing the target ABI.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.