Coverage Report

Created: 2026-07-12 09:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/opcodes/aarch64-opc.h
Line
Count
Source
1
/* aarch64-opc.h -- Header file for aarch64-opc.c and aarch64-opc-2.c.
2
   Copyright (C) 2012-2026 Free Software Foundation, Inc.
3
   Contributed by ARM Ltd.
4
5
   This file is part of the GNU opcodes library.
6
7
   This library is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3, or (at your option)
10
   any later version.
11
12
   It is distributed in the hope that it will be useful, but WITHOUT
13
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15
   License for more details.
16
17
   You should have received a copy of the GNU General Public License
18
   along with this program; see the file COPYING3. If not,
19
   see <http://www.gnu.org/licenses/>.  */
20
21
#ifndef OPCODES_AARCH64_OPC_H
22
#define OPCODES_AARCH64_OPC_H
23
24
#include <string.h>
25
#include "opcode/aarch64.h"
26
27
/* Field description.
28
29
   If is_const is false, this identifies a bitfield in an instruction encoding
30
   that has size WIDTH and has its least significant bit at position NUM.
31
32
   If is_const is true, this represents the constant bit string of size WIDTH
33
   bits stored in the least significant bits of NUM.  In this case, the
34
   leading 8-WIDTH bits of VALUE must be zero.
35
36
   A sequence of fields can be used to describe how instruction operands are
37
   represented in the 32-bit instruction encoding.
38
39
   For example, consider an instruction operand Zd that is an even numbered
40
   register in z16-z30, with the middle three bits of the register number
41
   stored in bits [19:17] of the encoding.  The register number can then be
42
   constructed by concatenating:
43
   - a constant bit '1' (represented here as {1, 1, true}),
44
   - bits [19:17] of the encoding (represented here as {3, 17, false}), and
45
   - a constant bit '0' (represented here as {1, 0, true}).
46
   This sequence of fields fully describes both the constraints on which
47
   register numbers are valid, and how valid register numbers are represented
48
   in the instruction encoding.  */
49
struct aarch64_field
50
{
51
  unsigned int width:8;
52
  unsigned int num:7;
53
  bool is_const:1;
54
};
55
56
typedef struct aarch64_field aarch64_field;
57
58
10.7M
#define AARCH64_FIELD(lsb, width) ((aarch64_field) {width, lsb, false})
59
#define AARCH64_FIELD_CONST(val, width) ((aarch64_field) {width, val, true})
60
69.7k
#define AARCH64_FIELD_NIL ((aarch64_field) {0, 0, false})
61
62
#define FLD_CONST_0 AARCH64_FIELD_CONST (0, 1)
63
#define FLD_CONST_00 AARCH64_FIELD_CONST (0, 2)
64
#define FLD_CONST_01 AARCH64_FIELD_CONST (1, 2)
65
#define FLD_CONST_1 AARCH64_FIELD_CONST (1, 1)
66
67
/* Instruction fields.  These defines are included to reduce the initial diff
68
   size, but the indirection should eventually be eliminated.  */
