Blame include/opcode/alpha.h

Packit bbfece
/* alpha.h -- Header file for Alpha opcode table
Packit bbfece
   Copyright (C) 1996-2018 Free Software Foundation, Inc.
Packit bbfece
   Contributed by Richard Henderson <rth@tamu.edu>,
Packit bbfece
   patterned after the PPC opcode table written by Ian Lance Taylor.
Packit bbfece
Packit bbfece
   This file is part of GDB, GAS, and the GNU binutils.
Packit bbfece
Packit bbfece
   GDB, GAS, and the GNU binutils are free software; you can redistribute
Packit bbfece
   them and/or modify them under the terms of the GNU General Public
Packit bbfece
   License as published by the Free Software Foundation; either version 3,
Packit bbfece
   or (at your option) any later version.
Packit bbfece
Packit bbfece
   GDB, GAS, and the GNU binutils are distributed in the hope that they
Packit bbfece
   will be useful, but WITHOUT ANY WARRANTY; without even the implied
Packit bbfece
   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
Packit bbfece
   the GNU General Public License for more details.
Packit bbfece
Packit bbfece
   You should have received a copy of the GNU General Public License
Packit bbfece
   along with this file; see the file COPYING3.  If not, write to the Free
Packit bbfece
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
Packit bbfece
   MA 02110-1301, USA.  */
Packit bbfece
Packit bbfece
#ifndef OPCODE_ALPHA_H
Packit bbfece
#define OPCODE_ALPHA_H
Packit bbfece
Packit bbfece
/* The opcode table is an array of struct alpha_opcode.  */
Packit bbfece
Packit bbfece
struct alpha_opcode
Packit bbfece
{
Packit bbfece
  /* The opcode name.  */
Packit bbfece
  const char *name;
Packit bbfece
Packit bbfece
  /* The opcode itself.  Those bits which will be filled in with
Packit bbfece
     operands are zeroes.  */
Packit bbfece
  unsigned opcode;
Packit bbfece
Packit bbfece
  /* The opcode mask.  This is used by the disassembler.  This is a
Packit bbfece
     mask containing ones indicating those bits which must match the
Packit bbfece
     opcode field, and zeroes indicating those bits which need not
Packit bbfece
     match (and are presumably filled in by operands).  */
Packit bbfece
  unsigned mask;
Packit bbfece
Packit bbfece
  /* One bit flags for the opcode.  These are primarily used to
Packit bbfece
     indicate specific processors and environments support the
Packit bbfece
     instructions.  The defined values are listed below. */
Packit bbfece
  unsigned flags;
Packit bbfece
Packit bbfece
  /* An array of operand codes.  Each code is an index into the
Packit bbfece
     operand table.  They appear in the order which the operands must
Packit bbfece
     appear in assembly code, and are terminated by a zero.  */
Packit bbfece
  unsigned char operands[4];
Packit bbfece
};
Packit bbfece
Packit bbfece
/* The table itself is sorted by major opcode number, and is otherwise
Packit bbfece
   in the order in which the disassembler should consider
Packit bbfece
   instructions.  */
Packit bbfece
extern const struct alpha_opcode alpha_opcodes[];
Packit bbfece
extern const unsigned alpha_num_opcodes;
Packit bbfece
Packit bbfece
/* Values defined for the flags field of a struct alpha_opcode.  */
Packit bbfece
Packit bbfece
/* CPU Availability */
Packit bbfece
#define AXP_OPCODE_BASE  0x0001  /* Base architecture -- all cpus.  */
Packit bbfece
#define AXP_OPCODE_EV4   0x0002  /* EV4 specific PALcode insns.  */
Packit bbfece
#define AXP_OPCODE_EV5   0x0004  /* EV5 specific PALcode insns.  */
Packit bbfece
#define AXP_OPCODE_EV6   0x0008  /* EV6 specific PALcode insns.  */
Packit bbfece
#define AXP_OPCODE_BWX   0x0100  /* Byte/word extension (amask bit 0).  */
Packit bbfece
#define AXP_OPCODE_CIX   0x0200  /* "Count" extension (amask bit 1).  */
Packit bbfece
#define AXP_OPCODE_MAX   0x0400  /* Multimedia extension (amask bit 8).  */
Packit bbfece
Packit bbfece
#define AXP_OPCODE_NOPAL (~(AXP_OPCODE_EV4|AXP_OPCODE_EV5|AXP_OPCODE_EV6))
Packit bbfece
Packit bbfece
/* A macro to extract the major opcode from an instruction.  */
Packit bbfece
#define AXP_OP(i)	(((i) >> 26) & 0x3F)
Packit bbfece
Packit bbfece
/* The total number of major opcodes. */
Packit bbfece
#define AXP_NOPS	0x40
Packit bbfece
Packit bbfece

