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