head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.4
	netbsd-11-0-RC3:1.1.1.4
	gdb-17-1:1.1.1.4
	netbsd-11-0-RC2:1.1.1.4
	netbsd-11-0-RC1:1.1.1.4
	gdb-16-3:1.1.1.4
	perseant-exfatfs-base-20250801:1.1.1.4
	netbsd-11:1.1.1.4.0.4
	netbsd-11-base:1.1.1.4
	netbsd-10-1-RELEASE:1.1.1.3
	gdb-15-1:1.1.1.4
	perseant-exfatfs-base-20240630:1.1.1.4
	perseant-exfatfs:1.1.1.4.0.2
	perseant-exfatfs-base:1.1.1.4
	netbsd-8-3-RELEASE:1.1.1.2
	netbsd-9-4-RELEASE:1.1.1.3
	netbsd-10-0-RELEASE:1.1.1.3
	netbsd-10-0-RC6:1.1.1.3
	netbsd-10-0-RC5:1.1.1.3
	netbsd-10-0-RC4:1.1.1.3
	netbsd-10-0-RC3:1.1.1.3
	netbsd-10-0-RC2:1.1.1.3
	netbsd-10-0-RC1:1.1.1.3
	gdb-13-2:1.1.1.4
	netbsd-10:1.1.1.3.0.10
	netbsd-10-base:1.1.1.3
	netbsd-9-3-RELEASE:1.1.1.3
	cjep_sun2x-base1:1.1.1.3
	cjep_sun2x:1.1.1.3.0.8
	cjep_sun2x-base:1.1.1.3
	cjep_staticlib_x-base1:1.1.1.3
	netbsd-9-2-RELEASE:1.1.1.3
	cjep_staticlib_x:1.1.1.3.0.6
	cjep_staticlib_x-base:1.1.1.3
	netbsd-9-1-RELEASE:1.1.1.3
	GDB-11-0-50-20200914-git:1.1.1.3
	phil-wifi-20200421:1.1.1.3
	phil-wifi-20200411:1.1.1.3
	is-mlppp:1.1.1.3.0.4
	is-mlppp-base:1.1.1.3
	phil-wifi-20200406:1.1.1.3
	netbsd-8-2-RELEASE:1.1.1.2
	netbsd-9-0-RELEASE:1.1.1.3
	netbsd-9-0-RC2:1.1.1.3
	netbsd-9-0-RC1:1.1.1.3
	phil-wifi-20191119:1.1.1.3
	netbsd-9:1.1.1.3.0.2
	netbsd-9-base:1.1.1.3
	phil-wifi-20190609:1.1.1.3
	netbsd-8-1-RELEASE:1.1.1.2
	gdb-8-3:1.1.1.3
	netbsd-8-1-RC1:1.1.1.2
	pgoyette-compat-merge-20190127:1.1.1.2
	pgoyette-compat-20190127:1.1.1.2
	pgoyette-compat-20190118:1.1.1.2
	pgoyette-compat-1226:1.1.1.2
	pgoyette-compat-1126:1.1.1.2
	pgoyette-compat-1020:1.1.1.2
	pgoyette-compat-0930:1.1.1.2
	pgoyette-compat-0906:1.1.1.2
	netbsd-7-2-RELEASE:1.1.1.2
	pgoyette-compat-0728:1.1.1.2
	netbsd-8-0-RELEASE:1.1.1.2
	phil-wifi:1.1.1.2.0.26
	phil-wifi-base:1.1.1.2
	pgoyette-compat-0625:1.1.1.2
	netbsd-8-0-RC2:1.1.1.2
	pgoyette-compat-0521:1.1.1.2
	pgoyette-compat-0502:1.1.1.2
	pgoyette-compat-0422:1.1.1.2
	netbsd-8-0-RC1:1.1.1.2
	pgoyette-compat-0415:1.1.1.2
	pgoyette-compat-0407:1.1.1.2
	pgoyette-compat-0330:1.1.1.2
	pgoyette-compat-0322:1.1.1.2
	pgoyette-compat-0315:1.1.1.2
	netbsd-7-1-2-RELEASE:1.1.1.2
	pgoyette-compat:1.1.1.2.0.24
	pgoyette-compat-base:1.1.1.2
	netbsd-7-1-1-RELEASE:1.1.1.2
	gdb-8-0-1:1.1.1.2
	matt-nb8-mediatek:1.1.1.2.0.22
	matt-nb8-mediatek-base:1.1.1.2
	perseant-stdc-iso10646:1.1.1.2.0.20
	perseant-stdc-iso10646-base:1.1.1.2
	netbsd-8:1.1.1.2.0.18
	netbsd-8-base:1.1.1.2
	prg-localcount2-base3:1.1.1.2
	prg-localcount2-base2:1.1.1.2
	prg-localcount2-base1:1.1.1.2
	prg-localcount2:1.1.1.2.0.16
	prg-localcount2-base:1.1.1.2
	pgoyette-localcount-20170426:1.1.1.2
	bouyer-socketcan-base1:1.1.1.2
	pgoyette-localcount-20170320:1.1.1.2
	netbsd-7-1:1.1.1.2.0.14
	netbsd-7-1-RELEASE:1.1.1.2
	netbsd-7-1-RC2:1.1.1.2
	netbsd-7-nhusb-base-20170116:1.1.1.2
	bouyer-socketcan:1.1.1.2.0.12
	bouyer-socketcan-base:1.1.1.2
	pgoyette-localcount-20170107:1.1.1.2
	netbsd-7-1-RC1:1.1.1.2
	pgoyette-localcount-20161104:1.1.1.2
	netbsd-7-0-2-RELEASE:1.1.1.2
	gdb-7-12:1.1.1.2
	localcount-20160914:1.1.1.2
	netbsd-7-nhusb:1.1.1.2.0.10
	netbsd-7-nhusb-base:1.1.1.2
	pgoyette-localcount-20160806:1.1.1.2
	pgoyette-localcount-20160726:1.1.1.2
	pgoyette-localcount:1.1.1.2.0.8
	pgoyette-localcount-base:1.1.1.2
	netbsd-7-0-1-RELEASE:1.1.1.2
	gdb-7-10-1:1.1.1.2
	netbsd-7-0:1.1.1.2.0.6
	netbsd-7-0-RELEASE:1.1.1.2
	gdb-7-9-1:1.1.1.2
	netbsd-7-0-RC3:1.1.1.2
	netbsd-7-0-RC2:1.1.1.2
	netbsd-7-0-RC1:1.1.1.2
	netbsd-6-0-6-RELEASE:1.1.1.1
	netbsd-6-1-5-RELEASE:1.1.1.1
	netbsd-7:1.1.1.2.0.4
	netbsd-7-base:1.1.1.2
	gdb-7-7-1:1.1.1.2
	yamt-pagecache-base9:1.1.1.2
	yamt-pagecache-tag8:1.1.1.1
	netbsd-6-1-4-RELEASE:1.1.1.1
	netbsd-6-0-5-RELEASE:1.1.1.1
	tls-earlyentropy:1.1.1.2.0.2
	tls-earlyentropy-base:1.1.1.2
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.2
	riastradh-drm2-base3:1.1.1.2
	netbsd-6-1-3-RELEASE:1.1.1.1
	netbsd-6-0-4-RELEASE:1.1.1.1
	gdb-7-6-1:1.1.1.2
	netbsd-6-1-2-RELEASE:1.1.1.1
	netbsd-6-0-3-RELEASE:1.1.1.1
	netbsd-6-1-1-RELEASE:1.1.1.1
	riastradh-drm2-base2:1.1.1.1
	riastradh-drm2-base1:1.1.1.1
	riastradh-drm2:1.1.1.1.0.12
	riastradh-drm2-base:1.1.1.1
	netbsd-6-1:1.1.1.1.0.16
	netbsd-6-0-2-RELEASE:1.1.1.1
	netbsd-6-1-RELEASE:1.1.1.1
	netbsd-6-1-RC4:1.1.1.1
	netbsd-6-1-RC3:1.1.1.1
	agc-symver:1.1.1.1.0.14
	agc-symver-base:1.1.1.1
	netbsd-6-1-RC2:1.1.1.1
	netbsd-6-1-RC1:1.1.1.1
	yamt-pagecache-base8:1.1.1.1
	netbsd-6-0-1-RELEASE:1.1.1.1
	yamt-pagecache-base7:1.1.1.1
	matt-nb6-plus-nbase:1.1.1.1
	yamt-pagecache-base6:1.1.1.1
	netbsd-6-0:1.1.1.1.0.10
	netbsd-6-0-RELEASE:1.1.1.1
	netbsd-6-0-RC2:1.1.1.1
	tls-maxphys:1.1.1.1.0.8
	tls-maxphys-base:1.1.1.2
	matt-nb6-plus:1.1.1.1.0.6
	matt-nb6-plus-base:1.1.1.1
	netbsd-6-0-RC1:1.1.1.1
	yamt-pagecache-base5:1.1.1.1
	yamt-pagecache-base4:1.1.1.1
	netbsd-6:1.1.1.1.0.4
	netbsd-6-base:1.1.1.1
	yamt-pagecache-base3:1.1.1.1
	yamt-pagecache-base2:1.1.1.1
	yamt-pagecache:1.1.1.1.0.2
	yamt-pagecache-base:1.1.1.1
	gdb-7-3-1:1.1.1.1
	FSF:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2011.09.24.20.06.28;	author christos;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2011.09.24.20.06.28;	author christos;	state Exp;
branches
	1.1.1.1.2.1
	1.1.1.1.8.1;
next	1.1.1.2;

1.1.1.2
date	2013.10.03.15.44.15;	author christos;	state Exp;
branches
	1.1.1.2.26.1;
next	1.1.1.3;
commitid	m91IYDmHTME7wR7x;

1.1.1.3
date	2019.05.26.21.01.53;	author christos;	state Exp;
branches;
next	1.1.1.4;
commitid	MDatjuvRsk0MXKoB;

1.1.1.4
date	2023.07.30.22.44.40;	author christos;	state Exp;
branches;
next	;
commitid	HEIv4Prd74m1wSyE;

1.1.1.1.2.1
date	2014.05.22.16.00.32;	author yamt;	state Exp;
branches;
next	;
commitid	SRuOnF9k1i4dcyBx;

1.1.1.1.8.1
date	2014.08.19.23.58.39;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.2.26.1
date	2019.06.10.21.58.31;	author christos;	state Exp;
branches;
next	;
commitid	jtc8rnCzWiEEHGqB;


desc
@@


1.1
log
@Initial revision
@
text
@/* Fujitsu FRV opcode support, for GNU Binutils.  -*- C -*-

   Copyright 2000, 2001, 2003, 2004, 2005, 2007, 2009
   Free Software Foundation, Inc.

   Contributed by Red Hat Inc; developed under contract from Fujitsu.

   This file is part of the GNU Binutils.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */


/* This file is an addendum to frv.cpu.  Heavy use of C code isn't
   appropriate in .cpu files, so it resides here.  This especially applies
   to assembly/disassembly where parsing/printing can be quite involved.
   Such things aren't really part of the specification of the cpu, per se,
   so .cpu files provide the general framework and .opc files handle the
   nitty-gritty details as necessary.

   Each section is delimited with start and end markers.

   <arch>-opc.h additions use: "-- opc.h"
   <arch>-opc.c additions use: "-- opc.c"
   <arch>-asm.c additions use: "-- asm.c"
   <arch>-dis.c additions use: "-- dis.c"
   <arch>-ibd.h additions use: "-- ibd.h".  */

/* -- opc.h */

#undef  CGEN_DIS_HASH_SIZE
#define CGEN_DIS_HASH_SIZE 128
#undef  CGEN_DIS_HASH
#define CGEN_DIS_HASH(buffer, value) (((value) >> 18) & 127)

/* Allows reason codes to be output when assembler errors occur.  */
#define CGEN_VERBOSE_ASSEMBLER_ERRORS

