198b9484cSchristos /* Opcode table for the ARC. 2*aab831ceSchristos Copyright (C) 1994-2024 Free Software Foundation, Inc. 3ba340e45Schristos 4ba340e45Schristos Contributed by Claudiu Zissulescu (claziss@synopsys.com) 598b9484cSchristos 698b9484cSchristos This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and 798b9484cSchristos the GNU Binutils. 898b9484cSchristos 998b9484cSchristos GAS/GDB is free software; you can redistribute it and/or modify 1098b9484cSchristos it under the terms of the GNU General Public License as published by 1198b9484cSchristos the Free Software Foundation; either version 3, or (at your option) 1298b9484cSchristos any later version. 1398b9484cSchristos 1498b9484cSchristos GAS/GDB is distributed in the hope that it will be useful, 1598b9484cSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1698b9484cSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1798b9484cSchristos GNU General Public License for more details. 1898b9484cSchristos 1998b9484cSchristos You should have received a copy of the GNU General Public License 2098b9484cSchristos along with GAS or GDB; see the file COPYING3. If not, write to 2198b9484cSchristos the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, 2298b9484cSchristos MA 02110-1301, USA. */ 2398b9484cSchristos 24ba340e45Schristos #ifndef OPCODE_ARC_H 25ba340e45Schristos #define OPCODE_ARC_H 2698b9484cSchristos 27ba340e45Schristos #ifdef __cplusplus 28ba340e45Schristos extern "C" { 29ba340e45Schristos #endif 3098b9484cSchristos 31ba340e45Schristos #ifndef MAX_INSN_ARGS 32ba340e45Schristos #define MAX_INSN_ARGS 16 33ba340e45Schristos #endif 3498b9484cSchristos 35ba340e45Schristos #ifndef MAX_INSN_FLGS 364559860eSchristos #define MAX_INSN_FLGS 4 37ba340e45Schristos #endif 3898b9484cSchristos 39ba340e45Schristos /* Instruction Class. */ 40ba340e45Schristos typedef enum 41ba340e45Schristos { 42ba340e45Schristos ACL, 43ba340e45Schristos ARITH, 44ba340e45Schristos AUXREG, 45796c32c9Schristos BBIT0, 46796c32c9Schristos BBIT1, 47796c32c9Schristos BI, 48796c32c9Schristos BIH, 49ba340e45Schristos BITOP, 50796c32c9Schristos BITSTREAM, 51ba340e45Schristos BMU, 52ba340e45Schristos BRANCH, 53796c32c9Schristos BRCC, 54ba340e45Schristos CONTROL, 55*aab831ceSchristos DBNZ, 56796c32c9Schristos DIVREM, 57796c32c9Schristos DMA, 58ba340e45Schristos DPI, 59ba340e45Schristos DSP, 60796c32c9Schristos EI, 61796c32c9Schristos ENTER, 62ba340e45Schristos FLOAT, 63ba340e45Schristos INVALID, 64796c32c9Schristos JLI, 65ba340e45Schristos JUMP, 66ba340e45Schristos KERNEL, 67796c32c9Schristos LEAVE, 688dffb485Schristos LLOCK, 69796c32c9Schristos LOAD, 70ba340e45Schristos LOGICAL, 71796c32c9Schristos LOOP, 72ba340e45Schristos MEMORY, 73796c32c9Schristos MISC, 74796c32c9Schristos MOVE, 75796c32c9Schristos MPY, 76ba340e45Schristos NET, 77796c32c9Schristos PROTOCOL_DECODE, 78796c32c9Schristos PMU, 79796c32c9Schristos POP, 80796c32c9Schristos PUSH, 818dffb485Schristos SCOND, 824559860eSchristos SJLI, 83796c32c9Schristos STORE, 84796c32c9Schristos SUB, 858dffb485Schristos SWITCH, 86796c32c9Schristos ULTRAIP, 87796c32c9Schristos XY 88ba340e45Schristos } insn_class_t; 8998b9484cSchristos 90ba340e45Schristos /* Instruction Subclass. */ 91ba340e45Schristos typedef enum 92ba340e45Schristos { 934559860eSchristos NONE = 0, 944559860eSchristos CVT = (1U << 1), 954559860eSchristos BTSCN = (1U << 2), 964559860eSchristos CD = (1U << 3), 974559860eSchristos CD1 = CD, 984559860eSchristos CD2 = CD, 994559860eSchristos COND = (1U << 4), 1004559860eSchristos DIV = (1U << 5), 1014559860eSchristos DP = (1U << 6), 1024559860eSchristos DPA = (1U << 7), 1034559860eSchristos DPX = (1U << 8), 1048dffb485Schristos FASTMATH = (1U << 23), 1054559860eSchristos LL64 = (1U << 9), 1064559860eSchristos MPY1E = (1U << 10), 1074559860eSchristos MPY6E = (1U << 11), 1084559860eSchristos MPY7E = (1U << 12), 1094559860eSchristos MPY8E = (1U << 13), 1104559860eSchristos MPY9E = (1U << 14), 1114559860eSchristos NPS400 = (1U << 15), 1124559860eSchristos QUARKSE1 = (1U << 16), 1134559860eSchristos QUARKSE2 = (1U << 17), 1144559860eSchristos SHFT1 = (1U << 18), 1154559860eSchristos SHFT2 = (1U << 19), 1164559860eSchristos SWAP = (1U << 20), 1174559860eSchristos SP = (1U << 21), 1184559860eSchristos SPX = (1U << 22) 119ba340e45Schristos } insn_subclass_t; 12098b9484cSchristos 121ba340e45Schristos /* Flags class. */ 122ba340e45Schristos typedef enum 123ba340e45Schristos { 124ba340e45Schristos F_CLASS_NONE = 0, 12598b9484cSchristos 126ba340e45Schristos /* At most one flag from the set of flags can appear in the 127ba340e45Schristos instruction. */ 128ba340e45Schristos F_CLASS_OPTIONAL = (1 << 0), 12998b9484cSchristos 130ba340e45Schristos /* Exactly one from from the set of flags must appear in the 131ba340e45Schristos instruction. */ 132ba340e45Schristos F_CLASS_REQUIRED = (1 << 1), 13398b9484cSchristos 134ba340e45Schristos /* The conditional code can be extended over the standard variants 135ba340e45Schristos via .extCondCode pseudo-op. */ 136ba340e45Schristos F_CLASS_EXTEND = (1 << 2), 13798b9484cSchristos 138ba340e45Schristos /* Condition code flag. */ 139796c32c9Schristos F_CLASS_COND = (1 << 3), 140796c32c9Schristos 141796c32c9Schristos /* Write back mode. */ 142796c32c9Schristos F_CLASS_WB = (1 << 4), 143796c32c9Schristos 144796c32c9Schristos /* Data size. */ 145796c32c9Schristos F_CLASS_ZZ = (1 << 5), 146796c32c9Schristos 147796c32c9Schristos /* Implicit flag. */ 148796c32c9Schristos F_CLASS_IMPLICIT = (1 << 6) 149ba340e45Schristos } flag_class_t; 15098b9484cSchristos 151ba340e45Schristos /* The opcode table is an array of struct arc_opcode. */ 152ba340e45Schristos struct arc_opcode 153ba340e45Schristos { 154ba340e45Schristos /* The opcode name. */ 155ba340e45Schristos const char * name; 15698b9484cSchristos 157ba340e45Schristos /* The opcode itself. Those bits which will be filled in with 158ba340e45Schristos operands are zeroes. */ 159796c32c9Schristos unsigned long long opcode; 16098b9484cSchristos 161ba340e45Schristos /* The opcode mask. This is used by the disassembler. This is a 162ba340e45Schristos mask containing ones indicating those bits which must match the 163ba340e45Schristos opcode field, and zeroes indicating those bits which need not 164ba340e45Schristos match (and are presumably filled in by operands). */ 165796c32c9Schristos unsigned long long mask; 16698b9484cSchristos 167ba340e45Schristos /* One bit flags for the opcode. These are primarily used to 168ba340e45Schristos indicate specific processors and environments support the 169ba340e45Schristos instructions. The defined values are listed below. */ 170ba340e45Schristos unsigned cpu; 17198b9484cSchristos 172ba340e45Schristos /* The instruction class. This is used by gdb. */ 173ba340e45Schristos insn_class_t insn_class; 17498b9484cSchristos 175ba340e45Schristos /* The instruction subclass. */ 176ba340e45Schristos insn_subclass_t subclass; 17798b9484cSchristos 178ba340e45Schristos /* An array of operand codes. Each code is an index into the 179ba340e45Schristos operand table. They appear in the order which the operands must 180ba340e45Schristos appear in assembly code, and are terminated by a zero. */ 181ba340e45Schristos unsigned char operands[MAX_INSN_ARGS + 1]; 182ba340e45Schristos 183ba340e45Schristos /* An array of flag codes. Each code is an index into the flag 184ba340e45Schristos table. They appear in the order which the flags must appear in 185ba340e45Schristos assembly code, and are terminated by a zero. */ 186ba340e45Schristos unsigned char flags[MAX_INSN_FLGS + 1]; 18798b9484cSchristos }; 18898b9484cSchristos 189ba340e45Schristos /* The table itself is sorted by major opcode number, and is otherwise 190ba340e45Schristos in the order in which the disassembler should consider 191ba340e45Schristos instructions. */ 192ba340e45Schristos extern const struct arc_opcode arc_opcodes[]; 19398b9484cSchristos 194796c32c9Schristos /* Return length of an instruction represented by OPCODE, in bytes. */ 195796c32c9Schristos extern int arc_opcode_len (const struct arc_opcode *opcode); 196796c32c9Schristos 197ba340e45Schristos /* CPU Availability. */ 198ba340e45Schristos #define ARC_OPCODE_NONE 0x0000 199ba340e45Schristos #define ARC_OPCODE_ARC600 0x0001 /* ARC 600 specific insns. */ 200ba340e45Schristos #define ARC_OPCODE_ARC700 0x0002 /* ARC 700 specific insns. */ 201ba340e45Schristos #define ARC_OPCODE_ARCv2EM 0x0004 /* ARCv2 EM specific insns. */ 202ba340e45Schristos #define ARC_OPCODE_ARCv2HS 0x0008 /* ARCv2 HS specific insns. */ 20398b9484cSchristos 204ba340e45Schristos /* CPU combi. */ 205ba340e45Schristos #define ARC_OPCODE_ARCALL (ARC_OPCODE_ARC600 | ARC_OPCODE_ARC700 \ 206ba340e45Schristos | ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS) 207ba340e45Schristos #define ARC_OPCODE_ARCFPX (ARC_OPCODE_ARC700 | ARC_OPCODE_ARCv2EM) 2084559860eSchristos #define ARC_OPCODE_ARCV1 (ARC_OPCODE_ARC600 | ARC_OPCODE_ARC700) 209796c32c9Schristos #define ARC_OPCODE_ARCV2 (ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS) 2104559860eSchristos #define ARC_OPCODE_ARCMPY6E (ARC_OPCODE_ARC700 | ARC_OPCODE_ARCV2) 21198b9484cSchristos 212ba340e45Schristos /* The operands table is an array of struct arc_operand. */ 213ba340e45Schristos struct arc_operand 214ba340e45Schristos { 215ba340e45Schristos /* The number of bits in the operand. */ 216ba340e45Schristos unsigned int bits; 21798b9484cSchristos 218ba340e45Schristos /* How far the operand is left shifted in the instruction. */ 219ba340e45Schristos unsigned int shift; 22098b9484cSchristos 221ba340e45Schristos /* The default relocation type for this operand. */ 222ba340e45Schristos signed int default_reloc; 22398b9484cSchristos 224ba340e45Schristos /* One bit syntax flags. */ 225ba340e45Schristos unsigned int flags; 22698b9484cSchristos 22798b9484cSchristos /* Insertion function. This is used by the assembler. To insert an 22898b9484cSchristos operand value into an instruction, check this field. 22998b9484cSchristos 23098b9484cSchristos If it is NULL, execute 231ba340e45Schristos i |= (op & ((1 << o->bits) - 1)) << o->shift; 232ba340e45Schristos (i is the instruction which we are filling in, o is a pointer to 233ba340e45Schristos this structure, and op is the opcode value; this assumes twos 23498b9484cSchristos complement arithmetic). 23598b9484cSchristos 23698b9484cSchristos If this field is not NULL, then simply call it with the 23798b9484cSchristos instruction and the operand value. It will return the new value 23898b9484cSchristos of the instruction. If the ERRMSG argument is not NULL, then if 23998b9484cSchristos the operand value is illegal, *ERRMSG will be set to a warning 24098b9484cSchristos string (the operand will be inserted in any case). If the 241ba340e45Schristos operand value is legal, *ERRMSG will be unchanged (most operands 242ba340e45Schristos can accept any value). */ 243796c32c9Schristos unsigned long long (*insert) (unsigned long long instruction, 244796c32c9Schristos long long int op, 245796c32c9Schristos const char **errmsg); 24698b9484cSchristos 24798b9484cSchristos /* Extraction function. This is used by the disassembler. To 24898b9484cSchristos extract this operand type from an instruction, check this field. 24998b9484cSchristos 25098b9484cSchristos If it is NULL, compute 25198b9484cSchristos op = ((i) >> o->shift) & ((1 << o->bits) - 1); 25298b9484cSchristos if ((o->flags & ARC_OPERAND_SIGNED) != 0 25398b9484cSchristos && (op & (1 << (o->bits - 1))) != 0) 25498b9484cSchristos op -= 1 << o->bits; 255ba340e45Schristos (i is the instruction, o is a pointer to this structure, and op 25698b9484cSchristos is the result; this assumes twos complement arithmetic). 25798b9484cSchristos 25898b9484cSchristos If this field is not NULL, then simply call it with the 25998b9484cSchristos instruction value. It will return the value of the operand. If 26098b9484cSchristos the INVALID argument is not NULL, *INVALID will be set to 261ba340e45Schristos TRUE if this operand type can not actually be extracted from 26298b9484cSchristos this operand (i.e., the instruction does not match). If the 263ba340e45Schristos operand is valid, *INVALID will not be changed. */ 2644b169a6bSchristos long long int (*extract) (unsigned long long instruction, bool *invalid); 26598b9484cSchristos }; 26698b9484cSchristos 267ba340e45Schristos /* Elements in the table are retrieved by indexing with values from 268ba340e45Schristos the operands field of the arc_opcodes table. */ 26998b9484cSchristos extern const struct arc_operand arc_operands[]; 270ba340e45Schristos extern const unsigned arc_num_operands; 271ba340e45Schristos extern const unsigned arc_Toperand; 272ba340e45Schristos extern const unsigned arc_NToperand; 27398b9484cSchristos 274ba340e45Schristos /* Values defined for the flags field of a struct arc_operand. */ 27598b9484cSchristos 276ba340e45Schristos /* This operand does not actually exist in the assembler input. This 277ba340e45Schristos is used to support extended mnemonics, for which two operands fields 278ba340e45Schristos are identical. The assembler should call the insert function with 279ba340e45Schristos any op value. The disassembler should call the extract function, 280ba340e45Schristos ignore the return value, and check the value placed in the invalid 281ba340e45Schristos argument. */ 282ba340e45Schristos #define ARC_OPERAND_FAKE 0x0001 283ba340e45Schristos 284ba340e45Schristos /* This operand names an integer register. */ 285ba340e45Schristos #define ARC_OPERAND_IR 0x0002 286ba340e45Schristos 287ba340e45Schristos /* This operand takes signed values. */ 288ba340e45Schristos #define ARC_OPERAND_SIGNED 0x0004 289ba340e45Schristos 290ba340e45Schristos /* This operand takes unsigned values. This exists primarily so that 291ba340e45Schristos a flags value of 0 can be treated as end-of-arguments. */ 292ba340e45Schristos #define ARC_OPERAND_UNSIGNED 0x0008 293ba340e45Schristos 294ba340e45Schristos /* This operand takes long immediate values. */ 295ba340e45Schristos #define ARC_OPERAND_LIMM 0x0010 296ba340e45Schristos 297ba340e45Schristos /* This operand is identical like the previous one. */ 298ba340e45Schristos #define ARC_OPERAND_DUPLICATE 0x0020 299ba340e45Schristos 300ba340e45Schristos /* This operand is PC relative. Used for internal relocs. */ 301ba340e45Schristos #define ARC_OPERAND_PCREL 0x0040 302ba340e45Schristos 303ba340e45Schristos /* This operand is truncated. The truncation is done accordingly to 304ba340e45Schristos operand alignment attribute. */ 305ba340e45Schristos #define ARC_OPERAND_TRUNCATE 0x0080 306ba340e45Schristos 307ba340e45Schristos /* This operand is 16bit aligned. */ 308ba340e45Schristos #define ARC_OPERAND_ALIGNED16 0x0100 309ba340e45Schristos 310ba340e45Schristos /* This operand is 32bit aligned. */ 311ba340e45Schristos #define ARC_OPERAND_ALIGNED32 0x0200 312ba340e45Schristos 313ba340e45Schristos /* This operand can be ignored by matching process if it is not 314ba340e45Schristos present. */ 315ba340e45Schristos #define ARC_OPERAND_IGNORE 0x0400 316ba340e45Schristos 317ba340e45Schristos /* Don't check the range when matching. */ 318ba340e45Schristos #define ARC_OPERAND_NCHK 0x0800 319ba340e45Schristos 320ba340e45Schristos /* Mark the braket possition. */ 321ba340e45Schristos #define ARC_OPERAND_BRAKET 0x1000 322ba340e45Schristos 323ba340e45Schristos /* Address type operand for NPS400. */ 324ba340e45Schristos #define ARC_OPERAND_ADDRTYPE 0x2000 325ba340e45Schristos 326ba340e45Schristos /* Mark the colon position. */ 327ba340e45Schristos #define ARC_OPERAND_COLON 0x4000 328ba340e45Schristos 329ba340e45Schristos /* Mask for selecting the type for typecheck purposes. */ 330ba340e45Schristos #define ARC_OPERAND_TYPECHECK_MASK \ 331ba340e45Schristos (ARC_OPERAND_IR \ 332ba340e45Schristos | ARC_OPERAND_LIMM | ARC_OPERAND_SIGNED \ 333ba340e45Schristos | ARC_OPERAND_UNSIGNED | ARC_OPERAND_BRAKET \ 334ba340e45Schristos | ARC_OPERAND_ADDRTYPE | ARC_OPERAND_COLON) 335ba340e45Schristos 336ba340e45Schristos /* Macro to determine if an operand is a fake operand. */ 337ba340e45Schristos #define ARC_OPERAND_IS_FAKE(op) \ 338ba340e45Schristos ((operand->flags & ARC_OPERAND_FAKE) \ 339ba340e45Schristos && !((operand->flags & ARC_OPERAND_BRAKET) \ 340ba340e45Schristos || (operand->flags & ARC_OPERAND_COLON))) 341ba340e45Schristos 342ba340e45Schristos /* The flags structure. */ 343ba340e45Schristos struct arc_flag_operand 344ba340e45Schristos { 345ba340e45Schristos /* The flag name. */ 346ba340e45Schristos const char * name; 347ba340e45Schristos 348ba340e45Schristos /* The flag code. */ 349ba340e45Schristos unsigned code; 350ba340e45Schristos 351ba340e45Schristos /* The number of bits in the operand. */ 352ba340e45Schristos unsigned int bits; 353ba340e45Schristos 354ba340e45Schristos /* How far the operand is left shifted in the instruction. */ 355ba340e45Schristos unsigned int shift; 356ba340e45Schristos 357ba340e45Schristos /* Available for disassembler. */ 358ba340e45Schristos unsigned char favail; 359ba340e45Schristos }; 360ba340e45Schristos 361ba340e45Schristos /* The flag operands table. */ 362ba340e45Schristos extern const struct arc_flag_operand arc_flag_operands[]; 363ba340e45Schristos extern const unsigned arc_num_flag_operands; 364ba340e45Schristos 365ba340e45Schristos /* The flag's class structure. */ 366ba340e45Schristos struct arc_flag_class 367ba340e45Schristos { 368ba340e45Schristos /* Flag class. */ 369ba340e45Schristos flag_class_t flag_class; 370ba340e45Schristos 371ba340e45Schristos /* List of valid flags (codes). */ 372ba340e45Schristos unsigned flags[256]; 373ba340e45Schristos }; 374ba340e45Schristos 375ba340e45Schristos extern const struct arc_flag_class arc_flag_classes[]; 376ba340e45Schristos 377ba340e45Schristos /* Structure for special cases. */ 378ba340e45Schristos struct arc_flag_special 379ba340e45Schristos { 380ba340e45Schristos /* Name of special case instruction. */ 381ba340e45Schristos const char *name; 382ba340e45Schristos 383ba340e45Schristos /* List of flags applicable for special case instruction. */ 384ba340e45Schristos unsigned flags[32]; 385ba340e45Schristos }; 386ba340e45Schristos 387ba340e45Schristos extern const struct arc_flag_special arc_flag_special_cases[]; 388ba340e45Schristos extern const unsigned arc_num_flag_special; 389ba340e45Schristos 390ba340e45Schristos /* Relocation equivalence structure. */ 391ba340e45Schristos struct arc_reloc_equiv_tab 392ba340e45Schristos { 393ba340e45Schristos const char * name; /* String to lookup. */ 394ba340e45Schristos const char * mnemonic; /* Extra matching condition. */ 395ba340e45Schristos unsigned flags[32]; /* Extra matching condition. */ 396ba340e45Schristos signed int oldreloc; /* Old relocation. */ 397ba340e45Schristos signed int newreloc; /* New relocation. */ 398ba340e45Schristos }; 399ba340e45Schristos 400ba340e45Schristos extern const struct arc_reloc_equiv_tab arc_reloc_equiv[]; 401ba340e45Schristos extern const unsigned arc_num_equiv_tab; 402ba340e45Schristos 403ba340e45Schristos /* Structure for operand operations for pseudo/alias instructions. */ 404ba340e45Schristos struct arc_operand_operation 405ba340e45Schristos { 406ba340e45Schristos /* The index for operand from operand array. */ 407ba340e45Schristos unsigned operand_idx; 408ba340e45Schristos 409ba340e45Schristos /* Defines if it needs the operand inserted by the assembler or 410ba340e45Schristos whether this operand comes from the pseudo instruction's 411ba340e45Schristos operands. */ 412ba340e45Schristos unsigned char needs_insert; 413ba340e45Schristos 414ba340e45Schristos /* Count we have to add to the operand. Use negative number to 415ba340e45Schristos subtract from the operand. Also use this number to add to 0 if 416ba340e45Schristos the operand needs to be inserted (i.e. needs_insert == 1). */ 417ba340e45Schristos int count; 418ba340e45Schristos 419ba340e45Schristos /* Index of the operand to swap with. To be done AFTER applying 420ba340e45Schristos inc_count. */ 421ba340e45Schristos unsigned swap_operand_idx; 422ba340e45Schristos }; 423ba340e45Schristos 424ba340e45Schristos /* Structure for pseudo/alias instructions. */ 425ba340e45Schristos struct arc_pseudo_insn 426ba340e45Schristos { 427ba340e45Schristos /* Mnemonic for pseudo/alias insn. */ 428ba340e45Schristos const char * mnemonic_p; 429ba340e45Schristos 430ba340e45Schristos /* Mnemonic for real instruction. */ 431ba340e45Schristos const char * mnemonic_r; 432ba340e45Schristos 433ba340e45Schristos /* Flag that will have to be added (if any). */ 434ba340e45Schristos const char * flag_r; 435ba340e45Schristos 436ba340e45Schristos /* Amount of operands. */ 437ba340e45Schristos unsigned operand_cnt; 438ba340e45Schristos 439ba340e45Schristos /* Array of operand operations. */ 440ba340e45Schristos struct arc_operand_operation operand[6]; 441ba340e45Schristos }; 442ba340e45Schristos 443ba340e45Schristos extern const struct arc_pseudo_insn arc_pseudo_insns[]; 444ba340e45Schristos extern const unsigned arc_num_pseudo_insn; 445ba340e45Schristos 446ba340e45Schristos /* Structure for AUXILIARY registers. */ 447ba340e45Schristos struct arc_aux_reg 448ba340e45Schristos { 449ba340e45Schristos /* Register address. */ 450ba340e45Schristos int address; 451ba340e45Schristos 452ba340e45Schristos /* One bit flags for the opcode. These are primarily used to 453ba340e45Schristos indicate specific processors and environments support the 454ba340e45Schristos instructions. */ 455ba340e45Schristos unsigned cpu; 456ba340e45Schristos 457ba340e45Schristos /* AUX register subclass. */ 458ba340e45Schristos insn_subclass_t subclass; 459ba340e45Schristos 460ba340e45Schristos /* Register name. */ 461ba340e45Schristos const char * name; 462ba340e45Schristos 463ba340e45Schristos /* Size of the string. */ 464ba340e45Schristos size_t length; 465ba340e45Schristos }; 466ba340e45Schristos 467ba340e45Schristos extern const struct arc_aux_reg arc_aux_regs[]; 468ba340e45Schristos extern const unsigned arc_num_aux_regs; 469ba340e45Schristos 470ba340e45Schristos extern const struct arc_opcode arc_relax_opcodes[]; 471ba340e45Schristos extern const unsigned arc_num_relax_opcodes; 472ba340e45Schristos 473ba340e45Schristos /* Macro used for generating one class of NPS instructions. */ 474ba340e45Schristos #define NPS_CMEM_HIGH_VALUE 0x57f0 475ba340e45Schristos 476ba340e45Schristos /* Macros to help generating regular pattern instructions. */ 477ba340e45Schristos #define FIELDA(word) (word & 0x3F) 478ba340e45Schristos #define FIELDB(word) (((word & 0x07) << 24) | (((word >> 3) & 0x07) << 12)) 479ba340e45Schristos #define FIELDC(word) ((word & 0x3F) << 6) 480ba340e45Schristos #define FIELDF (0x01 << 15) 481ba340e45Schristos #define FIELDQ (0x1F) 482ba340e45Schristos 483ba340e45Schristos #define INSN3OP(MOP,SOP) (((MOP & 0x1F) << 27) | ((SOP & 0x3F) << 16)) 484ba340e45Schristos #define INSN2OPX(MOP,SOP1,SOP2) (INSN3OP (MOP,SOP1) | (SOP2 & 0x3F)) 485ba340e45Schristos #define INSN2OP(MOP,SOP) (INSN2OPX (MOP,0x2F,SOP)) 486ba340e45Schristos 487ba340e45Schristos #define INSN3OP_ABC(MOP,SOP) (INSN3OP (MOP,SOP)) 488ba340e45Schristos #define INSN3OP_ALC(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDB (62)) 489ba340e45Schristos #define INSN3OP_ABL(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDC (62)) 490ba340e45Schristos #define INSN3OP_ALL(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDB (62) | FIELDC (62)) 491ba340e45Schristos #define INSN3OP_0BC(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62)) 492ba340e45Schristos #define INSN3OP_0LC(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62) | FIELDB (62)) 493ba340e45Schristos #define INSN3OP_0BL(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62) | FIELDC (62)) 494ba340e45Schristos #define INSN3OP_0LL(MOP,SOP) \ 495ba340e45Schristos (INSN3OP (MOP,SOP) | FIELDA (62) | FIELDB (62) | FIELDC (62)) 496ba340e45Schristos #define INSN3OP_ABU(MOP,SOP) (INSN3OP (MOP,SOP) | (0x01 << 22)) 497ba340e45Schristos #define INSN3OP_ALU(MOP,SOP) (INSN3OP (MOP,SOP) | (0x01 << 22) | FIELDB (62)) 498ba340e45Schristos #define INSN3OP_0BU(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62) | (0x01 << 22)) 499ba340e45Schristos #define INSN3OP_0LU(MOP,SOP) \ 500ba340e45Schristos (INSN3OP (MOP,SOP) | FIELDA (62) | (0x01 << 22) | FIELDB (62)) 501ba340e45Schristos #define INSN3OP_BBS(MOP,SOP) (INSN3OP (MOP,SOP) | (0x02 << 22)) 502ba340e45Schristos #define INSN3OP_0LS(MOP,SOP) (INSN3OP (MOP,SOP) | (0x02 << 22) | FIELDB (62)) 503ba340e45Schristos #define INSN3OP_CBBC(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22)) 504ba340e45Schristos #define INSN3OP_CBBL(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22) | FIELDC (62)) 505ba340e45Schristos #define INSN3OP_C0LC(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22) | FIELDB (62)) 506ba340e45Schristos #define INSN3OP_C0LL(MOP,SOP) \ 507ba340e45Schristos (INSN3OP (MOP,SOP) | (0x03 << 22) | FIELDC (62) | FIELDB (62)) 508ba340e45Schristos #define INSN3OP_CBBU(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22) | (0x01 << 5)) 509ba340e45Schristos #define INSN3OP_C0LU(MOP,SOP) \ 510ba340e45Schristos (INSN3OP (MOP,SOP) | (0x03 << 22) | (0x01 << 5) | FIELDB (62)) 511ba340e45Schristos 512796c32c9Schristos #define MASK_32BIT(VAL) (0xffffffff & (VAL)) 513796c32c9Schristos 514796c32c9Schristos #define MINSN3OP_ABC (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDB (63) | FIELDC (63)))) 515796c32c9Schristos #define MINSN3OP_ALC (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDC (63)))) 516796c32c9Schristos #define MINSN3OP_ABL (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDB (63)))) 517796c32c9Schristos #define MINSN3OP_ALL (MASK_32BIT (~(FIELDF | FIELDA (63)))) 518796c32c9Schristos #define MINSN3OP_0BC (MASK_32BIT (~(FIELDF | FIELDB (63) | FIELDC (63)))) 519796c32c9Schristos #define MINSN3OP_0LC (MASK_32BIT (~(FIELDF | FIELDC (63)))) 520796c32c9Schristos #define MINSN3OP_0BL (MASK_32BIT (~(FIELDF | FIELDB (63)))) 521796c32c9Schristos #define MINSN3OP_0LL (MASK_32BIT (~(FIELDF))) 522796c32c9Schristos #define MINSN3OP_ABU (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDB (63) | FIELDC (63)))) 523796c32c9Schristos #define MINSN3OP_ALU (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDC (63)))) 524796c32c9Schristos #define MINSN3OP_0BU (MASK_32BIT (~(FIELDF | FIELDB (63) | FIELDC (63)))) 525796c32c9Schristos #define MINSN3OP_0LU (MASK_32BIT (~(FIELDF | FIELDC (63)))) 526796c32c9Schristos #define MINSN3OP_BBS (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDB (63) | FIELDC (63)))) 527796c32c9Schristos #define MINSN3OP_0LS (MASK_32BIT (~(FIELDF | FIELDA (63) | FIELDC (63)))) 528796c32c9Schristos #define MINSN3OP_CBBC (MASK_32BIT (~(FIELDF | FIELDQ | FIELDB (63) | FIELDC (63)))) 529796c32c9Schristos #define MINSN3OP_CBBL (MASK_32BIT (~(FIELDF | FIELDQ | FIELDB (63)))) 530796c32c9Schristos #define MINSN3OP_C0LC (MASK_32BIT (~(FIELDF | FIELDQ | FIELDC (63)))) 531796c32c9Schristos #define MINSN3OP_C0LL (MASK_32BIT (~(FIELDF | FIELDQ))) 532796c32c9Schristos #define MINSN3OP_CBBU (MASK_32BIT (~(FIELDF | FIELDQ | FIELDB (63) | FIELDC (63)))) 533796c32c9Schristos #define MINSN3OP_C0LU (MASK_32BIT (~(FIELDF | FIELDQ | FIELDC (63)))) 534ba340e45Schristos 535ba340e45Schristos #define INSN2OP_BC(MOP,SOP) (INSN2OP (MOP,SOP)) 536ba340e45Schristos #define INSN2OP_BL(MOP,SOP) (INSN2OP (MOP,SOP) | FIELDC (62)) 537ba340e45Schristos #define INSN2OP_0C(MOP,SOP) (INSN2OP (MOP,SOP) | FIELDB (62)) 538ba340e45Schristos #define INSN2OP_0L(MOP,SOP) (INSN2OP (MOP,SOP) | FIELDB (62) | FIELDC (62)) 539ba340e45Schristos #define INSN2OP_BU(MOP,SOP) (INSN2OP (MOP,SOP) | (0x01 << 22)) 540ba340e45Schristos #define INSN2OP_0U(MOP,SOP) (INSN2OP (MOP,SOP) | (0x01 << 22) | FIELDB (62)) 541ba340e45Schristos 542796c32c9Schristos #define MINSN2OP_BC (MASK_32BIT ((~(FIELDF | FIELDB (63) | FIELDC (63))))) 543796c32c9Schristos #define MINSN2OP_BL (MASK_32BIT ((~(FIELDF | FIELDB (63))))) 544796c32c9Schristos #define MINSN2OP_0C (MASK_32BIT ((~(FIELDF | FIELDC (63))))) 545796c32c9Schristos #define MINSN2OP_0L (MASK_32BIT ((~(FIELDF)))) 546796c32c9Schristos #define MINSN2OP_BU (MASK_32BIT ((~(FIELDF | FIELDB (63) | FIELDC (63))))) 547796c32c9Schristos #define MINSN2OP_0U (MASK_32BIT ((~(FIELDF | FIELDC (63))))) 548ba340e45Schristos 549ba340e45Schristos /* Various constants used when defining an extension instruction. */ 550ba340e45Schristos #define ARC_SYNTAX_3OP (1 << 0) 551ba340e45Schristos #define ARC_SYNTAX_2OP (1 << 1) 552ba340e45Schristos #define ARC_SYNTAX_1OP (1 << 2) 553ba340e45Schristos #define ARC_SYNTAX_NOP (1 << 3) 554ba340e45Schristos #define ARC_SYNTAX_MASK (0x0F) 555ba340e45Schristos 556ba340e45Schristos #define ARC_OP1_MUST_BE_IMM (1 << 0) 557ba340e45Schristos #define ARC_OP1_IMM_IMPLIED (1 << 1) 558ba340e45Schristos 559ba340e45Schristos #define ARC_SUFFIX_NONE (1 << 0) 560ba340e45Schristos #define ARC_SUFFIX_COND (1 << 1) 561ba340e45Schristos #define ARC_SUFFIX_FLAG (1 << 2) 562ba340e45Schristos 563ba340e45Schristos #define ARC_REGISTER_READONLY (1 << 0) 564ba340e45Schristos #define ARC_REGISTER_WRITEONLY (1 << 1) 565ba340e45Schristos #define ARC_REGISTER_NOSHORT_CUT (1 << 2) 566ba340e45Schristos 567ba340e45Schristos /* Constants needed to initialize extension instructions. */ 568ba340e45Schristos extern const unsigned char flags_none[MAX_INSN_FLGS + 1]; 569ba340e45Schristos extern const unsigned char flags_f[MAX_INSN_FLGS + 1]; 570ba340e45Schristos extern const unsigned char flags_cc[MAX_INSN_FLGS + 1]; 571ba340e45Schristos extern const unsigned char flags_ccf[MAX_INSN_FLGS + 1]; 572ba340e45Schristos 573ba340e45Schristos extern const unsigned char arg_none[MAX_INSN_ARGS + 1]; 574ba340e45Schristos extern const unsigned char arg_32bit_rarbrc[MAX_INSN_ARGS + 1]; 575ba340e45Schristos extern const unsigned char arg_32bit_zarbrc[MAX_INSN_ARGS + 1]; 576ba340e45Schristos extern const unsigned char arg_32bit_rbrbrc[MAX_INSN_ARGS + 1]; 577ba340e45Schristos extern const unsigned char arg_32bit_rarbu6[MAX_INSN_ARGS + 1]; 578ba340e45Schristos extern const unsigned char arg_32bit_zarbu6[MAX_INSN_ARGS + 1]; 579ba340e45Schristos extern const unsigned char arg_32bit_rbrbu6[MAX_INSN_ARGS + 1]; 580ba340e45Schristos extern const unsigned char arg_32bit_rbrbs12[MAX_INSN_ARGS + 1]; 581ba340e45Schristos extern const unsigned char arg_32bit_ralimmrc[MAX_INSN_ARGS + 1]; 582ba340e45Schristos extern const unsigned char arg_32bit_rarblimm[MAX_INSN_ARGS + 1]; 583ba340e45Schristos extern const unsigned char arg_32bit_zalimmrc[MAX_INSN_ARGS + 1]; 584ba340e45Schristos extern const unsigned char arg_32bit_zarblimm[MAX_INSN_ARGS + 1]; 585ba340e45Schristos 586ba340e45Schristos extern const unsigned char arg_32bit_rbrblimm[MAX_INSN_ARGS + 1]; 587ba340e45Schristos extern const unsigned char arg_32bit_ralimmu6[MAX_INSN_ARGS + 1]; 588ba340e45Schristos extern const unsigned char arg_32bit_zalimmu6[MAX_INSN_ARGS + 1]; 589ba340e45Schristos 590ba340e45Schristos extern const unsigned char arg_32bit_zalimms12[MAX_INSN_ARGS + 1]; 591ba340e45Schristos extern const unsigned char arg_32bit_ralimmlimm[MAX_INSN_ARGS + 1]; 592ba340e45Schristos extern const unsigned char arg_32bit_zalimmlimm[MAX_INSN_ARGS + 1]; 593ba340e45Schristos 594ba340e45Schristos extern const unsigned char arg_32bit_rbrc[MAX_INSN_ARGS + 1]; 595ba340e45Schristos extern const unsigned char arg_32bit_zarc[MAX_INSN_ARGS + 1]; 596ba340e45Schristos extern const unsigned char arg_32bit_rbu6[MAX_INSN_ARGS + 1]; 597ba340e45Schristos extern const unsigned char arg_32bit_zau6[MAX_INSN_ARGS + 1]; 598ba340e45Schristos extern const unsigned char arg_32bit_rblimm[MAX_INSN_ARGS + 1]; 599ba340e45Schristos extern const unsigned char arg_32bit_zalimm[MAX_INSN_ARGS + 1]; 600ba340e45Schristos 601ba340e45Schristos extern const unsigned char arg_32bit_limmrc[MAX_INSN_ARGS + 1]; 602ba340e45Schristos extern const unsigned char arg_32bit_limmu6[MAX_INSN_ARGS + 1]; 603ba340e45Schristos extern const unsigned char arg_32bit_limms12[MAX_INSN_ARGS + 1]; 604ba340e45Schristos extern const unsigned char arg_32bit_limmlimm[MAX_INSN_ARGS + 1]; 605ba340e45Schristos 606ba340e45Schristos extern const unsigned char arg_32bit_rc[MAX_INSN_ARGS + 1]; 607ba340e45Schristos extern const unsigned char arg_32bit_u6[MAX_INSN_ARGS + 1]; 608ba340e45Schristos extern const unsigned char arg_32bit_limm[MAX_INSN_ARGS + 1]; 609ba340e45Schristos 610ba340e45Schristos /* Address types used in the NPS-400. See page 367 of the NPS-400 CTOP 611ba340e45Schristos Instruction Set Reference Manual v2.4 for a description of address types. */ 612ba340e45Schristos 613ba340e45Schristos typedef enum 614ba340e45Schristos { 615ba340e45Schristos /* Addresses in memory. */ 616ba340e45Schristos 617ba340e45Schristos /* Buffer descriptor. */ 618ba340e45Schristos ARC_NPS400_ADDRTYPE_BD, 619ba340e45Schristos 620ba340e45Schristos /* Job identifier. */ 621ba340e45Schristos ARC_NPS400_ADDRTYPE_JID, 622ba340e45Schristos 623ba340e45Schristos /* Linked Buffer Descriptor. */ 624ba340e45Schristos ARC_NPS400_ADDRTYPE_LBD, 625ba340e45Schristos 626ba340e45Schristos /* Multicast Buffer Descriptor. */ 627ba340e45Schristos ARC_NPS400_ADDRTYPE_MBD, 628ba340e45Schristos 629ba340e45Schristos /* Summarized Address. */ 630ba340e45Schristos ARC_NPS400_ADDRTYPE_SD, 631ba340e45Schristos 632ba340e45Schristos /* SMEM Security Context Local Memory. */ 633ba340e45Schristos ARC_NPS400_ADDRTYPE_SM, 634ba340e45Schristos 635ba340e45Schristos /* Extended Address. */ 636ba340e45Schristos ARC_NPS400_ADDRTYPE_XA, 637ba340e45Schristos 638ba340e45Schristos /* Extended Summarized Address. */ 639ba340e45Schristos ARC_NPS400_ADDRTYPE_XD, 640ba340e45Schristos 641ba340e45Schristos /* CMEM offset addresses. */ 642ba340e45Schristos 643ba340e45Schristos /* On-demand Counter Descriptor. */ 644ba340e45Schristos ARC_NPS400_ADDRTYPE_CD, 645ba340e45Schristos 646ba340e45Schristos /* CMEM Buffer Descriptor. */ 647ba340e45Schristos ARC_NPS400_ADDRTYPE_CBD, 648ba340e45Schristos 649ba340e45Schristos /* CMEM Job Identifier. */ 650ba340e45Schristos ARC_NPS400_ADDRTYPE_CJID, 651ba340e45Schristos 652ba340e45Schristos /* CMEM Linked Buffer Descriptor. */ 653ba340e45Schristos ARC_NPS400_ADDRTYPE_CLBD, 654ba340e45Schristos 655ba340e45Schristos /* CMEM Offset. */ 656ba340e45Schristos ARC_NPS400_ADDRTYPE_CM, 657ba340e45Schristos 658ba340e45Schristos /* CMEM Summarized Address. */ 659ba340e45Schristos ARC_NPS400_ADDRTYPE_CSD, 660ba340e45Schristos 661ba340e45Schristos /* CMEM Extended Address. */ 662ba340e45Schristos ARC_NPS400_ADDRTYPE_CXA, 663ba340e45Schristos 664ba340e45Schristos /* CMEM Extended Summarized Address. */ 665ba340e45Schristos ARC_NPS400_ADDRTYPE_CXD 666ba340e45Schristos 667ba340e45Schristos } arc_nps_address_type; 668ba340e45Schristos 669ba340e45Schristos #define ARC_NUM_ADDRTYPES 16 670ba340e45Schristos 671ba340e45Schristos #ifdef __cplusplus 672ba340e45Schristos } 673ba340e45Schristos #endif 674ba340e45Schristos 675ba340e45Schristos #endif /* OPCODE_ARC_H */ 676