changeset 101:1ce60358fbad

- mips related cleanup, mostly comments, cpp macro lib - sparc comment fix - mips o32 update in manual
author cslag
date Tue, 07 Jun 2016 07:34:37 +0200
parents dcb7157392f1
children b7a9b524f0c3
files doc/manual/callconvs/callconv_mips.tex dyncall/dyncall_call_mips_o32.h dyncall/dyncall_call_mips_o32_gas.s dyncall/dyncall_callvm_mips_o32.c dyncall/dyncall_macros.h dyncallback/dyncall_args_sparc64.h dyncallback/dyncall_callback_mips_eabi_gas.s dyncallback/dyncall_callback_mips_n32_gas.s dyncallback/dyncall_callback_mips_n64_gas.s dyncallback/dyncall_thunk.h dyncallback/dyncall_thunk_mips.c dyncallback/dyncall_thunk_mips.h
diffstat 12 files changed, 26 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/doc/manual/callconvs/callconv_mips.tex	Sun Jun 05 14:41:58 2016 +0200
+++ b/doc/manual/callconvs/callconv_mips.tex	Tue Jun 07 07:34:37 2016 +0200
@@ -38,8 +38,8 @@
 
 \paragraph{\product{dyncall} support}
 
-Currently, dyncall supports the EABI calling convention which is used on the Homebrew SDK for the Playstation Portable.
-As documentation for this EABI is unofficial, this port is currently experimental. It also supports O32, N32 and N64.
+Currently, dyncall supports for MIPS 32-bit architectures the O32 calling convention, as well as EABI (which is used on the Homebrew SDK for
+the Playstation Portable). For MIPS 64-bit machines, dyncall supports the N32 and N64 calling conventions.
 
 \subsubsection{MIPS EABI 32-bit Calling Convention}
 
@@ -124,9 +124,9 @@
 \hline                                                             
 {\bf \$0}                              & {\bf \$zero}              & Hardware zero \\
 {\bf \$1}                              & {\bf \$at}                & Assembler temporary \\
-{\bf \$2-\$3}                          & {\bf \$v0-\$v1}           & Integer results, scratch \\
-{\bf \$4-\$7}                          & {\bf \$a0-\$a3}           & Integer arguments, scratch\\
-{\bf \$8-\$15,\$24,\$25}               & {\bf \$t0-\$t7,\$t8,\$t9} & Integer temporaries, scratch \\
+{\bf \$2-\$3}                          & {\bf \$v0-\$v1}           & return value, scratch \\
+{\bf \$4-\$7}                          & {\bf \$a0-\$a3}           & first four word-arguments, scratch\\
+{\bf \$8-\$15,\$24,\$25}               & {\bf \$t0-\$t7,\$t8,\$t9} & temporaries, scratch \\
 {\bf \$16-\$23}                        & {\bf \$s0-\$s7}           & Preserved \\
 {\bf \$26,\$27}                        & {\bf \$k0,\$k1}           & Reserved for kernel \\
 {\bf \$28}                             & {\bf \$gp}                & Global pointer, preserve \\
@@ -146,10 +146,11 @@
 \item Stack parameter order: right-to-left
 \item Caller cleans up the stack
 \item The different stack areas (e.g. parameter area, register save area, ...) are always aligned to 8 bytes.
-\item first 4 32bit arguments are passed in registers \$a0-\$a3, respectively
+\item first four 32bit arguments are passed in registers \$a0-\$a3, respectively
 \item subsequent parameters are passed vie the stack
-\item @@@unsure... 64-bit floats and integers are passed on two integer registers starting at an even register number, probably skipping one odd register.
-\item results are returned in \$v0 (32-bit integer), \$v0 and \$v1 (64-bit integer/float)
+\item 64-bit params passed via registers are passed using two registers, starting at an even register number (skipping one odd register if necessary)
+\item 64-bit params passed via the stack are always 8-byte aligned
+\item results are returned in \$v0 (32-bit return values), \$v0 and \$v1 (64-bit)
 \item note that only s? registers that are modified by the function are required to be preserved on save area
 \end{itemize}
 
--- a/dyncall/dyncall_call_mips_o32.h	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncall/dyncall_call_mips_o32.h	Tue Jun 07 07:34:37 2016 +0200
@@ -43,8 +43,9 @@
   32-bit floating pointer registers.
   Float arguments map as following:
   
-    float argument 0 is at floats[1] and
-    float argument 1 is at floats[3] of DCRegData_mips_o32 union.
+    float argument 0 is at u[0][0] for little, u[0][1] for big endian and
+    float argument 1 is at u[1][0] for little, u[1][1] for big endian of
+	DCRegData_mips_o32 union.
 
 */
 
--- a/dyncall/dyncall_call_mips_o32_gas.s	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncall/dyncall_call_mips_o32_gas.s	Tue Jun 07 07:34:37 2016 +0200
@@ -77,9 +77,9 @@
 
 	l.d     $f12, 0($5)
 	l.d     $f14, 8($5)
+
 	/* prepare call */
 
-
 	move	$12, $7		/* $12  stack data */
 	move	$25, $4		/* $25  target function */
 
