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