extended asm - what does this option do?
Kalle Olavi Niemitalo
kon@iki.fi
Thu Apr 18 06:38:00 GMT 2013
dw <limegreensocks@yahoo.com> writes:
> Q1: So what's the difference between %k1 and just %1?
"k" and other codes are documented in comments above
gcc/gcc/final.c (output_asm_insn) and gcc/gcc/config/i386/i386.c
(ix86_print_operand). On i386, "k" means use a SImode (32-bit
integer) register. So if you have...
#define __cpuid(level, a, b, c, d) \
__asm__ __volatile__ ("xchg{l}\t{%%}ebx, %k1\n\t" \
"cpuid\n\t" \
"xchg{l}\t{%%}ebx, %1\n\t" \
: "=a" (a), "=&r" (b), "=c" (c), "=d" (d) \
: "0" (level))
int
fun (void)
{
long long a, b, c, d;
__cpuid(0, a, b, c, d);
return a;
}
... then the "%k1" might expand to "%r13d" but the "%1" to "%r13".
> Q2: And while I'm asking, what's with the {braces} in the asm?
Apparently, "{foo|bar}" becomes "foo" with -masm=att but "bar"
with -masm=intel. I didn't find this in the documentation.
It's implemented in gcc/gcc/final.c (do_assembler_dialects).
More information about the Gcc-help
mailing list