fpsf.S revision 1.1 1 1.1 matt /*-
2 1.1 matt * Copyright (c) 2016 The NetBSD Foundation, Inc.
3 1.1 matt * All rights reserved.
4 1.1 matt *
5 1.1 matt * This code is derived from software contributed to The NetBSD Foundation
6 1.1 matt * by Matt Thomas of 3am Software Foundry.
7 1.1 matt *
8 1.1 matt * Redistribution and use in source and binary forms, with or without
9 1.1 matt * modification, are permitted provided that the following conditions
10 1.1 matt * are met:
11 1.1 matt * 1. Redistributions of source code must retain the above copyright
12 1.1 matt * notice, this list of conditions and the following disclaimer.
13 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 matt * notice, this list of conditions and the following disclaimer in the
15 1.1 matt * documentation and/or other materials provided with the distribution.
16 1.1 matt *
17 1.1 matt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 1.1 matt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 1.1 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 1.1 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 1.1 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 1.1 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 1.1 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 1.1 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 1.1 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 1.1 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 1.1 matt * POSSIBILITY OF SUCH DAMAGE.
28 1.1 matt */
29 1.1 matt
30 1.1 matt #include <mips/asm.h>
31 1.1 matt
32 1.1 matt RCSID("$NetBSD: fpsf.S,v 1.1 2016/07/14 01:59:18 matt Exp $")
33 1.1 matt
34 1.1 matt /*
35 1.1 matt * This file provides softfloat compatible routines which use FP instructions
36 1.1 matt * to do the actual work. This should give near hard-float performance while
37 1.1 matt * being compatible with soft-float code.
38 1.1 matt *
39 1.1 matt * This file implements the single precision floating point routines.
40 1.1 matt */
41 1.1 matt
42 1.1 matt #ifdef MIPS3
43 1.1 matt #define COP1_SYNC nop
44 1.1 matt #else
45 1.1 matt #define COP1_SYNC
46 1.1 matt #endif
47 1.1 matt
48 1.1 matt LEAF_NOPROFILE(__addsf3)
49 1.1 matt mtc1 a0, $f12
50 1.1 matt mtc1 a1, $f14
51 1.1 matt COP1_SYNC
52 1.1 matt add.s $f0, $f12, $f14
53 1.1 matt mfc1 v0, $f0
54 1.1 matt jr ra
55 1.1 matt END(__addsf3)
56 1.1 matt
57 1.1 matt LEAF_NOPROFILE(__subsf3)
58 1.1 matt mtc1 a0, $f12
59 1.1 matt mtc1 a1, $f14
60 1.1 matt COP1_SYNC
61 1.1 matt sub.s $f0, $f12, $f14
62 1.1 matt mfc1 v0, $f0
63 1.1 matt jr ra
64 1.1 matt END(__subsf3)
65 1.1 matt
66 1.1 matt LEAF_NOPROFILE(__mulsf3)
67 1.1 matt mtc1 a0, $f12
68 1.1 matt mtc1 a1, $f14
69 1.1 matt COP1_SYNC
70 1.1 matt mul.s $f0, $f12, $f14
71 1.1 matt mfc1 v0, $f0
72 1.1 matt jr ra
73 1.1 matt END(__mulsf3)
74 1.1 matt
75 1.1 matt LEAF_NOPROFILE(__divsf3)
76 1.1 matt mtc1 a0, $f12
77 1.1 matt mtc1 a1, $f14
78 1.1 matt COP1_SYNC
79 1.1 matt div.s $f0, $f12, $f14
80 1.1 matt mfc1 v0, $f0
81 1.1 matt jr ra
82 1.1 matt END(__divsf3)
83 1.1 matt
84 1.1 matt LEAF_NOPROFILE(__negsf2)
85 1.1 matt mtc1 a0, $f12
86 1.1 matt COP1_SYNC
87 1.1 matt neg.s $f0, $f12
88 1.1 matt mfc1 v0, $f0
89 1.1 matt jr ra
90 1.1 matt END(__negsf2)
91 1.1 matt
92 1.1 matt LEAF_NOPROFILE(__truncdfsf2)
93 1.1 matt dmtc1 a0, $f12
94 1.1 matt COP1_SYNC
95 1.1 matt cvt.s.d $f0, $f12
96 1.1 matt mfc1 v0, $f0
97 1.1 matt jr ra
98 1.1 matt END(__truncdfsf2)
99 1.1 matt
100 1.1 matt LEAF_NOPROFILE(__fixsfdi)
101 1.1 matt mtc1 a0, $f12
102 1.1 matt COP1_SYNC
103 1.1 matt trunc.l.s $f0, $f12
104 1.1 matt dmfc1 v0, $f0
105 1.1 matt jr ra
106 1.1 matt END(__fixsfdi)
107 1.1 matt
108 1.1 matt LEAF_NOPROFILE(__fixsfsi)
109 1.1 matt mtc1 a0, $f12
110 1.1 matt COP1_SYNC
111 1.1 matt trunc.w.s $f0, $f12
112 1.1 matt mfc1 v0, $f0
113 1.1 matt jr ra
114 1.1 matt END(__fixsfsi)
115 1.1 matt
116 1.1 matt LEAF_NOPROFILE(__fixunssfdi)
117 1.1 matt lui t0, 0x5f00 # 9223372036854775808.0
118 1.1 matt mtc1 t0, $f0
119 1.1 matt mtc1 a0, $f12
120 1.1 matt COP1_SYNC
121 1.1 matt sub.s $f0, $f12, $f0 # convert to signed
122 1.1 matt trunc.l.s $f0, $f0
123 1.1 matt dmfc1 v0, $f0
124 1.1 matt li v1, 1
125 1.1 matt dsll v1, v1, 63
126 1.1 matt add v0, v0, v1 # convert to unsigned
127 1.1 matt jr ra
128 1.1 matt END(__fixunssfdi)
129 1.1 matt
130 1.1 matt LEAF_NOPROFILE(__fixunssfsi)
131 1.1 matt lui t0, 0x4f00 # 2147483648.0
132 1.1 matt mtc1 t0, $f0
133 1.1 matt mtc1 a0, $f12
134 1.1 matt COP1_SYNC
135 1.1 matt sub.s $f0, $f12, $f0 # convert to signed
136 1.1 matt trunc.w.s $f0, $f0
137 1.1 matt mfc1 v0, $f0
138 1.1 matt lui v1, 0x8000 # 0xffffffff80000000
139 1.1 matt add v0, v0, v1 # convert to unsigned
140 1.1 matt jr ra
141 1.1 matt END(__fixunssfsi)
142 1.1 matt
143 1.1 matt LEAF_NOPROFILE(__floatdisf)
144 1.1 matt dmtc1 a0, $f12
145 1.1 matt COP1_SYNC
146 1.1 matt cvt.s.l $f0, $f12
147 1.1 matt mfc1 v0, $f0
148 1.1 matt jr ra
149 1.1 matt END(__floatdisf)
150 1.1 matt
151 1.1 matt LEAF_NOPROFILE(__floatsisf)
152 1.1 matt mtc1 a0, $f12
153 1.1 matt COP1_SYNC
154 1.1 matt cvt.s.w $f0, $f12
155 1.1 matt mfc1 v0, $f0
156 1.1 matt jr ra
157 1.1 matt END(__floatsisf)
158 1.1 matt
159 1.1 matt LEAF_NOPROFILE(__floatundisf)
160 1.1 matt li t0, 1
161 1.1 matt dsll t0, t0, 63 # 9223372036854775808.0
162 1.1 matt dsub a0, a0, t0 # convert to signed
163 1.1 matt dmtc1 a0, $f12
164 1.1 matt dmtc1 t0, $f14
165 1.1 matt COP1_SYNC
166 1.1 matt cvt.s.l $f0, $f12
167 1.1 matt cvt.s.l $f2, $f14
168 1.1 matt add.s $f0, $f0, $f2 # convert back to unsigned
169 1.1 matt mfc1 v0, $f0
170 1.1 matt jr ra
171 1.1 matt END(__floatundisf)
172 1.1 matt
173 1.1 matt LEAF_NOPROFILE(__floatunsisf)
174 1.1 matt sll a0, a0, 0 # sign extend to 64 bits
175 1.1 matt dmtc1 a0, $f12
176 1.1 matt COP1_SYNC
177 1.1 matt cvt.s.l $f0, $f12
178 1.1 matt mfc1 v0, $f0
179 1.1 matt jr ra
180 1.1 matt END(__floatunsisf)
181 1.1 matt
182 1.1 matt STRONG_ALIAS(__eqsf2, __nedf2)
183 1.1 matt LEAF_NOPROFILE(__nesf2)
184 1.1 matt .set push
185 1.1 matt .set noreorder
186 1.1 matt mtc1 a0, $f12
187 1.1 matt mtc1 a1, $f14
188 1.1 matt COP1_SYNC
189 1.1 matt c.eq.s $f12, $f14
190 1.1 matt bc1f 2f
191 1.1 matt li v0, 1
192 1.1 matt move v0, zero
193 1.1 matt 2: jr ra
194 1.1 matt nop
195 1.1 matt .set pop
196 1.1 matt END(__nesf2)
197 1.1 matt
198 1.1 matt STRONG_ALIAS(__gesf2, __ltdf2)
199 1.1 matt LEAF_NOPROFILE(__ltsf2)
200 1.1 matt .set push
201 1.1 matt .set noreorder
202 1.1 matt mtc1 a0, $f12
203 1.1 matt mtc1 a1, $f14
204 1.1 matt COP1_SYNC
205 1.1 matt c.olt.s $f12, $f14
206 1.1 matt bc1t 2f
207 1.1 matt li v0, -1
208 1.1 matt move v0, zero
209 1.1 matt 2: jr ra
210 1.1 matt nop
211 1.1 matt .set pop
212 1.1 matt END(__ltsf2)
213 1.1 matt
214 1.1 matt STRONG_ALIAS(__gtsf2, __ledf2)
215 1.1 matt LEAF_NOPROFILE(__lesf2)
216 1.1 matt .set push
217 1.1 matt .set noreorder
218 1.1 matt mtc1 a0, $f12
219 1.1 matt mtc1 a1, $f14
220 1.1 matt COP1_SYNC
221 1.1 matt c.ole.s $f12, $f14
222 1.1 matt bc1f 2f
223 1.1 matt li v0, 1
224 1.1 matt move v0, zero
225 1.1 matt 2: jr ra
226 1.1 matt nop
227 1.1 matt .set pop
228 1.1 matt END(__lesf2)
229 1.1 matt
230 1.1 matt LEAF_NOPROFILE(__unordsf2)
231 1.1 matt .set push
232 1.1 matt .set noreorder
233 1.1 matt mtc1 a0, $f12
234 1.1 matt mtc1 a1, $f14
235 1.1 matt COP1_SYNC
236 1.1 matt c.un.s $f12, $f14
237 1.1 matt bc1t 2f
238 1.1 matt li v0, 1
239 1.1 matt move v0, zero
240 1.1 matt 2: jr ra
241 1.1 matt nop
242 1.1 matt .set pop
243 1.1 matt END(__unordsf2)
244