69
34.7k
#define FLD_CRm                AARCH64_FIELD( 8,  4)
70
422
#define FLD_CRm_dsb_nxs        AARCH64_FIELD(10,  2)
71
33.7k
#define FLD_CRn                AARCH64_FIELD(12,  4)
72
78.9k
#define FLD_H                  AARCH64_FIELD(11,  1)
73
77.5k
#define FLD_L                  AARCH64_FIELD(21,  1)
74
37.1k
#define FLD_M                  AARCH64_FIELD(20,  1)
75
143k
#define FLD_N                  AARCH64_FIELD(22,  1)
76
873k
#define FLD_Q                  AARCH64_FIELD(30,  1)
77
624k
#define FLD_Rm                 AARCH64_FIELD(16,  5)
78
982k
#define FLD_Rn                 AARCH64_FIELD( 5,  5)
79
717k
#define FLD_Rt                 AARCH64_FIELD( 0,  5)
80
96.8k
#define FLD_S                  AARCH64_FIELD(12,  1)
81
1.09k
#define FLD_SM3_imm2           AARCH64_FIELD(12,  2)
82
72.0k
#define FLD_SME_Q              AARCH64_FIELD(16,  1)
83
2.02k
#define FLD_SME_size_12        AARCH64_FIELD(12,  2)
84
84.3k
#define FLD_SME_size_22        AARCH64_FIELD(22,  2)
85
173
#define FLD_SME_sz_23          AARCH64_FIELD(23,  1)
86
7.09k
#define FLD_SME_tszh           AARCH64_FIELD(22,  1)
87
7.09k
#define FLD_SME_tszl           AARCH64_FIELD(18,  3)
88
183
#define FLD_SVE_M_4            AARCH64_FIELD( 4,  1)
89
13.7k
#define FLD_SVE_M_14           AARCH64_FIELD(14,  1)
90
3.50k
#define FLD_SVE_M_16           AARCH64_FIELD(16,  1)
91
93.9k
#define FLD_SVE_imm4           AARCH64_FIELD(16,  4)
92
20.1k
#define FLD_SVE_imm6           AARCH64_FIELD(16,  6)
93
2.07k
#define FLD_SVE_msz            AARCH64_FIELD(10,  2)
94
289
#define FLD_SVE_size           AARCH64_FIELD(17,  2)
95
18.7k
#define FLD_SVE_sz             AARCH64_FIELD(22,  1)
96
5.92k
#define FLD_SVE_sz2            AARCH64_FIELD(30,  1)
97
670
#define FLD_SVE_sz3            AARCH64_FIELD(17,  1)
98
150
#define FLD_SVE_sz4            AARCH64_FIELD(14,  1)
99
8.76k
#define FLD_SVE_tszh           AARCH64_FIELD(22,  2)
100
4.63k
#define FLD_SVE_tszl_8         AARCH64_FIELD( 8,  2)
101
10.1k
#define FLD_SVE_tszl_19        AARCH64_FIELD(19,  2)
102
6.29k
#define FLD_abc                AARCH64_FIELD(16,  3)
103
29.7k
#define FLD_asisdlso_opcode    AARCH64_FIELD(13,  3)
104
3.19k
#define FLD_cmode              AARCH64_FIELD(12,  4)
105
24.9k
#define FLD_cond               AARCH64_FIELD(12,  4)
106
38.5k
#define FLD_cond2              AARCH64_FIELD( 0,  4)
107
6.29k
#define FLD_defgh              AARCH64_FIELD( 5,  5)
108
96.0k
#define FLD_hw                 AARCH64_FIELD(21,  2)
109
169
#define FLD_imm1_22            AARCH64_FIELD(22,  1)
110
#define FLD_imm3_5             AARCH64_FIELD( 5,  3)
111
53.3k
#define FLD_imm3_10            AARCH64_FIELD(10,  3)
112
3.03k
#define FLD_imm3_19            AARCH64_FIELD(19,  3)
113
770
#define FLD_imm4_5             AARCH64_FIELD( 5,  4)
114
3.39k
#define FLD_imm4_11            AARCH64_FIELD(11,  4)
115
40.6k
#define FLD_imm5               AARCH64_FIELD(16,  5)
116
472k
#define FLD_imm6_10            AARCH64_FIELD(10,  6)
117
394k
#define FLD_imm12              AARCH64_FIELD(10, 12)
118
31.1k
#define FLD_immb               AARCH64_FIELD(16,  3)
119
67.2k
#define FLD_immh               AARCH64_FIELD(19,  4)
120
820k
#define FLD_ldst_size          AARCH64_FIELD(30,  2)
121
15.7k
#define FLD_len                AARCH64_FIELD(13,  2)
122
34.2k
#define FLD_lse_sz             AARCH64_FIELD(30,  1)
123
33.7k
#define FLD_op0                AARCH64_FIELD(19,  2)
124
33.9k
#define FLD_op1                AARCH64_FIELD(16,  3)
125
34.3k
#define FLD_op2                AARCH64_FIELD( 5,  3)
126
32.8k
#define FLD_opc                AARCH64_FIELD(22,  2)
127
228k
#define FLD_opc1               AARCH64_FIELD(23,  1)
128
54.3k
#define FLD_opcode             AARCH64_FIELD(12,  4)
129
111k
#define FLD_option             AARCH64_FIELD(13,  3)
130
2.44k
#define FLD_scale              AARCH64_FIELD(10,  6)
131
2.10M
#define FLD_sf                 AARCH64_FIELD(31,  1)
132
1.01M
#define FLD_shift              AARCH64_FIELD(22,  2)
133
663k
#define FLD_size               AARCH64_FIELD(22,  2)
134
2.64k
#define FLD_sz                 AARCH64_FIELD(22,  1)
135
63.1k
#define FLD_type               AARCH64_FIELD(22,  2)
136
85.9k
#define FLD_vldst_size         AARCH64_FIELD(10,  2)
137
#define FLD_off2               AARCH64_FIELD( 5,  2)
138
#define FLD_ol                 AARCH64_FIELD( 5,  1)
139
16.1k
#define FLD_opc2               AARCH64_FIELD(12,  4)
140
25.9k
#define FLD_rcpc3_size         AARCH64_FIELD(30,  2)
141
#define FLD_ZA8_1              AARCH64_FIELD( 8,  1)
142
#define FLD_ZA7_2              AARCH64_FIELD( 7,  2)
143
#define FLD_ZA6_3              AARCH64_FIELD( 6,  3)
144
#define FLD_ZA5_4              AARCH64_FIELD( 5,  4)
145
146

147
/* Operand description.  */
148
149
struct aarch64_operand
150
{
151
  enum aarch64_operand_class op_class;
152
153
  /* Name of the operand code; used mainly for the purpose of internal
154
     debugging.  */
155
  const char *name;
156
157
  unsigned int flags;
158
159
  /* The associated instruction bit-fields; no operand has more than 5
160
     bit-fields */
161
  aarch64_field fields[6];
162
163
  /* Brief description */
164
  const char *desc;
165
};
166
167
typedef struct aarch64_operand aarch64_operand;
168
169
extern const aarch64_operand aarch64_operands[];
170
171
enum err_type
172
verify_constraints (const struct aarch64_inst *, const aarch64_insn, bfd_vma,
173
        bool, aarch64_operand_error *, aarch64_instr_sequence*);
