184865Sobrien/* ia64-asmtab.h -- Header for compacted IA-64 opcode tables.
284865Sobrien   Copyright 1999, 2000 Free Software Foundation, Inc.
384865Sobrien   Contributed by Bob Manson of Cygnus Support <manson@cygnus.com>
484865Sobrien
584865Sobrien   This file is part of GDB, GAS, and the GNU binutils.
684865Sobrien
784865Sobrien   GDB, GAS, and the GNU binutils are free software; you can redistribute
884865Sobrien   them and/or modify them under the terms of the GNU General Public
984865Sobrien   License as published by the Free Software Foundation; either version
1084865Sobrien   2, or (at your option) any later version.
1184865Sobrien
1284865Sobrien   GDB, GAS, and the GNU binutils are distributed in the hope that they
1384865Sobrien   will be useful, but WITHOUT ANY WARRANTY; without even the implied
1484865Sobrien   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
1584865Sobrien   the GNU General Public License for more details.
1684865Sobrien
1784865Sobrien   You should have received a copy of the GNU General Public License
1884865Sobrien   along with this file; see the file COPYING.  If not, write to the
19218822Sdim   Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20218822Sdim   02110-1301, USA.  */
2184865Sobrien
2284865Sobrien#ifndef IA64_ASMTAB_H
2384865Sobrien#define IA64_ASMTAB_H
2484865Sobrien
2584865Sobrien#include "opcode/ia64.h"
2684865Sobrien
2784865Sobrien/* The primary opcode table is made up of the following: */
2884865Sobrienstruct ia64_main_table
2984865Sobrien{
3084865Sobrien  /* The entry in the string table that corresponds to the name of this
3184865Sobrien     opcode. */
3284865Sobrien  unsigned short name_index;
3384865Sobrien
3484865Sobrien  /* The type of opcode; corresponds to the TYPE field in
3584865Sobrien     struct ia64_opcode. */
3684865Sobrien  unsigned char opcode_type;
3784865Sobrien
3884865Sobrien  /* The number of outputs for this opcode. */
3984865Sobrien  unsigned char num_outputs;
4084865Sobrien
4184865Sobrien  /* The base insn value for this opcode.  It may be modified by completers. */
4284865Sobrien  ia64_insn opcode;
4384865Sobrien
4484865Sobrien  /* The mask of valid bits in OPCODE. Zeros indicate operand fields. */
4584865Sobrien  ia64_insn mask;
4684865Sobrien
4784865Sobrien  /* The operands of this instruction.  Corresponds to the OPERANDS field
4884865Sobrien     in struct ia64_opcode. */
4984865Sobrien  unsigned char operands[5];
5084865Sobrien
5184865Sobrien  /* The flags for this instruction.  Corresponds to the FLAGS field in
5284865Sobrien     struct ia64_opcode. */
5384865Sobrien  short flags;
5484865Sobrien
5584865Sobrien  /* The tree of completers for this instruction; this is an offset into
5684865Sobrien     completer_table. */
5784865Sobrien  short completers;
5884865Sobrien};
5984865Sobrien
6084865Sobrien/* Each instruction has a set of possible "completers", or additional
6184865Sobrien   suffixes that can alter the instruction's behavior, and which has
6284865Sobrien   potentially different dependencies.
6384865Sobrien
6484865Sobrien   The completer entries modify certain bits in the instruction opcode.
6584865Sobrien   Which bits are to be modified are marked by the BITS, MASK and
6684865Sobrien   OFFSET fields.  The completer entry may also note dependencies for the
6784865Sobrien   opcode.
6884865Sobrien
6984865Sobrien   These completers are arranged in a DAG; the pointers are indexes
7084865Sobrien   into the completer_table array.  The completer DAG is searched by
7184865Sobrien   find_completer () and ia64_find_matching_opcode ().
7284865Sobrien
7384865Sobrien   Note that each completer needs to be applied in turn, so that if we
7484865Sobrien   have the instruction
7584865Sobrien   	cmp.lt.unc
7684865Sobrien   the completer entries for both "lt" and "unc" would need to be applied
7784865Sobrien   to the opcode's value.
7884865Sobrien
7984865Sobrien   Some instructions do not require any completers; these contain an
8084865Sobrien   empty completer entry.  Instructions that require a completer do
8184865Sobrien   not contain an empty entry.
8284865Sobrien
8384865Sobrien   Terminal completers (those completers that validly complete an
8484865Sobrien   instruction) are marked by having the TERMINAL_COMPLETER flag set.
8584865Sobrien
8684865Sobrien   Only dependencies listed in the terminal completer for an opcode are
8784865Sobrien   considered to apply to that opcode instance. */
8884865Sobrien
8984865Sobrienstruct ia64_completer_table
9084865Sobrien{
9184865Sobrien  /* The bit value that this completer sets. */
9284865Sobrien  unsigned int bits;
9384865Sobrien
9484865Sobrien  /* And its mask. 1s are bits that are to be modified in the
9584865Sobrien     instruction. */
9684865Sobrien  unsigned int mask;
9784865Sobrien
9884865Sobrien  /* The entry in the string table that corresponds to the name of this
9984865Sobrien     completer. */
10084865Sobrien  unsigned short name_index;
10184865Sobrien
10284865Sobrien  /* An alternative completer, or -1 if this is the end of the chain. */
10384865Sobrien  short alternative;
10484865Sobrien
10584865Sobrien  /* A pointer to the DAG of completers that can potentially follow
10684865Sobrien     this one, or -1. */
10784865Sobrien  short subentries;
10884865Sobrien
10984865Sobrien  /* The bit offset in the instruction where BITS and MASK should be
11084865Sobrien     applied. */
11184865Sobrien  unsigned char offset : 7;
11284865Sobrien
11384865Sobrien  unsigned char terminal_completer : 1;
11484865Sobrien
11584865Sobrien  /* Index into the dependency list table */
11684865Sobrien  short dependencies;
11784865Sobrien};
11884865Sobrien
11984865Sobrien/* This contains sufficient information for the disassembler to resolve
12084865Sobrien   the complete name of the original instruction.  */
12184865Sobrienstruct ia64_dis_names
12284865Sobrien{
12384865Sobrien  /* COMPLETER_INDEX represents the tree of completers that make up
12484865Sobrien     the instruction.  The LSB represents the top of the tree for the
12584865Sobrien     specified instruction.
12684865Sobrien
12784865Sobrien     A 0 bit indicates to go to the next alternate completer via the
12884865Sobrien     alternative field; a 1 bit indicates that the current completer
12984865Sobrien     is part of the instruction, and to go down the subentries index.
13084865Sobrien     We know we've reached the final completer when we run out of 1
13184865Sobrien     bits.
13284865Sobrien
13384865Sobrien     There is always at least one 1 bit. */
13484865Sobrien  unsigned int completer_index : 20;
13584865Sobrien
13684865Sobrien  /* The index in the main_table[] array for the instruction. */
13784865Sobrien  unsigned short insn_index : 11;
13884865Sobrien
13984865Sobrien  /* If set, the next entry in this table is an alternate possibility
14084865Sobrien     for this instruction encoding.  Which one to use is determined by
14184865Sobrien     the instruction type and other factors (see opcode_verify ()).  */
14284865Sobrien  unsigned int next_flag : 1;
14384865Sobrien
14484865Sobrien  /* The disassembly priority of this entry among instructions. */
14584865Sobrien  unsigned short priority;
14684865Sobrien};
14784865Sobrien
14884865Sobrien#endif
149