x86/MMX/SSE shift by immediate

Richard Henderson rth@redhat.com
Wed Jan 7 22:45:00 GMT 2004


On Wed, Jan 07, 2004 at 02:36:13PM -0800, Stuart Hastings wrote:
> Yes, both of the CPUID instructions here kill %eax, %ebx, %ecx, and 
> %edx.  However, if I admit as much in the __asm__, and I compile with 
> -fPIC (default on Darwin/x86), GCC stops here with the diagnostic
> 
> 	/Volumes/sandbox/stuart/gcc.fsf/gcc/testsuite/gcc.dg/i386-cpuid.h:39: 
> error: PIC register `ebx' clobbered in `asm'
> 
> Ergo, I chose to lie to GCC about the CPUID instruction.  :-(  I really 
> dislike doing this; sleazy tricks like this usually cause maintenance 
> headaches later on (e.g. if GCC gets smarter about the PIC register, we 
> could and should describe CPUID correctly here).  Do you know a better 
> way?

	__asm__ ("push %ebx; cpuid; pop %ebx"
		 : "=a" (fl1)
		 : "0" (0)
		 : "ecx" "edx", cc");

Ok with that fix.  Which also removes the need for the nowhere
call too, right?


r~



More information about the Gcc-patches mailing list