1570af302Sopenharmony_ci#ifndef __loongarch_soft_float
2570af302Sopenharmony_ci
3570af302Sopenharmony_ci#ifdef BROKEN_LOONGARCH_FCSR_ASM
4570af302Sopenharmony_ci#define FCSR $r0
5570af302Sopenharmony_ci#else
6570af302Sopenharmony_ci#define FCSR $fcsr0
7570af302Sopenharmony_ci#endif
8570af302Sopenharmony_ci
9570af302Sopenharmony_ci.global feclearexcept
10570af302Sopenharmony_ci.type   feclearexcept,@function
11570af302Sopenharmony_cifeclearexcept:
12570af302Sopenharmony_ci	li.w    $t0, 0x1f0000
13570af302Sopenharmony_ci	and     $a0, $a0, $t0
14570af302Sopenharmony_ci	movfcsr2gr $t1, FCSR
15570af302Sopenharmony_ci	andn    $t1, $t1, $a0
16570af302Sopenharmony_ci	movgr2fcsr FCSR, $t1
17570af302Sopenharmony_ci	li.w    $a0, 0
18570af302Sopenharmony_ci	jr      $ra
19570af302Sopenharmony_ci
20570af302Sopenharmony_ci.global feraiseexcept
21570af302Sopenharmony_ci.type   feraiseexcept,@function
22570af302Sopenharmony_ciferaiseexcept:
23570af302Sopenharmony_ci	li.w    $t0, 0x1f0000
24570af302Sopenharmony_ci	and     $a0, $a0, $t0
25570af302Sopenharmony_ci	movfcsr2gr $t1, FCSR
26570af302Sopenharmony_ci	or      $t1, $t1, $a0
27570af302Sopenharmony_ci	movgr2fcsr FCSR, $t1
28570af302Sopenharmony_ci	li.w    $a0, 0
29570af302Sopenharmony_ci	jr      $ra
30570af302Sopenharmony_ci
31570af302Sopenharmony_ci.global fetestexcept
32570af302Sopenharmony_ci.type   fetestexcept,@function
33570af302Sopenharmony_cifetestexcept:
34570af302Sopenharmony_ci	li.w    $t0, 0x1f0000
35570af302Sopenharmony_ci	and     $a0, $a0, $t0
36570af302Sopenharmony_ci	movfcsr2gr $t1, FCSR
37570af302Sopenharmony_ci	and     $a0, $t1, $a0
38570af302Sopenharmony_ci	jr      $ra
39570af302Sopenharmony_ci
40570af302Sopenharmony_ci.global fegetround
41570af302Sopenharmony_ci.type   fegetround,@function
42570af302Sopenharmony_cifegetround:
43570af302Sopenharmony_ci	movfcsr2gr $t0, FCSR
44570af302Sopenharmony_ci	andi    $a0, $t0, 0x300
45570af302Sopenharmony_ci	jr      $ra
46570af302Sopenharmony_ci
47570af302Sopenharmony_ci.global __fesetround
48570af302Sopenharmony_ci.hidden __fesetround
49570af302Sopenharmony_ci.type   __fesetround,@function
50570af302Sopenharmony_ci__fesetround:
51570af302Sopenharmony_ci	li.w    $t0, 0x300
52570af302Sopenharmony_ci	and     $a0, $a0, $t0
53570af302Sopenharmony_ci	movfcsr2gr $t1, FCSR
54570af302Sopenharmony_ci	andn    $t1, $t1, $t0
55570af302Sopenharmony_ci	or      $t1, $t1, $a0
56570af302Sopenharmony_ci	movgr2fcsr FCSR, $t1
57570af302Sopenharmony_ci	li.w    $a0, 0
58570af302Sopenharmony_ci	jr      $ra
59570af302Sopenharmony_ci
60570af302Sopenharmony_ci.global fegetenv
61570af302Sopenharmony_ci.type   fegetenv,@function
62570af302Sopenharmony_cifegetenv:
63570af302Sopenharmony_ci	movfcsr2gr $t0, FCSR
64570af302Sopenharmony_ci	st.w    $t0, $a0, 0
65570af302Sopenharmony_ci	li.w    $a0, 0
66570af302Sopenharmony_ci	jr      $ra
67570af302Sopenharmony_ci
68570af302Sopenharmony_ci.global fesetenv
69570af302Sopenharmony_ci.type   fesetenv,@function
70570af302Sopenharmony_cifesetenv:
71570af302Sopenharmony_ci	addi.d  $t0, $a0, 1
72570af302Sopenharmony_ci	beq     $t0, $r0, 1f
73570af302Sopenharmony_ci	ld.w    $t0, $a0, 0
74570af302Sopenharmony_ci1:	movgr2fcsr FCSR, $t0
75570af302Sopenharmony_ci	li.w    $a0, 0
76570af302Sopenharmony_ci	jr      $ra
77570af302Sopenharmony_ci
78570af302Sopenharmony_ci#endif
79