[all-commits] [llvm/llvm-project] 4a9da9: [clang] Add cc1 --output-asm-variant= to set outpu...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Sep 24 15:59:55 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4a9da96dc68d878893399210888a03117b39b802
      https://github.com/llvm/llvm-project/commit/4a9da96dc68d878893399210888a03117b39b802
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-09-24 (Tue, 24 Sep 2024)

  Changed paths:
    M clang/include/clang/Basic/CodeGenOptions.def
    M clang/include/clang/Driver/Options.td
    M clang/lib/CodeGen/BackendUtil.cpp
    A clang/test/CodeGen/inline-asm-output-variant.c
    A clang/test/Misc/cc1as-output-asm-variant.c
    M llvm/include/llvm/MC/MCTargetOptions.h
    M llvm/lib/CodeGen/LLVMTargetMachine.cpp

  Log Message:
  -----------
  [clang] Add cc1 --output-asm-variant= to set output syntax

2fcaa549a824efeb56e807fcf750a56bf985296b (2010) added cc1as option
`-output-asm-variant` (untested) to set the output syntax.
`clang -cc1as -filetype asm -output-asm-variant 1` allows AT&T input and
Intel output (`AssemblerDialect` is also used by non-x86 targets).

This patch renames the cc1as option (to avoid collision with -o) and
makes it available for cc1 to set output syntax. This allows different
input & output syntax:

```
echo 'asm("mov $1, %eax");' | clang -xc - -S -o - -Xclang --output-asm-variant=1
```

Note: `AsmWriterFlavor` (with a misleading name), used to initialize
MCAsmInfo::AssemblerDialect, is primarily used for assembly input, not
for output.
Therefore,
`echo 'asm("mov $1, %eax");' | clang -x c - -mllvm --x86-asm-syntax=intel -S -o -`,
which achieves a similar goal before Clang 19, was unintended.

Close #109157

Pull Request: https://github.com/llvm/llvm-project/pull/109360



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list