4 // <insn-word> { "+" <insn-word> }
11 // { <insn-mnemonic> }
16 // IGEN config - mips16
17 // :option:16::insn-bit-size:16
18 // :option:16::hi-bit-nr:15
19 :option:16::insn-specifying-widths:true
20 :option:16::gen-delayed-branch:false
22 // IGEN config - mips32/64..
23 // :option:32::insn-bit-size:32
24 // :option:32::hi-bit-nr:31
25 :option:32::insn-specifying-widths:true
26 :option:32::gen-delayed-branch:false
29 // Generate separate simulators for each target
30 // :option:::multi-sim:true
33 // Models known by this simulator are defined below.
35 // When placing models in the instruction descriptions, please place
36 // them one per line, in the order given here.
40 // Instructions and related functions for these models are included in
42 :model:::mipsI:mips3000:
43 :model:::mipsII:mips6000:
44 :model:::mipsIII:mips4000:
45 :model:::mipsIV:mips8000:
46 :model:::mipsV:mipsisaV:
47 :model:::mips32:mipsisa32:
48 :model:::mips32r2:mipsisa32r2:
49 :model:::mips32r6:mipsisa32r6:
50 :model:::mips64:mipsisa64:
51 :model:::mips64r2:mipsisa64r2:
52 :model:::mips64r6:mipsisa64r6:
56 // Standard MIPS ISA instructions used for these models are listed here,
57 // as are functions needed by those standard instructions. Instructions
58 // which are model-dependent and which are not in the standard MIPS ISAs
59 // (or which pre-date or use different encodings than the standard
60 // instructions) are (for the most part) in separate .igen files.
61 :model:::vr4100:mips4100: // vr.igen
62 :model:::vr4120:mips4120:
63 :model:::vr5000:mips5000:
64 :model:::vr5400:mips5400:
65 :model:::vr5500:mips5500:
66 :model:::r3900:mips3900: // tx.igen
68 // MIPS Application Specific Extensions (ASEs)
70 // Instructions for the ASEs are in separate .igen files.
71 // ASEs add instructions on to a base ISA.
72 :model:::mips16:mips16: // m16.igen (and m16.dc)
73 :model:::mips16e:mips16e: // m16e.igen
74 :model:::mips3d:mips3d: // mips3d.igen
75 :model:::mdmx:mdmx: // mdmx.igen
76 :model:::dsp:dsp: // dsp.igen
77 :model:::dsp2:dsp2: // dsp2.igen
78 :model:::smartmips:smartmips: // smartmips.igen
79 :model:::micromips32:micromips64: // micromips.igen
80 :model:::micromips64:micromips64: // micromips.igen
81 :model:::micromipsdsp:micromipsdsp: // micromipsdsp.igen
85 // Instructions specific to these extensions are in separate .igen files.
86 // Extensions add instructions on to a base ISA.
87 :model:::sb1:sb1: // sb1.igen
90 // Pseudo instructions known by IGEN
93 SignalException (ReservedInstruction, 0);
97 // Pseudo instructions known by interp.c
98 // For grep - RSVD_INSTRUCTION, RSVD_INSTRUCTION_MASK
99 000000,5.*,5.*,5.*,5.OP,111001:SPECIAL:32::RSVD
102 SignalException (ReservedInstruction, instruction_0);
109 // Check if given instruction is CTI, if so signal
111 :function:::void:signal_if_cti:instruction_word instr
113 uint32_t maj = (instr & 0xfc000000) >> 26;
114 uint32_t special = instr & 0x3f;
115 if ((maj & 0x3e) == 0x06 /* Branch/Jump */
116 || ((maj & 0x38) == 0 && !((maj & 0x6) == 0))
118 || (maj & 0x37) == 0x32
119 || (maj & 0x37) == 0x36
120 || ((maj == 0) && (special == 0x9))
121 /* DERET/ERET/WAIT */
122 || ((maj == 0x10) && (instr & 0x02000000)
123 && (special == 0x1f || special == 0x18 || special == 0x20)))
125 SignalException (ReservedInstruction, instr);
130 // Simulate a 32 bit delayslot instruction
133 :function:::address_word:delayslot32:address_word target
135 instruction_word delay_insn;
136 sim_events_slip (SD, 1);
138 CIA = CIA + 4; /* NOTE not mips16 */
139 STATE |= simDELAYSLOT;
140 delay_insn = IMEM32 (CIA); /* NOTE not mips16 */
141 signal_if_cti (SD_, delay_insn);
142 ENGINE_ISSUE_PREFIX_HOOK();
143 idecode_issue (CPU_, delay_insn, (CIA));
144 STATE &= ~simDELAYSLOT;
149 // Simulate a 32 bit forbidden slot instruction
152 :function:::address_word:forbiddenslot32:
156 instruction_word delay_insn;
157 sim_events_slip (SD, 1);
160 STATE |= simFORBIDDENSLOT;
161 delay_insn = IMEM32 (CIA);
162 signal_if_cti (SD_, delay_insn);
163 ENGINE_ISSUE_PREFIX_HOOK ();
164 idecode_issue (CPU_, delay_insn, (CIA));
165 STATE &= ~simFORBIDDENSLOT;
169 :function:::address_word:nullify_next_insn32:
171 sim_events_slip (SD, 1);
172 dotrace (SD, CPU, tracefh, 2, CIA + 4, 4, "load instruction");
179 // Calculate an effective address given a base and an offset.
182 :function:::address_word:loadstore_ea:address_word base, address_word offset
196 return base + offset;
199 :function:::address_word:loadstore_ea:address_word base, address_word offset
205 #if 0 /* XXX FIXME: enable this only after some additional testing. */
206 /* If in user mode and UX is not set, use 32-bit compatibility effective
207 address computations as defined in the MIPS64 Architecture for
208 Programmers Volume III, Revision 0.95, section 4.9. */
209 if ((SR & (status_KSU_mask|status_EXL|status_ERL|status_UX))
210 == (ksu_user << status_KSU_shift))
211 return (address_word)((int32_t)base + (int32_t)offset);
213 return base + offset;
219 // Check that a 32-bit register value is properly sign-extended.
220 // (See NotWordValue in ISA spec.)
223 :function:::int:not_word_value:unsigned_word value
241 #if WITH_TARGET_WORD_BITSIZE == 64
242 return value != (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
250 // Handle UNPREDICTABLE operation behaviour. The goal here is to prevent
251 // theoretically portable code which invokes non-portable behaviour from
252 // running with no indication of the portability issue.
253 // (See definition of UNPREDICTABLE in ISA spec.)
256 :function:::void:unpredictable:
268 :function:::void:unpredictable:
278 unpredictable_action (CPU, CIA);
284 // Check that an access to a HI/LO register meets timing requirements
288 // OP {HI and LO} followed by MT{LO or HI} (and not MT{HI or LO})
289 // makes subsequent MF{HI or LO} UNPREDICTABLE. (1)
291 // The following restrictions exist for MIPS I - MIPS III:
293 // MF{HI or LO} followed by MT{HI or LO} w/ less than 2 instructions
294 // in between makes MF UNPREDICTABLE. (2)
296 // MF{HI or LO} followed by OP {HI and LO} w/ less than 2 instructions
297 // in between makes MF UNPREDICTABLE. (3)
299 // On the r3900, restriction (2) is not present, and restriction (3) is not
300 // present for multiplication.
302 // Unfortunately, there seems to be some confusion about whether the last
303 // two restrictions should apply to "MIPS IV" as well. One edition of
304 // the MIPS IV ISA says they do, but references in later ISA documents
305 // suggest they don't.
307 // In reality, some MIPS IV parts, such as the VR5000 and VR5400, do have
308 // these restrictions, while others, like the VR5500, don't. To accomodate
309 // such differences, the MIPS IV and MIPS V version of these helper functions
310 // use auxillary routines to determine whether the restriction applies.
314 // Helper used by check_mt_hilo, check_mult_hilo, and check_div_hilo
315 // to check for restrictions (2) and (3) above.
317 :function:::int:check_mf_cycles:hilo_history *history, int64_t time, const char *new
319 if (history->mf.timestamp + 3 > time)
321 sim_engine_abort (SD, CPU, CIA, "HILO: %s: %s at 0x%08lx too close to MF at 0x%08lx\n",
322 itable[MY_INDEX].name,
324 (long) history->mf.cia);
333 // Check for restriction (2) above (for ISAs/processors that have it),
334 // and record timestamps for restriction (1) above.
336 :function:::int:check_mt_hilo:hilo_history *history
343 int64_t time = sim_events_time (SD);
344 int ok = check_mf_cycles (SD_, history, time, "MT");
345 history->mt.timestamp = time;
346 history->mt.cia = CIA;
350 :function:::int:check_mt_hilo:hilo_history *history
354 int64_t time = sim_events_time (SD);
355 int ok = (! MIPS_MACH_HAS_MT_HILO_HAZARD (SD)
356 || check_mf_cycles (SD_, history, time, "MT"));
357 history->mt.timestamp = time;
358 history->mt.cia = CIA;
362 :function:::int:check_mt_hilo:hilo_history *history
373 int64_t time = sim_events_time (SD);
374 history->mt.timestamp = time;
375 history->mt.cia = CIA;
382 // Check for restriction (1) above, and record timestamps for
383 // restriction (2) and (3) above.
385 :function:::int:check_mf_hilo:hilo_history *history, hilo_history *peer
403 int64_t time = sim_events_time (SD);
406 && peer->mt.timestamp > history->op.timestamp
407 && history->mt.timestamp < history->op.timestamp
408 && ! (history->mf.timestamp > history->op.timestamp
409 && history->mf.timestamp < peer->mt.timestamp)
410 && ! (peer->mf.timestamp > history->op.timestamp
411 && peer->mf.timestamp < peer->mt.timestamp))
413 /* The peer has been written to since the last OP yet we have
415 sim_engine_abort (SD, CPU, CIA, "HILO: %s: MF at 0x%08lx following OP at 0x%08lx corrupted by MT at 0x%08lx\n",
416 itable[MY_INDEX].name,
418 (long) history->op.cia,
419 (long) peer->mt.cia);
422 history->mf.timestamp = time;
423 history->mf.cia = CIA;
431 // Check for restriction (3) above (for ISAs/processors that have it)
432 // for MULT ops, and record timestamps for restriction (1) above.
434 :function:::int:check_mult_hilo:hilo_history *hi, hilo_history *lo
441 int64_t time = sim_events_time (SD);
442 int ok = (check_mf_cycles (SD_, hi, time, "OP")
443 && check_mf_cycles (SD_, lo, time, "OP"));
444 hi->op.timestamp = time;
445 lo->op.timestamp = time;
451 :function:::int:check_mult_hilo:hilo_history *hi, hilo_history *lo
455 int64_t time = sim_events_time (SD);
456 int ok = (! MIPS_MACH_HAS_MULT_HILO_HAZARD (SD)
457 || (check_mf_cycles (SD_, hi, time, "OP")
458 && check_mf_cycles (SD_, lo, time, "OP")));
459 hi->op.timestamp = time;
460 lo->op.timestamp = time;
466 :function:::int:check_mult_hilo:hilo_history *hi, hilo_history *lo
477 /* FIXME: could record the fact that a stall occured if we want */
478 int64_t time = sim_events_time (SD);
479 hi->op.timestamp = time;
480 lo->op.timestamp = time;
489 // Check for restriction (3) above (for ISAs/processors that have it)
490 // for DIV ops, and record timestamps for restriction (1) above.
492 :function:::int:check_div_hilo:hilo_history *hi, hilo_history *lo
500 int64_t time = sim_events_time (SD);
501 int ok = (check_mf_cycles (SD_, hi, time, "OP")
502 && check_mf_cycles (SD_, lo, time, "OP"));
503 hi->op.timestamp = time;
504 lo->op.timestamp = time;
510 :function:::int:check_div_hilo:hilo_history *hi, hilo_history *lo
514 int64_t time = sim_events_time (SD);
515 int ok = (! MIPS_MACH_HAS_DIV_HILO_HAZARD (SD)
516 || (check_mf_cycles (SD_, hi, time, "OP")
517 && check_mf_cycles (SD_, lo, time, "OP")));
518 hi->op.timestamp = time;
519 lo->op.timestamp = time;
525 :function:::int:check_div_hilo:hilo_history *hi, hilo_history *lo
535 int64_t time = sim_events_time (SD);
536 hi->op.timestamp = time;
537 lo->op.timestamp = time;
546 // Check that the 64-bit instruction can currently be used, and signal
547 // a ReservedInstruction exception if not.
550 :function:::void:check_u64:instruction_word insn
560 // The check should be similar to mips64 for any with PX/UX bit equivalents.
563 :function:::void:check_u64:instruction_word insn
574 #if 0 /* XXX FIXME: enable this only after some additional testing. */
575 if (UserMode && (SR & (status_UX|status_PX)) == 0)
576 SignalException (ReservedInstruction, insn);
583 // MIPS Architecture:
585 // CPU Instruction Set (mipsI - mipsV, mips32/r2, mips64/r2)
589 :function:::void:do_add:int rs, int rt, int rd
591 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
593 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
595 ALU32_BEGIN (GPR[rs]);
597 ALU32_END (GPR[rd]); /* This checks for overflow. */
599 TRACE_ALU_RESULT (GPR[rd]);
602 :function:::void:do_addi:int rs, int rt, uint16_t immediate
604 if (NotWordValue (GPR[rs]))
606 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
608 ALU32_BEGIN (GPR[rs]);
609 ALU32_ADD (EXTEND16 (immediate));
610 ALU32_END (GPR[rt]); /* This checks for overflow. */
612 TRACE_ALU_RESULT (GPR[rt]);
615 :function:::void:do_andi:int rs, int rt, unsigned int immediate
617 TRACE_ALU_INPUT2 (GPR[rs], immediate);
618 GPR[rt] = GPR[rs] & immediate;
619 TRACE_ALU_RESULT (GPR[rt]);
622 :function:::void:do_dadd:int rd, int rs, int rt
624 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
626 ALU64_BEGIN (GPR[rs]);
628 ALU64_END (GPR[rd]); /* This checks for overflow. */
630 TRACE_ALU_RESULT (GPR[rd]);
633 :function:::void:do_daddi:int rt, int rs, int immediate
635 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
637 ALU64_BEGIN (GPR[rs]);
638 ALU64_ADD (EXTEND16 (immediate));
639 ALU64_END (GPR[rt]); /* This checks for overflow. */
641 TRACE_ALU_RESULT (GPR[rt]);
644 :function:::void:do_dsll32:int rd, int rt, int shift
647 TRACE_ALU_INPUT2 (GPR[rt], s);
648 GPR[rd] = GPR[rt] << s;
649 TRACE_ALU_RESULT (GPR[rd]);
652 :function:::void:do_dsra32:int rd, int rt, int shift
655 TRACE_ALU_INPUT2 (GPR[rt], s);
656 GPR[rd] = ((int64_t) GPR[rt]) >> s;
657 TRACE_ALU_RESULT (GPR[rd]);
660 :function:::void:do_dsrl32:int rd, int rt, int shift
663 TRACE_ALU_INPUT2 (GPR[rt], s);
664 GPR[rd] = (uint64_t) GPR[rt] >> s;
665 TRACE_ALU_RESULT (GPR[rd]);
668 :function:::void:do_dsub:int rd, int rs, int rt
670 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
672 ALU64_BEGIN (GPR[rs]);
674 ALU64_END (GPR[rd]); /* This checks for overflow. */
676 TRACE_ALU_RESULT (GPR[rd]);
679 :function:::void:do_break:address_word instruction_0
681 /* Check for some break instruction which are reserved for use by the
683 unsigned int break_code = instruction_0 & HALT_INSTRUCTION_MASK;
684 if (break_code == (HALT_INSTRUCTION & HALT_INSTRUCTION_MASK) ||
685 break_code == (HALT_INSTRUCTION2 & HALT_INSTRUCTION_MASK))
687 sim_engine_halt (SD, CPU, NULL, cia,
688 sim_exited, (unsigned int)(A0 & 0xFFFFFFFF));
690 else if (break_code == (BREAKPOINT_INSTRUCTION & HALT_INSTRUCTION_MASK) ||
691 break_code == (BREAKPOINT_INSTRUCTION2 & HALT_INSTRUCTION_MASK))
693 if (STATE & simDELAYSLOT)
694 PC = cia - 4; /* reference the branch instruction */
697 SignalException (BreakPoint, instruction_0);
702 /* If we get this far, we're not an instruction reserved by the sim. Raise
704 SignalException (BreakPoint, instruction_0);
708 :function:::void:do_break16:address_word instruction_0
710 if (STATE & simDELAYSLOT)
711 PC = cia - 2; /* reference the branch instruction */
714 SignalException (BreakPoint, instruction_0);
717 :function:::void:do_clo:int rd, int rs
719 uint32_t temp = GPR[rs];
721 if (NotWordValue (GPR[rs]))
723 TRACE_ALU_INPUT1 (GPR[rs]);
724 for (mask = ((uint32_t)1<<31), i = 0; i < 32; ++i)
726 if ((temp & mask) == 0)
730 GPR[rd] = EXTEND32 (i);
731 TRACE_ALU_RESULT (GPR[rd]);
734 :function:::void:do_clz:int rd, int rs
736 uint32_t temp = GPR[rs];
738 if (NotWordValue (GPR[rs]))
740 TRACE_ALU_INPUT1 (GPR[rs]);
741 for (mask = ((uint32_t)1<<31), i = 0; i < 32; ++i)
743 if ((temp & mask) != 0)
747 GPR[rd] = EXTEND32 (i);
748 TRACE_ALU_RESULT (GPR[rd]);
751 :function:::void:do_dclo:int rd, int rs
753 uint64_t temp = GPR[rs];
756 TRACE_ALU_INPUT1 (GPR[rs]);
757 for (mask = ((uint64_t)1<<63), i = 0; i < 64; ++i)
759 if ((temp & mask) == 0)
763 GPR[rd] = EXTEND32 (i);
764 TRACE_ALU_RESULT (GPR[rd]);
767 :function:::void:do_dclz:int rd, int rs
769 uint64_t temp = GPR[rs];
772 TRACE_ALU_INPUT1 (GPR[rs]);
773 for (mask = ((uint64_t)1<<63), i = 0; i < 64; ++i)
775 if ((temp & mask) != 0)
779 GPR[rd] = EXTEND32 (i);
780 TRACE_ALU_RESULT (GPR[rd]);
783 :function:::void:do_lb:int rt, int offset, int base
785 GPR[rt] = EXTEND8 (do_load (SD_, AccessLength_BYTE, GPR[base],
789 :function:::void:do_lh:int rt, int offset, int base
791 GPR[rt] = EXTEND16 (do_load (SD_, AccessLength_HALFWORD, GPR[base],
795 :function:::void:do_lwr:int rt, int offset, int base
797 GPR[rt] = EXTEND32 (do_load_right (SD_, AccessLength_WORD, GPR[base],
798 EXTEND16 (offset), GPR[rt]));
801 :function:::void:do_lwl:int rt, int offset, int base
803 GPR[rt] = EXTEND32 (do_load_left (SD_, AccessLength_WORD, GPR[base],
804 EXTEND16 (offset), GPR[rt]));
807 :function:::void:do_lwc:int num, int rt, int offset, int base
809 COP_LW (num, rt, do_load (SD_, AccessLength_WORD, GPR[base],
813 :function:::void:do_lw:int rt, int offset, int base
815 GPR[rt] = EXTEND32 (do_load (SD_, AccessLength_WORD, GPR[base],
819 :function:::void:do_lwu:int rt, int offset, int base, address_word instruction_0
821 check_u64 (SD_, instruction_0);
822 GPR[rt] = do_load (SD_, AccessLength_WORD, GPR[base], EXTEND16 (offset));
825 :function:::void:do_lhu:int rt, int offset, int base
827 GPR[rt] = do_load (SD_, AccessLength_HALFWORD, GPR[base], EXTEND16 (offset));
830 :function:::void:do_ldc:int num, int rt, int offset, int base
832 COP_LD (num, rt, do_load (SD_, AccessLength_DOUBLEWORD, GPR[base],
836 :function:::void:do_lbu:int rt, int offset, int base
838 GPR[rt] = do_load (SD_, AccessLength_BYTE, GPR[base], EXTEND16 (offset));
841 :function:::void:do_ll:int rt, int insn_offset, int basereg
843 address_word base = GPR[basereg];
844 address_word offset = EXTEND16 (insn_offset);
846 address_word vaddr = loadstore_ea (SD_, base, offset);
847 address_word paddr = vaddr;
848 if ((vaddr & 3) != 0)
850 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 4, vaddr, read_transfer,
851 sim_core_unaligned_signal);
856 uint64_t memval1 = 0;
857 uint64_t mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
858 unsigned int shift = 2;
859 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
860 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
862 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
863 LoadMemory (&memval, &memval1, AccessLength_WORD, paddr, vaddr,
865 byte = ((vaddr & mask) ^ (bigend << shift));
866 GPR[rt] = EXTEND32 (memval >> (8 * byte));
872 :function:::void:do_lld:int rt, int roffset, int rbase
874 address_word base = GPR[rbase];
875 address_word offset = EXTEND16 (roffset);
877 address_word vaddr = loadstore_ea (SD_, base, offset);
878 address_word paddr = vaddr;
880 if ((vaddr & 7) != 0)
882 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 8, vaddr, read_transfer,
883 sim_core_unaligned_signal);
888 uint64_t memval1 = 0;
889 LoadMemory (&memval, &memval1, AccessLength_DOUBLEWORD, paddr, vaddr,
897 :function:::void:do_lui:int rt, int immediate
899 TRACE_ALU_INPUT1 (immediate);
900 GPR[rt] = EXTEND32 (immediate << 16);
901 TRACE_ALU_RESULT (GPR[rt]);
904 :function:::void:do_madd:int rs, int rt
907 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
908 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
910 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
911 temp = (U8_4 (VL4_8 (HI), VL4_8 (LO))
912 + ((int64_t) EXTEND32 (GPR[rt]) * (int64_t) EXTEND32 (GPR[rs])));
913 LO = EXTEND32 (temp);
914 HI = EXTEND32 (VH4_8 (temp));
915 TRACE_ALU_RESULT2 (HI, LO);
918 :function:::void:do_dsp_madd:int ac, int rs, int rt
922 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
923 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
925 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
926 temp = (U8_4 (VL4_8 (DSPHI(ac)), VL4_8 (DSPLO(ac)))
927 + ((int64_t) EXTEND32 (GPR[rt]) * (int64_t) EXTEND32 (GPR[rs])));
928 DSPLO(ac) = EXTEND32 (temp);
929 DSPHI(ac) = EXTEND32 (VH4_8 (temp));
931 TRACE_ALU_RESULT2 (HI, LO);
934 :function:::void:do_maddu:int rs, int rt
937 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
938 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
940 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
941 temp = (U8_4 (VL4_8 (HI), VL4_8 (LO))
942 + ((uint64_t) VL4_8 (GPR[rs]) * (uint64_t) VL4_8 (GPR[rt])));
943 ACX += U8_4 (VL4_8 (HI), VL4_8 (LO)) < temp; /* SmartMIPS */
944 LO = EXTEND32 (temp);
945 HI = EXTEND32 (VH4_8 (temp));
946 TRACE_ALU_RESULT2 (HI, LO);
949 :function:::void:do_dsp_maddu:int ac, int rs, int rt
953 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
954 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
956 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
957 temp = (U8_4 (VL4_8 (DSPHI(ac)), VL4_8 (DSPLO(ac)))
958 + ((uint64_t) VL4_8 (GPR[rs]) * (uint64_t) VL4_8 (GPR[rt])));
960 ACX += U8_4 (VL4_8 (HI), VL4_8 (LO)) < temp; /* SmartMIPS */
961 DSPLO(ac) = EXTEND32 (temp);
962 DSPHI(ac) = EXTEND32 (VH4_8 (temp));
964 TRACE_ALU_RESULT2 (HI, LO);
967 :function:::void:do_dsp_mfhi:int ac, int rd
975 :function:::void:do_dsp_mflo:int ac, int rd
983 :function:::void:do_movn:int rd, int rs, int rt
988 TRACE_ALU_RESULT (GPR[rd]);
992 :function:::void:do_movz:int rd, int rs, int rt
997 TRACE_ALU_RESULT (GPR[rd]);
1001 :function:::void:do_msub:int rs, int rt
1004 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1005 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
1007 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1008 temp = (U8_4 (VL4_8 (HI), VL4_8 (LO))
1009 - ((int64_t) EXTEND32 (GPR[rt]) * (int64_t) EXTEND32 (GPR[rs])));
1010 LO = EXTEND32 (temp);
1011 HI = EXTEND32 (VH4_8 (temp));
1012 TRACE_ALU_RESULT2 (HI, LO);
1015 :function:::void:do_dsp_msub:int ac, int rs, int rt
1019 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1020 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
1022 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1023 temp = (U8_4 (VL4_8 (DSPHI(ac)), VL4_8 (DSPLO(ac)))
1024 - ((int64_t) EXTEND32 (GPR[rt]) * (int64_t) EXTEND32 (GPR[rs])));
1025 DSPLO(ac) = EXTEND32 (temp);
1026 DSPHI(ac) = EXTEND32 (VH4_8 (temp));
1028 TRACE_ALU_RESULT2 (HI, LO);
1031 :function:::void:do_msubu:int rs, int rt
1034 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1035 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
1037 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1038 temp = (U8_4 (VL4_8 (HI), VL4_8 (LO))
1039 - ((uint64_t) VL4_8 (GPR[rs]) * (uint64_t) VL4_8 (GPR[rt])));
1040 LO = EXTEND32 (temp);
1041 HI = EXTEND32 (VH4_8 (temp));
1042 TRACE_ALU_RESULT2 (HI, LO);
1045 :function:::void:do_dsp_msubu:int ac, int rs, int rt
1049 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1050 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
1052 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1053 temp = (U8_4 (VL4_8 (DSPHI(ac)), VL4_8 (DSPLO(ac)))
1054 - ((uint64_t) VL4_8 (GPR[rs]) * (uint64_t) VL4_8 (GPR[rt])));
1055 DSPLO(ac) = EXTEND32 (temp);
1056 DSPHI(ac) = EXTEND32 (VH4_8 (temp));
1058 TRACE_ALU_RESULT2 (HI, LO);
1061 :function:::void:do_mthi:int rs
1063 check_mt_hilo (SD_, HIHISTORY);
1067 :function:::void:do_dsp_mthi:int ac, int rs
1070 check_mt_hilo (SD_, HIHISTORY);
1071 DSPHI(ac) = GPR[rs];
1074 :function:::void:do_mtlo:int rs
1076 check_mt_hilo (SD_, LOHISTORY);
1080 :function:::void:do_dsp_mtlo:int ac, int rs
1083 check_mt_hilo (SD_, LOHISTORY);
1084 DSPLO(ac) = GPR[rs];
1087 :function:::void:do_mul:int rd, int rs, int rt
1090 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
1092 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1093 prod = (((int64_t)(int32_t) GPR[rs])
1094 * ((int64_t)(int32_t) GPR[rt]));
1095 GPR[rd] = EXTEND32 (VL4_8 (prod));
1096 TRACE_ALU_RESULT (GPR[rd]);
1099 :function:::void:do_dsp_mult:int ac, int rs, int rt
1103 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1104 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
1106 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1107 prod = ((int64_t)(int32_t) GPR[rs])
1108 * ((int64_t)(int32_t) GPR[rt]);
1109 DSPLO(ac) = EXTEND32 (VL4_8 (prod));
1110 DSPHI(ac) = EXTEND32 (VH4_8 (prod));
1113 ACX = 0; /* SmartMIPS */
1114 TRACE_ALU_RESULT2 (HI, LO);
1118 :function:::void:do_dsp_multu:int ac, int rs, int rt
1122 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1123 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
1125 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1126 prod = ((uint64_t)(uint32_t) GPR[rs])
1127 * ((uint64_t)(uint32_t) GPR[rt]);
1128 DSPLO(ac) = EXTEND32 (VL4_8 (prod));
1129 DSPHI(ac) = EXTEND32 (VH4_8 (prod));
1131 TRACE_ALU_RESULT2 (HI, LO);
1134 :function:::void:do_pref:int hint, int insn_offset, int insn_base
1137 address_word base = GPR[insn_base];
1138 address_word offset = EXTEND16 (insn_offset);
1139 address_word vaddr = loadstore_ea (SD_, base, offset);
1140 address_word paddr = vaddr;
1141 Prefetch (paddr, vaddr, isDATA, hint);
1145 :function:::void:do_sc:int rt, int offsetarg, int basereg, address_word instruction_0, int store_ll_bit
1147 address_word base = GPR[basereg];
1148 address_word offset = EXTEND16 (offsetarg);
1150 address_word vaddr = loadstore_ea (SD_, base, offset);
1151 address_word paddr = vaddr;
1153 if ((vaddr & 3) != 0)
1155 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 4, vaddr, write_transfer,
1156 sim_core_unaligned_signal);
1160 uint64_t memval = 0;
1161 uint64_t memval1 = 0;
1162 uint64_t mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1163 address_word reverseendian =
1164 (ReverseEndian ? (mask ^ AccessLength_WORD) : 0);
1165 address_word bigendiancpu =
1166 (BigEndianCPU ? (mask ^ AccessLength_WORD) : 0);
1168 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
1169 byte = ((vaddr & mask) ^ bigendiancpu);
1170 memval = ((uint64_t) GPR[rt] << (8 * byte));
1172 StoreMemory (AccessLength_WORD, memval, memval1, paddr, vaddr,
1180 :function:::void:do_scd:int rt, int roffset, int rbase, int store_ll_bit
1182 address_word base = GPR[rbase];
1183 address_word offset = EXTEND16 (roffset);
1185 address_word vaddr = loadstore_ea (SD_, base, offset);
1186 address_word paddr = vaddr;
1188 if ((vaddr & 7) != 0)
1190 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 8, vaddr, write_transfer,
1191 sim_core_unaligned_signal);
1195 uint64_t memval = 0;
1196 uint64_t memval1 = 0;
1199 StoreMemory (AccessLength_DOUBLEWORD, memval, memval1, paddr, vaddr,
1207 :function:::void:do_sub:int rs, int rt, int rd
1209 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
1211 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1213 ALU32_BEGIN (GPR[rs]);
1214 ALU32_SUB (GPR[rt]);
1215 ALU32_END (GPR[rd]); /* This checks for overflow. */
1217 TRACE_ALU_RESULT (GPR[rd]);
1220 :function:::void:do_sw:int rt, int offset, int base
1222 do_store (SD_, AccessLength_WORD, GPR[base], EXTEND16 (offset), GPR[rt]);
1225 :function:::void:do_teq:int rs, int rt, address_word instruction_0
1227 if ((signed_word) GPR[rs] == (signed_word) GPR[rt])
1228 SignalException (Trap, instruction_0);
1231 :function:::void:do_teqi:int rs, int immediate, address_word instruction_0
1233 if ((signed_word) GPR[rs] == (signed_word) EXTEND16 (immediate))
1234 SignalException (Trap, instruction_0);
1237 :function:::void:do_tge:int rs, int rt, address_word instruction_0
1239 if ((signed_word) GPR[rs] >= (signed_word) GPR[rt])
1240 SignalException (Trap, instruction_0);
1243 :function:::void:do_tgei:int rs, int immediate, address_word instruction_0
1245 if ((signed_word) GPR[rs] >= (signed_word) EXTEND16 (immediate))
1246 SignalException (Trap, instruction_0);
1249 :function:::void:do_tgeiu:int rs, int immediate, address_word instruction_0
1251 if ((unsigned_word) GPR[rs] >= (unsigned_word) EXTEND16 (immediate))
1252 SignalException (Trap, instruction_0);
1255 :function:::void:do_tgeu:int rs ,int rt, address_word instruction_0
1257 if ((unsigned_word) GPR[rs] >= (unsigned_word) GPR[rt])
1258 SignalException (Trap, instruction_0);
1261 :function:::void:do_tlt:int rs, int rt, address_word instruction_0
1263 if ((signed_word) GPR[rs] < (signed_word) GPR[rt])
1264 SignalException (Trap, instruction_0);
1267 :function:::void:do_tlti:int rs, int immediate, address_word instruction_0
1269 if ((signed_word) GPR[rs] < (signed_word) EXTEND16 (immediate))
1270 SignalException (Trap, instruction_0);
1273 :function:::void:do_tltiu:int rs, int immediate, address_word instruction_0
1275 if ((unsigned_word) GPR[rs] < (unsigned_word) EXTEND16 (immediate))
1276 SignalException (Trap, instruction_0);
1279 :function:::void:do_tltu:int rs, int rt, address_word instruction_0
1281 if ((unsigned_word) GPR[rs] < (unsigned_word) GPR[rt])
1282 SignalException (Trap, instruction_0);
1285 :function:::void:do_tne:int rs, int rt, address_word instruction_0
1287 if ((signed_word) GPR[rs] != (signed_word) GPR[rt])
1288 SignalException (Trap, instruction_0);
1291 :function:::void:do_tnei:int rs, int immediate, address_word instruction_0
1293 if ((signed_word) GPR[rs] != (signed_word) EXTEND16 (immediate))
1294 SignalException (Trap, instruction_0);
1297 :function:::void:do_abs_fmt:int fmt, int fd, int fs, address_word instruction_0
1300 check_fmt_p (SD_, fmt, instruction_0);
1301 StoreFPR (fd, fmt, AbsoluteValue (ValueFPR (fs, fmt), fmt));
1304 :function:::void:do_add_fmt:int fmt, int fd, int fs, int ft, address_word instruction_0
1307 check_fmt_p (SD_, fmt, instruction_0);
1308 StoreFPR (fd, fmt, Add (ValueFPR (fs, fmt), ValueFPR (ft, fmt), fmt));
1311 :function:::void:do_alnv_ps:int fd, int fs, int ft, int rs, address_word instruction_0
1317 check_u64 (SD_, instruction_0);
1318 fsx = ValueFPR (fs, fmt_ps);
1319 if ((GPR[rs] & 0x3) != 0)
1321 if ((GPR[rs] & 0x4) == 0)
1325 ftx = ValueFPR (ft, fmt_ps);
1327 fdx = PackPS (PSLower (fsx), PSUpper (ftx));
1329 fdx = PackPS (PSLower (ftx), PSUpper (fsx));
1331 StoreFPR (fd, fmt_ps, fdx);
1334 :function:::void:do_c_cond_fmt:int cond, int fmt, int cc, int fs, int ft, address_word instruction_0
1337 check_fmt_p (SD_, fmt, instruction_0);
1338 Compare (ValueFPR (fs, fmt), ValueFPR (ft, fmt), fmt, cond, cc);
1339 TRACE_ALU_RESULT (ValueFCR (31));
1342 :function:::void:do_ceil_fmt:int type, int fmt, int fd, int fs, address_word instruction_0
1345 check_fmt_p (SD_, fmt, instruction_0);
1346 StoreFPR (fd, type, Convert (FP_RM_TOPINF, ValueFPR (fs, fmt), fmt,
1350 :function:::void:do_cfc1:int rt, int fs
1353 if (fs == 0 || fs == 25 || fs == 26 || fs == 28 || fs == 31)
1355 unsigned_word fcr = ValueFCR (fs);
1356 TRACE_ALU_INPUT1 (fcr);
1360 TRACE_ALU_RESULT (GPR[rt]);
1363 :function:::void:do_ctc1:int rt, int fs
1366 TRACE_ALU_INPUT1 (GPR[rt]);
1367 if (fs == 25 || fs == 26 || fs == 28 || fs == 31)
1368 StoreFCR (fs, GPR[rt]);
1372 :function:::void:do_cvt_d_fmt:int fmt, int fd, int fs, address_word instruction_0
1375 if ((fmt == fmt_double) | 0)
1376 SignalException (ReservedInstruction, instruction_0);
1377 StoreFPR (fd, fmt_double, Convert (GETRM (), ValueFPR (fs, fmt), fmt,
1381 :function:::void:do_cvt_l_fmt:int fmt, int fd, int fs, address_word instruction_0
1384 if ((fmt == fmt_long) | ((fmt == fmt_long) || (fmt == fmt_word)))
1385 SignalException (ReservedInstruction, instruction_0);
1386 StoreFPR (fd, fmt_long, Convert (GETRM (), ValueFPR (fs, fmt), fmt,
1390 :function:::void:do_cvt_ps_s:int fd, int fs, int ft, address_word instruction_0
1393 check_u64 (SD_, instruction_0);
1394 StoreFPR (fd, fmt_ps, PackPS (ValueFPR (fs, fmt_single),
1395 ValueFPR (ft, fmt_single)));
1398 :function:::void:do_cvt_s_fmt:int fmt, int fd, int fs, address_word instruction_0
1401 if ((fmt == fmt_single) | 0)
1402 SignalException (ReservedInstruction, instruction_0);
1403 StoreFPR (fd, fmt_single, Convert (GETRM (), ValueFPR (fs, fmt), fmt,
1407 :function:::void:do_cvt_s_pl:int fd, int fs, address_word instruction_0
1410 check_u64 (SD_, instruction_0);
1411 StoreFPR (fd, fmt_single, PSLower (ValueFPR (fs, fmt_ps)));
1414 :function:::void:do_cvt_s_pu:int fd, int fs, address_word instruction_0
1417 check_u64 (SD_, instruction_0);
1418 StoreFPR (fd, fmt_single, PSUpper (ValueFPR (fs, fmt_ps)));
1421 :function:::void:do_cvt_w_fmt:int fmt, int fd, int fs, address_word instruction_0
1424 if ((fmt == fmt_word) | ((fmt == fmt_long) || (fmt == fmt_word)))
1425 SignalException (ReservedInstruction, instruction_0);
1426 StoreFPR (fd, fmt_word, Convert (GETRM (), ValueFPR (fs, fmt), fmt,
1430 :function:::void:do_div_fmt:int fmt, int fd, int fs, int ft, address_word instruction_0
1433 StoreFPR (fd, fmt, Divide (ValueFPR (fs, fmt), ValueFPR (ft, fmt), fmt));
1436 :function:::void:do_dmfc1b:int rt, int fs
1447 if (SizeFGR () == 64)
1449 else if ((fs & 0x1) == 0)
1450 GPR[rt] = SET64HI (FGR[fs+1]) | FGR[fs];
1453 TRACE_ALU_RESULT (GPR[rt]);
1456 :function:::void:do_dmtc1b:int rt, int fs
1458 if (SizeFGR () == 64)
1459 StoreFPR (fs, fmt_uninterpreted_64, GPR[rt]);
1460 else if ((fs & 0x1) == 0)
1461 StoreFPR (fs, fmt_uninterpreted_64, GPR[rt]);
1466 :function:::void:do_floor_fmt:int type, int fmt, int fd, int fs
1469 StoreFPR (fd, type, Convert (FP_RM_TOMINF, ValueFPR (fs, fmt), fmt,
1473 :function:::void:do_luxc1_32:int fd, int rindex, int rbase
1477 address_word base = GPR[rbase];
1478 address_word index = GPR[rindex];
1479 address_word vaddr = base + index;
1481 if (SizeFGR () != 64)
1483 /* Arrange for the bottom 3 bits of (base + index) to be 0. */
1484 if ((vaddr & 0x7) != 0)
1485 index -= (vaddr & 0x7);
1486 COP_LD (1, fd, do_load_double (SD_, base, index));
1489 :function:::void:do_luxc1_64:int fd, int rindex, int rbase
1491 address_word base = GPR[rbase];
1492 address_word index = GPR[rindex];
1493 address_word vaddr = base + index;
1494 if (SizeFGR () != 64)
1496 /* Arrange for the bottom 3 bits of (base + index) to be 0. */
1497 if ((vaddr & 0x7) != 0)
1498 index -= (vaddr & 0x7);
1499 COP_LD (1, fd, do_load (SD_, AccessLength_DOUBLEWORD, base, index));
1503 :function:::void:do_lwc1:int ft, int offset, int base
1506 COP_LW (1, ft, do_load (SD_, AccessLength_WORD, GPR[base],
1507 EXTEND16 (offset)));
1510 :function:::void:do_lwxc1:int fd, int index, int base, address_word instruction_0
1513 check_u64 (SD_, instruction_0);
1514 COP_LW (1, fd, do_load (SD_, AccessLength_WORD, GPR[base], GPR[index]));
1517 :function:::void:do_madd_fmt:int fmt, int fd, int fr, int fs, int ft, address_word instruction_0
1520 check_u64 (SD_, instruction_0);
1521 check_fmt_p (SD_, fmt, instruction_0);
1522 StoreFPR (fd, fmt, MultiplyAdd (ValueFPR (fs, fmt), ValueFPR (ft, fmt),
1523 ValueFPR (fr, fmt), fmt));
1526 :function:::void:do_mfc1b:int rt, int fs
1529 GPR[rt] = EXTEND32 (FGR[fs]);
1530 TRACE_ALU_RESULT (GPR[rt]);
1533 :function:::void:do_mov_fmt:int fmt, int fd, int fs, address_word instruction_0
1536 check_fmt_p (SD_, fmt, instruction_0);
1537 StoreFPR (fd, fmt, ValueFPR (fs, fmt));
1540 :function:::void:do_movtf:int tf, int rd, int rs, int cc
1543 if (GETFCC(cc) == tf)
1547 :function:::void:do_movtf_fmt:int tf, int fmt, int fd, int fs, int cc
1552 if (GETFCC(cc) == tf)
1553 StoreFPR (fd, fmt, ValueFPR (fs, fmt));
1555 StoreFPR (fd, fmt, ValueFPR (fd, fmt)); /* set fmt */
1560 fdx = PackPS (PSUpper (ValueFPR ((GETFCC (cc+1) == tf) ? fs : fd,
1562 PSLower (ValueFPR ((GETFCC (cc+0) == tf) ? fs : fd,
1564 StoreFPR (fd, fmt_ps, fdx);
1568 :function:::void:do_movn_fmt:int fmt, int fd, int fs, int rt
1572 StoreFPR (fd, fmt, ValueFPR (fs, fmt));
1574 StoreFPR (fd, fmt, ValueFPR (fd, fmt));
1577 :function:::void:do_movz_fmt:int fmt, int fd, int fs, int rt
1581 StoreFPR (fd, fmt, ValueFPR (fs, fmt));
1583 StoreFPR (fd, fmt, ValueFPR (fd, fmt));
1586 :function:::void:do_msub_fmt:int fmt, int fd, int fr, int fs, int ft, address_word instruction_0
1589 check_u64 (SD_, instruction_0);
1590 check_fmt_p (SD_, fmt, instruction_0);
1591 StoreFPR (fd, fmt, MultiplySub (ValueFPR (fs, fmt), ValueFPR (ft, fmt),
1592 ValueFPR (fr, fmt), fmt));
1595 :function:::void:do_mtc1b:int rt, int fs
1598 StoreFPR (fs, fmt_uninterpreted_32, VL4_8 (GPR[rt]));
1601 :function:::void:do_mul_fmt:int fmt, int fd, int fs, int ft, address_word instruction_0
1604 check_fmt_p (SD_, fmt, instruction_0);
1605 StoreFPR (fd, fmt, Multiply (ValueFPR (fs, fmt), ValueFPR (ft, fmt), fmt));
1608 :function:::void:do_neg_fmt:int fmt, int fd, int fs, address_word instruction_0
1611 check_fmt_p (SD_, fmt, instruction_0);
1612 StoreFPR (fd, fmt, Negate (ValueFPR (fs, fmt), fmt));
1615 :function:::void:do_nmadd_fmt:int fmt, int fd, int fr, int fs, int ft, address_word instruction_0
1618 check_u64 (SD_, instruction_0);
1619 check_fmt_p (SD_, fmt, instruction_0);
1620 StoreFPR (fd, fmt, NegMultiplyAdd (ValueFPR (fs, fmt), ValueFPR (ft, fmt),
1621 ValueFPR (fr, fmt), fmt));
1624 :function:::void:do_nmsub_fmt:int fmt, int fd, int fr, int fs, int ft, address_word instruction_0
1627 check_u64 (SD_, instruction_0);
1628 check_fmt_p (SD_, fmt, instruction_0);
1629 StoreFPR (fd, fmt, NegMultiplySub (ValueFPR (fs, fmt), ValueFPR (ft, fmt),
1630 ValueFPR (fr, fmt), fmt));
1633 :function:::void:do_pll_ps:int fd, int fs, int ft, address_word instruction_0
1636 check_u64 (SD_, instruction_0);
1637 StoreFPR (fd, fmt_ps, PackPS (PSLower (ValueFPR (fs, fmt_ps)),
1638 PSLower (ValueFPR (ft, fmt_ps))));
1641 :function:::void:do_plu_ps:int fd, int fs, int ft, address_word instruction_0
1644 check_u64 (SD_, instruction_0);
1645 StoreFPR (fd, fmt_ps, PackPS (PSLower (ValueFPR (fs, fmt_ps)),
1646 PSUpper (ValueFPR (ft, fmt_ps))));
1649 :function:::void:do_pul_ps:int fd, int fs, int ft, address_word instruction_0
1652 check_u64 (SD_, instruction_0);
1653 StoreFPR (fd, fmt_ps, PackPS (PSUpper (ValueFPR (fs, fmt_ps)),
1654 PSLower (ValueFPR (ft, fmt_ps))));
1657 :function:::void:do_puu_ps:int fd, int fs, int ft, address_word instruction_0
1660 check_u64 (SD_, instruction_0);
1661 StoreFPR (fd, fmt_ps, PackPS (PSUpper (ValueFPR (fs, fmt_ps)),
1662 PSUpper (ValueFPR (ft, fmt_ps))));
1665 :function:::void:do_recip_fmt:int fmt, int fd, int fs
1668 StoreFPR (fd, fmt, Recip (ValueFPR (fs, fmt), fmt));
1671 :function:::void:do_round_fmt:int type, int fmt, int fd, int fs
1674 StoreFPR (fd, type, Convert (FP_RM_NEAREST, ValueFPR (fs, fmt), fmt,
1678 :function:::void:do_rsqrt_fmt:int fmt, int fd, int fs
1681 StoreFPR (fd, fmt, RSquareRoot (ValueFPR (fs, fmt), fmt));
1684 :function:::void:do_prefx:int hint, int rindex, int rbase
1687 address_word base = GPR[rbase];
1688 address_word index = GPR[rindex];
1689 address_word vaddr = loadstore_ea (SD_, base, index);
1690 address_word paddr = vaddr;
1691 Prefetch (paddr, vaddr, isDATA, hint);
1695 :function:::void:do_sdc1:int ft, int offset, int base
1703 do_store_double (SD_, GPR[base], EXTEND16 (offset), COP_SD (1, ft));
1706 :function:::void:do_suxc1_32:int fs, int rindex, int rbase
1710 address_word base = GPR[rbase];
1711 address_word index = GPR[rindex];
1712 address_word vaddr = base + index;
1714 if (SizeFGR () != 64)
1716 /* Arrange for the bottom 3 bits of (base + index) to be 0. */
1717 if ((vaddr & 0x7) != 0)
1718 index -= (vaddr & 0x7);
1719 do_store_double (SD_, base, index, COP_SD (1, fs));
1722 :function:::void:do_suxc1_64:int fs, int rindex, int rbase
1724 address_word base = GPR[rbase];
1725 address_word index = GPR[rindex];
1726 address_word vaddr = base + index;
1727 if (SizeFGR () != 64)
1729 /* Arrange for the bottom 3 bits of (base + index) to be 0. */
1730 if ((vaddr & 0x7) != 0)
1731 index -= (vaddr & 0x7);
1732 do_store (SD_, AccessLength_DOUBLEWORD, base, index, COP_SD (1, fs));
1735 :function:::void:do_sqrt_fmt:int fmt, int fd, int fs
1738 StoreFPR (fd, fmt, (SquareRoot (ValueFPR (fs, fmt), fmt)));
1741 :function:::void:do_sub_fmt:int fmt, int fd, int fs, int ft, address_word instruction_0
1744 check_fmt_p (SD_, fmt, instruction_0);
1745 StoreFPR (fd, fmt, Sub (ValueFPR (fs, fmt), ValueFPR (ft, fmt), fmt));
1748 :function:::void:do_swc1:int ft, int roffset, int rbase, address_word instruction_0
1750 address_word base = GPR[rbase];
1751 address_word offset = EXTEND16 (roffset);
1754 address_word vaddr = loadstore_ea (SD_, base, offset);
1755 address_word paddr = vaddr;
1757 if ((vaddr & 3) != 0)
1759 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, AccessLength_WORD+1, vaddr,
1760 write_transfer, sim_core_unaligned_signal);
1765 uword64 memval1 = 0;
1766 uword64 mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1767 address_word reverseendian =
1768 (ReverseEndian ? (mask ^ AccessLength_WORD) : 0);
1769 address_word bigendiancpu =
1770 (BigEndianCPU ? (mask ^ AccessLength_WORD) : 0);
1772 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
1773 byte = ((vaddr & mask) ^ bigendiancpu);
1774 memval = (((uword64)COP_SW(1, ft)) << (8 * byte));
1775 StoreMemory (AccessLength_WORD, memval, memval1, paddr, vaddr, isREAL);
1780 :function:::void:do_swxc1:int fs, int rindex, int rbase, address_word instruction_0
1782 address_word base = GPR[rbase];
1783 address_word index = GPR[rindex];
1785 check_u64 (SD_, instruction_0);
1787 address_word vaddr = loadstore_ea (SD_, base, index);
1788 address_word paddr = vaddr;
1790 if ((vaddr & 3) != 0)
1792 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 4, vaddr, write_transfer,
1793 sim_core_unaligned_signal);
1797 uint64_t memval = 0;
1798 uint64_t memval1 = 0;
1799 uint64_t mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1800 address_word reverseendian =
1801 (ReverseEndian ? (mask ^ AccessLength_WORD) : 0);
1802 address_word bigendiancpu =
1803 (BigEndianCPU ? (mask ^ AccessLength_WORD) : 0);
1805 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
1806 byte = ((vaddr & mask) ^ bigendiancpu);
1807 memval = (((uint64_t)COP_SW(1,fs)) << (8 * byte));
1808 StoreMemory (AccessLength_WORD, memval, memval1, paddr, vaddr,
1814 :function:::void:do_trunc_fmt:int type, int fmt, int fd, int fs
1817 StoreFPR (fd, type, Convert (FP_RM_TOZERO, ValueFPR (fs, fmt), fmt,
1821 000000,5.RS,5.RT,5.RD,00000,100000:SPECIAL:32::ADD
1822 "add r<RD>, r<RS>, r<RT>"
1838 do_add (SD_, RS, RT, RD);
1843 001000,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDI
1844 "addi r<RT>, r<RS>, <IMMEDIATE>"
1858 do_addi (SD_, RS, RT, IMMEDIATE);
1863 :function:::void:do_addiu:int rs, int rt, uint16_t immediate
1865 if (NotWordValue (GPR[rs]))
1867 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
1868 GPR[rt] = EXTEND32 (GPR[rs] + EXTEND16 (immediate));
1869 TRACE_ALU_RESULT (GPR[rt]);
1872 001001,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDIU
1873 "addiu r<RT>, r<RS>, <IMMEDIATE>"
1889 do_addiu (SD_, RS, RT, IMMEDIATE);
1894 :function:::void:do_addu:int rs, int rt, int rd
1896 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
1898 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1899 GPR[rd] = EXTEND32 (GPR[rs] + GPR[rt]);
1900 TRACE_ALU_RESULT (GPR[rd]);
1903 000000,5.RS,5.RT,5.RD,00000,100001:SPECIAL:32::ADDU
1904 "addu r<RD>, r<RS>, r<RT>"
1920 do_addu (SD_, RS, RT, RD);
1925 :function:::void:do_and:int rs, int rt, int rd
1927 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1928 GPR[rd] = GPR[rs] & GPR[rt];
1929 TRACE_ALU_RESULT (GPR[rd]);
1932 000000,5.RS,5.RT,5.RD,00000,100100:SPECIAL:32::AND
1933 "and r<RD>, r<RS>, r<RT>"
1949 do_and (SD_, RS, RT, RD);
1954 001100,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ANDI
1955 "andi r<RT>, r<RS>, %#lx<IMMEDIATE>"
1971 do_andi (SD_,RS, RT, IMMEDIATE);
1976 000100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQ
1977 "beq r<RS>, r<RT>, <OFFSET>"
1991 address_word offset = EXTEND16 (OFFSET) << 2;
1992 if ((signed_word) GPR[RS] == (signed_word) GPR[RT])
1994 DELAY_SLOT (NIA + offset);
1999 000100,5.RS,5.RT,16.OFFSET:R6:32::BEQ
2000 "beq r<RS>, r<RT>, <OFFSET>"
2004 address_word offset = EXTEND16 (OFFSET) << 2;
2005 if (GPR[RS] == GPR[RT])
2006 DELAY_SLOT (NIA + offset);
2011 010100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQL
2012 "beql r<RS>, r<RT>, <OFFSET>"
2025 address_word offset = EXTEND16 (OFFSET) << 2;
2026 if ((signed_word) GPR[RS] == (signed_word) GPR[RT])
2028 DELAY_SLOT (NIA + offset);
2031 NULLIFY_NEXT_INSTRUCTION ();
2036 000001,5.RS,00001,16.OFFSET:REGIMM:32::BGEZ
2037 "bgez r<RS>, <OFFSET>"
2053 address_word offset = EXTEND16 (OFFSET) << 2;
2054 if ((signed_word) GPR[RS] >= 0)
2056 DELAY_SLOT (NIA + offset);
2062 000001,5.RS!31,10001,16.OFFSET:REGIMM:32::BGEZAL
2063 "bgezal r<RS>, <OFFSET>"
2077 address_word offset = EXTEND16 (OFFSET) << 2;
2081 if ((signed_word) GPR[RS] >= 0)
2083 DELAY_SLOT (NIA + offset);
2087 000001,00000,10001,16.OFFSET:REGIMM:32::BAL
2092 address_word offset = EXTEND16 (OFFSET) << 2;
2094 DELAY_SLOT (NIA + offset);
2097 000001,5.RS!31,10011,16.OFFSET:REGIMM:32::BGEZALL
2098 "bgezall r<RS>, <OFFSET>"
2111 address_word offset = EXTEND16 (OFFSET) << 2;
2115 /* NOTE: The branch occurs AFTER the next instruction has been
2117 if ((signed_word) GPR[RS] >= 0)
2119 DELAY_SLOT (NIA + offset);
2122 NULLIFY_NEXT_INSTRUCTION ();
2127 000001,5.RS,00011,16.OFFSET:REGIMM:32::BGEZL
2128 "bgezl r<RS>, <OFFSET>"
2141 address_word offset = EXTEND16 (OFFSET) << 2;
2142 if ((signed_word) GPR[RS] >= 0)
2144 DELAY_SLOT (NIA + offset);
2147 NULLIFY_NEXT_INSTRUCTION ();
2152 000111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZ
2153 "bgtz r<RS>, <OFFSET>"
2169 address_word offset = EXTEND16 (OFFSET) << 2;
2170 if ((signed_word) GPR[RS] > 0)
2172 DELAY_SLOT (NIA + offset);
2178 010111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZL
2179 "bgtzl r<RS>, <OFFSET>"
2192 address_word offset = EXTEND16 (OFFSET) << 2;
2193 /* NOTE: The branch occurs AFTER the next instruction has been
2195 if ((signed_word) GPR[RS] > 0)
2197 DELAY_SLOT (NIA + offset);
2200 NULLIFY_NEXT_INSTRUCTION ();
2205 000110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZ
2206 "blez r<RS>, <OFFSET>"
2222 address_word offset = EXTEND16 (OFFSET) << 2;
2223 /* NOTE: The branch occurs AFTER the next instruction has been
2225 if ((signed_word) GPR[RS] <= 0)
2227 DELAY_SLOT (NIA + offset);
2233 010110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZL
2234 "bgezl r<RS>, <OFFSET>"
2247 address_word offset = EXTEND16 (OFFSET) << 2;
2248 if ((signed_word) GPR[RS] <= 0)
2250 DELAY_SLOT (NIA + offset);
2253 NULLIFY_NEXT_INSTRUCTION ();
2258 000001,5.RS,00000,16.OFFSET:REGIMM:32::BLTZ
2259 "bltz r<RS>, <OFFSET>"
2275 address_word offset = EXTEND16 (OFFSET) << 2;
2276 if ((signed_word) GPR[RS] < 0)
2278 DELAY_SLOT (NIA + offset);
2284 000001,5.RS!31,10000,16.OFFSET:REGIMM:32::BLTZAL
2285 "bltzal r<RS>, <OFFSET>"
2299 address_word offset = EXTEND16 (OFFSET) << 2;
2303 /* NOTE: The branch occurs AFTER the next instruction has been
2305 if ((signed_word) GPR[RS] < 0)
2307 DELAY_SLOT (NIA + offset);
2313 000001,00000,10000,16.OFFSET:REGIMM:32::NAL
2318 address_word offset = EXTEND16 (OFFSET) << 2;
2325 000001,5.RS!31,10010,16.OFFSET:REGIMM:32::BLTZALL
2326 "bltzall r<RS>, <OFFSET>"
2339 address_word offset = EXTEND16 (OFFSET) << 2;
2343 if ((signed_word) GPR[RS] < 0)
2345 DELAY_SLOT (NIA + offset);
2348 NULLIFY_NEXT_INSTRUCTION ();
2353 000001,5.RS,00010,16.OFFSET:REGIMM:32::BLTZL
2354 "bltzl r<RS>, <OFFSET>"
2367 address_word offset = EXTEND16 (OFFSET) << 2;
2368 /* NOTE: The branch occurs AFTER the next instruction has been
2370 if ((signed_word) GPR[RS] < 0)
2372 DELAY_SLOT (NIA + offset);
2375 NULLIFY_NEXT_INSTRUCTION ();
2380 000101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNE
2381 "bne r<RS>, r<RT>, <OFFSET>"
2397 address_word offset = EXTEND16 (OFFSET) << 2;
2398 if ((signed_word) GPR[RS] != (signed_word) GPR[RT])
2400 DELAY_SLOT (NIA + offset);
2406 010101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNEL
2407 "bnel r<RS>, r<RT>, <OFFSET>"
2420 address_word offset = EXTEND16 (OFFSET) << 2;
2421 if ((signed_word) GPR[RS] != (signed_word) GPR[RT])
2423 DELAY_SLOT (NIA + offset);
2426 NULLIFY_NEXT_INSTRUCTION ();
2431 000000,20.CODE,001101:SPECIAL:32::BREAK
2448 do_break (SD_, instruction_0);
2453 011100,5.RS,5.RT,5.RD,00000,100001:SPECIAL2:32::CLO
2463 do_clo (SD_, RD, RS);
2468 011100,5.RS,5.RT,5.RD,00000,100000:SPECIAL2:32::CLZ
2478 do_clz (SD_, RD, RS);
2483 000000,5.RS,5.RT,5.RD,00000,101100:SPECIAL:64::DADD
2484 "dadd r<RD>, r<RS>, r<RT>"
2494 check_u64 (SD_, instruction_0);
2495 do_dadd (SD_, RD, RS, RT);
2500 011000,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDI
2501 "daddi r<RT>, r<RS>, <IMMEDIATE>"
2510 check_u64 (SD_, instruction_0);
2511 do_daddi (SD_, RT, RS, IMMEDIATE);
2516 :function:::void:do_daddiu:int rs, int rt, uint16_t immediate
2518 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
2519 GPR[rt] = GPR[rs] + EXTEND16 (immediate);
2520 TRACE_ALU_RESULT (GPR[rt]);
2523 011001,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDIU
2524 "daddiu r<RT>, r<RS>, <IMMEDIATE>"
2534 check_u64 (SD_, instruction_0);
2535 do_daddiu (SD_, RS, RT, IMMEDIATE);
2540 :function:::void:do_daddu:int rs, int rt, int rd
2542 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2543 GPR[rd] = GPR[rs] + GPR[rt];
2544 TRACE_ALU_RESULT (GPR[rd]);
2547 000000,5.RS,5.RT,5.RD,00000,101101:SPECIAL:64::DADDU
2548 "daddu r<RD>, r<RS>, r<RT>"
2558 check_u64 (SD_, instruction_0);
2559 do_daddu (SD_, RS, RT, RD);
2564 011100,5.RS,5.RT,5.RD,00000,100101:SPECIAL2:64::DCLO
2572 check_u64 (SD_, instruction_0);
2575 do_dclo (SD_, RD, RS);
2580 011100,5.RS,5.RT,5.RD,00000,100100:SPECIAL2:64::DCLZ
2588 check_u64 (SD_, instruction_0);
2591 do_dclz (SD_, RD, RS);
2596 :function:::void:do_ddiv:int rs, int rt
2598 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
2599 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2601 int64_t n = GPR[rs];
2602 int64_t d = GPR[rt];
2607 lo = SIGNED64 (0x8000000000000000);
2610 else if (d == -1 && n == SIGNED64 (0x8000000000000000))
2612 lo = SIGNED64 (0x8000000000000000);
2623 TRACE_ALU_RESULT2 (HI, LO);
2626 000000,5.RS,5.RT,0000000000,011110:SPECIAL:64::DDIV
2636 check_u64 (SD_, instruction_0);
2637 do_ddiv (SD_, RS, RT);
2642 :function:::void:do_ddivu:int rs, int rt
2644 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
2645 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2647 uint64_t n = GPR[rs];
2648 uint64_t d = GPR[rt];
2653 lo = SIGNED64 (0x8000000000000000);
2664 TRACE_ALU_RESULT2 (HI, LO);
2667 000000,5.RS,5.RT,0000000000,011111:SPECIAL:64::DDIVU
2668 "ddivu r<RS>, r<RT>"
2677 check_u64 (SD_, instruction_0);
2678 do_ddivu (SD_, RS, RT);
2681 :function:::void:do_div:int rs, int rt
2683 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
2684 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2686 int32_t n = GPR[rs];
2687 int32_t d = GPR[rt];
2690 LO = EXTEND32 (0x80000000);
2693 else if (n == SIGNED32 (0x80000000) && d == -1)
2695 LO = EXTEND32 (0x80000000);
2700 LO = EXTEND32 (n / d);
2701 HI = EXTEND32 (n % d);
2704 TRACE_ALU_RESULT2 (HI, LO);
2707 000000,5.RS,5.RT,0000000000,011010:SPECIAL:32::DIV
2722 do_div (SD_, RS, RT);
2727 :function:::void:do_divu:int rs, int rt
2729 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
2730 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2732 uint32_t n = GPR[rs];
2733 uint32_t d = GPR[rt];
2736 LO = EXTEND32 (0x80000000);
2741 LO = EXTEND32 (n / d);
2742 HI = EXTEND32 (n % d);
2745 TRACE_ALU_RESULT2 (HI, LO);
2748 000000,5.RS,5.RT,0000000000,011011:SPECIAL:32::DIVU
2763 do_divu (SD_, RS, RT);
2767 :function:::void:do_dmultx:int rs, int rt, int rd, int signed_p
2777 uint64_t op1 = GPR[rs];
2778 uint64_t op2 = GPR[rt];
2779 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
2780 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2781 /* make signed multiply unsigned */
2785 if ((int64_t) op1 < 0)
2790 if ((int64_t) op2 < 0)
2796 /* multiply out the 4 sub products */
2797 m00 = ((uint64_t) VL4_8 (op1) * (uint64_t) VL4_8 (op2));
2798 m10 = ((uint64_t) VH4_8 (op1) * (uint64_t) VL4_8 (op2));
2799 m01 = ((uint64_t) VL4_8 (op1) * (uint64_t) VH4_8 (op2));
2800 m11 = ((uint64_t) VH4_8 (op1) * (uint64_t) VH4_8 (op2));
2801 /* add the products */
2802 mid = ((uint64_t) VH4_8 (m00)
2803 + (uint64_t) VL4_8 (m10)
2804 + (uint64_t) VL4_8 (m01));
2805 lo = U8_4 (mid, m00);
2807 + (uint64_t) VH4_8 (mid)
2808 + (uint64_t) VH4_8 (m01)
2809 + (uint64_t) VH4_8 (m10));
2819 /* save the result HI/LO (and a gpr) */
2824 TRACE_ALU_RESULT2 (HI, LO);
2827 :function:::void:do_dmult:int rs, int rt, int rd
2829 do_dmultx (SD_, rs, rt, rd, 1);
2832 000000,5.RS,5.RT,0000000000,011100:SPECIAL:64::DMULT
2833 "dmult r<RS>, r<RT>"
2841 check_u64 (SD_, instruction_0);
2842 do_dmult (SD_, RS, RT, 0);
2845 000000,5.RS,5.RT,5.RD,00000,011100:SPECIAL:64::DMULT
2846 "dmult r<RS>, r<RT>":RD == 0
2847 "dmult r<RD>, r<RS>, r<RT>"
2850 check_u64 (SD_, instruction_0);
2851 do_dmult (SD_, RS, RT, RD);
2856 :function:::void:do_dmultu:int rs, int rt, int rd
2858 do_dmultx (SD_, rs, rt, rd, 0);
2861 000000,5.RS,5.RT,0000000000,011101:SPECIAL:64::DMULTU
2862 "dmultu r<RS>, r<RT>"
2870 check_u64 (SD_, instruction_0);
2871 do_dmultu (SD_, RS, RT, 0);
2874 000000,5.RS,5.RT,5.RD,00000,011101:SPECIAL:64::DMULTU
2875 "dmultu r<RD>, r<RS>, r<RT>":RD == 0
2876 "dmultu r<RS>, r<RT>"
2879 check_u64 (SD_, instruction_0);
2880 do_dmultu (SD_, RS, RT, RD);
2884 :function:::uint64_t:do_dror:uint64_t x,uint64_t y
2889 TRACE_ALU_INPUT2 (x, y);
2890 result = ROTR64 (x, y);
2891 TRACE_ALU_RESULT (result);
2895 000000,00001,5.RT,5.RD,5.SHIFT,111010::64::DROR
2896 "dror r<RD>, r<RT>, <SHIFT>"
2902 check_u64 (SD_, instruction_0);
2903 GPR[RD] = do_dror (SD_, GPR[RT], SHIFT);
2906 000000,00001,5.RT,5.RD,5.SHIFT,111110::64::DROR32
2907 "dror32 r<RD>, r<RT>, <SHIFT>"
2913 check_u64 (SD_, instruction_0);
2914 GPR[RD] = do_dror (SD_, GPR[RT], SHIFT + 32);
2917 000000,5.RS,5.RT,5.RD,00001,010110::64::DRORV
2918 "drorv r<RD>, r<RT>, r<RS>"
2924 check_u64 (SD_, instruction_0);
2925 GPR[RD] = do_dror (SD_, GPR[RT], GPR[RS]);
2929 :function:::void:do_dsll:int rt, int rd, int shift
2931 TRACE_ALU_INPUT2 (GPR[rt], shift);
2932 GPR[rd] = GPR[rt] << shift;
2933 TRACE_ALU_RESULT (GPR[rd]);
2936 000000,00000,5.RT,5.RD,5.SHIFT,111000:SPECIAL:64::DSLL
2937 "dsll r<RD>, r<RT>, <SHIFT>"
2947 check_u64 (SD_, instruction_0);
2948 do_dsll (SD_, RT, RD, SHIFT);
2952 000000,00000,5.RT,5.RD,5.SHIFT,111100:SPECIAL:64::DSLL32
2953 "dsll32 r<RD>, r<RT>, <SHIFT>"
2963 check_u64 (SD_, instruction_0);
2964 do_dsll32 (SD_, RD, RT, SHIFT);
2967 :function:::void:do_dsllv:int rs, int rt, int rd
2969 int s = MASKED64 (GPR[rs], 5, 0);
2970 TRACE_ALU_INPUT2 (GPR[rt], s);
2971 GPR[rd] = GPR[rt] << s;
2972 TRACE_ALU_RESULT (GPR[rd]);
2975 000000,5.RS,5.RT,5.RD,00000,010100:SPECIAL:64::DSLLV
2976 "dsllv r<RD>, r<RT>, r<RS>"
2986 check_u64 (SD_, instruction_0);
2987 do_dsllv (SD_, RS, RT, RD);
2990 :function:::void:do_dsra:int rt, int rd, int shift
2992 TRACE_ALU_INPUT2 (GPR[rt], shift);
2993 GPR[rd] = ((int64_t) GPR[rt]) >> shift;
2994 TRACE_ALU_RESULT (GPR[rd]);
2998 000000,00000,5.RT,5.RD,5.SHIFT,111011:SPECIAL:64::DSRA
2999 "dsra r<RD>, r<RT>, <SHIFT>"
3009 check_u64 (SD_, instruction_0);
3010 do_dsra (SD_, RT, RD, SHIFT);
3014 000000,00000,5.RT,5.RD,5.SHIFT,111111:SPECIAL:64::DSRA32
3015 "dsra32 r<RD>, r<RT>, <SHIFT>"
3025 check_u64 (SD_, instruction_0);
3026 do_dsra32 (SD_, RD, RT, SHIFT);
3030 :function:::void:do_dsrav:int rs, int rt, int rd
3032 int s = MASKED64 (GPR[rs], 5, 0);
3033 TRACE_ALU_INPUT2 (GPR[rt], s);
3034 GPR[rd] = ((int64_t) GPR[rt]) >> s;
3035 TRACE_ALU_RESULT (GPR[rd]);
3038 000000,5.RS,5.RT,5.RD,00000,010111:SPECIAL:64::DSRAV
3039 "dsrav r<RD>, r<RT>, r<RS>"
3049 check_u64 (SD_, instruction_0);
3050 do_dsrav (SD_, RS, RT, RD);
3053 :function:::void:do_dsrl:int rt, int rd, int shift
3055 TRACE_ALU_INPUT2 (GPR[rt], shift);
3056 GPR[rd] = (uint64_t) GPR[rt] >> shift;
3057 TRACE_ALU_RESULT (GPR[rd]);
3061 000000,00000,5.RT,5.RD,5.SHIFT,111010:SPECIAL:64::DSRL
3062 "dsrl r<RD>, r<RT>, <SHIFT>"
3072 check_u64 (SD_, instruction_0);
3073 do_dsrl (SD_, RT, RD, SHIFT);
3077 000000,00000,5.RT,5.RD,5.SHIFT,111110:SPECIAL:64::DSRL32
3078 "dsrl32 r<RD>, r<RT>, <SHIFT>"
3088 check_u64 (SD_, instruction_0);
3089 do_dsrl32 (SD_, RD, RT, SHIFT);
3093 :function:::void:do_dsrlv:int rs, int rt, int rd
3095 int s = MASKED64 (GPR[rs], 5, 0);
3096 TRACE_ALU_INPUT2 (GPR[rt], s);
3097 GPR[rd] = (uint64_t) GPR[rt] >> s;
3098 TRACE_ALU_RESULT (GPR[rd]);
3103 000000,5.RS,5.RT,5.RD,00000,010110:SPECIAL:64::DSRLV
3104 "dsrlv r<RD>, r<RT>, r<RS>"
3114 check_u64 (SD_, instruction_0);
3115 do_dsrlv (SD_, RS, RT, RD);
3119 000000,5.RS,5.RT,5.RD,00000,101110:SPECIAL:64::DSUB
3120 "dsub r<RD>, r<RS>, r<RT>"
3130 check_u64 (SD_, instruction_0);
3131 do_dsub (SD_, RD, RS, RT);
3135 :function:::void:do_dsubu:int rs, int rt, int rd
3137 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
3138 GPR[rd] = GPR[rs] - GPR[rt];
3139 TRACE_ALU_RESULT (GPR[rd]);
3142 000000,5.RS,5.RT,5.RD,00000,101111:SPECIAL:64::DSUBU
3143 "dsubu r<RD>, r<RS>, r<RT>"
3153 check_u64 (SD_, instruction_0);
3154 do_dsubu (SD_, RS, RT, RD);
3158 000010,26.INSTR_INDEX:NORMAL:32::J
3175 /* NOTE: The region used is that of the delay slot NIA and NOT the
3176 current instruction */
3177 address_word region = (NIA & MASK (63, 28));
3178 DELAY_SLOT (region | (INSTR_INDEX << 2));
3182 000011,26.INSTR_INDEX:NORMAL:32::JAL
3199 /* NOTE: The region used is that of the delay slot and NOT the
3200 current instruction */
3201 address_word region = (NIA & MASK (63, 28));
3203 DELAY_SLOT (region | (INSTR_INDEX << 2));
3206 000000,5.RS,00000,5.RD,00000,001001:SPECIAL:32::JALR
3207 "jalr r<RS>":RD == 31
3224 address_word temp = GPR[RS];
3229 000000,5.RS,00000,5.RD,10000,001001:SPECIAL:32::JALR_HB
3230 "jalr.hb r<RS>":RD == 31
3231 "jalr.hb r<RD>, r<RS>"
3237 address_word temp = GPR[RS];
3242 000000,5.RS,0000000000,00000,001000:SPECIAL:32::JR
3259 DELAY_SLOT (GPR[RS]);
3262 000000,5.RS,0000000000,10000,001000:SPECIAL:32::JR_HB
3269 DELAY_SLOT (GPR[RS]);
3272 :function:::unsigned_word:do_load:unsigned access, address_word base, address_word offset
3274 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
3275 address_word reverseendian = (ReverseEndian ? (mask ^ access) : 0);
3276 address_word bigendiancpu = (BigEndianCPU ? (mask ^ access) : 0);
3282 paddr = vaddr = loadstore_ea (SD_, base, offset);
3283 if ((vaddr & access) != 0)
3285 SIM_CORE_SIGNAL (SD, STATE_CPU (SD, 0), cia, read_map, access+1, vaddr, read_transfer, sim_core_unaligned_signal);
3287 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
3288 LoadMemory (&memval, NULL, access, paddr, vaddr, isDATA, isREAL);
3289 byte = ((vaddr & mask) ^ bigendiancpu);
3290 return (memval >> (8 * byte));
3293 :function:::unsigned_word:do_load_left:unsigned access, address_word base, address_word offset, unsigned_word rt
3295 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
3296 address_word reverseendian = (ReverseEndian ? -1 : 0);
3297 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
3305 unsigned_word lhs_mask;
3308 paddr = vaddr = loadstore_ea (SD_, base, offset);
3309 paddr = (paddr ^ (reverseendian & mask));
3310 if (BigEndianMem == 0)
3311 paddr = paddr & ~access;
3313 /* compute where within the word/mem we are */
3314 byte = ((vaddr ^ bigendiancpu) & access); /* 0..access */
3315 word = ((vaddr ^ bigendiancpu) & (mask & ~access)) / (access + 1); /* 0..1 */
3316 nr_lhs_bits = 8 * byte + 8;
3317 nr_rhs_bits = 8 * access - 8 * byte;
3318 /* nr_lhs_bits + nr_rhs_bits == 8 * (accesss + 1) */
3320 /* fprintf (stderr, "l[wd]l: 0x%08lx%08lx 0x%08lx%08lx %d:%d %d+%d\n",
3321 (long) ((uint64_t) vaddr >> 32), (long) vaddr,
3322 (long) ((uint64_t) paddr >> 32), (long) paddr,
3323 word, byte, nr_lhs_bits, nr_rhs_bits); */
3325 LoadMemory (&memval, NULL, byte, paddr, vaddr, isDATA, isREAL);
3328 /* GPR{31..32-NR_LHS_BITS} = memval{NR_LHS_BITS-1..0} */
3329 temp = (memval << nr_rhs_bits);
3333 /* GPR{31..32-NR_LHS_BITS = memval{32+NR_LHS_BITS..32} */
3334 temp = (memval >> nr_lhs_bits);
3336 lhs_mask = LSMASK (nr_lhs_bits + nr_rhs_bits - 1, nr_rhs_bits);
3337 rt = (rt & ~lhs_mask) | (temp & lhs_mask);
3339 /* fprintf (stderr, "l[wd]l: 0x%08lx%08lx -> 0x%08lx%08lx & 0x%08lx%08lx -> 0x%08lx%08lx\n",
3340 (long) ((uint64_t) memval >> 32), (long) memval,
3341 (long) ((uint64_t) temp >> 32), (long) temp,
3342 (long) ((uint64_t) lhs_mask >> 32), (long) lhs_mask,
3343 (long) (rt >> 32), (long) rt); */
3347 :function:::unsigned_word:do_load_right:unsigned access, address_word base, address_word offset, unsigned_word rt
3349 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
3350 address_word reverseendian = (ReverseEndian ? -1 : 0);
3351 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
3357 paddr = vaddr = loadstore_ea (SD_, base, offset);
3358 /* NOTE: SPEC is wrong, has `BigEndianMem == 0' not `BigEndianMem != 0' */
3359 paddr = (paddr ^ (reverseendian & mask));
3360 if (BigEndianMem != 0)
3361 paddr = paddr & ~access;
3362 byte = ((vaddr & mask) ^ (bigendiancpu & mask));
3363 /* NOTE: SPEC is wrong, had `byte' not `access - byte'. See SW. */
3364 LoadMemory (&memval, NULL, access - (access & byte), paddr, vaddr, isDATA, isREAL);
3365 /* printf ("lr: 0x%08lx %d@0x%08lx 0x%08lx\n",
3366 (long) paddr, byte, (long) paddr, (long) memval); */
3368 unsigned_word screen = LSMASK (8 * (access - (byte & access) + 1) - 1, 0);
3370 rt |= (memval >> (8 * byte)) & screen;
3376 100000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LB
3377 "lb r<RT>, <OFFSET>(r<BASE>)"
3393 do_lb (SD_,RT,OFFSET,BASE);
3397 100100,5.BASE,5.RT,16.OFFSET:NORMAL:32::LBU
3398 "lbu r<RT>, <OFFSET>(r<BASE>)"
3414 do_lbu (SD_, RT,OFFSET,BASE);
3418 110111,5.BASE,5.RT,16.OFFSET:NORMAL:64::LD
3419 "ld r<RT>, <OFFSET>(r<BASE>)"
3429 check_u64 (SD_, instruction_0);
3430 GPR[RT] = EXTEND64 (do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET)));
3434 1101,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDCz
3435 "ldc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
3448 do_ldc (SD_, ZZ, RT, OFFSET, BASE);
3454 011010,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDL
3455 "ldl r<RT>, <OFFSET>(r<BASE>)"
3464 check_u64 (SD_, instruction_0);
3465 GPR[RT] = do_load_left (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
3469 011011,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDR
3470 "ldr r<RT>, <OFFSET>(r<BASE>)"
3479 check_u64 (SD_, instruction_0);
3480 GPR[RT] = do_load_right (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
3484 100001,5.BASE,5.RT,16.OFFSET:NORMAL:32::LH
3485 "lh r<RT>, <OFFSET>(r<BASE>)"
3501 do_lh (SD_,RT,OFFSET,BASE);
3505 100101,5.BASE,5.RT,16.OFFSET:NORMAL:32::LHU
3506 "lhu r<RT>, <OFFSET>(r<BASE>)"
3522 do_lhu (SD_,RT,OFFSET,BASE);
3526 110000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LL
3527 "ll r<RT>, <OFFSET>(r<BASE>)"
3539 do_ll (SD_, RT, OFFSET, BASE);
3543 110100,5.BASE,5.RT,16.OFFSET:NORMAL:64::LLD
3544 "lld r<RT>, <OFFSET>(r<BASE>)"
3553 check_u64 (SD_, instruction_0);
3554 do_lld (SD_, RT, OFFSET, BASE);
3558 001111,00000,5.RT,16.IMMEDIATE:NORMAL:32::LUI
3559 "lui r<RT>, %#lx<IMMEDIATE>"
3575 do_lui (SD_, RT, IMMEDIATE);
3579 100011,5.BASE,5.RT,16.OFFSET:NORMAL:32::LW
3580 "lw r<RT>, <OFFSET>(r<BASE>)"
3596 do_lw (SD_,RT,OFFSET,BASE);
3600 1100,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWCz
3601 "lwc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
3615 do_lwc (SD_, ZZ, RT, OFFSET, BASE);
3619 100010,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWL
3620 "lwl r<RT>, <OFFSET>(r<BASE>)"
3634 do_lwl (SD_, RT, OFFSET, BASE);
3638 100110,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWR
3639 "lwr r<RT>, <OFFSET>(r<BASE>)"
3653 do_lwr (SD_, RT, OFFSET, BASE);
3657 100111,5.BASE,5.RT,16.OFFSET:NORMAL:64::LWU
3658 "lwu r<RT>, <OFFSET>(r<BASE>)"
3668 do_lwu (SD_, RT, OFFSET, BASE, instruction_0);
3673 011100,5.RS,5.RT,00000,00000,000000:SPECIAL2:32::MADD
3679 do_madd (SD_, RS, RT);
3683 011100,5.RS,5.RT,000,2.AC,00000,000000:SPECIAL2:32::MADD
3684 "madd r<RS>, r<RT>":AC == 0
3685 "madd ac<AC>, r<RS>, r<RT>"
3690 do_dsp_madd (SD_, AC, RS, RT);
3694 011100,5.RS,5.RT,00000,00000,000001:SPECIAL2:32::MADDU
3695 "maddu r<RS>, r<RT>"
3700 do_maddu (SD_, RS, RT);
3704 011100,5.RS,5.RT,000,2.AC,00000,000001:SPECIAL2:32::MADDU
3705 "maddu r<RS>, r<RT>":AC == 0
3706 "maddu ac<AC>, r<RS>, r<RT>"
3711 do_dsp_maddu (SD_, AC, RS, RT);
3715 :function:::void:do_mfhi:int rd
3717 check_mf_hilo (SD_, HIHISTORY, LOHISTORY);
3718 TRACE_ALU_INPUT1 (HI);
3720 TRACE_ALU_RESULT (GPR[rd]);
3723 000000,0000000000,5.RD,00000,010000:SPECIAL:32::MFHI
3740 000000,000,2.AC,00000,5.RD,00000,010000:SPECIAL:32::MFHI
3741 "mfhi r<RD>":AC == 0
3742 "mfhi r<RD>, ac<AC>"
3747 do_dsp_mfhi (SD_, AC, RD);
3751 :function:::void:do_mflo:int rd
3753 check_mf_hilo (SD_, LOHISTORY, HIHISTORY);
3754 TRACE_ALU_INPUT1 (LO);
3756 TRACE_ALU_RESULT (GPR[rd]);
3759 000000,0000000000,5.RD,00000,010010:SPECIAL:32::MFLO
3776 000000,000,2.AC,00000,5.RD,00000,010010:SPECIAL:32::MFLO
3777 "mflo r<RD>":AC == 0
3778 "mflo r<RD>, ac<AC>"
3783 do_dsp_mflo (SD_, AC, RD);
3787 000000,5.RS,5.RT,5.RD,00000,001011:SPECIAL:32::MOVN
3788 "movn r<RD>, r<RS>, r<RT>"
3797 do_movn (SD_, RD, RS, RT);
3802 000000,5.RS,5.RT,5.RD,00000,001010:SPECIAL:32::MOVZ
3803 "movz r<RD>, r<RS>, r<RT>"
3812 do_movz (SD_, RD, RS, RT);
3817 011100,5.RS,5.RT,00000,00000,000100:SPECIAL2:32::MSUB
3823 do_msub (SD_, RS, RT);
3827 011100,5.RS,5.RT,000,2.AC,00000,000100:SPECIAL2:32::MSUB
3828 "msub r<RS>, r<RT>":AC == 0
3829 "msub ac<AC>, r<RS>, r<RT>"
3834 do_dsp_msub (SD_, AC, RS, RT);
3838 011100,5.RS,5.RT,00000,00000,000101:SPECIAL2:32::MSUBU
3839 "msubu r<RS>, r<RT>"
3844 do_msubu (SD_, RS, RT);
3848 011100,5.RS,5.RT,000,2.AC,00000,000101:SPECIAL2:32::MSUBU
3849 "msubu r<RS>, r<RT>":AC == 0
3850 "msubu ac<AC>, r<RS>, r<RT>"
3855 do_dsp_msubu (SD_, AC, RS, RT);
3859 000000,5.RS,000000000000000,010001:SPECIAL:32::MTHI
3876 000000,5.RS,00000,000,2.AC,00000,010001:SPECIAL:32::MTHI
3877 "mthi r<RS>":AC == 0
3878 "mthi r<RS>, ac<AC>"
3883 do_dsp_mthi (SD_, AC, RS);
3887 000000,5.RS,000000000000000,010011:SPECIAL:32::MTLO
3904 000000,5.RS,00000,000,2.AC,00000,010011:SPECIAL:32::MTLO
3905 "mtlo r<RS>":AC == 0
3906 "mtlo r<RS>, ac<AC>"
3911 do_dsp_mtlo (SD_, AC, RS);
3915 011100,5.RS,5.RT,5.RD,00000,000010:SPECIAL2:32::MUL
3916 "mul r<RD>, r<RS>, r<RT>"
3923 do_mul (SD_, RD, RS, RT);
3928 :function:::void:do_mult:int rs, int rt, int rd
3931 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
3932 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
3934 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
3935 prod = (((int64_t)(int32_t) GPR[rs])
3936 * ((int64_t)(int32_t) GPR[rt]));
3937 LO = EXTEND32 (VL4_8 (prod));
3938 HI = EXTEND32 (VH4_8 (prod));
3939 ACX = 0; /* SmartMIPS */
3942 TRACE_ALU_RESULT2 (HI, LO);
3945 000000,5.RS,5.RT,0000000000,011000:SPECIAL:32::MULT
3956 do_mult (SD_, RS, RT, 0);
3960 000000,5.RS,5.RT,000,2.AC,00000,011000:SPECIAL:32::MULT
3961 "mult r<RS>, r<RT>":AC == 0
3962 "mult ac<AC>, r<RS>, r<RT>"
3967 do_dsp_mult (SD_, AC, RS, RT);
3971 000000,5.RS,5.RT,5.RD,00000,011000:SPECIAL:32::MULT
3972 "mult r<RS>, r<RT>":RD == 0
3973 "mult r<RD>, r<RS>, r<RT>"
3977 do_mult (SD_, RS, RT, RD);
3981 :function:::void:do_multu:int rs, int rt, int rd
3984 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
3985 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
3987 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
3988 prod = (((uint64_t)(uint32_t) GPR[rs])
3989 * ((uint64_t)(uint32_t) GPR[rt]));
3990 LO = EXTEND32 (VL4_8 (prod));
3991 HI = EXTEND32 (VH4_8 (prod));
3994 TRACE_ALU_RESULT2 (HI, LO);
3997 000000,5.RS,5.RT,0000000000,011001:SPECIAL:32::MULTU
3998 "multu r<RS>, r<RT>"
4008 do_multu (SD_, RS, RT, 0);
4012 000000,5.RS,5.RT,000,2.AC,00000,011001:SPECIAL:32::MULTU
4013 "multu r<RS>, r<RT>":AC == 0
4014 "multu r<RS>, r<RT>"
4019 do_dsp_multu (SD_, AC, RS, RT);
4023 000000,5.RS,5.RT,5.RD,00000,011001:SPECIAL:32::MULTU
4024 "multu r<RS>, r<RT>":RD == 0
4025 "multu r<RD>, r<RS>, r<RT>"
4029 do_multu (SD_, RS, RT, RD);
4033 :function:::void:do_nor:int rs, int rt, int rd
4035 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
4036 GPR[rd] = ~ (GPR[rs] | GPR[rt]);
4037 TRACE_ALU_RESULT (GPR[rd]);
4040 000000,5.RS,5.RT,5.RD,00000,100111:SPECIAL:32::NOR
4041 "nor r<RD>, r<RS>, r<RT>"
4057 do_nor (SD_, RS, RT, RD);
4061 :function:::void:do_or:int rs, int rt, int rd
4063 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
4064 GPR[rd] = (GPR[rs] | GPR[rt]);
4065 TRACE_ALU_RESULT (GPR[rd]);
4068 000000,5.RS,5.RT,5.RD,00000,100101:SPECIAL:32::OR
4069 "or r<RD>, r<RS>, r<RT>"
4085 do_or (SD_, RS, RT, RD);
4090 :function:::void:do_ori:int rs, int rt, unsigned immediate
4092 TRACE_ALU_INPUT2 (GPR[rs], immediate);
4093 GPR[rt] = (GPR[rs] | immediate);
4094 TRACE_ALU_RESULT (GPR[rt]);
4097 001101,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ORI
4098 "ori r<RT>, r<RS>, %#lx<IMMEDIATE>"
4114 do_ori (SD_, RS, RT, IMMEDIATE);
4118 110011,5.BASE,5.HINT,16.OFFSET:NORMAL:32::PREF
4119 "pref <HINT>, <OFFSET>(r<BASE>)"
4128 do_pref (SD_, HINT, OFFSET, BASE);
4132 :function:::uint64_t:do_ror:uint32_t x,uint32_t y
4137 TRACE_ALU_INPUT2 (x, y);
4138 result = EXTEND32 (ROTR32 (x, y));
4139 TRACE_ALU_RESULT (result);
4143 000000,00001,5.RT,5.RD,5.SHIFT,000010::32::ROR
4144 "ror r<RD>, r<RT>, <SHIFT>"
4153 GPR[RD] = do_ror (SD_, GPR[RT], SHIFT);
4156 000000,5.RS,5.RT,5.RD,00001,000110::32::RORV
4157 "rorv r<RD>, r<RT>, r<RS>"
4166 GPR[RD] = do_ror (SD_, GPR[RT], GPR[RS]);
4170 :function:::void:do_store:unsigned access, address_word base, address_word offset, unsigned_word word
4172 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
4173 address_word reverseendian = (ReverseEndian ? (mask ^ access) : 0);
4174 address_word bigendiancpu = (BigEndianCPU ? (mask ^ access) : 0);
4180 paddr = vaddr = loadstore_ea (SD_, base, offset);
4181 if ((vaddr & access) != 0)
4183 SIM_CORE_SIGNAL (SD, STATE_CPU(SD, 0), cia, read_map, access+1, vaddr, write_transfer, sim_core_unaligned_signal);
4185 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
4186 byte = ((vaddr & mask) ^ bigendiancpu);
4187 memval = (word << (8 * byte));
4188 StoreMemory (access, memval, 0, paddr, vaddr, isREAL);
4191 :function:::void:do_store_left:unsigned access, address_word base, address_word offset, unsigned_word rt
4193 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
4194 address_word reverseendian = (ReverseEndian ? -1 : 0);
4195 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
4204 paddr = vaddr = loadstore_ea (SD_, base, offset);
4205 paddr = (paddr ^ (reverseendian & mask));
4206 if (BigEndianMem == 0)
4207 paddr = paddr & ~access;
4209 /* compute where within the word/mem we are */
4210 byte = ((vaddr ^ bigendiancpu) & access); /* 0..access */
4211 word = ((vaddr ^ bigendiancpu) & (mask & ~access)) / (access + 1); /* 0..1 */
4212 nr_lhs_bits = 8 * byte + 8;
4213 nr_rhs_bits = 8 * access - 8 * byte;
4214 /* nr_lhs_bits + nr_rhs_bits == 8 * (accesss + 1) */
4215 /* fprintf (stderr, "s[wd]l: 0x%08lx%08lx 0x%08lx%08lx %d:%d %d+%d\n",
4216 (long) ((uint64_t) vaddr >> 32), (long) vaddr,
4217 (long) ((uint64_t) paddr >> 32), (long) paddr,
4218 word, byte, nr_lhs_bits, nr_rhs_bits); */
4222 memval = (rt >> nr_rhs_bits);
4226 memval = (rt << nr_lhs_bits);
4228 /* fprintf (stderr, "s[wd]l: 0x%08lx%08lx -> 0x%08lx%08lx\n",
4229 (long) ((uint64_t) rt >> 32), (long) rt,
4230 (long) ((uint64_t) memval >> 32), (long) memval); */
4231 StoreMemory (byte, memval, 0, paddr, vaddr, isREAL);
4234 :function:::void:do_store_right:unsigned access, address_word base, address_word offset, unsigned_word rt
4236 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
4237 address_word reverseendian = (ReverseEndian ? -1 : 0);
4238 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
4244 paddr = vaddr = loadstore_ea (SD_, base, offset);
4245 paddr = (paddr ^ (reverseendian & mask));
4246 if (BigEndianMem != 0)
4248 byte = ((vaddr & mask) ^ (bigendiancpu & mask));
4249 memval = (rt << (byte * 8));
4250 StoreMemory (access - (access & byte), memval, 0, paddr, vaddr, isREAL);
4254 101000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SB
4255 "sb r<RT>, <OFFSET>(r<BASE>)"
4271 do_store (SD_, AccessLength_BYTE, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
4275 111000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SC
4276 "sc r<RT>, <OFFSET>(r<BASE>)"
4288 do_sc (SD_, RT, OFFSET, BASE, instruction_0, 1);
4292 111100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SCD
4293 "scd r<RT>, <OFFSET>(r<BASE>)"
4302 check_u64 (SD_, instruction_0);
4303 do_scd (SD_, RT, OFFSET, BASE, 1);
4307 111111,5.BASE,5.RT,16.OFFSET:NORMAL:64::SD
4308 "sd r<RT>, <OFFSET>(r<BASE>)"
4318 check_u64 (SD_, instruction_0);
4319 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
4323 1111,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDCz
4324 "sdc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
4336 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), COP_SD (ZZ, RT));
4340 101100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDL
4341 "sdl r<RT>, <OFFSET>(r<BASE>)"
4350 check_u64 (SD_, instruction_0);
4351 do_store_left (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
4355 101101,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDR
4356 "sdr r<RT>, <OFFSET>(r<BASE>)"
4365 check_u64 (SD_, instruction_0);
4366 do_store_right (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
4371 101001,5.BASE,5.RT,16.OFFSET:NORMAL:32::SH
4372 "sh r<RT>, <OFFSET>(r<BASE>)"
4388 do_store (SD_, AccessLength_HALFWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
4392 :function:::void:do_sll:int rt, int rd, int shift
4394 uint32_t temp = (GPR[rt] << shift);
4395 TRACE_ALU_INPUT2 (GPR[rt], shift);
4396 GPR[rd] = EXTEND32 (temp);
4397 TRACE_ALU_RESULT (GPR[rd]);
4400 000000,00000,5.RT,5.RD,5.SHIFT,000000:SPECIAL:32::SLLa
4401 "nop":RD == 0 && RT == 0 && SHIFT == 0
4402 "sll r<RD>, r<RT>, <SHIFT>"
4412 /* Skip shift for NOP, so that there won't be lots of extraneous
4414 if (RD != 0 || RT != 0 || SHIFT != 0)
4415 do_sll (SD_, RT, RD, SHIFT);
4418 000000,00000,5.RT,5.RD,5.SHIFT,000000:SPECIAL:32::SLLb
4419 "nop":RD == 0 && RT == 0 && SHIFT == 0
4420 "ssnop":RD == 0 && RT == 0 && SHIFT == 1
4421 "ehb":RD == 0 && RT == 0 && SHIFT == 3
4422 "sll r<RD>, r<RT>, <SHIFT>"
4430 do_sll (SD_, RT, RD, SHIFT);
4434 :function:::void:do_sllv:int rs, int rt, int rd
4436 int s = MASKED (GPR[rs], 4, 0);
4437 uint32_t temp = (GPR[rt] << s);
4438 TRACE_ALU_INPUT2 (GPR[rt], s);
4439 GPR[rd] = EXTEND32 (temp);
4440 TRACE_ALU_RESULT (GPR[rd]);
4443 000000,5.RS,5.RT,5.RD,00000,000100:SPECIAL:32::SLLV
4444 "sllv r<RD>, r<RT>, r<RS>"
4460 do_sllv (SD_, RS, RT, RD);
4464 :function:::void:do_slt:int rs, int rt, int rd
4466 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
4467 GPR[rd] = ((signed_word) GPR[rs] < (signed_word) GPR[rt]);
4468 TRACE_ALU_RESULT (GPR[rd]);
4471 000000,5.RS,5.RT,5.RD,00000,101010:SPECIAL:32::SLT
4472 "slt r<RD>, r<RS>, r<RT>"
4488 do_slt (SD_, RS, RT, RD);
4492 :function:::void:do_slti:int rs, int rt, uint16_t immediate
4494 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
4495 GPR[rt] = ((signed_word) GPR[rs] < (signed_word) EXTEND16 (immediate));
4496 TRACE_ALU_RESULT (GPR[rt]);
4499 001010,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTI
4500 "slti r<RT>, r<RS>, <IMMEDIATE>"
4516 do_slti (SD_, RS, RT, IMMEDIATE);
4520 :function:::void:do_sltiu:int rs, int rt, uint16_t immediate
4522 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
4523 GPR[rt] = ((unsigned_word) GPR[rs] < (unsigned_word) EXTEND16 (immediate));
4524 TRACE_ALU_RESULT (GPR[rt]);
4527 001011,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTIU
4528 "sltiu r<RT>, r<RS>, <IMMEDIATE>"
4544 do_sltiu (SD_, RS, RT, IMMEDIATE);
4549 :function:::void:do_sltu:int rs, int rt, int rd
4551 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
4552 GPR[rd] = ((unsigned_word) GPR[rs] < (unsigned_word) GPR[rt]);
4553 TRACE_ALU_RESULT (GPR[rd]);
4556 000000,5.RS,5.RT,5.RD,00000,101011:SPECIAL:32::SLTU
4557 "sltu r<RD>, r<RS>, r<RT>"
4573 do_sltu (SD_, RS, RT, RD);
4577 :function:::void:do_sra:int rt, int rd, int shift
4579 int32_t temp = (int32_t) GPR[rt] >> shift;
4580 if (NotWordValue (GPR[rt]))
4582 TRACE_ALU_INPUT2 (GPR[rt], shift);
4583 GPR[rd] = EXTEND32 (temp);
4584 TRACE_ALU_RESULT (GPR[rd]);
4587 000000,00000,5.RT,5.RD,5.SHIFT,000011:SPECIAL:32::SRA
4588 "sra r<RD>, r<RT>, <SHIFT>"
4604 do_sra (SD_, RT, RD, SHIFT);
4609 :function:::void:do_srav:int rs, int rt, int rd
4611 int s = MASKED (GPR[rs], 4, 0);
4612 int32_t temp = (int32_t) GPR[rt] >> s;
4613 if (NotWordValue (GPR[rt]))
4615 TRACE_ALU_INPUT2 (GPR[rt], s);
4616 GPR[rd] = EXTEND32 (temp);
4617 TRACE_ALU_RESULT (GPR[rd]);
4620 000000,5.RS,5.RT,5.RD,00000,000111:SPECIAL:32::SRAV
4621 "srav r<RD>, r<RT>, r<RS>"
4637 do_srav (SD_, RS, RT, RD);
4642 :function:::void:do_srl:int rt, int rd, int shift
4644 uint32_t temp = (uint32_t) GPR[rt] >> shift;
4645 if (NotWordValue (GPR[rt]))
4647 TRACE_ALU_INPUT2 (GPR[rt], shift);
4648 GPR[rd] = EXTEND32 (temp);
4649 TRACE_ALU_RESULT (GPR[rd]);
4652 000000,00000,5.RT,5.RD,5.SHIFT,000010:SPECIAL:32::SRL
4653 "srl r<RD>, r<RT>, <SHIFT>"
4669 do_srl (SD_, RT, RD, SHIFT);
4673 :function:::void:do_srlv:int rs, int rt, int rd
4675 int s = MASKED (GPR[rs], 4, 0);
4676 uint32_t temp = (uint32_t) GPR[rt] >> s;
4677 if (NotWordValue (GPR[rt]))
4679 TRACE_ALU_INPUT2 (GPR[rt], s);
4680 GPR[rd] = EXTEND32 (temp);
4681 TRACE_ALU_RESULT (GPR[rd]);
4684 000000,5.RS,5.RT,5.RD,00000,000110:SPECIAL:32::SRLV
4685 "srlv r<RD>, r<RT>, r<RS>"
4701 do_srlv (SD_, RS, RT, RD);
4705 000000,5.RS,5.RT,5.RD,00000,100010:SPECIAL:32::SUB
4706 "sub r<RD>, r<RS>, r<RT>"
4722 do_sub (SD_, RD, RS, RT);
4726 :function:::void:do_subu:int rs, int rt, int rd
4728 if (NotWordValue (GPR[rs]) || NotWordValue (GPR[rt]))
4730 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
4731 GPR[rd] = EXTEND32 (GPR[rs] - GPR[rt]);
4732 TRACE_ALU_RESULT (GPR[rd]);
4735 000000,5.RS,5.RT,5.RD,00000,100011:SPECIAL:32::SUBU
4736 "subu r<RD>, r<RS>, r<RT>"
4752 do_subu (SD_, RS, RT, RD);
4756 101011,5.BASE,5.RT,16.OFFSET:NORMAL:32::SW
4757 "sw r<RT>, <OFFSET>(r<BASE>)"
4773 do_sw (SD_, RT, OFFSET, BASE);
4777 1110,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWCz
4778 "swc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
4792 do_store (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), COP_SW (ZZ, RT));
4796 101010,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWL
4797 "swl r<RT>, <OFFSET>(r<BASE>)"
4811 do_store_left (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
4815 101110,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWR
4816 "swr r<RT>, <OFFSET>(r<BASE>)"
4830 do_store_right (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
4834 000000,000000000000000,5.STYPE,001111:SPECIAL:32::SYNC
4851 SyncOperation (STYPE);
4855 000000,20.CODE,001100:SPECIAL:32::SYSCALL
4856 "syscall %#lx<CODE>"
4872 SignalException (SystemCall, instruction_0);
4876 000000,5.RS,5.RT,10.CODE,110100:SPECIAL:32::TEQ
4891 do_teq (SD_, RS, RT, instruction_0);
4895 000001,5.RS,01100,16.IMMEDIATE:REGIMM:32::TEQI
4896 "teqi r<RS>, <IMMEDIATE>"
4908 do_teqi (SD_, RS, IMMEDIATE, instruction_0);
4912 000000,5.RS,5.RT,10.CODE,110000:SPECIAL:32::TGE
4927 do_tge (SD_, RS, RT, instruction_0);
4931 000001,5.RS,01000,16.IMMEDIATE:REGIMM:32::TGEI
4932 "tgei r<RS>, <IMMEDIATE>"
4944 do_tgei (SD_, RS, IMMEDIATE, instruction_0);
4948 000001,5.RS,01001,16.IMMEDIATE:REGIMM:32::TGEIU
4949 "tgeiu r<RS>, <IMMEDIATE>"
4961 do_tgeiu (SD_, RS, IMMEDIATE, instruction_0);
4965 000000,5.RS,5.RT,10.CODE,110001:SPECIAL:32::TGEU
4980 do_tgeu (SD_, RS, RT, instruction_0);
4984 000000,5.RS,5.RT,10.CODE,110010:SPECIAL:32::TLT
4999 do_tlt (SD_, RS, RT, instruction_0);
5003 000001,5.RS,01010,16.IMMEDIATE:REGIMM:32::TLTI
5004 "tlti r<RS>, <IMMEDIATE>"
5016 do_tlti (SD_, RS, IMMEDIATE, instruction_0);
5020 000001,5.RS,01011,16.IMMEDIATE:REGIMM:32::TLTIU
5021 "tltiu r<RS>, <IMMEDIATE>"
5033 do_tltiu (SD_, RS, IMMEDIATE, instruction_0);
5037 000000,5.RS,5.RT,10.CODE,110011:SPECIAL:32::TLTU
5052 do_tltu (SD_, RS, RT, instruction_0);
5056 000000,5.RS,5.RT,10.CODE,110110:SPECIAL:32::TNE
5071 do_tne (SD_, RS, RT, instruction_0);
5075 000001,5.RS,01110,16.IMMEDIATE:REGIMM:32::TNEI
5076 "tnei r<RS>, <IMMEDIATE>"
5088 do_tnei (SD_, RS, IMMEDIATE, instruction_0);
5092 :function:::void:do_xor:int rs, int rt, int rd
5094 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
5095 GPR[rd] = GPR[rs] ^ GPR[rt];
5096 TRACE_ALU_RESULT (GPR[rd]);
5099 000000,5.RS,5.RT,5.RD,00000,100110:SPECIAL:32::XOR
5100 "xor r<RD>, r<RS>, r<RT>"
5116 do_xor (SD_, RS, RT, RD);
5120 :function:::void:do_xori:int rs, int rt, uint16_t immediate
5122 TRACE_ALU_INPUT2 (GPR[rs], immediate);
5123 GPR[rt] = GPR[rs] ^ immediate;
5124 TRACE_ALU_RESULT (GPR[rt]);
5127 001110,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::XORI
5128 "xori r<RT>, r<RS>, %#lx<IMMEDIATE>"
5144 do_xori (SD_, RS, RT, IMMEDIATE);
5149 // MIPS Architecture:
5151 // FPU Instruction Set (COP1 & COP1X)
5159 case fmt_single: return "s";
5160 case fmt_double: return "d";
5161 case fmt_word: return "w";
5162 case fmt_long: return "l";
5163 case fmt_ps: return "ps";
5164 default: return "?";
5184 :%s::::COND:int cond
5188 case 00: return "f";
5189 case 01: return "un";
5190 case 02: return "eq";
5191 case 03: return "ueq";
5192 case 04: return "olt";
5193 case 05: return "ult";
5194 case 06: return "ole";
5195 case 07: return "ule";
5196 case 010: return "sf";
5197 case 011: return "ngle";
5198 case 012: return "seq";
5199 case 013: return "ngl";
5200 case 014: return "lt";
5201 case 015: return "nge";
5202 case 016: return "le";
5203 case 017: return "ngt";
5204 default: return "?";
5211 // Check that the given FPU format is usable, and signal a
5212 // ReservedInstruction exception if not.
5215 // check_fmt_p checks that the format is single, double, or paired single.
5216 :function:::void:check_fmt_p:int fmt, instruction_word insn
5228 /* None of these ISAs support Paired Single, so just fall back to
5229 the single/double check. */
5230 if ((fmt != fmt_single) && (fmt != fmt_double))
5231 SignalException (ReservedInstruction, insn);
5234 :function:::void:check_fmt_p:int fmt, instruction_word insn
5238 if ((fmt != fmt_single) && (fmt != fmt_double) && (fmt != fmt_ps))
5239 SignalException (ReservedInstruction, insn);
5242 :function:::void:check_fmt_p:int fmt, instruction_word insn
5248 if ((fmt != fmt_single) && (fmt != fmt_double)
5249 && (fmt != fmt_ps || (UserMode && (SR & (status_UX|status_PX)) == 0)))
5250 SignalException (ReservedInstruction, insn);
5256 // Check that the FPU is currently usable, and signal a CoProcessorUnusable
5257 // exception if not.
5260 :function:::void:check_fpu:
5276 if (! COP_Usable (1))
5277 SignalExceptionCoProcessorUnusable (1);
5279 FCSR &= ~(fcsr_NAN2008_mask | fcsr_ABS2008_mask);
5280 sim_fpu_quiet_nan_inverted = true;
5285 // Check that the FPU is currently usable, and signal a CoProcessorUnusable
5286 // exception if not.
5289 :function:::void:check_fpu:
5293 if (! COP_Usable (1))
5294 SignalExceptionCoProcessorUnusable (1);
5296 FCSR |= (fcsr_NAN2008_mask | fcsr_ABS2008_mask);
5297 sim_fpu_quiet_nan_inverted = 0;
5298 sim_fpu_set_mode (sim_fpu_ieee754_2008);
5303 // Load a double word FP value using 2 32-bit memory cycles a la MIPS II
5304 // or MIPS32. do_load cannot be used instead because it returns an
5305 // unsigned_word, which is limited to the size of the machine's registers.
5308 :function:::uint64_t:do_load_double:address_word base, address_word offset
5315 int bigendian = (BigEndianCPU ? ! ReverseEndian : ReverseEndian);
5321 paddr = vaddr = loadstore_ea (SD_, base, offset);
5322 if ((vaddr & AccessLength_DOUBLEWORD) != 0)
5324 SIM_CORE_SIGNAL (SD, STATE_CPU (SD, 0), cia, read_map,
5325 AccessLength_DOUBLEWORD + 1, vaddr, read_transfer,
5326 sim_core_unaligned_signal);
5328 LoadMemory (&memval, NULL, AccessLength_WORD, paddr, vaddr, isDATA, isREAL);
5329 v = (uint64_t)memval;
5330 LoadMemory (&memval, NULL, AccessLength_WORD, paddr + 4, vaddr + 4, isDATA,
5332 return (bigendian ? ((v << 32) | memval) : (v | (memval << 32)));
5338 // Store a double word FP value using 2 32-bit memory cycles a la MIPS II
5339 // or MIPS32. do_load cannot be used instead because it returns an
5340 // unsigned_word, which is limited to the size of the machine's registers.
5343 :function:::void:do_store_double:address_word base, address_word offset, uint64_t v
5350 int bigendian = (BigEndianCPU ? ! ReverseEndian : ReverseEndian);
5355 paddr = vaddr = loadstore_ea (SD_, base, offset);
5356 if ((vaddr & AccessLength_DOUBLEWORD) != 0)
5358 SIM_CORE_SIGNAL (SD, STATE_CPU(SD, 0), cia, read_map,
5359 AccessLength_DOUBLEWORD + 1, vaddr, write_transfer,
5360 sim_core_unaligned_signal);
5362 memval = (bigendian ? (v >> 32) : (v & 0xFFFFFFFF));
5363 StoreMemory (AccessLength_WORD, memval, 0, paddr, vaddr, isREAL);
5364 memval = (bigendian ? (v & 0xFFFFFFFF) : (v >> 32));
5365 StoreMemory (AccessLength_WORD, memval, 0, paddr + 4, vaddr + 4, isREAL);
5369 010001,10,3.FMT!2!3!4!5!7,00000,5.FS,5.FD,000101:COP1:32,f::ABS.fmt
5370 "abs.%s<FMT> f<FD>, f<FS>"
5386 do_abs_fmt (SD_, FMT, FD, FS, instruction_0);
5391 010001,10,3.FMT!2!3!4!5!7,5.FT,5.FS,5.FD,000000:COP1:32,f::ADD.fmt
5392 "add.%s<FMT> f<FD>, f<FS>, f<FT>"
5408 do_add_fmt (SD_, FMT, FD, FS, FT, instruction_0);
5412 010011,5.RS,5.FT,5.FS,5.FD,011,110:COP1X:32,f::ALNV.PS
5413 "alnv.ps f<FD>, f<FS>, f<FT>, r<RS>"
5419 do_alnv_ps (SD_, FD, FS, FT, RS, instruction_0);
5428 010001,01000,3.0,1.ND,1.TF,16.OFFSET:COP1S:32,f::BC1a
5429 "bc1%s<TF>%s<ND> <OFFSET>"
5435 TRACE_BRANCH_INPUT (PREVCOC1());
5436 if (PREVCOC1() == TF)
5438 address_word dest = NIA + (EXTEND16 (OFFSET) << 2);
5439 TRACE_BRANCH_RESULT (dest);
5444 TRACE_BRANCH_RESULT (0);
5445 NULLIFY_NEXT_INSTRUCTION ();
5449 TRACE_BRANCH_RESULT (NIA);
5453 010001,01000,3.CC,1.ND,1.TF,16.OFFSET:COP1S:32,f::BC1b
5454 "bc1%s<TF>%s<ND> <OFFSET>":CC == 0
5455 "bc1%s<TF>%s<ND> <CC>, <OFFSET>"
5467 if (GETFCC(CC) == TF)
5469 address_word dest = NIA + (EXTEND16 (OFFSET) << 2);
5474 NULLIFY_NEXT_INSTRUCTION ();
5479 010001,10,3.FMT!2!3!4!5!6!7,5.FT,5.FS,3.0,00,11,4.COND:COP1:32,f::C.cond.fmta
5480 "c.%s<COND>.%s<FMT> f<FS>, f<FT>"
5487 Compare (ValueFPR (FS, fmt), ValueFPR (FT, fmt), fmt, COND, 0);
5488 TRACE_ALU_RESULT (ValueFCR (31));
5491 010001,10,3.FMT!2!3!4!5!7,5.FT,5.FS,3.CC,00,11,4.COND:COP1:32,f::C.cond.fmtb
5492 "c.%s<COND>.%s<FMT> f<FS>, f<FT>":CC == 0
5493 "c.%s<COND>.%s<FMT> <CC>, f<FS>, f<FT>"
5504 do_c_cond_fmt (SD_, COND, FMT, CC, FS, FT, instruction_0);
5508 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,001010:COP1:32,f::CEIL.L.fmt
5509 "ceil.l.%s<FMT> f<FD>, f<FS>"
5522 do_ceil_fmt (SD_, fmt_long, FMT, FD, FS, instruction_0);
5526 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,001110:COP1:32,f::CEIL.W
5527 "ceil.w.%s<FMT> f<FD>, f<FS>"
5542 do_ceil_fmt (SD_, fmt_word, FMT, FD, FS, instruction_0);
5546 010001,00010,5.RT,5.FS,00000000000:COP1:32,f::CFC1a
5554 PENDING_FILL (RT, EXTEND32 (FCR0));
5556 PENDING_FILL (RT, EXTEND32 (FCR31));
5560 010001,00010,5.RT,5.FS,00000000000:COP1:32,f::CFC1b
5568 if (FS == 0 || FS == 31)
5570 unsigned_word fcr = ValueFCR (FS);
5571 TRACE_ALU_INPUT1 (fcr);
5575 TRACE_ALU_RESULT (GPR[RT]);
5578 010001,00010,5.RT,5.FS,00000000000:COP1:32,f::CFC1c
5588 do_cfc1 (SD_, RT, FS);
5591 010001,00110,5.RT,5.FS,00000000000:COP1:32,f::CTC1a
5599 PENDING_FILL (FCRCS_REGNUM, VL4_8 (GPR[RT]));
5603 010001,00110,5.RT,5.FS,00000000000:COP1:32,f::CTC1b
5611 TRACE_ALU_INPUT1 (GPR[RT]);
5613 StoreFCR (FS, GPR[RT]);
5617 010001,00110,5.RT,5.FS,00000000000:COP1:32,f::CTC1c
5627 do_ctc1 (SD_, RT, FS);
5632 // FIXME: Does not correctly differentiate between mips*
5634 010001,10,3.FMT!1!2!3!6!7,00000,5.FS,5.FD,100001:COP1:32,f::CVT.D.fmt
5635 "cvt.d.%s<FMT> f<FD>, f<FS>"
5651 do_cvt_d_fmt (SD_, FMT, FD, FS, instruction_0);
5655 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,100101:COP1:32,f::CVT.L.fmt
5656 "cvt.l.%s<FMT> f<FD>, f<FS>"
5669 do_cvt_l_fmt (SD_, FMT, FD, FS, instruction_0);
5673 010001,10,000,5.FT,5.FS,5.FD,100110:COP1:32,f::CVT.PS.S
5674 "cvt.ps.s f<FD>, f<FS>, f<FT>"
5680 do_cvt_ps_s (SD_, FD, FS, FT, instruction_0);
5685 // FIXME: Does not correctly differentiate between mips*
5687 010001,10,3.FMT!0!2!3!6!7,00000,5.FS,5.FD,100000:COP1:32,f::CVT.S.fmt
5688 "cvt.s.%s<FMT> f<FD>, f<FS>"
5704 do_cvt_s_fmt (SD_, FMT, FD, FS, instruction_0);
5708 010001,10,110,00000,5.FS,5.FD,101000:COP1:32,f::CVT.S.PL
5709 "cvt.s.pl f<FD>, f<FS>"
5715 do_cvt_s_pl (SD_, FD, FS, instruction_0);
5719 010001,10,110,00000,5.FS,5.FD,100000:COP1:32,f::CVT.S.PU
5720 "cvt.s.pu f<FD>, f<FS>"
5726 do_cvt_s_pu (SD_, FD, FS, instruction_0);
5730 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,100100:COP1:32,f::CVT.W.fmt
5731 "cvt.w.%s<FMT> f<FD>, f<FS>"
5747 do_cvt_w_fmt (SD_, FMT, FD, FS, instruction_0);
5751 010001,10,3.FMT!2!3!4!5!6!7,5.FT,5.FS,5.FD,000011:COP1:32,f::DIV.fmt
5752 "div.%s<FMT> f<FD>, f<FS>, f<FT>"
5768 do_div_fmt (SD_, FMT, FD, FS, FT, instruction_0);
5772 010001,00001,5.RT,5.FS,00000000000:COP1:64,f::DMFC1a
5773 "dmfc1 r<RT>, f<FS>"
5778 check_u64 (SD_, instruction_0);
5779 if (SizeFGR () == 64)
5781 else if ((FS & 0x1) == 0)
5782 v = SET64HI (FGR[FS+1]) | FGR[FS];
5785 PENDING_FILL (RT, v);
5786 TRACE_ALU_RESULT (v);
5789 010001,00001,5.RT,5.FS,00000000000:COP1:64,f::DMFC1b
5790 "dmfc1 r<RT>, f<FS>"
5801 check_u64 (SD_, instruction_0);
5802 do_dmfc1b (SD_, RT, FS);
5806 010001,00101,5.RT,5.FS,00000000000:COP1:64,f::DMTC1a
5807 "dmtc1 r<RT>, f<FS>"
5812 check_u64 (SD_, instruction_0);
5813 if (SizeFGR () == 64)
5814 PENDING_FILL ((FS + FGR_BASE), GPR[RT]);
5815 else if ((FS & 0x1) == 0)
5817 PENDING_FILL (((FS + 1) + FGR_BASE), VH4_8 (GPR[RT]));
5818 PENDING_FILL ((FS + FGR_BASE), VL4_8 (GPR[RT]));
5822 TRACE_FP_RESULT (GPR[RT]);
5825 010001,00101,5.RT,5.FS,00000000000:COP1:64,f::DMTC1b
5826 "dmtc1 r<RT>, f<FS>"
5837 check_u64 (SD_, instruction_0);
5838 do_dmtc1b (SD_, RT, FS);
5842 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,001011:COP1:32,f::FLOOR.L.fmt
5843 "floor.l.%s<FMT> f<FD>, f<FS>"
5856 do_floor_fmt (SD_, fmt_long, FMT, FD, FS);
5860 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,001111:COP1:32,f::FLOOR.W.fmt
5861 "floor.w.%s<FMT> f<FD>, f<FS>"
5876 do_floor_fmt (SD_, fmt_word, FMT, FD, FS);
5880 110101,5.BASE,5.FT,16.OFFSET:COP1:32,f::LDC1a
5881 "ldc1 f<FT>, <OFFSET>(r<BASE>)"
5888 COP_LD (1, FT, do_load_double (SD_, GPR[BASE], EXTEND16 (OFFSET)));
5892 110101,5.BASE,5.FT,16.OFFSET:COP1:32,f::LDC1b
5893 "ldc1 f<FT>, <OFFSET>(r<BASE>)"
5905 COP_LD (1, FT, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET)));
5909 010011,5.BASE,5.INDEX,5.0,5.FD,000001:COP1X:32,f::LDXC1
5910 "ldxc1 f<FD>, r<INDEX>(r<BASE>)"
5914 COP_LD (1, FD, do_load_double (SD_, GPR[BASE], GPR[INDEX]));
5918 010011,5.BASE,5.INDEX,5.0,5.FD,000001:COP1X:64,f::LDXC1
5919 "ldxc1 f<FD>, r<INDEX>(r<BASE>)"
5927 check_u64 (SD_, instruction_0);
5928 COP_LD (1, FD, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], GPR[INDEX]));
5932 010011,5.BASE,5.INDEX,5.0,5.FD,000101:COP1X:32,f::LUXC1
5933 "luxc1 f<FD>, r<INDEX>(r<BASE>)"
5936 do_luxc1_32 (SD_, FD, INDEX, BASE);
5940 010011,5.BASE,5.INDEX,5.0,5.FD,000101:COP1X:64,f::LUXC1
5941 "luxc1 f<FD>, r<INDEX>(r<BASE>)"
5947 check_u64 (SD_, instruction_0);
5948 do_luxc1_64 (SD_, FD, INDEX, BASE);
5952 110001,5.BASE,5.FT,16.OFFSET:COP1:32,f::LWC1
5953 "lwc1 f<FT>, <OFFSET>(r<BASE>)"
5969 do_lwc1 (SD_, FT, OFFSET, BASE);
5973 010011,5.BASE,5.INDEX,5.0,5.FD,000000:COP1X:32,f::LWXC1
5974 "lwxc1 f<FD>, r<INDEX>(r<BASE>)"
5982 do_lwxc1 (SD_, FD, INDEX, BASE, instruction_0);
5987 010011,5.FR,5.FT,5.FS,5.FD,100,3.FMT!2!3!4!5!7:COP1X:32,f::MADD.fmt
5988 "madd.%s<FMT> f<FD>, f<FR>, f<FS>, f<FT>"
5996 do_madd_fmt (SD_, FMT, FD, FR, FS, FT, instruction_0);
6000 010001,00000,5.RT,5.FS,00000000000:COP1:32,f::MFC1a
6008 v = EXTEND32 (FGR[FS]);
6009 PENDING_FILL (RT, v);
6010 TRACE_ALU_RESULT (v);
6013 010001,00000,5.RT,5.FS,00000000000:COP1:32,f::MFC1b
6027 do_mfc1b (SD_, RT, FS);
6031 010001,10,3.FMT!2!3!4!5!7,00000,5.FS,5.FD,000110:COP1:32,f::MOV.fmt
6032 "mov.%s<FMT> f<FD>, f<FS>"
6048 do_mov_fmt (SD_, FMT, FD, FS, instruction_0);
6054 000000,5.RS,3.CC,0,1.TF,5.RD,00000,000001:SPECIAL:32,f::MOVtf
6055 "mov%s<TF> r<RD>, r<RS>, <CC>"
6064 do_movtf (SD_, TF, RD, RS, CC);
6070 010001,10,3.FMT!2!3!4!5!7,3.CC,0,1.TF,5.FS,5.FD,010001:COP1:32,f::MOVtf.fmt
6071 "mov%s<TF>.%s<FMT> f<FD>, f<FS>, <CC>"
6080 do_movtf_fmt (SD_, TF, FMT, FD, FS, CC);
6084 010001,10,3.FMT!2!3!4!5!7,5.RT,5.FS,5.FD,010011:COP1:32,f::MOVN.fmt
6085 "movn.%s<FMT> f<FD>, f<FS>, r<RT>"
6094 do_movn_fmt (SD_, FMT, FD, FS, RT);
6101 // MOVT.fmt see MOVtf.fmt
6105 010001,10,3.FMT!2!3!4!5!7,5.RT,5.FS,5.FD,010010:COP1:32,f::MOVZ.fmt
6106 "movz.%s<FMT> f<FD>, f<FS>, r<RT>"
6115 do_movz_fmt (SD_, FMT, FD, FS, RT);
6119 010011,5.FR,5.FT,5.FS,5.FD,101,3.FMT!2!3!4!5!7:COP1X:32,f::MSUB.fmt
6120 "msub.%s<FMT> f<FD>, f<FR>, f<FS>, f<FT>"
6128 do_msub_fmt (SD_, FMT, FD, FR, FS, FT, instruction_0);
6132 010001,00100,5.RT,5.FS,00000000000:COP1:32,f::MTC1a
6139 if (SizeFGR () == 64)
6140 PENDING_FILL ((FS + FGR_BASE), (SET64HI (0xDEADC0DE) | VL4_8 (GPR[RT])));
6142 PENDING_FILL ((FS + FGR_BASE), VL4_8 (GPR[RT]));
6143 TRACE_FP_RESULT (GPR[RT]);
6146 010001,00100,5.RT,5.FS,00000000000:COP1:32,f::MTC1b
6160 do_mtc1b (SD_, RT, FS);
6164 010001,10,3.FMT!2!3!4!5!7,5.FT,5.FS,5.FD,000010:COP1:32,f::MUL.fmt
6165 "mul.%s<FMT> f<FD>, f<FS>, f<FT>"
6181 do_mul_fmt (SD_, FMT, FD, FS, FT, instruction_0);
6185 010001,10,3.FMT!2!3!4!5!7,00000,5.FS,5.FD,000111:COP1:32,f::NEG.fmt
6186 "neg.%s<FMT> f<FD>, f<FS>"
6202 do_neg_fmt (SD_, FMT, FD, FS, instruction_0);
6206 010011,5.FR,5.FT,5.FS,5.FD,110,3.FMT!2!3!4!5!7:COP1X:32,f::NMADD.fmt
6207 "nmadd.%s<FMT> f<FD>, f<FR>, f<FS>, f<FT>"
6215 do_nmadd_fmt (SD_, FMT, FD, FR, FS, FT, instruction_0);
6219 010011,5.FR,5.FT,5.FS,5.FD,111,3.FMT!2!3!4!5!7:COP1X:32,f::NMSUB.fmt
6220 "nmsub.%s<FMT> f<FD>, f<FR>, f<FS>, f<FT>"
6228 do_nmsub_fmt (SD_, FMT, FD, FR, FS, FT, instruction_0);
6232 010001,10,110,5.FT,5.FS,5.FD,101100:COP1:32,f::PLL.PS
6233 "pll.ps f<FD>, f<FS>, f<FT>"
6239 do_pll_ps (SD_, FD, FS, FT, instruction_0);
6243 010001,10,110,5.FT,5.FS,5.FD,101101:COP1:32,f::PLU.PS
6244 "plu.ps f<FD>, f<FS>, f<FT>"
6250 do_plu_ps (SD_, FD, FS, FT, instruction_0);
6254 010011,5.BASE,5.INDEX,5.HINT,00000,001111:COP1X:32::PREFX
6255 "prefx <HINT>, r<INDEX>(r<BASE>)"
6263 do_prefx (SD_, HINT, INDEX, BASE);
6267 010001,10,110,5.FT,5.FS,5.FD,101110:COP1:32,f::PUL.PS
6268 "pul.ps f<FD>, f<FS>, f<FT>"
6274 do_pul_ps (SD_, FD, FS, FT, instruction_0);
6278 010001,10,110,5.FT,5.FS,5.FD,101111:COP1:32,f::PUU.PS
6279 "puu.ps f<FD>, f<FS>, f<FT>"
6285 do_puu_ps (SD_, FD, FS, FT, instruction_0);
6289 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,010101:COP1:32,f::RECIP.fmt
6290 "recip.%s<FMT> f<FD>, f<FS>"
6300 do_recip_fmt (SD_, FMT, FD, FS);
6304 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,001000:COP1:32,f::ROUND.L.fmt
6305 "round.l.%s<FMT> f<FD>, f<FS>"
6318 do_round_fmt (SD_, fmt_long, FMT, FD, FS);
6322 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,001100:COP1:32,f::ROUND.W.fmt
6323 "round.w.%s<FMT> f<FD>, f<FS>"
6338 do_round_fmt (SD_, fmt_word, FMT, FD, FS);
6342 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,010110:COP1:32,f::RSQRT.fmt
6343 "rsqrt.%s<FMT> f<FD>, f<FS>"
6353 do_rsqrt_fmt (SD_, FMT, FD, FS);
6357 111101,5.BASE,5.FT,16.OFFSET:COP1:32,f::SDC1a
6358 "sdc1 f<FT>, <OFFSET>(r<BASE>)"
6364 do_sdc1 (SD_, FT, OFFSET, BASE);
6368 111101,5.BASE,5.FT,16.OFFSET:COP1:32,f::SDC1b
6369 "sdc1 f<FT>, <OFFSET>(r<BASE>)"
6381 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), COP_SD (1, FT));
6385 010011,5.BASE,5.INDEX,5.FS,00000001001:COP1X:32,f::SDXC1
6386 "sdxc1 f<FS>, r<INDEX>(r<BASE>)"
6390 do_store_double (SD_, GPR[BASE], GPR[INDEX], COP_SD (1, FS));
6394 010011,5.BASE,5.INDEX,5.FS,00000001001:COP1X:64,f::SDXC1
6395 "sdxc1 f<FS>, r<INDEX>(r<BASE>)"
6403 check_u64 (SD_, instruction_0);
6404 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], GPR[INDEX], COP_SD (1, FS));
6408 010011,5.BASE,5.INDEX,5.FS,00000,001101:COP1X:32,f::SUXC1
6409 "suxc1 f<FS>, r<INDEX>(r<BASE>)"
6412 do_suxc1_32 (SD_, FS, INDEX, BASE);
6416 010011,5.BASE,5.INDEX,5.FS,00000,001101:COP1X:64,f::SUXC1
6417 "suxc1 f<FS>, r<INDEX>(r<BASE>)"
6423 check_u64 (SD_, instruction_0);
6424 do_suxc1_64 (SD_, FS, INDEX, BASE);
6428 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,000100:COP1:32,f::SQRT.fmt
6429 "sqrt.%s<FMT> f<FD>, f<FS>"
6444 do_sqrt_fmt (SD_, FMT, FD, FS);
6448 010001,10,3.FMT!2!3!4!5!7,5.FT,5.FS,5.FD,000001:COP1:32,f::SUB.fmt
6449 "sub.%s<FMT> f<FD>, f<FS>, f<FT>"
6465 do_sub_fmt (SD_, FMT, FD, FS, FT, instruction_0);
6470 111001,5.BASE,5.FT,16.OFFSET:COP1:32,f::SWC1
6471 "swc1 f<FT>, <OFFSET>(r<BASE>)"
6487 do_swc1 (SD_, FT, OFFSET, BASE, instruction_0);
6491 010011,5.BASE,5.INDEX,5.FS,00000,001000:COP1X:32,f::SWXC1
6492 "swxc1 f<FS>, r<INDEX>(r<BASE>)"
6500 do_swxc1 (SD_, FS, INDEX, BASE, instruction_0);
6504 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,001001:COP1:32,f::TRUNC.L.fmt
6505 "trunc.l.%s<FMT> f<FD>, f<FS>"
6518 do_trunc_fmt (SD_, fmt_long, FMT, FD, FS);
6522 010001,10,3.FMT!2!3!4!5!6!7,00000,5.FS,5.FD,001101:COP1:32,f::TRUNC.W
6523 "trunc.w.%s<FMT> f<FD>, f<FS>"
6538 do_trunc_fmt (SD_, fmt_word, FMT, FD, FS);
6543 // MIPS Architecture:
6545 // System Control Instruction Set (COP0)
6549 010000,01000,00000,16.OFFSET:COP0:32::BC0F
6565 010000,01000,00000,16.OFFSET:COP0:32::BC0F
6567 // stub needed for eCos as tx39 hardware bug workaround
6574 010000,01000,00010,16.OFFSET:COP0:32::BC0FL
6591 010000,01000,00001,16.OFFSET:COP0:32::BC0T
6607 010000,01000,00011,16.OFFSET:COP0:32::BC0TL
6623 :function:::void:do_cache:int op, int rbase, int roffset, address_word instruction_0
6625 address_word base = GPR[rbase];
6626 address_word offset = EXTEND16 (roffset);
6628 address_word vaddr = loadstore_ea (SD_, base, offset);
6629 address_word paddr = vaddr;
6630 CacheOp(op, vaddr, paddr, instruction_0);
6634 101111,5.BASE,5.OP,16.OFFSET:NORMAL:32::CACHE
6635 "cache <OP>, <OFFSET>(r<BASE>)"
6647 do_cache (SD_, OP, BASE, OFFSET, instruction_0);
6651 010000,00001,5.RT,5.RD,00000000,3.SEL:COP0:64::DMFC0
6652 "dmfc0 r<RT>, r<RD>"
6660 check_u64 (SD_, instruction_0);
6661 DecodeCoproc (instruction_0, 0, cp0_dmfc0, RT, RD, SEL);
6665 010000,00101,5.RT,5.RD,00000000,3.SEL:COP0:64::DMTC0
6666 "dmtc0 r<RT>, r<RD>"
6674 check_u64 (SD_, instruction_0);
6675 DecodeCoproc (instruction_0, 0, cp0_dmtc0, RT, RD, SEL);
6679 010000,1,0000000000000000000,011000:COP0:32::ERET
6693 if (SR & status_ERL)
6695 /* Oops, not yet available */
6696 sim_io_printf (SD, "Warning: ERET when SR[ERL] set not supported");
6708 010000,00000,5.RT,5.RD,00000000,3.SEL:COP0:32::MFC0
6709 "mfc0 r<RT>, r<RD> # <SEL>"
6725 TRACE_ALU_INPUT0 ();
6726 DecodeCoproc (instruction_0, 0, cp0_mfc0, RT, RD, SEL);
6727 TRACE_ALU_RESULT (GPR[RT]);
6730 010000,00100,5.RT,5.RD,00000000,3.SEL:COP0:32::MTC0
6731 "mtc0 r<RT>, r<RD> # <SEL>"
6747 DecodeCoproc (instruction_0, 0, cp0_mtc0, RT, RD, SEL);
6751 010000,1,0000000000000000000,010000:COP0:32::RFE
6762 DecodeCoproc (instruction_0, 0, cp0_rfe, 0, 0, 0x10);
6766 0100,ZZ!0!1!3,5.COP_FUN0!8,5.COP_FUN1,16.COP_FUN2:NORMAL:32::COPz
6767 "cop<ZZ> <COP_FUN0><COP_FUN1><COP_FUN2>"
6782 DecodeCoproc (instruction_0, 2, 0, 0, 0, 0);
6787 010000,1,0000000000000000000,001000:COP0:32::TLBP
6804 010000,1,0000000000000000000,000001:COP0:32::TLBR
6821 010000,1,0000000000000000000,000010:COP0:32::TLBWI
6838 010000,1,0000000000000000000,000110:COP0:32::TLBWR
6855 :include:::mips3264r2.igen
6856 :include:::mips3264r6.igen
6858 :include:::m16e.igen
6859 :include:::mdmx.igen
6860 :include:::mips3d.igen
6865 :include:::dsp2.igen
6866 :include:::smartmips.igen
6867 :include:::micromips.igen
6868 :include:::micromipsdsp.igen