/* Vliw support.  */
#define FRV_VLIW_SIZE 8 /* fr550 has largest vliw size of 8.  */
#define PAD_VLIW_COMBO ,UNIT_NIL,UNIT_NIL,UNIT_NIL,UNIT_NIL

typedef CGEN_ATTR_VALUE_ENUM_TYPE VLIW_COMBO[FRV_VLIW_SIZE];

typedef struct
{
  int                    next_slot;
  int                    constraint_violation;
  unsigned long          mach;
  unsigned long          elf_flags;
  CGEN_ATTR_VALUE_ENUM_TYPE * unit_mapping;
  VLIW_COMBO *           current_vliw;
  CGEN_ATTR_VALUE_ENUM_TYPE   major[FRV_VLIW_SIZE];
  const CGEN_INSN *      insn[FRV_VLIW_SIZE];
} FRV_VLIW;

int frv_is_branch_major (CGEN_ATTR_VALUE_ENUM_TYPE, unsigned long);
int frv_is_float_major  (CGEN_ATTR_VALUE_ENUM_TYPE, unsigned long);
int frv_is_media_major  (CGEN_ATTR_VALUE_ENUM_TYPE, unsigned long);
int frv_is_branch_insn  (const CGEN_INSN *);
int frv_is_float_insn   (const CGEN_INSN *);
int frv_is_media_insn   (const CGEN_INSN *);
void frv_vliw_reset     (FRV_VLIW *, unsigned long, unsigned long);
int frv_vliw_add_insn   (FRV_VLIW *, const CGEN_INSN *);
int spr_valid           (long);
/* -- */

/* -- opc.c */
#include "elf/frv.h"
#include <stdio.h>

/* DEBUG appears below as argument of OP macro.  */
#undef DEBUG

/* Returns TRUE if {MAJOR,MACH} is a major branch of the FRV
   development tree.  */

bfd_boolean
frv_is_branch_major (CGEN_ATTR_VALUE_ENUM_TYPE major, unsigned long mach)
{
  switch (mach)
    {
    case bfd_mach_fr400:
      if (major >= FR400_MAJOR_B_1 && major <= FR400_MAJOR_B_6)
	return TRUE;
      break;
    case bfd_mach_fr450:
      if (major >= FR450_MAJOR_B_1 && major <= FR450_MAJOR_B_6)
	return TRUE;
      break;
    default:
      if (major >= FR500_MAJOR_B_1 && major <= FR500_MAJOR_B_6)
	return TRUE;
      break;
    }

  return FALSE;
}

/* Returns TRUE if {MAJOR,MACH} supports floating point insns.  */

bfd_boolean
frv_is_float_major (CGEN_ATTR_VALUE_ENUM_TYPE major, unsigned long mach)
{
  switch (mach)
    {
    case bfd_mach_fr400:
    case bfd_mach_fr450:
      return FALSE;
    default:
      if (major >= FR500_MAJOR_F_1 && major <= FR500_MAJOR_F_8)
	return TRUE;
      break;
    }

  return FALSE;
}

/* Returns TRUE if {MAJOR,MACH} supports media insns.  */

bfd_boolean
frv_is_media_major (CGEN_ATTR_VALUE_ENUM_TYPE major, unsigned long mach)
{
  switch (mach)
    {
    case bfd_mach_fr400:
      if (major >= FR400_MAJOR_M_1 && major <= FR400_MAJOR_M_2)
	return TRUE;
      break;
    case bfd_mach_fr450:
      if (major >= FR450_MAJOR_M_1 && major <= FR450_MAJOR_M_6)
	return TRUE;
      break;
    default:
      if (major >= FR500_MAJOR_M_1 && major <= FR500_MAJOR_M_8)
	return TRUE;
      break;
    }

  return FALSE;
}

bfd_boolean
frv_is_branch_insn (const CGEN_INSN *insn)
{
  if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR),
			   bfd_mach_fr400))
    return TRUE;
  if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR),
			   bfd_mach_fr450))
    return TRUE;
  if (frv_is_branch_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR),
			   bfd_mach_fr500))
    return TRUE;

  return FALSE;
}

bfd_boolean
frv_is_float_insn (const CGEN_INSN *insn)
{
  if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR),
			  bfd_mach_fr400))
    return TRUE;
  if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR),
			  bfd_mach_fr450))
    return TRUE;
  if (frv_is_float_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR),
			  bfd_mach_fr500))
    return TRUE;

  return FALSE;
}

bfd_boolean
frv_is_media_insn (const CGEN_INSN *insn)
{
  if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR),
			  bfd_mach_fr400))
    return TRUE;
  if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR),
			  bfd_mach_fr450))
    return TRUE;
  if (frv_is_media_major (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR),
			  bfd_mach_fr500))
    return TRUE;

  return FALSE;
}

/* This table represents the allowable packing for vliw insns for the fr400.
   The fr400 has only 2 vliw slots. Represent this by not allowing any insns
   in the extra slots.
   Subsets of any given row are also allowed.  */
static VLIW_COMBO fr400_allowed_vliw[] =
{
  /*  slot0       slot1       slot2       slot3    */
  {  UNIT_I0,    UNIT_I1,    UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_I0,    UNIT_FM0,   UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_I0,    UNIT_B0,    UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_FM0,   UNIT_FM1,   UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_FM0,   UNIT_B0,    UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_B0,    UNIT_NIL,   UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_C,     UNIT_NIL,   UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO }
};

/* This table represents the allowable packing for vliw insns for the fr500.
   The fr500 has only 4 vliw slots. Represent this by not allowing any insns
   in the extra slots.
   Subsets of any given row are also allowed.  */
static VLIW_COMBO fr500_allowed_vliw[] =
{
  /*  slot0       slot1       slot2       slot3    */
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1  PAD_VLIW_COMBO },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_B0   PAD_VLIW_COMBO },
  {  UNIT_I0,    UNIT_FM0,   UNIT_FM1,   UNIT_B0   PAD_VLIW_COMBO },
  {  UNIT_I0,    UNIT_FM0,   UNIT_B0,    UNIT_B1   PAD_VLIW_COMBO },
  {  UNIT_I0,    UNIT_I1,    UNIT_B0,    UNIT_B1   PAD_VLIW_COMBO },
  {  UNIT_I0,    UNIT_B0,    UNIT_B1,    UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_FM0,   UNIT_FM1,   UNIT_B0,    UNIT_B1   PAD_VLIW_COMBO },
  {  UNIT_FM0,   UNIT_B0,    UNIT_B1,    UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_C,     UNIT_NIL,   UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO },
  {  UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL  PAD_VLIW_COMBO }
};

/* This table represents the allowable packing for vliw insns for the fr550.
   Subsets of any given row are also allowed.  */
static VLIW_COMBO fr550_allowed_vliw[] =
{
  /*  slot0       slot1       slot2       slot3       slot4       slot5       slot6       slot7   */
  {  UNIT_I0,    UNIT_I1,    UNIT_I2,    UNIT_I3,    UNIT_B0,    UNIT_B1 ,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_I0,    UNIT_I1,    UNIT_I2,    UNIT_B0,    UNIT_B1 ,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_I0,    UNIT_I1,    UNIT_B0,    UNIT_B1 ,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_I0,    UNIT_B0,    UNIT_B1 ,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_I2,    UNIT_FM2,   UNIT_I3,    UNIT_FM3 },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_I2,    UNIT_FM2,   UNIT_I3,    UNIT_B0  },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_I2,    UNIT_FM2,   UNIT_FM3,   UNIT_B0  },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_I2,    UNIT_FM2,   UNIT_B0,    UNIT_B1  },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_I2,    UNIT_I3,    UNIT_B0,    UNIT_B1  },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_I2,    UNIT_B0,    UNIT_B1,    UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_FM2,   UNIT_FM3,   UNIT_B0,    UNIT_B1  },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_FM2,   UNIT_FM3,   UNIT_B0,    UNIT_B1  },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_FM2,   UNIT_B0,    UNIT_B1,    UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_FM1,   UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_I2,    UNIT_I3,    UNIT_B0,    UNIT_B1,    UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_I2,    UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_I1,    UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_FM1,   UNIT_FM2,   UNIT_FM3,   UNIT_B0,    UNIT_B1,    UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_FM1,   UNIT_FM2,   UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_FM1,   UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_I0,    UNIT_FM0,   UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_C,     UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_FM0,   UNIT_FM1,   UNIT_FM2,   UNIT_FM3,   UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL },
  {  UNIT_FM0,   UNIT_FM1,   UNIT_FM2,   UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_FM0,   UNIT_FM1,   UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_FM0,   UNIT_B0,    UNIT_B1,    UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL },
  {  UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL,   UNIT_NIL }
};

/* Some insns are assigned specialized implementation units which map to
   different actual implementation units on different machines.  These
   tables perform that mapping.  */
static CGEN_ATTR_VALUE_ENUM_TYPE fr400_unit_mapping[] =
{
/* unit in insn    actual unit */
/* NIL      */     UNIT_NIL,
/* I0       */     UNIT_I0,
/* I1       */     UNIT_I1,
/* I01      */     UNIT_I01, 
/* I2       */     UNIT_NIL, /* no I2 or I3 unit */
/* I3       */     UNIT_NIL,
/* IALL     */     UNIT_I01, /* only I0 and I1 units */
/* FM0      */     UNIT_FM0,
/* FM1      */     UNIT_FM1,
/* FM01     */     UNIT_FM01,
/* FM2      */     UNIT_NIL, /* no F2 or M2 units */
/* FM3      */     UNIT_NIL, /* no F3 or M3 units */
/* FMALL    */     UNIT_FM01,/* Only F0,F1,M0,M1 units */
/* FMLOW    */     UNIT_FM0, /* Only F0,M0 units */
/* B0       */     UNIT_B0,  /* branches only in B0 unit.  */
/* B1       */     UNIT_B0,
/* B01      */     UNIT_B0,
/* C        */     UNIT_C,
/* MULT-DIV */     UNIT_I0,  /* multiply and divide only in I0  unit.  */
/* IACC     */     UNIT_I01, /* iacc multiply       in I0 or I1 unit.  */
/* LOAD     */     UNIT_I0,  /* load                only in I0  unit.  */
/* STORE    */     UNIT_I0,  /* store               only in I0  unit.  */
/* SCAN     */     UNIT_I0,  /* scan                only in I0  unit.  */
/* DCPL     */     UNIT_C,   /* dcpl                only in C   unit.  */
/* MDUALACC */     UNIT_FM0, /* media dual acc insn only in FM0 unit.  */
/* MDCUTSSI */     UNIT_FM0, /* mdcutssi            only in FM0 unit.  */
/* MCLRACC-1*/     UNIT_FM0  /* mclracc,A==1   insn only in FM0 unit.  */
};

/* Some insns are assigned specialized implementation units which map to
   different actual implementation units on different machines.  These
   tables perform that mapping.  */
static CGEN_ATTR_VALUE_ENUM_TYPE fr450_unit_mapping[] =
{
/* unit in insn    actual unit */
/* NIL      */     UNIT_NIL,
/* I0       */     UNIT_I0,
/* I1       */     UNIT_I1,
/* I01      */     UNIT_I01, 
/* I2       */     UNIT_NIL, /* no I2 or I3 unit */
/* I3       */     UNIT_NIL,
/* IALL     */     UNIT_I01, /* only I0 and I1 units */
/* FM0      */     UNIT_FM0,
/* FM1      */     UNIT_FM1,
/* FM01     */     UNIT_FM01,
/* FM2      */     UNIT_NIL, /* no F2 or M2 units */
/* FM3      */     UNIT_NIL, /* no F3 or M3 units */
/* FMALL    */     UNIT_FM01,/* Only F0,F1,M0,M1 units */
/* FMLOW    */     UNIT_FM0, /* Only F0,M0 units */
/* B0       */     UNIT_B0,  /* branches only in B0 unit.  */
/* B1       */     UNIT_B0,
/* B01      */     UNIT_B0,
/* C        */     UNIT_C,
/* MULT-DIV */     UNIT_I0,  /* multiply and divide only in I0  unit.  */
/* IACC     */     UNIT_I01, /* iacc multiply       in I0 or I1 unit.  */
/* LOAD     */     UNIT_I0,  /* load                only in I0  unit.  */
/* STORE    */     UNIT_I0,  /* store               only in I0  unit.  */
/* SCAN     */     UNIT_I0,  /* scan                only in I0  unit.  */
/* DCPL     */     UNIT_I0,  /* dcpl                only in I0  unit.  */
/* MDUALACC */     UNIT_FM0, /* media dual acc insn only in FM0 unit.  */
/* MDCUTSSI */     UNIT_FM01, /* mdcutssi           in FM0 or FM1.  */
/* MCLRACC-1*/     UNIT_FM0  /* mclracc,A==1   insn only in FM0 unit.  */
};

