2000-04-21 20:22:24 +00:00
|
|
|
|
/* ia64-gen.c -- Generate a shrunk set of opcode tables
|
2005-02-22 13:01:53 +00:00
|
|
|
|
Copyright 1999, 2000, 2001, 2002, 2004, 2005
|
|
|
|
|
Free Software Foundation, Inc.
|
2000-04-21 20:22:24 +00:00
|
|
|
|
Written by Bob Manson, Cygnus Solutions, <manson@cygnus.com>
|
|
|
|
|
|
|
|
|
|
This file is part of GDB, GAS, and the GNU binutils.
|
|
|
|
|
|
|
|
|
|
GDB, GAS, and the GNU binutils are free software; you can redistribute
|
|
|
|
|
them and/or modify them under the terms of the GNU General Public
|
|
|
|
|
License as published by the Free Software Foundation; either version
|
|
|
|
|
2, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
GDB, GAS, and the GNU binutils are distributed in the hope that they
|
|
|
|
|
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 file; see the file COPYING. If not, write to the
|
2005-05-07 07:34:31 +00:00
|
|
|
|
Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
|
|
|
|
|
02110-1301, USA. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
/* While the ia64-opc-* set of opcode tables are easy to maintain,
|
|
|
|
|
they waste a tremendous amount of space. ia64-gen rearranges the
|
|
|
|
|
instructions into a directed acyclic graph (DAG) of instruction opcodes and
|
|
|
|
|
their possible completers, as well as compacting the set of strings used.
|
|
|
|
|
|
|
|
|
|
The disassembler table consists of a state machine that does
|
|
|
|
|
branching based on the bits of the opcode being disassembled. The
|
|
|
|
|
state encodings have been chosen to minimize the amount of space
|
|
|
|
|
required.
|
|
|
|
|
|
|
|
|
|
The resource table is constructed based on some text dependency tables,
|
2002-11-07 14:33:48 +00:00
|
|
|
|
which are also easier to maintain than the final representation. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2002-11-07 14:33:48 +00:00
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <errno.h>
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
#include "ansidecl.h"
|
|
|
|
|
#include "libiberty.h"
|
2001-09-19 05:33:36 +00:00
|
|
|
|
#include "safe-ctype.h"
|
2000-04-21 20:22:24 +00:00
|
|
|
|
#include "sysdep.h"
|
2002-11-07 14:33:48 +00:00
|
|
|
|
#include "getopt.h"
|
2000-04-21 20:22:24 +00:00
|
|
|
|
#include "ia64-opc.h"
|
|
|
|
|
#include "ia64-opc-a.c"
|
|
|
|
|
#include "ia64-opc-i.c"
|
|
|
|
|
#include "ia64-opc-m.c"
|
|
|
|
|
#include "ia64-opc-b.c"
|
|
|
|
|
#include "ia64-opc-f.c"
|
|
|
|
|
#include "ia64-opc-x.c"
|
|
|
|
|
#include "ia64-opc-d.c"
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
#include <libintl.h>
|
|
|
|
|
#define _(String) gettext (String)
|
|
|
|
|
|
|
|
|
|
const char * program_name = NULL;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int debug = 0;
|
|
|
|
|
|
2005-01-31 08:48:32 +00:00
|
|
|
|
#define NELEMS(a) (sizeof (a) / sizeof ((a)[0]))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
#define tmalloc(X) (X *) xmalloc (sizeof (X))
|
|
|
|
|
|
|
|
|
|
/* The main opcode table entry. Each entry is a unique combination of
|
|
|
|
|
name and flags (no two entries in the table compare as being equal
|
2002-11-07 14:33:48 +00:00
|
|
|
|
via opcodes_eq). */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct main_entry
|
|
|
|
|
{
|
|
|
|
|
/* The base name of this opcode. The names of its completers are
|
2002-11-07 14:33:48 +00:00
|
|
|
|
appended to it to generate the full instruction name. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct string_entry *name;
|
|
|
|
|
/* The base opcode entry. Which one to use is a fairly arbitrary choice;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
it uses the first one passed to add_opcode_entry. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct ia64_opcode *opcode;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The list of completers that can be applied to this opcode. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct completer_entry *completers;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Next entry in the chain. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct main_entry *next;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Index in the main table. */
|
2000-04-23 02:39:13 +00:00
|
|
|
|
int main_index;
|
|
|
|
|
} *maintable, **ordered_table;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-23 02:39:13 +00:00
|
|
|
|
int otlen = 0;
|
|
|
|
|
int ottotlen = 0;
|
|
|
|
|
int opcode_count = 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The set of possible completers for an opcode. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct completer_entry
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* This entry's index in the ia64_completer_table[] array. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int num;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The name of the completer. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct string_entry *name;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* This entry's parent. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct completer_entry *parent;
|
|
|
|
|
|
|
|
|
|
/* Set if this is a terminal completer (occurs at the end of an
|
2002-11-07 14:33:48 +00:00
|
|
|
|
opcode). */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int is_terminal;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* An alternative completer. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct completer_entry *alternative;
|
|
|
|
|
|
|
|
|
|
/* Additional completers that can be appended to this one. */
|
|
|
|
|
struct completer_entry *addl_entries;
|
|
|
|
|
|
|
|
|
|
/* Before compute_completer_bits () is invoked, this contains the actual
|
|
|
|
|
instruction opcode for this combination of opcode and completers.
|
|
|
|
|
Afterwards, it contains those bits that are different from its
|
2002-11-07 14:33:48 +00:00
|
|
|
|
parent opcode. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ia64_insn bits;
|
|
|
|
|
|
|
|
|
|
/* Bits set to 1 correspond to those bits in this completer's opcode
|
|
|
|
|
that are different from its parent completer's opcode (or from
|
|
|
|
|
the base opcode if the entry is the root of the opcode's completer
|
2002-11-07 14:33:48 +00:00
|
|
|
|
list). This field is filled in by compute_completer_bits (). */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ia64_insn mask;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Index into the opcode dependency list, or -1 if none. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int dependencies;
|
2000-04-23 02:39:13 +00:00
|
|
|
|
|
|
|
|
|
/* Remember the order encountered in the opcode tables. */
|
|
|
|
|
int order;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* One entry in the disassembler name table. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct disent
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The index into the ia64_name_dis array for this entry. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int ournum;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The index into the main_table[] array. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int insn;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The disassmbly priority of this entry. */
|
2000-04-23 02:39:13 +00:00
|
|
|
|
int priority;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The completer_index value for this entry. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int completer_index;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* How many other entries share this decode. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int nextcnt;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The next entry sharing the same decode. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct disent *nexte;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The next entry in the name list. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct disent *next_ent;
|
|
|
|
|
} *disinsntable = NULL;
|
|
|
|
|
|
|
|
|
|
/* A state machine that will eventually be used to generate the
|
2002-11-07 14:33:48 +00:00
|
|
|
|
disassembler table. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct bittree
|
|
|
|
|
{
|
|
|
|
|
struct disent *disent;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
struct bittree *bits[3]; /* 0, 1, and X (don't care). */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int bits_to_skip;
|
|
|
|
|
int skip_flag;
|
|
|
|
|
} *bittree;
|
|
|
|
|
|
|
|
|
|
/* The string table contains all opcodes and completers sorted in
|
|
|
|
|
alphabetical order. */
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* One entry in the string table. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct string_entry
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The index in the ia64_strings[] array for this entry. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int num;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* And the string. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
char *s;
|
|
|
|
|
} **string_table = NULL;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int strtablen = 0;
|
|
|
|
|
int strtabtotlen = 0;
|
|
|
|
|
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Resource dependency entries. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct rdep
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
char *name; /* Resource name. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
unsigned
|
2002-11-07 14:33:48 +00:00
|
|
|
|
mode:2, /* RAW, WAW, or WAR. */
|
|
|
|
|
semantics:3; /* Dependency semantics. */
|
|
|
|
|
char *extra; /* Additional semantics info. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int nchks;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
int total_chks; /* Total #of terminal insns. */
|
|
|
|
|
int *chks; /* Insn classes which read (RAW), write
|
|
|
|
|
(WAW), or write (WAR) this rsrc. */
|
|
|
|
|
int *chknotes; /* Dependency notes for each class. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int nregs;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
int total_regs; /* Total #of terminal insns. */
|
|
|
|
|
int *regs; /* Insn class which write (RAW), write2
|
|
|
|
|
(WAW), or read (WAR) this rsrc. */
|
|
|
|
|
int *regnotes; /* Dependency notes for each class. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
int waw_special; /* Special WAW dependency note. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
} **rdeps = NULL;
|
|
|
|
|
|
|
|
|
|
static int rdepslen = 0;
|
|
|
|
|
static int rdepstotlen = 0;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Array of all instruction classes. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct iclass
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
char *name; /* Instruction class name. */
|
|
|
|
|
int is_class; /* Is a class, not a terminal. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int nsubs;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
int *subs; /* Other classes within this class. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int nxsubs;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
int xsubs[4]; /* Exclusions. */
|
|
|
|
|
char *comment; /* Optional comment. */
|
|
|
|
|
int note; /* Optional note. */
|
|
|
|
|
int terminal_resolved; /* Did we match this with anything? */
|
|
|
|
|
int orphan; /* Detect class orphans. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
} **ics = NULL;
|
|
|
|
|
|
|
|
|
|
static int iclen = 0;
|
|
|
|
|
static int ictotlen = 0;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* An opcode dependency (chk/reg pair of dependency lists). */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct opdep
|
|
|
|
|
{
|
|
|
|
|
int chk; /* index into dlists */
|
|
|
|
|
int reg; /* index into dlists */
|
|
|
|
|
} **opdeps;
|
|
|
|
|
|
|
|
|
|
static int opdeplen = 0;
|
|
|
|
|
static int opdeptotlen = 0;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* A generic list of dependencies w/notes encoded. These may be shared. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct deplist
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
unsigned short *deps;
|
|
|
|
|
} **dlists;
|
|
|
|
|
|
|
|
|
|
static int dlistlen = 0;
|
|
|
|
|
static int dlisttotlen = 0;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
|
|
|
|
static void fail (const char *, ...);
|
|
|
|
|
static void warn (const char *, ...);
|
|
|
|
|
static struct rdep * insert_resource (const char *, enum ia64_dependency_mode);
|
|
|
|
|
static int deplist_equals (struct deplist *, struct deplist *);
|
|
|
|
|
static short insert_deplist (int, unsigned short *);
|
|
|
|
|
static short insert_dependencies (int, unsigned short *, int, unsigned short *);
|
|
|
|
|
static void mark_used (struct iclass *, int);
|
|
|
|
|
static int fetch_insn_class (const char *, int);
|
|
|
|
|
static int sub_compare (const void *, const void *);
|
|
|
|
|
static void load_insn_classes (void);
|
|
|
|
|
static void parse_resource_users (const char *, int **, int *, int **);
|
|
|
|
|
static int parse_semantics (char *);
|
|
|
|
|
static void add_dep (const char *, const char *, const char *, int, int, char *, int);
|
|
|
|
|
static void load_depfile (const char *, enum ia64_dependency_mode);
|
|
|
|
|
static void load_dependencies (void);
|
|
|
|
|
static int irf_operand (int, const char *);
|
|
|
|
|
static int in_iclass_mov_x (struct ia64_opcode *, struct iclass *, const char *, const char *);
|
|
|
|
|
static int in_iclass (struct ia64_opcode *, struct iclass *, const char *, const char *, int *);
|
|
|
|
|
static int lookup_regindex (const char *, int);
|
|
|
|
|
static int lookup_specifier (const char *);
|
|
|
|
|
static void print_dependency_table (void);
|
|
|
|
|
static struct string_entry * insert_string (char *);
|
|
|
|
|
static void gen_dis_table (struct bittree *);
|
|
|
|
|
static void print_dis_table (void);
|
|
|
|
|
static void generate_disassembler (void);
|
|
|
|
|
static void print_string_table (void);
|
|
|
|
|
static int completer_entries_eq (struct completer_entry *, struct completer_entry *);
|
|
|
|
|
static struct completer_entry * insert_gclist (struct completer_entry *);
|
|
|
|
|
static int get_prefix_len (const char *);
|
|
|
|
|
static void compute_completer_bits (struct main_entry *, struct completer_entry *);
|
|
|
|
|
static void collapse_redundant_completers (void);
|
|
|
|
|
static int insert_opcode_dependencies (struct ia64_opcode *, struct completer_entry *);
|
|
|
|
|
static void insert_completer_entry (struct ia64_opcode *, struct main_entry *, int);
|
|
|
|
|
static void print_completer_entry (struct completer_entry *);
|
|
|
|
|
static void print_completer_table (void);
|
|
|
|
|
static int opcodes_eq (struct ia64_opcode *, struct ia64_opcode *);
|
|
|
|
|
static void add_opcode_entry (struct ia64_opcode *);
|
|
|
|
|
static void print_main_table (void);
|
|
|
|
|
static void shrink (struct ia64_opcode *);
|
|
|
|
|
static void print_version (void);
|
|
|
|
|
static void usage (FILE *, int);
|
|
|
|
|
static void finish_distable (void);
|
|
|
|
|
static void insert_bit_table_ent (struct bittree *, int, ia64_insn, ia64_insn, int, int, int);
|
|
|
|
|
static void add_dis_entry (struct bittree *, ia64_insn, ia64_insn, int, struct completer_entry *, int);
|
|
|
|
|
static void compact_distree (struct bittree *);
|
|
|
|
|
static struct bittree * make_bittree_entry (void);
|
|
|
|
|
static struct disent * add_dis_table_ent (struct disent *, int, int, int);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
fail (const char *message, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
va_start (args, message);
|
|
|
|
|
fprintf (stderr, _("%s: Error: "), program_name);
|
|
|
|
|
vfprintf (stderr, message, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
xexit (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
warn (const char *message, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
va_start (args, message);
|
|
|
|
|
|
|
|
|
|
fprintf (stderr, _("%s: Warning: "), program_name);
|
|
|
|
|
vfprintf (stderr, message, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add NAME to the resource table, where TYPE is RAW or WAW. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static struct rdep *
|
|
|
|
|
insert_resource (const char *name, enum ia64_dependency_mode type)
|
|
|
|
|
{
|
|
|
|
|
if (rdepslen == rdepstotlen)
|
|
|
|
|
{
|
|
|
|
|
rdepstotlen += 20;
|
|
|
|
|
rdeps = (struct rdep **)
|
|
|
|
|
xrealloc (rdeps, sizeof(struct rdep **) * rdepstotlen);
|
|
|
|
|
}
|
|
|
|
|
rdeps[rdepslen] = tmalloc(struct rdep);
|
|
|
|
|
memset((void *)rdeps[rdepslen], 0, sizeof(struct rdep));
|
|
|
|
|
rdeps[rdepslen]->name = xstrdup (name);
|
|
|
|
|
rdeps[rdepslen]->mode = type;
|
|
|
|
|
rdeps[rdepslen]->waw_special = 0;
|
|
|
|
|
|
|
|
|
|
return rdeps[rdepslen++];
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Are the lists of dependency indexes equivalent? */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static int
|
|
|
|
|
deplist_equals (struct deplist *d1, struct deplist *d2)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (d1->len != d2->len)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < d1->len; i++)
|
|
|
|
|
if (d1->deps[i] != d2->deps[i])
|
|
|
|
|
return 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Add the list of dependencies to the list of dependency lists. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static short
|
2002-11-07 14:33:48 +00:00
|
|
|
|
insert_deplist (int count, unsigned short *deps)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Sort the list, then see if an equivalent list exists already.
|
|
|
|
|
this results in a much smaller set of dependency lists. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct deplist *list;
|
|
|
|
|
char set[0x10000];
|
|
|
|
|
int i;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
memset ((void *)set, 0, sizeof (set));
|
|
|
|
|
for (i = 0; i < count; i++)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
set[deps[i]] = 1;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
count = 0;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < (int) sizeof (set); i++)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (set[i])
|
|
|
|
|
++count;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
list = tmalloc (struct deplist);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
list->len = count;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
list->deps = (unsigned short *) malloc (sizeof (unsigned short) * count);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0, count = 0; i < (int) sizeof (set); i++)
|
|
|
|
|
if (set[i])
|
|
|
|
|
list->deps[count++] = i;
|
|
|
|
|
|
|
|
|
|
/* Does this list exist already? */
|
|
|
|
|
for (i = 0; i < dlistlen; i++)
|
|
|
|
|
if (deplist_equals (list, dlists[i]))
|
|
|
|
|
{
|
|
|
|
|
free (list->deps);
|
|
|
|
|
free (list);
|
|
|
|
|
return i;
|
|
|
|
|
}
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
if (dlistlen == dlisttotlen)
|
|
|
|
|
{
|
|
|
|
|
dlisttotlen += 20;
|
|
|
|
|
dlists = (struct deplist **)
|
|
|
|
|
xrealloc (dlists, sizeof(struct deplist **) * dlisttotlen);
|
|
|
|
|
}
|
|
|
|
|
dlists[dlistlen] = list;
|
|
|
|
|
|
|
|
|
|
return dlistlen++;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Add the given pair of dependency lists to the opcode dependency list. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static short
|
|
|
|
|
insert_dependencies (int nchks, unsigned short *chks,
|
|
|
|
|
int nregs, unsigned short *regs)
|
|
|
|
|
{
|
|
|
|
|
struct opdep *pair;
|
|
|
|
|
int i;
|
|
|
|
|
int regind = -1;
|
|
|
|
|
int chkind = -1;
|
|
|
|
|
|
|
|
|
|
if (nregs > 0)
|
|
|
|
|
regind = insert_deplist (nregs, regs);
|
|
|
|
|
if (nchks > 0)
|
|
|
|
|
chkind = insert_deplist (nchks, chks);
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < opdeplen; i++)
|
|
|
|
|
if (opdeps[i]->chk == chkind
|
|
|
|
|
&& opdeps[i]->reg == regind)
|
|
|
|
|
return i;
|
|
|
|
|
|
|
|
|
|
pair = tmalloc (struct opdep);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
pair->chk = chkind;
|
|
|
|
|
pair->reg = regind;
|
|
|
|
|
|
|
|
|
|
if (opdeplen == opdeptotlen)
|
|
|
|
|
{
|
|
|
|
|
opdeptotlen += 20;
|
|
|
|
|
opdeps = (struct opdep **)
|
|
|
|
|
xrealloc (opdeps, sizeof(struct opdep **) * opdeptotlen);
|
|
|
|
|
}
|
|
|
|
|
opdeps[opdeplen] = pair;
|
|
|
|
|
|
|
|
|
|
return opdeplen++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
mark_used (struct iclass *ic, int clear_terminals)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
ic->orphan = 0;
|
|
|
|
|
if (clear_terminals)
|
|
|
|
|
ic->terminal_resolved = 1;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < ic->nsubs; i++)
|
|
|
|
|
mark_used (ics[ic->subs[i]], clear_terminals);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ic->nxsubs; i++)
|
|
|
|
|
mark_used (ics[ic->xsubs[i]], clear_terminals);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Look up an instruction class; if CREATE make a new one if none found;
|
|
|
|
|
returns the index into the insn class array. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static int
|
2002-11-07 14:33:48 +00:00
|
|
|
|
fetch_insn_class (const char *full_name, int create)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
char *name;
|
|
|
|
|
char *notestr;
|
|
|
|
|
char *xsect;
|
|
|
|
|
char *comment;
|
|
|
|
|
int i, note = 0;
|
|
|
|
|
int ind;
|
|
|
|
|
int is_class = 0;
|
|
|
|
|
|
|
|
|
|
if (strncmp (full_name, "IC:", 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
name = xstrdup (full_name + 3);
|
|
|
|
|
is_class = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
name = xstrdup (full_name);
|
|
|
|
|
|
|
|
|
|
if ((xsect = strchr(name, '\\')) != NULL)
|
|
|
|
|
is_class = 1;
|
|
|
|
|
if ((comment = strchr(name, '[')) != NULL)
|
|
|
|
|
is_class = 1;
|
|
|
|
|
if ((notestr = strchr(name, '+')) != NULL)
|
2001-03-20 02:32:27 +00:00
|
|
|
|
is_class = 1;
|
|
|
|
|
|
|
|
|
|
/* If it is a composite class, then ignore comments and notes that come after
|
|
|
|
|
the '\\', since they don't apply to the part we are decoding now. */
|
|
|
|
|
if (xsect)
|
|
|
|
|
{
|
|
|
|
|
if (comment > xsect)
|
|
|
|
|
comment = 0;
|
|
|
|
|
if (notestr > xsect)
|
|
|
|
|
notestr = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (notestr)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
char *nextnotestr;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
note = atoi (notestr + 1);
|
|
|
|
|
if ((nextnotestr = strchr (notestr + 1, '+')) != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (notestr, "+1+13") == 0)
|
|
|
|
|
note = 13;
|
|
|
|
|
else if (!xsect || nextnotestr < xsect)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("multiple note %s not handled\n"), notestr);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-20 02:32:27 +00:00
|
|
|
|
/* If it's a composite class, leave the notes and comments in place so that
|
|
|
|
|
we have a unique name for the composite class. Otherwise, we remove
|
|
|
|
|
them. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (!xsect)
|
|
|
|
|
{
|
|
|
|
|
if (notestr)
|
|
|
|
|
*notestr = 0;
|
|
|
|
|
if (comment)
|
|
|
|
|
*comment = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < iclen; i++)
|
|
|
|
|
if (strcmp (name, ics[i]->name) == 0
|
2000-04-21 20:22:24 +00:00
|
|
|
|
&& ((comment == NULL && ics[i]->comment == NULL)
|
|
|
|
|
|| (comment != NULL && ics[i]->comment != NULL
|
|
|
|
|
&& strncmp (ics[i]->comment, comment,
|
|
|
|
|
strlen (ics[i]->comment)) == 0))
|
|
|
|
|
&& note == ics[i]->note)
|
|
|
|
|
return i;
|
|
|
|
|
|
|
|
|
|
if (!create)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Doesn't exist, so make a new one. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (iclen == ictotlen)
|
|
|
|
|
{
|
|
|
|
|
ictotlen += 20;
|
|
|
|
|
ics = (struct iclass **)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
xrealloc (ics, (ictotlen) * sizeof (struct iclass *));
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ind = iclen++;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
ics[ind] = tmalloc (struct iclass);
|
|
|
|
|
memset ((void *)ics[ind], 0, sizeof (struct iclass));
|
|
|
|
|
ics[ind]->name = xstrdup (name);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ics[ind]->is_class = is_class;
|
|
|
|
|
ics[ind]->orphan = 1;
|
|
|
|
|
|
|
|
|
|
if (comment)
|
|
|
|
|
{
|
|
|
|
|
ics[ind]->comment = xstrdup (comment + 1);
|
2002-11-07 14:33:48 +00:00
|
|
|
|
ics[ind]->comment[strlen (ics[ind]->comment)-1] = 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (notestr)
|
|
|
|
|
ics[ind]->note = note;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* If it's a composite class, there's a comment or note, look for an
|
|
|
|
|
existing class or terminal with the same name. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if ((xsect || comment || notestr) && is_class)
|
|
|
|
|
{
|
2000-10-04 06:38:01 +00:00
|
|
|
|
/* First, populate with the class we're based on. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
char *subname = name;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (xsect)
|
|
|
|
|
*xsect = 0;
|
|
|
|
|
else if (comment)
|
|
|
|
|
*comment = 0;
|
|
|
|
|
else if (notestr)
|
|
|
|
|
*notestr = 0;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ics[ind]->nsubs = 1;
|
|
|
|
|
ics[ind]->subs = tmalloc(int);
|
|
|
|
|
ics[ind]->subs[0] = fetch_insn_class (subname, 1);;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (xsect)
|
|
|
|
|
{
|
|
|
|
|
char *subname = xsect + 1;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
xsect = strchr (subname, '\\');
|
|
|
|
|
if (xsect)
|
|
|
|
|
*xsect = 0;
|
|
|
|
|
ics[ind]->xsubs[ics[ind]->nxsubs] = fetch_insn_class (subname,1);
|
|
|
|
|
ics[ind]->nxsubs++;
|
|
|
|
|
}
|
|
|
|
|
free (name);
|
|
|
|
|
|
|
|
|
|
return ind;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* For sorting a class's sub-class list only; make sure classes appear before
|
|
|
|
|
terminals. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static int
|
|
|
|
|
sub_compare (const void *e1, const void *e2)
|
|
|
|
|
{
|
|
|
|
|
struct iclass *ic1 = ics[*(int *)e1];
|
|
|
|
|
struct iclass *ic2 = ics[*(int *)e2];
|
|
|
|
|
|
|
|
|
|
if (ic1->is_class)
|
|
|
|
|
{
|
|
|
|
|
if (!ic2->is_class)
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else if (ic2->is_class)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return strcmp (ic1->name, ic2->name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2002-11-07 14:33:48 +00:00
|
|
|
|
load_insn_classes (void)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
FILE *fp = fopen ("ia64-ic.tbl", "r");
|
2000-04-21 20:22:24 +00:00
|
|
|
|
char buf[2048];
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (fp == NULL)
|
|
|
|
|
fail (_("can't find ia64-ic.tbl for reading\n"));
|
2000-04-23 02:39:13 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Discard first line. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
fgets (buf, sizeof(buf), fp);
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
while (!feof (fp))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int iclass;
|
|
|
|
|
char *name;
|
|
|
|
|
char *tmp;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (fgets (buf, sizeof (buf), fp) == NULL)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
while (ISSPACE (buf[strlen (buf) - 1]))
|
|
|
|
|
buf[strlen (buf) - 1] = '\0';
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
name = tmp = buf;
|
|
|
|
|
while (*tmp != ';')
|
|
|
|
|
{
|
|
|
|
|
++tmp;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (tmp == buf + sizeof (buf))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
*tmp++ = '\0';
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
iclass = fetch_insn_class (name, 1);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ics[iclass]->is_class = 1;
|
|
|
|
|
|
|
|
|
|
if (strcmp (name, "none") == 0)
|
|
|
|
|
{
|
|
|
|
|
ics[iclass]->is_class = 0;
|
|
|
|
|
ics[iclass]->terminal_resolved = 1;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* For this class, record all sub-classes. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
while (*tmp)
|
|
|
|
|
{
|
|
|
|
|
char *subname;
|
|
|
|
|
int sub;
|
|
|
|
|
|
2001-09-19 05:33:36 +00:00
|
|
|
|
while (*tmp && ISSPACE (*tmp))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
++tmp;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (tmp == buf + sizeof (buf))
|
|
|
|
|
abort ();
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
subname = tmp;
|
|
|
|
|
while (*tmp && *tmp != ',')
|
|
|
|
|
{
|
|
|
|
|
++tmp;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (tmp == buf + sizeof (buf))
|
|
|
|
|
abort ();
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
if (*tmp == ',')
|
|
|
|
|
*tmp++ = '\0';
|
|
|
|
|
|
|
|
|
|
ics[iclass]->subs = (int *)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
xrealloc ((void *)ics[iclass]->subs,
|
|
|
|
|
(ics[iclass]->nsubs + 1) * sizeof (int));
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
sub = fetch_insn_class (subname, 1);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ics[iclass]->subs = (int *)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
xrealloc (ics[iclass]->subs, (ics[iclass]->nsubs + 1) * sizeof (int));
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ics[iclass]->subs[ics[iclass]->nsubs++] = sub;
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
|
|
|
|
/* Make sure classes come before terminals. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
qsort ((void *)ics[iclass]->subs,
|
|
|
|
|
ics[iclass]->nsubs, sizeof(int), sub_compare);
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
fclose (fp);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
if (debug)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("%d classes\n", iclen);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Extract the insn classes from the given line. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static void
|
2002-11-07 14:33:48 +00:00
|
|
|
|
parse_resource_users (ref, usersp, nusersp, notesp)
|
|
|
|
|
const char *ref;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int **usersp;
|
|
|
|
|
int *nusersp;
|
|
|
|
|
int **notesp;
|
|
|
|
|
{
|
|
|
|
|
int c;
|
|
|
|
|
char *line = xstrdup (ref);
|
|
|
|
|
char *tmp = line;
|
|
|
|
|
int *users = *usersp;
|
|
|
|
|
int count = *nusersp;
|
|
|
|
|
int *notes = *notesp;
|
|
|
|
|
|
|
|
|
|
c = *tmp;
|
|
|
|
|
while (c != 0)
|
|
|
|
|
{
|
|
|
|
|
char *notestr;
|
|
|
|
|
int note;
|
|
|
|
|
char *xsect;
|
|
|
|
|
int iclass;
|
|
|
|
|
int create = 0;
|
|
|
|
|
char *name;
|
|
|
|
|
|
2001-09-19 05:33:36 +00:00
|
|
|
|
while (ISSPACE (*tmp))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
++tmp;
|
|
|
|
|
name = tmp;
|
|
|
|
|
while (*tmp && *tmp != ',')
|
|
|
|
|
++tmp;
|
|
|
|
|
c = *tmp;
|
|
|
|
|
*tmp++ = '\0';
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
xsect = strchr (name, '\\');
|
|
|
|
|
if ((notestr = strstr (name, "+")) != NULL)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
char *nextnotestr;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
note = atoi (notestr + 1);
|
|
|
|
|
if ((nextnotestr = strchr (notestr + 1, '+')) != NULL)
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Note 13 always implies note 1. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (strcmp (notestr, "+1+13") == 0)
|
|
|
|
|
note = 13;
|
|
|
|
|
else if (!xsect || nextnotestr < xsect)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("multiple note %s not handled\n"), notestr);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
if (!xsect)
|
|
|
|
|
*notestr = '\0';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
note = 0;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
/* All classes are created when the insn class table is parsed;
|
|
|
|
|
Individual instructions might not appear until the dependency tables
|
|
|
|
|
are read. Only create new classes if it's *not* an insn class,
|
|
|
|
|
or if it's a composite class (which wouldn't necessarily be in the IC
|
2002-11-07 14:33:48 +00:00
|
|
|
|
table). */
|
|
|
|
|
if (strncmp (name, "IC:", 3) != 0 || xsect != NULL)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
create = 1;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
iclass = fetch_insn_class (name, create);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (iclass != -1)
|
|
|
|
|
{
|
|
|
|
|
users = (int *)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
xrealloc ((void *) users,(count + 1) * sizeof (int));
|
2000-04-21 20:22:24 +00:00
|
|
|
|
notes = (int *)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
xrealloc ((void *) notes,(count + 1) * sizeof (int));
|
2000-04-21 20:22:24 +00:00
|
|
|
|
notes[count] = note;
|
|
|
|
|
users[count++] = iclass;
|
|
|
|
|
mark_used (ics[iclass], 0);
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
else if (debug)
|
|
|
|
|
printf("Class %s not found\n", name);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Update the return values. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
*usersp = users;
|
|
|
|
|
*nusersp = count;
|
|
|
|
|
*notesp = notes;
|
|
|
|
|
|
|
|
|
|
free (line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
parse_semantics (char *sem)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (sem, "none") == 0)
|
|
|
|
|
return IA64_DVS_NONE;
|
|
|
|
|
else if (strcmp (sem, "implied") == 0)
|
|
|
|
|
return IA64_DVS_IMPLIED;
|
|
|
|
|
else if (strcmp (sem, "impliedF") == 0)
|
|
|
|
|
return IA64_DVS_IMPLIEDF;
|
|
|
|
|
else if (strcmp (sem, "data") == 0)
|
|
|
|
|
return IA64_DVS_DATA;
|
|
|
|
|
else if (strcmp (sem, "instr") == 0)
|
|
|
|
|
return IA64_DVS_INSTR;
|
|
|
|
|
else if (strcmp (sem, "specific") == 0)
|
|
|
|
|
return IA64_DVS_SPECIFIC;
|
Fix ia64 gas testsuite. Update ia64 DV tables. Fix ia64 gas testsuite again.
gas/ChangeLog
* config/tc-ia64.c (dv_sem): Add "stop".
(specify_resource, case IA64_RS_PR): Only handles regs 1 to 15 now.
(specify_resource, case IA64_RS_PRr): New for regs 16 to 62.
(specify_resource, case IA64_RS_PR63): Reorder (note == 7) test to
match above.
(mark_resources): Check IA64_RS_PRr.
gas/testsuite/ChangeLog
* gas/ia64/dv-raw-err.s: Add new testcases for PR%, 16 - 62.
* gas/ia64/dv-waw-err.s: Likewise.
* gas/ia64/dv-imply.d: Regenerate.
* gas/ia64/dv-mutex.d, gas/ia64/dv-raw-err.l, gas/ia64/dv-safe.d,
gas/ia64/dv-srlz.d, gas/ia64/dv-war-err.l, gas/ia64/dv-waw-err.l,
gas/ia64/opc-f.d, gas/ia64/opc-i.d, gas/ia64/opc-m.d: Likewise.
include/opcode/ChangeLog
* ia64.h (enum ia64_dependency_semantics): Add IA64_DVS_STOP.
opcodes/ChangeLog
* ia64-dis.c (print_insn_ia64): Revert Aug 7 byte skip count change.
* ia64-gen.c (parse_semantics): Handle IA64_DVS_STOP.
(lookup_specifier): Handle "PR%, 1 to 15" and "PR%, 16 to 62".
* ia64-ic.tbl, ia64-raw.tbl, ia64-war.tbl, ia64-waw.tbl: Update.
* ia64-asmtab.c: Regnerate.
2000-09-22 19:43:50 +00:00
|
|
|
|
else if (strcmp (sem, "stop") == 0)
|
|
|
|
|
return IA64_DVS_STOP;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
|
|
|
|
return IA64_DVS_OTHER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_dep (const char *name, const char *chk, const char *reg,
|
|
|
|
|
int semantics, int mode, char *extra, int flag)
|
|
|
|
|
{
|
|
|
|
|
struct rdep *rs;
|
|
|
|
|
|
|
|
|
|
rs = insert_resource (name, mode);
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
|
|
|
|
parse_resource_users (chk, &rs->chks, &rs->nchks, &rs->chknotes);
|
|
|
|
|
parse_resource_users (reg, &rs->regs, &rs->nregs, &rs->regnotes);
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
rs->semantics = semantics;
|
|
|
|
|
rs->extra = extra;
|
|
|
|
|
rs->waw_special = flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
load_depfile (const char *filename, enum ia64_dependency_mode mode)
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
FILE *fp = fopen (filename, "r");
|
2000-04-21 20:22:24 +00:00
|
|
|
|
char buf[1024];
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (fp == NULL)
|
|
|
|
|
fail (_("can't find %s for reading\n"), filename);
|
2000-04-23 02:39:13 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
fgets (buf, sizeof(buf), fp);
|
|
|
|
|
while (!feof (fp))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
char *name, *tmp;
|
|
|
|
|
int semantics;
|
|
|
|
|
char *extra;
|
|
|
|
|
char *regp, *chkp;
|
|
|
|
|
|
|
|
|
|
if (fgets (buf, sizeof(buf), fp) == NULL)
|
|
|
|
|
break;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
while (ISSPACE (buf[strlen (buf) - 1]))
|
|
|
|
|
buf[strlen (buf) - 1] = '\0';
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
name = tmp = buf;
|
|
|
|
|
while (*tmp != ';')
|
|
|
|
|
++tmp;
|
|
|
|
|
*tmp++ = '\0';
|
|
|
|
|
|
2001-09-19 05:33:36 +00:00
|
|
|
|
while (ISSPACE (*tmp))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
++tmp;
|
|
|
|
|
regp = tmp;
|
|
|
|
|
tmp = strchr (tmp, ';');
|
|
|
|
|
if (!tmp)
|
|
|
|
|
abort ();
|
|
|
|
|
*tmp++ = 0;
|
2001-09-19 05:33:36 +00:00
|
|
|
|
while (ISSPACE (*tmp))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
++tmp;
|
|
|
|
|
chkp = tmp;
|
|
|
|
|
tmp = strchr (tmp, ';');
|
|
|
|
|
if (!tmp)
|
|
|
|
|
abort ();
|
|
|
|
|
*tmp++ = 0;
|
2001-09-19 05:33:36 +00:00
|
|
|
|
while (ISSPACE (*tmp))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
++tmp;
|
|
|
|
|
semantics = parse_semantics (tmp);
|
|
|
|
|
extra = semantics == IA64_DVS_OTHER ? xstrdup (tmp) : NULL;
|
|
|
|
|
|
|
|
|
|
/* For WAW entries, if the chks and regs differ, we need to enter the
|
|
|
|
|
entries in both positions so that the tables will be parsed properly,
|
2002-11-07 14:33:48 +00:00
|
|
|
|
without a lot of extra work. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (mode == IA64_DV_WAW && strcmp (regp, chkp) != 0)
|
|
|
|
|
{
|
|
|
|
|
add_dep (name, chkp, regp, semantics, mode, extra, 0);
|
|
|
|
|
add_dep (name, regp, chkp, semantics, mode, extra, 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
add_dep (name, chkp, regp, semantics, mode, extra, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
fclose (fp);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2002-11-07 14:33:48 +00:00
|
|
|
|
load_dependencies (void)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
load_depfile ("ia64-raw.tbl", IA64_DV_RAW);
|
|
|
|
|
load_depfile ("ia64-waw.tbl", IA64_DV_WAW);
|
|
|
|
|
load_depfile ("ia64-war.tbl", IA64_DV_WAR);
|
|
|
|
|
|
|
|
|
|
if (debug)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("%d RAW/WAW/WAR dependencies\n", rdepslen);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Is the given operand an indirect register file operand? */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static int
|
|
|
|
|
irf_operand (int op, const char *field)
|
|
|
|
|
{
|
|
|
|
|
if (!field)
|
|
|
|
|
{
|
|
|
|
|
return op == IA64_OPND_RR_R3 || op == IA64_OPND_DBR_R3
|
2000-05-30 18:35:35 +00:00
|
|
|
|
|| op == IA64_OPND_IBR_R3 || op == IA64_OPND_PKR_R3
|
|
|
|
|
|| op == IA64_OPND_PMC_R3 || op == IA64_OPND_PMD_R3
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|| op == IA64_OPND_MSR_R3 || op == IA64_OPND_CPUID_R3;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return ((op == IA64_OPND_RR_R3 && strstr (field, "rr"))
|
|
|
|
|
|| (op == IA64_OPND_DBR_R3 && strstr (field, "dbr"))
|
|
|
|
|
|| (op == IA64_OPND_IBR_R3 && strstr (field, "ibr"))
|
|
|
|
|
|| (op == IA64_OPND_PKR_R3 && strstr (field, "pkr"))
|
|
|
|
|
|| (op == IA64_OPND_PMC_R3 && strstr (field, "pmc"))
|
|
|
|
|
|| (op == IA64_OPND_PMD_R3 && strstr (field, "pmd"))
|
|
|
|
|
|| (op == IA64_OPND_MSR_R3 && strstr (field, "msr"))
|
|
|
|
|
|| (op == IA64_OPND_CPUID_R3 && strstr (field, "cpuid")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Handle mov_ar, mov_br, mov_cr, mov_indirect, mov_ip, mov_pr, mov_psr, and
|
|
|
|
|
mov_um insn classes. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static int
|
|
|
|
|
in_iclass_mov_x (struct ia64_opcode *idesc, struct iclass *ic,
|
|
|
|
|
const char *format, const char *field)
|
|
|
|
|
{
|
|
|
|
|
int plain_mov = strcmp (idesc->name, "mov") == 0;
|
|
|
|
|
|
|
|
|
|
if (!format)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
switch (ic->name[4])
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
case 'a':
|
|
|
|
|
{
|
|
|
|
|
int i = strcmp (idesc->name, "mov.i") == 0;
|
|
|
|
|
int m = strcmp (idesc->name, "mov.m") == 0;
|
|
|
|
|
int i2627 = i && idesc->operands[0] == IA64_OPND_AR3;
|
|
|
|
|
int i28 = i && idesc->operands[1] == IA64_OPND_AR3;
|
|
|
|
|
int m2930 = m && idesc->operands[0] == IA64_OPND_AR3;
|
|
|
|
|
int m31 = m && idesc->operands[1] == IA64_OPND_AR3;
|
|
|
|
|
int pseudo0 = plain_mov && idesc->operands[1] == IA64_OPND_AR3;
|
|
|
|
|
int pseudo1 = plain_mov && idesc->operands[0] == IA64_OPND_AR3;
|
|
|
|
|
|
|
|
|
|
/* IC:mov ar */
|
|
|
|
|
if (i2627)
|
|
|
|
|
return strstr (format, "I26") || strstr (format, "I27");
|
|
|
|
|
if (i28)
|
|
|
|
|
return strstr (format, "I28") != NULL;
|
|
|
|
|
if (m2930)
|
|
|
|
|
return strstr (format, "M29") || strstr (format, "M30");
|
|
|
|
|
if (m31)
|
|
|
|
|
return strstr (format, "M31") != NULL;
|
|
|
|
|
if (pseudo0 || pseudo1)
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'b':
|
|
|
|
|
{
|
|
|
|
|
int i21 = idesc->operands[0] == IA64_OPND_B1;
|
|
|
|
|
int i22 = plain_mov && idesc->operands[1] == IA64_OPND_B2;
|
|
|
|
|
if (i22)
|
|
|
|
|
return strstr (format, "I22") != NULL;
|
|
|
|
|
if (i21)
|
|
|
|
|
return strstr (format, "I21") != NULL;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'c':
|
|
|
|
|
{
|
|
|
|
|
int m32 = plain_mov && idesc->operands[0] == IA64_OPND_CR3;
|
|
|
|
|
int m33 = plain_mov && idesc->operands[1] == IA64_OPND_CR3;
|
|
|
|
|
if (m32)
|
|
|
|
|
return strstr (format, "M32") != NULL;
|
|
|
|
|
if (m33)
|
|
|
|
|
return strstr (format, "M33") != NULL;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'i':
|
|
|
|
|
if (ic->name[5] == 'n')
|
|
|
|
|
{
|
|
|
|
|
int m42 = plain_mov && irf_operand (idesc->operands[0], field);
|
|
|
|
|
int m43 = plain_mov && irf_operand (idesc->operands[1], field);
|
|
|
|
|
if (m42)
|
|
|
|
|
return strstr (format, "M42") != NULL;
|
|
|
|
|
if (m43)
|
|
|
|
|
return strstr (format, "M43") != NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (ic->name[5] == 'p')
|
|
|
|
|
{
|
|
|
|
|
return idesc->operands[1] == IA64_OPND_IP;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
abort ();
|
|
|
|
|
break;
|
|
|
|
|
case 'p':
|
|
|
|
|
if (ic->name[5] == 'r')
|
|
|
|
|
{
|
|
|
|
|
int i25 = plain_mov && idesc->operands[1] == IA64_OPND_PR;
|
|
|
|
|
int i23 = plain_mov && idesc->operands[0] == IA64_OPND_PR;
|
|
|
|
|
int i24 = plain_mov && idesc->operands[0] == IA64_OPND_PR_ROT;
|
|
|
|
|
if (i23)
|
|
|
|
|
return strstr (format, "I23") != NULL;
|
|
|
|
|
if (i24)
|
|
|
|
|
return strstr (format, "I24") != NULL;
|
|
|
|
|
if (i25)
|
|
|
|
|
return strstr (format, "I25") != NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (ic->name[5] == 's')
|
|
|
|
|
{
|
|
|
|
|
int m35 = plain_mov && idesc->operands[0] == IA64_OPND_PSR_L;
|
|
|
|
|
int m36 = plain_mov && idesc->operands[1] == IA64_OPND_PSR;
|
|
|
|
|
if (m35)
|
|
|
|
|
return strstr (format, "M35") != NULL;
|
|
|
|
|
if (m36)
|
|
|
|
|
return strstr (format, "M36") != NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
abort ();
|
|
|
|
|
break;
|
|
|
|
|
case 'u':
|
|
|
|
|
{
|
|
|
|
|
int m35 = plain_mov && idesc->operands[0] == IA64_OPND_PSR_UM;
|
|
|
|
|
int m36 = plain_mov && idesc->operands[1] == IA64_OPND_PSR_UM;
|
|
|
|
|
if (m35)
|
|
|
|
|
return strstr (format, "M35") != NULL;
|
|
|
|
|
if (m36)
|
|
|
|
|
return strstr (format, "M36") != NULL;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Is the given opcode in the given insn class? */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static int
|
2002-11-07 14:33:48 +00:00
|
|
|
|
in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
|
|
|
|
|
const char *format, const char *field, int *notep)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int resolved = 0;
|
|
|
|
|
|
|
|
|
|
if (ic->comment)
|
|
|
|
|
{
|
|
|
|
|
if (!strncmp (ic->comment, "Format", 6))
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Assume that the first format seen is the most restrictive, and
|
|
|
|
|
only keep a later one if it looks like it's more restrictive. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (format)
|
|
|
|
|
{
|
|
|
|
|
if (strlen (ic->comment) < strlen (format))
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("most recent format '%s'\nappears more restrictive than '%s'\n"),
|
|
|
|
|
ic->comment, format);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
format = ic->comment;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
format = ic->comment;
|
|
|
|
|
}
|
|
|
|
|
else if (!strncmp (ic->comment, "Field", 5))
|
|
|
|
|
{
|
|
|
|
|
if (field)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("overlapping field %s->%s\n"),
|
|
|
|
|
ic->comment, field);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
field = ic->comment;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* An insn class matches anything that is the same followed by completers,
|
2000-04-21 20:22:24 +00:00
|
|
|
|
except when the absence and presence of completers constitutes different
|
2002-11-07 14:33:48 +00:00
|
|
|
|
instructions. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ic->nsubs == 0 && ic->nxsubs == 0)
|
|
|
|
|
{
|
|
|
|
|
int is_mov = strncmp (idesc->name, "mov", 3) == 0;
|
|
|
|
|
int plain_mov = strcmp (idesc->name, "mov") == 0;
|
|
|
|
|
int len = strlen(ic->name);
|
|
|
|
|
|
|
|
|
|
resolved = ((strncmp (ic->name, idesc->name, len) == 0)
|
|
|
|
|
&& (idesc->name[len] == '\0'
|
|
|
|
|
|| idesc->name[len] == '.'));
|
|
|
|
|
|
Patch to update IA-64 port to SDM 2.1.
bfd/ChangeLog
* cpu-ia64-opc.c: Add operand constant "ar.csd".
gas/ChangeLog
* config/tc-ia64.c (pseudo_func): Add "@pause" constant for "hint"
instruction.
(emit_one_bundle): Handle "hint" instruction.
(operand_match): Match IA64_OPND_AR_CSD.
gas/testsuite/ChangeLog
* gas/ia64/opc-b.d: Update for instructions added by SDM2.1.
* gas/ia64/opc-b.s: Ditto.
* gas/ia64/opc-f.d: Ditto.
* gas/ia64/opc-f.s: Ditto.
* gas/ia64/opc-i.d: Ditto.
* gas/ia64/opc-i.s: Ditto.
* gas/ia64/opc-m.d: Ditto.
* gas/ia64/opc-m.s: Ditto.
* gas/ia64/opc-x.d: Ditto.
* gas/ia64/opc-x.s: Ditto.
include/opcode/ChangeLog
* ia64.h: Fix copyright message.
(IA64_OPND_AR_CSD): New operand kind.
opcodes/ChangeLog
* ia64-opc-d.c (ia64_opcodes_d): Add "hint" instruction.
* ia64-opc-b.c: Add "hint.b" instruction.
* ia64-opc-f.c: Add "hint.f" instruction.
* ia64-opc-i.c: Add "hint.i" instruction.
* ia64-opc-m.c: Add "hint.m", "fc.i", "ld16", "st16", and
"cmp8xchg16" instructions.
* ia64-opc-x.c: Add "hint.x" instruction.
* ia64-opc.h (AR_CSD): New macro.
* ia64-ic.tbl: Update according to SDM2.1.
* ia64-raw.tbl: Ditto.
* ia64-waw.tbl: Ditto.
* ia64-gen.c (in_iclass): Handle "hint" like "nop".
(lookup_regindex): Recognize AR[FCR], AR[EFLAG], AR[CSD],
AR[SSD], AR[CFLG], AR[FSR], AR[FIR], and AR[FDR].
* ia64-asmtab.c: Regenerate.
2002-12-05 02:08:02 +00:00
|
|
|
|
/* All break, nop, and hint variations must match exactly. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (resolved &&
|
|
|
|
|
(strcmp (ic->name, "break") == 0
|
Patch to update IA-64 port to SDM 2.1.
bfd/ChangeLog
* cpu-ia64-opc.c: Add operand constant "ar.csd".
gas/ChangeLog
* config/tc-ia64.c (pseudo_func): Add "@pause" constant for "hint"
instruction.
(emit_one_bundle): Handle "hint" instruction.
(operand_match): Match IA64_OPND_AR_CSD.
gas/testsuite/ChangeLog
* gas/ia64/opc-b.d: Update for instructions added by SDM2.1.
* gas/ia64/opc-b.s: Ditto.
* gas/ia64/opc-f.d: Ditto.
* gas/ia64/opc-f.s: Ditto.
* gas/ia64/opc-i.d: Ditto.
* gas/ia64/opc-i.s: Ditto.
* gas/ia64/opc-m.d: Ditto.
* gas/ia64/opc-m.s: Ditto.
* gas/ia64/opc-x.d: Ditto.
* gas/ia64/opc-x.s: Ditto.
include/opcode/ChangeLog
* ia64.h: Fix copyright message.
(IA64_OPND_AR_CSD): New operand kind.
opcodes/ChangeLog
* ia64-opc-d.c (ia64_opcodes_d): Add "hint" instruction.
* ia64-opc-b.c: Add "hint.b" instruction.
* ia64-opc-f.c: Add "hint.f" instruction.
* ia64-opc-i.c: Add "hint.i" instruction.
* ia64-opc-m.c: Add "hint.m", "fc.i", "ld16", "st16", and
"cmp8xchg16" instructions.
* ia64-opc-x.c: Add "hint.x" instruction.
* ia64-opc.h (AR_CSD): New macro.
* ia64-ic.tbl: Update according to SDM2.1.
* ia64-raw.tbl: Ditto.
* ia64-waw.tbl: Ditto.
* ia64-gen.c (in_iclass): Handle "hint" like "nop".
(lookup_regindex): Recognize AR[FCR], AR[EFLAG], AR[CSD],
AR[SSD], AR[CFLG], AR[FSR], AR[FIR], and AR[FDR].
* ia64-asmtab.c: Regenerate.
2002-12-05 02:08:02 +00:00
|
|
|
|
|| strcmp (ic->name, "nop") == 0
|
|
|
|
|
|| strcmp (ic->name, "hint") == 0))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
resolved = strcmp (ic->name, idesc->name) == 0;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Assume restrictions in the FORMAT/FIELD negate resolution,
|
|
|
|
|
unless specifically allowed by clauses in this block. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (resolved && field)
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Check Field(sf)==sN against opcode sN. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (strstr(field, "(sf)==") != NULL)
|
|
|
|
|
{
|
|
|
|
|
char *sf;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if ((sf = strstr (idesc->name, ".s")) != 0)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
resolved = strcmp (sf + 1, strstr (field, "==") + 2) == 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Check Field(lftype)==XXX. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (strstr (field, "(lftype)") != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (strstr (idesc->name, "fault") != NULL)
|
|
|
|
|
resolved = strstr (field, "fault") != NULL;
|
|
|
|
|
else
|
|
|
|
|
resolved = strstr (field, "fault") == NULL;
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Handle Field(ctype)==XXX. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (strstr (field, "(ctype)") != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (strstr (idesc->name, "or.andcm"))
|
|
|
|
|
resolved = strstr (field, "or.andcm") != NULL;
|
|
|
|
|
else if (strstr (idesc->name, "and.orcm"))
|
|
|
|
|
resolved = strstr (field, "and.orcm") != NULL;
|
|
|
|
|
else if (strstr (idesc->name, "orcm"))
|
|
|
|
|
resolved = strstr (field, "or orcm") != NULL;
|
|
|
|
|
else if (strstr (idesc->name, "or"))
|
|
|
|
|
resolved = strstr (field, "or orcm") != NULL;
|
|
|
|
|
else if (strstr (idesc->name, "andcm"))
|
|
|
|
|
resolved = strstr (field, "and andcm") != NULL;
|
|
|
|
|
else if (strstr (idesc->name, "and"))
|
|
|
|
|
resolved = strstr (field, "and andcm") != NULL;
|
|
|
|
|
else if (strstr (idesc->name, "unc"))
|
|
|
|
|
resolved = strstr (field, "unc") != NULL;
|
|
|
|
|
else
|
|
|
|
|
resolved = strcmp (field, "Field(ctype)==") == 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (resolved && format)
|
|
|
|
|
{
|
|
|
|
|
if (strncmp (idesc->name, "dep", 3) == 0
|
|
|
|
|
&& strstr (format, "I13") != NULL)
|
|
|
|
|
resolved = idesc->operands[1] == IA64_OPND_IMM8;
|
|
|
|
|
else if (strncmp (idesc->name, "chk", 3) == 0
|
|
|
|
|
&& strstr (format, "M21") != NULL)
|
|
|
|
|
resolved = idesc->operands[0] == IA64_OPND_F2;
|
|
|
|
|
else if (strncmp (idesc->name, "lfetch", 6) == 0)
|
|
|
|
|
resolved = (strstr (format, "M14 M15") != NULL
|
|
|
|
|
&& (idesc->operands[1] == IA64_OPND_R2
|
|
|
|
|
|| idesc->operands[1] == IA64_OPND_IMM9b));
|
|
|
|
|
else if (strncmp (idesc->name, "br.call", 7) == 0
|
|
|
|
|
&& strstr (format, "B5") != NULL)
|
|
|
|
|
resolved = idesc->operands[1] == IA64_OPND_B2;
|
|
|
|
|
else if (strncmp (idesc->name, "br.call", 7) == 0
|
|
|
|
|
&& strstr (format, "B3") != NULL)
|
|
|
|
|
resolved = idesc->operands[1] == IA64_OPND_TGT25c;
|
|
|
|
|
else if (strncmp (idesc->name, "brp", 3) == 0
|
|
|
|
|
&& strstr (format, "B7") != NULL)
|
|
|
|
|
resolved = idesc->operands[0] == IA64_OPND_B2;
|
|
|
|
|
else if (strcmp (ic->name, "invala") == 0)
|
|
|
|
|
resolved = strcmp (idesc->name, ic->name) == 0;
|
2001-03-20 02:32:27 +00:00
|
|
|
|
else if (strncmp (idesc->name, "st", 2) == 0
|
2004-06-08 20:40:59 +00:00
|
|
|
|
&& (strstr (format, "M5") != NULL
|
|
|
|
|
|| strstr (format, "M10") != NULL))
|
|
|
|
|
resolved = idesc->flags & IA64_OPCODE_POSTINC;
|
|
|
|
|
else if (strncmp (idesc->name, "ld", 2) == 0
|
|
|
|
|
&& (strstr (format, "M2 M3") != NULL
|
|
|
|
|
|| strstr (format, "M12") != NULL
|
|
|
|
|
|| strstr (format, "M7 M8") != NULL))
|
2001-03-20 02:32:27 +00:00
|
|
|
|
resolved = idesc->flags & IA64_OPCODE_POSTINC;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
|
|
|
|
resolved = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Misc brl variations ('.cond' is optional);
|
|
|
|
|
plain brl matches brl.cond. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (!resolved
|
|
|
|
|
&& (strcmp (idesc->name, "brl") == 0
|
|
|
|
|
|| strncmp (idesc->name, "brl.", 4) == 0)
|
|
|
|
|
&& strcmp (ic->name, "brl.cond") == 0)
|
|
|
|
|
{
|
|
|
|
|
resolved = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Misc br variations ('.cond' is optional). */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (!resolved
|
|
|
|
|
&& (strcmp (idesc->name, "br") == 0
|
|
|
|
|
|| strncmp (idesc->name, "br.", 3) == 0)
|
|
|
|
|
&& strcmp (ic->name, "br.cond") == 0)
|
|
|
|
|
{
|
|
|
|
|
if (format)
|
|
|
|
|
resolved = (strstr (format, "B4") != NULL
|
|
|
|
|
&& idesc->operands[0] == IA64_OPND_B2)
|
|
|
|
|
|| (strstr (format, "B1") != NULL
|
|
|
|
|
&& idesc->operands[0] == IA64_OPND_TGT25c);
|
|
|
|
|
else
|
|
|
|
|
resolved = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* probe variations. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (!resolved && strncmp (idesc->name, "probe", 5) == 0)
|
|
|
|
|
{
|
|
|
|
|
resolved = strcmp (ic->name, "probe") == 0
|
|
|
|
|
&& !((strstr (idesc->name, "fault") != NULL)
|
|
|
|
|
^ (format && strstr (format, "M40") != NULL));
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
|
|
|
|
/* mov variations. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (!resolved && is_mov)
|
|
|
|
|
{
|
|
|
|
|
if (plain_mov)
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* mov alias for fmerge. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (strcmp (ic->name, "fmerge") == 0)
|
|
|
|
|
{
|
|
|
|
|
resolved = idesc->operands[0] == IA64_OPND_F1
|
|
|
|
|
&& idesc->operands[1] == IA64_OPND_F3;
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* mov alias for adds (r3 or imm14). */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (strcmp (ic->name, "adds") == 0)
|
|
|
|
|
{
|
|
|
|
|
resolved = (idesc->operands[0] == IA64_OPND_R1
|
|
|
|
|
&& (idesc->operands[1] == IA64_OPND_R3
|
|
|
|
|
|| (idesc->operands[1] == IA64_OPND_IMM14)));
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* mov alias for addl. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (strcmp (ic->name, "addl") == 0)
|
|
|
|
|
{
|
|
|
|
|
resolved = idesc->operands[0] == IA64_OPND_R1
|
|
|
|
|
&& idesc->operands[1] == IA64_OPND_IMM22;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
|
|
|
|
/* Some variants of mov and mov.[im]. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (!resolved && strncmp (ic->name, "mov_", 4) == 0)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
resolved = in_iclass_mov_x (idesc, ic, format, field);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Keep track of this so we can flag any insn classes which aren't
|
|
|
|
|
mapped onto at least one real insn. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (resolved)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
ic->terminal_resolved = 1;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
else for (i = 0; i < ic->nsubs; i++)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (in_iclass (idesc, ics[ic->subs[i]], format, field, notep))
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int j;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
|
|
|
|
for (j = 0; j < ic->nxsubs; j++)
|
|
|
|
|
if (in_iclass (idesc, ics[ic->xsubs[j]], NULL, NULL, NULL))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (debug > 1)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("%s is in IC %s\n", idesc->name, ic->name);
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
resolved = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* If it's in this IC, add the IC note (if any) to the insn. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (resolved)
|
|
|
|
|
{
|
|
|
|
|
if (ic->note && notep)
|
|
|
|
|
{
|
|
|
|
|
if (*notep && *notep != ic->note)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("overwriting note %d with note %d (IC:%s)\n"),
|
|
|
|
|
*notep, ic->note, ic->name);
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
*notep = ic->note;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resolved;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
lookup_regindex (const char *name, int specifier)
|
|
|
|
|
{
|
|
|
|
|
switch (specifier)
|
|
|
|
|
{
|
|
|
|
|
case IA64_RS_ARX:
|
|
|
|
|
if (strstr (name, "[RSC]"))
|
|
|
|
|
return 16;
|
|
|
|
|
if (strstr (name, "[BSP]"))
|
|
|
|
|
return 17;
|
|
|
|
|
else if (strstr (name, "[BSPSTORE]"))
|
|
|
|
|
return 18;
|
|
|
|
|
else if (strstr (name, "[RNAT]"))
|
|
|
|
|
return 19;
|
Patch to update IA-64 port to SDM 2.1.
bfd/ChangeLog
* cpu-ia64-opc.c: Add operand constant "ar.csd".
gas/ChangeLog
* config/tc-ia64.c (pseudo_func): Add "@pause" constant for "hint"
instruction.
(emit_one_bundle): Handle "hint" instruction.
(operand_match): Match IA64_OPND_AR_CSD.
gas/testsuite/ChangeLog
* gas/ia64/opc-b.d: Update for instructions added by SDM2.1.
* gas/ia64/opc-b.s: Ditto.
* gas/ia64/opc-f.d: Ditto.
* gas/ia64/opc-f.s: Ditto.
* gas/ia64/opc-i.d: Ditto.
* gas/ia64/opc-i.s: Ditto.
* gas/ia64/opc-m.d: Ditto.
* gas/ia64/opc-m.s: Ditto.
* gas/ia64/opc-x.d: Ditto.
* gas/ia64/opc-x.s: Ditto.
include/opcode/ChangeLog
* ia64.h: Fix copyright message.
(IA64_OPND_AR_CSD): New operand kind.
opcodes/ChangeLog
* ia64-opc-d.c (ia64_opcodes_d): Add "hint" instruction.
* ia64-opc-b.c: Add "hint.b" instruction.
* ia64-opc-f.c: Add "hint.f" instruction.
* ia64-opc-i.c: Add "hint.i" instruction.
* ia64-opc-m.c: Add "hint.m", "fc.i", "ld16", "st16", and
"cmp8xchg16" instructions.
* ia64-opc-x.c: Add "hint.x" instruction.
* ia64-opc.h (AR_CSD): New macro.
* ia64-ic.tbl: Update according to SDM2.1.
* ia64-raw.tbl: Ditto.
* ia64-waw.tbl: Ditto.
* ia64-gen.c (in_iclass): Handle "hint" like "nop".
(lookup_regindex): Recognize AR[FCR], AR[EFLAG], AR[CSD],
AR[SSD], AR[CFLG], AR[FSR], AR[FIR], and AR[FDR].
* ia64-asmtab.c: Regenerate.
2002-12-05 02:08:02 +00:00
|
|
|
|
else if (strstr (name, "[FCR]"))
|
|
|
|
|
return 21;
|
|
|
|
|
else if (strstr (name, "[EFLAG]"))
|
|
|
|
|
return 24;
|
|
|
|
|
else if (strstr (name, "[CSD]"))
|
|
|
|
|
return 25;
|
|
|
|
|
else if (strstr (name, "[SSD]"))
|
|
|
|
|
return 26;
|
|
|
|
|
else if (strstr (name, "[CFLG]"))
|
|
|
|
|
return 27;
|
|
|
|
|
else if (strstr (name, "[FSR]"))
|
|
|
|
|
return 28;
|
|
|
|
|
else if (strstr (name, "[FIR]"))
|
|
|
|
|
return 29;
|
|
|
|
|
else if (strstr (name, "[FDR]"))
|
|
|
|
|
return 30;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (strstr (name, "[CCV]"))
|
|
|
|
|
return 32;
|
|
|
|
|
else if (strstr (name, "[ITC]"))
|
|
|
|
|
return 44;
|
|
|
|
|
else if (strstr (name, "[PFS]"))
|
|
|
|
|
return 64;
|
|
|
|
|
else if (strstr (name, "[LC]"))
|
|
|
|
|
return 65;
|
|
|
|
|
else if (strstr (name, "[EC]"))
|
|
|
|
|
return 66;
|
|
|
|
|
abort ();
|
|
|
|
|
case IA64_RS_CRX:
|
|
|
|
|
if (strstr (name, "[DCR]"))
|
|
|
|
|
return 0;
|
|
|
|
|
else if (strstr (name, "[ITM]"))
|
|
|
|
|
return 1;
|
|
|
|
|
else if (strstr (name, "[IVA]"))
|
|
|
|
|
return 2;
|
|
|
|
|
else if (strstr (name, "[PTA]"))
|
|
|
|
|
return 8;
|
|
|
|
|
else if (strstr (name, "[GPTA]"))
|
|
|
|
|
return 9;
|
|
|
|
|
else if (strstr (name, "[IPSR]"))
|
|
|
|
|
return 16;
|
|
|
|
|
else if (strstr (name, "[ISR]"))
|
|
|
|
|
return 17;
|
|
|
|
|
else if (strstr (name, "[IIP]"))
|
|
|
|
|
return 19;
|
|
|
|
|
else if (strstr (name, "[IFA]"))
|
|
|
|
|
return 20;
|
|
|
|
|
else if (strstr (name, "[ITIR]"))
|
|
|
|
|
return 21;
|
|
|
|
|
else if (strstr (name, "[IIPA]"))
|
|
|
|
|
return 22;
|
|
|
|
|
else if (strstr (name, "[IFS]"))
|
|
|
|
|
return 23;
|
|
|
|
|
else if (strstr (name, "[IIM]"))
|
|
|
|
|
return 24;
|
|
|
|
|
else if (strstr (name, "[IHA]"))
|
|
|
|
|
return 25;
|
|
|
|
|
else if (strstr (name, "[LID]"))
|
|
|
|
|
return 64;
|
|
|
|
|
else if (strstr (name, "[IVR]"))
|
|
|
|
|
return 65;
|
|
|
|
|
else if (strstr (name, "[TPR]"))
|
|
|
|
|
return 66;
|
|
|
|
|
else if (strstr (name, "[EOI]"))
|
|
|
|
|
return 67;
|
|
|
|
|
else if (strstr (name, "[ITV]"))
|
|
|
|
|
return 72;
|
|
|
|
|
else if (strstr (name, "[PMV]"))
|
|
|
|
|
return 73;
|
|
|
|
|
else if (strstr (name, "[CMCV]"))
|
|
|
|
|
return 74;
|
|
|
|
|
abort ();
|
|
|
|
|
case IA64_RS_PSR:
|
|
|
|
|
if (strstr (name, ".be"))
|
|
|
|
|
return 1;
|
|
|
|
|
else if (strstr (name, ".up"))
|
|
|
|
|
return 2;
|
|
|
|
|
else if (strstr (name, ".ac"))
|
|
|
|
|
return 3;
|
|
|
|
|
else if (strstr (name, ".mfl"))
|
|
|
|
|
return 4;
|
|
|
|
|
else if (strstr (name, ".mfh"))
|
|
|
|
|
return 5;
|
|
|
|
|
else if (strstr (name, ".ic"))
|
|
|
|
|
return 13;
|
|
|
|
|
else if (strstr (name, ".i"))
|
|
|
|
|
return 14;
|
|
|
|
|
else if (strstr (name, ".pk"))
|
|
|
|
|
return 15;
|
|
|
|
|
else if (strstr (name, ".dt"))
|
|
|
|
|
return 17;
|
|
|
|
|
else if (strstr (name, ".dfl"))
|
|
|
|
|
return 18;
|
|
|
|
|
else if (strstr (name, ".dfh"))
|
|
|
|
|
return 19;
|
|
|
|
|
else if (strstr (name, ".sp"))
|
|
|
|
|
return 20;
|
|
|
|
|
else if (strstr (name, ".pp"))
|
|
|
|
|
return 21;
|
|
|
|
|
else if (strstr (name, ".di"))
|
|
|
|
|
return 22;
|
|
|
|
|
else if (strstr (name, ".si"))
|
|
|
|
|
return 23;
|
|
|
|
|
else if (strstr (name, ".db"))
|
|
|
|
|
return 24;
|
|
|
|
|
else if (strstr (name, ".lp"))
|
|
|
|
|
return 25;
|
|
|
|
|
else if (strstr (name, ".tb"))
|
|
|
|
|
return 26;
|
|
|
|
|
else if (strstr (name, ".rt"))
|
|
|
|
|
return 27;
|
|
|
|
|
else if (strstr (name, ".cpl"))
|
|
|
|
|
return 32;
|
|
|
|
|
else if (strstr (name, ".rs"))
|
|
|
|
|
return 34;
|
|
|
|
|
else if (strstr (name, ".mc"))
|
|
|
|
|
return 35;
|
|
|
|
|
else if (strstr (name, ".it"))
|
|
|
|
|
return 36;
|
|
|
|
|
else if (strstr (name, ".id"))
|
|
|
|
|
return 37;
|
|
|
|
|
else if (strstr (name, ".da"))
|
|
|
|
|
return 38;
|
|
|
|
|
else if (strstr (name, ".dd"))
|
|
|
|
|
return 39;
|
|
|
|
|
else if (strstr (name, ".ss"))
|
|
|
|
|
return 40;
|
|
|
|
|
else if (strstr (name, ".ri"))
|
|
|
|
|
return 41;
|
|
|
|
|
else if (strstr (name, ".ed"))
|
|
|
|
|
return 43;
|
|
|
|
|
else if (strstr (name, ".bn"))
|
|
|
|
|
return 44;
|
|
|
|
|
else if (strstr (name, ".ia"))
|
|
|
|
|
return 45;
|
|
|
|
|
else
|
|
|
|
|
abort ();
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return REG_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
lookup_specifier (const char *name)
|
|
|
|
|
{
|
|
|
|
|
if (strchr (name, '%'))
|
|
|
|
|
{
|
|
|
|
|
if (strstr (name, "AR[K%]") != NULL)
|
|
|
|
|
return IA64_RS_AR_K;
|
|
|
|
|
if (strstr (name, "AR[UNAT]") != NULL)
|
|
|
|
|
return IA64_RS_AR_UNAT;
|
|
|
|
|
if (strstr (name, "AR%, % in 8") != NULL)
|
|
|
|
|
return IA64_RS_AR;
|
|
|
|
|
if (strstr (name, "AR%, % in 48") != NULL)
|
|
|
|
|
return IA64_RS_ARb;
|
|
|
|
|
if (strstr (name, "BR%") != NULL)
|
|
|
|
|
return IA64_RS_BR;
|
|
|
|
|
if (strstr (name, "CR[IRR%]") != NULL)
|
|
|
|
|
return IA64_RS_CR_IRR;
|
|
|
|
|
if (strstr (name, "CR[LRR%]") != NULL)
|
|
|
|
|
return IA64_RS_CR_LRR;
|
|
|
|
|
if (strstr (name, "CR%") != NULL)
|
|
|
|
|
return IA64_RS_CR;
|
|
|
|
|
if (strstr (name, "FR%, % in 0") != NULL)
|
|
|
|
|
return IA64_RS_FR;
|
|
|
|
|
if (strstr (name, "FR%, % in 2") != NULL)
|
|
|
|
|
return IA64_RS_FRb;
|
|
|
|
|
if (strstr (name, "GR%") != NULL)
|
|
|
|
|
return IA64_RS_GR;
|
Fix ia64 gas testsuite. Update ia64 DV tables. Fix ia64 gas testsuite again.
gas/ChangeLog
* config/tc-ia64.c (dv_sem): Add "stop".
(specify_resource, case IA64_RS_PR): Only handles regs 1 to 15 now.
(specify_resource, case IA64_RS_PRr): New for regs 16 to 62.
(specify_resource, case IA64_RS_PR63): Reorder (note == 7) test to
match above.
(mark_resources): Check IA64_RS_PRr.
gas/testsuite/ChangeLog
* gas/ia64/dv-raw-err.s: Add new testcases for PR%, 16 - 62.
* gas/ia64/dv-waw-err.s: Likewise.
* gas/ia64/dv-imply.d: Regenerate.
* gas/ia64/dv-mutex.d, gas/ia64/dv-raw-err.l, gas/ia64/dv-safe.d,
gas/ia64/dv-srlz.d, gas/ia64/dv-war-err.l, gas/ia64/dv-waw-err.l,
gas/ia64/opc-f.d, gas/ia64/opc-i.d, gas/ia64/opc-m.d: Likewise.
include/opcode/ChangeLog
* ia64.h (enum ia64_dependency_semantics): Add IA64_DVS_STOP.
opcodes/ChangeLog
* ia64-dis.c (print_insn_ia64): Revert Aug 7 byte skip count change.
* ia64-gen.c (parse_semantics): Handle IA64_DVS_STOP.
(lookup_specifier): Handle "PR%, 1 to 15" and "PR%, 16 to 62".
* ia64-ic.tbl, ia64-raw.tbl, ia64-war.tbl, ia64-waw.tbl: Update.
* ia64-asmtab.c: Regnerate.
2000-09-22 19:43:50 +00:00
|
|
|
|
if (strstr (name, "PR%, % in 1 ") != NULL)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
return IA64_RS_PR;
|
Fix ia64 gas testsuite. Update ia64 DV tables. Fix ia64 gas testsuite again.
gas/ChangeLog
* config/tc-ia64.c (dv_sem): Add "stop".
(specify_resource, case IA64_RS_PR): Only handles regs 1 to 15 now.
(specify_resource, case IA64_RS_PRr): New for regs 16 to 62.
(specify_resource, case IA64_RS_PR63): Reorder (note == 7) test to
match above.
(mark_resources): Check IA64_RS_PRr.
gas/testsuite/ChangeLog
* gas/ia64/dv-raw-err.s: Add new testcases for PR%, 16 - 62.
* gas/ia64/dv-waw-err.s: Likewise.
* gas/ia64/dv-imply.d: Regenerate.
* gas/ia64/dv-mutex.d, gas/ia64/dv-raw-err.l, gas/ia64/dv-safe.d,
gas/ia64/dv-srlz.d, gas/ia64/dv-war-err.l, gas/ia64/dv-waw-err.l,
gas/ia64/opc-f.d, gas/ia64/opc-i.d, gas/ia64/opc-m.d: Likewise.
include/opcode/ChangeLog
* ia64.h (enum ia64_dependency_semantics): Add IA64_DVS_STOP.
opcodes/ChangeLog
* ia64-dis.c (print_insn_ia64): Revert Aug 7 byte skip count change.
* ia64-gen.c (parse_semantics): Handle IA64_DVS_STOP.
(lookup_specifier): Handle "PR%, 1 to 15" and "PR%, 16 to 62".
* ia64-ic.tbl, ia64-raw.tbl, ia64-war.tbl, ia64-waw.tbl: Update.
* ia64-asmtab.c: Regnerate.
2000-09-22 19:43:50 +00:00
|
|
|
|
if (strstr (name, "PR%, % in 16 ") != NULL)
|
|
|
|
|
return IA64_RS_PRr;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("don't know how to specify %% dependency %s\n"),
|
|
|
|
|
name);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
else if (strchr (name, '#'))
|
|
|
|
|
{
|
|
|
|
|
if (strstr (name, "CPUID#") != NULL)
|
|
|
|
|
return IA64_RS_CPUID;
|
|
|
|
|
if (strstr (name, "DBR#") != NULL)
|
|
|
|
|
return IA64_RS_DBR;
|
|
|
|
|
if (strstr (name, "IBR#") != NULL)
|
|
|
|
|
return IA64_RS_IBR;
|
|
|
|
|
if (strstr (name, "MSR#") != NULL)
|
|
|
|
|
return IA64_RS_MSR;
|
|
|
|
|
if (strstr (name, "PKR#") != NULL)
|
|
|
|
|
return IA64_RS_PKR;
|
|
|
|
|
if (strstr (name, "PMC#") != NULL)
|
|
|
|
|
return IA64_RS_PMC;
|
|
|
|
|
if (strstr (name, "PMD#") != NULL)
|
|
|
|
|
return IA64_RS_PMD;
|
|
|
|
|
if (strstr (name, "RR#") != NULL)
|
|
|
|
|
return IA64_RS_RR;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("Don't know how to specify # dependency %s\n"),
|
|
|
|
|
name);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
else if (strncmp (name, "AR[FPSR]", 8) == 0)
|
|
|
|
|
return IA64_RS_AR_FPSR;
|
|
|
|
|
else if (strncmp (name, "AR[", 3) == 0)
|
|
|
|
|
return IA64_RS_ARX;
|
|
|
|
|
else if (strncmp (name, "CR[", 3) == 0)
|
|
|
|
|
return IA64_RS_CRX;
|
|
|
|
|
else if (strncmp (name, "PSR.", 4) == 0)
|
|
|
|
|
return IA64_RS_PSR;
|
|
|
|
|
else if (strcmp (name, "InService*") == 0)
|
|
|
|
|
return IA64_RS_INSERVICE;
|
|
|
|
|
else if (strcmp (name, "GR0") == 0)
|
|
|
|
|
return IA64_RS_GR0;
|
|
|
|
|
else if (strcmp (name, "CFM") == 0)
|
|
|
|
|
return IA64_RS_CFM;
|
|
|
|
|
else if (strcmp (name, "PR63") == 0)
|
|
|
|
|
return IA64_RS_PR63;
|
|
|
|
|
else if (strcmp (name, "RSE") == 0)
|
|
|
|
|
return IA64_RS_RSE;
|
|
|
|
|
|
|
|
|
|
return IA64_RS_ANY;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-21 20:22:24 +00:00
|
|
|
|
print_dependency_table ()
|
|
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
|
|
if (debug)
|
|
|
|
|
{
|
|
|
|
|
for (i=0;i < iclen;i++)
|
|
|
|
|
{
|
|
|
|
|
if (ics[i]->is_class)
|
|
|
|
|
{
|
|
|
|
|
if (!ics[i]->nsubs)
|
|
|
|
|
{
|
|
|
|
|
if (ics[i]->comment)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("IC:%s [%s] has no terminals or sub-classes\n"),
|
|
|
|
|
ics[i]->name, ics[i]->comment);
|
|
|
|
|
else
|
|
|
|
|
warn (_("IC:%s has no terminals or sub-classes\n"),
|
|
|
|
|
ics[i]->name);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!ics[i]->terminal_resolved && !ics[i]->orphan)
|
|
|
|
|
{
|
|
|
|
|
if (ics[i]->comment)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("no insns mapped directly to terminal IC %s [%s]"),
|
|
|
|
|
ics[i]->name, ics[i]->comment);
|
|
|
|
|
else
|
|
|
|
|
warn (_("no insns mapped directly to terminal IC %s\n"),
|
|
|
|
|
ics[i]->name);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < iclen; i++)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
if (ics[i]->orphan)
|
|
|
|
|
{
|
|
|
|
|
mark_used (ics[i], 1);
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("class %s is defined but not used\n"),
|
|
|
|
|
ics[i]->name);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (debug > 1)
|
|
|
|
|
for (i = 0; i < rdepslen; i++)
|
|
|
|
|
{
|
|
|
|
|
static const char *mode_str[] = { "RAW", "WAW", "WAR" };
|
|
|
|
|
|
|
|
|
|
if (rdeps[i]->total_chks == 0)
|
|
|
|
|
warn (_("Warning: rsrc %s (%s) has no chks%s\n"),
|
|
|
|
|
rdeps[i]->name, mode_str[rdeps[i]->mode],
|
|
|
|
|
rdeps[i]->total_regs ? "" : " or regs");
|
|
|
|
|
else if (rdeps[i]->total_regs == 0)
|
|
|
|
|
warn (_("rsrc %s (%s) has no regs\n"),
|
|
|
|
|
rdeps[i]->name, mode_str[rdeps[i]->mode]);
|
|
|
|
|
}
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* The dependencies themselves. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
printf ("static const struct ia64_dependency\ndependencies[] = {\n");
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < rdepslen; i++)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
/* '%', '#', AR[], CR[], or PSR. indicates we need to specify the actual
|
2002-11-07 14:33:48 +00:00
|
|
|
|
resource used. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int specifier = lookup_specifier (rdeps[i]->name);
|
|
|
|
|
int regindex = lookup_regindex (rdeps[i]->name, specifier);
|
|
|
|
|
|
|
|
|
|
printf (" { \"%s\", %d, %d, %d, %d, ",
|
|
|
|
|
rdeps[i]->name, specifier,
|
|
|
|
|
(int)rdeps[i]->mode, (int)rdeps[i]->semantics, regindex);
|
|
|
|
|
if (rdeps[i]->semantics == IA64_DVS_OTHER)
|
|
|
|
|
printf ("\"%s\", ", rdeps[i]->extra);
|
2000-12-12 22:56:36 +00:00
|
|
|
|
else
|
|
|
|
|
printf ("NULL, ");
|
2000-04-21 20:22:24 +00:00
|
|
|
|
printf("},\n");
|
|
|
|
|
}
|
|
|
|
|
printf ("};\n\n");
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* And dependency lists. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (i=0;i < dlistlen;i++)
|
|
|
|
|
{
|
|
|
|
|
int len = 2;
|
2005-02-22 13:01:53 +00:00
|
|
|
|
printf ("static const unsigned short dep%d[] = {\n ", i);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (j=0;j < dlists[i]->len; j++)
|
|
|
|
|
{
|
|
|
|
|
len += printf ("%d, ", dlists[i]->deps[j]);
|
|
|
|
|
if (len > 75)
|
|
|
|
|
{
|
|
|
|
|
printf("\n ");
|
|
|
|
|
len = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf ("\n};\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* And opcode dependency list. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
printf ("#define NELS(X) (sizeof(X)/sizeof(X[0]))\n");
|
|
|
|
|
printf ("static const struct ia64_opcode_dependency\n");
|
|
|
|
|
printf ("op_dependencies[] = {\n");
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < opdeplen; i++)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
printf (" { ");
|
|
|
|
|
if (opdeps[i]->chk == -1)
|
|
|
|
|
printf ("0, NULL, ");
|
|
|
|
|
else
|
|
|
|
|
printf ("NELS(dep%d), dep%d, ", opdeps[i]->chk, opdeps[i]->chk);
|
|
|
|
|
if (opdeps[i]->reg == -1)
|
|
|
|
|
printf ("0, NULL, ");
|
|
|
|
|
else
|
|
|
|
|
printf ("NELS(dep%d), dep%d, ", opdeps[i]->reg, opdeps[i]->reg);
|
|
|
|
|
printf ("},\n");
|
|
|
|
|
}
|
|
|
|
|
printf ("};\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Add STR to the string table. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
static struct string_entry *
|
2002-11-07 14:33:48 +00:00
|
|
|
|
insert_string (char *str)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int start = 0, end = strtablen;
|
|
|
|
|
int i, x;
|
|
|
|
|
|
|
|
|
|
if (strtablen == strtabtotlen)
|
|
|
|
|
{
|
|
|
|
|
strtabtotlen += 20;
|
|
|
|
|
string_table = (struct string_entry **)
|
|
|
|
|
xrealloc (string_table,
|
|
|
|
|
sizeof (struct string_entry **) * strtabtotlen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strtablen == 0)
|
|
|
|
|
{
|
|
|
|
|
strtablen = 1;
|
|
|
|
|
string_table[0] = tmalloc (struct string_entry);
|
|
|
|
|
string_table[0]->s = xstrdup (str);
|
|
|
|
|
string_table[0]->num = 0;
|
|
|
|
|
return string_table[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp (str, string_table[strtablen - 1]->s) > 0)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
i = end;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (strcmp (str, string_table[0]->s) < 0)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
i = 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
i = (start + end) / 2;
|
|
|
|
|
c = strcmp (str, string_table[i]->s);
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (c < 0)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
end = i - 1;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (c == 0)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
return string_table[i];
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
start = i + 1;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (start > end)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
break;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (; i > 0 && i < strtablen; i--)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (strcmp (str, string_table[i - 1]->s) > 0)
|
|
|
|
|
break;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (; i < strtablen; i++)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (strcmp (str, string_table[i]->s) < 0)
|
|
|
|
|
break;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (x = strtablen - 1; x >= i; x--)
|
|
|
|
|
{
|
|
|
|
|
string_table[x + 1] = string_table[x];
|
|
|
|
|
string_table[x + 1]->num = x + 1;
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
string_table[i] = tmalloc (struct string_entry);
|
|
|
|
|
string_table[i]->s = xstrdup (str);
|
|
|
|
|
string_table[i]->num = i;
|
|
|
|
|
strtablen++;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
return string_table[i];
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static struct bittree *
|
|
|
|
|
make_bittree_entry (void)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
struct bittree *res = tmalloc (struct bittree);
|
|
|
|
|
|
|
|
|
|
res->disent = NULL;
|
|
|
|
|
res->bits[0] = NULL;
|
|
|
|
|
res->bits[1] = NULL;
|
|
|
|
|
res->bits[2] = NULL;
|
|
|
|
|
res->skip_flag = 0;
|
|
|
|
|
res->bits_to_skip = 0;
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static struct disent *
|
2000-04-23 02:39:13 +00:00
|
|
|
|
add_dis_table_ent (which, insn, order, completer_index)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct disent *which;
|
|
|
|
|
int insn;
|
2000-04-23 02:39:13 +00:00
|
|
|
|
int order;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int completer_index;
|
|
|
|
|
{
|
|
|
|
|
int ci = 0;
|
|
|
|
|
struct disent *ent;
|
|
|
|
|
|
|
|
|
|
if (which != NULL)
|
|
|
|
|
{
|
|
|
|
|
ent = which;
|
|
|
|
|
|
|
|
|
|
ent->nextcnt++;
|
|
|
|
|
while (ent->nexte != NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
ent = ent->nexte;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ent = (ent->nexte = tmalloc (struct disent));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ent = tmalloc (struct disent);
|
|
|
|
|
ent->next_ent = disinsntable;
|
|
|
|
|
disinsntable = ent;
|
|
|
|
|
which = ent;
|
|
|
|
|
}
|
|
|
|
|
ent->nextcnt = 0;
|
|
|
|
|
ent->nexte = NULL;
|
|
|
|
|
ent->insn = insn;
|
2000-04-23 02:39:13 +00:00
|
|
|
|
ent->priority = order;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
while (completer_index != 1)
|
|
|
|
|
{
|
|
|
|
|
ci = (ci << 1) | (completer_index & 1);
|
|
|
|
|
completer_index >>= 1;
|
|
|
|
|
}
|
|
|
|
|
ent->completer_index = ci;
|
|
|
|
|
return which;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-21 20:22:24 +00:00
|
|
|
|
finish_distable ()
|
|
|
|
|
{
|
|
|
|
|
struct disent *ent = disinsntable;
|
|
|
|
|
struct disent *prev = ent;
|
|
|
|
|
|
|
|
|
|
ent->ournum = 32768;
|
|
|
|
|
while ((ent = ent->next_ent) != NULL)
|
|
|
|
|
{
|
|
|
|
|
ent->ournum = prev->ournum + prev->nextcnt + 1;
|
|
|
|
|
prev = ent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-23 02:39:13 +00:00
|
|
|
|
insert_bit_table_ent (curr_ent, bit, opcode, mask,
|
|
|
|
|
opcodenum, order, completer_index)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct bittree *curr_ent;
|
|
|
|
|
int bit;
|
|
|
|
|
ia64_insn opcode;
|
|
|
|
|
ia64_insn mask;
|
|
|
|
|
int opcodenum;
|
2000-04-23 02:39:13 +00:00
|
|
|
|
int order;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int completer_index;
|
|
|
|
|
{
|
|
|
|
|
ia64_insn m;
|
|
|
|
|
int b;
|
|
|
|
|
struct bittree *next;
|
|
|
|
|
|
|
|
|
|
if (bit == -1)
|
|
|
|
|
{
|
2000-04-23 02:39:13 +00:00
|
|
|
|
struct disent *nent = add_dis_table_ent (curr_ent->disent,
|
|
|
|
|
opcodenum, order,
|
2000-04-21 20:22:24 +00:00
|
|
|
|
completer_index);
|
|
|
|
|
curr_ent->disent = nent;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m = ((ia64_insn) 1) << bit;
|
|
|
|
|
|
|
|
|
|
if (mask & m)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
b = (opcode & m) ? 1 : 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
b = 2;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
next = curr_ent->bits[b];
|
|
|
|
|
if (next == NULL)
|
|
|
|
|
{
|
|
|
|
|
next = make_bittree_entry ();
|
|
|
|
|
curr_ent->bits[b] = next;
|
|
|
|
|
}
|
2000-04-23 02:39:13 +00:00
|
|
|
|
insert_bit_table_ent (next, bit - 1, opcode, mask, opcodenum, order,
|
2000-04-21 20:22:24 +00:00
|
|
|
|
completer_index);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-21 20:22:24 +00:00
|
|
|
|
add_dis_entry (first, opcode, mask, opcodenum, ent, completer_index)
|
2000-04-23 02:39:13 +00:00
|
|
|
|
struct bittree *first;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ia64_insn opcode;
|
|
|
|
|
ia64_insn mask;
|
|
|
|
|
int opcodenum;
|
|
|
|
|
struct completer_entry *ent;
|
|
|
|
|
int completer_index;
|
|
|
|
|
{
|
|
|
|
|
if (completer_index & (1 << 20))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
2000-05-30 18:35:35 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
while (ent != NULL)
|
|
|
|
|
{
|
|
|
|
|
ia64_insn newopcode = (opcode & (~ ent->mask)) | ent->bits;
|
|
|
|
|
add_dis_entry (first, newopcode, mask, opcodenum, ent->addl_entries,
|
|
|
|
|
(completer_index << 1) | 1);
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ent->is_terminal)
|
|
|
|
|
{
|
2000-04-23 02:39:13 +00:00
|
|
|
|
insert_bit_table_ent (bittree, 40, newopcode, mask,
|
|
|
|
|
opcodenum, opcode_count - ent->order - 1,
|
2000-04-21 20:22:24 +00:00
|
|
|
|
(completer_index << 1) | 1);
|
|
|
|
|
}
|
|
|
|
|
completer_index <<= 1;
|
|
|
|
|
ent = ent->alternative;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* This optimization pass combines multiple "don't care" nodes. */
|
|
|
|
|
static void
|
2000-04-21 20:22:24 +00:00
|
|
|
|
compact_distree (ent)
|
|
|
|
|
struct bittree *ent;
|
|
|
|
|
{
|
|
|
|
|
#define IS_SKIP(ent) \
|
|
|
|
|
((ent->bits[2] !=NULL) \
|
|
|
|
|
&& (ent->bits[0] == NULL && ent->bits[1] == NULL && ent->skip_flag == 0))
|
|
|
|
|
|
|
|
|
|
int bitcnt = 0;
|
|
|
|
|
struct bittree *nent = ent;
|
|
|
|
|
int x;
|
|
|
|
|
|
|
|
|
|
while (IS_SKIP (nent))
|
|
|
|
|
{
|
|
|
|
|
bitcnt++;
|
|
|
|
|
nent = nent->bits[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bitcnt)
|
|
|
|
|
{
|
|
|
|
|
struct bittree *next = ent->bits[2];
|
|
|
|
|
|
|
|
|
|
ent->bits[0] = nent->bits[0];
|
|
|
|
|
ent->bits[1] = nent->bits[1];
|
|
|
|
|
ent->bits[2] = nent->bits[2];
|
|
|
|
|
ent->disent = nent->disent;
|
|
|
|
|
ent->skip_flag = 1;
|
|
|
|
|
ent->bits_to_skip = bitcnt;
|
|
|
|
|
while (next != nent)
|
|
|
|
|
{
|
|
|
|
|
struct bittree *b = next;
|
|
|
|
|
next = next->bits[2];
|
|
|
|
|
free (b);
|
|
|
|
|
}
|
|
|
|
|
free (nent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (x = 0; x < 3; x++)
|
|
|
|
|
{
|
|
|
|
|
struct bittree *i = ent->bits[x];
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (i != NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
compact_distree (i);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned char *insn_list;
|
|
|
|
|
static int insn_list_len = 0;
|
|
|
|
|
static int tot_insn_list_len = 0;
|
|
|
|
|
|
|
|
|
|
/* Generate the disassembler state machine corresponding to the tree
|
|
|
|
|
in ENT. */
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-21 20:22:24 +00:00
|
|
|
|
gen_dis_table (ent)
|
|
|
|
|
struct bittree *ent;
|
|
|
|
|
{
|
|
|
|
|
int x;
|
|
|
|
|
int our_offset = insn_list_len;
|
|
|
|
|
int bitsused = 5;
|
|
|
|
|
int totbits = bitsused;
|
|
|
|
|
int needed_bytes;
|
|
|
|
|
int zero_count = 0;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
int zero_dest = 0; /* Initialize this with 0 to keep gcc quiet... */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
/* If this is a terminal entry, there's no point in skipping any
|
2002-11-07 14:33:48 +00:00
|
|
|
|
bits. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ent->skip_flag && ent->bits[0] == NULL && ent->bits[1] == NULL &&
|
|
|
|
|
ent->bits[2] == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (ent->disent == NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
ent->skip_flag = 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Calculate the amount of space needed for this entry, or at least
|
2002-11-07 14:33:48 +00:00
|
|
|
|
a conservatively large approximation. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ent->skip_flag)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
totbits += 5;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (x = 1; x < 3; x++)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (ent->bits[x] != NULL)
|
|
|
|
|
totbits += 16;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
if (ent->disent != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (ent->bits[2] != NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
totbits += 16;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Now allocate the space. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
needed_bytes = (totbits + 7) / 8;
|
|
|
|
|
if ((needed_bytes + insn_list_len) > tot_insn_list_len)
|
|
|
|
|
{
|
|
|
|
|
tot_insn_list_len += 256;
|
2005-02-22 13:01:53 +00:00
|
|
|
|
insn_list = (unsigned char *) xrealloc (insn_list, tot_insn_list_len);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
our_offset = insn_list_len;
|
|
|
|
|
insn_list_len += needed_bytes;
|
|
|
|
|
memset (insn_list + our_offset, 0, needed_bytes);
|
|
|
|
|
|
|
|
|
|
/* Encode the skip entry by setting bit 6 set in the state op field,
|
2002-11-07 14:33:48 +00:00
|
|
|
|
and store the # of bits to skip immediately after. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ent->skip_flag)
|
|
|
|
|
{
|
|
|
|
|
bitsused += 5;
|
|
|
|
|
insn_list[our_offset + 0] |= 0x40 | ((ent->bits_to_skip >> 2) & 0xf);
|
|
|
|
|
insn_list[our_offset + 1] |= ((ent->bits_to_skip & 3) << 6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define IS_ONLY_IFZERO(ENT) \
|
|
|
|
|
((ENT)->bits[0] != NULL && (ENT)->bits[1] == NULL && (ENT)->bits[2] == NULL \
|
|
|
|
|
&& (ENT)->disent == NULL && (ENT)->skip_flag == 0)
|
|
|
|
|
|
|
|
|
|
/* Store an "if (bit is zero)" instruction by setting bit 7 in the
|
2002-11-07 14:33:48 +00:00
|
|
|
|
state op field. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ent->bits[0] != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct bittree *nent = ent->bits[0];
|
|
|
|
|
zero_count = 0;
|
|
|
|
|
|
|
|
|
|
insn_list[our_offset] |= 0x80;
|
|
|
|
|
|
|
|
|
|
/* We can encode sequences of multiple "if (bit is zero)" tests
|
|
|
|
|
by storing the # of zero bits to check in the lower 3 bits of
|
|
|
|
|
the instruction. However, this only applies if the state
|
|
|
|
|
solely tests for a zero bit. */
|
|
|
|
|
|
|
|
|
|
if (IS_ONLY_IFZERO (ent))
|
|
|
|
|
{
|
|
|
|
|
while (IS_ONLY_IFZERO (nent) && zero_count < 7)
|
|
|
|
|
{
|
|
|
|
|
nent = nent->bits[0];
|
|
|
|
|
zero_count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
insn_list[our_offset + 0] |= zero_count;
|
|
|
|
|
}
|
|
|
|
|
zero_dest = insn_list_len;
|
|
|
|
|
gen_dis_table (nent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now store the remaining tests. We also handle a sole "termination
|
|
|
|
|
entry" by storing it as an "any bit" test. */
|
|
|
|
|
|
|
|
|
|
for (x = 1; x < 3; x++)
|
|
|
|
|
{
|
|
|
|
|
if (ent->bits[x] != NULL || (x == 2 && ent->disent != NULL))
|
|
|
|
|
{
|
|
|
|
|
struct bittree *i = ent->bits[x];
|
|
|
|
|
int idest;
|
|
|
|
|
int currbits = 15;
|
|
|
|
|
|
|
|
|
|
if (i != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* If the instruction being branched to only consists of
|
|
|
|
|
a termination entry, use the termination entry as the
|
|
|
|
|
place to branch to instead. */
|
|
|
|
|
if (i->bits[0] == NULL && i->bits[1] == NULL
|
|
|
|
|
&& i->bits[2] == NULL && i->disent != NULL)
|
|
|
|
|
{
|
|
|
|
|
idest = i->disent->ournum;
|
|
|
|
|
i = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
idest = insn_list_len - our_offset;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
idest = ent->disent->ournum;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
/* If the destination offset for the if (bit is 1) test is less
|
|
|
|
|
than 256 bytes away, we can store it as 8-bits instead of 16;
|
|
|
|
|
the instruction has bit 5 set for the 16-bit address, and bit
|
|
|
|
|
4 for the 8-bit address. Since we've already allocated 16
|
|
|
|
|
bits for the address we need to deallocate the space.
|
|
|
|
|
|
|
|
|
|
Note that branchings within the table are relative, and
|
|
|
|
|
there are no branches that branch past our instruction yet
|
2002-11-07 14:33:48 +00:00
|
|
|
|
so we do not need to adjust any other offsets. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (x == 1)
|
|
|
|
|
{
|
|
|
|
|
if (idest <= 256)
|
|
|
|
|
{
|
|
|
|
|
int start = our_offset + bitsused / 8 + 1;
|
|
|
|
|
|
|
|
|
|
memmove (insn_list + start,
|
|
|
|
|
insn_list + start + 1,
|
|
|
|
|
insn_list_len - (start + 1));
|
|
|
|
|
currbits = 7;
|
|
|
|
|
totbits -= 8;
|
|
|
|
|
needed_bytes--;
|
|
|
|
|
insn_list_len--;
|
|
|
|
|
insn_list[our_offset] |= 0x10;
|
|
|
|
|
idest--;
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
insn_list[our_offset] |= 0x20;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* An instruction which solely consists of a termination
|
|
|
|
|
marker and whose disassembly name index is < 4096
|
|
|
|
|
can be stored in 16 bits. The encoding is slightly
|
|
|
|
|
odd; the upper 4 bits of the instruction are 0x3, and
|
|
|
|
|
bit 3 loses its normal meaning. */
|
|
|
|
|
|
|
|
|
|
if (ent->bits[0] == NULL && ent->bits[1] == NULL
|
|
|
|
|
&& ent->bits[2] == NULL && ent->skip_flag == 0
|
|
|
|
|
&& ent->disent != NULL
|
|
|
|
|
&& ent->disent->ournum < (32768 + 4096))
|
|
|
|
|
{
|
|
|
|
|
int start = our_offset + bitsused / 8 + 1;
|
|
|
|
|
|
|
|
|
|
memmove (insn_list + start,
|
|
|
|
|
insn_list + start + 1,
|
|
|
|
|
insn_list_len - (start + 1));
|
|
|
|
|
currbits = 11;
|
|
|
|
|
totbits -= 5;
|
|
|
|
|
bitsused--;
|
|
|
|
|
needed_bytes--;
|
|
|
|
|
insn_list_len--;
|
|
|
|
|
insn_list[our_offset] |= 0x30;
|
|
|
|
|
idest &= ~32768;
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
insn_list[our_offset] |= 0x08;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (debug)
|
|
|
|
|
{
|
|
|
|
|
int id = idest;
|
|
|
|
|
|
|
|
|
|
if (i == NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
id |= 32768;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (! (id & 32768))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
id += our_offset;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (x == 1)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("%d: if (1) goto %d\n", our_offset, id);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("%d: try %d\n", our_offset, id);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Store the address of the entry being branched to. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
while (currbits >= 0)
|
|
|
|
|
{
|
2005-02-22 13:01:53 +00:00
|
|
|
|
unsigned char *byte = insn_list + our_offset + bitsused / 8;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
if (idest & (1 << currbits))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
*byte |= (1 << (7 - (bitsused % 8)));
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
bitsused++;
|
|
|
|
|
currbits--;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Now generate the states for the entry being branched to. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (i != NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
gen_dis_table (i);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (debug)
|
|
|
|
|
{
|
|
|
|
|
if (ent->skip_flag)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("%d: skipping %d\n", our_offset, ent->bits_to_skip);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
if (ent->bits[0] != NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("%d: if (0:%d) goto %d\n", our_offset, zero_count + 1,
|
|
|
|
|
zero_dest);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (bitsused != totbits)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
|
|
|
|
print_dis_table (void)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int x;
|
|
|
|
|
struct disent *cent = disinsntable;
|
|
|
|
|
|
|
|
|
|
printf ("static const char dis_table[] = {\n");
|
|
|
|
|
for (x = 0; x < insn_list_len; x++)
|
|
|
|
|
{
|
|
|
|
|
if ((x > 0) && ((x % 12) == 0))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("\n");
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
printf ("0x%02x, ", insn_list[x]);
|
|
|
|
|
}
|
|
|
|
|
printf ("\n};\n\n");
|
|
|
|
|
|
|
|
|
|
printf ("static const struct ia64_dis_names ia64_dis_names[] = {\n");
|
|
|
|
|
while (cent != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct disent *ent = cent;
|
|
|
|
|
|
|
|
|
|
while (ent != NULL)
|
|
|
|
|
{
|
2000-04-23 02:39:13 +00:00
|
|
|
|
printf ("{ 0x%x, %d, %d, %d },\n", ent->completer_index,
|
|
|
|
|
ent->insn, (ent->nexte != NULL ? 1 : 0),
|
|
|
|
|
ent->priority);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ent = ent->nexte;
|
|
|
|
|
}
|
|
|
|
|
cent = cent->next_ent;
|
|
|
|
|
}
|
|
|
|
|
printf ("};\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
|
|
|
|
generate_disassembler (void)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
2000-04-23 02:39:13 +00:00
|
|
|
|
int i;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
bittree = make_bittree_entry ();
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < otlen; i++)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
2000-04-23 02:39:13 +00:00
|
|
|
|
struct main_entry *ptr = ordered_table[i];
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ptr->opcode->type != IA64_TYPE_DYN)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
add_dis_entry (bittree,
|
|
|
|
|
ptr->opcode->opcode, ptr->opcode->mask,
|
|
|
|
|
ptr->main_index,
|
|
|
|
|
ptr->completers, 1);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
compact_distree (bittree);
|
|
|
|
|
finish_distable ();
|
|
|
|
|
gen_dis_table (bittree);
|
|
|
|
|
|
|
|
|
|
print_dis_table ();
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
|
|
|
|
print_string_table (void)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int x;
|
|
|
|
|
char lbuf[80], buf[80];
|
|
|
|
|
int blen = 0;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("static const char * const ia64_strings[] = {\n");
|
2000-04-21 20:22:24 +00:00
|
|
|
|
lbuf[0] = '\0';
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (x = 0; x < strtablen; x++)
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
if (strlen (string_table[x]->s) > 75)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
sprintf (buf, " \"%s\",", string_table[x]->s);
|
|
|
|
|
len = strlen (buf);
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if ((blen + len) > 75)
|
|
|
|
|
{
|
|
|
|
|
printf (" %s\n", lbuf);
|
|
|
|
|
lbuf[0] = '\0';
|
|
|
|
|
blen = 0;
|
|
|
|
|
}
|
|
|
|
|
strcat (lbuf, buf);
|
|
|
|
|
blen += len;
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (blen > 0)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf (" %s\n", lbuf);
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
printf ("};\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct completer_entry **glist;
|
|
|
|
|
static int glistlen = 0;
|
|
|
|
|
static int glisttotlen = 0;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* If the completer trees ENT1 and ENT2 are equal, return 1. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static int
|
2000-04-21 20:22:24 +00:00
|
|
|
|
completer_entries_eq (ent1, ent2)
|
|
|
|
|
struct completer_entry *ent1, *ent2;
|
|
|
|
|
{
|
|
|
|
|
while (ent1 != NULL && ent2 != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (ent1->name->num != ent2->name->num
|
|
|
|
|
|| ent1->bits != ent2->bits
|
|
|
|
|
|| ent1->mask != ent2->mask
|
|
|
|
|
|| ent1->is_terminal != ent2->is_terminal
|
2000-04-23 02:39:13 +00:00
|
|
|
|
|| ent1->dependencies != ent2->dependencies
|
|
|
|
|
|| ent1->order != ent2->order)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (! completer_entries_eq (ent1->addl_entries, ent2->addl_entries))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ent1 = ent1->alternative;
|
|
|
|
|
ent2 = ent2->alternative;
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
return ent1 == ent2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Insert ENT into the global list of completers and return it. If an
|
|
|
|
|
equivalent entry (according to completer_entries_eq) already exists,
|
2002-11-07 14:33:48 +00:00
|
|
|
|
it is returned instead. */
|
|
|
|
|
static struct completer_entry *
|
|
|
|
|
insert_gclist (struct completer_entry *ent)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
if (ent != NULL)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int x;
|
|
|
|
|
int start = 0, end;
|
|
|
|
|
|
|
|
|
|
ent->addl_entries = insert_gclist (ent->addl_entries);
|
|
|
|
|
ent->alternative = insert_gclist (ent->alternative);
|
|
|
|
|
|
|
|
|
|
i = glistlen / 2;
|
|
|
|
|
end = glistlen;
|
|
|
|
|
|
|
|
|
|
if (glisttotlen == glistlen)
|
|
|
|
|
{
|
|
|
|
|
glisttotlen += 20;
|
|
|
|
|
glist = (struct completer_entry **)
|
|
|
|
|
xrealloc (glist, sizeof (struct completer_entry *) * glisttotlen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (glistlen == 0)
|
|
|
|
|
{
|
|
|
|
|
glist[0] = ent;
|
|
|
|
|
glistlen = 1;
|
|
|
|
|
return ent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ent->name->num < glist[0]->name->num)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
i = 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (ent->name->num > glist[end - 1]->name->num)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
i = end;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
i = (start + end) / 2;
|
|
|
|
|
c = ent->name->num - glist[i]->name->num;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (c < 0)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
end = i - 1;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else if (c == 0)
|
|
|
|
|
{
|
|
|
|
|
while (i > 0
|
|
|
|
|
&& ent->name->num == glist[i - 1]->name->num)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
i--;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
start = i + 1;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (start > end)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
break;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (c == 0)
|
|
|
|
|
{
|
|
|
|
|
while (i < glistlen)
|
|
|
|
|
{
|
|
|
|
|
if (ent->name->num != glist[i]->name->num)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (completer_entries_eq (ent, glist[i]))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
return glist[i];
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (; i > 0 && i < glistlen; i--)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (ent->name->num >= glist[i - 1]->name->num)
|
|
|
|
|
break;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (; i < glistlen; i++)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (ent->name->num < glist[i]->name->num)
|
|
|
|
|
break;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (x = glistlen - 1; x >= i; x--)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
glist[x + 1] = glist[x];
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
glist[i] = ent;
|
|
|
|
|
glistlen++;
|
|
|
|
|
}
|
|
|
|
|
return ent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
get_prefix_len (name)
|
|
|
|
|
const char *name;
|
|
|
|
|
{
|
|
|
|
|
char *c;
|
|
|
|
|
|
|
|
|
|
if (name[0] == '\0')
|
2002-11-07 14:33:48 +00:00
|
|
|
|
return 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
c = strchr (name, '.');
|
|
|
|
|
if (c != NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
return c - name;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
return strlen (name);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
compute_completer_bits (ment, ent)
|
|
|
|
|
struct main_entry *ment;
|
|
|
|
|
struct completer_entry *ent;
|
|
|
|
|
{
|
|
|
|
|
while (ent != NULL)
|
|
|
|
|
{
|
|
|
|
|
compute_completer_bits (ment, ent->addl_entries);
|
|
|
|
|
|
|
|
|
|
if (ent->is_terminal)
|
|
|
|
|
{
|
|
|
|
|
ia64_insn mask = 0;
|
|
|
|
|
ia64_insn our_bits = ent->bits;
|
|
|
|
|
struct completer_entry *p = ent->parent;
|
|
|
|
|
ia64_insn p_bits;
|
|
|
|
|
int x;
|
|
|
|
|
|
|
|
|
|
while (p != NULL && ! p->is_terminal)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
p = p->parent;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
if (p != NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
p_bits = p->bits;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
p_bits = ment->opcode->opcode;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
for (x = 0; x < 64; x++)
|
|
|
|
|
{
|
|
|
|
|
ia64_insn m = ((ia64_insn) 1) << x;
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if ((p_bits & m) != (our_bits & m))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
mask |= m;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
our_bits &= ~m;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
ent->bits = our_bits;
|
|
|
|
|
ent->mask = mask;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ent->bits = 0;
|
|
|
|
|
ent->mask = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ent = ent->alternative;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find identical completer trees that are used in different
|
2002-11-07 14:33:48 +00:00
|
|
|
|
instructions and collapse their entries. */
|
|
|
|
|
static void
|
|
|
|
|
collapse_redundant_completers (void)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
struct main_entry *ptr;
|
|
|
|
|
int x;
|
|
|
|
|
|
|
|
|
|
for (ptr = maintable; ptr != NULL; ptr = ptr->next)
|
|
|
|
|
{
|
|
|
|
|
if (ptr->completers == NULL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
compute_completer_bits (ptr, ptr->completers);
|
|
|
|
|
ptr->completers = insert_gclist (ptr->completers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The table has been finalized, now number the indexes. */
|
|
|
|
|
for (x = 0; x < glistlen; x++)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
glist[x]->num = x;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Attach two lists of dependencies to each opcode.
|
2000-04-21 20:22:24 +00:00
|
|
|
|
1) all resources which, when already marked in use, conflict with this
|
|
|
|
|
opcode (chks)
|
|
|
|
|
2) all resources which must be marked in use when this opcode is used
|
2002-11-07 14:33:48 +00:00
|
|
|
|
(regs). */
|
|
|
|
|
static int
|
2000-04-21 20:22:24 +00:00
|
|
|
|
insert_opcode_dependencies (opc, cmp)
|
|
|
|
|
struct ia64_opcode *opc;
|
2000-12-12 22:56:36 +00:00
|
|
|
|
struct completer_entry *cmp ATTRIBUTE_UNUSED;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Note all resources which point to this opcode. rfi has the most chks
|
|
|
|
|
(79) and cmpxchng has the most regs (54) so 100 here should be enough. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int i;
|
|
|
|
|
int nregs = 0;
|
|
|
|
|
unsigned short regs[256];
|
|
|
|
|
int nchks = 0;
|
|
|
|
|
unsigned short chks[256];
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* Flag insns for which no class matched; there should be none. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int no_class_found = 1;
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
for (i = 0; i < rdepslen; i++)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
struct rdep *rs = rdeps[i];
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
|
|
if (strcmp (opc->name, "cmp.eq.and") == 0
|
|
|
|
|
&& strncmp (rs->name, "PR%", 3) == 0
|
|
|
|
|
&& rs->mode == 1)
|
|
|
|
|
no_class_found = 99;
|
|
|
|
|
|
|
|
|
|
for (j=0; j < rs->nregs;j++)
|
|
|
|
|
{
|
|
|
|
|
int ic_note = 0;
|
|
|
|
|
|
|
|
|
|
if (in_iclass (opc, ics[rs->regs[j]], NULL, NULL, &ic_note))
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* We can ignore ic_note 11 for non PR resources. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ic_note == 11 && strncmp (rs->name, "PR", 2) != 0)
|
|
|
|
|
ic_note = 0;
|
|
|
|
|
|
|
|
|
|
if (ic_note != 0 && rs->regnotes[j] != 0
|
|
|
|
|
&& ic_note != rs->regnotes[j]
|
|
|
|
|
&& !(ic_note == 11 && rs->regnotes[j] == 1))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("IC note %d in opcode %s (IC:%s) conflicts with resource %s note %d\n"),
|
|
|
|
|
ic_note, opc->name, ics[rs->regs[j]]->name,
|
|
|
|
|
rs->name, rs->regnotes[j]);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
/* Instruction class notes override resource notes.
|
|
|
|
|
So far, only note 11 applies to an IC instead of a resource,
|
2002-11-07 14:33:48 +00:00
|
|
|
|
and note 11 implies note 1. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ic_note)
|
|
|
|
|
regs[nregs++] = RDEP(ic_note, i);
|
|
|
|
|
else
|
|
|
|
|
regs[nregs++] = RDEP(rs->regnotes[j], i);
|
|
|
|
|
no_class_found = 0;
|
|
|
|
|
++rs->total_regs;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
|
|
|
|
for (j = 0; j < rs->nchks; j++)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int ic_note = 0;
|
|
|
|
|
|
|
|
|
|
if (in_iclass (opc, ics[rs->chks[j]], NULL, NULL, &ic_note))
|
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
/* We can ignore ic_note 11 for non PR resources. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ic_note == 11 && strncmp (rs->name, "PR", 2) != 0)
|
|
|
|
|
ic_note = 0;
|
|
|
|
|
|
|
|
|
|
if (ic_note != 0 && rs->chknotes[j] != 0
|
|
|
|
|
&& ic_note != rs->chknotes[j]
|
|
|
|
|
&& !(ic_note == 11 && rs->chknotes[j] == 1))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("IC note %d for opcode %s (IC:%s) conflicts with resource %s note %d\n"),
|
|
|
|
|
ic_note, opc->name, ics[rs->chks[j]]->name,
|
|
|
|
|
rs->name, rs->chknotes[j]);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (ic_note)
|
|
|
|
|
chks[nchks++] = RDEP(ic_note, i);
|
|
|
|
|
else
|
|
|
|
|
chks[nchks++] = RDEP(rs->chknotes[j], i);
|
|
|
|
|
no_class_found = 0;
|
|
|
|
|
++rs->total_chks;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (no_class_found)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
warn (_("opcode %s has no class (ops %d %d %d)\n"),
|
|
|
|
|
opc->name,
|
|
|
|
|
opc->operands[0], opc->operands[1], opc->operands[2]);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
return insert_dependencies (nchks, chks, nregs, regs);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-23 02:39:13 +00:00
|
|
|
|
insert_completer_entry (opc, tabent, order)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
struct ia64_opcode *opc;
|
|
|
|
|
struct main_entry *tabent;
|
2000-04-23 02:39:13 +00:00
|
|
|
|
int order;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
struct completer_entry **ptr = &tabent->completers;
|
|
|
|
|
struct completer_entry *parent = NULL;
|
|
|
|
|
char pcopy[129], *prefix;
|
|
|
|
|
int at_end = 0;
|
|
|
|
|
|
|
|
|
|
if (strlen (opc->name) > 128)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
strcpy (pcopy, opc->name);
|
|
|
|
|
prefix = pcopy + get_prefix_len (pcopy);
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (prefix[0] != '\0')
|
2002-11-07 14:33:48 +00:00
|
|
|
|
prefix++;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
while (! at_end)
|
|
|
|
|
{
|
|
|
|
|
int need_new_ent = 1;
|
|
|
|
|
int plen = get_prefix_len (prefix);
|
|
|
|
|
struct string_entry *sent;
|
|
|
|
|
|
|
|
|
|
at_end = (prefix[plen] == '\0');
|
|
|
|
|
prefix[plen] = '\0';
|
|
|
|
|
sent = insert_string (prefix);
|
|
|
|
|
|
|
|
|
|
while (*ptr != NULL)
|
|
|
|
|
{
|
|
|
|
|
int cmpres = sent->num - (*ptr)->name->num;
|
|
|
|
|
|
|
|
|
|
if (cmpres == 0)
|
|
|
|
|
{
|
|
|
|
|
need_new_ent = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-11-07 14:33:48 +00:00
|
|
|
|
ptr = &((*ptr)->alternative);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (need_new_ent)
|
|
|
|
|
{
|
|
|
|
|
struct completer_entry *nent = tmalloc (struct completer_entry);
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
nent->name = sent;
|
|
|
|
|
nent->parent = parent;
|
|
|
|
|
nent->addl_entries = NULL;
|
|
|
|
|
nent->alternative = *ptr;
|
|
|
|
|
*ptr = nent;
|
|
|
|
|
nent->is_terminal = 0;
|
|
|
|
|
nent->dependencies = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! at_end)
|
|
|
|
|
{
|
|
|
|
|
parent = *ptr;
|
|
|
|
|
ptr = &((*ptr)->addl_entries);
|
|
|
|
|
prefix += plen + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((*ptr)->is_terminal)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
(*ptr)->is_terminal = 1;
|
|
|
|
|
(*ptr)->mask = (ia64_insn)-1;
|
|
|
|
|
(*ptr)->bits = opc->opcode;
|
|
|
|
|
(*ptr)->dependencies = insert_opcode_dependencies (opc, *ptr);
|
2000-04-23 02:39:13 +00:00
|
|
|
|
(*ptr)->order = order;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-21 20:22:24 +00:00
|
|
|
|
print_completer_entry (ent)
|
|
|
|
|
struct completer_entry *ent;
|
|
|
|
|
{
|
|
|
|
|
int moffset = 0;
|
|
|
|
|
ia64_insn mask = ent->mask, bits = ent->bits;
|
|
|
|
|
|
|
|
|
|
if (mask != 0)
|
|
|
|
|
{
|
|
|
|
|
while (! (mask & 1))
|
|
|
|
|
{
|
|
|
|
|
moffset++;
|
|
|
|
|
mask = mask >> 1;
|
|
|
|
|
bits = bits >> 1;
|
|
|
|
|
}
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (bits & 0xffffffff00000000LL)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf (" { 0x%x, 0x%x, %d, %d, %d, %d, %d, %d },\n",
|
|
|
|
|
(int)bits,
|
|
|
|
|
(int)mask,
|
|
|
|
|
ent->name->num,
|
|
|
|
|
ent->alternative != NULL ? ent->alternative->num : -1,
|
|
|
|
|
ent->addl_entries != NULL ? ent->addl_entries->num : -1,
|
|
|
|
|
moffset,
|
|
|
|
|
ent->is_terminal ? 1 : 0,
|
|
|
|
|
ent->dependencies);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-21 20:22:24 +00:00
|
|
|
|
print_completer_table ()
|
|
|
|
|
{
|
|
|
|
|
int x;
|
|
|
|
|
|
|
|
|
|
printf ("static const struct ia64_completer_table\ncompleter_table[] = {\n");
|
|
|
|
|
for (x = 0; x < glistlen; x++)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
print_completer_entry (glist[x]);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
printf ("};\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static int
|
2000-04-21 20:22:24 +00:00
|
|
|
|
opcodes_eq (opc1, opc2)
|
|
|
|
|
struct ia64_opcode *opc1;
|
|
|
|
|
struct ia64_opcode *opc2;
|
|
|
|
|
{
|
|
|
|
|
int x;
|
|
|
|
|
int plen1, plen2;
|
|
|
|
|
|
|
|
|
|
if ((opc1->mask != opc2->mask) || (opc1->type != opc2->type)
|
|
|
|
|
|| (opc1->num_outputs != opc2->num_outputs)
|
|
|
|
|
|| (opc1->flags != opc2->flags))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
for (x = 0; x < 5; x++)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
if (opc1->operands[x] != opc2->operands[x])
|
|
|
|
|
return 0;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
plen1 = get_prefix_len (opc1->name);
|
|
|
|
|
plen2 = get_prefix_len (opc2->name);
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
if (plen1 == plen2 && (memcmp (opc1->name, opc2->name, plen1) == 0))
|
2002-11-07 14:33:48 +00:00
|
|
|
|
return 1;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-21 20:22:24 +00:00
|
|
|
|
add_opcode_entry (opc)
|
|
|
|
|
struct ia64_opcode *opc;
|
|
|
|
|
{
|
|
|
|
|
struct main_entry **place;
|
|
|
|
|
struct string_entry *name;
|
|
|
|
|
char prefix[129];
|
|
|
|
|
int found_it = 0;
|
|
|
|
|
|
|
|
|
|
if (strlen (opc->name) > 128)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
abort ();
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
place = &maintable;
|
|
|
|
|
strcpy (prefix, opc->name);
|
|
|
|
|
prefix[get_prefix_len (prefix)] = '\0';
|
|
|
|
|
name = insert_string (prefix);
|
|
|
|
|
|
|
|
|
|
/* Walk the list of opcode table entries. If it's a new
|
2000-04-23 02:39:13 +00:00
|
|
|
|
instruction, allocate and fill in a new entry. Note
|
2002-11-07 14:33:48 +00:00
|
|
|
|
the main table is alphabetical by opcode name. */
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
while (*place != NULL)
|
|
|
|
|
{
|
|
|
|
|
if ((*place)->name->num == name->num
|
|
|
|
|
&& opcodes_eq ((*place)->opcode, opc))
|
|
|
|
|
{
|
|
|
|
|
found_it = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if ((*place)->name->num > name->num)
|
2002-11-07 14:33:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
place = &((*place)->next);
|
|
|
|
|
}
|
|
|
|
|
if (! found_it)
|
|
|
|
|
{
|
|
|
|
|
struct main_entry *nent = tmalloc (struct main_entry);
|
|
|
|
|
|
|
|
|
|
nent->name = name;
|
|
|
|
|
nent->opcode = opc;
|
|
|
|
|
nent->next = *place;
|
|
|
|
|
nent->completers = 0;
|
|
|
|
|
*place = nent;
|
2000-04-23 02:39:13 +00:00
|
|
|
|
|
|
|
|
|
if (otlen == ottotlen)
|
|
|
|
|
{
|
|
|
|
|
ottotlen += 20;
|
|
|
|
|
ordered_table = (struct main_entry **)
|
|
|
|
|
xrealloc (ordered_table, sizeof (struct main_entry *) * ottotlen);
|
|
|
|
|
}
|
|
|
|
|
ordered_table[otlen++] = nent;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
2000-05-30 18:35:35 +00:00
|
|
|
|
|
2000-04-23 02:39:13 +00:00
|
|
|
|
insert_completer_entry (opc, *place, opcode_count++);
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
|
|
|
|
print_main_table (void)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
struct main_entry *ptr = maintable;
|
2000-04-23 02:39:13 +00:00
|
|
|
|
int index = 0;
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
printf ("static const struct ia64_main_table\nmain_table[] = {\n");
|
|
|
|
|
while (ptr != NULL)
|
|
|
|
|
{
|
2000-12-12 22:56:36 +00:00
|
|
|
|
printf (" { %d, %d, %d, 0x",
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ptr->name->num,
|
|
|
|
|
ptr->opcode->type,
|
2000-12-12 22:56:36 +00:00
|
|
|
|
ptr->opcode->num_outputs);
|
|
|
|
|
fprintf_vma (stdout, ptr->opcode->opcode);
|
|
|
|
|
printf ("ull, 0x");
|
|
|
|
|
fprintf_vma (stdout, ptr->opcode->mask);
|
|
|
|
|
printf ("ull, { %d, %d, %d, %d, %d }, 0x%x, %d, },\n",
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ptr->opcode->operands[0],
|
|
|
|
|
ptr->opcode->operands[1],
|
|
|
|
|
ptr->opcode->operands[2],
|
|
|
|
|
ptr->opcode->operands[3],
|
|
|
|
|
ptr->opcode->operands[4],
|
|
|
|
|
ptr->opcode->flags,
|
|
|
|
|
ptr->completers->num);
|
|
|
|
|
|
2000-04-23 02:39:13 +00:00
|
|
|
|
ptr->main_index = index++;
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
ptr = ptr->next;
|
|
|
|
|
}
|
|
|
|
|
printf ("};\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
static void
|
2000-04-21 20:22:24 +00:00
|
|
|
|
shrink (table)
|
|
|
|
|
struct ia64_opcode *table;
|
|
|
|
|
{
|
|
|
|
|
int curr_opcode;
|
|
|
|
|
|
|
|
|
|
for (curr_opcode = 0; table[curr_opcode].name != NULL; curr_opcode++)
|
2005-01-31 08:48:32 +00:00
|
|
|
|
{
|
|
|
|
|
add_opcode_entry (table + curr_opcode);
|
|
|
|
|
if (table[curr_opcode].num_outputs == 2
|
|
|
|
|
&& ((table[curr_opcode].operands[0] == IA64_OPND_P1
|
|
|
|
|
&& table[curr_opcode].operands[1] == IA64_OPND_P2)
|
|
|
|
|
|| (table[curr_opcode].operands[0] == IA64_OPND_P2
|
|
|
|
|
&& table[curr_opcode].operands[1] == IA64_OPND_P1)))
|
|
|
|
|
{
|
|
|
|
|
struct ia64_opcode *alias = tmalloc(struct ia64_opcode);
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
*alias = table[curr_opcode];
|
|
|
|
|
for (i = 2; i < NELEMS (alias->operands); ++i)
|
|
|
|
|
alias->operands[i - 1] = alias->operands[i];
|
|
|
|
|
alias->operands[NELEMS (alias->operands) - 1] = IA64_OPND_NIL;
|
|
|
|
|
--alias->num_outputs;
|
|
|
|
|
alias->flags |= PSEUDO;
|
|
|
|
|
add_opcode_entry (alias);
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-21 20:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
|
|
|
|
|
/* Program options. */
|
|
|
|
|
#define OPTION_SRCDIR 200
|
|
|
|
|
|
|
|
|
|
struct option long_options[] =
|
|
|
|
|
{
|
|
|
|
|
{"srcdir", required_argument, NULL, OPTION_SRCDIR},
|
|
|
|
|
{"debug", no_argument, NULL, 'd'},
|
|
|
|
|
{"version", no_argument, NULL, 'V'},
|
|
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
|
{0, no_argument, NULL, 0}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_version (void)
|
|
|
|
|
{
|
|
|
|
|
printf ("%s: version 1.0\n", program_name);
|
|
|
|
|
xexit (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
usage (FILE * stream, int status)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stream, "Usage: %s [-V | --version] [-d | --debug] [--srcdir=dirname] [--help]\n",
|
|
|
|
|
program_name);
|
|
|
|
|
xexit (status);
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-21 20:22:24 +00:00
|
|
|
|
int
|
2002-11-07 14:33:48 +00:00
|
|
|
|
main (int argc, char **argv)
|
2000-04-21 20:22:24 +00:00
|
|
|
|
{
|
2002-11-07 14:33:48 +00:00
|
|
|
|
extern int chdir (char *);
|
|
|
|
|
char *srcdir = NULL;
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
program_name = *argv;
|
|
|
|
|
xmalloc_set_program_name (program_name);
|
|
|
|
|
|
|
|
|
|
while ((c = getopt_long (argc, argv, "vVdh", long_options, 0)) != EOF)
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case OPTION_SRCDIR:
|
|
|
|
|
srcdir = optarg;
|
|
|
|
|
break;
|
|
|
|
|
case 'V':
|
|
|
|
|
case 'v':
|
|
|
|
|
print_version ();
|
|
|
|
|
break;
|
|
|
|
|
case 'd':
|
|
|
|
|
debug = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 'h':
|
|
|
|
|
case '?':
|
|
|
|
|
usage (stderr, 0);
|
|
|
|
|
default:
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (optind != argc)
|
|
|
|
|
usage (stdout, 1);
|
|
|
|
|
|
|
|
|
|
if (srcdir != NULL)
|
|
|
|
|
if (chdir (srcdir) != 0)
|
|
|
|
|
fail (_("unable to change directory to \"%s\", errno = %s\n"),
|
|
|
|
|
srcdir, strerror (errno));
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
load_insn_classes ();
|
|
|
|
|
load_dependencies ();
|
2000-04-21 20:22:24 +00:00
|
|
|
|
|
|
|
|
|
shrink (ia64_opcodes_a);
|
|
|
|
|
shrink (ia64_opcodes_b);
|
|
|
|
|
shrink (ia64_opcodes_f);
|
|
|
|
|
shrink (ia64_opcodes_i);
|
|
|
|
|
shrink (ia64_opcodes_m);
|
|
|
|
|
shrink (ia64_opcodes_x);
|
|
|
|
|
shrink (ia64_opcodes_d);
|
|
|
|
|
|
|
|
|
|
collapse_redundant_completers ();
|
|
|
|
|
|
2002-11-07 14:33:48 +00:00
|
|
|
|
printf ("/* This file is automatically generated by ia64-gen. Do not edit! */\n");
|
2000-04-21 20:22:24 +00:00
|
|
|
|
print_string_table ();
|
|
|
|
|
print_dependency_table ();
|
|
|
|
|
print_completer_table ();
|
|
|
|
|
print_main_table ();
|
|
|
|
|
|
|
|
|
|
generate_disassembler ();
|
|
|
|
|
|
|
|
|
|
exit (0);
|
|
|
|
|
}
|