175fd0b74Schristos /* s390.h -- Header file for S390 opcode table 2*e992f068Schristos Copyright (C) 2000-2022 Free Software Foundation, Inc. 375fd0b74Schristos Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). 475fd0b74Schristos 575fd0b74Schristos This file is part of BFD, the Binary File Descriptor library. 675fd0b74Schristos 775fd0b74Schristos This program is free software; you can redistribute it and/or modify 875fd0b74Schristos it under the terms of the GNU General Public License as published by 975fd0b74Schristos the Free Software Foundation; either version 3 of the License, or 1075fd0b74Schristos (at your option) any later version. 1175fd0b74Schristos 1275fd0b74Schristos This program is distributed in the hope that it will be useful, 1375fd0b74Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1475fd0b74Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1575fd0b74Schristos GNU General Public License for more details. 1675fd0b74Schristos 1775fd0b74Schristos You should have received a copy of the GNU General Public License 1875fd0b74Schristos along with this program; if not, write to the Free Software 1975fd0b74Schristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 2075fd0b74Schristos 02110-1301, USA. */ 2175fd0b74Schristos 2275fd0b74Schristos #ifndef S390_H 2375fd0b74Schristos #define S390_H 2475fd0b74Schristos 2575fd0b74Schristos /* List of instruction sets variations. */ 2675fd0b74Schristos 2775fd0b74Schristos enum s390_opcode_mode_val 2875fd0b74Schristos { 2975fd0b74Schristos S390_OPCODE_ESA = 0, 3075fd0b74Schristos S390_OPCODE_ZARCH 3175fd0b74Schristos }; 3275fd0b74Schristos 3375fd0b74Schristos enum s390_opcode_cpu_val 3475fd0b74Schristos { 3575fd0b74Schristos S390_OPCODE_G5 = 0, 3675fd0b74Schristos S390_OPCODE_G6, 3775fd0b74Schristos S390_OPCODE_Z900, 3875fd0b74Schristos S390_OPCODE_Z990, 3975fd0b74Schristos S390_OPCODE_Z9_109, 4075fd0b74Schristos S390_OPCODE_Z9_EC, 4175fd0b74Schristos S390_OPCODE_Z10, 4275fd0b74Schristos S390_OPCODE_Z196, 4375fd0b74Schristos S390_OPCODE_ZEC12, 4475fd0b74Schristos S390_OPCODE_Z13, 45ede78133Schristos S390_OPCODE_ARCH12, 46012573ebSchristos S390_OPCODE_ARCH13, 47*e992f068Schristos S390_OPCODE_ARCH14, 4875fd0b74Schristos S390_OPCODE_MAXCPU 4975fd0b74Schristos }; 5075fd0b74Schristos 5175fd0b74Schristos /* Instruction specific flags. */ 5275fd0b74Schristos #define S390_INSTR_FLAG_OPTPARM 0x1 53ede78133Schristos #define S390_INSTR_FLAG_OPTPARM2 0x2 54ede78133Schristos 55ede78133Schristos #define S390_INSTR_FLAG_HTM 0x4 56ede78133Schristos #define S390_INSTR_FLAG_VX 0x8 57ede78133Schristos #define S390_INSTR_FLAG_FACILITY_MASK 0xc 5875fd0b74Schristos 5975fd0b74Schristos /* The opcode table is an array of struct s390_opcode. */ 6075fd0b74Schristos 6175fd0b74Schristos struct s390_opcode 6275fd0b74Schristos { 6375fd0b74Schristos /* The opcode name. */ 6475fd0b74Schristos const char * name; 6575fd0b74Schristos 6675fd0b74Schristos /* The opcode itself. Those bits which will be filled in with 6775fd0b74Schristos operands are zeroes. */ 6875fd0b74Schristos unsigned char opcode[6]; 6975fd0b74Schristos 7075fd0b74Schristos /* The opcode mask. This is used by the disassembler. This is a 7175fd0b74Schristos mask containing ones indicating those bits which must match the 7275fd0b74Schristos opcode field, and zeroes indicating those bits which need not 7375fd0b74Schristos match (and are presumably filled in by operands). */ 7475fd0b74Schristos unsigned char mask[6]; 7575fd0b74Schristos 7675fd0b74Schristos /* The opcode length in bytes. */ 7775fd0b74Schristos int oplen; 7875fd0b74Schristos 7975fd0b74Schristos /* An array of operand codes. Each code is an index into the 8075fd0b74Schristos operand table. They appear in the order which the operands must 8175fd0b74Schristos appear in assembly code, and are terminated by a zero. */ 8275fd0b74Schristos unsigned char operands[6]; 8375fd0b74Schristos 8475fd0b74Schristos /* Bitmask of execution modes this opcode is available for. */ 8575fd0b74Schristos unsigned int modes; 8675fd0b74Schristos 8775fd0b74Schristos /* First cpu this opcode is available for. */ 8875fd0b74Schristos enum s390_opcode_cpu_val min_cpu; 8975fd0b74Schristos 9075fd0b74Schristos /* Instruction specific flags. */ 9175fd0b74Schristos unsigned int flags; 9275fd0b74Schristos }; 9375fd0b74Schristos 9475fd0b74Schristos /* The table itself is sorted by major opcode number, and is otherwise 9575fd0b74Schristos in the order in which the disassembler should consider 9675fd0b74Schristos instructions. */ 9775fd0b74Schristos extern const struct s390_opcode s390_opcodes[]; 9875fd0b74Schristos extern const int s390_num_opcodes; 9975fd0b74Schristos 10075fd0b74Schristos /* A opcode format table for the .insn pseudo mnemonic. */ 10175fd0b74Schristos extern const struct s390_opcode s390_opformats[]; 10275fd0b74Schristos extern const int s390_num_opformats; 10375fd0b74Schristos 10475fd0b74Schristos /* Values defined for the flags field of a struct s390_opcode. */ 10575fd0b74Schristos 10675fd0b74Schristos /* The operands table is an array of struct s390_operand. */ 10775fd0b74Schristos 10875fd0b74Schristos struct s390_operand 10975fd0b74Schristos { 11075fd0b74Schristos /* The number of bits in the operand. */ 11175fd0b74Schristos int bits; 11275fd0b74Schristos 11375fd0b74Schristos /* How far the operand is left shifted in the instruction. */ 11475fd0b74Schristos int shift; 11575fd0b74Schristos 11675fd0b74Schristos /* One bit syntax flags. */ 11775fd0b74Schristos unsigned long flags; 11875fd0b74Schristos }; 11975fd0b74Schristos 12075fd0b74Schristos /* Elements in the table are retrieved by indexing with values from 12175fd0b74Schristos the operands field of the s390_opcodes table. */ 12275fd0b74Schristos 12375fd0b74Schristos extern const struct s390_operand s390_operands[]; 12475fd0b74Schristos 12575fd0b74Schristos /* Values defined for the flags field of a struct s390_operand. */ 12675fd0b74Schristos 12775fd0b74Schristos /* This operand names a register. The disassembler uses this to print 12875fd0b74Schristos register names with a leading 'r'. */ 12975fd0b74Schristos #define S390_OPERAND_GPR 0x1 13075fd0b74Schristos 13175fd0b74Schristos /* This operand names a floating point register. The disassembler 13275fd0b74Schristos prints these with a leading 'f'. */ 13375fd0b74Schristos #define S390_OPERAND_FPR 0x2 13475fd0b74Schristos 13575fd0b74Schristos /* This operand names an access register. The disassembler 13675fd0b74Schristos prints these with a leading 'a'. */ 13775fd0b74Schristos #define S390_OPERAND_AR 0x4 13875fd0b74Schristos 13975fd0b74Schristos /* This operand names a control register. The disassembler 14075fd0b74Schristos prints these with a leading 'c'. */ 14175fd0b74Schristos #define S390_OPERAND_CR 0x8 14275fd0b74Schristos 14375fd0b74Schristos /* This operand is a displacement. */ 14475fd0b74Schristos #define S390_OPERAND_DISP 0x10 14575fd0b74Schristos 14675fd0b74Schristos /* This operand names a base register. */ 14775fd0b74Schristos #define S390_OPERAND_BASE 0x20 14875fd0b74Schristos 14975fd0b74Schristos /* This operand names an index register, it can be skipped. */ 15075fd0b74Schristos #define S390_OPERAND_INDEX 0x40 15175fd0b74Schristos 15275fd0b74Schristos /* This operand is a relative branch displacement. The disassembler 15375fd0b74Schristos prints these symbolically if possible. */ 15475fd0b74Schristos #define S390_OPERAND_PCREL 0x80 15575fd0b74Schristos 15675fd0b74Schristos /* This operand takes signed values. */ 15775fd0b74Schristos #define S390_OPERAND_SIGNED 0x100 15875fd0b74Schristos 15975fd0b74Schristos /* This operand is a length. */ 16075fd0b74Schristos #define S390_OPERAND_LENGTH 0x200 16175fd0b74Schristos 16275fd0b74Schristos /* The operand needs to be a valid GP or FP register pair. */ 163ede78133Schristos #define S390_OPERAND_REG_PAIR 0x400 16475fd0b74Schristos 16575fd0b74Schristos /* This operand names a vector register. The disassembler uses this 16675fd0b74Schristos to print register names with a leading 'v'. */ 167ede78133Schristos #define S390_OPERAND_VR 0x800 16875fd0b74Schristos 169ede78133Schristos #define S390_OPERAND_CP16 0x1000 17075fd0b74Schristos 171ede78133Schristos #define S390_OPERAND_OR1 0x2000 172ede78133Schristos #define S390_OPERAND_OR2 0x4000 173ede78133Schristos #define S390_OPERAND_OR8 0x8000 17475fd0b74Schristos 17575fd0b74Schristos #endif /* S390_H */ 176