Commit | Line | Data |
---|---|---|
4a71579b PC |
1 | |
2 | .data 4 | |
3 | ok: | |
4 | .c "ok" | |
5 | ||
6 | . $($NaN = 0.0 / 0.0) | |
7 | . $($pInf = 1.0 / 0.0) | |
8 | . $($nInf = -1.0 / 0.0) | |
9 | #if __WORDSIZE == 32 | |
10 | # define x7f 0x7fffffff | |
11 | # define x80 0x80000000 | |
12 | #else | |
13 | # define x7f 0x7fffffffffffffff | |
14 | # define x80 0x8000000000000000 | |
15 | #endif | |
16 | ||
79bfeef6 | 17 | #if (__mips__ && __mips_isa_rev < 6) || __sparc__ || __hppa__ || __riscv |
4a71579b | 18 | # define wnan x7f |
79bfeef6 | 19 | #elif (__mips__ && __mips_isa_rev >= 6) || __arm__ || __aarch64__ || __alpha__ || __loongarch__ |
4a71579b PC |
20 | # define wnan 0 |
21 | #else | |
22 | # define wnan x80 | |
23 | #endif | |
24d91c0d | 24 | #if __mips__ || __arm__ || __ppc__ || __sparc__ || __hppa__ || __aarch64__ || __s390__ || __riscv || __loongarch__ |
4a71579b PC |
25 | # define wpinf x7f |
26 | #elif __alpha__ | |
27 | /* (at least) bug compatible with gcc 4.2.3 -ieee */ | |
28 | # define wpinf 0 | |
29 | #else | |
30 | # define wpinf x80 | |
31 | #endif | |
32 | #if __alpha__ | |
33 | /* (at least) bug compatible with gcc 4.2.3 -ieee */ | |
34 | # define wninf 0 | |
35 | #else | |
36 | # define wninf x80 | |
37 | #endif | |
38 | ||
39 | /* ensure result is correct and 0 or 1 in the result register */ | |
40 | #define xtcmp(l, t, op, r0, f0, f1, li, ri) \ | |
41 | movi##t %f0 li \ | |
42 | movi##t %f1 ri \ | |
43 | op##r##t %r0 %f0 %f1 \ | |
44 | bnei T##op##r##t##r0##f0##f1##l %r0 0 \ | |
45 | calli @abort \ | |
46 | T##op##r##t##r0##f0##f1##l: \ | |
47 | movi##t %f0 li \ | |
48 | movi##t %f1 ri \ | |
49 | b##op##r##t bT##op##r##t##r0##f0##f1##l %f0 %f1 \ | |
50 | calli @abort \ | |
51 | bT##op##r##t##r0##f0##f1##l: \ | |
52 | movi##t %f1 li \ | |
53 | op##i##t %r0 %f0 ri \ | |
54 | bnei T##op##i##t##r0##f0##f1##l %r0 0 \ | |
55 | calli @abort \ | |
56 | T##op##i##t##r0##f0##f1##l: \ | |
57 | movi##t %f1 li \ | |
58 | b##op##i##t bT##op##i##t##r0##f0##f1##l %f0 ri \ | |
59 | calli @abort \ | |
60 | bT##op##i##t##r0##f0##f1##l: \ | |
61 | movi##t %f0 li \ | |
62 | movi##t %f1 ri \ | |
63 | op##r##t %r0 %f0 %f1 \ | |
64 | beqi F##op##r##t##r0##f0##f1##l %r0 1 \ | |
65 | calli @abort \ | |
66 | F##op##r##t##r0##f0##f1##l: \ | |
67 | movi##t %f1 li \ | |
68 | op##i##t %r0 %f0 ri \ | |
69 | beqi F##op##i##t##r0##f0##f1##l %r0 1 \ | |
70 | calli @abort \ | |
71 | F##op##i##t##r0##f0##f1##l: | |
72 | #define tcmp1(l, t, op, r0, li, ri) \ | |
73 | xtcmp(l, t, op, r0, f0, f1, li, ri) \ | |
74 | xtcmp(l, t, op, r0, f1, f2, li, ri) \ | |
75 | xtcmp(l, t, op, r0, f2, f3, li, ri) \ | |
76 | xtcmp(l, t, op, r0, f3, f4, li, ri) \ | |
77 | xtcmp(l, t, op, r0, f4, f5, li, ri) | |
78 | #define tcmp0(l, t, op, li, ri) \ | |
79 | tcmp1(l, t, op, v0, li, ri) \ | |
80 | tcmp1(l, t, op, v1, li, ri) \ | |
81 | tcmp1(l, t, op, v2, li, ri) \ | |
82 | tcmp1(l, t, op, r0, li, ri) \ | |
83 | tcmp1(l, t, op, r1, li, ri) \ | |
84 | tcmp1(l, t, op, r2, li, ri) | |
85 | #if __ia64__ | |
86 | # define tcmp(l, op, li, ri) \ | |
87 | xtcmp(l, _f, op, r0, f0, f1, li, ri) \ | |
88 | xtcmp(l, _d, op, r0, f0, f1, li, ri) | |
89 | #else | |
90 | # define tcmp(l, op, li, ri) \ | |
91 | tcmp0(l, _f, op, li, ri) \ | |
92 | tcmp0(l, _d, op, li, ri) | |
93 | #endif | |
94 | ||
95 | #define xfcmp(l, t, op, r0, f0, f1, li, ri) \ | |
96 | movi##t %f0 li \ | |
97 | movi##t %f1 ri \ | |
98 | op##r##t %r0 %f0 %f1 \ | |
99 | beqi T##op##r##t##r0##f0##f1##l %r0 0 \ | |
100 | calli @abort \ | |
101 | T##op##r##t##r0##f0##f1##l: \ | |
102 | movi##t %f1 li \ | |
103 | op##i##t %r0 %f0 ri \ | |
104 | beqi T##op##i##t##r0##f0##f1##l %r0 0 \ | |
105 | calli @abort \ | |
106 | T##op##i##t##r0##f0##f1##l: \ | |
107 | movi##t %f0 li \ | |
108 | movi##t %f1 ri \ | |
109 | op##r##t %r0 %f0 %f1 \ | |
110 | bnei F##op##r##t##r0##f0##f1##l %r0 1 \ | |
111 | calli @abort \ | |
112 | F##op##r##t##r0##f0##f1##l: \ | |
113 | movi##t %f1 li \ | |
114 | op##i##t %r0 %f0 ri \ | |
115 | bnei F##op##i##t##r0##f0##f1##l %r0 1 \ | |
116 | calli @abort \ | |
117 | F##op##i##t##r0##f0##f1##l: | |
118 | #define fcmp1(l, t, op, r0, li, ri) \ | |
119 | xfcmp(l, t, op, r0, f0, f1, li, ri) \ | |
120 | xfcmp(l, t, op, r0, f1, f2, li, ri) \ | |
121 | xfcmp(l, t, op, r0, f2, f3, li, ri) \ | |
122 | xfcmp(l, t, op, r0, f3, f4, li, ri) \ | |
123 | xfcmp(l, t, op, r0, f4, f5, li, ri) | |
124 | #define fcmp0(l, t, op, li, ri) \ | |
125 | fcmp1(l, t, op, v0, li, ri) \ | |
126 | fcmp1(l, t, op, v1, li, ri) \ | |
127 | fcmp1(l, t, op, v2, li, ri) \ | |
128 | fcmp1(l, t, op, r0, li, ri) \ | |
129 | fcmp1(l, t, op, r1, li, ri) \ | |
130 | fcmp1(l, t, op, r2, li, ri) | |
131 | #if __ia64__ | |
132 | # define fcmp(l, op, li, ri) \ | |
133 | xfcmp(l, _f, op, r0, f0, f1, li, ri) \ | |
134 | xfcmp(l, _d, op, r0, f0, f1, li, ri) | |
135 | #else | |
136 | # define fcmp(l, op, li, ri) \ | |
137 | fcmp0(l, _f, op, li, ri) \ | |
138 | fcmp0(l, _d, op, li, ri) | |
139 | #endif | |
140 | ||
141 | #define xf2w(l, f, r0, f0, iv, fv) \ | |
142 | movi##f %f0 fv \ | |
143 | truncr##f %r0 %f0 \ | |
144 | beqi W##f##r0##f0##l %r0 iv \ | |
145 | calli @abort \ | |
146 | W##f##r0##f0##l: | |
147 | #define f2w1(l, t, r0, iv, fv) \ | |
148 | xf2w(l, t, r0, f0, iv, fv) \ | |
149 | xf2w(l, t, r0, f1, iv, fv) \ | |
150 | xf2w(l, t, r0, f2, iv, fv) \ | |
151 | xf2w(l, t, r0, f3, iv, fv) \ | |
152 | xf2w(l, t, r0, f4, iv, fv) \ | |
153 | xf2w(l, t, r0, f5, iv, fv) | |
154 | #define f2w0(l, t, iv, fv) \ | |
155 | f2w1(l, t, v0, iv, fv) \ | |
156 | f2w1(l, t, v1, iv, fv) \ | |
157 | f2w1(l, t, v2, iv, fv) \ | |
158 | f2w1(l, t, r0, iv, fv) \ | |
159 | f2w1(l, t, r1, iv, fv) \ | |
160 | f2w1(l, t, r2, iv, fv) | |
161 | #if __ia64__ | |
162 | # define f2w(l, iv, fv) \ | |
163 | xf2w(l, _f, r0, f0, iv, fv) \ | |
164 | xf2w(l, _d, r0, f0, iv, fv) | |
165 | #else | |
166 | # define f2w(l, iv, fv) \ | |
167 | f2w0(l, _f, iv, fv) \ | |
168 | f2w0(l, _d, iv, fv) | |
169 | #endif | |
170 | ||
171 | .code | |
172 | prolog | |
173 | ||
174 | tcmp(__LINE__, lt, 0, 1) | |
175 | tcmp(__LINE__, lt, $nInf, $pInf) | |
176 | tcmp(__LINE__, lt, $nInf, 0) | |
177 | tcmp(__LINE__, lt, 0, $pInf) | |
178 | fcmp(__LINE__, lt, $NaN, 0) | |
179 | fcmp(__LINE__, lt, $NaN, $NaN) | |
180 | fcmp(__LINE__, lt, $nInf, $NaN) | |
181 | fcmp(__LINE__, lt, 1, 0) | |
182 | fcmp(__LINE__, lt, 0, 0) | |
183 | fcmp(__LINE__, lt, $pInf, $nInf) | |
184 | fcmp(__LINE__, lt, 0, $nInf) | |
185 | fcmp(__LINE__, lt, 0, $NaN) | |
186 | ||
187 | tcmp(__LINE__, le, 0, 1) | |
188 | tcmp(__LINE__, le, 0, 0) | |
189 | tcmp(__LINE__, le, 1, 1) | |
190 | tcmp(__LINE__, le, $nInf, $pInf) | |
191 | tcmp(__LINE__, le, $nInf, 0) | |
192 | tcmp(__LINE__, le, 0, $pInf) | |
193 | fcmp(__LINE__, le, $NaN, 0) | |
194 | fcmp(__LINE__, le, $NaN, $NaN) | |
195 | fcmp(__LINE__, le, $nInf, $NaN) | |
196 | fcmp(__LINE__, le, 1, 0) | |
197 | fcmp(__LINE__, le, $pInf, $nInf) | |
198 | fcmp(__LINE__, le, 0, $nInf) | |
199 | fcmp(__LINE__, le, 0, $NaN) | |
200 | ||
201 | tcmp(__LINE__, eq, 0, 0) | |
202 | tcmp(__LINE__, eq, 1, 1) | |
203 | fcmp(__LINE__, eq, $NaN, 0) | |
204 | fcmp(__LINE__, eq, $NaN, $NaN) | |
205 | fcmp(__LINE__, eq, $nInf, $NaN) | |
206 | fcmp(__LINE__, eq, 0, 1) | |
207 | fcmp(__LINE__, eq, 1, 0) | |
208 | fcmp(__LINE__, eq, $pInf, $nInf) | |
209 | fcmp(__LINE__, eq, 0, $nInf) | |
210 | fcmp(__LINE__, eq, 0, $NaN) | |
211 | ||
212 | tcmp(__LINE__, ge, 1, 0) | |
213 | tcmp(__LINE__, ge, 0, 0) | |
214 | tcmp(__LINE__, ge, 1, 1) | |
215 | tcmp(__LINE__, ge, $pInf, $nInf) | |
216 | tcmp(__LINE__, ge, 0, $nInf) | |
217 | tcmp(__LINE__, ge, $pInf, 0) | |
218 | fcmp(__LINE__, ge, $NaN, 0) | |
219 | fcmp(__LINE__, ge, $NaN, $NaN) | |
220 | fcmp(__LINE__, ge, $nInf, $NaN) | |
221 | fcmp(__LINE__, ge, 0, 1) | |
222 | fcmp(__LINE__, ge, $nInf, $pInf) | |
223 | fcmp(__LINE__, ge, $nInf, 0) | |
224 | fcmp(__LINE__, ge, 0, $NaN) | |
225 | ||
226 | tcmp(__LINE__, gt, 1, 0) | |
227 | tcmp(__LINE__, gt, $pInf, $nInf) | |
228 | tcmp(__LINE__, gt, 0, $nInf) | |
229 | tcmp(__LINE__, gt, $pInf, 0) | |
230 | fcmp(__LINE__, gt, $NaN, 0) | |
231 | fcmp(__LINE__, gt, $NaN, $NaN) | |
232 | fcmp(__LINE__, gt, $nInf, $NaN) | |
233 | fcmp(__LINE__, gt, 0, 1) | |
234 | fcmp(__LINE__, gt, 0, 0) | |
235 | fcmp(__LINE__, gt, $nInf, $pInf) | |
236 | fcmp(__LINE__, gt, $nInf, 0) | |
237 | fcmp(__LINE__, gt, 0, $NaN) | |
238 | ||
239 | tcmp(__LINE__, ne, 0, 1) | |
240 | tcmp(__LINE__, ne, 1, 0) | |
241 | tcmp(__LINE__, ne, $NaN, $NaN) | |
242 | tcmp(__LINE__, ne, $nInf, $pInf) | |
243 | tcmp(__LINE__, ne, $NaN, 0) | |
244 | tcmp(__LINE__, ne, $nInf, $NaN) | |
245 | tcmp(__LINE__, ne, $pInf, $nInf) | |
246 | tcmp(__LINE__, ne, 0, $nInf) | |
247 | tcmp(__LINE__, ne, 0, $NaN) | |
248 | fcmp(__LINE__, ne, 0, 0) | |
249 | fcmp(__LINE__, ne, 1, 1) | |
250 | ||
251 | tcmp(__LINE__, unlt, 0, 1) | |
252 | tcmp(__LINE__, unlt, $nInf, $pInf) | |
253 | tcmp(__LINE__, unlt, $nInf, 0) | |
254 | tcmp(__LINE__, unlt, 0, $pInf) | |
255 | tcmp(__LINE__, unlt, $NaN, 0) | |
256 | tcmp(__LINE__, unlt, $NaN, $NaN) | |
257 | tcmp(__LINE__, unlt, $nInf, $NaN) | |
258 | tcmp(__LINE__, unlt, 0, $NaN) | |
259 | fcmp(__LINE__, unlt, 1, 0) | |
260 | fcmp(__LINE__, unlt, 0, 0) | |
261 | fcmp(__LINE__, unlt, $pInf, $nInf) | |
262 | fcmp(__LINE__, unlt, 0, $nInf) | |
263 | ||
264 | tcmp(__LINE__, unle, 0, 1) | |
265 | tcmp(__LINE__, unle, 0, 0) | |
266 | tcmp(__LINE__, unle, 1, 1) | |
267 | tcmp(__LINE__, unle, $nInf, $pInf) | |
268 | tcmp(__LINE__, unle, $nInf, 0) | |
269 | tcmp(__LINE__, unle, 0, $pInf) | |
270 | tcmp(__LINE__, unle, $NaN, 0) | |
271 | tcmp(__LINE__, unle, $NaN, $NaN) | |
272 | tcmp(__LINE__, unle, $nInf, $NaN) | |
273 | tcmp(__LINE__, unle, 0, $NaN) | |
274 | fcmp(__LINE__, unle, 1, 0) | |
275 | fcmp(__LINE__, unle, $pInf, $nInf) | |
276 | fcmp(__LINE__, unle, 0, $nInf) | |
277 | ||
278 | tcmp(__LINE__, uneq, 0, 0) | |
279 | tcmp(__LINE__, uneq, 1, 1) | |
280 | tcmp(__LINE__, uneq, $NaN, 0) | |
281 | tcmp(__LINE__, uneq, $NaN, $NaN) | |
282 | tcmp(__LINE__, uneq, $nInf, $NaN) | |
283 | tcmp(__LINE__, uneq, 0, $NaN) | |
284 | fcmp(__LINE__, uneq, 0, 1) | |
285 | fcmp(__LINE__, uneq, 1, 0) | |
286 | fcmp(__LINE__, uneq, $pInf, $nInf) | |
287 | fcmp(__LINE__, uneq, 0, $nInf) | |
288 | ||
289 | tcmp(__LINE__, unge, 1, 0) | |
290 | tcmp(__LINE__, unge, 0, 0) | |
291 | tcmp(__LINE__, unge, 1, 1) | |
292 | tcmp(__LINE__, unge, $pInf, $nInf) | |
293 | tcmp(__LINE__, unge, 0, $nInf) | |
294 | tcmp(__LINE__, unge, $pInf, 0) | |
295 | tcmp(__LINE__, unge, $NaN, 0) | |
296 | tcmp(__LINE__, unge, $NaN, $NaN) | |
297 | tcmp(__LINE__, unge, $nInf, $NaN) | |
298 | tcmp(__LINE__, unge, 0, $NaN) | |
299 | fcmp(__LINE__, unge, 0, 1) | |
300 | fcmp(__LINE__, unge, $nInf, $pInf) | |
301 | fcmp(__LINE__, unge, $nInf, 0) | |
302 | ||
303 | tcmp(__LINE__, ungt, 1, 0) | |
304 | tcmp(__LINE__, ungt, $pInf, $nInf) | |
305 | tcmp(__LINE__, ungt, 0, $nInf) | |
306 | tcmp(__LINE__, ungt, $pInf, 0) | |
307 | tcmp(__LINE__, ungt, $NaN, 0) | |
308 | tcmp(__LINE__, ungt, $NaN, $NaN) | |
309 | tcmp(__LINE__, ungt, $nInf, $NaN) | |
310 | tcmp(__LINE__, ungt, 0, $NaN) | |
311 | fcmp(__LINE__, ungt, 0, 1) | |
312 | fcmp(__LINE__, ungt, 0, 0) | |
313 | fcmp(__LINE__, ungt, $nInf, $pInf) | |
314 | fcmp(__LINE__, ungt, $nInf, 0) | |
315 | ||
316 | tcmp(__LINE__, ltgt, 0, 1) | |
317 | tcmp(__LINE__, ltgt, 1, 0) | |
318 | tcmp(__LINE__, ltgt, $nInf, $pInf) | |
319 | tcmp(__LINE__, ltgt, $pInf, $nInf) | |
320 | tcmp(__LINE__, ltgt, 0, $nInf) | |
321 | fcmp(__LINE__, ltgt, $NaN, $NaN) | |
322 | fcmp(__LINE__, ltgt, $NaN, 0) | |
323 | fcmp(__LINE__, ltgt, $nInf, $NaN) | |
324 | fcmp(__LINE__, ltgt, 0, $NaN) | |
325 | fcmp(__LINE__, ltgt, 0, 0) | |
326 | fcmp(__LINE__, ltgt, 1, 1) | |
327 | ||
328 | tcmp(__LINE__, ord, 0, 1) | |
329 | tcmp(__LINE__, ord, 1, 0) | |
330 | tcmp(__LINE__, ord, $nInf, $pInf) | |
331 | tcmp(__LINE__, ord, $pInf, $nInf) | |
332 | tcmp(__LINE__, ord, 0, $nInf) | |
333 | tcmp(__LINE__, ord, 0, 0) | |
334 | tcmp(__LINE__, ord, 1, 1) | |
335 | fcmp(__LINE__, ord, $NaN, $NaN) | |
336 | fcmp(__LINE__, ord, $NaN, 0) | |
337 | fcmp(__LINE__, ord, $nInf, $NaN) | |
338 | fcmp(__LINE__, ord, 0, $NaN) | |
339 | ||
340 | tcmp(__LINE__, unord, $NaN, $NaN) | |
341 | tcmp(__LINE__, unord, $NaN, 0) | |
342 | tcmp(__LINE__, unord, $nInf, $NaN) | |
343 | tcmp(__LINE__, unord, 0, $NaN) | |
344 | fcmp(__LINE__, unord, 0, 1) | |
345 | fcmp(__LINE__, unord, 1, 0) | |
346 | fcmp(__LINE__, unord, $nInf, $pInf) | |
347 | fcmp(__LINE__, unord, $pInf, $nInf) | |
348 | fcmp(__LINE__, unord, 0, $nInf) | |
349 | fcmp(__LINE__, unord, 0, 0) | |
350 | fcmp(__LINE__, unord, 1, 1) | |
351 | ||
352 | f2w(__LINE__, 0, 0) | |
353 | f2w(__LINE__, 1, 1) | |
354 | /* not all loongson agree on it */ | |
355 | #if !__mips__ | |
356 | f2w(__LINE__, wninf, $nInf) | |
357 | #endif | |
358 | f2w(__LINE__, wpinf, $pInf) | |
359 | f2w(__LINE__, wnan, $NaN) | |
360 | ||
361 | prepare | |
362 | pushargi ok | |
363 | ellipsis | |
364 | finishi @puts | |
365 | ||
366 | ret | |
367 | epilog |