174
175
/* Operand flags.  */
176
177
#define OPD_F_HAS_INSERTER  0x00000001
178
17.5M
#define OPD_F_HAS_EXTRACTOR 0x00000002
179
3.52M
#define OPD_F_SEXT    0x00000004  /* Require sign-extension.  */
180
4.69M
#define OPD_F_SHIFT_BY_2  0x00000008  /* Need to left shift the field
181
               value by 2 to get the value
182
               of an immediate operand.  */
183
147k
#define OPD_F_MAYBE_SP    0x00000010  /* May potentially be SP.  */
184
912k
#define OPD_F_OD_MASK   0x000001e0  /* Operand-dependent data.  */
185
912k
#define OPD_F_OD_LSB    5
186
213k
#define OPD_F_NO_ZR   0x00000200  /* ZR index not allowed.  */
187
2.65M
#define OPD_F_SHIFT_BY_3  0x00000400  /* Need to left shift the field
188
               value by 3 to get the value
189
               of an immediate operand.  */
190
2.65M
#define OPD_F_SHIFT_BY_4  0x00000800  /* Need to left shift the field
191
               value by 4 to get the value
192
               of an immediate operand.  */
193
1.17M
#define OPD_F_UNSIGNED    0x00001000  /* Expect an unsigned value.  */
194
195
196
/* Register flags.  */
197
198
#undef F_DEPRECATED
199
1.54k
#define F_DEPRECATED  (1 << 0)  /* Deprecated system register.  */
200
201
/*      (1 << 1)     Unused.  */
202
203
#undef F_HASXT
204
1.23k
#define F_HASXT   (1 << 2)  /* System instruction register <Xt>
205
             operand.  */
206
207
#undef F_REG_READ
208
8.34k
#define F_REG_READ  (1 << 3)  /* Register can only be used to read values
209
             out of.  */
210
211
#undef F_REG_WRITE
212
10.2k
#define F_REG_WRITE (1 << 4)  /* Register can only be written to but not
213
             read from.  */
214
215
#undef F_REG_IN_CRM
216
686
#define F_REG_IN_CRM  (1 << 5)  /* Register extra encoding in CRm.  */
217
218
#undef F_REG_ALIAS
219
1.54k
#define F_REG_ALIAS (1 << 6)  /* Register name aliases another.  */
220
221
#undef F_REG_128
222
0
#define F_REG_128 (1 << 7) /* System register implementable as 128-bit wide.  */
223
224
#undef F_TLBID_XT
225
942
#define F_TLBID_XT  (1 << 8)  /* System instruction register <Xt> as optional operand.  */
226
227
228
/* PSTATE field name for the MSR instruction this is encoded in "op1:op2:CRm".
229
   Part of CRm can be used to encode <pstatefield>. E.g. CRm[3:1] for SME.
230
   In order to set/get full PSTATE field name use flag F_REG_IN_CRM and below
231
   macros to encode and decode CRm encoding.
232
*/
233
#define PSTATE_ENCODE_CRM(val) (val << 6)
234
63
#define PSTATE_DECODE_CRM(flags) ((flags >> 6) & 0x0f)
235
236
#undef F_IMM_IN_CRM
237
223
#define F_IMM_IN_CRM  (1 << 10)  /* Immediate extra encoding in CRm.  */
238
239
/* Also CRm may contain, in addition to <pstatefield> immediate.
240
   E.g. CRm[0] <imm1> at bit 0 for SME. Use below macros to encode and decode
241
   immediate mask.
242
*/
243
#define PSTATE_ENCODE_CRM_IMM(mask) (mask << 11)
244
0
#define PSTATE_DECODE_CRM_IMM(mask) ((mask >> 11) & 0x0f)
245
246
/* Helper macro to ENCODE CRm and its immediate.  */
247
#define PSTATE_ENCODE_CRM_AND_IMM(CVAL,IMASK) \
248
        (F_REG_IN_CRM | PSTATE_ENCODE_CRM(CVAL) \
249
         | F_IMM_IN_CRM | PSTATE_ENCODE_CRM_IMM(IMASK))
