rust-lang / rust-lang/rustc_codegen_gcc

Fix for memory operands

Open
#584 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

It seems if we were to allow setting the asm dialect, we would not need to use -masm=intel to fix the issue with memory operands in inline asm.

Notes from IRC:

what I suggest is you need to add a new field to pass all the way down for inline-asm (ASM_INPUT/ASM_OPERANDS) to specify the asm variant and have a target hook to change the syntax during processing of inline-asm
memory operands in AT&T syntax is different from Intel syntax
GCC inline-asm can be indepedent of the variant of syntax even
see https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Extended-Asm.html#Multiple-assembler-dialects-in-asm-templates
in C you can add an attribute called asm_dialect which accepts a string and that string can be compared against different strings from a target hook which returns the dialect #. this is how you can support it in the rust front-end too via a target hook
the idea is front-ends should almost know anything about targets and everything should be a target hook (or a virtual function call); don't copy clang and their front-end idea of not using target hooks

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 tracing how inline assembly operands, including ASM_INPUT and ASM_OPERANDS, are processed and where target hooks can affect syntax. Review GCC's multiple assembler dialects documentation and the proposed asm_dialect attribute. Done means memory operands work without requiring -masm=intel and the dialect can flow through the relevant frontend and target-hook paths.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.