rust-lang / rust-lang/rust

Moving WebAssembly inline assembly forward

Open
#136,382 24 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-inline-assembly C-discussion O-wasm T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

View all comments

I'm opening this issue to consolidate some scattered discussion about what is needed to make inline assembly for Wasm work. This is tracked along with the other architectures at https://github.com/rust-lang/rust/issues/93335. That thread notes:

  • It must have clobber_abi.
  • It must be possible to clobber every register that is normally clobbered by a function call.
  • Generally review that the exposed register classes make sense.

So, for Wasm specifically:

  1. Syntax seems to be the biggest question (see below discussion), WAT vs. LLVM's format
  2. There are not any registers to be clobbered. Should there be some way to indicate the asm clobbers the top N elements on the stack?
  3. Should we be restricting dir specs (in, out, lateout, inout, inlateout) or options (pure, nomem, readonly, preserves_flags, noreturn, nostack, raw)? We should probably reject preserves_flags. I'm not sure if lateout and inlateout make sense.
  4. Is the LLVM side generally considered stable? It appears unchanging, but I don't see any of its constraints documented in langref https://llvm.org/docs/LangRef.html#inline-asm-constraint-string

Cc @daxpedda @hanna-kruppe @alexcrichton @hoodmane @solomatov, I think you have all been involved in the wasm-inline-asm discussion in different places.

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 with the related issue #93335 and the LLVM inline-assembly constraint documentation linked in this issue. Review the open Wasm questions about syntax, stack clobbers, operand directions, options, and LLVM stability. Done means the required behavior and constraints for Wasm inline assembly are resolved clearly enough to guide implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.