250
251
/* Bits [15, 18] contain the maximum value for an immediate MSR.  */
252
#define F_REG_MAX_VALUE(X) ((X) << 15)
253
223
#define F_GET_REG_MAX_VALUE(X) (((X) >> 15) & 0x0f)
254
255
static inline bool
256
operand_has_inserter (const aarch64_operand *operand)
257
0
{
258
0
  return (operand->flags & OPD_F_HAS_INSERTER) != 0;
259
0
}
Unexecuted instantiation: aarch64-dis.c:operand_has_inserter
Unexecuted instantiation: aarch64-dis-2.c:operand_has_inserter
Unexecuted instantiation: aarch64-opc.c:operand_has_inserter
Unexecuted instantiation: aarch64-opc-2.c:operand_has_inserter
260
261
static inline bool
262
operand_has_extractor (const aarch64_operand *operand)
263
17.5M
{
264
17.5M
  return (operand->flags & OPD_F_HAS_EXTRACTOR) != 0;
265
17.5M
}
aarch64-dis.c:operand_has_extractor
Line
Count
Source
263
17.5M
{
264
17.5M
  return (operand->flags & OPD_F_HAS_EXTRACTOR) != 0;
265
17.5M
}
Unexecuted instantiation: aarch64-dis-2.c:operand_has_extractor
Unexecuted instantiation: aarch64-opc.c:operand_has_extractor
Unexecuted instantiation: aarch64-opc-2.c:operand_has_extractor
266
267
static inline bool
268
operand_need_sign_extension (const aarch64_operand *operand)
269
3.52M
{
270
3.52M
  return (operand->flags & OPD_F_SEXT) != 0;
271
3.52M
}
aarch64-dis.c:operand_need_sign_extension
Line
Count
Source
269
3.52M
{
270
3.52M
  return (operand->flags & OPD_F_SEXT) != 0;
271
3.52M
}
Unexecuted instantiation: aarch64-dis-2.c:operand_need_sign_extension
Unexecuted instantiation: aarch64-opc.c:operand_need_sign_extension
Unexecuted instantiation: aarch64-opc-2.c:operand_need_sign_extension
272
273
static inline bool
274
operand_need_shift_by_two (const aarch64_operand *operand)
275
4.69M
{
276
4.69M
  return (operand->flags & OPD_F_SHIFT_BY_2) != 0;
277
4.69M
}
aarch64-dis.c:operand_need_shift_by_two
Line
Count
Source
275
3.52M
{
276
3.52M
  return (operand->flags & OPD_F_SHIFT_BY_2) != 0;
277
3.52M
}
Unexecuted instantiation: aarch64-dis-2.c:operand_need_shift_by_two
aarch64-opc.c:operand_need_shift_by_two
Line
Count
Source
275
1.17M
{
276
1.17M
  return (operand->flags & OPD_F_SHIFT_BY_2) != 0;
277
1.17M
}
Unexecuted instantiation: aarch64-opc-2.c:operand_need_shift_by_two
278
279
static inline bool
280
operand_need_shift_by_three (const aarch64_operand *operand)
281
2.65M
{
282
2.65M
  return (operand->flags & OPD_F_SHIFT_BY_3) != 0;
283
2.65M
}
aarch64-dis.c:operand_need_shift_by_three
Line
Count
Source
281
2.65M
{
282
2.65M
  return (operand->flags & OPD_F_SHIFT_BY_3) != 0;
283
2.65M
}
Unexecuted instantiation: aarch64-dis-2.c:operand_need_shift_by_three
Unexecuted instantiation: aarch64-opc.c:operand_need_shift_by_three
Unexecuted instantiation: aarch64-opc-2.c:operand_need_shift_by_three
284
285
static inline bool
286
operand_need_shift_by_four (const aarch64_operand *operand)
287
2.65M
{
288
2.65M
  return (operand->flags & OPD_F_SHIFT_BY_4) != 0;
289
2.65M
}
aarch64-dis.c:operand_need_shift_by_four
Line
Count
Source
287
2.65M
{
288
2.65M
  return (operand->flags & OPD_F_SHIFT_BY_4) != 0;
289
2.65M
}
Unexecuted instantiation: aarch64-dis-2.c:operand_need_shift_by_four
Unexecuted instantiation: aarch64-opc.c:operand_need_shift_by_four
Unexecuted instantiation: aarch64-opc-2.c:operand_need_shift_by_four
290
291
static inline bool
292
operand_need_unsigned_offset (const aarch64_operand *operand)
293
1.17M
{
294
1.17M
  return (operand->flags & OPD_F_UNSIGNED) != 0;
295
1.17M
}
Unexecuted instantiation: aarch64-dis.c:operand_need_unsigned_offset
Unexecuted instantiation: aarch64-dis-2.c:operand_need_unsigned_offset
aarch64-opc.c:operand_need_unsigned_offset
Line
Count
Source
293
1.17M
{
294
1.17M
  return (operand->flags & OPD_F_UNSIGNED) != 0;
295
1.17M
}
Unexecuted instantiation: aarch64-opc-2.c:operand_need_unsigned_offset
296
297
static inline bool
298
operand_maybe_stack_pointer (const aarch64_operand *operand)
299
147k
{
300
147k
  return (operand->flags & OPD_F_MAYBE_SP) != 0;
301
147k
}
Unexecuted instantiation: aarch64-dis.c:operand_maybe_stack_pointer
Unexecuted instantiation: aarch64-dis-2.c:operand_maybe_stack_pointer
aarch64-opc.c:operand_maybe_stack_pointer
Line
Count
Source
299
147k
{
300
147k
  return (operand->flags & OPD_F_MAYBE_SP) != 0;
301
147k
}
Unexecuted instantiation: aarch64-opc-2.c:operand_maybe_stack_pointer
302
303
/* Return the value of the operand-specific data field (OPD_F_OD_MASK).  */
304
static inline unsigned int
305
get_operand_specific_data (const aarch64_operand *operand)
306
912k
{
307
912k
  return (operand->flags & OPD_F_OD_MASK) >> OPD_F_OD_LSB;
308
912k
}
aarch64-dis.c:get_operand_specific_data
Line
Count
Source
306
486k
{
307
486k
  return (operand->flags & OPD_F_OD_MASK) >> OPD_F_OD_LSB;
308
486k
}
Unexecuted instantiation: aarch64-dis-2.c:get_operand_specific_data
aarch64-opc.c:get_operand_specific_data
Line
Count
Source
306
425k
{
307
425k
  return (operand->flags & OPD_F_OD_MASK) >> OPD_F_OD_LSB;
308
425k
}
Unexecuted instantiation: aarch64-opc-2.c:get_operand_specific_data
309
310
/* Return the width of field number N of operand *OPERAND.  */
311
static inline unsigned
312
get_operand_field_width (const aarch64_operand *operand, unsigned n)
313
486
{
314
486
  assert (operand->fields[n].width != 0);
315
486
  return operand->fields[n].width;
316
486
}
aarch64-dis.c:get_operand_field_width
Line
Count
Source
313
338
{
314
338
  assert (operand->fields[n].width != 0);
315
338
  return operand->fields[n].width;
316
338
}
Unexecuted instantiation: aarch64-dis-2.c:get_operand_field_width
aarch64-opc.c:get_operand_field_width
Line
Count
Source
313
148
{
314
148
  assert (operand->fields[n].width != 0);
315
148
  return operand->fields[n].width;
316
148
}
Unexecuted instantiation: aarch64-opc-2.c:get_operand_field_width
317
318
/* Return the total width of the operand *OPERAND.  */
319
static inline unsigned
320
get_operand_fields_width (const aarch64_operand *operand)
321
4.33M
{
322
4.33M
  int i = 0;
323
4.33M
  unsigned width = 0;
324
9.57M
  while (operand->fields[i].width != 0)
325
5.23M
    width += operand->fields[i++].width;
326
4.33M
  assert (width > 0 && width < 32);
327
4.33M
  return width;
328
4.33M
}
aarch64-dis.c:get_operand_fields_width
Line
Count
Source
321
1.31M
{
322
1.31M
  int i = 0;
323
1.31M
  unsigned width = 0;
324
3.06M
  while (operand->fields[i].width != 0)
325
1.75M
    width += operand->fields[i++].width;
326
1.31M
  assert (width > 0 && width < 32);
327
1.31M
  return width;
328
1.31M
}
Unexecuted instantiation: aarch64-dis-2.c:get_operand_fields_width
aarch64-opc.c:get_operand_fields_width
Line
Count
Source
321
3.01M
{
322
3.01M
  int i = 0;
323
3.01M
  unsigned width = 0;
324
6.50M
  while (operand->fields[i].width != 0)
325
3.48M
    width += operand->fields[i++].width;
326
3.01M
  assert (width > 0 && width < 32);
327
3.01M
  return width;
328
3.01M
}
Unexecuted instantiation: aarch64-opc-2.c:get_operand_fields_width
329
330
static inline const aarch64_operand *
331
get_operand_from_code (enum aarch64_opnd code)
332
4.19M
{
333
4.19M
  return aarch64_operands + code;
334
4.19M
}
Unexecuted instantiation: aarch64-dis.c:get_operand_from_code
Unexecuted instantiation: aarch64-dis-2.c:get_operand_from_code
aarch64-opc.c:get_operand_from_code
Line
Count
Source
332
4.19M
{
333
4.19M
  return aarch64_operands + code;
334
4.19M
}
Unexecuted instantiation: aarch64-opc-2.c:get_operand_from_code
335

