Coverage Report

Created: 2025-07-08 11:15

/src/binutils-gdb/opcodes/aarch64-opc.h
Line
Count
Source (jump to first uncovered line)
1
/* aarch64-opc.h -- Header file for aarch64-opc.c and aarch64-opc-2.c.
2
   Copyright (C) 2012-2025 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
/* Instruction fields.
28
   Keep this sorted alphanumerically and synced with the fields array
29
   in aarch64-opc.c.  */
30
enum aarch64_field_kind
31
{
32
  FLD_NIL,
33
  FLD_CRm,
34
  FLD_CRm_dsb_nxs,
35
  FLD_CRn,
36
  FLD_CSSC_imm8,
37
  FLD_H,
38
  FLD_L,
39
  FLD_LSE128_Rt,
40
  FLD_LSE128_Rt2,
41
  FLD_M,
42
  FLD_N,
43
  FLD_Q,
44
  FLD_Ra,
45
  FLD_Rd,
46
  FLD_Rm,
47
  FLD_Rn,
48
  FLD_Rs,
49
  FLD_Rt,
50
  FLD_Rt2,
51
  FLD_S,
52
  FLD_SM3_imm2,
53
  FLD_SME_Pdx2,
54
  FLD_SME_Pm,
55
  FLD_SME_PNd3,
56
  FLD_SME_PNn3,
57
  FLD_SME_Q,
58
  FLD_SME_Rm,
59
  FLD_SME_Rv,
60
  FLD_SME_V,
61
  FLD_SME_VL_10,
62
  FLD_SME_VL_13,
63
  FLD_SME_ZAda_1b,
64
  FLD_SME_ZAda_2b,
65
  FLD_SME_ZAda_3b,
66
  FLD_SME_Zdn2,
67
  FLD_SME_Zdn4,
68
  FLD_SME_Zm,
69
  FLD_SME_Zm2,
70
  FLD_SME_Zm4,
71
  FLD_SME_Zn2,
72
  FLD_SME_Zn4,
73
  FLD_SME_ZtT,
74
  FLD_SME_Zt3,
75
  FLD_SME_Zt2,
76
  FLD_SME_i1,
77
  FLD_SME_size_12,
78
  FLD_SME_size_22,
79
  FLD_SME_sz_23,
80
  FLD_SME_tszh,
81
  FLD_SME_tszl,
82
  FLD_SME_zero_mask,
83
  FLD_SVE_M_4,
84
  FLD_SVE_M_14,
85
  FLD_SVE_M_16,
86
  FLD_SVE_N,
87
  FLD_SVE_Pd,
88
  FLD_SVE_Pg3,
89
  FLD_SVE_Pg4_5,
90
  FLD_SVE_Pg4_10,
91
  FLD_SVE_Pg4_16,
92
  FLD_SVE_Pm,
93
  FLD_SVE_Pn,
94
  FLD_SVE_Pt,
95
  FLD_SVE_Rm,
96
  FLD_SVE_Rn,
97
  FLD_SVE_Vd,
98
  FLD_SVE_Vm,
99
  FLD_SVE_Vn,
100
  FLD_SVE_Za_5,
101
  FLD_SVE_Za_16,
102
  FLD_SVE_Zd,
103
  FLD_SVE_Zm_5,
104
  FLD_SVE_Zm_16,
105
  FLD_SVE_Zn,
106
  FLD_SVE_Zt,
107
  FLD_SVE_i1,
108
  FLD_SVE_i1_23,
109
  FLD_SVE_i2,
110
  FLD_SVE_i2h,
111
  FLD_SVE_i3h,
112
  FLD_SVE_i3h2,
113
  FLD_SVE_i3h3,
114
  FLD_SVE_i3l,
115
  FLD_SVE_i3l2,
116
  FLD_SVE_i4l2,
117
  FLD_SVE_imm3,
118
  FLD_SVE_imm4,
119
  FLD_SVE_imm5,
120
  FLD_SVE_imm5b,
121
  FLD_SVE_imm6,
122
  FLD_SVE_imm7,
123
  FLD_SVE_imm8,
124
  FLD_SVE_imm9,
125
  FLD_SVE_immr,
126
  FLD_SVE_imms,
127
  FLD_SVE_msz,
128
  FLD_SVE_pattern,
129
  FLD_SVE_prfop,
130
  FLD_SVE_rot1,
131
  FLD_SVE_rot2,
132
  FLD_SVE_rot3,
133
  FLD_SVE_size,
134
  FLD_SVE_sz,
135
  FLD_SVE_sz2,
136
  FLD_SVE_tsz,
137
  FLD_SVE_tszh,
138
  FLD_SVE_tszl_8,
139
  FLD_SVE_tszl_19,
140
  FLD_SVE_xs_14,
141
  FLD_SVE_xs_22,
142
  FLD_S_imm10,
143
  FLD_abc,
144
  FLD_asisdlso_opcode,
145
  FLD_b40,
146
  FLD_b5,
147
  FLD_cmode,
148
  FLD_cond,
149
  FLD_cond2,
150
  FLD_defgh,
151
  FLD_hw,
152
  FLD_imm1_0,
153
  FLD_imm1_2,
154
  FLD_imm1_3,
155
  FLD_imm1_8,
156
  FLD_imm1_10,
157
  FLD_imm1_14,
158
  FLD_imm1_15,
159
  FLD_imm1_16,
160
  FLD_imm2_0,
161
  FLD_imm2_1,
162
  FLD_imm2_2,
163
  FLD_imm2_8,
164
  FLD_imm2_10,
165
  FLD_imm2_12,
166
  FLD_imm2_13,
167
  FLD_imm2_15,
168
  FLD_imm2_16,
169
  FLD_imm2_19,
170
  FLD_imm3_0,
171
  FLD_imm3_5,
172
  FLD_imm3_10,
173
  FLD_imm3_12,
174
  FLD_imm3_14,
175
  FLD_imm3_15,
176
  FLD_imm3_19,
177
  FLD_imm4_0,
178
  FLD_imm4_5,
179
  FLD_imm4_10,
180
  FLD_imm4_11,
181
  FLD_imm4_14,
182
  FLD_imm5,
183
  FLD_imm6_10,
184
  FLD_imm6_15,
185
  FLD_imm7,
186
  FLD_imm8,
187
  FLD_imm9,
188
  FLD_imm9_5,
189
  FLD_imm12,
190
  FLD_imm14,
191
  FLD_imm16_0,
192
  FLD_imm16_5,
193
  FLD_imm17_1,
194
  FLD_imm17_2,
195
  FLD_imm19,
196
  FLD_imm26,
197
  FLD_immb,
198
  FLD_immh,
199
  FLD_immhi,
200
  FLD_immlo,
201
  FLD_immr,
202
  FLD_imms,
203
  FLD_index,
204
  FLD_index2,
205
  FLD_ldst_size,
206
  FLD_len,
207
  FLD_lse_sz,
208
  FLD_nzcv,
209
  FLD_op,
210
  FLD_op0,
211
  FLD_op1,
212
  FLD_op2,
213
  FLD_opc,
214
  FLD_opc1,
215
  FLD_opcode,
216
  FLD_option,
217
  FLD_rotate1,
218
  FLD_rotate2,
219
  FLD_rotate3,
220
  FLD_scale,
221
  FLD_sf,
222
  FLD_shift,
223
  FLD_size,
224
  FLD_sz,
225
  FLD_type,
226
  FLD_vldst_size,
227
  FLD_off3,
228
  FLD_off2,
229
  FLD_ZAn_1,
230
  FLD_ol,
231
  FLD_ZAn_2,
232
  FLD_ZAn_3,
233
  FLD_ZAn,
234
  FLD_opc2,
235
  FLD_rcpc3_size,
236
  FLD_brbop,
237
  FLD_ZA8_1,
238
  FLD_ZA7_2,
239
  FLD_ZA6_3,
240
  FLD_ZA5_4,
241
};
242
243
/* Field description.  */
244
struct aarch64_field
245
{
246
  int lsb;
247
  int width;
248
};
249
250
typedef struct aarch64_field aarch64_field;
251
252
extern const aarch64_field fields[];
253

