1a5a4af3bSchristos /* Opcode table for the ARC. 2*8b657b07Schristos Copyright (C) 1994-2022 Free Software Foundation, Inc. 3e5cb852cSchristos 4e5cb852cSchristos Contributed by Claudiu Zissulescu (claziss@synopsys.com) 5a5a4af3bSchristos 6a5a4af3bSchristos This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and 7a5a4af3bSchristos the GNU Binutils. 8a5a4af3bSchristos 9a5a4af3bSchristos GAS/GDB is free software; you can redistribute it and/or modify 10a5a4af3bSchristos it under the terms of the GNU General Public License as published by 11a5a4af3bSchristos the Free Software Foundation; either version 3, or (at your option) 12a5a4af3bSchristos any later version. 13a5a4af3bSchristos 14a5a4af3bSchristos GAS/GDB is distributed in the hope that it will be useful, 15a5a4af3bSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 16a5a4af3bSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17a5a4af3bSchristos GNU General Public License for more details. 18a5a4af3bSchristos 19a5a4af3bSchristos You should have received a copy of the GNU General Public License 20a5a4af3bSchristos along with GAS or GDB; see the file COPYING3. If not, write to 21a5a4af3bSchristos the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, 22a5a4af3bSchristos MA 02110-1301, USA. */ 23a5a4af3bSchristos 24e5cb852cSchristos #ifndef OPCODE_ARC_H 25e5cb852cSchristos #define OPCODE_ARC_H 26a5a4af3bSchristos 27e5cb852cSchristos #ifdef __cplusplus 28e5cb852cSchristos extern "C" { 29e5cb852cSchristos #endif 30a5a4af3bSchristos 31e5cb852cSchristos #ifndef MAX_INSN_ARGS 32e5cb852cSchristos #define MAX_INSN_ARGS 16 33e5cb852cSchristos #endif 34a5a4af3bSchristos 35e5cb852cSchristos #ifndef MAX_INSN_FLGS 3647c37bc2Schristos #define MAX_INSN_FLGS 4 37e5cb852cSchristos #endif 38a5a4af3bSchristos 39e5cb852cSchristos /* Instruction Class. */ 40e5cb852cSchristos typedef enum 41e5cb852cSchristos { 42e5cb852cSchristos ACL, 43e5cb852cSchristos ARITH, 44e5cb852cSchristos AUXREG, 4599e23f81Schristos BBIT0, 4699e23f81Schristos BBIT1, 4799e23f81Schristos BI, 4899e23f81Schristos BIH, 49e5cb852cSchristos BITOP, 5099e23f81Schristos BITSTREAM, 51e5cb852cSchristos BMU, 52e5cb852cSchristos BRANCH, 5399e23f81Schristos BRCC, 54e5cb852cSchristos CONTROL, 5599e23f81Schristos DIVREM, 5699e23f81Schristos DMA, 57e5cb852cSchristos DPI, 58e5cb852cSchristos DSP, 5999e23f81Schristos EI, 6099e23f81Schristos ENTER, 61e5cb852cSchristos FLOAT, 62e5cb852cSchristos INVALID, 6399e23f81Schristos JLI, 64e5cb852cSchristos JUMP, 65e5cb852cSchristos KERNEL, 6699e23f81Schristos LEAVE, 6782650ea5Schristos LLOCK, 6899e23f81Schristos LOAD, 69e5cb852cSchristos LOGICAL, 7099e23f81Schristos LOOP, 71e5cb852cSchristos MEMORY, 7299e23f81Schristos MISC, 7399e23f81Schristos MOVE, 7499e23f81Schristos MPY, 75e5cb852cSchristos NET, 7699e23f81Schristos PROTOCOL_DECODE, 7799e23f81Schristos PMU, 7899e23f81Schristos POP, 7999e23f81Schristos PUSH, 8082650ea5Schristos SCOND, 8147c37bc2Schristos SJLI, 8299e23f81Schristos STORE, 8399e23f81Schristos SUB, 8482650ea5Schristos SWITCH, 8599e23f81Schristos ULTRAIP, 8699e23f81Schristos XY 87e5cb852cSchristos } insn_class_t; 88a5a4af3bSchristos 89e5cb852cSchristos /* Instruction Subclass. */ 90e5cb852cSchristos typedef enum 91e5cb852cSchristos { 9247c37bc2Schristos NONE = 0, 9347c37bc2Schristos CVT = (1U << 1), 9447c37bc2Schristos BTSCN = (1U << 2), 9547c37bc2Schristos CD = (1U << 3), 9647c37bc2Schristos CD1 = CD, 9747c37bc2Schristos CD2 = CD, 9847c37bc2Schristos COND = (1U << 4), 9947c37bc2Schristos DIV = (1U << 5), 10047c37bc2Schristos DP = (1U << 6), 10147c37bc2Schristos DPA = (1U << 7), 10247c37bc2Schristos DPX = (1U << 8), 10382650ea5Schristos FASTMATH = (1U << 23), 10447c37bc2Schristos LL64 = (1U << 9), 10547c37bc2Schristos MPY1E = (1U << 10), 10647c37bc2Schristos MPY6E = (1U << 11), 10747c37bc2Schristos MPY7E = (1U << 12), 10847c37bc2Schristos MPY8E = (1U << 13), 10947c37bc2Schristos MPY9E = (1U << 14), 11047c37bc2Schristos NPS400 = (1U << 15), 11147c37bc2Schristos QUARKSE1 = (1U << 16), 11247c37bc2Schristos QUARKSE2 = (1U << 17), 11347c37bc2Schristos SHFT1 = (1U << 18), 11447c37bc2Schristos SHFT2 = (1U << 19), 11547c37bc2Schristos SWAP = (1U << 20), 11647c37bc2Schristos SP = (1U << 21), 11747c37bc2Schristos SPX = (1U << 22) 118e5cb852cSchristos } insn_subclass_t; 119a5a4af3bSchristos 120e5cb852cSchristos /* Flags class. */ 121e5cb852cSchristos typedef enum 122e5cb852cSchristos { 123e5cb852cSchristos F_CLASS_NONE = 0, 124a5a4af3bSchristos 125e5cb852cSchristos /* At most one flag from the set of flags can appear in the 126e5cb852cSchristos instruction. */ 127e5cb852cSchristos F_CLASS_OPTIONAL = (1 << 0), 128a5a4af3bSchristos 129e5cb852cSchristos /* Exactly one from from the set of flags must appear in the 130e5cb852cSchristos instruction. */ 131e5cb852cSchristos F_CLASS_REQUIRED = (1 << 1), 132a5a4af3bSchristos 133e5cb852cSchristos /* The conditional code can be extended over the standard variants 134e5cb852cSchristos via .extCondCode pseudo-op. */ 135e5cb852cSchristos F_CLASS_EXTEND = (1 << 2), 136a5a4af3bSchristos 137e5cb852cSchristos /* Condition code flag. */ 13899e23f81Schristos F_CLASS_COND = (1 << 3), 13999e23f81Schristos 14099e23f81Schristos /* Write back mode. */ 14199e23f81Schristos F_CLASS_WB = (1 << 4), 14299e23f81Schristos 14399e23f81Schristos /* Data size. */ 14499e23f81Schristos F_CLASS_ZZ = (1 << 5), 14599e23f81Schristos 14699e23f81Schristos /* Implicit flag. */ 14799e23f81Schristos F_CLASS_IMPLICIT = (1 << 6) 148e5cb852cSchristos } flag_class_t; 149a5a4af3bSchristos 150e5cb852cSchristos /* The opcode table is an array of struct arc_opcode. */ 151e5cb852cSchristos struct arc_opcode 152e5cb852cSchristos { 153e5cb852cSchristos /* The opcode name. */ 154e5cb852cSchristos const char * name; 155a5a4af3bSchristos 156e5cb852cSchristos /* The opcode itself. Those bits which will be filled in with 157e5cb852cSchristos operands are zeroes. */ 15899e23f81Schristos unsigned long long opcode; 159a5a4af3bSchristos 160e5cb852cSchristos /* The opcode mask. This is used by the disassembler. This is a 161e5cb852cSchristos mask containing ones indicating those bits which must match the 162e5cb852cSchristos opcode field, and zeroes indicating those bits which need not 163e5cb852cSchristos match (and are presumably filled in by operands). */ 16499e23f81Schristos unsigned long long mask; 165a5a4af3bSchristos 166e5cb852cSchristos /* One bit flags for the opcode. These are primarily used to 167e5cb852cSchristos indicate specific processors and environments support the 168e5cb852cSchristos instructions. The defined values are listed below. */ 169e5cb852cSchristos unsigned cpu; 170a5a4af3bSchristos 171e5cb852cSchristos /* The instruction class. This is used by gdb. */ 172e5cb852cSchristos insn_class_t insn_class; 173a5a4af3bSchristos 174e5cb852cSchristos /* The instruction subclass. */ 175e5cb852cSchristos insn_subclass_t subclass; 176a5a4af3bSchristos 177e5cb852cSchristos /* An array of operand codes. Each code is an index into the 178e5cb852cSchristos operand table. They appear in the order which the operands must 179e5cb852cSchristos appear in assembly code, and are terminated by a zero. */ 180e5cb852cSchristos unsigned char operands[MAX_INSN_ARGS + 1]; 181e5cb852cSchristos 182e5cb852cSchristos /* An array of flag codes. Each code is an index into the flag 183e5cb852cSchristos table. They appear in the order which the flags must appear in 184e5cb852cSchristos assembly code, and are terminated by a zero. */ 185e5cb852cSchristos unsigned char flags[MAX_INSN_FLGS + 1]; 186a5a4af3bSchristos }; 187a5a4af3bSchristos 188e5cb852cSchristos /* The table itself is sorted by major opcode number, and is otherwise 189e5cb852cSchristos in the order in which the disassembler should consider 190e5cb852cSchristos instructions. */ 191e5cb852cSchristos extern const struct arc_opcode arc_opcodes[]; 192a5a4af3bSchristos 19399e23f81Schristos /* Return length of an instruction represented by OPCODE, in bytes. */ 19499e23f81Schristos extern int arc_opcode_len (const struct arc_opcode *opcode); 19599e23f81Schristos 196e5cb852cSchristos /* CPU Availability. */ 197e5cb852cSchristos #define ARC_OPCODE_NONE 0x0000 198e5cb852cSchristos #define ARC_OPCODE_ARC600 0x0001 /* ARC 600 specific insns. */ 199e5cb852cSchristos #define ARC_OPCODE_ARC700 0x0002 /* ARC 700 specific insns. */ 200e5cb852cSchristos #define ARC_OPCODE_ARCv2EM 0x0004 /* ARCv2 EM specific insns. */ 201e5cb852cSchristos #define ARC_OPCODE_ARCv2HS 0x0008 /* ARCv2 HS specific insns. */ 202a5a4af3bSchristos 203e5cb852cSchristos /* CPU combi. */ 204e5cb852cSchristos #define ARC_OPCODE_ARCALL (ARC_OPCODE_ARC600 | ARC_OPCODE_ARC700 \ 205e5cb852cSchristos | ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS) 206e5cb852cSchristos #define ARC_OPCODE_ARCFPX (ARC_OPCODE_ARC700 | ARC_OPCODE_ARCv2EM) 20747c37bc2Schristos #define ARC_OPCODE_ARCV1 (ARC_OPCODE_ARC600 | ARC_OPCODE_ARC700) 20899e23f81Schristos #define ARC_OPCODE_ARCV2 (ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS) 20947c37bc2Schristos #define ARC_OPCODE_ARCMPY6E (ARC_OPCODE_ARC700 | ARC_OPCODE_ARCV2) 210a5a4af3bSchristos 211e5cb852cSchristos /* The operands table is an array of struct arc_operand. */ 212e5cb852cSchristos struct arc_operand 213e5cb852cSchristos { 214e5cb852cSchristos /* The number of bits in the operand. */ 215e5cb852cSchristos unsigned int bits; 216a5a4af3bSchristos 217e5cb852cSchristos /* How far the operand is left shifted in the instruction. */ 218e5cb852cSchristos unsigned int shift; 219a5a4af3bSchristos 220e5cb852cSchristos /* The default relocation type for this operand. */ 221e5cb852cSchristos signed int default_reloc; 222a5a4af3bSchristos 223e5cb852cSchristos /* One bit syntax flags. */ 224e5cb852cSchristos unsigned int flags; 225a5a4af3bSchristos 226a5a4af3bSchristos /* Insertion function. This is used by the assembler. To insert an 227a5a4af3bSchristos operand value into an instruction, check this field. 228a5a4af3bSchristos 229a5a4af3bSchristos If it is NULL, execute 230e5cb852cSchristos i |= (op & ((1 << o->bits) - 1)) << o->shift; 231e5cb852cSchristos (i is the instruction which we are filling in, o is a pointer to 232e5cb852cSchristos this structure, and op is the opcode value; this assumes twos 233a5a4af3bSchristos complement arithmetic). 234a5a4af3bSchristos 235a5a4af3bSchristos If this field is not NULL, then simply call it with the 236a5a4af3bSchristos instruction and the operand value. It will return the new value 237a5a4af3bSchristos of the instruction. If the ERRMSG argument is not NULL, then if 238a5a4af3bSchristos the operand value is illegal, *ERRMSG will be set to a warning 239a5a4af3bSchristos string (the operand will be inserted in any case). If the 240e5cb852cSchristos operand value is legal, *ERRMSG will be unchanged (most operands 241e5cb852cSchristos can accept any value). */ 24299e23f81Schristos unsigned long long (*insert) (unsigned long long instruction, 24399e23f81Schristos long long int op, 24499e23f81Schristos const char **errmsg); 245a5a4af3bSchristos 246a5a4af3bSchristos /* Extraction function. This is used by the disassembler. To 247a5a4af3bSchristos extract this operand type from an instruction, check this field. 248a5a4af3bSchristos 249a5a4af3bSchristos If it is NULL, compute 250a5a4af3bSchristos op = ((i) >> o->shift) & ((1 << o->bits) - 1); 251a5a4af3bSchristos if ((o->flags & ARC_OPERAND_SIGNED) != 0 252a5a4af3bSchristos && (op & (1 << (o->bits - 1))) != 0) 253a5a4af3bSchristos op -= 1 << o->bits; 254e5cb852cSchristos (i is the instruction, o is a pointer to this structure, and op 255a5a4af3bSchristos is the result; this assumes twos complement arithmetic). 256a5a4af3bSchristos 257a5a4af3bSchristos If this field is not NULL, then simply call it with the 258a5a4af3bSchristos instruction value. It will return the value of the operand. If 259a5a4af3bSchristos the INVALID argument is not NULL, *INVALID will be set to 260e5cb852cSchristos TRUE if this operand type can not actually be extracted from 261a5a4af3bSchristos this operand (i.e., the instruction does not match). If the 262e5cb852cSchristos operand is valid, *INVALID will not be changed. */ 263*8b657b07Schristos long long int (*extract) (unsigned long long instruction, bool *invalid); 264a5a4af3bSchristos }; 265a5a4af3bSchristos 266e5cb852cSchristos /* Elements in the table are retrieved by indexing with values from 267e5cb852cSchristos the operands field of the arc_opcodes table. */ 268a5a4af3bSchristos extern const struct arc_operand arc_operands[]; 269e5cb852cSchristos extern const unsigned arc_num_operands; 270e5cb852cSchristos extern const unsigned arc_Toperand; 271e5cb852cSchristos extern const unsigned arc_NToperand; 272a5a4af3bSchristos 273e5cb852cSchristos /* Values defined for the flags field of a struct arc_operand. */ 274a5a4af3bSchristos 275e5cb852cSchristos /* This operand does not actually exist in the assembler input. This 276e5cb852cSchristos is used to support extended mnemonics, for which two operands fields 277e5cb852cSchristos are identical. The assembler should call the insert function with 278e5cb852cSchristos any op value. The disassembler should call the extract function, 279e5cb852cSchristos ignore the return value, and check the value placed in the invalid 280e5cb852cSchristos argument. */ 281e5cb852cSchristos #define ARC_OPERAND_FAKE 0x0001 282e5cb852cSchristos 283e5cb852cSchristos /* This operand names an integer register. */ 284e5cb852cSchristos #define ARC_OPERAND_IR 0x0002 285e5cb852cSchristos 286e5cb852cSchristos /* This operand takes signed values. */ 287e5cb852cSchristos #define ARC_OPERAND_SIGNED 0x0004 288e5cb852cSchristos 289e5cb852cSchristos /* This operand takes unsigned values. This exists primarily so that 290e5cb852cSchristos a flags value of 0 can be treated as end-of-arguments. */ 291e5cb852cSchristos #define ARC_OPERAND_UNSIGNED 0x0008 292e5cb852cSchristos 293e5cb852cSchristos /* This operand takes long immediate values. */ 294e5cb852cSchristos #define ARC_OPERAND_LIMM 0x0010 295e5cb852cSchristos 296e5cb852cSchristos /* This operand is identical like the previous one. */ 297e5cb852cSchristos #define ARC_OPERAND_DUPLICATE 0x0020 298e5cb852cSchristos 299e5cb852cSchristos /* This operand is PC relative. Used for internal relocs. */ 300e5cb852cSchristos #define ARC_OPERAND_PCREL 0x0040 301e5cb852cSchristos 302e5cb852cSchristos /* This operand is truncated. The truncation is done accordingly to 303e5cb852cSchristos operand alignment attribute. */ 304e5cb852cSchristos #define ARC_OPERAND_TRUNCATE 0x0080 305e5cb852cSchristos 306e5cb852cSchristos /* This operand is 16bit aligned. */ 307e5cb852cSchristos #define ARC_OPERAND_ALIGNED16 0x0100 308e5cb852cSchristos 309e5cb852cSchristos /* This operand is 32bit aligned. */ 310e5cb852cSchristos #define ARC_OPERAND_ALIGNED32 0x0200 311e5cb852cSchristos 312e5cb852cSchristos /* This operand can be ignored by matching process if it is not 313e5cb852cSchristos present. */ 314e5cb852cSchristos #define ARC_OPERAND_IGNORE 0x0400 315e5cb852cSchristos 316e5cb852cSchristos /* Don't check the range when matching. */ 317e5cb852cSchristos #define ARC_OPERAND_NCHK 0x0800 318e5cb852cSchristos 319e5cb852cSchristos /* Mark the braket possition. */ 320e5cb852cSchristos #define ARC_OPERAND_BRAKET 0x1000 321e5cb852cSchristos 322e5cb852cSchristos /* Address type operand for NPS400. */ 323e5cb852cSchristos #define ARC_OPERAND_ADDRTYPE 0x2000 324e5cb852cSchristos 325e5cb852cSchristos /* Mark the colon position. */ 326e5cb852cSchristos #define ARC_OPERAND_COLON 0x4000 327e5cb852cSchristos 328e5cb852cSchristos /* Mask for selecting the type for typecheck purposes. */ 329e5cb852cSchristos #define ARC_OPERAND_TYPECHECK_MASK \ 330e5cb852cSchristos (ARC_OPERAND_IR \ 331e5cb852cSchristos | ARC_OPERAND_LIMM | ARC_OPERAND_SIGNED \ 332e5cb852cSchristos | ARC_OPERAND_UNSIGNED | ARC_OPERAND_BRAKET \ 333e5cb852cSchristos | ARC_OPERAND_ADDRTYPE | ARC_OPERAND_COLON) 334e5cb852cSchristos 335e5cb852cSchristos /* Macro to determine if an operand is a fake operand. */ 336e5cb852cSchristos #define ARC_OPERAND_IS_FAKE(op) \ 337e5cb852cSchristos ((operand->flags & ARC_OPERAND_FAKE) \ 338e5cb852cSchristos && !((operand->flags & ARC_OPERAND_BRAKET) \ 339e5cb852cSchristos || (operand->flags & ARC_OPERAND_COLON))) 340e5cb852cSchristos 341e5cb852cSchristos /* The flags structure. */ 342e5cb852cSchristos struct arc_flag_operand 343e5cb852cSchristos { 344e5cb852cSchristos /* The flag name. */ 345e5cb852cSchristos const char * name; 346e5cb852cSchristos 347e5cb852cSchristos /* The flag code. */ 348e5cb852cSchristos unsigned code; 349e5cb852cSchristos 350e5cb852cSchristos /* The number of bits in the operand. */ 351e5cb852cSchristos unsigned int bits; 352e5cb852cSchristos 353e5cb852cSchristos /* How far the operand is left shifted in the instruction. */ 354e5cb852cSchristos unsigned int shift; 355e5cb852cSchristos 356e5cb852cSchristos /* Available for disassembler. */ 357e5cb852cSchristos unsigned char favail; 358e5cb852cSchristos }; 359e5cb852cSchristos 360e5cb852cSchristos /* The flag operands table. */ 361e5cb852cSchristos extern const struct arc_flag_operand arc_flag_operands[]; 362e5cb852cSchristos extern const unsigned arc_num_flag_operands; 363e5cb852cSchristos 364e5cb852cSchristos /* The flag's class structure. */ 365e5cb852cSchristos struct arc_flag_class 366e5cb852cSchristos { 367e5cb852cSchristos /* Flag class. */ 368e5cb852cSchristos flag_class_t flag_class; 369e5cb852cSchristos 370e5cb852cSchristos /* List of valid flags (codes). */ 371e5cb852cSchristos unsigned flags[256]; 372e5cb852cSchristos }; 373e5cb852cSchristos 374e5cb852cSchristos extern const struct arc_flag_class arc_flag_classes[]; 375e5cb852cSchristos 376e5cb852cSchristos /* Structure for special cases. */ 377e5cb852cSchristos struct arc_flag_special 378e5cb852cSchristos { 379e5cb852cSchristos /* Name of special case instruction. */ 380e5cb852cSchristos const char *name; 381e5cb852cSchristos 382e5cb852cSchristos /* List of flags applicable for special case instruction. */ 383e5cb852cSchristos unsigned flags[32]; 384e5cb852cSchristos }; 385e5cb852cSchristos 386e5cb852cSchristos extern const struct arc_flag_special arc_flag_special_cases[]; 387e5cb852cSchristos extern const unsigned arc_num_flag_special; 388e5cb852cSchristos 389e5cb852cSchristos /* Relocation equivalence structure. */ 390e5cb852cSchristos struct arc_reloc_equiv_tab 391e5cb852cSchristos { 392e5cb852cSchristos const char * name; /* String to lookup. */ 393e5cb852cSchristos const char * mnemonic; /* Extra matching condition. */ 394e5cb852cSchristos unsigned flags[32]; /* Extra matching condition. */ 395e5cb852cSchristos signed int oldreloc; /* Old relocation. */ 396e5cb852cSchristos signed int newreloc; /* New relocation. */ 397e5cb852cSchristos }; 398e5cb852cSchristos 399e5cb852cSchristos extern const struct arc_reloc_equiv_tab arc_reloc_equiv[]; 400e5cb852cSchristos extern const unsigned arc_num_equiv_tab; 401e5cb852cSchristos 402e5cb852cSchristos /* Structure for operand operations for pseudo/alias instructions. */ 403e5cb852cSchristos struct arc_operand_operation 404e5cb852cSchristos { 405e5cb852cSchristos /* The index for operand from operand array. */ 406e5cb852cSchristos unsigned operand_idx; 407e5cb852cSchristos 408e5cb852cSchristos /* Defines if it needs the operand inserted by the assembler or 409e5cb852cSchristos whether this operand comes from the pseudo instruction's 410e5cb852cSchristos operands. */ 411e5cb852cSchristos unsigned char needs_insert; 412e5cb852cSchristos 413e5cb852cSchristos /* Count we have to add to the operand. Use negative number to 414e5cb852cSchristos subtract from the operand. Also use this number to add to 0 if 415e5cb852cSchristos the operand needs to be inserted (i.e. needs_insert == 1). */ 416e5cb852cSchristos int count; 417e5cb852cSchristos 418e5cb852cSchristos /* Index of the operand to swap with. To be done AFTER applying 419e5cb852cSchristos inc_count. */ 420e5cb852cSchristos unsigned swap_operand_idx; 421e5cb852cSchristos }; 422e5cb852cSchristos 423e5cb852cSchristos /* Structure for pseudo/alias instructions. */ 424e5cb852cSchristos struct arc_pseudo_insn 425e5cb852cSchristos { 426e5cb852cSchristos /* Mnemonic for pseudo/alias insn. */ 427e5cb852cSchristos const char * mnemonic_p; 428e5cb852cSchristos 429e5cb852cSchristos /* Mnemonic for real instruction. */ 430e5cb852cSchristos const char * mnemonic_r; 431e5cb852cSchristos 432e5cb852cSchristos /* Flag that will have to be added (if any). */ 433e5cb852cSchristos const char * flag_r; 434e5cb852cSchristos 435e5cb852cSchristos /* Amount of operands. */ 436e5cb852cSchristos unsigned operand_cnt; 437e5cb852cSchristos 438e5cb852cSchristos /* Array of operand operations. */ 439e5cb852cSchristos struct arc_operand_operation operand[6]; 440e5cb852cSchristos }; 441e5cb852cSchristos 442e5cb852cSchristos extern const struct arc_pseudo_insn arc_pseudo_insns[]; 443e5cb852cSchristos extern const unsigned arc_num_pseudo_insn; 444e5cb852cSchristos 445e5cb852cSchristos /* Structure for AUXILIARY registers. */ 446e5cb852cSchristos struct arc_aux_reg 447e5cb852cSchristos { 448e5cb852cSchristos /* Register address. */ 449e5cb852cSchristos int address; 450e5cb852cSchristos 451e5cb852cSchristos /* One bit flags for the opcode. These are primarily used to 452e5cb852cSchristos indicate specific processors and environments support the 453e5cb852cSchristos instructions. */ 454e5cb852cSchristos unsigned cpu; 455e5cb852cSchristos 456e5cb852cSchristos /* AUX register subclass. */ 457e5cb852cSchristos insn_subclass_t subclass; 458e5cb852cSchristos 459e5cb852cSchristos /* Register name. */ 460e5cb852cSchristos const char * name; 461e5cb852cSchristos 462e5cb852cSchristos /* Size of the string. */ 463e5cb852cSchristos size_t length; 464e5cb852cSchristos }; 465e5cb852cSchristos 466e5cb852cSchristos extern const struct arc_aux_reg arc_aux_regs[]; 467e5cb852cSchristos extern const unsigned arc_num_aux_regs; 468e5cb852cSchristos 469e5cb852cSchristos extern const struct arc_opcode arc_relax_opcodes[]; 470e5cb852cSchristos extern const unsigned arc_num_relax_opcodes; 471e5cb852cSchristos 472e5cb852cSchristos /* Macro used for generating one class of NPS instructions. */ 473e5cb852cSchristos #define NPS_CMEM_HIGH_VALUE 0x57f0 474e5cb852cSchristos 475e5cb852cSchristos /* Macros to help generating regular pattern instructions. */ 476e5cb852cSchristos #define FIELDA(word) (word & 0x3F) 477e5cb852cSchristos #define FIELDB(word) (((word & 0x07) << 24) | (((word >> 3) & 0x07) << 12)) 478e5cb852cSchristos #define FIELDC(word) ((word & 0x3F) << 6) 479e5cb852cSchristos #define FIELDF (0x01 << 15) 480e5cb852cSchristos #define FIELDQ (0x1F) 481e5cb852cSchristos 482e5cb852cSchristos #define INSN3OP(MOP,SOP) (((MOP & 0x1F) << 27) | ((SOP & 0x3F) << 16)) 483e5cb852cSchristos #define INSN2OPX(MOP,SOP1,SOP2) (INSN3OP (MOP,SOP1) | (SOP2 & 0x3F)) 484e5cb852cSchristos #define INSN2OP(MOP,SOP) (INSN2OPX (MOP,0x2F,SOP)) 485e5cb852cSchristos 486e5cb852cSchristos #define INSN3OP_ABC(MOP,SOP) (INSN3OP (MOP,SOP)) 487e5cb852cSchristos #define INSN3OP_ALC(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDB (62)) 488e5cb852cSchristos #define INSN3OP_ABL(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDC (62)) 489e5cb852cSchristos #define INSN3OP_ALL(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDB (62) | FIELDC (62)) 490e5cb852cSchristos #define INSN3OP_0BC(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62)) 491e5cb852cSchristos #define INSN3OP_0LC(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62) | FIELDB (62)) 492e5cb852cSchristos #define INSN3OP_0BL(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62) | FIELDC (62)) 493e5cb852cSchristos #define INSN3OP_0LL(MOP,SOP) \ 494e5cb852cSchristos (INSN3OP (MOP,SOP) | FIELDA (62) | FIELDB (62) | FIELDC (62)) 495e5cb852cSchristos #define INSN3OP_ABU(MOP,SOP) (INSN3OP (MOP,SOP) | (0x01 << 22)) 496e5cb852cSchristos #define INSN3OP_ALU(MOP,SOP) (INSN3OP (MOP,SOP) | (0x01 << 22) | FIELDB (62)) 497e5cb852cSchristos #define INSN3OP_0BU(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62) | (0x01 << 22)) 498e5cb852cSchristos #define INSN3OP_0LU(MOP,SOP) \ 499e5cb852cSchristos (INSN3OP (MOP,SOP) | FIELDA (62) | (0x01 << 22) | FIELDB (62)) 500e5cb852cSchristos #define INSN3OP_BBS(MOP,SOP) (INSN3OP (MOP,SOP) | (0x02 << 22)) 501e5cb852cSchristos #define INSN3OP_0LS(MOP,SOP) (INSN3OP (MOP,SOP) | (0x02 << 22) | FIELDB (62)) 502e5cb852cSchristos #define INSN3OP_CBBC(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22)) 503e5cb852cSchristos #define INSN3OP_CBBL(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22) | FIELDC (62)) 504e5cb852cSchristos #define INSN3OP_C0LC(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22) | FIELDB (62)) 505e5cb852cSchristos #define INSN3OP_C0LL(MOP,SOP) \ 506e5cb852cSchristos (INSN3OP (MOP,SOP) | (0x03 << 22) | FIELDC (62) | FIELDB (62)) 507e5cb852cSchristos #define INSN3OP_CBBU(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22) | (0x01 << 5)) 508e5cb852cSchristos #define INSN3OP_C0LU(MOP,SOP) \ 509e5cb852cSchristos (INSN3OP (MOP,SOP) | (0x03 << 22) | (0x01 << 5) | FIELDB (62)) 510e5cb852cSchristos 51199e23f81Schristos #define MASK_32BIT(VAL) (0xffffffff & (VAL)) 51299e23f81Schristos 51399e23f81Schristos #define MINSN3OP_ABC (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDB (63) | FIELDC (63)))) 51499e23f81Schristos #define MINSN3OP_ALC (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDC (63)))) 51599e23f81Schristos #define MINSN3OP_ABL (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDB (63)))) 51699e23f81Schristos #define MINSN3OP_ALL (MASK_32BIT (~(FIELDF | FIELDA (63)))) 51799e23f81Schristos #define MINSN3OP_0BC (MASK_32BIT (~(FIELDF | FIELDB (63) | FIELDC (63)))) 51899e23f81Schristos #define MINSN3OP_0LC (MASK_32BIT (~(FIELDF | FIELDC (63)))) 51999e23f81Schristos #define MINSN3OP_0BL (MASK_32BIT (~(FIELDF | FIELDB (63)))) 52099e23f81Schristos #define MINSN3OP_0LL (MASK_32BIT (~(FIELDF))) 52199e23f81Schristos #define MINSN3OP_ABU (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDB (63) | FIELDC (63)))) 52299e23f81Schristos #define MINSN3OP_ALU (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDC (63)))) 52399e23f81Schristos #define MINSN3OP_0BU (MASK_32BIT (~(FIELDF | FIELDB (63) | FIELDC (63)))) 52499e23f81Schristos #define MINSN3OP_0LU (MASK_32BIT (~(FIELDF | FIELDC (63)))) 52599e23f81Schristos #define MINSN3OP_BBS (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDB (63) | FIELDC (63)))) 52699e23f81Schristos #define MINSN3OP_0LS (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDC (63)))) 52799e23f81Schristos #define MINSN3OP_CBBC (MASK_32BIT (~(FIELDF | FIELDQ | FIELDB (63) | FIELDC (63)))) 52899e23f81Schristos #define MINSN3OP_CBBL (MASK_32BIT (~(FIELDF | FIELDQ | FIELDB (63)))) 52999e23f81Schristos #define MINSN3OP_C0LC (MASK_32BIT (~(FIELDF | FIELDQ | FIELDC (63)))) 53099e23f81Schristos #define MINSN3OP_C0LL (MASK_32BIT (~(FIELDF | FIELDQ))) 53199e23f81Schristos #define MINSN3OP_CBBU (MASK_32BIT (~(FIELDF | FIELDQ | FIELDB (63) | FIELDC (63)))) 53299e23f81Schristos #define MINSN3OP_C0LU (MASK_32BIT (~(FIELDF | FIELDQ | FIELDC (63)))) 533e5cb852cSchristos 534e5cb852cSchristos #define INSN2OP_BC(MOP,SOP) (INSN2OP (MOP,SOP)) 535e5cb852cSchristos #define INSN2OP_BL(MOP,SOP) (INSN2OP (MOP,SOP) | FIELDC (62)) 536e5cb852cSchristos #define INSN2OP_0C(MOP,SOP) (INSN2OP (MOP,SOP) | FIELDB (62)) 537e5cb852cSchristos #define INSN2OP_0L(MOP,SOP) (INSN2OP (MOP,SOP) | FIELDB (62) | FIELDC (62)) 538e5cb852cSchristos #define INSN2OP_BU(MOP,SOP) (INSN2OP (MOP,SOP) | (0x01 << 22)) 539e5cb852cSchristos #define INSN2OP_0U(MOP,SOP) (INSN2OP (MOP,SOP) | (0x01 << 22) | FIELDB (62)) 540e5cb852cSchristos 54199e23f81Schristos #define MINSN2OP_BC (MASK_32BIT ((~(FIELDF | FIELDB (63) | FIELDC (63))))) 54299e23f81Schristos #define MINSN2OP_BL (MASK_32BIT ((~(FIELDF | FIELDB (63))))) 54399e23f81Schristos #define MINSN2OP_0C (MASK_32BIT ((~(FIELDF | FIELDC (63))))) 54499e23f81Schristos #define MINSN2OP_0L (MASK_32BIT ((~(FIELDF)))) 54599e23f81Schristos #define MINSN2OP_BU (MASK_32BIT ((~(FIELDF | FIELDB (63) | FIELDC (63))))) 54699e23f81Schristos #define MINSN2OP_0U (MASK_32BIT ((~(FIELDF | FIELDC (63))))) 547e5cb852cSchristos 548e5cb852cSchristos /* Various constants used when defining an extension instruction. */ 549e5cb852cSchristos #define ARC_SYNTAX_3OP (1 << 0) 550e5cb852cSchristos #define ARC_SYNTAX_2OP (1 << 1) 551e5cb852cSchristos #define ARC_SYNTAX_1OP (1 << 2) 552e5cb852cSchristos #define ARC_SYNTAX_NOP (1 << 3) 553e5cb852cSchristos #define ARC_SYNTAX_MASK (0x0F) 554e5cb852cSchristos 555e5cb852cSchristos #define ARC_OP1_MUST_BE_IMM (1 << 0) 556e5cb852cSchristos #define ARC_OP1_IMM_IMPLIED (1 << 1) 557e5cb852cSchristos 558e5cb852cSchristos #define ARC_SUFFIX_NONE (1 << 0) 559e5cb852cSchristos #define ARC_SUFFIX_COND (1 << 1) 560e5cb852cSchristos #define ARC_SUFFIX_FLAG (1 << 2) 561e5cb852cSchristos 562e5cb852cSchristos #define ARC_REGISTER_READONLY (1 << 0) 563e5cb852cSchristos #define ARC_REGISTER_WRITEONLY (1 << 1) 564e5cb852cSchristos #define ARC_REGISTER_NOSHORT_CUT (1 << 2) 565e5cb852cSchristos 566e5cb852cSchristos /* Constants needed to initialize extension instructions. */ 567e5cb852cSchristos extern const unsigned char flags_none[MAX_INSN_FLGS + 1]; 568e5cb852cSchristos extern const unsigned char flags_f[MAX_INSN_FLGS + 1]; 569e5cb852cSchristos extern const unsigned char flags_cc[MAX_INSN_FLGS + 1]; 570e5cb852cSchristos extern const unsigned char flags_ccf[MAX_INSN_FLGS + 1]; 571e5cb852cSchristos 572e5cb852cSchristos extern const unsigned char arg_none[MAX_INSN_ARGS + 1]; 573e5cb852cSchristos extern const unsigned char arg_32bit_rarbrc[MAX_INSN_ARGS + 1]; 574e5cb852cSchristos extern const unsigned char arg_32bit_zarbrc[MAX_INSN_ARGS + 1]; 575e5cb852cSchristos extern const unsigned char arg_32bit_rbrbrc[MAX_INSN_ARGS + 1]; 576e5cb852cSchristos extern const unsigned char arg_32bit_rarbu6[MAX_INSN_ARGS + 1]; 577e5cb852cSchristos extern const unsigned char arg_32bit_zarbu6[MAX_INSN_ARGS + 1]; 578e5cb852cSchristos extern const unsigned char arg_32bit_rbrbu6[MAX_INSN_ARGS + 1]; 579e5cb852cSchristos extern const unsigned char arg_32bit_rbrbs12[MAX_INSN_ARGS + 1]; 580e5cb852cSchristos extern const unsigned char arg_32bit_ralimmrc[MAX_INSN_ARGS + 1]; 581e5cb852cSchristos extern const unsigned char arg_32bit_rarblimm[MAX_INSN_ARGS + 1]; 582e5cb852cSchristos extern const unsigned char arg_32bit_zalimmrc[MAX_INSN_ARGS + 1]; 583e5cb852cSchristos extern const unsigned char arg_32bit_zarblimm[MAX_INSN_ARGS + 1]; 584e5cb852cSchristos 585e5cb852cSchristos extern const unsigned char arg_32bit_rbrblimm[MAX_INSN_ARGS + 1]; 586e5cb852cSchristos extern const unsigned char arg_32bit_ralimmu6[MAX_INSN_ARGS + 1]; 587e5cb852cSchristos extern const unsigned char arg_32bit_zalimmu6[MAX_INSN_ARGS + 1]; 588e5cb852cSchristos 589e5cb852cSchristos extern const unsigned char arg_32bit_zalimms12[MAX_INSN_ARGS + 1]; 590e5cb852cSchristos extern const unsigned char arg_32bit_ralimmlimm[MAX_INSN_ARGS + 1]; 591e5cb852cSchristos extern const unsigned char arg_32bit_zalimmlimm[MAX_INSN_ARGS + 1]; 592e5cb852cSchristos 593e5cb852cSchristos extern const unsigned char arg_32bit_rbrc[MAX_INSN_ARGS + 1]; 594e5cb852cSchristos extern const unsigned char arg_32bit_zarc[MAX_INSN_ARGS + 1]; 595e5cb852cSchristos extern const unsigned char arg_32bit_rbu6[MAX_INSN_ARGS + 1]; 596e5cb852cSchristos extern const unsigned char arg_32bit_zau6[MAX_INSN_ARGS + 1]; 597e5cb852cSchristos extern const unsigned char arg_32bit_rblimm[MAX_INSN_ARGS + 1]; 598e5cb852cSchristos extern const unsigned char arg_32bit_zalimm[MAX_INSN_ARGS + 1]; 599e5cb852cSchristos 600e5cb852cSchristos extern const unsigned char arg_32bit_limmrc[MAX_INSN_ARGS + 1]; 601e5cb852cSchristos extern const unsigned char arg_32bit_limmu6[MAX_INSN_ARGS + 1]; 602e5cb852cSchristos extern const unsigned char arg_32bit_limms12[MAX_INSN_ARGS + 1]; 603e5cb852cSchristos extern const unsigned char arg_32bit_limmlimm[MAX_INSN_ARGS + 1]; 604e5cb852cSchristos 605e5cb852cSchristos extern const unsigned char arg_32bit_rc[MAX_INSN_ARGS + 1]; 606e5cb852cSchristos extern const unsigned char arg_32bit_u6[MAX_INSN_ARGS + 1]; 607e5cb852cSchristos extern const unsigned char arg_32bit_limm[MAX_INSN_ARGS + 1]; 608e5cb852cSchristos 609e5cb852cSchristos /* Address types used in the NPS-400. See page 367 of the NPS-400 CTOP 610e5cb852cSchristos Instruction Set Reference Manual v2.4 for a description of address types. */ 611e5cb852cSchristos 612e5cb852cSchristos typedef enum 613e5cb852cSchristos { 614e5cb852cSchristos /* Addresses in memory. */ 615e5cb852cSchristos 616e5cb852cSchristos /* Buffer descriptor. */ 617e5cb852cSchristos ARC_NPS400_ADDRTYPE_BD, 618e5cb852cSchristos 619e5cb852cSchristos /* Job identifier. */ 620e5cb852cSchristos ARC_NPS400_ADDRTYPE_JID, 621e5cb852cSchristos 622e5cb852cSchristos /* Linked Buffer Descriptor. */ 623e5cb852cSchristos ARC_NPS400_ADDRTYPE_LBD, 624e5cb852cSchristos 625e5cb852cSchristos /* Multicast Buffer Descriptor. */ 626e5cb852cSchristos ARC_NPS400_ADDRTYPE_MBD, 627e5cb852cSchristos 628e5cb852cSchristos /* Summarized Address. */ 629e5cb852cSchristos ARC_NPS400_ADDRTYPE_SD, 630e5cb852cSchristos 631e5cb852cSchristos /* SMEM Security Context Local Memory. */ 632e5cb852cSchristos ARC_NPS400_ADDRTYPE_SM, 633e5cb852cSchristos 634e5cb852cSchristos /* Extended Address. */ 635e5cb852cSchristos ARC_NPS400_ADDRTYPE_XA, 636e5cb852cSchristos 637e5cb852cSchristos /* Extended Summarized Address. */ 638e5cb852cSchristos ARC_NPS400_ADDRTYPE_XD, 639e5cb852cSchristos 640e5cb852cSchristos /* CMEM offset addresses. */ 641e5cb852cSchristos 642e5cb852cSchristos /* On-demand Counter Descriptor. */ 643e5cb852cSchristos ARC_NPS400_ADDRTYPE_CD, 644e5cb852cSchristos 645e5cb852cSchristos /* CMEM Buffer Descriptor. */ 646e5cb852cSchristos ARC_NPS400_ADDRTYPE_CBD, 647e5cb852cSchristos 648e5cb852cSchristos /* CMEM Job Identifier. */ 649e5cb852cSchristos ARC_NPS400_ADDRTYPE_CJID, 650e5cb852cSchristos 651e5cb852cSchristos /* CMEM Linked Buffer Descriptor. */ 652e5cb852cSchristos ARC_NPS400_ADDRTYPE_CLBD, 653e5cb852cSchristos 654e5cb852cSchristos /* CMEM Offset. */ 655e5cb852cSchristos ARC_NPS400_ADDRTYPE_CM, 656e5cb852cSchristos 657e5cb852cSchristos /* CMEM Summarized Address. */ 658e5cb852cSchristos ARC_NPS400_ADDRTYPE_CSD, 659e5cb852cSchristos 660e5cb852cSchristos /* CMEM Extended Address. */ 661e5cb852cSchristos ARC_NPS400_ADDRTYPE_CXA, 662e5cb852cSchristos 663e5cb852cSchristos /* CMEM Extended Summarized Address. */ 664e5cb852cSchristos ARC_NPS400_ADDRTYPE_CXD 665e5cb852cSchristos 666e5cb852cSchristos } arc_nps_address_type; 667e5cb852cSchristos 668e5cb852cSchristos #define ARC_NUM_ADDRTYPES 16 669e5cb852cSchristos 670e5cb852cSchristos #ifdef __cplusplus 671e5cb852cSchristos } 672e5cb852cSchristos #endif 673e5cb852cSchristos 674e5cb852cSchristos #endif /* OPCODE_ARC_H */ 675