Skip to content

Commit

Permalink
add MIPS architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
aharon-abramson committed Oct 26, 2023
1 parent 40aaa2b commit df7e13e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test_common/harness/fpcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ typedef int64_t FPU_mode_type;
#elif defined(__PPC__)
#include <fpu_control.h>
extern __thread fpu_control_t fpu_control;
#elif defined(__mips__)
#include "mips/m32c1.h"
#endif
// Set the reference hardware floating point unit to FTZ mode
inline void ForceFTZ(FPU_mode_type *mode)
Expand All @@ -65,6 +67,8 @@ inline void ForceFTZ(FPU_mode_type *mode)
__asm__ volatile("mrs %0, fpcr" : "=r"(fpscr));
*mode = fpscr;
__asm__ volatile("msr fpcr, %0" ::"r"(fpscr | (1U << 24)));
#elif defined(__mips__)
fpa_bissr(FPA_CSR_FS);
#else
#error ForceFTZ needs an implentation
#endif
Expand All @@ -91,6 +95,8 @@ inline void DisableFTZ(FPU_mode_type *mode)
__asm__ volatile("mrs %0, fpcr" : "=r"(fpscr));
*mode = fpscr;
__asm__ volatile("msr fpcr, %0" ::"r"(fpscr & ~(1U << 24)));
#elif defined(__mips__)
fpa_bicsr(FPA_CSR_FS);
#else
#error DisableFTZ needs an implentation
#endif
Expand All @@ -109,6 +115,8 @@ inline void RestoreFPState(FPU_mode_type *mode)
// Add 64 bit support
#elif defined(__aarch64__)
__asm__ volatile("msr fpcr, %0" ::"r"(*mode));
#elif defined(__mips__)
// Mips runs by default with DAZ=1 FTZ=1
#else
#error RestoreFPState needs an implementation
#endif
Expand Down
7 changes: 7 additions & 0 deletions test_common/harness/rounding_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ RoundingMode get_round(void)
#include <xmmintrin.h>
#elif defined(__PPC__)
#include <fpu_control.h>
#elif defined(__mips__)
#include "mips/m32c1.h"
#endif
void *FlushToZero(void)
{
Expand All @@ -219,6 +221,9 @@ void *FlushToZero(void)
flags |= _FPU_MASK_NI;
_FPU_SETCW(flags);
return NULL;
#elif defined(__mips__)
fpa_bissr(FPA_CSR_FS);
return NULL;
#else
#error Unknown arch
#endif
Expand Down Expand Up @@ -247,6 +252,8 @@ void UnFlushToZero(void *p)
_FPU_GETCW(flags);
flags &= ~_FPU_MASK_NI;
_FPU_SETCW(flags);
#elif defined(__mips__)
fpa_bicsr(FPA_CSR_FS);
#else
#error Unknown arch
#endif
Expand Down
2 changes: 2 additions & 0 deletions test_common/harness/testHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,8 @@ void PrintArch(void)
vlog("ARCH:\taarch64\n");
#elif defined(_WIN32)
vlog("ARCH:\tWindows\n");
#elif defined(__mips__)
vlog("ARCH:\tmips\n");
#else
#error unknown arch
#endif
Expand Down

0 comments on commit df7e13e

Please sign in to comment.