--- a/dyncall/dyncall_callvm_mips_o32.c	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncall/dyncall_callvm_mips_o32.c	Tue Jun 07 07:34:37 2016 +0200
@@ -116,7 +116,7 @@
 
   dcVecAppend(&self->mVecHead, &x, sizeof(DCfloat) );
   if (self->mArgCount < 2) {
-#if defined(__MIPSEL__)
+#if defined(DC__Endian_LITTLE)
     self->mRegData.u[self->mArgCount].f[0] = x;
 #else
     self->mRegData.u[self->mArgCount].f[1] = x;
@@ -136,7 +136,7 @@
 	lwc1	$f14, 8($5)      <--- byte offset 12 
 	lwc1	$f15, 12($5)
 
-#if defined(__MIPSEL__)
+#if defined(DC__Endian_LITTLE)
     /* index 0 and 2 */
     self->mRegData.floats[self->mArgCount*2] = x;
 #else
--- a/dyncall/dyncall_macros.h	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncall/dyncall_macros.h	Tue Jun 07 07:34:37 2016 +0200
@@ -272,9 +272,9 @@
 DC__Arch_Sparcv9
 DC__Arch_SuperH
 */
-# if (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 1)) || defined(_BIG_ENDIAN) || defined(MIPSEB)
+# if (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 1)) || defined(_BIG_ENDIAN) || defined(MIPSEB) || defined(__MIPSEB__)
 #  define DC__Endian_BIG
-# elif (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 2)) || defined(_LITTLE_ENDIAN) || defined(MIPSEL)
+# elif (defined(DC__Arch_PPC64) && (DC__ABI_PPC64_ELF_V == 2)) || defined(_LITTLE_ENDIAN) || defined(MIPSEL) || defined(__MIPSEL__)
 #  define DC__Endian_LITTLE
 # endif /* no else, leave unset if not sure */
 #endif
--- a/dyncallback/dyncall_args_sparc64.h	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncallback/dyncall_args_sparc64.h	Tue Jun 07 07:34:37 2016 +0200
@@ -3,7 +3,7 @@
  Package: dyncall
  Library: dyncallback
  File: dyncallback/dyncall_args_sparc64.h
- Description: Callback's Arguments VM - Header for sparc32 - not yet
+ Description: Callback's Arguments VM - Header for sparc64 - not yet
  License:
 
    Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
--- a/dyncallback/dyncall_callback_mips_eabi_gas.s	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncallback/dyncall_callback_mips_eabi_gas.s	Tue Jun 07 07:34:37 2016 +0200
@@ -3,7 +3,7 @@
  Package: dyncall
  Library: dyncallback
  File: dyncallback/dyncall_callback_mips_eabi_gas.s
- Description: Callback Thunk - Implementation for mips eabi
+ Description: Callback Thunk - Implementation for mips32 eabi
  License:
 
    Copyright (c) 2016 Tassilo Philipp <tphilipp@potion-studios.com>
--- a/dyncallback/dyncall_callback_mips_n32_gas.s	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncallback/dyncall_callback_mips_n32_gas.s	Tue Jun 07 07:34:37 2016 +0200
@@ -3,7 +3,7 @@
  Package: dyncall
  Library: dyncallback
  File: dyncallback/dyncall_callback_mips_n32_gas.s
- Description: Callback Thunk - Implementation for mips n32
+ Description: Callback Thunk - Implementation for mips64 n32
  License:
 
    Copyright (c) 2016 Tassilo Philipp <tphilipp@potion-studios.com>
--- a/dyncallback/dyncall_callback_mips_n64_gas.s	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncallback/dyncall_callback_mips_n64_gas.s	Tue Jun 07 07:34:37 2016 +0200
@@ -3,7 +3,7 @@
  Package: dyncall
  Library: dyncallback
  File: dyncallback/dyncall_callback_mips_n64_gas.s
- Description: Callback Thunk - Implementation for mips n64
+ Description: Callback Thunk - Implementation for mips64 n64
  License:
 
    Copyright (c) 2016 Tassilo Philipp <tphilipp@potion-studios.com>
--- a/dyncallback/dyncall_thunk.h	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncallback/dyncall_thunk.h	Tue Jun 07 07:34:37 2016 +0200
@@ -47,6 +47,7 @@
  ** ppc:   r2
  ** arm:  r12
  ** arm64: x9
+ ** mips:  t4
  **
  **/
 
@@ -88,3 +89,4 @@
 
 
 #endif /* DYNCALL_THUNK_H */
+
--- a/dyncallback/dyncall_thunk_mips.c	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncallback/dyncall_thunk_mips.c	Tue Jun 07 07:34:37 2016 +0200
@@ -35,8 +35,8 @@
 Thunk Register: $t4 ($12)
 According to o32abi: $t9 
 
-'The Linux/MIPS convention is that all PIC calls use t9 to hold the address of the called function.'
-[See MIPS Run, p.413]
+'The Linux/MIPS convention is that all PIC calls use t9 to hold the address of
+the called function.' [See MIPS Run, p.413]
 
     mips thunk code:
       lui $t4,      %hi(p)
--- a/dyncallback/dyncall_thunk_mips.h	Sun Jun 05 14:41:58 2016 +0200
+++ b/dyncallback/dyncall_thunk_mips.h	Tue Jun 07 07:34:37 2016 +0200
@@ -31,7 +31,7 @@
 {
   unsigned short data[6];
   unsigned int   jump;
-  unsigned short bddt[2];
+  unsigned short bddt[2]; // branch delay slots
 };
 
 #define DCTHUNK_MIPS_SIZE	20