Home | History | Annotate | Line # | Download | only in frv
profile-fr500.c revision 1.1.1.7
      1      1.1  christos /* frv simulator fr500 dependent profiling code.
      2      1.1  christos 
      3  1.1.1.7  christos    Copyright (C) 1998-2019 Free Software Foundation, Inc.
      4      1.1  christos    Contributed by Red Hat
      5      1.1  christos 
      6      1.1  christos This file is part of the GNU simulators.
      7      1.1  christos 
      8      1.1  christos This program is free software; you can redistribute it and/or modify
      9      1.1  christos it under the terms of the GNU General Public License as published by
     10      1.1  christos the Free Software Foundation; either version 3 of the License, or
     11      1.1  christos (at your option) any later version.
     12      1.1  christos 
     13      1.1  christos This program is distributed in the hope that it will be useful,
     14      1.1  christos but WITHOUT ANY WARRANTY; without even the implied warranty of
     15      1.1  christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16      1.1  christos GNU General Public License for more details.
     17      1.1  christos 
     18      1.1  christos You should have received a copy of the GNU General Public License
     19      1.1  christos along with this program.  If not, see <http://www.gnu.org/licenses/>.
     20      1.1  christos 
     21      1.1  christos */
     22      1.1  christos #define WANT_CPU
     23      1.1  christos #define WANT_CPU_FRVBF
     24      1.1  christos 
     25      1.1  christos #include "sim-main.h"
     26      1.1  christos #include "bfd.h"
     27      1.1  christos 
     28      1.1  christos #if WITH_PROFILE_MODEL_P
     29      1.1  christos 
     30      1.1  christos #include "profile.h"
     31      1.1  christos #include "profile-fr500.h"
     32      1.1  christos 
     33      1.1  christos /* Initialize cycle counting for an insn.
     34      1.1  christos    FIRST_P is non-zero if this is the first insn in a set of parallel
     35      1.1  christos    insns.  */
     36      1.1  christos void
     37      1.1  christos fr500_model_insn_before (SIM_CPU *cpu, int first_p)
     38      1.1  christos {
     39      1.1  christos   if (first_p)
     40      1.1  christos     {
     41      1.1  christos       MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
     42      1.1  christos       FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
     43      1.1  christos       ps->cur_gr_complex = ps->prev_gr_complex;
     44      1.1  christos       d->cur_fpop     = d->prev_fpop;
     45      1.1  christos       d->cur_media    = d->prev_media;
     46      1.1  christos       d->cur_cc_complex = d->prev_cc_complex;
     47      1.1  christos     }
     48      1.1  christos }
     49      1.1  christos 
     50      1.1  christos /* Record the cycles computed for an insn.
     51      1.1  christos    LAST_P is non-zero if this is the last insn in a set of parallel insns,
     52      1.1  christos    and we update the total cycle count.
     53      1.1  christos    CYCLES is the cycle count of the insn.  */
     54      1.1  christos void
     55      1.1  christos fr500_model_insn_after (SIM_CPU *cpu, int last_p, int cycles)
     56      1.1  christos {
     57      1.1  christos   if (last_p)
     58      1.1  christos     {
     59      1.1  christos       MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
     60      1.1  christos       FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
     61      1.1  christos       ps->prev_gr_complex = ps->cur_gr_complex;
     62      1.1  christos       d->prev_fpop     = d->cur_fpop;
     63      1.1  christos       d->prev_media    = d->cur_media;
     64      1.1  christos       d->prev_cc_complex = d->cur_cc_complex;
     65      1.1  christos     }
     66      1.1  christos }
     67      1.1  christos 
     68      1.1  christos static void
     69      1.1  christos set_use_is_fpop (SIM_CPU *cpu, INT fr)
     70      1.1  christos {
     71      1.1  christos   MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
     72      1.1  christos   fr500_reset_fr_flags (cpu, (fr));
     73      1.1  christos   d->cur_fpop |=  (((DI)1) << (fr));
     74      1.1  christos }
     75      1.1  christos 
     76      1.1  christos static void
     77      1.1  christos set_use_not_fpop (SIM_CPU *cpu, INT fr)
     78      1.1  christos {
     79      1.1  christos   MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
     80      1.1  christos   d->cur_fpop &= ~(((DI)1) << (fr));
     81      1.1  christos }
     82      1.1  christos 
     83      1.1  christos static int
     84      1.1  christos use_is_fpop (SIM_CPU *cpu, INT fr)
     85      1.1  christos {
     86      1.1  christos   MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
     87      1.1  christos   return d->prev_fpop & (((DI)1) << (fr));
     88      1.1  christos }
     89      1.1  christos 
     90      1.1  christos static void
     91      1.1  christos set_use_is_media ( SIM_CPU *cpu, INT fr)
     92      1.1  christos {
     93      1.1  christos   MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
     94      1.1  christos   fr500_reset_fr_flags (cpu, (fr));
     95      1.1  christos   d->cur_media |=  (((DI)1) << (fr));
     96      1.1  christos }
     97      1.1  christos 
     98      1.1  christos static void
     99      1.1  christos set_use_not_media (SIM_CPU *cpu, INT fr)
    100      1.1  christos {
    101      1.1  christos   MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
    102      1.1  christos   d->cur_media &= ~(((DI)1) << (fr));
    103      1.1  christos }
    104      1.1  christos 
    105      1.1  christos static int
    106      1.1  christos use_is_media (SIM_CPU *cpu, INT fr)
    107      1.1  christos {
    108      1.1  christos   MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
    109      1.1  christos   return d->prev_media & (((DI)1) << (fr));
    110      1.1  christos }
    111      1.1  christos 
    112      1.1  christos static void
    113      1.1  christos set_use_is_cc_complex (SIM_CPU *cpu, INT cc)
    114      1.1  christos {
    115      1.1  christos   MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
    116      1.1  christos   fr500_reset_cc_flags (cpu, cc);
    117      1.1  christos   d->cur_cc_complex |= (((DI)1) << (cc));
    118      1.1  christos }
    119      1.1  christos 
    120      1.1  christos static void
    121      1.1  christos set_use_not_cc_complex (SIM_CPU *cpu, INT cc)
    122      1.1  christos {
    123      1.1  christos   MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
    124      1.1  christos   d->cur_cc_complex &= ~(((DI)1) << (cc));
    125      1.1  christos }
    126      1.1  christos 
    127      1.1  christos static int
    128      1.1  christos use_is_cc_complex (SIM_CPU *cpu, INT cc)
    129      1.1  christos {
    130      1.1  christos   MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
    131      1.1  christos   return d->prev_cc_complex &   (((DI)1) << (cc));
    132      1.1  christos }
    133      1.1  christos 
    134      1.1  christos void
    135      1.1  christos fr500_reset_fr_flags (SIM_CPU *cpu, INT fr)
    136      1.1  christos {
    137      1.1  christos   set_use_not_fpop (cpu, fr);
    138      1.1  christos   set_use_not_media (cpu, fr);
    139      1.1  christos }
    140      1.1  christos 
    141      1.1  christos void
    142      1.1  christos fr500_reset_cc_flags (SIM_CPU *cpu, INT cc)
    143      1.1  christos {
    144      1.1  christos   set_use_not_cc_complex (cpu, cc);
    145      1.1  christos }
    146      1.1  christos 
    147      1.1  christos /* Latency of floating point registers may be less than recorded when followed
    148      1.1  christos    by another floating point insn.  */
    149      1.1  christos static void
    150      1.1  christos adjust_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
    151      1.1  christos 			    int cycles)
    152      1.1  christos {
    153      1.1  christos   /* If the registers were previously used in a floating point op,
    154      1.1  christos      then their latency will be less than previously recorded.
    155      1.1  christos      See Table 13-13 in the LSI.  */
    156      1.1  christos   if (in_FRi >= 0)
    157      1.1  christos     if (use_is_fpop (cpu, in_FRi))
    158      1.1  christos       decrease_FR_busy (cpu, in_FRi, cycles);
    159      1.1  christos     else
    160      1.1  christos       enforce_full_fr_latency (cpu, in_FRi);
    161      1.1  christos 
    162      1.1  christos   if (in_FRj >= 0 && in_FRj != in_FRi)
    163      1.1  christos     if (use_is_fpop (cpu, in_FRj))
    164      1.1  christos       decrease_FR_busy (cpu, in_FRj, cycles);
    165      1.1  christos     else
    166      1.1  christos       enforce_full_fr_latency (cpu, in_FRj);
    167      1.1  christos 
    168      1.1  christos   if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
    169      1.1  christos     if (use_is_fpop (cpu, out_FRk))
    170      1.1  christos       decrease_FR_busy (cpu, out_FRk, cycles);
    171      1.1  christos     else
    172      1.1  christos       enforce_full_fr_latency (cpu, out_FRk);
    173      1.1  christos }
    174      1.1  christos 
    175      1.1  christos /* Latency of floating point registers may be less than recorded when followed
    176      1.1  christos    by another floating point insn.  */
    177      1.1  christos static void
    178      1.1  christos adjust_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
    179      1.1  christos 			    int cycles)
    180      1.1  christos {
    181      1.1  christos   /* If the registers were previously used in a floating point op,
    182      1.1  christos      then their latency will be less than previously recorded.
    183      1.1  christos      See Table 13-13 in the LSI.  */
    184      1.1  christos   adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
    185      1.1  christos   if (in_FRi >= 0)  ++in_FRi;
    186      1.1  christos   if (in_FRj >= 0)  ++in_FRj;
    187      1.1  christos   if (out_FRk >= 0) ++out_FRk;
    188      1.1  christos   adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
    189      1.1  christos }
    190      1.1  christos 
    191      1.1  christos /* Latency of floating point registers is less than recorded when followed
    192      1.1  christos    by another floating point insn.  */
    193      1.1  christos static void
    194      1.1  christos restore_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
    195      1.1  christos 			     int cycles)
    196      1.1  christos {
    197      1.1  christos   /* If the registers were previously used in a floating point op,
    198      1.1  christos      then their latency will be less than previously recorded.
    199      1.1  christos      See Table 13-13 in the LSI.  */
    200      1.1  christos   if (in_FRi >= 0 && use_is_fpop (cpu, in_FRi))
    201      1.1  christos     increase_FR_busy (cpu, in_FRi, cycles);
    202      1.1  christos   if (in_FRj != in_FRi && use_is_fpop (cpu, in_FRj))
    203      1.1  christos     increase_FR_busy (cpu, in_FRj, cycles);
    204      1.1  christos   if (out_FRk != in_FRi && out_FRk != in_FRj && use_is_fpop (cpu, out_FRk))
    205      1.1  christos     increase_FR_busy (cpu, out_FRk, cycles);
    206      1.1  christos }
    207      1.1  christos 
    208      1.1  christos /* Latency of floating point registers is less than recorded when followed
    209      1.1  christos    by another floating point insn.  */
    210      1.1  christos static void
    211      1.1  christos restore_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
    212      1.1  christos 			    int cycles)
    213      1.1  christos {
    214      1.1  christos   /* If the registers were previously used in a floating point op,
    215      1.1  christos      then their latency will be less than previously recorded.
    216      1.1  christos      See Table 13-13 in the LSI.  */
    217      1.1  christos   restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
    218      1.1  christos   if (in_FRi >= 0)  ++in_FRi;
    219      1.1  christos   if (in_FRj >= 0)  ++in_FRj;
    220      1.1  christos   if (out_FRk >= 0) ++out_FRk;
    221      1.1  christos   restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
    222      1.1  christos }
    223      1.1  christos 
    224      1.1  christos int
    225      1.1  christos frvbf_model_fr500_u_exec (SIM_CPU *cpu, const IDESC *idesc,
    226      1.1  christos 			  int unit_num, int referenced)
    227      1.1  christos {
    228      1.1  christos   return idesc->timing->units[unit_num].done;
    229      1.1  christos }
    230      1.1  christos 
    231      1.1  christos int
    232      1.1  christos frvbf_model_fr500_u_integer (SIM_CPU *cpu, const IDESC *idesc,
    233      1.1  christos 			     int unit_num, int referenced,
    234      1.1  christos 			     INT in_GRi, INT in_GRj, INT out_GRk,
    235      1.1  christos 			     INT out_ICCi_1)
    236      1.1  christos {
    237      1.1  christos   int cycles;
    238      1.1  christos 
    239      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    240      1.1  christos     {
    241      1.1  christos       /* icc0-icc4 are the upper 4 fields of the CCR.  */
    242      1.1  christos       if (out_ICCi_1 >= 0)
    243      1.1  christos 	out_ICCi_1 += 4;
    244      1.1  christos 
    245      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    246      1.1  christos 	 which is not ready yet.
    247      1.1  christos 	 The latency of the registers may be less than previously recorded,
    248      1.1  christos 	 depending on how they were used previously.
    249      1.1  christos 	 See Table 13-8 in the LSI.  */
    250      1.1  christos       if (in_GRi != out_GRk && in_GRi >= 0)
    251      1.1  christos 	{
    252      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    253      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    254      1.1  christos 	}
    255      1.1  christos       if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
    256      1.1  christos 	{
    257      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    258      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    259      1.1  christos 	}
    260      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    261      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    262      1.1  christos       vliw_wait_for_GR (cpu, out_GRk);
    263      1.1  christos       vliw_wait_for_CCR (cpu, out_ICCi_1);
    264      1.1  christos       handle_resource_wait (cpu);
    265      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    266      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    267      1.1  christos       load_wait_for_GR (cpu, out_GRk);
    268      1.1  christos       trace_vliw_wait_cycles (cpu);
    269      1.1  christos       return 0;
    270      1.1  christos     }
    271      1.1  christos 
    272      1.1  christos   /* GRk is available immediately to the next VLIW insn as is ICCi_1.  */
    273      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    274      1.1  christos   return cycles;
    275      1.1  christos }
    276      1.1  christos 
    277      1.1  christos int
    278      1.1  christos frvbf_model_fr500_u_imul (SIM_CPU *cpu, const IDESC *idesc,
    279      1.1  christos 			  int unit_num, int referenced,
    280      1.1  christos 			  INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
    281      1.1  christos {
    282      1.1  christos   int cycles;
    283      1.1  christos   /* icc0-icc4 are the upper 4 fields of the CCR.  */
    284      1.1  christos   if (out_ICCi_1 >= 0)
    285      1.1  christos     out_ICCi_1 += 4;
    286      1.1  christos 
    287      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    288      1.1  christos     {
    289      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    290      1.1  christos 	 which is not ready yet.
    291      1.1  christos 	 The latency of the registers may be less than previously recorded,
    292      1.1  christos 	 depending on how they were used previously.
    293      1.1  christos 	 See Table 13-8 in the LSI.  */
    294      1.1  christos       if (in_GRi != out_GRk && in_GRi >= 0)
    295      1.1  christos 	{
    296      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    297      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    298      1.1  christos 	}
    299      1.1  christos       if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
    300      1.1  christos 	{
    301      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    302      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    303      1.1  christos 	}
    304      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    305      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    306      1.1  christos       vliw_wait_for_GRdouble (cpu, out_GRk);
    307      1.1  christos       vliw_wait_for_CCR (cpu, out_ICCi_1);
    308      1.1  christos       handle_resource_wait (cpu);
    309      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    310      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    311      1.1  christos       load_wait_for_GRdouble (cpu, out_GRk);
    312      1.1  christos       trace_vliw_wait_cycles (cpu);
    313      1.1  christos       return 0;
    314      1.1  christos     }
    315      1.1  christos 
    316      1.1  christos   /* GRk has a latency of 2 cycles.  */
    317      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    318      1.1  christos   update_GRdouble_latency (cpu, out_GRk, cycles + 2);
    319      1.1  christos   set_use_is_gr_complex (cpu, out_GRk);
    320      1.1  christos   set_use_is_gr_complex (cpu, out_GRk + 1);
    321      1.1  christos 
    322      1.1  christos   /* ICCi_1 has a latency of 1 cycle.  */
    323      1.1  christos   update_CCR_latency (cpu, out_ICCi_1, cycles + 1);
    324      1.1  christos 
    325      1.1  christos   return cycles;
    326      1.1  christos }
    327      1.1  christos 
    328      1.1  christos int
    329      1.1  christos frvbf_model_fr500_u_idiv (SIM_CPU *cpu, const IDESC *idesc,
    330      1.1  christos 			  int unit_num, int referenced,
    331      1.1  christos 			  INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
    332      1.1  christos {
    333      1.1  christos   int cycles;
    334      1.1  christos   FRV_VLIW *vliw;
    335      1.1  christos   int slot;
    336      1.1  christos 
    337      1.1  christos   /* icc0-icc4 are the upper 4 fields of the CCR.  */
    338      1.1  christos   if (out_ICCi_1 >= 0)
    339      1.1  christos     out_ICCi_1 += 4;
    340      1.1  christos 
    341      1.1  christos   vliw = CPU_VLIW (cpu);
    342      1.1  christos   slot = vliw->next_slot - 1;
    343      1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_I0;
    344      1.1  christos 
    345      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    346      1.1  christos     {
    347      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    348      1.1  christos 	 which is not ready yet.
    349      1.1  christos 	 The latency of the registers may be less than previously recorded,
    350      1.1  christos 	 depending on how they were used previously.
    351      1.1  christos 	 See Table 13-8 in the LSI.  */
    352      1.1  christos       if (in_GRi != out_GRk && in_GRi >= 0)
    353      1.1  christos 	{
    354      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    355      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    356      1.1  christos 	}
    357      1.1  christos       if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
    358      1.1  christos 	{
    359      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    360      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    361      1.1  christos 	}
    362      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    363      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    364      1.1  christos       vliw_wait_for_GR (cpu, out_GRk);
    365      1.1  christos       vliw_wait_for_CCR (cpu, out_ICCi_1);
    366      1.1  christos       vliw_wait_for_idiv_resource (cpu, slot);
    367      1.1  christos       handle_resource_wait (cpu);
    368      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    369      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    370      1.1  christos       load_wait_for_GR (cpu, out_GRk);
    371      1.1  christos       trace_vliw_wait_cycles (cpu);
    372      1.1  christos       return 0;
    373      1.1  christos     }
    374      1.1  christos 
    375      1.1  christos   /* GRk has a latency of 19 cycles!  */
    376      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    377      1.1  christos   update_GR_latency (cpu, out_GRk, cycles + 19);
    378      1.1  christos   set_use_is_gr_complex (cpu, out_GRk);
    379      1.1  christos 
    380      1.1  christos   /* ICCi_1 has a latency of 19 cycles.  */
    381      1.1  christos   update_CCR_latency (cpu, out_ICCi_1, cycles + 19);
    382      1.1  christos   set_use_is_cc_complex (cpu, out_ICCi_1);
    383      1.1  christos 
    384      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
    385      1.1  christos     {
    386      1.1  christos       /* GNER has a latency of 18 cycles.  */
    387      1.1  christos       update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 18);
    388      1.1  christos     }
    389      1.1  christos 
    390      1.1  christos   /* the idiv resource has a latency of 18 cycles!  */
    391      1.1  christos   update_idiv_resource_latency (cpu, slot, cycles + 18);
    392      1.1  christos 
    393      1.1  christos   return cycles;
    394      1.1  christos }
    395      1.1  christos 
    396      1.1  christos int
    397      1.1  christos frvbf_model_fr500_u_branch (SIM_CPU *cpu, const IDESC *idesc,
    398      1.1  christos 			    int unit_num, int referenced,
    399      1.1  christos 			    INT in_GRi, INT in_GRj,
    400      1.1  christos 			    INT in_ICCi_2, INT in_FCCi_2)
    401      1.1  christos {
    402      1.1  christos   int cycles;
    403      1.1  christos   FRV_PROFILE_STATE *ps;
    404      1.1  christos 
    405      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    406      1.1  christos     {
    407      1.1  christos       /* icc0-icc4 are the upper 4 fields of the CCR.  */
    408      1.1  christos       if (in_ICCi_2 >= 0)
    409      1.1  christos 	in_ICCi_2 += 4;
    410      1.1  christos 
    411      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    412      1.1  christos 	 which is not ready yet.
    413      1.1  christos 	 The latency of the registers may be less than previously recorded,
    414      1.1  christos 	 depending on how they were used previously.
    415      1.1  christos 	 See Table 13-8 in the LSI.  */
    416      1.1  christos       if (in_GRi >= 0)
    417      1.1  christos 	{
    418      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    419      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    420      1.1  christos 	}
    421      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
    422      1.1  christos 	{
    423      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    424      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    425      1.1  christos 	}
    426      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    427      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    428      1.1  christos       vliw_wait_for_CCR (cpu, in_ICCi_2);
    429      1.1  christos       vliw_wait_for_CCR (cpu, in_FCCi_2);
    430      1.1  christos       handle_resource_wait (cpu);
    431      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    432      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    433      1.1  christos       trace_vliw_wait_cycles (cpu);
    434      1.1  christos       return 0;
    435      1.1  christos     }
    436      1.1  christos 
    437      1.1  christos   /* When counting branches taken or not taken, don't consider branches after
    438      1.1  christos      the first taken branch in a vliw insn.  */
    439      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
    440      1.1  christos   if (! ps->vliw_branch_taken)
    441      1.1  christos     {
    442      1.1  christos       /* (1 << 4): The pc is the 5th element in inputs, outputs.
    443      1.1  christos 	 ??? can be cleaned up */
    444      1.1  christos       PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
    445      1.1  christos       int taken = (referenced & (1 << 4)) != 0;
    446      1.1  christos       if (taken)
    447      1.1  christos 	{
    448      1.1  christos 	  ++PROFILE_MODEL_TAKEN_COUNT (p);
    449      1.1  christos 	  ps->vliw_branch_taken = 1;
    450      1.1  christos 	}
    451      1.1  christos       else
    452      1.1  christos 	++PROFILE_MODEL_UNTAKEN_COUNT (p);
    453      1.1  christos     }
    454      1.1  christos 
    455      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    456      1.1  christos   return cycles;
    457      1.1  christos }
    458      1.1  christos 
    459      1.1  christos int
    460      1.1  christos frvbf_model_fr500_u_trap (SIM_CPU *cpu, const IDESC *idesc,
    461      1.1  christos 			  int unit_num, int referenced,
    462      1.1  christos 			  INT in_GRi, INT in_GRj,
    463      1.1  christos 			  INT in_ICCi_2, INT in_FCCi_2)
    464      1.1  christos {
    465      1.1  christos   int cycles;
    466      1.1  christos 
    467      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    468      1.1  christos     {
    469      1.1  christos       /* icc0-icc4 are the upper 4 fields of the CCR.  */
    470      1.1  christos       if (in_ICCi_2 >= 0)
    471      1.1  christos 	in_ICCi_2 += 4;
    472      1.1  christos 
    473      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    474      1.1  christos 	 which is not ready yet.
    475      1.1  christos 	 The latency of the registers may be less than previously recorded,
    476      1.1  christos 	 depending on how they were used previously.
    477      1.1  christos 	 See Table 13-8 in the LSI.  */
    478      1.1  christos       if (in_GRi >= 0)
    479      1.1  christos 	{
    480      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    481      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    482      1.1  christos 	}
    483      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
    484      1.1  christos 	{
    485      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    486      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    487      1.1  christos 	}
    488      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    489      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    490      1.1  christos       vliw_wait_for_CCR (cpu, in_ICCi_2);
    491      1.1  christos       vliw_wait_for_CCR (cpu, in_FCCi_2);
    492      1.1  christos       handle_resource_wait (cpu);
    493      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    494      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    495      1.1  christos       trace_vliw_wait_cycles (cpu);
    496      1.1  christos       return 0;
    497      1.1  christos     }
    498      1.1  christos 
    499      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    500      1.1  christos   return cycles;
    501      1.1  christos }
    502      1.1  christos 
    503      1.1  christos int
    504      1.1  christos frvbf_model_fr500_u_check (SIM_CPU *cpu, const IDESC *idesc,
    505      1.1  christos 			   int unit_num, int referenced,
    506      1.1  christos 			   INT in_ICCi_3, INT in_FCCi_3)
    507      1.1  christos {
    508      1.1  christos   int cycles;
    509      1.1  christos 
    510      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    511      1.1  christos     {
    512      1.1  christos       /* icc0-icc4 are the upper 4 fields of the CCR.  */
    513      1.1  christos       if (in_ICCi_3 >= 0)
    514      1.1  christos 	in_ICCi_3 += 4;
    515      1.1  christos 
    516      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    517      1.1  christos 	 which is not ready yet.  */
    518      1.1  christos       vliw_wait_for_CCR (cpu, in_ICCi_3);
    519      1.1  christos       vliw_wait_for_CCR (cpu, in_FCCi_3);
    520      1.1  christos       handle_resource_wait (cpu);
    521      1.1  christos       trace_vliw_wait_cycles (cpu);
    522      1.1  christos       return 0;
    523      1.1  christos     }
    524      1.1  christos 
    525      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    526      1.1  christos   return cycles;
    527      1.1  christos }
    528      1.1  christos 
    529      1.1  christos int
    530      1.1  christos frvbf_model_fr500_u_clrgr (SIM_CPU *cpu, const IDESC *idesc,
    531      1.1  christos 			   int unit_num, int referenced,
    532      1.1  christos 			   INT in_GRk)
    533      1.1  christos {
    534      1.1  christos   int cycles;
    535      1.1  christos 
    536      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    537      1.1  christos     {
    538      1.1  christos       /* Wait for both GNER registers or just the one specified.  */
    539      1.1  christos       if (in_GRk == -1)
    540      1.1  christos 	{
    541      1.1  christos 	  vliw_wait_for_SPR (cpu, H_SPR_GNER0);
    542      1.1  christos 	  vliw_wait_for_SPR (cpu, H_SPR_GNER1);
    543      1.1  christos 	}
    544      1.1  christos       else
    545      1.1  christos 	vliw_wait_for_SPR (cpu, GNER_FOR_GR (in_GRk));
    546      1.1  christos       handle_resource_wait (cpu);
    547      1.1  christos       trace_vliw_wait_cycles (cpu);
    548      1.1  christos       return 0;
    549      1.1  christos     }
    550      1.1  christos 
    551      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    552      1.1  christos   return cycles;
    553      1.1  christos }
    554      1.1  christos 
    555      1.1  christos int
    556      1.1  christos frvbf_model_fr500_u_clrfr (SIM_CPU *cpu, const IDESC *idesc,
    557      1.1  christos 			   int unit_num, int referenced,
    558      1.1  christos 			   INT in_FRk)
    559      1.1  christos {
    560      1.1  christos   int cycles;
    561      1.1  christos 
    562      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    563      1.1  christos     {
    564      1.1  christos       /* Wait for both GNER registers or just the one specified.  */
    565      1.1  christos       if (in_FRk == -1)
    566      1.1  christos 	{
    567      1.1  christos 	  vliw_wait_for_SPR (cpu, H_SPR_FNER0);
    568      1.1  christos 	  vliw_wait_for_SPR (cpu, H_SPR_FNER1);
    569      1.1  christos 	}
    570      1.1  christos       else
    571      1.1  christos 	vliw_wait_for_SPR (cpu, FNER_FOR_FR (in_FRk));
    572      1.1  christos       handle_resource_wait (cpu);
    573      1.1  christos       trace_vliw_wait_cycles (cpu);
    574      1.1  christos       return 0;
    575      1.1  christos     }
    576      1.1  christos 
    577      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    578      1.1  christos   return cycles;
    579      1.1  christos }
    580      1.1  christos 
    581      1.1  christos int
    582      1.1  christos frvbf_model_fr500_u_commit (SIM_CPU *cpu, const IDESC *idesc,
    583      1.1  christos 			    int unit_num, int referenced,
    584      1.1  christos 			    INT in_GRk, INT in_FRk)
    585      1.1  christos {
    586      1.1  christos   int cycles;
    587      1.1  christos 
    588      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    589      1.1  christos     {
    590      1.1  christos       /* If GR is specified, then FR is not and vice-versa. If neither is
    591      1.1  christos 	 then it's a commitga or commitfa. Check the insn attribute to
    592      1.1  christos 	 figure out which.  */
    593      1.1  christos       if (in_GRk != -1)
    594      1.1  christos 	vliw_wait_for_SPR (cpu, GNER_FOR_GR (in_GRk));
    595      1.1  christos       else if (in_FRk != -1)
    596      1.1  christos 	vliw_wait_for_SPR (cpu, FNER_FOR_FR (in_FRk));
    597      1.1  christos       else if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_FR_ACCESS))
    598      1.1  christos 	{
    599      1.1  christos 	  vliw_wait_for_SPR (cpu, H_SPR_FNER0);
    600      1.1  christos 	  vliw_wait_for_SPR (cpu, H_SPR_FNER1);
    601      1.1  christos 	}
    602      1.1  christos       else
    603      1.1  christos 	{
    604      1.1  christos 	  vliw_wait_for_SPR (cpu, H_SPR_GNER0);
    605      1.1  christos 	  vliw_wait_for_SPR (cpu, H_SPR_GNER1);
    606      1.1  christos 	}
    607      1.1  christos       handle_resource_wait (cpu);
    608      1.1  christos       trace_vliw_wait_cycles (cpu);
    609      1.1  christos       return 0;
    610      1.1  christos     }
    611      1.1  christos 
    612      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    613      1.1  christos   return cycles;
    614      1.1  christos }
    615      1.1  christos 
    616      1.1  christos int
    617      1.1  christos frvbf_model_fr500_u_set_hilo (SIM_CPU *cpu, const IDESC *idesc,
    618      1.1  christos 			     int unit_num, int referenced,
    619      1.1  christos 			     INT out_GRkhi, INT out_GRklo)
    620      1.1  christos {
    621      1.1  christos   int cycles;
    622      1.1  christos 
    623      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    624      1.1  christos     {
    625      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a GR
    626      1.1  christos 	 which is not ready yet.  */
    627      1.1  christos       vliw_wait_for_GR (cpu, out_GRkhi);
    628      1.1  christos       vliw_wait_for_GR (cpu, out_GRklo);
    629      1.1  christos       handle_resource_wait (cpu);
    630      1.1  christos       load_wait_for_GR (cpu, out_GRkhi);
    631      1.1  christos       load_wait_for_GR (cpu, out_GRklo);
    632      1.1  christos       trace_vliw_wait_cycles (cpu);
    633      1.1  christos       return 0;
    634      1.1  christos     }
    635      1.1  christos 
    636      1.1  christos   /* GRk is available immediately to the next VLIW insn.  */
    637      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    638      1.1  christos 
    639      1.1  christos   set_use_not_gr_complex (cpu, out_GRkhi);
    640      1.1  christos   set_use_not_gr_complex (cpu, out_GRklo);
    641      1.1  christos 
    642      1.1  christos   return cycles;
    643      1.1  christos }
    644      1.1  christos 
    645      1.1  christos int
    646      1.1  christos frvbf_model_fr500_u_gr_load (SIM_CPU *cpu, const IDESC *idesc,
    647      1.1  christos 			     int unit_num, int referenced,
    648      1.1  christos 			     INT in_GRi, INT in_GRj,
    649      1.1  christos 			     INT out_GRk, INT out_GRdoublek)
    650      1.1  christos {
    651      1.1  christos   int cycles;
    652      1.1  christos 
    653      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    654      1.1  christos     {
    655      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    656      1.1  christos 	 which is not ready yet.
    657      1.1  christos 	 The latency of the registers may be less than previously recorded,
    658      1.1  christos 	 depending on how they were used previously.
    659      1.1  christos 	 See Table 13-8 in the LSI.  */
    660      1.1  christos       if (in_GRi != out_GRk && in_GRi != out_GRdoublek
    661      1.1  christos 	  && in_GRi != out_GRdoublek + 1 && in_GRi >= 0)
    662      1.1  christos 	{
    663      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    664      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    665      1.1  christos 	}
    666      1.1  christos       if (in_GRj != in_GRi && in_GRj != out_GRk && in_GRj != out_GRdoublek
    667      1.1  christos 	  && in_GRj != out_GRdoublek + 1 && in_GRj >= 0)
    668      1.1  christos 
    669      1.1  christos 	{
    670      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    671      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    672      1.1  christos 	}
    673      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    674      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    675      1.1  christos       vliw_wait_for_GR (cpu, out_GRk);
    676      1.1  christos       vliw_wait_for_GRdouble (cpu, out_GRdoublek);
    677      1.1  christos       handle_resource_wait (cpu);
    678      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    679      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    680      1.1  christos       load_wait_for_GR (cpu, out_GRk);
    681      1.1  christos       load_wait_for_GRdouble (cpu, out_GRdoublek);
    682      1.1  christos       trace_vliw_wait_cycles (cpu);
    683      1.1  christos       return 0;
    684      1.1  christos     }
    685      1.1  christos 
    686      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    687      1.1  christos 
    688      1.1  christos   /* The latency of GRk for a load will depend on how long it takes to retrieve
    689      1.1  christos      the the data from the cache or memory.  */
    690      1.1  christos   update_GR_latency_for_load (cpu, out_GRk, cycles);
    691      1.1  christos   update_GRdouble_latency_for_load (cpu, out_GRdoublek, cycles);
    692      1.1  christos 
    693      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
    694      1.1  christos     {
    695      1.1  christos       /* GNER has a latency of 2 cycles.  */
    696      1.1  christos       update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 2);
    697      1.1  christos       update_SPR_latency (cpu, GNER_FOR_GR (out_GRdoublek), cycles + 2);
    698      1.1  christos     }
    699      1.1  christos 
    700      1.1  christos   if (out_GRk >= 0)
    701      1.1  christos     set_use_is_gr_complex (cpu, out_GRk);
    702      1.1  christos   if (out_GRdoublek != -1)
    703      1.1  christos     {
    704      1.1  christos       set_use_is_gr_complex (cpu, out_GRdoublek);
    705      1.1  christos       set_use_is_gr_complex (cpu, out_GRdoublek + 1);
    706      1.1  christos     }
    707      1.1  christos 
    708      1.1  christos   return cycles;
    709      1.1  christos }
    710      1.1  christos 
    711      1.1  christos int
    712      1.1  christos frvbf_model_fr500_u_gr_store (SIM_CPU *cpu, const IDESC *idesc,
    713      1.1  christos 			      int unit_num, int referenced,
    714      1.1  christos 			      INT in_GRi, INT in_GRj,
    715      1.1  christos 			      INT in_GRk, INT in_GRdoublek)
    716      1.1  christos {
    717      1.1  christos   int cycles;
    718      1.1  christos 
    719      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    720      1.1  christos     {
    721      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    722      1.1  christos 	 which is not ready yet.
    723      1.1  christos 	 The latency of the registers may be less than previously recorded,
    724      1.1  christos 	 depending on how they were used previously.
    725      1.1  christos 	 See Table 13-8 in the LSI.  */
    726      1.1  christos       if (in_GRi >= 0)
    727      1.1  christos 	{
    728      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    729      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    730      1.1  christos 	}
    731      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
    732      1.1  christos 	{
    733      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    734      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    735      1.1  christos 	}
    736      1.1  christos       if (in_GRk != in_GRi && in_GRk != in_GRj && in_GRk >= 0)
    737      1.1  christos 	{
    738      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRk))
    739      1.1  christos 	    decrease_GR_busy (cpu, in_GRk, 1);
    740      1.1  christos 	}
    741      1.1  christos       if (in_GRdoublek != in_GRi && in_GRdoublek != in_GRj
    742      1.1  christos           && in_GRdoublek + 1 != in_GRi && in_GRdoublek + 1 != in_GRj
    743      1.1  christos 	  && in_GRdoublek >= 0)
    744      1.1  christos 	{
    745      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRdoublek))
    746      1.1  christos 	    decrease_GR_busy (cpu, in_GRdoublek, 1);
    747      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRdoublek + 1))
    748      1.1  christos 	    decrease_GR_busy (cpu, in_GRdoublek + 1, 1);
    749      1.1  christos 	}
    750      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    751      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    752      1.1  christos       vliw_wait_for_GR (cpu, in_GRk);
    753      1.1  christos       vliw_wait_for_GRdouble (cpu, in_GRdoublek);
    754      1.1  christos       handle_resource_wait (cpu);
    755      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    756      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    757      1.1  christos       load_wait_for_GR (cpu, in_GRk);
    758      1.1  christos       load_wait_for_GRdouble (cpu, in_GRdoublek);
    759      1.1  christos       trace_vliw_wait_cycles (cpu);
    760      1.1  christos       return 0;
    761      1.1  christos     }
    762      1.1  christos 
    763      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    764      1.1  christos 
    765      1.1  christos   return cycles;
    766      1.1  christos }
    767      1.1  christos 
    768      1.1  christos int
    769      1.1  christos frvbf_model_fr500_u_gr_r_store (SIM_CPU *cpu, const IDESC *idesc,
    770      1.1  christos 				int unit_num, int referenced,
    771      1.1  christos 				INT in_GRi, INT in_GRj,
    772      1.1  christos 				INT in_GRk, INT in_GRdoublek)
    773      1.1  christos {
    774      1.1  christos   int cycles = frvbf_model_fr500_u_gr_store (cpu, idesc, unit_num, referenced,
    775      1.1  christos 					     in_GRi, in_GRj, in_GRk,
    776      1.1  christos 					     in_GRdoublek);
    777      1.1  christos 
    778      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_2)
    779      1.1  christos     {
    780      1.1  christos       if (CPU_RSTR_INVALIDATE(cpu))
    781      1.1  christos 	request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
    782      1.1  christos     }
    783      1.1  christos 
    784      1.1  christos   return cycles;
    785      1.1  christos }
    786      1.1  christos 
    787      1.1  christos int
    788      1.1  christos frvbf_model_fr500_u_fr_load (SIM_CPU *cpu, const IDESC *idesc,
    789      1.1  christos 			     int unit_num, int referenced,
    790      1.1  christos 			     INT in_GRi, INT in_GRj,
    791      1.1  christos 			     INT out_FRk, INT out_FRdoublek)
    792      1.1  christos {
    793      1.1  christos   int cycles;
    794      1.1  christos 
    795      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    796      1.1  christos     {
    797      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    798      1.1  christos 	 which is not ready yet.
    799      1.1  christos 	 The latency of the registers may be less than previously recorded,
    800      1.1  christos 	 depending on how they were used previously.
    801      1.1  christos 	 See Table 13-8 in the LSI.  */
    802      1.1  christos       if (in_GRi >= 0)
    803      1.1  christos 	{
    804      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    805      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    806      1.1  christos 	}
    807      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
    808      1.1  christos 	{
    809      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    810      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    811      1.1  christos 	}
    812      1.1  christos       if (out_FRk >= 0)
    813      1.1  christos 	{
    814      1.1  christos 	  if (use_is_media (cpu, out_FRk))
    815      1.1  christos 	    decrease_FR_busy (cpu, out_FRk, 1);
    816      1.1  christos 	  else
    817      1.1  christos 	    adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
    818      1.1  christos 	}
    819      1.1  christos       if (out_FRdoublek >= 0)
    820      1.1  christos 	{
    821      1.1  christos 	  if (use_is_media (cpu, out_FRdoublek))
    822      1.1  christos 	    decrease_FR_busy (cpu, out_FRdoublek, 1);
    823      1.1  christos 	  else
    824      1.1  christos 	    adjust_float_register_busy (cpu, -1, -1, out_FRdoublek, 1);
    825      1.1  christos 	  if (use_is_media (cpu, out_FRdoublek + 1))
    826      1.1  christos 	    decrease_FR_busy (cpu, out_FRdoublek + 1, 1);
    827      1.1  christos 	  else
    828      1.1  christos 	    adjust_float_register_busy (cpu, -1, -1, out_FRdoublek + 1, 1);
    829      1.1  christos 	}
    830      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    831      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    832      1.1  christos       vliw_wait_for_FR (cpu, out_FRk);
    833      1.1  christos       vliw_wait_for_FRdouble (cpu, out_FRdoublek);
    834      1.1  christos       if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
    835      1.1  christos 	{
    836      1.1  christos 	  vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
    837      1.1  christos 	  vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
    838      1.1  christos 	}
    839      1.1  christos       handle_resource_wait (cpu);
    840      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    841      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    842      1.1  christos       load_wait_for_FR (cpu, out_FRk);
    843      1.1  christos       load_wait_for_FRdouble (cpu, out_FRdoublek);
    844      1.1  christos       trace_vliw_wait_cycles (cpu);
    845      1.1  christos       return 0;
    846      1.1  christos     }
    847      1.1  christos 
    848      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    849      1.1  christos 
    850      1.1  christos   /* The latency of FRk for a load will depend on how long it takes to retrieve
    851      1.1  christos      the the data from the cache or memory.  */
    852      1.1  christos   update_FR_latency_for_load (cpu, out_FRk, cycles);
    853      1.1  christos   update_FRdouble_latency_for_load (cpu, out_FRdoublek, cycles);
    854      1.1  christos 
    855      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
    856      1.1  christos     {
    857      1.1  christos       /* FNER has a latency of 3 cycles.  */
    858      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), cycles + 3);
    859      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), cycles + 3);
    860      1.1  christos     }
    861      1.1  christos 
    862      1.1  christos   fr500_reset_fr_flags (cpu, out_FRk);
    863      1.1  christos 
    864      1.1  christos   return cycles;
    865      1.1  christos }
    866      1.1  christos 
    867      1.1  christos int
    868      1.1  christos frvbf_model_fr500_u_fr_store (SIM_CPU *cpu, const IDESC *idesc,
    869      1.1  christos 			      int unit_num, int referenced,
    870      1.1  christos 			      INT in_GRi, INT in_GRj,
    871      1.1  christos 			      INT in_FRk, INT in_FRdoublek)
    872      1.1  christos {
    873      1.1  christos   int cycles;
    874      1.1  christos 
    875      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    876      1.1  christos     {
    877      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    878      1.1  christos 	 which is not ready yet.
    879      1.1  christos 	 The latency of the registers may be less than previously recorded,
    880      1.1  christos 	 depending on how they were used previously.
    881      1.1  christos 	 See Table 13-8 in the LSI.  */
    882      1.1  christos       if (in_GRi >= 0)
    883      1.1  christos 	{
    884      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    885      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    886      1.1  christos 	}
    887      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
    888      1.1  christos 	{
    889      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    890      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    891      1.1  christos 	}
    892      1.1  christos       if (in_FRk >= 0)
    893      1.1  christos 	{
    894      1.1  christos 	  if (use_is_media (cpu, in_FRk))
    895      1.1  christos 	    decrease_FR_busy (cpu, in_FRk, 1);
    896      1.1  christos 	  else
    897      1.1  christos 	    adjust_float_register_busy (cpu, -1, -1, in_FRk, 1);
    898      1.1  christos 	}
    899      1.1  christos       if (in_FRdoublek >= 0)
    900      1.1  christos 	{
    901      1.1  christos 	  if (use_is_media (cpu, in_FRdoublek))
    902      1.1  christos 	    decrease_FR_busy (cpu, in_FRdoublek, 1);
    903      1.1  christos 	  else
    904      1.1  christos 	    adjust_float_register_busy (cpu, -1, -1, in_FRdoublek, 1);
    905      1.1  christos 	  if (use_is_media (cpu, in_FRdoublek + 1))
    906      1.1  christos 	    decrease_FR_busy (cpu, in_FRdoublek + 1, 1);
    907      1.1  christos 	  else
    908      1.1  christos 	    adjust_float_register_busy (cpu, -1, -1, in_FRdoublek + 1, 1);
    909      1.1  christos 	}
    910      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    911      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    912      1.1  christos       vliw_wait_for_FR (cpu, in_FRk);
    913      1.1  christos       vliw_wait_for_FRdouble (cpu, in_FRdoublek);
    914      1.1  christos       handle_resource_wait (cpu);
    915      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    916      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    917      1.1  christos       load_wait_for_FR (cpu, in_FRk);
    918      1.1  christos       load_wait_for_FRdouble (cpu, in_FRdoublek);
    919      1.1  christos       trace_vliw_wait_cycles (cpu);
    920      1.1  christos       return 0;
    921      1.1  christos     }
    922      1.1  christos 
    923      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    924      1.1  christos 
    925      1.1  christos   return cycles;
    926      1.1  christos }
    927      1.1  christos 
    928      1.1  christos int
    929      1.1  christos frvbf_model_fr500_u_fr_r_store (SIM_CPU *cpu, const IDESC *idesc,
    930      1.1  christos 				int unit_num, int referenced,
    931      1.1  christos 				INT in_GRi, INT in_GRj,
    932      1.1  christos 				INT in_FRk, INT in_FRdoublek)
    933      1.1  christos {
    934      1.1  christos   int cycles = frvbf_model_fr500_u_fr_store (cpu, idesc, unit_num, referenced,
    935      1.1  christos 					     in_GRi, in_GRj, in_FRk,
    936      1.1  christos 					     in_FRdoublek);
    937      1.1  christos 
    938      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_2)
    939      1.1  christos     {
    940      1.1  christos       if (CPU_RSTR_INVALIDATE(cpu))
    941      1.1  christos 	request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
    942      1.1  christos     }
    943      1.1  christos 
    944      1.1  christos   return cycles;
    945      1.1  christos }
    946      1.1  christos 
    947      1.1  christos int
    948      1.1  christos frvbf_model_fr500_u_swap (SIM_CPU *cpu, const IDESC *idesc,
    949      1.1  christos 			  int unit_num, int referenced,
    950      1.1  christos 			  INT in_GRi, INT in_GRj, INT out_GRk)
    951      1.1  christos {
    952      1.1  christos   int cycles;
    953      1.1  christos 
    954      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    955      1.1  christos     {
    956      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    957      1.1  christos 	 which is not ready yet.
    958      1.1  christos 	 The latency of the registers may be less than previously recorded,
    959      1.1  christos 	 depending on how they were used previously.
    960      1.1  christos 	 See Table 13-8 in the LSI.  */
    961      1.1  christos       if (in_GRi != out_GRk && in_GRi >= 0)
    962      1.1  christos 	{
    963      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
    964      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
    965      1.1  christos 	}
    966      1.1  christos       if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
    967      1.1  christos 	{
    968      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
    969      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
    970      1.1  christos 	}
    971      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    972      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    973      1.1  christos       vliw_wait_for_GR (cpu, out_GRk);
    974      1.1  christos       handle_resource_wait (cpu);
    975      1.1  christos       load_wait_for_GR (cpu, in_GRi);
    976      1.1  christos       load_wait_for_GR (cpu, in_GRj);
    977      1.1  christos       load_wait_for_GR (cpu, out_GRk);
    978      1.1  christos       trace_vliw_wait_cycles (cpu);
    979      1.1  christos       return 0;
    980      1.1  christos     }
    981      1.1  christos 
    982      1.1  christos   cycles = idesc->timing->units[unit_num].done;
    983      1.1  christos 
    984      1.1  christos   /* The latency of GRk will depend on how long it takes to swap
    985      1.1  christos      the the data from the cache or memory.  */
    986      1.1  christos   update_GR_latency_for_swap (cpu, out_GRk, cycles);
    987      1.1  christos   set_use_is_gr_complex (cpu, out_GRk);
    988      1.1  christos 
    989      1.1  christos   return cycles;
    990      1.1  christos }
    991      1.1  christos 
    992      1.1  christos int
    993      1.1  christos frvbf_model_fr500_u_fr2fr (SIM_CPU *cpu, const IDESC *idesc,
    994      1.1  christos 			   int unit_num, int referenced,
    995      1.1  christos 			   INT in_FRj, INT out_FRk)
    996      1.1  christos {
    997      1.1  christos   int cycles;
    998      1.1  christos 
    999      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1000      1.1  christos     {
   1001      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1002      1.1  christos 	 which is not ready yet.  */
   1003      1.1  christos       if (in_FRj >= 0)
   1004      1.1  christos 	{
   1005      1.1  christos 	  if (use_is_media (cpu, in_FRj))
   1006      1.1  christos 	    decrease_FR_busy (cpu, in_FRj, 1);
   1007      1.1  christos 	  else
   1008      1.1  christos 	    adjust_float_register_busy (cpu, -1, in_FRj, -1, 1);
   1009      1.1  christos 	}
   1010      1.1  christos       if (out_FRk >= 0 && out_FRk != in_FRj)
   1011      1.1  christos 	{
   1012      1.1  christos 	  if (use_is_media (cpu, out_FRk))
   1013      1.1  christos 	    decrease_FR_busy (cpu, out_FRk, 1);
   1014      1.1  christos 	  else
   1015      1.1  christos 	    adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
   1016      1.1  christos 	}
   1017      1.1  christos       vliw_wait_for_FR (cpu, in_FRj);
   1018      1.1  christos       vliw_wait_for_FR (cpu, out_FRk);
   1019      1.1  christos       handle_resource_wait (cpu);
   1020      1.1  christos       load_wait_for_FR (cpu, in_FRj);
   1021      1.1  christos       load_wait_for_FR (cpu, out_FRk);
   1022      1.1  christos       trace_vliw_wait_cycles (cpu);
   1023      1.1  christos       return 0;
   1024      1.1  christos     }
   1025      1.1  christos 
   1026      1.1  christos   /* The latency of FRj is 3 cycles.  */
   1027      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1028      1.1  christos   update_FR_latency (cpu, out_FRk, cycles + 3);
   1029      1.1  christos 
   1030      1.1  christos   return cycles;
   1031      1.1  christos }
   1032      1.1  christos 
   1033      1.1  christos int
   1034      1.1  christos frvbf_model_fr500_u_fr2gr (SIM_CPU *cpu, const IDESC *idesc,
   1035      1.1  christos 			   int unit_num, int referenced,
   1036      1.1  christos 			   INT in_FRk, INT out_GRj)
   1037      1.1  christos {
   1038      1.1  christos   int cycles;
   1039      1.1  christos 
   1040      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1041      1.1  christos     {
   1042      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1043      1.1  christos 	 which is not ready yet.  */
   1044      1.1  christos       if (in_FRk >= 0)
   1045      1.1  christos 	{
   1046      1.1  christos 	  if (use_is_media (cpu, in_FRk))
   1047      1.1  christos 	    decrease_FR_busy (cpu, in_FRk, 1);
   1048      1.1  christos 	  else
   1049      1.1  christos 	    adjust_float_register_busy (cpu, -1, in_FRk, -1, 1);
   1050      1.1  christos 	}
   1051      1.1  christos       vliw_wait_for_FR (cpu, in_FRk);
   1052      1.1  christos       vliw_wait_for_GR (cpu, out_GRj);
   1053      1.1  christos       handle_resource_wait (cpu);
   1054      1.1  christos       load_wait_for_FR (cpu, in_FRk);
   1055      1.1  christos       load_wait_for_GR (cpu, out_GRj);
   1056      1.1  christos       trace_vliw_wait_cycles (cpu);
   1057      1.1  christos       return 0;
   1058      1.1  christos     }
   1059      1.1  christos 
   1060      1.1  christos   /* The latency of GRj is 2 cycles.  */
   1061      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1062      1.1  christos   update_GR_latency (cpu, out_GRj, cycles + 2);
   1063      1.1  christos   set_use_is_gr_complex (cpu, out_GRj);
   1064      1.1  christos 
   1065      1.1  christos   return cycles;
   1066      1.1  christos }
   1067      1.1  christos 
   1068      1.1  christos int
   1069      1.1  christos frvbf_model_fr500_u_spr2gr (SIM_CPU *cpu, const IDESC *idesc,
   1070      1.1  christos 			   int unit_num, int referenced,
   1071      1.1  christos 			   INT in_spr, INT out_GRj)
   1072      1.1  christos {
   1073      1.1  christos   int cycles;
   1074      1.1  christos 
   1075      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1076      1.1  christos     {
   1077      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1078      1.1  christos 	 which is not ready yet.  */
   1079      1.1  christos       vliw_wait_for_SPR (cpu, in_spr);
   1080      1.1  christos       vliw_wait_for_GR (cpu, out_GRj);
   1081      1.1  christos       handle_resource_wait (cpu);
   1082      1.1  christos       load_wait_for_GR (cpu, out_GRj);
   1083      1.1  christos       trace_vliw_wait_cycles (cpu);
   1084      1.1  christos       return 0;
   1085      1.1  christos     }
   1086      1.1  christos 
   1087      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1088      1.1  christos 
   1089      1.1  christos #if 0 /* no latency?  */
   1090      1.1  christos   /* The latency of GRj is 2 cycles.  */
   1091      1.1  christos   update_GR_latency (cpu, out_GRj, cycles + 2);
   1092      1.1  christos #endif
   1093      1.1  christos 
   1094      1.1  christos   return cycles;
   1095      1.1  christos }
   1096      1.1  christos 
   1097      1.1  christos int
   1098      1.1  christos frvbf_model_fr500_u_gr2fr (SIM_CPU *cpu, const IDESC *idesc,
   1099      1.1  christos 			   int unit_num, int referenced,
   1100      1.1  christos 			   INT in_GRj, INT out_FRk)
   1101      1.1  christos {
   1102      1.1  christos   int cycles;
   1103      1.1  christos 
   1104      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1105      1.1  christos     {
   1106      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1107      1.1  christos 	 which is not ready yet.
   1108      1.1  christos 	 The latency of the registers may be less than previously recorded,
   1109      1.1  christos 	 depending on how they were used previously.
   1110      1.1  christos 	 See Table 13-8 in the LSI.  */
   1111      1.1  christos       if (in_GRj >= 0)
   1112      1.1  christos 	{
   1113      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
   1114      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
   1115      1.1  christos 	}
   1116      1.1  christos       if (out_FRk >= 0)
   1117      1.1  christos 	{
   1118      1.1  christos 	  if (use_is_media (cpu, out_FRk))
   1119      1.1  christos 	    decrease_FR_busy (cpu, out_FRk, 1);
   1120      1.1  christos 	  else
   1121      1.1  christos 	    adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
   1122      1.1  christos 	}
   1123      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1124      1.1  christos       vliw_wait_for_FR (cpu, out_FRk);
   1125      1.1  christos       handle_resource_wait (cpu);
   1126      1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1127      1.1  christos       load_wait_for_FR (cpu, out_FRk);
   1128      1.1  christos       trace_vliw_wait_cycles (cpu);
   1129      1.1  christos       return 0;
   1130      1.1  christos     }
   1131      1.1  christos 
   1132      1.1  christos   /* The latency of FRk is 2 cycles.  */
   1133      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1134      1.1  christos   update_FR_latency (cpu, out_FRk, cycles + 2);
   1135      1.1  christos 
   1136      1.1  christos   /* Mark this use of the register as NOT a floating point op.  */
   1137      1.1  christos   fr500_reset_fr_flags (cpu, out_FRk);
   1138      1.1  christos 
   1139      1.1  christos   return cycles;
   1140      1.1  christos }
   1141      1.1  christos 
   1142      1.1  christos int
   1143      1.1  christos frvbf_model_fr500_u_gr2spr (SIM_CPU *cpu, const IDESC *idesc,
   1144      1.1  christos 			    int unit_num, int referenced,
   1145      1.1  christos 			    INT in_GRj, INT out_spr)
   1146      1.1  christos {
   1147      1.1  christos   int cycles;
   1148      1.1  christos 
   1149      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1150      1.1  christos     {
   1151      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1152      1.1  christos 	 which is not ready yet.
   1153      1.1  christos 	 The latency of the registers may be less than previously recorded,
   1154      1.1  christos 	 depending on how they were used previously.
   1155      1.1  christos 	 See Table 13-8 in the LSI.  */
   1156      1.1  christos       if (in_GRj >= 0)
   1157      1.1  christos 	{
   1158      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
   1159      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
   1160      1.1  christos 	}
   1161      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1162      1.1  christos       vliw_wait_for_SPR (cpu, out_spr);
   1163      1.1  christos       handle_resource_wait (cpu);
   1164      1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1165      1.1  christos       trace_vliw_wait_cycles (cpu);
   1166      1.1  christos       return 0;
   1167      1.1  christos     }
   1168      1.1  christos 
   1169      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1170      1.1  christos 
   1171      1.1  christos #if 0
   1172      1.1  christos   /* The latency of spr is ? cycles.  */
   1173      1.1  christos   update_SPR_latency (cpu, out_spr, cycles + ?);
   1174      1.1  christos #endif
   1175      1.1  christos 
   1176      1.1  christos   return cycles;
   1177      1.1  christos }
   1178      1.1  christos 
   1179      1.1  christos int
   1180      1.1  christos frvbf_model_fr500_u_ici (SIM_CPU *cpu, const IDESC *idesc,
   1181      1.1  christos 			 int unit_num, int referenced,
   1182      1.1  christos 			 INT in_GRi, INT in_GRj)
   1183      1.1  christos {
   1184      1.1  christos   int cycles;
   1185      1.1  christos 
   1186      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1187      1.1  christos     {
   1188      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1189      1.1  christos 	 which is not ready yet.
   1190      1.1  christos 	 The latency of the registers may be less than previously recorded,
   1191      1.1  christos 	 depending on how they were used previously.
   1192      1.1  christos 	 See Table 13-8 in the LSI.  */
   1193      1.1  christos       if (in_GRi >= 0)
   1194      1.1  christos 	{
   1195      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
   1196      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
   1197      1.1  christos 	}
   1198      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
   1199      1.1  christos 	{
   1200      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
   1201      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
   1202      1.1  christos 	}
   1203      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
   1204      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1205      1.1  christos       handle_resource_wait (cpu);
   1206      1.1  christos       load_wait_for_GR (cpu, in_GRi);
   1207      1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1208      1.1  christos       trace_vliw_wait_cycles (cpu);
   1209      1.1  christos       return 0;
   1210      1.1  christos     }
   1211      1.1  christos 
   1212      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1213      1.1  christos   request_cache_invalidate (cpu, CPU_INSN_CACHE (cpu), cycles);
   1214      1.1  christos   return cycles;
   1215      1.1  christos }
   1216      1.1  christos 
   1217      1.1  christos int
   1218      1.1  christos frvbf_model_fr500_u_dci (SIM_CPU *cpu, const IDESC *idesc,
   1219      1.1  christos 			 int unit_num, int referenced,
   1220      1.1  christos 			 INT in_GRi, INT in_GRj)
   1221      1.1  christos {
   1222      1.1  christos   int cycles;
   1223      1.1  christos 
   1224      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1225      1.1  christos     {
   1226      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1227      1.1  christos 	 which is not ready yet.
   1228      1.1  christos 	 The latency of the registers may be less than previously recorded,
   1229      1.1  christos 	 depending on how they were used previously.
   1230      1.1  christos 	 See Table 13-8 in the LSI.  */
   1231      1.1  christos       if (in_GRi >= 0)
   1232      1.1  christos 	{
   1233      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
   1234      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
   1235      1.1  christos 	}
   1236      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
   1237      1.1  christos 	{
   1238      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
   1239      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
   1240      1.1  christos 	}
   1241      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
   1242      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1243      1.1  christos       handle_resource_wait (cpu);
   1244      1.1  christos       load_wait_for_GR (cpu, in_GRi);
   1245      1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1246      1.1  christos       trace_vliw_wait_cycles (cpu);
   1247      1.1  christos       return 0;
   1248      1.1  christos     }
   1249      1.1  christos 
   1250      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1251      1.1  christos   request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
   1252      1.1  christos   return cycles;
   1253      1.1  christos }
   1254      1.1  christos 
   1255      1.1  christos int
   1256      1.1  christos frvbf_model_fr500_u_dcf (SIM_CPU *cpu, const IDESC *idesc,
   1257      1.1  christos 			 int unit_num, int referenced,
   1258      1.1  christos 			 INT in_GRi, INT in_GRj)
   1259      1.1  christos {
   1260      1.1  christos   int cycles;
   1261      1.1  christos 
   1262      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1263      1.1  christos     {
   1264      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1265      1.1  christos 	 which is not ready yet.
   1266      1.1  christos 	 The latency of the registers may be less than previously recorded,
   1267      1.1  christos 	 depending on how they were used previously.
   1268      1.1  christos 	 See Table 13-8 in the LSI.  */
   1269      1.1  christos       if (in_GRi >= 0)
   1270      1.1  christos 	{
   1271      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
   1272      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
   1273      1.1  christos 	}
   1274      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
   1275      1.1  christos 	{
   1276      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
   1277      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
   1278      1.1  christos 	}
   1279      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
   1280      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1281      1.1  christos       handle_resource_wait (cpu);
   1282      1.1  christos       load_wait_for_GR (cpu, in_GRi);
   1283      1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1284      1.1  christos       trace_vliw_wait_cycles (cpu);
   1285      1.1  christos       return 0;
   1286      1.1  christos     }
   1287      1.1  christos 
   1288      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1289      1.1  christos   request_cache_flush (cpu, CPU_DATA_CACHE (cpu), cycles);
   1290      1.1  christos   return cycles;
   1291      1.1  christos }
   1292      1.1  christos 
   1293      1.1  christos int
   1294      1.1  christos frvbf_model_fr500_u_icpl (SIM_CPU *cpu, const IDESC *idesc,
   1295      1.1  christos 			  int unit_num, int referenced,
   1296      1.1  christos 			  INT in_GRi, INT in_GRj)
   1297      1.1  christos {
   1298      1.1  christos   int cycles;
   1299      1.1  christos 
   1300      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1301      1.1  christos     {
   1302      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1303      1.1  christos 	 which is not ready yet.
   1304      1.1  christos 	 The latency of the registers may be less than previously recorded,
   1305      1.1  christos 	 depending on how they were used previously.
   1306      1.1  christos 	 See Table 13-8 in the LSI.  */
   1307      1.1  christos       if (in_GRi >= 0)
   1308      1.1  christos 	{
   1309      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
   1310      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
   1311      1.1  christos 	}
   1312      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
   1313      1.1  christos 	{
   1314      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
   1315      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
   1316      1.1  christos 	}
   1317      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
   1318      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1319      1.1  christos       handle_resource_wait (cpu);
   1320      1.1  christos       load_wait_for_GR (cpu, in_GRi);
   1321      1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1322      1.1  christos       trace_vliw_wait_cycles (cpu);
   1323      1.1  christos       return 0;
   1324      1.1  christos     }
   1325      1.1  christos 
   1326      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1327      1.1  christos   request_cache_preload (cpu, CPU_INSN_CACHE (cpu), cycles);
   1328      1.1  christos   return cycles;
   1329      1.1  christos }
   1330      1.1  christos 
   1331      1.1  christos int
   1332      1.1  christos frvbf_model_fr500_u_dcpl (SIM_CPU *cpu, const IDESC *idesc,
   1333      1.1  christos 			  int unit_num, int referenced,
   1334      1.1  christos 			  INT in_GRi, INT in_GRj)
   1335      1.1  christos {
   1336      1.1  christos   int cycles;
   1337      1.1  christos 
   1338      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1339      1.1  christos     {
   1340      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1341      1.1  christos 	 which is not ready yet.
   1342      1.1  christos 	 The latency of the registers may be less than previously recorded,
   1343      1.1  christos 	 depending on how they were used previously.
   1344      1.1  christos 	 See Table 13-8 in the LSI.  */
   1345      1.1  christos       if (in_GRi >= 0)
   1346      1.1  christos 	{
   1347      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
   1348      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
   1349      1.1  christos 	}
   1350      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
   1351      1.1  christos 	{
   1352      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
   1353      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
   1354      1.1  christos 	}
   1355      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
   1356      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1357      1.1  christos       handle_resource_wait (cpu);
   1358      1.1  christos       load_wait_for_GR (cpu, in_GRi);
   1359      1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1360      1.1  christos       trace_vliw_wait_cycles (cpu);
   1361      1.1  christos       return 0;
   1362      1.1  christos     }
   1363      1.1  christos 
   1364      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1365      1.1  christos   request_cache_preload (cpu, CPU_DATA_CACHE (cpu), cycles);
   1366      1.1  christos   return cycles;
   1367      1.1  christos }
   1368      1.1  christos 
   1369      1.1  christos int
   1370      1.1  christos frvbf_model_fr500_u_icul (SIM_CPU *cpu, const IDESC *idesc,
   1371      1.1  christos 			  int unit_num, int referenced,
   1372      1.1  christos 			  INT in_GRi, INT in_GRj)
   1373      1.1  christos {
   1374      1.1  christos   int cycles;
   1375      1.1  christos 
   1376      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1377      1.1  christos     {
   1378      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1379      1.1  christos 	 which is not ready yet.
   1380      1.1  christos 	 The latency of the registers may be less than previously recorded,
   1381      1.1  christos 	 depending on how they were used previously.
   1382      1.1  christos 	 See Table 13-8 in the LSI.  */
   1383      1.1  christos       if (in_GRi >= 0)
   1384      1.1  christos 	{
   1385      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
   1386      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
   1387      1.1  christos 	}
   1388      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
   1389      1.1  christos 	{
   1390      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
   1391      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
   1392      1.1  christos 	}
   1393      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
   1394      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1395      1.1  christos       handle_resource_wait (cpu);
   1396      1.1  christos       load_wait_for_GR (cpu, in_GRi);
   1397      1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1398      1.1  christos       trace_vliw_wait_cycles (cpu);
   1399      1.1  christos       return 0;
   1400      1.1  christos     }
   1401      1.1  christos 
   1402      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1403      1.1  christos   request_cache_unlock (cpu, CPU_INSN_CACHE (cpu), cycles);
   1404      1.1  christos   return cycles;
   1405      1.1  christos }
   1406      1.1  christos 
   1407      1.1  christos int
   1408      1.1  christos frvbf_model_fr500_u_dcul (SIM_CPU *cpu, const IDESC *idesc,
   1409      1.1  christos 			  int unit_num, int referenced,
   1410      1.1  christos 			  INT in_GRi, INT in_GRj)
   1411      1.1  christos {
   1412      1.1  christos   int cycles;
   1413      1.1  christos 
   1414      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1415      1.1  christos     {
   1416      1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1417      1.1  christos 	 which is not ready yet.
   1418      1.1  christos 	 The latency of the registers may be less than previously recorded,
   1419      1.1  christos 	 depending on how they were used previously.
   1420      1.1  christos 	 See Table 13-8 in the LSI.  */
   1421      1.1  christos       if (in_GRi >= 0)
   1422      1.1  christos 	{
   1423      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRi))
   1424      1.1  christos 	    decrease_GR_busy (cpu, in_GRi, 1);
   1425      1.1  christos 	}
   1426      1.1  christos       if (in_GRj != in_GRi && in_GRj >= 0)
   1427      1.1  christos 	{
   1428      1.1  christos 	  if (use_is_gr_complex (cpu, in_GRj))
   1429      1.1  christos 	    decrease_GR_busy (cpu, in_GRj, 1);
   1430      1.1  christos 	}
   1431      1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
   1432      1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1433      1.1  christos       handle_resource_wait (cpu);
   1434      1.1  christos       load_wait_for_GR (cpu, in_GRi);
   1435      1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1436      1.1  christos       trace_vliw_wait_cycles (cpu);
   1437      1.1  christos       return 0;
   1438      1.1  christos     }
   1439      1.1  christos 
   1440      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1441      1.1  christos   request_cache_unlock (cpu, CPU_DATA_CACHE (cpu), cycles);
   1442      1.1  christos   return cycles;
   1443      1.1  christos }
   1444      1.1  christos 
   1445      1.1  christos int
   1446      1.1  christos frvbf_model_fr500_u_float_arith (SIM_CPU *cpu, const IDESC *idesc,
   1447      1.1  christos 				 int unit_num, int referenced,
   1448      1.1  christos 				 INT in_FRi, INT in_FRj,
   1449      1.1  christos 				 INT in_FRdoublei, INT in_FRdoublej,
   1450      1.1  christos 				 INT out_FRk, INT out_FRdoublek)
   1451      1.1  christos {
   1452      1.1  christos   int cycles;
   1453      1.1  christos   FRV_PROFILE_STATE *ps;
   1454      1.1  christos 
   1455      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1456      1.1  christos     return 0;
   1457      1.1  christos 
   1458      1.1  christos   /* The preprocessing can execute right away.  */
   1459      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1460      1.1  christos 
   1461      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1462      1.1  christos      which is not ready yet.  */
   1463      1.1  christos   adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
   1464      1.1  christos   adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
   1465      1.1  christos 			       1);
   1466      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1467      1.1  christos   ps->post_wait = cycles;
   1468      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1469      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1470      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1471      1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublei);
   1472      1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1473      1.1  christos   post_wait_for_FRdouble (cpu, out_FRdoublek);
   1474      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1475      1.1  christos     {
   1476      1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1477      1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
   1478      1.1  christos     }
   1479      1.1  christos   restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
   1480      1.1  christos   restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
   1481      1.1  christos 				1);
   1482      1.1  christos 
   1483      1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1484      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1485      1.1  christos   update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
   1486      1.1  christos 
   1487      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1488      1.1  christos     {
   1489      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
   1490      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
   1491      1.1  christos     }
   1492      1.1  christos 
   1493      1.1  christos   /* Once initiated, post-processing will take 3 cycles.  */
   1494      1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   1495      1.1  christos   update_FRdouble_ptime (cpu, out_FRdoublek, 3);
   1496      1.1  christos 
   1497      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1498      1.1  christos     {
   1499      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
   1500      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
   1501      1.1  christos     }
   1502      1.1  christos 
   1503      1.1  christos   /* Mark this use of the register as a floating point op.  */
   1504      1.1  christos   if (out_FRk >= 0)
   1505      1.1  christos     set_use_is_fpop (cpu, out_FRk);
   1506      1.1  christos   if (out_FRdoublek >= 0)
   1507      1.1  christos     {
   1508      1.1  christos       set_use_is_fpop (cpu, out_FRdoublek);
   1509      1.1  christos       if (out_FRdoublek < 63)
   1510      1.1  christos 	set_use_is_fpop (cpu, out_FRdoublek + 1);
   1511      1.1  christos     }
   1512      1.1  christos 
   1513      1.1  christos   return cycles;
   1514      1.1  christos }
   1515      1.1  christos 
   1516      1.1  christos int
   1517      1.1  christos frvbf_model_fr500_u_float_dual_arith (SIM_CPU *cpu, const IDESC *idesc,
   1518      1.1  christos 				      int unit_num, int referenced,
   1519      1.1  christos 				      INT in_FRi, INT in_FRj,
   1520      1.1  christos 				      INT in_FRdoublei, INT in_FRdoublej,
   1521      1.1  christos 				      INT out_FRk, INT out_FRdoublek)
   1522      1.1  christos {
   1523      1.1  christos   int cycles;
   1524      1.1  christos   INT dual_FRi;
   1525      1.1  christos   INT dual_FRj;
   1526      1.1  christos   INT dual_FRk;
   1527      1.1  christos   INT dual_FRdoublei;
   1528      1.1  christos   INT dual_FRdoublej;
   1529      1.1  christos   INT dual_FRdoublek;
   1530      1.1  christos   FRV_PROFILE_STATE *ps;
   1531      1.1  christos 
   1532      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1533      1.1  christos     return 0;
   1534      1.1  christos 
   1535      1.1  christos   /* The preprocessing can execute right away.  */
   1536      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1537      1.1  christos 
   1538      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1539      1.1  christos      which is not ready yet.  */
   1540      1.1  christos   dual_FRi = DUAL_REG (in_FRi);
   1541      1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   1542      1.1  christos   dual_FRk = DUAL_REG (out_FRk);
   1543      1.1  christos   dual_FRdoublei = DUAL_DOUBLE (in_FRdoublei);
   1544      1.1  christos   dual_FRdoublej = DUAL_DOUBLE (in_FRdoublej);
   1545      1.1  christos   dual_FRdoublek = DUAL_DOUBLE (out_FRdoublek);
   1546      1.1  christos 
   1547      1.1  christos   adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
   1548      1.1  christos   adjust_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
   1549      1.1  christos   adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
   1550      1.1  christos 			       1);
   1551      1.1  christos   adjust_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
   1552      1.1  christos 			       dual_FRdoublek, 1);
   1553      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1554      1.1  christos   ps->post_wait = cycles;
   1555      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1556      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1557      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1558      1.1  christos   post_wait_for_FR (cpu, dual_FRi);
   1559      1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   1560      1.1  christos   post_wait_for_FR (cpu, dual_FRk);
   1561      1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublei);
   1562      1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1563      1.1  christos   post_wait_for_FRdouble (cpu, out_FRdoublek);
   1564      1.1  christos   post_wait_for_FRdouble (cpu, dual_FRdoublei);
   1565      1.1  christos   post_wait_for_FRdouble (cpu, dual_FRdoublej);
   1566      1.1  christos   post_wait_for_FRdouble (cpu, dual_FRdoublek);
   1567      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1568      1.1  christos     {
   1569      1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1570      1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRk));
   1571      1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
   1572      1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRdoublek));
   1573      1.1  christos     }
   1574      1.1  christos   restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
   1575      1.1  christos   restore_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
   1576      1.1  christos   restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
   1577      1.1  christos 				1);
   1578      1.1  christos   restore_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
   1579      1.1  christos 				dual_FRdoublek, 1);
   1580      1.1  christos 
   1581      1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1582      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1583      1.1  christos   update_FR_latency (cpu, dual_FRk, ps->post_wait);
   1584      1.1  christos   update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
   1585      1.1  christos   update_FRdouble_latency (cpu, dual_FRdoublek, ps->post_wait);
   1586      1.1  christos 
   1587      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1588      1.1  christos     {
   1589      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
   1590      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (dual_FRk), ps->post_wait);
   1591      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
   1592      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (dual_FRdoublek), ps->post_wait);
   1593      1.1  christos     }
   1594      1.1  christos 
   1595      1.1  christos   /* Once initiated, post-processing will take 3 cycles.  */
   1596      1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   1597      1.1  christos   update_FR_ptime (cpu, dual_FRk, 3);
   1598      1.1  christos   update_FRdouble_ptime (cpu, out_FRdoublek, 3);
   1599      1.1  christos   update_FRdouble_ptime (cpu, dual_FRdoublek, 3);
   1600      1.1  christos 
   1601      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1602      1.1  christos     {
   1603      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
   1604      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRk), 3);
   1605      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
   1606      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRdoublek), 3);
   1607      1.1  christos     }
   1608      1.1  christos 
   1609      1.1  christos   /* Mark this use of the register as a floating point op.  */
   1610      1.1  christos   if (out_FRk >= 0)
   1611      1.1  christos     set_use_is_fpop (cpu, out_FRk);
   1612      1.1  christos   if (dual_FRk >= 0)
   1613      1.1  christos     set_use_is_fpop (cpu, dual_FRk);
   1614      1.1  christos   if (out_FRdoublek >= 0)
   1615      1.1  christos     {
   1616      1.1  christos       set_use_is_fpop (cpu, out_FRdoublek);
   1617      1.1  christos       if (out_FRdoublek < 63)
   1618      1.1  christos 	set_use_is_fpop (cpu, out_FRdoublek + 1);
   1619      1.1  christos     }
   1620      1.1  christos   if (dual_FRdoublek >= 0)
   1621      1.1  christos     {
   1622      1.1  christos       set_use_is_fpop (cpu, dual_FRdoublek);
   1623      1.1  christos       if (dual_FRdoublek < 63)
   1624      1.1  christos 	set_use_is_fpop (cpu, dual_FRdoublek + 1);
   1625      1.1  christos     }
   1626      1.1  christos 
   1627      1.1  christos   return cycles;
   1628      1.1  christos }
   1629      1.1  christos 
   1630      1.1  christos int
   1631      1.1  christos frvbf_model_fr500_u_float_div (SIM_CPU *cpu, const IDESC *idesc,
   1632      1.1  christos 			       int unit_num, int referenced,
   1633      1.1  christos 			       INT in_FRi, INT in_FRj, INT out_FRk)
   1634      1.1  christos {
   1635      1.1  christos   int cycles;
   1636      1.1  christos   FRV_VLIW *vliw;
   1637      1.1  christos   int slot;
   1638      1.1  christos   FRV_PROFILE_STATE *ps;
   1639      1.1  christos 
   1640      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1641      1.1  christos     return 0;
   1642      1.1  christos 
   1643      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1644      1.1  christos 
   1645      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1646      1.1  christos      which is not ready yet.  */
   1647      1.1  christos   adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
   1648      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1649      1.1  christos   ps->post_wait = cycles;
   1650      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1651      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1652      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1653      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1654      1.1  christos     post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1655      1.1  christos   vliw = CPU_VLIW (cpu);
   1656      1.1  christos   slot = vliw->next_slot - 1;
   1657      1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1658      1.1  christos   post_wait_for_fdiv (cpu, slot);
   1659      1.1  christos   restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
   1660      1.1  christos 
   1661      1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1662      1.1  christos   /* Once initiated, post-processing will take 10 cycles.  */
   1663      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1664      1.1  christos   update_FR_ptime (cpu, out_FRk, 10);
   1665      1.1  christos 
   1666      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1667      1.1  christos     {
   1668      1.1  christos       /* FNER has a latency of 10 cycles.  */
   1669      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
   1670      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 10);
   1671      1.1  christos     }
   1672      1.1  christos 
   1673      1.1  christos   /* The latency of the fdiv unit will be at least the latency of the other
   1674      1.1  christos      inputs.  Once initiated, post-processing will take 9 cycles.  */
   1675      1.1  christos   update_fdiv_resource_latency (cpu, slot, ps->post_wait + 9);
   1676      1.1  christos 
   1677      1.1  christos   /* Mark this use of the register as a floating point op.  */
   1678      1.1  christos   set_use_is_fpop (cpu, out_FRk);
   1679      1.1  christos 
   1680      1.1  christos   return cycles;
   1681      1.1  christos }
   1682      1.1  christos 
   1683      1.1  christos int
   1684      1.1  christos frvbf_model_fr500_u_float_sqrt (SIM_CPU *cpu, const IDESC *idesc,
   1685      1.1  christos 				int unit_num, int referenced,
   1686      1.1  christos 				INT in_FRj, INT in_FRdoublej,
   1687      1.1  christos 				INT out_FRk, INT out_FRdoublek)
   1688      1.1  christos {
   1689      1.1  christos   int cycles;
   1690      1.1  christos   FRV_VLIW *vliw;
   1691      1.1  christos   int slot;
   1692      1.1  christos   FRV_PROFILE_STATE *ps;
   1693      1.1  christos 
   1694      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1695      1.1  christos     return 0;
   1696      1.1  christos 
   1697      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1698      1.1  christos 
   1699      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1700      1.1  christos      which is not ready yet.  */
   1701      1.1  christos   adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
   1702      1.1  christos   adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
   1703      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1704      1.1  christos   ps->post_wait = cycles;
   1705      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1706      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1707      1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1708      1.1  christos   post_wait_for_FRdouble (cpu, out_FRdoublek);
   1709      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1710      1.1  christos     post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1711      1.1  christos   vliw = CPU_VLIW (cpu);
   1712      1.1  christos   slot = vliw->next_slot - 1;
   1713      1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1714      1.1  christos   post_wait_for_fsqrt (cpu, slot);
   1715      1.1  christos   restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
   1716      1.1  christos   restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
   1717      1.1  christos 
   1718      1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1719      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1720      1.1  christos   update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
   1721      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1722      1.1  christos     update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
   1723      1.1  christos 
   1724      1.1  christos   /* Once initiated, post-processing will take 15 cycles.  */
   1725      1.1  christos   update_FR_ptime (cpu, out_FRk, 15);
   1726      1.1  christos   update_FRdouble_ptime (cpu, out_FRdoublek, 15);
   1727      1.1  christos 
   1728      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1729      1.1  christos     update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 15);
   1730      1.1  christos 
   1731      1.1  christos   /* The latency of the sqrt unit will be the latency of the other
   1732      1.1  christos      inputs plus 14 cycles.  */
   1733      1.1  christos   update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
   1734      1.1  christos 
   1735      1.1  christos   /* Mark this use of the register as a floating point op.  */
   1736      1.1  christos   if (out_FRk >= 0)
   1737      1.1  christos     set_use_is_fpop (cpu, out_FRk);
   1738      1.1  christos   if (out_FRdoublek >= 0)
   1739      1.1  christos     {
   1740      1.1  christos       set_use_is_fpop (cpu, out_FRdoublek);
   1741      1.1  christos       if (out_FRdoublek < 63)
   1742      1.1  christos 	set_use_is_fpop (cpu, out_FRdoublek + 1);
   1743      1.1  christos     }
   1744      1.1  christos 
   1745      1.1  christos   return cycles;
   1746      1.1  christos }
   1747      1.1  christos 
   1748      1.1  christos int
   1749      1.1  christos frvbf_model_fr500_u_float_dual_sqrt (SIM_CPU *cpu, const IDESC *idesc,
   1750      1.1  christos 				     int unit_num, int referenced,
   1751      1.1  christos 				     INT in_FRj, INT out_FRk)
   1752      1.1  christos {
   1753      1.1  christos   int cycles;
   1754      1.1  christos   FRV_VLIW *vliw;
   1755      1.1  christos   int slot;
   1756      1.1  christos   INT dual_FRj;
   1757      1.1  christos   INT dual_FRk;
   1758      1.1  christos   FRV_PROFILE_STATE *ps;
   1759      1.1  christos 
   1760      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1761      1.1  christos     return 0;
   1762      1.1  christos 
   1763      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1764      1.1  christos 
   1765      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1766      1.1  christos      which is not ready yet.  */
   1767      1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   1768      1.1  christos   dual_FRk = DUAL_REG (out_FRk);
   1769      1.1  christos   adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
   1770      1.1  christos   adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
   1771      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1772      1.1  christos   ps->post_wait = cycles;
   1773      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1774      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1775      1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   1776      1.1  christos   post_wait_for_FR (cpu, dual_FRk);
   1777      1.1  christos 
   1778      1.1  christos   vliw = CPU_VLIW (cpu);
   1779      1.1  christos   slot = vliw->next_slot - 1;
   1780      1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1781      1.1  christos   post_wait_for_fsqrt (cpu, slot);
   1782      1.1  christos   restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
   1783      1.1  christos   restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
   1784      1.1  christos 
   1785      1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1786      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1787      1.1  christos   update_FR_latency (cpu, dual_FRk, ps->post_wait);
   1788      1.1  christos 
   1789      1.1  christos   /* Once initiated, post-processing will take 15 cycles.  */
   1790      1.1  christos   update_FR_ptime (cpu, out_FRk, 15);
   1791      1.1  christos   update_FR_ptime (cpu, dual_FRk, 15);
   1792      1.1  christos 
   1793      1.1  christos   /* The latency of the sqrt unit will be at least the latency of the other
   1794      1.1  christos      inputs.  */
   1795      1.1  christos   update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
   1796      1.1  christos 
   1797      1.1  christos   /* Mark this use of the register as a floating point op.  */
   1798      1.1  christos   if (out_FRk >= 0)
   1799      1.1  christos     set_use_is_fpop (cpu, out_FRk);
   1800      1.1  christos   if (dual_FRk >= 0)
   1801      1.1  christos     set_use_is_fpop (cpu, dual_FRk);
   1802      1.1  christos 
   1803      1.1  christos   return cycles;
   1804      1.1  christos }
   1805      1.1  christos 
   1806      1.1  christos int
   1807      1.1  christos frvbf_model_fr500_u_float_compare (SIM_CPU *cpu, const IDESC *idesc,
   1808      1.1  christos 				   int unit_num, int referenced,
   1809      1.1  christos 				   INT in_FRi, INT in_FRj,
   1810      1.1  christos 				   INT in_FRdoublei, INT in_FRdoublej,
   1811      1.1  christos 				   INT out_FCCi_2)
   1812      1.1  christos {
   1813      1.1  christos   int cycles;
   1814      1.1  christos   FRV_PROFILE_STATE *ps;
   1815      1.1  christos 
   1816      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1817      1.1  christos     return 0;
   1818      1.1  christos 
   1819      1.1  christos   /* The preprocessing can execute right away.  */
   1820      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1821      1.1  christos 
   1822      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1823      1.1  christos      which is not ready yet.  */
   1824      1.1  christos   adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
   1825      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1826      1.1  christos   ps->post_wait = cycles;
   1827      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1828      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1829      1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublei);
   1830      1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1831      1.1  christos   post_wait_for_CCR (cpu, out_FCCi_2);
   1832      1.1  christos   restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
   1833      1.1  christos 
   1834      1.1  christos   /* The latency of FCCi_2 will be the latency of the other inputs plus 3
   1835      1.1  christos      cycles.  */
   1836      1.1  christos   update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
   1837      1.1  christos 
   1838      1.1  christos   return cycles;
   1839      1.1  christos }
   1840      1.1  christos 
   1841      1.1  christos int
   1842      1.1  christos frvbf_model_fr500_u_float_dual_compare (SIM_CPU *cpu, const IDESC *idesc,
   1843      1.1  christos 					int unit_num, int referenced,
   1844      1.1  christos 					INT in_FRi, INT in_FRj,
   1845      1.1  christos 					INT out_FCCi_2)
   1846      1.1  christos {
   1847      1.1  christos   int cycles;
   1848      1.1  christos   INT dual_FRi;
   1849      1.1  christos   INT dual_FRj;
   1850      1.1  christos   INT dual_FCCi_2;
   1851      1.1  christos   FRV_PROFILE_STATE *ps;
   1852      1.1  christos 
   1853      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1854      1.1  christos     return 0;
   1855      1.1  christos 
   1856      1.1  christos   /* The preprocessing can execute right away.  */
   1857      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1858      1.1  christos 
   1859      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1860      1.1  christos      which is not ready yet.  */
   1861      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1862      1.1  christos   ps->post_wait = cycles;
   1863      1.1  christos   dual_FRi = DUAL_REG (in_FRi);
   1864      1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   1865      1.1  christos   dual_FCCi_2 = out_FCCi_2 + 1;
   1866      1.1  christos   adjust_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
   1867      1.1  christos   adjust_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
   1868      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1869      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1870      1.1  christos   post_wait_for_FR (cpu, dual_FRi);
   1871      1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   1872      1.1  christos   post_wait_for_CCR (cpu, out_FCCi_2);
   1873      1.1  christos   post_wait_for_CCR (cpu, dual_FCCi_2);
   1874      1.1  christos   restore_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
   1875      1.1  christos   restore_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
   1876      1.1  christos 
   1877      1.1  christos   /* The latency of FCCi_2 will be the latency of the other inputs plus 3
   1878      1.1  christos      cycles.  */
   1879      1.1  christos   update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
   1880      1.1  christos   update_CCR_latency (cpu, dual_FCCi_2, ps->post_wait + 3);
   1881      1.1  christos 
   1882      1.1  christos   return cycles;
   1883      1.1  christos }
   1884      1.1  christos 
   1885      1.1  christos int
   1886      1.1  christos frvbf_model_fr500_u_float_convert (SIM_CPU *cpu, const IDESC *idesc,
   1887      1.1  christos 				   int unit_num, int referenced,
   1888      1.1  christos 				   INT in_FRj, INT in_FRintj, INT in_FRdoublej,
   1889      1.1  christos 				   INT out_FRk, INT out_FRintk,
   1890      1.1  christos 				   INT out_FRdoublek)
   1891      1.1  christos {
   1892      1.1  christos   int cycles;
   1893      1.1  christos   FRV_PROFILE_STATE *ps;
   1894      1.1  christos 
   1895      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1896      1.1  christos     return 0;
   1897      1.1  christos 
   1898      1.1  christos   /* The preprocessing can execute right away.  */
   1899      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1900      1.1  christos 
   1901      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1902      1.1  christos      which is not ready yet.  */
   1903      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1904      1.1  christos   ps->post_wait = cycles;
   1905      1.1  christos   adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
   1906      1.1  christos   adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
   1907      1.1  christos   adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
   1908      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1909      1.1  christos   post_wait_for_FR (cpu, in_FRintj);
   1910      1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1911      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1912      1.1  christos   post_wait_for_FR (cpu, out_FRintk);
   1913      1.1  christos   post_wait_for_FRdouble (cpu, out_FRdoublek);
   1914      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1915      1.1  christos     {
   1916      1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1917      1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRintk));
   1918      1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
   1919      1.1  christos     }
   1920      1.1  christos   restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
   1921      1.1  christos   restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
   1922      1.1  christos   restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
   1923      1.1  christos 
   1924      1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1925      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1926      1.1  christos   update_FR_latency (cpu, out_FRintk, ps->post_wait);
   1927      1.1  christos   update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
   1928      1.1  christos 
   1929      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1930      1.1  christos     {
   1931      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
   1932      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRintk), ps->post_wait);
   1933      1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
   1934      1.1  christos     }
   1935      1.1  christos 
   1936      1.1  christos   /* Once initiated, post-processing will take 3 cycles.  */
   1937      1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   1938      1.1  christos   update_FR_ptime (cpu, out_FRintk, 3);
   1939      1.1  christos   update_FRdouble_ptime (cpu, out_FRdoublek, 3);
   1940      1.1  christos 
   1941      1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1942      1.1  christos     {
   1943      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
   1944      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRintk), 3);
   1945      1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
   1946      1.1  christos     }
   1947      1.1  christos 
   1948      1.1  christos   /* Mark this use of the register as a floating point op.  */
   1949      1.1  christos   if (out_FRk >= 0)
   1950      1.1  christos     set_use_is_fpop (cpu, out_FRk);
   1951      1.1  christos   if (out_FRintk >= 0)
   1952      1.1  christos     set_use_is_fpop (cpu, out_FRintk);
   1953      1.1  christos   if (out_FRdoublek >= 0)
   1954      1.1  christos     {
   1955      1.1  christos       set_use_is_fpop (cpu, out_FRdoublek);
   1956      1.1  christos       set_use_is_fpop (cpu, out_FRdoublek + 1);
   1957      1.1  christos     }
   1958      1.1  christos 
   1959      1.1  christos   return cycles;
   1960      1.1  christos }
   1961      1.1  christos 
   1962      1.1  christos int
   1963      1.1  christos frvbf_model_fr500_u_float_dual_convert (SIM_CPU *cpu, const IDESC *idesc,
   1964      1.1  christos 					int unit_num, int referenced,
   1965      1.1  christos 					INT in_FRj, INT in_FRintj,
   1966      1.1  christos 					INT out_FRk, INT out_FRintk)
   1967      1.1  christos {
   1968      1.1  christos   int cycles;
   1969      1.1  christos   INT dual_FRj;
   1970      1.1  christos   INT dual_FRintj;
   1971      1.1  christos   INT dual_FRk;
   1972      1.1  christos   INT dual_FRintk;
   1973      1.1  christos   FRV_PROFILE_STATE *ps;
   1974      1.1  christos 
   1975      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1976      1.1  christos     return 0;
   1977      1.1  christos 
   1978      1.1  christos   /* The preprocessing can execute right away.  */
   1979      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1980      1.1  christos 
   1981      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1982      1.1  christos      which is not ready yet.  */
   1983      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1984      1.1  christos   ps->post_wait = cycles;
   1985      1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   1986      1.1  christos   dual_FRintj = DUAL_REG (in_FRintj);
   1987      1.1  christos   dual_FRk = DUAL_REG (out_FRk);
   1988      1.1  christos   dual_FRintk = DUAL_REG (out_FRintk);
   1989      1.1  christos   adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
   1990      1.1  christos   adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
   1991      1.1  christos   adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
   1992      1.1  christos   adjust_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
   1993      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1994      1.1  christos   post_wait_for_FR (cpu, in_FRintj);
   1995      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1996      1.1  christos   post_wait_for_FR (cpu, out_FRintk);
   1997      1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   1998      1.1  christos   post_wait_for_FR (cpu, dual_FRintj);
   1999      1.1  christos   post_wait_for_FR (cpu, dual_FRk);
   2000      1.1  christos   post_wait_for_FR (cpu, dual_FRintk);
   2001      1.1  christos   restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
   2002      1.1  christos   restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
   2003      1.1  christos   restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
   2004      1.1  christos   restore_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
   2005      1.1  christos 
   2006      1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   2007      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   2008      1.1  christos   update_FR_latency (cpu, out_FRintk, ps->post_wait);
   2009      1.1  christos   update_FR_latency (cpu, dual_FRk, ps->post_wait);
   2010      1.1  christos   update_FR_latency (cpu, dual_FRintk, ps->post_wait);
   2011      1.1  christos 
   2012      1.1  christos   /* Once initiated, post-processing will take 3 cycles.  */
   2013      1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   2014      1.1  christos   update_FR_ptime (cpu, out_FRintk, 3);
   2015      1.1  christos   update_FR_ptime (cpu, dual_FRk, 3);
   2016      1.1  christos   update_FR_ptime (cpu, dual_FRintk, 3);
   2017      1.1  christos 
   2018      1.1  christos   /* Mark this use of the register as a floating point op.  */
   2019      1.1  christos   if (out_FRk >= 0)
   2020      1.1  christos     set_use_is_fpop (cpu, out_FRk);
   2021      1.1  christos   if (out_FRintk >= 0)
   2022      1.1  christos     set_use_is_fpop (cpu, out_FRintk);
   2023      1.1  christos 
   2024      1.1  christos   return cycles;
   2025      1.1  christos }
   2026      1.1  christos 
   2027      1.1  christos int
   2028      1.1  christos frvbf_model_fr500_u_media (SIM_CPU *cpu, const IDESC *idesc,
   2029      1.1  christos 			   int unit_num, int referenced,
   2030      1.1  christos 			   INT in_FRi, INT in_FRj, INT in_ACC40Si, INT in_ACCGi,
   2031      1.1  christos 			   INT out_FRk,
   2032      1.1  christos 			   INT out_ACC40Sk, INT out_ACC40Uk, INT out_ACCGk)
   2033      1.1  christos {
   2034      1.1  christos   int cycles;
   2035      1.1  christos   FRV_PROFILE_STATE *ps;
   2036      1.1  christos   const CGEN_INSN *insn;
   2037      1.1  christos   int is_media_s1;
   2038      1.1  christos   int is_media_s2;
   2039      1.1  christos   int busy_adjustment[] = {0, 0, 0};
   2040      1.1  christos   int *fr;
   2041      1.1  christos   int *acc;
   2042      1.1  christos 
   2043      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2044      1.1  christos     return 0;
   2045      1.1  christos 
   2046      1.1  christos   /* The preprocessing can execute right away.  */
   2047      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2048      1.1  christos 
   2049      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2050      1.1  christos   insn = idesc->idata;
   2051      1.1  christos 
   2052      1.1  christos   /* If the previous use of the registers was a media op,
   2053      1.1  christos      then their latency will be less than previously recorded.
   2054      1.1  christos      See Table 13-13 in the LSI.  */
   2055      1.1  christos   if (in_FRi >= 0)
   2056      1.1  christos     {
   2057      1.1  christos       if (use_is_media (cpu, in_FRi))
   2058      1.1  christos 	{
   2059      1.1  christos 	  busy_adjustment[0] = 2;
   2060      1.1  christos 	  decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
   2061      1.1  christos 	}
   2062      1.1  christos       else
   2063      1.1  christos 	enforce_full_fr_latency (cpu, in_FRi);
   2064      1.1  christos     }
   2065      1.1  christos   if (in_FRj >= 0 && in_FRj != in_FRi)
   2066      1.1  christos     {
   2067      1.1  christos       if (use_is_media (cpu, in_FRj))
   2068      1.1  christos 	{
   2069      1.1  christos 	  busy_adjustment[1] = 2;
   2070      1.1  christos 	  decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
   2071      1.1  christos 	}
   2072      1.1  christos       else
   2073      1.1  christos 	enforce_full_fr_latency (cpu, in_FRj);
   2074      1.1  christos     }
   2075      1.1  christos   if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
   2076      1.1  christos     {
   2077      1.1  christos       if (use_is_media (cpu, out_FRk))
   2078      1.1  christos 	{
   2079      1.1  christos 	  busy_adjustment[2] = 2;
   2080      1.1  christos 	  decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
   2081      1.1  christos 	}
   2082      1.1  christos       else
   2083      1.1  christos 	enforce_full_fr_latency (cpu, out_FRk);
   2084      1.1  christos     }
   2085      1.1  christos 
   2086      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2087      1.1  christos      which is not ready yet.  */
   2088      1.1  christos   ps->post_wait = cycles;
   2089      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2090      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   2091      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   2092      1.1  christos   post_wait_for_ACC (cpu, in_ACC40Si);
   2093      1.1  christos   post_wait_for_ACC (cpu, in_ACCGi);
   2094      1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2095      1.1  christos   post_wait_for_ACC (cpu, out_ACC40Uk);
   2096      1.1  christos   post_wait_for_ACC (cpu, out_ACCGk);
   2097      1.1  christos 
   2098      1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2099      1.1  christos   fr = ps->fr_busy;
   2100      1.1  christos   if (in_FRi >= 0)
   2101      1.1  christos     fr[in_FRi] += busy_adjustment[0];
   2102      1.1  christos   if (in_FRj >= 0)
   2103      1.1  christos     fr[in_FRj] += busy_adjustment[1];
   2104      1.1  christos   if (out_FRk >= 0)
   2105      1.1  christos     fr[out_FRk] += busy_adjustment[2];
   2106      1.1  christos 
   2107      1.1  christos   /* The latency of tht output register will be at least the latency of the
   2108      1.1  christos      other inputs.  Once initiated, post-processing will take 3 cycles.  */
   2109      1.1  christos   if (out_FRk >= 0)
   2110      1.1  christos     {
   2111      1.1  christos       update_FR_latency (cpu, out_FRk, ps->post_wait);
   2112      1.1  christos       update_FR_ptime (cpu, out_FRk, 3);
   2113      1.1  christos       /* Mark this use of the register as a media op.  */
   2114      1.1  christos       set_use_is_media (cpu, out_FRk);
   2115      1.1  christos     }
   2116      1.1  christos   /* The latency of tht output accumulator will be at least the latency of the
   2117      1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2118      1.1  christos   if (out_ACC40Sk >= 0)
   2119      1.1  christos     update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2120      1.1  christos   if (out_ACC40Uk >= 0)
   2121      1.1  christos     update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
   2122      1.1  christos   if (out_ACCGk >= 0)
   2123      1.1  christos     update_ACC_latency (cpu, out_ACCGk, ps->post_wait + 1);
   2124      1.1  christos 
   2125      1.1  christos   return cycles;
   2126      1.1  christos }
   2127      1.1  christos 
   2128      1.1  christos int
   2129      1.1  christos frvbf_model_fr500_u_media_quad_arith (SIM_CPU *cpu, const IDESC *idesc,
   2130      1.1  christos 				       int unit_num, int referenced,
   2131      1.1  christos 				       INT in_FRi, INT in_FRj,
   2132      1.1  christos 				       INT out_FRk)
   2133      1.1  christos {
   2134      1.1  christos   int cycles;
   2135      1.1  christos   INT dual_FRi;
   2136      1.1  christos   INT dual_FRj;
   2137      1.1  christos   INT dual_FRk;
   2138      1.1  christos   FRV_PROFILE_STATE *ps;
   2139      1.1  christos   int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
   2140      1.1  christos   int *fr;
   2141      1.1  christos 
   2142      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2143      1.1  christos     return 0;
   2144      1.1  christos 
   2145      1.1  christos   /* The preprocessing can execute right away.  */
   2146      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2147      1.1  christos 
   2148      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2149      1.1  christos   dual_FRi = DUAL_REG (in_FRi);
   2150      1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   2151      1.1  christos   dual_FRk = DUAL_REG (out_FRk);
   2152      1.1  christos 
   2153      1.1  christos   /* If the previous use of the registers was a media op,
   2154      1.1  christos      then their latency will be less than previously recorded.
   2155      1.1  christos      See Table 13-13 in the LSI.  */
   2156      1.1  christos   if (use_is_media (cpu, in_FRi))
   2157      1.1  christos     {
   2158      1.1  christos       busy_adjustment[0] = 2;
   2159      1.1  christos       decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
   2160      1.1  christos     }
   2161      1.1  christos   else
   2162      1.1  christos     enforce_full_fr_latency (cpu, in_FRi);
   2163      1.1  christos   if (dual_FRi >= 0 && use_is_media (cpu, dual_FRi))
   2164      1.1  christos     {
   2165      1.1  christos       busy_adjustment[1] = 2;
   2166      1.1  christos       decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
   2167      1.1  christos     }
   2168      1.1  christos   else
   2169      1.1  christos     enforce_full_fr_latency (cpu, dual_FRi);
   2170      1.1  christos   if (in_FRj != in_FRi)
   2171      1.1  christos     {
   2172      1.1  christos       if (use_is_media (cpu, in_FRj))
   2173      1.1  christos 	{
   2174      1.1  christos 	  busy_adjustment[2] = 2;
   2175      1.1  christos 	  decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
   2176      1.1  christos 	}
   2177      1.1  christos       else
   2178      1.1  christos 	enforce_full_fr_latency (cpu, in_FRj);
   2179      1.1  christos       if (dual_FRj >= 0 && use_is_media (cpu, dual_FRj))
   2180      1.1  christos 	{
   2181      1.1  christos 	  busy_adjustment[3] = 2;
   2182      1.1  christos 	  decrease_FR_busy (cpu, dual_FRj, busy_adjustment[3]);
   2183      1.1  christos 	}
   2184      1.1  christos       else
   2185      1.1  christos 	enforce_full_fr_latency (cpu, dual_FRj + 1);
   2186      1.1  christos     }
   2187      1.1  christos   if (out_FRk != in_FRi && out_FRk != in_FRj)
   2188      1.1  christos     {
   2189      1.1  christos       if (use_is_media (cpu, out_FRk))
   2190      1.1  christos 	{
   2191      1.1  christos 	  busy_adjustment[4] = 2;
   2192      1.1  christos 	  decrease_FR_busy (cpu, out_FRk, busy_adjustment[4]);
   2193      1.1  christos 	}
   2194      1.1  christos       else
   2195      1.1  christos 	enforce_full_fr_latency (cpu, out_FRk);
   2196      1.1  christos       if (dual_FRk >= 0 && use_is_media (cpu, dual_FRk))
   2197      1.1  christos 	{
   2198      1.1  christos 	  busy_adjustment[5] = 2;
   2199      1.1  christos 	  decrease_FR_busy (cpu, dual_FRk, busy_adjustment[5]);
   2200      1.1  christos 	}
   2201      1.1  christos       else
   2202      1.1  christos 	enforce_full_fr_latency (cpu, dual_FRk);
   2203      1.1  christos     }
   2204      1.1  christos 
   2205      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2206      1.1  christos      which is not ready yet.  */
   2207      1.1  christos   ps->post_wait = cycles;
   2208      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2209      1.1  christos   post_wait_for_FR (cpu, dual_FRi);
   2210      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   2211      1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   2212      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   2213      1.1  christos   post_wait_for_FR (cpu, dual_FRk);
   2214      1.1  christos 
   2215      1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2216      1.1  christos   fr = ps->fr_busy;
   2217      1.1  christos   fr[in_FRi] += busy_adjustment[0];
   2218      1.1  christos   if (dual_FRi >= 0)
   2219      1.1  christos     fr[dual_FRi] += busy_adjustment[1];
   2220      1.1  christos   fr[in_FRj] += busy_adjustment[2];
   2221      1.1  christos   if (dual_FRj >= 0)
   2222      1.1  christos     fr[dual_FRj] += busy_adjustment[3];
   2223      1.1  christos   fr[out_FRk] += busy_adjustment[4];
   2224      1.1  christos   if (dual_FRk >= 0)
   2225      1.1  christos     fr[dual_FRk] += busy_adjustment[5];
   2226      1.1  christos 
   2227      1.1  christos   /* The latency of tht output register will be at least the latency of the
   2228      1.1  christos      other inputs.  */
   2229      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   2230      1.1  christos 
   2231      1.1  christos   /* Once initiated, post-processing will take 3 cycles.  */
   2232      1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   2233      1.1  christos 
   2234      1.1  christos   /* Mark this use of the register as a media op.  */
   2235      1.1  christos   set_use_is_media (cpu, out_FRk);
   2236      1.1  christos   if (dual_FRk >= 0)
   2237      1.1  christos     {
   2238      1.1  christos       update_FR_latency (cpu, dual_FRk, ps->post_wait);
   2239      1.1  christos       update_FR_ptime (cpu, dual_FRk, 3);
   2240      1.1  christos       /* Mark this use of the register as a media op.  */
   2241      1.1  christos       set_use_is_media (cpu, dual_FRk);
   2242      1.1  christos     }
   2243      1.1  christos 
   2244      1.1  christos   return cycles;
   2245      1.1  christos }
   2246      1.1  christos 
   2247      1.1  christos int
   2248      1.1  christos frvbf_model_fr500_u_media_dual_mul (SIM_CPU *cpu, const IDESC *idesc,
   2249      1.1  christos 				    int unit_num, int referenced,
   2250      1.1  christos 				    INT in_FRi, INT in_FRj,
   2251      1.1  christos 				    INT out_ACC40Sk, INT out_ACC40Uk)
   2252      1.1  christos {
   2253      1.1  christos   int cycles;
   2254      1.1  christos   INT dual_ACC40Sk;
   2255      1.1  christos   INT dual_ACC40Uk;
   2256      1.1  christos   FRV_PROFILE_STATE *ps;
   2257      1.1  christos   int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
   2258      1.1  christos   int *fr;
   2259      1.1  christos   int *acc;
   2260      1.1  christos 
   2261      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2262      1.1  christos     return 0;
   2263      1.1  christos 
   2264      1.1  christos   /* The preprocessing can execute right away.  */
   2265      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2266      1.1  christos 
   2267      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2268      1.1  christos   dual_ACC40Sk = DUAL_REG (out_ACC40Sk);
   2269      1.1  christos   dual_ACC40Uk = DUAL_REG (out_ACC40Uk);
   2270      1.1  christos 
   2271      1.1  christos   /* If the previous use of the registers was a media op,
   2272      1.1  christos      then their latency will be less than previously recorded.
   2273      1.1  christos      See Table 13-13 in the LSI.  */
   2274      1.1  christos   if (use_is_media (cpu, in_FRi))
   2275      1.1  christos     {
   2276      1.1  christos       busy_adjustment[0] = 2;
   2277      1.1  christos       decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
   2278      1.1  christos     }
   2279      1.1  christos   else
   2280      1.1  christos     enforce_full_fr_latency (cpu, in_FRi);
   2281      1.1  christos   if (in_FRj != in_FRi)
   2282      1.1  christos     {
   2283      1.1  christos       if (use_is_media (cpu, in_FRj))
   2284      1.1  christos 	{
   2285      1.1  christos 	  busy_adjustment[1] = 2;
   2286      1.1  christos 	  decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
   2287      1.1  christos 	}
   2288      1.1  christos       else
   2289      1.1  christos 	enforce_full_fr_latency (cpu, in_FRj);
   2290      1.1  christos     }
   2291      1.1  christos   if (out_ACC40Sk >= 0)
   2292      1.1  christos     {
   2293      1.1  christos       busy_adjustment[2] = 1;
   2294      1.1  christos       decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
   2295      1.1  christos     }
   2296      1.1  christos   if (dual_ACC40Sk >= 0)
   2297      1.1  christos     {
   2298      1.1  christos       busy_adjustment[3] = 1;
   2299      1.1  christos       decrease_ACC_busy (cpu, dual_ACC40Sk, busy_adjustment[3]);
   2300      1.1  christos     }
   2301      1.1  christos   if (out_ACC40Uk >= 0)
   2302      1.1  christos     {
   2303      1.1  christos       busy_adjustment[4] = 1;
   2304      1.1  christos       decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
   2305      1.1  christos     }
   2306      1.1  christos   if (dual_ACC40Uk >= 0)
   2307      1.1  christos     {
   2308      1.1  christos       busy_adjustment[5] = 1;
   2309      1.1  christos       decrease_ACC_busy (cpu, dual_ACC40Uk, busy_adjustment[5]);
   2310      1.1  christos     }
   2311      1.1  christos 
   2312      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2313      1.1  christos      which is not ready yet.  */
   2314      1.1  christos   ps->post_wait = cycles;
   2315      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2316      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   2317      1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2318      1.1  christos   post_wait_for_ACC (cpu, dual_ACC40Sk);
   2319      1.1  christos   post_wait_for_ACC (cpu, out_ACC40Uk);
   2320      1.1  christos   post_wait_for_ACC (cpu, dual_ACC40Uk);
   2321      1.1  christos 
   2322      1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2323      1.1  christos   fr = ps->fr_busy;
   2324      1.1  christos   acc = ps->acc_busy;
   2325      1.1  christos   fr[in_FRi] += busy_adjustment[0];
   2326      1.1  christos   fr[in_FRj] += busy_adjustment[1];
   2327      1.1  christos   if (out_ACC40Sk >= 0)
   2328      1.1  christos     acc[out_ACC40Sk] += busy_adjustment[2];
   2329      1.1  christos   if (dual_ACC40Sk >= 0)
   2330      1.1  christos     acc[dual_ACC40Sk] += busy_adjustment[3];
   2331      1.1  christos   if (out_ACC40Uk >= 0)
   2332      1.1  christos     acc[out_ACC40Uk] += busy_adjustment[4];
   2333      1.1  christos   if (dual_ACC40Uk >= 0)
   2334      1.1  christos     acc[dual_ACC40Uk] += busy_adjustment[5];
   2335      1.1  christos 
   2336      1.1  christos   /* The latency of tht output register will be at least the latency of the
   2337      1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2338      1.1  christos   if (out_ACC40Sk >= 0)
   2339      1.1  christos     update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2340      1.1  christos   if (dual_ACC40Sk >= 0)
   2341      1.1  christos     update_ACC_latency (cpu, dual_ACC40Sk, ps->post_wait + 1);
   2342      1.1  christos   if (out_ACC40Uk >= 0)
   2343      1.1  christos     update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
   2344      1.1  christos   if (dual_ACC40Uk >= 0)
   2345      1.1  christos     update_ACC_latency (cpu, dual_ACC40Uk, ps->post_wait + 1);
   2346      1.1  christos 
   2347      1.1  christos   return cycles;
   2348      1.1  christos }
   2349      1.1  christos 
   2350      1.1  christos int
   2351      1.1  christos frvbf_model_fr500_u_media_quad_mul (SIM_CPU *cpu, const IDESC *idesc,
   2352      1.1  christos 				    int unit_num, int referenced,
   2353      1.1  christos 				    INT in_FRi, INT in_FRj,
   2354      1.1  christos 				    INT out_ACC40Sk, INT out_ACC40Uk)
   2355      1.1  christos {
   2356      1.1  christos   int cycles;
   2357      1.1  christos   INT FRi_1;
   2358      1.1  christos   INT FRj_1;
   2359      1.1  christos   INT ACC40Sk_1;
   2360      1.1  christos   INT ACC40Sk_2;
   2361      1.1  christos   INT ACC40Sk_3;
   2362      1.1  christos   INT ACC40Uk_1;
   2363      1.1  christos   INT ACC40Uk_2;
   2364      1.1  christos   INT ACC40Uk_3;
   2365      1.1  christos   FRV_PROFILE_STATE *ps;
   2366      1.1  christos   int busy_adjustment[] = {0, 0, 0, 0, 0, 0, 0 ,0};
   2367      1.1  christos   int *fr;
   2368      1.1  christos   int *acc;
   2369      1.1  christos 
   2370      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2371      1.1  christos     return 0;
   2372      1.1  christos 
   2373      1.1  christos   /* The preprocessing can execute right away.  */
   2374      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2375      1.1  christos 
   2376      1.1  christos   FRi_1 = DUAL_REG (in_FRi);
   2377      1.1  christos   FRj_1 = DUAL_REG (in_FRj);
   2378      1.1  christos   ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
   2379      1.1  christos   ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
   2380      1.1  christos   ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
   2381      1.1  christos   ACC40Uk_1 = DUAL_REG (out_ACC40Uk);
   2382      1.1  christos   ACC40Uk_2 = DUAL_REG (ACC40Uk_1);
   2383      1.1  christos   ACC40Uk_3 = DUAL_REG (ACC40Uk_2);
   2384      1.1  christos 
   2385      1.1  christos   /* If the previous use of the registers was a media op,
   2386      1.1  christos      then their latency will be less than previously recorded.
   2387      1.1  christos      See Table 13-13 in the LSI.  */
   2388      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2389      1.1  christos   if (use_is_media (cpu, in_FRi))
   2390      1.1  christos     {
   2391      1.1  christos       busy_adjustment[0] = 2;
   2392      1.1  christos       decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
   2393      1.1  christos     }
   2394      1.1  christos   else
   2395      1.1  christos     enforce_full_fr_latency (cpu, in_FRi);
   2396      1.1  christos   if (FRi_1 >= 0)
   2397      1.1  christos     {
   2398      1.1  christos       if (use_is_media (cpu, FRi_1))
   2399      1.1  christos 	{
   2400      1.1  christos 	  busy_adjustment[1] = 2;
   2401      1.1  christos 	  decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
   2402      1.1  christos 	}
   2403      1.1  christos       else
   2404      1.1  christos 	enforce_full_fr_latency (cpu, FRi_1);
   2405      1.1  christos     }
   2406      1.1  christos   if (in_FRj != in_FRi)
   2407      1.1  christos     {
   2408      1.1  christos       if (use_is_media (cpu, in_FRj))
   2409      1.1  christos 	{
   2410      1.1  christos 	  busy_adjustment[2] = 2;
   2411      1.1  christos 	  decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
   2412      1.1  christos 	}
   2413      1.1  christos       else
   2414      1.1  christos 	enforce_full_fr_latency (cpu, in_FRj);
   2415      1.1  christos       if (FRj_1 >= 0)
   2416      1.1  christos 	{
   2417      1.1  christos 	  if (use_is_media (cpu, FRj_1))
   2418      1.1  christos 	    {
   2419      1.1  christos 	      busy_adjustment[3] = 2;
   2420      1.1  christos 	      decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
   2421      1.1  christos 	    }
   2422      1.1  christos 	  else
   2423      1.1  christos 	    enforce_full_fr_latency (cpu, FRj_1);
   2424      1.1  christos 	}
   2425      1.1  christos     }
   2426      1.1  christos   if (out_ACC40Sk >= 0)
   2427      1.1  christos     {
   2428      1.1  christos       busy_adjustment[4] = 1;
   2429      1.1  christos       decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
   2430      1.1  christos 
   2431      1.1  christos       if (ACC40Sk_1 >= 0)
   2432      1.1  christos 	{
   2433      1.1  christos 	  busy_adjustment[5] = 1;
   2434      1.1  christos 	  decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
   2435      1.1  christos 	}
   2436      1.1  christos       if (ACC40Sk_2 >= 0)
   2437      1.1  christos 	{
   2438      1.1  christos 	  busy_adjustment[6] = 1;
   2439      1.1  christos 	  decrease_ACC_busy (cpu, ACC40Sk_2, busy_adjustment[6]);
   2440      1.1  christos 	}
   2441      1.1  christos       if (ACC40Sk_3 >= 0)
   2442      1.1  christos 	{
   2443      1.1  christos 	  busy_adjustment[7] = 1;
   2444      1.1  christos 	  decrease_ACC_busy (cpu, ACC40Sk_3, busy_adjustment[7]);
   2445      1.1  christos 	}
   2446      1.1  christos     }
   2447      1.1  christos   else if (out_ACC40Uk >= 0)
   2448      1.1  christos     {
   2449      1.1  christos       busy_adjustment[4] = 1;
   2450      1.1  christos       decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
   2451      1.1  christos 
   2452      1.1  christos       if (ACC40Uk_1 >= 0)
   2453      1.1  christos 	{
   2454      1.1  christos 	  busy_adjustment[5] = 1;
   2455      1.1  christos 	  decrease_ACC_busy (cpu, ACC40Uk_1, busy_adjustment[5]);
   2456      1.1  christos 	}
   2457      1.1  christos       if (ACC40Uk_2 >= 0)
   2458      1.1  christos 	{
   2459      1.1  christos 	  busy_adjustment[6] = 1;
   2460      1.1  christos 	  decrease_ACC_busy (cpu, ACC40Uk_2, busy_adjustment[6]);
   2461      1.1  christos 	}
   2462      1.1  christos       if (ACC40Uk_3 >= 0)
   2463      1.1  christos 	{
   2464      1.1  christos 	  busy_adjustment[7] = 1;
   2465      1.1  christos 	  decrease_ACC_busy (cpu, ACC40Uk_3, busy_adjustment[7]);
   2466      1.1  christos 	}
   2467      1.1  christos     }
   2468      1.1  christos 
   2469      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2470      1.1  christos      which is not ready yet.  */
   2471      1.1  christos   ps->post_wait = cycles;
   2472      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2473      1.1  christos   post_wait_for_FR (cpu, FRi_1);
   2474      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   2475      1.1  christos   post_wait_for_FR (cpu, FRj_1);
   2476      1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2477      1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_1);
   2478      1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_2);
   2479      1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_3);
   2480      1.1  christos   post_wait_for_ACC (cpu, out_ACC40Uk);
   2481      1.1  christos   post_wait_for_ACC (cpu, ACC40Uk_1);
   2482      1.1  christos   post_wait_for_ACC (cpu, ACC40Uk_2);
   2483      1.1  christos   post_wait_for_ACC (cpu, ACC40Uk_3);
   2484      1.1  christos 
   2485      1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2486      1.1  christos   fr = ps->fr_busy;
   2487      1.1  christos   acc = ps->acc_busy;
   2488      1.1  christos   fr[in_FRi] += busy_adjustment[0];
   2489      1.1  christos   if (FRi_1 >= 0)
   2490      1.1  christos     fr[FRi_1] += busy_adjustment[1];
   2491      1.1  christos   fr[in_FRj] += busy_adjustment[2];
   2492      1.1  christos   if (FRj_1 > 0)
   2493      1.1  christos     fr[FRj_1] += busy_adjustment[3];
   2494      1.1  christos   if (out_ACC40Sk >= 0)
   2495      1.1  christos     {
   2496      1.1  christos       acc[out_ACC40Sk] += busy_adjustment[4];
   2497      1.1  christos       if (ACC40Sk_1 >= 0)
   2498      1.1  christos 	acc[ACC40Sk_1] += busy_adjustment[5];
   2499      1.1  christos       if (ACC40Sk_2 >= 0)
   2500      1.1  christos 	acc[ACC40Sk_2] += busy_adjustment[6];
   2501      1.1  christos       if (ACC40Sk_3 >= 0)
   2502      1.1  christos 	acc[ACC40Sk_3] += busy_adjustment[7];
   2503      1.1  christos     }
   2504      1.1  christos   else if (out_ACC40Uk >= 0)
   2505      1.1  christos     {
   2506      1.1  christos       acc[out_ACC40Uk] += busy_adjustment[4];
   2507      1.1  christos       if (ACC40Uk_1 >= 0)
   2508      1.1  christos 	acc[ACC40Uk_1] += busy_adjustment[5];
   2509      1.1  christos       if (ACC40Uk_2 >= 0)
   2510      1.1  christos 	acc[ACC40Uk_2] += busy_adjustment[6];
   2511      1.1  christos       if (ACC40Uk_3 >= 0)
   2512      1.1  christos 	acc[ACC40Uk_3] += busy_adjustment[7];
   2513      1.1  christos     }
   2514      1.1  christos 
   2515      1.1  christos   /* The latency of tht output register will be at least the latency of the
   2516      1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2517      1.1  christos   if (out_ACC40Sk >= 0)
   2518      1.1  christos     {
   2519      1.1  christos       update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2520      1.1  christos       if (ACC40Sk_1 >= 0)
   2521      1.1  christos 	update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
   2522      1.1  christos       if (ACC40Sk_2 >= 0)
   2523      1.1  christos 	update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
   2524      1.1  christos       if (ACC40Sk_3 >= 0)
   2525      1.1  christos 	update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
   2526      1.1  christos     }
   2527      1.1  christos   else if (out_ACC40Uk >= 0)
   2528      1.1  christos     {
   2529      1.1  christos       update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
   2530      1.1  christos       if (ACC40Uk_1 >= 0)
   2531      1.1  christos 	update_ACC_latency (cpu, ACC40Uk_1, ps->post_wait + 1);
   2532      1.1  christos       if (ACC40Uk_2 >= 0)
   2533      1.1  christos 	update_ACC_latency (cpu, ACC40Uk_2, ps->post_wait + 1);
   2534      1.1  christos       if (ACC40Uk_3 >= 0)
   2535      1.1  christos 	update_ACC_latency (cpu, ACC40Uk_3, ps->post_wait + 1);
   2536      1.1  christos     }
   2537      1.1  christos 
   2538      1.1  christos   return cycles;
   2539      1.1  christos }
   2540      1.1  christos 
   2541      1.1  christos int
   2542      1.1  christos frvbf_model_fr500_u_media_quad_complex (SIM_CPU *cpu, const IDESC *idesc,
   2543      1.1  christos 					int unit_num, int referenced,
   2544      1.1  christos 					INT in_FRi, INT in_FRj,
   2545      1.1  christos 					INT out_ACC40Sk)
   2546      1.1  christos {
   2547      1.1  christos   int cycles;
   2548      1.1  christos   INT FRi_1;
   2549      1.1  christos   INT FRj_1;
   2550      1.1  christos   INT ACC40Sk_1;
   2551      1.1  christos   FRV_PROFILE_STATE *ps;
   2552      1.1  christos   int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
   2553      1.1  christos   int *fr;
   2554      1.1  christos   int *acc;
   2555      1.1  christos 
   2556      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2557      1.1  christos     return 0;
   2558      1.1  christos 
   2559      1.1  christos   /* The preprocessing can execute right away.  */
   2560      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2561      1.1  christos 
   2562      1.1  christos   FRi_1 = DUAL_REG (in_FRi);
   2563      1.1  christos   FRj_1 = DUAL_REG (in_FRj);
   2564      1.1  christos   ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
   2565      1.1  christos 
   2566      1.1  christos   /* If the previous use of the registers was a media op,
   2567      1.1  christos      then their latency will be less than previously recorded.
   2568      1.1  christos      See Table 13-13 in the LSI.  */
   2569      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2570      1.1  christos   if (use_is_media (cpu, in_FRi))
   2571      1.1  christos     {
   2572      1.1  christos       busy_adjustment[0] = 2;
   2573      1.1  christos       decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
   2574      1.1  christos     }
   2575      1.1  christos   else
   2576      1.1  christos     enforce_full_fr_latency (cpu, in_FRi);
   2577      1.1  christos   if (FRi_1 >= 0)
   2578      1.1  christos     {
   2579      1.1  christos       if (use_is_media (cpu, FRi_1))
   2580      1.1  christos 	{
   2581      1.1  christos 	  busy_adjustment[1] = 2;
   2582      1.1  christos 	  decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
   2583      1.1  christos 	}
   2584      1.1  christos       else
   2585      1.1  christos 	enforce_full_fr_latency (cpu, FRi_1);
   2586      1.1  christos     }
   2587      1.1  christos   if (in_FRj != in_FRi)
   2588      1.1  christos     {
   2589      1.1  christos       if (use_is_media (cpu, in_FRj))
   2590      1.1  christos 	{
   2591      1.1  christos 	  busy_adjustment[2] = 2;
   2592      1.1  christos 	  decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
   2593      1.1  christos 	}
   2594      1.1  christos       else
   2595      1.1  christos 	enforce_full_fr_latency (cpu, in_FRj);
   2596      1.1  christos       if (FRj_1 >= 0)
   2597      1.1  christos 	{
   2598      1.1  christos 	  if (use_is_media (cpu, FRj_1))
   2599      1.1  christos 	    {
   2600      1.1  christos 	      busy_adjustment[3] = 2;
   2601      1.1  christos 	      decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
   2602      1.1  christos 	    }
   2603      1.1  christos 	  else
   2604      1.1  christos 	    enforce_full_fr_latency (cpu, FRj_1);
   2605      1.1  christos 	}
   2606      1.1  christos     }
   2607      1.1  christos   if (out_ACC40Sk >= 0)
   2608      1.1  christos     {
   2609      1.1  christos       busy_adjustment[4] = 1;
   2610      1.1  christos       decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
   2611      1.1  christos 
   2612      1.1  christos       if (ACC40Sk_1 >= 0)
   2613      1.1  christos 	{
   2614      1.1  christos 	  busy_adjustment[5] = 1;
   2615      1.1  christos 	  decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
   2616      1.1  christos 	}
   2617      1.1  christos     }
   2618      1.1  christos 
   2619      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2620      1.1  christos      which is not ready yet.  */
   2621      1.1  christos   ps->post_wait = cycles;
   2622      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2623      1.1  christos   post_wait_for_FR (cpu, FRi_1);
   2624      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   2625      1.1  christos   post_wait_for_FR (cpu, FRj_1);
   2626      1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2627      1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_1);
   2628      1.1  christos 
   2629      1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2630      1.1  christos   fr = ps->fr_busy;
   2631      1.1  christos   acc = ps->acc_busy;
   2632      1.1  christos   fr[in_FRi] += busy_adjustment[0];
   2633      1.1  christos   if (FRi_1 >= 0)
   2634      1.1  christos     fr[FRi_1] += busy_adjustment[1];
   2635      1.1  christos   fr[in_FRj] += busy_adjustment[2];
   2636      1.1  christos   if (FRj_1 > 0)
   2637      1.1  christos     fr[FRj_1] += busy_adjustment[3];
   2638      1.1  christos   if (out_ACC40Sk >= 0)
   2639      1.1  christos     {
   2640      1.1  christos       acc[out_ACC40Sk] += busy_adjustment[4];
   2641      1.1  christos       if (ACC40Sk_1 >= 0)
   2642      1.1  christos 	acc[ACC40Sk_1] += busy_adjustment[5];
   2643      1.1  christos     }
   2644      1.1  christos 
   2645      1.1  christos   /* The latency of tht output register will be at least the latency of the
   2646      1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2647      1.1  christos   if (out_ACC40Sk >= 0)
   2648      1.1  christos     {
   2649      1.1  christos       update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2650      1.1  christos       if (ACC40Sk_1 >= 0)
   2651      1.1  christos 	update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
   2652      1.1  christos     }
   2653      1.1  christos 
   2654      1.1  christos   return cycles;
   2655      1.1  christos }
   2656      1.1  christos 
   2657      1.1  christos int
   2658      1.1  christos frvbf_model_fr500_u_media_dual_expand (SIM_CPU *cpu, const IDESC *idesc,
   2659      1.1  christos 				       int unit_num, int referenced,
   2660      1.1  christos 				       INT in_FRi,
   2661      1.1  christos 				       INT out_FRk)
   2662      1.1  christos {
   2663      1.1  christos   int cycles;
   2664      1.1  christos   INT dual_FRk;
   2665      1.1  christos   FRV_PROFILE_STATE *ps;
   2666      1.1  christos   int busy_adjustment[] = {0, 0, 0};
   2667      1.1  christos   int *fr;
   2668      1.1  christos 
   2669      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2670      1.1  christos     return 0;
   2671      1.1  christos 
   2672      1.1  christos   /* The preprocessing can execute right away.  */
   2673      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2674      1.1  christos 
   2675      1.1  christos   /* If the previous use of the registers was a media op,
   2676      1.1  christos      then their latency will be less than previously recorded.
   2677      1.1  christos      See Table 13-13 in the LSI.  */
   2678      1.1  christos   dual_FRk = DUAL_REG (out_FRk);
   2679      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2680      1.1  christos   if (use_is_media (cpu, in_FRi))
   2681      1.1  christos     {
   2682      1.1  christos       busy_adjustment[0] = 2;
   2683      1.1  christos       decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
   2684      1.1  christos     }
   2685      1.1  christos   else
   2686      1.1  christos     enforce_full_fr_latency (cpu, in_FRi);
   2687      1.1  christos   if (out_FRk != in_FRi)
   2688      1.1  christos     {
   2689      1.1  christos       if (use_is_media (cpu, out_FRk))
   2690      1.1  christos 	{
   2691      1.1  christos 	  busy_adjustment[1] = 2;
   2692      1.1  christos 	  decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
   2693      1.1  christos 	}
   2694      1.1  christos       else
   2695      1.1  christos 	enforce_full_fr_latency (cpu, out_FRk);
   2696      1.1  christos     }
   2697      1.1  christos   if (dual_FRk >= 0 && dual_FRk != in_FRi)
   2698      1.1  christos     {
   2699      1.1  christos       if (use_is_media (cpu, dual_FRk))
   2700      1.1  christos 	{
   2701      1.1  christos 	  busy_adjustment[2] = 2;
   2702      1.1  christos 	  decrease_FR_busy (cpu, dual_FRk, busy_adjustment[2]);
   2703      1.1  christos 	}
   2704      1.1  christos       else
   2705      1.1  christos 	enforce_full_fr_latency (cpu, dual_FRk);
   2706      1.1  christos     }
   2707      1.1  christos 
   2708      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2709      1.1  christos      which is not ready yet.  */
   2710      1.1  christos   ps->post_wait = cycles;
   2711      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2712      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   2713      1.1  christos   post_wait_for_FR (cpu, dual_FRk);
   2714      1.1  christos 
   2715      1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2716      1.1  christos   fr = ps->fr_busy;
   2717      1.1  christos   fr[in_FRi] += busy_adjustment[0];
   2718      1.1  christos   fr[out_FRk] += busy_adjustment[1];
   2719      1.1  christos   if (dual_FRk >= 0)
   2720      1.1  christos     fr[dual_FRk] += busy_adjustment[2];
   2721      1.1  christos 
   2722      1.1  christos   /* The latency of the output register will be at least the latency of the
   2723      1.1  christos      other inputs.  Once initiated, post-processing will take 3 cycles.  */
   2724      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   2725      1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   2726      1.1  christos 
   2727      1.1  christos   /* Mark this use of the register as a media op.  */
   2728      1.1  christos   set_use_is_media (cpu, out_FRk);
   2729      1.1  christos   if (dual_FRk >= 0)
   2730      1.1  christos     {
   2731      1.1  christos       update_FR_latency (cpu, dual_FRk, ps->post_wait);
   2732      1.1  christos       update_FR_ptime (cpu, dual_FRk, 3);
   2733      1.1  christos 
   2734      1.1  christos       /* Mark this use of the register as a media op.  */
   2735      1.1  christos       set_use_is_media (cpu, dual_FRk);
   2736      1.1  christos     }
   2737      1.1  christos 
   2738      1.1  christos   return cycles;
   2739      1.1  christos }
   2740      1.1  christos 
   2741      1.1  christos int
   2742      1.1  christos frvbf_model_fr500_u_media_dual_unpack (SIM_CPU *cpu, const IDESC *idesc,
   2743      1.1  christos 				       int unit_num, int referenced,
   2744      1.1  christos 				       INT in_FRi,
   2745      1.1  christos 				       INT out_FRk)
   2746      1.1  christos {
   2747      1.1  christos   int cycles;
   2748      1.1  christos   INT FRi_1;
   2749      1.1  christos   INT FRk_1;
   2750      1.1  christos   INT FRk_2;
   2751      1.1  christos   INT FRk_3;
   2752      1.1  christos   FRV_PROFILE_STATE *ps;
   2753      1.1  christos   int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
   2754      1.1  christos   int *fr;
   2755      1.1  christos 
   2756      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2757      1.1  christos     return 0;
   2758      1.1  christos 
   2759      1.1  christos   /* The preprocessing can execute right away.  */
   2760      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2761      1.1  christos 
   2762      1.1  christos   FRi_1 = DUAL_REG (in_FRi);
   2763      1.1  christos   FRk_1 = DUAL_REG (out_FRk);
   2764      1.1  christos   FRk_2 = DUAL_REG (FRk_1);
   2765      1.1  christos   FRk_3 = DUAL_REG (FRk_2);
   2766      1.1  christos 
   2767      1.1  christos   /* If the previous use of the registers was a media op,
   2768      1.1  christos      then their latency will be less than previously recorded.
   2769      1.1  christos      See Table 13-13 in the LSI.  */
   2770      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2771      1.1  christos   if (use_is_media (cpu, in_FRi))
   2772      1.1  christos     {
   2773      1.1  christos       busy_adjustment[0] = 2;
   2774      1.1  christos       decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
   2775      1.1  christos     }
   2776      1.1  christos   else
   2777      1.1  christos     enforce_full_fr_latency (cpu, in_FRi);
   2778      1.1  christos   if (FRi_1 >= 0 && use_is_media (cpu, FRi_1))
   2779      1.1  christos     {
   2780      1.1  christos       busy_adjustment[1] = 2;
   2781      1.1  christos       decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
   2782      1.1  christos     }
   2783      1.1  christos   else
   2784      1.1  christos     enforce_full_fr_latency (cpu, FRi_1);
   2785      1.1  christos   if (out_FRk != in_FRi)
   2786      1.1  christos     {
   2787      1.1  christos       if (use_is_media (cpu, out_FRk))
   2788      1.1  christos 	{
   2789      1.1  christos 	  busy_adjustment[2] = 2;
   2790      1.1  christos 	  decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
   2791      1.1  christos 	}
   2792      1.1  christos       else
   2793      1.1  christos 	enforce_full_fr_latency (cpu, out_FRk);
   2794      1.1  christos       if (FRk_1 >= 0 && FRk_1 != in_FRi)
   2795      1.1  christos 	{
   2796      1.1  christos 	  if (use_is_media (cpu, FRk_1))
   2797      1.1  christos 	    {
   2798      1.1  christos 	      busy_adjustment[3] = 2;
   2799      1.1  christos 	      decrease_FR_busy (cpu, FRk_1, busy_adjustment[3]);
   2800      1.1  christos 	    }
   2801      1.1  christos 	  else
   2802      1.1  christos 	    enforce_full_fr_latency (cpu, FRk_1);
   2803      1.1  christos 	}
   2804      1.1  christos       if (FRk_2 >= 0 && FRk_2 != in_FRi)
   2805      1.1  christos 	{
   2806      1.1  christos 	  if (use_is_media (cpu, FRk_2))
   2807      1.1  christos 	    {
   2808      1.1  christos 	      busy_adjustment[4] = 2;
   2809      1.1  christos 	      decrease_FR_busy (cpu, FRk_2, busy_adjustment[4]);
   2810      1.1  christos 	    }
   2811      1.1  christos 	  else
   2812      1.1  christos 	    enforce_full_fr_latency (cpu, FRk_2);
   2813      1.1  christos 	}
   2814      1.1  christos       if (FRk_3 >= 0 && FRk_3 != in_FRi)
   2815      1.1  christos 	{
   2816      1.1  christos 	  if (use_is_media (cpu, FRk_3))
   2817      1.1  christos 	    {
   2818      1.1  christos 	      busy_adjustment[5] = 2;
   2819      1.1  christos 	      decrease_FR_busy (cpu, FRk_3, busy_adjustment[5]);
   2820      1.1  christos 	    }
   2821      1.1  christos 	  else
   2822      1.1  christos 	    enforce_full_fr_latency (cpu, FRk_3);
   2823      1.1  christos 	}
   2824      1.1  christos     }
   2825      1.1  christos 
   2826      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2827      1.1  christos      which is not ready yet.  */
   2828      1.1  christos   ps->post_wait = cycles;
   2829      1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2830      1.1  christos   post_wait_for_FR (cpu, FRi_1);
   2831      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   2832      1.1  christos   post_wait_for_FR (cpu, FRk_1);
   2833      1.1  christos   post_wait_for_FR (cpu, FRk_2);
   2834      1.1  christos   post_wait_for_FR (cpu, FRk_3);
   2835      1.1  christos 
   2836      1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2837      1.1  christos   fr = ps->fr_busy;
   2838      1.1  christos   fr[in_FRi] += busy_adjustment[0];
   2839      1.1  christos   if (FRi_1 >= 0)
   2840      1.1  christos     fr[FRi_1] += busy_adjustment[1];
   2841      1.1  christos   fr[out_FRk] += busy_adjustment[2];
   2842      1.1  christos   if (FRk_1 >= 0)
   2843      1.1  christos     fr[FRk_1] += busy_adjustment[3];
   2844      1.1  christos   if (FRk_2 >= 0)
   2845      1.1  christos     fr[FRk_2] += busy_adjustment[4];
   2846      1.1  christos   if (FRk_3 >= 0)
   2847      1.1  christos     fr[FRk_3] += busy_adjustment[5];
   2848      1.1  christos 
   2849      1.1  christos   /* The latency of tht output register will be at least the latency of the
   2850      1.1  christos      other inputs.  Once initiated, post-processing will take 3 cycles.  */
   2851      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   2852      1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   2853      1.1  christos 
   2854      1.1  christos   /* Mark this use of the register as a media op.  */
   2855      1.1  christos   set_use_is_media (cpu, out_FRk);
   2856      1.1  christos   if (FRk_1 >= 0)
   2857      1.1  christos     {
   2858      1.1  christos       update_FR_latency (cpu, FRk_1, ps->post_wait);
   2859      1.1  christos       update_FR_ptime (cpu, FRk_1, 3);
   2860      1.1  christos 
   2861      1.1  christos       /* Mark this use of the register as a media op.  */
   2862      1.1  christos       set_use_is_media (cpu, FRk_1);
   2863      1.1  christos     }
   2864      1.1  christos   if (FRk_2 >= 0)
   2865      1.1  christos     {
   2866      1.1  christos       update_FR_latency (cpu, FRk_2, ps->post_wait);
   2867      1.1  christos       update_FR_ptime (cpu, FRk_2, 3);
   2868      1.1  christos 
   2869      1.1  christos       /* Mark this use of the register as a media op.  */
   2870      1.1  christos       set_use_is_media (cpu, FRk_2);
   2871      1.1  christos     }
   2872      1.1  christos   if (FRk_3 >= 0)
   2873      1.1  christos     {
   2874      1.1  christos       update_FR_latency (cpu, FRk_3, ps->post_wait);
   2875      1.1  christos       update_FR_ptime (cpu, FRk_3, 3);
   2876      1.1  christos 
   2877      1.1  christos       /* Mark this use of the register as a media op.  */
   2878      1.1  christos       set_use_is_media (cpu, FRk_3);
   2879      1.1  christos     }
   2880      1.1  christos 
   2881      1.1  christos   return cycles;
   2882      1.1  christos }
   2883      1.1  christos 
   2884      1.1  christos int
   2885      1.1  christos frvbf_model_fr500_u_media_dual_btoh (SIM_CPU *cpu, const IDESC *idesc,
   2886      1.1  christos 				     int unit_num, int referenced,
   2887      1.1  christos 				     INT in_FRj,
   2888      1.1  christos 				     INT out_FRk)
   2889      1.1  christos {
   2890      1.1  christos   return frvbf_model_fr500_u_media_dual_expand (cpu, idesc, unit_num,
   2891      1.1  christos 						referenced, in_FRj, out_FRk);
   2892      1.1  christos }
   2893      1.1  christos 
   2894      1.1  christos int
   2895      1.1  christos frvbf_model_fr500_u_media_dual_htob (SIM_CPU *cpu, const IDESC *idesc,
   2896      1.1  christos 				     int unit_num, int referenced,
   2897      1.1  christos 				     INT in_FRj,
   2898      1.1  christos 				     INT out_FRk)
   2899      1.1  christos {
   2900      1.1  christos   int cycles;
   2901      1.1  christos   INT dual_FRj;
   2902      1.1  christos   FRV_PROFILE_STATE *ps;
   2903      1.1  christos   int busy_adjustment[] = {0, 0, 0};
   2904      1.1  christos   int *fr;
   2905      1.1  christos 
   2906      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2907      1.1  christos     return 0;
   2908      1.1  christos 
   2909      1.1  christos   /* The preprocessing can execute right away.  */
   2910      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2911      1.1  christos 
   2912      1.1  christos   /* If the previous use of the registers was a media op,
   2913      1.1  christos      then their latency will be less than previously recorded.
   2914      1.1  christos      See Table 13-13 in the LSI.  */
   2915      1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   2916      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2917      1.1  christos   if (use_is_media (cpu, in_FRj))
   2918      1.1  christos     {
   2919      1.1  christos       busy_adjustment[0] = 2;
   2920      1.1  christos       decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
   2921      1.1  christos     }
   2922      1.1  christos   else
   2923      1.1  christos     enforce_full_fr_latency (cpu, in_FRj);
   2924      1.1  christos   if (dual_FRj >= 0)
   2925      1.1  christos     {
   2926      1.1  christos       if (use_is_media (cpu, dual_FRj))
   2927      1.1  christos 	{
   2928      1.1  christos 	  busy_adjustment[1] = 2;
   2929      1.1  christos 	  decrease_FR_busy (cpu, dual_FRj, busy_adjustment[1]);
   2930      1.1  christos 	}
   2931      1.1  christos       else
   2932      1.1  christos 	enforce_full_fr_latency (cpu, dual_FRj);
   2933      1.1  christos     }
   2934      1.1  christos   if (out_FRk != in_FRj)
   2935      1.1  christos     {
   2936      1.1  christos       if (use_is_media (cpu, out_FRk))
   2937      1.1  christos 	{
   2938      1.1  christos 	  busy_adjustment[2] = 2;
   2939      1.1  christos 	  decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
   2940      1.1  christos 	}
   2941      1.1  christos       else
   2942      1.1  christos 	enforce_full_fr_latency (cpu, out_FRk);
   2943      1.1  christos     }
   2944      1.1  christos 
   2945      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2946      1.1  christos      which is not ready yet.  */
   2947      1.1  christos   ps->post_wait = cycles;
   2948      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   2949      1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   2950      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   2951      1.1  christos 
   2952      1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2953      1.1  christos   fr = ps->fr_busy;
   2954      1.1  christos   fr[in_FRj] += busy_adjustment[0];
   2955      1.1  christos   if (dual_FRj >= 0)
   2956      1.1  christos     fr[dual_FRj] += busy_adjustment[1];
   2957      1.1  christos   fr[out_FRk] += busy_adjustment[2];
   2958      1.1  christos 
   2959      1.1  christos   /* The latency of tht output register will be at least the latency of the
   2960      1.1  christos      other inputs.  */
   2961      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   2962      1.1  christos 
   2963      1.1  christos   /* Once initiated, post-processing will take 3 cycles.  */
   2964      1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   2965      1.1  christos 
   2966      1.1  christos   /* Mark this use of the register as a media op.  */
   2967      1.1  christos   set_use_is_media (cpu, out_FRk);
   2968      1.1  christos 
   2969      1.1  christos   return cycles;
   2970      1.1  christos }
   2971      1.1  christos 
   2972      1.1  christos int
   2973      1.1  christos frvbf_model_fr500_u_media_dual_btohe (SIM_CPU *cpu, const IDESC *idesc,
   2974      1.1  christos 				      int unit_num, int referenced,
   2975      1.1  christos 				      INT in_FRj,
   2976      1.1  christos 				      INT out_FRk)
   2977      1.1  christos {
   2978      1.1  christos   int cycles;
   2979      1.1  christos   INT FRk_1;
   2980      1.1  christos   INT FRk_2;
   2981      1.1  christos   INT FRk_3;
   2982      1.1  christos   FRV_PROFILE_STATE *ps;
   2983      1.1  christos   int busy_adjustment[] = {0, 0, 0, 0, 0};
   2984      1.1  christos   int *fr;
   2985      1.1  christos 
   2986      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2987      1.1  christos     return 0;
   2988      1.1  christos 
   2989      1.1  christos   /* The preprocessing can execute right away.  */
   2990      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2991      1.1  christos 
   2992      1.1  christos   FRk_1 = DUAL_REG (out_FRk);
   2993      1.1  christos   FRk_2 = DUAL_REG (FRk_1);
   2994      1.1  christos   FRk_3 = DUAL_REG (FRk_2);
   2995      1.1  christos 
   2996      1.1  christos   /* If the previous use of the registers was a media op,
   2997      1.1  christos      then their latency will be less than previously recorded.
   2998      1.1  christos      See Table 13-13 in the LSI.  */
   2999      1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   3000      1.1  christos   if (use_is_media (cpu, in_FRj))
   3001      1.1  christos     {
   3002      1.1  christos       busy_adjustment[0] = 2;
   3003      1.1  christos       decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
   3004      1.1  christos     }
   3005      1.1  christos   else
   3006      1.1  christos     enforce_full_fr_latency (cpu, in_FRj);
   3007      1.1  christos   if (out_FRk != in_FRj)
   3008      1.1  christos     {
   3009      1.1  christos       if (use_is_media (cpu, out_FRk))
   3010      1.1  christos 	{
   3011      1.1  christos 	  busy_adjustment[1] = 2;
   3012      1.1  christos 	  decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
   3013      1.1  christos 	}
   3014      1.1  christos       else
   3015      1.1  christos 	enforce_full_fr_latency (cpu, out_FRk);
   3016      1.1  christos       if (FRk_1 >= 0 && FRk_1 != in_FRj)
   3017      1.1  christos 	{
   3018      1.1  christos 	  if (use_is_media (cpu, FRk_1))
   3019      1.1  christos 	    {
   3020      1.1  christos 	      busy_adjustment[2] = 2;
   3021      1.1  christos 	      decrease_FR_busy (cpu, FRk_1, busy_adjustment[2]);
   3022      1.1  christos 	    }
   3023      1.1  christos 	  else
   3024      1.1  christos 	    enforce_full_fr_latency (cpu, FRk_1);
   3025      1.1  christos 	}
   3026      1.1  christos       if (FRk_2 >= 0 && FRk_2 != in_FRj)
   3027      1.1  christos 	{
   3028      1.1  christos 	  if (use_is_media (cpu, FRk_2))
   3029      1.1  christos 	    {
   3030      1.1  christos 	      busy_adjustment[3] = 2;
   3031      1.1  christos 	      decrease_FR_busy (cpu, FRk_2, busy_adjustment[3]);
   3032      1.1  christos 	    }
   3033      1.1  christos 	  else
   3034      1.1  christos 	    enforce_full_fr_latency (cpu, FRk_2);
   3035      1.1  christos 	}
   3036      1.1  christos       if (FRk_3 >= 0 && FRk_3 != in_FRj)
   3037      1.1  christos 	{
   3038      1.1  christos 	  if (use_is_media (cpu, FRk_3))
   3039      1.1  christos 	    {
   3040      1.1  christos 	      busy_adjustment[4] = 2;
   3041      1.1  christos 	      decrease_FR_busy (cpu, FRk_3, busy_adjustment[4]);
   3042      1.1  christos 	    }
   3043      1.1  christos 	  else
   3044      1.1  christos 	    enforce_full_fr_latency (cpu, FRk_3);
   3045      1.1  christos 	}
   3046      1.1  christos     }
   3047      1.1  christos 
   3048      1.1  christos   /* The post processing must wait if there is a dependency on a FR
   3049      1.1  christos      which is not ready yet.  */
   3050      1.1  christos   ps->post_wait = cycles;
   3051      1.1  christos   post_wait_for_FR (cpu, in_FRj);
   3052      1.1  christos   post_wait_for_FR (cpu, out_FRk);
   3053      1.1  christos   post_wait_for_FR (cpu, FRk_1);
   3054      1.1  christos   post_wait_for_FR (cpu, FRk_2);
   3055      1.1  christos   post_wait_for_FR (cpu, FRk_3);
   3056      1.1  christos 
   3057      1.1  christos   /* Restore the busy cycles of the registers we used.  */
   3058      1.1  christos   fr = ps->fr_busy;
   3059      1.1  christos   fr[in_FRj] += busy_adjustment[0];
   3060      1.1  christos   fr[out_FRk] += busy_adjustment[1];
   3061      1.1  christos   if (FRk_1 >= 0)
   3062      1.1  christos     fr[FRk_1] += busy_adjustment[2];
   3063      1.1  christos   if (FRk_2 >= 0)
   3064      1.1  christos     fr[FRk_2] += busy_adjustment[3];
   3065      1.1  christos   if (FRk_3 >= 0)
   3066      1.1  christos     fr[FRk_3] += busy_adjustment[4];
   3067      1.1  christos 
   3068      1.1  christos   /* The latency of tht output register will be at least the latency of the
   3069      1.1  christos      other inputs.  Once initiated, post-processing will take 3 cycles.  */
   3070      1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   3071      1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   3072      1.1  christos 
   3073      1.1  christos   /* Mark this use of the register as a media op.  */
   3074      1.1  christos   set_use_is_media (cpu, out_FRk);
   3075      1.1  christos   if (FRk_1 >= 0)
   3076      1.1  christos     {
   3077      1.1  christos       update_FR_latency (cpu, FRk_1, ps->post_wait);
   3078      1.1  christos       update_FR_ptime (cpu, FRk_1, 3);
   3079      1.1  christos 
   3080      1.1  christos       /* Mark this use of the register as a media op.  */
   3081      1.1  christos       set_use_is_media (cpu, FRk_1);
   3082      1.1  christos     }
   3083      1.1  christos   if (FRk_2 >= 0)
   3084      1.1  christos     {
   3085      1.1  christos       update_FR_latency (cpu, FRk_2, ps->post_wait);
   3086      1.1  christos       update_FR_ptime (cpu, FRk_2, 3);
   3087      1.1  christos 
   3088      1.1  christos       /* Mark this use of the register as a media op.  */
   3089      1.1  christos       set_use_is_media (cpu, FRk_2);
   3090      1.1  christos     }
   3091      1.1  christos   if (FRk_3 >= 0)
   3092      1.1  christos     {
   3093      1.1  christos       update_FR_latency (cpu, FRk_3, ps->post_wait);
   3094      1.1  christos       update_FR_ptime (cpu, FRk_3, 3);
   3095      1.1  christos 
   3096      1.1  christos       /* Mark this use of the register as a media op.  */
   3097      1.1  christos       set_use_is_media (cpu, FRk_3);
   3098      1.1  christos     }
   3099      1.1  christos 
   3100      1.1  christos   return cycles;
   3101      1.1  christos }
   3102      1.1  christos 
   3103      1.1  christos int
   3104      1.1  christos frvbf_model_fr500_u_barrier (SIM_CPU *cpu, const IDESC *idesc,
   3105      1.1  christos 			     int unit_num, int referenced)
   3106      1.1  christos {
   3107      1.1  christos   int cycles;
   3108      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   3109      1.1  christos     {
   3110      1.1  christos       int i;
   3111      1.1  christos       /* Wait for ALL resources.  */
   3112      1.1  christos       for (i = 0; i < 64; ++i)
   3113      1.1  christos 	{
   3114      1.1  christos 	  enforce_full_fr_latency (cpu, i);
   3115      1.1  christos 	  vliw_wait_for_GR (cpu, i);
   3116      1.1  christos 	  vliw_wait_for_FR (cpu, i);
   3117      1.1  christos 	  vliw_wait_for_ACC (cpu, i);
   3118      1.1  christos 	}
   3119      1.1  christos       for (i = 0; i < 8; ++i)
   3120      1.1  christos 	vliw_wait_for_CCR (cpu, i);
   3121      1.1  christos       for (i = 0; i < 2; ++i)
   3122      1.1  christos 	{
   3123      1.1  christos 	  vliw_wait_for_idiv_resource (cpu, i);
   3124      1.1  christos 	  vliw_wait_for_fdiv_resource (cpu, i);
   3125      1.1  christos 	  vliw_wait_for_fsqrt_resource (cpu, i);
   3126      1.1  christos 	}
   3127      1.1  christos       handle_resource_wait (cpu);
   3128      1.1  christos       for (i = 0; i < 64; ++i)
   3129      1.1  christos 	{
   3130      1.1  christos 	  load_wait_for_GR (cpu, i);
   3131      1.1  christos 	  load_wait_for_FR (cpu, i);
   3132      1.1  christos 	}
   3133      1.1  christos       trace_vliw_wait_cycles (cpu);
   3134      1.1  christos       return 0;
   3135      1.1  christos     }
   3136      1.1  christos 
   3137      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   3138      1.1  christos   return cycles;
   3139      1.1  christos }
   3140      1.1  christos 
   3141      1.1  christos int
   3142      1.1  christos frvbf_model_fr500_u_membar (SIM_CPU *cpu, const IDESC *idesc,
   3143      1.1  christos 			    int unit_num, int referenced)
   3144      1.1  christos {
   3145      1.1  christos   int cycles;
   3146      1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   3147      1.1  christos     {
   3148      1.1  christos       int i;
   3149      1.1  christos       /* Wait for ALL resources, except GR and ICC.  */
   3150      1.1  christos       for (i = 0; i < 64; ++i)
   3151      1.1  christos 	{
   3152      1.1  christos 	  enforce_full_fr_latency (cpu, i);
   3153      1.1  christos 	  vliw_wait_for_FR (cpu, i);
   3154      1.1  christos 	  vliw_wait_for_ACC (cpu, i);
   3155      1.1  christos 	}
   3156      1.1  christos       for (i = 0; i < 4; ++i)
   3157      1.1  christos 	vliw_wait_for_CCR (cpu, i);
   3158      1.1  christos       for (i = 0; i < 2; ++i)
   3159      1.1  christos 	{
   3160      1.1  christos 	  vliw_wait_for_idiv_resource (cpu, i);
   3161      1.1  christos 	  vliw_wait_for_fdiv_resource (cpu, i);
   3162      1.1  christos 	  vliw_wait_for_fsqrt_resource (cpu, i);
   3163      1.1  christos 	}
   3164      1.1  christos       handle_resource_wait (cpu);
   3165      1.1  christos       for (i = 0; i < 64; ++i)
   3166      1.1  christos 	{
   3167      1.1  christos 	  load_wait_for_FR (cpu, i);
   3168      1.1  christos 	}
   3169      1.1  christos       trace_vliw_wait_cycles (cpu);
   3170      1.1  christos       return 0;
   3171      1.1  christos     }
   3172      1.1  christos 
   3173      1.1  christos   cycles = idesc->timing->units[unit_num].done;
   3174      1.1  christos   return cycles;
   3175      1.1  christos }
   3176      1.1  christos 
   3177      1.1  christos /* The frv machine is a fictional implementation of the fr500 which implements
   3178      1.1  christos    all frv architectural features.  */
   3179      1.1  christos int
   3180      1.1  christos frvbf_model_frv_u_exec (SIM_CPU *cpu, const IDESC *idesc,
   3181      1.1  christos 			    int unit_num, int referenced)
   3182      1.1  christos {
   3183      1.1  christos   return idesc->timing->units[unit_num].done;
   3184      1.1  christos }
   3185      1.1  christos 
   3186      1.1  christos /* The simple machine is a fictional implementation of the fr500 which
   3187      1.1  christos    implements limited frv architectural features.  */
   3188      1.1  christos int
   3189      1.1  christos frvbf_model_simple_u_exec (SIM_CPU *cpu, const IDESC *idesc,
   3190      1.1  christos 			    int unit_num, int referenced)
   3191      1.1  christos {
   3192      1.1  christos   return idesc->timing->units[unit_num].done;
   3193      1.1  christos }
   3194      1.1  christos 
   3195      1.1  christos /* The tomcat machine is models a prototype fr500 machine which had a few
   3196      1.1  christos    bugs and restrictions to work around.  */
   3197      1.1  christos int
   3198      1.1  christos frvbf_model_tomcat_u_exec (SIM_CPU *cpu, const IDESC *idesc,
   3199      1.1  christos 			    int unit_num, int referenced)
   3200      1.1  christos {
   3201      1.1  christos   return idesc->timing->units[unit_num].done;
   3202      1.1  christos }
   3203      1.1  christos 
   3204      1.1  christos #endif /* WITH_PROFILE_MODEL_P */
   3205