198b9484cSchristos /* d10v.h -- Header file for D10V opcode table 2*aab831ceSchristos Copyright (C) 1996-2024 Free Software Foundation, Inc. 398b9484cSchristos Written by Martin Hunt (hunt@cygnus.com), Cygnus Support 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, 2098b9484cSchristos MA 02110-1301, USA. */ 2198b9484cSchristos 2298b9484cSchristos #ifndef D10V_H 2398b9484cSchristos #define D10V_H 2498b9484cSchristos 25ba340e45Schristos #ifdef __cplusplus 26ba340e45Schristos extern "C" { 27ba340e45Schristos #endif 28ba340e45Schristos 2998b9484cSchristos /* Format Specifier */ 3098b9484cSchristos #define FM00 0 3198b9484cSchristos #define FM01 0x40000000 3298b9484cSchristos #define FM10 0x80000000 3398b9484cSchristos #define FM11 0xC0000000 3498b9484cSchristos 3598b9484cSchristos #define NOP 0x5e00 3698b9484cSchristos #define OPCODE_DIVS 0x14002800 3798b9484cSchristos 3898b9484cSchristos /* The opcode table is an array of struct d10v_opcode. */ 3998b9484cSchristos 4098b9484cSchristos struct d10v_opcode 4198b9484cSchristos { 4298b9484cSchristos /* The opcode name. */ 4398b9484cSchristos const char *name; 4498b9484cSchristos 4598b9484cSchristos /* the opcode format */ 4698b9484cSchristos int format; 4798b9484cSchristos 4898b9484cSchristos /* These numbers were picked so we can do if( i & SHORT_OPCODE) */ 4998b9484cSchristos #define SHORT_OPCODE 1 5098b9484cSchristos #define LONG_OPCODE 8 5198b9484cSchristos #define SHORT_2 1 /* short with 2 operands */ 5298b9484cSchristos #define SHORT_B 3 /* short with 8-bit branch */ 5398b9484cSchristos #define LONG_B 8 /* long with 16-bit branch */ 5498b9484cSchristos #define LONG_L 10 /* long with 3 operands */ 5598b9484cSchristos #define LONG_R 12 /* reserved */ 5698b9484cSchristos 5798b9484cSchristos /* just a placeholder for variable-length instructions */ 5898b9484cSchristos /* for example, "bra" will be a fake for "bra.s" and bra.l" */ 5998b9484cSchristos /* which will immediately follow in the opcode table. */ 6098b9484cSchristos #define OPCODE_FAKE 32 6198b9484cSchristos 6298b9484cSchristos /* the number of cycles */ 6398b9484cSchristos int cycles; 6498b9484cSchristos 6598b9484cSchristos /* the execution unit(s) used */ 6698b9484cSchristos int unit; 6798b9484cSchristos #define EITHER 0 6898b9484cSchristos #define IU 1 6998b9484cSchristos #define MU 2 7098b9484cSchristos #define BOTH 3 7198b9484cSchristos 7298b9484cSchristos /* execution type; parallel or sequential */ 7398b9484cSchristos /* this field is used to decide if two instructions */ 7498b9484cSchristos /* can be executed in parallel */ 7598b9484cSchristos int exec_type; 7698b9484cSchristos #define PARONLY 1 /* parallel only */ 7798b9484cSchristos #define SEQ 2 /* must be sequential */ 7898b9484cSchristos #define PAR 4 /* may be parallel */ 7998b9484cSchristos #define BRANCH_LINK 8 /* subroutine call. must be aligned */ 8098b9484cSchristos #define RMEM 16 /* reads memory */ 8198b9484cSchristos #define WMEM 32 /* writes memory */ 8298b9484cSchristos #define RF0 64 /* reads f0 */ 8398b9484cSchristos #define WF0 128 /* modifies f0 */ 8498b9484cSchristos #define WCAR 256 /* write Carry */ 8598b9484cSchristos #define BRANCH 512 /* branch, no link */ 8698b9484cSchristos #define ALONE 1024 /* short but pack with a NOP if on asm line alone */ 8798b9484cSchristos 8898b9484cSchristos /* the opcode */ 8998b9484cSchristos long opcode; 9098b9484cSchristos 9198b9484cSchristos /* mask. if( (i & mask) == opcode ) then match */ 9298b9484cSchristos long mask; 9398b9484cSchristos 9498b9484cSchristos /* An array of operand codes. Each code is an index into the 9598b9484cSchristos operand table. They appear in the order which the operands must 9698b9484cSchristos appear in assembly code, and are terminated by a zero. */ 9798b9484cSchristos unsigned char operands[6]; 9898b9484cSchristos }; 9998b9484cSchristos 10098b9484cSchristos /* The table itself is sorted by major opcode number, and is otherwise 10198b9484cSchristos in the order in which the disassembler should consider 10298b9484cSchristos instructions. */ 10398b9484cSchristos extern const struct d10v_opcode d10v_opcodes[]; 10498b9484cSchristos extern const int d10v_num_opcodes; 10598b9484cSchristos 10698b9484cSchristos /* The operands table is an array of struct d10v_operand. */ 10798b9484cSchristos struct d10v_operand 10898b9484cSchristos { 10998b9484cSchristos /* The number of bits in the operand. */ 11098b9484cSchristos int bits; 11198b9484cSchristos 11298b9484cSchristos /* How far the operand is left shifted in the instruction. */ 11398b9484cSchristos int shift; 11498b9484cSchristos 11598b9484cSchristos /* One bit syntax flags. */ 11698b9484cSchristos int flags; 11798b9484cSchristos }; 11898b9484cSchristos 11998b9484cSchristos /* Elements in the table are retrieved by indexing with values from 12098b9484cSchristos the operands field of the d10v_opcodes table. */ 12198b9484cSchristos 12298b9484cSchristos extern const struct d10v_operand d10v_operands[]; 12398b9484cSchristos 12498b9484cSchristos /* Values defined for the flags field of a struct d10v_operand. */ 12598b9484cSchristos 12698b9484cSchristos /* the operand must be an even number */ 12798b9484cSchristos #define OPERAND_EVEN (1) 12898b9484cSchristos 12998b9484cSchristos /* the operand must be an odd number */ 13098b9484cSchristos #define OPERAND_ODD (2) 13198b9484cSchristos 13298b9484cSchristos /* this is the destination register; it will be modified */ 13398b9484cSchristos /* this is used by the optimizer */ 13498b9484cSchristos #define OPERAND_DEST (4) 13598b9484cSchristos 13698b9484cSchristos /* number or symbol */ 13798b9484cSchristos #define OPERAND_NUM (8) 13898b9484cSchristos 13998b9484cSchristos /* address or label */ 14098b9484cSchristos #define OPERAND_ADDR (0x10) 14198b9484cSchristos 14298b9484cSchristos /* register */ 14398b9484cSchristos #define OPERAND_REG (0x20) 14498b9484cSchristos 14598b9484cSchristos /* postincrement + */ 14698b9484cSchristos #define OPERAND_PLUS (0x40) 14798b9484cSchristos 14898b9484cSchristos /* postdecrement - */ 14998b9484cSchristos #define OPERAND_MINUS (0x80) 15098b9484cSchristos 15198b9484cSchristos /* @ */ 15298b9484cSchristos #define OPERAND_ATSIGN (0x100) 15398b9484cSchristos 15498b9484cSchristos /* @( */ 15598b9484cSchristos #define OPERAND_ATPAR (0x200) 15698b9484cSchristos 15798b9484cSchristos /* accumulator 0 */ 15898b9484cSchristos #define OPERAND_ACC0 (0x400) 15998b9484cSchristos 16098b9484cSchristos /* accumulator 1 */ 16198b9484cSchristos #define OPERAND_ACC1 (0x800) 16298b9484cSchristos 16398b9484cSchristos /* f0 / f1 flag register */ 16498b9484cSchristos #define OPERAND_FFLAG (0x1000) 16598b9484cSchristos 16698b9484cSchristos /* c flag register */ 16798b9484cSchristos #define OPERAND_CFLAG (0x2000) 16898b9484cSchristos 16998b9484cSchristos /* control register */ 17098b9484cSchristos #define OPERAND_CONTROL (0x4000) 17198b9484cSchristos 17298b9484cSchristos /* predecrement mode '@-sp' */ 17398b9484cSchristos #define OPERAND_ATMINUS (0x8000) 17498b9484cSchristos 17598b9484cSchristos /* signed number */ 17698b9484cSchristos #define OPERAND_SIGNED (0x10000) 17798b9484cSchristos 17898b9484cSchristos /* special accumulator shifts need a 4-bit number */ 17998b9484cSchristos /* 1 <= x <= 16 */ 18098b9484cSchristos #define OPERAND_SHIFT (0x20000) 18198b9484cSchristos 18298b9484cSchristos /* general purpose register */ 18398b9484cSchristos #define OPERAND_GPR (0x40000) 18498b9484cSchristos 18598b9484cSchristos /* special imm3 values with range restricted to -2 <= imm3 <= 3 */ 18698b9484cSchristos /* needed for rac/rachi */ 18798b9484cSchristos #define RESTRICTED_NUM3 (0x80000) 18898b9484cSchristos 18998b9484cSchristos /* Pre-decrement is only supported for SP. */ 19098b9484cSchristos #define OPERAND_SP (0x100000) 19198b9484cSchristos 19298b9484cSchristos /* Post-decrement is not supported for SP. Like OPERAND_EVEN, and 19398b9484cSchristos unlike OPERAND_SP, this flag doesn't prevent the instruction from 19498b9484cSchristos matching, it only fails validation later on. */ 19598b9484cSchristos #define OPERAND_NOSP (0x200000) 19698b9484cSchristos 19798b9484cSchristos /* Structure to hold information about predefined registers. */ 19898b9484cSchristos struct pd_reg 19998b9484cSchristos { 20098b9484cSchristos char *name; /* name to recognize */ 20198b9484cSchristos char *pname; /* name to print for this register */ 20298b9484cSchristos int value; 20398b9484cSchristos }; 20498b9484cSchristos 20598b9484cSchristos extern const struct pd_reg d10v_predefined_registers[]; 20698b9484cSchristos int d10v_reg_name_cnt (void); 20798b9484cSchristos 20898b9484cSchristos /* an expressionS only has one register type, so we fake it */ 20998b9484cSchristos /* by setting high bits to indicate type */ 21098b9484cSchristos #define REGISTER_MASK 0xFF 21198b9484cSchristos 212ba340e45Schristos #ifdef __cplusplus 213ba340e45Schristos } 214ba340e45Schristos #endif 215ba340e45Schristos 21698b9484cSchristos #endif /* D10V_H */ 217