254
/* Operand description.  */
255
256
struct aarch64_operand
257
{
258
  enum aarch64_operand_class op_class;
259
260
  /* Name of the operand code; used mainly for the purpose of internal
261
     debugging.  */
262
  const char *name;
263
264
  unsigned int flags;
265
266
  /* The associated instruction bit-fields; no operand has more than 4
267
     bit-fields */
268
  enum aarch64_field_kind fields[5];
269
270
  /* Brief description */
271
  const char *desc;
272
};
273
274
typedef struct aarch64_operand aarch64_operand;
275
276
extern const aarch64_operand aarch64_operands[];
277
278
enum err_type
279
verify_constraints (const struct aarch64_inst *, const aarch64_insn, bfd_vma,
280
        bool, aarch64_operand_error *, aarch64_instr_sequence*);
281
282
/* Operand flags.  */
283
284
#define OPD_F_HAS_INSERTER  0x00000001
285
42.2M
#define OPD_F_HAS_EXTRACTOR 0x00000002
286
9.20M
#define OPD_F_SEXT    0x00000004  /* Require sign-extension.  */
287
12.1M
#define OPD_F_SHIFT_BY_2  0x00000008  /* Need to left shift the field
288
               value by 2 to get the value
289
               of an immediate operand.  */
290
328k
#define OPD_F_MAYBE_SP    0x00000010  /* May potentially be SP.  */
291
23.6M
#define OPD_F_OD_MASK   0x000001e0  /* Operand-dependent data.  */
292
23.6M
#define OPD_F_OD_LSB    5
293
414k
#define OPD_F_NO_ZR   0x00000200  /* ZR index not allowed.  */
294
6.88M
#define OPD_F_SHIFT_BY_3  0x00000400  /* Need to left shift the field
295
               value by 3 to get the value
