add MIPS architecture (#1837)

This commit is contained in:
Aharon Abramson
2023-11-07 19:36:45 +02:00
committed by GitHub
parent 42434d04d0
commit be626ca1fa
3 changed files with 17 additions and 0 deletions

View File

@@ -43,6 +43,8 @@ typedef int64_t FPU_mode_type;
#elif defined(__PPC__) #elif defined(__PPC__)
#include <fpu_control.h> #include <fpu_control.h>
extern __thread fpu_control_t fpu_control; extern __thread fpu_control_t fpu_control;
#elif defined(__mips__)
#include "mips/m32c1.h"
#endif #endif
// Set the reference hardware floating point unit to FTZ mode // Set the reference hardware floating point unit to FTZ mode
inline void ForceFTZ(FPU_mode_type *mode) inline void ForceFTZ(FPU_mode_type *mode)
@@ -65,6 +67,8 @@ inline void ForceFTZ(FPU_mode_type *mode)
__asm__ volatile("mrs %0, fpcr" : "=r"(fpscr)); __asm__ volatile("mrs %0, fpcr" : "=r"(fpscr));
*mode = fpscr; *mode = fpscr;
__asm__ volatile("msr fpcr, %0" ::"r"(fpscr | (1U << 24))); __asm__ volatile("msr fpcr, %0" ::"r"(fpscr | (1U << 24)));
#elif defined(__mips__)
fpa_bissr(FPA_CSR_FS);
#else #else
#error ForceFTZ needs an implentation #error ForceFTZ needs an implentation
#endif #endif
@@ -91,6 +95,8 @@ inline void DisableFTZ(FPU_mode_type *mode)
__asm__ volatile("mrs %0, fpcr" : "=r"(fpscr)); __asm__ volatile("mrs %0, fpcr" : "=r"(fpscr));
*mode = fpscr; *mode = fpscr;
__asm__ volatile("msr fpcr, %0" ::"r"(fpscr & ~(1U << 24))); __asm__ volatile("msr fpcr, %0" ::"r"(fpscr & ~(1U << 24)));
#elif defined(__mips__)
fpa_bicsr(FPA_CSR_FS);
#else #else
#error DisableFTZ needs an implentation #error DisableFTZ needs an implentation
#endif #endif
@@ -109,6 +115,8 @@ inline void RestoreFPState(FPU_mode_type *mode)
// Add 64 bit support // Add 64 bit support
#elif defined(__aarch64__) #elif defined(__aarch64__)
__asm__ volatile("msr fpcr, %0" ::"r"(*mode)); __asm__ volatile("msr fpcr, %0" ::"r"(*mode));
#elif defined(__mips__)
// Mips runs by default with DAZ=1 FTZ=1
#else #else
#error RestoreFPState needs an implementation #error RestoreFPState needs an implementation
#endif #endif

View File

@@ -197,6 +197,8 @@ RoundingMode get_round(void)
#include <xmmintrin.h> #include <xmmintrin.h>
#elif defined(__PPC__) #elif defined(__PPC__)
#include <fpu_control.h> #include <fpu_control.h>
#elif defined(__mips__)
#include "mips/m32c1.h"
#endif #endif
void *FlushToZero(void) void *FlushToZero(void)
{ {
@@ -219,6 +221,9 @@ void *FlushToZero(void)
flags |= _FPU_MASK_NI; flags |= _FPU_MASK_NI;
_FPU_SETCW(flags); _FPU_SETCW(flags);
return NULL; return NULL;
#elif defined(__mips__)
fpa_bissr(FPA_CSR_FS);
return NULL;
#else #else
#error Unknown arch #error Unknown arch
#endif #endif
@@ -247,6 +252,8 @@ void UnFlushToZero(void *p)
_FPU_GETCW(flags); _FPU_GETCW(flags);
flags &= ~_FPU_MASK_NI; flags &= ~_FPU_MASK_NI;
_FPU_SETCW(flags); _FPU_SETCW(flags);
#elif defined(__mips__)
fpa_bicsr(FPA_CSR_FS);
#else #else
#error Unknown arch #error Unknown arch
#endif #endif

View File

@@ -1298,6 +1298,8 @@ void PrintArch(void)
vlog("ARCH:\taarch64\n"); vlog("ARCH:\taarch64\n");
#elif defined(_WIN32) #elif defined(_WIN32)
vlog("ARCH:\tWindows\n"); vlog("ARCH:\tWindows\n");
#elif defined(__mips__)
vlog("ARCH:\tmips\n");
#else #else
#error unknown arch #error unknown arch
#endif #endif