This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bug report (reverse_bits asm)


Zack Weinberg wrote:
>  asm ("decl %2
> rev1:
>        rcrl $1,%3
>        rcll $1,%0
>        loop rev1" : "=r" (res) : "0" (res), "c" (len), "d" (code));
>
> Two additional notes: you should use a 'local label', so you can
> inline this function safely, and you should let the compiler do as
> much of the register allocation as possible.  The only instruction
> that cares which register something's in is 'loop', so:

 Just a tip: use the %= feature:

asm ("decl %2
  .L%=rev1:
      rcrl $1,%3
      rcll $1,%0
      loop .L%=rev1"
     : "=r" (res) : "0" (res), "c" (len), "d" (code));

  So then you can declare the function:
static inline unsigned reverse_bits(unsigned value, int len)
  {
  }

  And do not need the __fastcall, i.e. regparm(3).

  I would use a byte translation array for such a task,
 if I had some speed concern.

  Hope that helps,
  Etienne.
___________________________________________________________
Do You Yahoo!?
Achetez, vendez! À votre prix! Sur http://encheres.yahoo.fr

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]