rust-lang / rust-lang/rust

"--emit asm" uses different syntax than `asm!` on x86

Open
#121,592 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-contributor-roadblock A-inline-assembly C-enhancement T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Rust inline assembly expects to be written like this:

    crate::arch::asm!(
        "movntps [{mem_addr}], {a}",
        mem_addr = in(reg) mem_addr,
        a = in(xmm_reg) a,
    );

However, when dumping the output assembly via --emit asm, it looks like this:

	movntps	%xmm0, (%rdi)

Operand order is swapped, and it's using (%name) instead of [name]. I guess one is AT&T syntax and one is Intel syntax.

Would be good if Rust could be consistent with its own inline asm syntax. :)

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

Reproduce the issue with the shown x86 inline assembly and --emit asm output, then inspect the compiler path that emits assembly syntax. Compare the operand order and memory-operand notation with the inline asm syntax; done means the emitted assembly is consistent with the syntax accepted by asm!.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.