296
               of an immediate operand.  */
297
6.88M
#define OPD_F_SHIFT_BY_4  0x00000800  /* Need to left shift the field
298
               value by 4 to get the value
299
               of an immediate operand.  */
300
2.94M
#define OPD_F_UNSIGNED    0x00001000  /* Expect an unsigned value.  */
301
302
303
/* Register flags.  */
304
305
#undef F_DEPRECATED
306
691
#define F_DEPRECATED  (1 << 0)  /* Deprecated system register.  */
307
308
#undef F_ARCHEXT
309
0
#define F_ARCHEXT (1 << 1)  /* Architecture dependent system register.  */
310
311
#undef F_HASXT
312
356
#define F_HASXT   (1 << 2)  /* System instruction register <Xt>
313
             operand.  */
314
315
#undef F_REG_READ
316
15.3M
#define F_REG_READ  (1 << 3)  /* Register can only be used to read values
317
             out of.  */
318
319
#undef F_REG_WRITE
320
15.3M
#define F_REG_WRITE (1 << 4)  /* Register can only be written to but not
321
             read from.  */
322
323
#undef F_REG_IN_CRM
324
322
#define F_REG_IN_CRM  (1 << 5)  /* Register extra encoding in CRm.  */
325
326
#undef F_REG_ALIAS
327
691
#define F_REG_ALIAS (1 << 6)  /* Register name aliases another.  */
328
329
#undef F_REG_128
330
0
#define F_REG_128 (1 << 7) /* System register implementable as 128-bit wide.  */
331
332
333
/* PSTATE field name for the MSR instruction this is encoded in "op1:op2:CRm".
334
   Part of CRm can be used to encode <pstatefield>. E.g. CRm[3:1] for SME.
335
   In order to set/get full PSTATE field name use flag F_REG_IN_CRM and below
336
   macros to encode and decode CRm encoding.
337
*/
338
#define PSTATE_ENCODE_CRM(val) (val << 6)
339
153
#define PSTATE_DECODE_CRM(flags) ((flags >> 6) & 0x0f)
340
341
#undef F_IMM_IN_CRM
342
129
#define F_IMM_IN_CRM  (1 << 10)  /* Immediate extra encoding in CRm.  */
343
344
/* Also CRm may contain, in addition to <pstatefield> immediate.
345
   E.g. CRm[0] <imm1> at bit 0 for SME. Use below macros to encode and decode
346
   immediate mask.
347
*/
348
#define PSTATE_ENCODE_CRM_IMM(mask) (mask << 11)
349
0
#define PSTATE_DECODE_CRM_IMM(mask) ((mask >> 11) & 0x0f)
350
351
/* Helper macro to ENCODE CRm and its immediate.  */
352
#define PSTATE_ENCODE_CRM_AND_IMM(CVAL,IMASK) \
353
        (F_REG_IN_CRM | PSTATE_ENCODE_CRM(CVAL) \
354
         | F_IMM_IN_CRM | PSTATE_ENCODE_CRM_IMM(IMASK))
