1570af302Sopenharmony_ci#if __SH_FPU_ANY__ || __SH4__
2570af302Sopenharmony_ci
3570af302Sopenharmony_ci.global fegetround
4570af302Sopenharmony_ci.type   fegetround, @function
5570af302Sopenharmony_cifegetround:
6570af302Sopenharmony_ci	sts fpscr, r0
7570af302Sopenharmony_ci	rts
8570af302Sopenharmony_ci	 and #3, r0
9570af302Sopenharmony_ci
10570af302Sopenharmony_ci.global __fesetround
11570af302Sopenharmony_ci.hidden __fesetround
12570af302Sopenharmony_ci.type   __fesetround, @function
13570af302Sopenharmony_ci__fesetround:
14570af302Sopenharmony_ci	sts fpscr, r0
15570af302Sopenharmony_ci	mov #-4, r1
16570af302Sopenharmony_ci	and r1, r0
17570af302Sopenharmony_ci	or  r4, r0
18570af302Sopenharmony_ci	lds r0, fpscr
19570af302Sopenharmony_ci	rts
20570af302Sopenharmony_ci	 mov #0, r0
21570af302Sopenharmony_ci
22570af302Sopenharmony_ci.global fetestexcept
23570af302Sopenharmony_ci.type   fetestexcept, @function
24570af302Sopenharmony_cifetestexcept:
25570af302Sopenharmony_ci	sts fpscr, r0
26570af302Sopenharmony_ci	and r4, r0
27570af302Sopenharmony_ci	rts
28570af302Sopenharmony_ci	 and #0x7c, r0
29570af302Sopenharmony_ci
30570af302Sopenharmony_ci.global feclearexcept
31570af302Sopenharmony_ci.type   feclearexcept, @function
32570af302Sopenharmony_cifeclearexcept:
33570af302Sopenharmony_ci	mov r4, r0
34570af302Sopenharmony_ci	and #0x7c, r0
35570af302Sopenharmony_ci	not r0, r4
36570af302Sopenharmony_ci	sts fpscr, r0
37570af302Sopenharmony_ci	and r4, r0
38570af302Sopenharmony_ci	lds r0, fpscr
39570af302Sopenharmony_ci	rts
40570af302Sopenharmony_ci	 mov #0, r0
41570af302Sopenharmony_ci
42570af302Sopenharmony_ci.global feraiseexcept
43570af302Sopenharmony_ci.type   feraiseexcept, @function
44570af302Sopenharmony_ciferaiseexcept:
45570af302Sopenharmony_ci	mov r4, r0
46570af302Sopenharmony_ci	and #0x7c, r0
47570af302Sopenharmony_ci	sts fpscr, r4
48570af302Sopenharmony_ci	or  r4, r0
49570af302Sopenharmony_ci	lds r0, fpscr
50570af302Sopenharmony_ci	rts
51570af302Sopenharmony_ci	 mov #0, r0
52570af302Sopenharmony_ci
53570af302Sopenharmony_ci.global fegetenv
54570af302Sopenharmony_ci.type   fegetenv, @function
55570af302Sopenharmony_cifegetenv:
56570af302Sopenharmony_ci	sts fpscr, r0
57570af302Sopenharmony_ci	mov.l r0, @r4
58570af302Sopenharmony_ci	rts
59570af302Sopenharmony_ci	 mov #0, r0
60570af302Sopenharmony_ci
61570af302Sopenharmony_ci.global fesetenv
62570af302Sopenharmony_ci.type   fesetenv, @function
63570af302Sopenharmony_cifesetenv:
64570af302Sopenharmony_ci	mov r4, r0
65570af302Sopenharmony_ci	cmp/eq #-1, r0
66570af302Sopenharmony_ci	bf 1f
67570af302Sopenharmony_ci
68570af302Sopenharmony_ci	! the default environment is complicated by the fact that we need to
69570af302Sopenharmony_ci	! preserve the current precision bit, which we do not know a priori
70570af302Sopenharmony_ci	sts fpscr, r0
71570af302Sopenharmony_ci	mov #8, r1
72570af302Sopenharmony_ci	swap.w r1, r1
73570af302Sopenharmony_ci	bra 2f
74570af302Sopenharmony_ci	 and r1, r0
75570af302Sopenharmony_ci
76570af302Sopenharmony_ci1:	mov.l @r4, r0      ! non-default environment
77570af302Sopenharmony_ci2:	lds r0, fpscr
78570af302Sopenharmony_ci	rts
79570af302Sopenharmony_ci	 mov #0, r0
80570af302Sopenharmony_ci
81570af302Sopenharmony_ci#endif
82