1 /* frv simulator fr400 dependent profiling code.
3 Copyright (C) 2001, 2007, 2008 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 3 of the License, or
11 (at your option) any later version.
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
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #define WANT_CPU_FRVBF
28 #if WITH_PROFILE_MODEL_P
31 #include "profile-fr400.h"
33 /* These functions get and set flags representing the use of
34 registers/resources. */
35 static void set_use_not_fp_load (SIM_CPU *, INT);
36 static void set_use_not_media_p4 (SIM_CPU *, INT);
37 static void set_use_not_media_p6 (SIM_CPU *, INT);
39 static void set_acc_use_not_media_p2 (SIM_CPU *, INT);
40 static void set_acc_use_not_media_p4 (SIM_CPU *, INT);
43 fr400_reset_gr_flags (SIM_CPU *cpu, INT fr)
45 set_use_not_gr_complex (cpu, fr);
49 fr400_reset_fr_flags (SIM_CPU *cpu, INT fr)
51 set_use_not_fp_load (cpu, fr);
52 set_use_not_media_p4 (cpu, fr);
53 set_use_not_media_p6 (cpu, fr);
57 fr400_reset_acc_flags (SIM_CPU *cpu, INT acc)
59 set_acc_use_not_media_p2 (cpu, acc);
60 set_acc_use_not_media_p4 (cpu, acc);
64 set_use_is_fp_load (SIM_CPU *cpu, INT fr, INT fr_double)
66 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
69 fr400_reset_fr_flags (cpu, fr);
70 d->cur_fp_load |= (((DI)1) << fr);
74 fr400_reset_fr_flags (cpu, fr_double);
75 d->cur_fp_load |= (((DI)1) << fr_double);
78 fr400_reset_fr_flags (cpu, fr_double + 1);
79 d->cur_fp_load |= (((DI)1) << (fr_double + 1));
86 set_use_not_fp_load (SIM_CPU *cpu, INT fr)
88 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
90 d->cur_fp_load &= ~(((DI)1) << fr);
94 use_is_fp_load (SIM_CPU *cpu, INT fr)
96 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
98 return (d->prev_fp_load >> fr) & 1;
103 set_acc_use_is_media_p2 (SIM_CPU *cpu, INT acc)
105 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
108 fr400_reset_acc_flags (cpu, acc);
109 d->cur_acc_p2 |= (((DI)1) << acc);
114 set_acc_use_not_media_p2 (SIM_CPU *cpu, INT acc)
116 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
118 d->cur_acc_p2 &= ~(((DI)1) << acc);
122 acc_use_is_media_p2 (SIM_CPU *cpu, INT acc)
124 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
126 return d->cur_acc_p2 & (((DI)1) << acc);
131 set_use_is_media_p4 (SIM_CPU *cpu, INT fr)
133 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
136 fr400_reset_fr_flags (cpu, fr);
137 d->cur_fr_p4 |= (((DI)1) << fr);
142 set_use_not_media_p4 (SIM_CPU *cpu, INT fr)
144 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
146 d->cur_fr_p4 &= ~(((DI)1) << fr);
150 use_is_media_p4 (SIM_CPU *cpu, INT fr)
152 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
154 return d->cur_fr_p4 & (((DI)1) << fr);
159 set_acc_use_is_media_p4 (SIM_CPU *cpu, INT acc)
161 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
164 fr400_reset_acc_flags (cpu, acc);
165 d->cur_acc_p4 |= (((DI)1) << acc);
170 set_acc_use_not_media_p4 (SIM_CPU *cpu, INT acc)
172 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
174 d->cur_acc_p4 &= ~(((DI)1) << acc);
178 acc_use_is_media_p4 (SIM_CPU *cpu, INT acc)
180 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
182 return d->cur_acc_p4 & (((DI)1) << acc);
187 set_use_is_media_p6 (SIM_CPU *cpu, INT fr)
189 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
192 fr400_reset_fr_flags (cpu, fr);
193 d->cur_fr_p6 |= (((DI)1) << fr);
198 set_use_not_media_p6 (SIM_CPU *cpu, INT fr)
200 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
202 d->cur_fr_p6 &= ~(((DI)1) << fr);
206 use_is_media_p6 (SIM_CPU *cpu, INT fr)
208 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
210 return d->cur_fr_p6 & (((DI)1) << fr);
214 /* Initialize cycle counting for an insn.
215 FIRST_P is non-zero if this is the first insn in a set of parallel
218 fr400_model_insn_before (SIM_CPU *cpu, int first_p)
222 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
223 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
224 ps->cur_gr_complex = ps->prev_gr_complex;
225 d->cur_fp_load = d->prev_fp_load;
226 d->cur_fr_p4 = d->prev_fr_p4;
227 d->cur_fr_p6 = d->prev_fr_p6;
228 d->cur_acc_p2 = d->prev_acc_p2;
229 d->cur_acc_p4 = d->prev_acc_p4;
233 /* Record the cycles computed for an insn.
234 LAST_P is non-zero if this is the last insn in a set of parallel insns,
235 and we update the total cycle count.
236 CYCLES is the cycle count of the insn. */
238 fr400_model_insn_after (SIM_CPU *cpu, int last_p, int cycles)
242 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
243 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
244 ps->prev_gr_complex = ps->cur_gr_complex;
245 d->prev_fp_load = d->cur_fp_load;
246 d->prev_fr_p4 = d->cur_fr_p4;
247 d->prev_fr_p6 = d->cur_fr_p6;
248 d->prev_acc_p2 = d->cur_acc_p2;
249 d->prev_acc_p4 = d->cur_acc_p4;
254 frvbf_model_fr400_u_exec (SIM_CPU *cpu, const IDESC *idesc,
255 int unit_num, int referenced)
257 return idesc->timing->units[unit_num].done;
261 frvbf_model_fr400_u_integer (SIM_CPU *cpu, const IDESC *idesc,
262 int unit_num, int referenced,
263 INT in_GRi, INT in_GRj, INT out_GRk,
266 /* Modelling for this unit is the same as for fr500. */
267 return frvbf_model_fr500_u_integer (cpu, idesc, unit_num, referenced,
268 in_GRi, in_GRj, out_GRk, out_ICCi_1);
272 frvbf_model_fr400_u_imul (SIM_CPU *cpu, const IDESC *idesc,
273 int unit_num, int referenced,
274 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
276 /* Modelling for this unit is the same as for fr500. */
277 return frvbf_model_fr500_u_imul (cpu, idesc, unit_num, referenced,
278 in_GRi, in_GRj, out_GRk, out_ICCi_1);
282 frvbf_model_fr400_u_idiv (SIM_CPU *cpu, const IDESC *idesc,
283 int unit_num, int referenced,
284 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
290 /* icc0-icc4 are the upper 4 fields of the CCR. */
294 vliw = CPU_VLIW (cpu);
295 slot = vliw->next_slot - 1;
296 slot = (*vliw->current_vliw)[slot] - UNIT_I0;
298 if (model_insn == FRV_INSN_MODEL_PASS_1)
300 /* The entire VLIW insn must wait if there is a dependency on a register
301 which is not ready yet.
302 The latency of the registers may be less than previously recorded,
303 depending on how they were used previously.
304 See Table 13-8 in the LSI. */
305 if (in_GRi != out_GRk && in_GRi >= 0)
307 if (use_is_gr_complex (cpu, in_GRi))
308 decrease_GR_busy (cpu, in_GRi, 1);
310 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
312 if (use_is_gr_complex (cpu, in_GRj))
313 decrease_GR_busy (cpu, in_GRj, 1);
315 vliw_wait_for_GR (cpu, in_GRi);
316 vliw_wait_for_GR (cpu, in_GRj);
317 vliw_wait_for_GR (cpu, out_GRk);
318 vliw_wait_for_CCR (cpu, out_ICCi_1);
319 vliw_wait_for_idiv_resource (cpu, slot);
320 handle_resource_wait (cpu);
321 load_wait_for_GR (cpu, in_GRi);
322 load_wait_for_GR (cpu, in_GRj);
323 load_wait_for_GR (cpu, out_GRk);
324 trace_vliw_wait_cycles (cpu);
328 /* GRk has a latency of 19 cycles! */
329 cycles = idesc->timing->units[unit_num].done;
330 update_GR_latency (cpu, out_GRk, cycles + 19);
331 set_use_is_gr_complex (cpu, out_GRk);
333 /* ICCi_1 has a latency of 18 cycles. */
334 update_CCR_latency (cpu, out_ICCi_1, cycles + 18);
336 /* the idiv resource has a latency of 18 cycles! */
337 update_idiv_resource_latency (cpu, slot, cycles + 18);
343 frvbf_model_fr400_u_branch (SIM_CPU *cpu, const IDESC *idesc,
344 int unit_num, int referenced,
345 INT in_GRi, INT in_GRj,
346 INT in_ICCi_2, INT in_ICCi_3)
348 #define BRANCH_PREDICTED(ps) ((ps)->branch_hint & 2)
349 FRV_PROFILE_STATE *ps;
352 if (model_insn == FRV_INSN_MODEL_PASS_1)
354 /* Modelling for this unit is the same as for fr500 in pass 1. */
355 return frvbf_model_fr500_u_branch (cpu, idesc, unit_num, referenced,
356 in_GRi, in_GRj, in_ICCi_2, in_ICCi_3);
359 cycles = idesc->timing->units[unit_num].done;
361 /* Compute the branch penalty, based on the the prediction and the out
362 come. When counting branches taken or not taken, don't consider branches
363 after the first taken branch in a vliw insn. */
364 ps = CPU_PROFILE_STATE (cpu);
365 if (! ps->vliw_branch_taken)
368 /* (1 << 4): The pc is the 5th element in inputs, outputs.
369 ??? can be cleaned up */
370 PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
371 int taken = (referenced & (1 << 4)) != 0;
374 ++PROFILE_MODEL_TAKEN_COUNT (p);
375 ps->vliw_branch_taken = 1;
376 if (BRANCH_PREDICTED (ps))
383 ++PROFILE_MODEL_UNTAKEN_COUNT (p);
384 if (BRANCH_PREDICTED (ps))
391 /* Additional 1 cycle penalty if the branch address is not 8 byte
393 if (ps->branch_address & 7)
395 update_branch_penalty (cpu, penalty);
396 PROFILE_MODEL_CTI_STALL_CYCLES (p) += penalty;
404 frvbf_model_fr400_u_trap (SIM_CPU *cpu, const IDESC *idesc,
405 int unit_num, int referenced,
406 INT in_GRi, INT in_GRj,
407 INT in_ICCi_2, INT in_FCCi_2)
409 /* Modelling for this unit is the same as for fr500. */
410 return frvbf_model_fr500_u_trap (cpu, idesc, unit_num, referenced,
411 in_GRi, in_GRj, in_ICCi_2, in_FCCi_2);
415 frvbf_model_fr400_u_check (SIM_CPU *cpu, const IDESC *idesc,
416 int unit_num, int referenced,
417 INT in_ICCi_3, INT in_FCCi_3)
419 /* Modelling for this unit is the same as for fr500. */
420 return frvbf_model_fr500_u_check (cpu, idesc, unit_num, referenced,
421 in_ICCi_3, in_FCCi_3);
425 frvbf_model_fr400_u_set_hilo (SIM_CPU *cpu, const IDESC *idesc,
426 int unit_num, int referenced,
427 INT out_GRkhi, INT out_GRklo)
429 /* Modelling for this unit is the same as for fr500. */
430 return frvbf_model_fr500_u_set_hilo (cpu, idesc, unit_num, referenced,
431 out_GRkhi, out_GRklo);
435 frvbf_model_fr400_u_gr_load (SIM_CPU *cpu, const IDESC *idesc,
436 int unit_num, int referenced,
437 INT in_GRi, INT in_GRj,
438 INT out_GRk, INT out_GRdoublek)
440 /* Modelling for this unit is the same as for fr500. */
441 return frvbf_model_fr500_u_gr_load (cpu, idesc, unit_num, referenced,
442 in_GRi, in_GRj, out_GRk, out_GRdoublek);
446 frvbf_model_fr400_u_gr_store (SIM_CPU *cpu, const IDESC *idesc,
447 int unit_num, int referenced,
448 INT in_GRi, INT in_GRj,
449 INT in_GRk, INT in_GRdoublek)
451 /* Modelling for this unit is the same as for fr500. */
452 return frvbf_model_fr500_u_gr_store (cpu, idesc, unit_num, referenced,
453 in_GRi, in_GRj, in_GRk, in_GRdoublek);
457 frvbf_model_fr400_u_fr_load (SIM_CPU *cpu, const IDESC *idesc,
458 int unit_num, int referenced,
459 INT in_GRi, INT in_GRj,
460 INT out_FRk, INT out_FRdoublek)
464 if (model_insn == FRV_INSN_MODEL_PASS_1)
466 /* Pass 1 is the same as for fr500. */
467 return frvbf_model_fr500_u_fr_load (cpu, idesc, unit_num, referenced,
468 in_GRi, in_GRj, out_FRk,
472 cycles = idesc->timing->units[unit_num].done;
474 /* The latency of FRk for a load will depend on how long it takes to retrieve
475 the the data from the cache or memory. */
476 update_FR_latency_for_load (cpu, out_FRk, cycles);
477 update_FRdouble_latency_for_load (cpu, out_FRdoublek, cycles);
479 set_use_is_fp_load (cpu, out_FRk, out_FRdoublek);
485 frvbf_model_fr400_u_fr_store (SIM_CPU *cpu, const IDESC *idesc,
486 int unit_num, int referenced,
487 INT in_GRi, INT in_GRj,
488 INT in_FRk, INT in_FRdoublek)
492 if (model_insn == FRV_INSN_MODEL_PASS_1)
494 /* The entire VLIW insn must wait if there is a dependency on a register
495 which is not ready yet.
496 The latency of the registers may be less than previously recorded,
497 depending on how they were used previously.
498 See Table 13-8 in the LSI. */
501 if (use_is_gr_complex (cpu, in_GRi))
502 decrease_GR_busy (cpu, in_GRi, 1);
504 if (in_GRj != in_GRi && in_GRj >= 0)
506 if (use_is_gr_complex (cpu, in_GRj))
507 decrease_GR_busy (cpu, in_GRj, 1);
511 if (use_is_media_p4 (cpu, in_FRk) || use_is_media_p6 (cpu, in_FRk))
512 decrease_FR_busy (cpu, in_FRk, 1);
514 enforce_full_fr_latency (cpu, in_FRk);
516 vliw_wait_for_GR (cpu, in_GRi);
517 vliw_wait_for_GR (cpu, in_GRj);
518 vliw_wait_for_FR (cpu, in_FRk);
519 vliw_wait_for_FRdouble (cpu, in_FRdoublek);
520 handle_resource_wait (cpu);
521 load_wait_for_GR (cpu, in_GRi);
522 load_wait_for_GR (cpu, in_GRj);
523 load_wait_for_FR (cpu, in_FRk);
524 load_wait_for_FRdouble (cpu, in_FRdoublek);
525 trace_vliw_wait_cycles (cpu);
529 cycles = idesc->timing->units[unit_num].done;
535 frvbf_model_fr400_u_swap (SIM_CPU *cpu, const IDESC *idesc,
536 int unit_num, int referenced,
537 INT in_GRi, INT in_GRj, INT out_GRk)
539 /* Modelling for this unit is the same as for fr500. */
540 return frvbf_model_fr500_u_swap (cpu, idesc, unit_num, referenced,
541 in_GRi, in_GRj, out_GRk);
545 frvbf_model_fr400_u_fr2gr (SIM_CPU *cpu, const IDESC *idesc,
546 int unit_num, int referenced,
547 INT in_FRk, INT out_GRj)
551 if (model_insn == FRV_INSN_MODEL_PASS_1)
553 /* The entire VLIW insn must wait if there is a dependency on a register
554 which is not ready yet.
555 The latency of the registers may be less than previously recorded,
556 depending on how they were used previously.
557 See Table 13-8 in the LSI. */
560 if (use_is_media_p4 (cpu, in_FRk) || use_is_media_p6 (cpu, in_FRk))
561 decrease_FR_busy (cpu, in_FRk, 1);
563 enforce_full_fr_latency (cpu, in_FRk);
565 vliw_wait_for_FR (cpu, in_FRk);
566 vliw_wait_for_GR (cpu, out_GRj);
567 handle_resource_wait (cpu);
568 load_wait_for_FR (cpu, in_FRk);
569 load_wait_for_GR (cpu, out_GRj);
570 trace_vliw_wait_cycles (cpu);
574 /* The latency of GRj is 2 cycles. */
575 cycles = idesc->timing->units[unit_num].done;
576 update_GR_latency (cpu, out_GRj, cycles + 2);
577 set_use_is_gr_complex (cpu, out_GRj);
583 frvbf_model_fr400_u_spr2gr (SIM_CPU *cpu, const IDESC *idesc,
584 int unit_num, int referenced,
585 INT in_spr, INT out_GRj)
587 /* Modelling for this unit is the same as for fr500. */
588 return frvbf_model_fr500_u_spr2gr (cpu, idesc, unit_num, referenced,
593 frvbf_model_fr400_u_gr2fr (SIM_CPU *cpu, const IDESC *idesc,
594 int unit_num, int referenced,
595 INT in_GRj, INT out_FRk)
599 if (model_insn == FRV_INSN_MODEL_PASS_1)
601 /* Pass 1 is the same as for fr500. */
602 frvbf_model_fr500_u_gr2fr (cpu, idesc, unit_num, referenced,
606 /* The latency of FRk is 1 cycles. */
607 cycles = idesc->timing->units[unit_num].done;
608 update_FR_latency (cpu, out_FRk, cycles + 1);
614 frvbf_model_fr400_u_gr2spr (SIM_CPU *cpu, const IDESC *idesc,
615 int unit_num, int referenced,
616 INT in_GRj, INT out_spr)
618 /* Modelling for this unit is the same as for fr500. */
619 return frvbf_model_fr500_u_gr2spr (cpu, idesc, unit_num, referenced,
624 frvbf_model_fr400_u_media_1 (SIM_CPU *cpu, const IDESC *idesc,
625 int unit_num, int referenced,
626 INT in_FRi, INT in_FRj,
630 FRV_PROFILE_STATE *ps;
631 const CGEN_INSN *insn;
632 int busy_adjustment[] = {0, 0};
635 if (model_insn == FRV_INSN_MODEL_PASS_1)
638 /* The preprocessing can execute right away. */
639 cycles = idesc->timing->units[unit_num].done;
641 ps = CPU_PROFILE_STATE (cpu);
644 /* The latency of the registers may be less than previously recorded,
645 depending on how they were used previously.
646 See Table 13-8 in the LSI. */
649 if (use_is_fp_load (cpu, in_FRi))
651 busy_adjustment[0] = 1;
652 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
655 enforce_full_fr_latency (cpu, in_FRi);
657 if (in_FRj >= 0 && in_FRj != in_FRi)
659 if (use_is_fp_load (cpu, in_FRj))
661 busy_adjustment[1] = 1;
662 decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
665 enforce_full_fr_latency (cpu, in_FRj);
668 /* The post processing must wait if there is a dependency on a FR
669 which is not ready yet. */
670 ps->post_wait = cycles;
671 post_wait_for_FR (cpu, in_FRi);
672 post_wait_for_FR (cpu, in_FRj);
673 post_wait_for_FR (cpu, out_FRk);
675 /* Restore the busy cycles of the registers we used. */
678 fr[in_FRi] += busy_adjustment[0];
680 fr[in_FRj] += busy_adjustment[1];
682 /* The latency of the output register will be at least the latency of the
683 other inputs. Once initiated, post-processing has no latency. */
686 update_FR_latency (cpu, out_FRk, ps->post_wait);
687 update_FR_ptime (cpu, out_FRk, 0);
694 frvbf_model_fr400_u_media_1_quad (SIM_CPU *cpu, const IDESC *idesc,
695 int unit_num, int referenced,
696 INT in_FRi, INT in_FRj,
703 FRV_PROFILE_STATE *ps;
704 int busy_adjustment[] = {0, 0, 0, 0};
707 if (model_insn == FRV_INSN_MODEL_PASS_1)
710 /* The preprocessing can execute right away. */
711 cycles = idesc->timing->units[unit_num].done;
713 ps = CPU_PROFILE_STATE (cpu);
714 dual_FRi = DUAL_REG (in_FRi);
715 dual_FRj = DUAL_REG (in_FRj);
716 dual_FRk = DUAL_REG (out_FRk);
718 /* The latency of the registers may be less than previously recorded,
719 depending on how they were used previously.
720 See Table 13-8 in the LSI. */
721 if (use_is_fp_load (cpu, in_FRi))
723 busy_adjustment[0] = 1;
724 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
727 enforce_full_fr_latency (cpu, in_FRi);
728 if (dual_FRi >= 0 && use_is_fp_load (cpu, dual_FRi))
730 busy_adjustment[1] = 1;
731 decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
734 enforce_full_fr_latency (cpu, dual_FRi);
735 if (in_FRj != in_FRi)
737 if (use_is_fp_load (cpu, in_FRj))
739 busy_adjustment[2] = 1;
740 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
743 enforce_full_fr_latency (cpu, in_FRj);
744 if (dual_FRj >= 0 && use_is_fp_load (cpu, dual_FRj))
746 busy_adjustment[3] = 1;
747 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[3]);
750 enforce_full_fr_latency (cpu, dual_FRj);
753 /* The post processing must wait if there is a dependency on a FR
754 which is not ready yet. */
755 ps->post_wait = cycles;
756 post_wait_for_FR (cpu, in_FRi);
757 post_wait_for_FR (cpu, dual_FRi);
758 post_wait_for_FR (cpu, in_FRj);
759 post_wait_for_FR (cpu, dual_FRj);
760 post_wait_for_FR (cpu, out_FRk);
761 post_wait_for_FR (cpu, dual_FRk);
763 /* Restore the busy cycles of the registers we used. */
765 fr[in_FRi] += busy_adjustment[0];
767 fr[dual_FRi] += busy_adjustment[1];
768 fr[in_FRj] += busy_adjustment[2];
770 fr[dual_FRj] += busy_adjustment[3];
772 /* The latency of the output register will be at least the latency of the
774 update_FR_latency (cpu, out_FRk, ps->post_wait);
776 /* Once initiated, post-processing has no latency. */
777 update_FR_ptime (cpu, out_FRk, 0);
781 update_FR_latency (cpu, dual_FRk, ps->post_wait);
782 update_FR_ptime (cpu, dual_FRk, 0);
789 frvbf_model_fr400_u_media_hilo (SIM_CPU *cpu, const IDESC *idesc,
790 int unit_num, int referenced,
791 INT out_FRkhi, INT out_FRklo)
794 FRV_PROFILE_STATE *ps;
796 if (model_insn == FRV_INSN_MODEL_PASS_1)
799 /* The preprocessing can execute right away. */
800 cycles = idesc->timing->units[unit_num].done;
802 ps = CPU_PROFILE_STATE (cpu);
804 /* The post processing must wait if there is a dependency on a FR
805 which is not ready yet. */
806 ps->post_wait = cycles;
807 post_wait_for_FR (cpu, out_FRkhi);
808 post_wait_for_FR (cpu, out_FRklo);
810 /* The latency of the output register will be at least the latency of the
811 other inputs. Once initiated, post-processing has no latency. */
814 update_FR_latency (cpu, out_FRkhi, ps->post_wait);
815 update_FR_ptime (cpu, out_FRkhi, 0);
819 update_FR_latency (cpu, out_FRklo, ps->post_wait);
820 update_FR_ptime (cpu, out_FRklo, 0);
827 frvbf_model_fr400_u_media_2 (SIM_CPU *cpu, const IDESC *idesc,
828 int unit_num, int referenced,
829 INT in_FRi, INT in_FRj,
830 INT out_ACC40Sk, INT out_ACC40Uk)
835 FRV_PROFILE_STATE *ps;
836 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
840 if (model_insn == FRV_INSN_MODEL_PASS_1)
843 /* The preprocessing can execute right away. */
844 cycles = idesc->timing->units[unit_num].done;
846 ps = CPU_PROFILE_STATE (cpu);
847 dual_ACC40Sk = DUAL_REG (out_ACC40Sk);
848 dual_ACC40Uk = DUAL_REG (out_ACC40Uk);
850 /* The latency of the registers may be less than previously recorded,
851 depending on how they were used previously.
852 See Table 13-8 in the LSI. */
855 if (use_is_fp_load (cpu, in_FRi))
857 busy_adjustment[0] = 1;
858 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
861 enforce_full_fr_latency (cpu, in_FRi);
863 if (in_FRj >= 0 && in_FRj != in_FRi)
865 if (use_is_fp_load (cpu, in_FRj))
867 busy_adjustment[1] = 1;
868 decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
871 enforce_full_fr_latency (cpu, in_FRj);
873 if (out_ACC40Sk >= 0)
875 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
877 busy_adjustment[2] = 1;
878 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
881 if (dual_ACC40Sk >= 0)
883 if (acc_use_is_media_p2 (cpu, dual_ACC40Sk))
885 busy_adjustment[3] = 1;
886 decrease_ACC_busy (cpu, dual_ACC40Sk, busy_adjustment[3]);
889 if (out_ACC40Uk >= 0)
891 if (acc_use_is_media_p2 (cpu, out_ACC40Uk))
893 busy_adjustment[4] = 1;
894 decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
897 if (dual_ACC40Uk >= 0)
899 if (acc_use_is_media_p2 (cpu, dual_ACC40Uk))
901 busy_adjustment[5] = 1;
902 decrease_ACC_busy (cpu, dual_ACC40Uk, busy_adjustment[5]);
906 /* The post processing must wait if there is a dependency on a FR
907 which is not ready yet. */
908 ps->post_wait = cycles;
909 post_wait_for_FR (cpu, in_FRi);
910 post_wait_for_FR (cpu, in_FRj);
911 post_wait_for_ACC (cpu, out_ACC40Sk);
912 post_wait_for_ACC (cpu, dual_ACC40Sk);
913 post_wait_for_ACC (cpu, out_ACC40Uk);
914 post_wait_for_ACC (cpu, dual_ACC40Uk);
916 /* Restore the busy cycles of the registers we used. */
919 fr[in_FRi] += busy_adjustment[0];
920 fr[in_FRj] += busy_adjustment[1];
921 if (out_ACC40Sk >= 0)
922 acc[out_ACC40Sk] += busy_adjustment[2];
923 if (dual_ACC40Sk >= 0)
924 acc[dual_ACC40Sk] += busy_adjustment[3];
925 if (out_ACC40Uk >= 0)
926 acc[out_ACC40Uk] += busy_adjustment[4];
927 if (dual_ACC40Uk >= 0)
928 acc[dual_ACC40Uk] += busy_adjustment[5];
930 /* The latency of the output register will be at least the latency of the
931 other inputs. Once initiated, post-processing will take 1 cycles. */
932 if (out_ACC40Sk >= 0)
934 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
935 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
937 if (dual_ACC40Sk >= 0)
939 update_ACC_latency (cpu, dual_ACC40Sk, ps->post_wait + 1);
940 set_acc_use_is_media_p2 (cpu, dual_ACC40Sk);
942 if (out_ACC40Uk >= 0)
944 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
945 set_acc_use_is_media_p2 (cpu, out_ACC40Uk);
947 if (dual_ACC40Uk >= 0)
949 update_ACC_latency (cpu, dual_ACC40Uk, ps->post_wait + 1);
950 set_acc_use_is_media_p2 (cpu, dual_ACC40Uk);
957 frvbf_model_fr400_u_media_2_quad (SIM_CPU *cpu, const IDESC *idesc,
958 int unit_num, int referenced,
959 INT in_FRi, INT in_FRj,
960 INT out_ACC40Sk, INT out_ACC40Uk)
971 FRV_PROFILE_STATE *ps;
972 int busy_adjustment[] = {0, 0, 0, 0, 0, 0, 0 ,0};
976 if (model_insn == FRV_INSN_MODEL_PASS_1)
979 /* The preprocessing can execute right away. */
980 cycles = idesc->timing->units[unit_num].done;
982 dual_FRi = DUAL_REG (in_FRi);
983 dual_FRj = DUAL_REG (in_FRj);
984 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
985 ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
986 ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
987 ACC40Uk_1 = DUAL_REG (out_ACC40Uk);
988 ACC40Uk_2 = DUAL_REG (ACC40Uk_1);
989 ACC40Uk_3 = DUAL_REG (ACC40Uk_2);
991 ps = CPU_PROFILE_STATE (cpu);
992 /* The latency of the registers may be less than previously recorded,
993 depending on how they were used previously.
994 See Table 13-8 in the LSI. */
995 if (use_is_fp_load (cpu, in_FRi))
997 busy_adjustment[0] = 1;
998 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
1001 enforce_full_fr_latency (cpu, in_FRi);
1002 if (dual_FRi >= 0 && use_is_fp_load (cpu, dual_FRi))
1004 busy_adjustment[1] = 1;
1005 decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
1008 enforce_full_fr_latency (cpu, dual_FRi);
1009 if (in_FRj != in_FRi)
1011 if (use_is_fp_load (cpu, in_FRj))
1013 busy_adjustment[2] = 1;
1014 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
1017 enforce_full_fr_latency (cpu, in_FRj);
1018 if (dual_FRj >= 0 && use_is_fp_load (cpu, dual_FRj))
1020 busy_adjustment[3] = 1;
1021 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[3]);
1024 enforce_full_fr_latency (cpu, dual_FRj);
1026 if (out_ACC40Sk >= 0)
1028 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
1030 busy_adjustment[4] = 1;
1031 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
1035 if (acc_use_is_media_p2 (cpu, ACC40Sk_1))
1037 busy_adjustment[5] = 1;
1038 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
1043 if (acc_use_is_media_p2 (cpu, ACC40Sk_2))
1045 busy_adjustment[6] = 1;
1046 decrease_ACC_busy (cpu, ACC40Sk_2, busy_adjustment[6]);
1051 if (acc_use_is_media_p2 (cpu, ACC40Sk_3))
1053 busy_adjustment[7] = 1;
1054 decrease_ACC_busy (cpu, ACC40Sk_3, busy_adjustment[7]);
1058 else if (out_ACC40Uk >= 0)
1060 if (acc_use_is_media_p2 (cpu, out_ACC40Uk))
1062 busy_adjustment[4] = 1;
1063 decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
1067 if (acc_use_is_media_p2 (cpu, ACC40Uk_1))
1069 busy_adjustment[5] = 1;
1070 decrease_ACC_busy (cpu, ACC40Uk_1, busy_adjustment[5]);
1075 if (acc_use_is_media_p2 (cpu, ACC40Uk_2))
1077 busy_adjustment[6] = 1;
1078 decrease_ACC_busy (cpu, ACC40Uk_2, busy_adjustment[6]);
1083 if (acc_use_is_media_p2 (cpu, ACC40Uk_3))
1085 busy_adjustment[7] = 1;
1086 decrease_ACC_busy (cpu, ACC40Uk_3, busy_adjustment[7]);
1091 /* The post processing must wait if there is a dependency on a FR
1092 which is not ready yet. */
1093 ps->post_wait = cycles;
1094 post_wait_for_FR (cpu, in_FRi);
1095 post_wait_for_FR (cpu, dual_FRi);
1096 post_wait_for_FR (cpu, in_FRj);
1097 post_wait_for_FR (cpu, dual_FRj);
1098 post_wait_for_ACC (cpu, out_ACC40Sk);
1099 post_wait_for_ACC (cpu, ACC40Sk_1);
1100 post_wait_for_ACC (cpu, ACC40Sk_2);
1101 post_wait_for_ACC (cpu, ACC40Sk_3);
1102 post_wait_for_ACC (cpu, out_ACC40Uk);
1103 post_wait_for_ACC (cpu, ACC40Uk_1);
1104 post_wait_for_ACC (cpu, ACC40Uk_2);
1105 post_wait_for_ACC (cpu, ACC40Uk_3);
1107 /* Restore the busy cycles of the registers we used. */
1110 fr[in_FRi] += busy_adjustment[0];
1112 fr[dual_FRi] += busy_adjustment[1];
1113 fr[in_FRj] += busy_adjustment[2];
1115 fr[dual_FRj] += busy_adjustment[3];
1116 if (out_ACC40Sk >= 0)
1118 acc[out_ACC40Sk] += busy_adjustment[4];
1120 acc[ACC40Sk_1] += busy_adjustment[5];
1122 acc[ACC40Sk_2] += busy_adjustment[6];
1124 acc[ACC40Sk_3] += busy_adjustment[7];
1126 else if (out_ACC40Uk >= 0)
1128 acc[out_ACC40Uk] += busy_adjustment[4];
1130 acc[ACC40Uk_1] += busy_adjustment[5];
1132 acc[ACC40Uk_2] += busy_adjustment[6];
1134 acc[ACC40Uk_3] += busy_adjustment[7];
1137 /* The latency of the output register will be at least the latency of the
1138 other inputs. Once initiated, post-processing will take 1 cycle. */
1139 if (out_ACC40Sk >= 0)
1141 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1143 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1146 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
1148 set_acc_use_is_media_p2 (cpu, ACC40Sk_1);
1152 update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
1154 set_acc_use_is_media_p2 (cpu, ACC40Sk_2);
1158 update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
1160 set_acc_use_is_media_p2 (cpu, ACC40Sk_3);
1163 else if (out_ACC40Uk >= 0)
1165 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
1167 set_acc_use_is_media_p2 (cpu, out_ACC40Uk);
1170 update_ACC_latency (cpu, ACC40Uk_1, ps->post_wait + 1);
1172 set_acc_use_is_media_p2 (cpu, ACC40Uk_1);
1176 update_ACC_latency (cpu, ACC40Uk_2, ps->post_wait + 1);
1178 set_acc_use_is_media_p2 (cpu, ACC40Uk_2);
1182 update_ACC_latency (cpu, ACC40Uk_3, ps->post_wait + 1);
1184 set_acc_use_is_media_p2 (cpu, ACC40Uk_3);
1192 frvbf_model_fr400_u_media_2_acc (SIM_CPU *cpu, const IDESC *idesc,
1193 int unit_num, int referenced,
1194 INT in_ACC40Si, INT out_ACC40Sk)
1198 FRV_PROFILE_STATE *ps;
1199 int busy_adjustment[] = {0, 0, 0};
1202 if (model_insn == FRV_INSN_MODEL_PASS_1)
1205 /* The preprocessing can execute right away. */
1206 cycles = idesc->timing->units[unit_num].done;
1208 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1210 ps = CPU_PROFILE_STATE (cpu);
1211 /* The latency of the registers may be less than previously recorded,
1212 depending on how they were used previously.
1213 See Table 13-8 in the LSI. */
1214 if (acc_use_is_media_p2 (cpu, in_ACC40Si))
1216 busy_adjustment[0] = 1;
1217 decrease_ACC_busy (cpu, in_ACC40Si, busy_adjustment[0]);
1219 if (ACC40Si_1 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_1))
1221 busy_adjustment[1] = 1;
1222 decrease_ACC_busy (cpu, ACC40Si_1, busy_adjustment[1]);
1224 if (out_ACC40Sk != in_ACC40Si && out_ACC40Sk != ACC40Si_1
1225 && acc_use_is_media_p2 (cpu, out_ACC40Sk))
1227 busy_adjustment[2] = 1;
1228 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
1231 /* The post processing must wait if there is a dependency on a register
1232 which is not ready yet. */
1233 ps->post_wait = cycles;
1234 post_wait_for_ACC (cpu, in_ACC40Si);
1235 post_wait_for_ACC (cpu, ACC40Si_1);
1236 post_wait_for_ACC (cpu, out_ACC40Sk);
1238 /* Restore the busy cycles of the registers we used. */
1240 acc[in_ACC40Si] += busy_adjustment[0];
1242 acc[ACC40Si_1] += busy_adjustment[1];
1243 acc[out_ACC40Sk] += busy_adjustment[2];
1245 /* The latency of the output register will be at least the latency of the
1246 other inputs. Once initiated, post-processing will take 1 cycle. */
1247 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1248 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1254 frvbf_model_fr400_u_media_2_acc_dual (SIM_CPU *cpu, const IDESC *idesc,
1255 int unit_num, int referenced,
1256 INT in_ACC40Si, INT out_ACC40Sk)
1263 FRV_PROFILE_STATE *ps;
1264 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
1267 if (model_insn == FRV_INSN_MODEL_PASS_1)
1270 /* The preprocessing can execute right away. */
1271 cycles = idesc->timing->units[unit_num].done;
1273 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1274 ACC40Si_2 = DUAL_REG (ACC40Si_1);
1275 ACC40Si_3 = DUAL_REG (ACC40Si_2);
1276 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
1278 ps = CPU_PROFILE_STATE (cpu);
1279 /* The latency of the registers may be less than previously recorded,
1280 depending on how they were used previously.
1281 See Table 13-8 in the LSI. */
1282 if (acc_use_is_media_p2 (cpu, in_ACC40Si))
1284 busy_adjustment[0] = 1;
1285 decrease_ACC_busy (cpu, in_ACC40Si, busy_adjustment[0]);
1287 if (ACC40Si_1 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_1))
1289 busy_adjustment[1] = 1;
1290 decrease_ACC_busy (cpu, ACC40Si_1, busy_adjustment[1]);
1292 if (ACC40Si_2 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_2))
1294 busy_adjustment[2] = 1;
1295 decrease_ACC_busy (cpu, ACC40Si_2, busy_adjustment[2]);
1297 if (ACC40Si_3 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_3))
1299 busy_adjustment[3] = 1;
1300 decrease_ACC_busy (cpu, ACC40Si_3, busy_adjustment[3]);
1302 if (out_ACC40Sk != in_ACC40Si && out_ACC40Sk != ACC40Si_1
1303 && out_ACC40Sk != ACC40Si_2 && out_ACC40Sk != ACC40Si_3)
1305 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
1307 busy_adjustment[4] = 1;
1308 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
1311 if (ACC40Sk_1 != in_ACC40Si && ACC40Sk_1 != ACC40Si_1
1312 && ACC40Sk_1 != ACC40Si_2 && ACC40Sk_1 != ACC40Si_3)
1314 if (acc_use_is_media_p2 (cpu, ACC40Sk_1))
1316 busy_adjustment[5] = 1;
1317 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
1321 /* The post processing must wait if there is a dependency on a register
1322 which is not ready yet. */
1323 ps->post_wait = cycles;
1324 post_wait_for_ACC (cpu, in_ACC40Si);
1325 post_wait_for_ACC (cpu, ACC40Si_1);
1326 post_wait_for_ACC (cpu, ACC40Si_2);
1327 post_wait_for_ACC (cpu, ACC40Si_3);
1328 post_wait_for_ACC (cpu, out_ACC40Sk);
1329 post_wait_for_ACC (cpu, ACC40Sk_1);
1331 /* Restore the busy cycles of the registers we used. */
1333 acc[in_ACC40Si] += busy_adjustment[0];
1335 acc[ACC40Si_1] += busy_adjustment[1];
1337 acc[ACC40Si_2] += busy_adjustment[2];
1339 acc[ACC40Si_3] += busy_adjustment[3];
1340 acc[out_ACC40Sk] += busy_adjustment[4];
1342 acc[ACC40Sk_1] += busy_adjustment[5];
1344 /* The latency of the output register will be at least the latency of the
1345 other inputs. Once initiated, post-processing will take 1 cycle. */
1346 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1347 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1350 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
1351 set_acc_use_is_media_p2 (cpu, ACC40Sk_1);
1358 frvbf_model_fr400_u_media_2_add_sub (SIM_CPU *cpu, const IDESC *idesc,
1359 int unit_num, int referenced,
1360 INT in_ACC40Si, INT out_ACC40Sk)
1365 FRV_PROFILE_STATE *ps;
1366 int busy_adjustment[] = {0, 0, 0, 0};
1369 if (model_insn == FRV_INSN_MODEL_PASS_1)
1372 /* The preprocessing can execute right away. */
1373 cycles = idesc->timing->units[unit_num].done;
1375 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1376 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
1378 ps = CPU_PROFILE_STATE (cpu);
1379 /* The latency of the registers may be less than previously recorded,
1380 depending on how they were used previously.
1381 See Table 13-8 in the LSI. */
1382 if (acc_use_is_media_p2 (cpu, in_ACC40Si))
1384 busy_adjustment[0] = 1;
1385 decrease_ACC_busy (cpu, in_ACC40Si, busy_adjustment[0]);
1387 if (ACC40Si_1 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_1))
1389 busy_adjustment[1] = 1;
1390 decrease_ACC_busy (cpu, ACC40Si_1, busy_adjustment[1]);
1392 if (out_ACC40Sk != in_ACC40Si && out_ACC40Sk != ACC40Si_1)
1394 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
1396 busy_adjustment[2] = 1;
1397 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
1400 if (ACC40Sk_1 != in_ACC40Si && ACC40Sk_1 != ACC40Si_1)
1402 if (acc_use_is_media_p2 (cpu, ACC40Sk_1))
1404 busy_adjustment[3] = 1;
1405 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[3]);
1409 /* The post processing must wait if there is a dependency on a register
1410 which is not ready yet. */
1411 ps->post_wait = cycles;
1412 post_wait_for_ACC (cpu, in_ACC40Si);
1413 post_wait_for_ACC (cpu, ACC40Si_1);
1414 post_wait_for_ACC (cpu, out_ACC40Sk);
1415 post_wait_for_ACC (cpu, ACC40Sk_1);
1417 /* Restore the busy cycles of the registers we used. */
1419 acc[in_ACC40Si] += busy_adjustment[0];
1421 acc[ACC40Si_1] += busy_adjustment[1];
1422 acc[out_ACC40Sk] += busy_adjustment[2];
1424 acc[ACC40Sk_1] += busy_adjustment[3];
1426 /* The latency of the output register will be at least the latency of the
1427 other inputs. Once initiated, post-processing will take 1 cycle. */
1428 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1429 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1432 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
1433 set_acc_use_is_media_p2 (cpu, ACC40Sk_1);
1440 frvbf_model_fr400_u_media_2_add_sub_dual (SIM_CPU *cpu, const IDESC *idesc,
1441 int unit_num, int referenced,
1442 INT in_ACC40Si, INT out_ACC40Sk)
1451 FRV_PROFILE_STATE *ps;
1452 int busy_adjustment[] = {0, 0, 0, 0, 0, 0, 0, 0};
1455 if (model_insn == FRV_INSN_MODEL_PASS_1)
1458 /* The preprocessing can execute right away. */
1459 cycles = idesc->timing->units[unit_num].done;
1461 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1462 ACC40Si_2 = DUAL_REG (ACC40Si_1);
1463 ACC40Si_3 = DUAL_REG (ACC40Si_2);
1464 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
1465 ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
1466 ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
1468 ps = CPU_PROFILE_STATE (cpu);
1469 /* The latency of the registers may be less than previously recorded,
1470 depending on how they were used previously.
1471 See Table 13-8 in the LSI. */
1472 if (acc_use_is_media_p2 (cpu, in_ACC40Si))
1474 busy_adjustment[0] = 1;
1475 decrease_ACC_busy (cpu, in_ACC40Si, busy_adjustment[0]);
1477 if (ACC40Si_1 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_1))
1479 busy_adjustment[1] = 1;
1480 decrease_ACC_busy (cpu, ACC40Si_1, busy_adjustment[1]);
1482 if (ACC40Si_2 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_2))
1484 busy_adjustment[2] = 1;
1485 decrease_ACC_busy (cpu, ACC40Si_2, busy_adjustment[2]);
1487 if (ACC40Si_3 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_3))
1489 busy_adjustment[3] = 1;
1490 decrease_ACC_busy (cpu, ACC40Si_3, busy_adjustment[3]);
1492 if (out_ACC40Sk != in_ACC40Si && out_ACC40Sk != ACC40Si_1
1493 && out_ACC40Sk != ACC40Si_2 && out_ACC40Sk != ACC40Si_3)
1495 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
1497 busy_adjustment[4] = 1;
1498 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
1501 if (ACC40Sk_1 != in_ACC40Si && ACC40Sk_1 != ACC40Si_1
1502 && ACC40Sk_1 != ACC40Si_2 && ACC40Sk_1 != ACC40Si_3)
1504 if (acc_use_is_media_p2 (cpu, ACC40Sk_1))
1506 busy_adjustment[5] = 1;
1507 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
1510 if (ACC40Sk_2 != in_ACC40Si && ACC40Sk_2 != ACC40Si_1
1511 && ACC40Sk_2 != ACC40Si_2 && ACC40Sk_2 != ACC40Si_3)
1513 if (acc_use_is_media_p2 (cpu, ACC40Sk_2))
1515 busy_adjustment[6] = 1;
1516 decrease_ACC_busy (cpu, ACC40Sk_2, busy_adjustment[6]);
1519 if (ACC40Sk_3 != in_ACC40Si && ACC40Sk_3 != ACC40Si_1
1520 && ACC40Sk_3 != ACC40Si_2 && ACC40Sk_3 != ACC40Si_3)
1522 if (acc_use_is_media_p2 (cpu, ACC40Sk_3))
1524 busy_adjustment[7] = 1;
1525 decrease_ACC_busy (cpu, ACC40Sk_3, busy_adjustment[7]);
1529 /* The post processing must wait if there is a dependency on a register
1530 which is not ready yet. */
1531 ps->post_wait = cycles;
1532 post_wait_for_ACC (cpu, in_ACC40Si);
1533 post_wait_for_ACC (cpu, ACC40Si_1);
1534 post_wait_for_ACC (cpu, ACC40Si_2);
1535 post_wait_for_ACC (cpu, ACC40Si_3);
1536 post_wait_for_ACC (cpu, out_ACC40Sk);
1537 post_wait_for_ACC (cpu, ACC40Sk_1);
1538 post_wait_for_ACC (cpu, ACC40Sk_2);
1539 post_wait_for_ACC (cpu, ACC40Sk_3);
1541 /* Restore the busy cycles of the registers we used. */
1543 acc[in_ACC40Si] += busy_adjustment[0];
1545 acc[ACC40Si_1] += busy_adjustment[1];
1547 acc[ACC40Si_2] += busy_adjustment[2];
1549 acc[ACC40Si_3] += busy_adjustment[3];
1550 acc[out_ACC40Sk] += busy_adjustment[4];
1552 acc[ACC40Sk_1] += busy_adjustment[5];
1554 acc[ACC40Sk_2] += busy_adjustment[6];
1556 acc[ACC40Sk_3] += busy_adjustment[7];
1558 /* The latency of the output register will be at least the latency of the
1559 other inputs. Once initiated, post-processing will take 1 cycle. */
1560 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1561 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1564 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
1565 set_acc_use_is_media_p2 (cpu, ACC40Sk_1);
1569 update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
1570 set_acc_use_is_media_p2 (cpu, ACC40Sk_2);
1574 update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
1575 set_acc_use_is_media_p2 (cpu, ACC40Sk_3);
1582 frvbf_model_fr400_u_media_3 (SIM_CPU *cpu, const IDESC *idesc,
1583 int unit_num, int referenced,
1584 INT in_FRi, INT in_FRj,
1587 /* Modelling is the same as media unit 1. */
1588 return frvbf_model_fr400_u_media_1 (cpu, idesc, unit_num, referenced,
1589 in_FRi, in_FRj, out_FRk);
1593 frvbf_model_fr400_u_media_3_dual (SIM_CPU *cpu, const IDESC *idesc,
1594 int unit_num, int referenced,
1595 INT in_FRi, INT out_FRk)
1599 FRV_PROFILE_STATE *ps;
1600 int busy_adjustment[] = {0, 0};
1603 if (model_insn == FRV_INSN_MODEL_PASS_1)
1606 /* The preprocessing can execute right away. */
1607 cycles = idesc->timing->units[unit_num].done;
1609 ps = CPU_PROFILE_STATE (cpu);
1610 dual_FRi = DUAL_REG (in_FRi);
1612 /* The latency of the registers may be less than previously recorded,
1613 depending on how they were used previously.
1614 See Table 13-8 in the LSI. */
1615 if (use_is_fp_load (cpu, in_FRi))
1617 busy_adjustment[0] = 1;
1618 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
1621 enforce_full_fr_latency (cpu, in_FRi);
1622 if (dual_FRi >= 0 && use_is_fp_load (cpu, dual_FRi))
1624 busy_adjustment[1] = 1;
1625 decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
1628 enforce_full_fr_latency (cpu, dual_FRi);
1630 /* The post processing must wait if there is a dependency on a FR
1631 which is not ready yet. */
1632 ps->post_wait = cycles;
1633 post_wait_for_FR (cpu, in_FRi);
1634 post_wait_for_FR (cpu, dual_FRi);
1635 post_wait_for_FR (cpu, out_FRk);
1637 /* Restore the busy cycles of the registers we used. */
1639 fr[in_FRi] += busy_adjustment[0];
1641 fr[dual_FRi] += busy_adjustment[1];
1643 /* The latency of the output register will be at least the latency of the
1645 update_FR_latency (cpu, out_FRk, ps->post_wait);
1647 /* Once initiated, post-processing has no latency. */
1648 update_FR_ptime (cpu, out_FRk, 0);
1654 frvbf_model_fr400_u_media_3_quad (SIM_CPU *cpu, const IDESC *idesc,
1655 int unit_num, int referenced,
1656 INT in_FRi, INT in_FRj,
1659 /* Modelling is the same as media unit 1. */
1660 return frvbf_model_fr400_u_media_1_quad (cpu, idesc, unit_num, referenced,
1661 in_FRi, in_FRj, out_FRk);
1665 frvbf_model_fr400_u_media_4 (SIM_CPU *cpu, const IDESC *idesc,
1666 int unit_num, int referenced,
1667 INT in_ACC40Si, INT in_FRj,
1668 INT out_ACC40Sk, INT out_FRk)
1671 FRV_PROFILE_STATE *ps;
1672 const CGEN_INSN *insn;
1673 int busy_adjustment[] = {0};
1676 if (model_insn == FRV_INSN_MODEL_PASS_1)
1679 /* The preprocessing can execute right away. */
1680 cycles = idesc->timing->units[unit_num].done;
1682 ps = CPU_PROFILE_STATE (cpu);
1683 insn = idesc->idata;
1685 /* The latency of the registers may be less than previously recorded,
1686 depending on how they were used previously.
1687 See Table 13-8 in the LSI. */
1690 if (use_is_fp_load (cpu, in_FRj))
1692 busy_adjustment[0] = 1;
1693 decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
1696 enforce_full_fr_latency (cpu, in_FRj);
1699 /* The post processing must wait if there is a dependency on a FR
1700 which is not ready yet. */
1701 ps->post_wait = cycles;
1702 post_wait_for_ACC (cpu, in_ACC40Si);
1703 post_wait_for_ACC (cpu, out_ACC40Sk);
1704 post_wait_for_FR (cpu, in_FRj);
1705 post_wait_for_FR (cpu, out_FRk);
1707 /* Restore the busy cycles of the registers we used. */
1710 /* The latency of the output register will be at least the latency of the
1711 other inputs. Once initiated, post-processing will take 1 cycle. */
1714 update_FR_latency (cpu, out_FRk, ps->post_wait);
1715 update_FR_ptime (cpu, out_FRk, 1);
1716 /* Mark this use of the register as media unit 4. */
1717 set_use_is_media_p4 (cpu, out_FRk);
1719 else if (out_ACC40Sk >= 0)
1721 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait);
1722 update_ACC_ptime (cpu, out_ACC40Sk, 1);
1723 /* Mark this use of the register as media unit 4. */
1724 set_acc_use_is_media_p4 (cpu, out_ACC40Sk);
1731 frvbf_model_fr400_u_media_4_accg (SIM_CPU *cpu, const IDESC *idesc,
1732 int unit_num, int referenced,
1733 INT in_ACCGi, INT in_FRinti,
1734 INT out_ACCGk, INT out_FRintk)
1736 /* Modelling is the same as media-4 unit except use accumulator guards
1737 as input instead of accumulators. */
1738 return frvbf_model_fr400_u_media_4 (cpu, idesc, unit_num, referenced,
1739 in_ACCGi, in_FRinti,
1740 out_ACCGk, out_FRintk);
1744 frvbf_model_fr400_u_media_4_acc_dual (SIM_CPU *cpu, const IDESC *idesc,
1745 int unit_num, int referenced,
1746 INT in_ACC40Si, INT out_FRk)
1749 FRV_PROFILE_STATE *ps;
1750 const CGEN_INSN *insn;
1754 if (model_insn == FRV_INSN_MODEL_PASS_1)
1757 /* The preprocessing can execute right away. */
1758 cycles = idesc->timing->units[unit_num].done;
1760 ps = CPU_PROFILE_STATE (cpu);
1761 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1762 FRk_1 = DUAL_REG (out_FRk);
1764 insn = idesc->idata;
1766 /* The post processing must wait if there is a dependency on a FR
1767 which is not ready yet. */
1768 ps->post_wait = cycles;
1769 post_wait_for_ACC (cpu, in_ACC40Si);
1770 post_wait_for_ACC (cpu, ACC40Si_1);
1771 post_wait_for_FR (cpu, out_FRk);
1772 post_wait_for_FR (cpu, FRk_1);
1774 /* The latency of the output register will be at least the latency of the
1775 other inputs. Once initiated, post-processing will take 1 cycle. */
1778 update_FR_latency (cpu, out_FRk, ps->post_wait);
1779 update_FR_ptime (cpu, out_FRk, 1);
1780 /* Mark this use of the register as media unit 4. */
1781 set_use_is_media_p4 (cpu, out_FRk);
1785 update_FR_latency (cpu, FRk_1, ps->post_wait);
1786 update_FR_ptime (cpu, FRk_1, 1);
1787 /* Mark this use of the register as media unit 4. */
1788 set_use_is_media_p4 (cpu, FRk_1);
1795 frvbf_model_fr400_u_media_6 (SIM_CPU *cpu, const IDESC *idesc,
1796 int unit_num, int referenced,
1797 INT in_FRi, INT out_FRk)
1800 FRV_PROFILE_STATE *ps;
1801 const CGEN_INSN *insn;
1802 int busy_adjustment[] = {0};
1805 if (model_insn == FRV_INSN_MODEL_PASS_1)
1808 /* The preprocessing can execute right away. */
1809 cycles = idesc->timing->units[unit_num].done;
1811 ps = CPU_PROFILE_STATE (cpu);
1812 insn = idesc->idata;
1814 /* The latency of the registers may be less than previously recorded,
1815 depending on how they were used previously.
1816 See Table 13-8 in the LSI. */
1819 if (use_is_fp_load (cpu, in_FRi))
1821 busy_adjustment[0] = 1;
1822 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
1825 enforce_full_fr_latency (cpu, in_FRi);
1828 /* The post processing must wait if there is a dependency on a FR
1829 which is not ready yet. */
1830 ps->post_wait = cycles;
1831 post_wait_for_FR (cpu, in_FRi);
1832 post_wait_for_FR (cpu, out_FRk);
1834 /* Restore the busy cycles of the registers we used. */
1837 fr[in_FRi] += busy_adjustment[0];
1839 /* The latency of the output register will be at least the latency of the
1840 other inputs. Once initiated, post-processing will take 1 cycle. */
1843 update_FR_latency (cpu, out_FRk, ps->post_wait);
1844 update_FR_ptime (cpu, out_FRk, 1);
1846 /* Mark this use of the register as media unit 1. */
1847 set_use_is_media_p6 (cpu, out_FRk);
1854 frvbf_model_fr400_u_media_7 (SIM_CPU *cpu, const IDESC *idesc,
1855 int unit_num, int referenced,
1856 INT in_FRinti, INT in_FRintj,
1860 FRV_PROFILE_STATE *ps;
1861 int busy_adjustment[] = {0, 0};
1864 if (model_insn == FRV_INSN_MODEL_PASS_1)
1867 /* The preprocessing can execute right away. */
1868 cycles = idesc->timing->units[unit_num].done;
1870 /* The post processing must wait if there is a dependency on a FR
1871 which is not ready yet. */
1872 ps = CPU_PROFILE_STATE (cpu);
1874 /* The latency of the registers may be less than previously recorded,
1875 depending on how they were used previously.
1876 See Table 13-8 in the LSI. */
1879 if (use_is_fp_load (cpu, in_FRinti))
1881 busy_adjustment[0] = 1;
1882 decrease_FR_busy (cpu, in_FRinti, busy_adjustment[0]);
1885 enforce_full_fr_latency (cpu, in_FRinti);
1887 if (in_FRintj >= 0 && in_FRintj != in_FRinti)
1889 if (use_is_fp_load (cpu, in_FRintj))
1891 busy_adjustment[1] = 1;
1892 decrease_FR_busy (cpu, in_FRintj, busy_adjustment[1]);
1895 enforce_full_fr_latency (cpu, in_FRintj);
1898 ps->post_wait = cycles;
1899 post_wait_for_FR (cpu, in_FRinti);
1900 post_wait_for_FR (cpu, in_FRintj);
1901 post_wait_for_CCR (cpu, out_FCCk);
1903 /* Restore the busy cycles of the registers we used. */
1906 fr[in_FRinti] += busy_adjustment[0];
1908 fr[in_FRintj] += busy_adjustment[1];
1910 /* The latency of FCCi_2 will be the latency of the other inputs plus 1
1912 update_CCR_latency (cpu, out_FCCk, ps->post_wait + 1);
1918 frvbf_model_fr400_u_media_dual_expand (SIM_CPU *cpu, const IDESC *idesc,
1919 int unit_num, int referenced,
1923 /* Insns using this unit are media-3 class insns, with a dual FRk output. */
1926 FRV_PROFILE_STATE *ps;
1927 int busy_adjustment[] = {0};
1930 if (model_insn == FRV_INSN_MODEL_PASS_1)
1933 /* The preprocessing can execute right away. */
1934 cycles = idesc->timing->units[unit_num].done;
1936 /* If the previous use of the registers was a media op,
1937 then their latency will be less than previously recorded.
1938 See Table 13-13 in the LSI. */
1939 dual_FRk = DUAL_REG (out_FRk);
1940 ps = CPU_PROFILE_STATE (cpu);
1941 if (use_is_fp_load (cpu, in_FRi))
1943 busy_adjustment[0] = 1;
1944 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
1947 enforce_full_fr_latency (cpu, in_FRi);
1949 /* The post processing must wait if there is a dependency on a FR
1950 which is not ready yet. */
1951 ps->post_wait = cycles;
1952 post_wait_for_FR (cpu, in_FRi);
1953 post_wait_for_FR (cpu, out_FRk);
1954 post_wait_for_FR (cpu, dual_FRk);
1956 /* Restore the busy cycles of the registers we used. */
1958 fr[in_FRi] += busy_adjustment[0];
1960 /* The latency of the output register will be at least the latency of the
1961 other inputs. Once initiated, post-processing has no latency. */
1962 update_FR_latency (cpu, out_FRk, ps->post_wait);
1963 update_FR_ptime (cpu, out_FRk, 0);
1967 update_FR_latency (cpu, dual_FRk, ps->post_wait);
1968 update_FR_ptime (cpu, dual_FRk, 0);
1975 frvbf_model_fr400_u_media_dual_htob (SIM_CPU *cpu, const IDESC *idesc,
1976 int unit_num, int referenced,
1980 /* Insns using this unit are media-3 class insns, with a dual FRj input. */
1983 FRV_PROFILE_STATE *ps;
1984 int busy_adjustment[] = {0, 0};
1987 if (model_insn == FRV_INSN_MODEL_PASS_1)
1990 /* The preprocessing can execute right away. */
1991 cycles = idesc->timing->units[unit_num].done;
1993 /* If the previous use of the registers was a media op,
1994 then their latency will be less than previously recorded.
1995 See Table 13-13 in the LSI. */
1996 dual_FRj = DUAL_REG (in_FRj);
1997 ps = CPU_PROFILE_STATE (cpu);
1998 if (use_is_fp_load (cpu, in_FRj))
2000 busy_adjustment[0] = 1;
2001 decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
2004 enforce_full_fr_latency (cpu, in_FRj);
2007 if (use_is_fp_load (cpu, dual_FRj))
2009 busy_adjustment[1] = 1;
2010 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[1]);
2013 enforce_full_fr_latency (cpu, dual_FRj);
2016 /* The post processing must wait if there is a dependency on a FR
2017 which is not ready yet. */
2018 ps->post_wait = cycles;
2019 post_wait_for_FR (cpu, in_FRj);
2020 post_wait_for_FR (cpu, dual_FRj);
2021 post_wait_for_FR (cpu, out_FRk);
2023 /* Restore the busy cycles of the registers we used. */
2025 fr[in_FRj] += busy_adjustment[0];
2027 fr[dual_FRj] += busy_adjustment[1];
2029 /* The latency of the output register will be at least the latency of the
2031 update_FR_latency (cpu, out_FRk, ps->post_wait);
2033 /* Once initiated, post-processing has no latency. */
2034 update_FR_ptime (cpu, out_FRk, 0);
2040 frvbf_model_fr400_u_ici (SIM_CPU *cpu, const IDESC *idesc,
2041 int unit_num, int referenced,
2042 INT in_GRi, INT in_GRj)
2044 /* Modelling for this unit is the same as for fr500. */
2045 return frvbf_model_fr500_u_ici (cpu, idesc, unit_num, referenced,
2050 frvbf_model_fr400_u_dci (SIM_CPU *cpu, const IDESC *idesc,
2051 int unit_num, int referenced,
2052 INT in_GRi, INT in_GRj)
2054 /* Modelling for this unit is the same as for fr500. */
2055 return frvbf_model_fr500_u_dci (cpu, idesc, unit_num, referenced,
2060 frvbf_model_fr400_u_dcf (SIM_CPU *cpu, const IDESC *idesc,
2061 int unit_num, int referenced,
2062 INT in_GRi, INT in_GRj)
2064 /* Modelling for this unit is the same as for fr500. */
2065 return frvbf_model_fr500_u_dcf (cpu, idesc, unit_num, referenced,
2070 frvbf_model_fr400_u_icpl (SIM_CPU *cpu, const IDESC *idesc,
2071 int unit_num, int referenced,
2072 INT in_GRi, INT in_GRj)
2074 /* Modelling for this unit is the same as for fr500. */
2075 return frvbf_model_fr500_u_icpl (cpu, idesc, unit_num, referenced,
2080 frvbf_model_fr400_u_dcpl (SIM_CPU *cpu, const IDESC *idesc,
2081 int unit_num, int referenced,
2082 INT in_GRi, INT in_GRj)
2084 /* Modelling for this unit is the same as for fr500. */
2085 return frvbf_model_fr500_u_dcpl (cpu, idesc, unit_num, referenced,
2090 frvbf_model_fr400_u_icul (SIM_CPU *cpu, const IDESC *idesc,
2091 int unit_num, int referenced,
2092 INT in_GRi, INT in_GRj)
2094 /* Modelling for this unit is the same as for fr500. */
2095 return frvbf_model_fr500_u_icul (cpu, idesc, unit_num, referenced,
2100 frvbf_model_fr400_u_dcul (SIM_CPU *cpu, const IDESC *idesc,
2101 int unit_num, int referenced,
2102 INT in_GRi, INT in_GRj)
2104 /* Modelling for this unit is the same as for fr500. */
2105 return frvbf_model_fr500_u_dcul (cpu, idesc, unit_num, referenced,
2110 frvbf_model_fr400_u_barrier (SIM_CPU *cpu, const IDESC *idesc,
2111 int unit_num, int referenced)
2113 /* Modelling for this unit is the same as for fr500. */
2114 return frvbf_model_fr500_u_barrier (cpu, idesc, unit_num, referenced);
2118 frvbf_model_fr400_u_membar (SIM_CPU *cpu, const IDESC *idesc,
2119 int unit_num, int referenced)
2121 /* Modelling for this unit is the same as for fr500. */
2122 return frvbf_model_fr500_u_membar (cpu, idesc, unit_num, referenced);
2125 #endif /* WITH_PROFILE_MODEL_P */