xref: /netbsd-src/external/gpl3/gdb/dist/include/opcode/tic54x.h (revision aab831cebf6361fb2b518a47c70732e608d9abd2)
198b9484cSchristos /* tic54x.h -- Header file for TI TMS320C54X opcode table
2*aab831ceSchristos    Copyright (C) 1999-2024 Free Software Foundation, Inc.
398b9484cSchristos    Written by Timothy Wall (twall@cygnus.com)
498b9484cSchristos 
598b9484cSchristos    This file is part of GDB, GAS, and the GNU binutils.
698b9484cSchristos 
798b9484cSchristos    GDB, GAS, and the GNU binutils are free software; you can redistribute
898b9484cSchristos    them and/or modify them under the terms of the GNU General Public
998b9484cSchristos    License as published by the Free Software Foundation; either version 3,
1098b9484cSchristos    or (at your option) any later version.
1198b9484cSchristos 
1298b9484cSchristos    GDB, GAS, and the GNU binutils are distributed in the hope that they
1398b9484cSchristos    will be useful, but WITHOUT ANY WARRANTY; without even the implied
1498b9484cSchristos    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
1598b9484cSchristos    the GNU General Public License for more details.
1698b9484cSchristos 
1798b9484cSchristos    You should have received a copy of the GNU General Public License
1898b9484cSchristos    along with this file; see the file COPYING3.  If not, write to the Free
1998b9484cSchristos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
2098b9484cSchristos    02110-1301, USA.  */
2198b9484cSchristos 
2298b9484cSchristos #ifndef _opcode_tic54x_h_
2398b9484cSchristos #define _opcode_tic54x_h_
2498b9484cSchristos 
2598b9484cSchristos typedef struct _symbol
2698b9484cSchristos {
2798b9484cSchristos   const char *name;
2898b9484cSchristos   unsigned short value;
29ba340e45Schristos } tic54x_symbol;
3098b9484cSchristos 
3198b9484cSchristos enum optype {
3298b9484cSchristos   OPT = 0x8000,
3398b9484cSchristos   OP_None = 0x0,
3498b9484cSchristos 
3598b9484cSchristos   OP_Xmem, /* AR3 or AR4, indirect */
3698b9484cSchristos   OP_Ymem, /* AR3 or AR4, indirect */
3798b9484cSchristos   OP_pmad, /* PROG mem, direct */
3898b9484cSchristos   OP_dmad, /* DATA mem, direct */
3998b9484cSchristos   OP_Smem,
4098b9484cSchristos   OP_Lmem, /* 32-bit single-addressed (direct/indirect) */
4198b9484cSchristos   OP_MMR,
4298b9484cSchristos   OP_PA,
4398b9484cSchristos   OP_Sind,
4498b9484cSchristos   OP_xpmad,
4598b9484cSchristos   OP_xpmad_ms7,
4698b9484cSchristos   OP_MMRX,
4798b9484cSchristos   OP_MMRY,
4898b9484cSchristos 
4998b9484cSchristos   OP_SRC1, /* src accumulator in bit 8 */
5098b9484cSchristos   OP_SRC, /* src accumulator in bit 9 */
5198b9484cSchristos   OP_RND, /* rounded result dst accumulator, opposite of bit 8 */
5298b9484cSchristos   OP_DST, /* dst accumulator in bit 8 */
5398b9484cSchristos   OP_ARX, /* arX in bits 0-3 */
5498b9484cSchristos   OP_SHIFT, /* -16 to 15 (SHIFT), bits 0-4 */
5598b9484cSchristos   OP_SHFT, /*   0 to 15 (SHIFT1 in summary), bits 0-3 */
5698b9484cSchristos   OP_B, /* ACC B only */
5798b9484cSchristos   OP_A, /* ACC A only */
5898b9484cSchristos 
5998b9484cSchristos   OP_lk, /* 16-bit immediate, '#' optional */
6098b9484cSchristos   OP_TS,
6198b9484cSchristos   OP_k8, /* -128 <= k <= 128 */
6298b9484cSchristos   OP_16, /* literal "16" */
6398b9484cSchristos   OP_BITC, /* 0 to 16 */
6498b9484cSchristos   OP_CC, /* condition code */
6598b9484cSchristos   OP_CC2, /* 4-bit condition code */
6698b9484cSchristos   OP_CC3, /* 2-bit condition code */
6798b9484cSchristos   OP_123, /* 1, 2, or 3 */
6898b9484cSchristos   OP_031, /* 0-31, numeric */
6998b9484cSchristos   OP_k5, /* 0 to 31 */
7098b9484cSchristos   OP_k8u, /* 0 to 255 */
7198b9484cSchristos   OP_ASM, /* "ASM" */
7298b9484cSchristos   OP_T, /* "T" */
7398b9484cSchristos   OP_DP, /* "DP" */
7498b9484cSchristos   OP_ARP, /* "ARP" */
7598b9484cSchristos   OP_k3, /* 0-7 */
7698b9484cSchristos   OP_lku, /* 0 to 65535 */
7798b9484cSchristos   OP_N, /* 0/1 or ST0/ST1 */
7898b9484cSchristos   OP_SBIT, /* status bit or 0-15 */
7998b9484cSchristos   OP_12, /* one or two */
8098b9484cSchristos   OP_k9, /* 9 bits of data page (DP) address */
8198b9484cSchristos   OP_TRN, /* "TRN" */
8298b9484cSchristos 
8398b9484cSchristos };
8498b9484cSchristos 
8598b9484cSchristos typedef struct _template
8698b9484cSchristos {
8798b9484cSchristos   /* The opcode mnemonic */
8898b9484cSchristos   const char *name;
8998b9484cSchristos   unsigned int words; /* insn size in words */
9098b9484cSchristos   int minops, maxops; /* min/max operand count */
9198b9484cSchristos   /* The significant bits in the opcode.  Other bits are zero.
9298b9484cSchristos      Instructions with more than 16 bits of opcode store the rest in the upper
9398b9484cSchristos      16 bits.
9498b9484cSchristos    */
9598b9484cSchristos   unsigned short opcode;
9698b9484cSchristos #define INDIRECT(OP)    ((OP)&0x80)
9798b9484cSchristos #define MOD(OP)         (((OP)>>3)&0xF)
9898b9484cSchristos #define ARF(OP)         ((OP)&0x7)
9998b9484cSchristos #define IS_LKADDR(OP)   (INDIRECT(OP) && MOD(OP)>=12)
10098b9484cSchristos #define SRC(OP)         ((OP)&0x200)
10198b9484cSchristos #define DST(OP)         ((OP)&0x100)
10298b9484cSchristos #define SRC1(OP)        ((OP)&0x100)
10398b9484cSchristos #define SHIFT(OP)       (((OP)&0x10)?(((OP)&0x1F)-32):((OP)&0x1F))
10498b9484cSchristos #define SHFT(OP)        ((OP)&0xF)
10598b9484cSchristos #define ARX(OP)         ((OP)&0x7)
10698b9484cSchristos #define XMEM(OP)        (((OP)&0x00F0)>>4)
10798b9484cSchristos #define YMEM(OP)        ((OP)&0x000F)
10898b9484cSchristos #define XMOD(C)        (((C)&0xC)>>2)
10998b9484cSchristos #define XARX(C)        (((C)&0x3)+2)
11098b9484cSchristos #define CC3(OP)         (((OP)>>8)&0x3)
11198b9484cSchristos #define SBIT(OP)        ((OP)&0xF)
11298b9484cSchristos #define MMR(OP)         ((OP)&0x7F)
11398b9484cSchristos #define MMRX(OP)        ((((OP)>>4)&0xF)+16)
11498b9484cSchristos #define MMRY(OP)        (((OP)&0xF)+16)
11598b9484cSchristos 
11698b9484cSchristos #define OPTYPE(X)       ((X)&~OPT)
11798b9484cSchristos 
11898b9484cSchristos   /* Ones in this mask indicate which bits must match the opcode field.
11998b9484cSchristos      Zeroes indicate don't care bits (operands and/or opcode options) */
12098b9484cSchristos   unsigned short mask;
12198b9484cSchristos 
12298b9484cSchristos   /* An array of operand codes (at most 4 operands) */
12398b9484cSchristos #define MAX_OPERANDS 4
12498b9484cSchristos   enum optype operand_types[MAX_OPERANDS];
12598b9484cSchristos 
12698b9484cSchristos   /* Special purpose flags (e.g. branch type, parallel, delay, etc)
12798b9484cSchristos    */
12898b9484cSchristos   unsigned short flags;
12998b9484cSchristos #define B_NEXT      0 /* normal execution, next insn is next address */
13098b9484cSchristos #define B_BRANCH    1 /* next insn is in opcode */
13198b9484cSchristos #define B_RET       2 /* next insn is on stack */
13298b9484cSchristos #define B_BACC      3 /* next insn is in acc */
13398b9484cSchristos #define B_REPEAT    4 /* next insn repeats */
13498b9484cSchristos #define FL_BMASK    0x07
13598b9484cSchristos 
13698b9484cSchristos #define FL_DELAY    0x10 /* instruction uses delay slots */
13798b9484cSchristos #define FL_EXT      0x20 /* instruction takes two words */
13898b9484cSchristos #define FL_FAR      0x40 /* far mode addressing */
13998b9484cSchristos #define FL_LP       0x80 /* LP-only instruction */
14098b9484cSchristos #define FL_NR       0x100 /* no repeat allowed */
14198b9484cSchristos #define FL_SMR      0x200 /* Smem read (for flagging write-only *+ARx */
14298b9484cSchristos 
14398b9484cSchristos #define FL_PAR      0x400 /* Parallel instruction. */
14498b9484cSchristos 
14598b9484cSchristos   unsigned short opcode2, mask2;   /* some insns have an extended opcode */
14698b9484cSchristos 
14798b9484cSchristos   const char* parname;
14898b9484cSchristos   enum optype paroperand_types[MAX_OPERANDS];
14998b9484cSchristos 
15098b9484cSchristos } insn_template;
15198b9484cSchristos 
15298b9484cSchristos extern const insn_template tic54x_unknown_opcode;
15398b9484cSchristos extern const insn_template tic54x_optab[];
15498b9484cSchristos extern const insn_template tic54x_paroptab[];
1554b169a6bSchristos extern const tic54x_symbol tic54x_mmregs[], tic54x_regs[];
1564b169a6bSchristos extern const tic54x_symbol tic54x_condition_codes[], tic54x_cc2_codes[];
1574b169a6bSchristos extern const tic54x_symbol tic54x_status_bits[], tic54x_cc3_codes[];
1584b169a6bSchristos extern const char *tic54x_misc_symbols[];
15998b9484cSchristos struct disassemble_info;
16098b9484cSchristos extern const insn_template* tic54x_get_insn (struct disassemble_info *,
16198b9484cSchristos                                         bfd_vma, unsigned short, int *);
16298b9484cSchristos 
16398b9484cSchristos #endif /* _opcode_tic54x_h_ */
164