xref: /netbsd-src/external/gpl3/gdb.old/dist/include/opcode/tic54x.h (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1a5a4af3bSchristos /* tic54x.h -- Header file for TI TMS320C54X opcode table
2*8b657b07Schristos    Copyright (C) 1999-2022 Free Software Foundation, Inc.
3a5a4af3bSchristos    Written by Timothy Wall (twall@cygnus.com)
4a5a4af3bSchristos 
5a5a4af3bSchristos    This file is part of GDB, GAS, and the GNU binutils.
6a5a4af3bSchristos 
7a5a4af3bSchristos    GDB, GAS, and the GNU binutils are free software; you can redistribute
8a5a4af3bSchristos    them and/or modify them under the terms of the GNU General Public
9a5a4af3bSchristos    License as published by the Free Software Foundation; either version 3,
10a5a4af3bSchristos    or (at your option) any later version.
11a5a4af3bSchristos 
12a5a4af3bSchristos    GDB, GAS, and the GNU binutils are distributed in the hope that they
13a5a4af3bSchristos    will be useful, but WITHOUT ANY WARRANTY; without even the implied
14a5a4af3bSchristos    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
15a5a4af3bSchristos    the GNU General Public License for more details.
16a5a4af3bSchristos 
17a5a4af3bSchristos    You should have received a copy of the GNU General Public License
18a5a4af3bSchristos    along with this file; see the file COPYING3.  If not, write to the Free
19a5a4af3bSchristos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20a5a4af3bSchristos    02110-1301, USA.  */
21a5a4af3bSchristos 
22a5a4af3bSchristos #ifndef _opcode_tic54x_h_
23a5a4af3bSchristos #define _opcode_tic54x_h_
24a5a4af3bSchristos 
25a5a4af3bSchristos typedef struct _symbol
26a5a4af3bSchristos {
27a5a4af3bSchristos   const char *name;
28a5a4af3bSchristos   unsigned short value;
29e5cb852cSchristos } tic54x_symbol;
30a5a4af3bSchristos 
31a5a4af3bSchristos enum optype {
32a5a4af3bSchristos   OPT = 0x8000,
33a5a4af3bSchristos   OP_None = 0x0,
34a5a4af3bSchristos 
35a5a4af3bSchristos   OP_Xmem, /* AR3 or AR4, indirect */
36a5a4af3bSchristos   OP_Ymem, /* AR3 or AR4, indirect */
37a5a4af3bSchristos   OP_pmad, /* PROG mem, direct */
38a5a4af3bSchristos   OP_dmad, /* DATA mem, direct */
39a5a4af3bSchristos   OP_Smem,
40a5a4af3bSchristos   OP_Lmem, /* 32-bit single-addressed (direct/indirect) */
41a5a4af3bSchristos   OP_MMR,
42a5a4af3bSchristos   OP_PA,
43a5a4af3bSchristos   OP_Sind,
44a5a4af3bSchristos   OP_xpmad,
45a5a4af3bSchristos   OP_xpmad_ms7,
46a5a4af3bSchristos   OP_MMRX,
47a5a4af3bSchristos   OP_MMRY,
48a5a4af3bSchristos 
49a5a4af3bSchristos   OP_SRC1, /* src accumulator in bit 8 */
50a5a4af3bSchristos   OP_SRC, /* src accumulator in bit 9 */
51a5a4af3bSchristos   OP_RND, /* rounded result dst accumulator, opposite of bit 8 */
52a5a4af3bSchristos   OP_DST, /* dst accumulator in bit 8 */
53a5a4af3bSchristos   OP_ARX, /* arX in bits 0-3 */
54a5a4af3bSchristos   OP_SHIFT, /* -16 to 15 (SHIFT), bits 0-4 */
55a5a4af3bSchristos   OP_SHFT, /*   0 to 15 (SHIFT1 in summary), bits 0-3 */
56a5a4af3bSchristos   OP_B, /* ACC B only */
57a5a4af3bSchristos   OP_A, /* ACC A only */
58a5a4af3bSchristos 
59a5a4af3bSchristos   OP_lk, /* 16-bit immediate, '#' optional */
60a5a4af3bSchristos   OP_TS,
61a5a4af3bSchristos   OP_k8, /* -128 <= k <= 128 */
62a5a4af3bSchristos   OP_16, /* literal "16" */
63a5a4af3bSchristos   OP_BITC, /* 0 to 16 */
64a5a4af3bSchristos   OP_CC, /* condition code */
65a5a4af3bSchristos   OP_CC2, /* 4-bit condition code */
66a5a4af3bSchristos   OP_CC3, /* 2-bit condition code */
67a5a4af3bSchristos   OP_123, /* 1, 2, or 3 */
68a5a4af3bSchristos   OP_031, /* 0-31, numeric */
69a5a4af3bSchristos   OP_k5, /* 0 to 31 */
70a5a4af3bSchristos   OP_k8u, /* 0 to 255 */
71a5a4af3bSchristos   OP_ASM, /* "ASM" */
72a5a4af3bSchristos   OP_T, /* "T" */
73a5a4af3bSchristos   OP_DP, /* "DP" */
74a5a4af3bSchristos   OP_ARP, /* "ARP" */
75a5a4af3bSchristos   OP_k3, /* 0-7 */
76a5a4af3bSchristos   OP_lku, /* 0 to 65535 */
77a5a4af3bSchristos   OP_N, /* 0/1 or ST0/ST1 */
78a5a4af3bSchristos   OP_SBIT, /* status bit or 0-15 */
79a5a4af3bSchristos   OP_12, /* one or two */
80a5a4af3bSchristos   OP_k9, /* 9 bits of data page (DP) address */
81a5a4af3bSchristos   OP_TRN, /* "TRN" */
82a5a4af3bSchristos 
83a5a4af3bSchristos };
84a5a4af3bSchristos 
85a5a4af3bSchristos typedef struct _template
86a5a4af3bSchristos {
87a5a4af3bSchristos   /* The opcode mnemonic */
88a5a4af3bSchristos   const char *name;
89a5a4af3bSchristos   unsigned int words; /* insn size in words */
90a5a4af3bSchristos   int minops, maxops; /* min/max operand count */
91a5a4af3bSchristos   /* The significant bits in the opcode.  Other bits are zero.
92a5a4af3bSchristos      Instructions with more than 16 bits of opcode store the rest in the upper
93a5a4af3bSchristos      16 bits.
94a5a4af3bSchristos    */
95a5a4af3bSchristos   unsigned short opcode;
96a5a4af3bSchristos #define INDIRECT(OP)    ((OP)&0x80)
97a5a4af3bSchristos #define MOD(OP)         (((OP)>>3)&0xF)
98a5a4af3bSchristos #define ARF(OP)         ((OP)&0x7)
99a5a4af3bSchristos #define IS_LKADDR(OP)   (INDIRECT(OP) && MOD(OP)>=12)
100a5a4af3bSchristos #define SRC(OP)         ((OP)&0x200)
101a5a4af3bSchristos #define DST(OP)         ((OP)&0x100)
102a5a4af3bSchristos #define SRC1(OP)        ((OP)&0x100)
103a5a4af3bSchristos #define SHIFT(OP)       (((OP)&0x10)?(((OP)&0x1F)-32):((OP)&0x1F))
104a5a4af3bSchristos #define SHFT(OP)        ((OP)&0xF)
105a5a4af3bSchristos #define ARX(OP)         ((OP)&0x7)
106a5a4af3bSchristos #define XMEM(OP)        (((OP)&0x00F0)>>4)
107a5a4af3bSchristos #define YMEM(OP)        ((OP)&0x000F)
108a5a4af3bSchristos #define XMOD(C)        (((C)&0xC)>>2)
109a5a4af3bSchristos #define XARX(C)        (((C)&0x3)+2)
110a5a4af3bSchristos #define CC3(OP)         (((OP)>>8)&0x3)
111a5a4af3bSchristos #define SBIT(OP)        ((OP)&0xF)
112a5a4af3bSchristos #define MMR(OP)         ((OP)&0x7F)
113a5a4af3bSchristos #define MMRX(OP)        ((((OP)>>4)&0xF)+16)
114a5a4af3bSchristos #define MMRY(OP)        (((OP)&0xF)+16)
115a5a4af3bSchristos 
116a5a4af3bSchristos #define OPTYPE(X)       ((X)&~OPT)
117a5a4af3bSchristos 
118a5a4af3bSchristos   /* Ones in this mask indicate which bits must match the opcode field.
119a5a4af3bSchristos      Zeroes indicate don't care bits (operands and/or opcode options) */
120a5a4af3bSchristos   unsigned short mask;
121a5a4af3bSchristos 
122a5a4af3bSchristos   /* An array of operand codes (at most 4 operands) */
123a5a4af3bSchristos #define MAX_OPERANDS 4
124a5a4af3bSchristos   enum optype operand_types[MAX_OPERANDS];
125a5a4af3bSchristos 
126a5a4af3bSchristos   /* Special purpose flags (e.g. branch type, parallel, delay, etc)
127a5a4af3bSchristos    */
128a5a4af3bSchristos   unsigned short flags;
129a5a4af3bSchristos #define B_NEXT      0 /* normal execution, next insn is next address */
130a5a4af3bSchristos #define B_BRANCH    1 /* next insn is in opcode */
131a5a4af3bSchristos #define B_RET       2 /* next insn is on stack */
132a5a4af3bSchristos #define B_BACC      3 /* next insn is in acc */
133a5a4af3bSchristos #define B_REPEAT    4 /* next insn repeats */
134a5a4af3bSchristos #define FL_BMASK    0x07
135a5a4af3bSchristos 
136a5a4af3bSchristos #define FL_DELAY    0x10 /* instruction uses delay slots */
137a5a4af3bSchristos #define FL_EXT      0x20 /* instruction takes two words */
138a5a4af3bSchristos #define FL_FAR      0x40 /* far mode addressing */
139a5a4af3bSchristos #define FL_LP       0x80 /* LP-only instruction */
140a5a4af3bSchristos #define FL_NR       0x100 /* no repeat allowed */
141a5a4af3bSchristos #define FL_SMR      0x200 /* Smem read (for flagging write-only *+ARx */
142a5a4af3bSchristos 
143a5a4af3bSchristos #define FL_PAR      0x400 /* Parallel instruction. */
144a5a4af3bSchristos 
145a5a4af3bSchristos   unsigned short opcode2, mask2;   /* some insns have an extended opcode */
146a5a4af3bSchristos 
147a5a4af3bSchristos   const char* parname;
148a5a4af3bSchristos   enum optype paroperand_types[MAX_OPERANDS];
149a5a4af3bSchristos 
150a5a4af3bSchristos } insn_template;
151a5a4af3bSchristos 
152a5a4af3bSchristos extern const insn_template tic54x_unknown_opcode;
153a5a4af3bSchristos extern const insn_template tic54x_optab[];
154a5a4af3bSchristos extern const insn_template tic54x_paroptab[];
155*8b657b07Schristos extern const tic54x_symbol tic54x_mmregs[], tic54x_regs[];
156*8b657b07Schristos extern const tic54x_symbol tic54x_condition_codes[], tic54x_cc2_codes[];
157*8b657b07Schristos extern const tic54x_symbol tic54x_status_bits[], tic54x_cc3_codes[];
158*8b657b07Schristos extern const char *tic54x_misc_symbols[];
159a5a4af3bSchristos struct disassemble_info;
160a5a4af3bSchristos extern const insn_template* tic54x_get_insn (struct disassemble_info *,
161a5a4af3bSchristos                                         bfd_vma, unsigned short, int *);
162a5a4af3bSchristos 
163a5a4af3bSchristos #endif /* _opcode_tic54x_h_ */
164