Packit bbfece
/* The operands table is an array of struct alpha_operand.  */
Packit bbfece
Packit bbfece
struct alpha_operand
Packit bbfece
{
Packit bbfece
  /* The number of bits in the operand.  */
Packit bbfece
  unsigned int bits : 5;
Packit bbfece
Packit bbfece
  /* How far the operand is left shifted in the instruction.  */
Packit bbfece
  unsigned int shift : 5;
Packit bbfece
Packit bbfece
  /* The default relocation type for this operand.  */
Packit bbfece
  signed int default_reloc : 16;
Packit bbfece
Packit bbfece
  /* One bit syntax flags.  */
Packit bbfece
  unsigned int flags : 16;
Packit bbfece
Packit bbfece
  /* Insertion function.  This is used by the assembler.  To insert an
Packit bbfece
     operand value into an instruction, check this field.
Packit bbfece
Packit bbfece
     If it is NULL, execute
Packit bbfece
         i |= (op & ((1 << o->bits) - 1)) << o->shift;
Packit bbfece
     (i is the instruction which we are filling in, o is a pointer to
Packit bbfece
     this structure, and op is the opcode value; this assumes twos
Packit bbfece
     complement arithmetic).
Packit bbfece
Packit bbfece
     If this field is not NULL, then simply call it with the
Packit bbfece
     instruction and the operand value.  It will return the new value
Packit bbfece
     of the instruction.  If the ERRMSG argument is not NULL, then if
Packit bbfece
     the operand value is illegal, *ERRMSG will be set to a warning
Packit bbfece
     string (the operand will be inserted in any case).  If the
Packit bbfece
     operand value is legal, *ERRMSG will be unchanged (most operands
Packit bbfece
     can accept any value).  */
Packit bbfece
  unsigned (*insert) (unsigned instruction, int op, const char **errmsg);
Packit bbfece
Packit bbfece
  /* Extraction function.  This is used by the disassembler.  To
Packit bbfece
     extract this operand type from an instruction, check this field.
Packit bbfece
Packit bbfece
     If it is NULL, compute
Packit bbfece
         op = ((i) >> o->shift) & ((1 << o->bits) - 1);
Packit bbfece
	 if ((o->flags & AXP_OPERAND_SIGNED) != 0
Packit bbfece
	     && (op & (1 << (o->bits - 1))) != 0)
Packit bbfece
	   op -= 1 << o->bits;
Packit bbfece
     (i is the instruction, o is a pointer to this structure, and op
Packit bbfece
     is the result; this assumes twos complement arithmetic).
Packit bbfece
Packit bbfece
     If this field is not NULL, then simply call it with the
Packit bbfece
     instruction value.  It will return the value of the operand.  If
Packit bbfece
     the INVALID argument is not NULL, *INVALID will be set to
Packit bbfece
     non-zero if this operand type can not actually be extracted from
Packit bbfece
     this operand (i.e., the instruction does not match).  If the
Packit bbfece
     operand is valid, *INVALID will not be changed.  */
Packit bbfece
  int (*extract) (unsigned instruction, int *invalid);
Packit bbfece
};
Packit bbfece
Packit bbfece
/* Elements in the table are retrieved by indexing with values from
Packit bbfece
   the operands field of the alpha_opcodes table.  */
Packit bbfece
Packit bbfece
extern const struct alpha_operand alpha_operands[];
Packit bbfece
extern const unsigned alpha_num_operands;
Packit bbfece
Packit bbfece
/* Values defined for the flags field of a struct alpha_operand.  */
Packit bbfece
Packit bbfece
/* Mask for selecting the type for typecheck purposes */
Packit bbfece
#define AXP_OPERAND_TYPECHECK_MASK					\
Packit bbfece
  (AXP_OPERAND_PARENS | AXP_OPERAND_COMMA | AXP_OPERAND_IR |		\
Packit bbfece
   AXP_OPERAND_FPR | AXP_OPERAND_RELATIVE | AXP_OPERAND_SIGNED | 	\
Packit bbfece
   AXP_OPERAND_UNSIGNED)
Packit bbfece
Packit bbfece
/* This operand does not actually exist in the assembler input.  This
Packit bbfece
   is used to support extended mnemonics, for which two operands fields
Packit bbfece
   are identical.  The assembler should call the insert function with
Packit bbfece
   any op value.  The disassembler should call the extract function,
Packit bbfece
   ignore the return value, and check the value placed in the invalid
Packit bbfece
   argument.  */
