| 1 |
#ifndef __loongarch_soft_float |
| 2 |
|
| 3 |
#ifdef BROKEN_LOONGARCH_FCSR_ASM |
| 4 |
#define FCSR $r0 |
| 5 |
#else |
| 6 |
#define FCSR $fcsr0 |
| 7 |
#endif |
| 8 |
|
| 9 |
.global feclearexcept |
| 10 |
.type feclearexcept,@function |
| 11 |
feclearexcept: |
| 12 |
li.w $t0, 0x1f0000 |
| 13 |
and $a0, $a0, $t0 |
| 14 |
movfcsr2gr $t1, FCSR |
| 15 |
andn $t1, $t1, $a0 |
| 16 |
movgr2fcsr FCSR, $t1 |
| 17 |
li.w $a0, 0 |
| 18 |
jr $ra |
| 19 |
|
| 20 |
.global feraiseexcept |
| 21 |
.type feraiseexcept,@function |
| 22 |
feraiseexcept: |
| 23 |
li.w $t0, 0x1f0000 |
| 24 |
and $a0, $a0, $t0 |
| 25 |
movfcsr2gr $t1, FCSR |
| 26 |
or $t1, $t1, $a0 |
| 27 |
movgr2fcsr FCSR, $t1 |
| 28 |
li.w $a0, 0 |
| 29 |
jr $ra |
| 30 |
|
| 31 |
.global fetestexcept |
| 32 |
.type fetestexcept,@function |
| 33 |
fetestexcept: |
| 34 |
li.w $t0, 0x1f0000 |
| 35 |
and $a0, $a0, $t0 |
| 36 |
movfcsr2gr $t1, FCSR |
| 37 |
and $a0, $t1, $a0 |
| 38 |
jr $ra |
| 39 |
|
| 40 |
.global fegetround |
| 41 |
.type fegetround,@function |
| 42 |
fegetround: |
| 43 |
movfcsr2gr $t0, FCSR |
| 44 |
andi $a0, $t0, 0x300 |
| 45 |
jr $ra |
| 46 |
|
| 47 |
.global __fesetround |
| 48 |
.hidden __fesetround |
| 49 |
.type __fesetround,@function |
| 50 |
__fesetround: |
| 51 |
li.w $t0, 0x300 |
| 52 |
and $a0, $a0, $t0 |
| 53 |
movfcsr2gr $t1, FCSR |
| 54 |
andn $t1, $t1, $t0 |
| 55 |
or $t1, $t1, $a0 |
| 56 |
movgr2fcsr FCSR, $t1 |
| 57 |
li.w $a0, 0 |
| 58 |
jr $ra |
| 59 |
|
| 60 |
.global fegetenv |
| 61 |
.type fegetenv,@function |
| 62 |
fegetenv: |
| 63 |
movfcsr2gr $t0, FCSR |
| 64 |
st.w $t0, $a0, 0 |
| 65 |
li.w $a0, 0 |
| 66 |
jr $ra |
| 67 |
|
| 68 |
.global fesetenv |
| 69 |
.type fesetenv,@function |
| 70 |
fesetenv: |
| 71 |
addi.d $t0, $a0, 1 |
| 72 |
beq $t0, $r0, 1f |
| 73 |
ld.w $t0, $a0, 0 |
| 74 |
1: movgr2fcsr FCSR, $t0 |
| 75 |
li.w $a0, 0 |
| 76 |
jr $ra |
| 77 |
|
| 78 |
#endif |