336
/* Operand qualifier and operand constraint checking.  */
337
338
bool aarch64_match_operands_constraint (aarch64_inst *,
339
               aarch64_operand_error *);
340
341
/* Operand qualifier related functions.  */
342
const char* aarch64_get_qualifier_name (aarch64_opnd_qualifier_t);
343
unsigned char aarch64_get_qualifier_nelem (aarch64_opnd_qualifier_t);
344
aarch64_insn aarch64_get_qualifier_standard_value (aarch64_opnd_qualifier_t);
345
int aarch64_find_best_match (const aarch64_inst *,
346
           const aarch64_opnd_qualifier_seq_t *,
347
           int, aarch64_opnd_qualifier_t *, int *);
348
349
static inline void
350
reset_operand_qualifier (aarch64_inst *inst, int idx)
351
56.3k
{
352
56.3k
  assert (idx >=0 && idx < aarch64_num_of_operands (inst->opcode));
353
56.3k
  inst->operands[idx].qualifier = AARCH64_OPND_QLF_UNKNOWN;
354
56.3k
}
aarch64-dis.c:reset_operand_qualifier
Line
Count
Source
351
56.3k
{
352
56.3k
  assert (idx >=0 && idx < aarch64_num_of_operands (inst->opcode));
353
56.3k
  inst->operands[idx].qualifier = AARCH64_OPND_QLF_UNKNOWN;
354
56.3k
}
Unexecuted instantiation: aarch64-dis-2.c:reset_operand_qualifier
Unexecuted instantiation: aarch64-opc.c:reset_operand_qualifier
Unexecuted instantiation: aarch64-opc-2.c:reset_operand_qualifier
355

