1 /* frv simulator fr500 dependent profiling code.
3 Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
6 This file is part of the GNU simulators.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #define WANT_CPU_FRVBF
29 #if WITH_PROFILE_MODEL_P
32 #include "profile-fr500.h"
34 /* Initialize cycle counting for an insn.
35 FIRST_P is non-zero if this is the first insn in a set of parallel
38 fr500_model_insn_before (SIM_CPU *cpu, int first_p)
42 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
43 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
44 ps->cur_gr_complex = ps->prev_gr_complex;
45 d->cur_fpop = d->prev_fpop;
46 d->cur_media = d->prev_media;
47 d->cur_cc_complex = d->prev_cc_complex;
51 /* Record the cycles computed for an insn.
52 LAST_P is non-zero if this is the last insn in a set of parallel insns,
53 and we update the total cycle count.
54 CYCLES is the cycle count of the insn. */
56 fr500_model_insn_after (SIM_CPU *cpu, int last_p, int cycles)
60 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
61 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
62 ps->prev_gr_complex = ps->cur_gr_complex;
63 d->prev_fpop = d->cur_fpop;
64 d->prev_media = d->cur_media;
65 d->prev_cc_complex = d->cur_cc_complex;
70 set_use_is_fpop (SIM_CPU *cpu, INT fr)
72 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
73 fr500_reset_fr_flags (cpu, (fr));
74 d->cur_fpop |= (((DI)1) << (fr));
78 set_use_not_fpop (SIM_CPU *cpu, INT fr)
80 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
81 d->cur_fpop &= ~(((DI)1) << (fr));
85 use_is_fpop (SIM_CPU *cpu, INT fr)
87 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
88 return d->prev_fpop & (((DI)1) << (fr));
92 set_use_is_media ( SIM_CPU *cpu, INT fr)
94 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
95 fr500_reset_fr_flags (cpu, (fr));
96 d->cur_media |= (((DI)1) << (fr));
100 set_use_not_media (SIM_CPU *cpu, INT fr)
102 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
103 d->cur_media &= ~(((DI)1) << (fr));
107 use_is_media (SIM_CPU *cpu, INT fr)
109 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
110 return d->prev_media & (((DI)1) << (fr));
114 set_use_is_cc_complex (SIM_CPU *cpu, INT cc)
116 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
117 fr500_reset_cc_flags (cpu, cc);
118 d->cur_cc_complex |= (((DI)1) << (cc));
122 set_use_not_cc_complex (SIM_CPU *cpu, INT cc)
124 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
125 d->cur_cc_complex &= ~(((DI)1) << (cc));
129 use_is_cc_complex (SIM_CPU *cpu, INT cc)
131 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
132 return d->prev_cc_complex & (((DI)1) << (cc));
136 fr500_reset_fr_flags (SIM_CPU *cpu, INT fr)
138 set_use_not_fpop (cpu, fr);
139 set_use_not_media (cpu, fr);
143 fr500_reset_cc_flags (SIM_CPU *cpu, INT cc)
145 set_use_not_cc_complex (cpu, cc);
148 /* Latency of floating point registers may be less than recorded when followed
149 by another floating point insn. */
151 adjust_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
154 /* If the registers were previously used in a floating point op,
155 then their latency will be less than previously recorded.
156 See Table 13-13 in the LSI. */
158 if (use_is_fpop (cpu, in_FRi))
159 decrease_FR_busy (cpu, in_FRi, cycles);
161 enforce_full_fr_latency (cpu, in_FRi);
163 if (in_FRj >= 0 && in_FRj != in_FRi)
164 if (use_is_fpop (cpu, in_FRj))
165 decrease_FR_busy (cpu, in_FRj, cycles);
167 enforce_full_fr_latency (cpu, in_FRj);
169 if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
170 if (use_is_fpop (cpu, out_FRk))
171 decrease_FR_busy (cpu, out_FRk, cycles);
173 enforce_full_fr_latency (cpu, out_FRk);
176 /* Latency of floating point registers may be less than recorded when followed
177 by another floating point insn. */
179 adjust_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
182 /* If the registers were previously used in a floating point op,
183 then their latency will be less than previously recorded.
184 See Table 13-13 in the LSI. */
185 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
186 if (in_FRi >= 0) ++in_FRi;
187 if (in_FRj >= 0) ++in_FRj;
188 if (out_FRk >= 0) ++out_FRk;
189 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
192 /* Latency of floating point registers is less than recorded when followed
193 by another floating point insn. */
195 restore_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
198 /* If the registers were previously used in a floating point op,
199 then their latency will be less than previously recorded.
200 See Table 13-13 in the LSI. */
201 if (in_FRi >= 0 && use_is_fpop (cpu, in_FRi))
202 increase_FR_busy (cpu, in_FRi, cycles);
203 if (in_FRj != in_FRi && use_is_fpop (cpu, in_FRj))
204 increase_FR_busy (cpu, in_FRj, cycles);
205 if (out_FRk != in_FRi && out_FRk != in_FRj && use_is_fpop (cpu, out_FRk))
206 increase_FR_busy (cpu, out_FRk, cycles);
209 /* Latency of floating point registers is less than recorded when followed
210 by another floating point insn. */
212 restore_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
215 /* If the registers were previously used in a floating point op,
216 then their latency will be less than previously recorded.
217 See Table 13-13 in the LSI. */
218 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
219 if (in_FRi >= 0) ++in_FRi;
220 if (in_FRj >= 0) ++in_FRj;
221 if (out_FRk >= 0) ++out_FRk;
222 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
226 frvbf_model_fr500_u_exec (SIM_CPU *cpu, const IDESC *idesc,
227 int unit_num, int referenced)
229 return idesc->timing->units[unit_num].done;
233 frvbf_model_fr500_u_integer (SIM_CPU *cpu, const IDESC *idesc,
234 int unit_num, int referenced,
235 INT in_GRi, INT in_GRj, INT out_GRk,
240 if (model_insn == FRV_INSN_MODEL_PASS_1)
242 /* icc0-icc4 are the upper 4 fields of the CCR. */
246 /* The entire VLIW insn must wait if there is a dependency on a register
247 which is not ready yet.
248 The latency of the registers may be less than previously recorded,
249 depending on how they were used previously.
250 See Table 13-8 in the LSI. */
251 if (in_GRi != out_GRk && in_GRi >= 0)
253 if (use_is_gr_complex (cpu, in_GRi))
254 decrease_GR_busy (cpu, in_GRi, 1);
256 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
258 if (use_is_gr_complex (cpu, in_GRj))
259 decrease_GR_busy (cpu, in_GRj, 1);
261 vliw_wait_for_GR (cpu, in_GRi);
262 vliw_wait_for_GR (cpu, in_GRj);
263 vliw_wait_for_GR (cpu, out_GRk);
264 vliw_wait_for_CCR (cpu, out_ICCi_1);
265 handle_resource_wait (cpu);
266 load_wait_for_GR (cpu, in_GRi);
267 load_wait_for_GR (cpu, in_GRj);
268 load_wait_for_GR (cpu, out_GRk);
269 trace_vliw_wait_cycles (cpu);
273 /* GRk is available immediately to the next VLIW insn as is ICCi_1. */
274 cycles = idesc->timing->units[unit_num].done;
279 frvbf_model_fr500_u_imul (SIM_CPU *cpu, const IDESC *idesc,
280 int unit_num, int referenced,
281 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
284 /* icc0-icc4 are the upper 4 fields of the CCR. */
288 if (model_insn == FRV_INSN_MODEL_PASS_1)
290 /* The entire VLIW insn must wait if there is a dependency on a register
291 which is not ready yet.
292 The latency of the registers may be less than previously recorded,
293 depending on how they were used previously.
294 See Table 13-8 in the LSI. */
295 if (in_GRi != out_GRk && in_GRi >= 0)
297 if (use_is_gr_complex (cpu, in_GRi))
298 decrease_GR_busy (cpu, in_GRi, 1);
300 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
302 if (use_is_gr_complex (cpu, in_GRj))
303 decrease_GR_busy (cpu, in_GRj, 1);
305 vliw_wait_for_GR (cpu, in_GRi);
306 vliw_wait_for_GR (cpu, in_GRj);
307 vliw_wait_for_GRdouble (cpu, out_GRk);
308 vliw_wait_for_CCR (cpu, out_ICCi_1);
309 handle_resource_wait (cpu);
310 load_wait_for_GR (cpu, in_GRi);
311 load_wait_for_GR (cpu, in_GRj);
312 load_wait_for_GRdouble (cpu, out_GRk);
313 trace_vliw_wait_cycles (cpu);
317 /* GRk has a latency of 2 cycles. */
318 cycles = idesc->timing->units[unit_num].done;
319 update_GRdouble_latency (cpu, out_GRk, cycles + 2);
320 set_use_is_gr_complex (cpu, out_GRk);
321 set_use_is_gr_complex (cpu, out_GRk + 1);
323 /* ICCi_1 has a latency of 1 cycle. */
324 update_CCR_latency (cpu, out_ICCi_1, cycles + 1);
330 frvbf_model_fr500_u_idiv (SIM_CPU *cpu, const IDESC *idesc,
331 int unit_num, int referenced,
332 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
338 /* icc0-icc4 are the upper 4 fields of the CCR. */
342 vliw = CPU_VLIW (cpu);
343 slot = vliw->next_slot - 1;
344 slot = (*vliw->current_vliw)[slot] - UNIT_I0;
346 if (model_insn == FRV_INSN_MODEL_PASS_1)
348 /* The entire VLIW insn must wait if there is a dependency on a register
349 which is not ready yet.
350 The latency of the registers may be less than previously recorded,
351 depending on how they were used previously.
352 See Table 13-8 in the LSI. */
353 if (in_GRi != out_GRk && in_GRi >= 0)
355 if (use_is_gr_complex (cpu, in_GRi))
356 decrease_GR_busy (cpu, in_GRi, 1);
358 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
360 if (use_is_gr_complex (cpu, in_GRj))
361 decrease_GR_busy (cpu, in_GRj, 1);
363 vliw_wait_for_GR (cpu, in_GRi);
364 vliw_wait_for_GR (cpu, in_GRj);
365 vliw_wait_for_GR (cpu, out_GRk);
366 vliw_wait_for_CCR (cpu, out_ICCi_1);
367 vliw_wait_for_idiv_resource (cpu, slot);
368 handle_resource_wait (cpu);
369 load_wait_for_GR (cpu, in_GRi);
370 load_wait_for_GR (cpu, in_GRj);
371 load_wait_for_GR (cpu, out_GRk);
372 trace_vliw_wait_cycles (cpu);
376 /* GRk has a latency of 19 cycles! */
377 cycles = idesc->timing->units[unit_num].done;
378 update_GR_latency (cpu, out_GRk, cycles + 19);
379 set_use_is_gr_complex (cpu, out_GRk);
381 /* ICCi_1 has a latency of 19 cycles. */
382 update_CCR_latency (cpu, out_ICCi_1, cycles + 19);
383 set_use_is_cc_complex (cpu, out_ICCi_1);
385 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
387 /* GNER has a latency of 18 cycles. */
388 update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 18);
391 /* the idiv resource has a latency of 18 cycles! */
392 update_idiv_resource_latency (cpu, slot, cycles + 18);
398 frvbf_model_fr500_u_branch (SIM_CPU *cpu, const IDESC *idesc,
399 int unit_num, int referenced,
400 INT in_GRi, INT in_GRj,
401 INT in_ICCi_2, INT in_FCCi_2)
404 FRV_PROFILE_STATE *ps;
406 if (model_insn == FRV_INSN_MODEL_PASS_1)
408 /* icc0-icc4 are the upper 4 fields of the CCR. */
412 /* The entire VLIW insn must wait if there is a dependency on a register
413 which is not ready yet.
414 The latency of the registers may be less than previously recorded,
415 depending on how they were used previously.
416 See Table 13-8 in the LSI. */
419 if (use_is_gr_complex (cpu, in_GRi))
420 decrease_GR_busy (cpu, in_GRi, 1);
422 if (in_GRj != in_GRi && in_GRj >= 0)
424 if (use_is_gr_complex (cpu, in_GRj))
425 decrease_GR_busy (cpu, in_GRj, 1);
427 vliw_wait_for_GR (cpu, in_GRi);
428 vliw_wait_for_GR (cpu, in_GRj);
429 vliw_wait_for_CCR (cpu, in_ICCi_2);
430 vliw_wait_for_CCR (cpu, in_FCCi_2);
431 handle_resource_wait (cpu);
432 load_wait_for_GR (cpu, in_GRi);
433 load_wait_for_GR (cpu, in_GRj);
434 trace_vliw_wait_cycles (cpu);
438 /* When counting branches taken or not taken, don't consider branches after
439 the first taken branch in a vliw insn. */
440 ps = CPU_PROFILE_STATE (cpu);
441 if (! ps->vliw_branch_taken)
443 /* (1 << 4): The pc is the 5th element in inputs, outputs.
444 ??? can be cleaned up */
445 PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
446 int taken = (referenced & (1 << 4)) != 0;
449 ++PROFILE_MODEL_TAKEN_COUNT (p);
450 ps->vliw_branch_taken = 1;
453 ++PROFILE_MODEL_UNTAKEN_COUNT (p);
456 cycles = idesc->timing->units[unit_num].done;
461 frvbf_model_fr500_u_trap (SIM_CPU *cpu, const IDESC *idesc,
462 int unit_num, int referenced,
463 INT in_GRi, INT in_GRj,
464 INT in_ICCi_2, INT in_FCCi_2)
468 if (model_insn == FRV_INSN_MODEL_PASS_1)
470 /* icc0-icc4 are the upper 4 fields of the CCR. */
474 /* The entire VLIW insn must wait if there is a dependency on a register
475 which is not ready yet.
476 The latency of the registers may be less than previously recorded,
477 depending on how they were used previously.
478 See Table 13-8 in the LSI. */
481 if (use_is_gr_complex (cpu, in_GRi))
482 decrease_GR_busy (cpu, in_GRi, 1);
484 if (in_GRj != in_GRi && in_GRj >= 0)
486 if (use_is_gr_complex (cpu, in_GRj))
487 decrease_GR_busy (cpu, in_GRj, 1);
489 vliw_wait_for_GR (cpu, in_GRi);
490 vliw_wait_for_GR (cpu, in_GRj);
491 vliw_wait_for_CCR (cpu, in_ICCi_2);
492 vliw_wait_for_CCR (cpu, in_FCCi_2);
493 handle_resource_wait (cpu);
494 load_wait_for_GR (cpu, in_GRi);
495 load_wait_for_GR (cpu, in_GRj);
496 trace_vliw_wait_cycles (cpu);
500 cycles = idesc->timing->units[unit_num].done;
505 frvbf_model_fr500_u_check (SIM_CPU *cpu, const IDESC *idesc,
506 int unit_num, int referenced,
507 INT in_ICCi_3, INT in_FCCi_3)
511 if (model_insn == FRV_INSN_MODEL_PASS_1)
513 /* icc0-icc4 are the upper 4 fields of the CCR. */
517 /* The entire VLIW insn must wait if there is a dependency on a register
518 which is not ready yet. */
519 vliw_wait_for_CCR (cpu, in_ICCi_3);
520 vliw_wait_for_CCR (cpu, in_FCCi_3);
521 handle_resource_wait (cpu);
522 trace_vliw_wait_cycles (cpu);
526 cycles = idesc->timing->units[unit_num].done;
531 frvbf_model_fr500_u_clrgr (SIM_CPU *cpu, const IDESC *idesc,
532 int unit_num, int referenced,
537 if (model_insn == FRV_INSN_MODEL_PASS_1)
539 /* Wait for both GNER registers or just the one specified. */
542 vliw_wait_for_SPR (cpu, H_SPR_GNER0);
543 vliw_wait_for_SPR (cpu, H_SPR_GNER1);
546 vliw_wait_for_SPR (cpu, GNER_FOR_GR (in_GRk));
547 handle_resource_wait (cpu);
548 trace_vliw_wait_cycles (cpu);
552 cycles = idesc->timing->units[unit_num].done;
557 frvbf_model_fr500_u_clrfr (SIM_CPU *cpu, const IDESC *idesc,
558 int unit_num, int referenced,
563 if (model_insn == FRV_INSN_MODEL_PASS_1)
565 /* Wait for both GNER registers or just the one specified. */
568 vliw_wait_for_SPR (cpu, H_SPR_FNER0);
569 vliw_wait_for_SPR (cpu, H_SPR_FNER1);
572 vliw_wait_for_SPR (cpu, FNER_FOR_FR (in_FRk));
573 handle_resource_wait (cpu);
574 trace_vliw_wait_cycles (cpu);
578 cycles = idesc->timing->units[unit_num].done;
583 frvbf_model_fr500_u_set_hilo (SIM_CPU *cpu, const IDESC *idesc,
584 int unit_num, int referenced,
585 INT out_GRkhi, INT out_GRklo)
589 if (model_insn == FRV_INSN_MODEL_PASS_1)
591 /* The entire VLIW insn must wait if there is a dependency on a GR
592 which is not ready yet. */
593 vliw_wait_for_GR (cpu, out_GRkhi);
594 vliw_wait_for_GR (cpu, out_GRklo);
595 handle_resource_wait (cpu);
596 load_wait_for_GR (cpu, out_GRkhi);
597 load_wait_for_GR (cpu, out_GRklo);
598 trace_vliw_wait_cycles (cpu);
602 /* GRk is available immediately to the next VLIW insn. */
603 cycles = idesc->timing->units[unit_num].done;
605 set_use_not_gr_complex (cpu, out_GRkhi);
606 set_use_not_gr_complex (cpu, out_GRklo);
612 frvbf_model_fr500_u_gr_load (SIM_CPU *cpu, const IDESC *idesc,
613 int unit_num, int referenced,
614 INT in_GRi, INT in_GRj,
615 INT out_GRk, INT out_GRdoublek)
619 if (model_insn == FRV_INSN_MODEL_PASS_1)
621 /* The entire VLIW insn must wait if there is a dependency on a register
622 which is not ready yet.
623 The latency of the registers may be less than previously recorded,
624 depending on how they were used previously.
625 See Table 13-8 in the LSI. */
626 if (in_GRi != out_GRk && in_GRi != out_GRdoublek
627 && in_GRi != out_GRdoublek + 1 && in_GRi >= 0)
629 if (use_is_gr_complex (cpu, in_GRi))
630 decrease_GR_busy (cpu, in_GRi, 1);
632 if (in_GRj != in_GRi && in_GRj != out_GRk && in_GRj != out_GRdoublek
633 && in_GRj != out_GRdoublek + 1 && in_GRj >= 0)
636 if (use_is_gr_complex (cpu, in_GRj))
637 decrease_GR_busy (cpu, in_GRj, 1);
639 vliw_wait_for_GR (cpu, in_GRi);
640 vliw_wait_for_GR (cpu, in_GRj);
641 vliw_wait_for_GR (cpu, out_GRk);
642 vliw_wait_for_GRdouble (cpu, out_GRdoublek);
643 handle_resource_wait (cpu);
644 load_wait_for_GR (cpu, in_GRi);
645 load_wait_for_GR (cpu, in_GRj);
646 load_wait_for_GR (cpu, out_GRk);
647 load_wait_for_GRdouble (cpu, out_GRdoublek);
648 trace_vliw_wait_cycles (cpu);
652 cycles = idesc->timing->units[unit_num].done;
654 /* The latency of GRk for a load will depend on how long it takes to retrieve
655 the the data from the cache or memory. */
656 update_GR_latency_for_load (cpu, out_GRk, cycles);
657 update_GRdouble_latency_for_load (cpu, out_GRdoublek, cycles);
659 set_use_is_gr_complex (cpu, out_GRk);
660 set_use_is_gr_complex (cpu, out_GRdoublek);
661 set_use_is_gr_complex (cpu, out_GRdoublek + 1);
667 frvbf_model_fr500_u_gr_store (SIM_CPU *cpu, const IDESC *idesc,
668 int unit_num, int referenced,
669 INT in_GRi, INT in_GRj,
670 INT in_GRk, INT in_GRdoublek)
674 if (model_insn == FRV_INSN_MODEL_PASS_1)
676 /* The entire VLIW insn must wait if there is a dependency on a register
677 which is not ready yet.
678 The latency of the registers may be less than previously recorded,
679 depending on how they were used previously.
680 See Table 13-8 in the LSI. */
683 if (use_is_gr_complex (cpu, in_GRi))
684 decrease_GR_busy (cpu, in_GRi, 1);
686 if (in_GRj != in_GRi && in_GRj >= 0)
688 if (use_is_gr_complex (cpu, in_GRj))
689 decrease_GR_busy (cpu, in_GRj, 1);
691 if (in_GRk != in_GRi && in_GRk != in_GRj && in_GRk >= 0)
693 if (use_is_gr_complex (cpu, in_GRk))
694 decrease_GR_busy (cpu, in_GRk, 1);
696 if (in_GRdoublek != in_GRi && in_GRdoublek != in_GRj
697 && in_GRdoublek + 1 != in_GRi && in_GRdoublek + 1 != in_GRj
698 && in_GRdoublek >= 0)
700 if (use_is_gr_complex (cpu, in_GRdoublek))
701 decrease_GR_busy (cpu, in_GRdoublek, 1);
702 if (use_is_gr_complex (cpu, in_GRdoublek + 1))
703 decrease_GR_busy (cpu, in_GRdoublek + 1, 1);
705 vliw_wait_for_GR (cpu, in_GRi);
706 vliw_wait_for_GR (cpu, in_GRj);
707 vliw_wait_for_GR (cpu, in_GRk);
708 vliw_wait_for_GRdouble (cpu, in_GRdoublek);
709 handle_resource_wait (cpu);
710 load_wait_for_GR (cpu, in_GRi);
711 load_wait_for_GR (cpu, in_GRj);
712 load_wait_for_GR (cpu, in_GRk);
713 load_wait_for_GRdouble (cpu, in_GRdoublek);
714 trace_vliw_wait_cycles (cpu);
718 cycles = idesc->timing->units[unit_num].done;
724 frvbf_model_fr500_u_gr_r_store (SIM_CPU *cpu, const IDESC *idesc,
725 int unit_num, int referenced,
726 INT in_GRi, INT in_GRj,
727 INT in_GRk, INT in_GRdoublek)
729 int cycles = frvbf_model_fr500_u_gr_store (cpu, idesc, unit_num, referenced,
730 in_GRi, in_GRj, in_GRk,
733 if (model_insn == FRV_INSN_MODEL_PASS_2)
735 if (CPU_RSTR_INVALIDATE(cpu))
736 request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
743 frvbf_model_fr500_u_fr_load (SIM_CPU *cpu, const IDESC *idesc,
744 int unit_num, int referenced,
745 INT in_GRi, INT in_GRj,
746 INT out_FRk, INT out_FRdoublek)
750 if (model_insn == FRV_INSN_MODEL_PASS_1)
752 /* The entire VLIW insn must wait if there is a dependency on a register
753 which is not ready yet.
754 The latency of the registers may be less than previously recorded,
755 depending on how they were used previously.
756 See Table 13-8 in the LSI. */
759 if (use_is_gr_complex (cpu, in_GRi))
760 decrease_GR_busy (cpu, in_GRi, 1);
762 if (in_GRj != in_GRi && in_GRj >= 0)
764 if (use_is_gr_complex (cpu, in_GRj))
765 decrease_GR_busy (cpu, in_GRj, 1);
769 if (use_is_media (cpu, out_FRk))
770 decrease_FR_busy (cpu, out_FRk, 1);
772 adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
774 if (out_FRdoublek >= 0)
776 if (use_is_media (cpu, out_FRdoublek))
777 decrease_FR_busy (cpu, out_FRdoublek, 1);
779 adjust_float_register_busy (cpu, -1, -1, out_FRdoublek, 1);
780 if (use_is_media (cpu, out_FRdoublek + 1))
781 decrease_FR_busy (cpu, out_FRdoublek + 1, 1);
783 adjust_float_register_busy (cpu, -1, -1, out_FRdoublek + 1, 1);
785 vliw_wait_for_GR (cpu, in_GRi);
786 vliw_wait_for_GR (cpu, in_GRj);
787 vliw_wait_for_FR (cpu, out_FRk);
788 vliw_wait_for_FRdouble (cpu, out_FRdoublek);
789 handle_resource_wait (cpu);
790 load_wait_for_GR (cpu, in_GRi);
791 load_wait_for_GR (cpu, in_GRj);
792 load_wait_for_FR (cpu, out_FRk);
793 load_wait_for_FRdouble (cpu, out_FRdoublek);
794 trace_vliw_wait_cycles (cpu);
798 cycles = idesc->timing->units[unit_num].done;
800 /* The latency of FRk for a load will depend on how long it takes to retrieve
801 the the data from the cache or memory. */
802 update_FR_latency_for_load (cpu, out_FRk, cycles);
803 update_FRdouble_latency_for_load (cpu, out_FRdoublek, cycles);
805 fr500_reset_fr_flags (cpu, out_FRk);
811 frvbf_model_fr500_u_fr_store (SIM_CPU *cpu, const IDESC *idesc,
812 int unit_num, int referenced,
813 INT in_GRi, INT in_GRj,
814 INT in_FRk, INT in_FRdoublek)
818 if (model_insn == FRV_INSN_MODEL_PASS_1)
820 /* The entire VLIW insn must wait if there is a dependency on a register
821 which is not ready yet.
822 The latency of the registers may be less than previously recorded,
823 depending on how they were used previously.
824 See Table 13-8 in the LSI. */
827 if (use_is_gr_complex (cpu, in_GRi))
828 decrease_GR_busy (cpu, in_GRi, 1);
830 if (in_GRj != in_GRi && in_GRj >= 0)
832 if (use_is_gr_complex (cpu, in_GRj))
833 decrease_GR_busy (cpu, in_GRj, 1);
837 if (use_is_media (cpu, in_FRk))
838 decrease_FR_busy (cpu, in_FRk, 1);
840 adjust_float_register_busy (cpu, -1, -1, in_FRk, 1);
842 if (in_FRdoublek >= 0)
844 if (use_is_media (cpu, in_FRdoublek))
845 decrease_FR_busy (cpu, in_FRdoublek, 1);
847 adjust_float_register_busy (cpu, -1, -1, in_FRdoublek, 1);
848 if (use_is_media (cpu, in_FRdoublek + 1))
849 decrease_FR_busy (cpu, in_FRdoublek + 1, 1);
851 adjust_float_register_busy (cpu, -1, -1, in_FRdoublek + 1, 1);
853 vliw_wait_for_GR (cpu, in_GRi);
854 vliw_wait_for_GR (cpu, in_GRj);
855 vliw_wait_for_FR (cpu, in_FRk);
856 vliw_wait_for_FRdouble (cpu, in_FRdoublek);
857 handle_resource_wait (cpu);
858 load_wait_for_GR (cpu, in_GRi);
859 load_wait_for_GR (cpu, in_GRj);
860 load_wait_for_FR (cpu, in_FRk);
861 load_wait_for_FRdouble (cpu, in_FRdoublek);
862 trace_vliw_wait_cycles (cpu);
866 cycles = idesc->timing->units[unit_num].done;
872 frvbf_model_fr500_u_fr_r_store (SIM_CPU *cpu, const IDESC *idesc,
873 int unit_num, int referenced,
874 INT in_GRi, INT in_GRj,
875 INT in_FRk, INT in_FRdoublek)
877 int cycles = frvbf_model_fr500_u_fr_store (cpu, idesc, unit_num, referenced,
878 in_GRi, in_GRj, in_FRk,
881 if (model_insn == FRV_INSN_MODEL_PASS_2)
883 if (CPU_RSTR_INVALIDATE(cpu))
884 request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
891 frvbf_model_fr500_u_swap (SIM_CPU *cpu, const IDESC *idesc,
892 int unit_num, int referenced,
893 INT in_GRi, INT in_GRj, INT out_GRk)
897 if (model_insn == FRV_INSN_MODEL_PASS_1)
899 /* The entire VLIW insn must wait if there is a dependency on a register
900 which is not ready yet.
901 The latency of the registers may be less than previously recorded,
902 depending on how they were used previously.
903 See Table 13-8 in the LSI. */
904 if (in_GRi != out_GRk && in_GRi >= 0)
906 if (use_is_gr_complex (cpu, in_GRi))
907 decrease_GR_busy (cpu, in_GRi, 1);
909 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
911 if (use_is_gr_complex (cpu, in_GRj))
912 decrease_GR_busy (cpu, in_GRj, 1);
914 vliw_wait_for_GR (cpu, in_GRi);
915 vliw_wait_for_GR (cpu, in_GRj);
916 vliw_wait_for_GR (cpu, out_GRk);
917 handle_resource_wait (cpu);
918 load_wait_for_GR (cpu, in_GRi);
919 load_wait_for_GR (cpu, in_GRj);
920 load_wait_for_GR (cpu, out_GRk);
921 trace_vliw_wait_cycles (cpu);
925 cycles = idesc->timing->units[unit_num].done;
927 /* The latency of GRk will depend on how long it takes to swap
928 the the data from the cache or memory. */
929 update_GR_latency_for_swap (cpu, out_GRk, cycles);
930 set_use_is_gr_complex (cpu, out_GRk);
936 frvbf_model_fr500_u_fr2fr (SIM_CPU *cpu, const IDESC *idesc,
937 int unit_num, int referenced,
938 INT in_FRj, INT out_FRk)
942 if (model_insn == FRV_INSN_MODEL_PASS_1)
944 /* The entire VLIW insn must wait if there is a dependency on a register
945 which is not ready yet. */
948 if (use_is_media (cpu, in_FRj))
949 decrease_FR_busy (cpu, in_FRj, 1);
951 adjust_float_register_busy (cpu, -1, in_FRj, -1, 1);
953 if (out_FRk >= 0 && out_FRk != in_FRj)
955 if (use_is_media (cpu, out_FRk))
956 decrease_FR_busy (cpu, out_FRk, 1);
958 adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
960 vliw_wait_for_FR (cpu, in_FRj);
961 vliw_wait_for_FR (cpu, out_FRk);
962 handle_resource_wait (cpu);
963 load_wait_for_FR (cpu, in_FRj);
964 load_wait_for_FR (cpu, out_FRk);
965 trace_vliw_wait_cycles (cpu);
969 /* The latency of FRj is 3 cycles. */
970 cycles = idesc->timing->units[unit_num].done;
971 update_FR_latency (cpu, out_FRk, cycles + 3);
977 frvbf_model_fr500_u_fr2gr (SIM_CPU *cpu, const IDESC *idesc,
978 int unit_num, int referenced,
979 INT in_FRk, INT out_GRj)
983 if (model_insn == FRV_INSN_MODEL_PASS_1)
985 /* The entire VLIW insn must wait if there is a dependency on a register
986 which is not ready yet. */
989 if (use_is_media (cpu, in_FRk))
990 decrease_FR_busy (cpu, in_FRk, 1);
992 adjust_float_register_busy (cpu, -1, in_FRk, -1, 1);
994 vliw_wait_for_FR (cpu, in_FRk);
995 vliw_wait_for_GR (cpu, out_GRj);
996 handle_resource_wait (cpu);
997 load_wait_for_FR (cpu, in_FRk);
998 load_wait_for_GR (cpu, out_GRj);
999 trace_vliw_wait_cycles (cpu);
1003 /* The latency of GRj is 2 cycles. */
1004 cycles = idesc->timing->units[unit_num].done;
1005 update_GR_latency (cpu, out_GRj, cycles + 2);
1006 set_use_is_gr_complex (cpu, out_GRj);
1012 frvbf_model_fr500_u_spr2gr (SIM_CPU *cpu, const IDESC *idesc,
1013 int unit_num, int referenced,
1014 INT in_spr, INT out_GRj)
1018 if (model_insn == FRV_INSN_MODEL_PASS_1)
1020 /* The entire VLIW insn must wait if there is a dependency on a register
1021 which is not ready yet. */
1022 vliw_wait_for_SPR (cpu, in_spr);
1023 vliw_wait_for_GR (cpu, out_GRj);
1024 handle_resource_wait (cpu);
1025 load_wait_for_GR (cpu, out_GRj);
1026 trace_vliw_wait_cycles (cpu);
1030 cycles = idesc->timing->units[unit_num].done;
1032 #if 0 /* no latency? */
1033 /* The latency of GRj is 2 cycles. */
1034 update_GR_latency (cpu, out_GRj, cycles + 2);
1041 frvbf_model_fr500_u_gr2fr (SIM_CPU *cpu, const IDESC *idesc,
1042 int unit_num, int referenced,
1043 INT in_GRj, INT out_FRk)
1047 if (model_insn == FRV_INSN_MODEL_PASS_1)
1049 /* The entire VLIW insn must wait if there is a dependency on a register
1050 which is not ready yet.
1051 The latency of the registers may be less than previously recorded,
1052 depending on how they were used previously.
1053 See Table 13-8 in the LSI. */
1056 if (use_is_gr_complex (cpu, in_GRj))
1057 decrease_GR_busy (cpu, in_GRj, 1);
1061 if (use_is_media (cpu, out_FRk))
1062 decrease_FR_busy (cpu, out_FRk, 1);
1064 adjust_float_register_busy (cpu, -1, out_FRk, -1, 1);
1066 vliw_wait_for_GR (cpu, in_GRj);
1067 vliw_wait_for_FR (cpu, out_FRk);
1068 handle_resource_wait (cpu);
1069 load_wait_for_GR (cpu, in_GRj);
1070 load_wait_for_FR (cpu, out_FRk);
1071 trace_vliw_wait_cycles (cpu);
1075 /* The latency of FRk is 2 cycles. */
1076 cycles = idesc->timing->units[unit_num].done;
1077 update_FR_latency (cpu, out_FRk, cycles + 2);
1079 /* Mark this use of the register as NOT a floating point op. */
1080 fr500_reset_fr_flags (cpu, out_FRk);
1086 frvbf_model_fr500_u_gr2spr (SIM_CPU *cpu, const IDESC *idesc,
1087 int unit_num, int referenced,
1088 INT in_GRj, INT out_spr)
1092 if (model_insn == FRV_INSN_MODEL_PASS_1)
1094 /* The entire VLIW insn must wait if there is a dependency on a register
1095 which is not ready yet.
1096 The latency of the registers may be less than previously recorded,
1097 depending on how they were used previously.
1098 See Table 13-8 in the LSI. */
1101 if (use_is_gr_complex (cpu, in_GRj))
1102 decrease_GR_busy (cpu, in_GRj, 1);
1104 vliw_wait_for_GR (cpu, in_GRj);
1105 vliw_wait_for_SPR (cpu, out_spr);
1106 handle_resource_wait (cpu);
1107 load_wait_for_GR (cpu, in_GRj);
1108 trace_vliw_wait_cycles (cpu);
1112 cycles = idesc->timing->units[unit_num].done;
1115 /* The latency of spr is ? cycles. */
1116 update_SPR_latency (cpu, out_spr, cycles + ?);
1123 frvbf_model_fr500_u_ici (SIM_CPU *cpu, const IDESC *idesc,
1124 int unit_num, int referenced,
1125 INT in_GRi, INT in_GRj)
1129 if (model_insn == FRV_INSN_MODEL_PASS_1)
1131 /* The entire VLIW insn must wait if there is a dependency on a register
1132 which is not ready yet.
1133 The latency of the registers may be less than previously recorded,
1134 depending on how they were used previously.
1135 See Table 13-8 in the LSI. */
1138 if (use_is_gr_complex (cpu, in_GRi))
1139 decrease_GR_busy (cpu, in_GRi, 1);
1141 if (in_GRj != in_GRi && in_GRj >= 0)
1143 if (use_is_gr_complex (cpu, in_GRj))
1144 decrease_GR_busy (cpu, in_GRj, 1);
1146 vliw_wait_for_GR (cpu, in_GRi);
1147 vliw_wait_for_GR (cpu, in_GRj);
1148 handle_resource_wait (cpu);
1149 load_wait_for_GR (cpu, in_GRi);
1150 load_wait_for_GR (cpu, in_GRj);
1151 trace_vliw_wait_cycles (cpu);
1155 cycles = idesc->timing->units[unit_num].done;
1156 request_cache_invalidate (cpu, CPU_INSN_CACHE (cpu), cycles);
1161 frvbf_model_fr500_u_dci (SIM_CPU *cpu, const IDESC *idesc,
1162 int unit_num, int referenced,
1163 INT in_GRi, INT in_GRj)
1167 if (model_insn == FRV_INSN_MODEL_PASS_1)
1169 /* The entire VLIW insn must wait if there is a dependency on a register
1170 which is not ready yet.
1171 The latency of the registers may be less than previously recorded,
1172 depending on how they were used previously.
1173 See Table 13-8 in the LSI. */
1176 if (use_is_gr_complex (cpu, in_GRi))
1177 decrease_GR_busy (cpu, in_GRi, 1);
1179 if (in_GRj != in_GRi && in_GRj >= 0)
1181 if (use_is_gr_complex (cpu, in_GRj))
1182 decrease_GR_busy (cpu, in_GRj, 1);
1184 vliw_wait_for_GR (cpu, in_GRi);
1185 vliw_wait_for_GR (cpu, in_GRj);
1186 handle_resource_wait (cpu);
1187 load_wait_for_GR (cpu, in_GRi);
1188 load_wait_for_GR (cpu, in_GRj);
1189 trace_vliw_wait_cycles (cpu);
1193 cycles = idesc->timing->units[unit_num].done;
1194 request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
1199 frvbf_model_fr500_u_dcf (SIM_CPU *cpu, const IDESC *idesc,
1200 int unit_num, int referenced,
1201 INT in_GRi, INT in_GRj)
1205 if (model_insn == FRV_INSN_MODEL_PASS_1)
1207 /* The entire VLIW insn must wait if there is a dependency on a register
1208 which is not ready yet.
1209 The latency of the registers may be less than previously recorded,
1210 depending on how they were used previously.
1211 See Table 13-8 in the LSI. */
1214 if (use_is_gr_complex (cpu, in_GRi))
1215 decrease_GR_busy (cpu, in_GRi, 1);
1217 if (in_GRj != in_GRi && in_GRj >= 0)
1219 if (use_is_gr_complex (cpu, in_GRj))
1220 decrease_GR_busy (cpu, in_GRj, 1);
1222 vliw_wait_for_GR (cpu, in_GRi);
1223 vliw_wait_for_GR (cpu, in_GRj);
1224 handle_resource_wait (cpu);
1225 load_wait_for_GR (cpu, in_GRi);
1226 load_wait_for_GR (cpu, in_GRj);
1227 trace_vliw_wait_cycles (cpu);
1231 cycles = idesc->timing->units[unit_num].done;
1232 request_cache_flush (cpu, CPU_DATA_CACHE (cpu), cycles);
1237 frvbf_model_fr500_u_icpl (SIM_CPU *cpu, const IDESC *idesc,
1238 int unit_num, int referenced,
1239 INT in_GRi, INT in_GRj)
1243 if (model_insn == FRV_INSN_MODEL_PASS_1)
1245 /* The entire VLIW insn must wait if there is a dependency on a register
1246 which is not ready yet.
1247 The latency of the registers may be less than previously recorded,
1248 depending on how they were used previously.
1249 See Table 13-8 in the LSI. */
1252 if (use_is_gr_complex (cpu, in_GRi))
1253 decrease_GR_busy (cpu, in_GRi, 1);
1255 if (in_GRj != in_GRi && in_GRj >= 0)
1257 if (use_is_gr_complex (cpu, in_GRj))
1258 decrease_GR_busy (cpu, in_GRj, 1);
1260 vliw_wait_for_GR (cpu, in_GRi);
1261 vliw_wait_for_GR (cpu, in_GRj);
1262 handle_resource_wait (cpu);
1263 load_wait_for_GR (cpu, in_GRi);
1264 load_wait_for_GR (cpu, in_GRj);
1265 trace_vliw_wait_cycles (cpu);
1269 cycles = idesc->timing->units[unit_num].done;
1270 request_cache_preload (cpu, CPU_INSN_CACHE (cpu), cycles);
1275 frvbf_model_fr500_u_dcpl (SIM_CPU *cpu, const IDESC *idesc,
1276 int unit_num, int referenced,
1277 INT in_GRi, INT in_GRj)
1281 if (model_insn == FRV_INSN_MODEL_PASS_1)
1283 /* The entire VLIW insn must wait if there is a dependency on a register
1284 which is not ready yet.
1285 The latency of the registers may be less than previously recorded,
1286 depending on how they were used previously.
1287 See Table 13-8 in the LSI. */
1290 if (use_is_gr_complex (cpu, in_GRi))
1291 decrease_GR_busy (cpu, in_GRi, 1);
1293 if (in_GRj != in_GRi && in_GRj >= 0)
1295 if (use_is_gr_complex (cpu, in_GRj))
1296 decrease_GR_busy (cpu, in_GRj, 1);
1298 vliw_wait_for_GR (cpu, in_GRi);
1299 vliw_wait_for_GR (cpu, in_GRj);
1300 handle_resource_wait (cpu);
1301 load_wait_for_GR (cpu, in_GRi);
1302 load_wait_for_GR (cpu, in_GRj);
1303 trace_vliw_wait_cycles (cpu);
1307 cycles = idesc->timing->units[unit_num].done;
1308 request_cache_preload (cpu, CPU_DATA_CACHE (cpu), cycles);
1313 frvbf_model_fr500_u_icul (SIM_CPU *cpu, const IDESC *idesc,
1314 int unit_num, int referenced,
1315 INT in_GRi, INT in_GRj)
1319 if (model_insn == FRV_INSN_MODEL_PASS_1)
1321 /* The entire VLIW insn must wait if there is a dependency on a register
1322 which is not ready yet.
1323 The latency of the registers may be less than previously recorded,
1324 depending on how they were used previously.
1325 See Table 13-8 in the LSI. */
1328 if (use_is_gr_complex (cpu, in_GRi))
1329 decrease_GR_busy (cpu, in_GRi, 1);
1331 if (in_GRj != in_GRi && in_GRj >= 0)
1333 if (use_is_gr_complex (cpu, in_GRj))
1334 decrease_GR_busy (cpu, in_GRj, 1);
1336 vliw_wait_for_GR (cpu, in_GRi);
1337 vliw_wait_for_GR (cpu, in_GRj);
1338 handle_resource_wait (cpu);
1339 load_wait_for_GR (cpu, in_GRi);
1340 load_wait_for_GR (cpu, in_GRj);
1341 trace_vliw_wait_cycles (cpu);
1345 cycles = idesc->timing->units[unit_num].done;
1346 request_cache_unlock (cpu, CPU_INSN_CACHE (cpu), cycles);
1351 frvbf_model_fr500_u_dcul (SIM_CPU *cpu, const IDESC *idesc,
1352 int unit_num, int referenced,
1353 INT in_GRi, INT in_GRj)
1357 if (model_insn == FRV_INSN_MODEL_PASS_1)
1359 /* The entire VLIW insn must wait if there is a dependency on a register
1360 which is not ready yet.
1361 The latency of the registers may be less than previously recorded,
1362 depending on how they were used previously.
1363 See Table 13-8 in the LSI. */
1366 if (use_is_gr_complex (cpu, in_GRi))
1367 decrease_GR_busy (cpu, in_GRi, 1);
1369 if (in_GRj != in_GRi && in_GRj >= 0)
1371 if (use_is_gr_complex (cpu, in_GRj))
1372 decrease_GR_busy (cpu, in_GRj, 1);
1374 vliw_wait_for_GR (cpu, in_GRi);
1375 vliw_wait_for_GR (cpu, in_GRj);
1376 handle_resource_wait (cpu);
1377 load_wait_for_GR (cpu, in_GRi);
1378 load_wait_for_GR (cpu, in_GRj);
1379 trace_vliw_wait_cycles (cpu);
1383 cycles = idesc->timing->units[unit_num].done;
1384 request_cache_unlock (cpu, CPU_DATA_CACHE (cpu), cycles);
1388 /* Top up the post-processing time of the given FR by the given number of
1391 update_FR_ptime (SIM_CPU *cpu, INT out_FR, int cycles)
1395 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
1396 /* If a load is pending on this register, then add the cycles to
1397 the post processing time for this register. Otherwise apply it
1398 directly to the latency of the register. */
1399 if (! load_pending_for_register (cpu, out_FR, 1, REGTYPE_FR))
1401 int *fr = ps->fr_latency;
1402 fr[out_FR] += cycles;
1405 ps->fr_ptime[out_FR] += cycles;
1410 update_FRdouble_ptime (SIM_CPU *cpu, INT out_FR, int cycles)
1414 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
1415 /* If a load is pending on this register, then add the cycles to
1416 the post processing time for this register. Otherwise apply it
1417 directly to the latency of the register. */
1418 if (! load_pending_for_register (cpu, out_FR, 2, REGTYPE_FR))
1420 int *fr = ps->fr_latency;
1421 fr[out_FR] += cycles;
1423 fr[out_FR + 1] += cycles;
1427 ps->fr_ptime[out_FR] += cycles;
1429 ps->fr_ptime[out_FR + 1] += cycles;
1435 frvbf_model_fr500_u_float_arith (SIM_CPU *cpu, const IDESC *idesc,
1436 int unit_num, int referenced,
1437 INT in_FRi, INT in_FRj,
1438 INT in_FRdoublei, INT in_FRdoublej,
1439 INT out_FRk, INT out_FRdoublek)
1442 FRV_PROFILE_STATE *ps;
1444 if (model_insn == FRV_INSN_MODEL_PASS_1)
1447 /* The preprocessing can execute right away. */
1448 cycles = idesc->timing->units[unit_num].done;
1450 /* The post processing must wait if there is a dependency on a FR
1451 which is not ready yet. */
1452 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1453 adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
1455 ps = CPU_PROFILE_STATE (cpu);
1456 ps->post_wait = cycles;
1457 post_wait_for_FR (cpu, in_FRi);
1458 post_wait_for_FR (cpu, in_FRj);
1459 post_wait_for_FR (cpu, out_FRk);
1460 post_wait_for_FRdouble (cpu, in_FRdoublei);
1461 post_wait_for_FRdouble (cpu, in_FRdoublej);
1462 post_wait_for_FRdouble (cpu, out_FRdoublek);
1463 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1464 restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
1467 /* The latency of FRk will be at least the latency of the other inputs. */
1468 update_FR_latency (cpu, out_FRk, ps->post_wait);
1469 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1471 /* Once initiated, post-processing will take 3 cycles. */
1472 update_FR_ptime (cpu, out_FRk, 3);
1473 update_FRdouble_ptime (cpu, out_FRdoublek, 3);
1475 /* Mark this use of the register as a floating point op. */
1477 set_use_is_fpop (cpu, out_FRk);
1478 if (out_FRdoublek >= 0)
1480 set_use_is_fpop (cpu, out_FRdoublek);
1481 if (out_FRdoublek < 63)
1482 set_use_is_fpop (cpu, out_FRdoublek + 1);
1489 frvbf_model_fr500_u_float_dual_arith (SIM_CPU *cpu, const IDESC *idesc,
1490 int unit_num, int referenced,
1491 INT in_FRi, INT in_FRj,
1492 INT in_FRdoublei, INT in_FRdoublej,
1493 INT out_FRk, INT out_FRdoublek)
1502 FRV_PROFILE_STATE *ps;
1504 if (model_insn == FRV_INSN_MODEL_PASS_1)
1507 /* The preprocessing can execute right away. */
1508 cycles = idesc->timing->units[unit_num].done;
1510 /* The post processing must wait if there is a dependency on a FR
1511 which is not ready yet. */
1512 dual_FRi = DUAL_REG (in_FRi);
1513 dual_FRj = DUAL_REG (in_FRj);
1514 dual_FRk = DUAL_REG (out_FRk);
1515 dual_FRdoublei = DUAL_DOUBLE (in_FRdoublei);
1516 dual_FRdoublej = DUAL_DOUBLE (in_FRdoublej);
1517 dual_FRdoublek = DUAL_DOUBLE (out_FRdoublek);
1519 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1520 adjust_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
1521 adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
1523 adjust_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
1525 ps = CPU_PROFILE_STATE (cpu);
1526 ps->post_wait = cycles;
1527 post_wait_for_FR (cpu, in_FRi);
1528 post_wait_for_FR (cpu, in_FRj);
1529 post_wait_for_FR (cpu, out_FRk);
1530 post_wait_for_FR (cpu, dual_FRi);
1531 post_wait_for_FR (cpu, dual_FRj);
1532 post_wait_for_FR (cpu, dual_FRk);
1533 post_wait_for_FRdouble (cpu, in_FRdoublei);
1534 post_wait_for_FRdouble (cpu, in_FRdoublej);
1535 post_wait_for_FRdouble (cpu, out_FRdoublek);
1536 post_wait_for_FRdouble (cpu, dual_FRdoublei);
1537 post_wait_for_FRdouble (cpu, dual_FRdoublej);
1538 post_wait_for_FRdouble (cpu, dual_FRdoublek);
1539 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1540 restore_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
1541 restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
1543 restore_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
1546 /* The latency of FRk will be at least the latency of the other inputs. */
1547 update_FR_latency (cpu, out_FRk, ps->post_wait);
1548 update_FR_latency (cpu, dual_FRk, ps->post_wait);
1549 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1550 update_FRdouble_latency (cpu, dual_FRdoublek, ps->post_wait);
1552 /* Once initiated, post-processing will take 3 cycles. */
1553 update_FR_ptime (cpu, out_FRk, 3);
1554 update_FR_ptime (cpu, dual_FRk, 3);
1555 update_FRdouble_ptime (cpu, out_FRdoublek, 3);
1556 update_FRdouble_ptime (cpu, dual_FRdoublek, 3);
1558 /* Mark this use of the register as a floating point op. */
1560 set_use_is_fpop (cpu, out_FRk);
1562 set_use_is_fpop (cpu, dual_FRk);
1563 if (out_FRdoublek >= 0)
1565 set_use_is_fpop (cpu, out_FRdoublek);
1566 if (out_FRdoublek < 63)
1567 set_use_is_fpop (cpu, out_FRdoublek + 1);
1569 if (dual_FRdoublek >= 0)
1571 set_use_is_fpop (cpu, dual_FRdoublek);
1572 if (dual_FRdoublek < 63)
1573 set_use_is_fpop (cpu, dual_FRdoublek + 1);
1580 frvbf_model_fr500_u_float_div (SIM_CPU *cpu, const IDESC *idesc,
1581 int unit_num, int referenced,
1582 INT in_FRi, INT in_FRj, INT out_FRk)
1587 FRV_PROFILE_STATE *ps;
1589 if (model_insn == FRV_INSN_MODEL_PASS_1)
1592 cycles = idesc->timing->units[unit_num].done;
1594 /* The post processing must wait if there is a dependency on a FR
1595 which is not ready yet. */
1596 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1597 ps = CPU_PROFILE_STATE (cpu);
1598 ps->post_wait = cycles;
1599 post_wait_for_FR (cpu, in_FRi);
1600 post_wait_for_FR (cpu, in_FRj);
1601 post_wait_for_FR (cpu, out_FRk);
1602 vliw = CPU_VLIW (cpu);
1603 slot = vliw->next_slot - 1;
1604 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1605 post_wait_for_fdiv (cpu, slot);
1606 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1608 /* The latency of FRk will be at least the latency of the other inputs. */
1609 /* Once initiated, post-processing will take 10 cycles. */
1610 update_FR_latency (cpu, out_FRk, ps->post_wait);
1611 update_FR_ptime (cpu, out_FRk, 10);
1613 /* The latency of the fdiv unit will be at least the latency of the other
1614 inputs. Once initiated, post-processing will take 9 cycles. */
1615 update_fdiv_resource_latency (cpu, slot, ps->post_wait + 9);
1617 /* Mark this use of the register as a floating point op. */
1618 set_use_is_fpop (cpu, out_FRk);
1624 frvbf_model_fr500_u_float_sqrt (SIM_CPU *cpu, const IDESC *idesc,
1625 int unit_num, int referenced,
1626 INT in_FRj, INT in_FRdoublej,
1627 INT out_FRk, INT out_FRdoublek)
1632 FRV_PROFILE_STATE *ps;
1634 if (model_insn == FRV_INSN_MODEL_PASS_1)
1637 cycles = idesc->timing->units[unit_num].done;
1639 /* The post processing must wait if there is a dependency on a FR
1640 which is not ready yet. */
1641 adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1642 adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
1643 ps = CPU_PROFILE_STATE (cpu);
1644 ps->post_wait = cycles;
1645 post_wait_for_FR (cpu, in_FRj);
1646 post_wait_for_FR (cpu, out_FRk);
1647 post_wait_for_FRdouble (cpu, in_FRdoublej);
1648 post_wait_for_FRdouble (cpu, out_FRdoublek);
1649 vliw = CPU_VLIW (cpu);
1650 slot = vliw->next_slot - 1;
1651 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1652 post_wait_for_fsqrt (cpu, slot);
1653 restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1654 restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
1656 /* The latency of FRk will be at least the latency of the other inputs. */
1657 update_FR_latency (cpu, out_FRk, ps->post_wait);
1658 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1660 /* Once initiated, post-processing will take 15 cycles. */
1661 update_FR_ptime (cpu, out_FRk, 15);
1662 update_FRdouble_ptime (cpu, out_FRdoublek, 15);
1664 /* The latency of the sqrt unit will be the latency of the other
1665 inputs plus 14 cycles. */
1666 update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
1668 /* Mark this use of the register as a floating point op. */
1670 set_use_is_fpop (cpu, out_FRk);
1671 if (out_FRdoublek >= 0)
1673 set_use_is_fpop (cpu, out_FRdoublek);
1674 if (out_FRdoublek < 63)
1675 set_use_is_fpop (cpu, out_FRdoublek + 1);
1682 frvbf_model_fr500_u_float_dual_sqrt (SIM_CPU *cpu, const IDESC *idesc,
1683 int unit_num, int referenced,
1684 INT in_FRj, INT out_FRk)
1691 FRV_PROFILE_STATE *ps;
1693 if (model_insn == FRV_INSN_MODEL_PASS_1)
1696 cycles = idesc->timing->units[unit_num].done;
1698 /* The post processing must wait if there is a dependency on a FR
1699 which is not ready yet. */
1700 dual_FRj = DUAL_REG (in_FRj);
1701 dual_FRk = DUAL_REG (out_FRk);
1702 adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1703 adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
1704 ps = CPU_PROFILE_STATE (cpu);
1705 ps->post_wait = cycles;
1706 post_wait_for_FR (cpu, in_FRj);
1707 post_wait_for_FR (cpu, out_FRk);
1708 post_wait_for_FR (cpu, dual_FRj);
1709 post_wait_for_FR (cpu, dual_FRk);
1711 vliw = CPU_VLIW (cpu);
1712 slot = vliw->next_slot - 1;
1713 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1714 post_wait_for_fsqrt (cpu, slot);
1715 restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1716 restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
1718 /* The latency of FRk will be at least the latency of the other inputs. */
1719 update_FR_latency (cpu, out_FRk, ps->post_wait);
1720 update_FR_latency (cpu, dual_FRk, ps->post_wait);
1722 /* Once initiated, post-processing will take 15 cycles. */
1723 update_FR_ptime (cpu, out_FRk, 15);
1724 update_FR_ptime (cpu, dual_FRk, 15);
1726 /* The latency of the sqrt unit will be at least the latency of the other
1728 update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
1730 /* Mark this use of the register as a floating point op. */
1732 set_use_is_fpop (cpu, out_FRk);
1734 set_use_is_fpop (cpu, dual_FRk);
1740 frvbf_model_fr500_u_float_compare (SIM_CPU *cpu, const IDESC *idesc,
1741 int unit_num, int referenced,
1742 INT in_FRi, INT in_FRj,
1743 INT in_FRdoublei, INT in_FRdoublej,
1747 FRV_PROFILE_STATE *ps;
1749 if (model_insn == FRV_INSN_MODEL_PASS_1)
1752 /* The preprocessing can execute right away. */
1753 cycles = idesc->timing->units[unit_num].done;
1755 /* The post processing must wait if there is a dependency on a FR
1756 which is not ready yet. */
1757 adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
1758 ps = CPU_PROFILE_STATE (cpu);
1759 ps->post_wait = cycles;
1760 post_wait_for_FR (cpu, in_FRi);
1761 post_wait_for_FR (cpu, in_FRj);
1762 post_wait_for_FRdouble (cpu, in_FRdoublei);
1763 post_wait_for_FRdouble (cpu, in_FRdoublej);
1764 post_wait_for_CCR (cpu, out_FCCi_2);
1765 restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
1767 /* The latency of FCCi_2 will be the latency of the other inputs plus 3
1769 update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
1775 frvbf_model_fr500_u_float_dual_compare (SIM_CPU *cpu, const IDESC *idesc,
1776 int unit_num, int referenced,
1777 INT in_FRi, INT in_FRj,
1784 FRV_PROFILE_STATE *ps;
1786 if (model_insn == FRV_INSN_MODEL_PASS_1)
1789 /* The preprocessing can execute right away. */
1790 cycles = idesc->timing->units[unit_num].done;
1792 /* The post processing must wait if there is a dependency on a FR
1793 which is not ready yet. */
1794 ps = CPU_PROFILE_STATE (cpu);
1795 ps->post_wait = cycles;
1796 dual_FRi = DUAL_REG (in_FRi);
1797 dual_FRj = DUAL_REG (in_FRj);
1798 dual_FCCi_2 = out_FCCi_2 + 1;
1799 adjust_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
1800 adjust_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
1801 post_wait_for_FR (cpu, in_FRi);
1802 post_wait_for_FR (cpu, in_FRj);
1803 post_wait_for_FR (cpu, dual_FRi);
1804 post_wait_for_FR (cpu, dual_FRj);
1805 post_wait_for_CCR (cpu, out_FCCi_2);
1806 post_wait_for_CCR (cpu, dual_FCCi_2);
1807 restore_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
1808 restore_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
1810 /* The latency of FCCi_2 will be the latency of the other inputs plus 3
1812 update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
1813 update_CCR_latency (cpu, dual_FCCi_2, ps->post_wait + 3);
1819 frvbf_model_fr500_u_float_convert (SIM_CPU *cpu, const IDESC *idesc,
1820 int unit_num, int referenced,
1821 INT in_FRj, INT in_FRintj, INT in_FRdoublej,
1822 INT out_FRk, INT out_FRintk,
1826 FRV_PROFILE_STATE *ps;
1828 if (model_insn == FRV_INSN_MODEL_PASS_1)
1831 /* The preprocessing can execute right away. */
1832 cycles = idesc->timing->units[unit_num].done;
1834 /* The post processing must wait if there is a dependency on a FR
1835 which is not ready yet. */
1836 ps = CPU_PROFILE_STATE (cpu);
1837 ps->post_wait = cycles;
1838 adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1839 adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
1840 adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
1841 post_wait_for_FR (cpu, in_FRj);
1842 post_wait_for_FR (cpu, in_FRintj);
1843 post_wait_for_FRdouble (cpu, in_FRdoublej);
1844 post_wait_for_FR (cpu, out_FRk);
1845 post_wait_for_FR (cpu, out_FRintk);
1846 post_wait_for_FRdouble (cpu, out_FRdoublek);
1847 restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1848 restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
1849 restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
1851 /* The latency of FRk will be at least the latency of the other inputs. */
1852 update_FR_latency (cpu, out_FRk, ps->post_wait);
1853 update_FR_latency (cpu, out_FRintk, ps->post_wait);
1854 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1856 /* Once initiated, post-processing will take 3 cycles. */
1857 update_FR_ptime (cpu, out_FRk, 3);
1858 update_FR_ptime (cpu, out_FRintk, 3);
1859 update_FRdouble_ptime (cpu, out_FRdoublek, 3);
1861 /* Mark this use of the register as a floating point op. */
1863 set_use_is_fpop (cpu, out_FRk);
1864 if (out_FRintk >= 0)
1865 set_use_is_fpop (cpu, out_FRintk);
1866 if (out_FRdoublek >= 0)
1868 set_use_is_fpop (cpu, out_FRdoublek);
1869 set_use_is_fpop (cpu, out_FRdoublek + 1);
1876 frvbf_model_fr500_u_float_dual_convert (SIM_CPU *cpu, const IDESC *idesc,
1877 int unit_num, int referenced,
1878 INT in_FRj, INT in_FRintj,
1879 INT out_FRk, INT out_FRintk)
1886 FRV_PROFILE_STATE *ps;
1888 if (model_insn == FRV_INSN_MODEL_PASS_1)
1891 /* The preprocessing can execute right away. */
1892 cycles = idesc->timing->units[unit_num].done;
1894 /* The post processing must wait if there is a dependency on a FR
1895 which is not ready yet. */
1896 ps = CPU_PROFILE_STATE (cpu);
1897 ps->post_wait = cycles;
1898 dual_FRj = DUAL_REG (in_FRj);
1899 dual_FRintj = DUAL_REG (in_FRintj);
1900 dual_FRk = DUAL_REG (out_FRk);
1901 dual_FRintk = DUAL_REG (out_FRintk);
1902 adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1903 adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
1904 adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
1905 adjust_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
1906 post_wait_for_FR (cpu, in_FRj);
1907 post_wait_for_FR (cpu, in_FRintj);
1908 post_wait_for_FR (cpu, out_FRk);
1909 post_wait_for_FR (cpu, out_FRintk);
1910 post_wait_for_FR (cpu, dual_FRj);
1911 post_wait_for_FR (cpu, dual_FRintj);
1912 post_wait_for_FR (cpu, dual_FRk);
1913 post_wait_for_FR (cpu, dual_FRintk);
1914 restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1915 restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
1916 restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
1917 restore_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
1919 /* The latency of FRk will be at least the latency of the other inputs. */
1920 update_FR_latency (cpu, out_FRk, ps->post_wait);
1921 update_FR_latency (cpu, out_FRintk, ps->post_wait);
1922 update_FR_latency (cpu, dual_FRk, ps->post_wait);
1923 update_FR_latency (cpu, dual_FRintk, ps->post_wait);
1925 /* Once initiated, post-processing will take 3 cycles. */
1926 update_FR_ptime (cpu, out_FRk, 3);
1927 update_FR_ptime (cpu, out_FRintk, 3);
1928 update_FR_ptime (cpu, dual_FRk, 3);
1929 update_FR_ptime (cpu, dual_FRintk, 3);
1931 /* Mark this use of the register as a floating point op. */
1933 set_use_is_fpop (cpu, out_FRk);
1934 if (out_FRintk >= 0)
1935 set_use_is_fpop (cpu, out_FRintk);
1941 frvbf_model_fr500_u_media (SIM_CPU *cpu, const IDESC *idesc,
1942 int unit_num, int referenced,
1943 INT in_FRi, INT in_FRj, INT in_ACC40Si, INT in_ACCGi,
1945 INT out_ACC40Sk, INT out_ACC40Uk, INT out_ACCGk)
1948 FRV_PROFILE_STATE *ps;
1949 const CGEN_INSN *insn;
1952 int busy_adjustment[] = {0, 0, 0};
1956 if (model_insn == FRV_INSN_MODEL_PASS_1)
1959 /* The preprocessing can execute right away. */
1960 cycles = idesc->timing->units[unit_num].done;
1962 ps = CPU_PROFILE_STATE (cpu);
1963 insn = idesc->idata;
1965 /* If the previous use of the registers was a media op,
1966 then their latency will be less than previously recorded.
1967 See Table 13-13 in the LSI. */
1970 if (use_is_media (cpu, in_FRi))
1972 busy_adjustment[0] = 2;
1973 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
1976 enforce_full_fr_latency (cpu, in_FRi);
1978 if (in_FRj >= 0 && in_FRj != in_FRi)
1980 if (use_is_media (cpu, in_FRj))
1982 busy_adjustment[1] = 2;
1983 decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
1986 enforce_full_fr_latency (cpu, in_FRj);
1988 if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
1990 if (use_is_media (cpu, out_FRk))
1992 busy_adjustment[2] = 2;
1993 decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
1996 enforce_full_fr_latency (cpu, out_FRk);
1999 /* The post processing must wait if there is a dependency on a FR
2000 which is not ready yet. */
2001 ps->post_wait = cycles;
2002 post_wait_for_FR (cpu, in_FRi);
2003 post_wait_for_FR (cpu, in_FRj);
2004 post_wait_for_FR (cpu, out_FRk);
2005 post_wait_for_ACC (cpu, in_ACC40Si);
2006 post_wait_for_ACC (cpu, in_ACCGi);
2007 post_wait_for_ACC (cpu, out_ACC40Sk);
2008 post_wait_for_ACC (cpu, out_ACC40Uk);
2009 post_wait_for_ACC (cpu, out_ACCGk);
2011 /* Restore the busy cycles of the registers we used. */
2014 fr[in_FRi] += busy_adjustment[0];
2016 fr[in_FRj] += busy_adjustment[1];
2018 fr[out_FRk] += busy_adjustment[2];
2020 /* The latency of tht output register will be at least the latency of the
2021 other inputs. Once initiated, post-processing will take 3 cycles. */
2024 update_FR_latency (cpu, out_FRk, ps->post_wait);
2025 update_FR_ptime (cpu, out_FRk, 3);
2026 /* Mark this use of the register as a media op. */
2027 set_use_is_media (cpu, out_FRk);
2029 /* The latency of tht output accumulator will be at least the latency of the
2030 other inputs. Once initiated, post-processing will take 1 cycle. */
2031 if (out_ACC40Sk >= 0)
2032 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2033 if (out_ACC40Uk >= 0)
2034 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
2036 update_ACC_latency (cpu, out_ACCGk, ps->post_wait + 1);
2042 frvbf_model_fr500_u_media_quad_arith (SIM_CPU *cpu, const IDESC *idesc,
2043 int unit_num, int referenced,
2044 INT in_FRi, INT in_FRj,
2051 FRV_PROFILE_STATE *ps;
2052 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
2055 if (model_insn == FRV_INSN_MODEL_PASS_1)
2058 /* The preprocessing can execute right away. */
2059 cycles = idesc->timing->units[unit_num].done;
2061 ps = CPU_PROFILE_STATE (cpu);
2062 dual_FRi = DUAL_REG (in_FRi);
2063 dual_FRj = DUAL_REG (in_FRj);
2064 dual_FRk = DUAL_REG (out_FRk);
2066 /* If the previous use of the registers was a media op,
2067 then their latency will be less than previously recorded.
2068 See Table 13-13 in the LSI. */
2069 if (use_is_media (cpu, in_FRi))
2071 busy_adjustment[0] = 2;
2072 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2075 enforce_full_fr_latency (cpu, in_FRi);
2076 if (dual_FRi >= 0 && use_is_media (cpu, dual_FRi))
2078 busy_adjustment[1] = 2;
2079 decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
2082 enforce_full_fr_latency (cpu, dual_FRi);
2083 if (in_FRj != in_FRi)
2085 if (use_is_media (cpu, in_FRj))
2087 busy_adjustment[2] = 2;
2088 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
2091 enforce_full_fr_latency (cpu, in_FRj);
2092 if (dual_FRj >= 0 && use_is_media (cpu, dual_FRj))
2094 busy_adjustment[3] = 2;
2095 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[3]);
2098 enforce_full_fr_latency (cpu, dual_FRj + 1);
2100 if (out_FRk != in_FRi && out_FRk != in_FRj)
2102 if (use_is_media (cpu, out_FRk))
2104 busy_adjustment[4] = 2;
2105 decrease_FR_busy (cpu, out_FRk, busy_adjustment[4]);
2108 enforce_full_fr_latency (cpu, out_FRk);
2109 if (dual_FRk >= 0 && use_is_media (cpu, dual_FRk))
2111 busy_adjustment[5] = 2;
2112 decrease_FR_busy (cpu, dual_FRk, busy_adjustment[5]);
2115 enforce_full_fr_latency (cpu, dual_FRk);
2118 /* The post processing must wait if there is a dependency on a FR
2119 which is not ready yet. */
2120 ps->post_wait = cycles;
2121 post_wait_for_FR (cpu, in_FRi);
2122 post_wait_for_FR (cpu, dual_FRi);
2123 post_wait_for_FR (cpu, in_FRj);
2124 post_wait_for_FR (cpu, dual_FRj);
2125 post_wait_for_FR (cpu, out_FRk);
2126 post_wait_for_FR (cpu, dual_FRk);
2128 /* Restore the busy cycles of the registers we used. */
2130 fr[in_FRi] += busy_adjustment[0];
2132 fr[dual_FRi] += busy_adjustment[1];
2133 fr[in_FRj] += busy_adjustment[2];
2135 fr[dual_FRj] += busy_adjustment[3];
2136 fr[out_FRk] += busy_adjustment[4];
2138 fr[dual_FRk] += busy_adjustment[5];
2140 /* The latency of tht output register will be at least the latency of the
2142 update_FR_latency (cpu, out_FRk, ps->post_wait);
2144 /* Once initiated, post-processing will take 3 cycles. */
2145 update_FR_ptime (cpu, out_FRk, 3);
2147 /* Mark this use of the register as a media op. */
2148 set_use_is_media (cpu, out_FRk);
2151 update_FR_latency (cpu, dual_FRk, ps->post_wait);
2152 update_FR_ptime (cpu, dual_FRk, 3);
2153 /* Mark this use of the register as a media op. */
2154 set_use_is_media (cpu, dual_FRk);
2161 frvbf_model_fr500_u_media_dual_mul (SIM_CPU *cpu, const IDESC *idesc,
2162 int unit_num, int referenced,
2163 INT in_FRi, INT in_FRj,
2164 INT out_ACC40Sk, INT out_ACC40Uk)
2169 FRV_PROFILE_STATE *ps;
2170 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
2174 if (model_insn == FRV_INSN_MODEL_PASS_1)
2177 /* The preprocessing can execute right away. */
2178 cycles = idesc->timing->units[unit_num].done;
2180 ps = CPU_PROFILE_STATE (cpu);
2181 dual_ACC40Sk = DUAL_REG (out_ACC40Sk);
2182 dual_ACC40Uk = DUAL_REG (out_ACC40Uk);
2184 /* If the previous use of the registers was a media op,
2185 then their latency will be less than previously recorded.
2186 See Table 13-13 in the LSI. */
2187 if (use_is_media (cpu, in_FRi))
2189 busy_adjustment[0] = 2;
2190 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2193 enforce_full_fr_latency (cpu, in_FRi);
2194 if (in_FRj != in_FRi)
2196 if (use_is_media (cpu, in_FRj))
2198 busy_adjustment[1] = 2;
2199 decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
2202 enforce_full_fr_latency (cpu, in_FRj);
2204 if (out_ACC40Sk >= 0)
2206 busy_adjustment[2] = 1;
2207 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
2209 if (dual_ACC40Sk >= 0)
2211 busy_adjustment[3] = 1;
2212 decrease_ACC_busy (cpu, dual_ACC40Sk, busy_adjustment[3]);
2214 if (out_ACC40Uk >= 0)
2216 busy_adjustment[4] = 1;
2217 decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
2219 if (dual_ACC40Uk >= 0)
2221 busy_adjustment[5] = 1;
2222 decrease_ACC_busy (cpu, dual_ACC40Uk, busy_adjustment[5]);
2225 /* The post processing must wait if there is a dependency on a FR
2226 which is not ready yet. */
2227 ps->post_wait = cycles;
2228 post_wait_for_FR (cpu, in_FRi);
2229 post_wait_for_FR (cpu, in_FRj);
2230 post_wait_for_ACC (cpu, out_ACC40Sk);
2231 post_wait_for_ACC (cpu, dual_ACC40Sk);
2232 post_wait_for_ACC (cpu, out_ACC40Uk);
2233 post_wait_for_ACC (cpu, dual_ACC40Uk);
2235 /* Restore the busy cycles of the registers we used. */
2238 fr[in_FRi] += busy_adjustment[0];
2239 fr[in_FRj] += busy_adjustment[1];
2240 if (out_ACC40Sk >= 0)
2241 acc[out_ACC40Sk] += busy_adjustment[2];
2242 if (dual_ACC40Sk >= 0)
2243 acc[dual_ACC40Sk] += busy_adjustment[3];
2244 if (out_ACC40Uk >= 0)
2245 acc[out_ACC40Uk] += busy_adjustment[4];
2246 if (dual_ACC40Uk >= 0)
2247 acc[dual_ACC40Uk] += busy_adjustment[5];
2249 /* The latency of tht output register will be at least the latency of the
2250 other inputs. Once initiated, post-processing will take 1 cycle. */
2251 if (out_ACC40Sk >= 0)
2252 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2253 if (dual_ACC40Sk >= 0)
2254 update_ACC_latency (cpu, dual_ACC40Sk, ps->post_wait + 1);
2255 if (out_ACC40Uk >= 0)
2256 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
2257 if (dual_ACC40Uk >= 0)
2258 update_ACC_latency (cpu, dual_ACC40Uk, ps->post_wait + 1);
2264 frvbf_model_fr500_u_media_quad_mul (SIM_CPU *cpu, const IDESC *idesc,
2265 int unit_num, int referenced,
2266 INT in_FRi, INT in_FRj,
2267 INT out_ACC40Sk, INT out_ACC40Uk)
2278 FRV_PROFILE_STATE *ps;
2279 int busy_adjustment[] = {0, 0, 0, 0, 0, 0, 0 ,0};
2283 if (model_insn == FRV_INSN_MODEL_PASS_1)
2286 /* The preprocessing can execute right away. */
2287 cycles = idesc->timing->units[unit_num].done;
2289 FRi_1 = DUAL_REG (in_FRi);
2290 FRj_1 = DUAL_REG (in_FRj);
2291 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
2292 ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
2293 ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
2294 ACC40Uk_1 = DUAL_REG (out_ACC40Uk);
2295 ACC40Uk_2 = DUAL_REG (ACC40Uk_1);
2296 ACC40Uk_3 = DUAL_REG (ACC40Uk_2);
2298 /* If the previous use of the registers was a media op,
2299 then their latency will be less than previously recorded.
2300 See Table 13-13 in the LSI. */
2301 ps = CPU_PROFILE_STATE (cpu);
2302 if (use_is_media (cpu, in_FRi))
2304 busy_adjustment[0] = 2;
2305 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2308 enforce_full_fr_latency (cpu, in_FRi);
2311 if (use_is_media (cpu, FRi_1))
2313 busy_adjustment[1] = 2;
2314 decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
2317 enforce_full_fr_latency (cpu, FRi_1);
2319 if (in_FRj != in_FRi)
2321 if (use_is_media (cpu, in_FRj))
2323 busy_adjustment[2] = 2;
2324 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
2327 enforce_full_fr_latency (cpu, in_FRj);
2330 if (use_is_media (cpu, FRj_1))
2332 busy_adjustment[3] = 2;
2333 decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
2336 enforce_full_fr_latency (cpu, FRj_1);
2339 if (out_ACC40Sk >= 0)
2341 busy_adjustment[4] = 1;
2342 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
2346 busy_adjustment[5] = 1;
2347 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
2351 busy_adjustment[6] = 1;
2352 decrease_ACC_busy (cpu, ACC40Sk_2, busy_adjustment[6]);
2356 busy_adjustment[7] = 1;
2357 decrease_ACC_busy (cpu, ACC40Sk_3, busy_adjustment[7]);
2360 else if (out_ACC40Uk >= 0)
2362 busy_adjustment[4] = 1;
2363 decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
2367 busy_adjustment[5] = 1;
2368 decrease_ACC_busy (cpu, ACC40Uk_1, busy_adjustment[5]);
2372 busy_adjustment[6] = 1;
2373 decrease_ACC_busy (cpu, ACC40Uk_2, busy_adjustment[6]);
2377 busy_adjustment[7] = 1;
2378 decrease_ACC_busy (cpu, ACC40Uk_3, busy_adjustment[7]);
2382 /* The post processing must wait if there is a dependency on a FR
2383 which is not ready yet. */
2384 ps->post_wait = cycles;
2385 post_wait_for_FR (cpu, in_FRi);
2386 post_wait_for_FR (cpu, FRi_1);
2387 post_wait_for_FR (cpu, in_FRj);
2388 post_wait_for_FR (cpu, FRj_1);
2389 post_wait_for_ACC (cpu, out_ACC40Sk);
2390 post_wait_for_ACC (cpu, ACC40Sk_1);
2391 post_wait_for_ACC (cpu, ACC40Sk_2);
2392 post_wait_for_ACC (cpu, ACC40Sk_3);
2393 post_wait_for_ACC (cpu, out_ACC40Uk);
2394 post_wait_for_ACC (cpu, ACC40Uk_1);
2395 post_wait_for_ACC (cpu, ACC40Uk_2);
2396 post_wait_for_ACC (cpu, ACC40Uk_3);
2398 /* Restore the busy cycles of the registers we used. */
2401 fr[in_FRi] += busy_adjustment[0];
2403 fr[FRi_1] += busy_adjustment[1];
2404 fr[in_FRj] += busy_adjustment[2];
2406 fr[FRj_1] += busy_adjustment[3];
2407 if (out_ACC40Sk >= 0)
2409 acc[out_ACC40Sk] += busy_adjustment[4];
2411 acc[ACC40Sk_1] += busy_adjustment[5];
2413 acc[ACC40Sk_2] += busy_adjustment[6];
2415 acc[ACC40Sk_3] += busy_adjustment[7];
2417 else if (out_ACC40Uk >= 0)
2419 acc[out_ACC40Uk] += busy_adjustment[4];
2421 acc[ACC40Uk_1] += busy_adjustment[5];
2423 acc[ACC40Uk_2] += busy_adjustment[6];
2425 acc[ACC40Uk_3] += busy_adjustment[7];
2428 /* The latency of tht output register will be at least the latency of the
2429 other inputs. Once initiated, post-processing will take 1 cycle. */
2430 if (out_ACC40Sk >= 0)
2432 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2434 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
2436 update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
2438 update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
2440 else if (out_ACC40Uk >= 0)
2442 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
2444 update_ACC_latency (cpu, ACC40Uk_1, ps->post_wait + 1);
2446 update_ACC_latency (cpu, ACC40Uk_2, ps->post_wait + 1);
2448 update_ACC_latency (cpu, ACC40Uk_3, ps->post_wait + 1);
2455 frvbf_model_fr500_u_media_quad_complex (SIM_CPU *cpu, const IDESC *idesc,
2456 int unit_num, int referenced,
2457 INT in_FRi, INT in_FRj,
2464 FRV_PROFILE_STATE *ps;
2465 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
2469 if (model_insn == FRV_INSN_MODEL_PASS_1)
2472 /* The preprocessing can execute right away. */
2473 cycles = idesc->timing->units[unit_num].done;
2475 FRi_1 = DUAL_REG (in_FRi);
2476 FRj_1 = DUAL_REG (in_FRj);
2477 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
2479 /* If the previous use of the registers was a media op,
2480 then their latency will be less than previously recorded.
2481 See Table 13-13 in the LSI. */
2482 ps = CPU_PROFILE_STATE (cpu);
2483 if (use_is_media (cpu, in_FRi))
2485 busy_adjustment[0] = 2;
2486 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2489 enforce_full_fr_latency (cpu, in_FRi);
2492 if (use_is_media (cpu, FRi_1))
2494 busy_adjustment[1] = 2;
2495 decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
2498 enforce_full_fr_latency (cpu, FRi_1);
2500 if (in_FRj != in_FRi)
2502 if (use_is_media (cpu, in_FRj))
2504 busy_adjustment[2] = 2;
2505 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
2508 enforce_full_fr_latency (cpu, in_FRj);
2511 if (use_is_media (cpu, FRj_1))
2513 busy_adjustment[3] = 2;
2514 decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
2517 enforce_full_fr_latency (cpu, FRj_1);
2520 if (out_ACC40Sk >= 0)
2522 busy_adjustment[4] = 1;
2523 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
2527 busy_adjustment[5] = 1;
2528 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
2532 /* The post processing must wait if there is a dependency on a FR
2533 which is not ready yet. */
2534 ps->post_wait = cycles;
2535 post_wait_for_FR (cpu, in_FRi);
2536 post_wait_for_FR (cpu, FRi_1);
2537 post_wait_for_FR (cpu, in_FRj);
2538 post_wait_for_FR (cpu, FRj_1);
2539 post_wait_for_ACC (cpu, out_ACC40Sk);
2540 post_wait_for_ACC (cpu, ACC40Sk_1);
2542 /* Restore the busy cycles of the registers we used. */
2545 fr[in_FRi] += busy_adjustment[0];
2547 fr[FRi_1] += busy_adjustment[1];
2548 fr[in_FRj] += busy_adjustment[2];
2550 fr[FRj_1] += busy_adjustment[3];
2551 if (out_ACC40Sk >= 0)
2553 acc[out_ACC40Sk] += busy_adjustment[4];
2555 acc[ACC40Sk_1] += busy_adjustment[5];
2558 /* The latency of tht output register will be at least the latency of the
2559 other inputs. Once initiated, post-processing will take 1 cycle. */
2560 if (out_ACC40Sk >= 0)
2562 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2564 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
2571 frvbf_model_fr500_u_media_dual_expand (SIM_CPU *cpu, const IDESC *idesc,
2572 int unit_num, int referenced,
2578 FRV_PROFILE_STATE *ps;
2579 int busy_adjustment[] = {0, 0, 0};
2582 if (model_insn == FRV_INSN_MODEL_PASS_1)
2585 /* The preprocessing can execute right away. */
2586 cycles = idesc->timing->units[unit_num].done;
2588 /* If the previous use of the registers was a media op,
2589 then their latency will be less than previously recorded.
2590 See Table 13-13 in the LSI. */
2591 dual_FRk = DUAL_REG (out_FRk);
2592 ps = CPU_PROFILE_STATE (cpu);
2593 if (use_is_media (cpu, in_FRi))
2595 busy_adjustment[0] = 2;
2596 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2599 enforce_full_fr_latency (cpu, in_FRi);
2600 if (out_FRk != in_FRi)
2602 if (use_is_media (cpu, out_FRk))
2604 busy_adjustment[1] = 2;
2605 decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
2608 enforce_full_fr_latency (cpu, out_FRk);
2610 if (dual_FRk >= 0 && dual_FRk != in_FRi)
2612 if (use_is_media (cpu, dual_FRk))
2614 busy_adjustment[2] = 2;
2615 decrease_FR_busy (cpu, dual_FRk, busy_adjustment[2]);
2618 enforce_full_fr_latency (cpu, dual_FRk);
2621 /* The post processing must wait if there is a dependency on a FR
2622 which is not ready yet. */
2623 ps->post_wait = cycles;
2624 post_wait_for_FR (cpu, in_FRi);
2625 post_wait_for_FR (cpu, out_FRk);
2626 post_wait_for_FR (cpu, dual_FRk);
2628 /* Restore the busy cycles of the registers we used. */
2630 fr[in_FRi] += busy_adjustment[0];
2631 fr[out_FRk] += busy_adjustment[1];
2633 fr[dual_FRk] += busy_adjustment[2];
2635 /* The latency of tht output register will be at least the latency of the
2636 other inputs. Once initiated, post-processing will take 3 cycles. */
2637 update_FR_latency (cpu, out_FRk, ps->post_wait);
2638 update_FR_ptime (cpu, out_FRk, 3);
2640 /* Mark this use of the register as a media op. */
2641 set_use_is_media (cpu, out_FRk);
2644 update_FR_latency (cpu, dual_FRk, ps->post_wait);
2645 update_FR_ptime (cpu, dual_FRk, 3);
2647 /* Mark this use of the register as a media op. */
2648 set_use_is_media (cpu, dual_FRk);
2655 frvbf_model_fr500_u_media_dual_unpack (SIM_CPU *cpu, const IDESC *idesc,
2656 int unit_num, int referenced,
2665 FRV_PROFILE_STATE *ps;
2666 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
2669 if (model_insn == FRV_INSN_MODEL_PASS_1)
2672 /* The preprocessing can execute right away. */
2673 cycles = idesc->timing->units[unit_num].done;
2675 FRi_1 = DUAL_REG (in_FRi);
2676 FRk_1 = DUAL_REG (out_FRk);
2677 FRk_2 = DUAL_REG (FRk_1);
2678 FRk_3 = DUAL_REG (FRk_2);
2680 /* If the previous use of the registers was a media op,
2681 then their latency will be less than previously recorded.
2682 See Table 13-13 in the LSI. */
2683 ps = CPU_PROFILE_STATE (cpu);
2684 if (use_is_media (cpu, in_FRi))
2686 busy_adjustment[0] = 2;
2687 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2690 enforce_full_fr_latency (cpu, in_FRi);
2691 if (FRi_1 >= 0 && use_is_media (cpu, FRi_1))
2693 busy_adjustment[1] = 2;
2694 decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
2697 enforce_full_fr_latency (cpu, FRi_1);
2698 if (out_FRk != in_FRi)
2700 if (use_is_media (cpu, out_FRk))
2702 busy_adjustment[2] = 2;
2703 decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
2706 enforce_full_fr_latency (cpu, out_FRk);
2707 if (FRk_1 >= 0 && FRk_1 != in_FRi)
2709 if (use_is_media (cpu, FRk_1))
2711 busy_adjustment[3] = 2;
2712 decrease_FR_busy (cpu, FRk_1, busy_adjustment[3]);
2715 enforce_full_fr_latency (cpu, FRk_1);
2717 if (FRk_2 >= 0 && FRk_2 != in_FRi)
2719 if (use_is_media (cpu, FRk_2))
2721 busy_adjustment[4] = 2;
2722 decrease_FR_busy (cpu, FRk_2, busy_adjustment[4]);
2725 enforce_full_fr_latency (cpu, FRk_2);
2727 if (FRk_3 >= 0 && FRk_3 != in_FRi)
2729 if (use_is_media (cpu, FRk_3))
2731 busy_adjustment[5] = 2;
2732 decrease_FR_busy (cpu, FRk_3, busy_adjustment[5]);
2735 enforce_full_fr_latency (cpu, FRk_3);
2739 /* The post processing must wait if there is a dependency on a FR
2740 which is not ready yet. */
2741 ps->post_wait = cycles;
2742 post_wait_for_FR (cpu, in_FRi);
2743 post_wait_for_FR (cpu, FRi_1);
2744 post_wait_for_FR (cpu, out_FRk);
2745 post_wait_for_FR (cpu, FRk_1);
2746 post_wait_for_FR (cpu, FRk_2);
2747 post_wait_for_FR (cpu, FRk_3);
2749 /* Restore the busy cycles of the registers we used. */
2751 fr[in_FRi] += busy_adjustment[0];
2753 fr[FRi_1] += busy_adjustment[1];
2754 fr[out_FRk] += busy_adjustment[2];
2756 fr[FRk_1] += busy_adjustment[3];
2758 fr[FRk_2] += busy_adjustment[4];
2760 fr[FRk_3] += busy_adjustment[5];
2762 /* The latency of tht output register will be at least the latency of the
2763 other inputs. Once initiated, post-processing will take 3 cycles. */
2764 update_FR_latency (cpu, out_FRk, ps->post_wait);
2765 update_FR_ptime (cpu, out_FRk, 3);
2767 /* Mark this use of the register as a media op. */
2768 set_use_is_media (cpu, out_FRk);
2771 update_FR_latency (cpu, FRk_1, ps->post_wait);
2772 update_FR_ptime (cpu, FRk_1, 3);
2774 /* Mark this use of the register as a media op. */
2775 set_use_is_media (cpu, FRk_1);
2779 update_FR_latency (cpu, FRk_2, ps->post_wait);
2780 update_FR_ptime (cpu, FRk_2, 3);
2782 /* Mark this use of the register as a media op. */
2783 set_use_is_media (cpu, FRk_2);
2787 update_FR_latency (cpu, FRk_3, ps->post_wait);
2788 update_FR_ptime (cpu, FRk_3, 3);
2790 /* Mark this use of the register as a media op. */
2791 set_use_is_media (cpu, FRk_3);
2798 frvbf_model_fr500_u_media_dual_btoh (SIM_CPU *cpu, const IDESC *idesc,
2799 int unit_num, int referenced,
2803 return frvbf_model_fr500_u_media_dual_expand (cpu, idesc, unit_num,
2804 referenced, in_FRj, out_FRk);
2808 frvbf_model_fr500_u_media_dual_htob (SIM_CPU *cpu, const IDESC *idesc,
2809 int unit_num, int referenced,
2815 FRV_PROFILE_STATE *ps;
2816 int busy_adjustment[] = {0, 0, 0};
2819 if (model_insn == FRV_INSN_MODEL_PASS_1)
2822 /* The preprocessing can execute right away. */
2823 cycles = idesc->timing->units[unit_num].done;
2825 /* If the previous use of the registers was a media op,
2826 then their latency will be less than previously recorded.
2827 See Table 13-13 in the LSI. */
2828 dual_FRj = DUAL_REG (in_FRj);
2829 ps = CPU_PROFILE_STATE (cpu);
2830 if (use_is_media (cpu, in_FRj))
2832 busy_adjustment[0] = 2;
2833 decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
2836 enforce_full_fr_latency (cpu, in_FRj);
2839 if (use_is_media (cpu, dual_FRj))
2841 busy_adjustment[1] = 2;
2842 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[1]);
2845 enforce_full_fr_latency (cpu, dual_FRj);
2847 if (out_FRk != in_FRj)
2849 if (use_is_media (cpu, out_FRk))
2851 busy_adjustment[2] = 2;
2852 decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
2855 enforce_full_fr_latency (cpu, out_FRk);
2858 /* The post processing must wait if there is a dependency on a FR
2859 which is not ready yet. */
2860 ps->post_wait = cycles;
2861 post_wait_for_FR (cpu, in_FRj);
2862 post_wait_for_FR (cpu, dual_FRj);
2863 post_wait_for_FR (cpu, out_FRk);
2865 /* Restore the busy cycles of the registers we used. */
2867 fr[in_FRj] += busy_adjustment[0];
2869 fr[dual_FRj] += busy_adjustment[1];
2870 fr[out_FRk] += busy_adjustment[2];
2872 /* The latency of tht output register will be at least the latency of the
2874 update_FR_latency (cpu, out_FRk, ps->post_wait);
2876 /* Once initiated, post-processing will take 3 cycles. */
2877 update_FR_ptime (cpu, out_FRk, 3);
2879 /* Mark this use of the register as a media op. */
2880 set_use_is_media (cpu, out_FRk);
2886 frvbf_model_fr500_u_media_dual_btohe (SIM_CPU *cpu, const IDESC *idesc,
2887 int unit_num, int referenced,
2895 FRV_PROFILE_STATE *ps;
2896 int busy_adjustment[] = {0, 0, 0, 0, 0};
2899 if (model_insn == FRV_INSN_MODEL_PASS_1)
2902 /* The preprocessing can execute right away. */
2903 cycles = idesc->timing->units[unit_num].done;
2905 FRk_1 = DUAL_REG (out_FRk);
2906 FRk_2 = DUAL_REG (FRk_1);
2907 FRk_3 = DUAL_REG (FRk_2);
2909 /* If the previous use of the registers was a media op,
2910 then their latency will be less than previously recorded.
2911 See Table 13-13 in the LSI. */
2912 ps = CPU_PROFILE_STATE (cpu);
2913 if (use_is_media (cpu, in_FRj))
2915 busy_adjustment[0] = 2;
2916 decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
2919 enforce_full_fr_latency (cpu, in_FRj);
2920 if (out_FRk != in_FRj)
2922 if (use_is_media (cpu, out_FRk))
2924 busy_adjustment[1] = 2;
2925 decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
2928 enforce_full_fr_latency (cpu, out_FRk);
2929 if (FRk_1 >= 0 && FRk_1 != in_FRj)
2931 if (use_is_media (cpu, FRk_1))
2933 busy_adjustment[2] = 2;
2934 decrease_FR_busy (cpu, FRk_1, busy_adjustment[2]);
2937 enforce_full_fr_latency (cpu, FRk_1);
2939 if (FRk_2 >= 0 && FRk_2 != in_FRj)
2941 if (use_is_media (cpu, FRk_2))
2943 busy_adjustment[3] = 2;
2944 decrease_FR_busy (cpu, FRk_2, busy_adjustment[3]);
2947 enforce_full_fr_latency (cpu, FRk_2);
2949 if (FRk_3 >= 0 && FRk_3 != in_FRj)
2951 if (use_is_media (cpu, FRk_3))
2953 busy_adjustment[4] = 2;
2954 decrease_FR_busy (cpu, FRk_3, busy_adjustment[4]);
2957 enforce_full_fr_latency (cpu, FRk_3);
2961 /* The post processing must wait if there is a dependency on a FR
2962 which is not ready yet. */
2963 ps->post_wait = cycles;
2964 post_wait_for_FR (cpu, in_FRj);
2965 post_wait_for_FR (cpu, out_FRk);
2966 post_wait_for_FR (cpu, FRk_1);
2967 post_wait_for_FR (cpu, FRk_2);
2968 post_wait_for_FR (cpu, FRk_3);
2970 /* Restore the busy cycles of the registers we used. */
2972 fr[in_FRj] += busy_adjustment[0];
2973 fr[out_FRk] += busy_adjustment[1];
2975 fr[FRk_1] += busy_adjustment[2];
2977 fr[FRk_2] += busy_adjustment[3];
2979 fr[FRk_3] += busy_adjustment[4];
2981 /* The latency of tht output register will be at least the latency of the
2982 other inputs. Once initiated, post-processing will take 3 cycles. */
2983 update_FR_latency (cpu, out_FRk, ps->post_wait);
2984 update_FR_ptime (cpu, out_FRk, 3);
2986 /* Mark this use of the register as a media op. */
2987 set_use_is_media (cpu, out_FRk);
2990 update_FR_latency (cpu, FRk_1, ps->post_wait);
2991 update_FR_ptime (cpu, FRk_1, 3);
2993 /* Mark this use of the register as a media op. */
2994 set_use_is_media (cpu, FRk_1);
2998 update_FR_latency (cpu, FRk_2, ps->post_wait);
2999 update_FR_ptime (cpu, FRk_2, 3);
3001 /* Mark this use of the register as a media op. */
3002 set_use_is_media (cpu, FRk_2);
3006 update_FR_latency (cpu, FRk_3, ps->post_wait);
3007 update_FR_ptime (cpu, FRk_3, 3);
3009 /* Mark this use of the register as a media op. */
3010 set_use_is_media (cpu, FRk_3);
3017 frvbf_model_fr500_u_barrier (SIM_CPU *cpu, const IDESC *idesc,
3018 int unit_num, int referenced)
3021 if (model_insn == FRV_INSN_MODEL_PASS_1)
3024 /* Wait for ALL resources. */
3025 for (i = 0; i < 64; ++i)
3027 enforce_full_fr_latency (cpu, i);
3028 vliw_wait_for_GR (cpu, i);
3029 vliw_wait_for_FR (cpu, i);
3030 vliw_wait_for_ACC (cpu, i);
3032 for (i = 0; i < 8; ++i)
3033 vliw_wait_for_CCR (cpu, i);
3034 for (i = 0; i < 2; ++i)
3036 vliw_wait_for_idiv_resource (cpu, i);
3037 vliw_wait_for_fdiv_resource (cpu, i);
3038 vliw_wait_for_fsqrt_resource (cpu, i);
3040 handle_resource_wait (cpu);
3041 for (i = 0; i < 64; ++i)
3043 load_wait_for_GR (cpu, i);
3044 load_wait_for_FR (cpu, i);
3046 trace_vliw_wait_cycles (cpu);
3050 cycles = idesc->timing->units[unit_num].done;
3055 frvbf_model_fr500_u_membar (SIM_CPU *cpu, const IDESC *idesc,
3056 int unit_num, int referenced)
3059 if (model_insn == FRV_INSN_MODEL_PASS_1)
3062 /* Wait for ALL resources, except GR and ICC. */
3063 for (i = 0; i < 64; ++i)
3065 enforce_full_fr_latency (cpu, i);
3066 vliw_wait_for_FR (cpu, i);
3067 vliw_wait_for_ACC (cpu, i);
3069 for (i = 0; i < 4; ++i)
3070 vliw_wait_for_CCR (cpu, i);
3071 for (i = 0; i < 2; ++i)
3073 vliw_wait_for_idiv_resource (cpu, i);
3074 vliw_wait_for_fdiv_resource (cpu, i);
3075 vliw_wait_for_fsqrt_resource (cpu, i);
3077 handle_resource_wait (cpu);
3078 for (i = 0; i < 64; ++i)
3080 load_wait_for_FR (cpu, i);
3082 trace_vliw_wait_cycles (cpu);
3086 cycles = idesc->timing->units[unit_num].done;
3090 /* The frv machine is a fictional implementation of the fr500 which implements
3091 all frv architectural features. */
3093 frvbf_model_frv_u_exec (SIM_CPU *cpu, const IDESC *idesc,
3094 int unit_num, int referenced)
3096 return idesc->timing->units[unit_num].done;
3099 /* The simple machine is a fictional implementation of the fr500 which
3100 implements limited frv architectural features. */
3102 frvbf_model_simple_u_exec (SIM_CPU *cpu, const IDESC *idesc,
3103 int unit_num, int referenced)
3105 return idesc->timing->units[unit_num].done;
3108 /* The tomcat machine is models a prototype fr500 machine which had a few
3109 bugs and restrictions to work around. */
3111 frvbf_model_tomcat_u_exec (SIM_CPU *cpu, const IDESC *idesc,
3112 int unit_num, int referenced)
3114 return idesc->timing->units[unit_num].done;
3117 #endif /* WITH_PROFILE_MODEL_P */