This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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: libffi: improvements for MIPS o32.


Adding Eric Christopher and Richard Sandiford, to ask them this question:

Does it make sense to check the value of __mips_soft_float when building
libffi to control how it (libffi) handles the differences between o32 w/
FPU and o32 w/ soft float?

Do n32 and n64 have similar issues?

If so, doesn't this mean that in effect there are 6 mips ABIs (o32, n32
and n64) x (hard_float, soft_float)?

Casey Marshall wrote:
>>>>>>"David" == David Daney <ddaney@avtrex.com> writes:
> 
> 
> David> Casey Marshall wrote:
> 
>>>Hi.
>>>
>>>The attached patch expands on my previous patches to libffi for the
>>>MIPS o32 ABI. It adds closure and exception unwinding support for
>>>this architecture.
>>>
>>>I have some questions about this, however:
>>>
>>>* It's been indicated that the ABI is different for software-only
>>>floating point architectures. I don't know how to handle this,
>>>though. Is this something an #ifdef can handle?
> 
> 
> David> I was thinking something like this (untested):
> 
> (Bah... Emacs filled this...)

Sorry, it looks good on my mozilla mail client.  Attached is another copy.
>
> David> Now you have two ABIs for O32.  FFI_O32, and FFI_O32_SF The SF
> David> version does the "right thing" (ie not pass stuff around in the
> David> FPU registers).
> 
> Hmm, defining another ABI doesn't sound like the right thing to
> do. Are the FP/noFP ABIs similar enough to share code with o32.S?
> 

We aren't defining another ABI.  It already exists, and I am using it.
All I want is a way to call it via FFI.  If we want to use it from FFI
we need to have a FFI_MIPS_??? constant defined for it.


> I'm assuming that a soft-float ABI would use the integer registers for
> passing arguments and return values, so would this just mean replacing
> FPU stores/loads with normal ones?

Correct.

> 
> 
>>> * I'm using the `cacheflush' system call to flush the I-cache, but
>>>have been warned by the man page that that function is only
>>>available for MIPS. I don't know if this means "MIPS Linux", or if
>>>this system call is available on other OSes.
>>>
>>>I also see that on Linux this system call is totally inefficient
>>>(it flushes the entire cache, not just the region specified).
> 
> 
> David> I think that is all you can do for portable operation.  The
> David> mips32r2 ISA has the synci instruction, but many o32 based
> David> systems are not mips32r2, so it would not be portable.
> 
> Mine, for one, is only mips2.
> 
> David> If you really wanted to hack it up, you could test for the
> David> ability to execute synci and call cacheflush if you cannot use
> David> it.  Install a handler for SIGILL, and execute synci.  If you
> David> get SIGILL you have to use cacheflush.  Then uninstall the
> David> handler, and proceed.
> 
> Is there a convenient check for mips32r2? Would _MIPS_ARCH check this?
> 

_MIPS_ARCH and friends indicate what the compiler is generating code
for, not where the code is currently running.  If you made it depend on
MIPS_ARCH then a given build of libffi could not run on non mips32r2
systems unless you kept using cacheflush.  In which case the discussion
is meaningless.  But for tightly controlled environments where you knew
the target CPU it would work.

> 
--- ffitarget.h	2003-10-22 08:32:13.000000000 -0700
+++ /home/daney/ffitarget.h	2004-06-30 14:02:40.000000000 -0700
@@ -37,6 +37,9 @@
 #    define FFI_MIPS_N32
 #  else
 #    if _MIPS_SIM==_ABIO32 && defined(_ABIO32)
+#      ifdef __mips_soft_float
+#        define FFI_MIPS_O32_SF
+#      endif
 #      define FFI_MIPS_O32
 #    else
 -- this is an unsupported platform --
@@ -136,16 +139,21 @@
 typedef enum ffi_abi {
   FFI_FIRST_ABI = 0,
   FFI_O32,
+  FFI_O32_SF,
   FFI_N32,
   FFI_N64,
 
 #ifdef FFI_MIPS_O32
+#  ifdef FFI_MIPS_O32_SF
+  FFI_DEFAULT_ABI = FFI_O32_SF,
+#  else
   FFI_DEFAULT_ABI = FFI_O32,
+#  endif
 #else
   FFI_DEFAULT_ABI = FFI_N32,
 #endif
 
-  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1 /* FIXME: What is this all about? */
 } ffi_abi;
 
 #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag

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