1*5f210c2aSfgsch /* ia64-asmtab.h -- Header for compacted IA-64 opcode tables.
2*5f210c2aSfgsch    Copyright 1999, 2000 Free Software Foundation, Inc.
3*5f210c2aSfgsch    Contributed by Bob Manson of Cygnus Support <manson@cygnus.com>
4*5f210c2aSfgsch 
5*5f210c2aSfgsch    This file is part of GDB, GAS, and the GNU binutils.
6*5f210c2aSfgsch 
7*5f210c2aSfgsch    GDB, GAS, and the GNU binutils are free software; you can redistribute
8*5f210c2aSfgsch    them and/or modify them under the terms of the GNU General Public
9*5f210c2aSfgsch    License as published by the Free Software Foundation; either version
10*5f210c2aSfgsch    2, or (at your option) any later version.
11*5f210c2aSfgsch 
12*5f210c2aSfgsch    GDB, GAS, and the GNU binutils are distributed in the hope that they
13*5f210c2aSfgsch    will be useful, but WITHOUT ANY WARRANTY; without even the implied
14*5f210c2aSfgsch    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
15*5f210c2aSfgsch    the GNU General Public License for more details.
16*5f210c2aSfgsch 
17*5f210c2aSfgsch    You should have received a copy of the GNU General Public License
18*5f210c2aSfgsch    along with this file; see the file COPYING.  If not, write to the
19*5f210c2aSfgsch    Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20*5f210c2aSfgsch    02111-1307, USA.  */
21*5f210c2aSfgsch 
22*5f210c2aSfgsch #ifndef IA64_ASMTAB_H
23*5f210c2aSfgsch #define IA64_ASMTAB_H
24*5f210c2aSfgsch 
25*5f210c2aSfgsch #include "opcode/ia64.h"
26*5f210c2aSfgsch 
27*5f210c2aSfgsch /* The primary opcode table is made up of the following: */
28*5f210c2aSfgsch struct ia64_main_table
29*5f210c2aSfgsch {
30*5f210c2aSfgsch   /* The entry in the string table that corresponds to the name of this
31*5f210c2aSfgsch      opcode. */
32*5f210c2aSfgsch   unsigned short name_index;
33*5f210c2aSfgsch 
34*5f210c2aSfgsch   /* The type of opcode; corresponds to the TYPE field in
35*5f210c2aSfgsch      struct ia64_opcode. */
36*5f210c2aSfgsch   unsigned char opcode_type;
37*5f210c2aSfgsch 
38*5f210c2aSfgsch   /* The number of outputs for this opcode. */
39*5f210c2aSfgsch   unsigned char num_outputs;
40*5f210c2aSfgsch 
41*5f210c2aSfgsch   /* The base insn value for this opcode.  It may be modified by completers. */
42*5f210c2aSfgsch   ia64_insn opcode;
43*5f210c2aSfgsch 
44*5f210c2aSfgsch   /* The mask of valid bits in OPCODE. Zeros indicate operand fields. */
45*5f210c2aSfgsch   ia64_insn mask;
46*5f210c2aSfgsch 
47*5f210c2aSfgsch   /* The operands of this instruction.  Corresponds to the OPERANDS field
48*5f210c2aSfgsch      in struct ia64_opcode. */
49*5f210c2aSfgsch   unsigned char operands[5];
50*5f210c2aSfgsch 
51*5f210c2aSfgsch   /* The flags for this instruction.  Corresponds to the FLAGS field in
52*5f210c2aSfgsch      struct ia64_opcode. */
53*5f210c2aSfgsch   short flags;
54*5f210c2aSfgsch 
55*5f210c2aSfgsch   /* The tree of completers for this instruction; this is an offset into
56*5f210c2aSfgsch      completer_table. */
57*5f210c2aSfgsch   short completers;
58*5f210c2aSfgsch };
59*5f210c2aSfgsch 
60*5f210c2aSfgsch /* Each instruction has a set of possible "completers", or additional
61*5f210c2aSfgsch    suffixes that can alter the instruction's behavior, and which has
62*5f210c2aSfgsch    potentially different dependencies.
63*5f210c2aSfgsch 
64*5f210c2aSfgsch    The completer entries modify certain bits in the instruction opcode.
65*5f210c2aSfgsch    Which bits are to be modified are marked by the BITS, MASK and
66*5f210c2aSfgsch    OFFSET fields.  The completer entry may also note dependencies for the
67*5f210c2aSfgsch    opcode.
68*5f210c2aSfgsch 
69*5f210c2aSfgsch    These completers are arranged in a DAG; the pointers are indexes
70*5f210c2aSfgsch    into the completer_table array.  The completer DAG is searched by
71*5f210c2aSfgsch    find_completer () and ia64_find_matching_opcode ().
72*5f210c2aSfgsch 
73*5f210c2aSfgsch    Note that each completer needs to be applied in turn, so that if we
74*5f210c2aSfgsch    have the instruction
75*5f210c2aSfgsch    	cmp.lt.unc
76*5f210c2aSfgsch    the completer entries for both "lt" and "unc" would need to be applied
77*5f210c2aSfgsch    to the opcode's value.
78*5f210c2aSfgsch 
79*5f210c2aSfgsch    Some instructions do not require any completers; these contain an
80*5f210c2aSfgsch    empty completer entry.  Instructions that require a completer do
81*5f210c2aSfgsch    not contain an empty entry.
82*5f210c2aSfgsch 
83*5f210c2aSfgsch    Terminal completers (those completers that validly complete an
84*5f210c2aSfgsch    instruction) are marked by having the TERMINAL_COMPLETER flag set.
85*5f210c2aSfgsch 
86*5f210c2aSfgsch    Only dependencies listed in the terminal completer for an opcode are
87*5f210c2aSfgsch    considered to apply to that opcode instance. */
88*5f210c2aSfgsch 
89*5f210c2aSfgsch struct ia64_completer_table
90*5f210c2aSfgsch {
91*5f210c2aSfgsch   /* The bit value that this completer sets. */
92*5f210c2aSfgsch   unsigned int bits;
93*5f210c2aSfgsch 
94*5f210c2aSfgsch   /* And its mask. 1s are bits that are to be modified in the
95*5f210c2aSfgsch      instruction. */
96*5f210c2aSfgsch   unsigned int mask;
97*5f210c2aSfgsch 
98*5f210c2aSfgsch   /* The entry in the string table that corresponds to the name of this
99*5f210c2aSfgsch      completer. */
100*5f210c2aSfgsch   unsigned short name_index;
101*5f210c2aSfgsch 
102*5f210c2aSfgsch   /* An alternative completer, or -1 if this is the end of the chain. */
103*5f210c2aSfgsch   short alternative;
104*5f210c2aSfgsch 
105*5f210c2aSfgsch   /* A pointer to the DAG of completers that can potentially follow
106*5f210c2aSfgsch      this one, or -1. */
107*5f210c2aSfgsch   short subentries;
108*5f210c2aSfgsch 
109*5f210c2aSfgsch   /* The bit offset in the instruction where BITS and MASK should be
110*5f210c2aSfgsch      applied. */
111*5f210c2aSfgsch   unsigned char offset : 7;
112*5f210c2aSfgsch 
113*5f210c2aSfgsch   unsigned char terminal_completer : 1;
114*5f210c2aSfgsch 
115*5f210c2aSfgsch   /* Index into the dependency list table */
116*5f210c2aSfgsch   short dependencies;
117*5f210c2aSfgsch };
118*5f210c2aSfgsch 
119*5f210c2aSfgsch /* This contains sufficient information for the disassembler to resolve
120*5f210c2aSfgsch    the complete name of the original instruction.  */
121*5f210c2aSfgsch struct ia64_dis_names
122*5f210c2aSfgsch {
123*5f210c2aSfgsch   /* COMPLETER_INDEX represents the tree of completers that make up
124*5f210c2aSfgsch      the instruction.  The LSB represents the top of the tree for the
125*5f210c2aSfgsch      specified instruction.
126*5f210c2aSfgsch 
127*5f210c2aSfgsch      A 0 bit indicates to go to the next alternate completer via the
128*5f210c2aSfgsch      alternative field; a 1 bit indicates that the current completer
129*5f210c2aSfgsch      is part of the instruction, and to go down the subentries index.
130*5f210c2aSfgsch      We know we've reached the final completer when we run out of 1
131*5f210c2aSfgsch      bits.
132*5f210c2aSfgsch 
133*5f210c2aSfgsch      There is always at least one 1 bit. */
134*5f210c2aSfgsch   unsigned int completer_index : 20;
135*5f210c2aSfgsch 
136*5f210c2aSfgsch   /* The index in the main_table[] array for the instruction. */
137*5f210c2aSfgsch   unsigned short insn_index : 11;
138*5f210c2aSfgsch 
139*5f210c2aSfgsch   /* If set, the next entry in this table is an alternate possibility
140*5f210c2aSfgsch      for this instruction encoding.  Which one to use is determined by
141*5f210c2aSfgsch      the instruction type and other factors (see opcode_verify ()).  */
142*5f210c2aSfgsch   unsigned int next_flag : 1;
143*5f210c2aSfgsch 
144*5f210c2aSfgsch   /* The disassembly priority of this entry among instructions. */
145*5f210c2aSfgsch   unsigned short priority;
146*5f210c2aSfgsch };
147*5f210c2aSfgsch 
148*5f210c2aSfgsch #endif
149