Add enum values for HP extensions to DWARF standard
[deliverable/binutils-gdb.git] / sim / frv / profile-fr400.c
1 /* frv simulator fr400 dependent profiling code.
2
3 Copyright (C) 2001 Free Software Foundation, Inc.
4 Contributed by Red Hat
5
6 This file is part of the GNU simulators.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
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.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 */
23 #define WANT_CPU
24 #define WANT_CPU_FRVBF
25
26 #include "sim-main.h"
27 #include "bfd.h"
28
29 #if WITH_PROFILE_MODEL_P
30
31 #include "profile.h"
32 #include "profile-fr400.h"
33
34 /* These functions get and set flags representing the use of
35 registers/resources. */
36 static void set_use_not_fp_load (SIM_CPU *, INT);
37 static void set_use_not_media_p4 (SIM_CPU *, INT);
38 static void set_use_not_media_p6 (SIM_CPU *, INT);
39
40 static void set_acc_use_not_media_p2 (SIM_CPU *, INT);
41 static void set_acc_use_not_media_p4 (SIM_CPU *, INT);
42
43 void
44 fr400_reset_gr_flags (SIM_CPU *cpu, INT fr)
45 {
46 set_use_not_gr_complex (cpu, fr);
47 }
48
49 void
50 fr400_reset_fr_flags (SIM_CPU *cpu, INT fr)
51 {
52 set_use_not_fp_load (cpu, fr);
53 set_use_not_media_p4 (cpu, fr);
54 set_use_not_media_p6 (cpu, fr);
55 }
56
57 void
58 fr400_reset_acc_flags (SIM_CPU *cpu, INT acc)
59 {
60 set_acc_use_not_media_p2 (cpu, acc);
61 set_acc_use_not_media_p4 (cpu, acc);
62 }
63
64 static void
65 set_use_is_fp_load (SIM_CPU *cpu, INT fr, INT fr_double)
66 {
67 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
68 if (fr != -1)
69 {
70 fr400_reset_fr_flags (cpu, fr);
71 d->cur_fp_load |= (((DI)1) << fr);
72 }
73 if (fr_double != -1)
74 {
75 fr400_reset_fr_flags (cpu, fr_double);
76 d->cur_fp_load |= (((DI)1) << fr_double);
77 if (fr_double < 63)
78 {
79 fr400_reset_fr_flags (cpu, fr_double + 1);
80 d->cur_fp_load |= (((DI)1) << (fr_double + 1));
81 }
82 }
83
84 }
85
86 static void
87 set_use_not_fp_load (SIM_CPU *cpu, INT fr)
88 {
89 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
90 if (fr != -1)
91 d->cur_fp_load &= ~(((DI)1) << fr);
92 }
93
94 static int
95 use_is_fp_load (SIM_CPU *cpu, INT fr)
96 {
97 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
98 if (fr != -1)
99 return (d->prev_fp_load >> fr) & 1;
100 return 0;
101 }
102
103 static void
104 set_acc_use_is_media_p2 (SIM_CPU *cpu, INT acc)
105 {
106 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
107 if (acc != -1)
108 {
109 fr400_reset_acc_flags (cpu, acc);
110 d->cur_acc_p2 |= (((DI)1) << acc);
111 }
112 }
113
114 static void
115 set_acc_use_not_media_p2 (SIM_CPU *cpu, INT acc)
116 {
117 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
118 if (acc != -1)
119 d->cur_acc_p2 &= ~(((DI)1) << acc);
120 }
121
122 static int
123 acc_use_is_media_p2 (SIM_CPU *cpu, INT acc)
124 {
125 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
126 if (acc != -1)
127 return d->cur_acc_p2 & (((DI)1) << acc);
128 return 0;
129 }
130
131 static void
132 set_use_is_media_p4 (SIM_CPU *cpu, INT fr)
133 {
134 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
135 if (fr != -1)
136 {
137 fr400_reset_fr_flags (cpu, fr);
138 d->cur_fr_p4 |= (((DI)1) << fr);
139 }
140 }
141
142 static void
143 set_use_not_media_p4 (SIM_CPU *cpu, INT fr)
144 {
145 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
146 if (fr != -1)
147 d->cur_fr_p4 &= ~(((DI)1) << fr);
148 }
149
150 static int
151 use_is_media_p4 (SIM_CPU *cpu, INT fr)
152 {
153 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
154 if (fr != -1)
155 return d->cur_fr_p4 & (((DI)1) << fr);
156 return 0;
157 }
158
159 static void
160 set_acc_use_is_media_p4 (SIM_CPU *cpu, INT acc)
161 {
162 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
163 if (acc != -1)
164 {
165 fr400_reset_acc_flags (cpu, acc);
166 d->cur_acc_p4 |= (((DI)1) << acc);
167 }
168 }
169
170 static void
171 set_acc_use_not_media_p4 (SIM_CPU *cpu, INT acc)
172 {
173 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
174 if (acc != -1)
175 d->cur_acc_p4 &= ~(((DI)1) << acc);
176 }
177
178 static int
179 acc_use_is_media_p4 (SIM_CPU *cpu, INT acc)
180 {
181 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
182 if (acc != -1)
183 return d->cur_acc_p4 & (((DI)1) << acc);
184 return 0;
185 }
186
187 static void
188 set_use_is_media_p6 (SIM_CPU *cpu, INT fr)
189 {
190 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
191 if (fr != -1)
192 {
193 fr400_reset_fr_flags (cpu, fr);
194 d->cur_fr_p6 |= (((DI)1) << fr);
195 }
196 }
197
198 static void
199 set_use_not_media_p6 (SIM_CPU *cpu, INT fr)
200 {
201 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
202 if (fr != -1)
203 d->cur_fr_p6 &= ~(((DI)1) << fr);
204 }
205
206 static int
207 use_is_media_p6 (SIM_CPU *cpu, INT fr)
208 {
209 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
210 if (fr != -1)
211 return d->cur_fr_p6 & (((DI)1) << fr);
212 return 0;
213 }
214
215 /* Initialize cycle counting for an insn.
216 FIRST_P is non-zero if this is the first insn in a set of parallel
217 insns. */
218 void
219 fr400_model_insn_before (SIM_CPU *cpu, int first_p)
220 {
221 if (first_p)
222 {
223 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
224 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
225 ps->cur_gr_complex = ps->prev_gr_complex;
226 d->cur_fp_load = d->prev_fp_load;
227 d->cur_fr_p4 = d->prev_fr_p4;
228 d->cur_fr_p6 = d->prev_fr_p6;
229 d->cur_acc_p2 = d->prev_acc_p2;
230 d->cur_acc_p4 = d->prev_acc_p4;
231 }
232 }
233
234 /* Record the cycles computed for an insn.
235 LAST_P is non-zero if this is the last insn in a set of parallel insns,
236 and we update the total cycle count.
237 CYCLES is the cycle count of the insn. */
238 void
239 fr400_model_insn_after (SIM_CPU *cpu, int last_p, int cycles)
240 {
241 if (last_p)
242 {
243 MODEL_FR400_DATA *d = CPU_MODEL_DATA (cpu);
244 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
245 ps->prev_gr_complex = ps->cur_gr_complex;
246 d->prev_fp_load = d->cur_fp_load;
247 d->prev_fr_p4 = d->cur_fr_p4;
248 d->prev_fr_p6 = d->cur_fr_p6;
249 d->prev_acc_p2 = d->cur_acc_p2;
250 d->prev_acc_p4 = d->cur_acc_p4;
251 }
252 }
253
254 int
255 frvbf_model_fr400_u_exec (SIM_CPU *cpu, const IDESC *idesc,
256 int unit_num, int referenced)
257 {
258 return idesc->timing->units[unit_num].done;
259 }
260
261 int
262 frvbf_model_fr400_u_integer (SIM_CPU *cpu, const IDESC *idesc,
263 int unit_num, int referenced,
264 INT in_GRi, INT in_GRj, INT out_GRk,
265 INT out_ICCi_1)
266 {
267 /* Modelling for this unit is the same as for fr500. */
268 return frvbf_model_fr500_u_integer (cpu, idesc, unit_num, referenced,
269 in_GRi, in_GRj, out_GRk, out_ICCi_1);
270 }
271
272 int
273 frvbf_model_fr400_u_imul (SIM_CPU *cpu, const IDESC *idesc,
274 int unit_num, int referenced,
275 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
276 {
277 /* Modelling for this unit is the same as for fr500. */
278 return frvbf_model_fr500_u_imul (cpu, idesc, unit_num, referenced,
279 in_GRi, in_GRj, out_GRk, out_ICCi_1);
280 }
281
282 int
283 frvbf_model_fr400_u_idiv (SIM_CPU *cpu, const IDESC *idesc,
284 int unit_num, int referenced,
285 INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
286 {
287 int cycles;
288 FRV_VLIW *vliw;
289 int slot;
290
291 /* icc0-icc4 are the upper 4 fields of the CCR. */
292 if (out_ICCi_1 >= 0)
293 out_ICCi_1 += 4;
294
295 vliw = CPU_VLIW (cpu);
296 slot = vliw->next_slot - 1;
297 slot = (*vliw->current_vliw)[slot] - UNIT_I0;
298
299 if (model_insn == FRV_INSN_MODEL_PASS_1)
300 {
301 /* The entire VLIW insn must wait if there is a dependency on a register
302 which is not ready yet.
303 The latency of the registers may be less than previously recorded,
304 depending on how they were used previously.
305 See Table 13-8 in the LSI. */
306 if (in_GRi != out_GRk && in_GRi >= 0)
307 {
308 if (use_is_gr_complex (cpu, in_GRi))
309 decrease_GR_busy (cpu, in_GRi, 1);
310 }
311 if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
312 {
313 if (use_is_gr_complex (cpu, in_GRj))
314 decrease_GR_busy (cpu, in_GRj, 1);
315 }
316 vliw_wait_for_GR (cpu, in_GRi);
317 vliw_wait_for_GR (cpu, in_GRj);
318 vliw_wait_for_GR (cpu, out_GRk);
319 vliw_wait_for_CCR (cpu, out_ICCi_1);
320 vliw_wait_for_idiv_resource (cpu, slot);
321 handle_resource_wait (cpu);
322 load_wait_for_GR (cpu, in_GRi);
323 load_wait_for_GR (cpu, in_GRj);
324 load_wait_for_GR (cpu, out_GRk);
325 trace_vliw_wait_cycles (cpu);
326 return 0;
327 }
328
329 /* GRk has a latency of 19 cycles! */
330 cycles = idesc->timing->units[unit_num].done;
331 update_GR_latency (cpu, out_GRk, cycles + 19);
332 set_use_is_gr_complex (cpu, out_GRk);
333
334 /* ICCi_1 has a latency of 18 cycles. */
335 update_CCR_latency (cpu, out_ICCi_1, cycles + 18);
336
337 /* the idiv resource has a latency of 18 cycles! */
338 update_idiv_resource_latency (cpu, slot, cycles + 18);
339
340 return cycles;
341 }
342
343 int
344 frvbf_model_fr400_u_branch (SIM_CPU *cpu, const IDESC *idesc,
345 int unit_num, int referenced,
346 INT in_GRi, INT in_GRj,
347 INT in_ICCi_2, INT in_ICCi_3)
348 {
349 #define BRANCH_PREDICTED(ps) ((ps)->branch_hint & 2)
350 FRV_PROFILE_STATE *ps;
351 int cycles;
352
353 if (model_insn == FRV_INSN_MODEL_PASS_1)
354 {
355 /* Modelling for this unit is the same as for fr500 in pass 1. */
356 return frvbf_model_fr500_u_branch (cpu, idesc, unit_num, referenced,
357 in_GRi, in_GRj, in_ICCi_2, in_ICCi_3);
358 }
359
360 cycles = idesc->timing->units[unit_num].done;
361
362 /* Compute the branch penalty, based on the the prediction and the out
363 come. When counting branches taken or not taken, don't consider branches
364 after the first taken branch in a vliw insn. */
365 ps = CPU_PROFILE_STATE (cpu);
366 if (! ps->vliw_branch_taken)
367 {
368 int penalty;
369 /* (1 << 4): The pc is the 5th element in inputs, outputs.
370 ??? can be cleaned up */
371 PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
372 int taken = (referenced & (1 << 4)) != 0;
373 if (taken)
374 {
375 ++PROFILE_MODEL_TAKEN_COUNT (p);
376 ps->vliw_branch_taken = 1;
377 if (BRANCH_PREDICTED (ps))
378 penalty = 1;
379 else
380 penalty = 3;
381 }
382 else
383 {
384 ++PROFILE_MODEL_UNTAKEN_COUNT (p);
385 if (BRANCH_PREDICTED (ps))
386 penalty = 3;
387 else
388 penalty = 0;
389 }
390 if (penalty > 0)
391 {
392 /* Additional 1 cycle penalty if the branch address is not 8 byte
393 aligned. */
394 if (ps->branch_address & 7)
395 ++penalty;
396 update_branch_penalty (cpu, penalty);
397 PROFILE_MODEL_CTI_STALL_CYCLES (p) += penalty;
398 }
399 }
400
401 return cycles;
402 }
403
404 int
405 frvbf_model_fr400_u_trap (SIM_CPU *cpu, const IDESC *idesc,
406 int unit_num, int referenced,
407 INT in_GRi, INT in_GRj,
408 INT in_ICCi_2, INT in_FCCi_2)
409 {
410 /* Modelling for this unit is the same as for fr500. */
411 return frvbf_model_fr500_u_trap (cpu, idesc, unit_num, referenced,
412 in_GRi, in_GRj, in_ICCi_2, in_FCCi_2);
413 }
414
415 int
416 frvbf_model_fr400_u_check (SIM_CPU *cpu, const IDESC *idesc,
417 int unit_num, int referenced,
418 INT in_ICCi_3, INT in_FCCi_3)
419 {
420 /* Modelling for this unit is the same as for fr500. */
421 return frvbf_model_fr500_u_check (cpu, idesc, unit_num, referenced,
422 in_ICCi_3, in_FCCi_3);
423 }
424
425 int
426 frvbf_model_fr400_u_set_hilo (SIM_CPU *cpu, const IDESC *idesc,
427 int unit_num, int referenced,
428 INT out_GRkhi, INT out_GRklo)
429 {
430 /* Modelling for this unit is the same as for fr500. */
431 return frvbf_model_fr500_u_set_hilo (cpu, idesc, unit_num, referenced,
432 out_GRkhi, out_GRklo);
433 }
434
435 int
436 frvbf_model_fr400_u_gr_load (SIM_CPU *cpu, const IDESC *idesc,
437 int unit_num, int referenced,
438 INT in_GRi, INT in_GRj,
439 INT out_GRk, INT out_GRdoublek)
440 {
441 /* Modelling for this unit is the same as for fr500. */
442 return frvbf_model_fr500_u_gr_load (cpu, idesc, unit_num, referenced,
443 in_GRi, in_GRj, out_GRk, out_GRdoublek);
444 }
445
446 int
447 frvbf_model_fr400_u_gr_store (SIM_CPU *cpu, const IDESC *idesc,
448 int unit_num, int referenced,
449 INT in_GRi, INT in_GRj,
450 INT in_GRk, INT in_GRdoublek)
451 {
452 /* Modelling for this unit is the same as for fr500. */
453 return frvbf_model_fr500_u_gr_store (cpu, idesc, unit_num, referenced,
454 in_GRi, in_GRj, in_GRk, in_GRdoublek);
455 }
456
457 int
458 frvbf_model_fr400_u_fr_load (SIM_CPU *cpu, const IDESC *idesc,
459 int unit_num, int referenced,
460 INT in_GRi, INT in_GRj,
461 INT out_FRk, INT out_FRdoublek)
462 {
463 int cycles;
464
465 if (model_insn == FRV_INSN_MODEL_PASS_1)
466 {
467 /* Pass 1 is the same as for fr500. */
468 return frvbf_model_fr500_u_fr_load (cpu, idesc, unit_num, referenced,
469 in_GRi, in_GRj, out_FRk,
470 out_FRdoublek);
471 }
472
473 cycles = idesc->timing->units[unit_num].done;
474
475 /* The latency of FRk for a load will depend on how long it takes to retrieve
476 the the data from the cache or memory. */
477 update_FR_latency_for_load (cpu, out_FRk, cycles);
478 update_FRdouble_latency_for_load (cpu, out_FRdoublek, cycles);
479
480 set_use_is_fp_load (cpu, out_FRk, out_FRdoublek);
481
482 return cycles;
483 }
484
485 int
486 frvbf_model_fr400_u_fr_store (SIM_CPU *cpu, const IDESC *idesc,
487 int unit_num, int referenced,
488 INT in_GRi, INT in_GRj,
489 INT in_FRk, INT in_FRdoublek)
490 {
491 int cycles;
492
493 if (model_insn == FRV_INSN_MODEL_PASS_1)
494 {
495 /* The entire VLIW insn must wait if there is a dependency on a register
496 which is not ready yet.
497 The latency of the registers may be less than previously recorded,
498 depending on how they were used previously.
499 See Table 13-8 in the LSI. */
500 if (in_GRi >= 0)
501 {
502 if (use_is_gr_complex (cpu, in_GRi))
503 decrease_GR_busy (cpu, in_GRi, 1);
504 }
505 if (in_GRj != in_GRi && in_GRj >= 0)
506 {
507 if (use_is_gr_complex (cpu, in_GRj))
508 decrease_GR_busy (cpu, in_GRj, 1);
509 }
510 if (in_FRk >= 0)
511 {
512 if (use_is_media_p4 (cpu, in_FRk) || use_is_media_p6 (cpu, in_FRk))
513 decrease_FR_busy (cpu, in_FRk, 1);
514 else
515 enforce_full_fr_latency (cpu, in_FRk);
516 }
517 vliw_wait_for_GR (cpu, in_GRi);
518 vliw_wait_for_GR (cpu, in_GRj);
519 vliw_wait_for_FR (cpu, in_FRk);
520 vliw_wait_for_FRdouble (cpu, in_FRdoublek);
521 handle_resource_wait (cpu);
522 load_wait_for_GR (cpu, in_GRi);
523 load_wait_for_GR (cpu, in_GRj);
524 load_wait_for_FR (cpu, in_FRk);
525 load_wait_for_FRdouble (cpu, in_FRdoublek);
526 trace_vliw_wait_cycles (cpu);
527 return 0;
528 }
529
530 cycles = idesc->timing->units[unit_num].done;
531
532 return cycles;
533 }
534
535 int
536 frvbf_model_fr400_u_swap (SIM_CPU *cpu, const IDESC *idesc,
537 int unit_num, int referenced,
538 INT in_GRi, INT in_GRj, INT out_GRk)
539 {
540 /* Modelling for this unit is the same as for fr500. */
541 return frvbf_model_fr500_u_swap (cpu, idesc, unit_num, referenced,
542 in_GRi, in_GRj, out_GRk);
543 }
544
545 int
546 frvbf_model_fr400_u_fr2gr (SIM_CPU *cpu, const IDESC *idesc,
547 int unit_num, int referenced,
548 INT in_FRk, INT out_GRj)
549 {
550 int cycles;
551
552 if (model_insn == FRV_INSN_MODEL_PASS_1)
553 {
554 /* The entire VLIW insn must wait if there is a dependency on a register
555 which is not ready yet.
556 The latency of the registers may be less than previously recorded,
557 depending on how they were used previously.
558 See Table 13-8 in the LSI. */
559 if (in_FRk >= 0)
560 {
561 if (use_is_media_p4 (cpu, in_FRk) || use_is_media_p6 (cpu, in_FRk))
562 decrease_FR_busy (cpu, in_FRk, 1);
563 else
564 enforce_full_fr_latency (cpu, in_FRk);
565 }
566 vliw_wait_for_FR (cpu, in_FRk);
567 vliw_wait_for_GR (cpu, out_GRj);
568 handle_resource_wait (cpu);
569 load_wait_for_FR (cpu, in_FRk);
570 load_wait_for_GR (cpu, out_GRj);
571 trace_vliw_wait_cycles (cpu);
572 return 0;
573 }
574
575 /* The latency of GRj is 2 cycles. */
576 cycles = idesc->timing->units[unit_num].done;
577 update_GR_latency (cpu, out_GRj, cycles + 2);
578 set_use_is_gr_complex (cpu, out_GRj);
579
580 return cycles;
581 }
582
583 int
584 frvbf_model_fr400_u_spr2gr (SIM_CPU *cpu, const IDESC *idesc,
585 int unit_num, int referenced,
586 INT in_spr, INT out_GRj)
587 {
588 /* Modelling for this unit is the same as for fr500. */
589 return frvbf_model_fr500_u_spr2gr (cpu, idesc, unit_num, referenced,
590 in_spr, out_GRj);
591 }
592
593 int
594 frvbf_model_fr400_u_gr2fr (SIM_CPU *cpu, const IDESC *idesc,
595 int unit_num, int referenced,
596 INT in_GRj, INT out_FRk)
597 {
598 int cycles;
599
600 if (model_insn == FRV_INSN_MODEL_PASS_1)
601 {
602 /* Pass 1 is the same as for fr500. */
603 frvbf_model_fr500_u_gr2fr (cpu, idesc, unit_num, referenced,
604 in_GRj, out_FRk);
605 }
606
607 /* The latency of FRk is 1 cycles. */
608 cycles = idesc->timing->units[unit_num].done;
609 update_FR_latency (cpu, out_FRk, cycles + 1);
610
611 return cycles;
612 }
613
614 int
615 frvbf_model_fr400_u_gr2spr (SIM_CPU *cpu, const IDESC *idesc,
616 int unit_num, int referenced,
617 INT in_GRj, INT out_spr)
618 {
619 /* Modelling for this unit is the same as for fr500. */
620 return frvbf_model_fr500_u_gr2spr (cpu, idesc, unit_num, referenced,
621 in_GRj, out_spr);
622 }
623
624 /* Top up the post-processing time of the given FR by the given number of
625 cycles. */
626 static void
627 update_FR_ptime (SIM_CPU *cpu, INT out_FR, int cycles)
628 {
629 if (out_FR >= 0)
630 {
631 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
632 /* If a load is pending on this register, then add the cycles to
633 the post processing time for this register. Otherwise apply it
634 directly to the latency of the register. */
635 if (! load_pending_for_register (cpu, out_FR, 1, REGTYPE_FR))
636 {
637 int *fr = ps->fr_latency;
638 fr[out_FR] += cycles;
639 }
640 else
641 ps->fr_ptime[out_FR] += cycles;
642 }
643 }
644
645 static void
646 update_FRdouble_ptime (SIM_CPU *cpu, INT out_FR, int cycles)
647 {
648 if (out_FR >= 0)
649 {
650 FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
651 /* If a load is pending on this register, then add the cycles to
652 the post processing time for this register. Otherwise apply it
653 directly to the latency of the register. */
654 if (! load_pending_for_register (cpu, out_FR, 2, REGTYPE_FR))
655 {
656 int *fr = ps->fr_latency;
657 fr[out_FR] += cycles;
658 if (out_FR < 63)
659 fr[out_FR + 1] += cycles;
660 }
661 else
662 {
663 /* On the fr400, loads are available to media insns one cycle early,
664 so knock one cycle off the post processing time to account for
665 this. */
666 ps->fr_ptime[out_FR] += cycles - 1;
667 if (out_FR < 63)
668 ps->fr_ptime[out_FR + 1] += cycles - 1;
669 }
670 }
671 }
672
673 int
674 frvbf_model_fr400_u_media_1 (SIM_CPU *cpu, const IDESC *idesc,
675 int unit_num, int referenced,
676 INT in_FRi, INT in_FRj,
677 INT out_FRk)
678 {
679 int cycles;
680 FRV_PROFILE_STATE *ps;
681 const CGEN_INSN *insn;
682 int busy_adjustment[] = {0, 0};
683 int *fr;
684
685 if (model_insn == FRV_INSN_MODEL_PASS_1)
686 return 0;
687
688 /* The preprocessing can execute right away. */
689 cycles = idesc->timing->units[unit_num].done;
690
691 ps = CPU_PROFILE_STATE (cpu);
692 insn = idesc->idata;
693
694 /* The latency of the registers may be less than previously recorded,
695 depending on how they were used previously.
696 See Table 13-8 in the LSI. */
697 if (in_FRi >= 0)
698 {
699 if (use_is_fp_load (cpu, in_FRi))
700 {
701 busy_adjustment[0] = 1;
702 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
703 }
704 else
705 enforce_full_fr_latency (cpu, in_FRi);
706 }
707 if (in_FRj >= 0 && in_FRj != in_FRi)
708 {
709 if (use_is_fp_load (cpu, in_FRj))
710 {
711 busy_adjustment[1] = 1;
712 decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
713 }
714 else
715 enforce_full_fr_latency (cpu, in_FRj);
716 }
717
718 /* The post processing must wait if there is a dependency on a FR
719 which is not ready yet. */
720 ps->post_wait = cycles;
721 post_wait_for_FR (cpu, in_FRi);
722 post_wait_for_FR (cpu, in_FRj);
723 post_wait_for_FR (cpu, out_FRk);
724
725 /* Restore the busy cycles of the registers we used. */
726 fr = ps->fr_busy;
727 if (in_FRi >= 0)
728 fr[in_FRi] += busy_adjustment[0];
729 if (in_FRj >= 0)
730 fr[in_FRj] += busy_adjustment[1];
731
732 /* The latency of the output register will be at least the latency of the
733 other inputs. Once initiated, post-processing has no latency. */
734 if (out_FRk >= 0)
735 {
736 update_FR_latency (cpu, out_FRk, ps->post_wait);
737 update_FR_ptime (cpu, out_FRk, 0);
738 }
739
740 return cycles;
741 }
742
743 int
744 frvbf_model_fr400_u_media_1_quad (SIM_CPU *cpu, const IDESC *idesc,
745 int unit_num, int referenced,
746 INT in_FRi, INT in_FRj,
747 INT out_FRk)
748 {
749 int cycles;
750 INT dual_FRi;
751 INT dual_FRj;
752 INT dual_FRk;
753 FRV_PROFILE_STATE *ps;
754 int busy_adjustment[] = {0, 0, 0, 0};
755 int *fr;
756
757 if (model_insn == FRV_INSN_MODEL_PASS_1)
758 return 0;
759
760 /* The preprocessing can execute right away. */
761 cycles = idesc->timing->units[unit_num].done;
762
763 ps = CPU_PROFILE_STATE (cpu);
764 dual_FRi = DUAL_REG (in_FRi);
765 dual_FRj = DUAL_REG (in_FRj);
766 dual_FRk = DUAL_REG (out_FRk);
767
768 /* The latency of the registers may be less than previously recorded,
769 depending on how they were used previously.
770 See Table 13-8 in the LSI. */
771 if (use_is_fp_load (cpu, in_FRi))
772 {
773 busy_adjustment[0] = 1;
774 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
775 }
776 else
777 enforce_full_fr_latency (cpu, in_FRi);
778 if (dual_FRi >= 0 && use_is_fp_load (cpu, dual_FRi))
779 {
780 busy_adjustment[1] = 1;
781 decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
782 }
783 else
784 enforce_full_fr_latency (cpu, dual_FRi);
785 if (in_FRj != in_FRi)
786 {
787 if (use_is_fp_load (cpu, in_FRj))
788 {
789 busy_adjustment[2] = 1;
790 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
791 }
792 else
793 enforce_full_fr_latency (cpu, in_FRj);
794 if (dual_FRj >= 0 && use_is_fp_load (cpu, dual_FRj))
795 {
796 busy_adjustment[3] = 1;
797 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[3]);
798 }
799 else
800 enforce_full_fr_latency (cpu, dual_FRj);
801 }
802
803 /* The post processing must wait if there is a dependency on a FR
804 which is not ready yet. */
805 ps->post_wait = cycles;
806 post_wait_for_FR (cpu, in_FRi);
807 post_wait_for_FR (cpu, dual_FRi);
808 post_wait_for_FR (cpu, in_FRj);
809 post_wait_for_FR (cpu, dual_FRj);
810 post_wait_for_FR (cpu, out_FRk);
811 post_wait_for_FR (cpu, dual_FRk);
812
813 /* Restore the busy cycles of the registers we used. */
814 fr = ps->fr_busy;
815 fr[in_FRi] += busy_adjustment[0];
816 if (dual_FRi >= 0)
817 fr[dual_FRi] += busy_adjustment[1];
818 fr[in_FRj] += busy_adjustment[2];
819 if (dual_FRj >= 0)
820 fr[dual_FRj] += busy_adjustment[3];
821
822 /* The latency of the output register will be at least the latency of the
823 other inputs. */
824 update_FR_latency (cpu, out_FRk, ps->post_wait);
825
826 /* Once initiated, post-processing has no latency. */
827 update_FR_ptime (cpu, out_FRk, 0);
828
829 if (dual_FRk >= 0)
830 {
831 update_FR_latency (cpu, dual_FRk, ps->post_wait);
832 update_FR_ptime (cpu, dual_FRk, 0);
833 }
834
835 return cycles;
836 }
837
838 int
839 frvbf_model_fr400_u_media_hilo (SIM_CPU *cpu, const IDESC *idesc,
840 int unit_num, int referenced,
841 INT out_FRkhi, INT out_FRklo)
842 {
843 int cycles;
844 FRV_PROFILE_STATE *ps;
845
846 if (model_insn == FRV_INSN_MODEL_PASS_1)
847 return 0;
848
849 /* The preprocessing can execute right away. */
850 cycles = idesc->timing->units[unit_num].done;
851
852 ps = CPU_PROFILE_STATE (cpu);
853
854 /* The post processing must wait if there is a dependency on a FR
855 which is not ready yet. */
856 ps->post_wait = cycles;
857 post_wait_for_FR (cpu, out_FRkhi);
858 post_wait_for_FR (cpu, out_FRklo);
859
860 /* The latency of the output register will be at least the latency of the
861 other inputs. Once initiated, post-processing has no latency. */
862 if (out_FRkhi >= 0)
863 {
864 update_FR_latency (cpu, out_FRkhi, ps->post_wait);
865 update_FR_ptime (cpu, out_FRkhi, 0);
866 }
867 if (out_FRklo >= 0)
868 {
869 update_FR_latency (cpu, out_FRklo, ps->post_wait);
870 update_FR_ptime (cpu, out_FRklo, 0);
871 }
872
873 return cycles;
874 }
875
876 int
877 frvbf_model_fr400_u_media_2 (SIM_CPU *cpu, const IDESC *idesc,
878 int unit_num, int referenced,
879 INT in_FRi, INT in_FRj,
880 INT out_ACC40Sk, INT out_ACC40Uk)
881 {
882 int cycles;
883 INT dual_ACC40Sk;
884 INT dual_ACC40Uk;
885 FRV_PROFILE_STATE *ps;
886 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
887 int *fr;
888 int *acc;
889
890 if (model_insn == FRV_INSN_MODEL_PASS_1)
891 return 0;
892
893 /* The preprocessing can execute right away. */
894 cycles = idesc->timing->units[unit_num].done;
895
896 ps = CPU_PROFILE_STATE (cpu);
897 dual_ACC40Sk = DUAL_REG (out_ACC40Sk);
898 dual_ACC40Uk = DUAL_REG (out_ACC40Uk);
899
900 /* The latency of the registers may be less than previously recorded,
901 depending on how they were used previously.
902 See Table 13-8 in the LSI. */
903 if (in_FRi >= 0)
904 {
905 if (use_is_fp_load (cpu, in_FRi))
906 {
907 busy_adjustment[0] = 1;
908 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
909 }
910 else
911 enforce_full_fr_latency (cpu, in_FRi);
912 }
913 if (in_FRj >= 0 && in_FRj != in_FRi)
914 {
915 if (use_is_fp_load (cpu, in_FRj))
916 {
917 busy_adjustment[1] = 1;
918 decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
919 }
920 else
921 enforce_full_fr_latency (cpu, in_FRj);
922 }
923 if (out_ACC40Sk >= 0)
924 {
925 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
926 {
927 busy_adjustment[2] = 1;
928 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
929 }
930 }
931 if (dual_ACC40Sk >= 0)
932 {
933 if (acc_use_is_media_p2 (cpu, dual_ACC40Sk))
934 {
935 busy_adjustment[3] = 1;
936 decrease_ACC_busy (cpu, dual_ACC40Sk, busy_adjustment[3]);
937 }
938 }
939 if (out_ACC40Uk >= 0)
940 {
941 if (acc_use_is_media_p2 (cpu, out_ACC40Uk))
942 {
943 busy_adjustment[4] = 1;
944 decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
945 }
946 }
947 if (dual_ACC40Uk >= 0)
948 {
949 if (acc_use_is_media_p2 (cpu, dual_ACC40Uk))
950 {
951 busy_adjustment[5] = 1;
952 decrease_ACC_busy (cpu, dual_ACC40Uk, busy_adjustment[5]);
953 }
954 }
955
956 /* The post processing must wait if there is a dependency on a FR
957 which is not ready yet. */
958 ps->post_wait = cycles;
959 post_wait_for_FR (cpu, in_FRi);
960 post_wait_for_FR (cpu, in_FRj);
961 post_wait_for_ACC (cpu, out_ACC40Sk);
962 post_wait_for_ACC (cpu, dual_ACC40Sk);
963 post_wait_for_ACC (cpu, out_ACC40Uk);
964 post_wait_for_ACC (cpu, dual_ACC40Uk);
965
966 /* Restore the busy cycles of the registers we used. */
967 fr = ps->fr_busy;
968 acc = ps->acc_busy;
969 fr[in_FRi] += busy_adjustment[0];
970 fr[in_FRj] += busy_adjustment[1];
971 if (out_ACC40Sk >= 0)
972 acc[out_ACC40Sk] += busy_adjustment[2];
973 if (dual_ACC40Sk >= 0)
974 acc[dual_ACC40Sk] += busy_adjustment[3];
975 if (out_ACC40Uk >= 0)
976 acc[out_ACC40Uk] += busy_adjustment[4];
977 if (dual_ACC40Uk >= 0)
978 acc[dual_ACC40Uk] += busy_adjustment[5];
979
980 /* The latency of the output register will be at least the latency of the
981 other inputs. Once initiated, post-processing will take 1 cycles. */
982 if (out_ACC40Sk >= 0)
983 {
984 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
985 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
986 }
987 if (dual_ACC40Sk >= 0)
988 {
989 update_ACC_latency (cpu, dual_ACC40Sk, ps->post_wait + 1);
990 set_acc_use_is_media_p2 (cpu, dual_ACC40Sk);
991 }
992 if (out_ACC40Uk >= 0)
993 {
994 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
995 set_acc_use_is_media_p2 (cpu, out_ACC40Uk);
996 }
997 if (dual_ACC40Uk >= 0)
998 {
999 update_ACC_latency (cpu, dual_ACC40Uk, ps->post_wait + 1);
1000 set_acc_use_is_media_p2 (cpu, dual_ACC40Uk);
1001 }
1002
1003 return cycles;
1004 }
1005
1006 int
1007 frvbf_model_fr400_u_media_2_quad (SIM_CPU *cpu, const IDESC *idesc,
1008 int unit_num, int referenced,
1009 INT in_FRi, INT in_FRj,
1010 INT out_ACC40Sk, INT out_ACC40Uk)
1011 {
1012 int cycles;
1013 INT dual_FRi;
1014 INT dual_FRj;
1015 INT ACC40Sk_1;
1016 INT ACC40Sk_2;
1017 INT ACC40Sk_3;
1018 INT ACC40Uk_1;
1019 INT ACC40Uk_2;
1020 INT ACC40Uk_3;
1021 FRV_PROFILE_STATE *ps;
1022 int busy_adjustment[] = {0, 0, 0, 0, 0, 0, 0 ,0};
1023 int *fr;
1024 int *acc;
1025
1026 if (model_insn == FRV_INSN_MODEL_PASS_1)
1027 return 0;
1028
1029 /* The preprocessing can execute right away. */
1030 cycles = idesc->timing->units[unit_num].done;
1031
1032 dual_FRi = DUAL_REG (in_FRi);
1033 dual_FRj = DUAL_REG (in_FRj);
1034 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
1035 ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
1036 ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
1037 ACC40Uk_1 = DUAL_REG (out_ACC40Uk);
1038 ACC40Uk_2 = DUAL_REG (ACC40Uk_1);
1039 ACC40Uk_3 = DUAL_REG (ACC40Uk_2);
1040
1041 ps = CPU_PROFILE_STATE (cpu);
1042 /* The latency of the registers may be less than previously recorded,
1043 depending on how they were used previously.
1044 See Table 13-8 in the LSI. */
1045 if (use_is_fp_load (cpu, in_FRi))
1046 {
1047 busy_adjustment[0] = 1;
1048 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
1049 }
1050 else
1051 enforce_full_fr_latency (cpu, in_FRi);
1052 if (dual_FRi >= 0 && use_is_fp_load (cpu, dual_FRi))
1053 {
1054 busy_adjustment[1] = 1;
1055 decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
1056 }
1057 else
1058 enforce_full_fr_latency (cpu, dual_FRi);
1059 if (in_FRj != in_FRi)
1060 {
1061 if (use_is_fp_load (cpu, in_FRj))
1062 {
1063 busy_adjustment[2] = 1;
1064 decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
1065 }
1066 else
1067 enforce_full_fr_latency (cpu, in_FRj);
1068 if (dual_FRj >= 0 && use_is_fp_load (cpu, dual_FRj))
1069 {
1070 busy_adjustment[3] = 1;
1071 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[3]);
1072 }
1073 else
1074 enforce_full_fr_latency (cpu, dual_FRj);
1075 }
1076 if (out_ACC40Sk >= 0)
1077 {
1078 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
1079 {
1080 busy_adjustment[4] = 1;
1081 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
1082 }
1083 if (ACC40Sk_1 >= 0)
1084 {
1085 if (acc_use_is_media_p2 (cpu, ACC40Sk_1))
1086 {
1087 busy_adjustment[5] = 1;
1088 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
1089 }
1090 }
1091 if (ACC40Sk_2 >= 0)
1092 {
1093 if (acc_use_is_media_p2 (cpu, ACC40Sk_2))
1094 {
1095 busy_adjustment[6] = 1;
1096 decrease_ACC_busy (cpu, ACC40Sk_2, busy_adjustment[6]);
1097 }
1098 }
1099 if (ACC40Sk_3 >= 0)
1100 {
1101 if (acc_use_is_media_p2 (cpu, ACC40Sk_3))
1102 {
1103 busy_adjustment[7] = 1;
1104 decrease_ACC_busy (cpu, ACC40Sk_3, busy_adjustment[7]);
1105 }
1106 }
1107 }
1108 else if (out_ACC40Uk >= 0)
1109 {
1110 if (acc_use_is_media_p2 (cpu, out_ACC40Uk))
1111 {
1112 busy_adjustment[4] = 1;
1113 decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
1114 }
1115 if (ACC40Uk_1 >= 0)
1116 {
1117 if (acc_use_is_media_p2 (cpu, ACC40Uk_1))
1118 {
1119 busy_adjustment[5] = 1;
1120 decrease_ACC_busy (cpu, ACC40Uk_1, busy_adjustment[5]);
1121 }
1122 }
1123 if (ACC40Uk_2 >= 0)
1124 {
1125 if (acc_use_is_media_p2 (cpu, ACC40Uk_2))
1126 {
1127 busy_adjustment[6] = 1;
1128 decrease_ACC_busy (cpu, ACC40Uk_2, busy_adjustment[6]);
1129 }
1130 }
1131 if (ACC40Uk_3 >= 0)
1132 {
1133 if (acc_use_is_media_p2 (cpu, ACC40Uk_3))
1134 {
1135 busy_adjustment[7] = 1;
1136 decrease_ACC_busy (cpu, ACC40Uk_3, busy_adjustment[7]);
1137 }
1138 }
1139 }
1140
1141 /* The post processing must wait if there is a dependency on a FR
1142 which is not ready yet. */
1143 ps->post_wait = cycles;
1144 post_wait_for_FR (cpu, in_FRi);
1145 post_wait_for_FR (cpu, dual_FRi);
1146 post_wait_for_FR (cpu, in_FRj);
1147 post_wait_for_FR (cpu, dual_FRj);
1148 post_wait_for_ACC (cpu, out_ACC40Sk);
1149 post_wait_for_ACC (cpu, ACC40Sk_1);
1150 post_wait_for_ACC (cpu, ACC40Sk_2);
1151 post_wait_for_ACC (cpu, ACC40Sk_3);
1152 post_wait_for_ACC (cpu, out_ACC40Uk);
1153 post_wait_for_ACC (cpu, ACC40Uk_1);
1154 post_wait_for_ACC (cpu, ACC40Uk_2);
1155 post_wait_for_ACC (cpu, ACC40Uk_3);
1156
1157 /* Restore the busy cycles of the registers we used. */
1158 fr = ps->fr_busy;
1159 acc = ps->acc_busy;
1160 fr[in_FRi] += busy_adjustment[0];
1161 if (dual_FRi >= 0)
1162 fr[dual_FRi] += busy_adjustment[1];
1163 fr[in_FRj] += busy_adjustment[2];
1164 if (dual_FRj > 0)
1165 fr[dual_FRj] += busy_adjustment[3];
1166 if (out_ACC40Sk >= 0)
1167 {
1168 acc[out_ACC40Sk] += busy_adjustment[4];
1169 if (ACC40Sk_1 >= 0)
1170 acc[ACC40Sk_1] += busy_adjustment[5];
1171 if (ACC40Sk_2 >= 0)
1172 acc[ACC40Sk_2] += busy_adjustment[6];
1173 if (ACC40Sk_3 >= 0)
1174 acc[ACC40Sk_3] += busy_adjustment[7];
1175 }
1176 else if (out_ACC40Uk >= 0)
1177 {
1178 acc[out_ACC40Uk] += busy_adjustment[4];
1179 if (ACC40Uk_1 >= 0)
1180 acc[ACC40Uk_1] += busy_adjustment[5];
1181 if (ACC40Uk_2 >= 0)
1182 acc[ACC40Uk_2] += busy_adjustment[6];
1183 if (ACC40Uk_3 >= 0)
1184 acc[ACC40Uk_3] += busy_adjustment[7];
1185 }
1186
1187 /* The latency of the output register will be at least the latency of the
1188 other inputs. Once initiated, post-processing will take 1 cycle. */
1189 if (out_ACC40Sk >= 0)
1190 {
1191 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1192
1193 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1194 if (ACC40Sk_1 >= 0)
1195 {
1196 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
1197
1198 set_acc_use_is_media_p2 (cpu, ACC40Sk_1);
1199 }
1200 if (ACC40Sk_2 >= 0)
1201 {
1202 update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
1203
1204 set_acc_use_is_media_p2 (cpu, ACC40Sk_2);
1205 }
1206 if (ACC40Sk_3 >= 0)
1207 {
1208 update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
1209
1210 set_acc_use_is_media_p2 (cpu, ACC40Sk_3);
1211 }
1212 }
1213 else if (out_ACC40Uk >= 0)
1214 {
1215 update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
1216
1217 set_acc_use_is_media_p2 (cpu, out_ACC40Uk);
1218 if (ACC40Uk_1 >= 0)
1219 {
1220 update_ACC_latency (cpu, ACC40Uk_1, ps->post_wait + 1);
1221
1222 set_acc_use_is_media_p2 (cpu, ACC40Uk_1);
1223 }
1224 if (ACC40Uk_2 >= 0)
1225 {
1226 update_ACC_latency (cpu, ACC40Uk_2, ps->post_wait + 1);
1227
1228 set_acc_use_is_media_p2 (cpu, ACC40Uk_2);
1229 }
1230 if (ACC40Uk_3 >= 0)
1231 {
1232 update_ACC_latency (cpu, ACC40Uk_3, ps->post_wait + 1);
1233
1234 set_acc_use_is_media_p2 (cpu, ACC40Uk_3);
1235 }
1236 }
1237
1238 return cycles;
1239 }
1240
1241 int
1242 frvbf_model_fr400_u_media_2_acc (SIM_CPU *cpu, const IDESC *idesc,
1243 int unit_num, int referenced,
1244 INT in_ACC40Si, INT out_ACC40Sk)
1245 {
1246 int cycles;
1247 INT ACC40Si_1;
1248 FRV_PROFILE_STATE *ps;
1249 int busy_adjustment[] = {0, 0, 0};
1250 int *acc;
1251
1252 if (model_insn == FRV_INSN_MODEL_PASS_1)
1253 return 0;
1254
1255 /* The preprocessing can execute right away. */
1256 cycles = idesc->timing->units[unit_num].done;
1257
1258 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1259
1260 ps = CPU_PROFILE_STATE (cpu);
1261 /* The latency of the registers may be less than previously recorded,
1262 depending on how they were used previously.
1263 See Table 13-8 in the LSI. */
1264 if (acc_use_is_media_p2 (cpu, in_ACC40Si))
1265 {
1266 busy_adjustment[0] = 1;
1267 decrease_ACC_busy (cpu, in_ACC40Si, busy_adjustment[0]);
1268 }
1269 if (ACC40Si_1 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_1))
1270 {
1271 busy_adjustment[1] = 1;
1272 decrease_ACC_busy (cpu, ACC40Si_1, busy_adjustment[1]);
1273 }
1274 if (out_ACC40Sk != in_ACC40Si && out_ACC40Sk != ACC40Si_1
1275 && acc_use_is_media_p2 (cpu, out_ACC40Sk))
1276 {
1277 busy_adjustment[2] = 1;
1278 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
1279 }
1280
1281 /* The post processing must wait if there is a dependency on a register
1282 which is not ready yet. */
1283 ps->post_wait = cycles;
1284 post_wait_for_ACC (cpu, in_ACC40Si);
1285 post_wait_for_ACC (cpu, ACC40Si_1);
1286 post_wait_for_ACC (cpu, out_ACC40Sk);
1287
1288 /* Restore the busy cycles of the registers we used. */
1289 acc = ps->acc_busy;
1290 acc[in_ACC40Si] += busy_adjustment[0];
1291 if (ACC40Si_1 >= 0)
1292 acc[ACC40Si_1] += busy_adjustment[1];
1293 acc[out_ACC40Sk] += busy_adjustment[2];
1294
1295 /* The latency of the output register will be at least the latency of the
1296 other inputs. Once initiated, post-processing will take 1 cycle. */
1297 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1298 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1299
1300 return cycles;
1301 }
1302
1303 int
1304 frvbf_model_fr400_u_media_2_acc_dual (SIM_CPU *cpu, const IDESC *idesc,
1305 int unit_num, int referenced,
1306 INT in_ACC40Si, INT out_ACC40Sk)
1307 {
1308 int cycles;
1309 INT ACC40Si_1;
1310 INT ACC40Si_2;
1311 INT ACC40Si_3;
1312 INT ACC40Sk_1;
1313 FRV_PROFILE_STATE *ps;
1314 int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
1315 int *acc;
1316
1317 if (model_insn == FRV_INSN_MODEL_PASS_1)
1318 return 0;
1319
1320 /* The preprocessing can execute right away. */
1321 cycles = idesc->timing->units[unit_num].done;
1322
1323 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1324 ACC40Si_2 = DUAL_REG (ACC40Si_1);
1325 ACC40Si_3 = DUAL_REG (ACC40Si_2);
1326 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
1327
1328 ps = CPU_PROFILE_STATE (cpu);
1329 /* The latency of the registers may be less than previously recorded,
1330 depending on how they were used previously.
1331 See Table 13-8 in the LSI. */
1332 if (acc_use_is_media_p2 (cpu, in_ACC40Si))
1333 {
1334 busy_adjustment[0] = 1;
1335 decrease_ACC_busy (cpu, in_ACC40Si, busy_adjustment[0]);
1336 }
1337 if (ACC40Si_1 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_1))
1338 {
1339 busy_adjustment[1] = 1;
1340 decrease_ACC_busy (cpu, ACC40Si_1, busy_adjustment[1]);
1341 }
1342 if (ACC40Si_2 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_2))
1343 {
1344 busy_adjustment[2] = 1;
1345 decrease_ACC_busy (cpu, ACC40Si_2, busy_adjustment[2]);
1346 }
1347 if (ACC40Si_3 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_3))
1348 {
1349 busy_adjustment[3] = 1;
1350 decrease_ACC_busy (cpu, ACC40Si_3, busy_adjustment[3]);
1351 }
1352 if (out_ACC40Sk != in_ACC40Si && out_ACC40Sk != ACC40Si_1
1353 && out_ACC40Sk != ACC40Si_2 && out_ACC40Sk != ACC40Si_3)
1354 {
1355 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
1356 {
1357 busy_adjustment[4] = 1;
1358 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
1359 }
1360 }
1361 if (ACC40Sk_1 != in_ACC40Si && ACC40Sk_1 != ACC40Si_1
1362 && ACC40Sk_1 != ACC40Si_2 && ACC40Sk_1 != ACC40Si_3)
1363 {
1364 if (acc_use_is_media_p2 (cpu, ACC40Sk_1))
1365 {
1366 busy_adjustment[5] = 1;
1367 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
1368 }
1369 }
1370
1371 /* The post processing must wait if there is a dependency on a register
1372 which is not ready yet. */
1373 ps->post_wait = cycles;
1374 post_wait_for_ACC (cpu, in_ACC40Si);
1375 post_wait_for_ACC (cpu, ACC40Si_1);
1376 post_wait_for_ACC (cpu, ACC40Si_2);
1377 post_wait_for_ACC (cpu, ACC40Si_3);
1378 post_wait_for_ACC (cpu, out_ACC40Sk);
1379 post_wait_for_ACC (cpu, ACC40Sk_1);
1380
1381 /* Restore the busy cycles of the registers we used. */
1382 acc = ps->acc_busy;
1383 acc[in_ACC40Si] += busy_adjustment[0];
1384 if (ACC40Si_1 >= 0)
1385 acc[ACC40Si_1] += busy_adjustment[1];
1386 if (ACC40Si_2 >= 0)
1387 acc[ACC40Si_2] += busy_adjustment[2];
1388 if (ACC40Si_3 >= 0)
1389 acc[ACC40Si_3] += busy_adjustment[3];
1390 acc[out_ACC40Sk] += busy_adjustment[4];
1391 if (ACC40Sk_1 >= 0)
1392 acc[ACC40Sk_1] += busy_adjustment[5];
1393
1394 /* The latency of the output register will be at least the latency of the
1395 other inputs. Once initiated, post-processing will take 1 cycle. */
1396 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1397 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1398 if (ACC40Sk_1 >= 0)
1399 {
1400 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
1401 set_acc_use_is_media_p2 (cpu, ACC40Sk_1);
1402 }
1403
1404 return cycles;
1405 }
1406
1407 int
1408 frvbf_model_fr400_u_media_2_add_sub (SIM_CPU *cpu, const IDESC *idesc,
1409 int unit_num, int referenced,
1410 INT in_ACC40Si, INT out_ACC40Sk)
1411 {
1412 int cycles;
1413 INT ACC40Si_1;
1414 INT ACC40Sk_1;
1415 FRV_PROFILE_STATE *ps;
1416 int busy_adjustment[] = {0, 0, 0, 0};
1417 int *acc;
1418
1419 if (model_insn == FRV_INSN_MODEL_PASS_1)
1420 return 0;
1421
1422 /* The preprocessing can execute right away. */
1423 cycles = idesc->timing->units[unit_num].done;
1424
1425 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1426 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
1427
1428 ps = CPU_PROFILE_STATE (cpu);
1429 /* The latency of the registers may be less than previously recorded,
1430 depending on how they were used previously.
1431 See Table 13-8 in the LSI. */
1432 if (acc_use_is_media_p2 (cpu, in_ACC40Si))
1433 {
1434 busy_adjustment[0] = 1;
1435 decrease_ACC_busy (cpu, in_ACC40Si, busy_adjustment[0]);
1436 }
1437 if (ACC40Si_1 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_1))
1438 {
1439 busy_adjustment[1] = 1;
1440 decrease_ACC_busy (cpu, ACC40Si_1, busy_adjustment[1]);
1441 }
1442 if (out_ACC40Sk != in_ACC40Si && out_ACC40Sk != ACC40Si_1)
1443 {
1444 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
1445 {
1446 busy_adjustment[2] = 1;
1447 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
1448 }
1449 }
1450 if (ACC40Sk_1 != in_ACC40Si && ACC40Sk_1 != ACC40Si_1)
1451 {
1452 if (acc_use_is_media_p2 (cpu, ACC40Sk_1))
1453 {
1454 busy_adjustment[3] = 1;
1455 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[3]);
1456 }
1457 }
1458
1459 /* The post processing must wait if there is a dependency on a register
1460 which is not ready yet. */
1461 ps->post_wait = cycles;
1462 post_wait_for_ACC (cpu, in_ACC40Si);
1463 post_wait_for_ACC (cpu, ACC40Si_1);
1464 post_wait_for_ACC (cpu, out_ACC40Sk);
1465 post_wait_for_ACC (cpu, ACC40Sk_1);
1466
1467 /* Restore the busy cycles of the registers we used. */
1468 acc = ps->acc_busy;
1469 acc[in_ACC40Si] += busy_adjustment[0];
1470 if (ACC40Si_1 >= 0)
1471 acc[ACC40Si_1] += busy_adjustment[1];
1472 acc[out_ACC40Sk] += busy_adjustment[2];
1473 if (ACC40Sk_1 >= 0)
1474 acc[ACC40Sk_1] += busy_adjustment[3];
1475
1476 /* The latency of the output register will be at least the latency of the
1477 other inputs. Once initiated, post-processing will take 1 cycle. */
1478 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1479 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1480 if (ACC40Sk_1 >= 0)
1481 {
1482 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
1483 set_acc_use_is_media_p2 (cpu, ACC40Sk_1);
1484 }
1485
1486 return cycles;
1487 }
1488
1489 int
1490 frvbf_model_fr400_u_media_2_add_sub_dual (SIM_CPU *cpu, const IDESC *idesc,
1491 int unit_num, int referenced,
1492 INT in_ACC40Si, INT out_ACC40Sk)
1493 {
1494 int cycles;
1495 INT ACC40Si_1;
1496 INT ACC40Si_2;
1497 INT ACC40Si_3;
1498 INT ACC40Sk_1;
1499 INT ACC40Sk_2;
1500 INT ACC40Sk_3;
1501 FRV_PROFILE_STATE *ps;
1502 int busy_adjustment[] = {0, 0, 0, 0, 0, 0, 0, 0};
1503 int *acc;
1504
1505 if (model_insn == FRV_INSN_MODEL_PASS_1)
1506 return 0;
1507
1508 /* The preprocessing can execute right away. */
1509 cycles = idesc->timing->units[unit_num].done;
1510
1511 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1512 ACC40Si_2 = DUAL_REG (ACC40Si_1);
1513 ACC40Si_3 = DUAL_REG (ACC40Si_2);
1514 ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
1515 ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
1516 ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
1517
1518 ps = CPU_PROFILE_STATE (cpu);
1519 /* The latency of the registers may be less than previously recorded,
1520 depending on how they were used previously.
1521 See Table 13-8 in the LSI. */
1522 if (acc_use_is_media_p2 (cpu, in_ACC40Si))
1523 {
1524 busy_adjustment[0] = 1;
1525 decrease_ACC_busy (cpu, in_ACC40Si, busy_adjustment[0]);
1526 }
1527 if (ACC40Si_1 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_1))
1528 {
1529 busy_adjustment[1] = 1;
1530 decrease_ACC_busy (cpu, ACC40Si_1, busy_adjustment[1]);
1531 }
1532 if (ACC40Si_2 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_2))
1533 {
1534 busy_adjustment[2] = 1;
1535 decrease_ACC_busy (cpu, ACC40Si_2, busy_adjustment[2]);
1536 }
1537 if (ACC40Si_3 >= 0 && acc_use_is_media_p2 (cpu, ACC40Si_3))
1538 {
1539 busy_adjustment[3] = 1;
1540 decrease_ACC_busy (cpu, ACC40Si_3, busy_adjustment[3]);
1541 }
1542 if (out_ACC40Sk != in_ACC40Si && out_ACC40Sk != ACC40Si_1
1543 && out_ACC40Sk != ACC40Si_2 && out_ACC40Sk != ACC40Si_3)
1544 {
1545 if (acc_use_is_media_p2 (cpu, out_ACC40Sk))
1546 {
1547 busy_adjustment[4] = 1;
1548 decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
1549 }
1550 }
1551 if (ACC40Sk_1 != in_ACC40Si && ACC40Sk_1 != ACC40Si_1
1552 && ACC40Sk_1 != ACC40Si_2 && ACC40Sk_1 != ACC40Si_3)
1553 {
1554 if (acc_use_is_media_p2 (cpu, ACC40Sk_1))
1555 {
1556 busy_adjustment[5] = 1;
1557 decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
1558 }
1559 }
1560 if (ACC40Sk_2 != in_ACC40Si && ACC40Sk_2 != ACC40Si_1
1561 && ACC40Sk_2 != ACC40Si_2 && ACC40Sk_2 != ACC40Si_3)
1562 {
1563 if (acc_use_is_media_p2 (cpu, ACC40Sk_2))
1564 {
1565 busy_adjustment[6] = 1;
1566 decrease_ACC_busy (cpu, ACC40Sk_2, busy_adjustment[6]);
1567 }
1568 }
1569 if (ACC40Sk_3 != in_ACC40Si && ACC40Sk_3 != ACC40Si_1
1570 && ACC40Sk_3 != ACC40Si_2 && ACC40Sk_3 != ACC40Si_3)
1571 {
1572 if (acc_use_is_media_p2 (cpu, ACC40Sk_3))
1573 {
1574 busy_adjustment[7] = 1;
1575 decrease_ACC_busy (cpu, ACC40Sk_3, busy_adjustment[7]);
1576 }
1577 }
1578
1579 /* The post processing must wait if there is a dependency on a register
1580 which is not ready yet. */
1581 ps->post_wait = cycles;
1582 post_wait_for_ACC (cpu, in_ACC40Si);
1583 post_wait_for_ACC (cpu, ACC40Si_1);
1584 post_wait_for_ACC (cpu, ACC40Si_2);
1585 post_wait_for_ACC (cpu, ACC40Si_3);
1586 post_wait_for_ACC (cpu, out_ACC40Sk);
1587 post_wait_for_ACC (cpu, ACC40Sk_1);
1588 post_wait_for_ACC (cpu, ACC40Sk_2);
1589 post_wait_for_ACC (cpu, ACC40Sk_3);
1590
1591 /* Restore the busy cycles of the registers we used. */
1592 acc = ps->acc_busy;
1593 acc[in_ACC40Si] += busy_adjustment[0];
1594 if (ACC40Si_1 >= 0)
1595 acc[ACC40Si_1] += busy_adjustment[1];
1596 if (ACC40Si_2 >= 0)
1597 acc[ACC40Si_2] += busy_adjustment[2];
1598 if (ACC40Si_3 >= 0)
1599 acc[ACC40Si_3] += busy_adjustment[3];
1600 acc[out_ACC40Sk] += busy_adjustment[4];
1601 if (ACC40Sk_1 >= 0)
1602 acc[ACC40Sk_1] += busy_adjustment[5];
1603 if (ACC40Sk_2 >= 0)
1604 acc[ACC40Sk_2] += busy_adjustment[6];
1605 if (ACC40Sk_3 >= 0)
1606 acc[ACC40Sk_3] += busy_adjustment[7];
1607
1608 /* The latency of the output register will be at least the latency of the
1609 other inputs. Once initiated, post-processing will take 1 cycle. */
1610 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
1611 set_acc_use_is_media_p2 (cpu, out_ACC40Sk);
1612 if (ACC40Sk_1 >= 0)
1613 {
1614 update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
1615 set_acc_use_is_media_p2 (cpu, ACC40Sk_1);
1616 }
1617 if (ACC40Sk_2 >= 0)
1618 {
1619 update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
1620 set_acc_use_is_media_p2 (cpu, ACC40Sk_2);
1621 }
1622 if (ACC40Sk_3 >= 0)
1623 {
1624 update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
1625 set_acc_use_is_media_p2 (cpu, ACC40Sk_3);
1626 }
1627
1628 return cycles;
1629 }
1630
1631 int
1632 frvbf_model_fr400_u_media_3 (SIM_CPU *cpu, const IDESC *idesc,
1633 int unit_num, int referenced,
1634 INT in_FRi, INT in_FRj,
1635 INT out_FRk)
1636 {
1637 /* Modelling is the same as media unit 1. */
1638 return frvbf_model_fr400_u_media_1 (cpu, idesc, unit_num, referenced,
1639 in_FRi, in_FRj, out_FRk);
1640 }
1641
1642 int
1643 frvbf_model_fr400_u_media_3_dual (SIM_CPU *cpu, const IDESC *idesc,
1644 int unit_num, int referenced,
1645 INT in_FRi, INT out_FRk)
1646 {
1647 int cycles;
1648 INT dual_FRi;
1649 FRV_PROFILE_STATE *ps;
1650 int busy_adjustment[] = {0, 0};
1651 int *fr;
1652
1653 if (model_insn == FRV_INSN_MODEL_PASS_1)
1654 return 0;
1655
1656 /* The preprocessing can execute right away. */
1657 cycles = idesc->timing->units[unit_num].done;
1658
1659 ps = CPU_PROFILE_STATE (cpu);
1660 dual_FRi = DUAL_REG (in_FRi);
1661
1662 /* The latency of the registers may be less than previously recorded,
1663 depending on how they were used previously.
1664 See Table 13-8 in the LSI. */
1665 if (use_is_fp_load (cpu, in_FRi))
1666 {
1667 busy_adjustment[0] = 1;
1668 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
1669 }
1670 else
1671 enforce_full_fr_latency (cpu, in_FRi);
1672 if (dual_FRi >= 0 && use_is_fp_load (cpu, dual_FRi))
1673 {
1674 busy_adjustment[1] = 1;
1675 decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
1676 }
1677 else
1678 enforce_full_fr_latency (cpu, dual_FRi);
1679
1680 /* The post processing must wait if there is a dependency on a FR
1681 which is not ready yet. */
1682 ps->post_wait = cycles;
1683 post_wait_for_FR (cpu, in_FRi);
1684 post_wait_for_FR (cpu, dual_FRi);
1685 post_wait_for_FR (cpu, out_FRk);
1686
1687 /* Restore the busy cycles of the registers we used. */
1688 fr = ps->fr_busy;
1689 fr[in_FRi] += busy_adjustment[0];
1690 if (dual_FRi >= 0)
1691 fr[dual_FRi] += busy_adjustment[1];
1692
1693 /* The latency of the output register will be at least the latency of the
1694 other inputs. */
1695 update_FR_latency (cpu, out_FRk, ps->post_wait);
1696
1697 /* Once initiated, post-processing has no latency. */
1698 update_FR_ptime (cpu, out_FRk, 0);
1699
1700 return cycles;
1701 }
1702
1703 int
1704 frvbf_model_fr400_u_media_3_quad (SIM_CPU *cpu, const IDESC *idesc,
1705 int unit_num, int referenced,
1706 INT in_FRi, INT in_FRj,
1707 INT out_FRk)
1708 {
1709 /* Modelling is the same as media unit 1. */
1710 return frvbf_model_fr400_u_media_1_quad (cpu, idesc, unit_num, referenced,
1711 in_FRi, in_FRj, out_FRk);
1712 }
1713
1714 int
1715 frvbf_model_fr400_u_media_4 (SIM_CPU *cpu, const IDESC *idesc,
1716 int unit_num, int referenced,
1717 INT in_ACC40Si, INT in_FRj,
1718 INT out_ACC40Sk, INT out_FRk)
1719 {
1720 int cycles;
1721 FRV_PROFILE_STATE *ps;
1722 const CGEN_INSN *insn;
1723 int busy_adjustment[] = {0};
1724 int *fr;
1725
1726 if (model_insn == FRV_INSN_MODEL_PASS_1)
1727 return 0;
1728
1729 /* The preprocessing can execute right away. */
1730 cycles = idesc->timing->units[unit_num].done;
1731
1732 ps = CPU_PROFILE_STATE (cpu);
1733 insn = idesc->idata;
1734
1735 /* The latency of the registers may be less than previously recorded,
1736 depending on how they were used previously.
1737 See Table 13-8 in the LSI. */
1738 if (in_FRj >= 0)
1739 {
1740 if (use_is_fp_load (cpu, in_FRj))
1741 {
1742 busy_adjustment[0] = 1;
1743 decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
1744 }
1745 else
1746 enforce_full_fr_latency (cpu, in_FRj);
1747 }
1748
1749 /* The post processing must wait if there is a dependency on a FR
1750 which is not ready yet. */
1751 ps->post_wait = cycles;
1752 post_wait_for_ACC (cpu, in_ACC40Si);
1753 post_wait_for_ACC (cpu, out_ACC40Sk);
1754 post_wait_for_FR (cpu, in_FRj);
1755 post_wait_for_FR (cpu, out_FRk);
1756
1757 /* Restore the busy cycles of the registers we used. */
1758 fr = ps->fr_busy;
1759
1760 /* The latency of the output register will be at least the latency of the
1761 other inputs. Once initiated, post-processing will take 1 cycle. */
1762 if (out_FRk >= 0)
1763 {
1764 update_FR_latency (cpu, out_FRk, ps->post_wait);
1765 update_FR_ptime (cpu, out_FRk, 1);
1766 /* Mark this use of the register as media unit 4. */
1767 set_use_is_media_p4 (cpu, out_FRk);
1768 }
1769 else if (out_ACC40Sk >= 0)
1770 {
1771 update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait);
1772 update_ACC_ptime (cpu, out_ACC40Sk, 1);
1773 /* Mark this use of the register as media unit 4. */
1774 set_acc_use_is_media_p4 (cpu, out_ACC40Sk);
1775 }
1776
1777 return cycles;
1778 }
1779
1780 int
1781 frvbf_model_fr400_u_media_4_accg (SIM_CPU *cpu, const IDESC *idesc,
1782 int unit_num, int referenced,
1783 INT in_ACCGi, INT in_FRinti,
1784 INT out_ACCGk, INT out_FRintk)
1785 {
1786 /* Modelling is the same as media-4 unit except use accumulator guards
1787 as input instead of accumulators. */
1788 return frvbf_model_fr400_u_media_4 (cpu, idesc, unit_num, referenced,
1789 in_ACCGi, in_FRinti,
1790 out_ACCGk, out_FRintk);
1791 }
1792
1793 int
1794 frvbf_model_fr400_u_media_4_acc_dual (SIM_CPU *cpu, const IDESC *idesc,
1795 int unit_num, int referenced,
1796 INT in_ACC40Si, INT out_FRk)
1797 {
1798 int cycles;
1799 FRV_PROFILE_STATE *ps;
1800 const CGEN_INSN *insn;
1801 INT ACC40Si_1;
1802 INT FRk_1;
1803
1804 if (model_insn == FRV_INSN_MODEL_PASS_1)
1805 return 0;
1806
1807 /* The preprocessing can execute right away. */
1808 cycles = idesc->timing->units[unit_num].done;
1809
1810 ps = CPU_PROFILE_STATE (cpu);
1811 ACC40Si_1 = DUAL_REG (in_ACC40Si);
1812 FRk_1 = DUAL_REG (out_FRk);
1813
1814 insn = idesc->idata;
1815
1816 /* The post processing must wait if there is a dependency on a FR
1817 which is not ready yet. */
1818 ps->post_wait = cycles;
1819 post_wait_for_ACC (cpu, in_ACC40Si);
1820 post_wait_for_ACC (cpu, ACC40Si_1);
1821 post_wait_for_FR (cpu, out_FRk);
1822 post_wait_for_FR (cpu, FRk_1);
1823
1824 /* The latency of the output register will be at least the latency of the
1825 other inputs. Once initiated, post-processing will take 1 cycle. */
1826 if (out_FRk >= 0)
1827 {
1828 update_FR_latency (cpu, out_FRk, ps->post_wait);
1829 update_FR_ptime (cpu, out_FRk, 1);
1830 /* Mark this use of the register as media unit 4. */
1831 set_use_is_media_p4 (cpu, out_FRk);
1832 }
1833 if (FRk_1 >= 0)
1834 {
1835 update_FR_latency (cpu, FRk_1, ps->post_wait);
1836 update_FR_ptime (cpu, FRk_1, 1);
1837 /* Mark this use of the register as media unit 4. */
1838 set_use_is_media_p4 (cpu, FRk_1);
1839 }
1840
1841 return cycles;
1842 }
1843
1844 int
1845 frvbf_model_fr400_u_media_6 (SIM_CPU *cpu, const IDESC *idesc,
1846 int unit_num, int referenced,
1847 INT in_FRi, INT out_FRk)
1848 {
1849 int cycles;
1850 FRV_PROFILE_STATE *ps;
1851 const CGEN_INSN *insn;
1852 int busy_adjustment[] = {0};
1853 int *fr;
1854
1855 if (model_insn == FRV_INSN_MODEL_PASS_1)
1856 return 0;
1857
1858 /* The preprocessing can execute right away. */
1859 cycles = idesc->timing->units[unit_num].done;
1860
1861 ps = CPU_PROFILE_STATE (cpu);
1862 insn = idesc->idata;
1863
1864 /* The latency of the registers may be less than previously recorded,
1865 depending on how they were used previously.
1866 See Table 13-8 in the LSI. */
1867 if (in_FRi >= 0)
1868 {
1869 if (use_is_fp_load (cpu, in_FRi))
1870 {
1871 busy_adjustment[0] = 1;
1872 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
1873 }
1874 else
1875 enforce_full_fr_latency (cpu, in_FRi);
1876 }
1877
1878 /* The post processing must wait if there is a dependency on a FR
1879 which is not ready yet. */
1880 ps->post_wait = cycles;
1881 post_wait_for_FR (cpu, in_FRi);
1882 post_wait_for_FR (cpu, out_FRk);
1883
1884 /* Restore the busy cycles of the registers we used. */
1885 fr = ps->fr_busy;
1886 if (in_FRi >= 0)
1887 fr[in_FRi] += busy_adjustment[0];
1888
1889 /* The latency of the output register will be at least the latency of the
1890 other inputs. Once initiated, post-processing will take 1 cycle. */
1891 if (out_FRk >= 0)
1892 {
1893 update_FR_latency (cpu, out_FRk, ps->post_wait);
1894 update_FR_ptime (cpu, out_FRk, 1);
1895
1896 /* Mark this use of the register as media unit 1. */
1897 set_use_is_media_p6 (cpu, out_FRk);
1898 }
1899
1900 return cycles;
1901 }
1902
1903 int
1904 frvbf_model_fr400_u_media_7 (SIM_CPU *cpu, const IDESC *idesc,
1905 int unit_num, int referenced,
1906 INT in_FRinti, INT in_FRintj,
1907 INT out_FCCk)
1908 {
1909 int cycles;
1910 FRV_PROFILE_STATE *ps;
1911 int busy_adjustment[] = {0, 0};
1912 int *fr;
1913
1914 if (model_insn == FRV_INSN_MODEL_PASS_1)
1915 return 0;
1916
1917 /* The preprocessing can execute right away. */
1918 cycles = idesc->timing->units[unit_num].done;
1919
1920 /* The post processing must wait if there is a dependency on a FR
1921 which is not ready yet. */
1922 ps = CPU_PROFILE_STATE (cpu);
1923
1924 /* The latency of the registers may be less than previously recorded,
1925 depending on how they were used previously.
1926 See Table 13-8 in the LSI. */
1927 if (in_FRinti >= 0)
1928 {
1929 if (use_is_fp_load (cpu, in_FRinti))
1930 {
1931 busy_adjustment[0] = 1;
1932 decrease_FR_busy (cpu, in_FRinti, busy_adjustment[0]);
1933 }
1934 else
1935 enforce_full_fr_latency (cpu, in_FRinti);
1936 }
1937 if (in_FRintj >= 0 && in_FRintj != in_FRinti)
1938 {
1939 if (use_is_fp_load (cpu, in_FRintj))
1940 {
1941 busy_adjustment[1] = 1;
1942 decrease_FR_busy (cpu, in_FRintj, busy_adjustment[1]);
1943 }
1944 else
1945 enforce_full_fr_latency (cpu, in_FRintj);
1946 }
1947
1948 ps->post_wait = cycles;
1949 post_wait_for_FR (cpu, in_FRinti);
1950 post_wait_for_FR (cpu, in_FRintj);
1951 post_wait_for_CCR (cpu, out_FCCk);
1952
1953 /* Restore the busy cycles of the registers we used. */
1954 fr = ps->fr_busy;
1955 if (in_FRinti >= 0)
1956 fr[in_FRinti] += busy_adjustment[0];
1957 if (in_FRintj >= 0)
1958 fr[in_FRintj] += busy_adjustment[1];
1959
1960 /* The latency of FCCi_2 will be the latency of the other inputs plus 1
1961 cycle. */
1962 update_CCR_latency (cpu, out_FCCk, ps->post_wait + 1);
1963
1964 return cycles;
1965 }
1966
1967 int
1968 frvbf_model_fr400_u_media_dual_expand (SIM_CPU *cpu, const IDESC *idesc,
1969 int unit_num, int referenced,
1970 INT in_FRi,
1971 INT out_FRk)
1972 {
1973 /* Insns using this unit are media-3 class insns, with a dual FRk output. */
1974 int cycles;
1975 INT dual_FRk;
1976 FRV_PROFILE_STATE *ps;
1977 int busy_adjustment[] = {0};
1978 int *fr;
1979
1980 if (model_insn == FRV_INSN_MODEL_PASS_1)
1981 return 0;
1982
1983 /* The preprocessing can execute right away. */
1984 cycles = idesc->timing->units[unit_num].done;
1985
1986 /* If the previous use of the registers was a media op,
1987 then their latency will be less than previously recorded.
1988 See Table 13-13 in the LSI. */
1989 dual_FRk = DUAL_REG (out_FRk);
1990 ps = CPU_PROFILE_STATE (cpu);
1991 if (use_is_fp_load (cpu, in_FRi))
1992 {
1993 busy_adjustment[0] = 1;
1994 decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
1995 }
1996 else
1997 enforce_full_fr_latency (cpu, in_FRi);
1998
1999 /* The post processing must wait if there is a dependency on a FR
2000 which is not ready yet. */
2001 ps->post_wait = cycles;
2002 post_wait_for_FR (cpu, in_FRi);
2003 post_wait_for_FR (cpu, out_FRk);
2004 post_wait_for_FR (cpu, dual_FRk);
2005
2006 /* Restore the busy cycles of the registers we used. */
2007 fr = ps->fr_busy;
2008 fr[in_FRi] += busy_adjustment[0];
2009
2010 /* The latency of the output register will be at least the latency of the
2011 other inputs. Once initiated, post-processing has no latency. */
2012 update_FR_latency (cpu, out_FRk, ps->post_wait);
2013 update_FR_ptime (cpu, out_FRk, 0);
2014
2015 if (dual_FRk >= 0)
2016 {
2017 update_FR_latency (cpu, dual_FRk, ps->post_wait);
2018 update_FR_ptime (cpu, dual_FRk, 0);
2019 }
2020
2021 return cycles;
2022 }
2023
2024 int
2025 frvbf_model_fr400_u_media_dual_htob (SIM_CPU *cpu, const IDESC *idesc,
2026 int unit_num, int referenced,
2027 INT in_FRj,
2028 INT out_FRk)
2029 {
2030 /* Insns using this unit are media-3 class insns, with a dual FRj input. */
2031 int cycles;
2032 INT dual_FRj;
2033 FRV_PROFILE_STATE *ps;
2034 int busy_adjustment[] = {0, 0};
2035 int *fr;
2036
2037 if (model_insn == FRV_INSN_MODEL_PASS_1)
2038 return 0;
2039
2040 /* The preprocessing can execute right away. */
2041 cycles = idesc->timing->units[unit_num].done;
2042
2043 /* If the previous use of the registers was a media op,
2044 then their latency will be less than previously recorded.
2045 See Table 13-13 in the LSI. */
2046 dual_FRj = DUAL_REG (in_FRj);
2047 ps = CPU_PROFILE_STATE (cpu);
2048 if (use_is_fp_load (cpu, in_FRj))
2049 {
2050 busy_adjustment[0] = 1;
2051 decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
2052 }
2053 else
2054 enforce_full_fr_latency (cpu, in_FRj);
2055 if (dual_FRj >= 0)
2056 {
2057 if (use_is_fp_load (cpu, dual_FRj))
2058 {
2059 busy_adjustment[1] = 1;
2060 decrease_FR_busy (cpu, dual_FRj, busy_adjustment[1]);
2061 }
2062 else
2063 enforce_full_fr_latency (cpu, dual_FRj);
2064 }
2065
2066 /* The post processing must wait if there is a dependency on a FR
2067 which is not ready yet. */
2068 ps->post_wait = cycles;
2069 post_wait_for_FR (cpu, in_FRj);
2070 post_wait_for_FR (cpu, dual_FRj);
2071 post_wait_for_FR (cpu, out_FRk);
2072
2073 /* Restore the busy cycles of the registers we used. */
2074 fr = ps->fr_busy;
2075 fr[in_FRj] += busy_adjustment[0];
2076 if (dual_FRj >= 0)
2077 fr[dual_FRj] += busy_adjustment[1];
2078
2079 /* The latency of the output register will be at least the latency of the
2080 other inputs. */
2081 update_FR_latency (cpu, out_FRk, ps->post_wait);
2082
2083 /* Once initiated, post-processing has no latency. */
2084 update_FR_ptime (cpu, out_FRk, 0);
2085
2086 return cycles;
2087 }
2088
2089 int
2090 frvbf_model_fr400_u_ici (SIM_CPU *cpu, const IDESC *idesc,
2091 int unit_num, int referenced,
2092 INT in_GRi, INT in_GRj)
2093 {
2094 /* Modelling for this unit is the same as for fr500. */
2095 return frvbf_model_fr500_u_ici (cpu, idesc, unit_num, referenced,
2096 in_GRi, in_GRj);
2097 }
2098
2099 int
2100 frvbf_model_fr400_u_dci (SIM_CPU *cpu, const IDESC *idesc,
2101 int unit_num, int referenced,
2102 INT in_GRi, INT in_GRj)
2103 {
2104 /* Modelling for this unit is the same as for fr500. */
2105 return frvbf_model_fr500_u_dci (cpu, idesc, unit_num, referenced,
2106 in_GRi, in_GRj);
2107 }
2108
2109 int
2110 frvbf_model_fr400_u_dcf (SIM_CPU *cpu, const IDESC *idesc,
2111 int unit_num, int referenced,
2112 INT in_GRi, INT in_GRj)
2113 {
2114 /* Modelling for this unit is the same as for fr500. */
2115 return frvbf_model_fr500_u_dcf (cpu, idesc, unit_num, referenced,
2116 in_GRi, in_GRj);
2117 }
2118
2119 int
2120 frvbf_model_fr400_u_icpl (SIM_CPU *cpu, const IDESC *idesc,
2121 int unit_num, int referenced,
2122 INT in_GRi, INT in_GRj)
2123 {
2124 /* Modelling for this unit is the same as for fr500. */
2125 return frvbf_model_fr500_u_icpl (cpu, idesc, unit_num, referenced,
2126 in_GRi, in_GRj);
2127 }
2128
2129 int
2130 frvbf_model_fr400_u_dcpl (SIM_CPU *cpu, const IDESC *idesc,
2131 int unit_num, int referenced,
2132 INT in_GRi, INT in_GRj)
2133 {
2134 /* Modelling for this unit is the same as for fr500. */
2135 return frvbf_model_fr500_u_dcpl (cpu, idesc, unit_num, referenced,
2136 in_GRi, in_GRj);
2137 }
2138
2139 int
2140 frvbf_model_fr400_u_icul (SIM_CPU *cpu, const IDESC *idesc,
2141 int unit_num, int referenced,
2142 INT in_GRi, INT in_GRj)
2143 {
2144 /* Modelling for this unit is the same as for fr500. */
2145 return frvbf_model_fr500_u_icul (cpu, idesc, unit_num, referenced,
2146 in_GRi, in_GRj);
2147 }
2148
2149 int
2150 frvbf_model_fr400_u_dcul (SIM_CPU *cpu, const IDESC *idesc,
2151 int unit_num, int referenced,
2152 INT in_GRi, INT in_GRj)
2153 {
2154 /* Modelling for this unit is the same as for fr500. */
2155 return frvbf_model_fr500_u_dcul (cpu, idesc, unit_num, referenced,
2156 in_GRi, in_GRj);
2157 }
2158
2159 int
2160 frvbf_model_fr400_u_barrier (SIM_CPU *cpu, const IDESC *idesc,
2161 int unit_num, int referenced)
2162 {
2163 /* Modelling for this unit is the same as for fr500. */
2164 return frvbf_model_fr500_u_barrier (cpu, idesc, unit_num, referenced);
2165 }
2166
2167 int
2168 frvbf_model_fr400_u_membar (SIM_CPU *cpu, const IDESC *idesc,
2169 int unit_num, int referenced)
2170 {
2171 /* Modelling for this unit is the same as for fr500. */
2172 return frvbf_model_fr500_u_membar (cpu, idesc, unit_num, referenced);
2173 }
2174
2175 #endif /* WITH_PROFILE_MODEL_P */
This page took 0.073699 seconds and 4 git commands to generate.