static CGEN_ATTR_VALUE_ENUM_TYPE fr500_unit_mapping[] =
{
/* unit in insn    actual unit */
/* NIL      */     UNIT_NIL,
/* I0       */     UNIT_I0,
/* I1       */     UNIT_I1,
/* I01      */     UNIT_I01, 
/* I2       */     UNIT_NIL, /* no I2 or I3 unit */
/* I3       */     UNIT_NIL,
/* IALL     */     UNIT_I01, /* only I0 and I1 units */
/* FM0      */     UNIT_FM0,
/* FM1      */     UNIT_FM1,
/* FM01     */     UNIT_FM01,
/* FM2      */     UNIT_NIL, /* no F2 or M2 units */
/* FM3      */     UNIT_NIL, /* no F3 or M2 units */
/* FMALL    */     UNIT_FM01,/* Only F0,F1,M0,M1 units */
/* FMLOW    */     UNIT_FM0, /* Only F0,M0 units */
/* B0       */     UNIT_B0,
/* B1       */     UNIT_B1,
/* B01      */     UNIT_B01,
/* C        */     UNIT_C,
/* MULT-DIV */     UNIT_I01, /* multiply and divide in I0 or I1 unit.  */
/* IACC     */     UNIT_NIL, /* iacc multiply       not implemented */
/* LOAD     */     UNIT_I01, /* load                in I0 or I1 unit.  */
/* STORE    */     UNIT_I0,  /* store               only in I0 unit.  */
/* SCAN     */     UNIT_I01, /* scan                in I0 or I1 unit.  */
/* DCPL     */     UNIT_C,   /* dcpl                only in C unit.  */
/* MDUALACC */     UNIT_FM0, /* media dual acc insn only in FM0 unit.  */
/* MDCUTSSI */     UNIT_FM0, /* mdcutssi            only in FM0 unit.  */
/* MCLRACC-1*/     UNIT_FM01 /* mclracc,A==1 in FM0 or FM1 unit.  */
};

static CGEN_ATTR_VALUE_ENUM_TYPE fr550_unit_mapping[] =
{
/* unit in insn    actual unit */
/* NIL      */     UNIT_NIL,
/* I0       */     UNIT_I0,
/* I1       */     UNIT_I1,
/* I01      */     UNIT_I01, 
/* I2       */     UNIT_I2,
/* I3       */     UNIT_I3,
/* IALL     */     UNIT_IALL, 
/* FM0      */     UNIT_FM0,
/* FM1      */     UNIT_FM1,
/* FM01     */     UNIT_FM01,
/* FM2      */     UNIT_FM2,
/* FM3      */     UNIT_FM3,
/* FMALL    */     UNIT_FMALL,
/* FMLOW    */     UNIT_FM01, /* Only F0,F1,M0,M1 units */
/* B0       */     UNIT_B0,
/* B1       */     UNIT_B1,
/* B01      */     UNIT_B01,
/* C        */     UNIT_C,
/* MULT-DIV */     UNIT_I01,  /* multiply and divide in I0 or I1 unit.    */
/* IACC     */     UNIT_NIL,  /* iacc multiply       not implemented.     */
/* LOAD     */     UNIT_I01,  /* load                in I0 or I1 unit.    */
/* STORE    */     UNIT_I01,  /* store               in I0 or I1 unit.    */
/* SCAN     */     UNIT_IALL, /* scan                in any integer unit. */
/* DCPL     */     UNIT_I0,   /* dcpl                only in I0 unit.     */
/* MDUALACC */     UNIT_FMALL,/* media dual acc insn in all media units   */
/* MDCUTSSI */     UNIT_FM01, /* mdcutssi            in FM0 or FM1 unit.  */
/* MCLRACC-1*/     UNIT_FM01  /* mclracc,A==1 in FM0 or FM1 unit.         */
};

void
frv_vliw_reset (FRV_VLIW *vliw, unsigned long mach, unsigned long elf_flags)
{
  vliw->next_slot = 0;
  vliw->constraint_violation = 0;
  vliw->mach = mach;
  vliw->elf_flags = elf_flags;

  switch (mach)
    {
    case bfd_mach_fr400:
      vliw->current_vliw = fr400_allowed_vliw;
      vliw->unit_mapping = fr400_unit_mapping;
      break;
    case bfd_mach_fr450:
      vliw->current_vliw = fr400_allowed_vliw;
      vliw->unit_mapping = fr450_unit_mapping;
      break;
    case bfd_mach_fr550:
      vliw->current_vliw = fr550_allowed_vliw;
      vliw->unit_mapping = fr550_unit_mapping;
      break;
    default:
      vliw->current_vliw = fr500_allowed_vliw;
      vliw->unit_mapping = fr500_unit_mapping;
      break;
    }
}

/* Return TRUE if unit1 is a match for unit2.
   Unit1 comes from the insn's UNIT attribute. unit2 comes from one of the
   *_allowed_vliw tables above.  */
static bfd_boolean
match_unit (FRV_VLIW *vliw,
	    CGEN_ATTR_VALUE_ENUM_TYPE unit1, CGEN_ATTR_VALUE_ENUM_TYPE unit2)
{
  /* Map any specialized implementation units to actual ones.  */
  unit1 = vliw->unit_mapping[unit1];

  if (unit1 == unit2)
    return TRUE;
  if (unit1 < unit2)
    return FALSE;

  switch (unit1)
    {
    case UNIT_I01:
    case UNIT_FM01:
    case UNIT_B01:
      /* The 01 versions of these units are within 2 enums of the 0 or 1
	 versions.  */
      if (unit1 - unit2 <= 2)
	return TRUE;
      break;
    case UNIT_IALL:
    case UNIT_FMALL:
      /* The ALL versions of these units are within 5 enums of the 0, 1, 2 or 3
	 versions.  */
      if (unit1 - unit2 <= 5)
	return TRUE;
      break;
    default:
      break;
    }

  return FALSE;
}

/* Return TRUE if the vliws match, FALSE otherwise.  */

static bfd_boolean
match_vliw (VLIW_COMBO *vliw1, VLIW_COMBO *vliw2, int vliw_size)
{
  int i;

  for (i = 0; i < vliw_size; ++i)
    if ((*vliw1)[i] != (*vliw2)[i])
      return FALSE;

  return TRUE;
}

/* Find the next vliw vliw in the table that can accomodate the new insn.
   If one is found then return it. Otherwise return NULL.  */

static VLIW_COMBO *
add_next_to_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_ENUM_TYPE unit)
{
  int           next    = vliw->next_slot;
  VLIW_COMBO    *current = vliw->current_vliw;
  VLIW_COMBO    *potential;

  if (next <= 0)
    {
      fprintf (stderr, "frv-opc.c line %d: bad vliw->next_slot value.\n",
	       __LINE__);
      abort (); /* Should never happen.  */
    }

  /* The table is sorted by units allowed within slots, so vliws with
     identical starting sequences are together.  */
  potential = current;
  do
    {
      if (match_unit (vliw, unit, (*potential)[next]))
	return potential;
      ++potential;
    }
  while (match_vliw (potential, current, next));

  return NULL;
}

/* Look for the given major insn type in the given vliw.
   Returns TRUE if found, FALSE otherwise.  */

static bfd_boolean
find_major_in_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_ENUM_TYPE major)
{
  int i;

  for (i = 0; i < vliw->next_slot; ++i)
    if (vliw->major[i] == major)
      return TRUE;

  return FALSE;
}

/* Check for constraints between the insns in the vliw due to major insn
   types.  */

static bfd_boolean
fr400_check_insn_major_constraints (FRV_VLIW *vliw, CGEN_ATTR_VALUE_ENUM_TYPE major)
{
  /* In the cpu file, all media insns are represented as being allowed in
     both media units. This makes it easier since this is the case for fr500.
     Catch the invalid combinations here.  Insns of major class FR400_MAJOR_M_2
     cannot coexist with any other media insn in a vliw.  */
  switch (major)
    {
    case FR400_MAJOR_M_2:
      return ! find_major_in_vliw (vliw, FR400_MAJOR_M_1)
	&&   ! find_major_in_vliw (vliw, FR400_MAJOR_M_2);
    case FR400_MAJOR_M_1:
      return ! find_major_in_vliw (vliw, FR400_MAJOR_M_2);
    default:
      break;
    }
  return TRUE;
}

static bfd_boolean
fr450_check_insn_major_constraints (FRV_VLIW *vliw, CGEN_ATTR_VALUE_ENUM_TYPE major)
{
  CGEN_ATTR_VALUE_ENUM_TYPE other_major;

  /* Our caller guarantees there's at least one other instruction.  */
  other_major = CGEN_INSN_ATTR_VALUE (vliw->insn[0], CGEN_INSN_FR450_MAJOR);

  /* (M4, M5) and (M4, M6) are allowed.  */
  if (other_major == FR450_MAJOR_M_4)
    if (major == FR450_MAJOR_M_5 || major == FR450_MAJOR_M_6)
      return TRUE;

  /* Otherwise, instructions in even-numbered media categories cannot be
     executed in parallel with other media instructions.  */
  switch (major)
    {
    case FR450_MAJOR_M_2:
    case FR450_MAJOR_M_4:
    case FR450_MAJOR_M_6:
      return !(other_major >= FR450_MAJOR_M_1
	       && other_major <= FR450_MAJOR_M_6);

    case FR450_MAJOR_M_1:
    case FR450_MAJOR_M_3:
    case FR450_MAJOR_M_5:
      return !(other_major == FR450_MAJOR_M_2
	       || other_major == FR450_MAJOR_M_4
	       || other_major == FR450_MAJOR_M_6);

    default:
      return TRUE;
    }
}

static bfd_boolean
find_unit_in_vliw (FRV_VLIW *vliw, CGEN_ATTR_VALUE_ENUM_TYPE unit)
{
  int i;

  for (i = 0; i < vliw->next_slot; ++i)
    if (CGEN_INSN_ATTR_VALUE (vliw->insn[i], CGEN_INSN_UNIT) == unit)
      return TRUE;

  return FALSE; /* Not found.  */
}

static bfd_boolean
find_major_in_slot (FRV_VLIW *vliw,
		    CGEN_ATTR_VALUE_ENUM_TYPE major,
		    CGEN_ATTR_VALUE_ENUM_TYPE slot)
{
  int i;

  for (i = 0; i < vliw->next_slot; ++i)
    if (vliw->major[i] == major && (*vliw->current_vliw)[i] == slot)
      return TRUE;

  return FALSE;
}

static bfd_boolean
fr550_find_media_in_vliw (FRV_VLIW *vliw)
{
  int i;

  for (i = 0; i < vliw->next_slot; ++i)
    {
      if (vliw->major[i] < FR550_MAJOR_M_1 || vliw->major[i] > FR550_MAJOR_M_5)
	continue;

      /* Found a media insn, however, MNOP and MCLRACC don't count.  */
      if (CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_MNOP
	  || CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_MCLRACC_0
	  || CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_MCLRACC_1)
	continue;

      return TRUE; /* Found one.  */
    }

  return FALSE;
}

