grub-devel
[Top][All Lists]
Advanced

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

Re: Endianness macros capitalization


From: Pavel Roskin
Subject: Re: Endianness macros capitalization
Date: Wed, 09 Jul 2008 13:57:30 -0400

On Wed, 2008-07-09 at 14:50 +0200, Christian Franke wrote:

> Overall size from inline asm would only be smaller if there is any
> benefit from additional optimizations.

Correct.  Function calls use fixed registers for everything, but macros
don't have to.

> Result with the test script from my last mail:
> 
> Debian gcc 4.1.2-7:
> inline (portable)=357, inline (asm)=126, function=104
> 
> Cygwin gcc 3.4.4:
> inline (portable)=340, inline (asm)=124, function=96
> 
> Function call is still better. The only candidate for inline is probably
>  grub_swap_bytes16().

But we are getting closer!

> > .... And if written properly, it could work with any of
> > the registers that allow access to the lower two bytes (%eax, %ebx,
> > %ecx and %edx), thus giving more flexibility to the optimizer.
> > 
> 
> This would require support to access the Rl and Rh parts of eRx for each
> R in [a-d]. Something like:
> 
>    asm (
>         "xchg %0:l,%0:h\n"
>         "roll $0x10,%0\n"
>         "xchg %0:l,%0:h\n"
>         : "=r"(_y) : "0"(_x) \
>     );
> 
> Do gcc or gas provide a syntax to do this?

Yes.  That's %b0 and %h0.  Use "=q" for all registers with "upper
halves" (%ah-%dh).

Also, please be consistent and use width suffixes everywhere.  xchg
should be xchgb.

-- 
Regards,
Pavel Roskin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]