2 Copyright (C) 1999-2022 Free Software Foundation, Inc.
3 Contributed by Red Hat.
5 This file is part of the GNU simulators.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* This must come before any other includes. */
23 #define WANT_CPU frvbf
24 #define WANT_CPU_FRVBF
27 #include "cgen-engine.h"
30 #include "sim-signal.h"
31 #include "sim/callback.h"
34 #include "libiberty.h"
38 CGEN_ATTR_VALUE_ENUM_TYPE frv_current_fm_slot;
40 /* The semantic code invokes this for invalid (unrecognized) instructions. */
43 sim_engine_invalid_insn (SIM_CPU *current_cpu, IADDR cia, SEM_PC vpc)
45 frv_queue_program_interrupt (current_cpu, FRV_ILLEGAL_INSTRUCTION);
49 /* Process an address exception. */
52 frv_core_signal (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia,
53 unsigned int map, int nr_bytes, address_word addr,
54 transfer_type transfer, sim_core_signals sig)
56 if (sig == sim_core_unaligned_signal)
58 if (STATE_ARCHITECTURE (sd)->mach == bfd_mach_fr400
59 || STATE_ARCHITECTURE (sd)->mach == bfd_mach_fr450)
60 frv_queue_data_access_error_interrupt (current_cpu, addr);
62 frv_queue_mem_address_not_aligned_interrupt (current_cpu, addr);
66 sim_core_signal (sd, current_cpu, cia, map, nr_bytes, addr, transfer, sig);
70 frv_sim_engine_halt_hook (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia)
73 if (current_cpu != NULL)
74 CPU_PC_SET (current_cpu, cia);
76 /* Invalidate the insn and data caches of all cpus. */
77 for (i = 0; i < MAX_NR_PROCESSORS; ++i)
79 current_cpu = STATE_CPU (sd, i);
80 frv_cache_invalidate_all (CPU_INSN_CACHE (current_cpu), 0);
81 frv_cache_invalidate_all (CPU_DATA_CACHE (current_cpu), 1);
86 /* Read/write functions for system call interface. */
89 syscall_read_mem (host_callback *cb, struct cb_syscall *sc,
90 unsigned long taddr, char *buf, int bytes)
92 SIM_DESC sd = (SIM_DESC) sc->p1;
93 SIM_CPU *cpu = (SIM_CPU *) sc->p2;
95 frv_cache_invalidate_all (CPU_DATA_CACHE (cpu), 1);
96 return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
100 syscall_write_mem (host_callback *cb, struct cb_syscall *sc,
101 unsigned long taddr, const char *buf, int bytes)
103 SIM_DESC sd = (SIM_DESC) sc->p1;
104 SIM_CPU *cpu = (SIM_CPU *) sc->p2;
106 frv_cache_invalidate_all (CPU_INSN_CACHE (cpu), 0);
107 frv_cache_invalidate_all (CPU_DATA_CACHE (cpu), 1);
108 return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
111 /* Handle TRA and TIRA insns. */
113 frv_itrap (SIM_CPU *current_cpu, PCADDR pc, USI base, SI offset)
115 SIM_DESC sd = CPU_STATE (current_cpu);
116 host_callback *cb = STATE_CALLBACK (sd);
117 USI num = ((base + offset) & 0x7f) + 0x80;
119 if (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)
121 frv_queue_software_interrupt (current_cpu, num);
130 CB_SYSCALL_INIT (&s);
131 s.func = GET_H_GR (7);
132 s.arg1 = GET_H_GR (8);
133 s.arg2 = GET_H_GR (9);
134 s.arg3 = GET_H_GR (10);
136 if (cb_target_to_host_syscall (cb, s.func) == CB_SYS_exit)
138 sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, s.arg1);
143 s.read_mem = syscall_read_mem;
144 s.write_mem = syscall_write_mem;
146 SET_H_GR (8, s.result);
147 SET_H_GR (9, s.result2);
148 SET_H_GR (10, s.errcode);
152 case TRAP_BREAKPOINT:
153 sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped, SIM_SIGTRAP);
156 /* Add support for dumping registers, either at fixed traps, or all
157 unknown traps if configured with --enable-sim-trapdump. */
160 frv_queue_software_interrupt (current_cpu, num);
172 #if TRAPDUMP || (defined (TRAP_REGDUMP1)) || (defined (TRAP_REGDUMP2))
178 if (STATE_TEXT_SECTION (sd)
179 && pc >= STATE_TEXT_START (sd)
180 && pc < STATE_TEXT_END (sd))
182 const char *pc_filename = (const char *)0;
183 const char *pc_function = (const char *)0;
184 unsigned int pc_linenum = 0;
186 if (bfd_find_nearest_line (STATE_PROG_BFD (sd),
187 STATE_TEXT_SECTION (sd),
188 (struct bfd_symbol **) 0,
189 pc - STATE_TEXT_START (sd),
190 &pc_filename, &pc_function, &pc_linenum)
191 && (pc_function || pc_filename))
198 strcpy (p, pc_function);
203 char *q = (char *) strrchr (pc_filename, '/');
204 strcpy (p, (q) ? q+1 : pc_filename);
210 sprintf (p, " line %d", pc_linenum);
216 if ((p+1) - buf > sizeof (buf))
222 "\nRegister dump, pc = 0x%.8x%s, base = %u, offset = %d\n",
223 (unsigned)pc, buf, (unsigned)base, (int)offset);
225 for (i = 0; i < 64; i += 8)
227 long g0 = (long)GET_H_GR (i);
228 long g1 = (long)GET_H_GR (i+1);
229 long g2 = (long)GET_H_GR (i+2);
230 long g3 = (long)GET_H_GR (i+3);
231 long g4 = (long)GET_H_GR (i+4);
232 long g5 = (long)GET_H_GR (i+5);
233 long g6 = (long)GET_H_GR (i+6);
234 long g7 = (long)GET_H_GR (i+7);
236 if ((g0 | g1 | g2 | g3 | g4 | g5 | g6 | g7) != 0)
238 "\tgr%02d - gr%02d: 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx\n",
239 i, i+7, g0, g1, g2, g3, g4, g5, g6, g7);
242 for (i = 0; i < 64; i += 8)
244 long f0 = (long)GET_H_FR (i);
245 long f1 = (long)GET_H_FR (i+1);
246 long f2 = (long)GET_H_FR (i+2);
247 long f3 = (long)GET_H_FR (i+3);
248 long f4 = (long)GET_H_FR (i+4);
249 long f5 = (long)GET_H_FR (i+5);
250 long f6 = (long)GET_H_FR (i+6);
251 long f7 = (long)GET_H_FR (i+7);
253 if ((f0 | f1 | f2 | f3 | f4 | f5 | f6 | f7) != 0)
255 "\tfr%02d - fr%02d: 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx\n",
256 i, i+7, f0, f1, f2, f3, f4, f5, f6, f7);
260 "\tlr/lcr/cc/ccc: 0x%.8lx 0x%.8lx 0x%.8lx 0x%.8lx\n",
261 (long)GET_H_SPR (272),
262 (long)GET_H_SPR (273),
263 (long)GET_H_SPR (256),
264 (long)GET_H_SPR (263));
271 /* Handle the MTRAP insn. */
273 frv_mtrap (SIM_CPU *current_cpu)
275 SIM_DESC sd = CPU_STATE (current_cpu);
277 /* Check the status of media exceptions in MSR0. */
278 SI msr = GET_MSR (0);
279 if (GET_MSR_AOVF (msr)
280 || (GET_MSR_MTT (msr) && STATE_ARCHITECTURE (sd)->mach != bfd_mach_fr550))
281 frv_queue_program_interrupt (current_cpu, FRV_MP_EXCEPTION);
284 /* Handle the BREAK insn. */
286 frv_break (SIM_CPU *current_cpu)
288 SIM_DESC sd = CPU_STATE (current_cpu);
290 if (STATE_ENVIRONMENT (sd) != OPERATING_ENVIRONMENT)
292 /* Invalidate the insn cache because the debugger will presumably
293 replace the breakpoint insn with the real one. */
294 sim_engine_halt (sd, current_cpu, NULL, NULL_CIA, sim_stopped,
298 frv_queue_break_interrupt (current_cpu);
301 /* Return from trap. */
303 frv_rett (SIM_CPU *current_cpu, PCADDR pc, BI debug_field)
306 /* if (normal running mode and debug_field==0
310 else if (debug running mode and debug_field==1)
314 change to normal running mode
316 int psr_s = GET_H_PSR_S ();
317 int psr_et = GET_H_PSR_ET ();
319 /* Check for exceptions in the priority order listed in the FRV Architecture
323 /* Halt if PSR.ET is not set. See chapter 6 of the LSI. */
326 SIM_DESC sd = CPU_STATE (current_cpu);
327 sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped, SIM_SIGTRAP);
330 /* privileged_instruction interrupt will have already been queued by
331 frv_detect_insn_access_interrupts. */
336 /* Halt if PSR.S is set. See chapter 6 of the LSI. */
339 SIM_DESC sd = CPU_STATE (current_cpu);
340 sim_engine_halt (sd, current_cpu, NULL, pc, sim_stopped, SIM_SIGTRAP);
343 frv_queue_program_interrupt (current_cpu, FRV_ILLEGAL_INSTRUCTION);
346 else if (! CPU_DEBUG_STATE (current_cpu) && debug_field == 0)
348 USI psr = GET_PSR ();
349 /* Return from normal running state. */
350 new_pc = GET_H_SPR (H_SPR_PCSR);
352 SET_PSR_S (psr, GET_PSR_PS (psr));
353 sim_queue_fn_si_write (current_cpu, frvbf_h_spr_set, H_SPR_PSR, psr);
355 else if (CPU_DEBUG_STATE (current_cpu) && debug_field == 1)
357 USI psr = GET_PSR ();
358 /* Return from debug state. */
359 new_pc = GET_H_SPR (H_SPR_BPCSR);
360 SET_PSR_ET (psr, GET_H_BPSR_BET ());
361 SET_PSR_S (psr, GET_H_BPSR_BS ());
362 sim_queue_fn_si_write (current_cpu, frvbf_h_spr_set, H_SPR_PSR, psr);
363 CPU_DEBUG_STATE (current_cpu) = 0;
371 /* Functions for handling non-excepting instruction side effects. */
372 static SI next_available_nesr (SIM_CPU *current_cpu, SI current_index)
374 FRV_REGISTER_CONTROL *control = CPU_REGISTER_CONTROL (current_cpu);
375 if (control->spr[H_SPR_NECR].implemented)
378 USI necr = GET_NECR ();
380 /* See if any NESRs are implemented. First need to check the validity of
382 if (! GET_NECR_VALID (necr))
385 limit = GET_NECR_NEN (necr);
386 for (++current_index; current_index < limit; ++current_index)
388 SI nesr = GET_NESR (current_index);
389 if (! GET_NESR_VALID (nesr))
390 return current_index;
396 static SI next_valid_nesr (SIM_CPU *current_cpu, SI current_index)
398 FRV_REGISTER_CONTROL *control = CPU_REGISTER_CONTROL (current_cpu);
399 if (control->spr[H_SPR_NECR].implemented)
402 USI necr = GET_NECR ();
404 /* See if any NESRs are implemented. First need to check the validity of
406 if (! GET_NECR_VALID (necr))
409 limit = GET_NECR_NEN (necr);
410 for (++current_index; current_index < limit; ++current_index)
412 SI nesr = GET_NESR (current_index);
413 if (GET_NESR_VALID (nesr))
414 return current_index;
421 frvbf_check_non_excepting_load (
422 SIM_CPU *current_cpu, SI base_index, SI disp_index, SI target_index,
423 SI immediate_disp, QI data_size, BI is_float
426 BI rc = 1; /* perform the load. */
427 SIM_DESC sd = CPU_STATE (current_cpu);
437 FRV_REGISTER_CONTROL *control;
439 SI address = GET_H_GR (base_index);
441 address += GET_H_GR (disp_index);
443 address += immediate_disp;
445 /* Check for interrupt factors. */
463 if (target_index & 1)
469 if (target_index & 3)
474 IADDR pc = GET_H_PC ();
475 sim_engine_abort (sd, current_cpu, pc,
476 "check_non_excepting_load: Incorrect data_size\n");
481 control = CPU_REGISTER_CONTROL (current_cpu);
482 if (control->spr[H_SPR_NECR].implemented)
485 do_elos = GET_NECR_VALID (necr) && GET_NECR_ELOS (necr);
490 /* NECR, NESR, NEEAR are only implemented for the full frv machine. */
493 ne_index = next_available_nesr (current_cpu, NO_NESR);
494 if (ne_index == NO_NESR)
496 IADDR pc = GET_H_PC ();
497 sim_engine_abort (sd, current_cpu, pc,
498 "No available NESR register\n");
501 /* Fill in the basic fields of the NESR. */
502 nesr = GET_NESR (ne_index);
503 SET_NESR_VALID (nesr);
505 SET_NESR_DRN (nesr, target_index);
506 SET_NESR_SIZE (nesr, data_size);
507 SET_NESR_NEAN (nesr, ne_index);
511 CLEAR_NESR_FR (nesr);
513 /* Set the corresponding NEEAR. */
514 SET_NEEAR (ne_index, address);
516 SET_NESR_DAEC (nesr, 0);
517 SET_NESR_REC (nesr, 0);
518 SET_NESR_EC (nesr, 0);
521 /* Set the NE flag corresponding to the target register if an interrupt
523 daec is not checked here yet, but is declared for future reference. */
525 NE_base = H_SPR_FNER0;
527 NE_base = H_SPR_GNER0;
529 GET_NE_FLAGS (NE_flags, NE_base);
532 SET_NE_FLAG (NE_flags, target_index);
534 SET_NESR_REC (nesr, NESR_REGISTER_NOT_ALIGNED);
539 SET_NE_FLAG (NE_flags, target_index);
541 SET_NESR_EC (nesr, NESR_MEM_ADDRESS_NOT_ALIGNED);
545 SET_NESR (ne_index, nesr);
547 /* If no interrupt factor was detected then set the NE flag on the
548 target register if the NE flag on one of the input registers
550 if (! rec && ! ec && ! daec)
552 BI ne_flag = GET_NE_FLAG (NE_flags, base_index);
554 ne_flag |= GET_NE_FLAG (NE_flags, disp_index);
557 SET_NE_FLAG (NE_flags, target_index);
558 rc = 0; /* Do not perform the load. */
561 CLEAR_NE_FLAG (NE_flags, target_index);
564 SET_NE_FLAGS (NE_base, NE_flags);
566 return rc; /* perform the load? */
569 /* Record state for media exception: media_cr_not_aligned. */
571 frvbf_media_cr_not_aligned (SIM_CPU *current_cpu)
573 SIM_DESC sd = CPU_STATE (current_cpu);
575 /* On some machines this generates an illegal_instruction interrupt. */
576 switch (STATE_ARCHITECTURE (sd)->mach)
578 /* Note: there is a discrepancy between V2.2 of the FR400
579 instruction manual and the various FR4xx LSI specs. The former
580 claims that unaligned registers cause an mp_exception while the
581 latter say it's an illegal_instruction. The LSI specs appear
582 to be correct since MTT is fixed at 1. */
586 frv_queue_program_interrupt (current_cpu, FRV_ILLEGAL_INSTRUCTION);
589 frv_set_mp_exception_registers (current_cpu, MTT_CR_NOT_ALIGNED, 0);
594 /* Record state for media exception: media_acc_not_aligned. */
596 frvbf_media_acc_not_aligned (SIM_CPU *current_cpu)
598 SIM_DESC sd = CPU_STATE (current_cpu);
600 /* On some machines this generates an illegal_instruction interrupt. */
601 switch (STATE_ARCHITECTURE (sd)->mach)
603 /* See comment in frvbf_cr_not_aligned(). */
607 frv_queue_program_interrupt (current_cpu, FRV_ILLEGAL_INSTRUCTION);
610 frv_set_mp_exception_registers (current_cpu, MTT_ACC_NOT_ALIGNED, 0);
615 /* Record state for media exception: media_register_not_aligned. */
617 frvbf_media_register_not_aligned (SIM_CPU *current_cpu)
619 SIM_DESC sd = CPU_STATE (current_cpu);
621 /* On some machines this generates an illegal_instruction interrupt. */
622 switch (STATE_ARCHITECTURE (sd)->mach)
624 /* See comment in frvbf_cr_not_aligned(). */
628 frv_queue_program_interrupt (current_cpu, FRV_ILLEGAL_INSTRUCTION);
631 frv_set_mp_exception_registers (current_cpu, MTT_INVALID_FR, 0);
636 /* Record state for media exception: media_overflow. */
638 frvbf_media_overflow (SIM_CPU *current_cpu, int sie)
640 frv_set_mp_exception_registers (current_cpu, MTT_OVERFLOW, sie);
643 /* Queue a division exception. */
645 frvbf_division_exception (SIM_CPU *current_cpu, enum frv_dtt dtt,
646 int target_index, int non_excepting)
648 /* If there was an overflow and it is masked, then record it in
650 USI isr = GET_ISR ();
651 if ((dtt & FRV_DTT_OVERFLOW) && GET_ISR_EDE (isr))
653 dtt &= ~FRV_DTT_OVERFLOW;
657 if (dtt != FRV_DTT_NO_EXCEPTION)
661 /* Non excepting instruction, simply set the NE flag for the target
664 GET_NE_FLAGS (NE_flags, H_SPR_GNER0);
665 SET_NE_FLAG (NE_flags, target_index);
666 SET_NE_FLAGS (H_SPR_GNER0, NE_flags);
669 frv_queue_division_exception_interrupt (current_cpu, dtt);
675 frvbf_check_recovering_store (
676 SIM_CPU *current_cpu, PCADDR address, SI regno, int size, int is_float
679 FRV_CACHE *cache = CPU_DATA_CACHE (current_cpu);
682 CPU_RSTR_INVALIDATE(current_cpu) = 0;
684 for (reg_ix = next_valid_nesr (current_cpu, NO_NESR);
686 reg_ix = next_valid_nesr (current_cpu, reg_ix))
688 if (address == GET_H_SPR (H_SPR_NEEAR0 + reg_ix))
690 SI nesr = GET_NESR (reg_ix);
691 int nesr_drn = GET_NESR_DRN (nesr);
692 BI nesr_fr = GET_NESR_FR (nesr);
695 /* Invalidate cache block containing this address.
696 If we need to count cycles, then the cache operation will be
697 initiated from the model profiling functions.
698 See frvbf_model_.... */
701 CPU_RSTR_INVALIDATE(current_cpu) = 1;
702 CPU_LOAD_ADDRESS (current_cpu) = address;
705 frv_cache_invalidate (cache, address, 1/* flush */);
707 /* Copy the stored value to the register indicated by NESR.DRN. */
708 for (remain = size; remain > 0; remain -= 4)
713 value = GET_H_FR (regno);
715 value = GET_H_GR (regno);
730 sim_queue_fn_sf_write (current_cpu, frvbf_h_fr_set, nesr_drn,
733 sim_queue_fn_si_write (current_cpu, frvbf_h_gr_set, nesr_drn,
739 break; /* Only consider the first matching register. */
741 } /* loop over active neear registers. */
745 frvbf_check_acc_range (SIM_CPU *current_cpu, SI regno)
747 /* Only applicable to fr550 */
748 SIM_DESC sd = CPU_STATE (current_cpu);
749 if (STATE_ARCHITECTURE (sd)->mach != bfd_mach_fr550)
752 /* On the fr550, media insns in slots 0 and 2 can only access
753 accumulators acc0-acc3. Insns in slots 1 and 3 can only access
754 accumulators acc4-acc7 */
755 switch (frv_current_fm_slot)
760 return 1; /* all is ok */
765 return 1; /* all is ok */
769 /* The specified accumulator is out of range. Queue an illegal_instruction
771 frv_queue_program_interrupt (current_cpu, FRV_ILLEGAL_INSTRUCTION);
776 frvbf_check_swap_address (SIM_CPU *current_cpu, SI address)
778 /* Only applicable to fr550 */
779 SIM_DESC sd = CPU_STATE (current_cpu);
780 if (STATE_ARCHITECTURE (sd)->mach != bfd_mach_fr550)
783 /* Adress must be aligned on a word boundary. */
785 frv_queue_data_access_exception_interrupt (current_cpu);
789 clear_nesr_neear (SIM_CPU *current_cpu, SI target_index, BI is_float)
793 /* Only implemented for full frv. */
794 SIM_DESC sd = CPU_STATE (current_cpu);
795 if (STATE_ARCHITECTURE (sd)->mach != bfd_mach_frv)
798 /* Clear the appropriate NESR and NEEAR registers. */
799 for (reg_ix = next_valid_nesr (current_cpu, NO_NESR);
801 reg_ix = next_valid_nesr (current_cpu, reg_ix))
804 /* The register is available, now check if it is active. */
805 nesr = GET_NESR (reg_ix);
806 if (GET_NESR_FR (nesr) == is_float)
808 if (target_index < 0 || GET_NESR_DRN (nesr) == target_index)
810 SET_NESR (reg_ix, 0);
811 SET_NEEAR (reg_ix, 0);
819 SIM_CPU *current_cpu,
829 GET_NE_FLAGS (NE_flags, NE_base);
830 if (target_index >= 0)
831 CLEAR_NE_FLAG (NE_flags, target_index);
839 SET_NE_FLAGS (NE_base, NE_flags);
842 /* Return 1 if the given register is available, 0 otherwise. TARGET_INDEX==-1
843 means to check for any register available. */
845 which_registers_available (
846 SIM_CPU *current_cpu, int *hi_available, int *lo_available, int is_float
850 frv_fr_registers_available (current_cpu, hi_available, lo_available);
852 frv_gr_registers_available (current_cpu, hi_available, lo_available);
856 frvbf_clear_ne_flags (SIM_CPU *current_cpu, SI target_index, BI is_float)
863 FRV_REGISTER_CONTROL *control;
865 /* Check for availability of the target register(s). */
866 which_registers_available (current_cpu, & hi_available, & lo_available,
869 /* Check to make sure that the target register is available. */
870 if (! frv_check_register_access (current_cpu, target_index,
871 hi_available, lo_available))
874 /* Determine whether we're working with GR or FR registers. */
876 NE_base = H_SPR_FNER0;
878 NE_base = H_SPR_GNER0;
880 /* Always clear the appropriate NE flags. */
881 clear_ne_flags (current_cpu, target_index, hi_available, lo_available,
884 /* Clear the appropriate NESR and NEEAR registers. */
885 control = CPU_REGISTER_CONTROL (current_cpu);
886 if (control->spr[H_SPR_NECR].implemented)
889 if (GET_NECR_VALID (necr) && GET_NECR_ELOS (necr))
890 clear_nesr_neear (current_cpu, target_index, is_float);
895 frvbf_commit (SIM_CPU *current_cpu, SI target_index, BI is_float)
904 FRV_REGISTER_CONTROL *control;
906 /* Check for availability of the target register(s). */
907 which_registers_available (current_cpu, & hi_available, & lo_available,
910 /* Check to make sure that the target register is available. */
911 if (! frv_check_register_access (current_cpu, target_index,
912 hi_available, lo_available))
915 /* Determine whether we're working with GR or FR registers. */
917 NE_base = H_SPR_FNER0;
919 NE_base = H_SPR_GNER0;
921 /* Determine whether a ne exception is pending. */
922 GET_NE_FLAGS (NE_flags, NE_base);
923 if (target_index >= 0)
924 NE_flag = GET_NE_FLAG (NE_flags, target_index);
927 NE_flag = (hi_available && NE_flags[0] != 0)
928 || (lo_available && NE_flags[1] != 0);
931 /* Always clear the appropriate NE flags. */
932 clear_ne_flags (current_cpu, target_index, hi_available, lo_available,
935 control = CPU_REGISTER_CONTROL (current_cpu);
936 if (control->spr[H_SPR_NECR].implemented)
939 if (GET_NECR_VALID (necr) && GET_NECR_ELOS (necr) && NE_flag)
941 /* Clear the appropriate NESR and NEEAR registers. */
942 clear_nesr_neear (current_cpu, target_index, is_float);
943 frv_queue_program_interrupt (current_cpu, FRV_COMMIT_EXCEPTION);
948 /* Generate the appropriate fp_exception(s) based on the given status code. */
950 frvbf_fpu_error (CGEN_FPU* fpu, int status)
952 struct frv_fp_exception_info fp_info = {
953 FSR_NO_EXCEPTION, FTT_IEEE_754_EXCEPTION
957 (sim_fpu_status_invalid_snan |
958 sim_fpu_status_invalid_qnan |
959 sim_fpu_status_invalid_isi |
960 sim_fpu_status_invalid_idi |
961 sim_fpu_status_invalid_zdz |
962 sim_fpu_status_invalid_imz |
963 sim_fpu_status_invalid_cvi |
964 sim_fpu_status_invalid_cmp |
965 sim_fpu_status_invalid_sqrt))
966 fp_info.fsr_mask |= FSR_INVALID_OPERATION;
968 if (status & sim_fpu_status_invalid_div0)
969 fp_info.fsr_mask |= FSR_DIVISION_BY_ZERO;
971 if (status & sim_fpu_status_inexact)
972 fp_info.fsr_mask |= FSR_INEXACT;
974 if (status & sim_fpu_status_overflow)
975 fp_info.fsr_mask |= FSR_OVERFLOW;
977 if (status & sim_fpu_status_underflow)
978 fp_info.fsr_mask |= FSR_UNDERFLOW;
980 if (status & sim_fpu_status_denorm)
982 fp_info.fsr_mask |= FSR_DENORMAL_INPUT;
983 fp_info.ftt = FTT_DENORMAL_INPUT;
986 if (fp_info.fsr_mask != FSR_NO_EXCEPTION)
988 SIM_CPU *current_cpu = (SIM_CPU *)fpu->owner;
989 frv_queue_fp_exception_interrupt (current_cpu, & fp_info);