198b9484cSchristos /* d30v.h -- Header file for D30V opcode table 2*aab831ceSchristos Copyright (C) 1997-2024 Free Software Foundation, Inc. 398b9484cSchristos Written by Martin Hunt (hunt@cygnus.com), Cygnus Solutions 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 D30V_H 2398b9484cSchristos #define D30V_H 2498b9484cSchristos 25ba340e45Schristos #ifdef __cplusplus 26ba340e45Schristos extern "C" { 27ba340e45Schristos #endif 28ba340e45Schristos 2998b9484cSchristos #define NOP 0x00F00000 3098b9484cSchristos 3198b9484cSchristos /* Structure to hold information about predefined registers. */ 3298b9484cSchristos struct pd_reg 3398b9484cSchristos { 3498b9484cSchristos char *name; /* name to recognize */ 3598b9484cSchristos char *pname; /* name to print for this register */ 368dffb485Schristos unsigned int value; 3798b9484cSchristos }; 3898b9484cSchristos 3998b9484cSchristos extern const struct pd_reg pre_defined_registers[]; 4098b9484cSchristos int reg_name_cnt (void); 4198b9484cSchristos 4298b9484cSchristos /* the number of control registers */ 4398b9484cSchristos #define MAX_CONTROL_REG 64 4498b9484cSchristos 4598b9484cSchristos /* define the format specifiers */ 4698b9484cSchristos #define FM00 0 4798b9484cSchristos #define FM01 0x80000000 4898b9484cSchristos #define FM10 0x8000000000000000LL 4998b9484cSchristos #define FM11 0x8000000080000000LL 5098b9484cSchristos 5198b9484cSchristos /* define the opcode classes */ 5298b9484cSchristos #define BRA 0 5398b9484cSchristos #define LOGIC 1 5498b9484cSchristos #define IMEM 2 5598b9484cSchristos #define IALU1 4 5698b9484cSchristos #define IALU2 5 5798b9484cSchristos 5898b9484cSchristos /* define the execution condition codes */ 5998b9484cSchristos #define ECC_AL 0 /* ALways (default) */ 6098b9484cSchristos #define ECC_TX 1 /* F0=True, F1=Don't care */ 6198b9484cSchristos #define ECC_FX 2 /* F0=False, F1=Don't care */ 6298b9484cSchristos #define ECC_XT 3 /* F0=Don't care, F1=True */ 6398b9484cSchristos #define ECC_XF 4 /* F0=Don't care, F1=False */ 6498b9484cSchristos #define ECC_TT 5 /* F0=True, F1=True */ 6598b9484cSchristos #define ECC_TF 6 /* F0=True, F1=False */ 6698b9484cSchristos #define ECC_RESERVED 7 /* reserved */ 6798b9484cSchristos #define ECC_MAX ECC_RESERVED 6898b9484cSchristos 6998b9484cSchristos extern const char *d30v_ecc_names[]; 7098b9484cSchristos 7198b9484cSchristos /* condition code table for CMP and CMPU */ 7298b9484cSchristos extern const char *d30v_cc_names[]; 7398b9484cSchristos 7498b9484cSchristos /* The opcode table is an array of struct d30v_opcode. */ 7598b9484cSchristos struct d30v_opcode 7698b9484cSchristos { 7798b9484cSchristos /* The opcode name. */ 7898b9484cSchristos const char *name; 7998b9484cSchristos 8098b9484cSchristos /* the opcode */ 8198b9484cSchristos int op1; /* first part, "IALU1" for example */ 8298b9484cSchristos int op2; /* the rest of the opcode */ 8398b9484cSchristos 8498b9484cSchristos /* opcode format(s). These numbers correspond to entries */ 8598b9484cSchristos /* in the d30v_format_table */ 8698b9484cSchristos unsigned char format[4]; 8798b9484cSchristos 8898b9484cSchristos #define SHORT_M 1 8998b9484cSchristos #define SHORT_M2 5 /* for ld2w and st2w */ 9098b9484cSchristos #define SHORT_A 9 9198b9484cSchristos #define SHORT_B1 11 9298b9484cSchristos #define SHORT_B2 12 9398b9484cSchristos #define SHORT_B2r 13 9498b9484cSchristos #define SHORT_B3 14 9598b9484cSchristos #define SHORT_B3r 16 9698b9484cSchristos #define SHORT_B3b 18 9798b9484cSchristos #define SHORT_B3br 20 9898b9484cSchristos #define SHORT_D1r 22 9998b9484cSchristos #define SHORT_D2 24 10098b9484cSchristos #define SHORT_D2r 26 10198b9484cSchristos #define SHORT_D2Br 28 10298b9484cSchristos #define SHORT_U 30 /* unary SHORT_A. ABS for example */ 10398b9484cSchristos #define SHORT_F 31 /* SHORT_A with flag registers */ 10498b9484cSchristos #define SHORT_AF 33 /* SHORT_A with only the first register a flag register */ 10598b9484cSchristos #define SHORT_T 35 /* for trap instruction */ 10698b9484cSchristos #define SHORT_A5 36 /* SHORT_A with a 5-bit immediate instead of 6 */ 10798b9484cSchristos #define SHORT_CMP 38 /* special form for CMPcc */ 10898b9484cSchristos #define SHORT_CMPU 40 /* special form for CMPUcc */ 10998b9484cSchristos #define SHORT_A1 42 /* special form of SHORT_A for MACa opcodes where a=1 */ 11098b9484cSchristos #define SHORT_AA 44 /* SHORT_A with the first register an accumulator */ 11198b9484cSchristos #define SHORT_RA 46 /* SHORT_A with the second register an accumulator */ 11298b9484cSchristos #define SHORT_MODINC 48 11398b9484cSchristos #define SHORT_MODDEC 49 11498b9484cSchristos #define SHORT_C1 50 11598b9484cSchristos #define SHORT_C2 51 11698b9484cSchristos #define SHORT_UF 52 11798b9484cSchristos #define SHORT_A2 53 11898b9484cSchristos #define SHORT_NONE 55 /* no operands */ 11998b9484cSchristos #define SHORT_AR 56 /* like SHORT_AA but only accept register as third parameter */ 12098b9484cSchristos #define LONG 57 12198b9484cSchristos #define LONG_U 58 /* unary LONG */ 12298b9484cSchristos #define LONG_Ur 59 /* LONG pc-relative */ 12398b9484cSchristos #define LONG_CMP 60 /* special form for CMPcc and CMPUcc */ 12498b9484cSchristos #define LONG_M 61 /* Memory long for ldb, stb */ 12598b9484cSchristos #define LONG_M2 62 /* Memory long for ld2w, st2w */ 12698b9484cSchristos #define LONG_2 63 /* LONG with 2 operands; jmptnz */ 12798b9484cSchristos #define LONG_2r 64 /* LONG with 2 operands; bratnz */ 12898b9484cSchristos #define LONG_2b 65 /* LONG_2 with modifier of 3 */ 12998b9484cSchristos #define LONG_2br 66 /* LONG_2r with modifier of 3 */ 13098b9484cSchristos #define LONG_D 67 /* for DJMPI */ 13198b9484cSchristos #define LONG_Dr 68 /* for DBRAI */ 13298b9484cSchristos #define LONG_Dbr 69 /* for repeati */ 13398b9484cSchristos 13498b9484cSchristos /* the execution unit(s) used */ 13598b9484cSchristos int unit; 13698b9484cSchristos #define EITHER 0 13798b9484cSchristos #define IU 1 13898b9484cSchristos #define MU 2 13998b9484cSchristos #define EITHER_BUT_PREFER_MU 3 14098b9484cSchristos 14198b9484cSchristos /* this field is used to decide if two instructions */ 14298b9484cSchristos /* can be executed in parallel */ 14398b9484cSchristos long flags_used; 14498b9484cSchristos long flags_set; 14598b9484cSchristos #define FLAG_0 (1L<<0) 14698b9484cSchristos #define FLAG_1 (1L<<1) 14798b9484cSchristos #define FLAG_2 (1L<<2) 14898b9484cSchristos #define FLAG_3 (1L<<3) 14998b9484cSchristos #define FLAG_4 (1L<<4) /* S (saturation) */ 15098b9484cSchristos #define FLAG_5 (1L<<5) /* V (overflow) */ 15198b9484cSchristos #define FLAG_6 (1L<<6) /* VA (accumulated overflow) */ 15298b9484cSchristos #define FLAG_7 (1L<<7) /* C (carry/borrow) */ 15398b9484cSchristos #define FLAG_SM (1L<<8) /* SM (stack mode) */ 15498b9484cSchristos #define FLAG_RP (1L<<9) /* RP (repeat enable) */ 15598b9484cSchristos #define FLAG_CONTROL (1L<<10) /* control registers */ 15698b9484cSchristos #define FLAG_A0 (1L<<11) /* A0 */ 15798b9484cSchristos #define FLAG_A1 (1L<<12) /* A1 */ 15898b9484cSchristos #define FLAG_JMP (1L<<13) /* instruction is a branch */ 15998b9484cSchristos #define FLAG_JSR (1L<<14) /* subroutine call. must be aligned */ 16098b9484cSchristos #define FLAG_MEM (1L<<15) /* reads/writes memory */ 16198b9484cSchristos #define FLAG_NOT_WITH_ADDSUBppp (1L<<16) /* Old meaning: a 2 word 4 byter operation 16298b9484cSchristos New meaning: operation cannot be 16398b9484cSchristos combined in parallel with ADD/SUBppp. */ 16498b9484cSchristos #define FLAG_MUL16 (1L<<17) /* 16 bit multiply */ 16598b9484cSchristos #define FLAG_MUL32 (1L<<18) /* 32 bit multiply */ 16698b9484cSchristos #define FLAG_ADDSUBppp (1L<<19) /* ADDppp or SUBppp */ 16798b9484cSchristos #define FLAG_DELAY (1L<<20) /* This is a delayed branch or jump */ 16898b9484cSchristos #define FLAG_LKR (1L<<21) /* insn in left slot kills right slot */ 16998b9484cSchristos #define FLAG_CVVA (FLAG_5|FLAG_6|FLAG_7) 17098b9484cSchristos #define FLAG_C FLAG_7 17198b9484cSchristos #define FLAG_ALL (FLAG_0 | \ 17298b9484cSchristos FLAG_1 | \ 17398b9484cSchristos FLAG_2 | \ 17498b9484cSchristos FLAG_3 | \ 17598b9484cSchristos FLAG_4 | \ 17698b9484cSchristos FLAG_5 | \ 17798b9484cSchristos FLAG_6 | \ 17898b9484cSchristos FLAG_7 | \ 17998b9484cSchristos FLAG_SM | \ 18098b9484cSchristos FLAG_RP | \ 18198b9484cSchristos FLAG_CONTROL) 18298b9484cSchristos 18398b9484cSchristos int reloc_flag; 18498b9484cSchristos #define RELOC_PCREL 1 18598b9484cSchristos #define RELOC_ABS 2 18698b9484cSchristos }; 18798b9484cSchristos 18898b9484cSchristos extern const struct d30v_opcode d30v_opcode_table[]; 18998b9484cSchristos extern const int d30v_num_opcodes; 19098b9484cSchristos 19198b9484cSchristos /* The operands table is an array of struct d30v_operand. */ 19298b9484cSchristos struct d30v_operand 19398b9484cSchristos { 19498b9484cSchristos /* the length of the field */ 19598b9484cSchristos int length; 19698b9484cSchristos 19798b9484cSchristos /* The number of significant bits in the operand. */ 19898b9484cSchristos int bits; 19998b9484cSchristos 20098b9484cSchristos /* position relative to Ra */ 20198b9484cSchristos int position; 20298b9484cSchristos 20398b9484cSchristos /* syntax flags. */ 20498b9484cSchristos long flags; 20598b9484cSchristos }; 20698b9484cSchristos extern const struct d30v_operand d30v_operand_table[]; 20798b9484cSchristos 20898b9484cSchristos /* Values defined for the flags field of a struct d30v_operand. */ 20998b9484cSchristos 21098b9484cSchristos /* this is the destination register; it will be modified */ 21198b9484cSchristos /* this is used by the optimizer */ 21298b9484cSchristos #define OPERAND_DEST (1) 21398b9484cSchristos 21498b9484cSchristos /* number or symbol */ 21598b9484cSchristos #define OPERAND_NUM (2) 21698b9484cSchristos 21798b9484cSchristos /* address or label */ 21898b9484cSchristos #define OPERAND_ADDR (4) 21998b9484cSchristos 22098b9484cSchristos /* register */ 22198b9484cSchristos #define OPERAND_REG (8) 22298b9484cSchristos 22398b9484cSchristos /* postincrement + */ 22498b9484cSchristos #define OPERAND_PLUS (0x10) 22598b9484cSchristos 22698b9484cSchristos /* postdecrement - */ 22798b9484cSchristos #define OPERAND_MINUS (0x20) 22898b9484cSchristos 22998b9484cSchristos /* signed number */ 23098b9484cSchristos #define OPERAND_SIGNED (0x40) 23198b9484cSchristos 23298b9484cSchristos /* this operand must be shifted left by 3 */ 23398b9484cSchristos #define OPERAND_SHIFT (0x80) 23498b9484cSchristos 23598b9484cSchristos /* flag register */ 23698b9484cSchristos #define OPERAND_FLAG (0x100) 23798b9484cSchristos 23898b9484cSchristos /* control register */ 23998b9484cSchristos #define OPERAND_CONTROL (0x200) 24098b9484cSchristos 24198b9484cSchristos /* accumulator */ 24298b9484cSchristos #define OPERAND_ACC (0x400) 24398b9484cSchristos 24498b9484cSchristos /* @ */ 24598b9484cSchristos #define OPERAND_ATSIGN (0x800) 24698b9484cSchristos 24798b9484cSchristos /* @( */ 24898b9484cSchristos #define OPERAND_ATPAR (0x1000) 24998b9484cSchristos 25098b9484cSchristos /* predecrement mode '@-sp' */ 25198b9484cSchristos #define OPERAND_ATMINUS (0x2000) 25298b9484cSchristos 25398b9484cSchristos /* this operand changes the instruction name */ 25498b9484cSchristos /* for example, CPMcc, CMPUcc */ 25598b9484cSchristos #define OPERAND_NAME (0x4000) 25698b9484cSchristos 25798b9484cSchristos /* fake operand for mvtsys and mvfsys */ 25898b9484cSchristos #define OPERAND_SPECIAL (0x8000) 25998b9484cSchristos 26098b9484cSchristos /* let the optimizer know that two registers are affected */ 26198b9484cSchristos #define OPERAND_2REG (0x10000) 26298b9484cSchristos 26398b9484cSchristos /* This operand is pc-relative. Note that repeati can have two immediate 26498b9484cSchristos operands, one of which is pcrel, the other (the IMM6U one) is not. */ 26598b9484cSchristos #define OPERAND_PCREL (0x20000) 26698b9484cSchristos 26798b9484cSchristos /* The format table is an array of struct d30v_format. */ 26898b9484cSchristos struct d30v_format 26998b9484cSchristos { 27098b9484cSchristos int form; /* SHORT_A, LONG, etc */ 27198b9484cSchristos int modifier; /* two bit modifier following opcode */ 27298b9484cSchristos unsigned char operands[5]; 27398b9484cSchristos }; 27498b9484cSchristos extern const struct d30v_format d30v_format_table[]; 27598b9484cSchristos 27698b9484cSchristos 27798b9484cSchristos /* an instruction is defined by an opcode and a format */ 27898b9484cSchristos /* for example, "add" has one opcode, but three different */ 27998b9484cSchristos /* formats, 2 SHORT_A forms and a LONG form. */ 28098b9484cSchristos struct d30v_insn 28198b9484cSchristos { 28298b9484cSchristos struct d30v_opcode *op; /* pointer to an entry in the opcode table */ 28398b9484cSchristos struct d30v_format *form; /* pointer to an entry in the format table */ 28498b9484cSchristos int ecc; /* execution condition code */ 28598b9484cSchristos }; 28698b9484cSchristos 28798b9484cSchristos /* an expressionS only has one register type, so we fake it */ 28898b9484cSchristos /* by setting high bits to indicate type */ 28998b9484cSchristos #define REGISTER_MASK 0xFF 29098b9484cSchristos 291ba340e45Schristos #ifdef __cplusplus 292ba340e45Schristos } 293ba340e45Schristos #endif 294ba340e45Schristos 29598b9484cSchristos #endif /* D30V_H */ 296