]>
git.proxmox.com Git - mirror_qemu.git/blob - target-mips/op_helper.c
2 * MIPS emulation helpers for qemu.
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
23 #include "host-utils.h"
25 /*****************************************************************************/
26 /* Exceptions processing helpers */
28 void do_raise_exception_err (uint32_t exception
, int error_code
)
31 if (logfile
&& exception
< 0x100)
32 fprintf(logfile
, "%s: %d %d\n", __func__
, exception
, error_code
);
34 env
->exception_index
= exception
;
35 env
->error_code
= error_code
;
39 void do_raise_exception (uint32_t exception
)
41 do_raise_exception_err(exception
, 0);
44 void do_interrupt_restart (void)
46 if (!(env
->CP0_Status
& (1 << CP0St_EXL
)) &&
47 !(env
->CP0_Status
& (1 << CP0St_ERL
)) &&
48 !(env
->hflags
& MIPS_HFLAG_DM
) &&
49 (env
->CP0_Status
& (1 << CP0St_IE
)) &&
50 (env
->CP0_Status
& env
->CP0_Cause
& CP0Ca_IP_mask
)) {
51 env
->CP0_Cause
&= ~(0x1f << CP0Ca_EC
);
52 do_raise_exception(EXCP_EXT_INTERRUPT
);
56 void do_restore_state (void *pc_ptr
)
59 unsigned long pc
= (unsigned long) pc_ptr
;
63 cpu_restore_state (tb
, env
, pc
, NULL
);
67 target_ulong
do_clo (target_ulong t0
)
72 target_ulong
do_clz (target_ulong t0
)
77 #if defined(TARGET_MIPS64)
78 target_ulong
do_dclo (target_ulong t0
)
83 target_ulong
do_dclz (target_ulong t0
)
87 #endif /* TARGET_MIPS64 */
89 /* 64 bits arithmetic for 32 bits hosts */
90 static always_inline
uint64_t get_HILO (void)
92 return ((uint64_t)(env
->HI
[env
->current_tc
][0]) << 32) | (uint32_t)env
->LO
[env
->current_tc
][0];
95 static always_inline
void set_HILO (uint64_t HILO
)
97 env
->LO
[env
->current_tc
][0] = (int32_t)HILO
;
98 env
->HI
[env
->current_tc
][0] = (int32_t)(HILO
>> 32);
101 static always_inline
void set_HIT0_LO (target_ulong t0
, uint64_t HILO
)
103 env
->LO
[env
->current_tc
][0] = (int32_t)(HILO
& 0xFFFFFFFF);
104 t0
= env
->HI
[env
->current_tc
][0] = (int32_t)(HILO
>> 32);
107 static always_inline
void set_HI_LOT0 (target_ulong t0
, uint64_t HILO
)
109 t0
= env
->LO
[env
->current_tc
][0] = (int32_t)(HILO
& 0xFFFFFFFF);
110 env
->HI
[env
->current_tc
][0] = (int32_t)(HILO
>> 32);
113 #if TARGET_LONG_BITS > HOST_LONG_BITS
114 void do_madd (target_ulong t0
, target_ulong t1
)
118 tmp
= ((int64_t)(int32_t)t0
* (int64_t)(int32_t)t1
);
119 set_HILO((int64_t)get_HILO() + tmp
);
122 void do_maddu (target_ulong t0
, target_ulong t1
)
126 tmp
= ((uint64_t)(uint32_t)t0
* (uint64_t)(uint32_t)t1
);
127 set_HILO(get_HILO() + tmp
);
130 void do_msub (target_ulong t0
, target_ulong t1
)
134 tmp
= ((int64_t)(int32_t)t0
* (int64_t)(int32_t)t1
);
135 set_HILO((int64_t)get_HILO() - tmp
);
138 void do_msubu (target_ulong t0
, target_ulong t1
)
142 tmp
= ((uint64_t)(uint32_t)t0
* (uint64_t)(uint32_t)t1
);
143 set_HILO(get_HILO() - tmp
);
145 #endif /* TARGET_LONG_BITS > HOST_LONG_BITS */
147 /* Multiplication variants of the vr54xx. */
148 target_ulong
do_muls (target_ulong t0
, target_ulong t1
)
150 set_HI_LOT0(t0
, 0 - ((int64_t)(int32_t)t0
* (int64_t)(int32_t)t1
));
155 target_ulong
do_mulsu (target_ulong t0
, target_ulong t1
)
157 set_HI_LOT0(t0
, 0 - ((uint64_t)(uint32_t)t0
* (uint64_t)(uint32_t)t1
));
162 target_ulong
do_macc (target_ulong t0
, target_ulong t1
)
164 set_HI_LOT0(t0
, ((int64_t)get_HILO()) + ((int64_t)(int32_t)t0
* (int64_t)(int32_t)t1
));
169 target_ulong
do_macchi (target_ulong t0
, target_ulong t1
)
171 set_HIT0_LO(t0
, ((int64_t)get_HILO()) + ((int64_t)(int32_t)t0
* (int64_t)(int32_t)t1
));
176 target_ulong
do_maccu (target_ulong t0
, target_ulong t1
)
178 set_HI_LOT0(t0
, ((uint64_t)get_HILO()) + ((uint64_t)(uint32_t)t0
* (uint64_t)(uint32_t)t1
));
183 target_ulong
do_macchiu (target_ulong t0
, target_ulong t1
)
185 set_HIT0_LO(t0
, ((uint64_t)get_HILO()) + ((uint64_t)(uint32_t)t0
* (uint64_t)(uint32_t)t1
));
190 target_ulong
do_msac (target_ulong t0
, target_ulong t1
)
192 set_HI_LOT0(t0
, ((int64_t)get_HILO()) - ((int64_t)(int32_t)t0
* (int64_t)(int32_t)t1
));
197 target_ulong
do_msachi (target_ulong t0
, target_ulong t1
)
199 set_HIT0_LO(t0
, ((int64_t)get_HILO()) - ((int64_t)(int32_t)t0
* (int64_t)(int32_t)t1
));
204 target_ulong
do_msacu (target_ulong t0
, target_ulong t1
)
206 set_HI_LOT0(t0
, ((uint64_t)get_HILO()) - ((uint64_t)(uint32_t)t0
* (uint64_t)(uint32_t)t1
));
211 target_ulong
do_msachiu (target_ulong t0
, target_ulong t1
)
213 set_HIT0_LO(t0
, ((uint64_t)get_HILO()) - ((uint64_t)(uint32_t)t0
* (uint64_t)(uint32_t)t1
));
218 target_ulong
do_mulhi (target_ulong t0
, target_ulong t1
)
220 set_HIT0_LO(t0
, (int64_t)(int32_t)t0
* (int64_t)(int32_t)t1
);
225 target_ulong
do_mulhiu (target_ulong t0
, target_ulong t1
)
227 set_HIT0_LO(t0
, (uint64_t)(uint32_t)t0
* (uint64_t)(uint32_t)t1
);
232 target_ulong
do_mulshi (target_ulong t0
, target_ulong t1
)
234 set_HIT0_LO(t0
, 0 - ((int64_t)(int32_t)t0
* (int64_t)(int32_t)t1
));
239 target_ulong
do_mulshiu (target_ulong t0
, target_ulong t1
)
241 set_HIT0_LO(t0
, 0 - ((uint64_t)(uint32_t)t0
* (uint64_t)(uint32_t)t1
));
247 void do_dmult (target_ulong t0
, target_ulong t1
)
249 muls64(&(env
->LO
[env
->current_tc
][0]), &(env
->HI
[env
->current_tc
][0]), t0
, t1
);
252 void do_dmultu (target_ulong t0
, target_ulong t1
)
254 mulu64(&(env
->LO
[env
->current_tc
][0]), &(env
->HI
[env
->current_tc
][0]), t0
, t1
);
258 #ifdef TARGET_WORDS_BIGENDIAN
259 #define GET_LMASK(v) ((v) & 3)
260 #define GET_OFFSET(addr, offset) (addr + (offset))
262 #define GET_LMASK(v) (((v) & 3) ^ 3)
263 #define GET_OFFSET(addr, offset) (addr - (offset))
266 target_ulong
do_lwl(target_ulong t0
, target_ulong t1
, int mem_idx
)
270 #ifdef CONFIG_USER_ONLY
271 #define ldfun ldub_raw
273 int (*ldfun
)(target_ulong
);
277 case 0: ldfun
= ldub_kernel
; break;
278 case 1: ldfun
= ldub_super
; break;
280 case 2: ldfun
= ldub_user
; break;
284 t1
= (t1
& 0x00FFFFFF) | (tmp
<< 24);
286 if (GET_LMASK(t0
) <= 2) {
287 tmp
= ldfun(GET_OFFSET(t0
, 1));
288 t1
= (t1
& 0xFF00FFFF) | (tmp
<< 16);
291 if (GET_LMASK(t0
) <= 1) {
292 tmp
= ldfun(GET_OFFSET(t0
, 2));
293 t1
= (t1
& 0xFFFF00FF) | (tmp
<< 8);
296 if (GET_LMASK(t0
) == 0) {
297 tmp
= ldfun(GET_OFFSET(t0
, 3));
298 t1
= (t1
& 0xFFFFFF00) | tmp
;
303 target_ulong
do_lwr(target_ulong t0
, target_ulong t1
, int mem_idx
)
307 #ifdef CONFIG_USER_ONLY
308 #define ldfun ldub_raw
310 int (*ldfun
)(target_ulong
);
314 case 0: ldfun
= ldub_kernel
; break;
315 case 1: ldfun
= ldub_super
; break;
317 case 2: ldfun
= ldub_user
; break;
321 t1
= (t1
& 0xFFFFFF00) | tmp
;
323 if (GET_LMASK(t0
) >= 1) {
324 tmp
= ldfun(GET_OFFSET(t0
, -1));
325 t1
= (t1
& 0xFFFF00FF) | (tmp
<< 8);
328 if (GET_LMASK(t0
) >= 2) {
329 tmp
= ldfun(GET_OFFSET(t0
, -2));
330 t1
= (t1
& 0xFF00FFFF) | (tmp
<< 16);
333 if (GET_LMASK(t0
) == 3) {
334 tmp
= ldfun(GET_OFFSET(t0
, -3));
335 t1
= (t1
& 0x00FFFFFF) | (tmp
<< 24);
340 void do_swl(target_ulong t0
, target_ulong t1
, int mem_idx
)
342 #ifdef CONFIG_USER_ONLY
343 #define stfun stb_raw
345 void (*stfun
)(target_ulong
, int);
349 case 0: stfun
= stb_kernel
; break;
350 case 1: stfun
= stb_super
; break;
352 case 2: stfun
= stb_user
; break;
355 stfun(t0
, (uint8_t)(t1
>> 24));
357 if (GET_LMASK(t0
) <= 2)
358 stfun(GET_OFFSET(t0
, 1), (uint8_t)(t1
>> 16));
360 if (GET_LMASK(t0
) <= 1)
361 stfun(GET_OFFSET(t0
, 2), (uint8_t)(t1
>> 8));
363 if (GET_LMASK(t0
) == 0)
364 stfun(GET_OFFSET(t0
, 3), (uint8_t)t1
);
367 void do_swr(target_ulong t0
, target_ulong t1
, int mem_idx
)
369 #ifdef CONFIG_USER_ONLY
370 #define stfun stb_raw
372 void (*stfun
)(target_ulong
, int);
376 case 0: stfun
= stb_kernel
; break;
377 case 1: stfun
= stb_super
; break;
379 case 2: stfun
= stb_user
; break;
382 stfun(t0
, (uint8_t)t1
);
384 if (GET_LMASK(t0
) >= 1)
385 stfun(GET_OFFSET(t0
, -1), (uint8_t)(t1
>> 8));
387 if (GET_LMASK(t0
) >= 2)
388 stfun(GET_OFFSET(t0
, -2), (uint8_t)(t1
>> 16));
390 if (GET_LMASK(t0
) == 3)
391 stfun(GET_OFFSET(t0
, -3), (uint8_t)(t1
>> 24));
394 #if defined(TARGET_MIPS64)
395 /* "half" load and stores. We must do the memory access inline,
396 or fault handling won't work. */
398 #ifdef TARGET_WORDS_BIGENDIAN
399 #define GET_LMASK64(v) ((v) & 7)
401 #define GET_LMASK64(v) (((v) & 7) ^ 7)
404 target_ulong
do_ldl(target_ulong t0
, target_ulong t1
, int mem_idx
)
408 #ifdef CONFIG_USER_ONLY
409 #define ldfun ldub_raw
411 int (*ldfun
)(target_ulong
);
415 case 0: ldfun
= ldub_kernel
; break;
416 case 1: ldfun
= ldub_super
; break;
418 case 2: ldfun
= ldub_user
; break;
422 t1
= (t1
& 0x00FFFFFFFFFFFFFFULL
) | (tmp
<< 56);
424 if (GET_LMASK64(t0
) <= 6) {
425 tmp
= ldfun(GET_OFFSET(t0
, 1));
426 t1
= (t1
& 0xFF00FFFFFFFFFFFFULL
) | (tmp
<< 48);
429 if (GET_LMASK64(t0
) <= 5) {
430 tmp
= ldfun(GET_OFFSET(t0
, 2));
431 t1
= (t1
& 0xFFFF00FFFFFFFFFFULL
) | (tmp
<< 40);
434 if (GET_LMASK64(t0
) <= 4) {
435 tmp
= ldfun(GET_OFFSET(t0
, 3));
436 t1
= (t1
& 0xFFFFFF00FFFFFFFFULL
) | (tmp
<< 32);
439 if (GET_LMASK64(t0
) <= 3) {
440 tmp
= ldfun(GET_OFFSET(t0
, 4));
441 t1
= (t1
& 0xFFFFFFFF00FFFFFFULL
) | (tmp
<< 24);
444 if (GET_LMASK64(t0
) <= 2) {
445 tmp
= ldfun(GET_OFFSET(t0
, 5));
446 t1
= (t1
& 0xFFFFFFFFFF00FFFFULL
) | (tmp
<< 16);
449 if (GET_LMASK64(t0
) <= 1) {
450 tmp
= ldfun(GET_OFFSET(t0
, 6));
451 t1
= (t1
& 0xFFFFFFFFFFFF00FFULL
) | (tmp
<< 8);
454 if (GET_LMASK64(t0
) == 0) {
455 tmp
= ldfun(GET_OFFSET(t0
, 7));
456 t1
= (t1
& 0xFFFFFFFFFFFFFF00ULL
) | tmp
;
462 target_ulong
do_ldr(target_ulong t0
, target_ulong t1
, int mem_idx
)
466 #ifdef CONFIG_USER_ONLY
467 #define ldfun ldub_raw
469 int (*ldfun
)(target_ulong
);
473 case 0: ldfun
= ldub_kernel
; break;
474 case 1: ldfun
= ldub_super
; break;
476 case 2: ldfun
= ldub_user
; break;
480 t1
= (t1
& 0xFFFFFFFFFFFFFF00ULL
) | tmp
;
482 if (GET_LMASK64(t0
) >= 1) {
483 tmp
= ldfun(GET_OFFSET(t0
, -1));
484 t1
= (t1
& 0xFFFFFFFFFFFF00FFULL
) | (tmp
<< 8);
487 if (GET_LMASK64(t0
) >= 2) {
488 tmp
= ldfun(GET_OFFSET(t0
, -2));
489 t1
= (t1
& 0xFFFFFFFFFF00FFFFULL
) | (tmp
<< 16);
492 if (GET_LMASK64(t0
) >= 3) {
493 tmp
= ldfun(GET_OFFSET(t0
, -3));
494 t1
= (t1
& 0xFFFFFFFF00FFFFFFULL
) | (tmp
<< 24);
497 if (GET_LMASK64(t0
) >= 4) {
498 tmp
= ldfun(GET_OFFSET(t0
, -4));
499 t1
= (t1
& 0xFFFFFF00FFFFFFFFULL
) | (tmp
<< 32);
502 if (GET_LMASK64(t0
) >= 5) {
503 tmp
= ldfun(GET_OFFSET(t0
, -5));
504 t1
= (t1
& 0xFFFF00FFFFFFFFFFULL
) | (tmp
<< 40);
507 if (GET_LMASK64(t0
) >= 6) {
508 tmp
= ldfun(GET_OFFSET(t0
, -6));
509 t1
= (t1
& 0xFF00FFFFFFFFFFFFULL
) | (tmp
<< 48);
512 if (GET_LMASK64(t0
) == 7) {
513 tmp
= ldfun(GET_OFFSET(t0
, -7));
514 t1
= (t1
& 0x00FFFFFFFFFFFFFFULL
) | (tmp
<< 56);
520 void do_sdl(target_ulong t0
, target_ulong t1
, int mem_idx
)
522 #ifdef CONFIG_USER_ONLY
523 #define stfun stb_raw
525 void (*stfun
)(target_ulong
, int);
529 case 0: stfun
= stb_kernel
; break;
530 case 1: stfun
= stb_super
; break;
532 case 2: stfun
= stb_user
; break;
535 stfun(t0
, (uint8_t)(t1
>> 56));
537 if (GET_LMASK64(t0
) <= 6)
538 stfun(GET_OFFSET(t0
, 1), (uint8_t)(t1
>> 48));
540 if (GET_LMASK64(t0
) <= 5)
541 stfun(GET_OFFSET(t0
, 2), (uint8_t)(t1
>> 40));
543 if (GET_LMASK64(t0
) <= 4)
544 stfun(GET_OFFSET(t0
, 3), (uint8_t)(t1
>> 32));
546 if (GET_LMASK64(t0
) <= 3)
547 stfun(GET_OFFSET(t0
, 4), (uint8_t)(t1
>> 24));
549 if (GET_LMASK64(t0
) <= 2)
550 stfun(GET_OFFSET(t0
, 5), (uint8_t)(t1
>> 16));
552 if (GET_LMASK64(t0
) <= 1)
553 stfun(GET_OFFSET(t0
, 6), (uint8_t)(t1
>> 8));
555 if (GET_LMASK64(t0
) <= 0)
556 stfun(GET_OFFSET(t0
, 7), (uint8_t)t1
);
559 void do_sdr(target_ulong t0
, target_ulong t1
, int mem_idx
)
561 #ifdef CONFIG_USER_ONLY
562 #define stfun stb_raw
564 void (*stfun
)(target_ulong
, int);
568 case 0: stfun
= stb_kernel
; break;
569 case 1: stfun
= stb_super
; break;
571 case 2: stfun
= stb_user
; break;
574 stfun(t0
, (uint8_t)t1
);
576 if (GET_LMASK64(t0
) >= 1)
577 stfun(GET_OFFSET(t0
, -1), (uint8_t)(t1
>> 8));
579 if (GET_LMASK64(t0
) >= 2)
580 stfun(GET_OFFSET(t0
, -2), (uint8_t)(t1
>> 16));
582 if (GET_LMASK64(t0
) >= 3)
583 stfun(GET_OFFSET(t0
, -3), (uint8_t)(t1
>> 24));
585 if (GET_LMASK64(t0
) >= 4)
586 stfun(GET_OFFSET(t0
, -4), (uint8_t)(t1
>> 32));
588 if (GET_LMASK64(t0
) >= 5)
589 stfun(GET_OFFSET(t0
, -5), (uint8_t)(t1
>> 40));
591 if (GET_LMASK64(t0
) >= 6)
592 stfun(GET_OFFSET(t0
, -6), (uint8_t)(t1
>> 48));
594 if (GET_LMASK64(t0
) == 7)
595 stfun(GET_OFFSET(t0
, -7), (uint8_t)(t1
>> 56));
597 #endif /* TARGET_MIPS64 */
599 #ifdef CONFIG_USER_ONLY
600 void do_mfc0_random (void)
602 cpu_abort(env
, "mfc0 random\n");
605 void do_mfc0_count (void)
607 cpu_abort(env
, "mfc0 count\n");
610 void cpu_mips_store_count(CPUState
*env
, uint32_t value
)
612 cpu_abort(env
, "mtc0 count\n");
615 void cpu_mips_store_compare(CPUState
*env
, uint32_t value
)
617 cpu_abort(env
, "mtc0 compare\n");
620 void cpu_mips_start_count(CPUState
*env
)
622 cpu_abort(env
, "start count\n");
625 void cpu_mips_stop_count(CPUState
*env
)
627 cpu_abort(env
, "stop count\n");
630 void cpu_mips_update_irq(CPUState
*env
)
632 cpu_abort(env
, "mtc0 status / mtc0 cause\n");
635 void do_mtc0_status_debug(uint32_t old
, uint32_t val
)
637 cpu_abort(env
, "mtc0 status debug\n");
640 void do_mtc0_status_irqraise_debug (void)
642 cpu_abort(env
, "mtc0 status irqraise debug\n");
645 void cpu_mips_tlb_flush (CPUState
*env
, int flush_global
)
647 cpu_abort(env
, "mips_tlb_flush\n");
653 target_ulong
do_mfc0_mvpcontrol (void)
655 return env
->mvp
->CP0_MVPControl
;
658 target_ulong
do_mfc0_mvpconf0 (void)
660 return env
->mvp
->CP0_MVPConf0
;
663 target_ulong
do_mfc0_mvpconf1 (void)
665 return env
->mvp
->CP0_MVPConf1
;
668 target_ulong
do_mfc0_random (void)
670 return (int32_t)cpu_mips_get_random(env
);
673 target_ulong
do_mfc0_tcstatus (void)
675 return env
->CP0_TCStatus
[env
->current_tc
];
678 target_ulong
do_mftc0_tcstatus(void)
680 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
682 return env
->CP0_TCStatus
[other_tc
];
685 target_ulong
do_mfc0_tcbind (void)
687 return env
->CP0_TCBind
[env
->current_tc
];
690 target_ulong
do_mftc0_tcbind(void)
692 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
694 return env
->CP0_TCBind
[other_tc
];
697 target_ulong
do_mfc0_tcrestart (void)
699 return env
->PC
[env
->current_tc
];
702 target_ulong
do_mftc0_tcrestart(void)
704 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
706 return env
->PC
[other_tc
];
709 target_ulong
do_mfc0_tchalt (void)
711 return env
->CP0_TCHalt
[env
->current_tc
];
714 target_ulong
do_mftc0_tchalt(void)
716 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
718 return env
->CP0_TCHalt
[other_tc
];
721 target_ulong
do_mfc0_tccontext (void)
723 return env
->CP0_TCContext
[env
->current_tc
];
726 target_ulong
do_mftc0_tccontext(void)
728 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
730 return env
->CP0_TCContext
[other_tc
];
733 target_ulong
do_mfc0_tcschedule (void)
735 return env
->CP0_TCSchedule
[env
->current_tc
];
738 target_ulong
do_mftc0_tcschedule(void)
740 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
742 return env
->CP0_TCSchedule
[other_tc
];
745 target_ulong
do_mfc0_tcschefback (void)
747 return env
->CP0_TCScheFBack
[env
->current_tc
];
750 target_ulong
do_mftc0_tcschefback(void)
752 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
754 return env
->CP0_TCScheFBack
[other_tc
];
757 target_ulong
do_mfc0_count (void)
759 return (int32_t)cpu_mips_get_count(env
);
762 target_ulong
do_mftc0_entryhi(void)
764 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
766 return (env
->CP0_EntryHi
& ~0xff) | (env
->CP0_TCStatus
[other_tc
] & 0xff);
769 target_ulong
do_mftc0_status(void)
771 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
772 uint32_t tcstatus
= env
->CP0_TCStatus
[other_tc
];
775 t0
= env
->CP0_Status
& ~0xf1000018;
776 t0
|= tcstatus
& (0xf << CP0TCSt_TCU0
);
777 t0
|= (tcstatus
& (1 << CP0TCSt_TMX
)) >> (CP0TCSt_TMX
- CP0St_MX
);
778 t0
|= (tcstatus
& (0x3 << CP0TCSt_TKSU
)) >> (CP0TCSt_TKSU
- CP0St_KSU
);
783 target_ulong
do_mfc0_lladdr (void)
785 return (int32_t)env
->CP0_LLAddr
>> 4;
788 target_ulong
do_mfc0_watchlo (uint32_t sel
)
790 return (int32_t)env
->CP0_WatchLo
[sel
];
793 target_ulong
do_mfc0_watchhi (uint32_t sel
)
795 return env
->CP0_WatchHi
[sel
];
798 target_ulong
do_mfc0_debug (void)
800 target_ulong t0
= env
->CP0_Debug
;
801 if (env
->hflags
& MIPS_HFLAG_DM
)
807 target_ulong
do_mftc0_debug(void)
809 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
811 /* XXX: Might be wrong, check with EJTAG spec. */
812 return (env
->CP0_Debug
& ~((1 << CP0DB_SSt
) | (1 << CP0DB_Halt
))) |
813 (env
->CP0_Debug_tcstatus
[other_tc
] &
814 ((1 << CP0DB_SSt
) | (1 << CP0DB_Halt
)));
817 #if defined(TARGET_MIPS64)
818 target_ulong
do_dmfc0_tcrestart (void)
820 return env
->PC
[env
->current_tc
];
823 target_ulong
do_dmfc0_tchalt (void)
825 return env
->CP0_TCHalt
[env
->current_tc
];
828 target_ulong
do_dmfc0_tccontext (void)
830 return env
->CP0_TCContext
[env
->current_tc
];
833 target_ulong
do_dmfc0_tcschedule (void)
835 return env
->CP0_TCSchedule
[env
->current_tc
];
838 target_ulong
do_dmfc0_tcschefback (void)
840 return env
->CP0_TCScheFBack
[env
->current_tc
];
843 target_ulong
do_dmfc0_lladdr (void)
845 return env
->CP0_LLAddr
>> 4;
848 target_ulong
do_dmfc0_watchlo (uint32_t sel
)
850 return env
->CP0_WatchLo
[sel
];
852 #endif /* TARGET_MIPS64 */
854 void do_mtc0_index (target_ulong t0
)
857 unsigned int tmp
= env
->tlb
->nb_tlb
;
863 env
->CP0_Index
= (env
->CP0_Index
& 0x80000000) | (t0
& (num
- 1));
866 void do_mtc0_mvpcontrol (target_ulong t0
)
871 if (env
->CP0_VPEConf0
& (1 << CP0VPEC0_MVP
))
872 mask
|= (1 << CP0MVPCo_CPA
) | (1 << CP0MVPCo_VPC
) |
874 if (env
->mvp
->CP0_MVPControl
& (1 << CP0MVPCo_VPC
))
875 mask
|= (1 << CP0MVPCo_STLB
);
876 newval
= (env
->mvp
->CP0_MVPControl
& ~mask
) | (t0
& mask
);
878 // TODO: Enable/disable shared TLB, enable/disable VPEs.
880 env
->mvp
->CP0_MVPControl
= newval
;
883 void do_mtc0_vpecontrol (target_ulong t0
)
888 mask
= (1 << CP0VPECo_YSI
) | (1 << CP0VPECo_GSI
) |
889 (1 << CP0VPECo_TE
) | (0xff << CP0VPECo_TargTC
);
890 newval
= (env
->CP0_VPEControl
& ~mask
) | (t0
& mask
);
892 /* Yield scheduler intercept not implemented. */
893 /* Gating storage scheduler intercept not implemented. */
895 // TODO: Enable/disable TCs.
897 env
->CP0_VPEControl
= newval
;
900 void do_mtc0_vpeconf0 (target_ulong t0
)
905 if (env
->CP0_VPEConf0
& (1 << CP0VPEC0_MVP
)) {
906 if (env
->CP0_VPEConf0
& (1 << CP0VPEC0_VPA
))
907 mask
|= (0xff << CP0VPEC0_XTC
);
908 mask
|= (1 << CP0VPEC0_MVP
) | (1 << CP0VPEC0_VPA
);
910 newval
= (env
->CP0_VPEConf0
& ~mask
) | (t0
& mask
);
912 // TODO: TC exclusive handling due to ERL/EXL.
914 env
->CP0_VPEConf0
= newval
;
917 void do_mtc0_vpeconf1 (target_ulong t0
)
922 if (env
->mvp
->CP0_MVPControl
& (1 << CP0MVPCo_VPC
))
923 mask
|= (0xff << CP0VPEC1_NCX
) | (0xff << CP0VPEC1_NCP2
) |
924 (0xff << CP0VPEC1_NCP1
);
925 newval
= (env
->CP0_VPEConf1
& ~mask
) | (t0
& mask
);
927 /* UDI not implemented. */
928 /* CP2 not implemented. */
930 // TODO: Handle FPU (CP1) binding.
932 env
->CP0_VPEConf1
= newval
;
935 void do_mtc0_yqmask (target_ulong t0
)
937 /* Yield qualifier inputs not implemented. */
938 env
->CP0_YQMask
= 0x00000000;
941 void do_mtc0_vpeopt (target_ulong t0
)
943 env
->CP0_VPEOpt
= t0
& 0x0000ffff;
946 void do_mtc0_entrylo0 (target_ulong t0
)
948 /* Large physaddr (PABITS) not implemented */
949 /* 1k pages not implemented */
950 env
->CP0_EntryLo0
= t0
& 0x3FFFFFFF;
953 void do_mtc0_tcstatus (target_ulong t0
)
955 uint32_t mask
= env
->CP0_TCStatus_rw_bitmask
;
958 newval
= (env
->CP0_TCStatus
[env
->current_tc
] & ~mask
) | (t0
& mask
);
960 // TODO: Sync with CP0_Status.
962 env
->CP0_TCStatus
[env
->current_tc
] = newval
;
965 void do_mttc0_tcstatus (target_ulong t0
)
967 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
969 // TODO: Sync with CP0_Status.
971 env
->CP0_TCStatus
[other_tc
] = t0
;
974 void do_mtc0_tcbind (target_ulong t0
)
976 uint32_t mask
= (1 << CP0TCBd_TBE
);
979 if (env
->mvp
->CP0_MVPControl
& (1 << CP0MVPCo_VPC
))
980 mask
|= (1 << CP0TCBd_CurVPE
);
981 newval
= (env
->CP0_TCBind
[env
->current_tc
] & ~mask
) | (t0
& mask
);
982 env
->CP0_TCBind
[env
->current_tc
] = newval
;
985 void do_mttc0_tcbind (target_ulong t0
)
987 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
988 uint32_t mask
= (1 << CP0TCBd_TBE
);
991 if (env
->mvp
->CP0_MVPControl
& (1 << CP0MVPCo_VPC
))
992 mask
|= (1 << CP0TCBd_CurVPE
);
993 newval
= (env
->CP0_TCBind
[other_tc
] & ~mask
) | (t0
& mask
);
994 env
->CP0_TCBind
[other_tc
] = newval
;
997 void do_mtc0_tcrestart (target_ulong t0
)
999 env
->PC
[env
->current_tc
] = t0
;
1000 env
->CP0_TCStatus
[env
->current_tc
] &= ~(1 << CP0TCSt_TDS
);
1001 env
->CP0_LLAddr
= 0ULL;
1002 /* MIPS16 not implemented. */
1005 void do_mttc0_tcrestart (target_ulong t0
)
1007 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1009 env
->PC
[other_tc
] = t0
;
1010 env
->CP0_TCStatus
[other_tc
] &= ~(1 << CP0TCSt_TDS
);
1011 env
->CP0_LLAddr
= 0ULL;
1012 /* MIPS16 not implemented. */
1015 void do_mtc0_tchalt (target_ulong t0
)
1017 env
->CP0_TCHalt
[env
->current_tc
] = t0
& 0x1;
1019 // TODO: Halt TC / Restart (if allocated+active) TC.
1022 void do_mttc0_tchalt (target_ulong t0
)
1024 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1026 // TODO: Halt TC / Restart (if allocated+active) TC.
1028 env
->CP0_TCHalt
[other_tc
] = t0
;
1031 void do_mtc0_tccontext (target_ulong t0
)
1033 env
->CP0_TCContext
[env
->current_tc
] = t0
;
1036 void do_mttc0_tccontext (target_ulong t0
)
1038 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1040 env
->CP0_TCContext
[other_tc
] = t0
;
1043 void do_mtc0_tcschedule (target_ulong t0
)
1045 env
->CP0_TCSchedule
[env
->current_tc
] = t0
;
1048 void do_mttc0_tcschedule (target_ulong t0
)
1050 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1052 env
->CP0_TCSchedule
[other_tc
] = t0
;
1055 void do_mtc0_tcschefback (target_ulong t0
)
1057 env
->CP0_TCScheFBack
[env
->current_tc
] = t0
;
1060 void do_mttc0_tcschefback (target_ulong t0
)
1062 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1064 env
->CP0_TCScheFBack
[other_tc
] = t0
;
1067 void do_mtc0_entrylo1 (target_ulong t0
)
1069 /* Large physaddr (PABITS) not implemented */
1070 /* 1k pages not implemented */
1071 env
->CP0_EntryLo1
= t0
& 0x3FFFFFFF;
1074 void do_mtc0_context (target_ulong t0
)
1076 env
->CP0_Context
= (env
->CP0_Context
& 0x007FFFFF) | (t0
& ~0x007FFFFF);
1079 void do_mtc0_pagemask (target_ulong t0
)
1081 /* 1k pages not implemented */
1082 env
->CP0_PageMask
= t0
& (0x1FFFFFFF & (TARGET_PAGE_MASK
<< 1));
1085 void do_mtc0_pagegrain (target_ulong t0
)
1087 /* SmartMIPS not implemented */
1088 /* Large physaddr (PABITS) not implemented */
1089 /* 1k pages not implemented */
1090 env
->CP0_PageGrain
= 0;
1093 void do_mtc0_wired (target_ulong t0
)
1095 env
->CP0_Wired
= t0
% env
->tlb
->nb_tlb
;
1098 void do_mtc0_srsconf0 (target_ulong t0
)
1100 env
->CP0_SRSConf0
|= t0
& env
->CP0_SRSConf0_rw_bitmask
;
1103 void do_mtc0_srsconf1 (target_ulong t0
)
1105 env
->CP0_SRSConf1
|= t0
& env
->CP0_SRSConf1_rw_bitmask
;
1108 void do_mtc0_srsconf2 (target_ulong t0
)
1110 env
->CP0_SRSConf2
|= t0
& env
->CP0_SRSConf2_rw_bitmask
;
1113 void do_mtc0_srsconf3 (target_ulong t0
)
1115 env
->CP0_SRSConf3
|= t0
& env
->CP0_SRSConf3_rw_bitmask
;
1118 void do_mtc0_srsconf4 (target_ulong t0
)
1120 env
->CP0_SRSConf4
|= t0
& env
->CP0_SRSConf4_rw_bitmask
;
1123 void do_mtc0_hwrena (target_ulong t0
)
1125 env
->CP0_HWREna
= t0
& 0x0000000F;
1128 void do_mtc0_count (target_ulong t0
)
1130 cpu_mips_store_count(env
, t0
);
1133 void do_mtc0_entryhi (target_ulong t0
)
1135 target_ulong old
, val
;
1137 /* 1k pages not implemented */
1138 val
= t0
& ((TARGET_PAGE_MASK
<< 1) | 0xFF);
1139 #if defined(TARGET_MIPS64)
1140 val
&= env
->SEGMask
;
1142 old
= env
->CP0_EntryHi
;
1143 env
->CP0_EntryHi
= val
;
1144 if (env
->CP0_Config3
& (1 << CP0C3_MT
)) {
1145 uint32_t tcst
= env
->CP0_TCStatus
[env
->current_tc
] & ~0xff;
1146 env
->CP0_TCStatus
[env
->current_tc
] = tcst
| (val
& 0xff);
1148 /* If the ASID changes, flush qemu's TLB. */
1149 if ((old
& 0xFF) != (val
& 0xFF))
1150 cpu_mips_tlb_flush(env
, 1);
1153 void do_mttc0_entryhi(target_ulong t0
)
1155 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1157 env
->CP0_EntryHi
= (env
->CP0_EntryHi
& 0xff) | (t0
& ~0xff);
1158 env
->CP0_TCStatus
[other_tc
] = (env
->CP0_TCStatus
[other_tc
] & ~0xff) | (t0
& 0xff);
1161 void do_mtc0_compare (target_ulong t0
)
1163 cpu_mips_store_compare(env
, t0
);
1166 void do_mtc0_status (target_ulong t0
)
1169 uint32_t mask
= env
->CP0_Status_rw_bitmask
;
1172 old
= env
->CP0_Status
;
1173 env
->CP0_Status
= (env
->CP0_Status
& ~mask
) | val
;
1174 compute_hflags(env
);
1175 if (loglevel
& CPU_LOG_EXEC
)
1176 do_mtc0_status_debug(old
, val
);
1177 cpu_mips_update_irq(env
);
1180 void do_mttc0_status(target_ulong t0
)
1182 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1183 uint32_t tcstatus
= env
->CP0_TCStatus
[other_tc
];
1185 env
->CP0_Status
= t0
& ~0xf1000018;
1186 tcstatus
= (tcstatus
& ~(0xf << CP0TCSt_TCU0
)) | (t0
& (0xf << CP0St_CU0
));
1187 tcstatus
= (tcstatus
& ~(1 << CP0TCSt_TMX
)) | ((t0
& (1 << CP0St_MX
)) << (CP0TCSt_TMX
- CP0St_MX
));
1188 tcstatus
= (tcstatus
& ~(0x3 << CP0TCSt_TKSU
)) | ((t0
& (0x3 << CP0St_KSU
)) << (CP0TCSt_TKSU
- CP0St_KSU
));
1189 env
->CP0_TCStatus
[other_tc
] = tcstatus
;
1192 void do_mtc0_intctl (target_ulong t0
)
1194 /* vectored interrupts not implemented, no performance counters. */
1195 env
->CP0_IntCtl
= (env
->CP0_IntCtl
& ~0x000002e0) | (t0
& 0x000002e0);
1198 void do_mtc0_srsctl (target_ulong t0
)
1200 uint32_t mask
= (0xf << CP0SRSCtl_ESS
) | (0xf << CP0SRSCtl_PSS
);
1201 env
->CP0_SRSCtl
= (env
->CP0_SRSCtl
& ~mask
) | (t0
& mask
);
1204 void do_mtc0_cause (target_ulong t0
)
1206 uint32_t mask
= 0x00C00300;
1207 uint32_t old
= env
->CP0_Cause
;
1209 if (env
->insn_flags
& ISA_MIPS32R2
)
1210 mask
|= 1 << CP0Ca_DC
;
1212 env
->CP0_Cause
= (env
->CP0_Cause
& ~mask
) | (t0
& mask
);
1214 if ((old
^ env
->CP0_Cause
) & (1 << CP0Ca_DC
)) {
1215 if (env
->CP0_Cause
& (1 << CP0Ca_DC
))
1216 cpu_mips_stop_count(env
);
1218 cpu_mips_start_count(env
);
1221 /* Handle the software interrupt as an hardware one, as they
1223 if (t0
& CP0Ca_IP_mask
) {
1224 cpu_mips_update_irq(env
);
1228 void do_mtc0_ebase (target_ulong t0
)
1230 /* vectored interrupts not implemented */
1231 /* Multi-CPU not implemented */
1232 env
->CP0_EBase
= 0x80000000 | (t0
& 0x3FFFF000);
1235 void do_mtc0_config0 (target_ulong t0
)
1237 env
->CP0_Config0
= (env
->CP0_Config0
& 0x81FFFFF8) | (t0
& 0x00000007);
1240 void do_mtc0_config2 (target_ulong t0
)
1242 /* tertiary/secondary caches not implemented */
1243 env
->CP0_Config2
= (env
->CP0_Config2
& 0x8FFF0FFF);
1246 void do_mtc0_watchlo (target_ulong t0
, uint32_t sel
)
1248 /* Watch exceptions for instructions, data loads, data stores
1250 env
->CP0_WatchLo
[sel
] = (t0
& ~0x7);
1253 void do_mtc0_watchhi (target_ulong t0
, uint32_t sel
)
1255 env
->CP0_WatchHi
[sel
] = (t0
& 0x40FF0FF8);
1256 env
->CP0_WatchHi
[sel
] &= ~(env
->CP0_WatchHi
[sel
] & t0
& 0x7);
1259 void do_mtc0_xcontext (target_ulong t0
)
1261 target_ulong mask
= (1ULL << (env
->SEGBITS
- 7)) - 1;
1262 env
->CP0_XContext
= (env
->CP0_XContext
& mask
) | (t0
& ~mask
);
1265 void do_mtc0_framemask (target_ulong t0
)
1267 env
->CP0_Framemask
= t0
; /* XXX */
1270 void do_mtc0_debug (target_ulong t0
)
1272 env
->CP0_Debug
= (env
->CP0_Debug
& 0x8C03FC1F) | (t0
& 0x13300120);
1273 if (t0
& (1 << CP0DB_DM
))
1274 env
->hflags
|= MIPS_HFLAG_DM
;
1276 env
->hflags
&= ~MIPS_HFLAG_DM
;
1279 void do_mttc0_debug(target_ulong t0
)
1281 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1283 /* XXX: Might be wrong, check with EJTAG spec. */
1284 env
->CP0_Debug_tcstatus
[other_tc
] = t0
& ((1 << CP0DB_SSt
) | (1 << CP0DB_Halt
));
1285 env
->CP0_Debug
= (env
->CP0_Debug
& ((1 << CP0DB_SSt
) | (1 << CP0DB_Halt
))) |
1286 (t0
& ~((1 << CP0DB_SSt
) | (1 << CP0DB_Halt
)));
1289 void do_mtc0_performance0 (target_ulong t0
)
1291 env
->CP0_Performance0
= t0
& 0x000007ff;
1294 void do_mtc0_taglo (target_ulong t0
)
1296 env
->CP0_TagLo
= t0
& 0xFFFFFCF6;
1299 void do_mtc0_datalo (target_ulong t0
)
1301 env
->CP0_DataLo
= t0
; /* XXX */
1304 void do_mtc0_taghi (target_ulong t0
)
1306 env
->CP0_TagHi
= t0
; /* XXX */
1309 void do_mtc0_datahi (target_ulong t0
)
1311 env
->CP0_DataHi
= t0
; /* XXX */
1314 void do_mtc0_status_debug(uint32_t old
, uint32_t val
)
1316 fprintf(logfile
, "Status %08x (%08x) => %08x (%08x) Cause %08x",
1317 old
, old
& env
->CP0_Cause
& CP0Ca_IP_mask
,
1318 val
, val
& env
->CP0_Cause
& CP0Ca_IP_mask
,
1320 switch (env
->hflags
& MIPS_HFLAG_KSU
) {
1321 case MIPS_HFLAG_UM
: fputs(", UM\n", logfile
); break;
1322 case MIPS_HFLAG_SM
: fputs(", SM\n", logfile
); break;
1323 case MIPS_HFLAG_KM
: fputs("\n", logfile
); break;
1324 default: cpu_abort(env
, "Invalid MMU mode!\n"); break;
1328 void do_mtc0_status_irqraise_debug(void)
1330 fprintf(logfile
, "Raise pending IRQs\n");
1332 #endif /* !CONFIG_USER_ONLY */
1334 /* MIPS MT functions */
1335 target_ulong
do_mftgpr(target_ulong t0
, uint32_t sel
)
1337 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1339 return env
->gpr
[other_tc
][sel
];
1342 target_ulong
do_mftlo(target_ulong t0
, uint32_t sel
)
1344 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1346 return env
->LO
[other_tc
][sel
];
1349 target_ulong
do_mfthi(target_ulong t0
, uint32_t sel
)
1351 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1353 return env
->HI
[other_tc
][sel
];
1356 target_ulong
do_mftacx(target_ulong t0
, uint32_t sel
)
1358 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1360 return env
->ACX
[other_tc
][sel
];
1363 target_ulong
do_mftdsp(target_ulong t0
)
1365 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1367 return env
->DSPControl
[other_tc
];
1370 void do_mttgpr(target_ulong t0
, uint32_t sel
)
1372 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1374 env
->gpr
[other_tc
][sel
] = t0
;
1377 void do_mttlo(target_ulong t0
, uint32_t sel
)
1379 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1381 env
->LO
[other_tc
][sel
] = t0
;
1384 void do_mtthi(target_ulong t0
, uint32_t sel
)
1386 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1388 env
->HI
[other_tc
][sel
] = t0
;
1391 void do_mttacx(target_ulong t0
, uint32_t sel
)
1393 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1395 env
->ACX
[other_tc
][sel
] = t0
;
1398 void do_mttdsp(target_ulong t0
)
1400 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
1402 env
->DSPControl
[other_tc
] = t0
;
1405 /* MIPS MT functions */
1406 target_ulong
do_dmt(target_ulong t0
)
1415 target_ulong
do_emt(target_ulong t0
)
1424 target_ulong
do_dvpe(target_ulong t0
)
1433 target_ulong
do_evpe(target_ulong t0
)
1442 void do_fork(target_ulong t0
, target_ulong t1
)
1446 // TODO: store to TC register
1449 target_ulong
do_yield(target_ulong t0
)
1452 /* No scheduling policy implemented. */
1454 if (env
->CP0_VPEControl
& (1 << CP0VPECo_YSI
) &&
1455 env
->CP0_TCStatus
[env
->current_tc
] & (1 << CP0TCSt_DT
)) {
1456 env
->CP0_VPEControl
&= ~(0x7 << CP0VPECo_EXCPT
);
1457 env
->CP0_VPEControl
|= 4 << CP0VPECo_EXCPT
;
1458 do_raise_exception(EXCP_THREAD
);
1461 } else if (t0
== 0) {
1462 if (0 /* TODO: TC underflow */) {
1463 env
->CP0_VPEControl
&= ~(0x7 << CP0VPECo_EXCPT
);
1464 do_raise_exception(EXCP_THREAD
);
1466 // TODO: Deallocate TC
1468 } else if (t0
> 0) {
1469 /* Yield qualifier inputs not implemented. */
1470 env
->CP0_VPEControl
&= ~(0x7 << CP0VPECo_EXCPT
);
1471 env
->CP0_VPEControl
|= 2 << CP0VPECo_EXCPT
;
1472 do_raise_exception(EXCP_THREAD
);
1474 return env
->CP0_YQMask
;
1478 void fpu_handle_exception(void)
1480 #ifdef CONFIG_SOFTFLOAT
1481 int flags
= get_float_exception_flags(&env
->fpu
->fp_status
);
1482 unsigned int cpuflags
= 0, enable
, cause
= 0;
1484 enable
= GET_FP_ENABLE(env
->fpu
->fcr31
);
1486 /* determine current flags */
1487 if (flags
& float_flag_invalid
) {
1488 cpuflags
|= FP_INVALID
;
1489 cause
|= FP_INVALID
& enable
;
1491 if (flags
& float_flag_divbyzero
) {
1492 cpuflags
|= FP_DIV0
;
1493 cause
|= FP_DIV0
& enable
;
1495 if (flags
& float_flag_overflow
) {
1496 cpuflags
|= FP_OVERFLOW
;
1497 cause
|= FP_OVERFLOW
& enable
;
1499 if (flags
& float_flag_underflow
) {
1500 cpuflags
|= FP_UNDERFLOW
;
1501 cause
|= FP_UNDERFLOW
& enable
;
1503 if (flags
& float_flag_inexact
) {
1504 cpuflags
|= FP_INEXACT
;
1505 cause
|= FP_INEXACT
& enable
;
1507 SET_FP_FLAGS(env
->fpu
->fcr31
, cpuflags
);
1508 SET_FP_CAUSE(env
->fpu
->fcr31
, cause
);
1510 SET_FP_FLAGS(env
->fpu
->fcr31
, 0);
1511 SET_FP_CAUSE(env
->fpu
->fcr31
, 0);
1515 #ifndef CONFIG_USER_ONLY
1516 /* TLB management */
1517 void cpu_mips_tlb_flush (CPUState
*env
, int flush_global
)
1519 /* Flush qemu's TLB and discard all shadowed entries. */
1520 tlb_flush (env
, flush_global
);
1521 env
->tlb
->tlb_in_use
= env
->tlb
->nb_tlb
;
1524 static void r4k_mips_tlb_flush_extra (CPUState
*env
, int first
)
1526 /* Discard entries from env->tlb[first] onwards. */
1527 while (env
->tlb
->tlb_in_use
> first
) {
1528 r4k_invalidate_tlb(env
, --env
->tlb
->tlb_in_use
, 0);
1532 static void r4k_fill_tlb (int idx
)
1536 /* XXX: detect conflicting TLBs and raise a MCHECK exception when needed */
1537 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[idx
];
1538 tlb
->VPN
= env
->CP0_EntryHi
& (TARGET_PAGE_MASK
<< 1);
1539 #if defined(TARGET_MIPS64)
1540 tlb
->VPN
&= env
->SEGMask
;
1542 tlb
->ASID
= env
->CP0_EntryHi
& 0xFF;
1543 tlb
->PageMask
= env
->CP0_PageMask
;
1544 tlb
->G
= env
->CP0_EntryLo0
& env
->CP0_EntryLo1
& 1;
1545 tlb
->V0
= (env
->CP0_EntryLo0
& 2) != 0;
1546 tlb
->D0
= (env
->CP0_EntryLo0
& 4) != 0;
1547 tlb
->C0
= (env
->CP0_EntryLo0
>> 3) & 0x7;
1548 tlb
->PFN
[0] = (env
->CP0_EntryLo0
>> 6) << 12;
1549 tlb
->V1
= (env
->CP0_EntryLo1
& 2) != 0;
1550 tlb
->D1
= (env
->CP0_EntryLo1
& 4) != 0;
1551 tlb
->C1
= (env
->CP0_EntryLo1
>> 3) & 0x7;
1552 tlb
->PFN
[1] = (env
->CP0_EntryLo1
>> 6) << 12;
1555 void r4k_do_tlbwi (void)
1557 /* Discard cached TLB entries. We could avoid doing this if the
1558 tlbwi is just upgrading access permissions on the current entry;
1559 that might be a further win. */
1560 r4k_mips_tlb_flush_extra (env
, env
->tlb
->nb_tlb
);
1562 r4k_invalidate_tlb(env
, env
->CP0_Index
% env
->tlb
->nb_tlb
, 0);
1563 r4k_fill_tlb(env
->CP0_Index
% env
->tlb
->nb_tlb
);
1566 void r4k_do_tlbwr (void)
1568 int r
= cpu_mips_get_random(env
);
1570 r4k_invalidate_tlb(env
, r
, 1);
1574 void r4k_do_tlbp (void)
1583 ASID
= env
->CP0_EntryHi
& 0xFF;
1584 for (i
= 0; i
< env
->tlb
->nb_tlb
; i
++) {
1585 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[i
];
1586 /* 1k pages are not supported. */
1587 mask
= tlb
->PageMask
| ~(TARGET_PAGE_MASK
<< 1);
1588 tag
= env
->CP0_EntryHi
& ~mask
;
1589 VPN
= tlb
->VPN
& ~mask
;
1590 /* Check ASID, virtual page number & size */
1591 if ((tlb
->G
== 1 || tlb
->ASID
== ASID
) && VPN
== tag
) {
1597 if (i
== env
->tlb
->nb_tlb
) {
1598 /* No match. Discard any shadow entries, if any of them match. */
1599 for (i
= env
->tlb
->nb_tlb
; i
< env
->tlb
->tlb_in_use
; i
++) {
1600 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[i
];
1601 /* 1k pages are not supported. */
1602 mask
= tlb
->PageMask
| ~(TARGET_PAGE_MASK
<< 1);
1603 tag
= env
->CP0_EntryHi
& ~mask
;
1604 VPN
= tlb
->VPN
& ~mask
;
1605 /* Check ASID, virtual page number & size */
1606 if ((tlb
->G
== 1 || tlb
->ASID
== ASID
) && VPN
== tag
) {
1607 r4k_mips_tlb_flush_extra (env
, i
);
1612 env
->CP0_Index
|= 0x80000000;
1616 void r4k_do_tlbr (void)
1621 ASID
= env
->CP0_EntryHi
& 0xFF;
1622 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[env
->CP0_Index
% env
->tlb
->nb_tlb
];
1624 /* If this will change the current ASID, flush qemu's TLB. */
1625 if (ASID
!= tlb
->ASID
)
1626 cpu_mips_tlb_flush (env
, 1);
1628 r4k_mips_tlb_flush_extra(env
, env
->tlb
->nb_tlb
);
1630 env
->CP0_EntryHi
= tlb
->VPN
| tlb
->ASID
;
1631 env
->CP0_PageMask
= tlb
->PageMask
;
1632 env
->CP0_EntryLo0
= tlb
->G
| (tlb
->V0
<< 1) | (tlb
->D0
<< 2) |
1633 (tlb
->C0
<< 3) | (tlb
->PFN
[0] >> 6);
1634 env
->CP0_EntryLo1
= tlb
->G
| (tlb
->V1
<< 1) | (tlb
->D1
<< 2) |
1635 (tlb
->C1
<< 3) | (tlb
->PFN
[1] >> 6);
1638 #endif /* !CONFIG_USER_ONLY */
1641 target_ulong
do_di (target_ulong t0
)
1643 t0
= env
->CP0_Status
;
1644 env
->CP0_Status
= t0
& ~(1 << CP0St_IE
);
1645 cpu_mips_update_irq(env
);
1650 target_ulong
do_ei (target_ulong t0
)
1652 t0
= env
->CP0_Status
;
1653 env
->CP0_Status
= t0
| (1 << CP0St_IE
);
1654 cpu_mips_update_irq(env
);
1659 void debug_pre_eret (void)
1661 fprintf(logfile
, "ERET: PC " TARGET_FMT_lx
" EPC " TARGET_FMT_lx
,
1662 env
->PC
[env
->current_tc
], env
->CP0_EPC
);
1663 if (env
->CP0_Status
& (1 << CP0St_ERL
))
1664 fprintf(logfile
, " ErrorEPC " TARGET_FMT_lx
, env
->CP0_ErrorEPC
);
1665 if (env
->hflags
& MIPS_HFLAG_DM
)
1666 fprintf(logfile
, " DEPC " TARGET_FMT_lx
, env
->CP0_DEPC
);
1667 fputs("\n", logfile
);
1670 void debug_post_eret (void)
1672 fprintf(logfile
, " => PC " TARGET_FMT_lx
" EPC " TARGET_FMT_lx
,
1673 env
->PC
[env
->current_tc
], env
->CP0_EPC
);
1674 if (env
->CP0_Status
& (1 << CP0St_ERL
))
1675 fprintf(logfile
, " ErrorEPC " TARGET_FMT_lx
, env
->CP0_ErrorEPC
);
1676 if (env
->hflags
& MIPS_HFLAG_DM
)
1677 fprintf(logfile
, " DEPC " TARGET_FMT_lx
, env
->CP0_DEPC
);
1678 switch (env
->hflags
& MIPS_HFLAG_KSU
) {
1679 case MIPS_HFLAG_UM
: fputs(", UM\n", logfile
); break;
1680 case MIPS_HFLAG_SM
: fputs(", SM\n", logfile
); break;
1681 case MIPS_HFLAG_KM
: fputs("\n", logfile
); break;
1682 default: cpu_abort(env
, "Invalid MMU mode!\n"); break;
1688 if (loglevel
& CPU_LOG_EXEC
)
1690 if (env
->CP0_Status
& (1 << CP0St_ERL
)) {
1691 env
->PC
[env
->current_tc
] = env
->CP0_ErrorEPC
;
1692 env
->CP0_Status
&= ~(1 << CP0St_ERL
);
1694 env
->PC
[env
->current_tc
] = env
->CP0_EPC
;
1695 env
->CP0_Status
&= ~(1 << CP0St_EXL
);
1697 compute_hflags(env
);
1698 if (loglevel
& CPU_LOG_EXEC
)
1700 env
->CP0_LLAddr
= 1;
1703 void do_deret (void)
1705 if (loglevel
& CPU_LOG_EXEC
)
1707 env
->PC
[env
->current_tc
] = env
->CP0_DEPC
;
1708 env
->hflags
&= MIPS_HFLAG_DM
;
1709 compute_hflags(env
);
1710 if (loglevel
& CPU_LOG_EXEC
)
1712 env
->CP0_LLAddr
= 1;
1715 target_ulong
do_rdhwr_cpunum(target_ulong t0
)
1717 if ((env
->hflags
& MIPS_HFLAG_CP0
) ||
1718 (env
->CP0_HWREna
& (1 << 0)))
1719 t0
= env
->CP0_EBase
& 0x3ff;
1721 do_raise_exception(EXCP_RI
);
1726 target_ulong
do_rdhwr_synci_step(target_ulong t0
)
1728 if ((env
->hflags
& MIPS_HFLAG_CP0
) ||
1729 (env
->CP0_HWREna
& (1 << 1)))
1730 t0
= env
->SYNCI_Step
;
1732 do_raise_exception(EXCP_RI
);
1737 target_ulong
do_rdhwr_cc(target_ulong t0
)
1739 if ((env
->hflags
& MIPS_HFLAG_CP0
) ||
1740 (env
->CP0_HWREna
& (1 << 2)))
1741 t0
= env
->CP0_Count
;
1743 do_raise_exception(EXCP_RI
);
1748 target_ulong
do_rdhwr_ccres(target_ulong t0
)
1750 if ((env
->hflags
& MIPS_HFLAG_CP0
) ||
1751 (env
->CP0_HWREna
& (1 << 3)))
1754 do_raise_exception(EXCP_RI
);
1759 /* Bitfield operations. */
1760 target_ulong
do_ext(target_ulong t0
, target_ulong t1
, uint32_t pos
, uint32_t size
)
1762 return (int32_t)((t1
>> pos
) & ((size
< 32) ? ((1 << size
) - 1) : ~0));
1765 target_ulong
do_ins(target_ulong t0
, target_ulong t1
, uint32_t pos
, uint32_t size
)
1767 target_ulong mask
= ((size
< 32) ? ((1 << size
) - 1) : ~0) << pos
;
1769 return (int32_t)((t0
& ~mask
) | ((t1
<< pos
) & mask
));
1772 target_ulong
do_wsbh(target_ulong t0
, target_ulong t1
)
1774 return (int32_t)(((t1
<< 8) & ~0x00FF00FF) | ((t1
>> 8) & 0x00FF00FF));
1777 #if defined(TARGET_MIPS64)
1778 target_ulong
do_dext(target_ulong t0
, target_ulong t1
, uint32_t pos
, uint32_t size
)
1780 return (t1
>> pos
) & ((size
< 64) ? ((1ULL << size
) - 1) : ~0ULL);
1783 target_ulong
do_dins(target_ulong t0
, target_ulong t1
, uint32_t pos
, uint32_t size
)
1785 target_ulong mask
= ((size
< 64) ? ((1ULL << size
) - 1) : ~0ULL) << pos
;
1787 return (t0
& ~mask
) | ((t1
<< pos
) & mask
);
1790 target_ulong
do_dsbh(target_ulong t0
, target_ulong t1
)
1792 return ((t1
<< 8) & ~0x00FF00FF00FF00FFULL
) | ((t1
>> 8) & 0x00FF00FF00FF00FFULL
);
1795 target_ulong
do_dshd(target_ulong t0
, target_ulong t1
)
1797 t1
= ((t1
<< 16) & ~0x0000FFFF0000FFFFULL
) | ((t1
>> 16) & 0x0000FFFF0000FFFFULL
);
1798 return (t1
<< 32) | (t1
>> 32);
1802 void do_pmon (int function
)
1806 case 2: /* TODO: char inbyte(int waitflag); */
1807 if (env
->gpr
[env
->current_tc
][4] == 0)
1808 env
->gpr
[env
->current_tc
][2] = -1;
1810 case 11: /* TODO: char inbyte (void); */
1811 env
->gpr
[env
->current_tc
][2] = -1;
1815 printf("%c", (char)(env
->gpr
[env
->current_tc
][4] & 0xFF));
1821 unsigned char *fmt
= (void *)(unsigned long)env
->gpr
[env
->current_tc
][4];
1831 do_raise_exception(EXCP_HLT
);
1834 #if !defined(CONFIG_USER_ONLY)
1836 static void do_unaligned_access (target_ulong addr
, int is_write
, int is_user
, void *retaddr
);
1838 #define MMUSUFFIX _mmu
1839 #define ALIGNED_ONLY
1842 #include "softmmu_template.h"
1845 #include "softmmu_template.h"
1848 #include "softmmu_template.h"
1851 #include "softmmu_template.h"
1853 static void do_unaligned_access (target_ulong addr
, int is_write
, int is_user
, void *retaddr
)
1855 env
->CP0_BadVAddr
= addr
;
1856 do_restore_state (retaddr
);
1857 do_raise_exception ((is_write
== 1) ? EXCP_AdES
: EXCP_AdEL
);
1860 void tlb_fill (target_ulong addr
, int is_write
, int mmu_idx
, void *retaddr
)
1862 TranslationBlock
*tb
;
1863 CPUState
*saved_env
;
1867 /* XXX: hack to restore env in all cases, even if not called from
1870 env
= cpu_single_env
;
1871 ret
= cpu_mips_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
, 1);
1874 /* now we have a real cpu fault */
1875 pc
= (unsigned long)retaddr
;
1876 tb
= tb_find_pc(pc
);
1878 /* the PC is inside the translated code. It means that we have
1879 a virtual CPU fault */
1880 cpu_restore_state(tb
, env
, pc
, NULL
);
1883 do_raise_exception_err(env
->exception_index
, env
->error_code
);
1888 void do_unassigned_access(target_phys_addr_t addr
, int is_write
, int is_exec
,
1892 do_raise_exception(EXCP_IBE
);
1894 do_raise_exception(EXCP_DBE
);
1896 #endif /* !CONFIG_USER_ONLY */
1898 /* Complex FPU operations which may need stack space. */
1900 #define FLOAT_ONE32 make_float32(0x3f8 << 20)
1901 #define FLOAT_ONE64 make_float64(0x3ffULL << 52)
1902 #define FLOAT_TWO32 make_float32(1 << 30)
1903 #define FLOAT_TWO64 make_float64(1ULL << 62)
1904 #define FLOAT_QNAN32 0x7fbfffff
1905 #define FLOAT_QNAN64 0x7ff7ffffffffffffULL
1906 #define FLOAT_SNAN32 0x7fffffff
1907 #define FLOAT_SNAN64 0x7fffffffffffffffULL
1909 /* convert MIPS rounding mode in FCR31 to IEEE library */
1910 unsigned int ieee_rm
[] = {
1911 float_round_nearest_even
,
1912 float_round_to_zero
,
1917 #define RESTORE_ROUNDING_MODE \
1918 set_float_rounding_mode(ieee_rm[env->fpu->fcr31 & 3], &env->fpu->fp_status)
1920 target_ulong
do_cfc1 (uint32_t reg
)
1926 t0
= (int32_t)env
->fpu
->fcr0
;
1929 t0
= ((env
->fpu
->fcr31
>> 24) & 0xfe) | ((env
->fpu
->fcr31
>> 23) & 0x1);
1932 t0
= env
->fpu
->fcr31
& 0x0003f07c;
1935 t0
= (env
->fpu
->fcr31
& 0x00000f83) | ((env
->fpu
->fcr31
>> 22) & 0x4);
1938 t0
= (int32_t)env
->fpu
->fcr31
;
1945 void do_ctc1 (target_ulong t0
, uint32_t reg
)
1949 if (t0
& 0xffffff00)
1951 env
->fpu
->fcr31
= (env
->fpu
->fcr31
& 0x017fffff) | ((t0
& 0xfe) << 24) |
1955 if (t0
& 0x007c0000)
1957 env
->fpu
->fcr31
= (env
->fpu
->fcr31
& 0xfffc0f83) | (t0
& 0x0003f07c);
1960 if (t0
& 0x007c0000)
1962 env
->fpu
->fcr31
= (env
->fpu
->fcr31
& 0xfefff07c) | (t0
& 0x00000f83) |
1966 if (t0
& 0x007c0000)
1968 env
->fpu
->fcr31
= t0
;
1973 /* set rounding mode */
1974 RESTORE_ROUNDING_MODE
;
1975 set_float_exception_flags(0, &env
->fpu
->fp_status
);
1976 if ((GET_FP_ENABLE(env
->fpu
->fcr31
) | 0x20) & GET_FP_CAUSE(env
->fpu
->fcr31
))
1977 do_raise_exception(EXCP_FPE
);
1980 static always_inline
char ieee_ex_to_mips(char xcpt
)
1982 return (xcpt
& float_flag_inexact
) >> 5 |
1983 (xcpt
& float_flag_underflow
) >> 3 |
1984 (xcpt
& float_flag_overflow
) >> 1 |
1985 (xcpt
& float_flag_divbyzero
) << 1 |
1986 (xcpt
& float_flag_invalid
) << 4;
1989 static always_inline
char mips_ex_to_ieee(char xcpt
)
1991 return (xcpt
& FP_INEXACT
) << 5 |
1992 (xcpt
& FP_UNDERFLOW
) << 3 |
1993 (xcpt
& FP_OVERFLOW
) << 1 |
1994 (xcpt
& FP_DIV0
) >> 1 |
1995 (xcpt
& FP_INVALID
) >> 4;
1998 static always_inline
void update_fcr31(void)
2000 int tmp
= ieee_ex_to_mips(get_float_exception_flags(&env
->fpu
->fp_status
));
2002 SET_FP_CAUSE(env
->fpu
->fcr31
, tmp
);
2003 if (GET_FP_ENABLE(env
->fpu
->fcr31
) & tmp
)
2004 do_raise_exception(EXCP_FPE
);
2006 UPDATE_FP_FLAGS(env
->fpu
->fcr31
, tmp
);
2010 Single precition routines have a "s" suffix, double precision a
2011 "d" suffix, 32bit integer "w", 64bit integer "l", paired single "ps",
2012 paired single lower "pl", paired single upper "pu". */
2014 #define FLOAT_OP(name, p) void do_float_##name##_##p(void)
2016 /* unary operations, modifying fp status */
2017 #define FLOAT_UNOP(name) \
2020 FDT2 = float64_ ## name(FDT0, &env->fpu->fp_status); \
2024 FST2 = float32_ ## name(FST0, &env->fpu->fp_status); \
2031 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2032 FDT2
= float32_to_float64(FST0
, &env
->fpu
->fp_status
);
2037 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2038 FDT2
= int32_to_float64(WT0
, &env
->fpu
->fp_status
);
2043 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2044 FDT2
= int64_to_float64(DT0
, &env
->fpu
->fp_status
);
2049 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2050 DT2
= float64_to_int64(FDT0
, &env
->fpu
->fp_status
);
2052 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2057 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2058 DT2
= float32_to_int64(FST0
, &env
->fpu
->fp_status
);
2060 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2066 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2067 FST2
= int32_to_float32(WT0
, &env
->fpu
->fp_status
);
2068 FSTH2
= int32_to_float32(WTH0
, &env
->fpu
->fp_status
);
2073 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2074 WT2
= float32_to_int32(FST0
, &env
->fpu
->fp_status
);
2075 WTH2
= float32_to_int32(FSTH0
, &env
->fpu
->fp_status
);
2077 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2082 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2083 FST2
= float64_to_float32(FDT0
, &env
->fpu
->fp_status
);
2088 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2089 FST2
= int32_to_float32(WT0
, &env
->fpu
->fp_status
);
2094 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2095 FST2
= int64_to_float32(DT0
, &env
->fpu
->fp_status
);
2100 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2106 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2112 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2113 WT2
= float32_to_int32(FST0
, &env
->fpu
->fp_status
);
2115 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2120 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2121 WT2
= float64_to_int32(FDT0
, &env
->fpu
->fp_status
);
2123 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2129 set_float_rounding_mode(float_round_nearest_even
, &env
->fpu
->fp_status
);
2130 DT2
= float64_to_int64(FDT0
, &env
->fpu
->fp_status
);
2131 RESTORE_ROUNDING_MODE
;
2133 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2138 set_float_rounding_mode(float_round_nearest_even
, &env
->fpu
->fp_status
);
2139 DT2
= float32_to_int64(FST0
, &env
->fpu
->fp_status
);
2140 RESTORE_ROUNDING_MODE
;
2142 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2147 set_float_rounding_mode(float_round_nearest_even
, &env
->fpu
->fp_status
);
2148 WT2
= float64_to_int32(FDT0
, &env
->fpu
->fp_status
);
2149 RESTORE_ROUNDING_MODE
;
2151 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2156 set_float_rounding_mode(float_round_nearest_even
, &env
->fpu
->fp_status
);
2157 WT2
= float32_to_int32(FST0
, &env
->fpu
->fp_status
);
2158 RESTORE_ROUNDING_MODE
;
2160 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2166 DT2
= float64_to_int64_round_to_zero(FDT0
, &env
->fpu
->fp_status
);
2168 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2173 DT2
= float32_to_int64_round_to_zero(FST0
, &env
->fpu
->fp_status
);
2175 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2180 WT2
= float64_to_int32_round_to_zero(FDT0
, &env
->fpu
->fp_status
);
2182 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2187 WT2
= float32_to_int32_round_to_zero(FST0
, &env
->fpu
->fp_status
);
2189 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2195 set_float_rounding_mode(float_round_up
, &env
->fpu
->fp_status
);
2196 DT2
= float64_to_int64(FDT0
, &env
->fpu
->fp_status
);
2197 RESTORE_ROUNDING_MODE
;
2199 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2204 set_float_rounding_mode(float_round_up
, &env
->fpu
->fp_status
);
2205 DT2
= float32_to_int64(FST0
, &env
->fpu
->fp_status
);
2206 RESTORE_ROUNDING_MODE
;
2208 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2213 set_float_rounding_mode(float_round_up
, &env
->fpu
->fp_status
);
2214 WT2
= float64_to_int32(FDT0
, &env
->fpu
->fp_status
);
2215 RESTORE_ROUNDING_MODE
;
2217 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2222 set_float_rounding_mode(float_round_up
, &env
->fpu
->fp_status
);
2223 WT2
= float32_to_int32(FST0
, &env
->fpu
->fp_status
);
2224 RESTORE_ROUNDING_MODE
;
2226 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2232 set_float_rounding_mode(float_round_down
, &env
->fpu
->fp_status
);
2233 DT2
= float64_to_int64(FDT0
, &env
->fpu
->fp_status
);
2234 RESTORE_ROUNDING_MODE
;
2236 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2241 set_float_rounding_mode(float_round_down
, &env
->fpu
->fp_status
);
2242 DT2
= float32_to_int64(FST0
, &env
->fpu
->fp_status
);
2243 RESTORE_ROUNDING_MODE
;
2245 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2250 set_float_rounding_mode(float_round_down
, &env
->fpu
->fp_status
);
2251 WT2
= float64_to_int32(FDT0
, &env
->fpu
->fp_status
);
2252 RESTORE_ROUNDING_MODE
;
2254 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2259 set_float_rounding_mode(float_round_down
, &env
->fpu
->fp_status
);
2260 WT2
= float32_to_int32(FST0
, &env
->fpu
->fp_status
);
2261 RESTORE_ROUNDING_MODE
;
2263 if (GET_FP_CAUSE(env
->fpu
->fcr31
) & (FP_OVERFLOW
| FP_INVALID
))
2267 /* unary operations, not modifying fp status */
2268 #define FLOAT_UNOP(name) \
2271 FDT2 = float64_ ## name(FDT0); \
2275 FST2 = float32_ ## name(FST0); \
2277 FLOAT_OP(name, ps) \
2279 FST2 = float32_ ## name(FST0); \
2280 FSTH2 = float32_ ## name(FSTH0); \
2286 /* MIPS specific unary operations */
2289 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2290 FDT2
= float64_div(FLOAT_ONE64
, FDT0
, &env
->fpu
->fp_status
);
2295 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2296 FST2
= float32_div(FLOAT_ONE32
, FST0
, &env
->fpu
->fp_status
);
2302 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2303 FDT2
= float64_sqrt(FDT0
, &env
->fpu
->fp_status
);
2304 FDT2
= float64_div(FLOAT_ONE64
, FDT2
, &env
->fpu
->fp_status
);
2309 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2310 FST2
= float32_sqrt(FST0
, &env
->fpu
->fp_status
);
2311 FST2
= float32_div(FLOAT_ONE32
, FST2
, &env
->fpu
->fp_status
);
2317 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2318 FDT2
= float64_div(FLOAT_ONE64
, FDT0
, &env
->fpu
->fp_status
);
2323 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2324 FST2
= float32_div(FLOAT_ONE32
, FST0
, &env
->fpu
->fp_status
);
2327 FLOAT_OP(recip1
, ps
)
2329 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2330 FST2
= float32_div(FLOAT_ONE32
, FST0
, &env
->fpu
->fp_status
);
2331 FSTH2
= float32_div(FLOAT_ONE32
, FSTH0
, &env
->fpu
->fp_status
);
2337 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2338 FDT2
= float64_sqrt(FDT0
, &env
->fpu
->fp_status
);
2339 FDT2
= float64_div(FLOAT_ONE64
, FDT2
, &env
->fpu
->fp_status
);
2344 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2345 FST2
= float32_sqrt(FST0
, &env
->fpu
->fp_status
);
2346 FST2
= float32_div(FLOAT_ONE32
, FST2
, &env
->fpu
->fp_status
);
2349 FLOAT_OP(rsqrt1
, ps
)
2351 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2352 FST2
= float32_sqrt(FST0
, &env
->fpu
->fp_status
);
2353 FSTH2
= float32_sqrt(FSTH0
, &env
->fpu
->fp_status
);
2354 FST2
= float32_div(FLOAT_ONE32
, FST2
, &env
->fpu
->fp_status
);
2355 FSTH2
= float32_div(FLOAT_ONE32
, FSTH2
, &env
->fpu
->fp_status
);
2359 /* binary operations */
2360 #define FLOAT_BINOP(name) \
2363 set_float_exception_flags(0, &env->fpu->fp_status); \
2364 FDT2 = float64_ ## name (FDT0, FDT1, &env->fpu->fp_status); \
2366 if (GET_FP_CAUSE(env->fpu->fcr31) & FP_INVALID) \
2367 DT2 = FLOAT_QNAN64; \
2371 set_float_exception_flags(0, &env->fpu->fp_status); \
2372 FST2 = float32_ ## name (FST0, FST1, &env->fpu->fp_status); \
2374 if (GET_FP_CAUSE(env->fpu->fcr31) & FP_INVALID) \
2375 WT2 = FLOAT_QNAN32; \
2377 FLOAT_OP(name, ps) \
2379 set_float_exception_flags(0, &env->fpu->fp_status); \
2380 FST2 = float32_ ## name (FST0, FST1, &env->fpu->fp_status); \
2381 FSTH2 = float32_ ## name (FSTH0, FSTH1, &env->fpu->fp_status); \
2383 if (GET_FP_CAUSE(env->fpu->fcr31) & FP_INVALID) { \
2384 WT2 = FLOAT_QNAN32; \
2385 WTH2 = FLOAT_QNAN32; \
2394 /* ternary operations */
2395 #define FLOAT_TERNOP(name1, name2) \
2396 FLOAT_OP(name1 ## name2, d) \
2398 FDT0 = float64_ ## name1 (FDT0, FDT1, &env->fpu->fp_status); \
2399 FDT2 = float64_ ## name2 (FDT0, FDT2, &env->fpu->fp_status); \
2401 FLOAT_OP(name1 ## name2, s) \
2403 FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status); \
2404 FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status); \
2406 FLOAT_OP(name1 ## name2, ps) \
2408 FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status); \
2409 FSTH0 = float32_ ## name1 (FSTH0, FSTH1, &env->fpu->fp_status); \
2410 FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status); \
2411 FSTH2 = float32_ ## name2 (FSTH0, FSTH2, &env->fpu->fp_status); \
2413 FLOAT_TERNOP(mul
, add
)
2414 FLOAT_TERNOP(mul
, sub
)
2417 /* negated ternary operations */
2418 #define FLOAT_NTERNOP(name1, name2) \
2419 FLOAT_OP(n ## name1 ## name2, d) \
2421 FDT0 = float64_ ## name1 (FDT0, FDT1, &env->fpu->fp_status); \
2422 FDT2 = float64_ ## name2 (FDT0, FDT2, &env->fpu->fp_status); \
2423 FDT2 = float64_chs(FDT2); \
2425 FLOAT_OP(n ## name1 ## name2, s) \
2427 FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status); \
2428 FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status); \
2429 FST2 = float32_chs(FST2); \
2431 FLOAT_OP(n ## name1 ## name2, ps) \
2433 FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status); \
2434 FSTH0 = float32_ ## name1 (FSTH0, FSTH1, &env->fpu->fp_status); \
2435 FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status); \
2436 FSTH2 = float32_ ## name2 (FSTH0, FSTH2, &env->fpu->fp_status); \
2437 FST2 = float32_chs(FST2); \
2438 FSTH2 = float32_chs(FSTH2); \
2440 FLOAT_NTERNOP(mul
, add
)
2441 FLOAT_NTERNOP(mul
, sub
)
2442 #undef FLOAT_NTERNOP
2444 /* MIPS specific binary operations */
2447 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2448 FDT2
= float64_mul(FDT0
, FDT2
, &env
->fpu
->fp_status
);
2449 FDT2
= float64_chs(float64_sub(FDT2
, FLOAT_ONE64
, &env
->fpu
->fp_status
));
2454 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2455 FST2
= float32_mul(FST0
, FST2
, &env
->fpu
->fp_status
);
2456 FST2
= float32_chs(float32_sub(FST2
, FLOAT_ONE32
, &env
->fpu
->fp_status
));
2459 FLOAT_OP(recip2
, ps
)
2461 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2462 FST2
= float32_mul(FST0
, FST2
, &env
->fpu
->fp_status
);
2463 FSTH2
= float32_mul(FSTH0
, FSTH2
, &env
->fpu
->fp_status
);
2464 FST2
= float32_chs(float32_sub(FST2
, FLOAT_ONE32
, &env
->fpu
->fp_status
));
2465 FSTH2
= float32_chs(float32_sub(FSTH2
, FLOAT_ONE32
, &env
->fpu
->fp_status
));
2471 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2472 FDT2
= float64_mul(FDT0
, FDT2
, &env
->fpu
->fp_status
);
2473 FDT2
= float64_sub(FDT2
, FLOAT_ONE64
, &env
->fpu
->fp_status
);
2474 FDT2
= float64_chs(float64_div(FDT2
, FLOAT_TWO64
, &env
->fpu
->fp_status
));
2479 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2480 FST2
= float32_mul(FST0
, FST2
, &env
->fpu
->fp_status
);
2481 FST2
= float32_sub(FST2
, FLOAT_ONE32
, &env
->fpu
->fp_status
);
2482 FST2
= float32_chs(float32_div(FST2
, FLOAT_TWO32
, &env
->fpu
->fp_status
));
2485 FLOAT_OP(rsqrt2
, ps
)
2487 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2488 FST2
= float32_mul(FST0
, FST2
, &env
->fpu
->fp_status
);
2489 FSTH2
= float32_mul(FSTH0
, FSTH2
, &env
->fpu
->fp_status
);
2490 FST2
= float32_sub(FST2
, FLOAT_ONE32
, &env
->fpu
->fp_status
);
2491 FSTH2
= float32_sub(FSTH2
, FLOAT_ONE32
, &env
->fpu
->fp_status
);
2492 FST2
= float32_chs(float32_div(FST2
, FLOAT_TWO32
, &env
->fpu
->fp_status
));
2493 FSTH2
= float32_chs(float32_div(FSTH2
, FLOAT_TWO32
, &env
->fpu
->fp_status
));
2499 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2500 FST2
= float32_add (FST0
, FSTH0
, &env
->fpu
->fp_status
);
2501 FSTH2
= float32_add (FST1
, FSTH1
, &env
->fpu
->fp_status
);
2507 set_float_exception_flags(0, &env
->fpu
->fp_status
);
2508 FST2
= float32_mul (FST0
, FSTH0
, &env
->fpu
->fp_status
);
2509 FSTH2
= float32_mul (FST1
, FSTH1
, &env
->fpu
->fp_status
);
2513 /* compare operations */
2514 #define FOP_COND_D(op, cond) \
2515 void do_cmp_d_ ## op (long cc) \
2520 SET_FP_COND(cc, env->fpu); \
2522 CLEAR_FP_COND(cc, env->fpu); \
2524 void do_cmpabs_d_ ## op (long cc) \
2527 FDT0 = float64_abs(FDT0); \
2528 FDT1 = float64_abs(FDT1); \
2532 SET_FP_COND(cc, env->fpu); \
2534 CLEAR_FP_COND(cc, env->fpu); \
2537 int float64_is_unordered(int sig
, float64 a
, float64 b STATUS_PARAM
)
2539 if (float64_is_signaling_nan(a
) ||
2540 float64_is_signaling_nan(b
) ||
2541 (sig
&& (float64_is_nan(a
) || float64_is_nan(b
)))) {
2542 float_raise(float_flag_invalid
, status
);
2544 } else if (float64_is_nan(a
) || float64_is_nan(b
)) {
2551 /* NOTE: the comma operator will make "cond" to eval to false,
2552 * but float*_is_unordered() is still called. */
2553 FOP_COND_D(f
, (float64_is_unordered(0, FDT1
, FDT0
, &env
->fpu
->fp_status
), 0))
2554 FOP_COND_D(un
, float64_is_unordered(0, FDT1
, FDT0
, &env
->fpu
->fp_status
))
2555 FOP_COND_D(eq
, !float64_is_unordered(0, FDT1
, FDT0
, &env
->fpu
->fp_status
) && float64_eq(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2556 FOP_COND_D(ueq
, float64_is_unordered(0, FDT1
, FDT0
, &env
->fpu
->fp_status
) || float64_eq(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2557 FOP_COND_D(olt
, !float64_is_unordered(0, FDT1
, FDT0
, &env
->fpu
->fp_status
) && float64_lt(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2558 FOP_COND_D(ult
, float64_is_unordered(0, FDT1
, FDT0
, &env
->fpu
->fp_status
) || float64_lt(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2559 FOP_COND_D(ole
, !float64_is_unordered(0, FDT1
, FDT0
, &env
->fpu
->fp_status
) && float64_le(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2560 FOP_COND_D(ule
, float64_is_unordered(0, FDT1
, FDT0
, &env
->fpu
->fp_status
) || float64_le(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2561 /* NOTE: the comma operator will make "cond" to eval to false,
2562 * but float*_is_unordered() is still called. */
2563 FOP_COND_D(sf
, (float64_is_unordered(1, FDT1
, FDT0
, &env
->fpu
->fp_status
), 0))
2564 FOP_COND_D(ngle
,float64_is_unordered(1, FDT1
, FDT0
, &env
->fpu
->fp_status
))
2565 FOP_COND_D(seq
, !float64_is_unordered(1, FDT1
, FDT0
, &env
->fpu
->fp_status
) && float64_eq(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2566 FOP_COND_D(ngl
, float64_is_unordered(1, FDT1
, FDT0
, &env
->fpu
->fp_status
) || float64_eq(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2567 FOP_COND_D(lt
, !float64_is_unordered(1, FDT1
, FDT0
, &env
->fpu
->fp_status
) && float64_lt(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2568 FOP_COND_D(nge
, float64_is_unordered(1, FDT1
, FDT0
, &env
->fpu
->fp_status
) || float64_lt(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2569 FOP_COND_D(le
, !float64_is_unordered(1, FDT1
, FDT0
, &env
->fpu
->fp_status
) && float64_le(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2570 FOP_COND_D(ngt
, float64_is_unordered(1, FDT1
, FDT0
, &env
->fpu
->fp_status
) || float64_le(FDT0
, FDT1
, &env
->fpu
->fp_status
))
2572 #define FOP_COND_S(op, cond) \
2573 void do_cmp_s_ ## op (long cc) \
2578 SET_FP_COND(cc, env->fpu); \
2580 CLEAR_FP_COND(cc, env->fpu); \
2582 void do_cmpabs_s_ ## op (long cc) \
2585 FST0 = float32_abs(FST0); \
2586 FST1 = float32_abs(FST1); \
2590 SET_FP_COND(cc, env->fpu); \
2592 CLEAR_FP_COND(cc, env->fpu); \
2595 flag
float32_is_unordered(int sig
, float32 a
, float32 b STATUS_PARAM
)
2597 if (float32_is_signaling_nan(a
) ||
2598 float32_is_signaling_nan(b
) ||
2599 (sig
&& (float32_is_nan(a
) || float32_is_nan(b
)))) {
2600 float_raise(float_flag_invalid
, status
);
2602 } else if (float32_is_nan(a
) || float32_is_nan(b
)) {
2609 /* NOTE: the comma operator will make "cond" to eval to false,
2610 * but float*_is_unordered() is still called. */
2611 FOP_COND_S(f
, (float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
), 0))
2612 FOP_COND_S(un
, float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
))
2613 FOP_COND_S(eq
, !float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_eq(FST0
, FST1
, &env
->fpu
->fp_status
))
2614 FOP_COND_S(ueq
, float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_eq(FST0
, FST1
, &env
->fpu
->fp_status
))
2615 FOP_COND_S(olt
, !float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_lt(FST0
, FST1
, &env
->fpu
->fp_status
))
2616 FOP_COND_S(ult
, float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_lt(FST0
, FST1
, &env
->fpu
->fp_status
))
2617 FOP_COND_S(ole
, !float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_le(FST0
, FST1
, &env
->fpu
->fp_status
))
2618 FOP_COND_S(ule
, float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_le(FST0
, FST1
, &env
->fpu
->fp_status
))
2619 /* NOTE: the comma operator will make "cond" to eval to false,
2620 * but float*_is_unordered() is still called. */
2621 FOP_COND_S(sf
, (float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
), 0))
2622 FOP_COND_S(ngle
,float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
))
2623 FOP_COND_S(seq
, !float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_eq(FST0
, FST1
, &env
->fpu
->fp_status
))
2624 FOP_COND_S(ngl
, float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_eq(FST0
, FST1
, &env
->fpu
->fp_status
))
2625 FOP_COND_S(lt
, !float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_lt(FST0
, FST1
, &env
->fpu
->fp_status
))
2626 FOP_COND_S(nge
, float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_lt(FST0
, FST1
, &env
->fpu
->fp_status
))
2627 FOP_COND_S(le
, !float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_le(FST0
, FST1
, &env
->fpu
->fp_status
))
2628 FOP_COND_S(ngt
, float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_le(FST0
, FST1
, &env
->fpu
->fp_status
))
2630 #define FOP_COND_PS(op, condl, condh) \
2631 void do_cmp_ps_ ## op (long cc) \
2637 SET_FP_COND(cc, env->fpu); \
2639 CLEAR_FP_COND(cc, env->fpu); \
2641 SET_FP_COND(cc + 1, env->fpu); \
2643 CLEAR_FP_COND(cc + 1, env->fpu); \
2645 void do_cmpabs_ps_ ## op (long cc) \
2648 FST0 = float32_abs(FST0); \
2649 FSTH0 = float32_abs(FSTH0); \
2650 FST1 = float32_abs(FST1); \
2651 FSTH1 = float32_abs(FSTH1); \
2656 SET_FP_COND(cc, env->fpu); \
2658 CLEAR_FP_COND(cc, env->fpu); \
2660 SET_FP_COND(cc + 1, env->fpu); \
2662 CLEAR_FP_COND(cc + 1, env->fpu); \
2665 /* NOTE: the comma operator will make "cond" to eval to false,
2666 * but float*_is_unordered() is still called. */
2667 FOP_COND_PS(f
, (float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
), 0),
2668 (float32_is_unordered(0, FSTH1
, FSTH0
, &env
->fpu
->fp_status
), 0))
2669 FOP_COND_PS(un
, float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
),
2670 float32_is_unordered(0, FSTH1
, FSTH0
, &env
->fpu
->fp_status
))
2671 FOP_COND_PS(eq
, !float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_eq(FST0
, FST1
, &env
->fpu
->fp_status
),
2672 !float32_is_unordered(0, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) && float32_eq(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2673 FOP_COND_PS(ueq
, float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_eq(FST0
, FST1
, &env
->fpu
->fp_status
),
2674 float32_is_unordered(0, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) || float32_eq(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2675 FOP_COND_PS(olt
, !float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_lt(FST0
, FST1
, &env
->fpu
->fp_status
),
2676 !float32_is_unordered(0, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) && float32_lt(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2677 FOP_COND_PS(ult
, float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_lt(FST0
, FST1
, &env
->fpu
->fp_status
),
2678 float32_is_unordered(0, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) || float32_lt(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2679 FOP_COND_PS(ole
, !float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_le(FST0
, FST1
, &env
->fpu
->fp_status
),
2680 !float32_is_unordered(0, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) && float32_le(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2681 FOP_COND_PS(ule
, float32_is_unordered(0, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_le(FST0
, FST1
, &env
->fpu
->fp_status
),
2682 float32_is_unordered(0, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) || float32_le(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2683 /* NOTE: the comma operator will make "cond" to eval to false,
2684 * but float*_is_unordered() is still called. */
2685 FOP_COND_PS(sf
, (float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
), 0),
2686 (float32_is_unordered(1, FSTH1
, FSTH0
, &env
->fpu
->fp_status
), 0))
2687 FOP_COND_PS(ngle
,float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
),
2688 float32_is_unordered(1, FSTH1
, FSTH0
, &env
->fpu
->fp_status
))
2689 FOP_COND_PS(seq
, !float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_eq(FST0
, FST1
, &env
->fpu
->fp_status
),
2690 !float32_is_unordered(1, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) && float32_eq(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2691 FOP_COND_PS(ngl
, float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_eq(FST0
, FST1
, &env
->fpu
->fp_status
),
2692 float32_is_unordered(1, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) || float32_eq(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2693 FOP_COND_PS(lt
, !float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_lt(FST0
, FST1
, &env
->fpu
->fp_status
),
2694 !float32_is_unordered(1, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) && float32_lt(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2695 FOP_COND_PS(nge
, float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_lt(FST0
, FST1
, &env
->fpu
->fp_status
),
2696 float32_is_unordered(1, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) || float32_lt(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2697 FOP_COND_PS(le
, !float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) && float32_le(FST0
, FST1
, &env
->fpu
->fp_status
),
2698 !float32_is_unordered(1, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) && float32_le(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))
2699 FOP_COND_PS(ngt
, float32_is_unordered(1, FST1
, FST0
, &env
->fpu
->fp_status
) || float32_le(FST0
, FST1
, &env
->fpu
->fp_status
),
2700 float32_is_unordered(1, FSTH1
, FSTH0
, &env
->fpu
->fp_status
) || float32_le(FSTH0
, FSTH1
, &env
->fpu
->fp_status
))