Automatic date update in version.in
[binutils-gdb.git] / sim / frv / profile-fr500.c
blobca60061bf9caf5f965d7cfe9078b68b0db52c0a0
1 /* frv simulator fr500 dependent profiling code.
3 Copyright (C) 1998-2024 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/>. */
21 /* This must come before any other includes. */
22 #include "defs.h"
24 #define WANT_CPU
25 #define WANT_CPU_FRVBF
27 #include "sim-main.h"
28 #include "bfd.h"
30 #if WITH_PROFILE_MODEL_P
32 #include "profile.h"
33 #include "profile-fr500.h"
35 /* Initialize cycle counting for an insn.
36 FIRST_P is non-zero if this is the first insn in a set of parallel
37 insns. */
38 void
39 fr500_model_insn_before (SIM_CPU *cpu, int first_p)
41 if (first_p)
43 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
44 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
45 ps->cur_gr_complex = ps->prev_gr_complex;
46 d->cur_fpop = d->prev_fpop;
47 d->cur_media = d->prev_media;
48 d->cur_cc_complex = d->prev_cc_complex;
52 /* Record the cycles computed for an insn.
53 LAST_P is non-zero if this is the last insn in a set of parallel insns,
54 and we update the total cycle count.
55 CYCLES is the cycle count of the insn. */
56 void
57 fr500_model_insn_after (SIM_CPU *cpu, int last_p, int cycles)
59 if (last_p)
61 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
62 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
63 ps->prev_gr_complex = ps->cur_gr_complex;
64 d->prev_fpop = d->cur_fpop;
65 d->prev_media = d->cur_media;
66 d->prev_cc_complex = d->cur_cc_complex;
70 static void
71 set_use_is_fpop (SIM_CPU *cpu, INT fr)
73 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
74 fr500_reset_fr_flags (cpu, (fr));
75 d->cur_fpop |= (((DI)1) << (fr));
78 static void
79 set_use_not_fpop (SIM_CPU *cpu, INT fr)
81 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
82 d->cur_fpop &= ~(((DI)1) << (fr));
85 static int
86 use_is_fpop (SIM_CPU *cpu, INT fr)
88 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
89 return d->prev_fpop & (((DI)1) << (fr));
92 static void
93 set_use_is_media ( SIM_CPU *cpu, INT fr)
95 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
96 fr500_reset_fr_flags (cpu, (fr));
97 d->cur_media |= (((DI)1) << (fr));
100 static void
101 set_use_not_media (SIM_CPU *cpu, INT fr)
103 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
104 d->cur_media &= ~(((DI)1) << (fr));
107 static int
108 use_is_media (SIM_CPU *cpu, INT fr)
110 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
111 return d->prev_media & (((DI)1) << (fr));
114 static void
115 set_use_is_cc_complex (SIM_CPU *cpu, INT cc)
117 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
118 fr500_reset_cc_flags (cpu, cc);
119 d->cur_cc_complex |= (((DI)1) << (cc));
122 static void
123 set_use_not_cc_complex (SIM_CPU *cpu, INT cc)
125 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
126 d->cur_cc_complex &= ~(((DI)1) << (cc));
129 #if 0
130 static int
131 use_is_cc_complex (SIM_CPU *cpu, INT cc)
133 MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
134 return d->prev_cc_complex & (((DI)1) << (cc));
136 #endif
138 void
139 fr500_reset_fr_flags (SIM_CPU *cpu, INT fr)
141 set_use_not_fpop (cpu, fr);
142 set_use_not_media (cpu, fr);
145 void
146 fr500_reset_cc_flags (SIM_CPU *cpu, INT cc)
148 set_use_not_cc_complex (cpu, cc);
151 /* Latency of floating point registers may be less than recorded when followed
152 by another floating point insn. */
153 static void
154 adjust_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
155 int cycles)
157 /* If the registers were previously used in a floating point op,
158 then their latency will be less than previously recorded.
159 See Table 13-13 in the LSI. */
160 if (in_FRi >= 0)
162 if (use_is_fpop (cpu, in_FRi))
163 decrease_FR_busy (cpu, in_FRi, cycles);
164 else
165 enforce_full_fr_latency (cpu, in_FRi);
168 if (in_FRj >= 0 && in_FRj != in_FRi)
170 if (use_is_fpop (cpu, in_FRj))
171 decrease_FR_busy (cpu, in_FRj, cycles);
172 else
173 enforce_full_fr_latency (cpu, in_FRj);
176 if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
178 if (use_is_fpop (cpu, out_FRk))
179 decrease_FR_busy (cpu, out_FRk, cycles);
180 else
181 enforce_full_fr_latency (cpu, out_FRk);
185 /* Latency of floating point registers may be less than recorded when followed
186 by another floating point insn. */
187 static void
188 adjust_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
189 int cycles)
191 /* If the registers were previously used in a floating point op,
192 then their latency will be less than previously recorded.
193 See Table 13-13 in the LSI. */
194 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
195 if (in_FRi >= 0) ++in_FRi;
196 if (in_FRj >= 0) ++in_FRj;
197 if (out_FRk >= 0) ++out_FRk;
198 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
201 /* Latency of floating point registers is less than recorded when followed
202 by another floating point insn. */
203 static void
204 restore_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
205 int cycles)
207 /* If the registers were previously used in a floating point op,
208 then their latency will be less than previously recorded.
209 See Table 13-13 in the LSI. */
210 if (in_FRi >= 0 && use_is_fpop (cpu, in_FRi))
211 increase_FR_busy (cpu, in_FRi, cycles);
212 if (in_FRj != in_FRi && use_is_fpop (cpu, in_FRj))
213 increase_FR_busy (cpu, in_FRj, cycles);
214 if (out_FRk != in_FRi && out_FRk != in_FRj && use_is_fpop (cpu, out_FRk))
215 increase_FR_busy (cpu, out_FRk, cycles);
218 /* Latency of floating point registers is less than recorded when followed
219 by another floating point insn. */
220 static void
221 restore_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
222 int cycles)
224 /* If the registers were previously used in a floating point op,
225 then their latency will be less than previously recorded.
226 See Table 13-13 in the LSI. */
227 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
228 if (in_FRi >= 0) ++in_FRi;
229 if (in_FRj >= 0) ++in_FRj;
230 if (out_FRk >= 0) ++out_FRk;
231 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
235 frvbf_model_fr500_u_exec (SIM_CPU *cpu, const IDESC *idesc,
236 int unit_num, int referenced)
238 return idesc->timing->units[unit_num].done;
242 frvbf_model_fr500_u_integer (SIM_CPU *cpu, const IDESC *idesc,
243 int unit_num, int referenced,
244 INT in_GRi, INT in_GRj, INT out_GRk,
245 INT out_ICCi_1)
247 int cycles;
249 if (model_insn == FRV_INSN_MODEL_PASS_1)
251 /* icc0-icc4 are the upper 4 fields of the CCR. */
252 if (out_ICCi_1 >= 0)
253 out_ICCi_1 += 4;
255 /* The entire VLIW insn must wait if there is a dependency on a register
256 which is not ready yet.
257 The latency of the registers may be less than previously recorded,
258 depending on how they were used previously.
259 See Table 13-8 in the LSI. */
260 if (in_GRi != out_GRk && in_GRi >= 0)
262 if (use_is_gr_complex (cpu, in_GRi))
263 decrease_GR_busy (cpu, in_GRi, 1);
265 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
267 if (use_is_gr_complex (cpu, in_GRj))
268 decrease_GR_busy (cpu, in_GRj, 1);
270 vliw_wait_for_GR (cpu, in_GRi);
271 vliw_wait_for_GR (cpu, in_GRj);
272 vliw_wait_for_GR (cpu, out_GRk);
273 vliw_wait_for_CCR (cpu, out_ICCi_1);
274 handle_resource_wait (cpu);
275 load_wait_for_GR (cpu, in_GRi);
276 load_wait_for_GR (cpu, in_GRj);
277 load_wait_for_GR (cpu, out_GRk);
278 trace_vliw_wait_cycles (cpu);
279 return 0;
282 /* GRk is available immediately to the next VLIW insn as is ICCi_1. */
283 cycles = idesc->timing->units[unit_num].done;
284 return cycles;
288 frvbf_model_fr500_u_imul (SIM_CPU *cpu, const IDESC *idesc,
289 int unit_num, int referenced,
290 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
292 int cycles;
293 /* icc0-icc4 are the upper 4 fields of the CCR. */
294 if (out_ICCi_1 >= 0)
295 out_ICCi_1 += 4;
297 if (model_insn == FRV_INSN_MODEL_PASS_1)
299 /* The entire VLIW insn must wait if there is a dependency on a register
300 which is not ready yet.
301 The latency of the registers may be less than previously recorded,
302 depending on how they were used previously.
303 See Table 13-8 in the LSI. */
304 if (in_GRi != out_GRk && in_GRi >= 0)
306 if (use_is_gr_complex (cpu, in_GRi))
307 decrease_GR_busy (cpu, in_GRi, 1);
309 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
311 if (use_is_gr_complex (cpu, in_GRj))
312 decrease_GR_busy (cpu, in_GRj, 1);
314 vliw_wait_for_GR (cpu, in_GRi);
315 vliw_wait_for_GR (cpu, in_GRj);
316 vliw_wait_for_GRdouble (cpu, out_GRk);
317 vliw_wait_for_CCR (cpu, out_ICCi_1);
318 handle_resource_wait (cpu);
319 load_wait_for_GR (cpu, in_GRi);
320 load_wait_for_GR (cpu, in_GRj);
321 load_wait_for_GRdouble (cpu, out_GRk);
322 trace_vliw_wait_cycles (cpu);
323 return 0;
326 /* GRk has a latency of 2 cycles. */
327 cycles = idesc->timing->units[unit_num].done;
328 update_GRdouble_latency (cpu, out_GRk, cycles + 2);
329 set_use_is_gr_complex (cpu, out_GRk);
330 set_use_is_gr_complex (cpu, out_GRk + 1);
332 /* ICCi_1 has a latency of 1 cycle. */
333 update_CCR_latency (cpu, out_ICCi_1, cycles + 1);
335 return cycles;
339 frvbf_model_fr500_u_idiv (SIM_CPU *cpu, const IDESC *idesc,
340 int unit_num, int referenced,
341 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
343 int cycles;
344 FRV_VLIW *vliw;
345 int slot;
347 /* icc0-icc4 are the upper 4 fields of the CCR. */
348 if (out_ICCi_1 >= 0)
349 out_ICCi_1 += 4;
351 vliw = CPU_VLIW (cpu);
352 slot = vliw->next_slot - 1;
353 slot = (*vliw->current_vliw)[slot] - UNIT_I0;
355 if (model_insn == FRV_INSN_MODEL_PASS_1)
357 /* The entire VLIW insn must wait if there is a dependency on a register
358 which is not ready yet.
359 The latency of the registers may be less than previously recorded,
360 depending on how they were used previously.
361 See Table 13-8 in the LSI. */
362 if (in_GRi != out_GRk && in_GRi >= 0)
364 if (use_is_gr_complex (cpu, in_GRi))
365 decrease_GR_busy (cpu, in_GRi, 1);
367 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
369 if (use_is_gr_complex (cpu, in_GRj))
370 decrease_GR_busy (cpu, in_GRj, 1);
372 vliw_wait_for_GR (cpu, in_GRi);
373 vliw_wait_for_GR (cpu, in_GRj);
374 vliw_wait_for_GR (cpu, out_GRk);
375 vliw_wait_for_CCR (cpu, out_ICCi_1);
376 vliw_wait_for_idiv_resource (cpu, slot);
377 handle_resource_wait (cpu);
378 load_wait_for_GR (cpu, in_GRi);
379 load_wait_for_GR (cpu, in_GRj);
380 load_wait_for_GR (cpu, out_GRk);
381 trace_vliw_wait_cycles (cpu);
382 return 0;
385 /* GRk has a latency of 19 cycles! */
386 cycles = idesc->timing->units[unit_num].done;
387 update_GR_latency (cpu, out_GRk, cycles + 19);
388 set_use_is_gr_complex (cpu, out_GRk);
390 /* ICCi_1 has a latency of 19 cycles. */
391 update_CCR_latency (cpu, out_ICCi_1, cycles + 19);
392 set_use_is_cc_complex (cpu, out_ICCi_1);
394 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
396 /* GNER has a latency of 18 cycles. */
397 update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 18);
400 /* the idiv resource has a latency of 18 cycles! */
401 update_idiv_resource_latency (cpu, slot, cycles + 18);
403 return cycles;
407 frvbf_model_fr500_u_branch (SIM_CPU *cpu, const IDESC *idesc,
408 int unit_num, int referenced,
409 INT in_GRi, INT in_GRj,
410 INT in_ICCi_2, INT in_FCCi_2)
412 int cycles;
413 FRV_PROFILE_STATE *ps;
415 if (model_insn == FRV_INSN_MODEL_PASS_1)
417 /* icc0-icc4 are the upper 4 fields of the CCR. */
418 if (in_ICCi_2 >= 0)
419 in_ICCi_2 += 4;
421 /* The entire VLIW insn must wait if there is a dependency on a register
422 which is not ready yet.
423 The latency of the registers may be less than previously recorded,
424 depending on how they were used previously.
425 See Table 13-8 in the LSI. */
426 if (in_GRi >= 0)
428 if (use_is_gr_complex (cpu, in_GRi))
429 decrease_GR_busy (cpu, in_GRi, 1);
431 if (in_GRj != in_GRi && in_GRj >= 0)
433 if (use_is_gr_complex (cpu, in_GRj))
434 decrease_GR_busy (cpu, in_GRj, 1);
436 vliw_wait_for_GR (cpu, in_GRi);
437 vliw_wait_for_GR (cpu, in_GRj);
438 vliw_wait_for_CCR (cpu, in_ICCi_2);
439 vliw_wait_for_CCR (cpu, in_FCCi_2);
440 handle_resource_wait (cpu);
441 load_wait_for_GR (cpu, in_GRi);
442 load_wait_for_GR (cpu, in_GRj);
443 trace_vliw_wait_cycles (cpu);
444 return 0;
447 /* When counting branches taken or not taken, don't consider branches after
448 the first taken branch in a vliw insn. */
449 ps = CPU_PROFILE_STATE (cpu);
450 if (! ps->vliw_branch_taken)
452 /* (1 << 4): The pc is the 5th element in inputs, outputs.
453 ??? can be cleaned up */
454 PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
455 int taken = (referenced & (1 << 4)) != 0;
456 if (taken)
458 ++PROFILE_MODEL_TAKEN_COUNT (p);
459 ps->vliw_branch_taken = 1;
461 else
462 ++PROFILE_MODEL_UNTAKEN_COUNT (p);
465 cycles = idesc->timing->units[unit_num].done;
466 return cycles;
470 frvbf_model_fr500_u_trap (SIM_CPU *cpu, const IDESC *idesc,
471 int unit_num, int referenced,
472 INT in_GRi, INT in_GRj,
473 INT in_ICCi_2, INT in_FCCi_2)
475 int cycles;
477 if (model_insn == FRV_INSN_MODEL_PASS_1)
479 /* icc0-icc4 are the upper 4 fields of the CCR. */
480 if (in_ICCi_2 >= 0)
481 in_ICCi_2 += 4;
483 /* The entire VLIW insn must wait if there is a dependency on a register
484 which is not ready yet.
485 The latency of the registers may be less than previously recorded,
486 depending on how they were used previously.
487 See Table 13-8 in the LSI. */
488 if (in_GRi >= 0)
490 if (use_is_gr_complex (cpu, in_GRi))
491 decrease_GR_busy (cpu, in_GRi, 1);
493 if (in_GRj != in_GRi && in_GRj >= 0)
495 if (use_is_gr_complex (cpu, in_GRj))
496 decrease_GR_busy (cpu, in_GRj, 1);
498 vliw_wait_for_GR (cpu, in_GRi);
499 vliw_wait_for_GR (cpu, in_GRj);
500 vliw_wait_for_CCR (cpu, in_ICCi_2);
501 vliw_wait_for_CCR (cpu, in_FCCi_2);
502 handle_resource_wait (cpu);
503 load_wait_for_GR (cpu, in_GRi);
504 load_wait_for_GR (cpu, in_GRj);
505 trace_vliw_wait_cycles (cpu);
506 return 0;
509 cycles = idesc->timing->units[unit_num].done;
510 return cycles;
514 frvbf_model_fr500_u_check (SIM_CPU *cpu, const IDESC *idesc,
515 int unit_num, int referenced,
516 INT in_ICCi_3, INT in_FCCi_3)
518 int cycles;
520 if (model_insn == FRV_INSN_MODEL_PASS_1)
522 /* icc0-icc4 are the upper 4 fields of the CCR. */
523 if (in_ICCi_3 >= 0)
524 in_ICCi_3 += 4;
526 /* The entire VLIW insn must wait if there is a dependency on a register
527 which is not ready yet. */
528 vliw_wait_for_CCR (cpu, in_ICCi_3);
529 vliw_wait_for_CCR (cpu, in_FCCi_3);
530 handle_resource_wait (cpu);
531 trace_vliw_wait_cycles (cpu);
532 return 0;
535 cycles = idesc->timing->units[unit_num].done;
536 return cycles;
540 frvbf_model_fr500_u_clrgr (SIM_CPU *cpu, const IDESC *idesc,
541 int unit_num, int referenced,
542 INT in_GRk)
544 int cycles;
546 if (model_insn == FRV_INSN_MODEL_PASS_1)
548 /* Wait for both GNER registers or just the one specified. */
549 if (in_GRk == -1)
551 vliw_wait_for_SPR (cpu, H_SPR_GNER0);
552 vliw_wait_for_SPR (cpu, H_SPR_GNER1);
554 else
555 vliw_wait_for_SPR (cpu, GNER_FOR_GR (in_GRk));
556 handle_resource_wait (cpu);
557 trace_vliw_wait_cycles (cpu);
558 return 0;
561 cycles = idesc->timing->units[unit_num].done;
562 return cycles;
566 frvbf_model_fr500_u_clrfr (SIM_CPU *cpu, const IDESC *idesc,
567 int unit_num, int referenced,
568 INT in_FRk)
570 int cycles;
572 if (model_insn == FRV_INSN_MODEL_PASS_1)
574 /* Wait for both GNER registers or just the one specified. */
575 if (in_FRk == -1)
577 vliw_wait_for_SPR (cpu, H_SPR_FNER0);
578 vliw_wait_for_SPR (cpu, H_SPR_FNER1);
580 else
581 vliw_wait_for_SPR (cpu, FNER_FOR_FR (in_FRk));
582 handle_resource_wait (cpu);
583 trace_vliw_wait_cycles (cpu);
584 return 0;
587 cycles = idesc->timing->units[unit_num].done;
588 return cycles;
592 frvbf_model_fr500_u_commit (SIM_CPU *cpu, const IDESC *idesc,
593 int unit_num, int referenced,
594 INT in_GRk, INT in_FRk)
596 int cycles;
598 if (model_insn == FRV_INSN_MODEL_PASS_1)
600 /* If GR is specified, then FR is not and vice-versa. If neither is
601 then it's a commitga or commitfa. Check the insn attribute to
602 figure out which. */
603 if (in_GRk != -1)
604 vliw_wait_for_SPR (cpu, GNER_FOR_GR (in_GRk));
605 else if (in_FRk != -1)
606 vliw_wait_for_SPR (cpu, FNER_FOR_FR (in_FRk));
607 else if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_FR_ACCESS))
609 vliw_wait_for_SPR (cpu, H_SPR_FNER0);
610 vliw_wait_for_SPR (cpu, H_SPR_FNER1);
612 else
614 vliw_wait_for_SPR (cpu, H_SPR_GNER0);
615 vliw_wait_for_SPR (cpu, H_SPR_GNER1);
617 handle_resource_wait (cpu);
618 trace_vliw_wait_cycles (cpu);
619 return 0;
622 cycles = idesc->timing->units[unit_num].done;
623 return cycles;
627 frvbf_model_fr500_u_set_hilo (SIM_CPU *cpu, const IDESC *idesc,
628 int unit_num, int referenced,
629 INT out_GRkhi, INT out_GRklo)
631 int cycles;
633 if (model_insn == FRV_INSN_MODEL_PASS_1)
635 /* The entire VLIW insn must wait if there is a dependency on a GR
636 which is not ready yet. */
637 vliw_wait_for_GR (cpu, out_GRkhi);
638 vliw_wait_for_GR (cpu, out_GRklo);
639 handle_resource_wait (cpu);
640 load_wait_for_GR (cpu, out_GRkhi);
641 load_wait_for_GR (cpu, out_GRklo);
642 trace_vliw_wait_cycles (cpu);
643 return 0;
646 /* GRk is available immediately to the next VLIW insn. */
647 cycles = idesc->timing->units[unit_num].done;
649 set_use_not_gr_complex (cpu, out_GRkhi);
650 set_use_not_gr_complex (cpu, out_GRklo);
652 return cycles;
656 frvbf_model_fr500_u_gr_load (SIM_CPU *cpu, const IDESC *idesc,
657 int unit_num, int referenced,
658 INT in_GRi, INT in_GRj,
659 INT out_GRk, INT out_GRdoublek)
661 int cycles;
663 if (model_insn == FRV_INSN_MODEL_PASS_1)
665 /* The entire VLIW insn must wait if there is a dependency on a register
666 which is not ready yet.
667 The latency of the registers may be less than previously recorded,
668 depending on how they were used previously.
669 See Table 13-8 in the LSI. */
670 if (in_GRi != out_GRk && in_GRi != out_GRdoublek
671 && in_GRi != out_GRdoublek + 1 && in_GRi >= 0)
673 if (use_is_gr_complex (cpu, in_GRi))
674 decrease_GR_busy (cpu, in_GRi, 1);
676 if (in_GRj != in_GRi && in_GRj != out_GRk && in_GRj != out_GRdoublek
677 && in_GRj != out_GRdoublek + 1 && in_GRj >= 0)
680 if (use_is_gr_complex (cpu, in_GRj))
681 decrease_GR_busy (cpu, in_GRj, 1);
683 vliw_wait_for_GR (cpu, in_GRi);
684 vliw_wait_for_GR (cpu, in_GRj);
685 vliw_wait_for_GR (cpu, out_GRk);
686 vliw_wait_for_GRdouble (cpu, out_GRdoublek);
687 handle_resource_wait (cpu);
688 load_wait_for_GR (cpu, in_GRi);
689 load_wait_for_GR (cpu, in_GRj);
690 load_wait_for_GR (cpu, out_GRk);
691 load_wait_for_GRdouble (cpu, out_GRdoublek);
692 trace_vliw_wait_cycles (cpu);
693 return 0;
696 cycles = idesc->timing->units[unit_num].done;
698 /* The latency of GRk for a load will depend on how long it takes to retrieve
699 the the data from the cache or memory. */
700 update_GR_latency_for_load (cpu, out_GRk, cycles);
701 update_GRdouble_latency_for_load (cpu, out_GRdoublek, cycles);
703 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
705 /* GNER has a latency of 2 cycles. */
706 update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 2);
707 update_SPR_latency (cpu, GNER_FOR_GR (out_GRdoublek), cycles + 2);
710 if (out_GRk >= 0)
711 set_use_is_gr_complex (cpu, out_GRk);
712 if (out_GRdoublek != -1)
714 set_use_is_gr_complex (cpu, out_GRdoublek);
715 set_use_is_gr_complex (cpu, out_GRdoublek + 1);
718 return cycles;
722 frvbf_model_fr500_u_gr_store (SIM_CPU *cpu, const IDESC *idesc,
723 int unit_num, int referenced,
724 INT in_GRi, INT in_GRj,
725 INT in_GRk, INT in_GRdoublek)
727 int cycles;
729 if (model_insn == FRV_INSN_MODEL_PASS_1)
731 /* The entire VLIW insn must wait if there is a dependency on a register
732 which is not ready yet.
733 The latency of the registers may be less than previously recorded,
734 depending on how they were used previously.
735 See Table 13-8 in the LSI. */
736 if (in_GRi >= 0)
738 if (use_is_gr_complex (cpu, in_GRi))
739 decrease_GR_busy (cpu, in_GRi, 1);
741 if (in_GRj != in_GRi && in_GRj >= 0)
743 if (use_is_gr_complex (cpu, in_GRj))
744 decrease_GR_busy (cpu, in_GRj, 1);
746 if (in_GRk != in_GRi && in_GRk != in_GRj && in_GRk >= 0)
748 if (use_is_gr_complex (cpu, in_GRk))
749 decrease_GR_busy (cpu, in_GRk, 1);
751 if (in_GRdoublek != in_GRi && in_GRdoublek != in_GRj
752 && in_GRdoublek + 1 != in_GRi && in_GRdoublek + 1 != in_GRj
753 && in_GRdoublek >= 0)
755 if (use_is_gr_complex (cpu, in_GRdoublek))
756 decrease_GR_busy (cpu, in_GRdoublek, 1);
757 if (use_is_gr_complex (cpu, in_GRdoublek + 1))
758 decrease_GR_busy (cpu, in_GRdoublek + 1, 1);
760 vliw_wait_for_GR (cpu, in_GRi);
761 vliw_wait_for_GR (cpu, in_GRj);
762 vliw_wait_for_GR (cpu, in_GRk);
763 vliw_wait_for_GRdouble (cpu, in_GRdoublek);
764 handle_resource_wait (cpu);
765 load_wait_for_GR (cpu, in_GRi);
766 load_wait_for_GR (cpu, in_GRj);
767 load_wait_for_GR (cpu, in_GRk);
768 load_wait_for_GRdouble (cpu, in_GRdoublek);
769 trace_vliw_wait_cycles (cpu);
770 return 0;
773 cycles = idesc->timing->units[unit_num].done;
775 return cycles;
779 frvbf_model_fr500_u_gr_r_store (SIM_CPU *cpu, const IDESC *idesc,
780 int unit_num, int referenced,
781 INT in_GRi, INT in_GRj,
782 INT in_GRk, INT in_GRdoublek)
784 int cycles = frvbf_model_fr500_u_gr_store (cpu, idesc, unit_num, referenced,
785 in_GRi, in_GRj, in_GRk,
786 in_GRdoublek);
788 if (model_insn == FRV_INSN_MODEL_PASS_2)
790 if (CPU_RSTR_INVALIDATE(cpu))
791 request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
794 return cycles;
798 frvbf_model_fr500_u_fr_load (SIM_CPU *cpu, const IDESC *idesc,
799 int unit_num, int referenced,
800 INT in_GRi, INT in_GRj,
801 INT out_FRk, INT out_FRdoublek)
803 int cycles;
805 if (model_insn == FRV_INSN_MODEL_PASS_1)
807 /* The entire VLIW insn must wait if there is a dependency on a register
808 which is not ready yet.
809 The latency of the registers may be less than previously recorded,
810 depending on how they were used previously.
811 See Table 13-8 in the LSI. */
812 if (in_GRi >= 0)
814 if (use_is_gr_complex (cpu, in_GRi))
815 decrease_GR_busy (cpu, in_GRi, 1);
817 if (in_GRj != in_GRi && in_GRj >= 0)
819 if (use_is_gr_complex (cpu, in_GRj))
820 decrease_GR_busy (cpu, in_GRj, 1);
822 if (out_FRk >= 0)
824 if (use_is_media (cpu, out_FRk))
825 decrease_FR_busy (cpu, out_FRk, 1);
826 else
827 adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
829 if (out_FRdoublek >= 0)
831 if (use_is_media (cpu, out_FRdoublek))
832 decrease_FR_busy (cpu, out_FRdoublek, 1);
833 else
834 adjust_float_register_busy (cpu, -1, -1, out_FRdoublek, 1);
835 if (use_is_media (cpu, out_FRdoublek + 1))
836 decrease_FR_busy (cpu, out_FRdoublek + 1, 1);
837 else
838 adjust_float_register_busy (cpu, -1, -1, out_FRdoublek + 1, 1);
840 vliw_wait_for_GR (cpu, in_GRi);
841 vliw_wait_for_GR (cpu, in_GRj);
842 vliw_wait_for_FR (cpu, out_FRk);
843 vliw_wait_for_FRdouble (cpu, out_FRdoublek);
844 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
846 vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
847 vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
849 handle_resource_wait (cpu);
850 load_wait_for_GR (cpu, in_GRi);
851 load_wait_for_GR (cpu, in_GRj);
852 load_wait_for_FR (cpu, out_FRk);
853 load_wait_for_FRdouble (cpu, out_FRdoublek);
854 trace_vliw_wait_cycles (cpu);
855 return 0;
858 cycles = idesc->timing->units[unit_num].done;
860 /* The latency of FRk for a load will depend on how long it takes to retrieve
861 the the data from the cache or memory. */
862 update_FR_latency_for_load (cpu, out_FRk, cycles);
863 update_FRdouble_latency_for_load (cpu, out_FRdoublek, cycles);
865 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
867 /* FNER has a latency of 3 cycles. */
868 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), cycles + 3);
869 update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), cycles + 3);
872 fr500_reset_fr_flags (cpu, out_FRk);
874 return cycles;
878 frvbf_model_fr500_u_fr_store (SIM_CPU *cpu, const IDESC *idesc,
879 int unit_num, int referenced,
880 INT in_GRi, INT in_GRj,
881 INT in_FRk, INT in_FRdoublek)
883 int cycles;
885 if (model_insn == FRV_INSN_MODEL_PASS_1)
887 /* The entire VLIW insn must wait if there is a dependency on a register
888 which is not ready yet.
889 The latency of the registers may be less than previously recorded,
890 depending on how they were used previously.
891 See Table 13-8 in the LSI. */
892 if (in_GRi >= 0)
894 if (use_is_gr_complex (cpu, in_GRi))
895 decrease_GR_busy (cpu, in_GRi, 1);
897 if (in_GRj != in_GRi && in_GRj >= 0)
899 if (use_is_gr_complex (cpu, in_GRj))
900 decrease_GR_busy (cpu, in_GRj, 1);
902 if (in_FRk >= 0)
904 if (use_is_media (cpu, in_FRk))
905 decrease_FR_busy (cpu, in_FRk, 1);
906 else
907 adjust_float_register_busy (cpu, -1, -1, in_FRk, 1);
909 if (in_FRdoublek >= 0)
911 if (use_is_media (cpu, in_FRdoublek))
912 decrease_FR_busy (cpu, in_FRdoublek, 1);
913 else
914 adjust_float_register_busy (cpu, -1, -1, in_FRdoublek, 1);
915 if (use_is_media (cpu, in_FRdoublek + 1))
916 decrease_FR_busy (cpu, in_FRdoublek + 1, 1);
917 else
918 adjust_float_register_busy (cpu, -1, -1, in_FRdoublek + 1, 1);
920 vliw_wait_for_GR (cpu, in_GRi);
921 vliw_wait_for_GR (cpu, in_GRj);
922 vliw_wait_for_FR (cpu, in_FRk);
923 vliw_wait_for_FRdouble (cpu, in_FRdoublek);
924 handle_resource_wait (cpu);
925 load_wait_for_GR (cpu, in_GRi);
926 load_wait_for_GR (cpu, in_GRj);
927 load_wait_for_FR (cpu, in_FRk);
928 load_wait_for_FRdouble (cpu, in_FRdoublek);
929 trace_vliw_wait_cycles (cpu);
930 return 0;
933 cycles = idesc->timing->units[unit_num].done;
935 return cycles;
939 frvbf_model_fr500_u_fr_r_store (SIM_CPU *cpu, const IDESC *idesc,
940 int unit_num, int referenced,
941 INT in_GRi, INT in_GRj,
942 INT in_FRk, INT in_FRdoublek)
944 int cycles = frvbf_model_fr500_u_fr_store (cpu, idesc, unit_num, referenced,
945 in_GRi, in_GRj, in_FRk,
946 in_FRdoublek);
948 if (model_insn == FRV_INSN_MODEL_PASS_2)
950 if (CPU_RSTR_INVALIDATE(cpu))
951 request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
954 return cycles;
958 frvbf_model_fr500_u_swap (SIM_CPU *cpu, const IDESC *idesc,
959 int unit_num, int referenced,
960 INT in_GRi, INT in_GRj, INT out_GRk)
962 int cycles;
964 if (model_insn == FRV_INSN_MODEL_PASS_1)
966 /* The entire VLIW insn must wait if there is a dependency on a register
967 which is not ready yet.
968 The latency of the registers may be less than previously recorded,
969 depending on how they were used previously.
970 See Table 13-8 in the LSI. */
971 if (in_GRi != out_GRk && in_GRi >= 0)
973 if (use_is_gr_complex (cpu, in_GRi))
974 decrease_GR_busy (cpu, in_GRi, 1);
976 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
978 if (use_is_gr_complex (cpu, in_GRj))
979 decrease_GR_busy (cpu, in_GRj, 1);
981 vliw_wait_for_GR (cpu, in_GRi);
982 vliw_wait_for_GR (cpu, in_GRj);
983 vliw_wait_for_GR (cpu, out_GRk);
984 handle_resource_wait (cpu);
985 load_wait_for_GR (cpu, in_GRi);
986 load_wait_for_GR (cpu, in_GRj);
987 load_wait_for_GR (cpu, out_GRk);
988 trace_vliw_wait_cycles (cpu);
989 return 0;
992 cycles = idesc->timing->units[unit_num].done;
994 /* The latency of GRk will depend on how long it takes to swap
995 the the data from the cache or memory. */
996 update_GR_latency_for_swap (cpu, out_GRk, cycles);
997 set_use_is_gr_complex (cpu, out_GRk);
999 return cycles;
1003 frvbf_model_fr500_u_fr2fr (SIM_CPU *cpu, const IDESC *idesc,
1004 int unit_num, int referenced,
1005 INT in_FRj, INT out_FRk)
1007 int cycles;
1009 if (model_insn == FRV_INSN_MODEL_PASS_1)
1011 /* The entire VLIW insn must wait if there is a dependency on a register
1012 which is not ready yet. */
1013 if (in_FRj >= 0)
1015 if (use_is_media (cpu, in_FRj))
1016 decrease_FR_busy (cpu, in_FRj, 1);
1017 else
1018 adjust_float_register_busy (cpu, -1, in_FRj, -1, 1);
1020 if (out_FRk >= 0 && out_FRk != in_FRj)
1022 if (use_is_media (cpu, out_FRk))
1023 decrease_FR_busy (cpu, out_FRk, 1);
1024 else
1025 adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
1027 vliw_wait_for_FR (cpu, in_FRj);
1028 vliw_wait_for_FR (cpu, out_FRk);
1029 handle_resource_wait (cpu);
1030 load_wait_for_FR (cpu, in_FRj);
1031 load_wait_for_FR (cpu, out_FRk);
1032 trace_vliw_wait_cycles (cpu);
1033 return 0;
1036 /* The latency of FRj is 3 cycles. */
1037 cycles = idesc->timing->units[unit_num].done;
1038 update_FR_latency (cpu, out_FRk, cycles + 3);
1040 return cycles;
1044 frvbf_model_fr500_u_fr2gr (SIM_CPU *cpu, const IDESC *idesc,
1045 int unit_num, int referenced,
1046 INT in_FRk, INT out_GRj)
1048 int cycles;
1050 if (model_insn == FRV_INSN_MODEL_PASS_1)
1052 /* The entire VLIW insn must wait if there is a dependency on a register
1053 which is not ready yet. */
1054 if (in_FRk >= 0)
1056 if (use_is_media (cpu, in_FRk))
1057 decrease_FR_busy (cpu, in_FRk, 1);
1058 else
1059 adjust_float_register_busy (cpu, -1, in_FRk, -1, 1);
1061 vliw_wait_for_FR (cpu, in_FRk);
1062 vliw_wait_for_GR (cpu, out_GRj);
1063 handle_resource_wait (cpu);
1064 load_wait_for_FR (cpu, in_FRk);
1065 load_wait_for_GR (cpu, out_GRj);
1066 trace_vliw_wait_cycles (cpu);
1067 return 0;
1070 /* The latency of GRj is 2 cycles. */
1071 cycles = idesc->timing->units[unit_num].done;
1072 update_GR_latency (cpu, out_GRj, cycles + 2);
1073 set_use_is_gr_complex (cpu, out_GRj);
1075 return cycles;
1079 frvbf_model_fr500_u_spr2gr (SIM_CPU *cpu, const IDESC *idesc,
1080 int unit_num, int referenced,
1081 INT in_spr, INT out_GRj)
1083 int cycles;
1085 if (model_insn == FRV_INSN_MODEL_PASS_1)
1087 /* The entire VLIW insn must wait if there is a dependency on a register
1088 which is not ready yet. */
1089 vliw_wait_for_SPR (cpu, in_spr);
1090 vliw_wait_for_GR (cpu, out_GRj);
1091 handle_resource_wait (cpu);
1092 load_wait_for_GR (cpu, out_GRj);
1093 trace_vliw_wait_cycles (cpu);
1094 return 0;
1097 cycles = idesc->timing->units[unit_num].done;
1099 #if 0 /* no latency? */
1100 /* The latency of GRj is 2 cycles. */
1101 update_GR_latency (cpu, out_GRj, cycles + 2);
1102 #endif
1104 return cycles;
1108 frvbf_model_fr500_u_gr2fr (SIM_CPU *cpu, const IDESC *idesc,
1109 int unit_num, int referenced,
1110 INT in_GRj, INT out_FRk)
1112 int cycles;
1114 if (model_insn == FRV_INSN_MODEL_PASS_1)
1116 /* The entire VLIW insn must wait if there is a dependency on a register
1117 which is not ready yet.
1118 The latency of the registers may be less than previously recorded,
1119 depending on how they were used previously.
1120 See Table 13-8 in the LSI. */
1121 if (in_GRj >= 0)
1123 if (use_is_gr_complex (cpu, in_GRj))
1124 decrease_GR_busy (cpu, in_GRj, 1);
1126 if (out_FRk >= 0)
1128 if (use_is_media (cpu, out_FRk))
1129 decrease_FR_busy (cpu, out_FRk, 1);
1130 else
1131 adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
1133 vliw_wait_for_GR (cpu, in_GRj);
1134 vliw_wait_for_FR (cpu, out_FRk);
1135 handle_resource_wait (cpu);
1136 load_wait_for_GR (cpu, in_GRj);
1137 load_wait_for_FR (cpu, out_FRk);
1138 trace_vliw_wait_cycles (cpu);
1139 return 0;
1142 /* The latency of FRk is 2 cycles. */
1143 cycles = idesc->timing->units[unit_num].done;
1144 update_FR_latency (cpu, out_FRk, cycles + 2);
1146 /* Mark this use of the register as NOT a floating point op. */
1147 fr500_reset_fr_flags (cpu, out_FRk);
1149 return cycles;
1153 frvbf_model_fr500_u_gr2spr (SIM_CPU *cpu, const IDESC *idesc,
1154 int unit_num, int referenced,
1155 INT in_GRj, INT out_spr)
1157 int cycles;
1159 if (model_insn == FRV_INSN_MODEL_PASS_1)
1161 /* The entire VLIW insn must wait if there is a dependency on a register
1162 which is not ready yet.
1163 The latency of the registers may be less than previously recorded,
1164 depending on how they were used previously.
1165 See Table 13-8 in the LSI. */
1166 if (in_GRj >= 0)
1168 if (use_is_gr_complex (cpu, in_GRj))
1169 decrease_GR_busy (cpu, in_GRj, 1);
1171 vliw_wait_for_GR (cpu, in_GRj);
1172 vliw_wait_for_SPR (cpu, out_spr);
1173 handle_resource_wait (cpu);
1174 load_wait_for_GR (cpu, in_GRj);
1175 trace_vliw_wait_cycles (cpu);
1176 return 0;
1179 cycles = idesc->timing->units[unit_num].done;
1181 #if 0
1182 /* The latency of spr is ? cycles. */
1183 update_SPR_latency (cpu, out_spr, cycles + ?);
1184 #endif
1186 return cycles;
1190 frvbf_model_fr500_u_ici (SIM_CPU *cpu, const IDESC *idesc,
1191 int unit_num, int referenced,
1192 INT in_GRi, INT in_GRj)
1194 int cycles;
1196 if (model_insn == FRV_INSN_MODEL_PASS_1)
1198 /* The entire VLIW insn must wait if there is a dependency on a register
1199 which is not ready yet.
1200 The latency of the registers may be less than previously recorded,
1201 depending on how they were used previously.
1202 See Table 13-8 in the LSI. */
1203 if (in_GRi >= 0)
1205 if (use_is_gr_complex (cpu, in_GRi))
1206 decrease_GR_busy (cpu, in_GRi, 1);
1208 if (in_GRj != in_GRi && in_GRj >= 0)
1210 if (use_is_gr_complex (cpu, in_GRj))
1211 decrease_GR_busy (cpu, in_GRj, 1);
1213 vliw_wait_for_GR (cpu, in_GRi);
1214 vliw_wait_for_GR (cpu, in_GRj);
1215 handle_resource_wait (cpu);
1216 load_wait_for_GR (cpu, in_GRi);
1217 load_wait_for_GR (cpu, in_GRj);
1218 trace_vliw_wait_cycles (cpu);
1219 return 0;
1222 cycles = idesc->timing->units[unit_num].done;
1223 request_cache_invalidate (cpu, CPU_INSN_CACHE (cpu), cycles);
1224 return cycles;
1228 frvbf_model_fr500_u_dci (SIM_CPU *cpu, const IDESC *idesc,
1229 int unit_num, int referenced,
1230 INT in_GRi, INT in_GRj)
1232 int cycles;
1234 if (model_insn == FRV_INSN_MODEL_PASS_1)
1236 /* The entire VLIW insn must wait if there is a dependency on a register
1237 which is not ready yet.
1238 The latency of the registers may be less than previously recorded,
1239 depending on how they were used previously.
1240 See Table 13-8 in the LSI. */
1241 if (in_GRi >= 0)
1243 if (use_is_gr_complex (cpu, in_GRi))
1244 decrease_GR_busy (cpu, in_GRi, 1);
1246 if (in_GRj != in_GRi && in_GRj >= 0)
1248 if (use_is_gr_complex (cpu, in_GRj))
1249 decrease_GR_busy (cpu, in_GRj, 1);
1251 vliw_wait_for_GR (cpu, in_GRi);
1252 vliw_wait_for_GR (cpu, in_GRj);
1253 handle_resource_wait (cpu);
1254 load_wait_for_GR (cpu, in_GRi);
1255 load_wait_for_GR (cpu, in_GRj);
1256 trace_vliw_wait_cycles (cpu);
1257 return 0;
1260 cycles = idesc->timing->units[unit_num].done;
1261 request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
1262 return cycles;
1266 frvbf_model_fr500_u_dcf (SIM_CPU *cpu, const IDESC *idesc,
1267 int unit_num, int referenced,
1268 INT in_GRi, INT in_GRj)
1270 int cycles;
1272 if (model_insn == FRV_INSN_MODEL_PASS_1)
1274 /* The entire VLIW insn must wait if there is a dependency on a register
1275 which is not ready yet.
1276 The latency of the registers may be less than previously recorded,
1277 depending on how they were used previously.
1278 See Table 13-8 in the LSI. */
1279 if (in_GRi >= 0)
1281 if (use_is_gr_complex (cpu, in_GRi))
1282 decrease_GR_busy (cpu, in_GRi, 1);
1284 if (in_GRj != in_GRi && in_GRj >= 0)
1286 if (use_is_gr_complex (cpu, in_GRj))
1287 decrease_GR_busy (cpu, in_GRj, 1);
1289 vliw_wait_for_GR (cpu, in_GRi);
1290 vliw_wait_for_GR (cpu, in_GRj);
1291 handle_resource_wait (cpu);
1292 load_wait_for_GR (cpu, in_GRi);
1293 load_wait_for_GR (cpu, in_GRj);
1294 trace_vliw_wait_cycles (cpu);
1295 return 0;
1298 cycles = idesc->timing->units[unit_num].done;
1299 request_cache_flush (cpu, CPU_DATA_CACHE (cpu), cycles);
1300 return cycles;
1304 frvbf_model_fr500_u_icpl (SIM_CPU *cpu, const IDESC *idesc,
1305 int unit_num, int referenced,
1306 INT in_GRi, INT in_GRj)
1308 int cycles;
1310 if (model_insn == FRV_INSN_MODEL_PASS_1)
1312 /* The entire VLIW insn must wait if there is a dependency on a register
1313 which is not ready yet.
1314 The latency of the registers may be less than previously recorded,
1315 depending on how they were used previously.
1316 See Table 13-8 in the LSI. */
1317 if (in_GRi >= 0)
1319 if (use_is_gr_complex (cpu, in_GRi))
1320 decrease_GR_busy (cpu, in_GRi, 1);
1322 if (in_GRj != in_GRi && in_GRj >= 0)
1324 if (use_is_gr_complex (cpu, in_GRj))
1325 decrease_GR_busy (cpu, in_GRj, 1);
1327 vliw_wait_for_GR (cpu, in_GRi);
1328 vliw_wait_for_GR (cpu, in_GRj);
1329 handle_resource_wait (cpu);
1330 load_wait_for_GR (cpu, in_GRi);
1331 load_wait_for_GR (cpu, in_GRj);
1332 trace_vliw_wait_cycles (cpu);
1333 return 0;
1336 cycles = idesc->timing->units[unit_num].done;
1337 request_cache_preload (cpu, CPU_INSN_CACHE (cpu), cycles);
1338 return cycles;
1342 frvbf_model_fr500_u_dcpl (SIM_CPU *cpu, const IDESC *idesc,
1343 int unit_num, int referenced,
1344 INT in_GRi, INT in_GRj)
1346 int cycles;
1348 if (model_insn == FRV_INSN_MODEL_PASS_1)
1350 /* The entire VLIW insn must wait if there is a dependency on a register
1351 which is not ready yet.
1352 The latency of the registers may be less than previously recorded,
1353 depending on how they were used previously.
1354 See Table 13-8 in the LSI. */
1355 if (in_GRi >= 0)
1357 if (use_is_gr_complex (cpu, in_GRi))
1358 decrease_GR_busy (cpu, in_GRi, 1);
1360 if (in_GRj != in_GRi && in_GRj >= 0)
1362 if (use_is_gr_complex (cpu, in_GRj))
1363 decrease_GR_busy (cpu, in_GRj, 1);
1365 vliw_wait_for_GR (cpu, in_GRi);
1366 vliw_wait_for_GR (cpu, in_GRj);
1367 handle_resource_wait (cpu);
1368 load_wait_for_GR (cpu, in_GRi);
1369 load_wait_for_GR (cpu, in_GRj);
1370 trace_vliw_wait_cycles (cpu);
1371 return 0;
1374 cycles = idesc->timing->units[unit_num].done;
1375 request_cache_preload (cpu, CPU_DATA_CACHE (cpu), cycles);
1376 return cycles;
1380 frvbf_model_fr500_u_icul (SIM_CPU *cpu, const IDESC *idesc,
1381 int unit_num, int referenced,
1382 INT in_GRi, INT in_GRj)
1384 int cycles;
1386 if (model_insn == FRV_INSN_MODEL_PASS_1)
1388 /* The entire VLIW insn must wait if there is a dependency on a register
1389 which is not ready yet.
1390 The latency of the registers may be less than previously recorded,
1391 depending on how they were used previously.
1392 See Table 13-8 in the LSI. */
1393 if (in_GRi >= 0)
1395 if (use_is_gr_complex (cpu, in_GRi))
1396 decrease_GR_busy (cpu, in_GRi, 1);
1398 if (in_GRj != in_GRi && in_GRj >= 0)
1400 if (use_is_gr_complex (cpu, in_GRj))
1401 decrease_GR_busy (cpu, in_GRj, 1);
1403 vliw_wait_for_GR (cpu, in_GRi);
1404 vliw_wait_for_GR (cpu, in_GRj);
1405 handle_resource_wait (cpu);
1406 load_wait_for_GR (cpu, in_GRi);
1407 load_wait_for_GR (cpu, in_GRj);
1408 trace_vliw_wait_cycles (cpu);
1409 return 0;
1412 cycles = idesc->timing->units[unit_num].done;
1413 request_cache_unlock (cpu, CPU_INSN_CACHE (cpu), cycles);
1414 return cycles;
1418 frvbf_model_fr500_u_dcul (SIM_CPU *cpu, const IDESC *idesc,
1419 int unit_num, int referenced,
1420 INT in_GRi, INT in_GRj)
1422 int cycles;
1424 if (model_insn == FRV_INSN_MODEL_PASS_1)
1426 /* The entire VLIW insn must wait if there is a dependency on a register
1427 which is not ready yet.
1428 The latency of the registers may be less than previously recorded,
1429 depending on how they were used previously.
1430 See Table 13-8 in the LSI. */
1431 if (in_GRi >= 0)
1433 if (use_is_gr_complex (cpu, in_GRi))
1434 decrease_GR_busy (cpu, in_GRi, 1);
1436 if (in_GRj != in_GRi && in_GRj >= 0)
1438 if (use_is_gr_complex (cpu, in_GRj))
1439 decrease_GR_busy (cpu, in_GRj, 1);
1441 vliw_wait_for_GR (cpu, in_GRi);
1442 vliw_wait_for_GR (cpu, in_GRj);
1443 handle_resource_wait (cpu);
1444 load_wait_for_GR (cpu, in_GRi);
1445 load_wait_for_GR (cpu, in_GRj);
1446 trace_vliw_wait_cycles (cpu);
1447 return 0;
1450 cycles = idesc->timing->units[unit_num].done;
1451 request_cache_unlock (cpu, CPU_DATA_CACHE (cpu), cycles);
1452 return cycles;
1456 frvbf_model_fr500_u_float_arith (SIM_CPU *cpu, const IDESC *idesc,
1457 int unit_num, int referenced,
1458 INT in_FRi, INT in_FRj,
1459 INT in_FRdoublei, INT in_FRdoublej,
1460 INT out_FRk, INT out_FRdoublek)
1462 int cycles;
1463 FRV_PROFILE_STATE *ps;
1465 if (model_insn == FRV_INSN_MODEL_PASS_1)
1466 return 0;
1468 /* The preprocessing can execute right away. */
1469 cycles = idesc->timing->units[unit_num].done;
1471 /* The post processing must wait if there is a dependency on a FR
1472 which is not ready yet. */
1473 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1474 adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
1476 ps = CPU_PROFILE_STATE (cpu);
1477 ps->post_wait = cycles;
1478 post_wait_for_FR (cpu, in_FRi);
1479 post_wait_for_FR (cpu, in_FRj);
1480 post_wait_for_FR (cpu, out_FRk);
1481 post_wait_for_FRdouble (cpu, in_FRdoublei);
1482 post_wait_for_FRdouble (cpu, in_FRdoublej);
1483 post_wait_for_FRdouble (cpu, out_FRdoublek);
1484 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1486 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1487 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
1489 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1490 restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
1493 /* The latency of FRk will be at least the latency of the other inputs. */
1494 update_FR_latency (cpu, out_FRk, ps->post_wait);
1495 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1497 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1499 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1500 update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
1503 /* Once initiated, post-processing will take 3 cycles. */
1504 update_FR_ptime (cpu, out_FRk, 3);
1505 update_FRdouble_ptime (cpu, out_FRdoublek, 3);
1507 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1509 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
1510 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
1513 /* Mark this use of the register as a floating point op. */
1514 if (out_FRk >= 0)
1515 set_use_is_fpop (cpu, out_FRk);
1516 if (out_FRdoublek >= 0)
1518 set_use_is_fpop (cpu, out_FRdoublek);
1519 if (out_FRdoublek < 63)
1520 set_use_is_fpop (cpu, out_FRdoublek + 1);
1523 return cycles;
1527 frvbf_model_fr500_u_float_dual_arith (SIM_CPU *cpu, const IDESC *idesc,
1528 int unit_num, int referenced,
1529 INT in_FRi, INT in_FRj,
1530 INT in_FRdoublei, INT in_FRdoublej,
1531 INT out_FRk, INT out_FRdoublek)
1533 int cycles;
1534 INT dual_FRi;
1535 INT dual_FRj;
1536 INT dual_FRk;
1537 INT dual_FRdoublei;
1538 INT dual_FRdoublej;
1539 INT dual_FRdoublek;
1540 FRV_PROFILE_STATE *ps;
1542 if (model_insn == FRV_INSN_MODEL_PASS_1)
1543 return 0;
1545 /* The preprocessing can execute right away. */
1546 cycles = idesc->timing->units[unit_num].done;
1548 /* The post processing must wait if there is a dependency on a FR
1549 which is not ready yet. */
1550 dual_FRi = DUAL_REG (in_FRi);
1551 dual_FRj = DUAL_REG (in_FRj);
1552 dual_FRk = DUAL_REG (out_FRk);
1553 dual_FRdoublei = DUAL_DOUBLE (in_FRdoublei);
1554 dual_FRdoublej = DUAL_DOUBLE (in_FRdoublej);
1555 dual_FRdoublek = DUAL_DOUBLE (out_FRdoublek);
1557 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1558 adjust_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
1559 adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
1561 adjust_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
1562 dual_FRdoublek, 1);
1563 ps = CPU_PROFILE_STATE (cpu);
1564 ps->post_wait = cycles;
1565 post_wait_for_FR (cpu, in_FRi);
1566 post_wait_for_FR (cpu, in_FRj);
1567 post_wait_for_FR (cpu, out_FRk);
1568 post_wait_for_FR (cpu, dual_FRi);
1569 post_wait_for_FR (cpu, dual_FRj);
1570 post_wait_for_FR (cpu, dual_FRk);
1571 post_wait_for_FRdouble (cpu, in_FRdoublei);
1572 post_wait_for_FRdouble (cpu, in_FRdoublej);
1573 post_wait_for_FRdouble (cpu, out_FRdoublek);
1574 post_wait_for_FRdouble (cpu, dual_FRdoublei);
1575 post_wait_for_FRdouble (cpu, dual_FRdoublej);
1576 post_wait_for_FRdouble (cpu, dual_FRdoublek);
1577 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1579 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1580 post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRk));
1581 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
1582 post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRdoublek));
1584 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1585 restore_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
1586 restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
1588 restore_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
1589 dual_FRdoublek, 1);
1591 /* The latency of FRk will be at least the latency of the other inputs. */
1592 update_FR_latency (cpu, out_FRk, ps->post_wait);
1593 update_FR_latency (cpu, dual_FRk, ps->post_wait);
1594 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1595 update_FRdouble_latency (cpu, dual_FRdoublek, ps->post_wait);
1597 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1599 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1600 update_SPR_latency (cpu, FNER_FOR_FR (dual_FRk), ps->post_wait);
1601 update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
1602 update_SPR_latency (cpu, FNER_FOR_FR (dual_FRdoublek), ps->post_wait);
1605 /* Once initiated, post-processing will take 3 cycles. */
1606 update_FR_ptime (cpu, out_FRk, 3);
1607 update_FR_ptime (cpu, dual_FRk, 3);
1608 update_FRdouble_ptime (cpu, out_FRdoublek, 3);
1609 update_FRdouble_ptime (cpu, dual_FRdoublek, 3);
1611 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1613 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
1614 update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRk), 3);
1615 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
1616 update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRdoublek), 3);
1619 /* Mark this use of the register as a floating point op. */
1620 if (out_FRk >= 0)
1621 set_use_is_fpop (cpu, out_FRk);
1622 if (dual_FRk >= 0)
1623 set_use_is_fpop (cpu, dual_FRk);
1624 if (out_FRdoublek >= 0)
1626 set_use_is_fpop (cpu, out_FRdoublek);
1627 if (out_FRdoublek < 63)
1628 set_use_is_fpop (cpu, out_FRdoublek + 1);
1630 if (dual_FRdoublek >= 0)
1632 set_use_is_fpop (cpu, dual_FRdoublek);
1633 if (dual_FRdoublek < 63)
1634 set_use_is_fpop (cpu, dual_FRdoublek + 1);
1637 return cycles;
1641 frvbf_model_fr500_u_float_div (SIM_CPU *cpu, const IDESC *idesc,
1642 int unit_num, int referenced,
1643 INT in_FRi, INT in_FRj, INT out_FRk)
1645 int cycles;
1646 FRV_VLIW *vliw;
1647 int slot;
1648 FRV_PROFILE_STATE *ps;
1650 if (model_insn == FRV_INSN_MODEL_PASS_1)
1651 return 0;
1653 cycles = idesc->timing->units[unit_num].done;
1655 /* The post processing must wait if there is a dependency on a FR
1656 which is not ready yet. */
1657 adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1658 ps = CPU_PROFILE_STATE (cpu);
1659 ps->post_wait = cycles;
1660 post_wait_for_FR (cpu, in_FRi);
1661 post_wait_for_FR (cpu, in_FRj);
1662 post_wait_for_FR (cpu, out_FRk);
1663 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1664 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1665 vliw = CPU_VLIW (cpu);
1666 slot = vliw->next_slot - 1;
1667 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1668 post_wait_for_fdiv (cpu, slot);
1669 restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
1671 /* The latency of FRk will be at least the latency of the other inputs. */
1672 /* Once initiated, post-processing will take 10 cycles. */
1673 update_FR_latency (cpu, out_FRk, ps->post_wait);
1674 update_FR_ptime (cpu, out_FRk, 10);
1676 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1678 /* FNER has a latency of 10 cycles. */
1679 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1680 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 10);
1683 /* The latency of the fdiv unit will be at least the latency of the other
1684 inputs. Once initiated, post-processing will take 9 cycles. */
1685 update_fdiv_resource_latency (cpu, slot, ps->post_wait + 9);
1687 /* Mark this use of the register as a floating point op. */
1688 set_use_is_fpop (cpu, out_FRk);
1690 return cycles;
1694 frvbf_model_fr500_u_float_sqrt (SIM_CPU *cpu, const IDESC *idesc,
1695 int unit_num, int referenced,
1696 INT in_FRj, INT in_FRdoublej,
1697 INT out_FRk, INT out_FRdoublek)
1699 int cycles;
1700 FRV_VLIW *vliw;
1701 int slot;
1702 FRV_PROFILE_STATE *ps;
1704 if (model_insn == FRV_INSN_MODEL_PASS_1)
1705 return 0;
1707 cycles = idesc->timing->units[unit_num].done;
1709 /* The post processing must wait if there is a dependency on a FR
1710 which is not ready yet. */
1711 adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1712 adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
1713 ps = CPU_PROFILE_STATE (cpu);
1714 ps->post_wait = cycles;
1715 post_wait_for_FR (cpu, in_FRj);
1716 post_wait_for_FR (cpu, out_FRk);
1717 post_wait_for_FRdouble (cpu, in_FRdoublej);
1718 post_wait_for_FRdouble (cpu, out_FRdoublek);
1719 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1720 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1721 vliw = CPU_VLIW (cpu);
1722 slot = vliw->next_slot - 1;
1723 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1724 post_wait_for_fsqrt (cpu, slot);
1725 restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1726 restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
1728 /* The latency of FRk will be at least the latency of the other inputs. */
1729 update_FR_latency (cpu, out_FRk, ps->post_wait);
1730 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1731 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1732 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1734 /* Once initiated, post-processing will take 15 cycles. */
1735 update_FR_ptime (cpu, out_FRk, 15);
1736 update_FRdouble_ptime (cpu, out_FRdoublek, 15);
1738 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1739 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 15);
1741 /* The latency of the sqrt unit will be the latency of the other
1742 inputs plus 14 cycles. */
1743 update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
1745 /* Mark this use of the register as a floating point op. */
1746 if (out_FRk >= 0)
1747 set_use_is_fpop (cpu, out_FRk);
1748 if (out_FRdoublek >= 0)
1750 set_use_is_fpop (cpu, out_FRdoublek);
1751 if (out_FRdoublek < 63)
1752 set_use_is_fpop (cpu, out_FRdoublek + 1);
1755 return cycles;
1759 frvbf_model_fr500_u_float_dual_sqrt (SIM_CPU *cpu, const IDESC *idesc,
1760 int unit_num, int referenced,
1761 INT in_FRj, INT out_FRk)
1763 int cycles;
1764 FRV_VLIW *vliw;
1765 int slot;
1766 INT dual_FRj;
1767 INT dual_FRk;
1768 FRV_PROFILE_STATE *ps;
1770 if (model_insn == FRV_INSN_MODEL_PASS_1)
1771 return 0;
1773 cycles = idesc->timing->units[unit_num].done;
1775 /* The post processing must wait if there is a dependency on a FR
1776 which is not ready yet. */
1777 dual_FRj = DUAL_REG (in_FRj);
1778 dual_FRk = DUAL_REG (out_FRk);
1779 adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1780 adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
1781 ps = CPU_PROFILE_STATE (cpu);
1782 ps->post_wait = cycles;
1783 post_wait_for_FR (cpu, in_FRj);
1784 post_wait_for_FR (cpu, out_FRk);
1785 post_wait_for_FR (cpu, dual_FRj);
1786 post_wait_for_FR (cpu, dual_FRk);
1788 vliw = CPU_VLIW (cpu);
1789 slot = vliw->next_slot - 1;
1790 slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
1791 post_wait_for_fsqrt (cpu, slot);
1792 restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1793 restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
1795 /* The latency of FRk will be at least the latency of the other inputs. */
1796 update_FR_latency (cpu, out_FRk, ps->post_wait);
1797 update_FR_latency (cpu, dual_FRk, ps->post_wait);
1799 /* Once initiated, post-processing will take 15 cycles. */
1800 update_FR_ptime (cpu, out_FRk, 15);
1801 update_FR_ptime (cpu, dual_FRk, 15);
1803 /* The latency of the sqrt unit will be at least the latency of the other
1804 inputs. */
1805 update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
1807 /* Mark this use of the register as a floating point op. */
1808 if (out_FRk >= 0)
1809 set_use_is_fpop (cpu, out_FRk);
1810 if (dual_FRk >= 0)
1811 set_use_is_fpop (cpu, dual_FRk);
1813 return cycles;
1817 frvbf_model_fr500_u_float_compare (SIM_CPU *cpu, const IDESC *idesc,
1818 int unit_num, int referenced,
1819 INT in_FRi, INT in_FRj,
1820 INT in_FRdoublei, INT in_FRdoublej,
1821 INT out_FCCi_2)
1823 int cycles;
1824 FRV_PROFILE_STATE *ps;
1826 if (model_insn == FRV_INSN_MODEL_PASS_1)
1827 return 0;
1829 /* The preprocessing can execute right away. */
1830 cycles = idesc->timing->units[unit_num].done;
1832 /* The post processing must wait if there is a dependency on a FR
1833 which is not ready yet. */
1834 adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
1835 ps = CPU_PROFILE_STATE (cpu);
1836 ps->post_wait = cycles;
1837 post_wait_for_FR (cpu, in_FRi);
1838 post_wait_for_FR (cpu, in_FRj);
1839 post_wait_for_FRdouble (cpu, in_FRdoublei);
1840 post_wait_for_FRdouble (cpu, in_FRdoublej);
1841 post_wait_for_CCR (cpu, out_FCCi_2);
1842 restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
1844 /* The latency of FCCi_2 will be the latency of the other inputs plus 3
1845 cycles. */
1846 update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
1848 return cycles;
1852 frvbf_model_fr500_u_float_dual_compare (SIM_CPU *cpu, const IDESC *idesc,
1853 int unit_num, int referenced,
1854 INT in_FRi, INT in_FRj,
1855 INT out_FCCi_2)
1857 int cycles;
1858 INT dual_FRi;
1859 INT dual_FRj;
1860 INT dual_FCCi_2;
1861 FRV_PROFILE_STATE *ps;
1863 if (model_insn == FRV_INSN_MODEL_PASS_1)
1864 return 0;
1866 /* The preprocessing can execute right away. */
1867 cycles = idesc->timing->units[unit_num].done;
1869 /* The post processing must wait if there is a dependency on a FR
1870 which is not ready yet. */
1871 ps = CPU_PROFILE_STATE (cpu);
1872 ps->post_wait = cycles;
1873 dual_FRi = DUAL_REG (in_FRi);
1874 dual_FRj = DUAL_REG (in_FRj);
1875 dual_FCCi_2 = out_FCCi_2 + 1;
1876 adjust_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
1877 adjust_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
1878 post_wait_for_FR (cpu, in_FRi);
1879 post_wait_for_FR (cpu, in_FRj);
1880 post_wait_for_FR (cpu, dual_FRi);
1881 post_wait_for_FR (cpu, dual_FRj);
1882 post_wait_for_CCR (cpu, out_FCCi_2);
1883 post_wait_for_CCR (cpu, dual_FCCi_2);
1884 restore_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
1885 restore_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
1887 /* The latency of FCCi_2 will be the latency of the other inputs plus 3
1888 cycles. */
1889 update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
1890 update_CCR_latency (cpu, dual_FCCi_2, ps->post_wait + 3);
1892 return cycles;
1896 frvbf_model_fr500_u_float_convert (SIM_CPU *cpu, const IDESC *idesc,
1897 int unit_num, int referenced,
1898 INT in_FRj, INT in_FRintj, INT in_FRdoublej,
1899 INT out_FRk, INT out_FRintk,
1900 INT out_FRdoublek)
1902 int cycles;
1903 FRV_PROFILE_STATE *ps;
1905 if (model_insn == FRV_INSN_MODEL_PASS_1)
1906 return 0;
1908 /* The preprocessing can execute right away. */
1909 cycles = idesc->timing->units[unit_num].done;
1911 /* The post processing must wait if there is a dependency on a FR
1912 which is not ready yet. */
1913 ps = CPU_PROFILE_STATE (cpu);
1914 ps->post_wait = cycles;
1915 adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1916 adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
1917 adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
1918 post_wait_for_FR (cpu, in_FRj);
1919 post_wait_for_FR (cpu, in_FRintj);
1920 post_wait_for_FRdouble (cpu, in_FRdoublej);
1921 post_wait_for_FR (cpu, out_FRk);
1922 post_wait_for_FR (cpu, out_FRintk);
1923 post_wait_for_FRdouble (cpu, out_FRdoublek);
1924 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1926 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
1927 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRintk));
1928 post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
1930 restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
1931 restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
1932 restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
1934 /* The latency of FRk will be at least the latency of the other inputs. */
1935 update_FR_latency (cpu, out_FRk, ps->post_wait);
1936 update_FR_latency (cpu, out_FRintk, ps->post_wait);
1937 update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
1939 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1941 update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
1942 update_SPR_latency (cpu, FNER_FOR_FR (out_FRintk), ps->post_wait);
1943 update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
1946 /* Once initiated, post-processing will take 3 cycles. */
1947 update_FR_ptime (cpu, out_FRk, 3);
1948 update_FR_ptime (cpu, out_FRintk, 3);
1949 update_FRdouble_ptime (cpu, out_FRdoublek, 3);
1951 if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
1953 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
1954 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRintk), 3);
1955 update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
1958 /* Mark this use of the register as a floating point op. */
1959 if (out_FRk >= 0)
1960 set_use_is_fpop (cpu, out_FRk);
1961 if (out_FRintk >= 0)
1962 set_use_is_fpop (cpu, out_FRintk);
1963 if (out_FRdoublek >= 0)
1965 set_use_is_fpop (cpu, out_FRdoublek);
1966 set_use_is_fpop (cpu, out_FRdoublek + 1);
1969 return cycles;
1973 frvbf_model_fr500_u_float_dual_convert (SIM_CPU *cpu, const IDESC *idesc,
1974 int unit_num, int referenced,
1975 INT in_FRj, INT in_FRintj,
1976 INT out_FRk, INT out_FRintk)
1978 int cycles;
1979 INT dual_FRj;
1980 INT dual_FRintj;
1981 INT dual_FRk;
1982 INT dual_FRintk;
1983 FRV_PROFILE_STATE *ps;
1985 if (model_insn == FRV_INSN_MODEL_PASS_1)
1986 return 0;
1988 /* The preprocessing can execute right away. */
1989 cycles = idesc->timing->units[unit_num].done;
1991 /* The post processing must wait if there is a dependency on a FR
1992 which is not ready yet. */
1993 ps = CPU_PROFILE_STATE (cpu);
1994 ps->post_wait = cycles;
1995 dual_FRj = DUAL_REG (in_FRj);
1996 dual_FRintj = DUAL_REG (in_FRintj);
1997 dual_FRk = DUAL_REG (out_FRk);
1998 dual_FRintk = DUAL_REG (out_FRintk);
1999 adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
2000 adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
2001 adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
2002 adjust_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
2003 post_wait_for_FR (cpu, in_FRj);
2004 post_wait_for_FR (cpu, in_FRintj);
2005 post_wait_for_FR (cpu, out_FRk);
2006 post_wait_for_FR (cpu, out_FRintk);
2007 post_wait_for_FR (cpu, dual_FRj);
2008 post_wait_for_FR (cpu, dual_FRintj);
2009 post_wait_for_FR (cpu, dual_FRk);
2010 post_wait_for_FR (cpu, dual_FRintk);
2011 restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
2012 restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
2013 restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
2014 restore_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
2016 /* The latency of FRk will be at least the latency of the other inputs. */
2017 update_FR_latency (cpu, out_FRk, ps->post_wait);
2018 update_FR_latency (cpu, out_FRintk, ps->post_wait);
2019 update_FR_latency (cpu, dual_FRk, ps->post_wait);
2020 update_FR_latency (cpu, dual_FRintk, ps->post_wait);
2022 /* Once initiated, post-processing will take 3 cycles. */
2023 update_FR_ptime (cpu, out_FRk, 3);
2024 update_FR_ptime (cpu, out_FRintk, 3);
2025 update_FR_ptime (cpu, dual_FRk, 3);
2026 update_FR_ptime (cpu, dual_FRintk, 3);
2028 /* Mark this use of the register as a floating point op. */
2029 if (out_FRk >= 0)
2030 set_use_is_fpop (cpu, out_FRk);
2031 if (out_FRintk >= 0)
2032 set_use_is_fpop (cpu, out_FRintk);
2034 return cycles;
2038 frvbf_model_fr500_u_media (SIM_CPU *cpu, const IDESC *idesc,
2039 int unit_num, int referenced,
2040 INT in_FRi, INT in_FRj, INT in_ACC40Si, INT in_ACCGi,
2041 INT out_FRk,
2042 INT out_ACC40Sk, INT out_ACC40Uk, INT out_ACCGk)
2044 int cycles;
2045 FRV_PROFILE_STATE *ps;
2046 int busy_adjustment[] = {0, 0, 0};
2047 int *fr;
2049 if (model_insn == FRV_INSN_MODEL_PASS_1)
2050 return 0;
2052 /* The preprocessing can execute right away. */
2053 cycles = idesc->timing->units[unit_num].done;
2055 ps = CPU_PROFILE_STATE (cpu);
2057 /* If the previous use of the registers was a media op,
2058 then their latency will be less than previously recorded.
2059 See Table 13-13 in the LSI. */
2060 if (in_FRi >= 0)
2062 if (use_is_media (cpu, in_FRi))
2064 busy_adjustment[0] = 2;
2065 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2067 else
2068 enforce_full_fr_latency (cpu, in_FRi);
2070 if (in_FRj >= 0 && in_FRj != in_FRi)
2072 if (use_is_media (cpu, in_FRj))
2074 busy_adjustment[1] = 2;
2075 decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
2077 else
2078 enforce_full_fr_latency (cpu, in_FRj);
2080 if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
2082 if (use_is_media (cpu, out_FRk))
2084 busy_adjustment[2] = 2;
2085 decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
2087 else
2088 enforce_full_fr_latency (cpu, out_FRk);
2091 /* The post processing must wait if there is a dependency on a FR
2092 which is not ready yet. */
2093 ps->post_wait = cycles;
2094 post_wait_for_FR (cpu, in_FRi);
2095 post_wait_for_FR (cpu, in_FRj);
2096 post_wait_for_FR (cpu, out_FRk);
2097 post_wait_for_ACC (cpu, in_ACC40Si);
2098 post_wait_for_ACC (cpu, in_ACCGi);
2099 post_wait_for_ACC (cpu, out_ACC40Sk);
2100 post_wait_for_ACC (cpu, out_ACC40Uk);
2101 post_wait_for_ACC (cpu, out_ACCGk);
2103 /* Restore the busy cycles of the registers we used. */
2104 fr = ps->fr_busy;
2105 if (in_FRi >= 0)
2106 fr[in_FRi] += busy_adjustment[0];
2107 if (in_FRj >= 0)
2108 fr[in_FRj] += busy_adjustment[1];
2109 if (out_FRk >= 0)
2110 fr[out_FRk] += busy_adjustment[2];
2112 /* The latency of tht output register will be at least the latency of the
2113 other inputs. Once initiated, post-processing will take 3 cycles. */
2114 if (out_FRk >= 0)
2116 update_FR_latency (cpu, out_FRk, ps->post_wait);
2117 update_FR_ptime (cpu, out_FRk, 3);
2118 /* Mark this use of the register as a media op. */
2119 set_use_is_media (cpu, out_FRk);
2121 /* The latency of tht output accumulator will be at least the latency of the
2122 other inputs. Once initiated, post-processing will take 1 cycle. */
2123 if (out_ACC40Sk >= 0)
2124 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2125 if (out_ACC40Uk >= 0)
2126 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
2127 if (out_ACCGk >= 0)
2128 update_ACC_latency (cpu, out_ACCGk, ps->post_wait + 1);
2130 return cycles;
2134 frvbf_model_fr500_u_media_quad_arith (SIM_CPU *cpu, const IDESC *idesc,
2135 int unit_num, int referenced,
2136 INT in_FRi, INT in_FRj,
2137 INT out_FRk)
2139 int cycles;
2140 INT dual_FRi;
2141 INT dual_FRj;
2142 INT dual_FRk;
2143 FRV_PROFILE_STATE *ps;
2144 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
2145 int *fr;
2147 if (model_insn == FRV_INSN_MODEL_PASS_1)
2148 return 0;
2150 /* The preprocessing can execute right away. */
2151 cycles = idesc->timing->units[unit_num].done;
2153 ps = CPU_PROFILE_STATE (cpu);
2154 dual_FRi = DUAL_REG (in_FRi);
2155 dual_FRj = DUAL_REG (in_FRj);
2156 dual_FRk = DUAL_REG (out_FRk);
2158 /* If the previous use of the registers was a media op,
2159 then their latency will be less than previously recorded.
2160 See Table 13-13 in the LSI. */
2161 if (use_is_media (cpu, in_FRi))
2163 busy_adjustment[0] = 2;
2164 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2166 else
2167 enforce_full_fr_latency (cpu, in_FRi);
2168 if (dual_FRi >= 0 && use_is_media (cpu, dual_FRi))
2170 busy_adjustment[1] = 2;
2171 decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
2173 else
2174 enforce_full_fr_latency (cpu, dual_FRi);
2175 if (in_FRj != in_FRi)
2177 if (use_is_media (cpu, in_FRj))
2179 busy_adjustment[2] = 2;
2180 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
2182 else
2183 enforce_full_fr_latency (cpu, in_FRj);
2184 if (dual_FRj >= 0 && use_is_media (cpu, dual_FRj))
2186 busy_adjustment[3] = 2;
2187 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[3]);
2189 else
2190 enforce_full_fr_latency (cpu, dual_FRj + 1);
2192 if (out_FRk != in_FRi && out_FRk != in_FRj)
2194 if (use_is_media (cpu, out_FRk))
2196 busy_adjustment[4] = 2;
2197 decrease_FR_busy (cpu, out_FRk, busy_adjustment[4]);
2199 else
2200 enforce_full_fr_latency (cpu, out_FRk);
2201 if (dual_FRk >= 0 && use_is_media (cpu, dual_FRk))
2203 busy_adjustment[5] = 2;
2204 decrease_FR_busy (cpu, dual_FRk, busy_adjustment[5]);
2206 else
2207 enforce_full_fr_latency (cpu, dual_FRk);
2210 /* The post processing must wait if there is a dependency on a FR
2211 which is not ready yet. */
2212 ps->post_wait = cycles;
2213 post_wait_for_FR (cpu, in_FRi);
2214 post_wait_for_FR (cpu, dual_FRi);
2215 post_wait_for_FR (cpu, in_FRj);
2216 post_wait_for_FR (cpu, dual_FRj);
2217 post_wait_for_FR (cpu, out_FRk);
2218 post_wait_for_FR (cpu, dual_FRk);
2220 /* Restore the busy cycles of the registers we used. */
2221 fr = ps->fr_busy;
2222 fr[in_FRi] += busy_adjustment[0];
2223 if (dual_FRi >= 0)
2224 fr[dual_FRi] += busy_adjustment[1];
2225 fr[in_FRj] += busy_adjustment[2];
2226 if (dual_FRj >= 0)
2227 fr[dual_FRj] += busy_adjustment[3];
2228 fr[out_FRk] += busy_adjustment[4];
2229 if (dual_FRk >= 0)
2230 fr[dual_FRk] += busy_adjustment[5];
2232 /* The latency of tht output register will be at least the latency of the
2233 other inputs. */
2234 update_FR_latency (cpu, out_FRk, ps->post_wait);
2236 /* Once initiated, post-processing will take 3 cycles. */
2237 update_FR_ptime (cpu, out_FRk, 3);
2239 /* Mark this use of the register as a media op. */
2240 set_use_is_media (cpu, out_FRk);
2241 if (dual_FRk >= 0)
2243 update_FR_latency (cpu, dual_FRk, ps->post_wait);
2244 update_FR_ptime (cpu, dual_FRk, 3);
2245 /* Mark this use of the register as a media op. */
2246 set_use_is_media (cpu, dual_FRk);
2249 return cycles;
2253 frvbf_model_fr500_u_media_dual_mul (SIM_CPU *cpu, const IDESC *idesc,
2254 int unit_num, int referenced,
2255 INT in_FRi, INT in_FRj,
2256 INT out_ACC40Sk, INT out_ACC40Uk)
2258 int cycles;
2259 INT dual_ACC40Sk;
2260 INT dual_ACC40Uk;
2261 FRV_PROFILE_STATE *ps;
2262 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
2263 int *fr;
2264 int *acc;
2266 if (model_insn == FRV_INSN_MODEL_PASS_1)
2267 return 0;
2269 /* The preprocessing can execute right away. */
2270 cycles = idesc->timing->units[unit_num].done;
2272 ps = CPU_PROFILE_STATE (cpu);
2273 dual_ACC40Sk = DUAL_REG (out_ACC40Sk);
2274 dual_ACC40Uk = DUAL_REG (out_ACC40Uk);
2276 /* If the previous use of the registers was a media op,
2277 then their latency will be less than previously recorded.
2278 See Table 13-13 in the LSI. */
2279 if (use_is_media (cpu, in_FRi))
2281 busy_adjustment[0] = 2;
2282 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2284 else
2285 enforce_full_fr_latency (cpu, in_FRi);
2286 if (in_FRj != in_FRi)
2288 if (use_is_media (cpu, in_FRj))
2290 busy_adjustment[1] = 2;
2291 decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
2293 else
2294 enforce_full_fr_latency (cpu, in_FRj);
2296 if (out_ACC40Sk >= 0)
2298 busy_adjustment[2] = 1;
2299 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
2301 if (dual_ACC40Sk >= 0)
2303 busy_adjustment[3] = 1;
2304 decrease_ACC_busy (cpu, dual_ACC40Sk, busy_adjustment[3]);
2306 if (out_ACC40Uk >= 0)
2308 busy_adjustment[4] = 1;
2309 decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
2311 if (dual_ACC40Uk >= 0)
2313 busy_adjustment[5] = 1;
2314 decrease_ACC_busy (cpu, dual_ACC40Uk, busy_adjustment[5]);
2317 /* The post processing must wait if there is a dependency on a FR
2318 which is not ready yet. */
2319 ps->post_wait = cycles;
2320 post_wait_for_FR (cpu, in_FRi);
2321 post_wait_for_FR (cpu, in_FRj);
2322 post_wait_for_ACC (cpu, out_ACC40Sk);
2323 post_wait_for_ACC (cpu, dual_ACC40Sk);
2324 post_wait_for_ACC (cpu, out_ACC40Uk);
2325 post_wait_for_ACC (cpu, dual_ACC40Uk);
2327 /* Restore the busy cycles of the registers we used. */
2328 fr = ps->fr_busy;
2329 acc = ps->acc_busy;
2330 fr[in_FRi] += busy_adjustment[0];
2331 fr[in_FRj] += busy_adjustment[1];
2332 if (out_ACC40Sk >= 0)
2333 acc[out_ACC40Sk] += busy_adjustment[2];
2334 if (dual_ACC40Sk >= 0)
2335 acc[dual_ACC40Sk] += busy_adjustment[3];
2336 if (out_ACC40Uk >= 0)
2337 acc[out_ACC40Uk] += busy_adjustment[4];
2338 if (dual_ACC40Uk >= 0)
2339 acc[dual_ACC40Uk] += busy_adjustment[5];
2341 /* The latency of tht output register will be at least the latency of the
2342 other inputs. Once initiated, post-processing will take 1 cycle. */
2343 if (out_ACC40Sk >= 0)
2344 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2345 if (dual_ACC40Sk >= 0)
2346 update_ACC_latency (cpu, dual_ACC40Sk, ps->post_wait + 1);
2347 if (out_ACC40Uk >= 0)
2348 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
2349 if (dual_ACC40Uk >= 0)
2350 update_ACC_latency (cpu, dual_ACC40Uk, ps->post_wait + 1);
2352 return cycles;
2356 frvbf_model_fr500_u_media_quad_mul (SIM_CPU *cpu, const IDESC *idesc,
2357 int unit_num, int referenced,
2358 INT in_FRi, INT in_FRj,
2359 INT out_ACC40Sk, INT out_ACC40Uk)
2361 int cycles;
2362 INT FRi_1;
2363 INT FRj_1;
2364 INT ACC40Sk_1;
2365 INT ACC40Sk_2;
2366 INT ACC40Sk_3;
2367 INT ACC40Uk_1;
2368 INT ACC40Uk_2;
2369 INT ACC40Uk_3;
2370 FRV_PROFILE_STATE *ps;
2371 int busy_adjustment[] = {0, 0, 0, 0, 0, 0, 0 ,0};
2372 int *fr;
2373 int *acc;
2375 if (model_insn == FRV_INSN_MODEL_PASS_1)
2376 return 0;
2378 /* The preprocessing can execute right away. */
2379 cycles = idesc->timing->units[unit_num].done;
2381 FRi_1 = DUAL_REG (in_FRi);
2382 FRj_1 = DUAL_REG (in_FRj);
2383 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
2384 ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
2385 ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
2386 ACC40Uk_1 = DUAL_REG (out_ACC40Uk);
2387 ACC40Uk_2 = DUAL_REG (ACC40Uk_1);
2388 ACC40Uk_3 = DUAL_REG (ACC40Uk_2);
2390 /* If the previous use of the registers was a media op,
2391 then their latency will be less than previously recorded.
2392 See Table 13-13 in the LSI. */
2393 ps = CPU_PROFILE_STATE (cpu);
2394 if (use_is_media (cpu, in_FRi))
2396 busy_adjustment[0] = 2;
2397 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2399 else
2400 enforce_full_fr_latency (cpu, in_FRi);
2401 if (FRi_1 >= 0)
2403 if (use_is_media (cpu, FRi_1))
2405 busy_adjustment[1] = 2;
2406 decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
2408 else
2409 enforce_full_fr_latency (cpu, FRi_1);
2411 if (in_FRj != in_FRi)
2413 if (use_is_media (cpu, in_FRj))
2415 busy_adjustment[2] = 2;
2416 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
2418 else
2419 enforce_full_fr_latency (cpu, in_FRj);
2420 if (FRj_1 >= 0)
2422 if (use_is_media (cpu, FRj_1))
2424 busy_adjustment[3] = 2;
2425 decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
2427 else
2428 enforce_full_fr_latency (cpu, FRj_1);
2431 if (out_ACC40Sk >= 0)
2433 busy_adjustment[4] = 1;
2434 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
2436 if (ACC40Sk_1 >= 0)
2438 busy_adjustment[5] = 1;
2439 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
2441 if (ACC40Sk_2 >= 0)
2443 busy_adjustment[6] = 1;
2444 decrease_ACC_busy (cpu, ACC40Sk_2, busy_adjustment[6]);
2446 if (ACC40Sk_3 >= 0)
2448 busy_adjustment[7] = 1;
2449 decrease_ACC_busy (cpu, ACC40Sk_3, busy_adjustment[7]);
2452 else if (out_ACC40Uk >= 0)
2454 busy_adjustment[4] = 1;
2455 decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
2457 if (ACC40Uk_1 >= 0)
2459 busy_adjustment[5] = 1;
2460 decrease_ACC_busy (cpu, ACC40Uk_1, busy_adjustment[5]);
2462 if (ACC40Uk_2 >= 0)
2464 busy_adjustment[6] = 1;
2465 decrease_ACC_busy (cpu, ACC40Uk_2, busy_adjustment[6]);
2467 if (ACC40Uk_3 >= 0)
2469 busy_adjustment[7] = 1;
2470 decrease_ACC_busy (cpu, ACC40Uk_3, busy_adjustment[7]);
2474 /* The post processing must wait if there is a dependency on a FR
2475 which is not ready yet. */
2476 ps->post_wait = cycles;
2477 post_wait_for_FR (cpu, in_FRi);
2478 post_wait_for_FR (cpu, FRi_1);
2479 post_wait_for_FR (cpu, in_FRj);
2480 post_wait_for_FR (cpu, FRj_1);
2481 post_wait_for_ACC (cpu, out_ACC40Sk);
2482 post_wait_for_ACC (cpu, ACC40Sk_1);
2483 post_wait_for_ACC (cpu, ACC40Sk_2);
2484 post_wait_for_ACC (cpu, ACC40Sk_3);
2485 post_wait_for_ACC (cpu, out_ACC40Uk);
2486 post_wait_for_ACC (cpu, ACC40Uk_1);
2487 post_wait_for_ACC (cpu, ACC40Uk_2);
2488 post_wait_for_ACC (cpu, ACC40Uk_3);
2490 /* Restore the busy cycles of the registers we used. */
2491 fr = ps->fr_busy;
2492 acc = ps->acc_busy;
2493 fr[in_FRi] += busy_adjustment[0];
2494 if (FRi_1 >= 0)
2495 fr[FRi_1] += busy_adjustment[1];
2496 fr[in_FRj] += busy_adjustment[2];
2497 if (FRj_1 > 0)
2498 fr[FRj_1] += busy_adjustment[3];
2499 if (out_ACC40Sk >= 0)
2501 acc[out_ACC40Sk] += busy_adjustment[4];
2502 if (ACC40Sk_1 >= 0)
2503 acc[ACC40Sk_1] += busy_adjustment[5];
2504 if (ACC40Sk_2 >= 0)
2505 acc[ACC40Sk_2] += busy_adjustment[6];
2506 if (ACC40Sk_3 >= 0)
2507 acc[ACC40Sk_3] += busy_adjustment[7];
2509 else if (out_ACC40Uk >= 0)
2511 acc[out_ACC40Uk] += busy_adjustment[4];
2512 if (ACC40Uk_1 >= 0)
2513 acc[ACC40Uk_1] += busy_adjustment[5];
2514 if (ACC40Uk_2 >= 0)
2515 acc[ACC40Uk_2] += busy_adjustment[6];
2516 if (ACC40Uk_3 >= 0)
2517 acc[ACC40Uk_3] += busy_adjustment[7];
2520 /* The latency of tht output register will be at least the latency of the
2521 other inputs. Once initiated, post-processing will take 1 cycle. */
2522 if (out_ACC40Sk >= 0)
2524 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2525 if (ACC40Sk_1 >= 0)
2526 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
2527 if (ACC40Sk_2 >= 0)
2528 update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
2529 if (ACC40Sk_3 >= 0)
2530 update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
2532 else if (out_ACC40Uk >= 0)
2534 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
2535 if (ACC40Uk_1 >= 0)
2536 update_ACC_latency (cpu, ACC40Uk_1, ps->post_wait + 1);
2537 if (ACC40Uk_2 >= 0)
2538 update_ACC_latency (cpu, ACC40Uk_2, ps->post_wait + 1);
2539 if (ACC40Uk_3 >= 0)
2540 update_ACC_latency (cpu, ACC40Uk_3, ps->post_wait + 1);
2543 return cycles;
2547 frvbf_model_fr500_u_media_quad_complex (SIM_CPU *cpu, const IDESC *idesc,
2548 int unit_num, int referenced,
2549 INT in_FRi, INT in_FRj,
2550 INT out_ACC40Sk)
2552 int cycles;
2553 INT FRi_1;
2554 INT FRj_1;
2555 INT ACC40Sk_1;
2556 FRV_PROFILE_STATE *ps;
2557 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
2558 int *fr;
2559 int *acc;
2561 if (model_insn == FRV_INSN_MODEL_PASS_1)
2562 return 0;
2564 /* The preprocessing can execute right away. */
2565 cycles = idesc->timing->units[unit_num].done;
2567 FRi_1 = DUAL_REG (in_FRi);
2568 FRj_1 = DUAL_REG (in_FRj);
2569 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
2571 /* If the previous use of the registers was a media op,
2572 then their latency will be less than previously recorded.
2573 See Table 13-13 in the LSI. */
2574 ps = CPU_PROFILE_STATE (cpu);
2575 if (use_is_media (cpu, in_FRi))
2577 busy_adjustment[0] = 2;
2578 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2580 else
2581 enforce_full_fr_latency (cpu, in_FRi);
2582 if (FRi_1 >= 0)
2584 if (use_is_media (cpu, FRi_1))
2586 busy_adjustment[1] = 2;
2587 decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
2589 else
2590 enforce_full_fr_latency (cpu, FRi_1);
2592 if (in_FRj != in_FRi)
2594 if (use_is_media (cpu, in_FRj))
2596 busy_adjustment[2] = 2;
2597 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
2599 else
2600 enforce_full_fr_latency (cpu, in_FRj);
2601 if (FRj_1 >= 0)
2603 if (use_is_media (cpu, FRj_1))
2605 busy_adjustment[3] = 2;
2606 decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
2608 else
2609 enforce_full_fr_latency (cpu, FRj_1);
2612 if (out_ACC40Sk >= 0)
2614 busy_adjustment[4] = 1;
2615 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
2617 if (ACC40Sk_1 >= 0)
2619 busy_adjustment[5] = 1;
2620 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
2624 /* The post processing must wait if there is a dependency on a FR
2625 which is not ready yet. */
2626 ps->post_wait = cycles;
2627 post_wait_for_FR (cpu, in_FRi);
2628 post_wait_for_FR (cpu, FRi_1);
2629 post_wait_for_FR (cpu, in_FRj);
2630 post_wait_for_FR (cpu, FRj_1);
2631 post_wait_for_ACC (cpu, out_ACC40Sk);
2632 post_wait_for_ACC (cpu, ACC40Sk_1);
2634 /* Restore the busy cycles of the registers we used. */
2635 fr = ps->fr_busy;
2636 acc = ps->acc_busy;
2637 fr[in_FRi] += busy_adjustment[0];
2638 if (FRi_1 >= 0)
2639 fr[FRi_1] += busy_adjustment[1];
2640 fr[in_FRj] += busy_adjustment[2];
2641 if (FRj_1 > 0)
2642 fr[FRj_1] += busy_adjustment[3];
2643 if (out_ACC40Sk >= 0)
2645 acc[out_ACC40Sk] += busy_adjustment[4];
2646 if (ACC40Sk_1 >= 0)
2647 acc[ACC40Sk_1] += busy_adjustment[5];
2650 /* The latency of tht output register will be at least the latency of the
2651 other inputs. Once initiated, post-processing will take 1 cycle. */
2652 if (out_ACC40Sk >= 0)
2654 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
2655 if (ACC40Sk_1 >= 0)
2656 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
2659 return cycles;
2663 frvbf_model_fr500_u_media_dual_expand (SIM_CPU *cpu, const IDESC *idesc,
2664 int unit_num, int referenced,
2665 INT in_FRi,
2666 INT out_FRk)
2668 int cycles;
2669 INT dual_FRk;
2670 FRV_PROFILE_STATE *ps;
2671 int busy_adjustment[] = {0, 0, 0};
2672 int *fr;
2674 if (model_insn == FRV_INSN_MODEL_PASS_1)
2675 return 0;
2677 /* The preprocessing can execute right away. */
2678 cycles = idesc->timing->units[unit_num].done;
2680 /* If the previous use of the registers was a media op,
2681 then their latency will be less than previously recorded.
2682 See Table 13-13 in the LSI. */
2683 dual_FRk = DUAL_REG (out_FRk);
2684 ps = CPU_PROFILE_STATE (cpu);
2685 if (use_is_media (cpu, in_FRi))
2687 busy_adjustment[0] = 2;
2688 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2690 else
2691 enforce_full_fr_latency (cpu, in_FRi);
2692 if (out_FRk != in_FRi)
2694 if (use_is_media (cpu, out_FRk))
2696 busy_adjustment[1] = 2;
2697 decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
2699 else
2700 enforce_full_fr_latency (cpu, out_FRk);
2702 if (dual_FRk >= 0 && dual_FRk != in_FRi)
2704 if (use_is_media (cpu, dual_FRk))
2706 busy_adjustment[2] = 2;
2707 decrease_FR_busy (cpu, dual_FRk, busy_adjustment[2]);
2709 else
2710 enforce_full_fr_latency (cpu, dual_FRk);
2713 /* The post processing must wait if there is a dependency on a FR
2714 which is not ready yet. */
2715 ps->post_wait = cycles;
2716 post_wait_for_FR (cpu, in_FRi);
2717 post_wait_for_FR (cpu, out_FRk);
2718 post_wait_for_FR (cpu, dual_FRk);
2720 /* Restore the busy cycles of the registers we used. */
2721 fr = ps->fr_busy;
2722 fr[in_FRi] += busy_adjustment[0];
2723 fr[out_FRk] += busy_adjustment[1];
2724 if (dual_FRk >= 0)
2725 fr[dual_FRk] += busy_adjustment[2];
2727 /* The latency of the output register will be at least the latency of the
2728 other inputs. Once initiated, post-processing will take 3 cycles. */
2729 update_FR_latency (cpu, out_FRk, ps->post_wait);
2730 update_FR_ptime (cpu, out_FRk, 3);
2732 /* Mark this use of the register as a media op. */
2733 set_use_is_media (cpu, out_FRk);
2734 if (dual_FRk >= 0)
2736 update_FR_latency (cpu, dual_FRk, ps->post_wait);
2737 update_FR_ptime (cpu, dual_FRk, 3);
2739 /* Mark this use of the register as a media op. */
2740 set_use_is_media (cpu, dual_FRk);
2743 return cycles;
2747 frvbf_model_fr500_u_media_dual_unpack (SIM_CPU *cpu, const IDESC *idesc,
2748 int unit_num, int referenced,
2749 INT in_FRi,
2750 INT out_FRk)
2752 int cycles;
2753 INT FRi_1;
2754 INT FRk_1;
2755 INT FRk_2;
2756 INT FRk_3;
2757 FRV_PROFILE_STATE *ps;
2758 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
2759 int *fr;
2761 if (model_insn == FRV_INSN_MODEL_PASS_1)
2762 return 0;
2764 /* The preprocessing can execute right away. */
2765 cycles = idesc->timing->units[unit_num].done;
2767 FRi_1 = DUAL_REG (in_FRi);
2768 FRk_1 = DUAL_REG (out_FRk);
2769 FRk_2 = DUAL_REG (FRk_1);
2770 FRk_3 = DUAL_REG (FRk_2);
2772 /* If the previous use of the registers was a media op,
2773 then their latency will be less than previously recorded.
2774 See Table 13-13 in the LSI. */
2775 ps = CPU_PROFILE_STATE (cpu);
2776 if (use_is_media (cpu, in_FRi))
2778 busy_adjustment[0] = 2;
2779 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
2781 else
2782 enforce_full_fr_latency (cpu, in_FRi);
2783 if (FRi_1 >= 0 && use_is_media (cpu, FRi_1))
2785 busy_adjustment[1] = 2;
2786 decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
2788 else
2789 enforce_full_fr_latency (cpu, FRi_1);
2790 if (out_FRk != in_FRi)
2792 if (use_is_media (cpu, out_FRk))
2794 busy_adjustment[2] = 2;
2795 decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
2797 else
2798 enforce_full_fr_latency (cpu, out_FRk);
2799 if (FRk_1 >= 0 && FRk_1 != in_FRi)
2801 if (use_is_media (cpu, FRk_1))
2803 busy_adjustment[3] = 2;
2804 decrease_FR_busy (cpu, FRk_1, busy_adjustment[3]);
2806 else
2807 enforce_full_fr_latency (cpu, FRk_1);
2809 if (FRk_2 >= 0 && FRk_2 != in_FRi)
2811 if (use_is_media (cpu, FRk_2))
2813 busy_adjustment[4] = 2;
2814 decrease_FR_busy (cpu, FRk_2, busy_adjustment[4]);
2816 else
2817 enforce_full_fr_latency (cpu, FRk_2);
2819 if (FRk_3 >= 0 && FRk_3 != in_FRi)
2821 if (use_is_media (cpu, FRk_3))
2823 busy_adjustment[5] = 2;
2824 decrease_FR_busy (cpu, FRk_3, busy_adjustment[5]);
2826 else
2827 enforce_full_fr_latency (cpu, FRk_3);
2831 /* The post processing must wait if there is a dependency on a FR
2832 which is not ready yet. */
2833 ps->post_wait = cycles;
2834 post_wait_for_FR (cpu, in_FRi);
2835 post_wait_for_FR (cpu, FRi_1);
2836 post_wait_for_FR (cpu, out_FRk);
2837 post_wait_for_FR (cpu, FRk_1);
2838 post_wait_for_FR (cpu, FRk_2);
2839 post_wait_for_FR (cpu, FRk_3);
2841 /* Restore the busy cycles of the registers we used. */
2842 fr = ps->fr_busy;
2843 fr[in_FRi] += busy_adjustment[0];
2844 if (FRi_1 >= 0)
2845 fr[FRi_1] += busy_adjustment[1];
2846 fr[out_FRk] += busy_adjustment[2];
2847 if (FRk_1 >= 0)
2848 fr[FRk_1] += busy_adjustment[3];
2849 if (FRk_2 >= 0)
2850 fr[FRk_2] += busy_adjustment[4];
2851 if (FRk_3 >= 0)
2852 fr[FRk_3] += busy_adjustment[5];
2854 /* The latency of tht output register will be at least the latency of the
2855 other inputs. Once initiated, post-processing will take 3 cycles. */
2856 update_FR_latency (cpu, out_FRk, ps->post_wait);
2857 update_FR_ptime (cpu, out_FRk, 3);
2859 /* Mark this use of the register as a media op. */
2860 set_use_is_media (cpu, out_FRk);
2861 if (FRk_1 >= 0)
2863 update_FR_latency (cpu, FRk_1, ps->post_wait);
2864 update_FR_ptime (cpu, FRk_1, 3);
2866 /* Mark this use of the register as a media op. */
2867 set_use_is_media (cpu, FRk_1);
2869 if (FRk_2 >= 0)
2871 update_FR_latency (cpu, FRk_2, ps->post_wait);
2872 update_FR_ptime (cpu, FRk_2, 3);
2874 /* Mark this use of the register as a media op. */
2875 set_use_is_media (cpu, FRk_2);
2877 if (FRk_3 >= 0)
2879 update_FR_latency (cpu, FRk_3, ps->post_wait);
2880 update_FR_ptime (cpu, FRk_3, 3);
2882 /* Mark this use of the register as a media op. */
2883 set_use_is_media (cpu, FRk_3);
2886 return cycles;
2890 frvbf_model_fr500_u_media_dual_btoh (SIM_CPU *cpu, const IDESC *idesc,
2891 int unit_num, int referenced,
2892 INT in_FRj,
2893 INT out_FRk)
2895 return frvbf_model_fr500_u_media_dual_expand (cpu, idesc, unit_num,
2896 referenced, in_FRj, out_FRk);
2900 frvbf_model_fr500_u_media_dual_htob (SIM_CPU *cpu, const IDESC *idesc,
2901 int unit_num, int referenced,
2902 INT in_FRj,
2903 INT out_FRk)
2905 int cycles;
2906 INT dual_FRj;
2907 FRV_PROFILE_STATE *ps;
2908 int busy_adjustment[] = {0, 0, 0};
2909 int *fr;
2911 if (model_insn == FRV_INSN_MODEL_PASS_1)
2912 return 0;
2914 /* The preprocessing can execute right away. */
2915 cycles = idesc->timing->units[unit_num].done;
2917 /* If the previous use of the registers was a media op,
2918 then their latency will be less than previously recorded.
2919 See Table 13-13 in the LSI. */
2920 dual_FRj = DUAL_REG (in_FRj);
2921 ps = CPU_PROFILE_STATE (cpu);
2922 if (use_is_media (cpu, in_FRj))
2924 busy_adjustment[0] = 2;
2925 decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
2927 else
2928 enforce_full_fr_latency (cpu, in_FRj);
2929 if (dual_FRj >= 0)
2931 if (use_is_media (cpu, dual_FRj))
2933 busy_adjustment[1] = 2;
2934 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[1]);
2936 else
2937 enforce_full_fr_latency (cpu, dual_FRj);
2939 if (out_FRk != in_FRj)
2941 if (use_is_media (cpu, out_FRk))
2943 busy_adjustment[2] = 2;
2944 decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
2946 else
2947 enforce_full_fr_latency (cpu, out_FRk);
2950 /* The post processing must wait if there is a dependency on a FR
2951 which is not ready yet. */
2952 ps->post_wait = cycles;
2953 post_wait_for_FR (cpu, in_FRj);
2954 post_wait_for_FR (cpu, dual_FRj);
2955 post_wait_for_FR (cpu, out_FRk);
2957 /* Restore the busy cycles of the registers we used. */
2958 fr = ps->fr_busy;
2959 fr[in_FRj] += busy_adjustment[0];
2960 if (dual_FRj >= 0)
2961 fr[dual_FRj] += busy_adjustment[1];
2962 fr[out_FRk] += busy_adjustment[2];
2964 /* The latency of tht output register will be at least the latency of the
2965 other inputs. */
2966 update_FR_latency (cpu, out_FRk, ps->post_wait);
2968 /* Once initiated, post-processing will take 3 cycles. */
2969 update_FR_ptime (cpu, out_FRk, 3);
2971 /* Mark this use of the register as a media op. */
2972 set_use_is_media (cpu, out_FRk);
2974 return cycles;
2978 frvbf_model_fr500_u_media_dual_btohe (SIM_CPU *cpu, const IDESC *idesc,
2979 int unit_num, int referenced,
2980 INT in_FRj,
2981 INT out_FRk)
2983 int cycles;
2984 INT FRk_1;
2985 INT FRk_2;
2986 INT FRk_3;
2987 FRV_PROFILE_STATE *ps;
2988 int busy_adjustment[] = {0, 0, 0, 0, 0};
2989 int *fr;
2991 if (model_insn == FRV_INSN_MODEL_PASS_1)
2992 return 0;
2994 /* The preprocessing can execute right away. */
2995 cycles = idesc->timing->units[unit_num].done;
2997 FRk_1 = DUAL_REG (out_FRk);
2998 FRk_2 = DUAL_REG (FRk_1);
2999 FRk_3 = DUAL_REG (FRk_2);
3001 /* If the previous use of the registers was a media op,
3002 then their latency will be less than previously recorded.
3003 See Table 13-13 in the LSI. */
3004 ps = CPU_PROFILE_STATE (cpu);
3005 if (use_is_media (cpu, in_FRj))
3007 busy_adjustment[0] = 2;
3008 decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
3010 else
3011 enforce_full_fr_latency (cpu, in_FRj);
3012 if (out_FRk != in_FRj)
3014 if (use_is_media (cpu, out_FRk))
3016 busy_adjustment[1] = 2;
3017 decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
3019 else
3020 enforce_full_fr_latency (cpu, out_FRk);
3021 if (FRk_1 >= 0 && FRk_1 != in_FRj)
3023 if (use_is_media (cpu, FRk_1))
3025 busy_adjustment[2] = 2;
3026 decrease_FR_busy (cpu, FRk_1, busy_adjustment[2]);
3028 else
3029 enforce_full_fr_latency (cpu, FRk_1);
3031 if (FRk_2 >= 0 && FRk_2 != in_FRj)
3033 if (use_is_media (cpu, FRk_2))
3035 busy_adjustment[3] = 2;
3036 decrease_FR_busy (cpu, FRk_2, busy_adjustment[3]);
3038 else
3039 enforce_full_fr_latency (cpu, FRk_2);
3041 if (FRk_3 >= 0 && FRk_3 != in_FRj)
3043 if (use_is_media (cpu, FRk_3))
3045 busy_adjustment[4] = 2;
3046 decrease_FR_busy (cpu, FRk_3, busy_adjustment[4]);
3048 else
3049 enforce_full_fr_latency (cpu, FRk_3);
3053 /* The post processing must wait if there is a dependency on a FR
3054 which is not ready yet. */
3055 ps->post_wait = cycles;
3056 post_wait_for_FR (cpu, in_FRj);
3057 post_wait_for_FR (cpu, out_FRk);
3058 post_wait_for_FR (cpu, FRk_1);
3059 post_wait_for_FR (cpu, FRk_2);
3060 post_wait_for_FR (cpu, FRk_3);
3062 /* Restore the busy cycles of the registers we used. */
3063 fr = ps->fr_busy;
3064 fr[in_FRj] += busy_adjustment[0];
3065 fr[out_FRk] += busy_adjustment[1];
3066 if (FRk_1 >= 0)
3067 fr[FRk_1] += busy_adjustment[2];
3068 if (FRk_2 >= 0)
3069 fr[FRk_2] += busy_adjustment[3];
3070 if (FRk_3 >= 0)
3071 fr[FRk_3] += busy_adjustment[4];
3073 /* The latency of tht output register will be at least the latency of the
3074 other inputs. Once initiated, post-processing will take 3 cycles. */
3075 update_FR_latency (cpu, out_FRk, ps->post_wait);
3076 update_FR_ptime (cpu, out_FRk, 3);
3078 /* Mark this use of the register as a media op. */
3079 set_use_is_media (cpu, out_FRk);
3080 if (FRk_1 >= 0)
3082 update_FR_latency (cpu, FRk_1, ps->post_wait);
3083 update_FR_ptime (cpu, FRk_1, 3);
3085 /* Mark this use of the register as a media op. */
3086 set_use_is_media (cpu, FRk_1);
3088 if (FRk_2 >= 0)
3090 update_FR_latency (cpu, FRk_2, ps->post_wait);
3091 update_FR_ptime (cpu, FRk_2, 3);
3093 /* Mark this use of the register as a media op. */
3094 set_use_is_media (cpu, FRk_2);
3096 if (FRk_3 >= 0)
3098 update_FR_latency (cpu, FRk_3, ps->post_wait);
3099 update_FR_ptime (cpu, FRk_3, 3);
3101 /* Mark this use of the register as a media op. */
3102 set_use_is_media (cpu, FRk_3);
3105 return cycles;
3109 frvbf_model_fr500_u_barrier (SIM_CPU *cpu, const IDESC *idesc,
3110 int unit_num, int referenced)
3112 int cycles;
3113 if (model_insn == FRV_INSN_MODEL_PASS_1)
3115 int i;
3116 /* Wait for ALL resources. */
3117 for (i = 0; i < 64; ++i)
3119 enforce_full_fr_latency (cpu, i);
3120 vliw_wait_for_GR (cpu, i);
3121 vliw_wait_for_FR (cpu, i);
3122 vliw_wait_for_ACC (cpu, i);
3124 for (i = 0; i < 8; ++i)
3125 vliw_wait_for_CCR (cpu, i);
3126 for (i = 0; i < 2; ++i)
3128 vliw_wait_for_idiv_resource (cpu, i);
3129 vliw_wait_for_fdiv_resource (cpu, i);
3130 vliw_wait_for_fsqrt_resource (cpu, i);
3132 handle_resource_wait (cpu);
3133 for (i = 0; i < 64; ++i)
3135 load_wait_for_GR (cpu, i);
3136 load_wait_for_FR (cpu, i);
3138 trace_vliw_wait_cycles (cpu);
3139 return 0;
3142 cycles = idesc->timing->units[unit_num].done;
3143 return cycles;
3147 frvbf_model_fr500_u_membar (SIM_CPU *cpu, const IDESC *idesc,
3148 int unit_num, int referenced)
3150 int cycles;
3151 if (model_insn == FRV_INSN_MODEL_PASS_1)
3153 int i;
3154 /* Wait for ALL resources, except GR and ICC. */
3155 for (i = 0; i < 64; ++i)
3157 enforce_full_fr_latency (cpu, i);
3158 vliw_wait_for_FR (cpu, i);
3159 vliw_wait_for_ACC (cpu, i);
3161 for (i = 0; i < 4; ++i)
3162 vliw_wait_for_CCR (cpu, i);
3163 for (i = 0; i < 2; ++i)
3165 vliw_wait_for_idiv_resource (cpu, i);
3166 vliw_wait_for_fdiv_resource (cpu, i);
3167 vliw_wait_for_fsqrt_resource (cpu, i);
3169 handle_resource_wait (cpu);
3170 for (i = 0; i < 64; ++i)
3172 load_wait_for_FR (cpu, i);
3174 trace_vliw_wait_cycles (cpu);
3175 return 0;
3178 cycles = idesc->timing->units[unit_num].done;
3179 return cycles;
3182 /* The frv machine is a fictional implementation of the fr500 which implements
3183 all frv architectural features. */
3185 frvbf_model_frv_u_exec (SIM_CPU *cpu, const IDESC *idesc,
3186 int unit_num, int referenced)
3188 return idesc->timing->units[unit_num].done;
3191 /* The simple machine is a fictional implementation of the fr500 which
3192 implements limited frv architectural features. */
3194 frvbf_model_simple_u_exec (SIM_CPU *cpu, const IDESC *idesc,
3195 int unit_num, int referenced)
3197 return idesc->timing->units[unit_num].done;
3200 /* The tomcat machine is models a prototype fr500 machine which had a few
3201 bugs and restrictions to work around. */
3203 frvbf_model_tomcat_u_exec (SIM_CPU *cpu, const IDESC *idesc,
3204 int unit_num, int referenced)
3206 return idesc->timing->units[unit_num].done;
3209 #endif /* WITH_PROFILE_MODEL_P */