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