1c5dff60aSchristos /* Table of opcodes for the Texas Instruments TMS320C[34]X family.
2c5dff60aSchristos 
3*1424dfb3Schristos    Copyright (C) 2002-2020 Free Software Foundation, Inc.
4c5dff60aSchristos 
5c5dff60aSchristos    Contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz)
6c5dff60aSchristos 
7c5dff60aSchristos    This program is free software; you can redistribute it and/or modify
8c5dff60aSchristos    it under the terms of the GNU General Public License as published by
9c5dff60aSchristos    the Free Software Foundation; either version 3 of the License, or
10c5dff60aSchristos    (at your option) any later version.
11c5dff60aSchristos 
12c5dff60aSchristos    This program is distributed in the hope that it will be useful,
13c5dff60aSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
14c5dff60aSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15c5dff60aSchristos    GNU General Public License for more details.
16c5dff60aSchristos 
17c5dff60aSchristos    You should have received a copy of the GNU General Public License
18c5dff60aSchristos    along with this program; if not, write to the Free Software
19c5dff60aSchristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20c5dff60aSchristos    MA 02110-1301, USA.  */
21c5dff60aSchristos 
22c5dff60aSchristos #define IS_CPU_TIC3X(v) ((v) == 30 || (v) == 31 || (v) == 32 || (v) == 33)
23c5dff60aSchristos #define IS_CPU_TIC4X(v) ((v) ==  0 || (v) == 40 || (v) == 44)
24c5dff60aSchristos 
25c5dff60aSchristos /* Define some bitfield extraction/insertion macros.  */
26*1424dfb3Schristos #define EXTRU(inst, m, l) \
27*1424dfb3Schristos   (((inst) >> (l)) & ((2u << ((m) - (l))) - 1))
28*1424dfb3Schristos #define EXTRS(inst, m, l) \
29*1424dfb3Schristos   ((int) ((EXTRU (inst, m, l) ^ (1u << ((m) - (l)))) - (1u << ((m) - (l)))))
30*1424dfb3Schristos #define INSERTU(inst, val, m, l) \
31*1424dfb3Schristos   ((inst) |= ((val) & ((2u << ((m) - (l))) - 1)) << (l))
32*1424dfb3Schristos #define INSERTS INSERTU
33c5dff60aSchristos 
34c5dff60aSchristos /* Define register numbers.  */
35c5dff60aSchristos typedef enum
36c5dff60aSchristos   {
37c5dff60aSchristos     REG_R0, REG_R1, REG_R2, REG_R3,
38c5dff60aSchristos     REG_R4, REG_R5, REG_R6, REG_R7,
39c5dff60aSchristos     REG_AR0, REG_AR1, REG_AR2, REG_AR3,
40c5dff60aSchristos     REG_AR4, REG_AR5, REG_AR6, REG_AR7,
41c5dff60aSchristos     REG_DP, REG_IR0, REG_IR1, REG_BK,
42c5dff60aSchristos     REG_SP, REG_ST, REG_DIE, REG_IIE,
43c5dff60aSchristos     REG_IIF, REG_RS, REG_RE, REG_RC,
44c5dff60aSchristos     REG_R8, REG_R9, REG_R10, REG_R11,
45c5dff60aSchristos     REG_IVTP, REG_TVTP
46c5dff60aSchristos   }
47c5dff60aSchristos c4x_reg_t;
48c5dff60aSchristos 
49c5dff60aSchristos /* Note that the actual register numbers for IVTP is 0 and TVTP is 1.  */
50c5dff60aSchristos 
51c5dff60aSchristos #define REG_IE REG_DIE		/* C3x only */
52c5dff60aSchristos #define REG_IF REG_IIE		/* C3x only */
53c5dff60aSchristos #define REG_IOF REG_IIF		/* C3x only */
54c5dff60aSchristos 
55c5dff60aSchristos #define TIC3X_REG_MAX REG_RC
56c5dff60aSchristos #define TIC4X_REG_MAX REG_TVTP
57c5dff60aSchristos 
58c5dff60aSchristos /* Register table size including C4x expansion regs.  */
59c5dff60aSchristos #define REG_TABLE_SIZE (TIC4X_REG_MAX + 1)
60c5dff60aSchristos 
61c5dff60aSchristos struct tic4x_register
62c5dff60aSchristos {
63c03b94e9Schristos   const char *  name;
64c5dff60aSchristos   unsigned long regno;
65c5dff60aSchristos };
66c5dff60aSchristos 
67c5dff60aSchristos typedef struct tic4x_register tic4x_register_t;
68c5dff60aSchristos 
69c5dff60aSchristos /* We could store register synonyms here.  */
70c5dff60aSchristos static const tic4x_register_t tic3x_registers[] =
71c5dff60aSchristos {
72c5dff60aSchristos   {"f0",  REG_R0},
73c5dff60aSchristos   {"r0",  REG_R0},
74c5dff60aSchristos   {"f1",  REG_R1},
75c5dff60aSchristos   {"r1",  REG_R1},
76c5dff60aSchristos   {"f2",  REG_R2},
77c5dff60aSchristos   {"r2",  REG_R2},
78c5dff60aSchristos   {"f3",  REG_R3},
79c5dff60aSchristos   {"r3",  REG_R3},
80c5dff60aSchristos   {"f4",  REG_R4},
81c5dff60aSchristos   {"r4",  REG_R4},
82c5dff60aSchristos   {"f5",  REG_R5},
83c5dff60aSchristos   {"r5",  REG_R5},
84c5dff60aSchristos   {"f6",  REG_R6},
85c5dff60aSchristos   {"r6",  REG_R6},
86c5dff60aSchristos   {"f7",  REG_R7},
87c5dff60aSchristos   {"r7",  REG_R7},
88c5dff60aSchristos   {"ar0", REG_AR0},
89c5dff60aSchristos   {"ar1", REG_AR1},
90c5dff60aSchristos   {"ar2", REG_AR2},
91c5dff60aSchristos   {"ar3", REG_AR3},
92c5dff60aSchristos   {"ar4", REG_AR4},
93c5dff60aSchristos   {"ar5", REG_AR5},
94c5dff60aSchristos   {"ar6", REG_AR6},
95c5dff60aSchristos   {"ar7", REG_AR7},
96c5dff60aSchristos   {"dp",  REG_DP},
97c5dff60aSchristos   {"ir0", REG_IR0},
98c5dff60aSchristos   {"ir1", REG_IR1},
99c5dff60aSchristos   {"bk",  REG_BK},
100c5dff60aSchristos   {"sp",  REG_SP},
101c5dff60aSchristos   {"st",  REG_ST},
102c5dff60aSchristos   {"ie",  REG_IE},
103c5dff60aSchristos   {"if",  REG_IF},
104c5dff60aSchristos   {"iof", REG_IOF},
105c5dff60aSchristos   {"rs",  REG_RS},
106c5dff60aSchristos   {"re",  REG_RE},
107c5dff60aSchristos   {"rc",  REG_RC},
108c5dff60aSchristos   {"", 0}
109c5dff60aSchristos };
110c5dff60aSchristos 
111c5dff60aSchristos const unsigned int tic3x_num_registers = (((sizeof tic3x_registers) / (sizeof tic3x_registers[0])) - 1);
112c5dff60aSchristos 
113c5dff60aSchristos /* Define C4x registers in addition to C3x registers.  */
114c5dff60aSchristos static const tic4x_register_t tic4x_registers[] =
115c5dff60aSchristos {
116c5dff60aSchristos   {"die", REG_DIE},		/* Clobbers C3x REG_IE */
117c5dff60aSchristos   {"iie", REG_IIE},		/* Clobbers C3x REG_IF */
118c5dff60aSchristos   {"iif", REG_IIF},		/* Clobbers C3x REG_IOF */
119c5dff60aSchristos   {"f8",  REG_R8},
120c5dff60aSchristos   {"r8",  REG_R8},
121c5dff60aSchristos   {"f9",  REG_R9},
122c5dff60aSchristos   {"r9",  REG_R9},
123c5dff60aSchristos   {"f10", REG_R10},
124c5dff60aSchristos   {"r10", REG_R10},
125c5dff60aSchristos   {"f11", REG_R11},
126c5dff60aSchristos   {"r11", REG_R11},
127c5dff60aSchristos   {"ivtp", REG_IVTP},
128c5dff60aSchristos   {"tvtp", REG_TVTP},
129c5dff60aSchristos   {"", 0}
130c5dff60aSchristos };
131c5dff60aSchristos 
132c5dff60aSchristos const unsigned int tic4x_num_registers = (((sizeof tic4x_registers) / (sizeof tic4x_registers[0])) - 1);
133c5dff60aSchristos 
134c5dff60aSchristos struct tic4x_cond
135c5dff60aSchristos {
136c03b94e9Schristos   const char *  name;
137c5dff60aSchristos   unsigned long cond;
138c5dff60aSchristos };
139c5dff60aSchristos 
140c5dff60aSchristos typedef struct tic4x_cond tic4x_cond_t;
141c5dff60aSchristos 
142c5dff60aSchristos /* Define conditional branch/load suffixes.  Put desired form for
143c5dff60aSchristos    disassembler last.  */
144c5dff60aSchristos static const tic4x_cond_t tic4x_conds[] =
145c5dff60aSchristos {
146c5dff60aSchristos   { "u",    0x00 },
147c5dff60aSchristos   { "c",    0x01 }, { "lo",  0x01 },
148c5dff60aSchristos   { "ls",   0x02 },
149c5dff60aSchristos   { "hi",   0x03 },
150c5dff60aSchristos   { "nc",   0x04 }, { "hs",  0x04 },
151c5dff60aSchristos   { "z",    0x05 }, { "eq",  0x05 },
152c5dff60aSchristos   { "nz",   0x06 }, { "ne",  0x06 },
153c5dff60aSchristos   { "n",    0x07 }, { "l",   0x07 }, { "lt",  0x07 },
154c5dff60aSchristos   { "le",   0x08 },
155c5dff60aSchristos   { "p",    0x09 }, { "gt",  0x09 },
156c5dff60aSchristos   { "nn",   0x0a }, { "ge",  0x0a },
157c5dff60aSchristos   { "nv",   0x0c },
158c5dff60aSchristos   { "v",    0x0d },
159c5dff60aSchristos   { "nuf",  0x0e },
160c5dff60aSchristos   { "uf",   0x0f },
161c5dff60aSchristos   { "nlv",  0x10 },
162c5dff60aSchristos   { "lv",   0x11 },
163c5dff60aSchristos   { "nluf", 0x12 },
164c5dff60aSchristos   { "luf",  0x13 },
165c5dff60aSchristos   { "zuf",  0x14 },
166c5dff60aSchristos   /* Dummy entry, not included in num_conds.  This
167c5dff60aSchristos      lets code examine entry i+1 without checking
168c5dff60aSchristos      if we've run off the end of the table.  */
169c5dff60aSchristos   { "",      0x0}
170c5dff60aSchristos };
171c5dff60aSchristos 
172c5dff60aSchristos const unsigned int tic4x_num_conds = (((sizeof tic4x_conds) / (sizeof tic4x_conds[0])) - 1);
173c5dff60aSchristos 
174c5dff60aSchristos struct tic4x_indirect
175c5dff60aSchristos {
176c03b94e9Schristos   const char *  name;
177c5dff60aSchristos   unsigned long modn;
178c5dff60aSchristos };
179c5dff60aSchristos 
180c5dff60aSchristos typedef struct tic4x_indirect tic4x_indirect_t;
181c5dff60aSchristos 
182c5dff60aSchristos /* Define indirect addressing modes where:
183c5dff60aSchristos    d displacement (signed)
184c5dff60aSchristos    y ir0
185c5dff60aSchristos    z ir1  */
186c5dff60aSchristos 
187c5dff60aSchristos static const tic4x_indirect_t tic4x_indirects[] =
188c5dff60aSchristos {
189c5dff60aSchristos   { "*+a(d)",   0x00 },
190c5dff60aSchristos   { "*-a(d)",   0x01 },
191c5dff60aSchristos   { "*++a(d)",  0x02 },
192c5dff60aSchristos   { "*--a(d)",  0x03 },
193c5dff60aSchristos   { "*a++(d)",  0x04 },
194c5dff60aSchristos   { "*a--(d)",  0x05 },
195c5dff60aSchristos   { "*a++(d)%", 0x06 },
196c5dff60aSchristos   { "*a--(d)%", 0x07 },
197c5dff60aSchristos   { "*+a(y)",   0x08 },
198c5dff60aSchristos   { "*-a(y)",   0x09 },
199c5dff60aSchristos   { "*++a(y)",  0x0a },
200c5dff60aSchristos   { "*--a(y)",  0x0b },
201c5dff60aSchristos   { "*a++(y)",  0x0c },
202c5dff60aSchristos   { "*a--(y)",  0x0d },
203c5dff60aSchristos   { "*a++(y)%", 0x0e },
204c5dff60aSchristos   { "*a--(y)%", 0x0f },
205c5dff60aSchristos   { "*+a(z)",   0x10 },
206c5dff60aSchristos   { "*-a(z)",   0x11 },
207c5dff60aSchristos   { "*++a(z)",  0x12 },
208c5dff60aSchristos   { "*--a(z)",  0x13 },
209c5dff60aSchristos   { "*a++(z)",  0x14 },
210c5dff60aSchristos   { "*a--(z)",  0x15 },
211c5dff60aSchristos   { "*a++(z)%", 0x16 },
212c5dff60aSchristos   { "*a--(z)%", 0x17 },
213c5dff60aSchristos   { "*a",       0x18 },
214c5dff60aSchristos   { "*a++(y)b", 0x19 },
215c5dff60aSchristos   /* Dummy entry, not included in num_indirects.  This
216c5dff60aSchristos      lets code examine entry i+1 without checking
217c5dff60aSchristos      if we've run off the end of the table.  */
218c5dff60aSchristos   { "",      0x0}
219c5dff60aSchristos };
220c5dff60aSchristos 
221c5dff60aSchristos #define TIC3X_MODN_MAX 0x19
222c5dff60aSchristos 
223c5dff60aSchristos const unsigned int tic4x_num_indirects = (((sizeof tic4x_indirects) / (sizeof tic4x_indirects[0])) - 1);
224c5dff60aSchristos 
225c5dff60aSchristos /* Instruction template.  */
226c5dff60aSchristos struct tic4x_inst
227c5dff60aSchristos {
228c03b94e9Schristos   const char *  name;
229c5dff60aSchristos   unsigned long opcode;
230c5dff60aSchristos   unsigned long opmask;
231c03b94e9Schristos   const char *        args;
232c5dff60aSchristos   unsigned long oplevel;
233c5dff60aSchristos };
234c5dff60aSchristos 
235c5dff60aSchristos typedef struct tic4x_inst tic4x_inst_t;
236c5dff60aSchristos 
237c5dff60aSchristos /* Opcode infix
238c5dff60aSchristos    B  condition              16--20   U,C,Z,LO,HI, etc.
239c5dff60aSchristos    C  condition              23--27   U,C,Z,LO,HI, etc.
240c5dff60aSchristos 
241c5dff60aSchristos    Arguments
242c5dff60aSchristos    ,  required arg follows
243c5dff60aSchristos    ;  optional arg follows
244c5dff60aSchristos 
245c5dff60aSchristos    Argument types             bits    [classes] - example
246c5dff60aSchristos    -----------------------------------------------------------
247c5dff60aSchristos    *  indirect (all)          0--15   [A,AB,AU,AF,A2,A3,A6,A7,AY,B,BA,BB,BI,B6,B7] - *+AR0(5), *++AR0(IR0)
248c5dff60aSchristos    #  direct (for LDP)        0--15   [Z] - @start, start
249c5dff60aSchristos    @  direct                  0--15   [A,AB,AU,AF,A3,A6,A7,AY,B,BA,BB,BI,B6,B7] - @start, start
250c5dff60aSchristos    A  address register       22--24   [D] - AR0, AR7
251c5dff60aSchristos    B  unsigned integer        0--23   [I,I2] - @start, start  (absolute on C3x, relative on C4x)
252c5dff60aSchristos    C  indirect (disp - C4x)   0--7    [S,SC,S2,T,TC,T2,T2C] - *+AR0(5)
253c5dff60aSchristos    E  register (all)          0--7    [T,TC,T2,T2C] - R0, R7, R11, AR0, DP
254c5dff60aSchristos    e  register (0-11)         0--7    [S,SC,S2] - R0, R7, R11
255c5dff60aSchristos    F  short float immediate   0--15   [AF,B,BA,BB] - 3.5, 0e-3.5e-1
256c5dff60aSchristos    G  register (all)          8--15   [T,TC,T2,T2C] - R0, R7, R11, AR0, DP
257c5dff60aSchristos    g  register (0-11)         0--7    [S,SC,S2] - R0, R7, R11
258c5dff60aSchristos    H  register (0-7)         18--16   [LS,M,P,Q] - R0, R7
259c5dff60aSchristos    I  indirect (no disp)      0--7    [S,SC,S2,T,TC,T2,T2C] - *+AR0(1), *+AR0(IR0)
260c5dff60aSchristos    i  indirect (enhanced)     0--7    [LL,LS,M,P,Q,QC] - *+AR0(1), R5
261c5dff60aSchristos    J  indirect (no disp)      8--15   [LL,LS,P,Q,QC,S,SC,S2,T,TC,T2,T2C] - *+AR0(1), *+AR0(IR0)
262c5dff60aSchristos    j  indirect (enhanced)     8--15   [M] - *+AR0(1), R5
263c5dff60aSchristos    K  register               19--21   [LL,M,Q,QC] - R0, R7
264c5dff60aSchristos    L  register               22--24   [LL,LS,P,Q,QC] - R0, R7
265c5dff60aSchristos    M  register (R2,R3)       22--22   [M] R2, R3
266c5dff60aSchristos    N  register (R0,R1)       23--23   [M] R0, R1
267c5dff60aSchristos    O  indirect(disp - C4x)    8--15   [S,SC,S2,T,TC,T2] - *+AR0(5)
268c5dff60aSchristos    P  displacement (PC Rel)   0--15   [D,J,JS] - @start, start
269c5dff60aSchristos    Q  register (all)          0--15   [A,AB,AU,A2,A3,AY,BA,BI,D,I2,J,JS] - R0, AR0, DP, SP
270c5dff60aSchristos    q  register (0-11)         0--15   [AF,B,BB] - R0, R7, R11
271c5dff60aSchristos    R  register (all)         16--20   [A,AB,AU,AF,A6,A7,R,T,TC] - R0, AR0, DP, SP
272c5dff60aSchristos    r  register (0-11)        16--20   [B,BA,BB,BI,B6,B7,RF,S,SC] - R0, R1, R11
273c5dff60aSchristos    S  short int immediate     0--15   [A,AB,AY,BI] - -5, 5
274c5dff60aSchristos    T  integer (C4x)          16--20   [Z] - -5, 12
275c5dff60aSchristos    U  unsigned integer        0--15   [AU,A3] - 0, 65535
276c5dff60aSchristos    V  vector (C4x: 0--8)      0--4    [Z] - 25, 7
277c5dff60aSchristos    W  short int (C4x)         0--7    [T,TC,T2,T2C] - -3, 5
278c5dff60aSchristos    X  expansion reg (C4x)     0--4    [Z] - IVTP, TVTP
279c5dff60aSchristos    Y  address reg (C4x)      16--20   [Z] - AR0, DP, SP, IR0
280c5dff60aSchristos    Z  expansion reg (C4x)    16--20   [Z] - IVTP, TVTP
281c5dff60aSchristos */
282c5dff60aSchristos 
283c5dff60aSchristos #define TIC4X_OPERANDS_MAX 7	/* Max number of operands for an inst.  */
284c5dff60aSchristos #define TIC4X_NAME_MAX 16	/* Max number of chars in parallel name.  */
285c5dff60aSchristos 
286c5dff60aSchristos /* Define the instruction level */
287c5dff60aSchristos #define OP_C3X   0x1   /* C30 support - supported by all */
288c5dff60aSchristos #define OP_C4X   0x2   /* C40 support - C40, C44 */
289c5dff60aSchristos #define OP_ENH   0x4   /* Class LL,LS,M,P,Q,QC enhancements. Argument type
290c5dff60aSchristos                           I and J is enhanced in these classes - C31>=6.0,
291c5dff60aSchristos                           C32>=2.0, C33 */
292c5dff60aSchristos #define OP_LPWR  0x8   /* Low power support (LOPOWER, MAXSPEED) - C30>=7.0,
293c5dff60aSchristos                           LC31, C31>=5.0, C32 */
294c5dff60aSchristos #define OP_IDLE2 0x10  /* Idle2 support (IDLE2) - C30>=7.0, LC31, C31>=5.0,
295c5dff60aSchristos                           C32, C33, C40>=5.0, C44 */
296c5dff60aSchristos 
297c5dff60aSchristos /* The following class definition is a classification scheme for
298c5dff60aSchristos    putting instructions with similar type of arguments together. It
299c5dff60aSchristos    simplifies the op-code definitions significantly, as we then only
300c5dff60aSchristos    need to use the class macroes for 95% of the DSP's opcodes.
301c5dff60aSchristos */
302c5dff60aSchristos 
303c5dff60aSchristos /* A: General 2-operand integer operations
304c5dff60aSchristos    Syntax: <i> src, dst
305c5dff60aSchristos       src = Register (Q), Direct (@), Indirect (*), Signed immediate (S)
306c5dff60aSchristos       dst = Register (R)
307c5dff60aSchristos    Instr: 15/8 - ABSI, ADDC, ADDI, ASH, CMPI, LDI, LSH, MPYI, NEGB, NEGI,
308c5dff60aSchristos                 SUBB, SUBC, SUBI, SUBRB, SUBRI, C4x: LBn, LHn, LWLn, LWRn,
309c5dff60aSchristos                 MBn, MHn, MPYSHI, MPYUHI
310c5dff60aSchristos */
311c5dff60aSchristos #define A_CLASS_INSN(name, opcode, level) \
312c5dff60aSchristos   { name, opcode|0x00000000, 0xffe00000, "Q;R", level }, \
313c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "@,R", level }, \
314c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*,R", level }, \
315c5dff60aSchristos   { name, opcode|0x00600000, 0xffe00000, "S,R", level }
316c5dff60aSchristos 
317c5dff60aSchristos /* AB: General 2-operand integer operation with condition
318c5dff60aSchristos    Syntax: <i>c src, dst
319c5dff60aSchristos        c   = Condition
320c5dff60aSchristos        src = Register (Q), Direct (@), Indirect (*), Signed immediate (S)
321c5dff60aSchristos        dst = Register (R)
322c5dff60aSchristos    Instr: 1/0 - LDIc
323c5dff60aSchristos */
324c5dff60aSchristos #define AB_CLASS_INSN(name, opcode, level) \
325c5dff60aSchristos   { name, opcode|0x40000000, 0xf0600000, "Q;R", level }, \
326c5dff60aSchristos   { name, opcode|0x40200000, 0xf0600000, "@,R", level }, \
327c5dff60aSchristos   { name, opcode|0x40400000, 0xf0600000, "*,R", level }, \
328c5dff60aSchristos   { name, opcode|0x40600000, 0xf0600000, "S,R", level }
329c5dff60aSchristos 
330c5dff60aSchristos /* AU: General 2-operand unsigned integer operation
331c5dff60aSchristos    Syntax: <i> src, dst
332c5dff60aSchristos         src = Register (Q), Direct (@), Indirect (*), Unsigned immediate (U)
333c5dff60aSchristos         dst = Register (R)
334c5dff60aSchristos    Instr: 6/2 - AND, ANDN, NOT, OR, TSTB, XOR, C4x: LBUn, LHUn
335c5dff60aSchristos */
336c5dff60aSchristos #define AU_CLASS_INSN(name, opcode, level) \
337c5dff60aSchristos   { name, opcode|0x00000000, 0xffe00000, "Q;R", level }, \
338c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "@,R", level }, \
339c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*,R", level }, \
340c5dff60aSchristos   { name, opcode|0x00600000, 0xffe00000, "U,R", level }
341c5dff60aSchristos 
342c5dff60aSchristos /* AF: General 2-operand float to integer operation
343c5dff60aSchristos    Syntax: <i> src, dst
344c5dff60aSchristos         src = Register 0-11 (q), Direct (@), Indirect (*), Float immediate (F)
345c5dff60aSchristos         dst = Register (R)
346c5dff60aSchristos    Instr: 1/0 - FIX
347c5dff60aSchristos */
348c5dff60aSchristos #define AF_CLASS_INSN(name, opcode, level) \
349c5dff60aSchristos   { name, opcode|0x00000000, 0xffe00000, "q;R", level }, \
350c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "@,R", level }, \
351c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*,R", level }, \
352c5dff60aSchristos   { name, opcode|0x00600000, 0xffe00000, "F,R", level }
353c5dff60aSchristos 
354c5dff60aSchristos /* A2: Limited 1-operand (integer) operation
355c5dff60aSchristos    Syntax: <i> src
356c5dff60aSchristos        src = Register (Q), Indirect (*), None
357c5dff60aSchristos    Instr: 1/0 - NOP
358c5dff60aSchristos */
359c5dff60aSchristos #define A2_CLASS_INSN(name, opcode, level) \
360c5dff60aSchristos   { name, opcode|0x00000000, 0xffe00000, "Q", level }, \
361c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*", level }, \
362c5dff60aSchristos   { name, opcode|0x00000000, 0xffe00000, "" , level }
363c5dff60aSchristos 
364c5dff60aSchristos /* A3: General 1-operand unsigned integer operation
365c5dff60aSchristos    Syntax: <i> src
366c5dff60aSchristos         src = Register (Q), Direct (@), Indirect (*), Unsigned immediate (U)
367c5dff60aSchristos    Instr: 1/0 - RPTS
368c5dff60aSchristos */
369c5dff60aSchristos #define A3_CLASS_INSN(name, opcode, level) \
370c5dff60aSchristos   { name, opcode|0x00000000, 0xffff0000, "Q", level }, \
371c5dff60aSchristos   { name, opcode|0x00200000, 0xffff0000, "@", level }, \
372c5dff60aSchristos   { name, opcode|0x00400000, 0xffff0000, "*", level }, \
373c5dff60aSchristos   { name, opcode|0x00600000, 0xffff0000, "U", level }
374c5dff60aSchristos 
375c5dff60aSchristos /* A6: Limited 2-operand integer operation
376c5dff60aSchristos    Syntax: <i> src, dst
377c5dff60aSchristos        src = Direct (@), Indirect (*)
378c5dff60aSchristos        dst = Register (R)
379c5dff60aSchristos    Instr: 1/1 - LDII, C4x: SIGI
380c5dff60aSchristos */
381c5dff60aSchristos #define A6_CLASS_INSN(name, opcode, level) \
382c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "@,R", level }, \
383c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*,R", level }
384c5dff60aSchristos 
385c5dff60aSchristos /* A7: Limited 2-operand integer store operation
386c5dff60aSchristos    Syntax: <i> src, dst
387c5dff60aSchristos        src = Register (R)
388c5dff60aSchristos        dst = Direct (@), Indirect (*)
389c5dff60aSchristos    Instr: 2/0 - STI, STII
390c5dff60aSchristos */
391c5dff60aSchristos #define A7_CLASS_INSN(name, opcode, level) \
392c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "R,@", level }, \
393c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "R,*", level }
394c5dff60aSchristos 
395c5dff60aSchristos /* AY: General 2-operand signed address load operation
396c5dff60aSchristos    Syntax: <i> src, dst
397c5dff60aSchristos         src = Register (Q), Direct (@), Indirect (*), Signed immediate (S)
398c5dff60aSchristos         dst = Address register - ARx, IRx, DP, BK, SP (Y)
399c5dff60aSchristos    Instr: 0/1 - C4x: LDA
400c5dff60aSchristos    Note: Q and Y should *never* be the same register
401c5dff60aSchristos */
402c5dff60aSchristos #define AY_CLASS_INSN(name, opcode, level) \
403c5dff60aSchristos   { name, opcode|0x00000000, 0xffe00000, "Q,Y", level }, \
404c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "@,Y", level }, \
405c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*,Y", level }, \
406c5dff60aSchristos   { name, opcode|0x00600000, 0xffe00000, "S,Y", level }
407c5dff60aSchristos 
408c5dff60aSchristos /* B: General 2-operand float operation
409c5dff60aSchristos    Syntax: <i> src, dst
410c5dff60aSchristos        src = Register 0-11 (q), Direct (@), Indirect (*), Float immediate (F)
411c5dff60aSchristos        dst = Register 0-11 (r)
412c5dff60aSchristos    Instr: 12/2 - ABSF, ADDF, CMPF, LDE, LDF, LDM, MPYF, NEGF, NORM, RND,
413c5dff60aSchristos                  SUBF, SUBRF, C4x: RSQRF, TOIEEE
414c5dff60aSchristos */
415c5dff60aSchristos #define B_CLASS_INSN(name, opcode, level) \
416c5dff60aSchristos   { name, opcode|0x00000000, 0xffe00000, "q;r", level }, \
417c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "@,r", level }, \
418c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*,r", level }, \
419c5dff60aSchristos   { name, opcode|0x00600000, 0xffe00000, "F,r", level }
420c5dff60aSchristos 
421c5dff60aSchristos /* BA: General 2-operand integer to float operation
422c5dff60aSchristos    Syntax: <i> src, dst
423c5dff60aSchristos        src = Register (Q), Direct (@), Indirect (*), Float immediate (F)
424c5dff60aSchristos        dst = Register 0-11 (r)
425c5dff60aSchristos    Instr: 0/1 - C4x: CRCPF
426c5dff60aSchristos */
427c5dff60aSchristos #define BA_CLASS_INSN(name, opcode, level) \
428c5dff60aSchristos   { name, opcode|0x00000000, 0xffe00000, "Q;r", level }, \
429c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "@,r", level }, \
430c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*,r", level }, \
431c5dff60aSchristos   { name, opcode|0x00600000, 0xffe00000, "F,r", level }
432c5dff60aSchristos 
433c5dff60aSchristos /* BB: General 2-operand conditional float operation
434c5dff60aSchristos    Syntax: <i>c src, dst
435c5dff60aSchristos        c   = Condition
436c5dff60aSchristos        src = Register 0-11 (q), Direct (@), Indirect (*), Float immediate (F)
437c5dff60aSchristos        dst = Register 0-11 (r)
438c5dff60aSchristos    Instr: 1/0 - LDFc
439c5dff60aSchristos */
440c5dff60aSchristos #define BB_CLASS_INSN(name, opcode, level) \
441c5dff60aSchristos   { name, opcode|0x40000000, 0xf0600000, "q;r", level }, \
442c5dff60aSchristos   { name, opcode|0x40200000, 0xf0600000, "@,r", level }, \
443c5dff60aSchristos   { name, opcode|0x40400000, 0xf0600000, "*,r", level }, \
444c5dff60aSchristos   { name, opcode|0x40600000, 0xf0600000, "F,r", level }
445c5dff60aSchristos 
446c5dff60aSchristos /* BI: General 2-operand integer to float operation (yet different to BA)
447c5dff60aSchristos    Syntax: <i> src, dst
448c5dff60aSchristos        src = Register (Q), Direct (@), Indirect (*), Signed immediate (S)
449c5dff60aSchristos        dst = Register 0-11 (r)
450c5dff60aSchristos    Instr: 1/0 - FLOAT
451c5dff60aSchristos */
452c5dff60aSchristos #define BI_CLASS_INSN(name, opcode, level) \
453c5dff60aSchristos   { name, opcode|0x00000000, 0xffe00000, "Q;r", level }, \
454c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "@,r", level }, \
455c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*,r", level }, \
456c5dff60aSchristos   { name, opcode|0x00600000, 0xffe00000, "S,r", level }
457c5dff60aSchristos 
458c5dff60aSchristos /* B6: Limited 2-operand float operation
459c5dff60aSchristos    Syntax: <i> src, dst
460c5dff60aSchristos        src = Direct (@), Indirect (*)
461c5dff60aSchristos        dst = Register 0-11 (r)
462c5dff60aSchristos    Instr: 1/1 - LDFI, C4x: FRIEEE
463c5dff60aSchristos */
464c5dff60aSchristos #define B6_CLASS_INSN(name, opcode, level) \
465c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "@,r", level }, \
466c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "*,r", level }
467c5dff60aSchristos 
468c5dff60aSchristos /* B7: Limited 2-operand float store operation
469c5dff60aSchristos    Syntax: <i> src, dst
470c5dff60aSchristos        src = Register 0-11 (r)
471c5dff60aSchristos        dst = Direct (@), Indirect (*)
472c5dff60aSchristos    Instr: 2/0 - STF, STFI
473c5dff60aSchristos */
474c5dff60aSchristos #define B7_CLASS_INSN(name, opcode, level) \
475c5dff60aSchristos   { name, opcode|0x00200000, 0xffe00000, "r,@", level }, \
476c5dff60aSchristos   { name, opcode|0x00400000, 0xffe00000, "r,*", level }
477c5dff60aSchristos 
478c5dff60aSchristos /* D: Decrement and brach operations
479c5dff60aSchristos    Syntax: <i>c ARn, dst
480c5dff60aSchristos        c   = condition
481c5dff60aSchristos        ARn = AR register 0-7 (A)
482c5dff60aSchristos        dst = Register (Q), PC-relative (P)
483c5dff60aSchristos    Instr: 2/0 - DBc, DBcD
484c5dff60aSchristos    Alias: <name1> <name2>
485c5dff60aSchristos */
486c5dff60aSchristos #define D_CLASS_INSN(name1, name2, opcode, level) \
487c5dff60aSchristos   { name1, opcode|0x00000000, 0xfe200000, "A,Q", level }, \
488c5dff60aSchristos   { name1, opcode|0x02000000, 0xfe200000, "A,P", level }, \
489c5dff60aSchristos   { name2, opcode|0x00000000, 0xfe200000, "A,Q", level }, \
490c5dff60aSchristos   { name2, opcode|0x02000000, 0xfe200000, "A,P", level }
491c5dff60aSchristos 
492c5dff60aSchristos /* I: General branch operations
493c5dff60aSchristos    Syntax: <i> dst
494c5dff60aSchristos        dst = Address (B)
495c5dff60aSchristos    Instr: 3/1 - BR, BRD, CALL, C4x: LAJ
496c5dff60aSchristos */
497c5dff60aSchristos 
498c5dff60aSchristos /* I2: General branch operations (C4x addition)
499c5dff60aSchristos    Syntax: <i> dst
500c5dff60aSchristos        dst = Address (B), C4x: Register (Q)
501c5dff60aSchristos    Instr: 2/0 - RPTB, RPTBD
502c5dff60aSchristos */
503c5dff60aSchristos 
504c5dff60aSchristos /* J: General conditional branch operations
505c5dff60aSchristos    Syntax: <i>c dst
506c5dff60aSchristos        c   = Condition
507c5dff60aSchristos        dst = Register (Q), PC-relative (P)
508c5dff60aSchristos    Instr: 2/3 - Bc, BcD, C4x: BcAF, BcAT, LAJc
509c5dff60aSchristos    Alias: <name1> <name2>
510c5dff60aSchristos */
511c5dff60aSchristos #define J_CLASS_INSN(name1, name2, opcode, level) \
512c5dff60aSchristos   { name1, opcode|0x00000000, 0xffe00000, "Q", level }, \
513c5dff60aSchristos   { name1, opcode|0x02000000, 0xffe00000, "P", level }, \
514c5dff60aSchristos   { name2, opcode|0x00000000, 0xffe00000, "Q", level }, \
515c5dff60aSchristos   { name2, opcode|0x02000000, 0xffe00000, "P", level }
516c5dff60aSchristos 
517c5dff60aSchristos /* JS: General conditional branch operations
518c5dff60aSchristos    Syntax: <i>c dst
519c5dff60aSchristos        c   = Condition
520c5dff60aSchristos        dst = Register (Q), PC-relative (P)
521c5dff60aSchristos    Instr: 1/1 - CALLc, C4X: LAJc
522c5dff60aSchristos */
523c5dff60aSchristos 
524c5dff60aSchristos /* LL: Load-load parallell operation
525c5dff60aSchristos    Syntax: <i> src2, dst2 || <i> src1, dst1
526c5dff60aSchristos        src1 = Indirect 0,1,IR0,IR1 (J)
527c5dff60aSchristos        dst1 = Register 0-7 (K)
528c5dff60aSchristos        src2 = Indirect 0,1,IR0,IR1, ENH: Register (i)
529c5dff60aSchristos        dst2 = Register 0-7 (L)
530c5dff60aSchristos    Instr: 2/0 - LDF||LDF, LDI||LDI
531c5dff60aSchristos    Alias: i||i, i1||i2, i2||i1
532c5dff60aSchristos */
533c5dff60aSchristos #define LL_CLASS_INSN(name, opcode, level) \
534c5dff60aSchristos   { name "_"  name    , opcode, 0xfe000000, "i;L|J,K", level }, \
535c5dff60aSchristos   { name "2_" name "1", opcode, 0xfe000000, "i;L|J,K", level }, \
536c5dff60aSchristos   { name "1_" name "2", opcode, 0xfe000000, "J,K|i;L", level }
537c5dff60aSchristos 
538c5dff60aSchristos /* LS: Store-store parallell operation
539c5dff60aSchristos    Syntax: <i> src2, dst2 || <i> src1, dst1
540c5dff60aSchristos        src1 = Register 0-7 (H)
541c5dff60aSchristos        dst1 = Indirect 0,1,IR0,IR1 (J)
542c5dff60aSchristos        src2 = Register 0-7 (L)
543c5dff60aSchristos        dst2 = Indirect 0,1,IR0,IR1, ENH: register (i)
544c5dff60aSchristos    Instr: 2/0 - STF||STF, STI||STI
545c5dff60aSchristos    Alias: i||i, i1||i2, i2||i1.
546c5dff60aSchristos */
547c5dff60aSchristos #define LS_CLASS_INSN(name, opcode, level) \
548c5dff60aSchristos   { name "_"  name    , opcode, 0xfe000000, "L;i|H,J", level }, \
549c5dff60aSchristos   { name "2_" name "1", opcode, 0xfe000000, "L;i|H,J", level }, \
550c5dff60aSchristos   { name "1_" name "2", opcode, 0xfe000000, "H,J|L;i", level }
551c5dff60aSchristos 
552c5dff60aSchristos /* M: General multiply and add/sub operations
553c5dff60aSchristos    Syntax: <ia> src3,src4,dst1 || <ib> src2,src1,dst2 [00] - Manual
554c5dff60aSchristos            <ia> src3,src1,dst1 || <ib> src2,src4,dst2 [01] - Manual
555c5dff60aSchristos            <ia> src1,src3,dst1 || <ib> src2,src4,dst2 [01]
556c5dff60aSchristos            <ia> src1,src2,dst1 || <ib> src4,src3,dst2 [02] - Manual
557c5dff60aSchristos            <ia> src3,src1,dst1 || <ib> src4,src2,dst2 [03] - Manual
558c5dff60aSchristos            <ia> src1,src3,dst1 || <ib> src4,src2,dst2 [03]
559c5dff60aSchristos        src1 = Register 0-7 (K)
560c5dff60aSchristos        src2 = Register 0-7 (H)
561c5dff60aSchristos        src3 = Indirect 0,1,IR0,IR1, ENH: register (j)
562c5dff60aSchristos        src4 = Indirect 0,1,IR0,IR1, ENH: register (i)
563c5dff60aSchristos        dst1 = Register 0-1 (N)
564c5dff60aSchristos        dst2 = Register 2-3 (M)
565c5dff60aSchristos    Instr: 4/0 - MPYF3||ADDF3, MPYF3||SUBF3, MPYI3||ADDI3, MPYI3||SUBI3
566c5dff60aSchristos    Alias: a||b, a3||n, a||b3, a3||b3, b||a, b3||a, b||a3, b3||a3
567c5dff60aSchristos */
568c5dff60aSchristos #define M_CLASS_INSN(namea, nameb, opcode, level) \
569c5dff60aSchristos   { namea "_" nameb, opcode|0x00000000, 0xff000000, "i;j;N|H;K;M", level }, \
570c5dff60aSchristos   { namea "_" nameb, opcode|0x01000000, 0xff000000, "j;K;N|H;i;M", level }, \
571c5dff60aSchristos   { namea "_" nameb, opcode|0x01000000, 0xff000000, "K;j;N|H;i;M", level }, \
572c5dff60aSchristos   { namea "_" nameb, opcode|0x02000000, 0xff000000, "H;K;N|i;j;M", level }, \
573c5dff60aSchristos   { namea "_" nameb, opcode|0x03000000, 0xff000000, "j;K;N|i;H;M", level }, \
574c5dff60aSchristos   { namea "_" nameb, opcode|0x03000000, 0xff000000, "K;j;N|i;H;M", level }, \
575c5dff60aSchristos   { namea "3_" nameb, opcode|0x00000000, 0xff000000, "i;j;N|H;K;M", level }, \
576c5dff60aSchristos   { namea "3_" nameb, opcode|0x01000000, 0xff000000, "j;K;N|H;i;M", level }, \
577c5dff60aSchristos   { namea "3_" nameb, opcode|0x01000000, 0xff000000, "K;j;N|H;i;M", level }, \
578c5dff60aSchristos   { namea "3_" nameb, opcode|0x02000000, 0xff000000, "H;K;N|i;j;M", level }, \
579c5dff60aSchristos   { namea "3_" nameb, opcode|0x03000000, 0xff000000, "j;K;N|i;H;M", level }, \
580c5dff60aSchristos   { namea "3_" nameb, opcode|0x03000000, 0xff000000, "K;j;N|i;H;M", level }, \
581c5dff60aSchristos   { namea "_" nameb "3", opcode|0x00000000, 0xff000000, "i;j;N|H;K;M", level }, \
582c5dff60aSchristos   { namea "_" nameb "3", opcode|0x01000000, 0xff000000, "j;K;N|H;i;M", level }, \
583c5dff60aSchristos   { namea "_" nameb "3", opcode|0x01000000, 0xff000000, "K;j;N|H;i;M", level }, \
584c5dff60aSchristos   { namea "_" nameb "3", opcode|0x02000000, 0xff000000, "H;K;N|i;j;M", level }, \
585c5dff60aSchristos   { namea "_" nameb "3", opcode|0x03000000, 0xff000000, "j;K;N|i;H;M", level }, \
586c5dff60aSchristos   { namea "_" nameb "3", opcode|0x03000000, 0xff000000, "K;j;N|i;H;M", level }, \
587c5dff60aSchristos   { namea "3_" nameb "3", opcode|0x00000000, 0xff000000, "i;j;N|H;K;M", level }, \
588c5dff60aSchristos   { namea "3_" nameb "3", opcode|0x01000000, 0xff000000, "j;K;N|H;i;M", level }, \
589c5dff60aSchristos   { namea "3_" nameb "3", opcode|0x01000000, 0xff000000, "K;j;N|H;i;M", level }, \
590c5dff60aSchristos   { namea "3_" nameb "3", opcode|0x02000000, 0xff000000, "H;K;N|i;j;M", level }, \
591c5dff60aSchristos   { namea "3_" nameb "3", opcode|0x03000000, 0xff000000, "j;K;N|i;H;M", level }, \
592c5dff60aSchristos   { namea "3_" nameb "3", opcode|0x03000000, 0xff000000, "K;j;N|i;H;M", level }, \
593c5dff60aSchristos   { nameb "_" namea, opcode|0x00000000, 0xff000000, "H;K;M|i;j;N", level }, \
594c5dff60aSchristos   { nameb "_" namea, opcode|0x01000000, 0xff000000, "H;i;M|j;K;N", level }, \
595c5dff60aSchristos   { nameb "_" namea, opcode|0x01000000, 0xff000000, "H;i;M|K;j;N", level }, \
596c5dff60aSchristos   { nameb "_" namea, opcode|0x02000000, 0xff000000, "i;j;M|H;K;N", level }, \
597c5dff60aSchristos   { nameb "_" namea, opcode|0x03000000, 0xff000000, "i;H;M|j;K;N", level }, \
598c5dff60aSchristos   { nameb "_" namea, opcode|0x03000000, 0xff000000, "i;H;M|K;j;N", level }, \
599c5dff60aSchristos   { nameb "3_" namea, opcode|0x00000000, 0xff000000, "H;K;M|i;j;N", level }, \
600c5dff60aSchristos   { nameb "3_" namea, opcode|0x01000000, 0xff000000, "H;i;M|j;K;N", level }, \
601c5dff60aSchristos   { nameb "3_" namea, opcode|0x01000000, 0xff000000, "H;i;M|K;j;N", level }, \
602c5dff60aSchristos   { nameb "3_" namea, opcode|0x02000000, 0xff000000, "i;j;M|H;K;N", level }, \
603c5dff60aSchristos   { nameb "3_" namea, opcode|0x03000000, 0xff000000, "i;H;M|j;K;N", level }, \
604c5dff60aSchristos   { nameb "3_" namea, opcode|0x03000000, 0xff000000, "i;H;M|K;j;N", level }, \
605c5dff60aSchristos   { nameb "_" namea "3", opcode|0x00000000, 0xff000000, "H;K;M|i;j;N", level }, \
606c5dff60aSchristos   { nameb "_" namea "3", opcode|0x01000000, 0xff000000, "H;i;M|j;K;N", level }, \
607c5dff60aSchristos   { nameb "_" namea "3", opcode|0x01000000, 0xff000000, "H;i;M|K;j;N", level }, \
608c5dff60aSchristos   { nameb "_" namea "3", opcode|0x02000000, 0xff000000, "i;j;M|H;K;N", level }, \
609c5dff60aSchristos   { nameb "_" namea "3", opcode|0x03000000, 0xff000000, "i;H;M|j;K;N", level }, \
610c5dff60aSchristos   { nameb "_" namea "3", opcode|0x03000000, 0xff000000, "i;H;M|K;j;N", level }, \
611c5dff60aSchristos   { nameb "3_" namea "3", opcode|0x00000000, 0xff000000, "H;K;M|i;j;N", level }, \
612c5dff60aSchristos   { nameb "3_" namea "3", opcode|0x01000000, 0xff000000, "H;i;M|j;K;N", level }, \
613c5dff60aSchristos   { nameb "3_" namea "3", opcode|0x01000000, 0xff000000, "H;i;M|K;j;N", level }, \
614c5dff60aSchristos   { nameb "3_" namea "3", opcode|0x02000000, 0xff000000, "i;j;M|H;K;N", level }, \
615c5dff60aSchristos   { nameb "3_" namea "3", opcode|0x03000000, 0xff000000, "i;H;M|j;K;N", level }, \
616c5dff60aSchristos   { nameb "3_" namea "3", opcode|0x03000000, 0xff000000, "i;H;M|K;j;N", level }
617c5dff60aSchristos 
618c5dff60aSchristos /* P: General 2-operand operation with parallell store
619c5dff60aSchristos    Syntax: <ia> src2, dst1 || <ib> src3, dst2
620c5dff60aSchristos        src2 = Indirect 0,1,IR0,IR1, ENH: register (i)
621c5dff60aSchristos        dst1 = Register 0-7 (L)
622c5dff60aSchristos        src3 = Register 0-7 (H)
623c5dff60aSchristos        dst2 = Indirect 0,1,IR0,IR1 (J)
624c5dff60aSchristos    Instr: 9/2 - ABSF||STF, ABSI||STI, FIX||STI, FLOAT||STF, LDF||STF,
625c5dff60aSchristos                 LDI||STI, NEGF||STF, NEGI||STI, NOT||STI, C4x: FRIEEE||STF,
626c5dff60aSchristos                 TOIEEE||STF
627c5dff60aSchristos    Alias: a||b, b||a
628c5dff60aSchristos */
629c5dff60aSchristos #define P_CLASS_INSN(namea, nameb, opcode, level) \
630c5dff60aSchristos   { namea "_" nameb, opcode, 0xfe000000, "i;L|H,J", level }, \
631c5dff60aSchristos   { nameb "_" namea, opcode, 0xfe000000, "H,J|i;L", level }
632c5dff60aSchristos 
633c5dff60aSchristos /* Q: General 3-operand operation with parallell store
634c5dff60aSchristos    Syntax: <ia> src1, src2, dst1 || <ib> src3, dst2
635c5dff60aSchristos        src1 = Register 0-7 (K)
636c5dff60aSchristos        src2 = Indirect 0,1,IR0,IR1, ENH: register (i)
637c5dff60aSchristos        dst1 = Register 0-7 (L)
638c5dff60aSchristos        src3 = Register 0-7 (H)
639c5dff60aSchristos        dst2 = Indirect 0,1,IR0,IR1 (J)
640c5dff60aSchristos    Instr: 4/0 - ASH3||STI, LSH3||STI, SUBF3||STF, SUBI3||STI
641c5dff60aSchristos    Alias: a||b, b||a, a3||b, b||a3
642c5dff60aSchristos */
643c5dff60aSchristos #define Q_CLASS_INSN(namea, nameb, opcode, level) \
644c5dff60aSchristos   { namea "_"  nameb    , opcode, 0xfe000000, "K,i;L|H,J", level }, \
645c5dff60aSchristos   { nameb "_"  namea    , opcode, 0xfe000000, "H,J|K,i;L", level }, \
646c5dff60aSchristos   { namea "3_" nameb    , opcode, 0xfe000000, "K,i;L|H,J", level }, \
647c5dff60aSchristos   { nameb "_"  namea "3", opcode, 0xfe000000, "H,J|K,i;L", level }
648c5dff60aSchristos 
649c5dff60aSchristos /* QC: General commutative 3-operand operation with parallell store
650c5dff60aSchristos    Syntax: <ia> src2, src1, dst1 || <ib> src3, dst2
651c5dff60aSchristos            <ia> src1, src2, dst1 || <ib> src3, dst2 - Manual
652c5dff60aSchristos        src1 = Register 0-7 (K)
653c5dff60aSchristos        src2 = Indirect 0,1,IR0,IR1, ENH: register (i)
654c5dff60aSchristos        dst1 = Register 0-7 (L)
655c5dff60aSchristos        src3 = Register 0-7 (H)
656c5dff60aSchristos        dst2 = Indirect 0,1,IR0,IR1 (J)
657c5dff60aSchristos    Instr: 7/0 - ADDF3||STF, ADDI3||STI, AND3||STI, MPYF3||STF, MPYI3||STI,
658c5dff60aSchristos                 OR3||STI, XOR3||STI
659c5dff60aSchristos    Alias: a||b, b||a, a3||b, b||a3
660c5dff60aSchristos */
661c5dff60aSchristos #define QC_CLASS_INSN(namea, nameb, opcode, level) \
662c5dff60aSchristos   { namea "_"  nameb    , opcode, 0xfe000000, "i;K;L|H,J", level }, \
663c5dff60aSchristos   { namea "_"  nameb    , opcode, 0xfe000000, "K;i;L|H,J", level }, \
664c5dff60aSchristos   { nameb "_"  namea    , opcode, 0xfe000000, "H,J|i;K;L", level }, \
665c5dff60aSchristos   { nameb "_"  namea    , opcode, 0xfe000000, "H,J|K;i;L", level }, \
666c5dff60aSchristos   { namea "3_" nameb    , opcode, 0xfe000000, "i;K;L|H,J", level }, \
667c5dff60aSchristos   { namea "3_" nameb    , opcode, 0xfe000000, "K;i;L|H,J", level }, \
668c5dff60aSchristos   { nameb "_"  namea "3", opcode, 0xfe000000, "H,J|i;K;L", level }, \
669c5dff60aSchristos   { nameb "_"  namea "3", opcode, 0xfe000000, "H,J|K;i;L", level }
670c5dff60aSchristos 
671c5dff60aSchristos /* R: General register integer operation
672c5dff60aSchristos    Syntax: <i> dst
673c5dff60aSchristos        dst = Register (R)
674c5dff60aSchristos    Instr: 6/0 - POP, PUSH, ROL, ROLC, ROR, RORC
675c5dff60aSchristos */
676c5dff60aSchristos #define R_CLASS_INSN(name, opcode, level) \
677c5dff60aSchristos   { name, opcode, 0xffe0ffff, "R", level }
678c5dff60aSchristos 
679c5dff60aSchristos /* RF: General register float operation
680c5dff60aSchristos    Syntax: <i> dst
681c5dff60aSchristos        dst = Register 0-11 (r)
682c5dff60aSchristos    Instr: 2/0 - POPF, PUSHF
683c5dff60aSchristos */
684c5dff60aSchristos #define RF_CLASS_INSN(name, opcode, level) \
685c5dff60aSchristos   { name, opcode, 0xffe0ffff, "r", level }
686c5dff60aSchristos 
687c5dff60aSchristos /* S: General 3-operand float operation
688c5dff60aSchristos    Syntax: <i> src2, src1, dst
689c5dff60aSchristos        src2 = Register 0-11 (e), Indirect 0,1,IR0,IR1 (I), C4x T2: Indirect (C)
690c5dff60aSchristos        src1 = Register 0-11 (g), Indirect 0,1,IR0,IR1 (J), C4x T2: Indirect (O)
691c5dff60aSchristos        dst  = Register 0-11 (r)
692c5dff60aSchristos    Instr: 1/0 - SUBF3
693c5dff60aSchristos    Alias: i, i3
694c5dff60aSchristos */
695c5dff60aSchristos #define S_CLASS_INSN(name, opcode, level) \
696c5dff60aSchristos   { name, opcode|0x20000000, 0xffe00000, "e,g;r", level  }, \
697c5dff60aSchristos   { name, opcode|0x20200000, 0xffe00000, "e,J,r", level  }, \
698c5dff60aSchristos   { name, opcode|0x20400000, 0xffe00000, "I,g;r", level  }, \
699c5dff60aSchristos   { name, opcode|0x20600000, 0xffe00000, "I,J,r", level  }, \
700c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "C,g;r", OP_C4X }, \
701c5dff60aSchristos   { name, opcode|0x30600000, 0xffe00000, "C,O,r", OP_C4X }, \
702c5dff60aSchristos   { name "3", opcode|0x20000000, 0xffe00000, "e,g;r", level  }, \
703c5dff60aSchristos   { name "3", opcode|0x20200000, 0xffe00000, "e,J,r", level  }, \
704c5dff60aSchristos   { name "3", opcode|0x20400000, 0xffe00000, "I,g;r", level  }, \
705c5dff60aSchristos   { name "3", opcode|0x20600000, 0xffe00000, "I,J,r", level  }, \
706c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "C,g;r", OP_C4X }, \
707c5dff60aSchristos   { name "3", opcode|0x30600000, 0xffe00000, "C,O,r", OP_C4X }
708c5dff60aSchristos 
709c5dff60aSchristos /* SC: General commutative 3-operand float operation
710c5dff60aSchristos    Syntax: <i> src2, src1, dst - Manual
711c5dff60aSchristos            <i> src1, src2, dst
712c5dff60aSchristos        src2 = Register 0-11 (e), Indirect 0,1,IR0,IR1 (I), C4x T2: Indirect (C)
713c5dff60aSchristos        src1 = Register 0-11 (g), Indirect 0,1,IR0,IR1 (J), C4x T2: Indirect (O)
714c5dff60aSchristos        dst  = Register 0-11 (r)
715c5dff60aSchristos    Instr: 2/0 - ADDF3, MPYF3
716c5dff60aSchristos    Alias: i, i3
717c5dff60aSchristos */
718c5dff60aSchristos #define SC_CLASS_INSN(name, opcode, level) \
719c5dff60aSchristos   { name, opcode|0x20000000, 0xffe00000, "e,g;r", level  }, \
720c5dff60aSchristos   { name, opcode|0x20200000, 0xffe00000, "e,J,r", level  }, \
721c5dff60aSchristos   { name, opcode|0x20400000, 0xffe00000, "I,g;r", level  }, \
722c5dff60aSchristos   { name, opcode|0x20600000, 0xffe00000, "I,J,r", level  }, \
723c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "C,g;r", OP_C4X }, \
724c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "g,C,r", OP_C4X }, \
725c5dff60aSchristos   { name, opcode|0x30600000, 0xffe00000, "C,O,r", OP_C4X }, \
726c5dff60aSchristos   { name "3", opcode|0x20000000, 0xffe00000, "e,g;r", level  }, \
727c5dff60aSchristos   { name "3", opcode|0x20200000, 0xffe00000, "e,J,r", level  }, \
728c5dff60aSchristos   { name "3", opcode|0x20400000, 0xffe00000, "I,g;r", level  }, \
729c5dff60aSchristos   { name "3", opcode|0x20600000, 0xffe00000, "I,J,r", level  }, \
730c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "g,C,r", OP_C4X }, \
731c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "C,g;r", OP_C4X }, \
732c5dff60aSchristos   { name "3", opcode|0x30600000, 0xffe00000, "C,O,r", OP_C4X }
733c5dff60aSchristos 
734c5dff60aSchristos /* S2: General 3-operand float operation with 2 args
735c5dff60aSchristos    Syntax: <i> src2, src1
736c5dff60aSchristos        src2 = Register 0-11 (e), Indirect 0,1,IR0,IR1 (I), C4x T2: Indirect (C)
737c5dff60aSchristos        src1 = Register 0-11 (g), Indirect 0,1,IR0,IR1 (J), C4x T2: Indirect (O)
738c5dff60aSchristos    Instr: 1/0 - CMPF3
739c5dff60aSchristos    Alias: i, i3
740c5dff60aSchristos */
741c5dff60aSchristos #define S2_CLASS_INSN(name, opcode, level) \
742c5dff60aSchristos   { name, opcode|0x20000000, 0xffe00000, "e,g", level  }, \
743c5dff60aSchristos   { name, opcode|0x20200000, 0xffe00000, "e,J", level  }, \
744c5dff60aSchristos   { name, opcode|0x20400000, 0xffe00000, "I,g", level  }, \
745c5dff60aSchristos   { name, opcode|0x20600000, 0xffe00000, "I,J", level  }, \
746c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "C,g", OP_C4X }, \
747c5dff60aSchristos   { name, opcode|0x30600000, 0xffe00000, "C,O", OP_C4X }, \
748c5dff60aSchristos   { name "3", opcode|0x20000000, 0xffe00000, "e,g", level  }, \
749c5dff60aSchristos   { name "3", opcode|0x20200000, 0xffe00000, "e,J", level  }, \
750c5dff60aSchristos   { name "3", opcode|0x20400000, 0xffe00000, "I,g", level  }, \
751c5dff60aSchristos   { name "3", opcode|0x20600000, 0xffe00000, "I,J", level  }, \
752c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "C,g", OP_C4X }, \
753c5dff60aSchristos   { name "3", opcode|0x30600000, 0xffe00000, "C,O", OP_C4X }
754c5dff60aSchristos 
755c5dff60aSchristos /* T: General 3-operand integer operand
756c5dff60aSchristos    Syntax: <i> src2, src1, dst
757c5dff60aSchristos        src2 = Register (E), Indirect 0,1,IR0,IR1 (I), C4x T2: Indirect (C), Immediate (W)
758c5dff60aSchristos        src1 = Register (G), Indirect 0,1,IR0,IR1 (J), C4x T2: Indirect (O)
759c5dff60aSchristos        dst  = Register (R)
760c5dff60aSchristos    Instr: 5/0 - ANDN3, ASH3, LSH3, SUBB3, SUBI3
761c5dff60aSchristos    Alias: i, i3
762c5dff60aSchristos */
763c5dff60aSchristos #define T_CLASS_INSN(name, opcode, level) \
764c5dff60aSchristos   { name, opcode|0x20000000, 0xffe00000, "E,G;R", level  }, \
765c5dff60aSchristos   { name, opcode|0x20200000, 0xffe00000, "E,J,R", level  }, \
766c5dff60aSchristos   { name, opcode|0x20400000, 0xffe00000, "I,G;R", level  }, \
767c5dff60aSchristos   { name, opcode|0x20600000, 0xffe00000, "I,J,R", level  }, \
768c5dff60aSchristos   { name, opcode|0x30000000, 0xffe00000, "W,G;R", OP_C4X }, \
769c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "C,G;R", OP_C4X }, \
770c5dff60aSchristos   { name, opcode|0x30400000, 0xffe00000, "W,O,R", OP_C4X }, \
771c5dff60aSchristos   { name, opcode|0x30600000, 0xffe00000, "C,O,R", OP_C4X }, \
772c5dff60aSchristos   { name "3", opcode|0x20000000, 0xffe00000, "E,G;R", level  }, \
773c5dff60aSchristos   { name "3", opcode|0x20200000, 0xffe00000, "E,J,R", level  }, \
774c5dff60aSchristos   { name "3", opcode|0x20400000, 0xffe00000, "I,G;R", level  }, \
775c5dff60aSchristos   { name "3", opcode|0x20600000, 0xffe00000, "I,J,R", level  }, \
776c5dff60aSchristos   { name "3", opcode|0x30000000, 0xffe00000, "W,G;R", OP_C4X }, \
777c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "C,G;R", OP_C4X }, \
778c5dff60aSchristos   { name "3", opcode|0x30400000, 0xffe00000, "W,O,R", OP_C4X }, \
779c5dff60aSchristos   { name "3", opcode|0x30600000, 0xffe00000, "C,O,R", OP_C4X }
780c5dff60aSchristos 
781c5dff60aSchristos /* TC: General commutative 3-operand integer operation
782c5dff60aSchristos    Syntax: <i> src2, src1, dst
783c5dff60aSchristos            <i> src1, src2, dst
784c5dff60aSchristos        src2 = Register (E), Indirect 0,1,IR0,IR1 (I), C4x T2: Indirect (C), Immediate (W)
785c5dff60aSchristos        src1 = Register (G), Indirect 0,1,IR0,IR1 (J), C4x T2: Indirect (O)
786c5dff60aSchristos        dst  = Register (R)
787c5dff60aSchristos    Instr: 6/2 - ADDC3, ADDI3, AND3, MPYI3, OR3, XOR3, C4x: MPYSHI, MPYUHI
788c5dff60aSchristos    Alias: i, i3
789c5dff60aSchristos */
790c5dff60aSchristos #define TC_CLASS_INSN(name, opcode, level) \
791c5dff60aSchristos   { name, opcode|0x20000000, 0xffe00000, "E,G;R", level  }, \
792c5dff60aSchristos   { name, opcode|0x20200000, 0xffe00000, "E,J,R", level  }, \
793c5dff60aSchristos   { name, opcode|0x20400000, 0xffe00000, "I,G;R", level  }, \
794c5dff60aSchristos   { name, opcode|0x20600000, 0xffe00000, "I,J,R", level  }, \
795c5dff60aSchristos   { name, opcode|0x30000000, 0xffe00000, "W,G;R", OP_C4X }, \
796c5dff60aSchristos   { name, opcode|0x30000000, 0xffe00000, "G,W,R", OP_C4X }, \
797c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "C,G;R", OP_C4X }, \
798c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "G,C,R", OP_C4X }, \
799c5dff60aSchristos   { name, opcode|0x30400000, 0xffe00000, "W,O,R", OP_C4X }, \
800c5dff60aSchristos   { name, opcode|0x30400000, 0xffe00000, "O,W,R", OP_C4X }, \
801c5dff60aSchristos   { name, opcode|0x30600000, 0xffe00000, "C,O,R", OP_C4X }, \
802c5dff60aSchristos   { name "3", opcode|0x20000000, 0xffe00000, "E,G;R", level  }, \
803c5dff60aSchristos   { name "3", opcode|0x20200000, 0xffe00000, "E,J,R", level  }, \
804c5dff60aSchristos   { name "3", opcode|0x20400000, 0xffe00000, "I,G;R", level  }, \
805c5dff60aSchristos   { name "3", opcode|0x20600000, 0xffe00000, "I,J,R", level  }, \
806c5dff60aSchristos   { name "3", opcode|0x30000000, 0xffe00000, "W,G;R", OP_C4X }, \
807c5dff60aSchristos   { name "3", opcode|0x30000000, 0xffe00000, "G,W,R", OP_C4X }, \
808c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "C,G;R", OP_C4X }, \
809c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "G,C,R", OP_C4X }, \
810c5dff60aSchristos   { name "3", opcode|0x30400000, 0xffe00000, "W,O,R", OP_C4X }, \
811c5dff60aSchristos   { name "3", opcode|0x30400000, 0xffe00000, "O,W,R", OP_C4X }, \
812c5dff60aSchristos   { name "3", opcode|0x30600000, 0xffe00000, "C,O,R", OP_C4X }
813c5dff60aSchristos 
814c5dff60aSchristos /* T2: General 3-operand integer operation with 2 args
815c5dff60aSchristos    Syntax: <i> src2, src1
816c5dff60aSchristos        src2 = Register (E), Indirect 0,1,IR0,IR1 (I), C4x T2: Indirect (C), Immediate (W)
817c5dff60aSchristos        src1 = Register (G), Indirect 0,1,IR0,IR1 (J), C4x T2: Indirect (O)
818c5dff60aSchristos    Instr: 1/0 - CMPI3
819c5dff60aSchristos    Alias: i, i3
820c5dff60aSchristos */
821c5dff60aSchristos #define T2_CLASS_INSN(name, opcode, level) \
822c5dff60aSchristos   { name, opcode|0x20000000, 0xffe00000, "E,G", level  }, \
823c5dff60aSchristos   { name, opcode|0x20200000, 0xffe00000, "E,J", level  }, \
824c5dff60aSchristos   { name, opcode|0x20400000, 0xffe00000, "I,G", level  }, \
825c5dff60aSchristos   { name, opcode|0x20600000, 0xffe00000, "I,J", level  }, \
826c5dff60aSchristos   { name, opcode|0x30000000, 0xffe00000, "W,G", OP_C4X }, \
827c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "C,G", OP_C4X }, \
828c5dff60aSchristos   { name, opcode|0x30400000, 0xffe00000, "W,O", OP_C4X }, \
829c5dff60aSchristos   { name, opcode|0x30600000, 0xffe00000, "C,O", OP_C4X }, \
830c5dff60aSchristos   { name "3", opcode|0x20000000, 0xffe00000, "E,G", level  }, \
831c5dff60aSchristos   { name "3", opcode|0x20200000, 0xffe00000, "E,J", level  }, \
832c5dff60aSchristos   { name "3", opcode|0x20400000, 0xffe00000, "I,G", level  }, \
833c5dff60aSchristos   { name "3", opcode|0x20600000, 0xffe00000, "I,J", level  }, \
834c5dff60aSchristos   { name "3", opcode|0x30000000, 0xffe00000, "W,G", OP_C4X }, \
835c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "C,G", OP_C4X }, \
836c5dff60aSchristos   { name "3", opcode|0x30400000, 0xffe00000, "W,O", OP_C4X }, \
837c5dff60aSchristos   { name "3", opcode|0x30600000, 0xffe00000, "C,O", OP_C4X }
838c5dff60aSchristos 
839c5dff60aSchristos /* T2C: General commutative 3-operand integer operation with 2 args
840c5dff60aSchristos    Syntax: <i> src2, src1 - Manual
841c5dff60aSchristos            <i> src1, src2
842c5dff60aSchristos        src2 = Register (E), Indirect 0,1,IR0,IR1 (I), C4x T2: Indirect (C), Immediate (W)
843c5dff60aSchristos        src1 = Register (G), Indirect 0,1,IR0,IR1 (J), C4x T2: Indirect (0)
844c5dff60aSchristos    Instr: 1/0 - TSTB3
845c5dff60aSchristos    Alias: i, i3
846c5dff60aSchristos */
847c5dff60aSchristos #define T2C_CLASS_INSN(name, opcode, level) \
848c5dff60aSchristos   { name, opcode|0x20000000, 0xffe00000, "E,G", level  }, \
849c5dff60aSchristos   { name, opcode|0x20200000, 0xffe00000, "E,J", level  }, \
850c5dff60aSchristos   { name, opcode|0x20400000, 0xffe00000, "I,G", level  }, \
851c5dff60aSchristos   { name, opcode|0x20600000, 0xffe00000, "I,J", level  }, \
852c5dff60aSchristos   { name, opcode|0x30000000, 0xffe00000, "W,G", OP_C4X }, \
853c5dff60aSchristos   { name, opcode|0x30000000, 0xffe00000, "G,W", OP_C4X }, \
854c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "C,G", OP_C4X }, \
855c5dff60aSchristos   { name, opcode|0x30200000, 0xffe00000, "G,C", OP_C4X }, \
856c5dff60aSchristos   { name, opcode|0x30400000, 0xffe00000, "W,O", OP_C4X }, \
857c5dff60aSchristos   { name, opcode|0x30400000, 0xffe00000, "O,W", OP_C4X }, \
858c5dff60aSchristos   { name, opcode|0x30600000, 0xffe00000, "C,O", OP_C4X }, \
859c5dff60aSchristos   { name "3", opcode|0x20000000, 0xffe00000, "E,G", level  }, \
860c5dff60aSchristos   { name "3", opcode|0x20200000, 0xffe00000, "E,J", level  }, \
861c5dff60aSchristos   { name "3", opcode|0x20400000, 0xffe00000, "I,G", level  }, \
862c5dff60aSchristos   { name "3", opcode|0x20600000, 0xffe00000, "I,J", level  }, \
863c5dff60aSchristos   { name "3", opcode|0x30000000, 0xffe00000, "W,G", OP_C4X }, \
864c5dff60aSchristos   { name "3", opcode|0x30000000, 0xffe00000, "G,W", OP_C4X }, \
865c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "C,G", OP_C4X }, \
866c5dff60aSchristos   { name "3", opcode|0x30200000, 0xffe00000, "G,C", OP_C4X }, \
867c5dff60aSchristos   { name "3", opcode|0x30400000, 0xffe00000, "W,O", OP_C4X }, \
868c5dff60aSchristos   { name "3", opcode|0x30400000, 0xffe00000, "O,W", OP_C4X }, \
869c5dff60aSchristos   { name "3", opcode|0x30600000, 0xffe00000, "C,O", OP_C4X }
870c5dff60aSchristos 
871c5dff60aSchristos /* Z: Misc operations with or without arguments
872c5dff60aSchristos    Syntax: <i> <arg1>,...
873c5dff60aSchristos    Instr: 16 - RETIc, RETSc, SIGI(c3X), SWI, IDLE, IDLE2, RETIcD,
874c5dff60aSchristos                TRAPc, LATc, LDEP, LDEHI, LDEPE, LDPK, STIK, LDP, IACK
875c5dff60aSchristos */
876c5dff60aSchristos 
877c5dff60aSchristos 
878c5dff60aSchristos /* Define tic4x opcodes for assembler and disassembler.  */
879c5dff60aSchristos static const tic4x_inst_t tic4x_insts[] =
880c5dff60aSchristos {
881c5dff60aSchristos   /* Put synonyms after the desired forms in table so that they get
882c5dff60aSchristos      overwritten in the lookup table.  The disassembler will thus
883c5dff60aSchristos      print the `proper' mnemonics.  Note that the disassembler
884c5dff60aSchristos      only decodes the 11 MSBs, so instructions like ldp @0x500 will
885c5dff60aSchristos      be printed as ldiu 5, dp.  Note that with parallel instructions,
886c5dff60aSchristos      the second part is executed before the first part, unless
887c5dff60aSchristos      the sti1||sti2 form is used.  We also allow sti2||sti1
888c5dff60aSchristos      which is equivalent to the default sti||sti form.
889c5dff60aSchristos   */
890c5dff60aSchristos   B_CLASS_INSN(  "absf",          0x00000000, OP_C3X   ),
891c5dff60aSchristos   P_CLASS_INSN(  "absf",  "stf",  0xc8000000, OP_C3X   ),
892c5dff60aSchristos   A_CLASS_INSN(  "absi",          0x00800000, OP_C3X   ),
893c5dff60aSchristos   P_CLASS_INSN(  "absi",  "sti",  0xca000000, OP_C3X   ),
894c5dff60aSchristos   A_CLASS_INSN(  "addc",          0x01000000, OP_C3X   ),
895c5dff60aSchristos   TC_CLASS_INSN( "addc",          0x00000000, OP_C3X   ),
896c5dff60aSchristos   B_CLASS_INSN(  "addf",          0x01800000, OP_C3X   ),
897c5dff60aSchristos   SC_CLASS_INSN( "addf",          0x00800000, OP_C3X   ),
898c5dff60aSchristos   QC_CLASS_INSN( "addf",  "stf",  0xcc000000, OP_C3X   ),
899c5dff60aSchristos   A_CLASS_INSN(  "addi",          0x02000000, OP_C3X   ),
900c5dff60aSchristos   TC_CLASS_INSN( "addi",          0x01000000, OP_C3X   ),
901c5dff60aSchristos   QC_CLASS_INSN( "addi",  "sti",  0xce000000, OP_C3X   ),
902c5dff60aSchristos   AU_CLASS_INSN( "and",           0x02800000, OP_C3X   ),
903c5dff60aSchristos   TC_CLASS_INSN( "and",           0x01800000, OP_C3X   ),
904c5dff60aSchristos   QC_CLASS_INSN( "and",   "sti",  0xd0000000, OP_C3X   ),
905c5dff60aSchristos   AU_CLASS_INSN( "andn",          0x03000000, OP_C3X   ),
906c5dff60aSchristos   T_CLASS_INSN(  "andn",          0x02000000, OP_C3X   ),
907c5dff60aSchristos   A_CLASS_INSN(  "ash",           0x03800000, OP_C3X   ),
908c5dff60aSchristos   T_CLASS_INSN(  "ash",           0x02800000, OP_C3X   ),
909c5dff60aSchristos   Q_CLASS_INSN(  "ash",   "sti",  0xd2000000, OP_C3X   ),
910c5dff60aSchristos   J_CLASS_INSN(  "bB",    "b",    0x68000000, OP_C3X   ),
911c5dff60aSchristos   J_CLASS_INSN(  "bBd",   "bd",   0x68200000, OP_C3X   ),
912c5dff60aSchristos   J_CLASS_INSN(  "bBaf",  "baf",  0x68a00000, OP_C4X   ),
913c5dff60aSchristos   J_CLASS_INSN(  "bBat",  "bat",  0x68600000, OP_C4X   ),
914c5dff60aSchristos   { "br",     0x60000000, 0xff000000, "B"   , OP_C3X   },  /* I_CLASS */
915c5dff60aSchristos   { "brd",    0x61000000, 0xff000000, "B"   , OP_C3X   },  /* I_CLASS */
916c5dff60aSchristos   { "call",   0x62000000, 0xff000000, "B"   , OP_C3X   },  /* I_CLASS */
917c5dff60aSchristos   { "callB",  0x70000000, 0xffe00000, "Q"   , OP_C3X   },  /* JS_CLASS */
918c5dff60aSchristos   { "callB",  0x72000000, 0xffe00000, "P"   , OP_C3X   },  /* JS_CLASS */
919c5dff60aSchristos   B_CLASS_INSN(  "cmpf",          0x04000000, OP_C3X   ),
920c5dff60aSchristos   S2_CLASS_INSN( "cmpf",          0x03000000, OP_C3X   ),
921c5dff60aSchristos   A_CLASS_INSN(  "cmpi",          0x04800000, OP_C3X   ),
922c5dff60aSchristos   T2_CLASS_INSN( "cmpi",          0x03800000, OP_C3X   ),
923c5dff60aSchristos   D_CLASS_INSN(  "dbB",   "db",   0x6c000000, OP_C3X   ),
924c5dff60aSchristos   D_CLASS_INSN(  "dbBd",  "dbd",  0x6c200000, OP_C3X   ),
925c5dff60aSchristos   AF_CLASS_INSN( "fix",           0x05000000, OP_C3X   ),
926c5dff60aSchristos   P_CLASS_INSN(  "fix",   "sti",  0xd4000000, OP_C3X   ),
927c5dff60aSchristos   BI_CLASS_INSN( "float",         0x05800000, OP_C3X   ),
928c5dff60aSchristos   P_CLASS_INSN(  "float", "stf",  0xd6000000, OP_C3X   ),
929c5dff60aSchristos   B6_CLASS_INSN( "frieee",        0x1c000000, OP_C4X   ),
930c5dff60aSchristos   P_CLASS_INSN(  "frieee","stf",  0xf2000000, OP_C4X   ),
931c5dff60aSchristos   { "iack",   0x1b200000, 0xffe00000, "@"   , OP_C3X   },  /* Z_CLASS */
932c5dff60aSchristos   { "iack",   0x1b400000, 0xffe00000, "*"   , OP_C3X   },  /* Z_CLASS */
933c5dff60aSchristos   { "idle",   0x06000000, 0xffffffff, ""    , OP_C3X   },  /* Z_CLASS */
934c5dff60aSchristos   { "idlez",  0x06000000, 0xffffffff, ""    , OP_C3X   },  /* Z_CLASS */
935c5dff60aSchristos   { "idle2",  0x06000001, 0xffffffff, ""    , OP_IDLE2 },  /* Z_CLASS */
936c5dff60aSchristos   { "laj",    0x63000000, 0xff000000, "B"   , OP_C4X   },  /* I_CLASS */
937c5dff60aSchristos   { "lajB",   0x70200000, 0xffe00000, "Q"   , OP_C4X   },  /* JS_CLASS */
938c5dff60aSchristos   { "lajB",   0x72200000, 0xffe00000, "P"   , OP_C4X   },  /* JS_CLASS */
939c5dff60aSchristos   { "latB",   0x74800000, 0xffe00000, "V"   , OP_C4X   },  /* Z_CLASS */
940c5dff60aSchristos   A_CLASS_INSN(  "lb0",           0xb0000000, OP_C4X   ),
941c5dff60aSchristos   A_CLASS_INSN(  "lb1",           0xb0800000, OP_C4X   ),
942c5dff60aSchristos   A_CLASS_INSN(  "lb2",           0xb1000000, OP_C4X   ),
943c5dff60aSchristos   A_CLASS_INSN(  "lb3",           0xb1800000, OP_C4X   ),
944c5dff60aSchristos   AU_CLASS_INSN( "lbu0",          0xb2000000, OP_C4X   ),
945c5dff60aSchristos   AU_CLASS_INSN( "lbu1",          0xb2800000, OP_C4X   ),
946c5dff60aSchristos   AU_CLASS_INSN( "lbu2",          0xb3000000, OP_C4X   ),
947c5dff60aSchristos   AU_CLASS_INSN( "lbu3",          0xb3800000, OP_C4X   ),
948c5dff60aSchristos   AY_CLASS_INSN( "lda",           0x1e800000, OP_C4X   ),
949c5dff60aSchristos   B_CLASS_INSN(  "lde",           0x06800000, OP_C3X   ),
950c5dff60aSchristos   { "ldep",   0x76000000, 0xffe00000, "X,R" , OP_C4X   },  /* Z_CLASS */
951c5dff60aSchristos   B_CLASS_INSN(  "ldf",           0x07000000, OP_C3X   ),
952c5dff60aSchristos   LL_CLASS_INSN( "ldf",           0xc4000000, OP_C3X   ),
953c5dff60aSchristos   P_CLASS_INSN(  "ldf",   "stf",  0xd8000000, OP_C3X   ),
954c5dff60aSchristos   BB_CLASS_INSN( "ldfC",          0x00000000, OP_C3X   ),
955c5dff60aSchristos   B6_CLASS_INSN( "ldfi",          0x07800000, OP_C3X   ),
956c5dff60aSchristos   { "ldhi",   0x1fe00000, 0xffe00000, "U,R" , OP_C4X   },  /* Z_CLASS */
957c5dff60aSchristos   { "ldhi",   0x1fe00000, 0xffe00000, "#,R" , OP_C4X   },  /* Z_CLASS */
958c5dff60aSchristos   A_CLASS_INSN(  "ldi",           0x08000000, OP_C3X   ),
959c5dff60aSchristos   LL_CLASS_INSN( "ldi",           0xc6000000, OP_C3X   ),
960c5dff60aSchristos   P_CLASS_INSN(  "ldi",   "sti",  0xda000000, OP_C3X   ),
961c5dff60aSchristos   AB_CLASS_INSN( "ldiC",          0x10000000, OP_C3X   ),
962c5dff60aSchristos   A6_CLASS_INSN( "ldii",          0x08800000, OP_C3X   ),
963c5dff60aSchristos   { "ldp",    0x50700000, 0xffff0000, "#"   , OP_C3X   },  /* Z_CLASS - synonym for ldiu #,dp */
964c5dff60aSchristos   B_CLASS_INSN(  "ldm",           0x09000000, OP_C3X   ),
965c5dff60aSchristos   { "ldpe",   0x76800000, 0xffe00000, "Q,Z" , OP_C4X   },  /* Z_CLASS */
966c5dff60aSchristos   { "ldpk",   0x1F700000, 0xffff0000, "#"   , OP_C4X   },  /* Z_CLASS */
967c5dff60aSchristos   A_CLASS_INSN(  "lh0",           0xba000000, OP_C4X   ),
968c5dff60aSchristos   A_CLASS_INSN(  "lh1",           0xba800000, OP_C4X   ),
969c5dff60aSchristos   AU_CLASS_INSN( "lhu0",          0xbb000000, OP_C4X   ),
970c5dff60aSchristos   AU_CLASS_INSN( "lhu1",          0xbb800000, OP_C4X   ),
971c5dff60aSchristos   { "lopower", 0x10800001,0xffffffff, ""    , OP_LPWR  },  /* Z_CLASS */
972c5dff60aSchristos   A_CLASS_INSN(  "lsh",           0x09800000, OP_C3X   ),
973c5dff60aSchristos   T_CLASS_INSN(  "lsh",           0x04000000, OP_C3X   ),
974c5dff60aSchristos   Q_CLASS_INSN(  "lsh",   "sti",  0xdc000000, OP_C3X   ),
975c5dff60aSchristos   A_CLASS_INSN(  "lwl0",          0xb4000000, OP_C4X   ),
976c5dff60aSchristos   A_CLASS_INSN(  "lwl1",          0xb4800000, OP_C4X   ),
977c5dff60aSchristos   A_CLASS_INSN(  "lwl2",          0xb5000000, OP_C4X   ),
978c5dff60aSchristos   A_CLASS_INSN(  "lwl3",          0xb5800000, OP_C4X   ),
979c5dff60aSchristos   A_CLASS_INSN(  "lwr0",          0xb6000000, OP_C4X   ),
980c5dff60aSchristos   A_CLASS_INSN(  "lwr1",          0xb6800000, OP_C4X   ),
981c5dff60aSchristos   A_CLASS_INSN(  "lwr2",          0xb7000000, OP_C4X   ),
982c5dff60aSchristos   A_CLASS_INSN(  "lwr3",          0xb7800000, OP_C4X   ),
983c5dff60aSchristos   { "maxspeed",0x10800000,0xffffffff, ""    , OP_LPWR  },  /* Z_CLASS */
984c5dff60aSchristos   A_CLASS_INSN(  "mb0",           0xb8000000, OP_C4X   ),
985c5dff60aSchristos   A_CLASS_INSN(  "mb1",           0xb8800000, OP_C4X   ),
986c5dff60aSchristos   A_CLASS_INSN(  "mb2",           0xb9000000, OP_C4X   ),
987c5dff60aSchristos   A_CLASS_INSN(  "mb3",           0xb9800000, OP_C4X   ),
988c5dff60aSchristos   A_CLASS_INSN(  "mh0",           0xbc000000, OP_C4X   ),
989c5dff60aSchristos   A_CLASS_INSN(  "mh1",           0xbc800000, OP_C4X   ),
990c5dff60aSchristos   A_CLASS_INSN(  "mh2",           0xbd000000, OP_C4X   ),
991c5dff60aSchristos   A_CLASS_INSN(  "mh3",           0xbd800000, OP_C4X   ),
992c5dff60aSchristos   B_CLASS_INSN(  "mpyf",          0x0a000000, OP_C3X   ),
993c5dff60aSchristos   SC_CLASS_INSN( "mpyf",          0x04800000, OP_C3X   ),
994c5dff60aSchristos   M_CLASS_INSN(  "mpyf",  "addf", 0x80000000, OP_C3X   ),
995c5dff60aSchristos   QC_CLASS_INSN( "mpyf",  "stf",  0xde000000, OP_C3X   ),
996c5dff60aSchristos   M_CLASS_INSN(  "mpyf",  "subf", 0x84000000, OP_C3X   ),
997c5dff60aSchristos   A_CLASS_INSN(  "mpyi",          0x0a800000, OP_C3X   ),
998c5dff60aSchristos   TC_CLASS_INSN( "mpyi",          0x05000000, OP_C3X   ),
999c5dff60aSchristos   M_CLASS_INSN(  "mpyi",  "addi", 0x88000000, OP_C3X   ),
1000c5dff60aSchristos   QC_CLASS_INSN( "mpyi",  "sti",  0xe0000000, OP_C3X   ),
1001c5dff60aSchristos   M_CLASS_INSN(  "mpyi",  "subi", 0x8c000000, OP_C3X   ),
1002c5dff60aSchristos   A_CLASS_INSN(  "mpyshi",        0x1d800000, OP_C4X   ),
1003c5dff60aSchristos   TC_CLASS_INSN( "mpyshi",        0x28800000, OP_C4X   ),
1004c5dff60aSchristos   A_CLASS_INSN(  "mpyuhi",        0x1e000000, OP_C4X   ),
1005c5dff60aSchristos   TC_CLASS_INSN( "mpyuhi",        0x29000000, OP_C4X   ),
1006c5dff60aSchristos   A_CLASS_INSN(  "negb",          0x0b000000, OP_C3X   ),
1007c5dff60aSchristos   B_CLASS_INSN(  "negf",          0x0b800000, OP_C3X   ),
1008c5dff60aSchristos   P_CLASS_INSN(  "negf",  "stf",  0xe2000000, OP_C3X   ),
1009c5dff60aSchristos   A_CLASS_INSN(  "negi",          0x0c000000, OP_C3X   ),
1010c5dff60aSchristos   P_CLASS_INSN(  "negi",  "sti",  0xe4000000, OP_C3X   ),
1011c5dff60aSchristos   A2_CLASS_INSN( "nop",           0x0c800000, OP_C3X   ),
1012c5dff60aSchristos   B_CLASS_INSN(  "norm",          0x0d000000, OP_C3X   ),
1013c5dff60aSchristos   AU_CLASS_INSN( "not",           0x0d800000, OP_C3X   ),
1014c5dff60aSchristos   P_CLASS_INSN(  "not",   "sti",  0xe6000000, OP_C3X   ),
1015c5dff60aSchristos   AU_CLASS_INSN( "or",            0x10000000, OP_C3X   ),
1016c5dff60aSchristos   TC_CLASS_INSN( "or",            0x05800000, OP_C3X   ),
1017c5dff60aSchristos   QC_CLASS_INSN( "or",    "sti",  0xe8000000, OP_C3X   ),
1018c5dff60aSchristos   R_CLASS_INSN(  "pop",           0x0e200000, OP_C3X   ),
1019c5dff60aSchristos   RF_CLASS_INSN( "popf",          0x0ea00000, OP_C3X   ),
1020c5dff60aSchristos   R_CLASS_INSN(  "push",          0x0f200000, OP_C3X   ),
1021c5dff60aSchristos   RF_CLASS_INSN( "pushf",         0x0fa00000, OP_C3X   ),
1022c5dff60aSchristos   BA_CLASS_INSN( "rcpf",          0x1d000000, OP_C4X   ),
1023c5dff60aSchristos   { "retiB",  0x78000000, 0xffe00000, ""    , OP_C3X   },  /* Z_CLASS */
1024c5dff60aSchristos   { "reti",   0x78000000, 0xffe00000, ""    , OP_C3X   },  /* Z_CLASS  - Alias for retiu */
1025c5dff60aSchristos   { "retiBd", 0x78200000, 0xffe00000, ""    , OP_C4X   },  /* Z_CLASS */
1026c5dff60aSchristos   { "retid",  0x78200000, 0xffe00000, ""    , OP_C4X   },  /* Z_CLASS - Alias for retiud */
1027c5dff60aSchristos   { "retsB",  0x78800000, 0xffe00000, ""    , OP_C3X   },  /* Z_CLASS */
1028c5dff60aSchristos   { "rets",   0x78800000, 0xffe00000, ""    , OP_C3X   },  /* Z_CLASS  - Alias for retsu */
1029c5dff60aSchristos   B_CLASS_INSN(  "rnd",           0x11000000, OP_C3X   ),
1030c5dff60aSchristos   R_CLASS_INSN(  "rol",           0x11e00001, OP_C3X   ),
1031c5dff60aSchristos   R_CLASS_INSN(  "rolc",          0x12600001, OP_C3X   ),
1032c5dff60aSchristos   R_CLASS_INSN(  "ror",           0x12e0ffff, OP_C3X   ),
1033c5dff60aSchristos   R_CLASS_INSN(  "rorc",          0x1360ffff, OP_C3X   ),
1034c5dff60aSchristos   { "rptb",   0x64000000, 0xff000000, "B"   , OP_C3X   },  /* I2_CLASS */
1035c5dff60aSchristos   { "rptb",   0x79000000, 0xff000000, "Q"   , OP_C4X   },  /* I2_CLASS */
1036c5dff60aSchristos   { "rptbd",  0x65000000, 0xff000000, "B"   , OP_C4X   },  /* I2_CLASS */
1037c5dff60aSchristos   { "rptbd",  0x79800000, 0xff000000, "Q"   , OP_C4X   },  /* I2_CLASS */
1038c5dff60aSchristos   A3_CLASS_INSN( "rpts",          0x139b0000, OP_C3X   ),
1039c5dff60aSchristos   B_CLASS_INSN(  "rsqrf",         0x1c800000, OP_C4X   ),
1040c5dff60aSchristos   { "sigi",   0x16000000, 0xffe00000, ""    , OP_C3X   },  /* Z_CLASS */
1041c5dff60aSchristos   A6_CLASS_INSN( "sigi",          0x16000000, OP_C4X   ),
1042c5dff60aSchristos   B7_CLASS_INSN( "stf",           0x14000000, OP_C3X   ),
1043c5dff60aSchristos   LS_CLASS_INSN( "stf",           0xc0000000, OP_C3X   ),
1044c5dff60aSchristos   B7_CLASS_INSN( "stfi",          0x14800000, OP_C3X   ),
1045c5dff60aSchristos   A7_CLASS_INSN( "sti",           0x15000000, OP_C3X   ),
1046c5dff60aSchristos   { "sti",    0x15000000, 0xffe00000, "T,@" , OP_C4X   },  /* Class A7 - Alias for stik */
1047c5dff60aSchristos   { "sti",    0x15600000, 0xffe00000, "T,*" , OP_C4X   },  /* Class A7 */
1048c5dff60aSchristos   LS_CLASS_INSN( "sti",           0xc2000000, OP_C3X   ),
1049c5dff60aSchristos   A7_CLASS_INSN( "stii",          0x15800000, OP_C3X   ),
1050c5dff60aSchristos   { "stik",   0x15000000, 0xffe00000, "T,@" , OP_C4X   },  /* Z_CLASS */
1051c5dff60aSchristos   { "stik",   0x15600000, 0xffe00000, "T,*" , OP_C4X   },  /* Z_CLASS */
1052c5dff60aSchristos   A_CLASS_INSN(  "subb",          0x16800000, OP_C3X   ),
1053c5dff60aSchristos   T_CLASS_INSN(  "subb",          0x06000000, OP_C3X   ),
1054c5dff60aSchristos   A_CLASS_INSN(  "subc",          0x17000000, OP_C3X   ),
1055c5dff60aSchristos   B_CLASS_INSN(  "subf",          0x17800000, OP_C3X   ),
1056c5dff60aSchristos   S_CLASS_INSN(  "subf",          0x06800000, OP_C3X   ),
1057c5dff60aSchristos   Q_CLASS_INSN(  "subf",  "stf",  0xea000000, OP_C3X   ),
1058c5dff60aSchristos   A_CLASS_INSN(  "subi",          0x18000000, OP_C3X   ),
1059c5dff60aSchristos   T_CLASS_INSN(  "subi",          0x07000000, OP_C3X   ),
1060c5dff60aSchristos   Q_CLASS_INSN(  "subi",  "sti",  0xec000000, OP_C3X   ),
1061c5dff60aSchristos   A_CLASS_INSN(  "subrb",         0x18800000, OP_C3X   ),
1062c5dff60aSchristos   B_CLASS_INSN(  "subrf",         0x19000000, OP_C3X   ),
1063c5dff60aSchristos   A_CLASS_INSN(  "subri",         0x19800000, OP_C3X   ),
1064c5dff60aSchristos   { "swi",    0x66000000, 0xffffffff, ""    , OP_C3X   },  /* Z_CLASS */
1065c5dff60aSchristos   B_CLASS_INSN(  "toieee",        0x1b800000, OP_C4X   ),
1066c5dff60aSchristos   P_CLASS_INSN(  "toieee","stf",  0xf0000000, OP_C4X   ),
1067c5dff60aSchristos   { "trapB",  0x74000000, 0xffe00000, "V"   , OP_C3X   },  /* Z_CLASS */
1068c5dff60aSchristos   { "trap",   0x74000000, 0xffe00000, "V"   , OP_C3X   },  /* Z_CLASS - Alias for trapu */
1069c5dff60aSchristos   AU_CLASS_INSN( "tstb",          0x1a000000, OP_C3X   ),
1070c5dff60aSchristos   T2C_CLASS_INSN("tstb",          0x07800000, OP_C3X   ),
1071c5dff60aSchristos   AU_CLASS_INSN( "xor",           0x1a800000, OP_C3X   ),
1072c5dff60aSchristos   TC_CLASS_INSN( "xor",           0x08000000, OP_C3X   ),
1073c5dff60aSchristos   QC_CLASS_INSN( "xor",   "sti",  0xee000000, OP_C3X   ),
1074c5dff60aSchristos 
1075c5dff60aSchristos   /* Dummy entry, not included in tic4x_num_insts.  This
1076c5dff60aSchristos      lets code examine entry i + 1 without checking
1077c5dff60aSchristos      if we've run off the end of the table.  */
1078c5dff60aSchristos   { "",      0x0, 0x00, "", 0 }
1079c5dff60aSchristos };
1080c5dff60aSchristos 
1081c5dff60aSchristos const unsigned int tic4x_num_insts = (((sizeof tic4x_insts) / (sizeof tic4x_insts[0])) - 1);
1082