1f7cc78ecSespie /* d30v.h -- Header file for D30V opcode table 2*cf2f2c56Smiod Copyright 1997, 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. 3f7cc78ecSespie Written by Martin Hunt (hunt@cygnus.com), Cygnus Solutions 4f7cc78ecSespie 5f7cc78ecSespie This file is part of GDB, GAS, and the GNU binutils. 6f7cc78ecSespie 7f7cc78ecSespie GDB, GAS, and the GNU binutils are free software; you can redistribute 8f7cc78ecSespie them and/or modify them under the terms of the GNU General Public 9f7cc78ecSespie License as published by the Free Software Foundation; either version 10f7cc78ecSespie 1, or (at your option) any later version. 11f7cc78ecSespie 12f7cc78ecSespie GDB, GAS, and the GNU binutils are distributed in the hope that they 13f7cc78ecSespie will be useful, but WITHOUT ANY WARRANTY; without even the implied 14f7cc78ecSespie warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 15f7cc78ecSespie the GNU General Public License for more details. 16f7cc78ecSespie 17f7cc78ecSespie You should have received a copy of the GNU General Public License 18f7cc78ecSespie along with this file; see the file COPYING. If not, write to the Free 19f7cc78ecSespie Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 20f7cc78ecSespie 21f7cc78ecSespie #ifndef D30V_H 22f7cc78ecSespie #define D30V_H 23f7cc78ecSespie 24f7cc78ecSespie #define NOP 0x00F00000 25f7cc78ecSespie 26f7cc78ecSespie /* Structure to hold information about predefined registers. */ 27f7cc78ecSespie struct pd_reg 28f7cc78ecSespie { 29f7cc78ecSespie char *name; /* name to recognize */ 30f7cc78ecSespie char *pname; /* name to print for this register */ 31f7cc78ecSespie int value; 32f7cc78ecSespie }; 33f7cc78ecSespie 34f7cc78ecSespie extern const struct pd_reg pre_defined_registers[]; 35*cf2f2c56Smiod int reg_name_cnt (void); 36f7cc78ecSespie 37f7cc78ecSespie /* the number of control registers */ 38f7cc78ecSespie #define MAX_CONTROL_REG 64 39f7cc78ecSespie 40f7cc78ecSespie /* define the format specifiers */ 41f7cc78ecSespie #define FM00 0 42f7cc78ecSespie #define FM01 0x80000000 43f7cc78ecSespie #define FM10 0x8000000000000000LL 44f7cc78ecSespie #define FM11 0x8000000080000000LL 45f7cc78ecSespie 46f7cc78ecSespie /* define the opcode classes */ 47f7cc78ecSespie #define BRA 0 48f7cc78ecSespie #define LOGIC 1 49f7cc78ecSespie #define IMEM 2 50f7cc78ecSespie #define IALU1 4 51f7cc78ecSespie #define IALU2 5 52f7cc78ecSespie 53f7cc78ecSespie /* define the execution condition codes */ 54f7cc78ecSespie #define ECC_AL 0 /* ALways (default) */ 55f7cc78ecSespie #define ECC_TX 1 /* F0=True, F1=Don't care */ 56f7cc78ecSespie #define ECC_FX 2 /* F0=False, F1=Don't care */ 57f7cc78ecSespie #define ECC_XT 3 /* F0=Don't care, F1=True */ 58f7cc78ecSespie #define ECC_XF 4 /* F0=Don't care, F1=False */ 59f7cc78ecSespie #define ECC_TT 5 /* F0=True, F1=True */ 60f7cc78ecSespie #define ECC_TF 6 /* F0=True, F1=False */ 61f7cc78ecSespie #define ECC_RESERVED 7 /* reserved */ 62f7cc78ecSespie #define ECC_MAX ECC_RESERVED 63f7cc78ecSespie 64f7cc78ecSespie extern const char *d30v_ecc_names[]; 65f7cc78ecSespie 66f7cc78ecSespie /* condition code table for CMP and CMPU */ 67f7cc78ecSespie extern const char *d30v_cc_names[]; 68f7cc78ecSespie 69f7cc78ecSespie /* The opcode table is an array of struct d30v_opcode. */ 70f7cc78ecSespie struct d30v_opcode 71f7cc78ecSespie { 72f7cc78ecSespie /* The opcode name. */ 73f7cc78ecSespie const char *name; 74f7cc78ecSespie 75f7cc78ecSespie /* the opcode */ 76f7cc78ecSespie int op1; /* first part, "IALU1" for example */ 77f7cc78ecSespie int op2; /* the rest of the opcode */ 78f7cc78ecSespie 79f7cc78ecSespie /* opcode format(s). These numbers correspond to entries */ 80f7cc78ecSespie /* in the d30v_format_table */ 81f7cc78ecSespie unsigned char format[4]; 82f7cc78ecSespie 83f7cc78ecSespie #define SHORT_M 1 84f7cc78ecSespie #define SHORT_M2 5 /* for ld2w and st2w */ 85f7cc78ecSespie #define SHORT_A 9 86f7cc78ecSespie #define SHORT_B1 11 87f7cc78ecSespie #define SHORT_B2 12 88f7cc78ecSespie #define SHORT_B2r 13 89f7cc78ecSespie #define SHORT_B3 14 90f7cc78ecSespie #define SHORT_B3r 16 91f7cc78ecSespie #define SHORT_B3b 18 92f7cc78ecSespie #define SHORT_B3br 20 93f7cc78ecSespie #define SHORT_D1r 22 94f7cc78ecSespie #define SHORT_D2 24 95f7cc78ecSespie #define SHORT_D2r 26 96f7cc78ecSespie #define SHORT_D2Br 28 97f7cc78ecSespie #define SHORT_U 30 /* unary SHORT_A. ABS for example */ 98f7cc78ecSespie #define SHORT_F 31 /* SHORT_A with flag registers */ 99f7cc78ecSespie #define SHORT_AF 33 /* SHORT_A with only the first register a flag register */ 100f7cc78ecSespie #define SHORT_T 35 /* for trap instruction */ 101f7cc78ecSespie #define SHORT_A5 36 /* SHORT_A with a 5-bit immediate instead of 6 */ 102f7cc78ecSespie #define SHORT_CMP 38 /* special form for CMPcc */ 103f7cc78ecSespie #define SHORT_CMPU 40 /* special form for CMPUcc */ 104f7cc78ecSespie #define SHORT_A1 42 /* special form of SHORT_A for MACa opcodes where a=1 */ 105f7cc78ecSespie #define SHORT_AA 44 /* SHORT_A with the first register an accumulator */ 106f7cc78ecSespie #define SHORT_RA 46 /* SHORT_A with the second register an accumulator */ 107f7cc78ecSespie #define SHORT_MODINC 48 108f7cc78ecSespie #define SHORT_MODDEC 49 109f7cc78ecSespie #define SHORT_C1 50 110f7cc78ecSespie #define SHORT_C2 51 111f7cc78ecSespie #define SHORT_UF 52 112f7cc78ecSespie #define SHORT_A2 53 113f7cc78ecSespie #define SHORT_NONE 55 /* no operands */ 114f7cc78ecSespie #define SHORT_AR 56 /* like SHORT_AA but only accept register as third parameter */ 115f7cc78ecSespie #define LONG 57 116f7cc78ecSespie #define LONG_U 58 /* unary LONG */ 117f7cc78ecSespie #define LONG_Ur 59 /* LONG pc-relative */ 118f7cc78ecSespie #define LONG_CMP 60 /* special form for CMPcc and CMPUcc */ 119f7cc78ecSespie #define LONG_M 61 /* Memory long for ldb, stb */ 120f7cc78ecSespie #define LONG_M2 62 /* Memory long for ld2w, st2w */ 121f7cc78ecSespie #define LONG_2 63 /* LONG with 2 operands; jmptnz */ 122f7cc78ecSespie #define LONG_2r 64 /* LONG with 2 operands; bratnz */ 123f7cc78ecSespie #define LONG_2b 65 /* LONG_2 with modifier of 3 */ 124f7cc78ecSespie #define LONG_2br 66 /* LONG_2r with modifier of 3 */ 125f7cc78ecSespie #define LONG_D 67 /* for DJMPI */ 126f7cc78ecSespie #define LONG_Dr 68 /* for DBRAI */ 127f7cc78ecSespie #define LONG_Dbr 69 /* for repeati */ 128f7cc78ecSespie 129f7cc78ecSespie /* the execution unit(s) used */ 130f7cc78ecSespie int unit; 131f7cc78ecSespie #define EITHER 0 132f7cc78ecSespie #define IU 1 133f7cc78ecSespie #define MU 2 134f7cc78ecSespie #define EITHER_BUT_PREFER_MU 3 135f7cc78ecSespie 136f7cc78ecSespie /* this field is used to decide if two instructions */ 137f7cc78ecSespie /* can be executed in parallel */ 138f7cc78ecSespie long flags_used; 139f7cc78ecSespie long flags_set; 140f7cc78ecSespie #define FLAG_0 (1L<<0) 141f7cc78ecSespie #define FLAG_1 (1L<<1) 142f7cc78ecSespie #define FLAG_2 (1L<<2) 143f7cc78ecSespie #define FLAG_3 (1L<<3) 144f7cc78ecSespie #define FLAG_4 (1L<<4) /* S (saturation) */ 145f7cc78ecSespie #define FLAG_5 (1L<<5) /* V (overflow) */ 146f7cc78ecSespie #define FLAG_6 (1L<<6) /* VA (accumulated overflow) */ 147f7cc78ecSespie #define FLAG_7 (1L<<7) /* C (carry/borrow) */ 148f7cc78ecSespie #define FLAG_SM (1L<<8) /* SM (stack mode) */ 149f7cc78ecSespie #define FLAG_RP (1L<<9) /* RP (repeat enable) */ 150f7cc78ecSespie #define FLAG_CONTROL (1L<<10) /* control registers */ 151f7cc78ecSespie #define FLAG_A0 (1L<<11) /* A0 */ 152f7cc78ecSespie #define FLAG_A1 (1L<<12) /* A1 */ 153f7cc78ecSespie #define FLAG_JMP (1L<<13) /* instruction is a branch */ 154f7cc78ecSespie #define FLAG_JSR (1L<<14) /* subroutine call. must be aligned */ 155f7cc78ecSespie #define FLAG_MEM (1L<<15) /* reads/writes memory */ 156f7cc78ecSespie #define FLAG_NOT_WITH_ADDSUBppp (1L<<16) /* Old meaning: a 2 word 4 byter operation 157f7cc78ecSespie New meaning: operation cannot be 158f7cc78ecSespie combined in parallel with ADD/SUBppp. */ 159f7cc78ecSespie #define FLAG_MUL16 (1L<<17) /* 16 bit multiply */ 160f7cc78ecSespie #define FLAG_MUL32 (1L<<18) /* 32 bit multiply */ 161f7cc78ecSespie #define FLAG_ADDSUBppp (1L<<19) /* ADDppp or SUBppp */ 162f7cc78ecSespie #define FLAG_DELAY (1L<<20) /* This is a delayed branch or jump */ 163f7cc78ecSespie #define FLAG_LKR (1L<<21) /* insn in left slot kills right slot */ 164f7cc78ecSespie #define FLAG_CVVA (FLAG_5|FLAG_6|FLAG_7) 165f7cc78ecSespie #define FLAG_C FLAG_7 166f7cc78ecSespie #define FLAG_ALL (FLAG_0 | \ 167f7cc78ecSespie FLAG_1 | \ 168f7cc78ecSespie FLAG_2 | \ 169f7cc78ecSespie FLAG_3 | \ 170f7cc78ecSespie FLAG_4 | \ 171f7cc78ecSespie FLAG_5 | \ 172f7cc78ecSespie FLAG_6 | \ 173f7cc78ecSespie FLAG_7 | \ 174f7cc78ecSespie FLAG_SM | \ 175f7cc78ecSespie FLAG_RP | \ 176f7cc78ecSespie FLAG_CONTROL) 177f7cc78ecSespie 178f7cc78ecSespie int reloc_flag; 179f7cc78ecSespie #define RELOC_PCREL 1 180f7cc78ecSespie #define RELOC_ABS 2 181f7cc78ecSespie }; 182f7cc78ecSespie 183f7cc78ecSespie extern const struct d30v_opcode d30v_opcode_table[]; 184f7cc78ecSespie extern const int d30v_num_opcodes; 185f7cc78ecSespie 186f7cc78ecSespie /* The operands table is an array of struct d30v_operand. */ 187f7cc78ecSespie struct d30v_operand 188f7cc78ecSespie { 189f7cc78ecSespie /* the length of the field */ 190f7cc78ecSespie int length; 191f7cc78ecSespie 192f7cc78ecSespie /* The number of significant bits in the operand. */ 193f7cc78ecSespie int bits; 194f7cc78ecSespie 195f7cc78ecSespie /* position relative to Ra */ 196f7cc78ecSespie int position; 197f7cc78ecSespie 198f7cc78ecSespie /* syntax flags. */ 199f7cc78ecSespie long flags; 200f7cc78ecSespie }; 201f7cc78ecSespie extern const struct d30v_operand d30v_operand_table[]; 202f7cc78ecSespie 203f7cc78ecSespie /* Values defined for the flags field of a struct d30v_operand. */ 204f7cc78ecSespie 205f7cc78ecSespie /* this is the destination register; it will be modified */ 206f7cc78ecSespie /* this is used by the optimizer */ 207f7cc78ecSespie #define OPERAND_DEST (1) 208f7cc78ecSespie 209f7cc78ecSespie /* number or symbol */ 210f7cc78ecSespie #define OPERAND_NUM (2) 211f7cc78ecSespie 212f7cc78ecSespie /* address or label */ 213f7cc78ecSespie #define OPERAND_ADDR (4) 214f7cc78ecSespie 215f7cc78ecSespie /* register */ 216f7cc78ecSespie #define OPERAND_REG (8) 217f7cc78ecSespie 218f7cc78ecSespie /* postincrement + */ 219f7cc78ecSespie #define OPERAND_PLUS (0x10) 220f7cc78ecSespie 221f7cc78ecSespie /* postdecrement - */ 222f7cc78ecSespie #define OPERAND_MINUS (0x20) 223f7cc78ecSespie 224f7cc78ecSespie /* signed number */ 225f7cc78ecSespie #define OPERAND_SIGNED (0x40) 226f7cc78ecSespie 227f7cc78ecSespie /* this operand must be shifted left by 3 */ 228f7cc78ecSespie #define OPERAND_SHIFT (0x80) 229f7cc78ecSespie 230f7cc78ecSespie /* flag register */ 231f7cc78ecSespie #define OPERAND_FLAG (0x100) 232f7cc78ecSespie 233f7cc78ecSespie /* control register */ 234f7cc78ecSespie #define OPERAND_CONTROL (0x200) 235f7cc78ecSespie 236f7cc78ecSespie /* accumulator */ 237f7cc78ecSespie #define OPERAND_ACC (0x400) 238f7cc78ecSespie 239f7cc78ecSespie /* @ */ 240f7cc78ecSespie #define OPERAND_ATSIGN (0x800) 241f7cc78ecSespie 242f7cc78ecSespie /* @( */ 243f7cc78ecSespie #define OPERAND_ATPAR (0x1000) 244f7cc78ecSespie 245f7cc78ecSespie /* predecrement mode '@-sp' */ 246f7cc78ecSespie #define OPERAND_ATMINUS (0x2000) 247f7cc78ecSespie 248f7cc78ecSespie /* this operand changes the instruction name */ 249f7cc78ecSespie /* for example, CPMcc, CMPUcc */ 250f7cc78ecSespie #define OPERAND_NAME (0x4000) 251f7cc78ecSespie 252f7cc78ecSespie /* fake operand for mvtsys and mvfsys */ 253f7cc78ecSespie #define OPERAND_SPECIAL (0x8000) 254f7cc78ecSespie 255f7cc78ecSespie /* let the optimizer know that two registers are affected */ 256f7cc78ecSespie #define OPERAND_2REG (0x10000) 257f7cc78ecSespie 258f7cc78ecSespie /* This operand is pc-relative. Note that repeati can have two immediate 259f7cc78ecSespie operands, one of which is pcrel, the other (the IMM6U one) is not. */ 260f7cc78ecSespie #define OPERAND_PCREL (0x20000) 261f7cc78ecSespie 262f7cc78ecSespie /* The format table is an array of struct d30v_format. */ 263f7cc78ecSespie struct d30v_format 264f7cc78ecSespie { 265f7cc78ecSespie int form; /* SHORT_A, LONG, etc */ 266f7cc78ecSespie int modifier; /* two bit modifier following opcode */ 267f7cc78ecSespie unsigned char operands[5]; 268f7cc78ecSespie }; 269f7cc78ecSespie extern const struct d30v_format d30v_format_table[]; 270f7cc78ecSespie 271f7cc78ecSespie 272f7cc78ecSespie /* an instruction is defined by an opcode and a format */ 273f7cc78ecSespie /* for example, "add" has one opcode, but three different */ 274f7cc78ecSespie /* formats, 2 SHORT_A forms and a LONG form. */ 275f7cc78ecSespie struct d30v_insn 276f7cc78ecSespie { 277f7cc78ecSespie struct d30v_opcode *op; /* pointer to an entry in the opcode table */ 278f7cc78ecSespie struct d30v_format *form; /* pointer to an entry in the format table */ 279f7cc78ecSespie int ecc; /* execution condition code */ 280f7cc78ecSespie }; 281f7cc78ecSespie 282f7cc78ecSespie /* an expressionS only has one register type, so we fake it */ 283f7cc78ecSespie /* by setting high bits to indicate type */ 284f7cc78ecSespie #define REGISTER_MASK 0xFF 285f7cc78ecSespie 286f7cc78ecSespie #endif /* D30V_H */ 287