356
/* Inline functions operating on instruction bit-field(s).  */
357
358
/* Generate a mask that has WIDTH number of consecutive 1s.  */
359
360
static inline aarch64_insn
361
gen_mask (int width)
362
29.3M
{
363
29.3M
  return ((aarch64_insn) 1 << width) - 1;
364
29.3M
}
aarch64-dis.c:gen_mask
Line
Count
Source
362
29.3M
{
363
29.3M
  return ((aarch64_insn) 1 << width) - 1;
364
29.3M
}
Unexecuted instantiation: aarch64-dis-2.c:gen_mask
Unexecuted instantiation: aarch64-opc.c:gen_mask
Unexecuted instantiation: aarch64-opc-2.c:gen_mask
365
366
/* LSB_REL is the relative location of the lsb in the sub field, starting from 0.  */
367
static inline int
368
gen_sub_field (aarch64_field field, int lsb_rel, int width, aarch64_field *ret)
369
66.6k
{
370
66.6k
  if (lsb_rel < 0 || width <= 0 || lsb_rel + width > field.width)
371
101
    return 0;
372
66.5k
  ret->num = field.num + lsb_rel;
373
66.5k
  ret->width = width;
374
66.5k
  return 1;
375
66.6k
}
aarch64-dis.c:gen_sub_field
Line
Count
Source
369
66.6k
{
370
66.6k
  if (lsb_rel < 0 || width <= 0 || lsb_rel + width > field.width)
371
101
    return 0;
372
66.5k
  ret->num = field.num + lsb_rel;
373
66.5k
  ret->width = width;
374
66.5k
  return 1;
375
66.6k
}
Unexecuted instantiation: aarch64-dis-2.c:gen_sub_field
Unexecuted instantiation: aarch64-opc.c:gen_sub_field
Unexecuted instantiation: aarch64-opc-2.c:gen_sub_field
376
377
/* Insert VALUE into FIELD of CODE.  MASK can be zero or the base mask
378
   of the opcode.  */
379
380
static inline void
381
insert_field (aarch64_field field, aarch64_insn *code,
382
        aarch64_insn value, aarch64_insn mask)
383
0
{
384
0
  assert (field.width < 32 && field.width >= 1
385
0
    && (field.is_const ? (field.num < 1 << field.width)
386
0
            : (field.num + field.width <= 32)));
387
0
  value &= gen_mask (field.width);
388
0
  if (field.is_const)
389
0
    {
390
0
      assert (value == field.num);
391
0
      return;
392
0
    }
393
0
  value <<= field.num;
394
0
  /* In some opcodes, field can be part of the base opcode, e.g. the size
395
0
     field in FADD.  The following helps avoid corrupt the base opcode.  */
396
0
  value &= ~mask;
397
0
  *code |= value;
398
0
}
Unexecuted instantiation: aarch64-dis.c:insert_field
Unexecuted instantiation: aarch64-dis-2.c:insert_field
Unexecuted instantiation: aarch64-opc.c:insert_field
Unexecuted instantiation: aarch64-opc-2.c:insert_field
399
400
/* Extract FIELD of CODE and return the value.  MASK can be zero or the base
401
   mask of the opcode.  */
402
403
static inline aarch64_insn
404
extract_field (aarch64_field field, aarch64_insn code,
405
         aarch64_insn mask)
406
29.4M
{
407
29.4M
  aarch64_insn value;
408
  /* Check for constant field.  */
409
29.4M
  if (field.is_const)
410
161k
    return field.num;
411
412
  /* Clear any bit that is a part of the base opcode.  */
413
29.3M
  code &= ~mask;
414
29.3M
  value = (code >> field.num) & gen_mask (field.width);
415
29.3M
  return value;
416
29.4M
}
aarch64-dis.c:extract_field
Line
Count
Source
406
29.4M
{
407
29.4M
  aarch64_insn value;
408
  /* Check for constant field.  */
409
29.4M
  if (field.is_const)
410
161k
    return field.num;
411
412
  /* Clear any bit that is a part of the base opcode.  */
413
29.3M
  code &= ~mask;
414
29.3M
  value = (code >> field.num) & gen_mask (field.width);
415
29.3M
  return value;
416
29.4M
}
Unexecuted instantiation: aarch64-dis-2.c:extract_field
Unexecuted instantiation: aarch64-opc.c:extract_field
Unexecuted instantiation: aarch64-opc-2.c:extract_field
417
418
extern aarch64_insn
419
extract_fields (aarch64_insn code, aarch64_insn mask, ...);
420

421
/* Inline functions selecting operand to do the encoding/decoding for a
422
   certain instruction bit-field.  */
423
424
/* Select the operand to do the encoding/decoding of the 'sf' field.
425
   The heuristic-based rule is that the result operand is respected more.  */
