8 . $($nInf = -1.0 / 0.0)
10 # define x7f 0x7fffffff
11 # define x80 0x80000000
13 # define x7f 0x7fffffffffffffff
14 # define x80 0x8000000000000000
17 #if (__mips__ && __mips_isa_rev < 6) || __sparc__ || __hppa__ || __riscv
19 #elif (__mips__ && __mips_isa_rev >= 6) || __arm__ || __aarch64__ || __alpha__ || __loongarch__
24 #if __mips__ || __arm__ || __ppc__ || __sparc__ || __hppa__ || __aarch64__ || __s390__ || __riscv || __loongarch__
27 /* (at least) bug compatible with gcc 4.2.3 -ieee */
33 /* (at least) bug compatible with gcc 4.2.3 -ieee */
39 /* ensure result is correct and 0 or 1 in the result register */
40 #define xtcmp(l, t, op, r0, f0, f1, li, ri) \
43 op##r##t %r0 %f0 %f1 \
44 bnei T##op##r##t##r0##f0##f1##l %r0 0 \
46 T##op##r##t##r0##f0##f1##l: \
49 b##op##r##t bT##op##r##t##r0##f0##f1##l %f0 %f1 \
51 bT##op##r##t##r0##f0##f1##l: \
54 bnei T##op##i##t##r0##f0##f1##l %r0 0 \
56 T##op##i##t##r0##f0##f1##l: \
58 b##op##i##t bT##op##i##t##r0##f0##f1##l %f0 ri \
60 bT##op##i##t##r0##f0##f1##l: \
63 op##r##t %r0 %f0 %f1 \
64 beqi F##op##r##t##r0##f0##f1##l %r0 1 \
66 F##op##r##t##r0##f0##f1##l: \
69 beqi F##op##i##t##r0##f0##f1##l %r0 1 \
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)
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)
90 # define tcmp(l, op, li, ri) \
91 tcmp0(l, _f, op, li, ri) \
92 tcmp0(l, _d, op, li, ri)
95 #define xfcmp(l, t, op, r0, f0, f1, li, ri) \
98 op##r##t %r0 %f0 %f1 \
99 beqi T##op##r##t##r0##f0##f1##l %r0 0 \
101 T##op##r##t##r0##f0##f1##l: \
103 op##i##t %r0 %f0 ri \
104 beqi T##op##i##t##r0##f0##f1##l %r0 0 \
106 T##op##i##t##r0##f0##f1##l: \
109 op##r##t %r0 %f0 %f1 \
110 bnei F##op##r##t##r0##f0##f1##l %r0 1 \
112 F##op##r##t##r0##f0##f1##l: \
114 op##i##t %r0 %f0 ri \
115 bnei F##op##i##t##r0##f0##f1##l %r0 1 \
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)
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)
136 # define fcmp(l, op, li, ri) \
137 fcmp0(l, _f, op, li, ri) \
138 fcmp0(l, _d, op, li, ri)
141 #define xf2w(l, f, r0, f0, iv, fv) \
144 beqi W##f##r0##f0##l %r0 iv \
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)
162 # define f2w(l, iv, fv) \
163 xf2w(l, _f, r0, f0, iv, fv) \
164 xf2w(l, _d, r0, f0, iv, fv)
166 # define f2w(l, iv, fv) \
167 f2w0(l, _f, iv, fv) \
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
354 /* not all loongson agree on it */
356 f2w(__LINE__, wninf, $nInf)
358 f2w(__LINE__, wpinf, $pInf)
359 f2w(__LINE__, wnan, $NaN)