Blame sim/frv/pipeline.c

Packit 7cb7d8
/* frv vliw model.
Packit 7cb7d8
   Copyright (C) 1999-2018 Free Software Foundation, Inc.
Packit 7cb7d8
   Contributed by Red Hat.
Packit 7cb7d8
Packit 7cb7d8
This file is part of the GNU simulators.
Packit 7cb7d8
Packit 7cb7d8
This program is free software; you can redistribute it and/or modify
Packit 7cb7d8
it under the terms of the GNU General Public License as published by
Packit 7cb7d8
the Free Software Foundation; either version 3 of the License, or
Packit 7cb7d8
(at your option) any later version.
Packit 7cb7d8
Packit 7cb7d8
This program is distributed in the hope that it will be useful,
Packit 7cb7d8
but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7cb7d8
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 7cb7d8
GNU General Public License for more details.
Packit 7cb7d8
Packit 7cb7d8
You should have received a copy of the GNU General Public License
Packit 7cb7d8
along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 7cb7d8
Packit 7cb7d8
#define WANT_CPU frvbf
Packit 7cb7d8
#define WANT_CPU_FRVBF
Packit 7cb7d8
Packit 7cb7d8
#include "sim-main.h"
Packit 7cb7d8
Packit 7cb7d8
/* Simulator specific vliw related functions.  Additional vliw related
Packit 7cb7d8
   code used by both the simulator and the assembler is in frv.opc.  */
Packit 7cb7d8
Packit 7cb7d8
int insns_in_slot[UNIT_NUM_UNITS] = {0};
Packit 7cb7d8
Packit 7cb7d8
void
Packit 7cb7d8
frv_vliw_setup_insn (SIM_CPU *current_cpu, const CGEN_INSN *insn)
Packit 7cb7d8
{
Packit 7cb7d8
  FRV_VLIW *vliw;
Packit 7cb7d8
  int index;
Packit 7cb7d8
Packit 7cb7d8
  /* Always clear the NE index which indicates the target register
Packit 7cb7d8
     of a non excepting insn. This will be reset by the insn if
Packit 7cb7d8
     necessary.  */
Packit 7cb7d8
  frv_interrupt_state.ne_index = NE_NOFLAG;
Packit 7cb7d8
Packit 7cb7d8
  vliw = CPU_VLIW (current_cpu);
Packit 7cb7d8
  index = vliw->next_slot - 1;
Packit 7cb7d8
  if (frv_is_float_insn (insn))
Packit 7cb7d8
    {
Packit 7cb7d8
      /* If the insn is to be added and is a floating point insn and
Packit 7cb7d8
	 it is the first floating point insn in the vliw, then clear
Packit 7cb7d8
	 FSR0.FTT.  */
Packit 7cb7d8
      int i;
Packit 7cb7d8
      for (i = 0; i < index; ++i)
Packit 7cb7d8
	if (frv_is_float_major (vliw->major[i], vliw->mach))
Packit 7cb7d8
	  break; /* found float insn.  */
Packit 7cb7d8
      if (i >= index)
Packit 7cb7d8
	{
Packit 7cb7d8
	  SI fsr0 = GET_FSR (0);
Packit 7cb7d8
	  SET_FSR_FTT (fsr0, FTT_NONE);
Packit 7cb7d8
	  SET_FSR (0, fsr0);
Packit 7cb7d8
	}
Packit 7cb7d8
    }
Packit 7cb7d8
  else if (frv_is_media_insn (insn))
Packit 7cb7d8
    {
Packit 7cb7d8
      /* Clear the appropriate MSR fields depending on which slot
Packit 7cb7d8
	 this insn is in.  */
Packit 7cb7d8
      CGEN_ATTR_VALUE_ENUM_TYPE preserve_ovf;
Packit 7cb7d8
      SI msr0 = GET_MSR (0);
Packit 7cb7d8
Packit 7cb7d8
      preserve_ovf = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_PRESERVE_OVF);
Packit 7cb7d8
      if ((*vliw->current_vliw)[index] == UNIT_FM0)
Packit 7cb7d8
	{
Packit 7cb7d8
	  if (! preserve_ovf)
Packit 7cb7d8
	    {
Packit 7cb7d8
	      /* Clear MSR0.OVF and MSR0.SIE.  */
Packit 7cb7d8
	      CLEAR_MSR_SIE (msr0);
Packit 7cb7d8
	      CLEAR_MSR_OVF (msr0);
Packit 7cb7d8
	    }
Packit 7cb7d8
	}
Packit 7cb7d8
      else
Packit 7cb7d8
	{
Packit 7cb7d8
	  if (! preserve_ovf)
Packit 7cb7d8
	    {
Packit 7cb7d8
	      /* Clear MSR1.OVF and MSR1.SIE.  */
Packit 7cb7d8
	      SI msr1 = GET_MSR (1);
Packit 7cb7d8
	      CLEAR_MSR_SIE (msr1);
Packit 7cb7d8
	      CLEAR_MSR_OVF (msr1);
Packit 7cb7d8
	      SET_MSR (1, msr1);
Packit 7cb7d8
	    }
Packit 7cb7d8
	}
Packit 7cb7d8
      SET_MSR (0, msr0);
Packit 7cb7d8
    } /* Insn is a media insns.  */
Packit 7cb7d8
  COUNT_INSNS_IN_SLOT ((*vliw->current_vliw)[index]);
Packit 7cb7d8
}
Packit 7cb7d8