With this,
void f() { __asm__("mov eax, ebx"); }
now compiles with clang with -masm=intel.
This matches gcc.
The flag is not accepted in clang-cl mode. It has no effect on
MSVC-style __asm {} blocks, which are unconditionally in intel
mode both before and after this change.
One difference to gcc is that in clang, inline asm strings are
"local" while they're "global" in gcc. Building the following with
-masm=intel works with clang, but not with gcc where the ".att_syntax"
from the 2nd asm() is in effect until file end (or until a
".intel_syntax" somewhere later in the file):
__asm__("mov eax, ebx"); __asm__(".att_syntax\nmovl %ebx, %eax"); __asm__("mov eax, ebx");
This also updates clang's intrinsic headers to work both in
-masm=att (the default) and -masm=intel modes.
The official solution for this according to "Multiple assembler dialects in asm
templates" in gcc docs->Extensions->Inline Assembly->Extended Asm
is to write every inline asm snippet twice:
bt{l %[Offset],%[Base] | %[Base],%[Offset]}
This works in LLVM after D113932 and D113894, so use that.
(Just putting .att_syntax at the start of the snippet works in some but not
all cases: When LLVM interpolates in parameters like %0, it uses at&t or
intel syntax according to the inline asm snippet's flavor, so the .att_syntax
within the snippet happens to late: The interpolated-in parameter is already
in intel style, and then won't parse in the switched .att_syntax)
It might be nice to invent a #pragma clang asm_dialect push "att" /
#pragma clang asm_dialect pop to be able to force asm style per snippet,
so that the inline asm string doesn't contain the same code in two variants,
but let's leave that for a follow-up.
Fixes PR21401 and PR20241.
the 'l' suffix is probably not even needed for any of these movs?