Packit bbfece
#define AXP_OPERAND_FAKE	01
Packit bbfece
Packit bbfece
/* The operand should be wrapped in parentheses rather than separated
Packit bbfece
   from the previous by a comma.  This is used for the load and store
Packit bbfece
   instructions which want their operands to look like "Ra,disp(Rb)".  */
Packit bbfece
#define AXP_OPERAND_PARENS	02
Packit bbfece
Packit bbfece
/* Used in combination with PARENS, this supresses the supression of
Packit bbfece
   the comma.  This is used for "jmp Ra,(Rb),hint".  */
Packit bbfece
#define AXP_OPERAND_COMMA	04
Packit bbfece
Packit bbfece
/* This operand names an integer register.  */
Packit bbfece
#define AXP_OPERAND_IR		010
Packit bbfece
Packit bbfece
/* This operand names a floating point register.  */
Packit bbfece
#define AXP_OPERAND_FPR		020
Packit bbfece
Packit bbfece
/* This operand is a relative branch displacement.  The disassembler
Packit bbfece
   prints these symbolically if possible.  */
Packit bbfece
#define AXP_OPERAND_RELATIVE	040
Packit bbfece
Packit bbfece
/* This operand takes signed values.  */
Packit bbfece
#define AXP_OPERAND_SIGNED	0100
Packit bbfece
Packit bbfece
/* This operand takes unsigned values.  This exists primarily so that
Packit bbfece
   a flags value of 0 can be treated as end-of-arguments.  */
Packit bbfece
#define AXP_OPERAND_UNSIGNED	0200
Packit bbfece
Packit bbfece
/* Supress overflow detection on this field.  This is used for hints. */
Packit bbfece
#define AXP_OPERAND_NOOVERFLOW	0400
Packit bbfece
Packit bbfece
/* Mask for optional argument default value.  */
Packit bbfece
#define AXP_OPERAND_OPTIONAL_MASK 07000
Packit bbfece
Packit bbfece
/* This operand defaults to zero.  This is used for jump hints.  */
Packit bbfece
#define AXP_OPERAND_DEFAULT_ZERO 01000
Packit bbfece
Packit bbfece
/* This operand should default to the first (real) operand and is used
Packit bbfece
   in conjunction with AXP_OPERAND_OPTIONAL.  This allows
Packit bbfece
   "and $0,3,$0" to be written as "and $0,3", etc.  I don't like
Packit bbfece
   it, but it's what DEC does.  */
Packit bbfece
#define AXP_OPERAND_DEFAULT_FIRST 02000
Packit bbfece
Packit bbfece
/* Similarly, this operand should default to the second (real) operand.
Packit bbfece
   This allows "negl $0" instead of "negl $0,$0".  */
Packit bbfece
#define AXP_OPERAND_DEFAULT_SECOND 04000
Packit bbfece
Packit bbfece

Packit bbfece
/* Register common names */
Packit bbfece
Packit bbfece
#define AXP_REG_V0	0
Packit bbfece
#define AXP_REG_T0	1
Packit bbfece
#define AXP_REG_T1	2
Packit bbfece
#define AXP_REG_T2	3
Packit bbfece
#define AXP_REG_T3	4
Packit bbfece
#define AXP_REG_T4	5
Packit bbfece
#define AXP_REG_T5	6
Packit bbfece
#define AXP_REG_T6	7
Packit bbfece
#define AXP_REG_T7	8
Packit bbfece
#define AXP_REG_S0	9
Packit bbfece
#define AXP_REG_S1	10
Packit bbfece
#define AXP_REG_S2	11
Packit bbfece
#define AXP_REG_S3	12
Packit bbfece
#define AXP_REG_S4	13
Packit bbfece
#define AXP_REG_S5	14
Packit bbfece
#define AXP_REG_FP	15
Packit bbfece
#define AXP_REG_A0	16
Packit bbfece
#define AXP_REG_A1	17
Packit bbfece
#define AXP_REG_A2	18
Packit bbfece
#define AXP_REG_A3	19
Packit bbfece
#define AXP_REG_A4	20
Packit bbfece
#define AXP_REG_A5	21
Packit bbfece
#define AXP_REG_T8	22
Packit bbfece
#define AXP_REG_T9	23
Packit bbfece
#define AXP_REG_T10	24
Packit bbfece
#define AXP_REG_T11	25
Packit bbfece
#define AXP_REG_RA	26
Packit bbfece
#define AXP_REG_PV	27
Packit bbfece
#define AXP_REG_T12	27
Packit bbfece
#define AXP_REG_AT	28
Packit bbfece
#define AXP_REG_GP	29
Packit bbfece
#define AXP_REG_SP	30
Packit bbfece
#define AXP_REG_ZERO	31
Packit bbfece
Packit bbfece
#endif /* OPCODE_ALPHA_H */