declare fpu usage to the assembler in arm hard-float asm files
[musl] / src / fenv / powerpc / fenv.s
1 .global feclearexcept
2 .type feclearexcept,@function
3 feclearexcept:
4         andis. 3,3,0x3e00
5         # if (r3 & FE_INVALID) r3 |= all_invalid_flags
6         andis. 0,3,0x2000
7         stwu 1,-16(1)
8         beq- 0,1f
9         oris 3,3,0x01f8
10         ori  3,3,0x0700
11 1:
12         # note: fpscr contains various fpu status and control
13         # flags and we dont check if r3 may alter other flags
14         # than the exception related ones
15         # fpscr &= ~r3
16         mffs 0
17         stfd 0,8(1)
18         lwz 9,12(1)
19         andc 9,9,3
20         stw 9,12(1)
21         lfd 0,8(1)
22         mtfsf 255,0
23
24         # return 0
25         li 3,0
26         addi 1,1,16
27         blr
28
29 .global feraiseexcept
30 .type feraiseexcept,@function
31 feraiseexcept:
32         andis. 3,3,0x3e00
33         # if (r3 & FE_INVALID) r3 |= software_invalid_flag
34         andis. 0,3,0x2000
35         stwu 1,-16(1)
36         beq- 0,1f
37         ori 3,3,0x0400
38 1:
39         # fpscr |= r3
40         mffs 0
41         stfd 0,8(1)
42         lwz 9,12(1)
43         or 9,9,3
44         stw 9,12(1)
45         lfd 0,8(1)
46         mtfsf 255,0
47
48         # return 0
49         li 3,0
50         addi 1,1,16
51         blr
52
53 .global fetestexcept
54 .type fetestexcept,@function
55 fetestexcept:
56         andis. 3,3,0x3e00
57         # return r3 & fpscr
58         stwu 1,-16(1)
59         mffs 0
60         stfd 0,8(1)
61         lwz 9,12(1)
62         addi 1,1,16
63         and 3,3,9
64         blr
65
66 .global fegetround
67 .type fegetround,@function
68 fegetround:
69         # return fpscr & 3
70         stwu 1,-16(1)
71         mffs 0
72         stfd 0,8(1)
73         lwz 3,12(1)
74         addi 1,1,16
75         clrlwi 3,3,30
76         blr
77
78 .global __fesetround
79 .type __fesetround,@function
80 __fesetround:
81         # note: invalid input is not checked, r3 < 4 must hold
82         # fpscr = (fpscr & -4U) | r3
83         stwu 1,-16(1)
84         mffs 0
85         stfd 0,8(1)
86         lwz 9,12(1)
87         clrrwi 9,9,2
88         or 9,9,3
89         stw 9,12(1)
90         lfd 0,8(1)
91         mtfsf 255,0
92
93         # return 0
94         li 3,0
95         addi 1,1,16
96         blr
97
98 .global fegetenv
99 .type fegetenv,@function
100 fegetenv:
101         # *r3 = fpscr
102         mffs 0
103         stfd 0,0(3)
104         # return 0
105         li 3,0
106         blr
107
108 .global fesetenv
109 .type fesetenv,@function
110 fesetenv:
111         cmpwi 3, -1
112         bne 1f
113         mflr 4
114         bl 2f
115         .zero 8
116 2:      mflr 3
117         mtlr 4
118 1:      # fpscr = *r3
119         lfd 0,0(3)
120         mtfsf 255,0
121         # return 0
122         li 3,0
123         blr