Hello Maciej,

> > > 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.
> > 
> > Probably showing my ignorance, but I couldn't see this in the patch.
> 
>  This has raised my attention -- AFAICS the binutils change recently 
> approved correctly disables DMULT, DDIV, CVT.W.S, etc. for -march=r5900, 
> but does not do that for LL or SC.  I think that should be fixed.  And I 
> gather LLD and SCD should then be disabled as well.

The glibc can only be compiled with support for ll and sc. The Linux kernel 
successfully emulates these instructions. When compiling GCC for 
mips*r5900*-elf (i.e. not Linux), the instructions ll/sc and lld/scd are 
disabled by my patch.

>  Things would get more complicated if one wanted to run a real OS such as 
> Linux on the R5900 and let the kernel FP emulator handle the missing 
> double FP automagically -- this is a little bit out of scope here as 
> regular -mdouble-float would then just do, but makes me wonder whether 
> -mfp32 should really be enforced (as opposed to just defaulted) for the 
> R5900, hmm...

I tried to emulate the 64 Bit FPU when the real 32 Bit FPU was enabled in 
Linux. There are 2 problems with this:
1. When the program starts, I don't know if it needs a 64 Bit or 32 Bit FPRs. 
So registers are initialized for 32 bit. When dmfc0 or dmtc0 appears, I need to 
emulate them using 32 Bit FPU, because some 32 bit programs use these 
instructions with a 32 Bit FPU (e.g. Linux 2.6.35 kernel and Debian 5.0). When 
a 64 bit calculation instructions appears, I need to switch from 32 bit FPRs to 
64 bit FPRs. When the program used 32 bit instructions with the odd FPRs, there 
is no way to reconstruct the overwritten part of the 64 bit FPRs.
2. Some undefined instructions (e.g. c.eq.d) doesn't lead to an exception on an 
r5900, but have undefined behavior. So there is no emulation possible. It just 
calculates random stuff.
So the FPU needs to be disabled and completely emulated by the kernel, because 
then all FPU instructions lead to an exception. This is working with Linux 2.6 
on PS2.
There are even more problems when running unchanged code from official Fedora 
12 on PS2, because of some different opcode encoding. The users of my PS2 Linux 
2.6 complain about low speed, because many instructions are emulated. I need 
some fast implementation, even if the size of the floating point data types is 
smaller. So 32 bit FPU must be default for r5900.

Best regards
Jürgen

Reply via email to