426
427
static inline int
428
select_operand_for_sf_field_coding (const aarch64_opcode *opcode)
429
2.14M
{
430
2.14M
  int idx = -1;
431
2.14M
  if (opcode->iclass == fprcvtfloat2int)
432
1.54k
    return 0;
433
2.13M
  else if (opcode->iclass == fprcvtint2float)
434
191
    return 1;
435
436
2.13M
  if (aarch64_get_operand_class (opcode->operands[0])
437
2.13M
      == AARCH64_OPND_CLASS_INT_REG)
438
    /* normal case.  */
439
2.13M
    idx = 0;
440
1.24k
  else if (aarch64_get_operand_class (opcode->operands[1])
441
1.24k
     == AARCH64_OPND_CLASS_INT_REG)
442
    /* e.g. float2fix.  */
443
1.24k
    idx = 1;
444
0
  else
445
0
    { assert (0); abort (); }
446
2.13M
  return idx;
447
2.13M
}
aarch64-dis.c:select_operand_for_sf_field_coding
Line
Count
Source
429
2.14M
{
430
2.14M
  int idx = -1;
431
2.14M
  if (opcode->iclass == fprcvtfloat2int)
432
1.54k
    return 0;
433
2.13M
  else if (opcode->iclass == fprcvtint2float)
434
191
    return 1;
435
436
2.13M
  if (aarch64_get_operand_class (opcode->operands[0])
437
2.13M
      == AARCH64_OPND_CLASS_INT_REG)
438
    /* normal case.  */
439
2.13M
    idx = 0;
440
1.24k
  else if (aarch64_get_operand_class (opcode->operands[1])
441
1.24k
     == AARCH64_OPND_CLASS_INT_REG)
442
    /* e.g. float2fix.  */
443
1.24k
    idx = 1;
444
0
  else
445
0
    { assert (0); abort (); }
446
2.13M
  return idx;
447
2.13M
}
Unexecuted instantiation: aarch64-dis-2.c:select_operand_for_sf_field_coding
Unexecuted instantiation: aarch64-opc.c:select_operand_for_sf_field_coding
Unexecuted instantiation: aarch64-opc-2.c:select_operand_for_sf_field_coding
448
449
/* Select the operand to do the encoding/decoding of the 'type' field in
450
   the floating-point instructions.
451
   The heuristic-based rule is that the source operand is respected more.  */
452
453
static inline int
454
select_operand_for_fptype_field_coding (const aarch64_opcode *opcode)
455
63.1k
{
456
63.1k
  int idx;
457
63.1k
  if (opcode->iclass == fprcvtfloat2int)
458
1.54k
    return 1;
459
61.5k
  else if (opcode->iclass == fprcvtint2float)
460
191
    return 0;
461
462
61.3k
  if (aarch64_get_operand_class (opcode->operands[1])
463
61.3k
      == AARCH64_OPND_CLASS_FP_REG)
464
    /* normal case.  */
465
59.8k
    idx = 1;
466
1.50k
  else if (aarch64_get_operand_class (opcode->operands[0])
467
1.50k
     == AARCH64_OPND_CLASS_FP_REG)
468
    /* e.g. float2fix.  */
469
1.50k
    idx = 0;
470
0
  else
471
0
    { assert (0); abort (); }
472
61.3k
  return idx;
473
61.3k
}
aarch64-dis.c:select_operand_for_fptype_field_coding
Line
Count
Source
455
63.1k
{
456
63.1k
  int idx;
457
63.1k
  if (opcode->iclass == fprcvtfloat2int)
458
1.54k
    return 1;
459
61.5k
  else if (opcode->iclass == fprcvtint2float)
460
191
    return 0;
461
462
61.3k
  if (aarch64_get_operand_class (opcode->operands[1])
463
61.3k
      == AARCH64_OPND_CLASS_FP_REG)
464
    /* normal case.  */
465
59.8k
    idx = 1;
466
1.50k
  else if (aarch64_get_operand_class (opcode->operands[0])
467
1.50k
     == AARCH64_OPND_CLASS_FP_REG)
468
    /* e.g. float2fix.  */
469
1.50k
    idx = 0;
470
0
  else
471
0
    { assert (0); abort (); }
472
61.3k
  return idx;
473
61.3k
}
Unexecuted instantiation: aarch64-dis-2.c:select_operand_for_fptype_field_coding
Unexecuted instantiation: aarch64-opc.c:select_operand_for_fptype_field_coding
Unexecuted instantiation: aarch64-opc-2.c:select_operand_for_fptype_field_coding
474
475
/* Select the operand to do the encoding/decoding of the 'size' field in
476
   the AdvSIMD scalar instructions.
477
   The heuristic-based rule is that the destination operand is respected
478
   more.  */
