Restore build on older Linux hosts.
[qemu/dscho.git] / target-mips / op_helper.c
blob477b80d516e5720ae4763b3ea24fbc2e53702598
1 /*
2 * MIPS emulation helpers for qemu.
3 *
4 * Copyright (c) 2004-2005 Jocelyn Mayer
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <stdlib.h>
21 #include "exec.h"
23 #define GETPC() (__builtin_return_address(0))
25 /*****************************************************************************/
26 /* Exceptions processing helpers */
28 void do_raise_exception_err (uint32_t exception, int error_code)
30 #if 1
31 if (logfile && exception < 0x100)
32 fprintf(logfile, "%s: %d %d\n", __func__, exception, error_code);
33 #endif
34 env->exception_index = exception;
35 env->error_code = error_code;
36 T0 = 0;
37 cpu_loop_exit();
40 void do_raise_exception (uint32_t exception)
42 do_raise_exception_err(exception, 0);
45 void do_restore_state (void *pc_ptr)
47 TranslationBlock *tb;
48 unsigned long pc = (unsigned long) pc_ptr;
50 tb = tb_find_pc (pc);
51 cpu_restore_state (tb, env, pc, NULL);
54 void do_raise_exception_direct_err (uint32_t exception, int error_code)
56 do_restore_state (GETPC ());
57 do_raise_exception_err (exception, error_code);
60 void do_raise_exception_direct (uint32_t exception)
62 do_raise_exception_direct_err (exception, 0);
65 #define MEMSUFFIX _raw
66 #include "op_helper_mem.c"
67 #undef MEMSUFFIX
68 #if !defined(CONFIG_USER_ONLY)
69 #define MEMSUFFIX _user
70 #include "op_helper_mem.c"
71 #undef MEMSUFFIX
72 #define MEMSUFFIX _kernel
73 #include "op_helper_mem.c"
74 #undef MEMSUFFIX
75 #endif
77 #ifdef TARGET_MIPS64
78 #if TARGET_LONG_BITS > HOST_LONG_BITS
79 /* Those might call libgcc functions. */
80 void do_dsll (void)
82 T0 = T0 << T1;
85 void do_dsll32 (void)
87 T0 = T0 << (T1 + 32);
90 void do_dsra (void)
92 T0 = (int64_t)T0 >> T1;
95 void do_dsra32 (void)
97 T0 = (int64_t)T0 >> (T1 + 32);
100 void do_dsrl (void)
102 T0 = T0 >> T1;
105 void do_dsrl32 (void)
107 T0 = T0 >> (T1 + 32);
110 void do_drotr (void)
112 target_ulong tmp;
114 if (T1) {
115 tmp = T0 << (0x40 - T1);
116 T0 = (T0 >> T1) | tmp;
120 void do_drotr32 (void)
122 target_ulong tmp;
124 if (T1) {
125 tmp = T0 << (0x40 - (32 + T1));
126 T0 = (T0 >> (32 + T1)) | tmp;
130 void do_dsllv (void)
132 T0 = T1 << (T0 & 0x3F);
135 void do_dsrav (void)
137 T0 = (int64_t)T1 >> (T0 & 0x3F);
140 void do_dsrlv (void)
142 T0 = T1 >> (T0 & 0x3F);
145 void do_drotrv (void)
147 target_ulong tmp;
149 T0 &= 0x3F;
150 if (T0) {
151 tmp = T1 << (0x40 - T0);
152 T0 = (T1 >> T0) | tmp;
153 } else
154 T0 = T1;
156 #endif /* TARGET_LONG_BITS > HOST_LONG_BITS */
157 #endif /* TARGET_MIPS64 */
159 /* 64 bits arithmetic for 32 bits hosts */
160 #if TARGET_LONG_BITS > HOST_LONG_BITS
161 static inline uint64_t get_HILO (void)
163 return (env->HI << 32) | (uint32_t)env->LO;
166 static inline void set_HILO (uint64_t HILO)
168 env->LO = (int32_t)HILO;
169 env->HI = (int32_t)(HILO >> 32);
172 void do_mult (void)
174 set_HILO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
177 void do_multu (void)
179 set_HILO((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
182 void do_madd (void)
184 int64_t tmp;
186 tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
187 set_HILO((int64_t)get_HILO() + tmp);
190 void do_maddu (void)
192 uint64_t tmp;
194 tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
195 set_HILO(get_HILO() + tmp);
198 void do_msub (void)
200 int64_t tmp;
202 tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
203 set_HILO((int64_t)get_HILO() - tmp);
206 void do_msubu (void)
208 uint64_t tmp;
210 tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
211 set_HILO(get_HILO() - tmp);
213 #endif
215 #if HOST_LONG_BITS < 64
216 void do_div (void)
218 /* 64bit datatypes because we may see overflow/underflow. */
219 if (T1 != 0) {
220 env->LO = (int32_t)((int64_t)(int32_t)T0 / (int32_t)T1);
221 env->HI = (int32_t)((int64_t)(int32_t)T0 % (int32_t)T1);
224 #endif
226 #ifdef TARGET_MIPS64
227 void do_ddiv (void)
229 if (T1 != 0) {
230 lldiv_t res = lldiv((int64_t)T0, (int64_t)T1);
231 env->LO = res.quot;
232 env->HI = res.rem;
236 #if TARGET_LONG_BITS > HOST_LONG_BITS
237 void do_ddivu (void)
239 if (T1 != 0) {
240 env->LO = T0 / T1;
241 env->HI = T0 % T1;
244 #endif
245 #endif /* TARGET_MIPS64 */
247 #if defined(CONFIG_USER_ONLY)
248 void do_mfc0_random (void)
250 cpu_abort(env, "mfc0 random\n");
253 void do_mfc0_count (void)
255 cpu_abort(env, "mfc0 count\n");
258 void cpu_mips_store_count(CPUState *env, uint32_t value)
260 cpu_abort(env, "mtc0 count\n");
263 void cpu_mips_store_compare(CPUState *env, uint32_t value)
265 cpu_abort(env, "mtc0 compare\n");
268 void cpu_mips_update_irq(CPUState *env)
270 cpu_abort(env, "mtc0 status / mtc0 cause\n");
273 void do_mtc0_status_debug(uint32_t old, uint32_t val)
275 cpu_abort(env, "mtc0 status debug\n");
278 void do_mtc0_status_irqraise_debug (void)
280 cpu_abort(env, "mtc0 status irqraise debug\n");
283 void cpu_mips_tlb_flush (CPUState *env, int flush_global)
285 cpu_abort(env, "mips_tlb_flush\n");
288 #else
290 /* CP0 helpers */
291 void do_mfc0_random (void)
293 T0 = (int32_t)cpu_mips_get_random(env);
296 void do_mfc0_count (void)
298 T0 = (int32_t)cpu_mips_get_count(env);
301 void do_mtc0_status_debug(uint32_t old, uint32_t val)
303 fprintf(logfile, "Status %08x (%08x) => %08x (%08x) Cause %08x",
304 old, old & env->CP0_Cause & CP0Ca_IP_mask,
305 val, val & env->CP0_Cause & CP0Ca_IP_mask,
306 env->CP0_Cause);
307 (env->hflags & MIPS_HFLAG_UM) ? fputs(", UM\n", logfile)
308 : fputs("\n", logfile);
311 void do_mtc0_status_irqraise_debug(void)
313 fprintf(logfile, "Raise pending IRQs\n");
316 void fpu_handle_exception(void)
318 #ifdef CONFIG_SOFTFLOAT
319 int flags = get_float_exception_flags(&env->fp_status);
320 unsigned int cpuflags = 0, enable, cause = 0;
322 enable = GET_FP_ENABLE(env->fcr31);
324 /* determine current flags */
325 if (flags & float_flag_invalid) {
326 cpuflags |= FP_INVALID;
327 cause |= FP_INVALID & enable;
329 if (flags & float_flag_divbyzero) {
330 cpuflags |= FP_DIV0;
331 cause |= FP_DIV0 & enable;
333 if (flags & float_flag_overflow) {
334 cpuflags |= FP_OVERFLOW;
335 cause |= FP_OVERFLOW & enable;
337 if (flags & float_flag_underflow) {
338 cpuflags |= FP_UNDERFLOW;
339 cause |= FP_UNDERFLOW & enable;
341 if (flags & float_flag_inexact) {
342 cpuflags |= FP_INEXACT;
343 cause |= FP_INEXACT & enable;
345 SET_FP_FLAGS(env->fcr31, cpuflags);
346 SET_FP_CAUSE(env->fcr31, cause);
347 #else
348 SET_FP_FLAGS(env->fcr31, 0);
349 SET_FP_CAUSE(env->fcr31, 0);
350 #endif
353 /* TLB management */
354 void cpu_mips_tlb_flush (CPUState *env, int flush_global)
356 /* Flush qemu's TLB and discard all shadowed entries. */
357 tlb_flush (env, flush_global);
358 env->tlb_in_use = env->nb_tlb;
361 static void r4k_mips_tlb_flush_extra (CPUState *env, int first)
363 /* Discard entries from env->tlb[first] onwards. */
364 while (env->tlb_in_use > first) {
365 r4k_invalidate_tlb(env, --env->tlb_in_use, 0);
369 static void r4k_fill_tlb (int idx)
371 r4k_tlb_t *tlb;
373 /* XXX: detect conflicting TLBs and raise a MCHECK exception when needed */
374 tlb = &env->mmu.r4k.tlb[idx];
375 tlb->VPN = env->CP0_EntryHi & (TARGET_PAGE_MASK << 1);
376 #ifdef TARGET_MIPS64
377 tlb->VPN &= env->SEGMask;
378 #endif
379 tlb->ASID = env->CP0_EntryHi & 0xFF;
380 tlb->PageMask = env->CP0_PageMask;
381 tlb->G = env->CP0_EntryLo0 & env->CP0_EntryLo1 & 1;
382 tlb->V0 = (env->CP0_EntryLo0 & 2) != 0;
383 tlb->D0 = (env->CP0_EntryLo0 & 4) != 0;
384 tlb->C0 = (env->CP0_EntryLo0 >> 3) & 0x7;
385 tlb->PFN[0] = (env->CP0_EntryLo0 >> 6) << 12;
386 tlb->V1 = (env->CP0_EntryLo1 & 2) != 0;
387 tlb->D1 = (env->CP0_EntryLo1 & 4) != 0;
388 tlb->C1 = (env->CP0_EntryLo1 >> 3) & 0x7;
389 tlb->PFN[1] = (env->CP0_EntryLo1 >> 6) << 12;
392 void r4k_do_tlbwi (void)
394 /* Discard cached TLB entries. We could avoid doing this if the
395 tlbwi is just upgrading access permissions on the current entry;
396 that might be a further win. */
397 r4k_mips_tlb_flush_extra (env, env->nb_tlb);
399 r4k_invalidate_tlb(env, env->CP0_Index % env->nb_tlb, 0);
400 r4k_fill_tlb(env->CP0_Index % env->nb_tlb);
403 void r4k_do_tlbwr (void)
405 int r = cpu_mips_get_random(env);
407 r4k_invalidate_tlb(env, r, 1);
408 r4k_fill_tlb(r);
411 void r4k_do_tlbp (void)
413 r4k_tlb_t *tlb;
414 target_ulong mask;
415 target_ulong tag;
416 target_ulong VPN;
417 uint8_t ASID;
418 int i;
420 ASID = env->CP0_EntryHi & 0xFF;
421 for (i = 0; i < env->nb_tlb; i++) {
422 tlb = &env->mmu.r4k.tlb[i];
423 /* 1k pages are not supported. */
424 mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
425 tag = env->CP0_EntryHi & ~mask;
426 VPN = tlb->VPN & ~mask;
427 /* Check ASID, virtual page number & size */
428 if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) {
429 /* TLB match */
430 env->CP0_Index = i;
431 break;
434 if (i == env->nb_tlb) {
435 /* No match. Discard any shadow entries, if any of them match. */
436 for (i = env->nb_tlb; i < env->tlb_in_use; i++) {
437 tlb = &env->mmu.r4k.tlb[i];
438 /* 1k pages are not supported. */
439 mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
440 tag = env->CP0_EntryHi & ~mask;
441 VPN = tlb->VPN & ~mask;
442 /* Check ASID, virtual page number & size */
443 if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) {
444 r4k_mips_tlb_flush_extra (env, i);
445 break;
449 env->CP0_Index |= 0x80000000;
453 void r4k_do_tlbr (void)
455 r4k_tlb_t *tlb;
456 uint8_t ASID;
458 ASID = env->CP0_EntryHi & 0xFF;
459 tlb = &env->mmu.r4k.tlb[env->CP0_Index % env->nb_tlb];
461 /* If this will change the current ASID, flush qemu's TLB. */
462 if (ASID != tlb->ASID)
463 cpu_mips_tlb_flush (env, 1);
465 r4k_mips_tlb_flush_extra(env, env->nb_tlb);
467 env->CP0_EntryHi = tlb->VPN | tlb->ASID;
468 env->CP0_PageMask = tlb->PageMask;
469 env->CP0_EntryLo0 = tlb->G | (tlb->V0 << 1) | (tlb->D0 << 2) |
470 (tlb->C0 << 3) | (tlb->PFN[0] >> 6);
471 env->CP0_EntryLo1 = tlb->G | (tlb->V1 << 1) | (tlb->D1 << 2) |
472 (tlb->C1 << 3) | (tlb->PFN[1] >> 6);
475 #endif /* !CONFIG_USER_ONLY */
477 void dump_ldst (const unsigned char *func)
479 if (loglevel)
480 fprintf(logfile, "%s => " TARGET_FMT_lx " " TARGET_FMT_lx "\n", __func__, T0, T1);
483 void dump_sc (void)
485 if (loglevel) {
486 fprintf(logfile, "%s " TARGET_FMT_lx " at " TARGET_FMT_lx " (" TARGET_FMT_lx ")\n", __func__,
487 T1, T0, env->CP0_LLAddr);
491 void debug_pre_eret (void)
493 fprintf(logfile, "ERET: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx,
494 env->PC, env->CP0_EPC);
495 if (env->CP0_Status & (1 << CP0St_ERL))
496 fprintf(logfile, " ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC);
497 if (env->hflags & MIPS_HFLAG_DM)
498 fprintf(logfile, " DEPC " TARGET_FMT_lx, env->CP0_DEPC);
499 fputs("\n", logfile);
502 void debug_post_eret (void)
504 fprintf(logfile, " => PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx,
505 env->PC, env->CP0_EPC);
506 if (env->CP0_Status & (1 << CP0St_ERL))
507 fprintf(logfile, " ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC);
508 if (env->hflags & MIPS_HFLAG_DM)
509 fprintf(logfile, " DEPC " TARGET_FMT_lx, env->CP0_DEPC);
510 if (env->hflags & MIPS_HFLAG_UM)
511 fputs(", UM\n", logfile);
512 else
513 fputs("\n", logfile);
516 void do_pmon (int function)
518 function /= 2;
519 switch (function) {
520 case 2: /* TODO: char inbyte(int waitflag); */
521 if (env->gpr[4] == 0)
522 env->gpr[2] = -1;
523 /* Fall through */
524 case 11: /* TODO: char inbyte (void); */
525 env->gpr[2] = -1;
526 break;
527 case 3:
528 case 12:
529 printf("%c", (char)(env->gpr[4] & 0xFF));
530 break;
531 case 17:
532 break;
533 case 158:
535 unsigned char *fmt = (void *)(unsigned long)env->gpr[4];
536 printf("%s", fmt);
538 break;
542 #if !defined(CONFIG_USER_ONLY)
544 static void do_unaligned_access (target_ulong addr, int is_write, int is_user, void *retaddr);
546 #define MMUSUFFIX _mmu
547 #define ALIGNED_ONLY
549 #define SHIFT 0
550 #include "softmmu_template.h"
552 #define SHIFT 1
553 #include "softmmu_template.h"
555 #define SHIFT 2
556 #include "softmmu_template.h"
558 #define SHIFT 3
559 #include "softmmu_template.h"
561 static void do_unaligned_access (target_ulong addr, int is_write, int is_user, void *retaddr)
563 env->CP0_BadVAddr = addr;
564 do_restore_state (retaddr);
565 do_raise_exception ((is_write == 1) ? EXCP_AdES : EXCP_AdEL);
568 void tlb_fill (target_ulong addr, int is_write, int is_user, void *retaddr)
570 TranslationBlock *tb;
571 CPUState *saved_env;
572 unsigned long pc;
573 int ret;
575 /* XXX: hack to restore env in all cases, even if not called from
576 generated code */
577 saved_env = env;
578 env = cpu_single_env;
579 ret = cpu_mips_handle_mmu_fault(env, addr, is_write, is_user, 1);
580 if (ret) {
581 if (retaddr) {
582 /* now we have a real cpu fault */
583 pc = (unsigned long)retaddr;
584 tb = tb_find_pc(pc);
585 if (tb) {
586 /* the PC is inside the translated code. It means that we have
587 a virtual CPU fault */
588 cpu_restore_state(tb, env, pc, NULL);
591 do_raise_exception_err(env->exception_index, env->error_code);
593 env = saved_env;
596 #endif
598 /* Complex FPU operations which may need stack space. */
600 #define FLOAT_SIGN32 (1 << 31)
601 #define FLOAT_SIGN64 (1ULL << 63)
602 #define FLOAT_ONE32 (0x3f8 << 20)
603 #define FLOAT_ONE64 (0x3ffULL << 52)
604 #define FLOAT_TWO32 (1 << 30)
605 #define FLOAT_TWO64 (1ULL << 62)
607 /* convert MIPS rounding mode in FCR31 to IEEE library */
608 unsigned int ieee_rm[] = {
609 float_round_nearest_even,
610 float_round_to_zero,
611 float_round_up,
612 float_round_down
615 #define RESTORE_ROUNDING_MODE \
616 set_float_rounding_mode(ieee_rm[env->fcr31 & 3], &env->fp_status)
618 void do_ctc1 (void)
620 switch(T1) {
621 case 25:
622 if (T0 & 0xffffff00)
623 return;
624 env->fcr31 = (env->fcr31 & 0x017fffff) | ((T0 & 0xfe) << 24) |
625 ((T0 & 0x1) << 23);
626 break;
627 case 26:
628 if (T0 & 0x007c0000)
629 return;
630 env->fcr31 = (env->fcr31 & 0xfffc0f83) | (T0 & 0x0003f07c);
631 break;
632 case 28:
633 if (T0 & 0x007c0000)
634 return;
635 env->fcr31 = (env->fcr31 & 0xfefff07c) | (T0 & 0x00000f83) |
636 ((T0 & 0x4) << 22);
637 break;
638 case 31:
639 if (T0 & 0x007c0000)
640 return;
641 env->fcr31 = T0;
642 break;
643 default:
644 return;
646 /* set rounding mode */
647 RESTORE_ROUNDING_MODE;
648 set_float_exception_flags(0, &env->fp_status);
649 if ((GET_FP_ENABLE(env->fcr31) | 0x20) & GET_FP_CAUSE(env->fcr31))
650 do_raise_exception(EXCP_FPE);
653 inline char ieee_ex_to_mips(char xcpt)
655 return (xcpt & float_flag_inexact) >> 5 |
656 (xcpt & float_flag_underflow) >> 3 |
657 (xcpt & float_flag_overflow) >> 1 |
658 (xcpt & float_flag_divbyzero) << 1 |
659 (xcpt & float_flag_invalid) << 4;
662 inline char mips_ex_to_ieee(char xcpt)
664 return (xcpt & FP_INEXACT) << 5 |
665 (xcpt & FP_UNDERFLOW) << 3 |
666 (xcpt & FP_OVERFLOW) << 1 |
667 (xcpt & FP_DIV0) >> 1 |
668 (xcpt & FP_INVALID) >> 4;
671 inline void update_fcr31(void)
673 int tmp = ieee_ex_to_mips(get_float_exception_flags(&env->fp_status));
675 SET_FP_CAUSE(env->fcr31, tmp);
676 if (GET_FP_ENABLE(env->fcr31) & tmp)
677 do_raise_exception(EXCP_FPE);
678 else
679 UPDATE_FP_FLAGS(env->fcr31, tmp);
682 #define FLOAT_OP(name, p) void do_float_##name##_##p(void)
684 FLOAT_OP(cvtd, s)
686 set_float_exception_flags(0, &env->fp_status);
687 FDT2 = float32_to_float64(FST0, &env->fp_status);
688 update_fcr31();
690 FLOAT_OP(cvtd, w)
692 set_float_exception_flags(0, &env->fp_status);
693 FDT2 = int32_to_float64(WT0, &env->fp_status);
694 update_fcr31();
696 FLOAT_OP(cvtd, l)
698 set_float_exception_flags(0, &env->fp_status);
699 FDT2 = int64_to_float64(DT0, &env->fp_status);
700 update_fcr31();
702 FLOAT_OP(cvtl, d)
704 set_float_exception_flags(0, &env->fp_status);
705 DT2 = float64_to_int64(FDT0, &env->fp_status);
706 update_fcr31();
707 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
708 DT2 = 0x7fffffffffffffffULL;
710 FLOAT_OP(cvtl, s)
712 set_float_exception_flags(0, &env->fp_status);
713 DT2 = float32_to_int64(FST0, &env->fp_status);
714 update_fcr31();
715 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
716 DT2 = 0x7fffffffffffffffULL;
719 FLOAT_OP(cvtps, pw)
721 set_float_exception_flags(0, &env->fp_status);
722 FST2 = int32_to_float32(WT0, &env->fp_status);
723 FSTH2 = int32_to_float32(WTH0, &env->fp_status);
724 update_fcr31();
726 FLOAT_OP(cvtpw, ps)
728 set_float_exception_flags(0, &env->fp_status);
729 WT2 = float32_to_int32(FST0, &env->fp_status);
730 WTH2 = float32_to_int32(FSTH0, &env->fp_status);
731 update_fcr31();
732 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
733 WT2 = 0x7fffffff;
735 FLOAT_OP(cvts, d)
737 set_float_exception_flags(0, &env->fp_status);
738 FST2 = float64_to_float32(FDT0, &env->fp_status);
739 update_fcr31();
741 FLOAT_OP(cvts, w)
743 set_float_exception_flags(0, &env->fp_status);
744 FST2 = int32_to_float32(WT0, &env->fp_status);
745 update_fcr31();
747 FLOAT_OP(cvts, l)
749 set_float_exception_flags(0, &env->fp_status);
750 FST2 = int64_to_float32(DT0, &env->fp_status);
751 update_fcr31();
753 FLOAT_OP(cvts, pl)
755 set_float_exception_flags(0, &env->fp_status);
756 WT2 = WT0;
757 update_fcr31();
759 FLOAT_OP(cvts, pu)
761 set_float_exception_flags(0, &env->fp_status);
762 WT2 = WTH0;
763 update_fcr31();
765 FLOAT_OP(cvtw, s)
767 set_float_exception_flags(0, &env->fp_status);
768 WT2 = float32_to_int32(FST0, &env->fp_status);
769 update_fcr31();
770 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
771 WT2 = 0x7fffffff;
773 FLOAT_OP(cvtw, d)
775 set_float_exception_flags(0, &env->fp_status);
776 WT2 = float64_to_int32(FDT0, &env->fp_status);
777 update_fcr31();
778 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
779 WT2 = 0x7fffffff;
782 FLOAT_OP(roundl, d)
784 set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
785 DT2 = float64_to_int64(FDT0, &env->fp_status);
786 RESTORE_ROUNDING_MODE;
787 update_fcr31();
788 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
789 DT2 = 0x7fffffffffffffffULL;
791 FLOAT_OP(roundl, s)
793 set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
794 DT2 = float32_to_int64(FST0, &env->fp_status);
795 RESTORE_ROUNDING_MODE;
796 update_fcr31();
797 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
798 DT2 = 0x7fffffffffffffffULL;
800 FLOAT_OP(roundw, d)
802 set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
803 WT2 = float64_to_int32(FDT0, &env->fp_status);
804 RESTORE_ROUNDING_MODE;
805 update_fcr31();
806 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
807 WT2 = 0x7fffffff;
809 FLOAT_OP(roundw, s)
811 set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
812 WT2 = float32_to_int32(FST0, &env->fp_status);
813 RESTORE_ROUNDING_MODE;
814 update_fcr31();
815 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
816 WT2 = 0x7fffffff;
819 FLOAT_OP(truncl, d)
821 DT2 = float64_to_int64_round_to_zero(FDT0, &env->fp_status);
822 update_fcr31();
823 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
824 DT2 = 0x7fffffffffffffffULL;
826 FLOAT_OP(truncl, s)
828 DT2 = float32_to_int64_round_to_zero(FST0, &env->fp_status);
829 update_fcr31();
830 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
831 DT2 = 0x7fffffffffffffffULL;
833 FLOAT_OP(truncw, d)
835 WT2 = float64_to_int32_round_to_zero(FDT0, &env->fp_status);
836 update_fcr31();
837 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
838 WT2 = 0x7fffffff;
840 FLOAT_OP(truncw, s)
842 WT2 = float32_to_int32_round_to_zero(FST0, &env->fp_status);
843 update_fcr31();
844 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
845 WT2 = 0x7fffffff;
848 FLOAT_OP(ceill, d)
850 set_float_rounding_mode(float_round_up, &env->fp_status);
851 DT2 = float64_to_int64(FDT0, &env->fp_status);
852 RESTORE_ROUNDING_MODE;
853 update_fcr31();
854 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
855 DT2 = 0x7fffffffffffffffULL;
857 FLOAT_OP(ceill, s)
859 set_float_rounding_mode(float_round_up, &env->fp_status);
860 DT2 = float32_to_int64(FST0, &env->fp_status);
861 RESTORE_ROUNDING_MODE;
862 update_fcr31();
863 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
864 DT2 = 0x7fffffffffffffffULL;
866 FLOAT_OP(ceilw, d)
868 set_float_rounding_mode(float_round_up, &env->fp_status);
869 WT2 = float64_to_int32(FDT0, &env->fp_status);
870 RESTORE_ROUNDING_MODE;
871 update_fcr31();
872 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
873 WT2 = 0x7fffffff;
875 FLOAT_OP(ceilw, s)
877 set_float_rounding_mode(float_round_up, &env->fp_status);
878 WT2 = float32_to_int32(FST0, &env->fp_status);
879 RESTORE_ROUNDING_MODE;
880 update_fcr31();
881 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
882 WT2 = 0x7fffffff;
885 FLOAT_OP(floorl, d)
887 set_float_rounding_mode(float_round_down, &env->fp_status);
888 DT2 = float64_to_int64(FDT0, &env->fp_status);
889 RESTORE_ROUNDING_MODE;
890 update_fcr31();
891 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
892 DT2 = 0x7fffffffffffffffULL;
894 FLOAT_OP(floorl, s)
896 set_float_rounding_mode(float_round_down, &env->fp_status);
897 DT2 = float32_to_int64(FST0, &env->fp_status);
898 RESTORE_ROUNDING_MODE;
899 update_fcr31();
900 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
901 DT2 = 0x7fffffffffffffffULL;
903 FLOAT_OP(floorw, d)
905 set_float_rounding_mode(float_round_down, &env->fp_status);
906 WT2 = float64_to_int32(FDT0, &env->fp_status);
907 RESTORE_ROUNDING_MODE;
908 update_fcr31();
909 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
910 WT2 = 0x7fffffff;
912 FLOAT_OP(floorw, s)
914 set_float_rounding_mode(float_round_down, &env->fp_status);
915 WT2 = float32_to_int32(FST0, &env->fp_status);
916 RESTORE_ROUNDING_MODE;
917 update_fcr31();
918 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
919 WT2 = 0x7fffffff;
922 /* MIPS specific unary operations */
923 FLOAT_OP(recip, d)
925 set_float_exception_flags(0, &env->fp_status);
926 FDT2 = float64_div(FLOAT_ONE64, FDT0, &env->fp_status);
927 update_fcr31();
929 FLOAT_OP(recip, s)
931 set_float_exception_flags(0, &env->fp_status);
932 FST2 = float32_div(FLOAT_ONE32, FST0, &env->fp_status);
933 update_fcr31();
936 FLOAT_OP(rsqrt, d)
938 set_float_exception_flags(0, &env->fp_status);
939 FDT2 = float64_sqrt(FDT0, &env->fp_status);
940 FDT2 = float64_div(FLOAT_ONE64, FDT2, &env->fp_status);
941 update_fcr31();
943 FLOAT_OP(rsqrt, s)
945 set_float_exception_flags(0, &env->fp_status);
946 FST2 = float32_sqrt(FST0, &env->fp_status);
947 FST2 = float32_div(FLOAT_ONE32, FST2, &env->fp_status);
948 update_fcr31();
951 FLOAT_OP(recip1, d)
953 set_float_exception_flags(0, &env->fp_status);
954 FDT2 = float64_div(FLOAT_ONE64, FDT0, &env->fp_status);
955 update_fcr31();
957 FLOAT_OP(recip1, s)
959 set_float_exception_flags(0, &env->fp_status);
960 FST2 = float32_div(FLOAT_ONE32, FST0, &env->fp_status);
961 update_fcr31();
963 FLOAT_OP(recip1, ps)
965 set_float_exception_flags(0, &env->fp_status);
966 FST2 = float32_div(FLOAT_ONE32, FST0, &env->fp_status);
967 FSTH2 = float32_div(FLOAT_ONE32, FSTH0, &env->fp_status);
968 update_fcr31();
971 FLOAT_OP(rsqrt1, d)
973 set_float_exception_flags(0, &env->fp_status);
974 FDT2 = float64_sqrt(FDT0, &env->fp_status);
975 FDT2 = float64_div(FLOAT_ONE64, FDT2, &env->fp_status);
976 update_fcr31();
978 FLOAT_OP(rsqrt1, s)
980 set_float_exception_flags(0, &env->fp_status);
981 FST2 = float32_sqrt(FST0, &env->fp_status);
982 FST2 = float32_div(FLOAT_ONE32, FST2, &env->fp_status);
983 update_fcr31();
985 FLOAT_OP(rsqrt1, ps)
987 set_float_exception_flags(0, &env->fp_status);
988 FST2 = float32_sqrt(FST0, &env->fp_status);
989 FSTH2 = float32_sqrt(FSTH0, &env->fp_status);
990 FST2 = float32_div(FLOAT_ONE32, FST2, &env->fp_status);
991 FSTH2 = float32_div(FLOAT_ONE32, FSTH2, &env->fp_status);
992 update_fcr31();
995 /* binary operations */
996 #define FLOAT_BINOP(name) \
997 FLOAT_OP(name, d) \
999 set_float_exception_flags(0, &env->fp_status); \
1000 FDT2 = float64_ ## name (FDT0, FDT1, &env->fp_status); \
1001 update_fcr31(); \
1002 if (GET_FP_CAUSE(env->fcr31) & FP_INVALID) \
1003 FDT2 = 0x7ff7ffffffffffffULL; \
1004 else if (GET_FP_CAUSE(env->fcr31) & FP_UNDERFLOW) { \
1005 if ((env->fcr31 & 0x3) == 0) \
1006 FDT2 &= FLOAT_SIGN64; \
1009 FLOAT_OP(name, s) \
1011 set_float_exception_flags(0, &env->fp_status); \
1012 FST2 = float32_ ## name (FST0, FST1, &env->fp_status); \
1013 update_fcr31(); \
1014 if (GET_FP_CAUSE(env->fcr31) & FP_INVALID) \
1015 FST2 = 0x7fbfffff; \
1016 else if (GET_FP_CAUSE(env->fcr31) & FP_UNDERFLOW) { \
1017 if ((env->fcr31 & 0x3) == 0) \
1018 FST2 &= FLOAT_SIGN32; \
1021 FLOAT_OP(name, ps) \
1023 set_float_exception_flags(0, &env->fp_status); \
1024 FST2 = float32_ ## name (FST0, FST1, &env->fp_status); \
1025 FSTH2 = float32_ ## name (FSTH0, FSTH1, &env->fp_status); \
1026 update_fcr31(); \
1027 if (GET_FP_CAUSE(env->fcr31) & FP_INVALID) { \
1028 FST2 = 0x7fbfffff; \
1029 FSTH2 = 0x7fbfffff; \
1030 } else if (GET_FP_CAUSE(env->fcr31) & FP_UNDERFLOW) { \
1031 if ((env->fcr31 & 0x3) == 0) { \
1032 FST2 &= FLOAT_SIGN32; \
1033 FSTH2 &= FLOAT_SIGN32; \
1037 FLOAT_BINOP(add)
1038 FLOAT_BINOP(sub)
1039 FLOAT_BINOP(mul)
1040 FLOAT_BINOP(div)
1041 #undef FLOAT_BINOP
1043 /* MIPS specific binary operations */
1044 FLOAT_OP(recip2, d)
1046 set_float_exception_flags(0, &env->fp_status);
1047 FDT2 = float64_mul(FDT0, FDT2, &env->fp_status);
1048 FDT2 = float64_sub(FDT2, FLOAT_ONE64, &env->fp_status) ^ FLOAT_SIGN64;
1049 update_fcr31();
1051 FLOAT_OP(recip2, s)
1053 set_float_exception_flags(0, &env->fp_status);
1054 FST2 = float32_mul(FST0, FST2, &env->fp_status);
1055 FST2 = float32_sub(FST2, FLOAT_ONE32, &env->fp_status) ^ FLOAT_SIGN32;
1056 update_fcr31();
1058 FLOAT_OP(recip2, ps)
1060 set_float_exception_flags(0, &env->fp_status);
1061 FST2 = float32_mul(FST0, FST2, &env->fp_status);
1062 FSTH2 = float32_mul(FSTH0, FSTH2, &env->fp_status);
1063 FST2 = float32_sub(FST2, FLOAT_ONE32, &env->fp_status) ^ FLOAT_SIGN32;
1064 FSTH2 = float32_sub(FSTH2, FLOAT_ONE32, &env->fp_status) ^ FLOAT_SIGN32;
1065 update_fcr31();
1068 FLOAT_OP(rsqrt2, d)
1070 set_float_exception_flags(0, &env->fp_status);
1071 FDT2 = float64_mul(FDT0, FDT2, &env->fp_status);
1072 FDT2 = float64_sub(FDT2, FLOAT_ONE64, &env->fp_status);
1073 FDT2 = float64_div(FDT2, FLOAT_TWO64, &env->fp_status) ^ FLOAT_SIGN64;
1074 update_fcr31();
1076 FLOAT_OP(rsqrt2, s)
1078 set_float_exception_flags(0, &env->fp_status);
1079 FST2 = float32_mul(FST0, FST2, &env->fp_status);
1080 FST2 = float32_sub(FST2, FLOAT_ONE32, &env->fp_status);
1081 FST2 = float32_div(FST2, FLOAT_TWO32, &env->fp_status) ^ FLOAT_SIGN32;
1082 update_fcr31();
1084 FLOAT_OP(rsqrt2, ps)
1086 set_float_exception_flags(0, &env->fp_status);
1087 FST2 = float32_mul(FST0, FST2, &env->fp_status);
1088 FSTH2 = float32_mul(FSTH0, FSTH2, &env->fp_status);
1089 FST2 = float32_sub(FST2, FLOAT_ONE32, &env->fp_status);
1090 FSTH2 = float32_sub(FSTH2, FLOAT_ONE32, &env->fp_status);
1091 FST2 = float32_div(FST2, FLOAT_TWO32, &env->fp_status) ^ FLOAT_SIGN32;
1092 FSTH2 = float32_div(FSTH2, FLOAT_TWO32, &env->fp_status) ^ FLOAT_SIGN32;
1093 update_fcr31();
1096 FLOAT_OP(addr, ps)
1098 set_float_exception_flags(0, &env->fp_status);
1099 FST2 = float32_add (FST0, FSTH0, &env->fp_status);
1100 FSTH2 = float32_add (FST1, FSTH1, &env->fp_status);
1101 update_fcr31();
1104 FLOAT_OP(mulr, ps)
1106 set_float_exception_flags(0, &env->fp_status);
1107 FST2 = float32_mul (FST0, FSTH0, &env->fp_status);
1108 FSTH2 = float32_mul (FST1, FSTH1, &env->fp_status);
1109 update_fcr31();
1112 /* compare operations */
1113 #define FOP_COND_D(op, cond) \
1114 void do_cmp_d_ ## op (long cc) \
1116 int c = cond; \
1117 update_fcr31(); \
1118 if (c) \
1119 SET_FP_COND(cc, env); \
1120 else \
1121 CLEAR_FP_COND(cc, env); \
1123 void do_cmpabs_d_ ## op (long cc) \
1125 int c; \
1126 FDT0 &= ~FLOAT_SIGN64; \
1127 FDT1 &= ~FLOAT_SIGN64; \
1128 c = cond; \
1129 update_fcr31(); \
1130 if (c) \
1131 SET_FP_COND(cc, env); \
1132 else \
1133 CLEAR_FP_COND(cc, env); \
1136 int float64_is_unordered(int sig, float64 a, float64 b STATUS_PARAM)
1138 if (float64_is_signaling_nan(a) ||
1139 float64_is_signaling_nan(b) ||
1140 (sig && (float64_is_nan(a) || float64_is_nan(b)))) {
1141 float_raise(float_flag_invalid, status);
1142 return 1;
1143 } else if (float64_is_nan(a) || float64_is_nan(b)) {
1144 return 1;
1145 } else {
1146 return 0;
1150 /* NOTE: the comma operator will make "cond" to eval to false,
1151 * but float*_is_unordered() is still called. */
1152 FOP_COND_D(f, (float64_is_unordered(0, FDT1, FDT0, &env->fp_status), 0))
1153 FOP_COND_D(un, float64_is_unordered(0, FDT1, FDT0, &env->fp_status))
1154 FOP_COND_D(eq, !float64_is_unordered(0, FDT1, FDT0, &env->fp_status) && float64_eq(FDT0, FDT1, &env->fp_status))
1155 FOP_COND_D(ueq, float64_is_unordered(0, FDT1, FDT0, &env->fp_status) || float64_eq(FDT0, FDT1, &env->fp_status))
1156 FOP_COND_D(olt, !float64_is_unordered(0, FDT1, FDT0, &env->fp_status) && float64_lt(FDT0, FDT1, &env->fp_status))
1157 FOP_COND_D(ult, float64_is_unordered(0, FDT1, FDT0, &env->fp_status) || float64_lt(FDT0, FDT1, &env->fp_status))
1158 FOP_COND_D(ole, !float64_is_unordered(0, FDT1, FDT0, &env->fp_status) && float64_le(FDT0, FDT1, &env->fp_status))
1159 FOP_COND_D(ule, float64_is_unordered(0, FDT1, FDT0, &env->fp_status) || float64_le(FDT0, FDT1, &env->fp_status))
1160 /* NOTE: the comma operator will make "cond" to eval to false,
1161 * but float*_is_unordered() is still called. */
1162 FOP_COND_D(sf, (float64_is_unordered(1, FDT1, FDT0, &env->fp_status), 0))
1163 FOP_COND_D(ngle,float64_is_unordered(1, FDT1, FDT0, &env->fp_status))
1164 FOP_COND_D(seq, !float64_is_unordered(1, FDT1, FDT0, &env->fp_status) && float64_eq(FDT0, FDT1, &env->fp_status))
1165 FOP_COND_D(ngl, float64_is_unordered(1, FDT1, FDT0, &env->fp_status) || float64_eq(FDT0, FDT1, &env->fp_status))
1166 FOP_COND_D(lt, !float64_is_unordered(1, FDT1, FDT0, &env->fp_status) && float64_lt(FDT0, FDT1, &env->fp_status))
1167 FOP_COND_D(nge, float64_is_unordered(1, FDT1, FDT0, &env->fp_status) || float64_lt(FDT0, FDT1, &env->fp_status))
1168 FOP_COND_D(le, !float64_is_unordered(1, FDT1, FDT0, &env->fp_status) && float64_le(FDT0, FDT1, &env->fp_status))
1169 FOP_COND_D(ngt, float64_is_unordered(1, FDT1, FDT0, &env->fp_status) || float64_le(FDT0, FDT1, &env->fp_status))
1171 #define FOP_COND_S(op, cond) \
1172 void do_cmp_s_ ## op (long cc) \
1174 int c = cond; \
1175 update_fcr31(); \
1176 if (c) \
1177 SET_FP_COND(cc, env); \
1178 else \
1179 CLEAR_FP_COND(cc, env); \
1181 void do_cmpabs_s_ ## op (long cc) \
1183 int c; \
1184 FST0 &= ~FLOAT_SIGN32; \
1185 FST1 &= ~FLOAT_SIGN32; \
1186 c = cond; \
1187 update_fcr31(); \
1188 if (c) \
1189 SET_FP_COND(cc, env); \
1190 else \
1191 CLEAR_FP_COND(cc, env); \
1194 flag float32_is_unordered(int sig, float32 a, float32 b STATUS_PARAM)
1196 if (float32_is_signaling_nan(a) ||
1197 float32_is_signaling_nan(b) ||
1198 (sig && (float32_is_nan(a) || float32_is_nan(b)))) {
1199 float_raise(float_flag_invalid, status);
1200 return 1;
1201 } else if (float32_is_nan(a) || float32_is_nan(b)) {
1202 return 1;
1203 } else {
1204 return 0;
1208 /* NOTE: the comma operator will make "cond" to eval to false,
1209 * but float*_is_unordered() is still called. */
1210 FOP_COND_S(f, (float32_is_unordered(0, FST1, FST0, &env->fp_status), 0))
1211 FOP_COND_S(un, float32_is_unordered(0, FST1, FST0, &env->fp_status))
1212 FOP_COND_S(eq, !float32_is_unordered(0, FST1, FST0, &env->fp_status) && float32_eq(FST0, FST1, &env->fp_status))
1213 FOP_COND_S(ueq, float32_is_unordered(0, FST1, FST0, &env->fp_status) || float32_eq(FST0, FST1, &env->fp_status))
1214 FOP_COND_S(olt, !float32_is_unordered(0, FST1, FST0, &env->fp_status) && float32_lt(FST0, FST1, &env->fp_status))
1215 FOP_COND_S(ult, float32_is_unordered(0, FST1, FST0, &env->fp_status) || float32_lt(FST0, FST1, &env->fp_status))
1216 FOP_COND_S(ole, !float32_is_unordered(0, FST1, FST0, &env->fp_status) && float32_le(FST0, FST1, &env->fp_status))
1217 FOP_COND_S(ule, float32_is_unordered(0, FST1, FST0, &env->fp_status) || float32_le(FST0, FST1, &env->fp_status))
1218 /* NOTE: the comma operator will make "cond" to eval to false,
1219 * but float*_is_unordered() is still called. */
1220 FOP_COND_S(sf, (float32_is_unordered(1, FST1, FST0, &env->fp_status), 0))
1221 FOP_COND_S(ngle,float32_is_unordered(1, FST1, FST0, &env->fp_status))
1222 FOP_COND_S(seq, !float32_is_unordered(1, FST1, FST0, &env->fp_status) && float32_eq(FST0, FST1, &env->fp_status))
1223 FOP_COND_S(ngl, float32_is_unordered(1, FST1, FST0, &env->fp_status) || float32_eq(FST0, FST1, &env->fp_status))
1224 FOP_COND_S(lt, !float32_is_unordered(1, FST1, FST0, &env->fp_status) && float32_lt(FST0, FST1, &env->fp_status))
1225 FOP_COND_S(nge, float32_is_unordered(1, FST1, FST0, &env->fp_status) || float32_lt(FST0, FST1, &env->fp_status))
1226 FOP_COND_S(le, !float32_is_unordered(1, FST1, FST0, &env->fp_status) && float32_le(FST0, FST1, &env->fp_status))
1227 FOP_COND_S(ngt, float32_is_unordered(1, FST1, FST0, &env->fp_status) || float32_le(FST0, FST1, &env->fp_status))
1229 #define FOP_COND_PS(op, condl, condh) \
1230 void do_cmp_ps_ ## op (long cc) \
1232 int cl = condl; \
1233 int ch = condh; \
1234 update_fcr31(); \
1235 if (cl) \
1236 SET_FP_COND(cc, env); \
1237 else \
1238 CLEAR_FP_COND(cc, env); \
1239 if (ch) \
1240 SET_FP_COND(cc + 1, env); \
1241 else \
1242 CLEAR_FP_COND(cc + 1, env); \
1244 void do_cmpabs_ps_ ## op (long cc) \
1246 int cl, ch; \
1247 FST0 &= ~FLOAT_SIGN32; \
1248 FSTH0 &= ~FLOAT_SIGN32; \
1249 FST1 &= ~FLOAT_SIGN32; \
1250 FSTH1 &= ~FLOAT_SIGN32; \
1251 cl = condl; \
1252 ch = condh; \
1253 update_fcr31(); \
1254 if (cl) \
1255 SET_FP_COND(cc, env); \
1256 else \
1257 CLEAR_FP_COND(cc, env); \
1258 if (ch) \
1259 SET_FP_COND(cc + 1, env); \
1260 else \
1261 CLEAR_FP_COND(cc + 1, env); \
1264 /* NOTE: the comma operator will make "cond" to eval to false,
1265 * but float*_is_unordered() is still called. */
1266 FOP_COND_PS(f, (float32_is_unordered(0, FST1, FST0, &env->fp_status), 0),
1267 (float32_is_unordered(0, FSTH1, FSTH0, &env->fp_status), 0))
1268 FOP_COND_PS(un, float32_is_unordered(0, FST1, FST0, &env->fp_status),
1269 float32_is_unordered(0, FSTH1, FSTH0, &env->fp_status))
1270 FOP_COND_PS(eq, !float32_is_unordered(0, FST1, FST0, &env->fp_status) && float32_eq(FST0, FST1, &env->fp_status),
1271 !float32_is_unordered(0, FSTH1, FSTH0, &env->fp_status) && float32_eq(FSTH0, FSTH1, &env->fp_status))
1272 FOP_COND_PS(ueq, float32_is_unordered(0, FST1, FST0, &env->fp_status) || float32_eq(FST0, FST1, &env->fp_status),
1273 float32_is_unordered(0, FSTH1, FSTH0, &env->fp_status) || float32_eq(FSTH0, FSTH1, &env->fp_status))
1274 FOP_COND_PS(olt, !float32_is_unordered(0, FST1, FST0, &env->fp_status) && float32_lt(FST0, FST1, &env->fp_status),
1275 !float32_is_unordered(0, FSTH1, FSTH0, &env->fp_status) && float32_lt(FSTH0, FSTH1, &env->fp_status))
1276 FOP_COND_PS(ult, float32_is_unordered(0, FST1, FST0, &env->fp_status) || float32_lt(FST0, FST1, &env->fp_status),
1277 float32_is_unordered(0, FSTH1, FSTH0, &env->fp_status) || float32_lt(FSTH0, FSTH1, &env->fp_status))
1278 FOP_COND_PS(ole, !float32_is_unordered(0, FST1, FST0, &env->fp_status) && float32_le(FST0, FST1, &env->fp_status),
1279 !float32_is_unordered(0, FSTH1, FSTH0, &env->fp_status) && float32_le(FSTH0, FSTH1, &env->fp_status))
1280 FOP_COND_PS(ule, float32_is_unordered(0, FST1, FST0, &env->fp_status) || float32_le(FST0, FST1, &env->fp_status),
1281 float32_is_unordered(0, FSTH1, FSTH0, &env->fp_status) || float32_le(FSTH0, FSTH1, &env->fp_status))
1282 /* NOTE: the comma operator will make "cond" to eval to false,
1283 * but float*_is_unordered() is still called. */
1284 FOP_COND_PS(sf, (float32_is_unordered(1, FST1, FST0, &env->fp_status), 0),
1285 (float32_is_unordered(1, FSTH1, FSTH0, &env->fp_status), 0))
1286 FOP_COND_PS(ngle,float32_is_unordered(1, FST1, FST0, &env->fp_status),
1287 float32_is_unordered(1, FSTH1, FSTH0, &env->fp_status))
1288 FOP_COND_PS(seq, !float32_is_unordered(1, FST1, FST0, &env->fp_status) && float32_eq(FST0, FST1, &env->fp_status),
1289 !float32_is_unordered(1, FSTH1, FSTH0, &env->fp_status) && float32_eq(FSTH0, FSTH1, &env->fp_status))
1290 FOP_COND_PS(ngl, float32_is_unordered(1, FST1, FST0, &env->fp_status) || float32_eq(FST0, FST1, &env->fp_status),
1291 float32_is_unordered(1, FSTH1, FSTH0, &env->fp_status) || float32_eq(FSTH0, FSTH1, &env->fp_status))
1292 FOP_COND_PS(lt, !float32_is_unordered(1, FST1, FST0, &env->fp_status) && float32_lt(FST0, FST1, &env->fp_status),
1293 !float32_is_unordered(1, FSTH1, FSTH0, &env->fp_status) && float32_lt(FSTH0, FSTH1, &env->fp_status))
1294 FOP_COND_PS(nge, float32_is_unordered(1, FST1, FST0, &env->fp_status) || float32_lt(FST0, FST1, &env->fp_status),
1295 float32_is_unordered(1, FSTH1, FSTH0, &env->fp_status) || float32_lt(FSTH0, FSTH1, &env->fp_status))
1296 FOP_COND_PS(le, !float32_is_unordered(1, FST1, FST0, &env->fp_status) && float32_le(FST0, FST1, &env->fp_status),
1297 !float32_is_unordered(1, FSTH1, FSTH0, &env->fp_status) && float32_le(FSTH0, FSTH1, &env->fp_status))
1298 FOP_COND_PS(ngt, float32_is_unordered(1, FST1, FST0, &env->fp_status) || float32_le(FST0, FST1, &env->fp_status),
1299 float32_is_unordered(1, FSTH1, FSTH0, &env->fp_status) || float32_le(FSTH0, FSTH1, &env->fp_status))