198b9484cSchristos /* s390.h -- Header file for S390 opcode table 2*02f41505Schristos Copyright (C) 2000-2024 Free Software Foundation, Inc. 398b9484cSchristos Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). 498b9484cSchristos 598b9484cSchristos This file is part of BFD, the Binary File Descriptor library. 698b9484cSchristos 798b9484cSchristos This program is free software; you can redistribute it and/or modify 898b9484cSchristos it under the terms of the GNU General Public License as published by 998b9484cSchristos the Free Software Foundation; either version 3 of the License, or 1098b9484cSchristos (at your option) any later version. 1198b9484cSchristos 1298b9484cSchristos This program is distributed in the hope that it will be useful, 1398b9484cSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1498b9484cSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1598b9484cSchristos GNU General Public License for more details. 1698b9484cSchristos 1798b9484cSchristos You should have received a copy of the GNU General Public License 1898b9484cSchristos along with this program; if not, write to the Free Software 1998b9484cSchristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 2098b9484cSchristos 02110-1301, USA. */ 2198b9484cSchristos 2298b9484cSchristos #ifndef S390_H 2398b9484cSchristos #define S390_H 2498b9484cSchristos 2598b9484cSchristos /* List of instruction sets variations. */ 2698b9484cSchristos 2798b9484cSchristos enum s390_opcode_mode_val 2898b9484cSchristos { 2998b9484cSchristos S390_OPCODE_ESA = 0, 3098b9484cSchristos S390_OPCODE_ZARCH 3198b9484cSchristos }; 3298b9484cSchristos 3398b9484cSchristos enum s390_opcode_cpu_val 3498b9484cSchristos { 3598b9484cSchristos S390_OPCODE_G5 = 0, 3698b9484cSchristos S390_OPCODE_G6, 3798b9484cSchristos S390_OPCODE_Z900, 3898b9484cSchristos S390_OPCODE_Z990, 3998b9484cSchristos S390_OPCODE_Z9_109, 4098b9484cSchristos S390_OPCODE_Z9_EC, 4198b9484cSchristos S390_OPCODE_Z10, 4298b9484cSchristos S390_OPCODE_Z196, 43a2e2270fSchristos S390_OPCODE_ZEC12, 44212397c6Schristos S390_OPCODE_Z13, 45796c32c9Schristos S390_OPCODE_ARCH12, 464559860eSchristos S390_OPCODE_ARCH13, 474b169a6bSchristos S390_OPCODE_ARCH14, 4898b9484cSchristos S390_OPCODE_MAXCPU 4998b9484cSchristos }; 5098b9484cSchristos 51*02f41505Schristos /* Values defined for the flags field of a struct s390_opcode. */ 52*02f41505Schristos 53*02f41505Schristos /* Last one or two instruction operands are optional. */ 54212397c6Schristos #define S390_INSTR_FLAG_OPTPARM 0x1 554559860eSchristos #define S390_INSTR_FLAG_OPTPARM2 0x2 56796c32c9Schristos 57*02f41505Schristos /* Instruction requires a specific facility. */ 584559860eSchristos #define S390_INSTR_FLAG_HTM 0x4 594559860eSchristos #define S390_INSTR_FLAG_VX 0x8 604559860eSchristos #define S390_INSTR_FLAG_FACILITY_MASK 0xc 61212397c6Schristos 62*02f41505Schristos /* Instruction annotations for jump visualization. */ 63*02f41505Schristos #define S390_INSTR_FLAG_CLASS_BRANCH 0x10 64*02f41505Schristos #define S390_INSTR_FLAG_CLASS_RELATIVE 0x20 65*02f41505Schristos #define S390_INSTR_FLAG_CLASS_CONDITIONAL 0x40 66*02f41505Schristos #define S390_INSTR_FLAG_CLASS_SUBROUTINE 0x80 67*02f41505Schristos #define S390_INSTR_FLAG_CLASS_MASK 0xf0 68*02f41505Schristos 69*02f41505Schristos #define S390_INSTR_FLAGS_CLASS_JUMP \ 70*02f41505Schristos (S390_INSTR_FLAG_CLASS_BRANCH | S390_INSTR_FLAG_CLASS_RELATIVE) 71*02f41505Schristos 72*02f41505Schristos #define S390_INSTR_FLAGS_CLASS_CONDJUMP \ 73*02f41505Schristos (S390_INSTR_FLAG_CLASS_BRANCH | S390_INSTR_FLAG_CLASS_RELATIVE \ 74*02f41505Schristos | S390_INSTR_FLAG_CLASS_CONDITIONAL) 75*02f41505Schristos 76*02f41505Schristos #define S390_INSTR_FLAGS_CLASS_JUMPSR \ 77*02f41505Schristos (S390_INSTR_FLAG_CLASS_BRANCH | S390_INSTR_FLAG_CLASS_RELATIVE \ 78*02f41505Schristos | S390_INSTR_FLAG_CLASS_SUBROUTINE) 79*02f41505Schristos 80*02f41505Schristos /* Instruction is an .insn pseudo-mnemonic. */ 81*02f41505Schristos #define S390_INSTR_FLAG_PSEUDO_MNEMONIC 0x100 82*02f41505Schristos 8398b9484cSchristos /* The opcode table is an array of struct s390_opcode. */ 8498b9484cSchristos 8598b9484cSchristos struct s390_opcode 8698b9484cSchristos { 87*02f41505Schristos /* The opcode name (mnemonic). */ 8898b9484cSchristos const char * name; 8998b9484cSchristos 9098b9484cSchristos /* The opcode itself. Those bits which will be filled in with 9198b9484cSchristos operands are zeroes. */ 9298b9484cSchristos unsigned char opcode[6]; 9398b9484cSchristos 9498b9484cSchristos /* The opcode mask. This is used by the disassembler. This is a 9598b9484cSchristos mask containing ones indicating those bits which must match the 9698b9484cSchristos opcode field, and zeroes indicating those bits which need not 9798b9484cSchristos match (and are presumably filled in by operands). */ 9898b9484cSchristos unsigned char mask[6]; 9998b9484cSchristos 10098b9484cSchristos /* The opcode length in bytes. */ 10198b9484cSchristos int oplen; 10298b9484cSchristos 10398b9484cSchristos /* An array of operand codes. Each code is an index into the 10498b9484cSchristos operand table. They appear in the order which the operands must 10598b9484cSchristos appear in assembly code, and are terminated by a zero. */ 10698b9484cSchristos unsigned char operands[6]; 10798b9484cSchristos 10898b9484cSchristos /* Bitmask of execution modes this opcode is available for. */ 10998b9484cSchristos unsigned int modes; 11098b9484cSchristos 11198b9484cSchristos /* First cpu this opcode is available for. */ 11298b9484cSchristos enum s390_opcode_cpu_val min_cpu; 113212397c6Schristos 114212397c6Schristos /* Instruction specific flags. */ 115212397c6Schristos unsigned int flags; 116*02f41505Schristos 117*02f41505Schristos /* Instruction description. */ 118*02f41505Schristos const char * description; 11998b9484cSchristos }; 12098b9484cSchristos 12198b9484cSchristos /* The table itself is sorted by major opcode number, and is otherwise 12298b9484cSchristos in the order in which the disassembler should consider 12398b9484cSchristos instructions. */ 12498b9484cSchristos extern const struct s390_opcode s390_opcodes[]; 12598b9484cSchristos extern const int s390_num_opcodes; 12698b9484cSchristos 12798b9484cSchristos /* A opcode format table for the .insn pseudo mnemonic. */ 12898b9484cSchristos extern const struct s390_opcode s390_opformats[]; 12998b9484cSchristos extern const int s390_num_opformats; 13098b9484cSchristos 13198b9484cSchristos /* The operands table is an array of struct s390_operand. */ 13298b9484cSchristos 13398b9484cSchristos struct s390_operand 13498b9484cSchristos { 13598b9484cSchristos /* The number of bits in the operand. */ 13698b9484cSchristos int bits; 13798b9484cSchristos 13898b9484cSchristos /* How far the operand is left shifted in the instruction. */ 13998b9484cSchristos int shift; 14098b9484cSchristos 14198b9484cSchristos /* One bit syntax flags. */ 14298b9484cSchristos unsigned long flags; 14398b9484cSchristos }; 14498b9484cSchristos 14598b9484cSchristos /* Elements in the table are retrieved by indexing with values from 146212397c6Schristos the operands field of the s390_opcodes table. */ 14798b9484cSchristos 14898b9484cSchristos extern const struct s390_operand s390_operands[]; 14998b9484cSchristos 15098b9484cSchristos /* Values defined for the flags field of a struct s390_operand. */ 15198b9484cSchristos 15298b9484cSchristos /* This operand names a register. The disassembler uses this to print 15398b9484cSchristos register names with a leading 'r'. */ 15498b9484cSchristos #define S390_OPERAND_GPR 0x1 15598b9484cSchristos 15698b9484cSchristos /* This operand names a floating point register. The disassembler 15798b9484cSchristos prints these with a leading 'f'. */ 15898b9484cSchristos #define S390_OPERAND_FPR 0x2 15998b9484cSchristos 16098b9484cSchristos /* This operand names an access register. The disassembler 16198b9484cSchristos prints these with a leading 'a'. */ 16298b9484cSchristos #define S390_OPERAND_AR 0x4 16398b9484cSchristos 16498b9484cSchristos /* This operand names a control register. The disassembler 16598b9484cSchristos prints these with a leading 'c'. */ 16698b9484cSchristos #define S390_OPERAND_CR 0x8 16798b9484cSchristos 16898b9484cSchristos /* This operand is a displacement. */ 16998b9484cSchristos #define S390_OPERAND_DISP 0x10 17098b9484cSchristos 17198b9484cSchristos /* This operand names a base register. */ 17298b9484cSchristos #define S390_OPERAND_BASE 0x20 17398b9484cSchristos 17498b9484cSchristos /* This operand names an index register, it can be skipped. */ 17598b9484cSchristos #define S390_OPERAND_INDEX 0x40 17698b9484cSchristos 17798b9484cSchristos /* This operand is a relative branch displacement. The disassembler 17898b9484cSchristos prints these symbolically if possible. */ 17998b9484cSchristos #define S390_OPERAND_PCREL 0x80 18098b9484cSchristos 18198b9484cSchristos /* This operand takes signed values. */ 18298b9484cSchristos #define S390_OPERAND_SIGNED 0x100 18398b9484cSchristos 18498b9484cSchristos /* This operand is a length. */ 18598b9484cSchristos #define S390_OPERAND_LENGTH 0x200 18698b9484cSchristos 187a2e2270fSchristos /* The operand needs to be a valid GP or FP register pair. */ 1884559860eSchristos #define S390_OPERAND_REG_PAIR 0x400 189a2e2270fSchristos 190212397c6Schristos /* This operand names a vector register. The disassembler uses this 191212397c6Schristos to print register names with a leading 'v'. */ 1924559860eSchristos #define S390_OPERAND_VR 0x800 193212397c6Schristos 1944559860eSchristos #define S390_OPERAND_CP16 0x1000 195212397c6Schristos 1964559860eSchristos #define S390_OPERAND_OR1 0x2000 1974559860eSchristos #define S390_OPERAND_OR2 0x4000 1984559860eSchristos #define S390_OPERAND_OR8 0x8000 199212397c6Schristos 20098b9484cSchristos #endif /* S390_H */ 201