Home | History | Annotate | Line # | Download | only in frv
      1   1.1  christos /* frv simulator fr550 dependent profiling code.
      2   1.1  christos 
      3  1.11  christos    Copyright (C) 2003-2024 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.10  christos along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     20  1.10  christos 
     21  1.10  christos /* This must come before any other includes.  */
     22  1.10  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-fr550.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 fr550_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_FR550_DATA *d = CPU_MODEL_DATA (cpu);
     44   1.1  christos       d->cur_fr_load      = d->prev_fr_load;
     45   1.1  christos       d->cur_fr_complex_1 = d->prev_fr_complex_1;
     46   1.1  christos       d->cur_fr_complex_2 = d->prev_fr_complex_2;
     47   1.1  christos       d->cur_ccr_complex  = d->prev_ccr_complex;
     48   1.1  christos       d->cur_acc_mmac     = d->prev_acc_mmac;
     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 fr550_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_FR550_DATA *d = CPU_MODEL_DATA (cpu);
     62   1.1  christos       d->prev_fr_load      = d->cur_fr_load;
     63   1.1  christos       d->prev_fr_complex_1 = d->cur_fr_complex_1;
     64   1.1  christos       d->prev_fr_complex_2 = d->cur_fr_complex_2;
     65   1.1  christos       d->prev_ccr_complex  = d->cur_ccr_complex;
     66   1.1  christos       d->prev_acc_mmac     = d->cur_acc_mmac;
     67   1.1  christos     }
     68   1.1  christos }
     69   1.1  christos 
     70   1.1  christos static void fr550_reset_fr_flags (SIM_CPU *cpu, INT fr);
     71   1.1  christos static void fr550_reset_ccr_flags (SIM_CPU *cpu, INT ccr);
     72   1.1  christos static void fr550_reset_acc_flags (SIM_CPU *cpu, INT acc);
     73   1.1  christos 
     74   1.1  christos static void
     75   1.1  christos set_use_is_fr_load (SIM_CPU *cpu, INT fr)
     76   1.1  christos {
     77   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
     78   1.1  christos   fr550_reset_fr_flags (cpu, (fr));
     79   1.1  christos   d->cur_fr_load |= (((DI)1) << (fr));
     80   1.1  christos }
     81   1.1  christos 
     82   1.1  christos static void
     83   1.1  christos set_use_not_fr_load (SIM_CPU *cpu, INT fr)
     84   1.1  christos {
     85   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
     86   1.1  christos   d->cur_fr_load &= ~(((DI)1) << (fr));
     87   1.1  christos }
     88   1.1  christos 
     89   1.1  christos static int
     90   1.1  christos use_is_fr_load (SIM_CPU *cpu, INT fr)
     91   1.1  christos {
     92   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
     93   1.1  christos   return d->prev_fr_load & (((DI)1) << (fr));
     94   1.1  christos }
     95   1.1  christos 
     96   1.1  christos static void
     97   1.1  christos set_use_is_fr_complex_1 (SIM_CPU *cpu, INT fr)
     98   1.1  christos {
     99   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    100   1.1  christos   fr550_reset_fr_flags (cpu, (fr));
    101   1.1  christos   d->cur_fr_complex_1 |= (((DI)1) << (fr));
    102   1.1  christos }
    103   1.1  christos 
    104   1.1  christos static void
    105   1.1  christos set_use_not_fr_complex_1 (SIM_CPU *cpu, INT fr)
    106   1.1  christos {
    107   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    108   1.1  christos   d->cur_fr_complex_1 &= ~(((DI)1) << (fr));
    109   1.1  christos }
    110   1.1  christos 
    111   1.1  christos static int
    112   1.1  christos use_is_fr_complex_1 (SIM_CPU *cpu, INT fr)
    113   1.1  christos {
    114   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    115   1.1  christos   return d->prev_fr_complex_1 & (((DI)1) << (fr));
    116   1.1  christos }
    117   1.1  christos 
    118   1.1  christos static void
    119   1.1  christos set_use_is_fr_complex_2 (SIM_CPU *cpu, INT fr)
    120   1.1  christos {
    121   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    122   1.1  christos   fr550_reset_fr_flags (cpu, (fr));
    123   1.1  christos   d->cur_fr_complex_2 |= (((DI)1) << (fr));
    124   1.1  christos }
    125   1.1  christos 
    126   1.1  christos static void
    127   1.1  christos set_use_not_fr_complex_2 (SIM_CPU *cpu, INT fr)
    128   1.1  christos {
    129   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    130   1.1  christos   d->cur_fr_complex_2 &= ~(((DI)1) << (fr));
    131   1.1  christos }
    132   1.1  christos 
    133   1.1  christos static int
    134   1.1  christos use_is_fr_complex_2 (SIM_CPU *cpu, INT fr)
    135   1.1  christos {
    136   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    137   1.1  christos   return d->prev_fr_complex_2 & (((DI)1) << (fr));
    138   1.1  christos }
    139   1.1  christos 
    140   1.1  christos static void
    141   1.1  christos set_use_is_ccr_complex (SIM_CPU *cpu, INT ccr)
    142   1.1  christos {
    143   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    144   1.1  christos   fr550_reset_ccr_flags (cpu, (ccr));
    145   1.1  christos   d->cur_ccr_complex |= (((SI)1) << (ccr));
    146   1.1  christos }
    147   1.1  christos 
    148   1.1  christos static void
    149   1.1  christos set_use_not_ccr_complex (SIM_CPU *cpu, INT ccr)
    150   1.1  christos {
    151   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    152   1.1  christos   d->cur_ccr_complex &= ~(((SI)1) << (ccr));
    153   1.1  christos }
    154   1.1  christos 
    155  1.10  christos #if 0
    156   1.1  christos static int
    157   1.1  christos use_is_ccr_complex (SIM_CPU *cpu, INT ccr)
    158   1.1  christos {
    159   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    160   1.1  christos   return d->prev_ccr_complex & (((SI)1) << (ccr));
    161   1.1  christos }
    162  1.10  christos #endif
    163   1.1  christos 
    164   1.1  christos static void
    165   1.1  christos set_use_is_acc_mmac (SIM_CPU *cpu, INT acc)
    166   1.1  christos {
    167   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    168   1.1  christos   fr550_reset_acc_flags (cpu, (acc));
    169   1.1  christos   d->cur_acc_mmac |= (((DI)1) << (acc));
    170   1.1  christos }
    171   1.1  christos 
    172   1.1  christos static void
    173   1.1  christos set_use_not_acc_mmac (SIM_CPU *cpu, INT acc)
    174   1.1  christos {
    175   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    176   1.1  christos   d->cur_acc_mmac &= ~(((DI)1) << (acc));
    177   1.1  christos }
    178   1.1  christos 
    179   1.1  christos static int
    180   1.1  christos use_is_acc_mmac (SIM_CPU *cpu, INT acc)
    181   1.1  christos {
    182   1.1  christos   MODEL_FR550_DATA *d = CPU_MODEL_DATA (cpu);
    183   1.1  christos   return d->prev_acc_mmac & (((DI)1) << (acc));
    184   1.1  christos }
    185   1.1  christos 
    186   1.1  christos static void
    187   1.1  christos fr550_reset_fr_flags (SIM_CPU *cpu, INT fr)
    188   1.1  christos {
    189   1.1  christos   set_use_not_fr_load (cpu, fr);
    190   1.1  christos   set_use_not_fr_complex_1 (cpu, fr);
    191   1.1  christos   set_use_not_fr_complex_2 (cpu, fr);
    192   1.1  christos }
    193   1.1  christos 
    194   1.1  christos static void
    195   1.1  christos fr550_reset_ccr_flags (SIM_CPU *cpu, INT ccr)
    196   1.1  christos {
    197   1.1  christos   set_use_not_ccr_complex (cpu, ccr);
    198   1.1  christos }
    199   1.1  christos 
    200   1.1  christos static void
    201   1.1  christos fr550_reset_acc_flags (SIM_CPU *cpu, INT acc)
    202   1.1  christos {
    203   1.1  christos   set_use_not_acc_mmac (cpu, acc);
    204   1.1  christos }
    205   1.1  christos 
    206   1.1  christos /* Detect overlap between two register ranges. Works if one of the registers
    207   1.1  christos    is -1 with width 1 (i.e. undefined), but not both.  */
    208   1.1  christos #define REG_OVERLAP(r1, w1, r2, w2) ( \
    209   1.1  christos   (r1) + (w1) - 1 >= (r2) && (r2) + (w2) - 1 >= (r1) \
    210   1.1  christos )
    211   1.1  christos 
    212   1.1  christos /* Latency of floating point registers may be less than recorded when followed
    213   1.1  christos    by another floating point insn.  */
    214   1.1  christos static void
    215   1.1  christos adjust_float_register_busy (SIM_CPU *cpu,
    216   1.1  christos 			    INT in_FRi, int iwidth,
    217   1.1  christos 			    INT in_FRj, int jwidth,
    218   1.1  christos 			    INT out_FRk, int kwidth)
    219   1.1  christos {
    220   1.1  christos   int i;
    221   1.1  christos   /* The latency of FRk may be less than previously recorded.
    222   1.1  christos      See Table 14-15 in the LSI.  */
    223   1.1  christos   if (in_FRi >= 0)
    224   1.1  christos     {
    225   1.1  christos       for (i = 0; i < iwidth; ++i)
    226   1.1  christos 	{
    227   1.1  christos 	  if (! REG_OVERLAP (in_FRi + i, 1, out_FRk, kwidth))
    228  1.10  christos 	    {
    229  1.10  christos 	      if (use_is_fr_load (cpu, in_FRi + i))
    230  1.10  christos 		decrease_FR_busy (cpu, in_FRi + i, 1);
    231  1.10  christos 	      else
    232  1.10  christos 		enforce_full_fr_latency (cpu, in_FRi + i);
    233  1.10  christos 	    }
    234   1.1  christos 	}
    235   1.1  christos     }
    236   1.1  christos 
    237   1.1  christos   if (in_FRj >= 0)
    238   1.1  christos     {
    239   1.1  christos       for (i = 0; i < jwidth; ++i)
    240   1.1  christos 	{
    241   1.1  christos 	  if (! REG_OVERLAP (in_FRj + i, 1, in_FRi, iwidth)
    242   1.1  christos 	      && ! REG_OVERLAP (in_FRj + i, 1, out_FRk, kwidth))
    243  1.10  christos 	    {
    244  1.10  christos 	      if (use_is_fr_load (cpu, in_FRj + i))
    245  1.10  christos 		decrease_FR_busy (cpu, in_FRj + i, 1);
    246  1.10  christos 	      else
    247  1.10  christos 		enforce_full_fr_latency (cpu, in_FRj + i);
    248  1.10  christos 	    }
    249   1.1  christos 	}
    250   1.1  christos     }
    251   1.1  christos 
    252   1.1  christos   if (out_FRk >= 0)
    253   1.1  christos     {
    254   1.1  christos       for (i = 0; i < kwidth; ++i)
    255   1.1  christos 	{
    256   1.1  christos 	  if (! REG_OVERLAP (out_FRk + i, 1, in_FRi, iwidth)
    257   1.1  christos 	      && ! REG_OVERLAP (out_FRk + i, 1, in_FRj, jwidth))
    258   1.1  christos 	    {
    259   1.1  christos 	      if (use_is_fr_complex_1 (cpu, out_FRk + i))
    260   1.1  christos 		decrease_FR_busy (cpu, out_FRk + i, 1);
    261   1.1  christos 	      else if (use_is_fr_complex_2 (cpu, out_FRk + i))
    262   1.1  christos 		decrease_FR_busy (cpu, out_FRk + i, 2);
    263   1.1  christos 	      else
    264   1.1  christos 		enforce_full_fr_latency (cpu, out_FRk + i);
    265   1.1  christos 	    }
    266   1.1  christos 	}
    267   1.1  christos     }
    268   1.1  christos }
    269   1.1  christos 
    270   1.1  christos static void
    271   1.1  christos restore_float_register_busy (SIM_CPU *cpu,
    272   1.1  christos 			     INT in_FRi, int iwidth,
    273   1.1  christos 			     INT in_FRj, int jwidth,
    274   1.1  christos 			     INT out_FRk, int kwidth)
    275   1.1  christos {
    276   1.1  christos   int i;
    277   1.1  christos   /* The latency of FRk may be less than previously recorded.
    278   1.1  christos      See Table 14-15 in the LSI.  */
    279   1.1  christos   if (in_FRi >= 0)
    280   1.1  christos     {
    281   1.1  christos       for (i = 0; i < iwidth; ++i)
    282   1.1  christos 	{
    283   1.1  christos 	  if (! REG_OVERLAP (in_FRi + i, 1, out_FRk, kwidth))
    284   1.1  christos 	    if (use_is_fr_load (cpu, in_FRi + i))
    285   1.1  christos 	      increase_FR_busy (cpu, in_FRi + i, 1);
    286   1.1  christos 	}
    287   1.1  christos     }
    288   1.1  christos 
    289   1.1  christos   if (in_FRj >= 0)
    290   1.1  christos     {
    291   1.1  christos       for (i = 0; i < jwidth; ++i)
    292   1.1  christos 	{
    293   1.1  christos 	  if (! REG_OVERLAP (in_FRj + i, 1, in_FRi, iwidth)
    294   1.1  christos 	      && ! REG_OVERLAP (in_FRj + i, 1, out_FRk, kwidth))
    295   1.1  christos 	    if (use_is_fr_load (cpu, in_FRj + i))
    296   1.1  christos 	      increase_FR_busy (cpu, in_FRj + i, 1);
    297   1.1  christos 	}
    298   1.1  christos     }
    299   1.1  christos 
    300   1.1  christos   if (out_FRk >= 0)
    301   1.1  christos     {
    302   1.1  christos       for (i = 0; i < kwidth; ++i)
    303   1.1  christos 	{
    304   1.1  christos 	  if (! REG_OVERLAP (out_FRk + i, 1, in_FRi, iwidth)
    305   1.1  christos 	      && ! REG_OVERLAP (out_FRk + i, 1, in_FRj, jwidth))
    306   1.1  christos 	    {
    307   1.1  christos 	      if (use_is_fr_complex_1 (cpu, out_FRk + i))
    308   1.1  christos 		increase_FR_busy (cpu, out_FRk + i, 1);
    309   1.1  christos 	      else if (use_is_fr_complex_2 (cpu, out_FRk + i))
    310   1.1  christos 		increase_FR_busy (cpu, out_FRk + i, 2);
    311   1.1  christos 	    }
    312   1.1  christos 	}
    313   1.1  christos     }
    314   1.1  christos }
    315   1.1  christos 
    316   1.1  christos /* Latency of floating point registers may be less than recorded when used in a
    317   1.1  christos    media insns and followed by another media insn.  */
    318   1.1  christos static void
    319   1.1  christos adjust_float_register_busy_for_media (SIM_CPU *cpu,
    320   1.1  christos 				      INT in_FRi, int iwidth,
    321   1.1  christos 				      INT in_FRj, int jwidth,
    322   1.1  christos 				      INT out_FRk, int kwidth)
    323   1.1  christos {
    324   1.1  christos   int i;
    325   1.1  christos   /* The latency of FRk may be less than previously recorded.
    326   1.1  christos      See Table 14-15 in the LSI.  */
    327   1.1  christos   if (out_FRk >= 0)
    328   1.1  christos     {
    329   1.1  christos       for (i = 0; i < kwidth; ++i)
    330   1.1  christos 	{
    331   1.1  christos 	  if (! REG_OVERLAP (out_FRk + i, 1, in_FRi, iwidth)
    332   1.1  christos 	      && ! REG_OVERLAP (out_FRk + i, 1, in_FRj, jwidth))
    333   1.1  christos 	    {
    334   1.1  christos 	      if (use_is_fr_complex_1 (cpu, out_FRk + i))
    335   1.1  christos 		decrease_FR_busy (cpu, out_FRk + i, 1);
    336   1.1  christos 	      else
    337   1.1  christos 		enforce_full_fr_latency (cpu, out_FRk + i);
    338   1.1  christos 	    }
    339   1.1  christos 	}
    340   1.1  christos     }
    341   1.1  christos }
    342   1.1  christos 
    343   1.1  christos static void
    344   1.1  christos restore_float_register_busy_for_media (SIM_CPU *cpu,
    345   1.1  christos 				       INT in_FRi, int iwidth,
    346   1.1  christos 				       INT in_FRj, int jwidth,
    347   1.1  christos 				       INT out_FRk, int kwidth)
    348   1.1  christos {
    349   1.1  christos   int i;
    350   1.1  christos   if (out_FRk >= 0)
    351   1.1  christos     {
    352   1.1  christos       for (i = 0; i < kwidth; ++i)
    353   1.1  christos 	{
    354   1.1  christos 	  if (! REG_OVERLAP (out_FRk + i, 1, in_FRi, iwidth)
    355   1.1  christos 	      && ! REG_OVERLAP (out_FRk + i, 1, in_FRj, jwidth))
    356   1.1  christos 	    {
    357   1.1  christos 	      if (use_is_fr_complex_1 (cpu, out_FRk + i))
    358   1.1  christos 		increase_FR_busy (cpu, out_FRk + i, 1);
    359   1.1  christos 	    }
    360   1.1  christos 	}
    361   1.1  christos     }
    362   1.1  christos }
    363   1.1  christos 
    364   1.1  christos /* Latency of accumulator registers may be less than recorded when used in a
    365   1.1  christos    media insns and followed by another media insn.  */
    366   1.1  christos static void
    367   1.1  christos adjust_acc_busy_for_mmac (SIM_CPU *cpu,
    368   1.1  christos 			  INT in_ACC, int inwidth,
    369   1.1  christos 			  INT out_ACC, int outwidth)
    370   1.1  christos {
    371   1.1  christos   int i;
    372   1.1  christos   /* The latency of an accumulator may be less than previously recorded.
    373   1.1  christos      See Table 14-15 in the LSI.  */
    374   1.1  christos   if (in_ACC >= 0)
    375   1.1  christos     {
    376   1.1  christos       for (i = 0; i < inwidth; ++i)
    377   1.1  christos 	{
    378   1.1  christos 	  if (use_is_acc_mmac (cpu, in_ACC + i))
    379   1.1  christos 	    decrease_ACC_busy (cpu, in_ACC + i, 1);
    380   1.1  christos 	  else
    381   1.1  christos 	    enforce_full_acc_latency (cpu, in_ACC + i);
    382   1.1  christos 	}
    383   1.1  christos     }
    384   1.1  christos   if (out_ACC >= 0)
    385   1.1  christos     {
    386   1.1  christos       for (i = 0; i < outwidth; ++i)
    387   1.1  christos 	{
    388   1.1  christos 	  if (! REG_OVERLAP (out_ACC + i, 1, in_ACC, inwidth))
    389   1.1  christos 	    {
    390   1.1  christos 	      if (use_is_acc_mmac (cpu, out_ACC + i))
    391   1.1  christos 		decrease_ACC_busy (cpu, out_ACC + i, 1);
    392   1.1  christos 	      else
    393   1.1  christos 		enforce_full_acc_latency (cpu, out_ACC + i);
    394   1.1  christos 	    }
    395   1.1  christos 	}
    396   1.1  christos     }
    397   1.1  christos }
    398   1.1  christos 
    399   1.1  christos static void
    400   1.1  christos restore_acc_busy_for_mmac (SIM_CPU *cpu,
    401   1.1  christos 			   INT in_ACC, int inwidth,
    402   1.1  christos 			   INT out_ACC, int outwidth)
    403   1.1  christos {
    404   1.1  christos   int i;
    405   1.1  christos   if (in_ACC >= 0)
    406   1.1  christos     {
    407   1.1  christos       for (i = 0; i < inwidth; ++i)
    408   1.1  christos 	{
    409   1.1  christos 	  if (use_is_acc_mmac (cpu, in_ACC + i))
    410   1.1  christos 	    increase_ACC_busy (cpu, in_ACC + i, 1);
    411   1.1  christos 	}
    412   1.1  christos     }
    413   1.1  christos   if (out_ACC >= 0)
    414   1.1  christos     {
    415   1.1  christos       for (i = 0; i < outwidth; ++i)
    416   1.1  christos 	{
    417   1.1  christos 	  if (! REG_OVERLAP (out_ACC + i, 1, in_ACC, inwidth))
    418   1.1  christos 	    {
    419   1.1  christos 	      if (use_is_acc_mmac (cpu, out_ACC + i))
    420   1.1  christos 		increase_ACC_busy (cpu, out_ACC + i, 1);
    421   1.1  christos 	    }
    422   1.1  christos 	}
    423   1.1  christos     }
    424   1.1  christos }
    425   1.1  christos 
    426   1.1  christos int
    427   1.1  christos frvbf_model_fr550_u_exec (SIM_CPU *cpu, const IDESC *idesc,
    428   1.1  christos 			  int unit_num, int referenced)
    429   1.1  christos {
    430   1.1  christos   return idesc->timing->units[unit_num].done;
    431   1.1  christos }
    432   1.1  christos 
    433   1.1  christos int
    434   1.1  christos frvbf_model_fr550_u_integer (SIM_CPU *cpu, const IDESC *idesc,
    435   1.1  christos 			     int unit_num, int referenced,
    436   1.1  christos 			     INT in_GRi, INT in_GRj, INT out_GRk,
    437   1.1  christos 			     INT out_ICCi_1)
    438   1.1  christos {
    439   1.1  christos   int cycles;
    440   1.1  christos 
    441   1.1  christos   /* icc0-icc4 are the upper 4 fields of the CCR.  */
    442   1.1  christos   if (out_ICCi_1 >= 0)
    443   1.1  christos     out_ICCi_1 += 4;
    444   1.1  christos 
    445   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    446   1.1  christos     {
    447   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    448   1.1  christos 	 which is not ready yet.  */
    449   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    450   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    451   1.1  christos       vliw_wait_for_GR (cpu, out_GRk);
    452   1.1  christos       vliw_wait_for_CCR (cpu, out_ICCi_1);
    453   1.1  christos       handle_resource_wait (cpu);
    454   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    455   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    456   1.1  christos       load_wait_for_GR (cpu, out_GRk);
    457   1.1  christos       trace_vliw_wait_cycles (cpu);
    458   1.1  christos       return 0;
    459   1.1  christos     }
    460   1.1  christos 
    461   1.1  christos   fr550_reset_ccr_flags (cpu, out_ICCi_1);
    462   1.1  christos 
    463   1.1  christos   /* GRk is available immediately to the next VLIW insn as is ICCi_1.  */
    464   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    465   1.1  christos   return cycles;
    466   1.1  christos }
    467   1.1  christos 
    468   1.1  christos int
    469   1.1  christos frvbf_model_fr550_u_imul (SIM_CPU *cpu, const IDESC *idesc,
    470   1.1  christos 			  int unit_num, int referenced,
    471   1.1  christos 			  INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
    472   1.1  christos {
    473   1.1  christos   int cycles;
    474   1.1  christos   /* icc0-icc4 are the upper 4 fields of the CCR.  */
    475   1.1  christos   if (out_ICCi_1 >= 0)
    476   1.1  christos     out_ICCi_1 += 4;
    477   1.1  christos 
    478   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    479   1.1  christos     {
    480   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    481   1.1  christos 	 which is not ready yet.  */
    482   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    483   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    484   1.1  christos       vliw_wait_for_GRdouble (cpu, out_GRk);
    485   1.1  christos       vliw_wait_for_CCR (cpu, out_ICCi_1);
    486   1.1  christos       handle_resource_wait (cpu);
    487   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    488   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    489   1.1  christos       load_wait_for_GRdouble (cpu, out_GRk);
    490   1.1  christos       trace_vliw_wait_cycles (cpu);
    491   1.1  christos       return 0;
    492   1.1  christos     }
    493   1.1  christos 
    494   1.1  christos   /* GRk has a latency of 1 cycles.  */
    495   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    496   1.1  christos   update_GRdouble_latency (cpu, out_GRk, cycles + 1);
    497   1.1  christos 
    498   1.1  christos   /* ICCi_1 has a latency of 1 cycle.  */
    499   1.1  christos   update_CCR_latency (cpu, out_ICCi_1, cycles + 1);
    500   1.1  christos 
    501   1.1  christos   fr550_reset_ccr_flags (cpu, out_ICCi_1);
    502   1.1  christos 
    503   1.1  christos   return cycles;
    504   1.1  christos }
    505   1.1  christos 
    506   1.1  christos int
    507   1.1  christos frvbf_model_fr550_u_idiv (SIM_CPU *cpu, const IDESC *idesc,
    508   1.1  christos 			  int unit_num, int referenced,
    509   1.1  christos 			  INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
    510   1.1  christos {
    511   1.1  christos   int cycles;
    512   1.1  christos   FRV_VLIW *vliw;
    513   1.1  christos   int slot;
    514   1.1  christos 
    515   1.1  christos   /* icc0-icc4 are the upper 4 fields of the CCR.  */
    516   1.1  christos   if (out_ICCi_1 >= 0)
    517   1.1  christos     out_ICCi_1 += 4;
    518   1.1  christos 
    519   1.1  christos   vliw = CPU_VLIW (cpu);
    520   1.1  christos   slot = vliw->next_slot - 1;
    521   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_I0;
    522   1.1  christos 
    523   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    524   1.1  christos     {
    525   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    526   1.1  christos 	 which is not ready yet.  */
    527   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    528   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    529   1.1  christos       vliw_wait_for_GR (cpu, out_GRk);
    530   1.1  christos       vliw_wait_for_CCR (cpu, out_ICCi_1);
    531   1.1  christos       vliw_wait_for_idiv_resource (cpu, slot);
    532   1.1  christos       handle_resource_wait (cpu);
    533   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    534   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    535   1.1  christos       load_wait_for_GR (cpu, out_GRk);
    536   1.1  christos       trace_vliw_wait_cycles (cpu);
    537   1.1  christos       return 0;
    538   1.1  christos     }
    539   1.1  christos 
    540   1.1  christos   /* GRk has a latency of 18 cycles!  */
    541   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    542   1.1  christos   update_GR_latency (cpu, out_GRk, cycles + 18);
    543   1.1  christos 
    544   1.1  christos   /* ICCi_1 has a latency of 18 cycles.  */
    545   1.1  christos   update_CCR_latency (cpu, out_ICCi_1, cycles + 18);
    546   1.1  christos 
    547   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
    548   1.1  christos     {
    549   1.1  christos       /* GNER has a latency of 18 cycles.  */
    550   1.1  christos       update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 18);
    551   1.1  christos     }
    552   1.1  christos 
    553   1.1  christos   /* the idiv resource has a latency of 18 cycles!  */
    554   1.1  christos   update_idiv_resource_latency (cpu, slot, cycles + 18);
    555   1.1  christos 
    556   1.1  christos   fr550_reset_ccr_flags (cpu, out_ICCi_1);
    557   1.1  christos 
    558   1.1  christos   return cycles;
    559   1.1  christos }
    560   1.1  christos 
    561   1.1  christos int
    562   1.1  christos frvbf_model_fr550_u_branch (SIM_CPU *cpu, const IDESC *idesc,
    563   1.1  christos 			    int unit_num, int referenced,
    564   1.1  christos 			    INT in_GRi, INT in_GRj,
    565   1.1  christos 			    INT in_ICCi_2, INT in_FCCi_2)
    566   1.1  christos {
    567   1.1  christos   int cycles;
    568   1.1  christos   FRV_PROFILE_STATE *ps;
    569   1.1  christos 
    570   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    571   1.1  christos     {
    572   1.1  christos       /* icc0-icc4 are the upper 4 fields of the CCR.  */
    573   1.1  christos       if (in_ICCi_2 >= 0)
    574   1.1  christos 	in_ICCi_2 += 4;
    575   1.1  christos 
    576   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    577   1.1  christos 	 which is not ready yet.  */
    578   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    579   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    580   1.1  christos       vliw_wait_for_CCR (cpu, in_ICCi_2);
    581   1.1  christos       vliw_wait_for_CCR (cpu, in_FCCi_2);
    582   1.1  christos       handle_resource_wait (cpu);
    583   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    584   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    585   1.1  christos       trace_vliw_wait_cycles (cpu);
    586   1.1  christos       return 0;
    587   1.1  christos     }
    588   1.1  christos 
    589   1.1  christos   /* When counting branches taken or not taken, don't consider branches after
    590   1.1  christos      the first taken branch in a vliw insn.  */
    591   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
    592   1.1  christos   if (! ps->vliw_branch_taken)
    593   1.1  christos     {
    594   1.1  christos       /* (1 << 4): The pc is the 5th element in inputs, outputs.
    595   1.1  christos 	 ??? can be cleaned up */
    596   1.1  christos       PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
    597   1.1  christos       int taken = (referenced & (1 << 4)) != 0;
    598   1.1  christos       if (taken)
    599   1.1  christos 	{
    600   1.1  christos 	  ++PROFILE_MODEL_TAKEN_COUNT (p);
    601   1.1  christos 	  ps->vliw_branch_taken = 1;
    602   1.1  christos 	}
    603   1.1  christos       else
    604   1.1  christos 	++PROFILE_MODEL_UNTAKEN_COUNT (p);
    605   1.1  christos     }
    606   1.1  christos 
    607   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    608   1.1  christos   return cycles;
    609   1.1  christos }
    610   1.1  christos 
    611   1.1  christos int
    612   1.1  christos frvbf_model_fr550_u_trap (SIM_CPU *cpu, const IDESC *idesc,
    613   1.1  christos 			  int unit_num, int referenced,
    614   1.1  christos 			  INT in_GRi, INT in_GRj,
    615   1.1  christos 			  INT in_ICCi_2, INT in_FCCi_2)
    616   1.1  christos {
    617   1.1  christos   int cycles;
    618   1.1  christos 
    619   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    620   1.1  christos     {
    621   1.1  christos       /* icc0-icc4 are the upper 4 fields of the CCR.  */
    622   1.1  christos       if (in_ICCi_2 >= 0)
    623   1.1  christos 	in_ICCi_2 += 4;
    624   1.1  christos 
    625   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    626   1.1  christos 	 which is not ready yet.  */
    627   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    628   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    629   1.1  christos       vliw_wait_for_CCR (cpu, in_ICCi_2);
    630   1.1  christos       vliw_wait_for_CCR (cpu, in_FCCi_2);
    631   1.1  christos       handle_resource_wait (cpu);
    632   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    633   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    634   1.1  christos       trace_vliw_wait_cycles (cpu);
    635   1.1  christos       return 0;
    636   1.1  christos     }
    637   1.1  christos 
    638   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    639   1.1  christos   return cycles;
    640   1.1  christos }
    641   1.1  christos 
    642   1.1  christos int
    643   1.1  christos frvbf_model_fr550_u_check (SIM_CPU *cpu, const IDESC *idesc,
    644   1.1  christos 			   int unit_num, int referenced,
    645   1.1  christos 			   INT in_ICCi_3, INT in_FCCi_3)
    646   1.1  christos {
    647   1.1  christos   /* Modelling for this unit is the same as for fr500.  */
    648   1.1  christos   return frvbf_model_fr500_u_check (cpu, idesc, unit_num, referenced,
    649   1.1  christos 				    in_ICCi_3, in_FCCi_3);
    650   1.1  christos }
    651   1.1  christos 
    652   1.1  christos int
    653   1.1  christos frvbf_model_fr550_u_set_hilo (SIM_CPU *cpu, const IDESC *idesc,
    654   1.1  christos 			     int unit_num, int referenced,
    655   1.1  christos 			     INT out_GRkhi, INT out_GRklo)
    656   1.1  christos {
    657   1.1  christos   int cycles;
    658   1.1  christos 
    659   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    660   1.1  christos     {
    661   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a GR
    662   1.1  christos 	 which is not ready yet.  */
    663   1.1  christos       vliw_wait_for_GR (cpu, out_GRkhi);
    664   1.1  christos       vliw_wait_for_GR (cpu, out_GRklo);
    665   1.1  christos       handle_resource_wait (cpu);
    666   1.1  christos       load_wait_for_GR (cpu, out_GRkhi);
    667   1.1  christos       load_wait_for_GR (cpu, out_GRklo);
    668   1.1  christos       trace_vliw_wait_cycles (cpu);
    669   1.1  christos       return 0;
    670   1.1  christos     }
    671   1.1  christos 
    672   1.1  christos   /* GRk is available immediately to the next VLIW insn.  */
    673   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    674   1.1  christos 
    675   1.1  christos   return cycles;
    676   1.1  christos }
    677   1.1  christos 
    678   1.1  christos int
    679   1.1  christos frvbf_model_fr550_u_gr_load (SIM_CPU *cpu, const IDESC *idesc,
    680   1.1  christos 			     int unit_num, int referenced,
    681   1.1  christos 			     INT in_GRi, INT in_GRj,
    682   1.1  christos 			     INT out_GRk, INT out_GRdoublek)
    683   1.1  christos {
    684   1.1  christos   int cycles;
    685   1.1  christos 
    686   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    687   1.1  christos     {
    688   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    689   1.1  christos 	 which is not ready yet.  */
    690   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    691   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    692   1.1  christos       vliw_wait_for_GR (cpu, out_GRk);
    693   1.1  christos       vliw_wait_for_GRdouble (cpu, out_GRdoublek);
    694   1.1  christos       handle_resource_wait (cpu);
    695   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    696   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    697   1.1  christos       load_wait_for_GR (cpu, out_GRk);
    698   1.1  christos       load_wait_for_GRdouble (cpu, out_GRdoublek);
    699   1.1  christos       trace_vliw_wait_cycles (cpu);
    700   1.1  christos       return 0;
    701   1.1  christos     }
    702   1.1  christos 
    703   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    704   1.1  christos 
    705   1.1  christos   /* The latency of GRk for a load will depend on how long it takes to retrieve
    706   1.1  christos      the the data from the cache or memory.  */
    707   1.1  christos   update_GR_latency_for_load (cpu, out_GRk, cycles);
    708   1.1  christos   update_GRdouble_latency_for_load (cpu, out_GRdoublek, cycles);
    709   1.1  christos 
    710   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
    711   1.1  christos     {
    712   1.1  christos       /* GNER has a latency of 2 cycles.  */
    713   1.1  christos       update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 2);
    714   1.1  christos       update_SPR_latency (cpu, GNER_FOR_GR (out_GRdoublek), cycles + 2);
    715   1.1  christos     }
    716   1.1  christos 
    717   1.1  christos   return cycles;
    718   1.1  christos }
    719   1.1  christos 
    720   1.1  christos int
    721   1.1  christos frvbf_model_fr550_u_gr_store (SIM_CPU *cpu, const IDESC *idesc,
    722   1.1  christos 			      int unit_num, int referenced,
    723   1.1  christos 			      INT in_GRi, INT in_GRj,
    724   1.1  christos 			      INT in_GRk, INT in_GRdoublek)
    725   1.1  christos {
    726   1.1  christos   int cycles;
    727   1.1  christos 
    728   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    729   1.1  christos     {
    730   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    731   1.1  christos 	 which is not ready yet.  */
    732   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    733   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    734   1.1  christos       vliw_wait_for_GR (cpu, in_GRk);
    735   1.1  christos       vliw_wait_for_GRdouble (cpu, in_GRdoublek);
    736   1.1  christos       handle_resource_wait (cpu);
    737   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    738   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    739   1.1  christos       load_wait_for_GR (cpu, in_GRk);
    740   1.1  christos       load_wait_for_GRdouble (cpu, in_GRdoublek);
    741   1.1  christos       trace_vliw_wait_cycles (cpu);
    742   1.1  christos       return 0;
    743   1.1  christos     }
    744   1.1  christos 
    745   1.1  christos   /* The target register is available immediately.  */
    746   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    747   1.1  christos 
    748   1.1  christos   return cycles;
    749   1.1  christos }
    750   1.1  christos 
    751   1.1  christos int
    752   1.1  christos frvbf_model_fr550_u_fr_load (SIM_CPU *cpu, const IDESC *idesc,
    753   1.1  christos 			     int unit_num, int referenced,
    754   1.1  christos 			     INT in_GRi, INT in_GRj,
    755   1.1  christos 			     INT out_FRk, INT out_FRdoublek)
    756   1.1  christos {
    757   1.1  christos   int cycles;
    758   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    759   1.1  christos     {
    760   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    761   1.1  christos 	 which is not ready yet.
    762   1.1  christos 	 The latency of the registers may be less than previously recorded,
    763   1.1  christos 	 depending on how they were used previously.
    764   1.1  christos 	 See Table 13-8 in the LSI.  */
    765   1.1  christos       adjust_float_register_busy (cpu, -1, 1, -1, 1, out_FRk, 1);
    766   1.1  christos       adjust_float_register_busy (cpu, -1, 1, -1, 1, out_FRdoublek, 2);
    767   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    768   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    769   1.1  christos       vliw_wait_for_FR (cpu, out_FRk);
    770   1.1  christos       vliw_wait_for_FRdouble (cpu, out_FRdoublek);
    771   1.1  christos       if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
    772   1.1  christos 	{
    773   1.1  christos 	  vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
    774   1.1  christos 	  vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
    775   1.1  christos 	}
    776   1.1  christos       handle_resource_wait (cpu);
    777   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    778   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    779   1.1  christos       load_wait_for_FR (cpu, out_FRk);
    780   1.1  christos       load_wait_for_FRdouble (cpu, out_FRdoublek);
    781   1.1  christos       trace_vliw_wait_cycles (cpu);
    782   1.1  christos       return 0;
    783   1.1  christos     }
    784   1.1  christos 
    785   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    786   1.1  christos 
    787   1.1  christos   /* The latency of FRk for a load will depend on how long it takes to retrieve
    788   1.1  christos      the the data from the cache or memory.  */
    789   1.1  christos   update_FR_latency_for_load (cpu, out_FRk, cycles);
    790   1.1  christos   update_FRdouble_latency_for_load (cpu, out_FRdoublek, cycles);
    791   1.1  christos 
    792   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
    793   1.1  christos     {
    794   1.1  christos       /* FNER has a latency of 3 cycles.  */
    795   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), cycles + 3);
    796   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), cycles + 3);
    797   1.1  christos     }
    798   1.1  christos 
    799   1.1  christos   if (out_FRk >= 0)
    800   1.1  christos     set_use_is_fr_load (cpu, out_FRk);
    801   1.1  christos   if (out_FRdoublek >= 0)
    802   1.1  christos     {
    803   1.1  christos       set_use_is_fr_load (cpu, out_FRdoublek);
    804   1.1  christos       set_use_is_fr_load (cpu, out_FRdoublek + 1);
    805   1.1  christos     }
    806   1.1  christos 
    807   1.1  christos   return cycles;
    808   1.1  christos }
    809   1.1  christos 
    810   1.1  christos int
    811   1.1  christos frvbf_model_fr550_u_fr_store (SIM_CPU *cpu, const IDESC *idesc,
    812   1.1  christos 			      int unit_num, int referenced,
    813   1.1  christos 			      INT in_GRi, INT in_GRj,
    814   1.1  christos 			      INT in_FRk, INT in_FRdoublek)
    815   1.1  christos {
    816   1.1  christos   int cycles;
    817   1.1  christos 
    818   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    819   1.1  christos     {
    820   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    821   1.1  christos 	 which is not ready yet.  */
    822   1.1  christos       adjust_float_register_busy (cpu, in_FRk, 1, -1, 1, -1, 1);
    823   1.1  christos       adjust_float_register_busy (cpu, in_FRdoublek, 2, -1, 1, -1, 1);
    824   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    825   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    826   1.1  christos       vliw_wait_for_FR (cpu, in_FRk);
    827   1.1  christos       vliw_wait_for_FRdouble (cpu, in_FRdoublek);
    828   1.1  christos       handle_resource_wait (cpu);
    829   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    830   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    831   1.1  christos       load_wait_for_FR (cpu, in_FRk);
    832   1.1  christos       load_wait_for_FRdouble (cpu, in_FRdoublek);
    833   1.1  christos       trace_vliw_wait_cycles (cpu);
    834   1.1  christos       return 0;
    835   1.1  christos     }
    836   1.1  christos 
    837   1.1  christos   /* The target register is available immediately.  */
    838   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    839   1.1  christos 
    840   1.1  christos   return cycles;
    841   1.1  christos }
    842   1.1  christos 
    843   1.1  christos int
    844   1.1  christos frvbf_model_fr550_u_ici (SIM_CPU *cpu, const IDESC *idesc,
    845   1.1  christos 			 int unit_num, int referenced,
    846   1.1  christos 			 INT in_GRi, INT in_GRj)
    847   1.1  christos {
    848   1.1  christos   int cycles;
    849   1.1  christos 
    850   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    851   1.1  christos     {
    852   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    853   1.1  christos 	 which is not ready yet.  */
    854   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    855   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    856   1.1  christos       handle_resource_wait (cpu);
    857   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    858   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    859   1.1  christos       trace_vliw_wait_cycles (cpu);
    860   1.1  christos       return 0;
    861   1.1  christos     }
    862   1.1  christos 
    863   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    864   1.1  christos   request_cache_invalidate (cpu, CPU_INSN_CACHE (cpu), cycles);
    865   1.1  christos   return cycles;
    866   1.1  christos }
    867   1.1  christos 
    868   1.1  christos int
    869   1.1  christos frvbf_model_fr550_u_dci (SIM_CPU *cpu, const IDESC *idesc,
    870   1.1  christos 			 int unit_num, int referenced,
    871   1.1  christos 			 INT in_GRi, INT in_GRj)
    872   1.1  christos {
    873   1.1  christos   int cycles;
    874   1.1  christos 
    875   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    876   1.1  christos     {
    877   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    878   1.1  christos 	 which is not ready yet.  */
    879   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    880   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    881   1.1  christos       handle_resource_wait (cpu);
    882   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    883   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    884   1.1  christos       trace_vliw_wait_cycles (cpu);
    885   1.1  christos       return 0;
    886   1.1  christos     }
    887   1.1  christos 
    888   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    889   1.1  christos   request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
    890   1.1  christos   return cycles;
    891   1.1  christos }
    892   1.1  christos 
    893   1.1  christos int
    894   1.1  christos frvbf_model_fr550_u_dcf (SIM_CPU *cpu, const IDESC *idesc,
    895   1.1  christos 			 int unit_num, int referenced,
    896   1.1  christos 			 INT in_GRi, INT in_GRj)
    897   1.1  christos {
    898   1.1  christos   int cycles;
    899   1.1  christos 
    900   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    901   1.1  christos     {
    902   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    903   1.1  christos 	 which is not ready yet.  */
    904   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    905   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    906   1.1  christos       handle_resource_wait (cpu);
    907   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    908   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    909   1.1  christos       trace_vliw_wait_cycles (cpu);
    910   1.1  christos       return 0;
    911   1.1  christos     }
    912   1.1  christos 
    913   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    914   1.1  christos   request_cache_flush (cpu, CPU_DATA_CACHE (cpu), cycles);
    915   1.1  christos   return cycles;
    916   1.1  christos }
    917   1.1  christos 
    918   1.1  christos int
    919   1.1  christos frvbf_model_fr550_u_icpl (SIM_CPU *cpu, const IDESC *idesc,
    920   1.1  christos 			  int unit_num, int referenced,
    921   1.1  christos 			  INT in_GRi, INT in_GRj)
    922   1.1  christos {
    923   1.1  christos   int cycles;
    924   1.1  christos 
    925   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    926   1.1  christos     {
    927   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    928   1.1  christos 	 which is not ready yet.  */
    929   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    930   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    931   1.1  christos       handle_resource_wait (cpu);
    932   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    933   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    934   1.1  christos       trace_vliw_wait_cycles (cpu);
    935   1.1  christos       return 0;
    936   1.1  christos     }
    937   1.1  christos 
    938   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    939   1.1  christos   request_cache_preload (cpu, CPU_INSN_CACHE (cpu), cycles);
    940   1.1  christos   return cycles;
    941   1.1  christos }
    942   1.1  christos 
    943   1.1  christos int
    944   1.1  christos frvbf_model_fr550_u_dcpl (SIM_CPU *cpu, const IDESC *idesc,
    945   1.1  christos 			  int unit_num, int referenced,
    946   1.1  christos 			  INT in_GRi, INT in_GRj)
    947   1.1  christos {
    948   1.1  christos   int cycles;
    949   1.1  christos 
    950   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    951   1.1  christos     {
    952   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    953   1.1  christos 	 which is not ready yet.  */
    954   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    955   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    956   1.1  christos       handle_resource_wait (cpu);
    957   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    958   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    959   1.1  christos       trace_vliw_wait_cycles (cpu);
    960   1.1  christos       return 0;
    961   1.1  christos     }
    962   1.1  christos 
    963   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    964   1.1  christos   request_cache_preload (cpu, CPU_DATA_CACHE (cpu), cycles);
    965   1.1  christos   return cycles;
    966   1.1  christos }
    967   1.1  christos 
    968   1.1  christos int
    969   1.1  christos frvbf_model_fr550_u_icul (SIM_CPU *cpu, const IDESC *idesc,
    970   1.1  christos 			  int unit_num, int referenced,
    971   1.1  christos 			  INT in_GRi, INT in_GRj)
    972   1.1  christos {
    973   1.1  christos   int cycles;
    974   1.1  christos 
    975   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
    976   1.1  christos     {
    977   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
    978   1.1  christos 	 which is not ready yet.  */
    979   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
    980   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
    981   1.1  christos       handle_resource_wait (cpu);
    982   1.1  christos       load_wait_for_GR (cpu, in_GRi);
    983   1.1  christos       load_wait_for_GR (cpu, in_GRj);
    984   1.1  christos       trace_vliw_wait_cycles (cpu);
    985   1.1  christos       return 0;
    986   1.1  christos     }
    987   1.1  christos 
    988   1.1  christos   cycles = idesc->timing->units[unit_num].done;
    989   1.1  christos   request_cache_unlock (cpu, CPU_INSN_CACHE (cpu), cycles);
    990   1.1  christos   return cycles;
    991   1.1  christos }
    992   1.1  christos 
    993   1.1  christos int
    994   1.1  christos frvbf_model_fr550_u_dcul (SIM_CPU *cpu, const IDESC *idesc,
    995   1.1  christos 			  int unit_num, int referenced,
    996   1.1  christos 			  INT in_GRi, INT in_GRj)
    997   1.1  christos {
    998   1.1  christos   int cycles;
    999   1.1  christos 
   1000   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1001   1.1  christos     {
   1002   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1003   1.1  christos 	 which is not ready yet.  */
   1004   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
   1005   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1006   1.1  christos       handle_resource_wait (cpu);
   1007   1.1  christos       load_wait_for_GR (cpu, in_GRi);
   1008   1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1009   1.1  christos       trace_vliw_wait_cycles (cpu);
   1010   1.1  christos       return 0;
   1011   1.1  christos     }
   1012   1.1  christos 
   1013   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1014   1.1  christos   request_cache_unlock (cpu, CPU_DATA_CACHE (cpu), cycles);
   1015   1.1  christos   return cycles;
   1016   1.1  christos }
   1017   1.1  christos 
   1018   1.1  christos int
   1019   1.1  christos frvbf_model_fr550_u_float_arith (SIM_CPU *cpu, const IDESC *idesc,
   1020   1.1  christos 				 int unit_num, int referenced,
   1021   1.1  christos 				 INT in_FRi, INT in_FRj,
   1022   1.1  christos 				 INT in_FRdoublei, INT in_FRdoublej,
   1023   1.1  christos 				 INT out_FRk, INT out_FRdoublek)
   1024   1.1  christos {
   1025   1.1  christos   int cycles;
   1026   1.1  christos   FRV_PROFILE_STATE *ps;
   1027   1.1  christos   FRV_VLIW *vliw;
   1028   1.1  christos   int slot;
   1029   1.1  christos 
   1030   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1031   1.1  christos     return 0;
   1032   1.1  christos 
   1033   1.1  christos   /* The preprocessing can execute right away.  */
   1034   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1035   1.1  christos 
   1036   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1037   1.1  christos      which is not ready yet.  */
   1038   1.1  christos   adjust_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
   1039   1.1  christos   adjust_float_register_busy (cpu, in_FRdoublei, 2, in_FRdoublej, 2, out_FRdoublek, 2);
   1040   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1041   1.1  christos   ps->post_wait = cycles;
   1042   1.1  christos   vliw = CPU_VLIW (cpu);
   1043   1.1  christos   slot = vliw->next_slot - 1;
   1044   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1045   1.1  christos   post_wait_for_float (cpu, slot);
   1046   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1047   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1048   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1049   1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublei);
   1050   1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1051   1.1  christos   post_wait_for_FRdouble (cpu, out_FRdoublek);
   1052   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1053   1.1  christos     {
   1054   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1055   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
   1056   1.1  christos     }
   1057   1.1  christos   restore_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
   1058   1.1  christos   restore_float_register_busy (cpu, in_FRdoublei, 2, in_FRdoublej, 2, out_FRdoublek, 2);
   1059   1.1  christos 
   1060   1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1061   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1062   1.1  christos   update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
   1063   1.1  christos 
   1064   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1065   1.1  christos     {
   1066   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
   1067   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
   1068   1.1  christos     }
   1069   1.1  christos 
   1070   1.1  christos   /* Once initiated, post-processing will take 2 cycles.  */
   1071   1.1  christos   update_FR_ptime (cpu, out_FRk, 2);
   1072   1.1  christos   update_FRdouble_ptime (cpu, out_FRdoublek, 2);
   1073   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1074   1.1  christos     {
   1075   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 2);
   1076   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 2);
   1077   1.1  christos     }
   1078   1.1  christos 
   1079   1.1  christos   /* Mark this use of the register as a floating point op.  */
   1080   1.1  christos   if (out_FRk >= 0)
   1081   1.1  christos     set_use_is_fr_complex_2 (cpu, out_FRk);
   1082   1.1  christos   if (out_FRdoublek >= 0)
   1083   1.1  christos     {
   1084   1.1  christos       set_use_is_fr_complex_2 (cpu, out_FRdoublek);
   1085   1.1  christos       if (out_FRdoublek < 63)
   1086   1.1  christos 	set_use_is_fr_complex_2 (cpu, out_FRdoublek + 1);
   1087   1.1  christos     }
   1088   1.1  christos 
   1089   1.1  christos   /* the media point unit resource has a latency of 4 cycles  */
   1090   1.1  christos   update_media_resource_latency (cpu, slot, cycles + 4);
   1091   1.1  christos 
   1092   1.1  christos   return cycles;
   1093   1.1  christos }
   1094   1.1  christos 
   1095   1.1  christos int
   1096   1.1  christos frvbf_model_fr550_u_float_dual_arith (SIM_CPU *cpu, const IDESC *idesc,
   1097   1.1  christos 				      int unit_num, int referenced,
   1098   1.1  christos 				      INT in_FRi, INT in_FRj,
   1099   1.1  christos 				      INT in_FRdoublei, INT in_FRdoublej,
   1100   1.1  christos 				      INT out_FRk, INT out_FRdoublek)
   1101   1.1  christos {
   1102   1.1  christos   int cycles;
   1103   1.1  christos   INT dual_FRi;
   1104   1.1  christos   INT dual_FRj;
   1105   1.1  christos   INT dual_FRk;
   1106   1.1  christos   INT dual_FRdoublei;
   1107   1.1  christos   INT dual_FRdoublej;
   1108   1.1  christos   INT dual_FRdoublek;
   1109   1.1  christos   FRV_PROFILE_STATE *ps;
   1110   1.1  christos   FRV_VLIW *vliw;
   1111   1.1  christos   int slot;
   1112   1.1  christos 
   1113   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1114   1.1  christos     return 0;
   1115   1.1  christos 
   1116   1.1  christos   /* The preprocessing can execute right away.  */
   1117   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1118   1.1  christos 
   1119   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1120   1.1  christos      which is not ready yet.  */
   1121   1.1  christos   dual_FRi = DUAL_REG (in_FRi);
   1122   1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   1123   1.1  christos   dual_FRk = DUAL_REG (out_FRk);
   1124   1.1  christos   dual_FRdoublei = DUAL_DOUBLE (in_FRdoublei);
   1125   1.1  christos   dual_FRdoublej = DUAL_DOUBLE (in_FRdoublej);
   1126   1.1  christos   dual_FRdoublek = DUAL_DOUBLE (out_FRdoublek);
   1127   1.1  christos 
   1128   1.1  christos   adjust_float_register_busy (cpu, in_FRi, 2, in_FRj, 2, out_FRk, 2);
   1129   1.1  christos   adjust_float_register_busy (cpu, in_FRdoublei, 4, in_FRdoublej, 4, out_FRdoublek, 4);
   1130   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1131   1.1  christos   ps->post_wait = cycles;
   1132   1.1  christos   vliw = CPU_VLIW (cpu);
   1133   1.1  christos   slot = vliw->next_slot - 1;
   1134   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1135   1.1  christos   post_wait_for_float (cpu, slot);
   1136   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1137   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1138   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1139   1.1  christos   post_wait_for_FR (cpu, dual_FRi);
   1140   1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   1141   1.1  christos   post_wait_for_FR (cpu, dual_FRk);
   1142   1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublei);
   1143   1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1144   1.1  christos   post_wait_for_FRdouble (cpu, out_FRdoublek);
   1145   1.1  christos   post_wait_for_FRdouble (cpu, dual_FRdoublei);
   1146   1.1  christos   post_wait_for_FRdouble (cpu, dual_FRdoublej);
   1147   1.1  christos   post_wait_for_FRdouble (cpu, dual_FRdoublek);
   1148   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1149   1.1  christos     {
   1150   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1151   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRk));
   1152   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
   1153   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRdoublek));
   1154   1.1  christos     }
   1155   1.1  christos   restore_float_register_busy (cpu, in_FRi, 2, in_FRj, 2, out_FRk, 2);
   1156   1.1  christos   restore_float_register_busy (cpu, in_FRdoublei, 4, in_FRdoublej, 4, out_FRdoublek, 4);
   1157   1.1  christos 
   1158   1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1159   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1160   1.1  christos   update_FR_latency (cpu, dual_FRk, ps->post_wait);
   1161   1.1  christos   update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
   1162   1.1  christos   update_FRdouble_latency (cpu, dual_FRdoublek, ps->post_wait);
   1163   1.1  christos 
   1164   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1165   1.1  christos     {
   1166   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
   1167   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (dual_FRk), ps->post_wait);
   1168   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
   1169   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (dual_FRdoublek), ps->post_wait);
   1170   1.1  christos     }
   1171   1.1  christos 
   1172   1.1  christos   /* Once initiated, post-processing will take 3 cycles.  */
   1173   1.1  christos   update_FR_ptime (cpu, out_FRk, 3);
   1174   1.1  christos   update_FR_ptime (cpu, dual_FRk, 3);
   1175   1.1  christos   update_FRdouble_ptime (cpu, out_FRdoublek, 3);
   1176   1.1  christos   update_FRdouble_ptime (cpu, dual_FRdoublek, 3);
   1177   1.1  christos 
   1178   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1179   1.1  christos     {
   1180   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
   1181   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRk), 3);
   1182   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
   1183   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRdoublek), 3);
   1184   1.1  christos     }
   1185   1.1  christos 
   1186   1.1  christos   /* Mark this use of the register as a floating point op.  */
   1187   1.1  christos   if (out_FRk >= 0)
   1188   1.1  christos     fr550_reset_fr_flags (cpu, out_FRk);
   1189   1.1  christos   if (dual_FRk >= 0)
   1190   1.1  christos     fr550_reset_fr_flags (cpu, dual_FRk);
   1191   1.1  christos   if (out_FRdoublek >= 0)
   1192   1.1  christos     {
   1193   1.1  christos       fr550_reset_fr_flags (cpu, out_FRdoublek);
   1194   1.1  christos       if (out_FRdoublek < 63)
   1195   1.1  christos 	fr550_reset_fr_flags (cpu, out_FRdoublek + 1);
   1196   1.1  christos     }
   1197   1.1  christos   if (dual_FRdoublek >= 0)
   1198   1.1  christos     {
   1199   1.1  christos       fr550_reset_fr_flags (cpu, dual_FRdoublek);
   1200   1.1  christos       if (dual_FRdoublek < 63)
   1201   1.1  christos 	fr550_reset_fr_flags (cpu, dual_FRdoublek + 1);
   1202   1.1  christos     }
   1203   1.1  christos 
   1204   1.1  christos   /* the media point unit resource has a latency of 5 cycles  */
   1205   1.1  christos   update_media_resource_latency (cpu, slot, cycles + 5);
   1206   1.1  christos 
   1207   1.1  christos   return cycles;
   1208   1.1  christos }
   1209   1.1  christos 
   1210   1.1  christos int
   1211   1.1  christos frvbf_model_fr550_u_float_div (SIM_CPU *cpu, const IDESC *idesc,
   1212   1.1  christos 			       int unit_num, int referenced,
   1213   1.1  christos 			       INT in_FRi, INT in_FRj, INT out_FRk)
   1214   1.1  christos {
   1215   1.1  christos   int cycles;
   1216   1.1  christos   FRV_VLIW *vliw;
   1217   1.1  christos   int slot;
   1218   1.1  christos   FRV_PROFILE_STATE *ps;
   1219   1.1  christos 
   1220   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1221   1.1  christos     return 0;
   1222   1.1  christos 
   1223   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1224   1.1  christos 
   1225   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1226   1.1  christos      which is not ready yet.  */
   1227   1.1  christos   adjust_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
   1228   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1229   1.1  christos   ps->post_wait = cycles;
   1230   1.1  christos   vliw = CPU_VLIW (cpu);
   1231   1.1  christos   slot = vliw->next_slot - 1;
   1232   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1233   1.1  christos   post_wait_for_float (cpu, slot);
   1234   1.1  christos   post_wait_for_fdiv (cpu, slot);
   1235   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1236   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1237   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1238   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1239   1.1  christos     post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1240   1.1  christos   restore_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
   1241   1.1  christos 
   1242   1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1243   1.1  christos   /* Once initiated, post-processing will take 9 cycles.  */
   1244   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1245   1.1  christos   update_FR_ptime (cpu, out_FRk, 9);
   1246   1.1  christos 
   1247   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1248   1.1  christos     {
   1249   1.1  christos       /* FNER has a latency of 9 cycles.  */
   1250   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
   1251   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 9);
   1252   1.1  christos     }
   1253   1.1  christos 
   1254   1.1  christos   /* The latency of the fdiv unit will be at least the latency of the other
   1255   1.1  christos      inputs.  Once initiated, post-processing will take 9 cycles.  */
   1256   1.1  christos   update_fdiv_resource_latency (cpu, slot, ps->post_wait + 9);
   1257   1.1  christos 
   1258   1.1  christos   /* the media point unit resource has a latency of 11 cycles  */
   1259   1.1  christos   update_media_resource_latency (cpu, slot, cycles + 11);
   1260   1.1  christos 
   1261   1.1  christos   fr550_reset_fr_flags (cpu, out_FRk);
   1262   1.1  christos 
   1263   1.1  christos   return cycles;
   1264   1.1  christos }
   1265   1.1  christos 
   1266   1.1  christos int
   1267   1.1  christos frvbf_model_fr550_u_float_sqrt (SIM_CPU *cpu, const IDESC *idesc,
   1268   1.1  christos 				int unit_num, int referenced,
   1269   1.1  christos 				INT in_FRj, INT in_FRdoublej,
   1270   1.1  christos 				INT out_FRk, INT out_FRdoublek)
   1271   1.1  christos {
   1272   1.1  christos   int cycles;
   1273   1.1  christos   FRV_VLIW *vliw;
   1274   1.1  christos   int slot;
   1275   1.1  christos   FRV_PROFILE_STATE *ps;
   1276   1.1  christos 
   1277   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1278   1.1  christos     return 0;
   1279   1.1  christos 
   1280   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1281   1.1  christos 
   1282   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1283   1.1  christos      which is not ready yet.  */
   1284   1.1  christos   adjust_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
   1285   1.1  christos   adjust_float_register_busy (cpu, -1, 1, in_FRdoublej, 2, out_FRdoublek, 2);
   1286   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1287   1.1  christos   ps->post_wait = cycles;
   1288   1.1  christos   vliw = CPU_VLIW (cpu);
   1289   1.1  christos   slot = vliw->next_slot - 1;
   1290   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1291   1.1  christos   post_wait_for_float (cpu, slot);
   1292   1.1  christos   post_wait_for_fsqrt (cpu, slot);
   1293   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1294   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1295   1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1296   1.1  christos   post_wait_for_FRdouble (cpu, out_FRdoublek);
   1297   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1298   1.1  christos     {
   1299   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1300   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
   1301   1.1  christos     }
   1302   1.1  christos   restore_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
   1303   1.1  christos   restore_float_register_busy (cpu, -1, 1, in_FRdoublej, 2, out_FRdoublek, 2);
   1304   1.1  christos 
   1305   1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1306   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1307   1.1  christos   update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
   1308   1.1  christos 
   1309   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1310   1.1  christos     {
   1311   1.1  christos       /* FNER has a latency of 14 cycles.  */
   1312   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
   1313   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
   1314   1.1  christos     }
   1315   1.1  christos 
   1316   1.1  christos   /* Once initiated, post-processing will take 14 cycles.  */
   1317   1.1  christos   update_FR_ptime (cpu, out_FRk, 14);
   1318   1.1  christos   update_FRdouble_ptime (cpu, out_FRdoublek, 14);
   1319   1.1  christos 
   1320   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1321   1.1  christos     {
   1322   1.1  christos       /* FNER has a latency of 14 cycles.  */
   1323   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 14);
   1324   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 14);
   1325   1.1  christos     }
   1326   1.1  christos 
   1327   1.1  christos   /* The latency of the sqrt unit will be the latency of the other
   1328   1.1  christos      inputs plus 14 cycles.  */
   1329   1.1  christos   update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
   1330   1.1  christos 
   1331   1.1  christos   fr550_reset_fr_flags (cpu, out_FRk);
   1332   1.1  christos   if (out_FRdoublek != -1)
   1333   1.1  christos     {
   1334   1.1  christos       fr550_reset_fr_flags (cpu, out_FRdoublek);
   1335   1.1  christos       fr550_reset_fr_flags (cpu, out_FRdoublek + 1);
   1336   1.1  christos     }
   1337   1.1  christos 
   1338   1.1  christos   /* the media point unit resource has a latency of 16 cycles  */
   1339   1.1  christos   update_media_resource_latency (cpu, slot, cycles + 16);
   1340   1.1  christos 
   1341   1.1  christos   return cycles;
   1342   1.1  christos }
   1343   1.1  christos 
   1344   1.1  christos int
   1345   1.1  christos frvbf_model_fr550_u_float_compare (SIM_CPU *cpu, const IDESC *idesc,
   1346   1.1  christos 				   int unit_num, int referenced,
   1347   1.1  christos 				   INT in_FRi, INT in_FRj,
   1348   1.1  christos 				   INT in_FRdoublei, INT in_FRdoublej,
   1349   1.1  christos 				   INT out_FCCi_2)
   1350   1.1  christos {
   1351   1.1  christos   int cycles;
   1352   1.1  christos   FRV_PROFILE_STATE *ps;
   1353   1.1  christos   FRV_VLIW *vliw;
   1354   1.1  christos   int slot;
   1355   1.1  christos 
   1356   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1357   1.1  christos     return 0;
   1358   1.1  christos 
   1359   1.1  christos   /* The preprocessing can execute right away.  */
   1360   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1361   1.1  christos 
   1362   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1363   1.1  christos      which is not ready yet.  */
   1364   1.1  christos   adjust_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, -1, 1);
   1365   1.1  christos   adjust_float_register_busy (cpu, in_FRdoublei, 2, in_FRdoublej, 2, -1, 1);
   1366   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1367   1.1  christos   ps->post_wait = cycles;
   1368   1.1  christos   vliw = CPU_VLIW (cpu);
   1369   1.1  christos   slot = vliw->next_slot - 1;
   1370   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1371   1.1  christos   post_wait_for_float (cpu, slot);
   1372   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1373   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1374   1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublei);
   1375   1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1376   1.1  christos   post_wait_for_CCR (cpu, out_FCCi_2);
   1377   1.1  christos   restore_float_register_busy (cpu, in_FRi, 1, in_FRj, 1, -1, 1);
   1378   1.1  christos   restore_float_register_busy (cpu, in_FRdoublei, 2, in_FRdoublej, 2, -1, 1);
   1379   1.1  christos 
   1380   1.1  christos   /* The latency of FCCi_2 will be the latency of the other inputs plus 2
   1381   1.1  christos      cycles.  */
   1382   1.1  christos   update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 2);
   1383   1.1  christos 
   1384   1.1  christos   /* the media point unit resource has a latency of 4 cycles  */
   1385   1.1  christos   update_media_resource_latency (cpu, slot, cycles + 4);
   1386   1.1  christos 
   1387   1.1  christos   set_use_is_ccr_complex (cpu, out_FCCi_2);
   1388   1.1  christos 
   1389   1.1  christos   return cycles;
   1390   1.1  christos }
   1391   1.1  christos 
   1392   1.1  christos int
   1393   1.1  christos frvbf_model_fr550_u_float_dual_compare (SIM_CPU *cpu, const IDESC *idesc,
   1394   1.1  christos 					int unit_num, int referenced,
   1395   1.1  christos 					INT in_FRi, INT in_FRj,
   1396   1.1  christos 					INT out_FCCi_2)
   1397   1.1  christos {
   1398   1.1  christos   int cycles;
   1399   1.1  christos   INT dual_FRi;
   1400   1.1  christos   INT dual_FRj;
   1401   1.1  christos   INT dual_FCCi_2;
   1402   1.1  christos   FRV_PROFILE_STATE *ps;
   1403   1.1  christos   FRV_VLIW *vliw;
   1404   1.1  christos   int slot;
   1405   1.1  christos 
   1406   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1407   1.1  christos     return 0;
   1408   1.1  christos 
   1409   1.1  christos   /* The preprocessing can execute right away.  */
   1410   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1411   1.1  christos 
   1412   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1413   1.1  christos      which is not ready yet.  */
   1414   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1415   1.1  christos   ps->post_wait = cycles;
   1416   1.1  christos   dual_FRi = DUAL_REG (in_FRi);
   1417   1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   1418   1.1  christos   dual_FCCi_2 = out_FCCi_2 + 1;
   1419   1.1  christos   adjust_float_register_busy (cpu, in_FRi, 2, in_FRj, 2, -1, 1);
   1420   1.1  christos   vliw = CPU_VLIW (cpu);
   1421   1.1  christos   slot = vliw->next_slot - 1;
   1422   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1423   1.1  christos   post_wait_for_float (cpu, slot);
   1424   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1425   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1426   1.1  christos   post_wait_for_FR (cpu, dual_FRi);
   1427   1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   1428   1.1  christos   post_wait_for_CCR (cpu, out_FCCi_2);
   1429   1.1  christos   post_wait_for_CCR (cpu, dual_FCCi_2);
   1430   1.1  christos   restore_float_register_busy (cpu, in_FRi, 2, in_FRj, 2, -1, 1);
   1431   1.1  christos 
   1432   1.1  christos   /* The latency of FCCi_2 will be the latency of the other inputs plus 3
   1433   1.1  christos      cycles.  */
   1434   1.1  christos   update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
   1435   1.1  christos   update_CCR_latency (cpu, dual_FCCi_2, ps->post_wait + 3);
   1436   1.1  christos 
   1437   1.1  christos   set_use_is_ccr_complex (cpu, out_FCCi_2);
   1438   1.1  christos   if (dual_FCCi_2 >= 0)
   1439   1.1  christos     set_use_is_ccr_complex (cpu, dual_FCCi_2);
   1440   1.1  christos 
   1441   1.1  christos   /* the media point unit resource has a latency of 5 cycles  */
   1442   1.1  christos   update_media_resource_latency (cpu, slot, cycles + 5);
   1443   1.1  christos 
   1444   1.1  christos   return cycles;
   1445   1.1  christos }
   1446   1.1  christos 
   1447   1.1  christos int
   1448   1.1  christos frvbf_model_fr550_u_float_convert (SIM_CPU *cpu, const IDESC *idesc,
   1449   1.1  christos 				   int unit_num, int referenced,
   1450   1.1  christos 				   INT in_FRj, INT in_FRintj, INT in_FRdoublej,
   1451   1.1  christos 				   INT out_FRk, INT out_FRintk,
   1452   1.1  christos 				   INT out_FRdoublek)
   1453   1.1  christos {
   1454   1.1  christos   int cycles;
   1455   1.1  christos   FRV_PROFILE_STATE *ps;
   1456   1.1  christos   FRV_VLIW *vliw;
   1457   1.1  christos   int slot;
   1458   1.1  christos 
   1459   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1460   1.1  christos     return 0;
   1461   1.1  christos 
   1462   1.1  christos   /* The preprocessing can execute right away.  */
   1463   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1464   1.1  christos 
   1465   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1466   1.1  christos      which is not ready yet.  */
   1467   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1468   1.1  christos   ps->post_wait = cycles;
   1469   1.1  christos   adjust_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
   1470   1.1  christos   adjust_float_register_busy (cpu, -1, 1, in_FRintj, 1, out_FRintk, 1);
   1471   1.1  christos   adjust_float_register_busy (cpu, -1, 1, in_FRdoublej, 2, out_FRdoublek, 2);
   1472   1.1  christos   vliw = CPU_VLIW (cpu);
   1473   1.1  christos   slot = vliw->next_slot - 1;
   1474   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1475   1.1  christos   post_wait_for_float (cpu, slot);
   1476   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1477   1.1  christos   post_wait_for_FR (cpu, in_FRintj);
   1478   1.1  christos   post_wait_for_FRdouble (cpu, in_FRdoublej);
   1479   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1480   1.1  christos   post_wait_for_FR (cpu, out_FRintk);
   1481   1.1  christos   post_wait_for_FRdouble (cpu, out_FRdoublek);
   1482   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1483   1.1  christos     {
   1484   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
   1485   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRintk));
   1486   1.1  christos       post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
   1487   1.1  christos     }
   1488   1.1  christos   restore_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
   1489   1.1  christos   restore_float_register_busy (cpu, -1, 1, in_FRintj, 1, out_FRintk, 1);
   1490   1.1  christos   restore_float_register_busy (cpu, -1, 1, in_FRdoublej, 2, out_FRdoublek, 2);
   1491   1.1  christos 
   1492   1.1  christos   /* The latency of FRk will be at least the latency of the other inputs.  */
   1493   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1494   1.1  christos   update_FR_latency (cpu, out_FRintk, 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_FRintk), ps->post_wait);
   1501   1.1  christos       update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
   1502   1.1  christos     }
   1503   1.1  christos 
   1504   1.1  christos   /* Once initiated, post-processing will take 2 cycles.  */
   1505   1.1  christos   update_FR_ptime (cpu, out_FRk, 2);
   1506   1.1  christos   update_FR_ptime (cpu, out_FRintk, 2);
   1507   1.1  christos   update_FRdouble_ptime (cpu, out_FRdoublek, 2);
   1508   1.1  christos 
   1509   1.1  christos   if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
   1510   1.1  christos     {
   1511   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 2);
   1512   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRintk), 2);
   1513   1.1  christos       update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 2);
   1514   1.1  christos     }
   1515   1.1  christos 
   1516   1.1  christos   /* Mark this use of the register as a floating point op.  */
   1517   1.1  christos   if (out_FRk >= 0)
   1518   1.1  christos     set_use_is_fr_complex_2 (cpu, out_FRk);
   1519   1.1  christos   if (out_FRintk >= 0)
   1520   1.1  christos     set_use_is_fr_complex_2 (cpu, out_FRintk);
   1521   1.1  christos   if (out_FRdoublek >= 0)
   1522   1.1  christos     {
   1523   1.1  christos       set_use_is_fr_complex_2 (cpu, out_FRdoublek);
   1524   1.1  christos       set_use_is_fr_complex_2 (cpu, out_FRdoublek + 1);
   1525   1.1  christos     }
   1526   1.1  christos 
   1527   1.1  christos   /* the media point unit resource has a latency of 4 cycles  */
   1528   1.1  christos   update_media_resource_latency (cpu, slot, cycles + 4);
   1529   1.1  christos 
   1530   1.1  christos   return cycles;
   1531   1.1  christos }
   1532   1.1  christos 
   1533   1.1  christos int
   1534   1.1  christos frvbf_model_fr550_u_spr2gr (SIM_CPU *cpu, const IDESC *idesc,
   1535   1.1  christos 			    int unit_num, int referenced,
   1536   1.1  christos 			    INT in_spr, INT out_GRj)
   1537   1.1  christos {
   1538   1.1  christos   /* Modelling for this unit is the same as for fr500.  */
   1539   1.1  christos   return frvbf_model_fr500_u_spr2gr (cpu, idesc, unit_num, referenced,
   1540   1.1  christos 				     in_spr, out_GRj);
   1541   1.1  christos }
   1542   1.1  christos 
   1543   1.1  christos int
   1544   1.1  christos frvbf_model_fr550_u_gr2spr (SIM_CPU *cpu, const IDESC *idesc,
   1545   1.1  christos 			    int unit_num, int referenced,
   1546   1.1  christos 			    INT in_GRj, INT out_spr)
   1547   1.1  christos {
   1548   1.1  christos   int cycles;
   1549   1.1  christos 
   1550   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1551   1.1  christos     {
   1552   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1553   1.1  christos 	 which is not ready yet.  */
   1554   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1555   1.1  christos       vliw_wait_for_SPR (cpu, out_spr);
   1556   1.1  christos       handle_resource_wait (cpu);
   1557   1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1558   1.1  christos       trace_vliw_wait_cycles (cpu);
   1559   1.1  christos       return 0;
   1560   1.1  christos     }
   1561   1.1  christos 
   1562   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1563   1.1  christos 
   1564   1.1  christos #if 0
   1565   1.1  christos   /* The latency of spr is ? cycles.  */
   1566   1.1  christos   update_SPR_latency (cpu, out_spr, cycles + ?);
   1567   1.1  christos #endif
   1568   1.1  christos 
   1569   1.1  christos   return cycles;
   1570   1.1  christos }
   1571   1.1  christos 
   1572   1.1  christos int
   1573   1.1  christos frvbf_model_fr550_u_gr2fr (SIM_CPU *cpu, const IDESC *idesc,
   1574   1.1  christos 			   int unit_num, int referenced,
   1575   1.1  christos 			   INT in_GRj, INT out_FRk)
   1576   1.1  christos {
   1577   1.1  christos   int cycles;
   1578   1.1  christos 
   1579   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1580   1.1  christos     {
   1581   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1582   1.1  christos 	 which is not ready yet.
   1583   1.1  christos 	 The latency of the registers may be less than previously recorded,
   1584   1.1  christos 	 depending on how they were used previously.
   1585   1.1  christos 	 See Table 14-15 in the LSI.  */
   1586   1.1  christos       adjust_float_register_busy (cpu, -1, 1, -1, 1, out_FRk, 1);
   1587   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1588   1.1  christos       vliw_wait_for_FR (cpu, out_FRk);
   1589   1.1  christos       handle_resource_wait (cpu);
   1590   1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1591   1.1  christos       load_wait_for_FR (cpu, out_FRk);
   1592   1.1  christos       trace_vliw_wait_cycles (cpu);
   1593   1.1  christos       return 0;
   1594   1.1  christos     }
   1595   1.1  christos 
   1596   1.1  christos   /* The latency of FRk is 1 cycles.  */
   1597   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1598   1.1  christos   update_FR_latency (cpu, out_FRk, cycles + 1);
   1599   1.1  christos 
   1600   1.1  christos   set_use_is_fr_complex_1 (cpu, out_FRk);
   1601   1.1  christos 
   1602   1.1  christos   return cycles;
   1603   1.1  christos }
   1604   1.1  christos 
   1605   1.1  christos int
   1606   1.1  christos frvbf_model_fr550_u_swap (SIM_CPU *cpu, const IDESC *idesc,
   1607   1.1  christos 			  int unit_num, int referenced,
   1608   1.1  christos 			  INT in_GRi, INT in_GRj, INT out_GRk)
   1609   1.1  christos {
   1610   1.1  christos   int cycles;
   1611   1.1  christos 
   1612   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1613   1.1  christos     {
   1614   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1615   1.1  christos 	 which is not ready yet.  */
   1616   1.1  christos       vliw_wait_for_GR (cpu, in_GRi);
   1617   1.1  christos       vliw_wait_for_GR (cpu, in_GRj);
   1618   1.1  christos       vliw_wait_for_GR (cpu, out_GRk);
   1619   1.1  christos       handle_resource_wait (cpu);
   1620   1.1  christos       load_wait_for_GR (cpu, in_GRi);
   1621   1.1  christos       load_wait_for_GR (cpu, in_GRj);
   1622   1.1  christos       load_wait_for_GR (cpu, out_GRk);
   1623   1.1  christos       trace_vliw_wait_cycles (cpu);
   1624   1.1  christos       return 0;
   1625   1.1  christos     }
   1626   1.1  christos 
   1627   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1628   1.1  christos 
   1629   1.1  christos   /* The latency of GRk will depend on how long it takes to swap
   1630   1.1  christos      the the data from the cache or memory.  */
   1631   1.1  christos   update_GR_latency_for_swap (cpu, out_GRk, cycles);
   1632   1.1  christos 
   1633   1.1  christos   return cycles;
   1634   1.1  christos }
   1635   1.1  christos 
   1636   1.1  christos int
   1637   1.1  christos frvbf_model_fr550_u_fr2fr (SIM_CPU *cpu, const IDESC *idesc,
   1638   1.1  christos 			   int unit_num, int referenced,
   1639   1.1  christos 			   INT in_FRj, INT out_FRk)
   1640   1.1  christos {
   1641   1.1  christos   int cycles;
   1642   1.1  christos 
   1643   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1644   1.1  christos     {
   1645   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1646   1.1  christos 	 which is not ready yet.
   1647   1.1  christos 	 The latency of the registers may be less than previously recorded,
   1648   1.1  christos 	 depending on how they were used previously.
   1649   1.1  christos 	 See Table 14-15 in the LSI.  */
   1650   1.1  christos       adjust_float_register_busy (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
   1651   1.1  christos       vliw_wait_for_FR (cpu, in_FRj);
   1652   1.1  christos       vliw_wait_for_FR (cpu, out_FRk);
   1653   1.1  christos       handle_resource_wait (cpu);
   1654   1.1  christos       load_wait_for_FR (cpu, in_FRj);
   1655   1.1  christos       load_wait_for_FR (cpu, out_FRk);
   1656   1.1  christos       trace_vliw_wait_cycles (cpu);
   1657   1.1  christos       return 0;
   1658   1.1  christos     }
   1659   1.1  christos 
   1660   1.1  christos   /* The latency of FRj is 2 cycles.  */
   1661   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1662   1.1  christos   update_FR_latency (cpu, out_FRk, cycles + 2);
   1663   1.1  christos 
   1664   1.1  christos   set_use_is_fr_complex_2 (cpu, out_FRk);
   1665   1.1  christos 
   1666   1.1  christos   return cycles;
   1667   1.1  christos }
   1668   1.1  christos 
   1669   1.1  christos int
   1670   1.1  christos frvbf_model_fr550_u_fr2gr (SIM_CPU *cpu, const IDESC *idesc,
   1671   1.1  christos 			   int unit_num, int referenced,
   1672   1.1  christos 			   INT in_FRk, INT out_GRj)
   1673   1.1  christos {
   1674   1.1  christos   int cycles;
   1675   1.1  christos 
   1676   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1677   1.1  christos     {
   1678   1.1  christos       /* The entire VLIW insn must wait if there is a dependency on a register
   1679   1.1  christos 	 which is not ready yet.
   1680   1.1  christos 	 The latency of the registers may be less than previously recorded,
   1681   1.1  christos 	 depending on how they were used previously.
   1682   1.1  christos 	 See Table 14-15 in the LSI.  */
   1683   1.1  christos       adjust_float_register_busy (cpu, in_FRk, 1, -1, 1, -1, 1);
   1684   1.1  christos       vliw_wait_for_FR (cpu, in_FRk);
   1685   1.1  christos       vliw_wait_for_GR (cpu, out_GRj);
   1686   1.1  christos       handle_resource_wait (cpu);
   1687   1.1  christos       load_wait_for_FR (cpu, in_FRk);
   1688   1.1  christos       load_wait_for_GR (cpu, out_GRj);
   1689   1.1  christos       trace_vliw_wait_cycles (cpu);
   1690   1.1  christos       return 0;
   1691   1.1  christos     }
   1692   1.1  christos 
   1693   1.1  christos   /* The latency of GRj is 1 cycle.  */
   1694   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1695   1.1  christos   update_GR_latency (cpu, out_GRj, cycles + 1);
   1696   1.1  christos 
   1697   1.1  christos   return cycles;
   1698   1.1  christos }
   1699   1.1  christos 
   1700   1.1  christos int
   1701   1.1  christos frvbf_model_fr550_u_clrgr (SIM_CPU *cpu, const IDESC *idesc,
   1702   1.1  christos 			   int unit_num, int referenced,
   1703   1.1  christos 			   INT in_GRk)
   1704   1.1  christos {
   1705   1.1  christos   /* Modelling for this unit is the same as for fr500.  */
   1706   1.1  christos   return frvbf_model_fr500_u_clrgr (cpu, idesc, unit_num, referenced, in_GRk);
   1707   1.1  christos }
   1708   1.1  christos 
   1709   1.1  christos int
   1710   1.1  christos frvbf_model_fr550_u_clrfr (SIM_CPU *cpu, const IDESC *idesc,
   1711   1.1  christos 			   int unit_num, int referenced,
   1712   1.1  christos 			   INT in_FRk)
   1713   1.1  christos {
   1714   1.1  christos   /* Modelling for this unit is the same as for fr500.  */
   1715   1.1  christos   return frvbf_model_fr500_u_clrfr (cpu, idesc, unit_num, referenced, in_FRk);
   1716   1.1  christos }
   1717   1.1  christos 
   1718   1.1  christos int
   1719   1.1  christos frvbf_model_fr550_u_commit (SIM_CPU *cpu, const IDESC *idesc,
   1720   1.1  christos 			    int unit_num, int referenced,
   1721   1.1  christos 			    INT in_GRk, INT in_FRk)
   1722   1.1  christos {
   1723   1.1  christos   /* Modelling for this unit is the same as for fr500.  */
   1724   1.1  christos   return frvbf_model_fr500_u_commit (cpu, idesc, unit_num, referenced,
   1725   1.1  christos 				     in_GRk, in_FRk);
   1726   1.1  christos }
   1727   1.1  christos 
   1728   1.1  christos int
   1729   1.1  christos frvbf_model_fr550_u_media (SIM_CPU *cpu, const IDESC *idesc,
   1730   1.1  christos 			   int unit_num, int referenced,
   1731   1.1  christos 			   INT in_FRi, INT in_FRj, INT out_FRk)
   1732   1.1  christos {
   1733   1.1  christos   int cycles;
   1734   1.1  christos   FRV_PROFILE_STATE *ps;
   1735   1.1  christos   FRV_VLIW *vliw;
   1736   1.1  christos   int slot;
   1737   1.1  christos 
   1738   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1739   1.1  christos     return 0;
   1740   1.1  christos 
   1741   1.1  christos   /* The preprocessing can execute right away.  */
   1742   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1743   1.1  christos 
   1744   1.1  christos   /* If the previous use of the registers was a media op,
   1745   1.1  christos      then their latency may be less than previously recorded.
   1746   1.1  christos      See Table 14-15 in the LSI.  */
   1747   1.1  christos   adjust_float_register_busy_for_media (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
   1748   1.1  christos 
   1749   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1750   1.1  christos      which is not ready yet.  */
   1751   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1752   1.1  christos   ps->post_wait = cycles;
   1753   1.1  christos   vliw = CPU_VLIW (cpu);
   1754   1.1  christos   slot = vliw->next_slot - 1;
   1755   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1756   1.1  christos   post_wait_for_media (cpu, slot);
   1757   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1758   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1759   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1760   1.1  christos 
   1761   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   1762   1.1  christos   restore_float_register_busy_for_media (cpu, in_FRi, 1, in_FRj, 1, out_FRk, 1);
   1763   1.1  christos 
   1764   1.1  christos   /* The latency of tht output register will be at least the latency of the
   1765   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   1766   1.1  christos   if (out_FRk >= 0)
   1767   1.1  christos     {
   1768   1.1  christos       update_FR_latency (cpu, out_FRk, ps->post_wait);
   1769   1.1  christos       update_FR_ptime (cpu, out_FRk, 1);
   1770   1.1  christos       /* Mark this use of the register as a media op.  */
   1771   1.1  christos       set_use_is_fr_complex_1 (cpu, out_FRk);
   1772   1.1  christos     }
   1773   1.1  christos 
   1774   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   1775   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   1776   1.1  christos 
   1777   1.1  christos   return cycles;
   1778   1.1  christos }
   1779   1.1  christos 
   1780   1.1  christos int
   1781   1.1  christos frvbf_model_fr550_u_media_quad (SIM_CPU *cpu, const IDESC *idesc,
   1782   1.1  christos 				int unit_num, int referenced,
   1783   1.1  christos 				INT in_FRi, INT in_FRj,
   1784   1.1  christos 				INT out_FRk)
   1785   1.1  christos {
   1786   1.1  christos   int cycles;
   1787   1.1  christos   INT dual_FRi;
   1788   1.1  christos   INT dual_FRj;
   1789   1.1  christos   INT dual_FRk;
   1790   1.1  christos   FRV_PROFILE_STATE *ps;
   1791   1.1  christos   FRV_VLIW *vliw;
   1792   1.1  christos   int slot;
   1793   1.1  christos 
   1794   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1795   1.1  christos     return 0;
   1796   1.1  christos 
   1797   1.1  christos   /* The preprocessing can execute right away.  */
   1798   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1799   1.1  christos 
   1800   1.1  christos   dual_FRi = DUAL_REG (in_FRi);
   1801   1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   1802   1.1  christos   dual_FRk = DUAL_REG (out_FRk);
   1803   1.1  christos 
   1804   1.1  christos   /* The latency of the registers may be less than previously recorded,
   1805   1.1  christos      depending on how they were used previously.
   1806   1.1  christos      See Table 14-15 in the LSI.  */
   1807   1.1  christos   adjust_float_register_busy_for_media (cpu, in_FRi, 2, in_FRj, 2, out_FRk, 2);
   1808   1.1  christos 
   1809   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1810   1.1  christos      which is not ready yet.  */
   1811   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1812   1.1  christos   ps->post_wait = cycles;
   1813   1.1  christos   vliw = CPU_VLIW (cpu);
   1814   1.1  christos   slot = vliw->next_slot - 1;
   1815   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1816   1.1  christos   post_wait_for_media (cpu, slot);
   1817   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1818   1.1  christos   post_wait_for_FR (cpu, dual_FRi);
   1819   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1820   1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   1821   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1822   1.1  christos   post_wait_for_FR (cpu, dual_FRk);
   1823   1.1  christos 
   1824   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   1825   1.1  christos   restore_float_register_busy_for_media (cpu, in_FRi, 2, in_FRj, 2, out_FRk, 2);
   1826   1.1  christos 
   1827   1.1  christos   /* The latency of the output register will be at least the latency of the
   1828   1.1  christos      other inputs.  Once initiated, post-processing take 1 cycle.  */
   1829   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1830   1.1  christos   update_FR_ptime (cpu, out_FRk, 1);
   1831   1.1  christos   set_use_is_fr_complex_1 (cpu, out_FRk);
   1832   1.1  christos 
   1833   1.1  christos   if (dual_FRk >= 0)
   1834   1.1  christos     {
   1835   1.1  christos       update_FR_latency (cpu, dual_FRk, ps->post_wait);
   1836   1.1  christos       update_FR_ptime (cpu, dual_FRk, 1);
   1837   1.1  christos       set_use_is_fr_complex_1 (cpu, dual_FRk);
   1838   1.1  christos     }
   1839   1.1  christos 
   1840   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   1841   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   1842   1.1  christos 
   1843   1.1  christos   return cycles;
   1844   1.1  christos }
   1845   1.1  christos 
   1846   1.1  christos int
   1847   1.1  christos frvbf_model_fr550_u_media_dual_expand (SIM_CPU *cpu, const IDESC *idesc,
   1848   1.1  christos 				       int unit_num, int referenced,
   1849   1.1  christos 				       INT in_FRi, INT out_FRk)
   1850   1.1  christos {
   1851   1.1  christos   int cycles;
   1852   1.1  christos   INT dual_FRk;
   1853   1.1  christos   FRV_PROFILE_STATE *ps;
   1854   1.1  christos   FRV_VLIW *vliw;
   1855   1.1  christos   int slot;
   1856   1.1  christos 
   1857   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1858   1.1  christos     return 0;
   1859   1.1  christos 
   1860   1.1  christos   /* The preprocessing can execute right away.  */
   1861   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1862   1.1  christos 
   1863   1.1  christos   /* If the previous use of the registers was a media op,
   1864   1.1  christos      then their latency will be less than previously recorded.
   1865   1.1  christos      See Table 14-15 in the LSI.  */
   1866   1.1  christos   dual_FRk = DUAL_REG (out_FRk);
   1867   1.1  christos   adjust_float_register_busy_for_media (cpu, in_FRi, 1, -1, 1, out_FRk, 2);
   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   vliw = CPU_VLIW (cpu);
   1874   1.1  christos   slot = vliw->next_slot - 1;
   1875   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1876   1.1  christos   post_wait_for_media (cpu, slot);
   1877   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1878   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1879   1.1  christos   post_wait_for_FR (cpu, dual_FRk);
   1880   1.1  christos 
   1881   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   1882   1.1  christos   restore_float_register_busy_for_media (cpu, in_FRi, 1, -1, 1, out_FRk, 2);
   1883   1.1  christos 
   1884   1.1  christos   /* The latency of the output register will be at least the latency of the
   1885   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   1886   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1887   1.1  christos   update_FR_ptime (cpu, out_FRk, 1);
   1888   1.1  christos   set_use_is_fr_complex_1 (cpu, out_FRk);
   1889   1.1  christos 
   1890   1.1  christos   if (dual_FRk >= 0)
   1891   1.1  christos     {
   1892   1.1  christos       update_FR_latency (cpu, dual_FRk, ps->post_wait);
   1893   1.1  christos       update_FR_ptime (cpu, dual_FRk, 1);
   1894   1.1  christos       set_use_is_fr_complex_1 (cpu, dual_FRk);
   1895   1.1  christos     }
   1896   1.1  christos 
   1897   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   1898   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   1899   1.1  christos 
   1900   1.1  christos   return cycles;
   1901   1.1  christos }
   1902   1.1  christos 
   1903   1.1  christos int
   1904   1.1  christos frvbf_model_fr550_u_media_3_dual (SIM_CPU *cpu, const IDESC *idesc,
   1905   1.1  christos 				  int unit_num, int referenced,
   1906   1.1  christos 				  INT in_FRi, INT out_FRk)
   1907   1.1  christos {
   1908   1.1  christos   int cycles;
   1909   1.1  christos   INT dual_FRi;
   1910   1.1  christos   FRV_PROFILE_STATE *ps;
   1911   1.1  christos   FRV_VLIW *vliw;
   1912   1.1  christos   int slot;
   1913   1.1  christos 
   1914   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1915   1.1  christos     return 0;
   1916   1.1  christos 
   1917   1.1  christos   /* The preprocessing can execute right away.  */
   1918   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1919   1.1  christos 
   1920   1.1  christos   dual_FRi = DUAL_REG (in_FRi);
   1921   1.1  christos 
   1922   1.1  christos   /* The latency of the registers may be less than previously recorded,
   1923   1.1  christos      depending on how they were used previously.
   1924   1.1  christos      See Table 14-15 in the LSI.  */
   1925   1.1  christos   adjust_float_register_busy_for_media (cpu, in_FRi, 2, -1, 1, out_FRk, 1);
   1926   1.1  christos 
   1927   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1928   1.1  christos      which is not ready yet.  */
   1929   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1930   1.1  christos   ps->post_wait = cycles;
   1931   1.1  christos   vliw = CPU_VLIW (cpu);
   1932   1.1  christos   slot = vliw->next_slot - 1;
   1933   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1934   1.1  christos   post_wait_for_media (cpu, slot);
   1935   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   1936   1.1  christos   post_wait_for_FR (cpu, dual_FRi);
   1937   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1938   1.1  christos 
   1939   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   1940   1.1  christos   restore_float_register_busy_for_media (cpu, in_FRi, 2, -1, 1, out_FRk, 1);
   1941   1.1  christos 
   1942   1.1  christos   /* The latency of the output register will be at least the latency of the
   1943   1.1  christos      other inputs.  Once initiated, post-processing takes 1 cycle.  */
   1944   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1945   1.1  christos   update_FR_ptime (cpu, out_FRk, 1);
   1946   1.1  christos 
   1947   1.1  christos   set_use_is_fr_complex_1 (cpu, out_FRk);
   1948   1.1  christos 
   1949   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   1950   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   1951   1.1  christos 
   1952   1.1  christos   return cycles;
   1953   1.1  christos }
   1954   1.1  christos 
   1955   1.1  christos int
   1956   1.1  christos frvbf_model_fr550_u_media_3_acc (SIM_CPU *cpu, const IDESC *idesc,
   1957   1.1  christos 				 int unit_num, int referenced,
   1958   1.1  christos 				 INT in_FRj, INT in_ACC40Si,
   1959   1.1  christos 				 INT out_FRk)
   1960   1.1  christos {
   1961   1.1  christos   int cycles;
   1962   1.1  christos   FRV_PROFILE_STATE *ps;
   1963   1.1  christos   FRV_VLIW *vliw;
   1964   1.1  christos   int slot;
   1965   1.1  christos 
   1966   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   1967   1.1  christos     return 0;
   1968   1.1  christos 
   1969   1.1  christos   /* The preprocessing can execute right away.  */
   1970   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   1971   1.1  christos 
   1972   1.1  christos   /* If the previous use of the registers was a media op,
   1973   1.1  christos      then their latency will be less than previously recorded.
   1974   1.1  christos      See Table 14-15 in the LSI.  */
   1975   1.1  christos   adjust_float_register_busy_for_media (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
   1976   1.1  christos 
   1977   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   1978   1.1  christos      which is not ready yet.  */
   1979   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   1980   1.1  christos   ps->post_wait = cycles;
   1981   1.1  christos   vliw = CPU_VLIW (cpu);
   1982   1.1  christos   slot = vliw->next_slot - 1;
   1983   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   1984   1.1  christos   post_wait_for_media (cpu, slot);
   1985   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   1986   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   1987   1.1  christos   post_wait_for_ACC (cpu, in_ACC40Si);
   1988   1.1  christos 
   1989   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   1990   1.1  christos   restore_float_register_busy_for_media (cpu, -1, 1, in_FRj, 1, out_FRk, 1);
   1991   1.1  christos 
   1992   1.1  christos   /* The latency of tht output register will be at least the latency of the
   1993   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   1994   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   1995   1.1  christos   update_FR_ptime (cpu, out_FRk, 1);
   1996   1.1  christos 
   1997   1.1  christos   set_use_is_fr_complex_1 (cpu, out_FRk);
   1998   1.1  christos 
   1999   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2000   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2001   1.1  christos 
   2002   1.1  christos   return cycles;
   2003   1.1  christos }
   2004   1.1  christos 
   2005   1.1  christos int
   2006   1.1  christos frvbf_model_fr550_u_media_3_acc_dual (SIM_CPU *cpu, const IDESC *idesc,
   2007   1.1  christos 				      int unit_num, int referenced,
   2008   1.1  christos 				      INT in_ACC40Si, INT out_FRk)
   2009   1.1  christos {
   2010   1.1  christos   int cycles;
   2011   1.1  christos   FRV_PROFILE_STATE *ps;
   2012   1.1  christos   INT ACC40Si_1;
   2013   1.1  christos   INT dual_FRk;
   2014   1.1  christos   FRV_VLIW *vliw;
   2015   1.1  christos   int slot;
   2016   1.1  christos 
   2017   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2018   1.1  christos     return 0;
   2019   1.1  christos 
   2020   1.1  christos   /* The preprocessing can execute right away.  */
   2021   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2022   1.1  christos 
   2023   1.1  christos   ACC40Si_1 = DUAL_REG (in_ACC40Si);
   2024   1.1  christos   dual_FRk = DUAL_REG (out_FRk);
   2025   1.1  christos 
   2026   1.1  christos   /* If the previous use of the registers was a media op,
   2027   1.1  christos      then their latency will be less than previously recorded.
   2028   1.1  christos      See Table 14-15 in the LSI.  */
   2029   1.1  christos   adjust_float_register_busy_for_media (cpu, -1, 1, -1, 1, out_FRk, 2);
   2030   1.1  christos 
   2031   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2032   1.1  christos      which is not ready yet.  */
   2033   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2034   1.1  christos   ps->post_wait = cycles;
   2035   1.1  christos   vliw = CPU_VLIW (cpu);
   2036   1.1  christos   slot = vliw->next_slot - 1;
   2037   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2038   1.1  christos   post_wait_for_media (cpu, slot);
   2039   1.1  christos   post_wait_for_ACC (cpu, in_ACC40Si);
   2040   1.1  christos   post_wait_for_ACC (cpu, ACC40Si_1);
   2041   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   2042   1.1  christos   post_wait_for_FR (cpu, dual_FRk);
   2043   1.1  christos 
   2044   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2045   1.1  christos   restore_float_register_busy_for_media (cpu, -1, 1, -1, 1, out_FRk, 2);
   2046   1.1  christos 
   2047   1.1  christos   /* The latency of the output register will be at least the latency of the
   2048   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2049   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   2050   1.1  christos   update_FR_ptime (cpu, out_FRk, 1);
   2051   1.1  christos   set_use_is_fr_complex_1 (cpu, out_FRk);
   2052   1.1  christos   if (dual_FRk >= 0)
   2053   1.1  christos     {
   2054   1.1  christos       update_FR_latency (cpu, dual_FRk, ps->post_wait);
   2055   1.1  christos       update_FR_ptime (cpu, dual_FRk, 1);
   2056   1.1  christos       set_use_is_fr_complex_1 (cpu, dual_FRk);
   2057   1.1  christos     }
   2058   1.1  christos 
   2059   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2060   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2061   1.1  christos 
   2062   1.1  christos   return cycles;
   2063   1.1  christos }
   2064   1.1  christos 
   2065   1.1  christos int
   2066   1.1  christos frvbf_model_fr550_u_media_3_wtacc (SIM_CPU *cpu, const IDESC *idesc,
   2067   1.1  christos 				   int unit_num, int referenced,
   2068   1.1  christos 				   INT in_FRi, INT out_ACC40Sk)
   2069   1.1  christos {
   2070   1.1  christos   int cycles;
   2071   1.1  christos   FRV_PROFILE_STATE *ps;
   2072   1.1  christos   FRV_VLIW *vliw;
   2073   1.1  christos   int slot;
   2074   1.1  christos 
   2075   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2076   1.1  christos     return 0;
   2077   1.1  christos 
   2078   1.1  christos   /* The preprocessing can execute right away.  */
   2079   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2080   1.1  christos 
   2081   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2082   1.1  christos 
   2083   1.1  christos   /* The latency of the registers may be less than previously recorded,
   2084   1.1  christos      depending on how they were used previously.
   2085   1.1  christos      See Table 14-15 in the LSI.  */
   2086   1.1  christos   adjust_float_register_busy_for_media (cpu, in_FRi, 1, -1, 1, -1, 1);
   2087   1.1  christos 
   2088   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2089   1.1  christos      which is not ready yet.  */
   2090   1.1  christos   ps->post_wait = cycles;
   2091   1.1  christos   vliw = CPU_VLIW (cpu);
   2092   1.1  christos   slot = vliw->next_slot - 1;
   2093   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2094   1.1  christos   post_wait_for_media (cpu, slot);
   2095   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2096   1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2097   1.1  christos 
   2098   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2099   1.1  christos   restore_float_register_busy_for_media (cpu, in_FRi, 1, -1, 1, -1, 1);
   2100   1.1  christos 
   2101   1.1  christos   /* The latency of the output register will be at least the latency of the
   2102   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2103   1.1  christos   update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait);
   2104   1.1  christos   update_ACC_ptime (cpu, out_ACC40Sk, 1);
   2105   1.1  christos   set_use_is_acc_mmac (cpu, out_ACC40Sk);
   2106   1.1  christos 
   2107   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2108   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2109   1.1  christos 
   2110   1.1  christos   return cycles;
   2111   1.1  christos }
   2112   1.1  christos 
   2113   1.1  christos int
   2114   1.1  christos frvbf_model_fr550_u_media_3_mclracc (SIM_CPU *cpu, const IDESC *idesc,
   2115   1.1  christos 				     int unit_num, int referenced)
   2116   1.1  christos {
   2117   1.1  christos   int cycles;
   2118   1.1  christos   FRV_PROFILE_STATE *ps;
   2119   1.1  christos   FRV_VLIW *vliw;
   2120   1.1  christos   int slot;
   2121   1.1  christos   int i;
   2122   1.1  christos 
   2123   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2124   1.1  christos     return 0;
   2125   1.1  christos 
   2126   1.1  christos   /* The preprocessing can execute right away.  */
   2127   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2128   1.1  christos 
   2129   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2130   1.1  christos 
   2131   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2132   1.1  christos      which is not ready yet.  */
   2133   1.1  christos   ps->post_wait = cycles;
   2134   1.1  christos   vliw = CPU_VLIW (cpu);
   2135   1.1  christos   slot = vliw->next_slot - 1;
   2136   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2137   1.1  christos   post_wait_for_media (cpu, slot);
   2138   1.1  christos 
   2139   1.1  christos   /* If A was 1 and the accumulator was ACC0, then we must check all
   2140   1.1  christos      accumulators. Otherwise just wait for the specified accumulator.  */
   2141   1.1  christos   if (ps->mclracc_A && ps->mclracc_acc == 0)
   2142   1.1  christos     {
   2143   1.1  christos       for (i = 0; i < 8; ++i)
   2144   1.1  christos 	post_wait_for_ACC (cpu, i);
   2145   1.1  christos     }
   2146   1.1  christos   else
   2147   1.1  christos     post_wait_for_ACC (cpu, ps->mclracc_acc);
   2148   1.1  christos 
   2149   1.1  christos   /* The latency of the output registers will be at least the latency of the
   2150   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2151   1.1  christos   if (ps->mclracc_A && ps->mclracc_acc == 0)
   2152   1.1  christos     {
   2153   1.1  christos       for (i = 0; i < 8; ++i)
   2154   1.1  christos 	{
   2155   1.1  christos 	  update_ACC_latency (cpu, i, ps->post_wait);
   2156   1.1  christos 	  update_ACC_ptime (cpu, i, 1);
   2157   1.1  christos 	  set_use_is_acc_mmac (cpu, i);
   2158   1.1  christos 	}
   2159   1.1  christos     }
   2160   1.1  christos   else
   2161   1.1  christos     {
   2162   1.1  christos       update_ACC_latency (cpu, ps->mclracc_acc, ps->post_wait);
   2163   1.1  christos       update_ACC_ptime (cpu, ps->mclracc_acc, 1);
   2164   1.1  christos       set_use_is_acc_mmac (cpu, ps->mclracc_acc);
   2165   1.1  christos     }
   2166   1.1  christos 
   2167   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2168   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2169   1.1  christos 
   2170   1.1  christos   return cycles;
   2171   1.1  christos }
   2172   1.1  christos 
   2173   1.1  christos int
   2174   1.1  christos frvbf_model_fr550_u_media_set (SIM_CPU *cpu, const IDESC *idesc,
   2175   1.1  christos 			       int unit_num, int referenced,
   2176   1.1  christos 			       INT out_FRk)
   2177   1.1  christos {
   2178   1.1  christos   int cycles;
   2179   1.1  christos   FRV_PROFILE_STATE *ps;
   2180   1.1  christos   FRV_VLIW *vliw;
   2181   1.1  christos   int slot;
   2182   1.1  christos 
   2183   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2184   1.1  christos     return 0;
   2185   1.1  christos 
   2186   1.1  christos   /* The preprocessing can execute right away.  */
   2187   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2188   1.1  christos 
   2189   1.1  christos   /* If the previous use of the registers was a media op,
   2190   1.1  christos      then their latency will be less than previously recorded.
   2191   1.1  christos      See Table 14-15 in the LSI.  */
   2192   1.1  christos   adjust_float_register_busy_for_media (cpu, -1, 1, -1, 1, out_FRk, 1);
   2193   1.1  christos 
   2194   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2195   1.1  christos      which is not ready yet.  */
   2196   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2197   1.1  christos   ps->post_wait = cycles;
   2198   1.1  christos   vliw = CPU_VLIW (cpu);
   2199   1.1  christos   slot = vliw->next_slot - 1;
   2200   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2201   1.1  christos   post_wait_for_media (cpu, slot);
   2202   1.1  christos   post_wait_for_FR (cpu, out_FRk);
   2203   1.1  christos 
   2204   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2205   1.1  christos   restore_float_register_busy_for_media (cpu, -1, 1, -1, 1, out_FRk, 1);
   2206   1.1  christos 
   2207   1.1  christos   /* The latency of the output register will be at least the latency of the
   2208   1.1  christos      other inputs.  Once initiated, post-processing takes 1 cycle.  */
   2209   1.1  christos   update_FR_latency (cpu, out_FRk, ps->post_wait);
   2210   1.1  christos   update_FR_ptime (cpu, out_FRk, 1);
   2211   1.1  christos   fr550_reset_acc_flags (cpu, out_FRk);
   2212   1.1  christos 
   2213   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2214   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2215   1.1  christos 
   2216   1.1  christos   return cycles;
   2217   1.1  christos }
   2218   1.1  christos 
   2219   1.1  christos int
   2220   1.1  christos frvbf_model_fr550_u_media_4 (SIM_CPU *cpu, const IDESC *idesc,
   2221   1.1  christos 			     int unit_num, int referenced,
   2222   1.1  christos 			     INT in_FRi, INT in_FRj,
   2223   1.1  christos 			     INT out_ACC40Sk, INT out_ACC40Uk)
   2224   1.1  christos {
   2225   1.1  christos   int cycles;
   2226   1.1  christos   INT dual_ACC40Sk;
   2227   1.1  christos   INT dual_ACC40Uk;
   2228   1.1  christos   FRV_PROFILE_STATE *ps;
   2229   1.1  christos   FRV_VLIW *vliw;
   2230   1.1  christos   int slot;
   2231   1.1  christos 
   2232   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2233   1.1  christos     return 0;
   2234   1.1  christos 
   2235   1.1  christos   /* The preprocessing can execute right away.  */
   2236   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2237   1.1  christos 
   2238   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2239   1.1  christos   dual_ACC40Sk = DUAL_REG (out_ACC40Sk);
   2240   1.1  christos   dual_ACC40Uk = DUAL_REG (out_ACC40Uk);
   2241   1.1  christos 
   2242   1.1  christos   /* The latency of the registers may be less than previously recorded,
   2243   1.1  christos      depending on how they were used previously.
   2244   1.1  christos      See Table 14-15 in the LSI.  */
   2245   1.1  christos   adjust_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Sk, 2);
   2246   1.1  christos   adjust_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Uk, 2);
   2247   1.1  christos 
   2248   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2249   1.1  christos      which is not ready yet.  */
   2250   1.1  christos   ps->post_wait = cycles;
   2251   1.1  christos   vliw = CPU_VLIW (cpu);
   2252   1.1  christos   slot = vliw->next_slot - 1;
   2253   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2254   1.1  christos   post_wait_for_media (cpu, slot);
   2255   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2256   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   2257   1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2258   1.1  christos   post_wait_for_ACC (cpu, dual_ACC40Sk);
   2259   1.1  christos   post_wait_for_ACC (cpu, out_ACC40Uk);
   2260   1.1  christos   post_wait_for_ACC (cpu, dual_ACC40Uk);
   2261   1.1  christos 
   2262   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2263   1.1  christos   restore_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Sk, 2);
   2264   1.1  christos   restore_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Uk, 2);
   2265   1.1  christos 
   2266   1.1  christos   /* The latency of the output register will be at least the latency of the
   2267   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycles.  */
   2268   1.1  christos   if (out_ACC40Sk >= 0)
   2269   1.1  christos     {
   2270   1.1  christos       update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2271   1.1  christos       set_use_is_acc_mmac (cpu, out_ACC40Sk);
   2272   1.1  christos     }
   2273   1.1  christos   if (dual_ACC40Sk >= 0)
   2274   1.1  christos     {
   2275   1.1  christos       update_ACC_latency (cpu, dual_ACC40Sk, ps->post_wait + 1);
   2276   1.1  christos       set_use_is_acc_mmac (cpu, dual_ACC40Sk);
   2277   1.1  christos     }
   2278   1.1  christos   if (out_ACC40Uk >= 0)
   2279   1.1  christos     {
   2280   1.1  christos       update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
   2281   1.1  christos       set_use_is_acc_mmac (cpu, out_ACC40Uk);
   2282   1.1  christos     }
   2283   1.1  christos   if (dual_ACC40Uk >= 0)
   2284   1.1  christos     {
   2285   1.1  christos       update_ACC_latency (cpu, dual_ACC40Uk, ps->post_wait + 1);
   2286   1.1  christos       set_use_is_acc_mmac (cpu, dual_ACC40Uk);
   2287   1.1  christos     }
   2288   1.1  christos 
   2289   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2290   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2291   1.1  christos 
   2292   1.1  christos   return cycles;
   2293   1.1  christos }
   2294   1.1  christos 
   2295   1.1  christos int
   2296   1.1  christos frvbf_model_fr550_u_media_4_acc (SIM_CPU *cpu, const IDESC *idesc,
   2297   1.1  christos 				 int unit_num, int referenced,
   2298   1.1  christos 				 INT in_ACC40Si, INT out_ACC40Sk)
   2299   1.1  christos {
   2300   1.1  christos   int cycles;
   2301   1.1  christos   INT ACC40Si_1;
   2302   1.1  christos   FRV_PROFILE_STATE *ps;
   2303   1.1  christos   FRV_VLIW *vliw;
   2304   1.1  christos   int slot;
   2305   1.1  christos 
   2306   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2307   1.1  christos     return 0;
   2308   1.1  christos 
   2309   1.1  christos   /* The preprocessing can execute right away.  */
   2310   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2311   1.1  christos 
   2312   1.1  christos   ACC40Si_1 = DUAL_REG (in_ACC40Si);
   2313   1.1  christos 
   2314   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2315   1.1  christos   /* The latency of the registers may be less than previously recorded,
   2316   1.1  christos      depending on how they were used previously.
   2317   1.1  christos      See Table 14-15 in the LSI.  */
   2318   1.1  christos   adjust_acc_busy_for_mmac (cpu, in_ACC40Si, 2, out_ACC40Sk, 1);
   2319   1.1  christos 
   2320   1.1  christos   /* The post processing must wait if there is a dependency on a register
   2321   1.1  christos      which is not ready yet.  */
   2322   1.1  christos   ps->post_wait = cycles;
   2323   1.1  christos   vliw = CPU_VLIW (cpu);
   2324   1.1  christos   slot = vliw->next_slot - 1;
   2325   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2326   1.1  christos   post_wait_for_media (cpu, slot);
   2327   1.1  christos   post_wait_for_ACC (cpu, in_ACC40Si);
   2328   1.1  christos   post_wait_for_ACC (cpu, ACC40Si_1);
   2329   1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2330   1.1  christos 
   2331   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2332   1.1  christos   restore_acc_busy_for_mmac (cpu, in_ACC40Si, 2, out_ACC40Sk, 1);
   2333   1.1  christos 
   2334   1.1  christos   /* The latency of the output register will be at least the latency of the
   2335   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2336   1.1  christos   update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2337   1.1  christos   set_use_is_acc_mmac (cpu, out_ACC40Sk);
   2338   1.1  christos 
   2339   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2340   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2341   1.1  christos 
   2342   1.1  christos   return cycles;
   2343   1.1  christos }
   2344   1.1  christos 
   2345   1.1  christos int
   2346   1.1  christos frvbf_model_fr550_u_media_4_acc_dual (SIM_CPU *cpu, const IDESC *idesc,
   2347   1.1  christos 				      int unit_num, int referenced,
   2348   1.1  christos 				      INT in_ACC40Si, INT out_ACC40Sk)
   2349   1.1  christos {
   2350   1.1  christos   int cycles;
   2351   1.1  christos   INT ACC40Si_1;
   2352   1.1  christos   INT ACC40Si_2;
   2353   1.1  christos   INT ACC40Si_3;
   2354   1.1  christos   INT ACC40Sk_1;
   2355   1.1  christos   FRV_PROFILE_STATE *ps;
   2356   1.1  christos   FRV_VLIW *vliw;
   2357   1.1  christos   int slot;
   2358   1.1  christos 
   2359   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2360   1.1  christos     return 0;
   2361   1.1  christos 
   2362   1.1  christos   /* The preprocessing can execute right away.  */
   2363   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2364   1.1  christos 
   2365   1.1  christos   ACC40Si_1 = DUAL_REG (in_ACC40Si);
   2366   1.1  christos   ACC40Si_2 = DUAL_REG (ACC40Si_1);
   2367   1.1  christos   ACC40Si_3 = DUAL_REG (ACC40Si_2);
   2368   1.1  christos   ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
   2369   1.1  christos 
   2370   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2371   1.1  christos   /* The latency of the registers may be less than previously recorded,
   2372   1.1  christos      depending on how they were used previously.
   2373   1.1  christos      See Table 14-15 in the LSI.  */
   2374   1.1  christos   adjust_acc_busy_for_mmac (cpu, in_ACC40Si, 4, out_ACC40Sk, 2);
   2375   1.1  christos 
   2376   1.1  christos   /* The post processing must wait if there is a dependency on a register
   2377   1.1  christos      which is not ready yet.  */
   2378   1.1  christos   ps->post_wait = cycles;
   2379   1.1  christos   vliw = CPU_VLIW (cpu);
   2380   1.1  christos   slot = vliw->next_slot - 1;
   2381   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2382   1.1  christos   post_wait_for_media (cpu, slot);
   2383   1.1  christos   post_wait_for_ACC (cpu, in_ACC40Si);
   2384   1.1  christos   post_wait_for_ACC (cpu, ACC40Si_1);
   2385   1.1  christos   post_wait_for_ACC (cpu, ACC40Si_2);
   2386   1.1  christos   post_wait_for_ACC (cpu, ACC40Si_3);
   2387   1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2388   1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_1);
   2389   1.1  christos 
   2390   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2391   1.1  christos   restore_acc_busy_for_mmac (cpu, in_ACC40Si, 4, out_ACC40Sk, 2);
   2392   1.1  christos 
   2393   1.1  christos   /* The latency of the output register will be at least the latency of the
   2394   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2395   1.1  christos   update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2396   1.1  christos   set_use_is_acc_mmac (cpu, out_ACC40Sk);
   2397   1.1  christos   if (ACC40Sk_1 >= 0)
   2398   1.1  christos     {
   2399   1.1  christos       update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
   2400   1.1  christos       set_use_is_acc_mmac (cpu, ACC40Sk_1);
   2401   1.1  christos     }
   2402   1.1  christos 
   2403   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2404   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2405   1.1  christos 
   2406   1.1  christos   return cycles;
   2407   1.1  christos }
   2408   1.1  christos 
   2409   1.1  christos int
   2410   1.1  christos frvbf_model_fr550_u_media_4_add_sub (SIM_CPU *cpu, const IDESC *idesc,
   2411   1.1  christos 				     int unit_num, int referenced,
   2412   1.1  christos 				     INT in_ACC40Si, INT out_ACC40Sk)
   2413   1.1  christos {
   2414   1.1  christos   int cycles;
   2415   1.1  christos   INT ACC40Si_1;
   2416   1.1  christos   INT ACC40Sk_1;
   2417   1.1  christos   FRV_PROFILE_STATE *ps;
   2418   1.1  christos   FRV_VLIW *vliw;
   2419   1.1  christos   int slot;
   2420   1.1  christos 
   2421   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2422   1.1  christos     return 0;
   2423   1.1  christos 
   2424   1.1  christos   /* The preprocessing can execute right away.  */
   2425   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2426   1.1  christos 
   2427   1.1  christos   ACC40Si_1 = DUAL_REG (in_ACC40Si);
   2428   1.1  christos   ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
   2429   1.1  christos 
   2430   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2431   1.1  christos   /* The latency of the registers may be less than previously recorded,
   2432   1.1  christos      depending on how they were used previously.
   2433   1.1  christos      See Table 14-15 in the LSI.  */
   2434   1.1  christos   adjust_acc_busy_for_mmac (cpu, in_ACC40Si, 2, out_ACC40Sk, 2);
   2435   1.1  christos 
   2436   1.1  christos   /* The post processing must wait if there is a dependency on a register
   2437   1.1  christos      which is not ready yet.  */
   2438   1.1  christos   ps->post_wait = cycles;
   2439   1.1  christos   vliw = CPU_VLIW (cpu);
   2440   1.1  christos   slot = vliw->next_slot - 1;
   2441   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2442   1.1  christos   post_wait_for_media (cpu, slot);
   2443   1.1  christos   post_wait_for_ACC (cpu, in_ACC40Si);
   2444   1.1  christos   post_wait_for_ACC (cpu, ACC40Si_1);
   2445   1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2446   1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_1);
   2447   1.1  christos 
   2448   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2449   1.1  christos   restore_acc_busy_for_mmac (cpu, in_ACC40Si, 2, out_ACC40Sk, 2);
   2450   1.1  christos 
   2451   1.1  christos   /* The latency of the output register will be at least the latency of the
   2452   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2453   1.1  christos   update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2454   1.1  christos   set_use_is_acc_mmac (cpu, out_ACC40Sk);
   2455   1.1  christos   if (ACC40Sk_1 >= 0)
   2456   1.1  christos     {
   2457   1.1  christos       update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
   2458   1.1  christos       set_use_is_acc_mmac (cpu, ACC40Sk_1);
   2459   1.1  christos     }
   2460   1.1  christos 
   2461   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2462   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2463   1.1  christos 
   2464   1.1  christos   return cycles;
   2465   1.1  christos }
   2466   1.1  christos 
   2467   1.1  christos int
   2468   1.1  christos frvbf_model_fr550_u_media_4_add_sub_dual (SIM_CPU *cpu, const IDESC *idesc,
   2469   1.1  christos 					  int unit_num, int referenced,
   2470   1.1  christos 					  INT in_ACC40Si, INT out_ACC40Sk)
   2471   1.1  christos {
   2472   1.1  christos   int cycles;
   2473   1.1  christos   INT ACC40Si_1;
   2474   1.1  christos   INT ACC40Si_2;
   2475   1.1  christos   INT ACC40Si_3;
   2476   1.1  christos   INT ACC40Sk_1;
   2477   1.1  christos   INT ACC40Sk_2;
   2478   1.1  christos   INT ACC40Sk_3;
   2479   1.1  christos   FRV_PROFILE_STATE *ps;
   2480   1.1  christos   FRV_VLIW *vliw;
   2481   1.1  christos   int slot;
   2482   1.1  christos 
   2483   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2484   1.1  christos     return 0;
   2485   1.1  christos 
   2486   1.1  christos   /* The preprocessing can execute right away.  */
   2487   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2488   1.1  christos 
   2489   1.1  christos   ACC40Si_1 = DUAL_REG (in_ACC40Si);
   2490   1.1  christos   ACC40Si_2 = DUAL_REG (ACC40Si_1);
   2491   1.1  christos   ACC40Si_3 = DUAL_REG (ACC40Si_2);
   2492   1.1  christos   ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
   2493   1.1  christos   ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
   2494   1.1  christos   ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
   2495   1.1  christos 
   2496   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2497   1.1  christos   /* The latency of the registers may be less than previously recorded,
   2498   1.1  christos      depending on how they were used previously.
   2499   1.1  christos      See Table 14-15 in the LSI.  */
   2500   1.1  christos   adjust_acc_busy_for_mmac (cpu, in_ACC40Si, 4, out_ACC40Sk, 4);
   2501   1.1  christos 
   2502   1.1  christos   /* The post processing must wait if there is a dependency on a register
   2503   1.1  christos      which is not ready yet.  */
   2504   1.1  christos   ps->post_wait = cycles;
   2505   1.1  christos   vliw = CPU_VLIW (cpu);
   2506   1.1  christos   slot = vliw->next_slot - 1;
   2507   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2508   1.1  christos   post_wait_for_media (cpu, slot);
   2509   1.1  christos   post_wait_for_ACC (cpu, in_ACC40Si);
   2510   1.1  christos   post_wait_for_ACC (cpu, ACC40Si_1);
   2511   1.1  christos   post_wait_for_ACC (cpu, ACC40Si_2);
   2512   1.1  christos   post_wait_for_ACC (cpu, ACC40Si_3);
   2513   1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2514   1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_1);
   2515   1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_2);
   2516   1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_3);
   2517   1.1  christos 
   2518   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2519   1.1  christos   restore_acc_busy_for_mmac (cpu, in_ACC40Si, 4, out_ACC40Sk, 4);
   2520   1.1  christos 
   2521   1.1  christos   /* The latency of the output register will be at least the latency of the
   2522   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2523   1.1  christos   update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2524   1.1  christos   set_use_is_acc_mmac (cpu, out_ACC40Sk);
   2525   1.1  christos   if (ACC40Sk_1 >= 0)
   2526   1.1  christos     {
   2527   1.1  christos       update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
   2528   1.1  christos       set_use_is_acc_mmac (cpu, ACC40Sk_1);
   2529   1.1  christos     }
   2530   1.1  christos   if (ACC40Sk_2 >= 0)
   2531   1.1  christos     {
   2532   1.1  christos       update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
   2533   1.1  christos       set_use_is_acc_mmac (cpu, ACC40Sk_2);
   2534   1.1  christos     }
   2535   1.1  christos   if (ACC40Sk_3 >= 0)
   2536   1.1  christos     {
   2537   1.1  christos       update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
   2538   1.1  christos       set_use_is_acc_mmac (cpu, ACC40Sk_3);
   2539   1.1  christos     }
   2540   1.1  christos 
   2541   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2542   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2543   1.1  christos 
   2544   1.1  christos   return cycles;
   2545   1.1  christos }
   2546   1.1  christos 
   2547   1.1  christos int
   2548   1.1  christos frvbf_model_fr550_u_media_4_quad (SIM_CPU *cpu, const IDESC *idesc,
   2549   1.1  christos 				  int unit_num, int referenced,
   2550   1.1  christos 				  INT in_FRi, INT in_FRj,
   2551   1.1  christos 				  INT out_ACC40Sk, INT out_ACC40Uk)
   2552   1.1  christos {
   2553   1.1  christos   int cycles;
   2554   1.1  christos   INT dual_FRi;
   2555   1.1  christos   INT dual_FRj;
   2556   1.1  christos   INT ACC40Sk_1;
   2557   1.1  christos   INT ACC40Sk_2;
   2558   1.1  christos   INT ACC40Sk_3;
   2559   1.1  christos   INT ACC40Uk_1;
   2560   1.1  christos   INT ACC40Uk_2;
   2561   1.1  christos   INT ACC40Uk_3;
   2562   1.1  christos   FRV_PROFILE_STATE *ps;
   2563   1.1  christos   FRV_VLIW *vliw;
   2564   1.1  christos   int slot;
   2565   1.1  christos 
   2566   1.1  christos   if (model_insn == FRV_INSN_MODEL_PASS_1)
   2567   1.1  christos     return 0;
   2568   1.1  christos 
   2569   1.1  christos   /* The preprocessing can execute right away.  */
   2570   1.1  christos   cycles = idesc->timing->units[unit_num].done;
   2571   1.1  christos 
   2572   1.1  christos   dual_FRi = DUAL_REG (in_FRi);
   2573   1.1  christos   dual_FRj = DUAL_REG (in_FRj);
   2574   1.1  christos   ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
   2575   1.1  christos   ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
   2576   1.1  christos   ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
   2577   1.1  christos   ACC40Uk_1 = DUAL_REG (out_ACC40Uk);
   2578   1.1  christos   ACC40Uk_2 = DUAL_REG (ACC40Uk_1);
   2579   1.1  christos   ACC40Uk_3 = DUAL_REG (ACC40Uk_2);
   2580   1.1  christos 
   2581   1.1  christos   ps = CPU_PROFILE_STATE (cpu);
   2582   1.1  christos   /* The latency of the registers may be less than previously recorded,
   2583   1.1  christos      depending on how they were used previously.
   2584   1.1  christos      See Table 14-15 in the LSI.  */
   2585   1.1  christos   adjust_float_register_busy_for_media (cpu, in_FRi, 2, in_FRj, 2, -1, 1);
   2586   1.1  christos   adjust_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Sk, 4);
   2587   1.1  christos   adjust_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Uk, 4);
   2588   1.1  christos 
   2589   1.1  christos   /* The post processing must wait if there is a dependency on a FR
   2590   1.1  christos      which is not ready yet.  */
   2591   1.1  christos   ps->post_wait = cycles;
   2592   1.1  christos   vliw = CPU_VLIW (cpu);
   2593   1.1  christos   slot = vliw->next_slot - 1;
   2594   1.1  christos   slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
   2595   1.1  christos   post_wait_for_media (cpu, slot);
   2596   1.1  christos   post_wait_for_FR (cpu, in_FRi);
   2597   1.1  christos   post_wait_for_FR (cpu, dual_FRi);
   2598   1.1  christos   post_wait_for_FR (cpu, in_FRj);
   2599   1.1  christos   post_wait_for_FR (cpu, dual_FRj);
   2600   1.1  christos   post_wait_for_ACC (cpu, out_ACC40Sk);
   2601   1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_1);
   2602   1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_2);
   2603   1.1  christos   post_wait_for_ACC (cpu, ACC40Sk_3);
   2604   1.1  christos   post_wait_for_ACC (cpu, out_ACC40Uk);
   2605   1.1  christos   post_wait_for_ACC (cpu, ACC40Uk_1);
   2606   1.1  christos   post_wait_for_ACC (cpu, ACC40Uk_2);
   2607   1.1  christos   post_wait_for_ACC (cpu, ACC40Uk_3);
   2608   1.1  christos 
   2609   1.1  christos   /* Restore the busy cycles of the registers we used.  */
   2610   1.1  christos   restore_float_register_busy_for_media (cpu, in_FRi, 2, in_FRj, 2, -1, 1);
   2611   1.1  christos   restore_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Sk, 4);
   2612   1.1  christos   restore_acc_busy_for_mmac (cpu, -1, 1, out_ACC40Uk, 4);
   2613   1.1  christos 
   2614   1.1  christos   /* The latency of the output register will be at least the latency of the
   2615   1.1  christos      other inputs.  Once initiated, post-processing will take 1 cycle.  */
   2616   1.1  christos   if (out_ACC40Sk >= 0)
   2617   1.1  christos     {
   2618   1.1  christos       update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
   2619   1.1  christos 
   2620   1.1  christos       set_use_is_acc_mmac (cpu, out_ACC40Sk);
   2621   1.1  christos       if (ACC40Sk_1 >= 0)
   2622   1.1  christos 	{
   2623   1.1  christos 	  update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
   2624   1.1  christos 
   2625   1.1  christos 	  set_use_is_acc_mmac (cpu, ACC40Sk_1);
   2626   1.1  christos 	}
   2627   1.1  christos       if (ACC40Sk_2 >= 0)
   2628   1.1  christos 	{
   2629   1.1  christos 	  update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
   2630   1.1  christos 
   2631   1.1  christos 	  set_use_is_acc_mmac (cpu, ACC40Sk_2);
   2632   1.1  christos 	}
   2633   1.1  christos       if (ACC40Sk_3 >= 0)
   2634   1.1  christos 	{
   2635   1.1  christos 	  update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
   2636   1.1  christos 
   2637   1.1  christos 	  set_use_is_acc_mmac (cpu, ACC40Sk_3);
   2638   1.1  christos 	}
   2639   1.1  christos     }
   2640   1.1  christos   else if (out_ACC40Uk >= 0)
   2641   1.1  christos     {
   2642   1.1  christos       update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
   2643   1.1  christos 
   2644   1.1  christos       set_use_is_acc_mmac (cpu, out_ACC40Uk);
   2645   1.1  christos       if (ACC40Uk_1 >= 0)
   2646   1.1  christos 	{
   2647   1.1  christos 	  update_ACC_latency (cpu, ACC40Uk_1, ps->post_wait + 1);
   2648   1.1  christos 
   2649   1.1  christos 	  set_use_is_acc_mmac (cpu, ACC40Uk_1);
   2650   1.1  christos 	}
   2651   1.1  christos       if (ACC40Uk_2 >= 0)
   2652   1.1  christos 	{
   2653   1.1  christos 	  update_ACC_latency (cpu, ACC40Uk_2, ps->post_wait + 1);
   2654   1.1  christos 
   2655   1.1  christos 	  set_use_is_acc_mmac (cpu, ACC40Uk_2);
   2656   1.1  christos 	}
   2657   1.1  christos       if (ACC40Uk_3 >= 0)
   2658   1.1  christos 	{
   2659   1.1  christos 	  update_ACC_latency (cpu, ACC40Uk_3, ps->post_wait + 1);
   2660   1.1  christos 
   2661   1.1  christos 	  set_use_is_acc_mmac (cpu, ACC40Uk_3);
   2662   1.1  christos 	}
   2663   1.1  christos     }
   2664   1.1  christos 
   2665   1.1  christos   /* the floating point unit resource has a latency of 3 cycles  */
   2666   1.1  christos   update_float_resource_latency (cpu, slot, cycles + 3);
   2667   1.1  christos 
   2668   1.1  christos   return cycles;
   2669   1.1  christos }
   2670   1.1  christos 
   2671   1.1  christos #endif /* WITH_PROFILE_MODEL_P */
   2672