355
356
/* Bits [15, 18] contain the maximum value for an immediate MSR.  */
357
#define F_REG_MAX_VALUE(X) ((X) << 15)
358
129
#define F_GET_REG_MAX_VALUE(X) (((X) >> 15) & 0x0f)
359
360
/* HINT operand flags.  */
361
207
#define HINT_OPD_F_NOPRINT  (1 << 0)  /* Should not be printed.  */
362
363
/* Encode 7-bit HINT #imm in the lower 8 bits.  Use higher bits for flags.  */
364
#define HINT_ENCODE(flag, val) ((flag << 8) | val)
365
207
#define HINT_FLAG(val) (val >> 8)
366
1.23k
#define HINT_VAL(val) (val & 0xff)
367
368
static inline bool
369
operand_has_inserter (const aarch64_operand *operand)
370
0
{
371
0
  return (operand->flags & OPD_F_HAS_INSERTER) != 0;
372
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
373
374
static inline bool
375
operand_has_extractor (const aarch64_operand *operand)
376
42.2M
{
377
42.2M
  return (operand->flags & OPD_F_HAS_EXTRACTOR) != 0;
378
42.2M
}
aarch64-dis.c:operand_has_extractor
Line
Count
Source
376
42.2M
{
377
42.2M
  return (operand->flags & OPD_F_HAS_EXTRACTOR) != 0;
378
42.2M
}
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
379
380
static inline bool
381
operand_need_sign_extension (const aarch64_operand *operand)
382
9.20M
{
383
9.20M
  return (operand->flags & OPD_F_SEXT) != 0;
384
9.20M
}
aarch64-dis.c:operand_need_sign_extension
Line
Count
Source
382
9.20M
{
383
9.20M
  return (operand->flags & OPD_F_SEXT) != 0;
384
9.20M
}
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
385
386
static inline bool
387
operand_need_shift_by_two (const aarch64_operand *operand)
388
12.1M
{
389
12.1M
  return (operand->flags & OPD_F_SHIFT_BY_2) != 0;
390
12.1M
}
aarch64-dis.c:operand_need_shift_by_two
Line
Count
Source
388
9.20M
{
389
9.20M
  return (operand->flags & OPD_F_SHIFT_BY_2) != 0;
390
9.20M
}
Unexecuted instantiation: aarch64-dis-2.c:operand_need_shift_by_two
aarch64-opc.c:operand_need_shift_by_two
Line
Count
Source
388
2.94M
{
389
2.94M
  return (operand->flags & OPD_F_SHIFT_BY_2) != 0;
390
2.94M
}
Unexecuted instantiation: aarch64-opc-2.c:operand_need_shift_by_two
391
392
static inline bool
393
operand_need_shift_by_three (const aarch64_operand *operand)
394
6.88M
{
395
6.88M
  return (operand->flags & OPD_F_SHIFT_BY_3) != 0;
396
6.88M
}
aarch64-dis.c:operand_need_shift_by_three
Line
Count
Source
394
6.88M
{
395
6.88M
  return (operand->flags & OPD_F_SHIFT_BY_3) != 0;
396
6.88M
}
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
397
398
static inline bool
399
operand_need_shift_by_four (const aarch64_operand *operand)
400
6.88M
{
401
6.88M
  return (operand->flags & OPD_F_SHIFT_BY_4) != 0;
402
6.88M
}
aarch64-dis.c:operand_need_shift_by_four
Line
Count
Source
400
6.88M
{
401
6.88M
  return (operand->flags & OPD_F_SHIFT_BY_4) != 0;
402
6.88M
}
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
403
404
static inline bool
405
operand_need_unsigned_offset (const aarch64_operand *operand)
406
2.94M
{
407
2.94M
  return (operand->flags & OPD_F_UNSIGNED) != 0;
408
2.94M
}
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
406
2.94M
{
407
2.94M
  return (operand->flags & OPD_F_UNSIGNED) != 0;
408
2.94M
}
Unexecuted instantiation: aarch64-opc-2.c:operand_need_unsigned_offset
409
410
static inline bool
411
operand_maybe_stack_pointer (const aarch64_operand *operand)
412
328k
{
413
328k
  return (operand->flags & OPD_F_MAYBE_SP) != 0;
414
328k
}
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
412
328k
{
413
328k
  return (operand->flags & OPD_F_MAYBE_SP) != 0;
414
328k
}
Unexecuted instantiation: aarch64-opc-2.c:operand_maybe_stack_pointer
415
416
/* Return the value of the operand-specific data field (OPD_F_OD_MASK).  */
417
static inline unsigned int
418
get_operand_specific_data (const aarch64_operand *operand)
419
23.6M
{
420
23.6M
  return (operand->flags & OPD_F_OD_MASK) >> OPD_F_OD_LSB;
421
23.6M
}
aarch64-dis.c:get_operand_specific_data
Line
Count
Source
419
22.9M
{
420
22.9M
  return (operand->flags & OPD_F_OD_MASK) >> OPD_F_OD_LSB;
421
22.9M
}
Unexecuted instantiation: aarch64-dis-2.c:get_operand_specific_data
aarch64-opc.c:get_operand_specific_data
Line
Count
Source
419
709k
{
420
709k
  return (operand->flags & OPD_F_OD_MASK) >> OPD_F_OD_LSB;
421
709k
}
Unexecuted instantiation: aarch64-opc-2.c:get_operand_specific_data
422
423
/* Return the width of field number N of operand *OPERAND.  */
424
static inline unsigned
425
get_operand_field_width (const aarch64_operand *operand, unsigned n)
426
250
{
427
250
  assert (operand->fields[n] != FLD_NIL);
428
250
  return fields[operand->fields[n]].width;
429
250
}
aarch64-dis.c:get_operand_field_width
Line
Count
Source
426
140
{
427
140
  assert (operand->fields[n] != FLD_NIL);
428
140
  return fields[operand->fields[n]].width;
429
140
}
Unexecuted instantiation: aarch64-dis-2.c:get_operand_field_width
aarch64-opc.c:get_operand_field_width
Line
Count
Source
426
110
{
427
110
  assert (operand->fields[n] != FLD_NIL);
428
110
  return fields[operand->fields[n]].width;
429
110
}
Unexecuted instantiation: aarch64-opc-2.c:get_operand_field_width
430
431
/* Return the total width of the operand *OPERAND.  */
432
static inline unsigned
433
get_operand_fields_width (const aarch64_operand *operand)
434
11.1M
{
435
11.1M
  int i = 0;
436
11.1M
  unsigned width = 0;
437
24.1M
  while (operand->fields[i] != FLD_NIL)
438
13.0M
    width += fields[operand->fields[i++]].width;
439
11.1M
  assert (width > 0 && width < 32);
440
11.1M
  return width;
441
11.1M
}
aarch64-dis.c:get_operand_fields_width
Line
Count
Source
434
3.38M
{
435
3.38M
  int i = 0;
436
3.38M
  unsigned width = 0;
437
7.81M
  while (operand->fields[i] != FLD_NIL)
438
4.42M
    width += fields[operand->fields[i++]].width;
439
3.38M
  assert (width > 0 && width < 32);
440
3.38M
  return width;
441
3.38M
}
Unexecuted instantiation: aarch64-dis-2.c:get_operand_fields_width
aarch64-opc.c:get_operand_fields_width
Line
Count
Source
434
7.72M
{
435
7.72M
  int i = 0;
436
7.72M
  unsigned width = 0;
437
16.3M
  while (operand->fields[i] != FLD_NIL)
438
8.58M
    width += fields[operand->fields[i++]].width;
439
7.72M
  assert (width > 0 && width < 32);
440
7.72M
  return width;
441
7.72M
}
Unexecuted instantiation: aarch64-opc-2.c:get_operand_fields_width
442
443
static inline const aarch64_operand *
444
get_operand_from_code (enum aarch64_opnd code)
445
10.6M
{
446
10.6M
  return aarch64_operands + code;
447
10.6M
}
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
445
10.6M
{
446
10.6M
  return aarch64_operands + code;
447
10.6M
}
Unexecuted instantiation: aarch64-opc-2.c:get_operand_from_code
448

449
/* Operand qualifier and operand constraint checking.  */
450
451
bool aarch64_match_operands_constraint (aarch64_inst *,
452
               aarch64_operand_error *);
453
454
/* Operand qualifier related functions.  */
455
const char* aarch64_get_qualifier_name (aarch64_opnd_qualifier_t);
456
unsigned char aarch64_get_qualifier_nelem (aarch64_opnd_qualifier_t);
457
aarch64_insn aarch64_get_qualifier_standard_value (aarch64_opnd_qualifier_t);
458
int aarch64_find_best_match (const aarch64_inst *,
459
           const aarch64_opnd_qualifier_seq_t *,
460
           int, aarch64_opnd_qualifier_t *, int *);
461
462
static inline void
463
reset_operand_qualifier (aarch64_inst *inst, int idx)
464
123k
{
465
123k
  assert (idx >=0 && idx < aarch64_num_of_operands (inst->opcode));
466
123k
  inst->operands[idx].qualifier = AARCH64_OPND_QLF_NIL;
467
123k
}
aarch64-dis.c:reset_operand_qualifier
Line
Count
Source
464
123k
{
465
123k
  assert (idx >=0 && idx < aarch64_num_of_operands (inst->opcode));
466
123k
  inst->operands[idx].qualifier = AARCH64_OPND_QLF_NIL;
467
123k
}
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
468

469
/* Inline functions operating on instruction bit-field(s).  */
470
471
/* Generate a mask that has WIDTH number of consecutive 1s.  */
472
473
static inline aarch64_insn
474
gen_mask (int width)
475
70.6M
{
476
70.6M
  return ((aarch64_insn) 1 << width) - 1;
477
70.6M
}
aarch64-dis.c:gen_mask
Line
Count
Source
475
70.6M
{
476
70.6M
  return ((aarch64_insn) 1 << width) - 1;
477
70.6M
}
Unexecuted instantiation: aarch64-dis-2.c:gen_mask
Unexecuted instantiation: aarch64-opc.c:gen_mask
Unexecuted instantiation: aarch64-opc-2.c:gen_mask
478
479
/* LSB_REL is the relative location of the lsb in the sub field, starting from 0.  */
480
static inline int
481
gen_sub_field (enum aarch64_field_kind kind, int lsb_rel, int width, aarch64_field *ret)
482
168k
{
483
168k
  const aarch64_field *field = &fields[kind];
484
168k
  if (lsb_rel < 0 || width <= 0 || lsb_rel + width > field->width)
485
195
    return 0;
486
168k
  ret->lsb = field->lsb + lsb_rel;
487
168k
  ret->width = width;
488
168k
  return 1;
489
168k
}
aarch64-dis.c:gen_sub_field
Line
Count
Source
482
168k
{
483
168k
  const aarch64_field *field = &fields[kind];
484
168k
  if (lsb_rel < 0 || width <= 0 || lsb_rel + width > field->width)
485
195
    return 0;
486
168k
  ret->lsb = field->lsb + lsb_rel;
487
168k
  ret->width = width;
488
168k
  return 1;
489
168k
}
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
490
491
/* Insert VALUE into FIELD of CODE.  MASK can be zero or the base mask
492
   of the opcode.  */
493
494
static inline void
495
insert_field_2 (const aarch64_field *field, aarch64_insn *code,
496
    aarch64_insn value, aarch64_insn mask)
497
0
{
498
0
  assert (field->width < 32 && field->width >= 1 && field->lsb >= 0
499
0
    && field->lsb + field->width <= 32);
500
0
  value &= gen_mask (field->width);
501
0
  value <<= field->lsb;
502
0
  /* In some opcodes, field can be part of the base opcode, e.g. the size
503
0
     field in FADD.  The following helps avoid corrupt the base opcode.  */
504
0
  value &= ~mask;
505
0
  *code |= value;
506
0
}
Unexecuted instantiation: aarch64-dis.c:insert_field_2
Unexecuted instantiation: aarch64-dis-2.c:insert_field_2
Unexecuted instantiation: aarch64-opc.c:insert_field_2
Unexecuted instantiation: aarch64-opc-2.c:insert_field_2
507
508
/* Extract FIELD of CODE and return the value.  MASK can be zero or the base
509
   mask of the opcode.  */
510
511
static inline aarch64_insn
512
extract_field_2 (const aarch64_field *field, aarch64_insn code,
513
     aarch64_insn mask)
514
70.6M
{
515
70.6M
  aarch64_insn value;
516
  /* Clear any bit that is a part of the base opcode.  */
517
70.6M
  code &= ~mask;
518
70.6M
  value = (code >> field->lsb) & gen_mask (field->width);
519
70.6M
  return value;
520
70.6M
}
aarch64-dis.c:extract_field_2
Line
Count
Source
514
70.6M
{
515
70.6M
  aarch64_insn value;
516
  /* Clear any bit that is a part of the base opcode.  */
517
70.6M
  code &= ~mask;
518
70.6M
  value = (code >> field->lsb) & gen_mask (field->width);
519
70.6M
  return value;
520
70.6M
}
Unexecuted instantiation: aarch64-dis-2.c:extract_field_2
Unexecuted instantiation: aarch64-opc.c:extract_field_2
Unexecuted instantiation: aarch64-opc-2.c:extract_field_2
521
522
/* Insert VALUE into field KIND of CODE.  MASK can be zero or the base mask
523
   of the opcode.  */
524
525
static inline void
526
insert_field (enum aarch64_field_kind kind, aarch64_insn *code,
527
        aarch64_insn value, aarch64_insn mask)
528
0
{
529
0
  insert_field_2 (&fields[kind], code, value, mask);
530
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
531
532
/* Extract field KIND of CODE and return the value.  MASK can be zero or the
533
   base mask of the opcode.  */
534
535
static inline aarch64_insn
536
extract_field (enum aarch64_field_kind kind, aarch64_insn code,
537
         aarch64_insn mask)
538
70.4M
{
539
70.4M
  return extract_field_2 (&fields[kind], code, mask);
540
70.4M
}
aarch64-dis.c:extract_field
Line
Count
Source
538
70.4M
{
539
70.4M
  return extract_field_2 (&fields[kind], code, mask);
540
70.4M
}
Unexecuted instantiation: aarch64-dis-2.c:extract_field
Unexecuted instantiation: aarch64-opc.c:extract_field
Unexecuted instantiation: aarch64-opc-2.c:extract_field
541
542
extern aarch64_insn
543
extract_fields (aarch64_insn code, aarch64_insn mask, ...);
544

545
/* Inline functions selecting operand to do the encoding/decoding for a
546
   certain instruction bit-field.  */
547
548
/* Select the operand to do the encoding/decoding of the 'sf' field.
549
   The heuristic-based rule is that the result operand is respected more.  */
550
551
static inline int
552
select_operand_for_sf_field_coding (const aarch64_opcode *opcode)
553
5.88M
{
554
5.88M
  int idx = -1;
555
5.88M
  if (opcode->iclass == fprcvtfloat2int)
556
363
    return 0;
557
5.88M
  else if (opcode->iclass == fprcvtint2float)
558
132
    return 1;
559
560
5.88M
  if (aarch64_get_operand_class (opcode->operands[0])
561
5.88M
      == AARCH64_OPND_CLASS_INT_REG)
562
    /* normal case.  */
563
5.88M
    idx = 0;
564
2.41k
  else if (aarch64_get_operand_class (opcode->operands[1])
565
2.41k
     == AARCH64_OPND_CLASS_INT_REG)
566
    /* e.g. float2fix.  */
567
2.41k
    idx = 1;
568
0
  else
569
0
    { assert (0); abort (); }
570
5.88M
  return idx;
571
5.88M
}
aarch64-dis.c:select_operand_for_sf_field_coding
Line
Count
Source
553
5.88M
{
554
5.88M
  int idx = -1;
555
5.88M
  if (opcode->iclass == fprcvtfloat2int)
556
363
    return 0;
557
5.88M
  else if (opcode->iclass == fprcvtint2float)
558
132
    return 1;
559
560
5.88M
  if (aarch64_get_operand_class (opcode->operands[0])
561
5.88M
      == AARCH64_OPND_CLASS_INT_REG)
562
    /* normal case.  */
563
5.88M
    idx = 0;
564
2.41k
  else if (aarch64_get_operand_class (opcode->operands[1])
565
2.41k
     == AARCH64_OPND_CLASS_INT_REG)
566
    /* e.g. float2fix.  */
567
2.41k
    idx = 1;
568
0
  else
569
0
    { assert (0); abort (); }
570
5.88M
  return idx;
571
5.88M
}
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
572
573
/* Select the operand to do the encoding/decoding of the 'type' field in
574
   the floating-point instructions.
575
   The heuristic-based rule is that the source operand is respected more.  */
576
577
static inline int
578
select_operand_for_fptype_field_coding (const aarch64_opcode *opcode)
579
147k
{
580
147k
  int idx;
581
147k
  if (opcode->iclass == fprcvtfloat2int)
582
363
    return 1;
583
147k
  else if (opcode->iclass == fprcvtint2float)
584
132
    return 0;
585
586
147k
  if (aarch64_get_operand_class (opcode->operands[1])
587
147k
      == AARCH64_OPND_CLASS_FP_REG)
588
    /* normal case.  */
589
144k
    idx = 1;
590
2.74k
  else if (aarch64_get_operand_class (opcode->operands[0])
591
2.74k
     == AARCH64_OPND_CLASS_FP_REG)
592
    /* e.g. float2fix.  */
593
2.74k
    idx = 0;
594
0
  else
595
0
    { assert (0); abort (); }
596
147k
  return idx;
597
147k
}
aarch64-dis.c:select_operand_for_fptype_field_coding
Line
Count
Source
579
147k
{
580
147k
  int idx;
581
147k
  if (opcode->iclass == fprcvtfloat2int)
582
363
    return 1;
583
147k
  else if (opcode->iclass == fprcvtint2float)
584
132
    return 0;
585
586
147k
  if (aarch64_get_operand_class (opcode->operands[1])
587
147k
      == AARCH64_OPND_CLASS_FP_REG)
588
    /* normal case.  */
589
144k
    idx = 1;
590
2.74k
  else if (aarch64_get_operand_class (opcode->operands[0])
591
2.74k
     == AARCH64_OPND_CLASS_FP_REG)
592
    /* e.g. float2fix.  */
593
2.74k
    idx = 0;
594
0
  else
595
0
    { assert (0); abort (); }
596
147k
  return idx;
597
147k
}
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
598
599
/* Select the operand to do the encoding/decoding of the 'size' field in
600
   the AdvSIMD scalar instructions.
601
   The heuristic-based rule is that the destination operand is respected
602
   more.  */
603
604
static inline int
605
select_operand_for_scalar_size_field_coding (const aarch64_opcode *opcode)
606
39.9k
{
607
39.9k
  int src_size = 0, dst_size = 0;
608
39.9k
  if (aarch64_get_operand_class (opcode->operands[0])
609
39.9k
      == AARCH64_OPND_CLASS_SISD_REG)
610
39.9k
    dst_size = aarch64_get_qualifier_esize (opcode->qualifiers_list[0][0]);
611
39.9k
  if (aarch64_get_operand_class (opcode->operands[1])
612
39.9k
      == AARCH64_OPND_CLASS_SISD_REG)
613
39.9k
    src_size = aarch64_get_qualifier_esize (opcode->qualifiers_list[0][1]);
614
39.9k
  if (src_size == dst_size && src_size == 0)
615
0
    { assert (0); abort (); }
616
  /* When the result is not a sisd register or it is a long operation.  */
617
39.9k
  if (dst_size == 0 || dst_size == src_size << 1)
618
13.9k
    return 1;
619
25.9k
  else
620
25.9k
    return 0;
621
39.9k
}
aarch64-dis.c:select_operand_for_scalar_size_field_coding
Line
Count
Source
606
39.9k
{
607
39.9k
  int src_size = 0, dst_size = 0;
608
39.9k
  if (aarch64_get_operand_class (opcode->operands[0])
609
39.9k
      == AARCH64_OPND_CLASS_SISD_REG)
610
39.9k
    dst_size = aarch64_get_qualifier_esize (opcode->qualifiers_list[0][0]);
611
39.9k
  if (aarch64_get_operand_class (opcode->operands[1])
612
39.9k
      == AARCH64_OPND_CLASS_SISD_REG)
613
39.9k
    src_size = aarch64_get_qualifier_esize (opcode->qualifiers_list[0][1]);
614
39.9k
  if (src_size == dst_size && src_size == 0)
615
0
    { assert (0); abort (); }
616
  /* When the result is not a sisd register or it is a long operation.  */
617
39.9k
  if (dst_size == 0 || dst_size == src_size << 1)
618
13.9k
    return 1;
619
25.9k
  else
620
25.9k
    return 0;
621
39.9k
}
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
622
623
/* Select the operand to do the encoding/decoding of the 'size:Q' fields in
624
   the AdvSIMD instructions.  */
625
626
int aarch64_select_operand_for_sizeq_field_coding (const aarch64_opcode *);
627

628
/* Miscellaneous.  */
629
630
aarch64_insn aarch64_get_operand_modifier_value (enum aarch64_modifier_kind);
631
enum aarch64_modifier_kind
632
aarch64_get_operand_modifier_from_value (aarch64_insn, bool);
633
634
635
bool aarch64_wide_constant_p (uint64_t, int, unsigned int *);
636
bool aarch64_logical_immediate_p (uint64_t, int, aarch64_insn *);
637
int aarch64_shrink_expanded_imm8 (uint64_t);
638
639
/* Copy the content of INST->OPERANDS[SRC] to INST->OPERANDS[DST].  */
640
static inline void
641
copy_operand_info (aarch64_inst *inst, int dst, int src)
642
11.4k
{
643
11.4k
  assert (dst >= 0 && src >= 0 && dst < AARCH64_MAX_OPND_NUM
644
11.4k
    && src < AARCH64_MAX_OPND_NUM);
645
11.4k
  memcpy (&inst->operands[dst], &inst->operands[src],
646
11.4k
    sizeof (aarch64_opnd_info));
647
11.4k
  inst->operands[dst].idx = dst;
648
11.4k
}
aarch64-dis.c:copy_operand_info
Line
Count
Source
642
11.4k
{
643
11.4k
  assert (dst >= 0 && src >= 0 && dst < AARCH64_MAX_OPND_NUM
644
11.4k
    && src < AARCH64_MAX_OPND_NUM);
645
11.4k
  memcpy (&inst->operands[dst], &inst->operands[src],
646
11.4k
    sizeof (aarch64_opnd_info));
647
11.4k
  inst->operands[dst].idx = dst;
648
11.4k
}
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
649
650
/* A primitive log caculator.  */
651
652
static inline unsigned int
653
get_logsz (unsigned int size)
654
1.00M
{
655
1.00M
  const unsigned char ls[16] =
656
1.00M
    {0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4};
657
1.00M
  if (size > 16)
658
0
    {
659
0
      assert (0);
660
0
      return -1;
661
0
    }
662
1.00M
  assert (ls[size - 1] != (unsigned char)-1);
663
1.00M
  return ls[size - 1];
664
1.00M
}
aarch64-dis.c:get_logsz
Line
Count
Source
654
961k
{
655
961k
  const unsigned char ls[16] =
656
961k
    {0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4};
657
961k
  if (size > 16)
658
0
    {
659
0
      assert (0);
660
0
      return -1;
661
0
    }
662
961k
  assert (ls[size - 1] != (unsigned char)-1);
663
961k
  return ls[size - 1];
664
961k
}
Unexecuted instantiation: aarch64-dis-2.c:get_logsz
aarch64-opc.c:get_logsz
Line
Count
Source
654
42.8k
{
655
42.8k
  const unsigned char ls[16] =
656
42.8k
    {0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4};
657
42.8k
  if (size > 16)
658
0
    {
659
0
      assert (0);
660
0
      return -1;
661
0
    }
662
42.8k
  assert (ls[size - 1] != (unsigned char)-1);
663
42.8k
  return ls[size - 1];
664
42.8k
}
Unexecuted instantiation: aarch64-opc-2.c:get_logsz
665
666
#endif /* OPCODES_AARCH64_OPC_H */