Home | History | Annotate | Line # | Download | only in opcode
      1       1.1     skrll /* s390.h -- Header file for S390 opcode table
      2  1.1.1.11  christos    Copyright (C) 2000-2026 Free Software Foundation, Inc.
      3       1.1     skrll    Contributed by Martin Schwidefsky (schwidefsky (at) de.ibm.com).
      4       1.1     skrll 
      5       1.1     skrll    This file is part of BFD, the Binary File Descriptor library.
      6       1.1     skrll 
      7       1.1     skrll    This program is free software; you can redistribute it and/or modify
      8       1.1     skrll    it under the terms of the GNU General Public License as published by
      9   1.1.1.2  christos    the Free Software Foundation; either version 3 of the License, or
     10       1.1     skrll    (at your option) any later version.
     11       1.1     skrll 
     12       1.1     skrll    This program is distributed in the hope that it will be useful,
     13       1.1     skrll    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14       1.1     skrll    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15       1.1     skrll    GNU General Public License for more details.
     16       1.1     skrll 
     17       1.1     skrll    You should have received a copy of the GNU General Public License
     18       1.1     skrll    along with this program; if not, write to the Free Software
     19       1.1     skrll    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
     20       1.1     skrll    02110-1301, USA.  */
     21       1.1     skrll 
     22       1.1     skrll #ifndef S390_H
     23       1.1     skrll #define S390_H
     24       1.1     skrll 
     25       1.1     skrll /* List of instruction sets variations. */
     26       1.1     skrll 
     27       1.1     skrll enum s390_opcode_mode_val
     28       1.1     skrll   {
     29       1.1     skrll     S390_OPCODE_ESA = 0,
     30       1.1     skrll     S390_OPCODE_ZARCH
     31       1.1     skrll   };
     32       1.1     skrll 
     33       1.1     skrll enum s390_opcode_cpu_val
     34       1.1     skrll   {
     35       1.1     skrll     S390_OPCODE_G5 = 0,
     36       1.1     skrll     S390_OPCODE_G6,
     37       1.1     skrll     S390_OPCODE_Z900,
     38       1.1     skrll     S390_OPCODE_Z990,
     39       1.1     skrll     S390_OPCODE_Z9_109,
     40       1.1     skrll     S390_OPCODE_Z9_EC,
     41   1.1.1.2  christos     S390_OPCODE_Z10,
     42   1.1.1.2  christos     S390_OPCODE_Z196,
     43   1.1.1.4  christos     S390_OPCODE_ZEC12,
     44   1.1.1.4  christos     S390_OPCODE_Z13,
     45   1.1.1.6  christos     S390_OPCODE_ARCH12,
     46   1.1.1.7  christos     S390_OPCODE_ARCH13,
     47   1.1.1.8  christos     S390_OPCODE_ARCH14,
     48  1.1.1.10  christos     S390_OPCODE_ARCH15,
     49   1.1.1.2  christos     S390_OPCODE_MAXCPU
     50       1.1     skrll   };
     51       1.1     skrll 
     52   1.1.1.9  christos /* Values defined for the flags field of a struct s390_opcode.  */
     53   1.1.1.9  christos 
     54   1.1.1.9  christos /* Last one or two instruction operands are optional.  */
     55   1.1.1.4  christos #define S390_INSTR_FLAG_OPTPARM 0x1
     56   1.1.1.6  christos #define S390_INSTR_FLAG_OPTPARM2 0x2
     57   1.1.1.6  christos 
     58   1.1.1.9  christos /* Instruction requires a specific facility.  */
     59   1.1.1.6  christos #define S390_INSTR_FLAG_HTM 0x4
     60   1.1.1.6  christos #define S390_INSTR_FLAG_VX 0x8
     61   1.1.1.6  christos #define S390_INSTR_FLAG_FACILITY_MASK 0xc
     62   1.1.1.4  christos 
     63   1.1.1.9  christos /* Instruction annotations for jump visualization.  */
     64   1.1.1.9  christos #define S390_INSTR_FLAG_CLASS_BRANCH 0x10
     65   1.1.1.9  christos #define S390_INSTR_FLAG_CLASS_RELATIVE 0x20
     66   1.1.1.9  christos #define S390_INSTR_FLAG_CLASS_CONDITIONAL 0x40
     67   1.1.1.9  christos #define S390_INSTR_FLAG_CLASS_SUBROUTINE 0x80
     68   1.1.1.9  christos #define S390_INSTR_FLAG_CLASS_MASK 0xf0
     69   1.1.1.9  christos 
     70   1.1.1.9  christos #define S390_INSTR_FLAGS_CLASS_JUMP \
     71   1.1.1.9  christos   (S390_INSTR_FLAG_CLASS_BRANCH | S390_INSTR_FLAG_CLASS_RELATIVE)
     72   1.1.1.9  christos 
     73   1.1.1.9  christos #define S390_INSTR_FLAGS_CLASS_CONDJUMP \
     74   1.1.1.9  christos   (S390_INSTR_FLAG_CLASS_BRANCH | S390_INSTR_FLAG_CLASS_RELATIVE \
     75   1.1.1.9  christos    | S390_INSTR_FLAG_CLASS_CONDITIONAL)
     76   1.1.1.9  christos 
     77   1.1.1.9  christos #define S390_INSTR_FLAGS_CLASS_JUMPSR \
     78   1.1.1.9  christos   (S390_INSTR_FLAG_CLASS_BRANCH | S390_INSTR_FLAG_CLASS_RELATIVE \
     79   1.1.1.9  christos    | S390_INSTR_FLAG_CLASS_SUBROUTINE)
     80   1.1.1.9  christos 
     81  1.1.1.10  christos /* Instruction is an .insn pseudo-mnemonic.  */
     82  1.1.1.10  christos #define S390_INSTR_FLAG_PSEUDO_MNEMONIC 0x100
     83  1.1.1.10  christos 
     84       1.1     skrll /* The opcode table is an array of struct s390_opcode.  */
     85       1.1     skrll 
     86       1.1     skrll struct s390_opcode
     87       1.1     skrll   {
     88   1.1.1.9  christos     /* The opcode name (mnemonic).  */
     89       1.1     skrll     const char * name;
     90       1.1     skrll 
     91       1.1     skrll     /* The opcode itself.  Those bits which will be filled in with
     92       1.1     skrll        operands are zeroes.  */
     93       1.1     skrll     unsigned char opcode[6];
     94       1.1     skrll 
     95       1.1     skrll     /* The opcode mask.  This is used by the disassembler.  This is a
     96       1.1     skrll        mask containing ones indicating those bits which must match the
     97       1.1     skrll        opcode field, and zeroes indicating those bits which need not
     98       1.1     skrll        match (and are presumably filled in by operands).  */
     99       1.1     skrll     unsigned char mask[6];
    100       1.1     skrll 
    101       1.1     skrll     /* The opcode length in bytes. */
    102       1.1     skrll     int oplen;
    103       1.1     skrll 
    104       1.1     skrll     /* An array of operand codes.  Each code is an index into the
    105       1.1     skrll        operand table.  They appear in the order which the operands must
    106       1.1     skrll        appear in assembly code, and are terminated by a zero.  */
    107       1.1     skrll     unsigned char operands[6];
    108       1.1     skrll 
    109       1.1     skrll     /* Bitmask of execution modes this opcode is available for.  */
    110       1.1     skrll     unsigned int modes;
    111       1.1     skrll 
    112       1.1     skrll     /* First cpu this opcode is available for.  */
    113       1.1     skrll     enum s390_opcode_cpu_val min_cpu;
    114   1.1.1.4  christos 
    115   1.1.1.4  christos     /* Instruction specific flags.  */
    116   1.1.1.4  christos     unsigned int flags;
    117   1.1.1.9  christos 
    118   1.1.1.9  christos     /* Instruction description.  */
    119   1.1.1.9  christos     const char * description;
    120       1.1     skrll   };
    121       1.1     skrll 
    122       1.1     skrll /* The table itself is sorted by major opcode number, and is otherwise
    123       1.1     skrll    in the order in which the disassembler should consider
    124       1.1     skrll    instructions.  */
    125       1.1     skrll extern const struct s390_opcode s390_opcodes[];
    126       1.1     skrll extern const int                s390_num_opcodes;
    127       1.1     skrll 
    128       1.1     skrll /* A opcode format table for the .insn pseudo mnemonic.  */
    129       1.1     skrll extern const struct s390_opcode s390_opformats[];
    130       1.1     skrll extern const int                s390_num_opformats;
    131       1.1     skrll 
    132       1.1     skrll /* The operands table is an array of struct s390_operand.  */
    133       1.1     skrll 
    134       1.1     skrll struct s390_operand
    135       1.1     skrll   {
    136       1.1     skrll     /* The number of bits in the operand.  */
    137       1.1     skrll     int bits;
    138       1.1     skrll 
    139       1.1     skrll     /* How far the operand is left shifted in the instruction.  */
    140       1.1     skrll     int shift;
    141       1.1     skrll 
    142       1.1     skrll     /* One bit syntax flags.  */
    143       1.1     skrll     unsigned long flags;
    144       1.1     skrll   };
    145       1.1     skrll 
    146       1.1     skrll /* Elements in the table are retrieved by indexing with values from
    147   1.1.1.4  christos    the operands field of the s390_opcodes table.  */
    148       1.1     skrll 
    149       1.1     skrll extern const struct s390_operand s390_operands[];
    150       1.1     skrll 
    151       1.1     skrll /* Values defined for the flags field of a struct s390_operand.  */
    152       1.1     skrll 
    153       1.1     skrll /* This operand names a register.  The disassembler uses this to print
    154       1.1     skrll    register names with a leading 'r'.  */
    155       1.1     skrll #define S390_OPERAND_GPR 0x1
    156       1.1     skrll 
    157       1.1     skrll /* This operand names a floating point register.  The disassembler
    158       1.1     skrll    prints these with a leading 'f'. */
    159       1.1     skrll #define S390_OPERAND_FPR 0x2
    160       1.1     skrll 
    161       1.1     skrll /* This operand names an access register.  The disassembler
    162       1.1     skrll    prints these with a leading 'a'.  */
    163       1.1     skrll #define S390_OPERAND_AR 0x4
    164       1.1     skrll 
    165       1.1     skrll /* This operand names a control register.  The disassembler
    166       1.1     skrll    prints these with a leading 'c'.  */
    167       1.1     skrll #define S390_OPERAND_CR 0x8
    168       1.1     skrll 
    169       1.1     skrll /* This operand is a displacement.  */
    170       1.1     skrll #define S390_OPERAND_DISP 0x10
    171       1.1     skrll 
    172       1.1     skrll /* This operand names a base register.  */
    173       1.1     skrll #define S390_OPERAND_BASE 0x20
    174       1.1     skrll 
    175       1.1     skrll /* This operand names an index register, it can be skipped.  */
    176       1.1     skrll #define S390_OPERAND_INDEX 0x40
    177       1.1     skrll 
    178       1.1     skrll /* This operand is a relative branch displacement.  The disassembler
    179       1.1     skrll    prints these symbolically if possible.  */
    180       1.1     skrll #define S390_OPERAND_PCREL 0x80
    181       1.1     skrll 
    182       1.1     skrll /* This operand takes signed values.  */
    183       1.1     skrll #define S390_OPERAND_SIGNED 0x100
    184       1.1     skrll 
    185       1.1     skrll /* This operand is a length.  */
    186       1.1     skrll #define S390_OPERAND_LENGTH 0x200
    187       1.1     skrll 
    188   1.1.1.3  christos /* The operand needs to be a valid GP or FP register pair.  */
    189   1.1.1.6  christos #define S390_OPERAND_REG_PAIR 0x400
    190   1.1.1.3  christos 
    191   1.1.1.4  christos /* This operand names a vector register.  The disassembler uses this
    192   1.1.1.4  christos    to print register names with a leading 'v'.  */
    193   1.1.1.6  christos #define S390_OPERAND_VR 0x800
    194   1.1.1.4  christos 
    195   1.1.1.6  christos #define S390_OPERAND_CP16 0x1000
    196   1.1.1.4  christos 
    197   1.1.1.4  christos #endif /* S390_H */
    198