[all-commits] [llvm/llvm-project] d4cb5d: [X86] Add "Ws" constraint and "p" modifier for sym...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Jan 16 23:57:53 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d4cb5d9f2ba636b0049fc5791d378e224e3a3ae7
      https://github.com/llvm/llvm-project/commit/d4cb5d9f2ba636b0049fc5791d378e224e3a3ae7
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-01-16 (Tue, 16 Jan 2024)

  Changed paths:
    M clang/lib/Basic/Targets/X86.cpp
    M clang/test/CodeGen/X86/inline-asm-constraints.c
    M clang/test/Sema/inline-asm-validate-x86.c
    M llvm/docs/LangRef.rst
    M llvm/lib/Target/X86/X86AsmPrinter.cpp
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    A llvm/test/CodeGen/X86/inline-asm-Ws-constraint-error.ll
    A llvm/test/CodeGen/X86/inline-asm-Ws-constraint.ll

  Log Message:
  -----------
  [X86] Add "Ws" constraint and "p" modifier for symbolic address/label reference (#77886)

Printing the raw symbol is useful in inline asm (e.g. getting the C++
mangled name, referencing a symbol in a custom way while ensuring it is
not optimized out even if internal). Similar constraints are available
in other targets (e.g. "S" for aarch64/riscv, "Cs" for m68k).

```
namespace ns { extern int var, a[4]; }
void foo() {
  asm(".pushsection .xxx,\"aw\"; .dc.a %p0; .popsection" :: "Ws"(&ns::var));
  asm(".reloc ., BFD_RELOC_NONE, %p0" :: "Ws"(&ns::a[3]));
}
```

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105576




More information about the All-commits mailing list