479
480
static inline int
481
select_operand_for_scalar_size_field_coding (const aarch64_opcode *opcode)
482
17.8k
{
483
17.8k
  int src_size = 0, dst_size = 0;
484
17.8k
  if (aarch64_get_operand_class (opcode->operands[0])
485
17.8k
      == AARCH64_OPND_CLASS_SISD_REG)
486
17.8k
    dst_size = aarch64_get_qualifier_esize (opcode->qualifiers_list[0][0]);
487
17.8k
  if (aarch64_get_operand_class (opcode->operands[1])
488
17.8k
      == AARCH64_OPND_CLASS_SISD_REG)
489
17.8k
    src_size = aarch64_get_qualifier_esize (opcode->qualifiers_list[0][1]);
490
17.8k
  if (src_size == dst_size && src_size == 0)
491
0
    { assert (0); abort (); }
492
  /* When the result is not a sisd register or it is a long operation.  */
493
17.8k
  if (dst_size == 0 || dst_size == src_size << 1)
494
3.59k
    return 1;
495
14.2k
  else
496
14.2k
    return 0;
497
17.8k
}
aarch64-dis.c:select_operand_for_scalar_size_field_coding
Line
Count
Source
482
17.8k
{
483
17.8k
  int src_size = 0, dst_size = 0;
484
17.8k
  if (aarch64_get_operand_class (opcode->operands[0])
485
17.8k
      == AARCH64_OPND_CLASS_SISD_REG)
486
17.8k
    dst_size = aarch64_get_qualifier_esize (opcode->qualifiers_list[0][0]);
487
17.8k
  if (aarch64_get_operand_class (opcode->operands[1])
488
17.8k
      == AARCH64_OPND_CLASS_SISD_REG)
489
17.8k
    src_size = aarch64_get_qualifier_esize (opcode->qualifiers_list[0][1]);
490
17.8k
  if (src_size == dst_size && src_size == 0)
491
0
    { assert (0); abort (); }
492
  /* When the result is not a sisd register or it is a long operation.  */
493
17.8k
  if (dst_size == 0 || dst_size == src_size << 1)
494
3.59k
    return 1;
495
14.2k
  else
496
14.2k
    return 0;
497
17.8k
}
Unexecuted instantiation: aarch64-dis-2.c:select_operand_for_scalar_size_field_coding
Unexecuted instantiation: aarch64-opc.c:select_operand_for_scalar_size_field_coding
Unexecuted instantiation: aarch64-opc-2.c:select_operand_for_scalar_size_field_coding
498
499
/* Select the operand to do the encoding/decoding of the 'size:Q' fields in
500
   the AdvSIMD instructions.  */
501
502
int aarch64_select_operand_for_sizeq_field_coding (const aarch64_opcode *);
503

504
/* Miscellaneous.  */
505
506
aarch64_insn aarch64_get_operand_modifier_value (enum aarch64_modifier_kind);
507
enum aarch64_modifier_kind
508
aarch64_get_operand_modifier_from_value (aarch64_insn, bool);
509
510
511
bool aarch64_wide_constant_p (uint64_t, int, unsigned int *);
512
bool aarch64_logical_immediate_p (uint64_t, int, aarch64_insn *);
513
int aarch64_shrink_expanded_imm8 (uint64_t);
514
515
/* Copy the content of INST->OPERANDS[SRC] to INST->OPERANDS[DST].  */
516
static inline void
517
copy_operand_info (aarch64_inst *inst, int dst, int src)
518
2.16k
{
519
2.16k
  assert (dst >= 0 && src >= 0 && dst < AARCH64_MAX_OPND_NUM
520
2.16k
    && src < AARCH64_MAX_OPND_NUM);
521
2.16k
  memcpy (&inst->operands[dst], &inst->operands[src],
522
2.16k
    sizeof (aarch64_opnd_info));
523
2.16k
  inst->operands[dst].idx = dst;
524
2.16k
}
aarch64-dis.c:copy_operand_info
Line
Count
Source
518
2.16k
{
519
2.16k
  assert (dst >= 0 && src >= 0 && dst < AARCH64_MAX_OPND_NUM
520
2.16k
    && src < AARCH64_MAX_OPND_NUM);
521
2.16k
  memcpy (&inst->operands[dst], &inst->operands[src],
522
2.16k
    sizeof (aarch64_opnd_info));
523
2.16k
  inst->operands[dst].idx = dst;
524
2.16k
}
Unexecuted instantiation: aarch64-dis-2.c:copy_operand_info
Unexecuted instantiation: aarch64-opc.c:copy_operand_info
Unexecuted instantiation: aarch64-opc-2.c:copy_operand_info
525
526
/* A primitive log caculator.  */
527
528
static inline unsigned int
529
get_logsz (unsigned int size)
530
307k
{
531
307k
  const unsigned char ls[16] =
532
307k
    {0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4};
533
307k
  if (size > 16)
534
0
    {
535
0
      assert (0);
536
0
      return -1;
537
0
    }
538
307k
  assert (ls[size - 1] != (unsigned char)-1);
539
307k
  return ls[size - 1];
540
307k
}
aarch64-dis.c:get_logsz
Line
Count
Source
530
270k
{
531
270k
  const unsigned char ls[16] =
532
270k
    {0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4};
533
270k
  if (size > 16)
534
0
    {
535
0
      assert (0);
536
0
      return -1;
537
0
    }
538
270k
  assert (ls[size - 1] != (unsigned char)-1);
539
270k
  return ls[size - 1];
540
270k
}
Unexecuted instantiation: aarch64-dis-2.c:get_logsz
aarch64-opc.c:get_logsz
Line
Count
Source
530
37.2k
{
531
37.2k
  const unsigned char ls[16] =
532
37.2k
    {0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4};
533
37.2k
  if (size > 16)
534
0
    {
535
0
      assert (0);
536
0
      return -1;
537
0
    }
538
37.2k
  assert (ls[size - 1] != (unsigned char)-1);
539
37.2k
  return ls[size - 1];
540
37.2k
}
Unexecuted instantiation: aarch64-opc-2.c:get_logsz
541
542
#endif /* OPCODES_AARCH64_OPC_H */