2fcaa549a8 (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
27 lines
799 B
C
27 lines
799 B
C
// REQUIRES: x86-registered-target
|
|
/// AT&T input
|
|
// RUN: %clang_cc1 -triple x86_64 -S --output-asm-variant=0 %s -o - | FileCheck --check-prefix=ATT %s
|
|
// RUN: %clang_cc1 -triple x86_64 -S --output-asm-variant=1 %s -o - | FileCheck --check-prefix=INTEL %s
|
|
|
|
/// Intel input
|
|
// RUN: %clang_cc1 -triple x86_64 -S -D INTEL -mllvm -x86-asm-syntax=intel -inline-asm=intel %s -o - | FileCheck --check-prefix=INTEL %s
|
|
// RUN: %clang_cc1 -triple x86_64 -S -D INTEL -mllvm -x86-asm-syntax=intel -inline-asm=intel --output-asm-variant=1 %s -o - | FileCheck --check-prefix=INTEL %s
|
|
|
|
// ATT: movl $1, %eax
|
|
// ATT: movl $2, %eax
|
|
|
|
// INTEL: mov eax, 1
|
|
// INTEL: mov eax, 2
|
|
|
|
#ifdef INTEL
|
|
asm("mov eax, 1");
|
|
void foo() {
|
|
asm("mov eax, 2");
|
|
}
|
|
#else
|
|
asm("mov $1, %eax");
|
|
void foo() {
|
|
asm("mov $2, %eax");
|
|
}
|
|
#endif
|