diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-10-18 20:19:53 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-10-18 20:19:53 -0400 |
commit | f321de9e0ae130e21faab5afe109270ec913602d (patch) | |
tree | 91efafaac63b0469d28f419b22f0978aacd47675 | |
parent | 97c8bdd88ae2ee03eb9d333a79fa669b3878fc76 (diff) | |
download | musl-f321de9e0ae130e21faab5afe109270ec913602d.tar.gz |
floating point environment/exceptions support for mips
-rw-r--r-- | arch/mips/bits/fenv.h | 16 | ||||
-rw-r--r-- | src/fenv/mips/fenv.s | 60 |
2 files changed, 73 insertions, 3 deletions
diff --git a/arch/mips/bits/fenv.h b/arch/mips/bits/fenv.h index edbdea2a..b2a6db9a 100644 --- a/arch/mips/bits/fenv.h +++ b/arch/mips/bits/fenv.h @@ -1,10 +1,20 @@ -#define FE_ALL_EXCEPT 0 +#define FE_INEXACT 4 +#define FE_UNDERFLOW 8 +#define FE_OVERFLOW 16 +#define FE_DIVBYZERO 32 +#define FE_INVALID 64 + +#define FE_ALL_EXCEPT 124 + #define FE_TONEAREST 0 +#define FE_TOWARDZERO 1 +#define FE_UPWARD 2 +#define FE_DOWNWARD 3 -typedef unsigned long fexcept_t; +typedef unsigned short fexcept_t; typedef struct { - unsigned long __cw; + unsigned __cw; } fenv_t; #define FE_DFL_ENV ((const fenv_t *) -1) diff --git a/src/fenv/mips/fenv.s b/src/fenv/mips/fenv.s new file mode 100644 index 00000000..49ff36c0 --- /dev/null +++ b/src/fenv/mips/fenv.s @@ -0,0 +1,60 @@ +.set noreorder + +.global feclearexcept +.type feclearexcept,@function +feclearexcept: + cfc1 $5, $31 + or $5, $5, $4 + xor $5, $5, $4 + ctc1 $5, $31 + jr $ra + li $2, 0 + +.global feraiseexcept +.type feraiseexcept,@function +feraiseexcept: + cfc1 $5, $31 + or $5, $5, $4 + ctc1 $5, $31 + jr $ra + li $2, 0 + +.global fetestexcept +.type fetestexcept,@function +fetestexcept: + cfc1 $2, $31 + jr $ra + and $2, $2, $4 + +.global fegetround +.type fegetround,@function +fegetround: + cfc1 $2, $31 + jr $ra + andi $2, $2, 3 + +.global fesetround +.type fesetround,@function +fesetround: + cfc1 $5, $31 + li $6, -4 + and $5, $5, $6 + or $5, $5, $4 + jr $ra + li $2, 0 + +.global fegetenv +.type fegetenv,@function +fegetenv: + cfc1 $5, $31 + sw $5, 0($4) + jr $ra + li $2, 0 + +.global fesetenv +.type fesetenv,@function +fesetenv: + lw $5, 0($4) + ctc1 $5, $31 + jr $ra + li $2, 0 |