S/390: Fix symbolic displacement in lay
[binutils-gdb.git] / sim / frv / profile-fr550.c
blobe06b4d222235bdfcf0a1693e90a675bbfca141b7
1 /* frv simulator fr550 dependent profiling code.
3 Copyright (C) 2003-2018 Free Software Foundation, Inc.
4 Contributed by Red Hat
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/>.
22 #define WANT_CPU
23 #define WANT_CPU_FRVBF
25 #include "sim-main.h"
26 #include "bfd.h"
28 #if WITH_PROFILE_MODEL_P
30 #include "profile.h"
31 #include "profile-fr550.h"
33 /* Initialize cycle counting for an insn.
34 FIRST_P is non-zero if this is the first insn in a set of parallel
35 insns. */
36 void
37 fr550_model_insn_before (SIM_CPU *cpu, int first_p)
39 if (first_p)
41 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
42 d->cur_fr_load = d->prev_fr_load;
43 d->cur_fr_complex_1 = d->prev_fr_complex_1;
44 d->cur_fr_complex_2 = d->prev_fr_complex_2;
45 d->cur_ccr_complex = d->prev_ccr_complex;
46 d->cur_acc_mmac = d->prev_acc_mmac;
50 /* Record the cycles computed for an insn.
51 LAST_P is non-zero if this is the last insn in a set of parallel insns,
52 and we update the total cycle count.
53 CYCLES is the cycle count of the insn. */
54 void
55 fr550_model_insn_after (SIM_CPU *cpu, int last_p, int cycles)
57 if (last_p)
59 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
60 d->prev_fr_load = d->cur_fr_load;
61 d->prev_fr_complex_1 = d->cur_fr_complex_1;
62 d->prev_fr_complex_2 = d->cur_fr_complex_2;
63 d->prev_ccr_complex = d->cur_ccr_complex;
64 d->prev_acc_mmac = d->cur_acc_mmac;
68 static void fr550_reset_fr_flags (SIM_CPU *cpu, INT fr);
69 static void fr550_reset_ccr_flags (SIM_CPU *cpu, INT ccr);
70 static void fr550_reset_acc_flags (SIM_CPU *cpu, INT acc);
72 static void
73 set_use_is_fr_load (SIM_CPU *cpu, INT fr)
75 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
76 fr550_reset_fr_flags (cpu, (fr));
77 d->cur_fr_load |= (((DI)1) << (fr));
80 static void
81 set_use_not_fr_load (SIM_CPU *cpu, INT fr)
83 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
84 d->cur_fr_load &= ~(((DI)1) << (fr));
87 static int
88 use_is_fr_load (SIM_CPU *cpu, INT fr)
90 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
91 return d->prev_fr_load & (((DI)1) << (fr));
94 static void
95 set_use_is_fr_complex_1 (SIM_CPU *cpu, INT fr)
97 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
98 fr550_reset_fr_flags (cpu, (fr));
99 d->cur_fr_complex_1 |= (((DI)1) << (fr));
102 static void
103 set_use_not_fr_complex_1 (SIM_CPU *cpu, INT fr)
105 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
106 d->cur_fr_complex_1 &= ~(((DI)1) << (fr));
109 static int
110 use_is_fr_complex_1 (SIM_CPU *cpu, INT fr)
112 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
113 return d->prev_fr_complex_1 & (((DI)1) << (fr));
116 static void
117 set_use_is_fr_complex_2 (SIM_CPU *cpu, INT fr)
119 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
120 fr550_reset_fr_flags (cpu, (fr));
121 d->cur_fr_complex_2 |= (((DI)1) << (fr));
124 static void
125 set_use_not_fr_complex_2 (SIM_CPU *cpu, INT fr)
127 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
128 d->cur_fr_complex_2 &= ~(((DI)1) << (fr));
131 static int
132 use_is_fr_complex_2 (SIM_CPU *cpu, INT fr)
134 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
135 return d->prev_fr_complex_2 & (((DI)1) << (fr));
138 static void
139 set_use_is_ccr_complex (SIM_CPU *cpu, INT ccr)
141 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
142 fr550_reset_ccr_flags (cpu, (ccr));
143 d->cur_ccr_complex |= (((SI)1) << (ccr));
146 static void
147 set_use_not_ccr_complex (SIM_CPU *cpu, INT ccr)
149 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
150 d->cur_ccr_complex &= ~(((SI)1) << (ccr));
153 static int
154 use_is_ccr_complex (SIM_CPU *cpu, INT ccr)
156 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
157 return d->prev_ccr_complex & (((SI)1) << (ccr));
160 static void
161 set_use_is_acc_mmac (SIM_CPU *cpu, INT acc)
163 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
164 fr550_reset_acc_flags (cpu, (acc));
165 d->cur_acc_mmac |= (((DI)1) << (acc));
168 static void
169 set_use_not_acc_mmac (SIM_CPU *cpu, INT acc)
171 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
172 d->cur_acc_mmac &= ~(((DI)1) << (acc));
175 static int
176 use_is_acc_mmac (SIM_CPU *cpu, INT acc)
178 MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
179 return d->prev_acc_mmac & (((DI)1) << (acc));
182 static void
183 fr550_reset_fr_flags (SIM_CPU *cpu, INT fr)
185 set_use_not_fr_load (cpu, fr);
186 set_use_not_fr_complex_1 (cpu, fr);
187 set_use_not_fr_complex_2 (cpu, fr);
190 static void
191 fr550_reset_ccr_flags (SIM_CPU *cpu, INT ccr)
193 set_use_not_ccr_complex (cpu, ccr);
196 static void
197 fr550_reset_acc_flags (SIM_CPU *cpu, INT acc)
199 set_use_not_acc_mmac (cpu, acc);
202 /* Detect overlap between two register ranges. Works if one of the registers
203 is -1 with width 1 (i.e. undefined), but not both. */
204 #define REG_OVERLAP(r1, w1, r2, w2) ( \
205 (r1) + (w1) - 1 >= (r2) && (r2) + (w2) - 1 >= (r1) \
208 /* Latency of floating point registers may be less than recorded when followed
209 by another floating point insn. */
210 static void
211 adjust_float_register_busy (SIM_CPU *cpu,
212 INT in_FRi, int iwidth,
213 INT in_FRj, int jwidth,
214 INT out_FRk, int kwidth)
216 int i;
217 /* The latency of FRk may be less than previously recorded.
218 See Table 14-15 in the LSI. */
219 if (in_FRi >= 0)
221 for (i = 0; i < iwidth; ++i)
223 if (! REG_OVERLAP (in_FRi + i, 1, out_FRk, kwidth))
224 if (use_is_fr_load (cpu, in_FRi + i))
225 decrease_FR_busy (cpu, in_FRi + i, 1);
226 else
227 enforce_full_fr_latency (cpu, in_FRi + i);
231 if (in_FRj >= 0)
233 for (i = 0; i < jwidth; ++i)
235 if (! REG_OVERLAP (in_FRj + i, 1, in_FRi, iwidth)
236 && ! REG_OVERLAP (in_FRj + i, 1, out_FRk, kwidth))
237 if (use_is_fr_load (cpu, in_FRj + i))
238 decrease_FR_busy (cpu, in_FRj + i, 1);
239 else
240 enforce_full_fr_latency (cpu, in_FRj + i);
244 if (out_FRk >= 0)
246 for (i = 0; i < kwidth; ++i)
248 if (! REG_OVERLAP (out_FRk + i, 1, in_FRi, iwidth)
249 && ! REG_OVERLAP (out_FRk + i, 1, in_FRj, jwidth))
251 if (use_is_fr_complex_1 (cpu, out_FRk + i))
252 decrease_FR_busy (cpu, out_FRk + i, 1);
253 else if (use_is_fr_complex_2 (cpu, out_FRk + i))
254 decrease_FR_busy (cpu, out_FRk + i, 2);
255 else
256 enforce_full_fr_latency (cpu, out_FRk + i);
262 static void
263 restore_float_register_busy (SIM_CPU *cpu,
264 INT in_FRi, int iwidth,
265 INT in_FRj, int jwidth,
266 INT out_FRk, int kwidth)
268 int i;
269 /* The latency of FRk may be less than previously recorded.
270 See Table 14-15 in the LSI. */
271 if (in_FRi >= 0)
273 for (i = 0; i < iwidth; ++i)
275 if (! REG_OVERLAP (in_FRi + i, 1, out_FRk, kwidth))
276 if (use_is_fr_load (cpu, in_FRi + i))
277 increase_FR_busy (cpu, in_FRi + i, 1);
281 if (in_FRj >= 0)
283 for (i = 0; i < jwidth; ++i)
285 if (! REG_OVERLAP (in_FRj + i, 1, in_FRi, iwidth)
286 && ! REG_OVERLAP (in_FRj + i, 1, out_FRk, kwidth))
287 if (use_is_fr_load (cpu, in_FRj + i))
288 increase_FR_busy (cpu, in_FRj + i, 1);
292 if (out_FRk >= 0)
294 for (i = 0; i < kwidth; ++i)
296 if (! REG_OVERLAP (out_FRk + i, 1, in_FRi, iwidth)
297 && ! REG_OVERLAP (out_FRk + i, 1, in_FRj, jwidth))
299 if (use_is_fr_complex_1 (cpu, out_FRk + i))
300 increase_FR_busy (cpu, out_FRk + i, 1);
301 else if (use_is_fr_complex_2 (cpu, out_FRk + i))
302 increase_FR_busy (cpu, out_FRk + i, 2);
308 /* Latency of floating point registers may be less than recorded when used in a
309 media insns and followed by another media insn. */
310 static void
311 adjust_float_register_busy_for_media (SIM_CPU *cpu,
312 INT in_FRi, int iwidth,
313 INT in_FRj, int jwidth,
314 INT out_FRk, int kwidth)
316 int i;
317 /* The latency of FRk may be less than previously recorded.
318 See Table 14-15 in the LSI. */
319 if (out_FRk >= 0)
321 for (i = 0; i < kwidth; ++i)
323 if (! REG_OVERLAP (out_FRk + i, 1, in_FRi, iwidth)
324 && ! REG_OVERLAP (out_FRk + i, 1, in_FRj, jwidth))
326 if (use_is_fr_complex_1 (cpu, out_FRk + i))
327 decrease_FR_busy (cpu, out_FRk + i, 1);
328 else
329 enforce_full_fr_latency (cpu, out_FRk + i);
335 static void
336 restore_float_register_busy_for_media (SIM_CPU *cpu,
337 INT in_FRi, int iwidth,
338 INT in_FRj, int jwidth,
339 INT out_FRk, int kwidth)
341 int i;
342 if (out_FRk >= 0)
344 for (i = 0; i < kwidth; ++i)
346 if (! REG_OVERLAP (out_FRk + i, 1, in_FRi, iwidth)
347 && ! REG_OVERLAP (out_FRk + i, 1, in_FRj, jwidth))
349 if (use_is_fr_complex_1 (cpu, out_FRk + i))
350 increase_FR_busy (cpu, out_FRk + i, 1);
356 /* Latency of accumulator registers may be less than recorded when used in a
357 media insns and followed by another media insn. */
358 static void
359 adjust_acc_busy_for_mmac (SIM_CPU *cpu,
360 INT in_ACC, int inwidth,
361 INT out_ACC, int outwidth)
363 int i;
364 /* The latency of an accumulator may be less than previously recorded.
365 See Table 14-15 in the LSI. */
366 if (in_ACC >= 0)
368 for (i = 0; i < inwidth; ++i)
370 if (use_is_acc_mmac (cpu, in_ACC + i))
371 decrease_ACC_busy (cpu, in_ACC + i, 1);
372 else
373 enforce_full_acc_latency (cpu, in_ACC + i);
376 if (out_ACC >= 0)
378 for (i = 0; i < outwidth; ++i)
380 if (! REG_OVERLAP (out_ACC + i, 1, in_ACC, inwidth))
382 if (use_is_acc_mmac (cpu, out_ACC + i))
383 decrease_ACC_busy (cpu, out_ACC + i, 1);
384 else
385 enforce_full_acc_latency (cpu, out_ACC + i);
391 static void
392 restore_acc_busy_for_mmac (SIM_CPU *cpu,
393 INT in_ACC, int inwidth,
394 INT out_ACC, int outwidth)
396 int i;
397 if (in_ACC >= 0)
399 for (i = 0; i < inwidth; ++i)
401 if (use_is_acc_mmac (cpu, in_ACC + i))
402 increase_ACC_busy (cpu, in_ACC + i, 1);
405 if (out_ACC >= 0)
407 for (i = 0; i < outwidth; ++i)
409 if (! REG_OVERLAP (out_ACC + i, 1, in_ACC, inwidth))
411 if (use_is_acc_mmac (cpu, out_ACC + i))
412 increase_ACC_busy (cpu, out_ACC + i, 1);
419 frvbf_model_fr550_u_exec (SIM_CPU *cpu, const IDESC *idesc,
420 int unit_num, int referenced)
422 return idesc->timing->units[unit_num].done;
426 frvbf_model_fr550_u_integer (SIM_CPU *cpu, const IDESC *idesc,
427 int unit_num, int referenced,
428 INT in_GRi, INT in_GRj, INT out_GRk,
429 INT out_ICCi_1)
431 int cycles;
433 /* icc0-icc4 are the upper 4 fields of the CCR. */
434 if (out_ICCi_1 >= 0)
435 out_ICCi_1 += 4;
437 if (model_insn == FRV_INSN_MODEL_PASS_1)
439 /* The entire VLIW insn must wait if there is a dependency on a register
440 which is not ready yet. */
441 vliw_wait_for_GR (cpu, in_GRi);
442 vliw_wait_for_GR (cpu, in_GRj);
443 vliw_wait_for_GR (cpu, out_GRk);
444 vliw_wait_for_CCR (cpu, out_ICCi_1);
445 handle_resource_wait (cpu);
446 load_wait_for_GR (cpu, in_GRi);
447 load_wait_for_GR (cpu, in_GRj);
448 load_wait_for_GR (cpu, out_GRk);
449 trace_vliw_wait_cycles (cpu);
450 return 0;
453 fr550_reset_ccr_flags (cpu, out_ICCi_1);
455 /* GRk is available immediately to the next VLIW insn as is ICCi_1. */
456 cycles = idesc->timing->units[unit_num].done;
457 return cycles;
461 frvbf_model_fr550_u_imul (SIM_CPU *cpu, const IDESC *idesc,
462 int unit_num, int referenced,
463 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
465 int cycles;
466 /* icc0-icc4 are the upper 4 fields of the CCR. */
467 if (out_ICCi_1 >= 0)
468 out_ICCi_1 += 4;
470 if (model_insn == FRV_INSN_MODEL_PASS_1)
472 /* The entire VLIW insn must wait if there is a dependency on a register
473 which is not ready yet. */
474 vliw_wait_for_GR (cpu, in_GRi);
475 vliw_wait_for_GR (cpu, in_GRj);
476 vliw_wait_for_GRdouble (cpu, out_GRk);
477 vliw_wait_for_CCR (cpu, out_ICCi_1);
478 handle_resource_wait (cpu);
479 load_wait_for_GR (cpu, in_GRi);
480 load_wait_for_GR (cpu, in_GRj);
481 load_wait_for_GRdouble (cpu, out_GRk);
482 trace_vliw_wait_cycles (cpu);
483 return 0;
486 /* GRk has a latency of 1 cycles. */
487 cycles = idesc->timing->units[unit_num].done;
488 update_GRdouble_latency (cpu, out_GRk, cycles + 1);
490 /* ICCi_1 has a latency of 1 cycle. */
491 update_CCR_latency (cpu, out_ICCi_1, cycles + 1);
493 fr550_reset_ccr_flags (cpu, out_ICCi_1);
495 return cycles;
499 frvbf_model_fr550_u_idiv (SIM_CPU *cpu, const IDESC *idesc,
500 int unit_num, int referenced,
501 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
503 int cycles;
504 FRV_VLIW *vliw;
505 int slot;
507 /* icc0-icc4 are the upper 4 fields of the CCR. */
508 if (out_ICCi_1 >= 0)
509 out_ICCi_1 += 4;
511 vliw = CPU_VLIW (cpu);
512 slot = vliw->next_slot - 1;
513 slot = (*vliw->current_vliw)[slot] - UNIT_I0;
515 if (model_insn == FRV_INSN_MODEL_PASS_1)
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_GR (cpu, in_GRi);
520 vliw_wait_for_GR (cpu, in_GRj);
521 vliw_wait_for_GR (cpu, out_GRk);
522 vliw_wait_for_CCR (cpu, out_ICCi_1);
523 vliw_wait_for_idiv_resource (cpu, slot);
524 handle_resource_wait (cpu);
525 load_wait_for_GR (cpu, in_GRi);
526 load_wait_for_GR (cpu, in_GRj);
527 load_wait_for_GR (cpu, out_GRk);
528 trace_vliw_wait_cycles (cpu);
529 return 0;
532 /* GRk has a latency of 18 cycles! */
533 cycles = idesc->timing->units[unit_num].done;
534 update_GR_latency (cpu, out_GRk, cycles + 18);
536 /* ICCi_1 has a latency of 18 cycles. */
537 update_CCR_latency (cpu, out_ICCi_1, cycles + 18);
539 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
541 /* GNER has a latency of 18 cycles. */
542 update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 18);
545 /* the idiv resource has a latency of 18 cycles! */
546 update_idiv_resource_latency (cpu, slot, cycles + 18);
548 fr550_reset_ccr_flags (cpu, out_ICCi_1);
550 return cycles;
554 frvbf_model_fr550_u_branch (SIM_CPU *cpu, const IDESC *idesc,
555 int unit_num, int referenced,
556 INT in_GRi, INT in_GRj,
557 INT in_ICCi_2, INT in_FCCi_2)
559 int cycles;
560 FRV_PROFILE_STATE *ps;
562 if (model_insn == FRV_INSN_MODEL_PASS_1)
564 /* icc0-icc4 are the upper 4 fields of the CCR. */
565 if (in_ICCi_2 >= 0)
566 in_ICCi_2 += 4;
568 /* The entire VLIW insn must wait if there is a dependency on a register
569 which is not ready yet. */
570 vliw_wait_for_GR (cpu, in_GRi);
571 vliw_wait_for_GR (cpu, in_GRj);
572 vliw_wait_for_CCR (cpu, in_ICCi_2);
573 vliw_wait_for_CCR (cpu, in_FCCi_2);
574 handle_resource_wait (cpu);
575 load_wait_for_GR (cpu, in_GRi);
576 load_wait_for_GR (cpu, in_GRj);
577 trace_vliw_wait_cycles (cpu);
578 return 0;
581 /* When counting branches taken or not taken, don't consider branches after
582 the first taken branch in a vliw insn. */
583 ps = CPU_PROFILE_STATE (cpu);
584 if (! ps->vliw_branch_taken)
586 /* (1 << 4): The pc is the 5th element in inputs, outputs.
587 ??? can be cleaned up */
588 PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
589 int taken = (referenced & (1 << 4)) != 0;
590 if (taken)
592 ++PROFILE_MODEL_TAKEN_COUNT (p);
593 ps->vliw_branch_taken = 1;
595 else
596 ++PROFILE_MODEL_UNTAKEN_COUNT (p);
599 cycles = idesc->timing->units[unit_num].done;
600 return cycles;
604 frvbf_model_fr550_u_trap (SIM_CPU *cpu, const IDESC *idesc,
605 int unit_num, int referenced,
606 INT in_GRi, INT in_GRj,
607 INT in_ICCi_2, INT in_FCCi_2)
609 int cycles;
611 if (model_insn == FRV_INSN_MODEL_PASS_1)
613 /* icc0-icc4 are the upper 4 fields of the CCR. */
614 if (in_ICCi_2 >= 0)
615 in_ICCi_2 += 4;
617 /* The entire VLIW insn must wait if there is a dependency on a register
618 which is not ready yet. */
619 vliw_wait_for_GR (cpu, in_GRi);
620 vliw_wait_for_GR (cpu, in_GRj);
621 vliw_wait_for_CCR (cpu, in_ICCi_2);
622 vliw_wait_for_CCR (cpu, in_FCCi_2);
623 handle_resource_wait (cpu);
624 load_wait_for_GR (cpu, in_GRi);
625 load_wait_for_GR (cpu, in_GRj);
626 trace_vliw_wait_cycles (cpu);
627 return 0;
630 cycles = idesc->timing->units[unit_num].done;
631 return cycles;
635 frvbf_model_fr550_u_check (SIM_CPU *cpu, const IDESC *idesc,
636 int unit_num, int referenced,
637 INT in_ICCi_3, INT in_FCCi_3)
639 /* Modelling for this unit is the same as for fr500. */
640 return frvbf_model_fr500_u_check (cpu, idesc, unit_num, referenced,
641 in_ICCi_3, in_FCCi_3);
645 frvbf_model_fr550_u_set_hilo (SIM_CPU *cpu, const IDESC *idesc,
646 int unit_num, int referenced,
647 INT out_GRkhi, INT out_GRklo)
649 int cycles;
651 if (model_insn == FRV_INSN_MODEL_PASS_1)
653 /* The entire VLIW insn must wait if there is a dependency on a GR
654 which is not ready yet. */
655 vliw_wait_for_GR (cpu, out_GRkhi);
656 vliw_wait_for_GR (cpu, out_GRklo);
657 handle_resource_wait (cpu);
658 load_wait_for_GR (cpu, out_GRkhi);
659 load_wait_for_GR (cpu, out_GRklo);
660 trace_vliw_wait_cycles (cpu);
661 return 0;
664 /* GRk is available immediately to the next VLIW insn. */
665 cycles = idesc->timing->units[unit_num].done;
667 return cycles;
671 frvbf_model_fr550_u_gr_load (SIM_CPU *cpu, const IDESC *idesc,
672 int unit_num, int referenced,
673 INT in_GRi, INT in_GRj,
674 INT out_GRk, INT out_GRdoublek)
676 int cycles;
678 if (model_insn == FRV_INSN_MODEL_PASS_1)
680 /* The entire VLIW insn must wait if there is a dependency on a register
681 which is not ready yet. */
682 vliw_wait_for_GR (cpu, in_GRi);
683 vliw_wait_for_GR (cpu, in_GRj);
684 vliw_wait_for_GR (cpu, out_GRk);
685 vliw_wait_for_GRdouble (cpu, out_GRdoublek);
686 handle_resource_wait (cpu);
687 load_wait_for_GR (cpu, in_GRi);
688 load_wait_for_GR (cpu, in_GRj);
689 load_wait_for_GR (cpu, out_GRk);
690 load_wait_for_GRdouble (cpu, out_GRdoublek);
691 trace_vliw_wait_cycles (cpu);
692 return 0;
695 cycles = idesc->timing->units[unit_num].done;
697 /* The latency of GRk for a load will depend on how long it takes to retrieve
698 the the data from the cache or memory. */
699 update_GR_latency_for_load (cpu, out_GRk, cycles);
700 update_GRdouble_latency_for_load (cpu, out_GRdoublek, cycles);
702 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
704 /* GNER has a latency of 2 cycles. */
705 update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 2);
706 update_SPR_latency (cpu, GNER_FOR_GR (out_GRdoublek), cycles + 2);
709 return cycles;
713 frvbf_model_fr550_u_gr_store (SIM_CPU *cpu, const IDESC *idesc,
714 int unit_num, int referenced,
715 INT in_GRi, INT in_GRj,
716 INT in_GRk, INT in_GRdoublek)
718 int cycles;
720 if (model_insn == FRV_INSN_MODEL_PASS_1)
722 /* The entire VLIW insn must wait if there is a dependency on a register
723 which is not ready yet. */
724 vliw_wait_for_GR (cpu, in_GRi);
725 vliw_wait_for_GR (cpu, in_GRj);
726 vliw_wait_for_GR (cpu, in_GRk);
727 vliw_wait_for_GRdouble (cpu, in_GRdoublek);
728 handle_resource_wait (cpu);
729 load_wait_for_GR (cpu, in_GRi);
730 load_wait_for_GR (cpu, in_GRj);
731 load_wait_for_GR (cpu, in_GRk);
732 load_wait_for_GRdouble (cpu, in_GRdoublek);
733 trace_vliw_wait_cycles (cpu);
734 return 0;
737 /* The target register is available immediately. */
738 cycles = idesc->timing->units[unit_num].done;
740 return cycles;
744 frvbf_model_fr550_u_fr_load (SIM_CPU *cpu, const IDESC *idesc,
745 int unit_num, int referenced,
746 INT in_GRi, INT in_GRj,
747 INT out_FRk, INT out_FRdoublek)
749 int cycles;
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. */
757 adjust_float_register_busy (cpu, -1, 1, -1, 1, out_FRk, 1);
758 adjust_float_register_busy (cpu, -1, 1, -1, 1, out_FRdoublek, 2);
759 vliw_wait_for_GR (cpu, in_GRi);
760 vliw_wait_for_GR (cpu, in_GRj);
761 vliw_wait_for_FR (cpu, out_FRk);
762 vliw_wait_for_FRdouble (cpu, out_FRdoublek);
763 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
765 vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
766 vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
768 handle_resource_wait (cpu);
769 load_wait_for_GR (cpu, in_GRi);
770 load_wait_for_GR (cpu, in_GRj);
771 load_wait_for_FR (cpu, out_FRk);
772 load_wait_for_FRdouble (cpu, out_FRdoublek);
773 trace_vliw_wait_cycles (cpu);
774 return 0;
777 cycles = idesc->timing->units[unit_num].done;
779 /* The latency of FRk for a load will depend on how long it takes to retrieve
780 the the data from the cache or memory. */
781 update_FR_latency_for_load (cpu, out_FRk, cycles);
782 update_FRdouble_latency_for_load (cpu, out_FRdoublek, cycles);
784 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
786 /* FNER has a latency of 3 cycles. */
787 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), cycles + 3);
788 update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), cycles + 3);
791 if (out_FRk >= 0)
792 set_use_is_fr_load (cpu, out_FRk);
793 if (out_FRdoublek >= 0)
795 set_use_is_fr_load (cpu, out_FRdoublek);
796 set_use_is_fr_load (cpu, out_FRdoublek + 1);
799 return cycles;
803 frvbf_model_fr550_u_fr_store (SIM_CPU *cpu, const IDESC *idesc,
804 int unit_num, int referenced,
805 INT in_GRi, INT in_GRj,
806 INT in_FRk, INT in_FRdoublek)
808 int cycles;
810 if (model_insn == FRV_INSN_MODEL_PASS_1)
812 /* The entire VLIW insn must wait if there is a dependency on a register
813 which is not ready yet. */
814 adjust_float_register_busy (cpu, in_FRk, 1, -1, 1, -1, 1);
815 adjust_float_register_busy (cpu, in_FRdoublek, 2, -1, 1, -1, 1);
816 vliw_wait_for_GR (cpu, in_GRi);
817 vliw_wait_for_GR (cpu, in_GRj);
818 vliw_wait_for_FR (cpu, in_FRk);
819 vliw_wait_for_FRdouble (cpu, in_FRdoublek);
820 handle_resource_wait (cpu);
821 load_wait_for_GR (cpu, in_GRi);
822 load_wait_for_GR (cpu, in_GRj);
823 load_wait_for_FR (cpu, in_FRk);
824 load_wait_for_FRdouble (cpu, in_FRdoublek);
825 trace_vliw_wait_cycles (cpu);
826 return 0;
829 /* The target register is available immediately. */
830 cycles = idesc->timing->units[unit_num].done;
832 return cycles;
836 frvbf_model_fr550_u_ici (SIM_CPU *cpu, const IDESC *idesc,
837 int unit_num, int referenced,
838 INT in_GRi, INT in_GRj)
840 int cycles;
842 if (model_insn == FRV_INSN_MODEL_PASS_1)
844 /* The entire VLIW insn must wait if there is a dependency on a register
845 which is not ready yet. */
846 vliw_wait_for_GR (cpu, in_GRi);
847 vliw_wait_for_GR (cpu, in_GRj);
848 handle_resource_wait (cpu);
849 load_wait_for_GR (cpu, in_GRi);
850 load_wait_for_GR (cpu, in_GRj);
851 trace_vliw_wait_cycles (cpu);
852 return 0;
855 cycles = idesc->timing->units[unit_num].done;
856 request_cache_invalidate (cpu, CPU_INSN_CACHE (cpu), cycles);
857 return cycles;
861 frvbf_model_fr550_u_dci (SIM_CPU *cpu, const IDESC *idesc,
862 int unit_num, int referenced,
863 INT in_GRi, INT in_GRj)
865 int cycles;
867 if (model_insn == FRV_INSN_MODEL_PASS_1)
869 /* The entire VLIW insn must wait if there is a dependency on a register
870 which is not ready yet. */
871 vliw_wait_for_GR (cpu, in_GRi);
872 vliw_wait_for_GR (cpu, in_GRj);
873 handle_resource_wait (cpu);
874 load_wait_for_GR (cpu, in_GRi);
875 load_wait_for_GR (cpu, in_GRj);
876 trace_vliw_wait_cycles (cpu);
877 return 0;
880 cycles = idesc->timing->units[unit_num].done;
881 request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
882 return cycles;
886 frvbf_model_fr550_u_dcf (SIM_CPU *cpu, const IDESC *idesc,
887 int unit_num, int referenced,
888 INT in_GRi, INT in_GRj)
890 int cycles;
892 if (model_insn == FRV_INSN_MODEL_PASS_1)
894 /* The entire VLIW insn must wait if there is a dependency on a register
895 which is not ready yet. */
896 vliw_wait_for_GR (cpu, in_GRi);
897 vliw_wait_for_GR (cpu, in_GRj);
898 handle_resource_wait (cpu);
899 load_wait_for_GR (cpu, in_GRi);
900 load_wait_for_GR (cpu, in_GRj);
901 trace_vliw_wait_cycles (cpu);
902 return 0;
905 cycles = idesc->timing->units[unit_num].done;
906 request_cache_flush (cpu, CPU_DATA_CACHE (cpu), cycles);
907 return cycles;
911 frvbf_model_fr550_u_icpl (SIM_CPU *cpu, const IDESC *idesc,
912 int unit_num, int referenced,
913 INT in_GRi, INT in_GRj)
915 int cycles;
917 if (model_insn == FRV_INSN_MODEL_PASS_1)
919 /* The entire VLIW insn must wait if there is a dependency on a register
920 which is not ready yet. */
921 vliw_wait_for_GR (cpu, in_GRi);
922 vliw_wait_for_GR (cpu, in_GRj);
923 handle_resource_wait (cpu);
924 load_wait_for_GR (cpu, in_GRi);
925 load_wait_for_GR (cpu, in_GRj);
926 trace_vliw_wait_cycles (cpu);
927 return 0;
930 cycles = idesc->timing->units[unit_num].done;
931 request_cache_preload (cpu, CPU_INSN_CACHE (cpu), cycles);
932 return cycles;
936 frvbf_model_fr550_u_dcpl (SIM_CPU *cpu, const IDESC *idesc,
937 int unit_num, int referenced,
938 INT in_GRi, INT in_GRj)
940 int cycles;
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. */
946 vliw_wait_for_GR (cpu, in_GRi);
947 vliw_wait_for_GR (cpu, in_GRj);
948 handle_resource_wait (cpu);
949 load_wait_for_GR (cpu, in_GRi);
950 load_wait_for_GR (cpu, in_GRj);
951 trace_vliw_wait_cycles (cpu);
952 return 0;
955 cycles = idesc->timing->units[unit_num].done;
956 request_cache_preload (cpu, CPU_DATA_CACHE (cpu), cycles);
957 return cycles;
961 frvbf_model_fr550_u_icul (SIM_CPU *cpu, const IDESC *idesc,
962 int unit_num, int referenced,
963 INT in_GRi, INT in_GRj)
965 int cycles;
967 if (model_insn == FRV_INSN_MODEL_PASS_1)
969 /* The entire VLIW insn must wait if there is a dependency on a register
970 which is not ready yet. */
971 vliw_wait_for_GR (cpu, in_GRi);
972 vliw_wait_for_GR (cpu, in_GRj);
973 handle_resource_wait (cpu);
974 load_wait_for_GR (cpu, in_GRi);
975 load_wait_for_GR (cpu, in_GRj);
976 trace_vliw_wait_cycles (cpu);
977 return 0;
980 cycles = idesc->timing->units[unit_num].done;
981 request_cache_unlock (cpu, CPU_INSN_CACHE (cpu), cycles);
982 return cycles;
986 frvbf_model_fr550_u_dcul (SIM_CPU *cpu, const IDESC *idesc,
987 int unit_num, int referenced,
988 INT in_GRi, INT in_GRj)
990 int cycles;
992 if (model_insn == FRV_INSN_MODEL_PASS_1)
994 /* The entire VLIW insn must wait if there is a dependency on a register
995 which is not ready yet. */
996 vliw_wait_for_GR (cpu, in_GRi);
997 vliw_wait_for_GR (cpu, in_GRj);
998 handle_resource_wait (cpu);
999 load_wait_for_GR (cpu, in_GRi);
1000 load_wait_for_GR (cpu, in_GRj);
1001 trace_vliw_wait_cycles (cpu);
1002 return 0;
1005 cycles = idesc->timing->units[unit_num].done;
1006 request_cache_unlock (cpu, CPU_DATA_CACHE (cpu), cycles);
1007 return cycles;
1011 frvbf_model_fr550_u_float_arith (SIM_CPU *cpu, const IDESC *idesc,
1012 int unit_num, int referenced,
1013 INT in_FRi, INT in_FRj,
1014 INT in_FRdoublei, INT in_FRdoublej,
1015 INT out_FRk, INT out_FRdoublek)
1017 int cycles;
1018 FRV_PROFILE_STATE *ps;
1019 FRV_VLIW *vliw;
1020 int slot;
1022 if (model_insn == FRV_INSN_MODEL_PASS_1)
1023 return 0;
1025 /* The preprocessing can execute right away. */
1026 cycles = idesc->timing->units[unit_num].done;
1028 /* The post processing must wait if there is a dependency on a FR
1029 which is not ready yet. */
1030 adjust_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
1031 adjust_float_register_busy (cpu, in_FRdoublei, 2, in_FRdoublej, 2, out_FRdoublek, 2);
1032 ps = CPU_PROFILE_STATE (cpu);
1033 ps->post_wait = cycles;
1034 vliw = CPU_VLIW (cpu);
1035 slot = vliw->next_slot - 1;
1036 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1037 post_wait_for_float (cpu, slot);
1038 post_wait_for_FR (cpu, in_FRi);
1039 post_wait_for_FR (cpu, in_FRj);
1040 post_wait_for_FR (cpu, out_FRk);
1041 post_wait_for_FRdouble (cpu, in_FRdoublei);
1042 post_wait_for_FRdouble (cpu, in_FRdoublej);
1043 post_wait_for_FRdouble (cpu, out_FRdoublek);
1044 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1046 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1047 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
1049 restore_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
1050 restore_float_register_busy (cpu, in_FRdoublei, 2, in_FRdoublej, 2, out_FRdoublek, 2);
1052 /* The latency of FRk will be at least the latency of the other inputs. */
1053 update_FR_latency (cpu, out_FRk, ps->post_wait);
1054 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1056 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1058 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1059 update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
1062 /* Once initiated, post-processing will take 2 cycles. */
1063 update_FR_ptime (cpu, out_FRk, 2);
1064 update_FRdouble_ptime (cpu, out_FRdoublek, 2);
1065 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1067 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 2);
1068 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 2);
1071 /* Mark this use of the register as a floating point op. */
1072 if (out_FRk >= 0)
1073 set_use_is_fr_complex_2 (cpu, out_FRk);
1074 if (out_FRdoublek >= 0)
1076 set_use_is_fr_complex_2 (cpu, out_FRdoublek);
1077 if (out_FRdoublek < 63)
1078 set_use_is_fr_complex_2 (cpu, out_FRdoublek + 1);
1081 /* the media point unit resource has a latency of 4 cycles */
1082 update_media_resource_latency (cpu, slot, cycles + 4);
1084 return cycles;
1088 frvbf_model_fr550_u_float_dual_arith (SIM_CPU *cpu, const IDESC *idesc,
1089 int unit_num, int referenced,
1090 INT in_FRi, INT in_FRj,
1091 INT in_FRdoublei, INT in_FRdoublej,
1092 INT out_FRk, INT out_FRdoublek)
1094 int cycles;
1095 INT dual_FRi;
1096 INT dual_FRj;
1097 INT dual_FRk;
1098 INT dual_FRdoublei;
1099 INT dual_FRdoublej;
1100 INT dual_FRdoublek;
1101 FRV_PROFILE_STATE *ps;
1102 FRV_VLIW *vliw;
1103 int slot;
1105 if (model_insn == FRV_INSN_MODEL_PASS_1)
1106 return 0;
1108 /* The preprocessing can execute right away. */
1109 cycles = idesc->timing->units[unit_num].done;
1111 /* The post processing must wait if there is a dependency on a FR
1112 which is not ready yet. */
1113 dual_FRi = DUAL_REG (in_FRi);
1114 dual_FRj = DUAL_REG (in_FRj);
1115 dual_FRk = DUAL_REG (out_FRk);
1116 dual_FRdoublei = DUAL_DOUBLE (in_FRdoublei);
1117 dual_FRdoublej = DUAL_DOUBLE (in_FRdoublej);
1118 dual_FRdoublek = DUAL_DOUBLE (out_FRdoublek);
1120 adjust_float_register_busy (cpu, in_FRi, 2, in_FRj, 2, out_FRk, 2);
1121 adjust_float_register_busy (cpu, in_FRdoublei, 4, in_FRdoublej, 4, out_FRdoublek, 4);
1122 ps = CPU_PROFILE_STATE (cpu);
1123 ps->post_wait = cycles;
1124 vliw = CPU_VLIW (cpu);
1125 slot = vliw->next_slot - 1;
1126 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1127 post_wait_for_float (cpu, slot);
1128 post_wait_for_FR (cpu, in_FRi);
1129 post_wait_for_FR (cpu, in_FRj);
1130 post_wait_for_FR (cpu, out_FRk);
1131 post_wait_for_FR (cpu, dual_FRi);
1132 post_wait_for_FR (cpu, dual_FRj);
1133 post_wait_for_FR (cpu, dual_FRk);
1134 post_wait_for_FRdouble (cpu, in_FRdoublei);
1135 post_wait_for_FRdouble (cpu, in_FRdoublej);
1136 post_wait_for_FRdouble (cpu, out_FRdoublek);
1137 post_wait_for_FRdouble (cpu, dual_FRdoublei);
1138 post_wait_for_FRdouble (cpu, dual_FRdoublej);
1139 post_wait_for_FRdouble (cpu, dual_FRdoublek);
1140 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1142 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1143 post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRk));
1144 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
1145 post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRdoublek));
1147 restore_float_register_busy (cpu, in_FRi, 2, in_FRj, 2, out_FRk, 2);
1148 restore_float_register_busy (cpu, in_FRdoublei, 4, in_FRdoublej, 4, out_FRdoublek, 4);
1150 /* The latency of FRk will be at least the latency of the other inputs. */
1151 update_FR_latency (cpu, out_FRk, ps->post_wait);
1152 update_FR_latency (cpu, dual_FRk, ps->post_wait);
1153 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1154 update_FRdouble_latency (cpu, dual_FRdoublek, ps->post_wait);
1156 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1158 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1159 update_SPR_latency (cpu, FNER_FOR_FR (dual_FRk), ps->post_wait);
1160 update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
1161 update_SPR_latency (cpu, FNER_FOR_FR (dual_FRdoublek), ps->post_wait);
1164 /* Once initiated, post-processing will take 3 cycles. */
1165 update_FR_ptime (cpu, out_FRk, 3);
1166 update_FR_ptime (cpu, dual_FRk, 3);
1167 update_FRdouble_ptime (cpu, out_FRdoublek, 3);
1168 update_FRdouble_ptime (cpu, dual_FRdoublek, 3);
1170 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1172 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
1173 update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRk), 3);
1174 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
1175 update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRdoublek), 3);
1178 /* Mark this use of the register as a floating point op. */
1179 if (out_FRk >= 0)
1180 fr550_reset_fr_flags (cpu, out_FRk);
1181 if (dual_FRk >= 0)
1182 fr550_reset_fr_flags (cpu, dual_FRk);
1183 if (out_FRdoublek >= 0)
1185 fr550_reset_fr_flags (cpu, out_FRdoublek);
1186 if (out_FRdoublek < 63)
1187 fr550_reset_fr_flags (cpu, out_FRdoublek + 1);
1189 if (dual_FRdoublek >= 0)
1191 fr550_reset_fr_flags (cpu, dual_FRdoublek);
1192 if (dual_FRdoublek < 63)
1193 fr550_reset_fr_flags (cpu, dual_FRdoublek + 1);
1196 /* the media point unit resource has a latency of 5 cycles */
1197 update_media_resource_latency (cpu, slot, cycles + 5);
1199 return cycles;
1203 frvbf_model_fr550_u_float_div (SIM_CPU *cpu, const IDESC *idesc,
1204 int unit_num, int referenced,
1205 INT in_FRi, INT in_FRj, INT out_FRk)
1207 int cycles;
1208 FRV_VLIW *vliw;
1209 int slot;
1210 FRV_PROFILE_STATE *ps;
1212 if (model_insn == FRV_INSN_MODEL_PASS_1)
1213 return 0;
1215 cycles = idesc->timing->units[unit_num].done;
1217 /* The post processing must wait if there is a dependency on a FR
1218 which is not ready yet. */
1219 adjust_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
1220 ps = CPU_PROFILE_STATE (cpu);
1221 ps->post_wait = cycles;
1222 vliw = CPU_VLIW (cpu);
1223 slot = vliw->next_slot - 1;
1224 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1225 post_wait_for_float (cpu, slot);
1226 post_wait_for_fdiv (cpu, slot);
1227 post_wait_for_FR (cpu, in_FRi);
1228 post_wait_for_FR (cpu, in_FRj);
1229 post_wait_for_FR (cpu, out_FRk);
1230 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1231 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1232 restore_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
1234 /* The latency of FRk will be at least the latency of the other inputs. */
1235 /* Once initiated, post-processing will take 9 cycles. */
1236 update_FR_latency (cpu, out_FRk, ps->post_wait);
1237 update_FR_ptime (cpu, out_FRk, 9);
1239 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1241 /* FNER has a latency of 9 cycles. */
1242 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1243 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 9);
1246 /* The latency of the fdiv unit will be at least the latency of the other
1247 inputs. Once initiated, post-processing will take 9 cycles. */
1248 update_fdiv_resource_latency (cpu, slot, ps->post_wait + 9);
1250 /* the media point unit resource has a latency of 11 cycles */
1251 update_media_resource_latency (cpu, slot, cycles + 11);
1253 fr550_reset_fr_flags (cpu, out_FRk);
1255 return cycles;
1259 frvbf_model_fr550_u_float_sqrt (SIM_CPU *cpu, const IDESC *idesc,
1260 int unit_num, int referenced,
1261 INT in_FRj, INT in_FRdoublej,
1262 INT out_FRk, INT out_FRdoublek)
1264 int cycles;
1265 FRV_VLIW *vliw;
1266 int slot;
1267 FRV_PROFILE_STATE *ps;
1269 if (model_insn == FRV_INSN_MODEL_PASS_1)
1270 return 0;
1272 cycles = idesc->timing->units[unit_num].done;
1274 /* The post processing must wait if there is a dependency on a FR
1275 which is not ready yet. */
1276 adjust_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
1277 adjust_float_register_busy (cpu, -1, 1, in_FRdoublej, 2, out_FRdoublek, 2);
1278 ps = CPU_PROFILE_STATE (cpu);
1279 ps->post_wait = cycles;
1280 vliw = CPU_VLIW (cpu);
1281 slot = vliw->next_slot - 1;
1282 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1283 post_wait_for_float (cpu, slot);
1284 post_wait_for_fsqrt (cpu, slot);
1285 post_wait_for_FR (cpu, in_FRj);
1286 post_wait_for_FR (cpu, out_FRk);
1287 post_wait_for_FRdouble (cpu, in_FRdoublej);
1288 post_wait_for_FRdouble (cpu, out_FRdoublek);
1289 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1291 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1292 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
1294 restore_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
1295 restore_float_register_busy (cpu, -1, 1, in_FRdoublej, 2, out_FRdoublek, 2);
1297 /* The latency of FRk will be at least the latency of the other inputs. */
1298 update_FR_latency (cpu, out_FRk, ps->post_wait);
1299 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1301 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1303 /* FNER has a latency of 14 cycles. */
1304 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1305 update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
1308 /* Once initiated, post-processing will take 14 cycles. */
1309 update_FR_ptime (cpu, out_FRk, 14);
1310 update_FRdouble_ptime (cpu, out_FRdoublek, 14);
1312 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1314 /* FNER has a latency of 14 cycles. */
1315 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 14);
1316 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 14);
1319 /* The latency of the sqrt unit will be the latency of the other
1320 inputs plus 14 cycles. */
1321 update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
1323 fr550_reset_fr_flags (cpu, out_FRk);
1324 if (out_FRdoublek != -1)
1326 fr550_reset_fr_flags (cpu, out_FRdoublek);
1327 fr550_reset_fr_flags (cpu, out_FRdoublek + 1);
1330 /* the media point unit resource has a latency of 16 cycles */
1331 update_media_resource_latency (cpu, slot, cycles + 16);
1333 return cycles;
1337 frvbf_model_fr550_u_float_compare (SIM_CPU *cpu, const IDESC *idesc,
1338 int unit_num, int referenced,
1339 INT in_FRi, INT in_FRj,
1340 INT in_FRdoublei, INT in_FRdoublej,
1341 INT out_FCCi_2)
1343 int cycles;
1344 FRV_PROFILE_STATE *ps;
1345 FRV_VLIW *vliw;
1346 int slot;
1348 if (model_insn == FRV_INSN_MODEL_PASS_1)
1349 return 0;
1351 /* The preprocessing can execute right away. */
1352 cycles = idesc->timing->units[unit_num].done;
1354 /* The post processing must wait if there is a dependency on a FR
1355 which is not ready yet. */
1356 adjust_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, -1, 1);
1357 adjust_float_register_busy (cpu, in_FRdoublei, 2, in_FRdoublej, 2, -1, 1);
1358 ps = CPU_PROFILE_STATE (cpu);
1359 ps->post_wait = cycles;
1360 vliw = CPU_VLIW (cpu);
1361 slot = vliw->next_slot - 1;
1362 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1363 post_wait_for_float (cpu, slot);
1364 post_wait_for_FR (cpu, in_FRi);
1365 post_wait_for_FR (cpu, in_FRj);
1366 post_wait_for_FRdouble (cpu, in_FRdoublei);
1367 post_wait_for_FRdouble (cpu, in_FRdoublej);
1368 post_wait_for_CCR (cpu, out_FCCi_2);
1369 restore_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, -1, 1);
1370 restore_float_register_busy (cpu, in_FRdoublei, 2, in_FRdoublej, 2, -1, 1);
1372 /* The latency of FCCi_2 will be the latency of the other inputs plus 2
1373 cycles. */
1374 update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 2);
1376 /* the media point unit resource has a latency of 4 cycles */
1377 update_media_resource_latency (cpu, slot, cycles + 4);
1379 set_use_is_ccr_complex (cpu, out_FCCi_2);
1381 return cycles;
1385 frvbf_model_fr550_u_float_dual_compare (SIM_CPU *cpu, const IDESC *idesc,
1386 int unit_num, int referenced,
1387 INT in_FRi, INT in_FRj,
1388 INT out_FCCi_2)
1390 int cycles;
1391 INT dual_FRi;
1392 INT dual_FRj;
1393 INT dual_FCCi_2;
1394 FRV_PROFILE_STATE *ps;
1395 FRV_VLIW *vliw;
1396 int slot;
1398 if (model_insn == FRV_INSN_MODEL_PASS_1)
1399 return 0;
1401 /* The preprocessing can execute right away. */
1402 cycles = idesc->timing->units[unit_num].done;
1404 /* The post processing must wait if there is a dependency on a FR
1405 which is not ready yet. */
1406 ps = CPU_PROFILE_STATE (cpu);
1407 ps->post_wait = cycles;
1408 dual_FRi = DUAL_REG (in_FRi);
1409 dual_FRj = DUAL_REG (in_FRj);
1410 dual_FCCi_2 = out_FCCi_2 + 1;
1411 adjust_float_register_busy (cpu, in_FRi, 2, in_FRj, 2, -1, 1);
1412 vliw = CPU_VLIW (cpu);
1413 slot = vliw->next_slot - 1;
1414 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1415 post_wait_for_float (cpu, slot);
1416 post_wait_for_FR (cpu, in_FRi);
1417 post_wait_for_FR (cpu, in_FRj);
1418 post_wait_for_FR (cpu, dual_FRi);
1419 post_wait_for_FR (cpu, dual_FRj);
1420 post_wait_for_CCR (cpu, out_FCCi_2);
1421 post_wait_for_CCR (cpu, dual_FCCi_2);
1422 restore_float_register_busy (cpu, in_FRi, 2, in_FRj, 2, -1, 1);
1424 /* The latency of FCCi_2 will be the latency of the other inputs plus 3
1425 cycles. */
1426 update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
1427 update_CCR_latency (cpu, dual_FCCi_2, ps->post_wait + 3);
1429 set_use_is_ccr_complex (cpu, out_FCCi_2);
1430 if (dual_FCCi_2 >= 0)
1431 set_use_is_ccr_complex (cpu, dual_FCCi_2);
1433 /* the media point unit resource has a latency of 5 cycles */
1434 update_media_resource_latency (cpu, slot, cycles + 5);
1436 return cycles;
1440 frvbf_model_fr550_u_float_convert (SIM_CPU *cpu, const IDESC *idesc,
1441 int unit_num, int referenced,
1442 INT in_FRj, INT in_FRintj, INT in_FRdoublej,
1443 INT out_FRk, INT out_FRintk,
1444 INT out_FRdoublek)
1446 int cycles;
1447 FRV_PROFILE_STATE *ps;
1448 FRV_VLIW *vliw;
1449 int slot;
1451 if (model_insn == FRV_INSN_MODEL_PASS_1)
1452 return 0;
1454 /* The preprocessing can execute right away. */
1455 cycles = idesc->timing->units[unit_num].done;
1457 /* The post processing must wait if there is a dependency on a FR
1458 which is not ready yet. */
1459 ps = CPU_PROFILE_STATE (cpu);
1460 ps->post_wait = cycles;
1461 adjust_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
1462 adjust_float_register_busy (cpu, -1, 1, in_FRintj, 1, out_FRintk, 1);
1463 adjust_float_register_busy (cpu, -1, 1, in_FRdoublej, 2, out_FRdoublek, 2);
1464 vliw = CPU_VLIW (cpu);
1465 slot = vliw->next_slot - 1;
1466 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1467 post_wait_for_float (cpu, slot);
1468 post_wait_for_FR (cpu, in_FRj);
1469 post_wait_for_FR (cpu, in_FRintj);
1470 post_wait_for_FRdouble (cpu, in_FRdoublej);
1471 post_wait_for_FR (cpu, out_FRk);
1472 post_wait_for_FR (cpu, out_FRintk);
1473 post_wait_for_FRdouble (cpu, out_FRdoublek);
1474 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1476 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1477 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRintk));
1478 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
1480 restore_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
1481 restore_float_register_busy (cpu, -1, 1, in_FRintj, 1, out_FRintk, 1);
1482 restore_float_register_busy (cpu, -1, 1, in_FRdoublej, 2, out_FRdoublek, 2);
1484 /* The latency of FRk will be at least the latency of the other inputs. */
1485 update_FR_latency (cpu, out_FRk, ps->post_wait);
1486 update_FR_latency (cpu, out_FRintk, ps->post_wait);
1487 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1489 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1491 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1492 update_SPR_latency (cpu, FNER_FOR_FR (out_FRintk), ps->post_wait);
1493 update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
1496 /* Once initiated, post-processing will take 2 cycles. */
1497 update_FR_ptime (cpu, out_FRk, 2);
1498 update_FR_ptime (cpu, out_FRintk, 2);
1499 update_FRdouble_ptime (cpu, out_FRdoublek, 2);
1501 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1503 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 2);
1504 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRintk), 2);
1505 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 2);
1508 /* Mark this use of the register as a floating point op. */
1509 if (out_FRk >= 0)
1510 set_use_is_fr_complex_2 (cpu, out_FRk);
1511 if (out_FRintk >= 0)
1512 set_use_is_fr_complex_2 (cpu, out_FRintk);
1513 if (out_FRdoublek >= 0)
1515 set_use_is_fr_complex_2 (cpu, out_FRdoublek);
1516 set_use_is_fr_complex_2 (cpu, out_FRdoublek + 1);
1519 /* the media point unit resource has a latency of 4 cycles */
1520 update_media_resource_latency (cpu, slot, cycles + 4);
1522 return cycles;
1526 frvbf_model_fr550_u_spr2gr (SIM_CPU *cpu, const IDESC *idesc,
1527 int unit_num, int referenced,
1528 INT in_spr, INT out_GRj)
1530 /* Modelling for this unit is the same as for fr500. */
1531 return frvbf_model_fr500_u_spr2gr (cpu, idesc, unit_num, referenced,
1532 in_spr, out_GRj);
1536 frvbf_model_fr550_u_gr2spr (SIM_CPU *cpu, const IDESC *idesc,
1537 int unit_num, int referenced,
1538 INT in_GRj, INT out_spr)
1540 int cycles;
1542 if (model_insn == FRV_INSN_MODEL_PASS_1)
1544 /* The entire VLIW insn must wait if there is a dependency on a register
1545 which is not ready yet. */
1546 vliw_wait_for_GR (cpu, in_GRj);
1547 vliw_wait_for_SPR (cpu, out_spr);
1548 handle_resource_wait (cpu);
1549 load_wait_for_GR (cpu, in_GRj);
1550 trace_vliw_wait_cycles (cpu);
1551 return 0;
1554 cycles = idesc->timing->units[unit_num].done;
1556 #if 0
1557 /* The latency of spr is ? cycles. */
1558 update_SPR_latency (cpu, out_spr, cycles + ?);
1559 #endif
1561 return cycles;
1565 frvbf_model_fr550_u_gr2fr (SIM_CPU *cpu, const IDESC *idesc,
1566 int unit_num, int referenced,
1567 INT in_GRj, INT out_FRk)
1569 int cycles;
1571 if (model_insn == FRV_INSN_MODEL_PASS_1)
1573 /* The entire VLIW insn must wait if there is a dependency on a register
1574 which is not ready yet.
1575 The latency of the registers may be less than previously recorded,
1576 depending on how they were used previously.
1577 See Table 14-15 in the LSI. */
1578 adjust_float_register_busy (cpu, -1, 1, -1, 1, out_FRk, 1);
1579 vliw_wait_for_GR (cpu, in_GRj);
1580 vliw_wait_for_FR (cpu, out_FRk);
1581 handle_resource_wait (cpu);
1582 load_wait_for_GR (cpu, in_GRj);
1583 load_wait_for_FR (cpu, out_FRk);
1584 trace_vliw_wait_cycles (cpu);
1585 return 0;
1588 /* The latency of FRk is 1 cycles. */
1589 cycles = idesc->timing->units[unit_num].done;
1590 update_FR_latency (cpu, out_FRk, cycles + 1);
1592 set_use_is_fr_complex_1 (cpu, out_FRk);
1594 return cycles;
1598 frvbf_model_fr550_u_swap (SIM_CPU *cpu, const IDESC *idesc,
1599 int unit_num, int referenced,
1600 INT in_GRi, INT in_GRj, INT out_GRk)
1602 int cycles;
1604 if (model_insn == FRV_INSN_MODEL_PASS_1)
1606 /* The entire VLIW insn must wait if there is a dependency on a register
1607 which is not ready yet. */
1608 vliw_wait_for_GR (cpu, in_GRi);
1609 vliw_wait_for_GR (cpu, in_GRj);
1610 vliw_wait_for_GR (cpu, out_GRk);
1611 handle_resource_wait (cpu);
1612 load_wait_for_GR (cpu, in_GRi);
1613 load_wait_for_GR (cpu, in_GRj);
1614 load_wait_for_GR (cpu, out_GRk);
1615 trace_vliw_wait_cycles (cpu);
1616 return 0;
1619 cycles = idesc->timing->units[unit_num].done;
1621 /* The latency of GRk will depend on how long it takes to swap
1622 the the data from the cache or memory. */
1623 update_GR_latency_for_swap (cpu, out_GRk, cycles);
1625 return cycles;
1629 frvbf_model_fr550_u_fr2fr (SIM_CPU *cpu, const IDESC *idesc,
1630 int unit_num, int referenced,
1631 INT in_FRj, INT out_FRk)
1633 int cycles;
1635 if (model_insn == FRV_INSN_MODEL_PASS_1)
1637 /* The entire VLIW insn must wait if there is a dependency on a register
1638 which is not ready yet.
1639 The latency of the registers may be less than previously recorded,
1640 depending on how they were used previously.
1641 See Table 14-15 in the LSI. */
1642 adjust_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
1643 vliw_wait_for_FR (cpu, in_FRj);
1644 vliw_wait_for_FR (cpu, out_FRk);
1645 handle_resource_wait (cpu);
1646 load_wait_for_FR (cpu, in_FRj);
1647 load_wait_for_FR (cpu, out_FRk);
1648 trace_vliw_wait_cycles (cpu);
1649 return 0;
1652 /* The latency of FRj is 2 cycles. */
1653 cycles = idesc->timing->units[unit_num].done;
1654 update_FR_latency (cpu, out_FRk, cycles + 2);
1656 set_use_is_fr_complex_2 (cpu, out_FRk);
1658 return cycles;
1662 frvbf_model_fr550_u_fr2gr (SIM_CPU *cpu, const IDESC *idesc,
1663 int unit_num, int referenced,
1664 INT in_FRk, INT out_GRj)
1666 int cycles;
1668 if (model_insn == FRV_INSN_MODEL_PASS_1)
1670 /* The entire VLIW insn must wait if there is a dependency on a register
1671 which is not ready yet.
1672 The latency of the registers may be less than previously recorded,
1673 depending on how they were used previously.
1674 See Table 14-15 in the LSI. */
1675 adjust_float_register_busy (cpu, in_FRk, 1, -1, 1, -1, 1);
1676 vliw_wait_for_FR (cpu, in_FRk);
1677 vliw_wait_for_GR (cpu, out_GRj);
1678 handle_resource_wait (cpu);
1679 load_wait_for_FR (cpu, in_FRk);
1680 load_wait_for_GR (cpu, out_GRj);
1681 trace_vliw_wait_cycles (cpu);
1682 return 0;
1685 /* The latency of GRj is 1 cycle. */
1686 cycles = idesc->timing->units[unit_num].done;
1687 update_GR_latency (cpu, out_GRj, cycles + 1);
1689 return cycles;
1693 frvbf_model_fr550_u_clrgr (SIM_CPU *cpu, const IDESC *idesc,
1694 int unit_num, int referenced,
1695 INT in_GRk)
1697 /* Modelling for this unit is the same as for fr500. */
1698 return frvbf_model_fr500_u_clrgr (cpu, idesc, unit_num, referenced, in_GRk);
1702 frvbf_model_fr550_u_clrfr (SIM_CPU *cpu, const IDESC *idesc,
1703 int unit_num, int referenced,
1704 INT in_FRk)
1706 /* Modelling for this unit is the same as for fr500. */
1707 return frvbf_model_fr500_u_clrfr (cpu, idesc, unit_num, referenced, in_FRk);
1711 frvbf_model_fr550_u_commit (SIM_CPU *cpu, const IDESC *idesc,
1712 int unit_num, int referenced,
1713 INT in_GRk, INT in_FRk)
1715 /* Modelling for this unit is the same as for fr500. */
1716 return frvbf_model_fr500_u_commit (cpu, idesc, unit_num, referenced,
1717 in_GRk, in_FRk);
1721 frvbf_model_fr550_u_media (SIM_CPU *cpu, const IDESC *idesc,
1722 int unit_num, int referenced,
1723 INT in_FRi, INT in_FRj, INT out_FRk)
1725 int cycles;
1726 FRV_PROFILE_STATE *ps;
1727 FRV_VLIW *vliw;
1728 int slot;
1730 if (model_insn == FRV_INSN_MODEL_PASS_1)
1731 return 0;
1733 /* The preprocessing can execute right away. */
1734 cycles = idesc->timing->units[unit_num].done;
1736 /* If the previous use of the registers was a media op,
1737 then their latency may be less than previously recorded.
1738 See Table 14-15 in the LSI. */
1739 adjust_float_register_busy_for_media (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
1741 /* The post processing must wait if there is a dependency on a FR
1742 which is not ready yet. */
1743 ps = CPU_PROFILE_STATE (cpu);
1744 ps->post_wait = cycles;
1745 vliw = CPU_VLIW (cpu);
1746 slot = vliw->next_slot - 1;
1747 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1748 post_wait_for_media (cpu, slot);
1749 post_wait_for_FR (cpu, in_FRi);
1750 post_wait_for_FR (cpu, in_FRj);
1751 post_wait_for_FR (cpu, out_FRk);
1753 /* Restore the busy cycles of the registers we used. */
1754 restore_float_register_busy_for_media (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
1756 /* The latency of tht output register will be at least the latency of the
1757 other inputs. Once initiated, post-processing will take 1 cycle. */
1758 if (out_FRk >= 0)
1760 update_FR_latency (cpu, out_FRk, ps->post_wait);
1761 update_FR_ptime (cpu, out_FRk, 1);
1762 /* Mark this use of the register as a media op. */
1763 set_use_is_fr_complex_1 (cpu, out_FRk);
1766 /* the floating point unit resource has a latency of 3 cycles */
1767 update_float_resource_latency (cpu, slot, cycles + 3);
1769 return cycles;
1773 frvbf_model_fr550_u_media_quad (SIM_CPU *cpu, const IDESC *idesc,
1774 int unit_num, int referenced,
1775 INT in_FRi, INT in_FRj,
1776 INT out_FRk)
1778 int cycles;
1779 INT dual_FRi;
1780 INT dual_FRj;
1781 INT dual_FRk;
1782 FRV_PROFILE_STATE *ps;
1783 FRV_VLIW *vliw;
1784 int slot;
1786 if (model_insn == FRV_INSN_MODEL_PASS_1)
1787 return 0;
1789 /* The preprocessing can execute right away. */
1790 cycles = idesc->timing->units[unit_num].done;
1792 dual_FRi = DUAL_REG (in_FRi);
1793 dual_FRj = DUAL_REG (in_FRj);
1794 dual_FRk = DUAL_REG (out_FRk);
1796 /* The latency of the registers may be less than previously recorded,
1797 depending on how they were used previously.
1798 See Table 14-15 in the LSI. */
1799 adjust_float_register_busy_for_media (cpu, in_FRi, 2, in_FRj, 2, out_FRk, 2);
1801 /* The post processing must wait if there is a dependency on a FR
1802 which is not ready yet. */
1803 ps = CPU_PROFILE_STATE (cpu);
1804 ps->post_wait = cycles;
1805 vliw = CPU_VLIW (cpu);
1806 slot = vliw->next_slot - 1;
1807 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1808 post_wait_for_media (cpu, slot);
1809 post_wait_for_FR (cpu, in_FRi);
1810 post_wait_for_FR (cpu, dual_FRi);
1811 post_wait_for_FR (cpu, in_FRj);
1812 post_wait_for_FR (cpu, dual_FRj);
1813 post_wait_for_FR (cpu, out_FRk);
1814 post_wait_for_FR (cpu, dual_FRk);
1816 /* Restore the busy cycles of the registers we used. */
1817 restore_float_register_busy_for_media (cpu, in_FRi, 2, in_FRj, 2, out_FRk, 2);
1819 /* The latency of the output register will be at least the latency of the
1820 other inputs. Once initiated, post-processing take 1 cycle. */
1821 update_FR_latency (cpu, out_FRk, ps->post_wait);
1822 update_FR_ptime (cpu, out_FRk, 1);
1823 set_use_is_fr_complex_1 (cpu, out_FRk);
1825 if (dual_FRk >= 0)
1827 update_FR_latency (cpu, dual_FRk, ps->post_wait);
1828 update_FR_ptime (cpu, dual_FRk, 1);
1829 set_use_is_fr_complex_1 (cpu, dual_FRk);
1832 /* the floating point unit resource has a latency of 3 cycles */
1833 update_float_resource_latency (cpu, slot, cycles + 3);
1835 return cycles;
1839 frvbf_model_fr550_u_media_dual_expand (SIM_CPU *cpu, const IDESC *idesc,
1840 int unit_num, int referenced,
1841 INT in_FRi, INT out_FRk)
1843 int cycles;
1844 INT dual_FRk;
1845 FRV_PROFILE_STATE *ps;
1846 FRV_VLIW *vliw;
1847 int slot;
1849 if (model_insn == FRV_INSN_MODEL_PASS_1)
1850 return 0;
1852 /* The preprocessing can execute right away. */
1853 cycles = idesc->timing->units[unit_num].done;
1855 /* If the previous use of the registers was a media op,
1856 then their latency will be less than previously recorded.
1857 See Table 14-15 in the LSI. */
1858 dual_FRk = DUAL_REG (out_FRk);
1859 adjust_float_register_busy_for_media (cpu, in_FRi, 1, -1, 1, out_FRk, 2);
1861 /* The post processing must wait if there is a dependency on a FR
1862 which is not ready yet. */
1863 ps = CPU_PROFILE_STATE (cpu);
1864 ps->post_wait = cycles;
1865 vliw = CPU_VLIW (cpu);
1866 slot = vliw->next_slot - 1;
1867 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1868 post_wait_for_media (cpu, slot);
1869 post_wait_for_FR (cpu, in_FRi);
1870 post_wait_for_FR (cpu, out_FRk);
1871 post_wait_for_FR (cpu, dual_FRk);
1873 /* Restore the busy cycles of the registers we used. */
1874 restore_float_register_busy_for_media (cpu, in_FRi, 1, -1, 1, out_FRk, 2);
1876 /* The latency of the output register will be at least the latency of the
1877 other inputs. Once initiated, post-processing will take 1 cycle. */
1878 update_FR_latency (cpu, out_FRk, ps->post_wait);
1879 update_FR_ptime (cpu, out_FRk, 1);
1880 set_use_is_fr_complex_1 (cpu, out_FRk);
1882 if (dual_FRk >= 0)
1884 update_FR_latency (cpu, dual_FRk, ps->post_wait);
1885 update_FR_ptime (cpu, dual_FRk, 1);
1886 set_use_is_fr_complex_1 (cpu, dual_FRk);
1889 /* the floating point unit resource has a latency of 3 cycles */
1890 update_float_resource_latency (cpu, slot, cycles + 3);
1892 return cycles;
1896 frvbf_model_fr550_u_media_3_dual (SIM_CPU *cpu, const IDESC *idesc,
1897 int unit_num, int referenced,
1898 INT in_FRi, INT out_FRk)
1900 int cycles;
1901 INT dual_FRi;
1902 FRV_PROFILE_STATE *ps;
1903 FRV_VLIW *vliw;
1904 int slot;
1906 if (model_insn == FRV_INSN_MODEL_PASS_1)
1907 return 0;
1909 /* The preprocessing can execute right away. */
1910 cycles = idesc->timing->units[unit_num].done;
1912 dual_FRi = DUAL_REG (in_FRi);
1914 /* The latency of the registers may be less than previously recorded,
1915 depending on how they were used previously.
1916 See Table 14-15 in the LSI. */
1917 adjust_float_register_busy_for_media (cpu, in_FRi, 2, -1, 1, out_FRk, 1);
1919 /* The post processing must wait if there is a dependency on a FR
1920 which is not ready yet. */
1921 ps = CPU_PROFILE_STATE (cpu);
1922 ps->post_wait = cycles;
1923 vliw = CPU_VLIW (cpu);
1924 slot = vliw->next_slot - 1;
1925 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1926 post_wait_for_media (cpu, slot);
1927 post_wait_for_FR (cpu, in_FRi);
1928 post_wait_for_FR (cpu, dual_FRi);
1929 post_wait_for_FR (cpu, out_FRk);
1931 /* Restore the busy cycles of the registers we used. */
1932 restore_float_register_busy_for_media (cpu, in_FRi, 2, -1, 1, out_FRk, 1);
1934 /* The latency of the output register will be at least the latency of the
1935 other inputs. Once initiated, post-processing takes 1 cycle. */
1936 update_FR_latency (cpu, out_FRk, ps->post_wait);
1937 update_FR_ptime (cpu, out_FRk, 1);
1939 set_use_is_fr_complex_1 (cpu, out_FRk);
1941 /* the floating point unit resource has a latency of 3 cycles */
1942 update_float_resource_latency (cpu, slot, cycles + 3);
1944 return cycles;
1948 frvbf_model_fr550_u_media_3_acc (SIM_CPU *cpu, const IDESC *idesc,
1949 int unit_num, int referenced,
1950 INT in_FRj, INT in_ACC40Si,
1951 INT out_FRk)
1953 int cycles;
1954 FRV_PROFILE_STATE *ps;
1955 FRV_VLIW *vliw;
1956 int slot;
1958 if (model_insn == FRV_INSN_MODEL_PASS_1)
1959 return 0;
1961 /* The preprocessing can execute right away. */
1962 cycles = idesc->timing->units[unit_num].done;
1964 /* If the previous use of the registers was a media op,
1965 then their latency will be less than previously recorded.
1966 See Table 14-15 in the LSI. */
1967 adjust_float_register_busy_for_media (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
1969 /* The post processing must wait if there is a dependency on a FR
1970 which is not ready yet. */
1971 ps = CPU_PROFILE_STATE (cpu);
1972 ps->post_wait = cycles;
1973 vliw = CPU_VLIW (cpu);
1974 slot = vliw->next_slot - 1;
1975 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1976 post_wait_for_media (cpu, slot);
1977 post_wait_for_FR (cpu, in_FRj);
1978 post_wait_for_FR (cpu, out_FRk);
1979 post_wait_for_ACC (cpu, in_ACC40Si);
1981 /* Restore the busy cycles of the registers we used. */
1982 restore_float_register_busy_for_media (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
1984 /* The latency of tht output register will be at least the latency of the
1985 other inputs. Once initiated, post-processing will take 1 cycle. */
1986 update_FR_latency (cpu, out_FRk, ps->post_wait);
1987 update_FR_ptime (cpu, out_FRk, 1);
1989 set_use_is_fr_complex_1 (cpu, out_FRk);
1991 /* the floating point unit resource has a latency of 3 cycles */
1992 update_float_resource_latency (cpu, slot, cycles + 3);
1994 return cycles;
1998 frvbf_model_fr550_u_media_3_acc_dual (SIM_CPU *cpu, const IDESC *idesc,
1999 int unit_num, int referenced,
2000 INT in_ACC40Si, INT out_FRk)
2002 int cycles;
2003 FRV_PROFILE_STATE *ps;
2004 INT ACC40Si_1;
2005 INT dual_FRk;
2006 FRV_VLIW *vliw;
2007 int slot;
2009 if (model_insn == FRV_INSN_MODEL_PASS_1)
2010 return 0;
2012 /* The preprocessing can execute right away. */
2013 cycles = idesc->timing->units[unit_num].done;
2015 ACC40Si_1 = DUAL_REG (in_ACC40Si);
2016 dual_FRk = DUAL_REG (out_FRk);
2018 /* If the previous use of the registers was a media op,
2019 then their latency will be less than previously recorded.
2020 See Table 14-15 in the LSI. */
2021 adjust_float_register_busy_for_media (cpu, -1, 1, -1, 1, out_FRk, 2);
2023 /* The post processing must wait if there is a dependency on a FR
2024 which is not ready yet. */
2025 ps = CPU_PROFILE_STATE (cpu);
2026 ps->post_wait = cycles;
2027 vliw = CPU_VLIW (cpu);
2028 slot = vliw->next_slot - 1;
2029 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2030 post_wait_for_media (cpu, slot);
2031 post_wait_for_ACC (cpu, in_ACC40Si);
2032 post_wait_for_ACC (cpu, ACC40Si_1);
2033 post_wait_for_FR (cpu, out_FRk);
2034 post_wait_for_FR (cpu, dual_FRk);
2036 /* Restore the busy cycles of the registers we used. */
2037 restore_float_register_busy_for_media (cpu, -1, 1, -1, 1, out_FRk, 2);
2039 /* The latency of the output register will be at least the latency of the
2040 other inputs. Once initiated, post-processing will take 1 cycle. */
2041 update_FR_latency (cpu, out_FRk, ps->post_wait);
2042 update_FR_ptime (cpu, out_FRk, 1);
2043 set_use_is_fr_complex_1 (cpu, out_FRk);
2044 if (dual_FRk >= 0)
2046 update_FR_latency (cpu, dual_FRk, ps->post_wait);
2047 update_FR_ptime (cpu, dual_FRk, 1);
2048 set_use_is_fr_complex_1 (cpu, dual_FRk);
2051 /* the floating point unit resource has a latency of 3 cycles */
2052 update_float_resource_latency (cpu, slot, cycles + 3);
2054 return cycles;
2058 frvbf_model_fr550_u_media_3_wtacc (SIM_CPU *cpu, const IDESC *idesc,
2059 int unit_num, int referenced,
2060 INT in_FRi, INT out_ACC40Sk)
2062 int cycles;
2063 FRV_PROFILE_STATE *ps;
2064 FRV_VLIW *vliw;
2065 int slot;
2067 if (model_insn == FRV_INSN_MODEL_PASS_1)
2068 return 0;
2070 /* The preprocessing can execute right away. */
2071 cycles = idesc->timing->units[unit_num].done;
2073 ps = CPU_PROFILE_STATE (cpu);
2075 /* The latency of the registers may be less than previously recorded,
2076 depending on how they were used previously.
2077 See Table 14-15 in the LSI. */
2078 adjust_float_register_busy_for_media (cpu, in_FRi, 1, -1, 1, -1, 1);
2080 /* The post processing must wait if there is a dependency on a FR
2081 which is not ready yet. */
2082 ps->post_wait = cycles;
2083 vliw = CPU_VLIW (cpu);
2084 slot = vliw->next_slot - 1;
2085 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2086 post_wait_for_media (cpu, slot);
2087 post_wait_for_FR (cpu, in_FRi);
2088 post_wait_for_ACC (cpu, out_ACC40Sk);
2090 /* Restore the busy cycles of the registers we used. */
2091 restore_float_register_busy_for_media (cpu, in_FRi, 1, -1, 1, -1, 1);
2093 /* The latency of the output register will be at least the latency of the
2094 other inputs. Once initiated, post-processing will take 1 cycle. */
2095 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait);
2096 update_ACC_ptime (cpu, out_ACC40Sk, 1);
2097 set_use_is_acc_mmac (cpu, out_ACC40Sk);
2099 /* the floating point unit resource has a latency of 3 cycles */
2100 update_float_resource_latency (cpu, slot, cycles + 3);
2102 return cycles;
2106 frvbf_model_fr550_u_media_3_mclracc (SIM_CPU *cpu, const IDESC *idesc,
2107 int unit_num, int referenced)
2109 int cycles;
2110 FRV_PROFILE_STATE *ps;
2111 FRV_VLIW *vliw;
2112 int slot;
2113 int i;
2115 if (model_insn == FRV_INSN_MODEL_PASS_1)
2116 return 0;
2118 /* The preprocessing can execute right away. */
2119 cycles = idesc->timing->units[unit_num].done;
2121 ps = CPU_PROFILE_STATE (cpu);
2123 /* The post processing must wait if there is a dependency on a FR
2124 which is not ready yet. */
2125 ps->post_wait = cycles;
2126 vliw = CPU_VLIW (cpu);
2127 slot = vliw->next_slot - 1;
2128 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2129 post_wait_for_media (cpu, slot);
2131 /* If A was 1 and the accumulator was ACC0, then we must check all
2132 accumulators. Otherwise just wait for the specified accumulator. */
2133 if (ps->mclracc_A && ps->mclracc_acc == 0)
2135 for (i = 0; i < 8; ++i)
2136 post_wait_for_ACC (cpu, i);
2138 else
2139 post_wait_for_ACC (cpu, ps->mclracc_acc);
2141 /* The latency of the output registers will be at least the latency of the
2142 other inputs. Once initiated, post-processing will take 1 cycle. */
2143 if (ps->mclracc_A && ps->mclracc_acc == 0)
2145 for (i = 0; i < 8; ++i)
2147 update_ACC_latency (cpu, i, ps->post_wait);
2148 update_ACC_ptime (cpu, i, 1);
2149 set_use_is_acc_mmac (cpu, i);
2152 else
2154 update_ACC_latency (cpu, ps->mclracc_acc, ps->post_wait);
2155 update_ACC_ptime (cpu, ps->mclracc_acc, 1);
2156 set_use_is_acc_mmac (cpu, ps->mclracc_acc);
2159 /* the floating point unit resource has a latency of 3 cycles */
2160 update_float_resource_latency (cpu, slot, cycles + 3);
2162 return cycles;
2166 frvbf_model_fr550_u_media_set (SIM_CPU *cpu, const IDESC *idesc,
2167 int unit_num, int referenced,
2168 INT out_FRk)
2170 int cycles;
2171 FRV_PROFILE_STATE *ps;
2172 FRV_VLIW *vliw;
2173 int slot;
2175 if (model_insn == FRV_INSN_MODEL_PASS_1)
2176 return 0;
2178 /* The preprocessing can execute right away. */
2179 cycles = idesc->timing->units[unit_num].done;
2181 /* If the previous use of the registers was a media op,
2182 then their latency will be less than previously recorded.
2183 See Table 14-15 in the LSI. */
2184 adjust_float_register_busy_for_media (cpu, -1, 1, -1, 1, out_FRk, 1);
2186 /* The post processing must wait if there is a dependency on a FR
2187 which is not ready yet. */
2188 ps = CPU_PROFILE_STATE (cpu);
2189 ps->post_wait = cycles;
2190 vliw = CPU_VLIW (cpu);
2191 slot = vliw->next_slot - 1;
2192 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2193 post_wait_for_media (cpu, slot);
2194 post_wait_for_FR (cpu, out_FRk);
2196 /* Restore the busy cycles of the registers we used. */
2197 restore_float_register_busy_for_media (cpu, -1, 1, -1, 1, out_FRk, 1);
2199 /* The latency of the output register will be at least the latency of the
2200 other inputs. Once initiated, post-processing takes 1 cycle. */
2201 update_FR_latency (cpu, out_FRk, ps->post_wait);
2202 update_FR_ptime (cpu, out_FRk, 1);
2203 fr550_reset_acc_flags (cpu, out_FRk);
2205 /* the floating point unit resource has a latency of 3 cycles */
2206 update_float_resource_latency (cpu, slot, cycles + 3);
2208 return cycles;
2212 frvbf_model_fr550_u_media_4 (SIM_CPU *cpu, const IDESC *idesc,
2213 int unit_num, int referenced,
2214 INT in_FRi, INT in_FRj,
2215 INT out_ACC40Sk, INT out_ACC40Uk)
2217 int cycles;
2218 INT dual_ACC40Sk;
2219 INT dual_ACC40Uk;
2220 FRV_PROFILE_STATE *ps;
2221 FRV_VLIW *vliw;
2222 int slot;
2224 if (model_insn == FRV_INSN_MODEL_PASS_1)
2225 return 0;
2227 /* The preprocessing can execute right away. */
2228 cycles = idesc->timing->units[unit_num].done;
2230 ps = CPU_PROFILE_STATE (cpu);
2231 dual_ACC40Sk = DUAL_REG (out_ACC40Sk);
2232 dual_ACC40Uk = DUAL_REG (out_ACC40Uk);
2234 /* The latency of the registers may be less than previously recorded,
2235 depending on how they were used previously.
2236 See Table 14-15 in the LSI. */
2237 adjust_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Sk, 2);
2238 adjust_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Uk, 2);
2240 /* The post processing must wait if there is a dependency on a FR
2241 which is not ready yet. */
2242 ps->post_wait = cycles;
2243 vliw = CPU_VLIW (cpu);
2244 slot = vliw->next_slot - 1;
2245 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2246 post_wait_for_media (cpu, slot);
2247 post_wait_for_FR (cpu, in_FRi);
2248 post_wait_for_FR (cpu, in_FRj);
2249 post_wait_for_ACC (cpu, out_ACC40Sk);
2250 post_wait_for_ACC (cpu, dual_ACC40Sk);
2251 post_wait_for_ACC (cpu, out_ACC40Uk);
2252 post_wait_for_ACC (cpu, dual_ACC40Uk);
2254 /* Restore the busy cycles of the registers we used. */
2255 restore_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Sk, 2);
2256 restore_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Uk, 2);
2258 /* The latency of the output register will be at least the latency of the
2259 other inputs. Once initiated, post-processing will take 1 cycles. */
2260 if (out_ACC40Sk >= 0)
2262 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2263 set_use_is_acc_mmac (cpu, out_ACC40Sk);
2265 if (dual_ACC40Sk >= 0)
2267 update_ACC_latency (cpu, dual_ACC40Sk, ps->post_wait + 1);
2268 set_use_is_acc_mmac (cpu, dual_ACC40Sk);
2270 if (out_ACC40Uk >= 0)
2272 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
2273 set_use_is_acc_mmac (cpu, out_ACC40Uk);
2275 if (dual_ACC40Uk >= 0)
2277 update_ACC_latency (cpu, dual_ACC40Uk, ps->post_wait + 1);
2278 set_use_is_acc_mmac (cpu, dual_ACC40Uk);
2281 /* the floating point unit resource has a latency of 3 cycles */
2282 update_float_resource_latency (cpu, slot, cycles + 3);
2284 return cycles;
2288 frvbf_model_fr550_u_media_4_acc (SIM_CPU *cpu, const IDESC *idesc,
2289 int unit_num, int referenced,
2290 INT in_ACC40Si, INT out_ACC40Sk)
2292 int cycles;
2293 INT ACC40Si_1;
2294 FRV_PROFILE_STATE *ps;
2295 FRV_VLIW *vliw;
2296 int slot;
2298 if (model_insn == FRV_INSN_MODEL_PASS_1)
2299 return 0;
2301 /* The preprocessing can execute right away. */
2302 cycles = idesc->timing->units[unit_num].done;
2304 ACC40Si_1 = DUAL_REG (in_ACC40Si);
2306 ps = CPU_PROFILE_STATE (cpu);
2307 /* The latency of the registers may be less than previously recorded,
2308 depending on how they were used previously.
2309 See Table 14-15 in the LSI. */
2310 adjust_acc_busy_for_mmac (cpu, in_ACC40Si, 2, out_ACC40Sk, 1);
2312 /* The post processing must wait if there is a dependency on a register
2313 which is not ready yet. */
2314 ps->post_wait = cycles;
2315 vliw = CPU_VLIW (cpu);
2316 slot = vliw->next_slot - 1;
2317 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2318 post_wait_for_media (cpu, slot);
2319 post_wait_for_ACC (cpu, in_ACC40Si);
2320 post_wait_for_ACC (cpu, ACC40Si_1);
2321 post_wait_for_ACC (cpu, out_ACC40Sk);
2323 /* Restore the busy cycles of the registers we used. */
2324 restore_acc_busy_for_mmac (cpu, in_ACC40Si, 2, out_ACC40Sk, 1);
2326 /* The latency of the output register will be at least the latency of the
2327 other inputs. Once initiated, post-processing will take 1 cycle. */
2328 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2329 set_use_is_acc_mmac (cpu, out_ACC40Sk);
2331 /* the floating point unit resource has a latency of 3 cycles */
2332 update_float_resource_latency (cpu, slot, cycles + 3);
2334 return cycles;
2338 frvbf_model_fr550_u_media_4_acc_dual (SIM_CPU *cpu, const IDESC *idesc,
2339 int unit_num, int referenced,
2340 INT in_ACC40Si, INT out_ACC40Sk)
2342 int cycles;
2343 INT ACC40Si_1;
2344 INT ACC40Si_2;
2345 INT ACC40Si_3;
2346 INT ACC40Sk_1;
2347 FRV_PROFILE_STATE *ps;
2348 FRV_VLIW *vliw;
2349 int slot;
2351 if (model_insn == FRV_INSN_MODEL_PASS_1)
2352 return 0;
2354 /* The preprocessing can execute right away. */
2355 cycles = idesc->timing->units[unit_num].done;
2357 ACC40Si_1 = DUAL_REG (in_ACC40Si);
2358 ACC40Si_2 = DUAL_REG (ACC40Si_1);
2359 ACC40Si_3 = DUAL_REG (ACC40Si_2);
2360 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
2362 ps = CPU_PROFILE_STATE (cpu);
2363 /* The latency of the registers may be less than previously recorded,
2364 depending on how they were used previously.
2365 See Table 14-15 in the LSI. */
2366 adjust_acc_busy_for_mmac (cpu, in_ACC40Si, 4, out_ACC40Sk, 2);
2368 /* The post processing must wait if there is a dependency on a register
2369 which is not ready yet. */
2370 ps->post_wait = cycles;
2371 vliw = CPU_VLIW (cpu);
2372 slot = vliw->next_slot - 1;
2373 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2374 post_wait_for_media (cpu, slot);
2375 post_wait_for_ACC (cpu, in_ACC40Si);
2376 post_wait_for_ACC (cpu, ACC40Si_1);
2377 post_wait_for_ACC (cpu, ACC40Si_2);
2378 post_wait_for_ACC (cpu, ACC40Si_3);
2379 post_wait_for_ACC (cpu, out_ACC40Sk);
2380 post_wait_for_ACC (cpu, ACC40Sk_1);
2382 /* Restore the busy cycles of the registers we used. */
2383 restore_acc_busy_for_mmac (cpu, in_ACC40Si, 4, out_ACC40Sk, 2);
2385 /* The latency of the output register will be at least the latency of the
2386 other inputs. Once initiated, post-processing will take 1 cycle. */
2387 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2388 set_use_is_acc_mmac (cpu, out_ACC40Sk);
2389 if (ACC40Sk_1 >= 0)
2391 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
2392 set_use_is_acc_mmac (cpu, ACC40Sk_1);
2395 /* the floating point unit resource has a latency of 3 cycles */
2396 update_float_resource_latency (cpu, slot, cycles + 3);
2398 return cycles;
2402 frvbf_model_fr550_u_media_4_add_sub (SIM_CPU *cpu, const IDESC *idesc,
2403 int unit_num, int referenced,
2404 INT in_ACC40Si, INT out_ACC40Sk)
2406 int cycles;
2407 INT ACC40Si_1;
2408 INT ACC40Sk_1;
2409 FRV_PROFILE_STATE *ps;
2410 FRV_VLIW *vliw;
2411 int slot;
2413 if (model_insn == FRV_INSN_MODEL_PASS_1)
2414 return 0;
2416 /* The preprocessing can execute right away. */
2417 cycles = idesc->timing->units[unit_num].done;
2419 ACC40Si_1 = DUAL_REG (in_ACC40Si);
2420 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
2422 ps = CPU_PROFILE_STATE (cpu);
2423 /* The latency of the registers may be less than previously recorded,
2424 depending on how they were used previously.
2425 See Table 14-15 in the LSI. */
2426 adjust_acc_busy_for_mmac (cpu, in_ACC40Si, 2, out_ACC40Sk, 2);
2428 /* The post processing must wait if there is a dependency on a register
2429 which is not ready yet. */
2430 ps->post_wait = cycles;
2431 vliw = CPU_VLIW (cpu);
2432 slot = vliw->next_slot - 1;
2433 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2434 post_wait_for_media (cpu, slot);
2435 post_wait_for_ACC (cpu, in_ACC40Si);
2436 post_wait_for_ACC (cpu, ACC40Si_1);
2437 post_wait_for_ACC (cpu, out_ACC40Sk);
2438 post_wait_for_ACC (cpu, ACC40Sk_1);
2440 /* Restore the busy cycles of the registers we used. */
2441 restore_acc_busy_for_mmac (cpu, in_ACC40Si, 2, out_ACC40Sk, 2);
2443 /* The latency of the output register will be at least the latency of the
2444 other inputs. Once initiated, post-processing will take 1 cycle. */
2445 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2446 set_use_is_acc_mmac (cpu, out_ACC40Sk);
2447 if (ACC40Sk_1 >= 0)
2449 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
2450 set_use_is_acc_mmac (cpu, ACC40Sk_1);
2453 /* the floating point unit resource has a latency of 3 cycles */
2454 update_float_resource_latency (cpu, slot, cycles + 3);
2456 return cycles;
2460 frvbf_model_fr550_u_media_4_add_sub_dual (SIM_CPU *cpu, const IDESC *idesc,
2461 int unit_num, int referenced,
2462 INT in_ACC40Si, INT out_ACC40Sk)
2464 int cycles;
2465 INT ACC40Si_1;
2466 INT ACC40Si_2;
2467 INT ACC40Si_3;
2468 INT ACC40Sk_1;
2469 INT ACC40Sk_2;
2470 INT ACC40Sk_3;
2471 FRV_PROFILE_STATE *ps;
2472 FRV_VLIW *vliw;
2473 int slot;
2475 if (model_insn == FRV_INSN_MODEL_PASS_1)
2476 return 0;
2478 /* The preprocessing can execute right away. */
2479 cycles = idesc->timing->units[unit_num].done;
2481 ACC40Si_1 = DUAL_REG (in_ACC40Si);
2482 ACC40Si_2 = DUAL_REG (ACC40Si_1);
2483 ACC40Si_3 = DUAL_REG (ACC40Si_2);
2484 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
2485 ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
2486 ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
2488 ps = CPU_PROFILE_STATE (cpu);
2489 /* The latency of the registers may be less than previously recorded,
2490 depending on how they were used previously.
2491 See Table 14-15 in the LSI. */
2492 adjust_acc_busy_for_mmac (cpu, in_ACC40Si, 4, out_ACC40Sk, 4);
2494 /* The post processing must wait if there is a dependency on a register
2495 which is not ready yet. */
2496 ps->post_wait = cycles;
2497 vliw = CPU_VLIW (cpu);
2498 slot = vliw->next_slot - 1;
2499 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2500 post_wait_for_media (cpu, slot);
2501 post_wait_for_ACC (cpu, in_ACC40Si);
2502 post_wait_for_ACC (cpu, ACC40Si_1);
2503 post_wait_for_ACC (cpu, ACC40Si_2);
2504 post_wait_for_ACC (cpu, ACC40Si_3);
2505 post_wait_for_ACC (cpu, out_ACC40Sk);
2506 post_wait_for_ACC (cpu, ACC40Sk_1);
2507 post_wait_for_ACC (cpu, ACC40Sk_2);
2508 post_wait_for_ACC (cpu, ACC40Sk_3);
2510 /* Restore the busy cycles of the registers we used. */
2511 restore_acc_busy_for_mmac (cpu, in_ACC40Si, 4, out_ACC40Sk, 4);
2513 /* The latency of the output register will be at least the latency of the
2514 other inputs. Once initiated, post-processing will take 1 cycle. */
2515 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2516 set_use_is_acc_mmac (cpu, out_ACC40Sk);
2517 if (ACC40Sk_1 >= 0)
2519 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
2520 set_use_is_acc_mmac (cpu, ACC40Sk_1);
2522 if (ACC40Sk_2 >= 0)
2524 update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
2525 set_use_is_acc_mmac (cpu, ACC40Sk_2);
2527 if (ACC40Sk_3 >= 0)
2529 update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
2530 set_use_is_acc_mmac (cpu, ACC40Sk_3);
2533 /* the floating point unit resource has a latency of 3 cycles */
2534 update_float_resource_latency (cpu, slot, cycles + 3);
2536 return cycles;
2540 frvbf_model_fr550_u_media_4_quad (SIM_CPU *cpu, const IDESC *idesc,
2541 int unit_num, int referenced,
2542 INT in_FRi, INT in_FRj,
2543 INT out_ACC40Sk, INT out_ACC40Uk)
2545 int cycles;
2546 INT dual_FRi;
2547 INT dual_FRj;
2548 INT ACC40Sk_1;
2549 INT ACC40Sk_2;
2550 INT ACC40Sk_3;
2551 INT ACC40Uk_1;
2552 INT ACC40Uk_2;
2553 INT ACC40Uk_3;
2554 FRV_PROFILE_STATE *ps;
2555 FRV_VLIW *vliw;
2556 int slot;
2558 if (model_insn == FRV_INSN_MODEL_PASS_1)
2559 return 0;
2561 /* The preprocessing can execute right away. */
2562 cycles = idesc->timing->units[unit_num].done;
2564 dual_FRi = DUAL_REG (in_FRi);
2565 dual_FRj = DUAL_REG (in_FRj);
2566 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
2567 ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
2568 ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
2569 ACC40Uk_1 = DUAL_REG (out_ACC40Uk);
2570 ACC40Uk_2 = DUAL_REG (ACC40Uk_1);
2571 ACC40Uk_3 = DUAL_REG (ACC40Uk_2);
2573 ps = CPU_PROFILE_STATE (cpu);
2574 /* The latency of the registers may be less than previously recorded,
2575 depending on how they were used previously.
2576 See Table 14-15 in the LSI. */
2577 adjust_float_register_busy_for_media (cpu, in_FRi, 2, in_FRj, 2, -1, 1);
2578 adjust_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Sk, 4);
2579 adjust_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Uk, 4);
2581 /* The post processing must wait if there is a dependency on a FR
2582 which is not ready yet. */
2583 ps->post_wait = cycles;
2584 vliw = CPU_VLIW (cpu);
2585 slot = vliw->next_slot - 1;
2586 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
2587 post_wait_for_media (cpu, slot);
2588 post_wait_for_FR (cpu, in_FRi);
2589 post_wait_for_FR (cpu, dual_FRi);
2590 post_wait_for_FR (cpu, in_FRj);
2591 post_wait_for_FR (cpu, dual_FRj);
2592 post_wait_for_ACC (cpu, out_ACC40Sk);
2593 post_wait_for_ACC (cpu, ACC40Sk_1);
2594 post_wait_for_ACC (cpu, ACC40Sk_2);
2595 post_wait_for_ACC (cpu, ACC40Sk_3);
2596 post_wait_for_ACC (cpu, out_ACC40Uk);
2597 post_wait_for_ACC (cpu, ACC40Uk_1);
2598 post_wait_for_ACC (cpu, ACC40Uk_2);
2599 post_wait_for_ACC (cpu, ACC40Uk_3);
2601 /* Restore the busy cycles of the registers we used. */
2602 restore_float_register_busy_for_media (cpu, in_FRi, 2, in_FRj, 2, -1, 1);
2603 restore_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Sk, 4);
2604 restore_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Uk, 4);
2606 /* The latency of the output register will be at least the latency of the
2607 other inputs. Once initiated, post-processing will take 1 cycle. */
2608 if (out_ACC40Sk >= 0)
2610 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2612 set_use_is_acc_mmac (cpu, out_ACC40Sk);
2613 if (ACC40Sk_1 >= 0)
2615 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
2617 set_use_is_acc_mmac (cpu, ACC40Sk_1);
2619 if (ACC40Sk_2 >= 0)
2621 update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
2623 set_use_is_acc_mmac (cpu, ACC40Sk_2);
2625 if (ACC40Sk_3 >= 0)
2627 update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
2629 set_use_is_acc_mmac (cpu, ACC40Sk_3);
2632 else if (out_ACC40Uk >= 0)
2634 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
2636 set_use_is_acc_mmac (cpu, out_ACC40Uk);
2637 if (ACC40Uk_1 >= 0)
2639 update_ACC_latency (cpu, ACC40Uk_1, ps->post_wait + 1);
2641 set_use_is_acc_mmac (cpu, ACC40Uk_1);
2643 if (ACC40Uk_2 >= 0)
2645 update_ACC_latency (cpu, ACC40Uk_2, ps->post_wait + 1);
2647 set_use_is_acc_mmac (cpu, ACC40Uk_2);
2649 if (ACC40Uk_3 >= 0)
2651 update_ACC_latency (cpu, ACC40Uk_3, ps->post_wait + 1);
2653 set_use_is_acc_mmac (cpu, ACC40Uk_3);
2657 /* the floating point unit resource has a latency of 3 cycles */
2658 update_float_resource_latency (cpu, slot, cycles + 3);
2660 return cycles;
2663 #endif /* WITH_PROFILE_MODEL_P */