Support for MIPS r5900

"Jürgen Urban"
Sun Jan 6 22:57:00 GMT 2013


I created a patch from scratch to support MIPS r5900 used in the Playstation 2, but I have some problems with it.
The attached patch only works with the latest binutils from CVS. The binutils forces the compiler to use r5900 compatible instructions which is good to find errors in the GCC. Later I will try to submit a patch here, but first I need some help.
The MIPS r5900 supports 32 bit, 64 bit and 128 bit data accesses on a 32 Bit address bus. It supports instructions from MIPS ISA I, II, III, IV and has additional instructions, but none of them are complete. On each ISA level there are instructions missing.
It can run MIPS ABI o32, n32 and o64 code, as long as unsupported instructions are not used or emulated by the operating system and the addresses keep in the first 32 bit.
My patch adds support for r5900 and tries to disable the following unsupported instructions:
ll, sc, dmult, ddiv, cvt.w.s, 64 bit FPU instructions.
ll and sc is disabled with "-mno-llsc" and works.
cvt.w.s is replaced by trunc.w.s. This seems to work.
I disabled 64 bit FPU instructions by "-msoft-float". This works, but using "-msingle-float" fails. This would be the better configuration. There are still 64 bit FPU instructions used (e.g. "dmfc1   $2,$f0" when using "long double" multiplication). So "-msingle-float" doesn't seem to work on generic mips64-linux-gnu.
I tried to disable dmult and ddiv (see Disabling worked, but now muldi3 calls itself in libgcc2. I thought this should work, because I got this working with GCC 4.3, but the latest GCC version is a problem. multi3 is calling muldi3, so that muldi3 should be able to use mulsi3, because it is the same C code in libgcc2. Can someone get me some hints or comments? How can this be debugged?

Does someone know how to enable TImode in MIPS ABI o32 (this doesn't need to use the 128 bit instructions at the moment)? There is some old code for the Playstation 2 which needs this. I know that TImode is supported in ABI n32, but some code uses also the 32 bit FPU and FPU registers are not available with "-msoft-float" in inline assembler.

What is the best way to change the alignment to 128 bit for all structures and stack in any MIPS ABI? Much old code for the Playstation 2 expects this.

Best regards
Jürgen Urban
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-svn-20130105-mips-ps2.patch
Type: text/x-patch
Size: 26207 bytes
Desc: not available
URL: <>

More information about the Gcc-patches mailing list