[llvm] X86: Support dollar symbol for AT&T syntax and add output-asm-variant to llc (PR #147876)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 9 22:15:33 PDT 2025


MaskRay wrote:

> In your commit I suspect this will not be correct: `calll ($hen at PLT)` It should be `calll ($hen)@PLT`. The modifier is not to be mistaken as part of the symbol.

Both  `calll ($hen at PLT)` and `calll ($hen)@PLT` are assembled correctly in GAS and LLVM integrated assembler.
This patch prints the first form as it minimizes changes to the generic MCAsmInfo::printExpr MCExpr::print.

> As said earlier the at&t syntax is just nonsense like in `movl ($a)+16(%rip), %eax`. Only the symbol itself should be quoted.

Both `movl ($a)+16(%rip), %eax` and `movl ($a+16)(%rip), %eax` are acceptable.

In MC, $a+16 is encoded as:

```
MCBinaryExpr +
  MCSymbolRefExpr $a
  MCConstantExpr 16
```

To handle this and deeper nesting, the PR uses a straightforward approach that checks if the output begins with `$`, avoiding the complexity of examining the outermost MCExpr's structure (MCSymbolRefExpr, MCBinaryExpr, or MCSpecifierExpr).


https://github.com/llvm/llvm-project/pull/147876


More information about the llvm-commits mailing list