[opcodes, ARM, 14/16] Add mode availability to coprocessor table entries
[binutils-gdb.git] / opcodes / s12z-opc.h
blob04e15595b3876279877b43a69d86ae1d12ae8b5e
1 /* s12z-dis.h -- Header file for s12z-dis.c and s12z-decode.c
2 Copyright (C) 2019 Free Software Foundation, Inc.
4 This file is part of the GNU opcodes library.
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
11 It is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING3. If not,
18 see <http://www.gnu.org/licenses/>. */
20 #ifndef S12Z_OPC_H
21 #define S12Z_OPC_H
23 #include <stdbool.h>
25 /* An abstraction used to read machine code from a source. */
26 struct mem_read_abstraction_base
28 int (*read) (struct mem_read_abstraction_base *, int, size_t, bfd_byte *);
29 void (*advance) (struct mem_read_abstraction_base *);
30 bfd_vma (*posn) (struct mem_read_abstraction_base *);
34 /* Machine code operators.
35 These *roughly* correspond to opcodes.
36 But describe their purpose rather than their form. */
37 enum optr
39 OP_INVALID = 0,
41 OP_push,
42 OP_pull,
43 /* Test and branch. */
44 OP_tbNE, OP_tbEQ, OP_tbPL, OP_tbMI, OP_tbGT, OP_tbLE,
45 /* Decrement and branch. */
46 OP_dbNE, OP_dbEQ, OP_dbPL, OP_dbMI, OP_dbGT, OP_dbLE,
48 /* Note: sex and exg are the same opcode.
49 They are mnemonic changes according to the operands. */
50 OP_sex,
51 OP_exg,
53 /* Shifters. */
54 OP_lsl, OP_lsr,
55 OP_asl, OP_asr,
56 OP_rol, OP_ror,
57 /* Bit field operations. */
58 OP_bfins, OP_bfext,
59 OP_trap,
61 OP_ld,
62 OP_st,
63 OP_cmp,
65 OP_stop,
66 OP_wai,
67 OP_sys,
69 OP_minu,
70 OP_mins,
71 OP_maxu,
72 OP_maxs,
74 OP_abs,
75 OP_adc,
76 OP_bit,
77 OP_sbc,
78 OP_rti,
79 OP_clb,
80 OP_eor,
82 OP_sat,
84 OP_nop,
85 OP_bgnd,
86 OP_brclr,
87 OP_brset,
88 OP_rts,
89 OP_lea,
90 OP_mov,
92 OP_bra,
93 OP_bsr,
94 OP_bhi,
95 OP_bls,
96 OP_bcc,
97 OP_bcs,
98 OP_bne,
99 OP_beq,
100 OP_bvc,
101 OP_bvs,
102 OP_bpl,
103 OP_bmi,
104 OP_bge,
105 OP_blt,
106 OP_bgt,
107 OP_ble,
108 OP_inc,
109 OP_clr,
110 OP_dec,
112 OP_add,
113 OP_sub,
114 OP_and,
115 OP_or,
117 OP_tfr,
118 OP_jmp,
119 OP_jsr,
120 OP_com,
121 OP_andcc,
122 OP_neg,
123 OP_orcc,
124 OP_bclr,
125 OP_bset,
126 OP_btgl,
127 OP_swi,
129 OP_mulu,
130 OP_divu,
131 OP_modu,
132 OP_macu,
133 OP_qmulu,
135 OP_muls,
136 OP_divs,
137 OP_mods,
138 OP_macs,
139 OP_qmuls,
141 OPBASE_mul = 0x4000,
142 OPBASE_div,
143 OPBASE_mod,
144 OPBASE_mac,
145 OPBASE_qmul,
147 n_OPS
151 /* Used for operands which mutate their index/base registers.
152 Eg ld d0, (s+). */
153 enum op_reg_mutation
155 OPND_RM_NONE,
156 OPND_RM_PRE_DEC,
157 OPND_RM_PRE_INC,
158 OPND_RM_POST_DEC,
159 OPND_RM_POST_INC
162 /* The class of an operand. */
163 enum opnd_class
165 OPND_CL_IMMEDIATE,
166 OPND_CL_MEMORY,
167 OPND_CL_REGISTER,
168 OPND_CL_REGISTER_ALL, /* Used only for psh/pul. */
169 OPND_CL_REGISTER_ALL16, /* Used only for psh/pul. */
170 OPND_CL_SIMPLE_MEMORY,
171 OPND_CL_BIT_FIELD
175 /* Base structure of all operands. */
176 struct operand
178 enum opnd_class cl;
180 /* OSIZE determines the size of memory access for
181 the operation in which the operand participates.
182 It may be -1 which indicates either unknown
183 (must be determined by other operands) or if
184 it is not applicable for this operation. */
185 int osize;
188 /* Immediate operands. Eg: #23 */
189 struct immediate_operand
191 struct operand parent;
192 int value;
195 /* Bitfield operands. Used only in bfext and bfins
196 instructions. */
197 struct bitfield_operand
199 struct operand parent;
200 int width;
201 int offset;
204 /* Register operands. */
205 struct register_operand
207 struct operand parent;
208 int reg;
212 /* Simple memory operands. ie, direct memory,
213 no index, no pre/post inc/dec. May be either relative or absolute.
214 Eg st d0, 0x123456 */
215 struct simple_memory_operand
217 struct operand parent;
219 bfd_vma addr;
220 bfd_vma base;
221 bool relative;
225 /* Memory operands. Should be able to represent all memory
226 operands in the S12Z instruction set which are not simple
227 memory operands. */
228 struct memory_operand
230 struct operand parent;
232 /* True for indirect operands: eg [0x123456] */
233 bool indirect;
235 /* The value of any offset. eg 45 in (45,d7) */
236 int base_offset;
238 /* Does this operand increment or decrement
239 its participating registers. Eg (-s) */
240 enum op_reg_mutation mutation;
242 /* The number of registers participating in this operand.
243 For S12Z this is always in the range [0, 6] (but for most
244 instructions it's <= 2). */
245 int n_regs;
247 /* The participating registers. */
248 int regs[6];
252 /* Decode a single instruction.
253 OPERATOR, OSIZE, N_OPERANDS and OPERANDS are pointers to
254 variables which must be provided by the caller.
255 N_OPERANDS will be incremented by the number of operands read, so
256 you should assign it to something before calling this function.
257 OPERANDS must be large enough to contain all operands read
258 (which may be up to 6).
259 It is the responsibility of the caller to free all operands
260 when they are no longer needed.
261 Returns the number of bytes read. */
262 int decode_s12z (enum optr *myoperator, short *osize,
263 int *n_operands, struct operand **operands,
264 struct mem_read_abstraction_base *);
267 #endif /* S12Z_OPC_H */