198b9484cSchristos /* alpha.h -- Header file for Alpha opcode table 2*aab831ceSchristos Copyright (C) 1996-2024 Free Software Foundation, Inc. 398b9484cSchristos Contributed by Richard Henderson <rth@tamu.edu>, 498b9484cSchristos patterned after the PPC opcode table written by Ian Lance Taylor. 598b9484cSchristos 698b9484cSchristos This file is part of GDB, GAS, and the GNU binutils. 798b9484cSchristos 898b9484cSchristos GDB, GAS, and the GNU binutils are free software; you can redistribute 998b9484cSchristos them and/or modify them under the terms of the GNU General Public 1098b9484cSchristos License as published by the Free Software Foundation; either version 3, 1198b9484cSchristos or (at your option) any later version. 1298b9484cSchristos 1398b9484cSchristos GDB, GAS, and the GNU binutils are distributed in the hope that they 1498b9484cSchristos will be useful, but WITHOUT ANY WARRANTY; without even the implied 1598b9484cSchristos warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 1698b9484cSchristos the GNU General Public License for more details. 1798b9484cSchristos 1898b9484cSchristos You should have received a copy of the GNU General Public License 1998b9484cSchristos along with this file; see the file COPYING3. If not, write to the Free 2098b9484cSchristos Software Foundation, 51 Franklin Street - Fifth Floor, Boston, 2198b9484cSchristos MA 02110-1301, USA. */ 2298b9484cSchristos 2398b9484cSchristos #ifndef OPCODE_ALPHA_H 2498b9484cSchristos #define OPCODE_ALPHA_H 2598b9484cSchristos 2698b9484cSchristos /* The opcode table is an array of struct alpha_opcode. */ 2798b9484cSchristos 2898b9484cSchristos struct alpha_opcode 2998b9484cSchristos { 3098b9484cSchristos /* The opcode name. */ 3198b9484cSchristos const char *name; 3298b9484cSchristos 3398b9484cSchristos /* The opcode itself. Those bits which will be filled in with 3498b9484cSchristos operands are zeroes. */ 3598b9484cSchristos unsigned opcode; 3698b9484cSchristos 3798b9484cSchristos /* The opcode mask. This is used by the disassembler. This is a 3898b9484cSchristos mask containing ones indicating those bits which must match the 3998b9484cSchristos opcode field, and zeroes indicating those bits which need not 4098b9484cSchristos match (and are presumably filled in by operands). */ 4198b9484cSchristos unsigned mask; 4298b9484cSchristos 4398b9484cSchristos /* One bit flags for the opcode. These are primarily used to 4498b9484cSchristos indicate specific processors and environments support the 4598b9484cSchristos instructions. The defined values are listed below. */ 4698b9484cSchristos unsigned flags; 4798b9484cSchristos 4898b9484cSchristos /* An array of operand codes. Each code is an index into the 4998b9484cSchristos operand table. They appear in the order which the operands must 5098b9484cSchristos appear in assembly code, and are terminated by a zero. */ 5198b9484cSchristos unsigned char operands[4]; 5298b9484cSchristos }; 5398b9484cSchristos 5498b9484cSchristos /* The table itself is sorted by major opcode number, and is otherwise 5598b9484cSchristos in the order in which the disassembler should consider 5698b9484cSchristos instructions. */ 5798b9484cSchristos extern const struct alpha_opcode alpha_opcodes[]; 5898b9484cSchristos extern const unsigned alpha_num_opcodes; 5998b9484cSchristos 6098b9484cSchristos /* Values defined for the flags field of a struct alpha_opcode. */ 6198b9484cSchristos 6298b9484cSchristos /* CPU Availability */ 6398b9484cSchristos #define AXP_OPCODE_BASE 0x0001 /* Base architecture -- all cpus. */ 6498b9484cSchristos #define AXP_OPCODE_EV4 0x0002 /* EV4 specific PALcode insns. */ 6598b9484cSchristos #define AXP_OPCODE_EV5 0x0004 /* EV5 specific PALcode insns. */ 6698b9484cSchristos #define AXP_OPCODE_EV6 0x0008 /* EV6 specific PALcode insns. */ 6798b9484cSchristos #define AXP_OPCODE_BWX 0x0100 /* Byte/word extension (amask bit 0). */ 6898b9484cSchristos #define AXP_OPCODE_CIX 0x0200 /* "Count" extension (amask bit 1). */ 6998b9484cSchristos #define AXP_OPCODE_MAX 0x0400 /* Multimedia extension (amask bit 8). */ 7098b9484cSchristos 7198b9484cSchristos #define AXP_OPCODE_NOPAL (~(AXP_OPCODE_EV4|AXP_OPCODE_EV5|AXP_OPCODE_EV6)) 7298b9484cSchristos 7398b9484cSchristos /* A macro to extract the major opcode from an instruction. */ 7498b9484cSchristos #define AXP_OP(i) (((i) >> 26) & 0x3F) 7598b9484cSchristos 7698b9484cSchristos /* The total number of major opcodes. */ 7798b9484cSchristos #define AXP_NOPS 0x40 7898b9484cSchristos 7998b9484cSchristos 8098b9484cSchristos /* The operands table is an array of struct alpha_operand. */ 8198b9484cSchristos 8298b9484cSchristos struct alpha_operand 8398b9484cSchristos { 8498b9484cSchristos /* The number of bits in the operand. */ 8598b9484cSchristos unsigned int bits : 5; 8698b9484cSchristos 8798b9484cSchristos /* How far the operand is left shifted in the instruction. */ 8898b9484cSchristos unsigned int shift : 5; 8998b9484cSchristos 9098b9484cSchristos /* The default relocation type for this operand. */ 9198b9484cSchristos signed int default_reloc : 16; 9298b9484cSchristos 9398b9484cSchristos /* One bit syntax flags. */ 9498b9484cSchristos unsigned int flags : 16; 9598b9484cSchristos 9698b9484cSchristos /* Insertion function. This is used by the assembler. To insert an 9798b9484cSchristos operand value into an instruction, check this field. 9898b9484cSchristos 9998b9484cSchristos If it is NULL, execute 10098b9484cSchristos i |= (op & ((1 << o->bits) - 1)) << o->shift; 10198b9484cSchristos (i is the instruction which we are filling in, o is a pointer to 10298b9484cSchristos this structure, and op is the opcode value; this assumes twos 10398b9484cSchristos complement arithmetic). 10498b9484cSchristos 10598b9484cSchristos If this field is not NULL, then simply call it with the 10698b9484cSchristos instruction and the operand value. It will return the new value 10798b9484cSchristos of the instruction. If the ERRMSG argument is not NULL, then if 10898b9484cSchristos the operand value is illegal, *ERRMSG will be set to a warning 10998b9484cSchristos string (the operand will be inserted in any case). If the 11098b9484cSchristos operand value is legal, *ERRMSG will be unchanged (most operands 11198b9484cSchristos can accept any value). */ 11298b9484cSchristos unsigned (*insert) (unsigned instruction, int op, const char **errmsg); 11398b9484cSchristos 11498b9484cSchristos /* Extraction function. This is used by the disassembler. To 11598b9484cSchristos extract this operand type from an instruction, check this field. 11698b9484cSchristos 11798b9484cSchristos If it is NULL, compute 11898b9484cSchristos op = ((i) >> o->shift) & ((1 << o->bits) - 1); 11998b9484cSchristos if ((o->flags & AXP_OPERAND_SIGNED) != 0 12098b9484cSchristos && (op & (1 << (o->bits - 1))) != 0) 12198b9484cSchristos op -= 1 << o->bits; 12298b9484cSchristos (i is the instruction, o is a pointer to this structure, and op 12398b9484cSchristos is the result; this assumes twos complement arithmetic). 12498b9484cSchristos 12598b9484cSchristos If this field is not NULL, then simply call it with the 12698b9484cSchristos instruction value. It will return the value of the operand. If 12798b9484cSchristos the INVALID argument is not NULL, *INVALID will be set to 12898b9484cSchristos non-zero if this operand type can not actually be extracted from 12998b9484cSchristos this operand (i.e., the instruction does not match). If the 13098b9484cSchristos operand is valid, *INVALID will not be changed. */ 13198b9484cSchristos int (*extract) (unsigned instruction, int *invalid); 13298b9484cSchristos }; 13398b9484cSchristos 13498b9484cSchristos /* Elements in the table are retrieved by indexing with values from 13598b9484cSchristos the operands field of the alpha_opcodes table. */ 13698b9484cSchristos 13798b9484cSchristos extern const struct alpha_operand alpha_operands[]; 13898b9484cSchristos extern const unsigned alpha_num_operands; 13998b9484cSchristos 14098b9484cSchristos /* Values defined for the flags field of a struct alpha_operand. */ 14198b9484cSchristos 14298b9484cSchristos /* Mask for selecting the type for typecheck purposes */ 14398b9484cSchristos #define AXP_OPERAND_TYPECHECK_MASK \ 14498b9484cSchristos (AXP_OPERAND_PARENS | AXP_OPERAND_COMMA | AXP_OPERAND_IR | \ 14598b9484cSchristos AXP_OPERAND_FPR | AXP_OPERAND_RELATIVE | AXP_OPERAND_SIGNED | \ 14698b9484cSchristos AXP_OPERAND_UNSIGNED) 14798b9484cSchristos 14898b9484cSchristos /* This operand does not actually exist in the assembler input. This 14998b9484cSchristos is used to support extended mnemonics, for which two operands fields 15098b9484cSchristos are identical. The assembler should call the insert function with 15198b9484cSchristos any op value. The disassembler should call the extract function, 15298b9484cSchristos ignore the return value, and check the value placed in the invalid 15398b9484cSchristos argument. */ 15498b9484cSchristos #define AXP_OPERAND_FAKE 01 15598b9484cSchristos 15698b9484cSchristos /* The operand should be wrapped in parentheses rather than separated 15798b9484cSchristos from the previous by a comma. This is used for the load and store 15898b9484cSchristos instructions which want their operands to look like "Ra,disp(Rb)". */ 15998b9484cSchristos #define AXP_OPERAND_PARENS 02 16098b9484cSchristos 16198b9484cSchristos /* Used in combination with PARENS, this supresses the supression of 16298b9484cSchristos the comma. This is used for "jmp Ra,(Rb),hint". */ 16398b9484cSchristos #define AXP_OPERAND_COMMA 04 16498b9484cSchristos 16598b9484cSchristos /* This operand names an integer register. */ 16698b9484cSchristos #define AXP_OPERAND_IR 010 16798b9484cSchristos 16898b9484cSchristos /* This operand names a floating point register. */ 16998b9484cSchristos #define AXP_OPERAND_FPR 020 17098b9484cSchristos 17198b9484cSchristos /* This operand is a relative branch displacement. The disassembler 17298b9484cSchristos prints these symbolically if possible. */ 17398b9484cSchristos #define AXP_OPERAND_RELATIVE 040 17498b9484cSchristos 17598b9484cSchristos /* This operand takes signed values. */ 17698b9484cSchristos #define AXP_OPERAND_SIGNED 0100 17798b9484cSchristos 17898b9484cSchristos /* This operand takes unsigned values. This exists primarily so that 17998b9484cSchristos a flags value of 0 can be treated as end-of-arguments. */ 18098b9484cSchristos #define AXP_OPERAND_UNSIGNED 0200 18198b9484cSchristos 18298b9484cSchristos /* Supress overflow detection on this field. This is used for hints. */ 18398b9484cSchristos #define AXP_OPERAND_NOOVERFLOW 0400 18498b9484cSchristos 18598b9484cSchristos /* Mask for optional argument default value. */ 18698b9484cSchristos #define AXP_OPERAND_OPTIONAL_MASK 07000 18798b9484cSchristos 18898b9484cSchristos /* This operand defaults to zero. This is used for jump hints. */ 18998b9484cSchristos #define AXP_OPERAND_DEFAULT_ZERO 01000 19098b9484cSchristos 19198b9484cSchristos /* This operand should default to the first (real) operand and is used 19298b9484cSchristos in conjunction with AXP_OPERAND_OPTIONAL. This allows 19398b9484cSchristos "and $0,3,$0" to be written as "and $0,3", etc. I don't like 19498b9484cSchristos it, but it's what DEC does. */ 19598b9484cSchristos #define AXP_OPERAND_DEFAULT_FIRST 02000 19698b9484cSchristos 19798b9484cSchristos /* Similarly, this operand should default to the second (real) operand. 19898b9484cSchristos This allows "negl $0" instead of "negl $0,$0". */ 19998b9484cSchristos #define AXP_OPERAND_DEFAULT_SECOND 04000 20098b9484cSchristos 20198b9484cSchristos 20298b9484cSchristos /* Register common names */ 20398b9484cSchristos 20498b9484cSchristos #define AXP_REG_V0 0 20598b9484cSchristos #define AXP_REG_T0 1 20698b9484cSchristos #define AXP_REG_T1 2 20798b9484cSchristos #define AXP_REG_T2 3 20898b9484cSchristos #define AXP_REG_T3 4 20998b9484cSchristos #define AXP_REG_T4 5 21098b9484cSchristos #define AXP_REG_T5 6 21198b9484cSchristos #define AXP_REG_T6 7 21298b9484cSchristos #define AXP_REG_T7 8 21398b9484cSchristos #define AXP_REG_S0 9 21498b9484cSchristos #define AXP_REG_S1 10 21598b9484cSchristos #define AXP_REG_S2 11 21698b9484cSchristos #define AXP_REG_S3 12 21798b9484cSchristos #define AXP_REG_S4 13 21898b9484cSchristos #define AXP_REG_S5 14 21998b9484cSchristos #define AXP_REG_FP 15 22098b9484cSchristos #define AXP_REG_A0 16 22198b9484cSchristos #define AXP_REG_A1 17 22298b9484cSchristos #define AXP_REG_A2 18 22398b9484cSchristos #define AXP_REG_A3 19 22498b9484cSchristos #define AXP_REG_A4 20 22598b9484cSchristos #define AXP_REG_A5 21 22698b9484cSchristos #define AXP_REG_T8 22 22798b9484cSchristos #define AXP_REG_T9 23 22898b9484cSchristos #define AXP_REG_T10 24 22998b9484cSchristos #define AXP_REG_T11 25 23098b9484cSchristos #define AXP_REG_RA 26 23198b9484cSchristos #define AXP_REG_PV 27 23298b9484cSchristos #define AXP_REG_T12 27 23398b9484cSchristos #define AXP_REG_AT 28 23498b9484cSchristos #define AXP_REG_GP 29 23598b9484cSchristos #define AXP_REG_SP 30 23698b9484cSchristos #define AXP_REG_ZERO 31 23798b9484cSchristos 23898b9484cSchristos #endif /* OPCODE_ALPHA_H */ 239