Re: Proper use of x86/x86_64 CPUID instruction with extended assembler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/19/2015 10:06 AM, Jeffrey Walton wrote:
My question is, will the extended assembly preserve the registers? Is
it sufficient to list "b" as a clobber? Or do I need to do something
special?
It will not preserve the registers, except those that are required to by the
ABI ("b").  The clobber tells gcc which registers are destroyed by the
instruction, not which registers to preserve; it already knows the latter.

If I need to do something special, then what needs to be done?
Nothing much; just drop that "b" clobber.

(I also looked at
https://gcc.gnu.org/ml/gcc-patches/2007-09/msg00324.html, which is a
GCC patch for cpuid.h. But its not clear to me if the above is correct
because the operands are 32-bit in size. Naively, if I use "a" and "b"
with a 32-bit operand, then I would expect code for EAX and EBX; and
not RAX and RBX).
It is correct.
Thanks Avi. Regarding the GCC patch... if the output register and the
ABI tells GCC that EBX needs to be preserved, then why does the patch
take special steps to preserve it?



Well I just tried it, and gcc is indeed not clever enough to do this on its own. So it is needed.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux