[PATCH] PPC64 Poor assembly coding style

Benjamin Herrenschmidt benh at kernel.crashing.org
Tue Nov 9 09:33:56 EST 2004


On Mon, 2004-11-08 at 12:16 -0600, Linas Vepstas wrote:
> Hi,
> 
> Doug Maxey reported a bug with the latest/greatest gas assembler
> that demonstrates some poor coding style in entry.S and head.S.
> The following patch cleans up that style, and also avoids assembler
> confusion.  Basically, in entry.S,
> 
>  cmpldi  0,r0,NR_syscalls   should be written as either
> 
>  cmpldi  r0,NR_syscalls   or as    cmpldi  cr0,r0,NR_syscalls
> 
> All three forms are theoretically equivalent; in practice,
> I find the first alternative the cleanest (and also consistent
> with usage elsewhere in the files).
> 
> The new assembler seems to be mistaking NR_syscalls for a register
> number, which is clearly out of bounds (its not in 0..31).
> I think it would be cleaner overall to just drop the superfluous
> leading cr0.  There are two other confusing usages, in head.S:
> I propose that
>   cmpldi  cr0,r5,0 should be cmpldi  r5,0
>   cmpld   0,r6,r5  should be cmpld   r6,r5

I dont agree with "poor coding style" here, and you should remember that
this code has been worked on by different people with different habits.
Besides, gas does not know those register names, so the above is
actually cmpldi 0,5,0 and cmpld 0,6,5 and writing that is perfectly
valid.

We defined some macros for register names to make things easier in the
kernel, but they are not mandatory at all.

Removing the first argument is an accepted construct, but in no way it
"should" been done that way.

In fact, I'd rather _add_ the implicit first argument in all cases to
avoid confusion. You are welcome to submit a patch doing so, but please,
avoid naming it "poor coding style" ...

Ben.





More information about the Linuxppc64-dev mailing list