This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch to implement rotates by zero


At Tue, 20 Aug 2002 13:19:12 +0000 (UTC), "Maciej W. Rozycki" wrote:
> On 17 Aug 2002 cgd@broadcom.com wrote:
> > AFAIK, 'sll' w/ a shift of 0 is only guaranteed to sign-extend by
> > MIPS64.  I've seen no previous documentation that defined that it must
> > work that way.
> 
>  Well, the behaviour is defined explicitly for "sll" and "sllv" by "MIPS
> R4000 Microprocessor User's Manual" (pp. A-140, A-141), the original spec
> for the original MIPS III processor, so the assumption should be any MIPS
> III+ implementation must do them this way; otherwise it is non-compliant
> (or simply broken).

So, i did some more looking.

points that agree with you:

* All of the specific processor user manuals i checked have similar
  wording re: sll doing a sign extension even for not-sign-extended
  64-bit inputs, but i didn't check many.

* I checked the r4k UM and it does in fact match what you said, _but_
  I do note that the PDF I have (second edition, from the MIPS web
  site IIRC), same pages as you mention, has change bars next to the
  statements in sll/sllv descriptions which define this behaviour.  I
  don't know how first edition looked (or how the earliest r4k parts
  behaved).

* An ancient MIPS IV ISA document i got from the SGI web or FTP site
  once ("it was a while ago") agrees.  (it also has the
  broken-assembler caveat.)

points that don't (but don't strongly disagree wither):

* MIPS RISC Architecture (Kane & Heinrich -- the version updated for
  r4000) makes no specific mention of this behaviour.  (it doesn't
  provide the description about unpredictable operation for the
  not-sign-extended 64-bit operands, either, though.  Arguably, this
  is more of an 'architecture' reference than the r4k UM is... but,
  well, this isn't a great book IMO.  8-S)

* similarly, See MIPS Run doesn't mention this sign-extending
  behaviour, either, at least not in the most obvious-to-me places.
  (IMO, for precise instruction descriptions, though, this isn't the
  best book in the world either.)


Personally, I only use binutils as my assembler, and I only use mips64
parts these days... so doing what you suggest would be fine w/ me.

Looking at the documentation, I can't find any strong counterexamples
to your claim that using sll consistently to sign extend should be OK.
However, if it is used, and support for other assemblers is continued
in gcc there probably should be an autoconf test to see that the
assembler is OK.



cgd


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