From b81b53dd33ccc80b8654dd0181c4fbe71397ab9d Mon Sep 17 00:00:00 2001 From: Matt Madison Date: Thu, 18 Sep 2014 11:53:12 -0700 Subject: Re-code the saving of the gp register for MIPS64 so it compiles under recent versions of gcc. --- platform/switch_mips_unix.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/switch_mips_unix.h b/platform/switch_mips_unix.h index 94b5489..9acf2b5 100644 --- a/platform/switch_mips_unix.h +++ b/platform/switch_mips_unix.h @@ -12,17 +12,16 @@ #define STACK_MAGIC 0 -#ifdef __mips64 -#define REGS_TO_SAVE "$16", "$17", "$18", "$19", "$20", "$21", "$22", \ - "$23", "$28", "$30" -#else #define REGS_TO_SAVE "$16", "$17", "$18", "$19", "$20", "$21", "$22", \ "$23", "$30" -#endif static int slp_switch(void) { register int *stackref, stsizediff; +#ifdef __mips64 + volatile register void *gp __asm__("$28"); + volatile void *gpsave = gp; +#endif __asm__ __volatile__ ("" : : : REGS_TO_SAVE); __asm__ ("move %0, $29" : "=r" (stackref) : ); { @@ -39,6 +38,9 @@ slp_switch(void) SLP_RESTORE_STATE(); } __asm__ __volatile__ ("" : : : REGS_TO_SAVE); +#ifdef __mips64 + gp = gpsave; +#endif return 0; } -- cgit v1.2.1 From 10ff5cfd628dda0618038ad23c35fe4155703222 Mon Sep 17 00:00:00 2001 From: Matt Madison Date: Fri, 19 Sep 2014 05:53:23 -0700 Subject: Use assembler directives to perform the gp register save/restore. --- platform/switch_mips_unix.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/platform/switch_mips_unix.h b/platform/switch_mips_unix.h index 9acf2b5..10e392b 100644 --- a/platform/switch_mips_unix.h +++ b/platform/switch_mips_unix.h @@ -6,6 +6,7 @@ * Ported from ppc. */ +#include #define STACK_REFPLUS 1 #ifdef SLP_EVAL @@ -18,11 +19,15 @@ static int slp_switch(void) { register int *stackref, stsizediff; -#ifdef __mips64 - volatile register void *gp __asm__("$28"); - volatile void *gpsave = gp; +#if _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32 + void *gpsave; #endif __asm__ __volatile__ ("" : : : REGS_TO_SAVE); +#if _MIPS_SIM == _ABI64 + __asm__ __volatile__ ("sd $28,%0" : "=m" (gpsave) : : ); +#elif _MIPS_SIM == _ABIN32 + __asm__ __volatile__ ("sw $28,%0" : "=m" (gpsave) : : ); +#endif __asm__ ("move %0, $29" : "=r" (stackref) : ); { SLP_SAVE_STATE(stackref, stsizediff); @@ -37,10 +42,12 @@ slp_switch(void) ); SLP_RESTORE_STATE(); } - __asm__ __volatile__ ("" : : : REGS_TO_SAVE); -#ifdef __mips64 - gp = gpsave; +#if _MIPS_SIM == _ABI64 + __asm__ __volatile__ ("ld $28,%0" : : "m" (gpsave) : ); +#elif _MIPS_SIM == _ABIN32 + __asm__ __volatile__ ("lw $28,%0" : : "m" (gpsave) : ); #endif + __asm__ __volatile__ ("" : : : REGS_TO_SAVE); return 0; } -- cgit v1.2.1 From 3055d8d1792b092bd6e1299027dba6a79df02004 Mon Sep 17 00:00:00 2001 From: Matt Madison Date: Sat, 20 Sep 2014 10:11:58 -0700 Subject: Simply remove the additional GP register saves for MIPS64, as they appear to be unnecessary. --- platform/switch_mips_unix.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/platform/switch_mips_unix.h b/platform/switch_mips_unix.h index 10e392b..3aed027 100644 --- a/platform/switch_mips_unix.h +++ b/platform/switch_mips_unix.h @@ -19,15 +19,7 @@ static int slp_switch(void) { register int *stackref, stsizediff; -#if _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32 - void *gpsave; -#endif __asm__ __volatile__ ("" : : : REGS_TO_SAVE); -#if _MIPS_SIM == _ABI64 - __asm__ __volatile__ ("sd $28,%0" : "=m" (gpsave) : : ); -#elif _MIPS_SIM == _ABIN32 - __asm__ __volatile__ ("sw $28,%0" : "=m" (gpsave) : : ); -#endif __asm__ ("move %0, $29" : "=r" (stackref) : ); { SLP_SAVE_STATE(stackref, stsizediff); @@ -42,11 +34,6 @@ slp_switch(void) ); SLP_RESTORE_STATE(); } -#if _MIPS_SIM == _ABI64 - __asm__ __volatile__ ("ld $28,%0" : : "m" (gpsave) : ); -#elif _MIPS_SIM == _ABIN32 - __asm__ __volatile__ ("lw $28,%0" : : "m" (gpsave) : ); -#endif __asm__ __volatile__ ("" : : : REGS_TO_SAVE); return 0; } -- cgit v1.2.1 From 55e5a8fadc0dd3abedabb71cf2d1634dbc32e975 Mon Sep 17 00:00:00 2001 From: Matt Madison Date: Sat, 20 Sep 2014 10:17:52 -0700 Subject: Clean up stray extra include from prior versions. --- platform/switch_mips_unix.h | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/switch_mips_unix.h b/platform/switch_mips_unix.h index 3aed027..e3a2218 100644 --- a/platform/switch_mips_unix.h +++ b/platform/switch_mips_unix.h @@ -6,7 +6,6 @@ * Ported from ppc. */ -#include #define STACK_REFPLUS 1 #ifdef SLP_EVAL -- cgit v1.2.1 From 4d8bc09f455ca7c2034e7df2b692b54d2e44e9ac Mon Sep 17 00:00:00 2001 From: Matt Madison Date: Sat, 20 Sep 2014 13:04:06 -0700 Subject: Add back in the explicit save/restore, in case there is a situation where the compiler does not automatically save it for us. Eliminate the special handling for N32 ABI, as registers are still 64 bits in that case. --- platform/switch_mips_unix.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platform/switch_mips_unix.h b/platform/switch_mips_unix.h index e3a2218..c35f6e6 100644 --- a/platform/switch_mips_unix.h +++ b/platform/switch_mips_unix.h @@ -18,7 +18,13 @@ static int slp_switch(void) { register int *stackref, stsizediff; +#ifdef __mips64 + uint64_t gpsave; +#endif __asm__ __volatile__ ("" : : : REGS_TO_SAVE); +#ifdef __mips64 + __asm__ __volatile__ ("sd $28,%0" : "=m" (gpsave) : : ); +#endif __asm__ ("move %0, $29" : "=r" (stackref) : ); { SLP_SAVE_STATE(stackref, stsizediff); @@ -33,6 +39,9 @@ slp_switch(void) ); SLP_RESTORE_STATE(); } +#ifdef __mips64 + __asm__ __volatile__ ("ld $28,%0" : : "m" (gpsave) : ); +#endif __asm__ __volatile__ ("" : : : REGS_TO_SAVE); return 0; } -- cgit v1.2.1