static bfd_boolean
fr550_find_float_in_vliw (FRV_VLIW *vliw)
{
  int i;

  for (i = 0; i < vliw->next_slot; ++i)
    {
      if (vliw->major[i] < FR550_MAJOR_F_1 || vliw->major[i] > FR550_MAJOR_F_4)
	continue;

      /* Found a floating point insn, however, FNOP doesn't count.  */
      if (CGEN_INSN_NUM (vliw->insn[i]) == FRV_INSN_FNOP)
	continue;

      return TRUE; /* Found one.  */
    }

  return FALSE;
}

static bfd_boolean
fr550_check_insn_major_constraints (FRV_VLIW *vliw,
				    CGEN_ATTR_VALUE_ENUM_TYPE major,
				    const CGEN_INSN *insn)
{
  CGEN_ATTR_VALUE_ENUM_TYPE unit;
  CGEN_ATTR_VALUE_ENUM_TYPE slot = (*vliw->current_vliw)[vliw->next_slot];
  switch (slot)
    {
    case UNIT_I2:
      /* If it's a store, then there must be another store in I1 */
      unit = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_UNIT);
      if (unit == UNIT_STORE)
	return find_unit_in_vliw (vliw, UNIT_STORE);
      break;
    case UNIT_FM2:
    case UNIT_FM3:
      /* Floating point insns other than FNOP in slot f2 or f3 cannot coexist
	 with media insns.  */
      if (major >= FR550_MAJOR_F_1 && major <= FR550_MAJOR_F_4
	  && CGEN_INSN_NUM (insn) != FRV_INSN_FNOP)
	return ! fr550_find_media_in_vliw (vliw);
      /* Media insns other than MNOP in slot m2 or m3 cannot coexist with
	 floating point insns.  */
      if (major >= FR550_MAJOR_M_1 && major <= FR550_MAJOR_M_5
	  && CGEN_INSN_NUM (insn) != FRV_INSN_MNOP)
	return ! fr550_find_float_in_vliw (vliw);
      /* F-2 in slot f2 or f3 cannot coexist with F-2 or F-4 in slot f1 or f2
	 respectively.  */
      if (major == FR550_MAJOR_F_2)
	return ! find_major_in_slot (vliw, FR550_MAJOR_F_2,
				     slot - (UNIT_FM2 - UNIT_FM0))
	  &&   ! find_major_in_slot (vliw, FR550_MAJOR_F_4,
				     slot - (UNIT_FM2 - UNIT_FM0));
      /* M-2 or M-5 in slot m2 or m3 cannot coexist with M-2 in slot m1 or m2
	 respectively.  */
      if (major == FR550_MAJOR_M_2 || major == FR550_MAJOR_M_5)
	return ! find_major_in_slot (vliw, FR550_MAJOR_M_2,
				     slot - (UNIT_FM2 - UNIT_FM0));
      /* M-4 in slot m2 or m3 cannot coexist with M-4 in slot m1 or m2
	 respectively.  */
      if (major == FR550_MAJOR_M_4)
	return ! find_major_in_slot (vliw, FR550_MAJOR_M_4,
				     slot - (UNIT_FM2 - UNIT_FM0));
      break;
    default:
      break;
    }
  return TRUE; /* All OK.  */
}

static bfd_boolean
fr500_check_insn_major_constraints (FRV_VLIW *vliw, CGEN_ATTR_VALUE_ENUM_TYPE major)
{
  /* TODO: A table might be faster for some of the more complex instances
     here.  */
  switch (major)
    {
    case FR500_MAJOR_I_1:
    case FR500_MAJOR_I_4:
    case FR500_MAJOR_I_5:
    case FR500_MAJOR_I_6:
    case FR500_MAJOR_B_1:
    case FR500_MAJOR_B_2:
    case FR500_MAJOR_B_3:
    case FR500_MAJOR_B_4:
    case FR500_MAJOR_B_5:
    case FR500_MAJOR_B_6:
    case FR500_MAJOR_F_4:
    case FR500_MAJOR_F_8:
    case FR500_MAJOR_M_8:
      return TRUE; /* OK */
    case FR500_MAJOR_I_2:
      /* Cannot coexist with I-3 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_I_3);
    case FR500_MAJOR_I_3:
      /* Cannot coexist with I-2 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_I_2);
    case FR500_MAJOR_F_1:
    case FR500_MAJOR_F_2:
      /* Cannot coexist with F-5, F-6, or M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
    case FR500_MAJOR_F_3:
      /* Cannot coexist with F-7, or M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_F_7)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
    case FR500_MAJOR_F_5:
      /* Cannot coexist with F-1, F-2, F-6, F-7, or M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_F_1)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_2)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_7)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
    case FR500_MAJOR_F_6:
      /* Cannot coexist with F-1, F-2, F-5, F-6, or M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_F_1)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_2)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
    case FR500_MAJOR_F_7:
      /* Cannot coexist with F-3, F-5, F-7, or M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_F_3)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_7)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
    case FR500_MAJOR_M_1:
      /* Cannot coexist with M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
    case FR500_MAJOR_M_2:
    case FR500_MAJOR_M_3:
      /* Cannot coexist with M-5, M-6 or M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
    case FR500_MAJOR_M_4:
      /* Cannot coexist with M-6 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_M_6);
    case FR500_MAJOR_M_5:
      /* Cannot coexist with M-2, M-3, M-5, M-6  or M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_M_2)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_3)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
    case FR500_MAJOR_M_6:
      /* Cannot coexist with M-2, M-3, M-4, M-5, M-6  or M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_M_2)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_3)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_4)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_7);
    case FR500_MAJOR_M_7:
      /* Cannot coexist with M-1, M-2, M-3, M-5, M-6  or M-7 insn.  */
      return ! find_major_in_vliw (vliw, FR500_MAJOR_M_1)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_2)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_3)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_5)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_6)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_M_7)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_1)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_2)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_3)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_5)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_6)
	&&   ! find_major_in_vliw (vliw, FR500_MAJOR_F_7);
    default:
      fprintf (stderr, "frv-opc.c, line %d: bad major code, aborting.\n",
	       __LINE__);
      abort ();
      break;
    }
  return TRUE;
}

static bfd_boolean
check_insn_major_constraints (FRV_VLIW *vliw,
			      CGEN_ATTR_VALUE_ENUM_TYPE major,
			      const CGEN_INSN *insn)
{
  switch (vliw->mach)
    {
    case bfd_mach_fr400:
      return fr400_check_insn_major_constraints (vliw, major);

    case bfd_mach_fr450:
      return fr450_check_insn_major_constraints (vliw, major);

    case bfd_mach_fr550:
      return fr550_check_insn_major_constraints (vliw, major, insn);

    default:
      return fr500_check_insn_major_constraints (vliw, major);
    }
}

/* Add in insn to the VLIW vliw if possible.
   Return 0 if successful, non-zero otherwise.  */

int
frv_vliw_add_insn (FRV_VLIW *vliw, const CGEN_INSN *insn)
{
  int slot_index;
  CGEN_ATTR_VALUE_ENUM_TYPE major;
  CGEN_ATTR_VALUE_ENUM_TYPE unit;
  VLIW_COMBO *new_vliw;

  if (vliw->constraint_violation || CGEN_INSN_INVALID_P (insn))
    return 1;

  slot_index = vliw->next_slot;
  if (slot_index >= FRV_VLIW_SIZE)
    return 1;

  unit = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_UNIT);
  if (unit == UNIT_NIL)
    {
      fprintf (stderr, "frv-opc.c line %d: bad insn unit.\n",
	       __LINE__);
      abort (); /* No UNIT specified for this insn in frv.cpu.  */
    }

  switch (vliw->mach)
    {
    case bfd_mach_fr400:
      major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR400_MAJOR);
      break;
    case bfd_mach_fr450:
      major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR450_MAJOR);
      break;
    case bfd_mach_fr550:
      major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR550_MAJOR);
      break;
    default:
      major = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_FR500_MAJOR);
      break;
    }

  if (slot_index <= 0)
    {
      /* Any insn can be added to slot 0.  */
      while (! match_unit (vliw, unit, (*vliw->current_vliw)[0]))
	++vliw->current_vliw;
      vliw->major[0] = major;
      vliw->insn[0] = insn;
      vliw->next_slot = 1;
      return 0;
    }

  /* If there are already insns in the vliw(s) check to see that
     this one can be added.  Do this by finding an allowable vliw
     combination that can accept the new insn.  */
  if (! (vliw->elf_flags & EF_FRV_NOPACK))
    {
      new_vliw = add_next_to_vliw (vliw, unit);
      if (new_vliw && check_insn_major_constraints (vliw, major, insn))
	{
	  vliw->current_vliw = new_vliw;
	  vliw->major[slot_index] = major;
	  vliw->insn[slot_index] = insn;
	  vliw->next_slot++;
	  return 0;
	}

      /* The frv machine supports all packing conbinations.  If we fail,
	 to add the insn, then it could not be handled as if it was the fr500.
	 Just return as if it was handled ok.  */
      if (vliw->mach == bfd_mach_frv)
	return 0;
    }

  vliw->constraint_violation = 1;
  return 1;
}

bfd_boolean
spr_valid (long regno)
{
  if (regno < 0)     return FALSE;
  if (regno <= 4095) return TRUE;
  return FALSE;
}
/* -- */

/* -- asm.c */
inline static const char *
parse_symbolic_address (CGEN_CPU_DESC cd,
			const char **strp,
			int opindex,
			int opinfo,
			enum cgen_parse_operand_result *resultp,
			bfd_vma *valuep)
{
  enum cgen_parse_operand_result result_type;
  const char *errmsg = (* cd->parse_operand_fn)
    (cd, CGEN_PARSE_OPERAND_SYMBOLIC, strp, opindex, opinfo,
     &result_type, valuep);

  if (errmsg == NULL
      && result_type != CGEN_PARSE_OPERAND_RESULT_QUEUED)
    return "symbolic expression required";

  if (resultp)
    *resultp = result_type;

  return errmsg;
}

static const char *
parse_ldd_annotation (CGEN_CPU_DESC cd,
		      const char **strp,
		      int opindex,
		      unsigned long *valuep)
{
  const char *errmsg;
  enum cgen_parse_operand_result result_type;
  bfd_vma value;

  if (**strp == '#' || **strp == '%')
    {
      if (strncasecmp (*strp + 1, "tlsdesc(", 8) == 0)
	{
	  *strp += 9;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_TLSDESC_RELAX,
					   &result_type, &value);
	  if (**strp != ')')
	    return "missing ')'";
	  if (valuep)
	    *valuep = value;
	  ++*strp;
	  if (errmsg)
	    return errmsg;
	}
    }
  
  while (**strp == ' ' || **strp == '\t')
    ++*strp;
  
  if (**strp != '@@')
    return "missing `@@'";

  ++*strp;

  return NULL;
}

static const char *
parse_call_annotation (CGEN_CPU_DESC cd,
		       const char **strp,
		       int opindex,
		       unsigned long *valuep)
{
  const char *errmsg;
  enum cgen_parse_operand_result result_type;
  bfd_vma value;

  if (**strp == '#' || **strp == '%')
    {
      if (strncasecmp (*strp + 1, "gettlsoff(", 10) == 0)
	{
	  *strp += 11;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GETTLSOFF_RELAX,
					   &result_type, &value);
	  if (**strp != ')')
	    return "missing ')'";
	  if (valuep)
	    *valuep = value;
	  ++*strp;
	  if (errmsg)
	    return errmsg;
	}
    }
  
  while (**strp == ' ' || **strp == '\t')
    ++*strp;
  
  if (**strp != '@@')
    return "missing `@@'";

  ++*strp;

  return NULL;
}

