summaryrefslogtreecommitdiff
path: root/src/mips/ffitarget.h
diff options
context:
space:
mode:
authorJames Cowgill <jcowgill@users.noreply.github.com>2018-04-19 01:28:23 +0100
committerAnthony Green <green@moxielogic.com>2018-04-18 20:28:23 -0400
commit159b94e5fd4aa2d88e1b5b389092cefd9472a741 (patch)
treec32e9065a401e971f248da608487198eb501fedd /src/mips/ffitarget.h
parentf2afda08e85b02888350449dcf39a6c37cfb7bc4 (diff)
downloadlibffi-159b94e5fd4aa2d88e1b5b389092cefd9472a741.tar.gz
Various MIPS Fixes (#425)
* mips: simplify closure #defines This commit should have no visible effect. * mips: add special handling of variadic functions MIPS requires special handling of variadic functions which pass floating point arguments: * In the o32 ABI, all float arguments are passed in integer registers. * In the n32/n64 ABIs, float arguments after the ellipsis are passed in integer registers. Implement this in libffi. To support this in n32/n64 closures, we need to add a new mips_nfixedargs field to ffi_cif which will break the libffi ABI. This fixes the libffi.call/cls_longdouble_va.c test which was failing on 64-bit MIPS. * mips: align argn for all 64-bit types in o32 closure handler Ensure that argn is pre-aligned for all 64-bit argument types (including doubles) and not just integer types. This fixes closures of the form "f(float, double, <some integer args>)". Previously the first integer argument would be read from a2 which is garbage at this point (the float arguments have already "consumed" a0-a3). After this commit, argn is correctly padded between the "float" and "double" arguments so that the first integer argument is read from the stack. Fixes "double f(float,double,int)" test in #371 * mips: do not read from floating point register if returning a struct In the o32 ABI, the pointer passed in a0 used to return structures indirectly is treated as the first argument for argument allocation purposes. This means that it should inhibit floating point registers the same way that other integer arguments do. Fixes "Double f(float,Double,double)" test in #371 * mips: fix pointer cast warnings Fix two pointer cast warnings when compiled on 64-bit mips by casting through uintptr_t. Fixes mips64el part of #404
Diffstat (limited to 'src/mips/ffitarget.h')
-rw-r--r--src/mips/ffitarget.h19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/mips/ffitarget.h b/src/mips/ffitarget.h
index 9715890..fffdb97 100644
--- a/src/mips/ffitarget.h
+++ b/src/mips/ffitarget.h
@@ -224,26 +224,21 @@ typedef enum ffi_abi {
#endif
} ffi_abi;
-#define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
+#define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag; unsigned mips_nfixedargs
+#define FFI_TARGET_SPECIFIC_VARIADIC
#endif /* !LIBFFI_ASM */
/* ---- Definitions for closures ----------------------------------------- */
-#if defined(FFI_MIPS_O32)
#define FFI_CLOSURES 1
#define FFI_GO_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 20
-#else
-/* N32/N64. */
-# define FFI_CLOSURES 1
-#define FFI_GO_CLOSURES 1
-#if _MIPS_SIM==_ABI64
-#define FFI_TRAMPOLINE_SIZE 56
+#define FFI_NATIVE_RAW_API 0
+
+#if defined(FFI_MIPS_O32) || (_MIPS_SIM ==_ABIN32)
+# define FFI_TRAMPOLINE_SIZE 20
#else
-#define FFI_TRAMPOLINE_SIZE 20
+# define FFI_TRAMPOLINE_SIZE 56
#endif
-#endif /* FFI_MIPS_O32 */
-#define FFI_NATIVE_RAW_API 0
#endif