public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Richard Sandiford <rdsandiford@googlemail.com>
To: "Jürgen Urban" <JuergenUrban@gmx.de>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] Support for MIPS R5900 (Sony Playstation 2)
Date: Sun, 25 Nov 2012 11:17:00 -0000	[thread overview]
Message-ID: <87obimszj0.fsf@talisman.default> (raw)
In-Reply-To: <20121124173446.247380@gmx.net> (=?utf-8?Q?=22J=C3=BCrgen?= Urban"'s message of	"Sat, 24 Nov 2012 18:34:46 +0100")

Hi Jürgen,

"Jürgen Urban" <JuergenUrban@gmx.de> writes:
> It would be nice when this can be added to the offical binutils. Please
> tell me if this acceptable or there is a problem.

I suppose the main potential barrier is whether the copyright can still
be assigned to the FSF.  I imagine this code has been worked on by
several people over the years.  Is that right?  If so, I think they
would all need to sign a copyright assignment.

Are there still remnants of the original Cygnus implementation, or was
this written from scratch?  There was often talk at Cygnus/Red Hat of
formally submitting the port (along with the tx79), but it never happened
due to lack of time.

I'll hold off a full review until the copyright situation is clearer,
but generally the patch looks good.  There shouldn't be any major
technical obstacles to getting the support in.

Some specific comments:

> The R5900 CPU is used as the main processor in the Sony Playstation 2 (ps2).
> The CPU supports MIPS ISA I, II, III and IV, but not all
> instructions. There are only few instructions which are MIPS IV, so it
> is configured as MIPS III in binutils.
> R5900 supports 32-bit, 64-bit and 128-bit data transfers and registers.
> The address bus is 32-bit. There fore the CPU can run MIPS ABI o32 and
> n32 code. o64 and n64 code would run until an address outside the first
> 4 GByte is addressed (Indeed the PS2 has 32 MByte RAM and the PS2 Tool
> has 128 MByte).

FWIW, o64 is like n32: an ABI for 64-bit targets that uses 32-bit ELF.
By default it has 32-bit pointers and longs, although some people have
used it with -mlong64.  It shouldn't really be used in new code though.

The mips64*-ps2-elf* stanzas in config.bfd include the n64 vectors,
which is good.  So even if o64 and n64 aren't supported at runtime,
we should still be able to assemble o64 and n64 code.  The "n32native"
part of the testsuite patch doesn't look right from that point of view,
although it looks like "!n32native" might actually be skipping based
on something other than the ABI.

> - Support for VU instructions of the COP 2 (VU0 in Macro Mode). This
> includes special register suffixes.

We're running very short of single character operand markers, so for:

+   VU0 Macromode:
+   "+m" vu0 immediate for viaddi (OP_*_VADDI)
+   "+5" vu0 fp reg position 1 (OP_*_VUTREG)
+   "+6" vu0 fp reg position 2 (OP_*_VUSREG)
+   "+7" vu0 fp reg position 3 (OP_*_VUDREG)
+   "+8" vu0 int reg position 1 (OP_*_VUTREG)
+   "+9" vu0 int reg position 2 (OP_*_VUSREG)
+   "+0" vu0 int reg position 3 (OP_*_VURREG)
+   "+d" vu0 fp reg with ftf modifier (OP_*_VUTREG and OP_*_VUFTF)
+   "+e" vu0 fp reg with fsf modifier (OP_*_VUSREG and OP_*_VUFSF)
+   "+f" Immediate operand for vcallms instruction. (OP_*_VUCALLMS)
+   "+i" vu0 I register
+   "+q" vu0 Q register
+   "+r" vu0 R register
+   "#" optional suffix that must match if present
+   "=" dest operant completer, must match previous dest if present
+   "?" dest instruction completer (OP_*_VUDEST)
+   ";" dest instruction completer, must by xyz
+   "_" vu0 ACC register

I think all the operands should have a prefix (i.e. the last 5 too).
Same for the ++/-- formats.

> - Detecting of short loops because of a CPU bug (minimum number of
> instructions needed in a conditional loop).

I haven't looked at this in detail, but I noticed:

+  /* On R5900 short loops need to be fixed by inserting a nop in
+     the branch delay slots.
+     A short loop can be terminated too early.  */
+  if (mips_opts.arch == CPU_R5900
+      /* Check if instruction has a parameter, ignore "j $31". */
+      && (address_expr != NULL)
+      /* Parameter must be 16 bit. */
+      && (*reloc_type == BFD_RELOC_16_PCREL_S2)
+      /* Branch to same segment. */
+      && (S_GET_SEGMENT(address_expr->X_add_symbol) == now_seg)
+      /* Branch to same code fragment. */
+      && (symbol_get_frag(address_expr->X_add_symbol) == frag_now)

Even tight loops can be split over several frags.  The start of the loop
might have been at the very end of the buffer allocated for one frag, or
the loop might contain a macro-derived variant instruction, etc.

> - New parameter "-mhard-ldsd" to support ld and sd instructions in MIPS
> ABI o32. This is needed to compile the Linux kernel with support for 64
> bit registers, because otherwise the instructions ld and sd are replaced
> by lw and sw.

It seems dangerous to ignore HAVE_64BIT_GPRs in this one instance
(and only this one instance).  Could you explain in more detail
in which situations the kernel needs to use LD and SD?

> - The "-mtune=r5900" parameter forces "-march=r5900", because this is
> the only configurable option of GCC to support R5900 as default with
> mips64el-linux-gnu or mipsel-linux-gnu.

FWIW, the defaults for both -march and -mtune can be set when GCC is
configured (using --with-arch and --with-tune respectively).

-mtune must never change the architecture.  I'm afraid that rule
has to win over anything R5900-specific.

Richard

  reply	other threads:[~2012-11-25 11:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-24 17:35 "Jürgen Urban"
2012-11-25 11:17 ` Richard Sandiford [this message]
2012-11-25 23:37   ` "Jürgen Urban"
2012-12-04  0:03 "Jürgen Urban"
2012-12-21 23:02 "Jürgen Urban"
2013-01-03  8:40 ` nick clifton
2013-01-03 18:34   ` "Jürgen Urban"
2013-01-04 17:24     ` nick clifton
2013-01-07 21:21       ` Maciej W. Rozycki
2013-01-08 21:48         ` "Jürgen Urban"
2013-01-10 23:19           ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87obimszj0.fsf@talisman.default \
    --to=rdsandiford@googlemail.com \
    --cc=JuergenUrban@gmx.de \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).