static const char *
parse_ld_annotation (CGEN_CPU_DESC cd,
		     const char **strp,
		     int opindex,
		     unsigned long *valuep)
{
  const char *errmsg;
  enum cgen_parse_operand_result result_type;
  bfd_vma value;

  if (**strp == '#' || **strp == '%')
    {
      if (strncasecmp (*strp + 1, "tlsoff(", 7) == 0)
	{
	  *strp += 8;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_TLSOFF_RELAX,
					   &result_type, &value);
	  if (**strp != ')')
	    return "missing ')'";
	  if (valuep)
	    *valuep = value;
	  ++*strp;
	  if (errmsg)
	    return errmsg;
	}
    }
  
  while (**strp == ' ' || **strp == '\t')
    ++*strp;
  
  if (**strp != '@@')
    return "missing `@@'";

  ++*strp;

  return NULL;
}

static const char *
parse_ulo16 (CGEN_CPU_DESC cd,
	     const char **strp,
	     int opindex,
	     unsigned long *valuep)
{
  const char *errmsg;
  enum cgen_parse_operand_result result_type;
  bfd_vma value;
 
  if (**strp == '#' || **strp == '%')
    {
      if (strncasecmp (*strp + 1, "lo(", 3) == 0)
	{
	  *strp += 4;
	  errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_LO16,
				       & result_type, & value);
	  if (**strp != ')')
	    return "missing `)'";
	  ++*strp;
	  if (errmsg == NULL
	      && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
	    value &= 0xffff;
	  *valuep = value;
	  return errmsg;
	}
      if (strncasecmp (*strp + 1, "gprello(", 8) == 0)
	{
	  *strp += 9;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GPRELLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotlo(", 6) == 0)
	{
	  *strp += 7;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotfuncdesclo(", 14) == 0)
	{
	  *strp += 15;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOTLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotofflo(", 9) == 0)
	{
	  *strp += 10;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTOFFLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotofffuncdesclo(", 17) == 0)
	{
	  *strp += 18;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOTOFFLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsdesclo(", 13) == 0)
	{
	  *strp += 14;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSDESCLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "tlsmofflo(", 10) == 0)
	{
	  *strp += 11;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_TLSMOFFLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsofflo(", 12) == 0)
	{
	  *strp += 13;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSOFFLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
    }
  return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
}

static const char *
parse_uslo16 (CGEN_CPU_DESC cd,
	      const char **strp,
	      int opindex,
	      signed long *valuep)
{
  const char *errmsg;
  enum cgen_parse_operand_result result_type;
  bfd_vma value;
 
  if (**strp == '#' || **strp == '%')
    {
      if (strncasecmp (*strp + 1, "lo(", 3) == 0)
	{
	  *strp += 4;
	  errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_LO16,
				       & result_type, & value);
	  if (**strp != ')')
	    return "missing `)'";
	  ++*strp;
	  if (errmsg == NULL
	      && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
	    value &= 0xffff;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gprello(", 8) == 0)
	{
	  *strp += 9;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GPRELLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotlo(", 6) == 0)
	{
	  *strp += 7;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotfuncdesclo(", 14) == 0)
	{
	  *strp += 15;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOTLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotofflo(", 9) == 0)
	{
	  *strp += 10;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTOFFLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotofffuncdesclo(", 17) == 0)
	{
	  *strp += 18;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOTOFFLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsdesclo(", 13) == 0)
	{
	  *strp += 14;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSDESCLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "tlsmofflo(", 10) == 0)
	{
	  *strp += 11;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_TLSMOFFLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsofflo(", 12) == 0)
	{
	  *strp += 13;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSOFFLO,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
    }
  return cgen_parse_signed_integer (cd, strp, opindex, valuep);
}

static const char *
parse_uhi16 (CGEN_CPU_DESC cd,
	     const char **strp,
	     int opindex,
	     unsigned long *valuep)
{
  const char *errmsg;
  enum cgen_parse_operand_result result_type;
  bfd_vma value;
 
  if (**strp == '#' || **strp == '%')
    {
      if (strncasecmp (*strp + 1, "hi(", 3) == 0)
	{
	  *strp += 4;
	  errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_FRV_HI16,
				       & result_type, & value);
	  if (**strp != ')')
	    return "missing `)'";
	  ++*strp;
	  if (errmsg == NULL
	      && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
	    {
	      /* If bfd_vma is wider than 32 bits, but we have a sign-
		 or zero-extension, truncate it.  */
	      if (value >= - ((bfd_vma)1 << 31)
		  || value <= ((bfd_vma)1 << 31) - (bfd_vma)1)
		value &= (((bfd_vma)1 << 16) << 16) - 1;
	      value >>= 16;
	    }
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gprelhi(", 8) == 0)
	{
	  *strp += 9;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GPRELHI,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gothi(", 6) == 0)
	{
	  *strp += 7;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTHI,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotfuncdeschi(", 14) == 0)
	{
	  *strp += 15;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOTHI,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotoffhi(", 9) == 0)
	{
	  *strp += 10;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTOFFHI,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotofffuncdeschi(", 17) == 0)
	{
	  *strp += 18;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOTOFFHI,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsdeschi(", 13) == 0)
	{
	  *strp += 14;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSDESCHI,
					   &result_type, &value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "tlsmoffhi(", 10) == 0)
	{
	  *strp += 11;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_TLSMOFFHI,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsoffhi(", 12) == 0)
	{
	  *strp += 13;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSOFFHI,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
    }
  return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
}

static long
parse_register_number (const char **strp)
{
  int regno;

  if (**strp < '0' || **strp > '9')
    return -1; /* error */

  regno = **strp - '0';
  for (++*strp; **strp >= '0' && **strp <= '9'; ++*strp)
    regno = regno * 10 + (**strp - '0');

  return regno;
}

static const char *
parse_spr (CGEN_CPU_DESC cd,
	   const char **strp,
	   CGEN_KEYWORD * table,
	   long *valuep)
{
  const char *save_strp;
  long regno;

  /* Check for spr index notation.  */
  if (strncasecmp (*strp, "spr[", 4) == 0)
    {
      *strp += 4;
      regno = parse_register_number (strp);
      if (**strp != ']')
        return _("missing `]'");
      ++*strp;
      if (! spr_valid (regno))
	return _("Special purpose register number is out of range");
      *valuep = regno;
      return NULL;
    }

  save_strp = *strp;
  regno = parse_register_number (strp);
  if (regno != -1)
    {
      if (! spr_valid (regno))
	return _("Special purpose register number is out of range");
      *valuep = regno;
      return NULL;
    }

  *strp = save_strp;
  return cgen_parse_keyword (cd, strp, table, valuep);
}

static const char *
parse_d12 (CGEN_CPU_DESC cd,
	   const char **strp,
	   int opindex,
	   long *valuep)
{
  const char *errmsg;
  enum cgen_parse_operand_result result_type;
  bfd_vma value;
 
  /* Check for small data reference.  */
  if (**strp == '#' || **strp == '%')
    {
      if (strncasecmp (*strp + 1, "gprel12(", 8) == 0)
        {
          *strp += 9;
          errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GPREL12,
					   & result_type, & value);
          if (**strp != ')')
            return "missing `)'";
          ++*strp;
          *valuep = value;
          return errmsg;
        }
      else if (strncasecmp (*strp + 1, "got12(", 6) == 0)
	{
	  *strp += 7;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOT12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotfuncdesc12(", 14) == 0)
	{
	  *strp += 15;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOT12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotoff12(", 9) == 0)
	{
	  *strp += 10;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTOFF12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotofffuncdesc12(", 17) == 0)
	{
	  *strp += 18;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOTOFF12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsdesc12(", 13) == 0)
	{
	  *strp += 14;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSDESC12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "tlsmoff12(", 10) == 0)
	{
	  *strp += 11;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_TLSMOFF12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsoff12(", 12) == 0)
	{
	  *strp += 13;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSOFF12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
    }
  return cgen_parse_signed_integer (cd, strp, opindex, valuep);
}

static const char *
parse_s12 (CGEN_CPU_DESC cd,
	   const char **strp,
	   int opindex,
	   long *valuep)
{
  const char *errmsg;
  enum cgen_parse_operand_result result_type;
  bfd_vma value;
 
  /* Check for small data reference.  */
  if (**strp == '#' || **strp == '%')
    {
      if (strncasecmp (*strp + 1, "gprel12(", 8) == 0)
	{
	  *strp += 9;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GPREL12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing `)'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "got12(", 6) == 0)
	{
	  *strp += 7;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOT12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotfuncdesc12(", 14) == 0)
	{
	  *strp += 15;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOT12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotoff12(", 9) == 0)
	{
	  *strp += 10;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTOFF12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gotofffuncdesc12(", 17) == 0)
	{
	  *strp += 18;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_FUNCDESC_GOTOFF12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsdesc12(", 13) == 0)
	{
	  *strp += 14;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSDESC12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "tlsmoff12(", 10) == 0)
	{
	  *strp += 11;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_TLSMOFF12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
      else if (strncasecmp (*strp + 1, "gottlsoff12(", 12) == 0)
	{
	  *strp += 13;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GOTTLSOFF12,
					   & result_type, & value);
	  if (**strp != ')')
	    return "missing ')'";
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
    }

  if (**strp == '#')
    ++*strp;
  return cgen_parse_signed_integer (cd, strp, opindex, valuep);
}

static const char *
parse_u12 (CGEN_CPU_DESC cd,
	   const char **strp,
	   int opindex,
	   long *valuep)
{
  const char *errmsg;
  enum cgen_parse_operand_result result_type;
  bfd_vma value;
 
  /* Check for small data reference.  */
  if ((**strp == '#' || **strp == '%')
      && strncasecmp (*strp + 1, "gprel12(", 8) == 0)
    {
      *strp += 9;
      errmsg = parse_symbolic_address (cd, strp, opindex,
				       BFD_RELOC_FRV_GPRELU12,
				       & result_type, & value);
      if (**strp != ')')
        return "missing `)'";
      ++*strp;
      *valuep = value;
      return errmsg;
    }
  else
    {
      if (**strp == '#')
        ++*strp;
      return cgen_parse_signed_integer (cd, strp, opindex, valuep);
    }
}

static const char *
parse_A (CGEN_CPU_DESC cd,
	 const char **strp,
	 int opindex,
	 unsigned long *valuep,
	 unsigned long A)
{
  const char *errmsg;
 
  if (**strp == '#')
    ++*strp;

  errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
  if (errmsg)
    return errmsg;

  if (*valuep != A)
    return _("Value of A operand must be 0 or 1");

  return NULL;
}

static const char *
parse_A0 (CGEN_CPU_DESC cd,
	  const char **strp,
	  int opindex,
	  unsigned long *valuep)
{
  return parse_A (cd, strp, opindex, valuep, 0);
}

static const char *
parse_A1 (CGEN_CPU_DESC cd,
	  const char **strp,
	  int opindex,
	  unsigned long *valuep)
{
  return parse_A (cd, strp, opindex, valuep, 1);
}

static const char *
parse_even_register (CGEN_CPU_DESC  cd,
		     const char **  strP,
		     CGEN_KEYWORD * tableP,
		     long *         valueP)
{
  const char * errmsg;
  const char * saved_star_strP = * strP;

  errmsg = cgen_parse_keyword (cd, strP, tableP, valueP);

  if (errmsg == NULL && ((* valueP) & 1))
    {
      errmsg = _("register number must be even");
      * strP = saved_star_strP;
    }

  return errmsg;
}

static const char *
parse_call_label (CGEN_CPU_DESC cd,
		  const char **strp,
		  int opindex,
		  int opinfo,
		  enum cgen_parse_operand_result *resultp,
		  bfd_vma *valuep)
{
  const char *errmsg;
  bfd_vma value;
 
  /* Check for small data reference.  */
  if (opinfo == 0 && (**strp == '#' || **strp == '%'))
    {
      if (strncasecmp (*strp + 1, "gettlsoff(", 10) == 0)
	{
	  *strp += 11;
	  errmsg = parse_symbolic_address (cd, strp, opindex,
					   BFD_RELOC_FRV_GETTLSOFF,
					   resultp, &value);
	  if (**strp != ')')
	    return _("missing `)'");
	  ++*strp;
	  *valuep = value;
	  return errmsg;
	}
    }

  return cgen_parse_address (cd, strp, opindex, opinfo, resultp, valuep);
}

/* -- */

/* -- dis.c */
static void
print_at (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
	  void * dis_info,
	  long reloc_ann ATTRIBUTE_UNUSED,
	  long value ATTRIBUTE_UNUSED,
	  bfd_vma pc ATTRIBUTE_UNUSED,
	  int length ATTRIBUTE_UNUSED)
{
  disassemble_info *info = (disassemble_info *) dis_info;

  (*info->fprintf_func) (info->stream, "@@");
}  

static void
print_spr (CGEN_CPU_DESC cd,
	   void * dis_info,
	   CGEN_KEYWORD *names,
	   long regno,
	   unsigned int attrs)
{
  /* Use the register index format for any unnamed registers.  */
  if (cgen_keyword_lookup_value (names, regno) == NULL)
    {
      disassemble_info *info = (disassemble_info *) dis_info;
      (*info->fprintf_func) (info->stream, "spr[%ld]", regno);
    }
  else
    print_keyword (cd, dis_info, names, regno, attrs);
}

static void
print_hi (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
	  void * dis_info,
	  long value,
	  unsigned int attrs ATTRIBUTE_UNUSED,
	  bfd_vma pc ATTRIBUTE_UNUSED,
	  int length ATTRIBUTE_UNUSED)
{
  disassemble_info *info = (disassemble_info *) dis_info;

  (*info->fprintf_func) (info->stream, value ? "0x%lx" : "hi(0x%lx)", value);
}

static void
print_lo (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
	  void * dis_info,
	  long value,
	  unsigned int attrs ATTRIBUTE_UNUSED,
	  bfd_vma pc ATTRIBUTE_UNUSED,
	  int length ATTRIBUTE_UNUSED)
{
  disassemble_info *info = (disassemble_info *) dis_info;
  if (value)
    (*info->fprintf_func) (info->stream, "0x%lx", value);
  else
    (*info->fprintf_func) (info->stream, "lo(0x%lx)", value);
}

/* -- */
@


1.1.1.1
log
@import 7.3.1
@
text
@@


1.1.1.1.8.1
log
@Rebase to HEAD as of a few days ago.
@
text
@d1346 5
a1350 5
 	      /* If value is wider than 32 bits then be
 		 careful about how we extract bits 16-31.  */
 	      if (sizeof (value) > 4)
 		value &= (((bfd_vma)1 << 16) << 16) - 1;

@


1.1.1.1.2.1
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@d1346 5
a1350 5
 	      /* If value is wider than 32 bits then be
 		 careful about how we extract bits 16-31.  */
 	      if (sizeof (value) > 4)
 		value &= (((bfd_vma)1 << 16) << 16) - 1;

@


1.1.1.2
log
@Import gdb 7.6.1
News from: http://sourceware.org/gdb/news:

August 30th, 2013: GDB 7.6.1 Released!
The latest version of GDB, version 7.6.1, is available for download.

This is a minor corrective release over GDB 7.6, fixing the following issues:

PR tdep/15420 (Cannot debug threaded programs on newer versions of x86-solaris - Solaris 10, Update 10 or later)
PR remote/15455 (QTro remote packet broken)
PR build/15476 (Build failure due to incomplete enum type in utils.h)
PR server/15594 (tls support in 64x32 x86 gdbserver doesn't extend address to 64 bit)
PR server/15075 (dprintf inteferes with "next")
PR server/15434 (dprintf uses a synchronous 'continue' even in non-stop mode)
PR tui/14880 (In split register layouts, up results in assertion failure in value.c)
PR c++/15519 (GDB 7.6 is 94x slower than GDB 7.5.1 using a certain core file)
PR gdb/15837 (GDB prints entry values for local variables)
PR gdb/15415 (gdb resolves symbolic links when passing argv[0])
PR cli/15603 (CTRL-C can no longer interrupt inferior)
PR gdb/15604 (gdbserver socket leak 7.5 regression)
April 26th, 2013: GDB 7.6 Released!
The latest version of GDB, version 7.6, is available for download.

Changes in this release include:

New native configurations (ARM AArch64 GNU/Linux, FreeBSD/powerpc, 86_64/Cygwin and Tilera TILE-Gx GNU/Linux)
New target configurations (ARM AArch64, ARM AArch64 GNU/Linux, Lynx 178 PowerPC, x86_64/Cygwin, and Tilera TILE-Gx GNU/Linux)
Support for the "mini debuginfo" section, .gnu_debugdata
The C++ ABI now defaults to the GNU v3 ABI
More Python scripting improvements
Some GDB/MI improvements
New configure options, new commands, and options
New remote packets
A new "target record-btrace" has been added while the "target record" command has been renamed to "target record-full"
See the NEWS file for a more complete and detailed list of what this release includes.
March 12th, 2013: GDB 7.6 branch created
The GDB 7.6 branch (gdb_7_6-branch) has been created. To check out a copy of the branch use:

cvs -d :pserver:anoncvs@@sourceware.org:/cvs/src co -r gdb_7_6-branch gdb
November 29th, 2012: GDB 7.5.1 Released!
The latest version of GDB, version 7.5.1, is available for download.

This is a minor corrective release over GDB 7.5, fixing the following issues:

An "Attempt to dereference a generic pointer" errors (-var-create).
Backtrace problems on x32 (PR backtrace/14646).
next/step/finish problems on x32 (PR gdb/14647).
A "malformed linespec error: unexpected keyword, [...]" error (PR breakpoints/14643).
GDB crash while stepping through powerpc (32bits) code.
A failed assertion in linux_ptrace_test_ret_to_nx.
A "!frame_id_inlined_p (frame_id)" failed assertion.
A "No more reverse-execution history." error during reverse "next" execution (PR 14548).
Incomplete command descriptions in "apropos" output.
PR gdb/14494 (a GDB crash difficult to characterize).
Various build warnings.
August 17th, 2012: GDB 7.5 Released!
The latest version of GDB, version 7.5, is available for download.

Changes in this release include:

Go language support.
New targets (x32 ABI, microMIPS, Renesas RL78, HP OpenVMS ia64).
More Python scripting improvements.
SDT (Static Defined Tracing) probes support with SystemTap probes.
GDBserver improvements (stdio connections, target-side evaluation of breakpoint conditions, remote protocol improvements).
Other miscellaneous improvements (ability to stop when a shared library is loaded/unloaded, dynamic printf, etc).
Reverse debugging on ARM.
The binary "gdbtui" has been abandoned and can no longer be built. Use "gdb -tui" instead.
See the NEWS file for a more complete and detailed list of what this release includes.
July 17th, 2012: GDB 7.5 branch created
The GDB 7.5 branch (gdb_7_5-branch) has been created. To check out a copy of the branch use:

cvs -d :pserver:anoncvs@@sourceware.org:/cvs/src co -r gdb_7_5-branch gdb
April 26th, 2012: GDB 7.4.1 Released!
The latest version of GDB, version 7.4.1, is available for download.

This is a minor corrective release over GDB 7.4, fixing the following issues:

[GDB/MI] Error when resuming program execution in all-stop mode ("Cannot execute this command without a live selected thread").
[Pascal] Polluted display of class methods parameters.
[target remote] Errror when connecting to remote target where disconnected tracing is in effect.
[AVX] Float and ymm* register values not available.
[GDB] Crash when using the "finish" command.
[build] makeinfo should not be required to build GDB.
January 24th, 2012: GDB 7.4 Released!
The latest version of GDB, version 7.4, is available for download.

Changes in this release include:

Many Python scripting improvements
Better support for ambiguous linespecs
Masked watchpoints
Tracepoint support improvements
Support for Texas Instruments TMS320C6x (tic6x-*-*)
A Renesas RL78 simulator (rl78-*-elf)
Some minor Remote protocol extensions and GDB/MI changes
See the NEWS file for a more complete and detailed list of what this release includes. Note that the gdbtui binary is deprecated, starting with GDB 7.5. Use "gdb -tui" instead.
January 9, 2012: Extensibility support using Guile
GDB ought to support extensibility using Guile, the GNU extensibility package (an implementation of Scheme). We are looking for people to write the code to interface the two. Please write to gdb-patches AT sourceware DOT org if you are interested.

December 13, 2011: GDB 7.4 branch created
The GDB 7.4 branch (gdb_7_4-branch) has been created. To check out a copy of the branch use:

cvs -d :pserver:anoncvs@@sourceware.org:/cvs/src co -r gdb_7_4-branch gdb
September 30, 2011: Release Mistakes in GDB Versions 6.0 - 7.3
A mistake has been detected in the release tar files for all GDB releases from version 6.0 to version 7.3 (included). The mistake has been corrected, and the FSF issued the following announcements:

Making up for a release mistake in GDB versions 6.0 - 6.6
Making up for a release mistake in GDB versions 6.7 - 7.3
@
text
@d1346 5
a1350 5
 	      /* If value is wider than 32 bits then be
 		 careful about how we extract bits 16-31.  */
 	      if (sizeof (value) > 4)
 		value &= (((bfd_vma)1 << 16) << 16) - 1;

@


1.1.1.2.26.1
log
@Sync with HEAD
@
text
@a80 1
#include "opintl.h"
d503 3
a505 3
      /* xgettext:c-format */
      opcodes_error_handler (_("internal error: bad vliw->next_slot value"));
      abort ();
d813 2
a814 2
      /* xgettext:c-format */
      opcodes_error_handler (_("internal error: bad major code"));
d863 3
a865 3
      /* xgettext:c-format */
      opcodes_error_handler (_("internal error: bad insn unit"));
      abort ();
@


1.1.1.3
log
@   May 11th, 2019: GDB 8.3 Released!
          The latest version of GDB, version 8.3, is available for
          download.

          This version of GDB includes the following changes and
          enhancements:

          + Support for new native configurations (also available as a
            target configuration):
               o RISC-V GNU/Linux (riscv*-*-linux*)
               o RISC-V FreeBSD (riscv*-*-freebsd*)
          + Support for new target configurations:
               o CSKY ELF (csky*-*-elf)
               o CSKY GNU/Linux (csky*-*-linux)
               o NXP S12Z ELF (s12z-*-elf)
               o OpenRISC GNU/Linux (or1k*-*-linux*)
          + Native Windows debugging is only supported on Windows XP or
            later.
          + The Python API in GDB now requires Python 2.6 or later.
          + GDB now supports terminal styling for the CLI and TUI. Source
            highlighting is also supported by building GDB with GNU
            Highlight.
          + Experimental support for compilation and injection of C++
            source code into the inferior (requires GCC 7.1 or higher,
            built with libcp1.so).
          + GDB and GDBserver now support IPv6 connections.
          + Target description support on RISC-V targets.
          + Various enhancements to several commands:
               o "frame", "select-frame" and "info frame" commands
               o "info functions", "info types", "info variables"
               o "info thread"
               o "info proc"
               o System call alias catchpoint support on FreeBSD
               o "target remote" support for Unix Domain sockets.
          + Support for displaying all files opened by a process

         + DWARF index cache: GDB can now automatically save indices of
            DWARF symbols on disk to speed up further loading of the same
            binaries.
          + Various GDB/MI enhancements.
          + GDBserver on PowerPC GNU/Linux now supports access to the PPR,
            DSCR, TAR, EBB/PMU, and HTM registers.
          + Ada task switching support when debugging programs built with
            the Ravenscar profile added to aarch64-elf.
          + GDB in batch mode now exits with status 1 if the last executed
            command failed.
          + Support for building GDB with GCC's Undefined Behavior
            Sanitizer.

          See the NEWS file for a more complete and detailed list of what
          this release includes.

   February 27th, 2019: GDB 8.3 branch created
          The GDB 8.3 branch (gdb-8.3-branch) has been created. To check
          out a copy of the branch use:

git clone --branch gdb-8.3-branch ssh://sourceware.org/git/binutils-gdb.git

   December 23rd, 2018: GDB 8.2.1 Released!
          The latest version of GDB, version 8.2.1, is available for
          download.

          This is a minor corrective release over GDB 8.2, fixing the
          following issues:

          + PR build/23516 (gdb build error under msys+mingw: strip can't
            handle gdb-add-index.exe)
          + PR build/23623 (install-strip fails)
          + PR rust/23626 (gdb crashes in upstream rust nil-enum test)
          + PR rust/23650 (rust field name access error mentions "foo")
          + PR gdb/23663 (gdb 8.1.1: undefined rpl_stat function with musl
            toolchains)
          + PR python/23669 (gdb.execute("show commands") doesn't work)
          + PR python/23714 (Command repetition stops working after
            gdb.execute)
          + PR gdb/23838 (8.2 regression for invalid -data-directory)
          + PR gdb/23974 ("info os" crash when specifying invalid object)
          + PR gdb/23999 (SYMBOL_LANGUAGE assertion failure on AIX)
          + PR gdb/24003 (Error when binary searching CUs for a specific
            DIE when using DWZ)

   September 5th, 2018: GDB 8.2 Released!
          The latest version of GDB, version 8.2, is available for
          download.

          This version of GDB includes the following changes and
          enhancements:

          + Support for the following target has been added:
               o RiscV ELF (riscv*-*-elf)
          + Support for following targets and native configurations has
            been removed:
               o m88k running OpenBSD (m88*-*-openbsd*)
               o SH-5/SH64 ELF (sh64-*-elf*)
               o SH-5/SH64 (sh*)
               o SH-5/SH64 running GNU/Linux (sh*-*-linux*)
               o SH-5/SH64 running OpenBSD (sh*-*-openbsd*)
          + Various Python API enhancements
          + Aarch64/Linux enhancements:
               o SVE support.
               o Hardware watchpoints improvements for entities stored at
                 unaligned addresses.
                    # New "c" response to disable the pager for the rest
                      of the current command.
                    # C expressions can now use _Alignof, and C++
                      expressions can now use alignof.
                    # Improved flexibility for loading symbol files.
                    # The 'info proc' command nows works on running
                      processes on FreeBSD systems as well as core files
                      created on FreeBSD systems.
                    # A new --enable-codesign=CERT configure option to
                      automatically codesign GDB after build (useful on
                      MacOS X).
                 See the NEWS file for a more complete and detailed list
                 of what this release includes.

   July 31st, 2018: GDB 8.1.1 Released!
       The latest version of GDB, version 8.1.1, is available
       for download.
       This is a minor corrective release over GDB 8.1, fixing
       the following issues:
	  # PR gdb/22824 (misleading description of new rbreak
	    Python function in GDB 8.1 NEWS file)
	  # PR gdb/22849 (ctrl-c doesn't work in
	    extended-remote)
	  # PR gdb/22907 ([Regression] gdbserver doesn't work
	    with filename-only binaries)
	 # PR gdb/23028 (inconsistent disassemble of vcvtpd2dq)
	  # PR gdb/23053 (Fix -D_GLIBCXX_DEBUG gdb-add-index
	    regression)
	  # PR gdb/23127 ([AArch64] GDB cannot be used for
	    debugging software that uses high Virtual Addresses)
	  # PR server/23158 (gdbserver no longer functional on
	    Windows)
	  # PR breakpoints/23210 ([8.1/8.2 Regression] Bogus
	    Breakpoint address adjusted from 0xf7fe7dd3 to
	    0xfffffffff7fe7dd3)

   July 4th, 2018: GDB 8.2 branch created
       The GDB 8.2 branch (gdb-8.2-branch) has been created. To
       check out a copy of the branch use:
 git clone --branch gdb-8.2-branch ssh://sourceware.org/git/binutils-gdb.git

   January 31st, 2018: GDB 8.1 Released!
       The latest version of GDB, version 8.1, is available for
       download.
       Changes in this release include:
	  # Breakpoints on C++ functions are now set on all
	    scopes by default ("wild" matching);
	  # Support for inserting breakpoints on functions
	    marked with C++ ABI tags;
	  # Target floating-point arithmetic emulation during
	    expression evaluation (requires MPFR 3.1 or later);
	  # Various Python Scripting enhancements;
	  # Improved Rust support; in particular, Trait objects
	    can now be inspected when debugging Rust code;
	  # GDB no longer makes assumptions about the type of
	    symbols without debugging information to avoid
	    producing erroneous and often confusing results;
	  # The 'enable' and 'disable' commands now accept a
	    range of breakpoint locations;
	  # New 'starti' command to start the program at the
	    first instruction;
	  # New 'rbreak' command to insert a number of
	    breakpoints via a regular expression pattern
	    (requires Python);
	  # The 'ptype' command now supports printing the offset
	    and size of the fields in a struct;
	  # The 'gcore' command now supports dumping all the
	    memory mappings ('-a' command-line option);
	  # New shortcuts for TUI Single-Key mode: 'i' for
	    stepi, and 'o' for nexti;
	  # GDBserver enhancements:
	       @@ Support for transmitting environment variables
		 to GDBserver;
	       @@ Support for starting inferior processes with a
		 specified initial working directory;
	       @@ On Unix systems, support for globbing expansion
		 and variable substitution of inferior
		 command-line arguments;
	  # Various completion enhancements;
	  # The command used to compile and inject code with the
	    'compile' command is now configurable;
	  # New '--readnever' command-line option to speed the
	    GDB startup when debugging information is not
	    needed;
	  # Support for the following new native configurations:
	       @@ FreeBSD/aarch64 (aarch64*-*-freebsd*);
	       @@ FreeBSD/arm (arm*-*-freebsd*);
	  # Support for the following new targets:
	       @@ FreeBSD/aarch64 (aarch64*-*-freebsd*);
	       @@ FreeBSD/arm (arm*-*-freebsd*);
	       @@ OpenRISC ELF (or1k*-*-elf)
	  # Removed support for the following targets and native
	    configurations:
	       @@ Solaris2/x86 (i?86-*-solaris2.[0-9]);
	       @@ Solaris2/sparc (sparc*-*-solaris2.[0-9]);
       See the NEWS file for a more complete and detailed list
       of what this release includes.

   January 5th, 2018: GDB 8.1 branch created
       The GDB 8.1 branch (gdb-8.1-branch) has been created. To
       check out a copy of the branch use:
 git clone --branch gdb-8.1-branch ssh://sourceware.org/git/binutils-gdb.git

   November 1st, 2017: Debugging Tools Devroom at FOSDEM 2018
       We will have a Debugging Tools Devroom at FOSDEM 2018.
       The Call for Participation has recently been announced.
       The Devroom is on the first of the two FOSDEM days, on
       Saturday 3 Feb 2018. See you all at FOSDEM in Brussels!

   September 7th, 2017: GDB 8.0.1 Released!
       The latest version of GDB, version 8.0.1, is available
       for download.
       This is a minor corrective release over GDB 8.0, fixing
       the following issues:
	  # PR breakpoint/21886 (Compressed MIPS code debugging
	    impossible due to memory breakpoint misplacement)
	  # PR symtab/22002 (Assertion on debuggee built with
	    -gdwarf-5 -fdebug-types-section)
						  GDB News (p6 of 30)
	  # PR symtab/22003 (Incompatibility with -gdwarf-5 -
	    DW_FORM_implicit_const)
	  # PR gdb/22046 (Regression on older kernels for T
	    (stopped) processes)
	  # PR sim/20863 (gdb-7.12 powerpc-rtems4.12-gdb does
	    not build on FreeBSD)
	  # PR breakpoint/21555 ("error re-setting breakpoint"
	    on PIE executables)
	  # PR tdep/21717 ("print $fpscr" says "" until some VFP
	    data register is printed)
	  # PR exp/21827 (Regression: gdb command lookup became
	    case-sensitive; but definitions are forced into
	    lowercase)
	  # PR remote/22021 (Multi-arch exec fails with a remote
	    target)
@
text
@a80 1
#include "opintl.h"
d503 3
a505 3
      /* xgettext:c-format */
      opcodes_error_handler (_("internal error: bad vliw->next_slot value"));
      abort ();
d813 2
a814 2
      /* xgettext:c-format */
      opcodes_error_handler (_("internal error: bad major code"));
d863 3
a865 3
      /* xgettext:c-format */
      opcodes_error_handler (_("internal error: bad insn unit"));
      abort ();
@


1.1.1.4
log
@Import gdb-13.2 over gdb-11.0.50

May 27th, 2023: GDB 13.2 Released!
The latest version of GDB, version 13.2, is available for download.

This is a minor corrective release over GDB 13.1, fixing the following issues:

PR testsuite/30158 (rustc testsuite fails with 13.1, apparently
		    worked before with trunk 20230114 on i686-linux-gnu and
		    powerpc64le-linux-gnu)
PR gdb/30214 (GDB 13.1 does not compile on FreeBSD 13.1)
PR gdb/30240 ((linux/aarch) thread.c:86: internal-error: inferior_thread:
              Assertion `current_thread_ != nullptr' failed)
PR gdb/30249 ([13 regression] hookpost-extended-remote will not work)
PR exp/30271 (Addresses of static thread_local fields are badly
              calculated sometimes)
PR symtab/30357 (Segmentation fault for the 'start' command)
PR symtab/30369 ([gdb/symtab] False match issue in
skip_prologue_using_linetable)

PR gdb/30423 (Build failures with clang 16)
PR build/30450 (Build failure (linux-low.cc:5393:45: error: expected
		':' before ')' token) with musl-1.2.4)

See the NEWS file for a more complete and detailed list of what this release
 includes.

Feb 19th, 2023: GDB 13.1 Released!

The latest version of GDB, version 13.1, is available for download.
This version of GDB includes the following changes and enhancements:
Support for the following new targets has been added in both GDB and GDBserver:
GNU/Linux/LoongArch (gdbserver) loongarch*-*-linux*
GNU/Linux/CSKY (gdbserver) csky*-*linux*
The Windows native target now supports target async.
FreeBSD:
Arm and AArch64: Support for Thread Local Storage (TLS) variables
Hardware watchpoint support on AArch64 FreeBSD
Floating-point support has now been added on LoongArch GNU/Linux.
New commands:
set print nibbles [on|off]
show print nibbles

This controls whether the 'print/t' command will display binary
values in groups of four bits, known as "nibbles". The default is
'off'.

Various styling-related commands. See the gdb/NEWS file for more details.
Various maintenance commands. These are normally aimed at GDB
experts or developers. See the gdb/NEWS file for more details.

Python API improvements:
New Python API for instruction disassembly.

The new attribute 'locations' of gdb.Breakpoint returns a list of
gdb.BreakpointLocation objects specifying the locations where the
breakpoint is inserted into the debuggee.
New Python type gdb.BreakpointLocation.
New function gdb.format_address(ADDRESS, PROGSPACE, ARCHITECTURE)
that formats ADDRESS as 'address '
New function gdb.current_language that returns the name of the
current language. Unlike gdb.parameter('language'), this will never
return 'auto'.
New function gdb.print_options that returns a dictionary of the
prevailing print options, in the form accepted by gdb.Value.format_string.
New method gdb.Frame.language that returns the name of the frame's language.
gdb.Value.format_string now uses the format provided by 'print',
if it is called during a 'print' or other similar operation.
gdb.Value.format_string now accepts the 'summary' keyword. This
can be used to request a shorter representation of a value, the
way that 'set print frame-arguments scalars' does.
The gdb.register_window_type method now restricts the set of
acceptable window names. The first character of a window's name
must start with a character in the set [a-zA-Z], every subsequent
character of a window's name must be in the set [-_.a-zA-Z0-9].
` GDB/MI changes:  MI version 1 is deprecated, and will be removed
in GDB 14.  The async record stating the stopped reason 'breakpoint-hit'
now contains an optional field locno.

Miscellaneous improvements:
gdb now supports zstd compressed debug sections (ELFCOMPRESS_ZSTD) for ELF.
New convenience variable $_inferior_thread_count contains the number
of live threads in the current inferior.
New convenience variables $_hit_bpnum and $_hit_locno, set to the
breakpoint number and the breakpoint location number of the breakpoint
last hit.
The "info breakpoints" now displays enabled breakpoint locations
of disabled breakpoints as in the "y-" state.
The format of 'disassemble /r' and 'record instruction-history /r'
has changed to match the layout of GNU objdump when disassembling.

A new format "/b" has been introduce to provide the old behavior of "/r".
The TUI no longer styles the source and assembly code highlighted
by the current position indicator by default. You can however
re-enable styling using the new "set style tui-current-position"
command.
It is now possible to use the "document" command to document
user-defined commands.
Support for memory tag data for AArch64 MTE.
Support Removal notices:
DBX mode has been removed.
Support for building against Python version 2 has been removed. It
is now only possible to build GDB against Python 3.
Support for the following commands has been removed:

set debug aix-solib on|off
show debug aix-solib
set debug solib-frv on|off
show debug solib-frv

Use the "set/show debug solib" commands instead.
See the NEWS file for a more complete and detailed list of what
this release includes.

Dec 18th, 2022: GDB 13 branch created
The GDB 13 branch (gdb-13-branch) has been created. To check out
a copy of the branch use:

git clone --branch gdb-13-branch https://sourceware.org/git/binutils-gdb.git
May 1st, 2022: GDB 12.1 Released!
The latest version of GDB, version 12.1, is available for download.

This version of GDB includes the following changes and enhancements:

New support for the following native configuration:
GNU/Linux/OpenRISC or1k*-*-linux*
New support for the following targets:
GNU/Linux/LoongArch loongarch*-*-linux*
New GDBserver support on the following configuration:
GNU/Linux/OpenRISC or1k*-*-linux*
Support for the following target has been removed:
S+core score-*-*
Multithreaded symbol loading is now enabled by default

Deprecation Notices:
GDB 12 is the last release of GDB that will support building against Python 2
DBX mode is deprecated, and will be removed in GDB 13
GDB/MI changes:
The '-add-inferior' with no option flags now inherits the connection
of the current inferior, this restores the behaviour of GDB as it
was prior to GDB 10.
The '-add-inferior' command now accepts a '--no-connection' option,
which causes the new inferior to start without a connection.

Python API enhancements:
It is now possible to add GDB/MI commands implemented in Python
New function gdb.Architecture.integer_type()
New gdb.events.gdb_exiting event
New 'gdb.events.connection_removed' event registry
New gdb.TargetConnection object
New gdb.Inferior.connection property
New read-only attribute gdb.InferiorThread.details
New gdb.RemoteTargetConnection.send_packet method
New read-only attributes gdb.Type.is_scalar and gdb.Type.is_signed
The gdb.Value.format_string method now takes a 'styling' argument
Various new function in the "gdb" module
Miscellaneous:
The FreeBSD native target now supports async mode

Improved C++ template support
Support for disabling source highlighting through GNU of the Pygments
library instead.
The "print" command has been changed so as to print floating-point
values with a base-modifying formats such as "/x" to display the
underlying bytes of the value in the desired base.
The "clone-inferior" command now ensures that the TTY, CMD and ARGS
settings are copied from the original inferior to the new one. All
modifications to the environment variables done using the 'set
environment' or 'unset environment' commands are also copied to
the new inferior.
Various new commands have been introduced
See the NEWS file for a more complete and detailed list of what
this release includes.

Mar 20th, 2022: GDB 12 branch created
The GDB 12 branch (gdb-12-branch) has been created. To check out a copy of the branch use:

git clone --branch gdb-12-branch https://sourceware.org/git/binutils-gdb.git
January 16th, 2022: GDB 11.2 Released!
The latest version of GDB, version 11.2, is available for download.

This is a minor corrective release over GDB 11.1, fixing the following issues:

PR sim/28302 (gdb fails to build with glibc 2.34)
PR build/28318 (std::thread support configure check does not use CXX_DIALECT)
PR gdb/28405 (arm-none-eabi: internal-error: ptid_t
	      remote_target::select_thread_for_ambiguous_stop_reply(const
	      target_waitstatus*): Assertion `first_resumed_thread != nullptr'
	      failed)
PR tui/28483 ([gdb/tui] breakpoint creation not displayed)
PR build/28555 (uclibc compile failure since commit
		4655f8509fd44e6efabefa373650d9982ff37fd6)
PR rust/28637 (Rust characters will be encoded using DW_ATE_UTF)
PR gdb/28758 (GDB 11 doesn't work correctly on binaries with a
              SHT_RELR (.relr.dyn) section)
PR gdb/28785 (Support SHT_RELR (.relr.dyn) section)
See the NEWS file for a more complete and detailed list of what
this release includes.

September 13th, 2021: GDB 11.1 Released!
The latest version of GDB, version 11.1, is available for download.

This version of GDB includes the following changes and enhancements:

Support for ARM Symbian (arm*-*-symbianelf*) has been removed.
Building GDB now requires GMP (The GNU Multiple Precision Arithmetic Library).
New command-line options "--early-init-command" (or "-eix") and
"--early-init-eval-command" (or "-eiex")

GDB/MI Changes:
New --qualified option for the '-break-insert' and '-dprintf-insert' commands.
New --force-condition option for the '-break-insert' and
'-dprintf-insert' commands.
New --force option for the '-break-condition' command.
The '-file-list-exec-source-files' now accepts an optional regular
expression to filter the source files included in the result.
The results from '-file-list-exec-source-files' now include a
'debug-fully-read' field to indicate if the corresponding source's
debugging information has been partially read (false) or has been
fully read (true).

TUI Improvements:
Mouse actions are now supported. The mouse wheel scrolls the
appropriate window.  Key combinations that do not have a specific
action on the focused window are now passed to GDB.

Python enhancements:
Inferior objects now contain a read-only 'connection_num' attribute
that gives the connection number as seen in 'info connections' and
'info inferiors'.
New method gdb.Frame.level() which returns the stack level of the frame object.
New method gdb.PendingFrame.level() which returns the stack level
of the frame object.
When hitting a catchpoint, the Python API will now emit a
gdb.BreakpointEvent rather than a gdb.StopEvent. The gdb.Breakpoint
attached to the event will have type BP_CATCHPOINT.
Python TUI windows can now receive mouse click events. If the Window
object implements the click method, it is called for each mouse
click event in this window.  New setting "python ignore-environment
on|off"; if "on", causes GDB's builtin Python to ignore any
environment variable that would otherwise affect how Python behaves
(needs to be set during "early initialization" (see above).  New
setting "python dont-write-bytecode auto|on|off".

Guile API enhancements:
Improved support for rvalue reference values.
New procedures for obtaining value variants: value-reference-value,
value-rvalue-reference-value and value-const-value.
New "qMemTags" and "QMemTags" remote protocol packets (associated
with Memory Tagging).
GDB will now look for the .gdbinit file in a config directory before
looking for ~/.gdbinit. The file is searched for in the following
locations: $XDG_CONFIG_HOME/gdb/gdbinit, $HOME/.config/gdb/gdbinit,
$HOME/.gdbinit. On Apple hosts the search order is instead:
$HOME/Library/Preferences/gdb/gdbinit, $HOME/.gdbinit.  The "break
[...] if CONDITION" command no longer returns an error when the
condition is invalid at one or more locations. Instead, if the
condition is valid at one or more locations, the locations where
the condition is not valid are disabled.
The behavior of the "condition" command is changed to match the
new behavior of the "break" command.

Support for general memory tagging functionality (currently limited
to AArch64 MTE)

Core file debugging now supported for x86_64 Cygwin programs.
New "org.gnu.gdb.riscv.vector" feature for RISC-V targets.
GDB now supports fixed point types which are described in DWARF as
base types with a fixed-point encoding. Additionally, support for
the DW_AT_GNU_numerator and DW_AT_GNU_denominator has also been
added.

Miscellaneous:
New "startup-quietly on|off" setting; when "on", behaves the same
as passing the "-silent" option on the command line.
New "print type hex on|off" setting; when 'on', the 'ptype' command
uses hexadecimal notation to print sizes and offsets of struct
members. When 'off', decimal notation is used.
The "inferior" command, when run without argument, prints information
about the current inferior.
The "ptype" command now supports "/x" and "/d", affecting the base
used to print sizes and offsets.
The output of the "info source" has been restructured.
New "style version foreground | background | intensity" commands
to control the styling of the GDB version number.
Various debug and maintenance commands (mostly useful for the GDB
developers) See the NEWS file for a more complete and detailed list
of what this release includes.
@
text
@d69 9
a77 9
bool frv_is_branch_major (CGEN_ATTR_VALUE_ENUM_TYPE, unsigned long);
bool frv_is_float_major  (CGEN_ATTR_VALUE_ENUM_TYPE, unsigned long);
bool frv_is_media_major  (CGEN_ATTR_VALUE_ENUM_TYPE, unsigned long);
bool frv_is_branch_insn  (const CGEN_INSN *);
bool frv_is_float_insn   (const CGEN_INSN *);
bool frv_is_media_insn   (const CGEN_INSN *);
void frv_vliw_reset      (FRV_VLIW *, unsigned long, unsigned long);
int  frv_vliw_add_insn   (FRV_VLIW *, const CGEN_INSN *);
bool spr_valid           (long);
d91 1
a91 1
bool
d98 1
a98 1
	return true;
d102 1
a102 1
	return true;
d106 1
a106 1
	return true;
d110 1
a110 1
  return false;
d115 1
a115 1
bool
d122 1
a122 1
      return false;
d125 1
a125 1
	return true;
d129 1
a129 1
  return false;
d134 1
a134 1
bool
d141 1
a141 1
	return true;
d145 1
a145 1
	return true;
d149 1
a149 1
	return true;
d153 1
a153 1
  return false;
d156 1
a156 1
bool
d161 1
a161 1
    return true;
d164 1
a164 1
    return true;
d167 1
a167 1
    return true;
d169 1
a169 1
  return false;
d172 1
a172 1
bool
d177 1
a177 1
    return true;
d180 1
a180 1
    return true;
d183 1
a183 1
    return true;
d185 1
a185 1
  return false;
d188 1
a188 1
bool
d193 1
a193 1
    return true;
d196 1
a196 1
    return true;
d199 1
a199 1
    return true;
d201 1
a201 1
  return false;
d442 1
a442 1
static bool
d450 1
a450 1
    return true;
d452 1
a452 1
    return false;
d462 1
a462 1
	return true;
d469 1
a469 1
	return true;
d475 1
a475 1
  return false;
d480 1
a480 1
static bool
d487 1
a487 1
      return false;
d489 1
a489 1
  return true;
d526 1
a526 1
static bool
d533 1
a533 1
      return true;
d535 1
a535 1
  return false;
d541 1
a541 1
static bool
d558 1
a558 1
  return true;
d561 1
a561 1
static bool
d572 1
a572 1
      return true;
d592 1
a592 1
      return true;
d596 1
a596 1
static bool
d603 1
a603 1
      return true;
d605 1
a605 1
  return false; /* Not found.  */
d608 1
a608 1
static bool
d617 1
a617 1
      return true;
d619 1
a619 1
  return false;
d622 1
a622 1
static bool
d638 1
a638 1
      return true; /* Found one.  */
d641 1
a641 1
  return false;
d644 1
a644 1
static bool
d658 1
a658 1
      return true; /* Found one.  */
d661 1
a661 1
  return false;
d664 1
a664 1
static bool
d712 1
a712 1
  return true; /* All OK.  */
d715 1
a715 1
static bool
d735 1
a735 1
      return true; /* OK */
d819 1
a819 1
  return true;
d822 1
a822 1
static bool
d922 1
a922 1
bool
d925 3
a927 3
  if (regno < 0)     return false;
  if (regno <= 4095) return true;
  return false;
@


