Coverage Report

Created: 2023-06-29 07:13

/src/binutils-gdb/opcodes/aarch64-opc.c
Line
Count
Source (jump to first uncovered line)
1
/* aarch64-opc.c -- AArch64 opcode support.
2
   Copyright (C) 2009-2023 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
#include "sysdep.h"
22
#include <assert.h>
23
#include <stdlib.h>
24
#include <stdio.h>
25
#include <stdint.h>
26
#include <stdarg.h>
27
#include <inttypes.h>
28
29
#include "opintl.h"
30
#include "libiberty.h"
31
32
#include "aarch64-opc.h"
33
34
#ifdef DEBUG_AARCH64
35
int debug_dump = false;
36
#endif /* DEBUG_AARCH64 */
37
38
/* The enumeration strings associated with each value of a 5-bit SVE
39
   pattern operand.  A null entry indicates a reserved meaning.  */
40
const char *const aarch64_sve_pattern_array[32] = {
41
  /* 0-7.  */
42
  "pow2",
43
  "vl1",
44
  "vl2",
45
  "vl3",
46
  "vl4",
47
  "vl5",
48
  "vl6",
49
  "vl7",
50
  /* 8-15.  */
51
  "vl8",
52
  "vl16",
53
  "vl32",
54
  "vl64",
55
  "vl128",
56
  "vl256",
57
  0,
58
  0,
59
  /* 16-23.  */
60
  0,
61
  0,
62
  0,
63
  0,
64
  0,
65
  0,
66
  0,
67
  0,
68
  /* 24-31.  */
69
  0,
70
  0,
71
  0,
72
  0,
73
  0,
74
  "mul4",
75
  "mul3",
76
  "all"
77
};
78
79
/* The enumeration strings associated with each value of a 4-bit SVE
80
   prefetch operand.  A null entry indicates a reserved meaning.  */
81
const char *const aarch64_sve_prfop_array[16] = {
82
  /* 0-7.  */
83
  "pldl1keep",
84
  "pldl1strm",
85
  "pldl2keep",
86
  "pldl2strm",
87
  "pldl3keep",
88
  "pldl3strm",
89
  0,
90
  0,
91
  /* 8-15.  */
92
  "pstl1keep",
93
  "pstl1strm",
94
  "pstl2keep",
95
  "pstl2strm",
96
  "pstl3keep",
97
  "pstl3strm",
98
  0,
99
  0
100
};
101
102
/* The enumeration strings associated with each value of a 6-bit RPRFM
103
   operation.  */
104
const char *const aarch64_rprfmop_array[64] = {
105
  "pldkeep",
106
  "pstkeep",
107
  0,
108
  0,
109
  "pldstrm",
110
  "pststrm"
111
};
112
113
/* Vector length multiples for a predicate-as-counter operand.  Used in things
114
   like AARCH64_OPND_SME_VLxN_10.  */
115
const char *const aarch64_sme_vlxn_array[2] = {
116
  "vlx2",
117
  "vlx4"
118
};
119
120
/* Helper functions to determine which operand to be used to encode/decode
121
   the size:Q fields for AdvSIMD instructions.  */
122
123
static inline bool
124
vector_qualifier_p (enum aarch64_opnd_qualifier qualifier)
125
731k
{
126
731k
  return (qualifier >= AARCH64_OPND_QLF_V_8B
127
731k
    && qualifier <= AARCH64_OPND_QLF_V_1Q);
128
731k
}
129
130
static inline bool
131
fp_qualifier_p (enum aarch64_opnd_qualifier qualifier)
132
749
{
133
749
  return (qualifier >= AARCH64_OPND_QLF_S_B
134
749
    && qualifier <= AARCH64_OPND_QLF_S_Q);
135
749
}
136
137
enum data_pattern
138
{
139
  DP_UNKNOWN,
140
  DP_VECTOR_3SAME,
141
  DP_VECTOR_LONG,
142
  DP_VECTOR_WIDE,
143
  DP_VECTOR_ACROSS_LANES,
144
};
145
146
static const char significant_operand_index [] =
147
{
148
  0,  /* DP_UNKNOWN, by default using operand 0.  */
149
  0,  /* DP_VECTOR_3SAME */
150
  1,  /* DP_VECTOR_LONG */
151
  2,  /* DP_VECTOR_WIDE */
152
  1,  /* DP_VECTOR_ACROSS_LANES */
153
};
154
155
/* Given a sequence of qualifiers in QUALIFIERS, determine and return
156
   the data pattern.
157
   N.B. QUALIFIERS is a possible sequence of qualifiers each of which
158
   corresponds to one of a sequence of operands.  */
159
160
static enum data_pattern
161
get_data_pattern (const aarch64_opnd_qualifier_seq_t qualifiers)
162
316k
{
163
316k
  if (vector_qualifier_p (qualifiers[0]))
164
315k
    {
165
      /* e.g. v.4s, v.4s, v.4s
166
     or v.4h, v.4h, v.h[3].  */
167
315k
      if (qualifiers[0] == qualifiers[1]
168
315k
    && vector_qualifier_p (qualifiers[2])
169
315k
    && (aarch64_get_qualifier_esize (qualifiers[0])
170
104k
        == aarch64_get_qualifier_esize (qualifiers[1]))
171
315k
    && (aarch64_get_qualifier_esize (qualifiers[0])
172
104k
        == aarch64_get_qualifier_esize (qualifiers[2])))
173
100k
  return DP_VECTOR_3SAME;
174
      /* e.g. v.8h, v.8b, v.8b.
175
           or v.4s, v.4h, v.h[2].
176
     or v.8h, v.16b.  */
177
215k
      if (vector_qualifier_p (qualifiers[1])
178
215k
    && aarch64_get_qualifier_esize (qualifiers[0]) != 0
179
215k
    && (aarch64_get_qualifier_esize (qualifiers[0])
180
135k
        == aarch64_get_qualifier_esize (qualifiers[1]) << 1))
181
58.2k
  return DP_VECTOR_LONG;
182
      /* e.g. v.8h, v.8h, v.8b.  */
183
157k
      if (qualifiers[0] == qualifiers[1]
184
157k
    && vector_qualifier_p (qualifiers[2])
185
157k
    && aarch64_get_qualifier_esize (qualifiers[0]) != 0
186
157k
    && (aarch64_get_qualifier_esize (qualifiers[0])
187
3.83k
        == aarch64_get_qualifier_esize (qualifiers[2]) << 1)
188
157k
    && (aarch64_get_qualifier_esize (qualifiers[0])
189
3.83k
        == aarch64_get_qualifier_esize (qualifiers[1])))
190
3.83k
  return DP_VECTOR_WIDE;
191
157k
    }
192
749
  else if (fp_qualifier_p (qualifiers[0]))
193
749
    {
194
      /* e.g. SADDLV <V><d>, <Vn>.<T>.  */
195
749
      if (vector_qualifier_p (qualifiers[1])
196
749
    && qualifiers[2] == AARCH64_OPND_QLF_NIL)
197
673
  return DP_VECTOR_ACROSS_LANES;
198
749
    }
199
200
153k
  return DP_UNKNOWN;
201
316k
}
202
203
/* Select the operand to do the encoding/decoding of the 'size:Q' fields in
204
   the AdvSIMD instructions.  */
205
/* N.B. it is possible to do some optimization that doesn't call
206
   get_data_pattern each time when we need to select an operand.  We can
207
   either buffer the caculated the result or statically generate the data,
208
   however, it is not obvious that the optimization will bring significant
209
   benefit.  */
210
211
int
212
aarch64_select_operand_for_sizeq_field_coding (const aarch64_opcode *opcode)
213
316k
{
214
316k
  return
215
316k
    significant_operand_index [get_data_pattern (opcode->qualifiers_list[0])];
216
316k
}
217

218
/* Instruction bit-fields.
219
+   Keep synced with 'enum aarch64_field_kind'.  */
220
const aarch64_field fields[] =
221
{
222
    {  0,  0 }, /* NIL.  */
223
    {  8,  4 }, /* CRm: in the system instructions.  */
224
    { 10,  2 }, /* CRm_dsb_nxs: 2-bit imm. encoded in CRm<3:2>.  */
225
    { 12,  4 }, /* CRn: in the system instructions.  */
226
    { 10,  8 }, /* CSSC_imm8.  */
227
    { 11,  1 }, /* H: in advsimd scalar x indexed element instructions.  */
228
    { 21,  1 }, /* L: in advsimd scalar x indexed element instructions.  */
229
    { 20,  1 }, /* M: in advsimd scalar x indexed element instructions.  */
230
    { 22,  1 }, /* N: in logical (immediate) instructions.  */
231
    { 30,  1 }, /* Q: in most AdvSIMD instructions.  */
232
    { 10,  5 }, /* Ra: in fp instructions.  */
233
    {  0,  5 }, /* Rd: in many integer instructions.  */
234
    { 16,  5 }, /* Rm: in ld/st reg offset and some integer inst.  */
235
    {  5,  5 }, /* Rn: in many integer instructions.  */
236
    { 16,  5 }, /* Rs: in load/store exclusive instructions.  */
237
    {  0,  5 }, /* Rt: in load/store instructions.  */
238
    { 10,  5 }, /* Rt2: in load/store pair instructions.  */
239
    { 12,  1 }, /* S: in load/store reg offset instructions.  */
240
    { 12,  2 }, /* SM3_imm2: Indexed element SM3 2 bits index immediate.  */
241
    {  1,  3 }, /* SME_Pdx2: predicate register, multiple of 2, [3:1].  */
242
    { 13,  3 }, /* SME_Pm: second source scalable predicate register P0-P7.  */
243
    {  0,  3 }, /* SME_PNd3: PN0-PN7, bits [2:0].  */
244
    {  5,  3 }, /* SME_PNn3: PN0-PN7, bits [7:5].  */
245
    { 16,  1 }, /* SME_Q: Q class bit, bit 16.  */
246
    { 16,  2 }, /* SME_Rm: index base register W12-W15 [17:16].  */
247
    { 13,  2 }, /* SME_Rv: vector select register W12-W15, bits [14:13].  */
248
    { 15,  1 }, /* SME_V: (horizontal / vertical tiles), bit 15.  */
249
    { 10,  1 }, /* SME_VL_10: VLx2 or VLx4, bit [10].  */
250
    { 13,  1 }, /* SME_VL_13: VLx2 or VLx4, bit [13].  */
251
    {  0,  2 }, /* SME_ZAda_2b: tile ZA0-ZA3.  */
252
    {  0,  3 }, /* SME_ZAda_3b: tile ZA0-ZA7.  */
253
    {  1,  4 }, /* SME_Zdn2: Z0-Z31, multiple of 2, bits [4:1].  */
254
    {  2,  3 }, /* SME_Zdn4: Z0-Z31, multiple of 4, bits [4:2].  */
255
    { 16,  4 }, /* SME_Zm: Z0-Z15, bits [19:16].  */
256
    { 17,  4 }, /* SME_Zm2: Z0-Z31, multiple of 2, bits [20:17].  */
257
    { 18,  3 }, /* SME_Zm4: Z0-Z31, multiple of 4, bits [20:18].  */
258
    {  6,  4 }, /* SME_Zn2: Z0-Z31, multiple of 2, bits [9:6].  */
259
    {  7,  3 }, /* SME_Zn4: Z0-Z31, multiple of 4, bits [9:7].  */
260
    {  4,  1 }, /* SME_ZtT: upper bit of Zt, bit [4].  */
261
    {  0,  3 }, /* SME_Zt3: lower 3 bits of Zt, bits [2:0].  */
262
    {  0,  2 }, /* SME_Zt2: lower 2 bits of Zt, bits [1:0].  */
263
    { 23,  1 }, /* SME_i1: immediate field, bit 23.  */
264
    { 12,  2 }, /* SME_size_12: bits [13:12].  */
265
    { 22,  2 }, /* SME_size_22: size<1>, size<0> class field, [23:22].  */
266
    { 23,  1 }, /* SME_sz_23: bit [23].  */
267
    { 22,  1 }, /* SME_tszh: immediate and qualifier field, bit 22.  */
268
    { 18,  3 }, /* SME_tszl: immediate and qualifier field, bits [20:18].  */
269
    { 0,   8 }, /* SME_zero_mask: list of up to 8 tile names separated by commas [7:0].  */
270
    {  4,  1 }, /* SVE_M_4: Merge/zero select, bit 4.  */
271
    { 14,  1 }, /* SVE_M_14: Merge/zero select, bit 14.  */
272
    { 16,  1 }, /* SVE_M_16: Merge/zero select, bit 16.  */
273
    { 17,  1 }, /* SVE_N: SVE equivalent of N.  */
274
    {  0,  4 }, /* SVE_Pd: p0-p15, bits [3,0].  */
275
    { 10,  3 }, /* SVE_Pg3: p0-p7, bits [12,10].  */
276
    {  5,  4 }, /* SVE_Pg4_5: p0-p15, bits [8,5].  */
277
    { 10,  4 }, /* SVE_Pg4_10: p0-p15, bits [13,10].  */
278
    { 16,  4 }, /* SVE_Pg4_16: p0-p15, bits [19,16].  */
279
    { 16,  4 }, /* SVE_Pm: p0-p15, bits [19,16].  */
280
    {  5,  4 }, /* SVE_Pn: p0-p15, bits [8,5].  */
281
    {  0,  4 }, /* SVE_Pt: p0-p15, bits [3,0].  */
282
    {  5,  5 }, /* SVE_Rm: SVE alternative position for Rm.  */
283
    { 16,  5 }, /* SVE_Rn: SVE alternative position for Rn.  */
284
    {  0,  5 }, /* SVE_Vd: Scalar SIMD&FP register, bits [4,0].  */
285
    {  5,  5 }, /* SVE_Vm: Scalar SIMD&FP register, bits [9,5].  */
286
    {  5,  5 }, /* SVE_Vn: Scalar SIMD&FP register, bits [9,5].  */
287
    {  5,  5 }, /* SVE_Za_5: SVE vector register, bits [9,5].  */
288
    { 16,  5 }, /* SVE_Za_16: SVE vector register, bits [20,16].  */
289
    {  0,  5 }, /* SVE_Zd: SVE vector register. bits [4,0].  */
290
    {  5,  5 }, /* SVE_Zm_5: SVE vector register, bits [9,5].  */
291
    { 16,  5 }, /* SVE_Zm_16: SVE vector register, bits [20,16]. */
292
    {  5,  5 }, /* SVE_Zn: SVE vector register, bits [9,5].  */
293
    {  0,  5 }, /* SVE_Zt: SVE vector register, bits [4,0].  */
294
    {  5,  1 }, /* SVE_i1: single-bit immediate.  */
295
    { 20,  1 }, /* SVE_i2h: high bit of 2bit immediate, bits.  */
296
    { 22,  1 }, /* SVE_i3h: high bit of 3-bit immediate.  */
297
    { 19,  2 }, /* SVE_i3h2: two high bits of 3bit immediate, bits [20,19].  */
298
    { 11,  1 }, /* SVE_i3l: low bit of 3-bit immediate.  */
299
    { 16,  3 }, /* SVE_imm3: 3-bit immediate field.  */
300
    { 16,  4 }, /* SVE_imm4: 4-bit immediate field.  */
301
    {  5,  5 }, /* SVE_imm5: 5-bit immediate field.  */
302
    { 16,  5 }, /* SVE_imm5b: secondary 5-bit immediate field.  */
303
    { 16,  6 }, /* SVE_imm6: 6-bit immediate field.  */
304
    { 14,  7 }, /* SVE_imm7: 7-bit immediate field.  */
305
    {  5,  8 }, /* SVE_imm8: 8-bit immediate field.  */
306
    {  5,  9 }, /* SVE_imm9: 9-bit immediate field.  */
307
    { 11,  6 }, /* SVE_immr: SVE equivalent of immr.  */
308
    {  5,  6 }, /* SVE_imms: SVE equivalent of imms.  */
309
    { 10,  2 }, /* SVE_msz: 2-bit shift amount for ADR.  */
310
    {  5,  5 }, /* SVE_pattern: vector pattern enumeration.  */
311
    {  0,  4 }, /* SVE_prfop: prefetch operation for SVE PRF[BHWD].  */
312
    { 16,  1 }, /* SVE_rot1: 1-bit rotation amount.  */
313
    { 10,  2 }, /* SVE_rot2: 2-bit rotation amount.  */
314
    { 10,  1 }, /* SVE_rot3: 1-bit rotation amount at bit 10.  */
315
    { 17,  2 }, /* SVE_size: 2-bit element size, bits [18,17].  */
316
    { 22,  1 }, /* SVE_sz: 1-bit element size select.  */
317
    { 30,  1 }, /* SVE_sz2: 1-bit element size select.  */
318
    { 16,  4 }, /* SVE_tsz: triangular size select.  */
319
    { 22,  2 }, /* SVE_tszh: triangular size select high, bits [23,22].  */
320
    {  8,  2 }, /* SVE_tszl_8: triangular size select low, bits [9,8].  */
321
    { 19,  2 }, /* SVE_tszl_19: triangular size select low, bits [20,19].  */
322
    { 14,  1 }, /* SVE_xs_14: UXTW/SXTW select (bit 14).  */
323
    { 22,  1 }, /* SVE_xs_22: UXTW/SXTW select (bit 22).  */
324
    { 22,  1 }, /* S_imm10: in LDRAA and LDRAB instructions.  */
325
    { 16,  3 }, /* abc: a:b:c bits in AdvSIMD modified immediate.  */
326
    { 13,  3 }, /* asisdlso_opcode: opcode in advsimd ld/st single element.  */
327
    { 19,  5 }, /* b40: in the test bit and branch instructions.  */
328
    { 31,  1 }, /* b5: in the test bit and branch instructions.  */
329
    { 12,  4 }, /* cmode: in advsimd modified immediate instructions.  */
330
    { 12,  4 }, /* cond: condition flags as a source operand.  */
331
    {  0,  4 }, /* cond2: condition in truly conditional-executed inst.  */
332
    {  5,  5 }, /* defgh: d:e:f:g:h bits in AdvSIMD modified immediate.  */
333
    { 21,  2 }, /* hw: in move wide constant instructions.  */
334
    {  0,  1 }, /* imm1_0: general immediate in bits [0].  */
335
    {  2,  1 }, /* imm1_2: general immediate in bits [2].  */
336
    {  8,  1 }, /* imm1_8: general immediate in bits [8].  */
337
    { 10,  1 }, /* imm1_10: general immediate in bits [10].  */
338
    { 15,  1 }, /* imm1_15: general immediate in bits [15].  */
339
    { 16,  1 }, /* imm1_16: general immediate in bits [16].  */
340
    {  0,  2 }, /* imm2_0: general immediate in bits [1:0].  */
341
    {  1,  2 }, /* imm2_1: general immediate in bits [2:1].  */
342
    {  8,  2 }, /* imm2_8: general immediate in bits [9:8].  */
343
    { 10,  2 }, /* imm2_10: 2-bit immediate, bits [11:10] */
344
    { 12,  2 }, /* imm2_12: 2-bit immediate, bits [13:12] */
345
    { 15,  2 }, /* imm2_15: 2-bit immediate, bits [16:15] */
346
    { 16,  2 }, /* imm2_16: 2-bit immediate, bits [17:16] */
347
    { 19,  2 }, /* imm2_19: 2-bit immediate, bits [20:19] */
348
    {  0,  3 }, /* imm3_0: general immediate in bits [2:0].  */
349
    {  5,  3 }, /* imm3_5: general immediate in bits [7:5].  */
350
    { 10,  3 }, /* imm3_10: in add/sub extended reg instructions.  */
351
    { 12,  3 }, /* imm3_12: general immediate in bits [14:12].  */
352
    { 14,  3 }, /* imm3_14: general immediate in bits [16:14].  */
353
    { 15,  3 }, /* imm3_15: general immediate in bits [17:15].  */
354
    {  0,  4 }, /* imm4_0: in rmif instructions.  */
355
    {  5,  4 }, /* imm4_5: in SME instructions.  */
356
    { 10,  4 }, /* imm4_10: in adddg/subg instructions.  */
357
    { 11,  4 }, /* imm4_11: in advsimd ext and advsimd ins instructions.  */
358
    { 14,  4 }, /* imm4_14: general immediate in bits [17:14].  */
359
    { 16,  5 }, /* imm5: in conditional compare (immediate) instructions.  */
360
    { 10,  6 }, /* imm6_10: in add/sub reg shifted instructions.  */
361
    { 15,  6 }, /* imm6_15: in rmif instructions.  */
362
    { 15,  7 }, /* imm7: in load/store pair pre/post index instructions.  */
363
    { 13,  8 }, /* imm8: in floating-point scalar move immediate inst.  */
364
    { 12,  9 }, /* imm9: in load/store pre/post index instructions.  */
365
    { 10, 12 }, /* imm12: in ld/st unsigned imm or add/sub shifted inst.  */
366
    {  5, 14 }, /* imm14: in test bit and branch instructions.  */
367
    {  0, 16 }, /* imm16_0: in udf instruction. */
368
    {  5, 16 }, /* imm16_5: in exception instructions.  */
369
    {  5, 19 }, /* imm19: e.g. in CBZ.  */
370
    {  0, 26 }, /* imm26: in unconditional branch instructions.  */
371
    { 16,  3 }, /* immb: in advsimd shift by immediate instructions.  */
372
    { 19,  4 }, /* immh: in advsimd shift by immediate instructions.  */
373
    {  5, 19 }, /* immhi: e.g. in ADRP.  */
374
    { 29,  2 }, /* immlo: e.g. in ADRP.  */
375
    { 16,  6 }, /* immr: in bitfield and logical immediate instructions.  */
376
    { 10,  6 }, /* imms: in bitfield and logical immediate instructions.  */
377
    { 11,  1 }, /* index: in ld/st inst deciding the pre/post-index.  */
378
    { 24,  1 }, /* index2: in ld/st pair inst deciding the pre/post-index.  */
379
    { 30,  2 }, /* ldst_size: size field in ld/st reg offset inst.  */
380
    { 13,  2 }, /* len: in advsimd tbl/tbx instructions.  */
381
    { 30,  1 }, /* lse_sz: in LSE extension atomic instructions.  */
382
    {  0,  4 }, /* nzcv: flag bit specifier, encoded in the "nzcv" field.  */
383
    { 29,  1 }, /* op: in AdvSIMD modified immediate instructions.  */
384
    { 19,  2 }, /* op0: in the system instructions.  */
385
    { 16,  3 }, /* op1: in the system instructions.  */
386
    {  5,  3 }, /* op2: in the system instructions.  */
387
    { 22,  2 }, /* opc: in load/store reg offset instructions.  */
388
    { 23,  1 }, /* opc1: in load/store reg offset instructions.  */
389
    { 12,  4 }, /* opcode: in advsimd load/store instructions.  */
390
    { 13,  3 }, /* option: in ld/st reg offset + add/sub extended reg inst.  */
391
    { 11,  2 }, /* rotate1: FCMLA immediate rotate.  */
392
    { 13,  2 }, /* rotate2: Indexed element FCMLA immediate rotate.  */
393
    { 12,  1 }, /* rotate3: FCADD immediate rotate.  */
394
    { 10,  6 }, /* scale: in the fixed-point scalar to fp converting inst.  */
395
    { 31,  1 }, /* sf: in integer data processing instructions.  */
396
    { 22,  2 }, /* shift: in add/sub reg/imm shifted instructions.  */
397
    { 22,  2 }, /* size: in most AdvSIMD and floating-point instructions.  */
398
    { 22,  1 }, /* sz: 1-bit element size select.  */
399
    { 22,  2 }, /* type: floating point type field in fp data inst.  */
400
    { 10,  2 }, /* vldst_size: size field in the AdvSIMD load/store inst.  */
401
};
402
403
enum aarch64_operand_class
404
aarch64_get_operand_class (enum aarch64_opnd type)
405
3.24M
{
406
3.24M
  return aarch64_operands[type].op_class;
407
3.24M
}
408
409
const char *
410
aarch64_get_operand_name (enum aarch64_opnd type)
411
0
{
412
0
  return aarch64_operands[type].name;
413
0
}
414
415
/* Get operand description string.
416
   This is usually for the diagnosis purpose.  */
417
const char *
418
aarch64_get_operand_desc (enum aarch64_opnd type)
419
0
{
420
0
  return aarch64_operands[type].desc;
421
0
}
422
423
/* Table of all conditional affixes.  */
424
const aarch64_cond aarch64_conds[16] =
425
{
426
  {{"eq", "none"}, 0x0},
427
  {{"ne", "any"}, 0x1},
428
  {{"cs", "hs", "nlast"}, 0x2},
429
  {{"cc", "lo", "ul", "last"}, 0x3},
430
  {{"mi", "first"}, 0x4},
431
  {{"pl", "nfrst"}, 0x5},
432
  {{"vs"}, 0x6},
433
  {{"vc"}, 0x7},
434
  {{"hi", "pmore"}, 0x8},
435
  {{"ls", "plast"}, 0x9},
436
  {{"ge", "tcont"}, 0xa},
437
  {{"lt", "tstop"}, 0xb},
438
  {{"gt"}, 0xc},
439
  {{"le"}, 0xd},
440
  {{"al"}, 0xe},
441
  {{"nv"}, 0xf},
442
};
443
444
const aarch64_cond *
445
get_cond_from_value (aarch64_insn value)
446
87.8k
{
447
87.8k
  assert (value < 16);
448
87.8k
  return &aarch64_conds[(unsigned int) value];
449
87.8k
}
450
451
const aarch64_cond *
452
get_inverted_cond (const aarch64_cond *cond)
453
1.24k
{
454
1.24k
  return &aarch64_conds[cond->value ^ 0x1];
455
1.24k
}
456
457
/* Table describing the operand extension/shifting operators; indexed by
458
   enum aarch64_modifier_kind.
459
460
   The value column provides the most common values for encoding modifiers,
461
   which enables table-driven encoding/decoding for the modifiers.  */
462
const struct aarch64_name_value_pair aarch64_operand_modifiers [] =
463
{
464
    {"none", 0x0},
465
    {"msl",  0x0},
466
    {"ror",  0x3},
467
    {"asr",  0x2},
468
    {"lsr",  0x1},
469
    {"lsl",  0x0},
470
    {"uxtb", 0x0},
471
    {"uxth", 0x1},
472
    {"uxtw", 0x2},
473
    {"uxtx", 0x3},
474
    {"sxtb", 0x4},
475
    {"sxth", 0x5},
476
    {"sxtw", 0x6},
477
    {"sxtx", 0x7},
478
    {"mul", 0x0},
479
    {"mul vl", 0x0},
480
    {NULL, 0},
481
};
482
483
enum aarch64_modifier_kind
484
aarch64_get_operand_modifier (const struct aarch64_name_value_pair *desc)
485
0
{
486
0
  return desc - aarch64_operand_modifiers;
487
0
}
488
489
aarch64_insn
490
aarch64_get_operand_modifier_value (enum aarch64_modifier_kind kind)
491
0
{
492
0
  return aarch64_operand_modifiers[kind].value;
493
0
}
494
495
enum aarch64_modifier_kind
496
aarch64_get_operand_modifier_from_value (aarch64_insn value,
497
           bool extend_p)
498
854k
{
499
854k
  if (extend_p)
500
132k
    return AARCH64_MOD_UXTB + value;
501
722k
  else
502
722k
    return AARCH64_MOD_LSL - value;
503
854k
}
504
505
bool
506
aarch64_extend_operator_p (enum aarch64_modifier_kind kind)
507
76.0k
{
508
76.0k
  return kind > AARCH64_MOD_LSL && kind <= AARCH64_MOD_SXTX;
509
76.0k
}
510
511
static inline bool
512
aarch64_shift_operator_p (enum aarch64_modifier_kind kind)
513
689k
{
514
689k
  return kind >= AARCH64_MOD_ROR && kind <= AARCH64_MOD_LSL;
515
689k
}
516
517
const struct aarch64_name_value_pair aarch64_barrier_options[16] =
518
{
519
    { "#0x00", 0x0 },
520
    { "oshld", 0x1 },
521
    { "oshst", 0x2 },
522
    { "osh",   0x3 },
523
    { "#0x04", 0x4 },
524
    { "nshld", 0x5 },
525
    { "nshst", 0x6 },
526
    { "nsh",   0x7 },
527
    { "#0x08", 0x8 },
528
    { "ishld", 0x9 },
529
    { "ishst", 0xa },
530
    { "ish",   0xb },
531
    { "#0x0c", 0xc },
532
    { "ld",    0xd },
533
    { "st",    0xe },
534
    { "sy",    0xf },
535
};
536
537
const struct aarch64_name_value_pair aarch64_barrier_dsb_nxs_options[4] =
538
{                       /*  CRm<3:2>  #imm  */
539
    { "oshnxs", 16 },    /*    00       16   */
540
    { "nshnxs", 20 },    /*    01       20   */
541
    { "ishnxs", 24 },    /*    10       24   */
542
    { "synxs",  28 },    /*    11       28   */
543
};
544
545
/* Table describing the operands supported by the aliases of the HINT
546
   instruction.
547
548
   The name column is the operand that is accepted for the alias.  The value
549
   column is the hint number of the alias.  The list of operands is terminated
550
   by NULL in the name column.  */
551
552
const struct aarch64_name_value_pair aarch64_hint_options[] =
553
{
554
  /* BTI.  This is also the F_DEFAULT entry for AARCH64_OPND_BTI_TARGET.  */
555
  { " ",  HINT_ENCODE (HINT_OPD_F_NOPRINT, 0x20) },
556
  { "csync",  HINT_OPD_CSYNC }, /* PSB CSYNC.  */
557
  { "c",  HINT_OPD_C },   /* BTI C.  */
558
  { "j",  HINT_OPD_J },   /* BTI J.  */
559
  { "jc", HINT_OPD_JC },    /* BTI JC.  */
560
  { NULL, HINT_OPD_NULL },
561
};
562
563
/* op -> op:       load = 0 instruction = 1 store = 2
564
   l  -> level:    1-3
565
   t  -> temporal: temporal (retained) = 0 non-temporal (streaming) = 1   */
566
#define B(op,l,t) (((op) << 3) | (((l) - 1) << 1) | (t))
567
const struct aarch64_name_value_pair aarch64_prfops[32] =
568
{
569
  { "pldl1keep", B(0, 1, 0) },
570
  { "pldl1strm", B(0, 1, 1) },
571
  { "pldl2keep", B(0, 2, 0) },
572
  { "pldl2strm", B(0, 2, 1) },
573
  { "pldl3keep", B(0, 3, 0) },
574
  { "pldl3strm", B(0, 3, 1) },
575
  { NULL, 0x06 },
576
  { NULL, 0x07 },
577
  { "plil1keep", B(1, 1, 0) },
578
  { "plil1strm", B(1, 1, 1) },
579
  { "plil2keep", B(1, 2, 0) },
580
  { "plil2strm", B(1, 2, 1) },
581
  { "plil3keep", B(1, 3, 0) },
582
  { "plil3strm", B(1, 3, 1) },
583
  { NULL, 0x0e },
584
  { NULL, 0x0f },
585
  { "pstl1keep", B(2, 1, 0) },
586
  { "pstl1strm", B(2, 1, 1) },
587
  { "pstl2keep", B(2, 2, 0) },
588
  { "pstl2strm", B(2, 2, 1) },
589
  { "pstl3keep", B(2, 3, 0) },
590
  { "pstl3strm", B(2, 3, 1) },
591
  { NULL, 0x16 },
592
  { NULL, 0x17 },
593
  { NULL, 0x18 },
594
  { NULL, 0x19 },
595
  { NULL, 0x1a },
596
  { NULL, 0x1b },
597
  { NULL, 0x1c },
598
  { NULL, 0x1d },
599
  { NULL, 0x1e },
600
  { NULL, 0x1f },
601
};
602
#undef B
603

604
/* Utilities on value constraint.  */
605
606
static inline int
607
value_in_range_p (int64_t value, int low, int high)
608
3.02M
{
609
3.02M
  return (value >= low && value <= high) ? 1 : 0;
610
3.02M
}
611
612
/* Return true if VALUE is a multiple of ALIGN.  */
613
static inline int
614
value_aligned_p (int64_t value, int align)
615
2.18M
{
616
2.18M
  return (value % align) == 0;
617
2.18M
}
618
619
/* A signed value fits in a field.  */
620
static inline int
621
value_fit_signed_field_p (int64_t value, unsigned width)
622
1.34M
{
623
1.34M
  assert (width < 32);
624
1.34M
  if (width < sizeof (value) * 8)
625
1.34M
    {
626
1.34M
      int64_t lim = (uint64_t) 1 << (width - 1);
627
1.34M
      if (value >= -lim && value < lim)
628
1.34M
  return 1;
629
1.34M
    }
630
0
  return 0;
631
1.34M
}
632
633
/* An unsigned value fits in a field.  */
634
static inline int
635
value_fit_unsigned_field_p (int64_t value, unsigned width)
636
2.04M
{
637
2.04M
  assert (width < 32);
638
2.04M
  if (width < sizeof (value) * 8)
639
2.04M
    {
640
2.04M
      int64_t lim = (uint64_t) 1 << width;
641
2.04M
      if (value >= 0 && value < lim)
642
2.04M
  return 1;
643
2.04M
    }
644
0
  return 0;
645
2.04M
}
646
647
/* Return 1 if OPERAND is SP or WSP.  */
648
int
649
aarch64_stack_pointer_p (const aarch64_opnd_info *operand)
650
235k
{
651
235k
  return ((aarch64_get_operand_class (operand->type)
652
235k
     == AARCH64_OPND_CLASS_INT_REG)
653
235k
    && operand_maybe_stack_pointer (aarch64_operands + operand->type)
654
235k
    && operand->reg.regno == 31);
655
235k
}
656
657
/* Return 1 if OPERAND is XZR or WZP.  */
658
int
659
aarch64_zero_register_p (const aarch64_opnd_info *operand)
660
0
{
661
0
  return ((aarch64_get_operand_class (operand->type)
662
0
     == AARCH64_OPND_CLASS_INT_REG)
663
0
    && !operand_maybe_stack_pointer (aarch64_operands + operand->type)
664
0
    && operand->reg.regno == 31);
665
0
}
666
667
/* Return true if the operand *OPERAND that has the operand code
668
   OPERAND->TYPE and been qualified by OPERAND->QUALIFIER can be also
669
   qualified by the qualifier TARGET.  */
670
671
static inline int
672
operand_also_qualified_p (const struct aarch64_opnd_info *operand,
673
        aarch64_opnd_qualifier_t target)
674
5.35M
{
675
5.35M
  switch (operand->qualifier)
676
5.35M
    {
677
4.87k
    case AARCH64_OPND_QLF_W:
678
4.87k
      if (target == AARCH64_OPND_QLF_WSP && aarch64_stack_pointer_p (operand))
679
182
  return 1;
680
4.69k
      break;
681
1.44M
    case AARCH64_OPND_QLF_X:
682
1.44M
      if (target == AARCH64_OPND_QLF_SP && aarch64_stack_pointer_p (operand))
683
66
  return 1;
684
1.44M
      break;
685
1.44M
    case AARCH64_OPND_QLF_WSP:
686
0
      if (target == AARCH64_OPND_QLF_W
687
0
    && operand_maybe_stack_pointer (aarch64_operands + operand->type))
688
0
  return 1;
689
0
      break;
690
0
    case AARCH64_OPND_QLF_SP:
691
0
      if (target == AARCH64_OPND_QLF_X
692
0
    && operand_maybe_stack_pointer (aarch64_operands + operand->type))
693
0
  return 1;
694
0
      break;
695
3.90M
    default:
696
3.90M
      break;
697
5.35M
    }
698
699
5.35M
  return 0;
700
5.35M
}
701
702
/* Given qualifier sequence list QSEQ_LIST and the known qualifier KNOWN_QLF
703
   for operand KNOWN_IDX, return the expected qualifier for operand IDX.
704
705
   Return NIL if more than one expected qualifiers are found.  */
706
707
aarch64_opnd_qualifier_t
708
aarch64_get_expected_qualifier (const aarch64_opnd_qualifier_seq_t *qseq_list,
709
        int idx,
710
        const aarch64_opnd_qualifier_t known_qlf,
711
        int known_idx)
712
0
{
713
0
  int i, saved_i;
714
715
  /* Special case.
716
717
     When the known qualifier is NIL, we have to assume that there is only
718
     one qualifier sequence in the *QSEQ_LIST and return the corresponding
719
     qualifier directly.  One scenario is that for instruction
720
  PRFM <prfop>, [<Xn|SP>, #:lo12:<symbol>]
721
     which has only one possible valid qualifier sequence
722
  NIL, S_D
723
     the caller may pass NIL in KNOWN_QLF to obtain S_D so that it can
724
     determine the correct relocation type (i.e. LDST64_LO12) for PRFM.
725
726
     Because the qualifier NIL has dual roles in the qualifier sequence:
727
     it can mean no qualifier for the operand, or the qualifer sequence is
728
     not in use (when all qualifiers in the sequence are NILs), we have to
729
     handle this special case here.  */
730
0
  if (known_qlf == AARCH64_OPND_NIL)
731
0
    {
732
0
      assert (qseq_list[0][known_idx] == AARCH64_OPND_NIL);
733
0
      return qseq_list[0][idx];
734
0
    }
735
736
0
  for (i = 0, saved_i = -1; i < AARCH64_MAX_QLF_SEQ_NUM; ++i)
737
0
    {
738
0
      if (qseq_list[i][known_idx] == known_qlf)
739
0
  {
740
0
    if (saved_i != -1)
741
      /* More than one sequences are found to have KNOWN_QLF at
742
         KNOWN_IDX.  */
743
0
      return AARCH64_OPND_NIL;
744
0
    saved_i = i;
745
0
  }
746
0
    }
747
748
0
  return qseq_list[saved_i][idx];
749
0
}
750
751
enum operand_qualifier_kind
752
{
753
  OQK_NIL,
754
  OQK_OPD_VARIANT,
755
  OQK_VALUE_IN_RANGE,
756
  OQK_MISC,
757
};
758
759
/* Operand qualifier description.  */
760
struct operand_qualifier_data
761
{
762
  /* The usage of the three data fields depends on the qualifier kind.  */
763
  int data0;
764
  int data1;
765
  int data2;
766
  /* Description.  */
767
  const char *desc;
768
  /* Kind.  */
769
  enum operand_qualifier_kind kind;
770
};
771
772
/* Indexed by the operand qualifier enumerators.  */
773
struct operand_qualifier_data aarch64_opnd_qualifiers[] =
774
{
775
  {0, 0, 0, "NIL", OQK_NIL},
776
777
  /* Operand variant qualifiers.
778
     First 3 fields:
779
     element size, number of elements and common value for encoding.  */
780
781
  {4, 1, 0x0, "w", OQK_OPD_VARIANT},
782
  {8, 1, 0x1, "x", OQK_OPD_VARIANT},
783
  {4, 1, 0x0, "wsp", OQK_OPD_VARIANT},
784
  {8, 1, 0x1, "sp", OQK_OPD_VARIANT},
785
786
  {1, 1, 0x0, "b", OQK_OPD_VARIANT},
787
  {2, 1, 0x1, "h", OQK_OPD_VARIANT},
788
  {4, 1, 0x2, "s", OQK_OPD_VARIANT},
789
  {8, 1, 0x3, "d", OQK_OPD_VARIANT},
790
  {16, 1, 0x4, "q", OQK_OPD_VARIANT},
791
  {4, 1, 0x0, "4b", OQK_OPD_VARIANT},
792
  {4, 1, 0x0, "2h", OQK_OPD_VARIANT},
793
794
  {1, 4, 0x0, "4b", OQK_OPD_VARIANT},
795
  {1, 8, 0x0, "8b", OQK_OPD_VARIANT},
796
  {1, 16, 0x1, "16b", OQK_OPD_VARIANT},
797
  {2, 2, 0x0, "2h", OQK_OPD_VARIANT},
798
  {2, 4, 0x2, "4h", OQK_OPD_VARIANT},
799
  {2, 8, 0x3, "8h", OQK_OPD_VARIANT},
800
  {4, 2, 0x4, "2s", OQK_OPD_VARIANT},
801
  {4, 4, 0x5, "4s", OQK_OPD_VARIANT},
802
  {8, 1, 0x6, "1d", OQK_OPD_VARIANT},
803
  {8, 2, 0x7, "2d", OQK_OPD_VARIANT},
804
  {16, 1, 0x8, "1q", OQK_OPD_VARIANT},
805
806
  {0, 0, 0, "z", OQK_OPD_VARIANT},
807
  {0, 0, 0, "m", OQK_OPD_VARIANT},
808
809
  /* Qualifier for scaled immediate for Tag granule (stg,st2g,etc).  */
810
  {16, 0, 0, "tag", OQK_OPD_VARIANT},
811
812
  /* Qualifiers constraining the value range.
813
     First 3 fields:
814
     Lower bound, higher bound, unused.  */
815
816
  {0, 15, 0, "CR",       OQK_VALUE_IN_RANGE},
817
  {0,  7, 0, "imm_0_7" , OQK_VALUE_IN_RANGE},
818
  {0, 15, 0, "imm_0_15", OQK_VALUE_IN_RANGE},
819
  {0, 31, 0, "imm_0_31", OQK_VALUE_IN_RANGE},
820
  {0, 63, 0, "imm_0_63", OQK_VALUE_IN_RANGE},
821
  {1, 32, 0, "imm_1_32", OQK_VALUE_IN_RANGE},
822
  {1, 64, 0, "imm_1_64", OQK_VALUE_IN_RANGE},
823
824
  /* Qualifiers for miscellaneous purpose.
825
     First 3 fields:
826
     unused, unused and unused.  */
827
828
  {0, 0, 0, "lsl", 0},
829
  {0, 0, 0, "msl", 0},
830
831
  {0, 0, 0, "retrieving", 0},
832
};
833
834
static inline bool
835
operand_variant_qualifier_p (aarch64_opnd_qualifier_t qualifier)
836
12.7M
{
837
12.7M
  return aarch64_opnd_qualifiers[qualifier].kind == OQK_OPD_VARIANT;
838
12.7M
}
839
840
static inline bool
841
qualifier_value_in_range_constraint_p (aarch64_opnd_qualifier_t qualifier)
842
4.41M
{
843
4.41M
  return aarch64_opnd_qualifiers[qualifier].kind == OQK_VALUE_IN_RANGE;
844
4.41M
}
845
846
const char*
847
aarch64_get_qualifier_name (aarch64_opnd_qualifier_t qualifier)
848
4.03M
{
849
4.03M
  return aarch64_opnd_qualifiers[qualifier].desc;
850
4.03M
}
851
852
/* Given an operand qualifier, return the expected data element size
853
   of a qualified operand.  */
854
unsigned char
855
aarch64_get_qualifier_esize (aarch64_opnd_qualifier_t qualifier)
856
9.07M
{
857
9.07M
  assert (operand_variant_qualifier_p (qualifier));
858
9.07M
  return aarch64_opnd_qualifiers[qualifier].data0;
859
9.07M
}
860
861
unsigned char
862
aarch64_get_qualifier_nelem (aarch64_opnd_qualifier_t qualifier)
863
80.6k
{
864
80.6k
  assert (operand_variant_qualifier_p (qualifier));
865
80.6k
  return aarch64_opnd_qualifiers[qualifier].data1;
866
80.6k
}
867
868
aarch64_insn
869
aarch64_get_qualifier_standard_value (aarch64_opnd_qualifier_t qualifier)
870
3.57M
{
871
3.57M
  assert (operand_variant_qualifier_p (qualifier));
872
3.57M
  return aarch64_opnd_qualifiers[qualifier].data2;
873
3.57M
}
874
875
static int
876
get_lower_bound (aarch64_opnd_qualifier_t qualifier)
877
616k
{
878
616k
  assert (qualifier_value_in_range_constraint_p (qualifier));
879
616k
  return aarch64_opnd_qualifiers[qualifier].data0;
880
616k
}
881
882
static int
883
get_upper_bound (aarch64_opnd_qualifier_t qualifier)
884
655k
{
885
655k
  assert (qualifier_value_in_range_constraint_p (qualifier));
886
655k
  return aarch64_opnd_qualifiers[qualifier].data1;
887
655k
}
888
889
#ifdef DEBUG_AARCH64
890
void
891
aarch64_verbose (const char *str, ...)
892
{
893
  va_list ap;
894
  va_start (ap, str);
895
  printf ("#### ");
896
  vprintf (str, ap);
897
  printf ("\n");
898
  va_end (ap);
899
}
900
901
static inline void
902
dump_qualifier_sequence (const aarch64_opnd_qualifier_t *qualifier)
903
{
904
  int i;
905
  printf ("#### \t");
906
  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i, ++qualifier)
907
    printf ("%s,", aarch64_get_qualifier_name (*qualifier));
908
  printf ("\n");
909
}
910
911
static void
912
dump_match_qualifiers (const struct aarch64_opnd_info *opnd,
913
           const aarch64_opnd_qualifier_t *qualifier)
914
{
915
  int i;
916
  aarch64_opnd_qualifier_t curr[AARCH64_MAX_OPND_NUM];
917
918
  aarch64_verbose ("dump_match_qualifiers:");
919
  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
920
    curr[i] = opnd[i].qualifier;
921
  dump_qualifier_sequence (curr);
922
  aarch64_verbose ("against");
923
  dump_qualifier_sequence (qualifier);
924
}
925
#endif /* DEBUG_AARCH64 */
926
927
/* This function checks if the given instruction INSN is a destructive
928
   instruction based on the usage of the registers.  It does not recognize
929
   unary destructive instructions.  */
930
bool
931
aarch64_is_destructive_by_operands (const aarch64_opcode *opcode)
932
293
{
933
293
  int i = 0;
934
293
  const enum aarch64_opnd *opnds = opcode->operands;
935
936
293
  if (opnds[0] == AARCH64_OPND_NIL)
937
0
    return false;
938
939
761
  while (opnds[++i] != AARCH64_OPND_NIL)
940
674
    if (opnds[i] == opnds[0])
941
206
      return true;
942
943
87
  return false;
944
293
}
945
946
/* TODO improve this, we can have an extra field at the runtime to
947
   store the number of operands rather than calculating it every time.  */
948
949
int
950
aarch64_num_of_operands (const aarch64_opcode *opcode)
951
9.91M
{
952
9.91M
  int i = 0;
953
9.91M
  const enum aarch64_opnd *opnds = opcode->operands;
954
34.4M
  while (opnds[i++] != AARCH64_OPND_NIL)
955
24.5M
    ;
956
9.91M
  --i;
957
9.91M
  assert (i >= 0 && i <= AARCH64_MAX_OPND_NUM);
958
9.91M
  return i;
959
9.91M
}
960
961
/* Find the best matched qualifier sequence in *QUALIFIERS_LIST for INST.
962
   If succeeds, fill the found sequence in *RET, return 1; otherwise return 0.
963
964
   Store the smallest number of non-matching qualifiers in *INVALID_COUNT.
965
   This is always 0 if the function succeeds.
966
967
   N.B. on the entry, it is very likely that only some operands in *INST
968
   have had their qualifiers been established.
969
970
   If STOP_AT is not -1, the function will only try to match
971
   the qualifier sequence for operands before and including the operand
972
   of index STOP_AT; and on success *RET will only be filled with the first
973
   (STOP_AT+1) qualifiers.
974
975
   A couple examples of the matching algorithm:
976
977
   X,W,NIL should match
978
   X,W,NIL
979
980
   NIL,NIL should match
981
   X  ,NIL
982
983
   Apart from serving the main encoding routine, this can also be called
984
   during or after the operand decoding.  */
985
986
int
987
aarch64_find_best_match (const aarch64_inst *inst,
988
       const aarch64_opnd_qualifier_seq_t *qualifiers_list,
989
       int stop_at, aarch64_opnd_qualifier_t *ret,
990
       int *invalid_count)
991
8.90M
{
992
8.90M
  int i, num_opnds, invalid, min_invalid;
993
8.90M
  const aarch64_opnd_qualifier_t *qualifiers;
994
995
8.90M
  num_opnds = aarch64_num_of_operands (inst->opcode);
996
8.90M
  if (num_opnds == 0)
997
3
    {
998
3
      DEBUG_TRACE ("SUCCEED: no operand");
999
3
      *invalid_count = 0;
1000
3
      return 1;
1001
3
    }
1002
1003
8.90M
  if (stop_at < 0 || stop_at >= num_opnds)
1004
7.71M
    stop_at = num_opnds - 1;
1005
1006
  /* For each pattern.  */
1007
8.90M
  min_invalid = num_opnds;
1008
12.8M
  for (i = 0; i < AARCH64_MAX_QLF_SEQ_NUM; ++i, ++qualifiers_list)
1009
12.8M
    {
1010
12.8M
      int j;
1011
12.8M
      qualifiers = *qualifiers_list;
1012
1013
      /* Start as positive.  */
1014
12.8M
      invalid = 0;
1015
1016
12.8M
      DEBUG_TRACE ("%d", i);
1017
#ifdef DEBUG_AARCH64
1018
      if (debug_dump)
1019
  dump_match_qualifiers (inst->operands, qualifiers);
1020
#endif
1021
1022
      /* The first entry should be taken literally, even if it's an empty
1023
   qualifier sequence.  (This matters for strict testing.)  In other
1024
   positions an empty sequence acts as a terminator.  */
1025
12.8M
      if (i > 0 && empty_qualifier_sequence_p (qualifiers))
1026
68.0k
  break;
1027
1028
44.6M
      for (j = 0; j < num_opnds && j <= stop_at; ++j, ++qualifiers)
1029
31.9M
  {
1030
31.9M
    if (inst->operands[j].qualifier == AARCH64_OPND_QLF_NIL
1031
31.9M
        && !(inst->opcode->flags & F_STRICT))
1032
16.9M
      {
1033
        /* Either the operand does not have qualifier, or the qualifier
1034
     for the operand needs to be deduced from the qualifier
1035
     sequence.
1036
     In the latter case, any constraint checking related with
1037
     the obtained qualifier should be done later in
1038
     operand_general_constraint_met_p.  */
1039
16.9M
        continue;
1040
16.9M
      }
1041
14.9M
    else if (*qualifiers != inst->operands[j].qualifier)
1042
5.35M
      {
1043
        /* Unless the target qualifier can also qualify the operand
1044
     (which has already had a non-nil qualifier), non-equal
1045
     qualifiers are generally un-matched.  */
1046
5.35M
        if (operand_also_qualified_p (inst->operands + j, *qualifiers))
1047
248
    continue;
1048
5.35M
        else
1049
5.35M
    invalid += 1;
1050
5.35M
      }
1051
9.57M
    else
1052
9.57M
      continue; /* Equal qualifiers are certainly matched.  */
1053
31.9M
  }
1054
1055
12.7M
      if (min_invalid > invalid)
1056
11.2M
  min_invalid = invalid;
1057
1058
      /* Qualifiers established.  */
1059
12.7M
      if (min_invalid == 0)
1060
8.84M
  break;
1061
12.7M
    }
1062
1063
8.90M
  *invalid_count = min_invalid;
1064
8.90M
  if (min_invalid == 0)
1065
8.84M
    {
1066
      /* Fill the result in *RET.  */
1067
8.84M
      int j;
1068
8.84M
      qualifiers = *qualifiers_list;
1069
1070
8.84M
      DEBUG_TRACE ("complete qualifiers using list %d", i);
1071
#ifdef DEBUG_AARCH64
1072
      if (debug_dump)
1073
  dump_qualifier_sequence (qualifiers);
1074
#endif
1075
1076
30.0M
      for (j = 0; j <= stop_at; ++j, ++qualifiers)
1077
21.2M
  ret[j] = *qualifiers;
1078
40.6M
      for (; j < AARCH64_MAX_OPND_NUM; ++j)
1079
31.8M
  ret[j] = AARCH64_OPND_QLF_NIL;
1080
1081
8.84M
      DEBUG_TRACE ("SUCCESS");
1082
8.84M
      return 1;
1083
8.84M
    }
1084
1085
68.0k
  DEBUG_TRACE ("FAIL");
1086
68.0k
  return 0;
1087
8.90M
}
1088
1089
/* Operand qualifier matching and resolving.
1090
1091
   Return 1 if the operand qualifier(s) in *INST match one of the qualifier
1092
   sequences in INST->OPCODE->qualifiers_list; otherwise return 0.
1093
1094
   Store the smallest number of non-matching qualifiers in *INVALID_COUNT.
1095
   This is always 0 if the function succeeds.
1096
1097
   if UPDATE_P, update the qualifier(s) in *INST after the matching
1098
   succeeds.  */
1099
1100
static int
1101
match_operands_qualifier (aarch64_inst *inst, bool update_p,
1102
        int *invalid_count)
1103
7.71M
{
1104
7.71M
  int i;
1105
7.71M
  aarch64_opnd_qualifier_seq_t qualifiers;
1106
1107
7.71M
  if (!aarch64_find_best_match (inst, inst->opcode->qualifiers_list, -1,
1108
7.71M
        qualifiers, invalid_count))
1109
40.2k
    {
1110
40.2k
      DEBUG_TRACE ("matching FAIL");
1111
40.2k
      return 0;
1112
40.2k
    }
1113
1114
  /* Update the qualifiers.  */
1115
7.67M
  if (update_p)
1116
25.9M
    for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
1117
25.9M
      {
1118
25.9M
  if (inst->opcode->operands[i] == AARCH64_OPND_NIL)
1119
7.67M
    break;
1120
18.2M
  DEBUG_TRACE_IF (inst->operands[i].qualifier != qualifiers[i],
1121
18.2M
      "update %s with %s for operand %d",
1122
18.2M
      aarch64_get_qualifier_name (inst->operands[i].qualifier),
1123
18.2M
      aarch64_get_qualifier_name (qualifiers[i]), i);
1124
18.2M
  inst->operands[i].qualifier = qualifiers[i];
1125
18.2M
      }
1126
1127
7.67M
  DEBUG_TRACE ("matching SUCCESS");
1128
7.67M
  return 1;
1129
7.71M
}
1130
1131
/* Return TRUE if VALUE is a wide constant that can be moved into a general
1132
   register by MOVZ.
1133
1134
   IS32 indicates whether value is a 32-bit immediate or not.
1135
   If SHIFT_AMOUNT is not NULL, on the return of TRUE, the logical left shift
1136
   amount will be returned in *SHIFT_AMOUNT.  */
1137
1138
bool
1139
aarch64_wide_constant_p (uint64_t value, int is32, unsigned int *shift_amount)
1140
111k
{
1141
111k
  int amount;
1142
1143
111k
  DEBUG_TRACE ("enter with 0x%" PRIx64 "(%" PRIi64 ")", value, value);
1144
1145
111k
  if (is32)
1146
35.0k
    {
1147
      /* Allow all zeros or all ones in top 32-bits, so that
1148
   32-bit constant expressions like ~0x80000000 are
1149
   permitted.  */
1150
35.0k
      if (value >> 32 != 0 && value >> 32 != 0xffffffff)
1151
  /* Immediate out of range.  */
1152
0
  return false;
1153
35.0k
      value &= 0xffffffff;
1154
35.0k
    }
1155
1156
  /* first, try movz then movn */
1157
111k
  amount = -1;
1158
111k
  if ((value & ((uint64_t) 0xffff << 0)) == value)
1159
40.4k
    amount = 0;
1160
70.9k
  else if ((value & ((uint64_t) 0xffff << 16)) == value)
1161
14.3k
    amount = 16;
1162
56.6k
  else if (!is32 && (value & ((uint64_t) 0xffff << 32)) == value)
1163
13.0k
    amount = 32;
1164
43.5k
  else if (!is32 && (value & ((uint64_t) 0xffff << 48)) == value)
1165
7.25k
    amount = 48;
1166
1167
111k
  if (amount == -1)
1168
36.2k
    {
1169
36.2k
      DEBUG_TRACE ("exit false with 0x%" PRIx64 "(%" PRIi64 ")", value, value);
1170
36.2k
      return false;
1171
36.2k
    }
1172
1173
75.1k
  if (shift_amount != NULL)
1174
0
    *shift_amount = amount;
1175
1176
75.1k
  DEBUG_TRACE ("exit true with amount %d", amount);
1177
1178
75.1k
  return true;
1179
111k
}
1180
1181
/* Build the accepted values for immediate logical SIMD instructions.
1182
1183
   The standard encodings of the immediate value are:
1184
     N      imms     immr         SIMD size  R             S
1185
     1      ssssss   rrrrrr       64      UInt(rrrrrr)  UInt(ssssss)
1186
     0      0sssss   0rrrrr       32      UInt(rrrrr)   UInt(sssss)
1187
     0      10ssss   00rrrr       16      UInt(rrrr)    UInt(ssss)
1188
     0      110sss   000rrr       8       UInt(rrr)     UInt(sss)
1189
     0      1110ss   0000rr       4       UInt(rr)      UInt(ss)
1190
     0      11110s   00000r       2       UInt(r)       UInt(s)
1191
   where all-ones value of S is reserved.
1192
1193
   Let's call E the SIMD size.
1194
1195
   The immediate value is: S+1 bits '1' rotated to the right by R.
1196
1197
   The total of valid encodings is 64*63 + 32*31 + ... + 2*1 = 5334
1198
   (remember S != E - 1).  */
1199
1200
336k
#define TOTAL_IMM_NB  5334
1201
1202
typedef struct
1203
{
1204
  uint64_t imm;
1205
  aarch64_insn encoding;
1206
} simd_imm_encoding;
1207
1208
static simd_imm_encoding simd_immediates[TOTAL_IMM_NB];
1209
1210
static int
1211
simd_imm_encoding_cmp(const void *i1, const void *i2)
1212
3.98M
{
1213
3.98M
  const simd_imm_encoding *imm1 = (const simd_imm_encoding *)i1;
1214
3.98M
  const simd_imm_encoding *imm2 = (const simd_imm_encoding *)i2;
1215
1216
3.98M
  if (imm1->imm < imm2->imm)
1217
1.97M
    return -1;
1218
2.00M
  if (imm1->imm > imm2->imm)
1219
1.66M
    return +1;
1220
336k
  return 0;
1221
2.00M
}
1222
1223
/* immediate bitfield standard encoding
1224
   imm13<12> imm13<5:0> imm13<11:6> SIMD size R      S
1225
   1         ssssss     rrrrrr      64        rrrrrr ssssss
1226
   0         0sssss     0rrrrr      32        rrrrr  sssss
1227
   0         10ssss     00rrrr      16        rrrr   ssss
1228
   0         110sss     000rrr      8         rrr    sss
1229
   0         1110ss     0000rr      4         rr     ss
1230
   0         11110s     00000r      2         r      s  */
1231
static inline int
1232
encode_immediate_bitfield (int is64, uint32_t s, uint32_t r)
1233
10.6k
{
1234
10.6k
  return (is64 << 12) | (r << 6) | s;
1235
10.6k
}
1236
1237
static void
1238
build_immediate_table (void)
1239
2
{
1240
2
  uint32_t log_e, e, s, r, s_mask;
1241
2
  uint64_t mask, imm;
1242
2
  int nb_imms;
1243
2
  int is64;
1244
1245
2
  nb_imms = 0;
1246
14
  for (log_e = 1; log_e <= 6; log_e++)
1247
12
    {
1248
      /* Get element size.  */
1249
12
      e = 1u << log_e;
1250
12
      if (log_e == 6)
1251
2
  {
1252
2
    is64 = 1;
1253
2
    mask = 0xffffffffffffffffull;
1254
2
    s_mask = 0;
1255
2
  }
1256
10
      else
1257
10
  {
1258
10
    is64 = 0;
1259
10
    mask = (1ull << e) - 1;
1260
    /* log_e  s_mask
1261
       1     ((1 << 4) - 1) << 2 = 111100
1262
       2     ((1 << 3) - 1) << 3 = 111000
1263
       3     ((1 << 2) - 1) << 4 = 110000
1264
       4     ((1 << 1) - 1) << 5 = 100000
1265
       5     ((1 << 0) - 1) << 6 = 000000  */
1266
10
    s_mask = ((1u << (5 - log_e)) - 1) << (log_e + 1);
1267
10
  }
1268
252
      for (s = 0; s < e - 1; s++)
1269
10.9k
  for (r = 0; r < e; r++)
1270
10.6k
    {
1271
      /* s+1 consecutive bits to 1 (s < 63) */
1272
10.6k
      imm = (1ull << (s + 1)) - 1;
1273
      /* rotate right by r */
1274
10.6k
      if (r != 0)
1275
10.4k
        imm = (imm >> r) | ((imm << (e - r)) & mask);
1276
      /* replicate the constant depending on SIMD size */
1277
10.6k
      switch (log_e)
1278
10.6k
        {
1279
4
        case 1: imm = (imm <<  2) | imm;
1280
    /* Fall through.  */
1281
28
        case 2: imm = (imm <<  4) | imm;
1282
    /* Fall through.  */
1283
140
        case 3: imm = (imm <<  8) | imm;
1284
    /* Fall through.  */
1285
620
        case 4: imm = (imm << 16) | imm;
1286
    /* Fall through.  */
1287
2.60k
        case 5: imm = (imm << 32) | imm;
1288
    /* Fall through.  */
1289
10.6k
        case 6: break;
1290
0
        default: abort ();
1291
10.6k
        }
1292
10.6k
      simd_immediates[nb_imms].imm = imm;
1293
10.6k
      simd_immediates[nb_imms].encoding =
1294
10.6k
        encode_immediate_bitfield(is64, s | s_mask, r);
1295
10.6k
      nb_imms++;
1296
10.6k
    }
1297
12
    }
1298
2
  assert (nb_imms == TOTAL_IMM_NB);
1299
2
  qsort(simd_immediates, nb_imms,
1300
2
  sizeof(simd_immediates[0]), simd_imm_encoding_cmp);
1301
2
}
1302
1303
/* Return TRUE if VALUE is a valid logical immediate, i.e. bitmask, that can
1304
   be accepted by logical (immediate) instructions
1305
   e.g. ORR <Xd|SP>, <Xn>, #<imm>.
1306
1307
   ESIZE is the number of bytes in the decoded immediate value.
1308
   If ENCODING is not NULL, on the return of TRUE, the standard encoding for
1309
   VALUE will be returned in *ENCODING.  */
1310
1311
bool
1312
aarch64_logical_immediate_p (uint64_t value, int esize, aarch64_insn *encoding)
1313
336k
{
1314
336k
  simd_imm_encoding imm_enc;
1315
336k
  const simd_imm_encoding *imm_encoding;
1316
336k
  static bool initialized = false;
1317
336k
  uint64_t upper;
1318
336k
  int i;
1319
1320
336k
  DEBUG_TRACE ("enter with 0x%" PRIx64 "(%" PRIi64 "), esize: %d", value,
1321
336k
         value, esize);
1322
1323
336k
  if (!initialized)
1324
2
    {
1325
2
      build_immediate_table ();
1326
2
      initialized = true;
1327
2
    }
1328
1329
  /* Allow all zeros or all ones in top bits, so that
1330
     constant expressions like ~1 are permitted.  */
1331
336k
  upper = (uint64_t) -1 << (esize * 4) << (esize * 4);
1332
336k
  if ((value & ~upper) != value && (value | upper) != value)
1333
0
    return false;
1334
1335
  /* Replicate to a full 64-bit value.  */
1336
336k
  value &= ~upper;
1337
562k
  for (i = esize * 8; i < 64; i *= 2)
1338
226k
    value |= (value << i);
1339
1340
336k
  imm_enc.imm = value;
1341
336k
  imm_encoding = (const simd_imm_encoding *)
1342
336k
    bsearch(&imm_enc, simd_immediates, TOTAL_IMM_NB,
1343
336k
            sizeof(simd_immediates[0]), simd_imm_encoding_cmp);
1344
336k
  if (imm_encoding == NULL)
1345
0
    {
1346
0
      DEBUG_TRACE ("exit with false");
1347
0
      return false;
1348
0
    }
1349
336k
  if (encoding != NULL)
1350
0
    *encoding = imm_encoding->encoding;
1351
336k
  DEBUG_TRACE ("exit with true");
1352
336k
  return true;
1353
336k
}
1354
1355
/* If 64-bit immediate IMM is in the format of
1356
   "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffgggggggghhhhhhhh",
1357
   where a, b, c, d, e, f, g and h are independently 0 or 1, return an integer
1358
   of value "abcdefgh".  Otherwise return -1.  */
1359
int
1360
aarch64_shrink_expanded_imm8 (uint64_t imm)
1361
164
{
1362
164
  int i, ret;
1363
164
  uint32_t byte;
1364
1365
164
  ret = 0;
1366
1.47k
  for (i = 0; i < 8; i++)
1367
1.31k
    {
1368
1.31k
      byte = (imm >> (8 * i)) & 0xff;
1369
1.31k
      if (byte == 0xff)
1370
592
  ret |= 1 << i;
1371
720
      else if (byte != 0x00)
1372
0
  return -1;
1373
1.31k
    }
1374
164
  return ret;
1375
164
}
1376
1377
/* Utility inline functions for operand_general_constraint_met_p.  */
1378
1379
static inline void
1380
set_error (aarch64_operand_error *mismatch_detail,
1381
     enum aarch64_operand_error_kind kind, int idx,
1382
     const char* error)
1383
0
{
1384
0
  if (mismatch_detail == NULL)
1385
0
    return;
1386
0
  mismatch_detail->kind = kind;
1387
0
  mismatch_detail->index = idx;
1388
0
  mismatch_detail->error = error;
1389
0
}
1390
1391
static inline void
1392
set_syntax_error (aarch64_operand_error *mismatch_detail, int idx,
1393
      const char* error)
1394
1.36k
{
1395
1.36k
  if (mismatch_detail == NULL)
1396
1.36k
    return;
1397
0
  set_error (mismatch_detail, AARCH64_OPDE_SYNTAX_ERROR, idx, error);
1398
0
}
1399
1400
static inline void
1401
set_invalid_regno_error (aarch64_operand_error *mismatch_detail, int idx,
1402
       const char *prefix, int lower_bound, int upper_bound)
1403
0
{
1404
0
  if (mismatch_detail == NULL)
1405
0
    return;
1406
0
  set_error (mismatch_detail, AARCH64_OPDE_INVALID_REGNO, idx, NULL);
1407
0
  mismatch_detail->data[0].s = prefix;
1408
0
  mismatch_detail->data[1].i = lower_bound;
1409
0
  mismatch_detail->data[2].i = upper_bound;
1410
0
}
1411
1412
static inline void
1413
set_out_of_range_error (aarch64_operand_error *mismatch_detail,
1414
      int idx, int lower_bound, int upper_bound,
1415
      const char* error)
1416
0
{
1417
0
  if (mismatch_detail == NULL)
1418
0
    return;
1419
0
  set_error (mismatch_detail, AARCH64_OPDE_OUT_OF_RANGE, idx, error);
1420
0
  mismatch_detail->data[0].i = lower_bound;
1421
0
  mismatch_detail->data[1].i = upper_bound;
1422
0
}
1423
1424
static inline void
1425
set_imm_out_of_range_error (aarch64_operand_error *mismatch_detail,
1426
          int idx, int lower_bound, int upper_bound)
1427
100k
{
1428
100k
  if (mismatch_detail == NULL)
1429
100k
    return;
1430
0
  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1431
0
        _("immediate value"));
1432
0
}
1433
1434
static inline void
1435
set_offset_out_of_range_error (aarch64_operand_error *mismatch_detail,
1436
             int idx, int lower_bound, int upper_bound)
1437
0
{
1438
0
  if (mismatch_detail == NULL)
1439
0
    return;
1440
0
  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1441
0
        _("immediate offset"));
1442
0
}
1443
1444
static inline void
1445
set_regno_out_of_range_error (aarch64_operand_error *mismatch_detail,
1446
            int idx, int lower_bound, int upper_bound)
1447
0
{
1448
0
  if (mismatch_detail == NULL)
1449
0
    return;
1450
0
  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1451
0
        _("register number"));
1452
0
}
1453
1454
static inline void
1455
set_elem_idx_out_of_range_error (aarch64_operand_error *mismatch_detail,
1456
         int idx, int lower_bound, int upper_bound)
1457
804
{
1458
804
  if (mismatch_detail == NULL)
1459
804
    return;
1460
0
  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1461
0
        _("register element index"));
1462
0
}
1463
1464
static inline void
1465
set_sft_amount_out_of_range_error (aarch64_operand_error *mismatch_detail,
1466
           int idx, int lower_bound, int upper_bound)
1467
123k
{
1468
123k
  if (mismatch_detail == NULL)
1469
123k
    return;
1470
0
  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1471
0
        _("shift amount"));
1472
0
}
1473
1474
/* Report that the MUL modifier in operand IDX should be in the range
1475
   [LOWER_BOUND, UPPER_BOUND].  */
1476
static inline void
1477
set_multiplier_out_of_range_error (aarch64_operand_error *mismatch_detail,
1478
           int idx, int lower_bound, int upper_bound)
1479
0
{
1480
0
  if (mismatch_detail == NULL)
1481
0
    return;
1482
0
  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1483
0
        _("multiplier"));
1484
0
}
1485
1486
static inline void
1487
set_unaligned_error (aarch64_operand_error *mismatch_detail, int idx,
1488
         int alignment)
1489
0
{
1490
0
  if (mismatch_detail == NULL)
1491
0
    return;
1492
0
  set_error (mismatch_detail, AARCH64_OPDE_UNALIGNED, idx, NULL);
1493
0
  mismatch_detail->data[0].i = alignment;
1494
0
}
1495
1496
static inline void
1497
set_reg_list_length_error (aarch64_operand_error *mismatch_detail, int idx,
1498
         int expected_num)
1499
906
{
1500
906
  if (mismatch_detail == NULL)
1501
906
    return;
1502
0
  set_error (mismatch_detail, AARCH64_OPDE_REG_LIST_LENGTH, idx, NULL);
1503
0
  mismatch_detail->data[0].i = 1 << expected_num;
1504
0
}
1505
1506
static inline void
1507
set_reg_list_stride_error (aarch64_operand_error *mismatch_detail, int idx,
1508
         int expected_num)
1509
0
{
1510
0
  if (mismatch_detail == NULL)
1511
0
    return;
1512
0
  set_error (mismatch_detail, AARCH64_OPDE_REG_LIST_STRIDE, idx, NULL);
1513
0
  mismatch_detail->data[0].i = 1 << expected_num;
1514
0
}
1515
1516
static inline void
1517
set_invalid_vg_size (aarch64_operand_error *mismatch_detail,
1518
         int idx, int expected)
1519
0
{
1520
0
  if (mismatch_detail == NULL)
1521
0
    return;
1522
0
  set_error (mismatch_detail, AARCH64_OPDE_INVALID_VG_SIZE, idx, NULL);
1523
0
  mismatch_detail->data[0].i = expected;
1524
0
}
1525
1526
static inline void
1527
set_other_error (aarch64_operand_error *mismatch_detail, int idx,
1528
     const char* error)
1529
32.0k
{
1530
32.0k
  if (mismatch_detail == NULL)
1531
32.0k
    return;
1532
0
  set_error (mismatch_detail, AARCH64_OPDE_OTHER_ERROR, idx, error);
1533
0
}
1534
1535
/* Check that indexed register operand OPND has a register in the range
1536
   [MIN_REGNO, MAX_REGNO] and an index in the range [MIN_INDEX, MAX_INDEX].
1537
   PREFIX is the register prefix, such as "z" for SVE vector registers.  */
1538
1539
static bool
1540
check_reglane (const aarch64_opnd_info *opnd,
1541
         aarch64_operand_error *mismatch_detail, int idx,
1542
         const char *prefix, int min_regno, int max_regno,
1543
         int min_index, int max_index)
1544
41.3k
{
1545
41.3k
  if (!value_in_range_p (opnd->reglane.regno, min_regno, max_regno))
1546
0
    {
1547
0
      set_invalid_regno_error (mismatch_detail, idx, prefix, min_regno,
1548
0
             max_regno);
1549
0
      return false;
1550
0
    }
1551
41.3k
  if (!value_in_range_p (opnd->reglane.index, min_index, max_index))
1552
0
    {
1553
0
      set_elem_idx_out_of_range_error (mismatch_detail, idx, min_index,
1554
0
               max_index);
1555
0
      return false;
1556
0
    }
1557
41.3k
  return true;
1558
41.3k
}
1559
1560
/* Check that register list operand OPND has NUM_REGS registers and a
1561
   register stride of STRIDE.  */
1562
1563
static bool
1564
check_reglist (const aarch64_opnd_info *opnd,
1565
         aarch64_operand_error *mismatch_detail, int idx,
1566
         int num_regs, int stride)
1567
372k
{
1568
372k
  if (opnd->reglist.num_regs != num_regs)
1569
906
    {
1570
906
      set_reg_list_length_error (mismatch_detail, idx, num_regs);
1571
906
      return false;
1572
906
    }
1573
371k
  if (opnd->reglist.stride != stride)
1574
0
    {
1575
0
      set_reg_list_stride_error (mismatch_detail, idx, stride);
1576
0
      return false;
1577
0
    }
1578
371k
  return true;
1579
371k
}
1580
1581
/* Check that indexed ZA operand OPND has:
1582
1583
   - a selection register in the range [MIN_WREG, MIN_WREG + 3]
1584
1585
   - RANGE_SIZE consecutive immediate offsets.
1586
1587
   - an initial immediate offset that is a multiple of RANGE_SIZE
1588
     in the range [0, MAX_VALUE * RANGE_SIZE]
1589
1590
   - a vector group size of GROUP_SIZE.  */
1591
1592
static bool
1593
check_za_access (const aarch64_opnd_info *opnd,
1594
     aarch64_operand_error *mismatch_detail, int idx,
1595
     int min_wreg, int max_value, unsigned int range_size,
1596
     int group_size)
1597
71.6k
{
1598
71.6k
  if (!value_in_range_p (opnd->indexed_za.index.regno, min_wreg, min_wreg + 3))
1599
0
    {
1600
0
      if (min_wreg == 12)
1601
0
  set_other_error (mismatch_detail, idx,
1602
0
       _("expected a selection register in the"
1603
0
         " range w12-w15"));
1604
0
      else if (min_wreg == 8)
1605
0
  set_other_error (mismatch_detail, idx,
1606
0
       _("expected a selection register in the"
1607
0
         " range w8-w11"));
1608
0
      else
1609
0
  abort ();
1610
0
      return false;
1611
0
    }
1612
1613
71.6k
  int max_index = max_value * range_size;
1614
71.6k
  if (!value_in_range_p (opnd->indexed_za.index.imm, 0, max_index))
1615
0
    {
1616
0
      set_offset_out_of_range_error (mismatch_detail, idx, 0, max_index);
1617
0
      return false;
1618
0
    }
1619
1620
71.6k
  if ((opnd->indexed_za.index.imm % range_size) != 0)
1621
0
    {
1622
0
      assert (range_size == 2 || range_size == 4);
1623
0
      set_other_error (mismatch_detail, idx,
1624
0
           range_size == 2
1625
0
           ? _("starting offset is not a multiple of 2")
1626
0
           : _("starting offset is not a multiple of 4"));
1627
0
      return false;
1628
0
    }
1629
1630
71.6k
  if (opnd->indexed_za.index.countm1 != range_size - 1)
1631
0
    {
1632
0
      if (range_size == 1)
1633
0
  set_other_error (mismatch_detail, idx,
1634
0
       _("expected a single offset rather than"
1635
0
         " a range"));
1636
0
      else if (range_size == 2)
1637
0
  set_other_error (mismatch_detail, idx,
1638
0
       _("expected a range of two offsets"));
1639
0
      else if (range_size == 4)
1640
0
  set_other_error (mismatch_detail, idx,
1641
0
       _("expected a range of four offsets"));
1642
0
      else
1643
0
  abort ();
1644
0
      return false;
1645
0
    }
1646
1647
  /* The vector group specifier is optional in assembly code.  */
1648
71.6k
  if (opnd->indexed_za.group_size != 0
1649
71.6k
      && opnd->indexed_za.group_size != group_size)
1650
0
    {
1651
0
      set_invalid_vg_size (mismatch_detail, idx, group_size);
1652
0
      return false;
1653
0
    }
1654
1655
71.6k
  return true;
1656
71.6k
}
1657
1658
/* General constraint checking based on operand code.
1659
1660
   Return 1 if OPNDS[IDX] meets the general constraint of operand code TYPE
1661
   as the IDXth operand of opcode OPCODE.  Otherwise return 0.
1662
1663
   This function has to be called after the qualifiers for all operands
1664
   have been resolved.
1665
1666
   Mismatching error message is returned in *MISMATCH_DETAIL upon request,
1667
   i.e. when MISMATCH_DETAIL is non-NULL.  This avoids the generation
1668
   of error message during the disassembling where error message is not
1669
   wanted.  We avoid the dynamic construction of strings of error messages
1670
   here (i.e. in libopcodes), as it is costly and complicated; instead, we
1671
   use a combination of error code, static string and some integer data to
1672
   represent an error.  */
1673
1674
static int
1675
operand_general_constraint_met_p (const aarch64_opnd_info *opnds, int idx,
1676
          enum aarch64_opnd type,
1677
          const aarch64_opcode *opcode,
1678
          aarch64_operand_error *mismatch_detail)
1679
18.1M
{
1680
18.1M
  unsigned num, modifiers, shift;
1681
18.1M
  unsigned char size;
1682
18.1M
  int64_t imm, min_value, max_value;
1683
18.1M
  uint64_t uvalue, mask;
1684
18.1M
  const aarch64_opnd_info *opnd = opnds + idx;
1685
18.1M
  aarch64_opnd_qualifier_t qualifier = opnd->qualifier;
1686
18.1M
  int i;
1687
1688
18.1M
  assert (opcode->operands[idx] == opnd->type && opnd->type == type);
1689
1690
18.1M
  switch (aarch64_operands[type].op_class)
1691
18.1M
    {
1692
6.43M
    case AARCH64_OPND_CLASS_INT_REG:
1693
      /* Check pair reg constraints for cas* instructions.  */
1694
6.43M
      if (type == AARCH64_OPND_PAIRREG)
1695
3.54k
  {
1696
3.54k
    assert (idx == 1 || idx == 3);
1697
3.54k
    if (opnds[idx - 1].reg.regno % 2 != 0)
1698
1.36k
      {
1699
1.36k
        set_syntax_error (mismatch_detail, idx - 1,
1700
1.36k
        _("reg pair must start from even reg"));
1701
1.36k
        return 0;
1702
1.36k
      }
1703
2.17k
    if (opnds[idx].reg.regno != opnds[idx - 1].reg.regno + 1)
1704
0
      {
1705
0
        set_syntax_error (mismatch_detail, idx,
1706
0
        _("reg pair must be contiguous"));
1707
0
        return 0;
1708
0
      }
1709
2.17k
    break;
1710
2.17k
  }
1711
1712
      /* <Xt> may be optional in some IC and TLBI instructions.  */
1713
6.43M
      if (type == AARCH64_OPND_Rt_SYS)
1714
377
  {
1715
377
    assert (idx == 1 && (aarch64_get_operand_class (opnds[0].type)
1716
377
             == AARCH64_OPND_CLASS_SYSTEM));
1717
377
    if (opnds[1].present
1718
377
        && !aarch64_sys_ins_reg_has_xt (opnds[0].sysins_op))
1719
0
      {
1720
0
        set_other_error (mismatch_detail, idx, _("extraneous register"));
1721
0
        return 0;
1722
0
      }
1723
377
    if (!opnds[1].present
1724
377
        && aarch64_sys_ins_reg_has_xt (opnds[0].sysins_op))
1725
0
      {
1726
0
        set_other_error (mismatch_detail, idx, _("missing register"));
1727
0
        return 0;
1728
0
      }
1729
377
  }
1730
6.43M
      switch (qualifier)
1731
6.43M
  {
1732
2.12k
  case AARCH64_OPND_QLF_WSP:
1733
5.01k
  case AARCH64_OPND_QLF_SP:
1734
5.01k
    if (!aarch64_stack_pointer_p (opnd))
1735
2.57k
      {
1736
2.57k
        set_other_error (mismatch_detail, idx,
1737
2.57k
           _("stack pointer register expected"));
1738
2.57k
        return 0;
1739
2.57k
      }
1740
2.43k
    break;
1741
6.43M
  default:
1742
6.43M
    break;
1743
6.43M
  }
1744
6.43M
      break;
1745
1746
6.43M
    case AARCH64_OPND_CLASS_SVE_REG:
1747
1.26M
      switch (type)
1748
1.26M
  {
1749
4.24k
  case AARCH64_OPND_SVE_Zm3_INDEX:
1750
7.89k
  case AARCH64_OPND_SVE_Zm3_22_INDEX:
1751
8.14k
  case AARCH64_OPND_SVE_Zm3_19_INDEX:
1752
15.6k
  case AARCH64_OPND_SVE_Zm3_11_INDEX:
1753
19.5k
  case AARCH64_OPND_SVE_Zm4_11_INDEX:
1754
24.6k
  case AARCH64_OPND_SVE_Zm4_INDEX:
1755
24.6k
    size = get_operand_fields_width (get_operand_from_code (type));
1756
24.6k
    shift = get_operand_specific_data (&aarch64_operands[type]);
1757
24.6k
    if (!check_reglane (opnd, mismatch_detail, idx,
1758
24.6k
            "z", 0, (1 << shift) - 1,
1759
24.6k
            0, (1u << (size - shift)) - 1))
1760
0
      return 0;
1761
24.6k
    break;
1762
1763
24.6k
  case AARCH64_OPND_SVE_Zn_INDEX:
1764
2.42k
    size = aarch64_get_qualifier_esize (opnd->qualifier);
1765
2.42k
    if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 31,
1766
2.42k
            0, 64 / size - 1))
1767
0
      return 0;
1768
2.42k
    break;
1769
1770
2.42k
  case AARCH64_OPND_SME_PNn3_INDEX1:
1771
38
  case AARCH64_OPND_SME_PNn3_INDEX2:
1772
38
    size = get_operand_field_width (get_operand_from_code (type), 1);
1773
38
    if (!check_reglane (opnd, mismatch_detail, idx, "pn", 8, 15,
1774
38
            0, (1 << size) - 1))
1775
0
      return 0;
1776
38
    break;
1777
1778
38
  case AARCH64_OPND_SME_Zn_INDEX1_16:
1779
13
  case AARCH64_OPND_SME_Zn_INDEX2_15:
1780
16
  case AARCH64_OPND_SME_Zn_INDEX2_16:
1781
40
  case AARCH64_OPND_SME_Zn_INDEX3_14:
1782
93
  case AARCH64_OPND_SME_Zn_INDEX3_15:
1783
726
  case AARCH64_OPND_SME_Zn_INDEX4_14:
1784
726
    size = get_operand_fields_width (get_operand_from_code (type)) - 5;
1785
726
    if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 31,
1786
726
            0, (1 << size) - 1))
1787
0
      return 0;
1788
726
    break;
1789
1790
726
  case AARCH64_OPND_SME_Zm_INDEX1:
1791
1.93k
  case AARCH64_OPND_SME_Zm_INDEX2:
1792
3.53k
  case AARCH64_OPND_SME_Zm_INDEX3_1:
1793
4.79k
  case AARCH64_OPND_SME_Zm_INDEX3_2:
1794
8.97k
  case AARCH64_OPND_SME_Zm_INDEX3_10:
1795
9.64k
  case AARCH64_OPND_SME_Zm_INDEX4_1:
1796
13.5k
  case AARCH64_OPND_SME_Zm_INDEX4_10:
1797
13.5k
    size = get_operand_fields_width (get_operand_from_code (type)) - 4;
1798
13.5k
    if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 15,
1799
13.5k
            0, (1 << size) - 1))
1800
0
      return 0;
1801
13.5k
    break;
1802
1803
13.5k
  case AARCH64_OPND_SME_Zm:
1804
3.90k
    if (opnd->reg.regno > 15)
1805
0
      {
1806
0
        set_invalid_regno_error (mismatch_detail, idx, "z", 0, 15);
1807
0
        return 0;
1808
0
      }
1809
3.90k
    break;
1810
1811
3.90k
  case AARCH64_OPND_SME_PnT_Wm_imm:
1812
1.64k
    size = aarch64_get_qualifier_esize (opnd->qualifier);
1813
1.64k
    max_value = 16 / size - 1;
1814
1.64k
    if (!check_za_access (opnd, mismatch_detail, idx,
1815
1.64k
        12, max_value, 1, 0))
1816
0
      return 0;
1817
1.64k
    break;
1818
1819
1.21M
  default:
1820
1.21M
    break;
1821
1.26M
  }
1822
1.26M
      break;
1823
1824
1.26M
    case AARCH64_OPND_CLASS_SVE_REGLIST:
1825
332k
      switch (type)
1826
332k
  {
1827
312
  case AARCH64_OPND_SME_Pdx2:
1828
15.1k
  case AARCH64_OPND_SME_Zdnx2:
1829
19.5k
  case AARCH64_OPND_SME_Zdnx4:
1830
20.9k
  case AARCH64_OPND_SME_Zmx2:
1831
21.1k
  case AARCH64_OPND_SME_Zmx4:
1832
27.0k
  case AARCH64_OPND_SME_Znx2:
1833
28.6k
  case AARCH64_OPND_SME_Znx4:
1834
28.6k
    num = get_operand_specific_data (&aarch64_operands[type]);
1835
28.6k
    if (!check_reglist (opnd, mismatch_detail, idx, num, 1))
1836
0
      return 0;
1837
28.6k
    if ((opnd->reglist.first_regno % num) != 0)
1838
0
      {
1839
0
        set_other_error (mismatch_detail, idx,
1840
0
             _("start register out of range"));
1841
0
        return 0;
1842
0
      }
1843
28.6k
    break;
1844
1845
28.6k
  case AARCH64_OPND_SME_Ztx2_STRIDED:
1846
9.94k
  case AARCH64_OPND_SME_Ztx4_STRIDED:
1847
    /* 2-register lists have a stride of 8 and 4-register lists
1848
       have a stride of 4.  */
1849
9.94k
    num = get_operand_specific_data (&aarch64_operands[type]);
1850
9.94k
    if (!check_reglist (opnd, mismatch_detail, idx, num, 16 / num))
1851
0
      return 0;
1852
9.94k
    num = 16 | (opnd->reglist.stride - 1);
1853
9.94k
    if ((opnd->reglist.first_regno & ~num) != 0)
1854
0
      {
1855
0
        set_other_error (mismatch_detail, idx,
1856
0
             _("start register out of range"));
1857
0
        return 0;
1858
0
      }
1859
9.94k
    break;
1860
1861
9.94k
  case AARCH64_OPND_SME_PdxN:
1862
6.99k
  case AARCH64_OPND_SVE_ZnxN:
1863
294k
  case AARCH64_OPND_SVE_ZtxN:
1864
294k
    num = get_opcode_dependent_value (opcode);
1865
294k
    if (!check_reglist (opnd, mismatch_detail, idx, num, 1))
1866
0
      return 0;
1867
294k
    break;
1868
1869
294k
  default:
1870
0
    abort ();
1871
332k
  }
1872
332k
      break;
1873
1874
332k
    case AARCH64_OPND_CLASS_ZA_ACCESS:
1875
69.9k
      switch (type)
1876
69.9k
  {
1877
799
  case AARCH64_OPND_SME_ZA_HV_idx_src:
1878
11.1k
  case AARCH64_OPND_SME_ZA_HV_idx_dest:
1879
50.2k
  case AARCH64_OPND_SME_ZA_HV_idx_ldstr:
1880
50.2k
    size = aarch64_get_qualifier_esize (opnd->qualifier);
1881
50.2k
    max_value = 16 / size - 1;
1882
50.2k
    if (!check_za_access (opnd, mismatch_detail, idx, 12, max_value, 1,
1883
50.2k
        get_opcode_dependent_value (opcode)))
1884
0
      return 0;
1885
50.2k
    break;
1886
1887
50.2k
  case AARCH64_OPND_SME_ZA_array_off4:
1888
1.36k
    if (!check_za_access (opnd, mismatch_detail, idx, 12, 15, 1,
1889
1.36k
        get_opcode_dependent_value (opcode)))
1890
0
      return 0;
1891
1.36k
    break;
1892
1893
3.89k
  case AARCH64_OPND_SME_ZA_array_off3_0:
1894
3.90k
  case AARCH64_OPND_SME_ZA_array_off3_5:
1895
3.90k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 7, 1,
1896
3.90k
        get_opcode_dependent_value (opcode)))
1897
0
      return 0;
1898
3.90k
    break;
1899
1900
3.90k
  case AARCH64_OPND_SME_ZA_array_off1x4:
1901
3.57k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 1, 4,
1902
3.57k
        get_opcode_dependent_value (opcode)))
1903
0
      return 0;
1904
3.57k
    break;
1905
1906
3.57k
  case AARCH64_OPND_SME_ZA_array_off2x2:
1907
2.07k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 3, 2,
1908
2.07k
        get_opcode_dependent_value (opcode)))
1909
0
      return 0;
1910
2.07k
    break;
1911
1912
5.58k
  case AARCH64_OPND_SME_ZA_array_off2x4:
1913
5.58k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 3, 4,
1914
5.58k
        get_opcode_dependent_value (opcode)))
1915
0
      return 0;
1916
5.58k
    break;
1917
1918
5.58k
  case AARCH64_OPND_SME_ZA_array_off3x2:
1919
2.82k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 7, 2,
1920
2.82k
        get_opcode_dependent_value (opcode)))
1921
0
      return 0;
1922
2.82k
    break;
1923
1924
2.82k
  case AARCH64_OPND_SME_ZA_HV_idx_srcxN:
1925
434
  case AARCH64_OPND_SME_ZA_HV_idx_destxN:
1926
434
    size = aarch64_get_qualifier_esize (opnd->qualifier);
1927
434
    num = get_opcode_dependent_value (opcode);
1928
434
    max_value = 16 / num / size;
1929
434
    if (max_value > 0)
1930
415
      max_value -= 1;
1931
434
    if (!check_za_access (opnd, mismatch_detail, idx,
1932
434
        12, max_value, num, 0))
1933
0
      return 0;
1934
434
    break;
1935
1936
434
  default:
1937
0
    abort ();
1938
69.9k
  }
1939
69.9k
      break;
1940
1941
927k
    case AARCH64_OPND_CLASS_PRED_REG:
1942
927k
      switch (type)
1943
927k
  {
1944
2.05k
  case AARCH64_OPND_SME_PNd3:
1945
29.5k
  case AARCH64_OPND_SME_PNg3:
1946
29.5k
    if (opnd->reg.regno < 8)
1947
0
      {
1948
0
        set_invalid_regno_error (mismatch_detail, idx, "pn", 8, 15);
1949
0
        return 0;
1950
0
      }
1951
29.5k
    break;
1952
1953
897k
  default:
1954
897k
    if (opnd->reg.regno >= 8
1955
897k
        && get_operand_fields_width (get_operand_from_code (type)) == 3)
1956
0
      {
1957
0
        set_invalid_regno_error (mismatch_detail, idx, "p", 0, 7);
1958
0
        return 0;
1959
0
      }
1960
897k
    break;
1961
927k
  }
1962
927k
      break;
1963
1964
927k
    case AARCH64_OPND_CLASS_COND:
1965
34.2k
      if (type == AARCH64_OPND_COND1
1966
34.2k
    && (opnds[idx].cond->value & 0xe) == 0xe)
1967
0
  {
1968
    /* Not allow AL or NV.  */
1969
0
    set_syntax_error (mismatch_detail, idx, NULL);
1970
0
  }
1971
34.2k
      break;
1972
1973
3.30M
    case AARCH64_OPND_CLASS_ADDRESS:
1974
      /* Check writeback.  */
1975
3.30M
      switch (opcode->iclass)
1976
3.30M
  {
1977
309k
  case ldst_pos:
1978
392k
  case ldst_unscaled:
1979
552k
  case ldstnapair_offs:
1980
723k
  case ldstpair_off:
1981
740k
  case ldst_unpriv:
1982
740k
    if (opnd->addr.writeback == 1)
1983
0
      {
1984
0
        set_syntax_error (mismatch_detail, idx,
1985
0
        _("unexpected address writeback"));
1986
0
        return 0;
1987
0
      }
1988
740k
    break;
1989
740k
  case ldst_imm10:
1990
14.7k
    if (opnd->addr.writeback == 1 && opnd->addr.preind != 1)
1991
0
      {
1992
0
        set_syntax_error (mismatch_detail, idx,
1993
0
        _("unexpected address writeback"));
1994
0
        return 0;
1995
0
      }
1996
14.7k
    break;
1997
69.2k
  case ldst_imm9:
1998
294k
  case ldstpair_indexed:
1999
303k
  case asisdlsep:
2000
322k
  case asisdlsop:
2001
322k
    if (opnd->addr.writeback == 0)
2002
0
      {
2003
0
        set_syntax_error (mismatch_detail, idx,
2004
0
        _("address writeback expected"));
2005
0
        return 0;
2006
0
      }
2007
322k
    break;
2008
2.22M
  default:
2009
2.22M
    assert (opnd->addr.writeback == 0);
2010
2.22M
    break;
2011
3.30M
  }
2012
3.30M
      switch (type)
2013
3.30M
  {
2014
528k
  case AARCH64_OPND_ADDR_SIMM7:
2015
    /* Scaled signed 7 bits immediate offset.  */
2016
    /* Get the size of the data element that is accessed, which may be
2017
       different from that of the source register size,
2018
       e.g. in strb/ldrb.  */
2019
528k
    size = aarch64_get_qualifier_esize (opnd->qualifier);
2020
528k
    if (!value_in_range_p (opnd->addr.offset.imm, -64 * size, 63 * size))
2021
0
      {
2022
0
        set_offset_out_of_range_error (mismatch_detail, idx,
2023
0
               -64 * size, 63 * size);
2024
0
        return 0;
2025
0
      }
2026
528k
    if (!value_aligned_p (opnd->addr.offset.imm, size))
2027
0
      {
2028
0
        set_unaligned_error (mismatch_detail, idx, size);
2029
0
        return 0;
2030
0
      }
2031
528k
    break;
2032
528k
  case AARCH64_OPND_ADDR_OFFSET:
2033
158k
  case AARCH64_OPND_ADDR_SIMM9:
2034
    /* Unscaled signed 9 bits immediate offset.  */
2035
158k
    if (!value_in_range_p (opnd->addr.offset.imm, -256, 255))
2036
0
      {
2037
0
        set_offset_out_of_range_error (mismatch_detail, idx, -256, 255);
2038
0
        return 0;
2039
0
      }
2040
158k
    break;
2041
2042
158k
  case AARCH64_OPND_ADDR_SIMM9_2:
2043
    /* Unscaled signed 9 bits immediate offset, which has to be negative
2044
       or unaligned.  */
2045
0
    size = aarch64_get_qualifier_esize (qualifier);
2046
0
    if ((value_in_range_p (opnd->addr.offset.imm, 0, 255)
2047
0
         && !value_aligned_p (opnd->addr.offset.imm, size))
2048
0
        || value_in_range_p (opnd->addr.offset.imm, -256, -1))
2049
0
      return 1;
2050
0
    set_other_error (mismatch_detail, idx,
2051
0
         _("negative or unaligned offset expected"));
2052
0
    return 0;
2053
2054
14.7k
  case AARCH64_OPND_ADDR_SIMM10:
2055
    /* Scaled signed 10 bits immediate offset.  */
2056
14.7k
    if (!value_in_range_p (opnd->addr.offset.imm, -4096, 4088))
2057
0
      {
2058
0
        set_offset_out_of_range_error (mismatch_detail, idx, -4096, 4088);
2059
0
        return 0;
2060
0
      }
2061
14.7k
    if (!value_aligned_p (opnd->addr.offset.imm, 8))
2062
0
      {
2063
0
        set_unaligned_error (mismatch_detail, idx, 8);
2064
0
        return 0;
2065
0
      }
2066
14.7k
    break;
2067
2068
27.1k
  case AARCH64_OPND_ADDR_SIMM11:
2069
    /* Signed 11 bits immediate offset (multiple of 16).  */
2070
27.1k
    if (!value_in_range_p (opnd->addr.offset.imm, -1024, 1008))
2071
0
      {
2072
0
        set_offset_out_of_range_error (mismatch_detail, idx, -1024, 1008);
2073
0
        return 0;
2074
0
      }
2075
2076
27.1k
    if (!value_aligned_p (opnd->addr.offset.imm, 16))
2077
0
      {
2078
0
        set_unaligned_error (mismatch_detail, idx, 16);
2079
0
        return 0;
2080
0
      }
2081
27.1k
    break;
2082
2083
27.1k
  case AARCH64_OPND_ADDR_SIMM13:
2084
    /* Signed 13 bits immediate offset (multiple of 16).  */
2085
11.1k
    if (!value_in_range_p (opnd->addr.offset.imm, -4096, 4080))
2086
0
      {
2087
0
        set_offset_out_of_range_error (mismatch_detail, idx, -4096, 4080);
2088
0
        return 0;
2089
0
      }
2090
2091
11.1k
    if (!value_aligned_p (opnd->addr.offset.imm, 16))
2092
0
      {
2093
0
        set_unaligned_error (mismatch_detail, idx, 16);
2094
0
        return 0;
2095
0
      }
2096
11.1k
    break;
2097
2098
27.9k
  case AARCH64_OPND_SIMD_ADDR_POST:
2099
    /* AdvSIMD load/store multiple structures, post-index.  */
2100
27.9k
    assert (idx == 1);
2101
27.9k
    if (opnd->addr.offset.is_reg)
2102
26.8k
      {
2103
26.8k
        if (value_in_range_p (opnd->addr.offset.regno, 0, 30))
2104
26.8k
    return 1;
2105
0
        else
2106
0
    {
2107
0
      set_other_error (mismatch_detail, idx,
2108
0
           _("invalid register offset"));
2109
0
      return 0;
2110
0
    }
2111
26.8k
      }
2112
1.12k
    else
2113
1.12k
      {
2114
1.12k
        const aarch64_opnd_info *prev = &opnds[idx-1];
2115
1.12k
        unsigned num_bytes; /* total number of bytes transferred.  */
2116
        /* The opcode dependent area stores the number of elements in
2117
     each structure to be loaded/stored.  */
2118
1.12k
        int is_ld1r = get_opcode_dependent_value (opcode) == 1;
2119
1.12k
        if (opcode->operands[0] == AARCH64_OPND_LVt_AL)
2120
    /* Special handling of loading single structure to all lane.  */
2121
142
    num_bytes = (is_ld1r ? 1 : prev->reglist.num_regs)
2122
142
      * aarch64_get_qualifier_esize (prev->qualifier);
2123
980
        else
2124
980
    num_bytes = prev->reglist.num_regs
2125
980
      * aarch64_get_qualifier_esize (prev->qualifier)
2126
980
      * aarch64_get_qualifier_nelem (prev->qualifier);
2127
1.12k
        if ((int) num_bytes != opnd->addr.offset.imm)
2128
0
    {
2129
0
      set_other_error (mismatch_detail, idx,
2130
0
           _("invalid post-increment amount"));
2131
0
      return 0;
2132
0
    }
2133
1.12k
      }
2134
1.12k
    break;
2135
2136
55.8k
  case AARCH64_OPND_ADDR_REGOFF:
2137
    /* Get the size of the data element that is accessed, which may be
2138
       different from that of the source register size,
2139
       e.g. in strb/ldrb.  */
2140
55.8k
    size = aarch64_get_qualifier_esize (opnd->qualifier);
2141
    /* It is either no shift or shift by the binary logarithm of SIZE.  */
2142
55.8k
    if (opnd->shifter.amount != 0
2143
55.8k
        && opnd->shifter.amount != (int)get_logsz (size))
2144
0
      {
2145
0
        set_other_error (mismatch_detail, idx,
2146
0
             _("invalid shift amount"));
2147
0
        return 0;
2148
0
      }
2149
    /* Only UXTW, LSL, SXTW and SXTX are the accepted extending
2150
       operators.  */
2151
55.8k
    switch (opnd->shifter.kind)
2152
55.8k
      {
2153
3.79k
      case AARCH64_MOD_UXTW:
2154
18.2k
      case AARCH64_MOD_LSL:
2155
22.7k
      case AARCH64_MOD_SXTW:
2156
28.1k
      case AARCH64_MOD_SXTX: break;
2157
27.6k
      default:
2158
27.6k
        set_other_error (mismatch_detail, idx,
2159
27.6k
             _("invalid extend/shift operator"));
2160
27.6k
        return 0;
2161
55.8k
      }
2162
28.1k
    break;
2163
2164
309k
  case AARCH64_OPND_ADDR_UIMM12:
2165
309k
    imm = opnd->addr.offset.imm;
2166
    /* Get the size of the data element that is accessed, which may be
2167
       different from that of the source register size,
2168
       e.g. in strb/ldrb.  */
2169
309k
    size = aarch64_get_qualifier_esize (qualifier);
2170
309k
    if (!value_in_range_p (opnd->addr.offset.imm, 0, 4095 * size))
2171
0
      {
2172
0
        set_offset_out_of_range_error (mismatch_detail, idx,
2173
0
               0, 4095 * size);
2174
0
        return 0;
2175
0
      }
2176
309k
    if (!value_aligned_p (opnd->addr.offset.imm, size))
2177
0
      {
2178
0
        set_unaligned_error (mismatch_detail, idx, size);
2179
0
        return 0;
2180
0
      }
2181
309k
    break;
2182
2183
309k
  case AARCH64_OPND_ADDR_PCREL14:
2184
709k
  case AARCH64_OPND_ADDR_PCREL19:
2185
1.00M
  case AARCH64_OPND_ADDR_PCREL21:
2186
1.32M
  case AARCH64_OPND_ADDR_PCREL26:
2187
1.32M
    imm = opnd->imm.value;
2188
1.32M
    if (operand_need_shift_by_two (get_operand_from_code (type)))
2189
1.03M
      {
2190
        /* The offset value in a PC-relative branch instruction is alway
2191
     4-byte aligned and is encoded without the lowest 2 bits.  */
2192
1.03M
        if (!value_aligned_p (imm, 4))
2193
0
    {
2194
0
      set_unaligned_error (mismatch_detail, idx, 4);
2195
0
      return 0;
2196
0
    }
2197
        /* Right shift by 2 so that we can carry out the following check
2198
     canonically.  */
2199
1.03M
        imm >>= 2;
2200
1.03M
      }
2201
1.32M
    size = get_operand_fields_width (get_operand_from_code (type));
2202
1.32M
    if (!value_fit_signed_field_p (imm, size))
2203
0
      {
2204
0
        set_other_error (mismatch_detail, idx,
2205
0
             _("immediate out of range"));
2206
0
        return 0;
2207
0
      }
2208
1.32M
    break;
2209
2210
1.32M
  case AARCH64_OPND_SME_ADDR_RI_U4xVL:
2211
1.36k
    if (!value_in_range_p (opnd->addr.offset.imm, 0, 15))
2212
0
      {
2213
0
        set_offset_out_of_range_error (mismatch_detail, idx, 0, 15);
2214
0
        return 0;
2215
0
      }
2216
1.36k
    break;
2217
2218
48.9k
  case AARCH64_OPND_SVE_ADDR_RI_S4xVL:
2219
56.8k
  case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL:
2220
60.9k
  case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL:
2221
67.6k
  case AARCH64_OPND_SVE_ADDR_RI_S4x4xVL:
2222
67.6k
    min_value = -8;
2223
67.6k
    max_value = 7;
2224
78.2k
  sve_imm_offset_vl:
2225
78.2k
    assert (!opnd->addr.offset.is_reg);
2226
78.2k
    assert (opnd->addr.preind);
2227
78.2k
    num = 1 + get_operand_specific_data (&aarch64_operands[type]);
2228
78.2k
    min_value *= num;
2229
78.2k
    max_value *= num;
2230
78.2k
    if ((opnd->addr.offset.imm != 0 && !opnd->shifter.operator_present)
2231
78.2k
        || (opnd->shifter.operator_present
2232
78.2k
      && opnd->shifter.kind != AARCH64_MOD_MUL_VL))
2233
0
      {
2234
0
        set_other_error (mismatch_detail, idx,
2235
0
             _("invalid addressing mode"));
2236
0
        return 0;
2237
0
      }
2238
78.2k
    if (!value_in_range_p (opnd->addr.offset.imm, min_value, max_value))
2239
0
      {
2240
0
        set_offset_out_of_range_error (mismatch_detail, idx,
2241
0
               min_value, max_value);
2242
0
        return 0;
2243
0
      }
2244
78.2k
    if (!value_aligned_p (opnd->addr.offset.imm, num))
2245
0
      {
2246
0
        set_unaligned_error (mismatch_detail, idx, num);
2247
0
        return 0;
2248
0
      }
2249
78.2k
    break;
2250
2251
78.2k
  case AARCH64_OPND_SVE_ADDR_RI_S6xVL:
2252
3.12k
    min_value = -32;
2253
3.12k
    max_value = 31;
2254
3.12k
    goto sve_imm_offset_vl;
2255
2256
7.55k
  case AARCH64_OPND_SVE_ADDR_RI_S9xVL:
2257
7.55k
    min_value = -256;
2258
7.55k
    max_value = 255;
2259
7.55k
    goto sve_imm_offset_vl;
2260
2261
9.02k
  case AARCH64_OPND_SVE_ADDR_RI_U6:
2262
14.1k
  case AARCH64_OPND_SVE_ADDR_RI_U6x2:
2263
18.3k
  case AARCH64_OPND_SVE_ADDR_RI_U6x4:
2264
19.7k
  case AARCH64_OPND_SVE_ADDR_RI_U6x8:
2265
19.7k
    min_value = 0;
2266
19.7k
    max_value = 63;
2267
41.5k
  sve_imm_offset:
2268
41.5k
    assert (!opnd->addr.offset.is_reg);
2269
41.5k
    assert (opnd->addr.preind);
2270
41.5k
    num = 1 << get_operand_specific_data (&aarch64_operands[type]);
2271
41.5k
    min_value *= num;
2272
41.5k
    max_value *= num;
2273
41.5k
    if (opnd->shifter.operator_present
2274
41.5k
        || opnd->shifter.amount_present)
2275
0
      {
2276
0
        set_other_error (mismatch_detail, idx,
2277
0
             _("invalid addressing mode"));
2278
0
        return 0;
2279
0
      }
2280
41.5k
    if (!value_in_range_p (opnd->addr.offset.imm, min_value, max_value))
2281
0
      {
2282
0
        set_offset_out_of_range_error (mismatch_detail, idx,
2283
0
               min_value, max_value);
2284
0
        return 0;
2285
0
      }
2286
41.5k
    if (!value_aligned_p (opnd->addr.offset.imm, num))
2287
0
      {
2288
0
        set_unaligned_error (mismatch_detail, idx, num);
2289
0
        return 0;
2290
0
      }
2291
41.5k
    break;
2292
2293
41.5k
  case AARCH64_OPND_SVE_ADDR_RI_S4x16:
2294
3.13k
  case AARCH64_OPND_SVE_ADDR_RI_S4x32:
2295
3.13k
    min_value = -8;
2296
3.13k
    max_value = 7;
2297
3.13k
    goto sve_imm_offset;
2298
2299
18.1k
  case AARCH64_OPND_SVE_ADDR_ZX:
2300
    /* Everything is already ensured by parse_operands or
2301
       aarch64_ext_sve_addr_rr_lsl (because this is a very specific
2302
       argument type).  */
2303
18.1k
    assert (opnd->addr.offset.is_reg);
2304
18.1k
    assert (opnd->addr.preind);
2305
18.1k
    assert ((aarch64_operands[type].flags & OPD_F_NO_ZR) == 0);
2306
18.1k
    assert (opnd->shifter.kind == AARCH64_MOD_LSL);
2307
18.1k
    assert (opnd->shifter.operator_present == 0);
2308
18.1k
    break;
2309
2310
18.1k
  case AARCH64_OPND_SVE_ADDR_R:
2311
22.6k
  case AARCH64_OPND_SVE_ADDR_RR:
2312
35.1k
  case AARCH64_OPND_SVE_ADDR_RR_LSL1:
2313
44.4k
  case AARCH64_OPND_SVE_ADDR_RR_LSL2:
2314
61.6k
  case AARCH64_OPND_SVE_ADDR_RR_LSL3:
2315
70.3k
  case AARCH64_OPND_SVE_ADDR_RR_LSL4:
2316
85.7k
  case AARCH64_OPND_SVE_ADDR_RX:
2317
96.8k
  case AARCH64_OPND_SVE_ADDR_RX_LSL1:
2318
110k
  case AARCH64_OPND_SVE_ADDR_RX_LSL2:
2319
118k
  case AARCH64_OPND_SVE_ADDR_RX_LSL3:
2320
145k
  case AARCH64_OPND_SVE_ADDR_RZ:
2321
148k
  case AARCH64_OPND_SVE_ADDR_RZ_LSL1:
2322
151k
  case AARCH64_OPND_SVE_ADDR_RZ_LSL2:
2323
153k
  case AARCH64_OPND_SVE_ADDR_RZ_LSL3:
2324
153k
    modifiers = 1 << AARCH64_MOD_LSL;
2325
246k
  sve_rr_operand:
2326
246k
    assert (opnd->addr.offset.is_reg);
2327
246k
    assert (opnd->addr.preind);
2328
246k
    if ((aarch64_operands[type].flags & OPD_F_NO_ZR) != 0
2329
246k
        && opnd->addr.offset.regno == 31)
2330
0
      {
2331
0
        set_other_error (mismatch_detail, idx,
2332
0
             _("index register xzr is not allowed"));
2333
0
        return 0;
2334
0
      }
2335
246k
    if (((1 << opnd->shifter.kind) & modifiers) == 0
2336
246k
        || (opnd->shifter.amount
2337
246k
      != get_operand_specific_data (&aarch64_operands[type])))
2338
0
      {
2339
0
        set_other_error (mismatch_detail, idx,
2340
0
             _("invalid addressing mode"));
2341
0
        return 0;
2342
0
      }
2343
246k
    break;
2344
2345
246k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW_14:
2346
58.6k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW_22:
2347
60.3k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW1_14:
2348
71.6k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW1_22:
2349
73.4k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW2_14:
2350
82.6k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW2_22:
2351
84.1k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW3_14:
2352
93.0k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW3_22:
2353
93.0k
    modifiers = (1 << AARCH64_MOD_SXTW) | (1 << AARCH64_MOD_UXTW);
2354
93.0k
    goto sve_rr_operand;
2355
2356
5.92k
  case AARCH64_OPND_SVE_ADDR_ZI_U5:
2357
12.4k
  case AARCH64_OPND_SVE_ADDR_ZI_U5x2:
2358
16.4k
  case AARCH64_OPND_SVE_ADDR_ZI_U5x4:
2359
18.6k
  case AARCH64_OPND_SVE_ADDR_ZI_U5x8:
2360
18.6k
    min_value = 0;
2361
18.6k
    max_value = 31;
2362
18.6k
    goto sve_imm_offset;
2363
2364
814
  case AARCH64_OPND_SVE_ADDR_ZZ_LSL:
2365
814
    modifiers = 1 << AARCH64_MOD_LSL;
2366
1.82k
  sve_zz_operand:
2367
1.82k
    assert (opnd->addr.offset.is_reg);
2368
1.82k
    assert (opnd->addr.preind);
2369
1.82k
    if (((1 << opnd->shifter.kind) & modifiers) == 0
2370
1.82k
        || opnd->shifter.amount < 0
2371
1.82k
        || opnd->shifter.amount > 3)
2372
0
      {
2373
0
        set_other_error (mismatch_detail, idx,
2374
0
             _("invalid addressing mode"));
2375
0
        return 0;
2376
0
      }
2377
1.82k
    break;
2378
2379
1.82k
  case AARCH64_OPND_SVE_ADDR_ZZ_SXTW:
2380
464
    modifiers = (1 << AARCH64_MOD_SXTW);
2381
464
    goto sve_zz_operand;
2382
2383
542
  case AARCH64_OPND_SVE_ADDR_ZZ_UXTW:
2384
542
    modifiers = 1 << AARCH64_MOD_UXTW;
2385
542
    goto sve_zz_operand;
2386
2387
461k
  default:
2388
461k
    break;
2389
3.30M
  }
2390
3.24M
      break;
2391
2392
3.24M
    case AARCH64_OPND_CLASS_SIMD_REGLIST:
2393
57.6k
      if (type == AARCH64_OPND_LEt)
2394
23.9k
  {
2395
    /* Get the upper bound for the element index.  */
2396
23.9k
    num = 16 / aarch64_get_qualifier_esize (qualifier) - 1;
2397
23.9k
    if (!value_in_range_p (opnd->reglist.index, 0, num))
2398
0
      {
2399
0
        set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, num);
2400
0
        return 0;
2401
0
      }
2402
23.9k
  }
2403
      /* The opcode dependent area stores the number of elements in
2404
   each structure to be loaded/stored.  */
2405
57.6k
      num = get_opcode_dependent_value (opcode);
2406
57.6k
      switch (type)
2407
57.6k
  {
2408
17.9k
  case AARCH64_OPND_LVt:
2409
17.9k
    assert (num >= 1 && num <= 4);
2410
    /* Unless LD1/ST1, the number of registers should be equal to that
2411
       of the structure elements.  */
2412
17.9k
    if (num != 1 && !check_reglist (opnd, mismatch_detail, idx, num, 1))
2413
906
      return 0;
2414
17.0k
    break;
2415
17.0k
  case AARCH64_OPND_LVt_AL:
2416
25.6k
  case AARCH64_OPND_LEt:
2417
25.6k
    assert (num >= 1 && num <= 4);
2418
    /* The number of registers should be equal to that of the structure
2419
       elements.  */
2420
25.6k
    if (!check_reglist (opnd, mismatch_detail, idx, num, 1))
2421
0
      return 0;
2422
25.6k
    break;
2423
25.6k
  default:
2424
14.1k
    break;
2425
57.6k
  }
2426
56.7k
      if (opnd->reglist.stride != 1)
2427
0
  {
2428
0
    set_reg_list_stride_error (mismatch_detail, idx, 1);
2429
0
    return 0;
2430
0
  }
2431
56.7k
      break;
2432
2433
3.14M
    case AARCH64_OPND_CLASS_IMMEDIATE:
2434
      /* Constraint check on immediate operand.  */
2435
3.14M
      imm = opnd->imm.value;
2436
      /* E.g. imm_0_31 constrains value to be 0..31.  */
2437
3.14M
      if (qualifier_value_in_range_constraint_p (qualifier)
2438
3.14M
    && !value_in_range_p (imm, get_lower_bound (qualifier),
2439
515k
        get_upper_bound (qualifier)))
2440
100k
  {
2441
100k
    set_imm_out_of_range_error (mismatch_detail, idx,
2442
100k
              get_lower_bound (qualifier),
2443
100k
              get_upper_bound (qualifier));
2444
100k
    return 0;
2445
100k
  }
2446
2447
3.04M
      switch (type)
2448
3.04M
  {
2449
460k
  case AARCH64_OPND_AIMM:
2450
460k
    if (opnd->shifter.kind != AARCH64_MOD_LSL)
2451
0
      {
2452
0
        set_other_error (mismatch_detail, idx,
2453
0
             _("invalid shift operator"));
2454
0
        return 0;
2455
0
      }
2456
460k
    if (opnd->shifter.amount != 0 && opnd->shifter.amount != 12)
2457
0
      {
2458
0
        set_other_error (mismatch_detail, idx,
2459
0
             _("shift amount must be 0 or 12"));
2460
0
        return 0;
2461
0
      }
2462
460k
    if (!value_fit_unsigned_field_p (opnd->imm.value, 12))
2463
0
      {
2464
0
        set_other_error (mismatch_detail, idx,
2465
0
             _("immediate out of range"));
2466
0
        return 0;
2467
0
      }
2468
460k
    break;
2469
2470
460k
  case AARCH64_OPND_HALF:
2471
138k
    assert (idx == 1 && opnds[0].type == AARCH64_OPND_Rd);
2472
138k
    if (opnd->shifter.kind != AARCH64_MOD_LSL)
2473
0
      {
2474
0
        set_other_error (mismatch_detail, idx,
2475
0
             _("invalid shift operator"));
2476
0
        return 0;
2477
0
      }
2478
138k
    size = aarch64_get_qualifier_esize (opnds[0].qualifier);
2479
138k
    if (!value_aligned_p (opnd->shifter.amount, 16))
2480
0
      {
2481
0
        set_other_error (mismatch_detail, idx,
2482
0
             _("shift amount must be a multiple of 16"));
2483
0
        return 0;
2484
0
      }
2485
138k
    if (!value_in_range_p (opnd->shifter.amount, 0, size * 8 - 16))
2486
27.3k
      {
2487
27.3k
        set_sft_amount_out_of_range_error (mismatch_detail, idx,
2488
27.3k
             0, size * 8 - 16);
2489
27.3k
        return 0;
2490
27.3k
      }
2491
111k
    if (opnd->imm.value < 0)
2492
0
      {
2493
0
        set_other_error (mismatch_detail, idx,
2494
0
             _("negative immediate value not allowed"));
2495
0
        return 0;
2496
0
      }
2497
111k
    if (!value_fit_unsigned_field_p (opnd->imm.value, 16))
2498
0
      {
2499
0
        set_other_error (mismatch_detail, idx,
2500
0
             _("immediate out of range"));
2501
0
        return 0;
2502
0
      }
2503
111k
    break;
2504
2505
111k
  case AARCH64_OPND_IMM_MOV:
2506
75.4k
      {
2507
75.4k
        int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2508
75.4k
        imm = opnd->imm.value;
2509
75.4k
        assert (idx == 1);
2510
75.4k
        switch (opcode->op)
2511
75.4k
    {
2512
34.4k
    case OP_MOV_IMM_WIDEN:
2513
34.4k
      imm = ~imm;
2514
      /* Fall through.  */
2515
74.4k
    case OP_MOV_IMM_WIDE:
2516
74.4k
      if (!aarch64_wide_constant_p (imm, esize == 4, NULL))
2517
0
        {
2518
0
          set_other_error (mismatch_detail, idx,
2519
0
               _("immediate out of range"));
2520
0
          return 0;
2521
0
        }
2522
74.4k
      break;
2523
74.4k
    case OP_MOV_IMM_LOG:
2524
993
      if (!aarch64_logical_immediate_p (imm, esize, NULL))
2525
0
        {
2526
0
          set_other_error (mismatch_detail, idx,
2527
0
               _("immediate out of range"));
2528
0
          return 0;
2529
0
        }
2530
993
      break;
2531
993
    default:
2532
0
      assert (0);
2533
0
      return 0;
2534
75.4k
    }
2535
75.4k
      }
2536
75.4k
    break;
2537
2538
75.4k
  case AARCH64_OPND_NZCV:
2539
10.8k
  case AARCH64_OPND_CCMP_IMM:
2540
11.7k
  case AARCH64_OPND_EXCEPTION:
2541
1.41M
  case AARCH64_OPND_UNDEFINED:
2542
1.41M
  case AARCH64_OPND_TME_UIMM16:
2543
1.42M
  case AARCH64_OPND_UIMM4:
2544
1.42M
  case AARCH64_OPND_UIMM4_ADDG:
2545
1.42M
  case AARCH64_OPND_UIMM7:
2546
1.42M
  case AARCH64_OPND_UIMM3_OP1:
2547
1.43M
  case AARCH64_OPND_UIMM3_OP2:
2548
1.43M
  case AARCH64_OPND_SVE_UIMM3:
2549
1.46M
  case AARCH64_OPND_SVE_UIMM7:
2550
1.46M
  case AARCH64_OPND_SVE_UIMM8:
2551
1.46M
  case AARCH64_OPND_SVE_UIMM8_53:
2552
1.47M
  case AARCH64_OPND_CSSC_UIMM8:
2553
1.47M
    size = get_operand_fields_width (get_operand_from_code (type));
2554
1.47M
    assert (size < 32);
2555
1.47M
    if (!value_fit_unsigned_field_p (opnd->imm.value, size))
2556
0
      {
2557
0
        set_imm_out_of_range_error (mismatch_detail, idx, 0,
2558
0
            (1u << size) - 1);
2559
0
        return 0;
2560
0
      }
2561
1.47M
    break;
2562
2563
1.47M
  case AARCH64_OPND_UIMM10:
2564
    /* Scaled unsigned 10 bits immediate offset.  */
2565
3.46k
    if (!value_in_range_p (opnd->imm.value, 0, 1008))
2566
0
      {
2567
0
        set_imm_out_of_range_error (mismatch_detail, idx, 0, 1008);
2568
0
        return 0;
2569
0
      }
2570
2571
3.46k
    if (!value_aligned_p (opnd->imm.value, 16))
2572
0
      {
2573
0
        set_unaligned_error (mismatch_detail, idx, 16);
2574
0
        return 0;
2575
0
      }
2576
3.46k
    break;
2577
2578
13.9k
  case AARCH64_OPND_SIMM5:
2579
15.0k
  case AARCH64_OPND_SVE_SIMM5:
2580
15.8k
  case AARCH64_OPND_SVE_SIMM5B:
2581
17.4k
  case AARCH64_OPND_SVE_SIMM6:
2582
17.8k
  case AARCH64_OPND_SVE_SIMM8:
2583
20.4k
  case AARCH64_OPND_CSSC_SIMM8:
2584
20.4k
    size = get_operand_fields_width (get_operand_from_code (type));
2585
20.4k
    assert (size < 32);
2586
20.4k
    if (!value_fit_signed_field_p (opnd->imm.value, size))
2587
0
      {
2588
0
        set_imm_out_of_range_error (mismatch_detail, idx,
2589
0
            -(1 << (size - 1)),
2590
0
            (1 << (size - 1)) - 1);
2591
0
        return 0;
2592
0
      }
2593
20.4k
    break;
2594
2595
39.6k
  case AARCH64_OPND_WIDTH:
2596
39.6k
    assert (idx > 1 && opnds[idx-1].type == AARCH64_OPND_IMM
2597
39.6k
      && opnds[0].type == AARCH64_OPND_Rd);
2598
39.6k
    size = get_upper_bound (qualifier);
2599
39.6k
    if (opnd->imm.value + opnds[idx-1].imm.value > size)
2600
      /* lsb+width <= reg.size  */
2601
0
      {
2602
0
        set_imm_out_of_range_error (mismatch_detail, idx, 1,
2603
0
            size - opnds[idx-1].imm.value);
2604
0
        return 0;
2605
0
      }
2606
39.6k
    break;
2607
2608
289k
  case AARCH64_OPND_LIMM:
2609
332k
  case AARCH64_OPND_SVE_LIMM:
2610
332k
    {
2611
332k
      int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2612
332k
      uint64_t uimm = opnd->imm.value;
2613
332k
      if (opcode->op == OP_BIC)
2614
0
        uimm = ~uimm;
2615
332k
      if (!aarch64_logical_immediate_p (uimm, esize, NULL))
2616
0
        {
2617
0
    set_other_error (mismatch_detail, idx,
2618
0
         _("immediate out of range"));
2619
0
    return 0;
2620
0
        }
2621
332k
    }
2622
332k
    break;
2623
2624
332k
  case AARCH64_OPND_IMM0:
2625
488
  case AARCH64_OPND_FPIMM0:
2626
488
    if (opnd->imm.value != 0)
2627
0
      {
2628
0
        set_other_error (mismatch_detail, idx,
2629
0
             _("immediate zero expected"));
2630
0
        return 0;
2631
0
      }
2632
488
    break;
2633
2634
1.10k
  case AARCH64_OPND_IMM_ROT1:
2635
18.3k
  case AARCH64_OPND_IMM_ROT2:
2636
26.6k
  case AARCH64_OPND_SVE_IMM_ROT2:
2637
26.6k
    if (opnd->imm.value != 0
2638
26.6k
        && opnd->imm.value != 90
2639
26.6k
        && opnd->imm.value != 180
2640
26.6k
        && opnd->imm.value != 270)
2641
0
      {
2642
0
        set_other_error (mismatch_detail, idx,
2643
0
             _("rotate expected to be 0, 90, 180 or 270"));
2644
0
        return 0;
2645
0
      }
2646
26.6k
    break;
2647
2648
26.6k
  case AARCH64_OPND_IMM_ROT3:
2649
1.11k
  case AARCH64_OPND_SVE_IMM_ROT1:
2650
1.14k
  case AARCH64_OPND_SVE_IMM_ROT3:
2651
1.14k
    if (opnd->imm.value != 90 && opnd->imm.value != 270)
2652
0
      {
2653
0
        set_other_error (mismatch_detail, idx,
2654
0
             _("rotate expected to be 90 or 270"));
2655
0
        return 0;
2656
0
      }
2657
1.14k
    break;
2658
2659
1.14k
  case AARCH64_OPND_SHLL_IMM:
2660
108
    assert (idx == 2);
2661
108
    size = 8 * aarch64_get_qualifier_esize (opnds[idx - 1].qualifier);
2662
108
    if (opnd->imm.value != size)
2663
0
      {
2664
0
        set_other_error (mismatch_detail, idx,
2665
0
             _("invalid shift amount"));
2666
0
        return 0;
2667
0
      }
2668
108
    break;
2669
2670
11.2k
  case AARCH64_OPND_IMM_VLSL:
2671
11.2k
    size = aarch64_get_qualifier_esize (qualifier);
2672
11.2k
    if (!value_in_range_p (opnd->imm.value, 0, size * 8 - 1))
2673
0
      {
2674
0
        set_imm_out_of_range_error (mismatch_detail, idx, 0,
2675
0
            size * 8 - 1);
2676
0
        return 0;
2677
0
      }
2678
11.2k
    break;
2679
2680
13.1k
  case AARCH64_OPND_IMM_VLSR:
2681
13.1k
    size = aarch64_get_qualifier_esize (qualifier);
2682
13.1k
    if (!value_in_range_p (opnd->imm.value, 1, size * 8))
2683
0
      {
2684
0
        set_imm_out_of_range_error (mismatch_detail, idx, 1, size * 8);
2685
0
        return 0;
2686
0
      }
2687
13.1k
    break;
2688
2689
13.1k
  case AARCH64_OPND_SIMD_IMM:
2690
2.81k
  case AARCH64_OPND_SIMD_IMM_SFT:
2691
    /* Qualifier check.  */
2692
2.81k
    switch (qualifier)
2693
2.81k
      {
2694
2.13k
      case AARCH64_OPND_QLF_LSL:
2695
2.13k
        if (opnd->shifter.kind != AARCH64_MOD_LSL)
2696
0
    {
2697
0
      set_other_error (mismatch_detail, idx,
2698
0
           _("invalid shift operator"));
2699
0
      return 0;
2700
0
    }
2701
2.13k
        break;
2702
2.13k
      case AARCH64_OPND_QLF_MSL:
2703
513
        if (opnd->shifter.kind != AARCH64_MOD_MSL)
2704
0
    {
2705
0
      set_other_error (mismatch_detail, idx,
2706
0
           _("invalid shift operator"));
2707
0
      return 0;
2708
0
    }
2709
513
        break;
2710
513
      case AARCH64_OPND_QLF_NIL:
2711
164
        if (opnd->shifter.kind != AARCH64_MOD_NONE)
2712
0
    {
2713
0
      set_other_error (mismatch_detail, idx,
2714
0
           _("shift is not permitted"));
2715
0
      return 0;
2716
0
    }
2717
164
        break;
2718
164
      default:
2719
0
        assert (0);
2720
0
        return 0;
2721
2.81k
      }
2722
    /* Is the immediate valid?  */
2723
2.81k
    assert (idx == 1);
2724
2.81k
    if (aarch64_get_qualifier_esize (opnds[0].qualifier) != 8)
2725
2.65k
      {
2726
        /* uimm8 or simm8 */
2727
2.65k
        if (!value_in_range_p (opnd->imm.value, -128, 255))
2728
0
    {
2729
0
      set_imm_out_of_range_error (mismatch_detail, idx, -128, 255);
2730
0
      return 0;
2731
0
    }
2732
2.65k
      }
2733
164
    else if (aarch64_shrink_expanded_imm8 (opnd->imm.value) < 0)
2734
0
      {
2735
        /* uimm64 is not
2736
     'aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
2737
     ffffffffgggggggghhhhhhhh'.  */
2738
0
        set_other_error (mismatch_detail, idx,
2739
0
             _("invalid value for immediate"));
2740
0
        return 0;
2741
0
      }
2742
    /* Is the shift amount valid?  */
2743
2.81k
    switch (opnd->shifter.kind)
2744
2.81k
      {
2745
2.13k
      case AARCH64_MOD_LSL:
2746
2.13k
        size = aarch64_get_qualifier_esize (opnds[0].qualifier);
2747
2.13k
        if (!value_in_range_p (opnd->shifter.amount, 0, (size - 1) * 8))
2748
0
    {
2749
0
      set_sft_amount_out_of_range_error (mismatch_detail, idx, 0,
2750
0
                 (size - 1) * 8);
2751
0
      return 0;
2752
0
    }
2753
2.13k
        if (!value_aligned_p (opnd->shifter.amount, 8))
2754
0
    {
2755
0
      set_unaligned_error (mismatch_detail, idx, 8);
2756
0
      return 0;
2757
0
    }
2758
2.13k
        break;
2759
2.13k
      case AARCH64_MOD_MSL:
2760
        /* Only 8 and 16 are valid shift amount.  */
2761
513
        if (opnd->shifter.amount != 8 && opnd->shifter.amount != 16)
2762
0
    {
2763
0
      set_other_error (mismatch_detail, idx,
2764
0
           _("shift amount must be 0 or 16"));
2765
0
      return 0;
2766
0
    }
2767
513
        break;
2768
513
      default:
2769
164
        if (opnd->shifter.kind != AARCH64_MOD_NONE)
2770
0
    {
2771
0
      set_other_error (mismatch_detail, idx,
2772
0
           _("invalid shift operator"));
2773
0
      return 0;
2774
0
    }
2775
164
        break;
2776
2.81k
      }
2777
2.81k
    break;
2778
2779
2.81k
  case AARCH64_OPND_FPIMM:
2780
2.27k
  case AARCH64_OPND_SIMD_FPIMM:
2781
4.46k
  case AARCH64_OPND_SVE_FPIMM8:
2782
4.46k
    if (opnd->imm.is_fp == 0)
2783
0
      {
2784
0
        set_other_error (mismatch_detail, idx,
2785
0
             _("floating-point immediate expected"));
2786
0
        return 0;
2787
0
      }
2788
    /* The value is expected to be an 8-bit floating-point constant with
2789
       sign, 3-bit exponent and normalized 4 bits of precision, encoded
2790
       in "a:b:c:d:e:f:g:h" or FLD_imm8 (depending on the type of the
2791
       instruction).  */
2792
4.46k
    if (!value_in_range_p (opnd->imm.value, 0, 255))
2793
0
      {
2794
0
        set_other_error (mismatch_detail, idx,
2795
0
             _("immediate out of range"));
2796
0
        return 0;
2797
0
      }
2798
4.46k
    if (opnd->shifter.kind != AARCH64_MOD_NONE)
2799
0
      {
2800
0
        set_other_error (mismatch_detail, idx,
2801
0
             _("invalid shift operator"));
2802
0
        return 0;
2803
0
      }
2804
4.46k
    break;
2805
2806
4.46k
  case AARCH64_OPND_SVE_AIMM:
2807
2.95k
    min_value = 0;
2808
22.6k
  sve_aimm:
2809
22.6k
    assert (opnd->shifter.kind == AARCH64_MOD_LSL);
2810
22.6k
    size = aarch64_get_qualifier_esize (opnds[0].qualifier);
2811
22.6k
    mask = ~((uint64_t) -1 << (size * 4) << (size * 4));
2812
22.6k
    uvalue = opnd->imm.value;
2813
22.6k
    shift = opnd->shifter.amount;
2814
22.6k
    if (size == 1)
2815
4.28k
      {
2816
4.28k
        if (shift != 0)
2817
129
    {
2818
129
      set_other_error (mismatch_detail, idx,
2819
129
           _("no shift amount allowed for"
2820
129
             " 8-bit constants"));
2821
129
      return 0;
2822
129
    }
2823
4.28k
      }
2824
18.3k
    else
2825
18.3k
      {
2826
18.3k
        if (shift != 0 && shift != 8)
2827
0
    {
2828
0
      set_other_error (mismatch_detail, idx,
2829
0
           _("shift amount must be 0 or 8"));
2830
0
      return 0;
2831
0
    }
2832
18.3k
        if (shift == 0 && (uvalue & 0xff) == 0)
2833
10.2k
    {
2834
10.2k
      shift = 8;
2835
10.2k
      uvalue = (int64_t) uvalue / 256;
2836
10.2k
    }
2837
18.3k
      }
2838
22.4k
    mask >>= shift;
2839
22.4k
    if ((uvalue & mask) != uvalue && (uvalue | ~mask) != uvalue)
2840
1.41k
      {
2841
1.41k
        set_other_error (mismatch_detail, idx,
2842
1.41k
             _("immediate too big for element size"));
2843
1.41k
        return 0;
2844
1.41k
      }
2845
21.0k
    uvalue = (uvalue - min_value) & mask;
2846
21.0k
    if (uvalue > 0xff)
2847
0
      {
2848
0
        set_other_error (mismatch_detail, idx,
2849
0
             _("invalid arithmetic immediate"));
2850
0
        return 0;
2851
0
      }
2852
21.0k
    break;
2853
2854
21.0k
  case AARCH64_OPND_SVE_ASIMM:
2855
19.6k
    min_value = -128;
2856
19.6k
    goto sve_aimm;
2857
2858
233
  case AARCH64_OPND_SVE_I1_HALF_ONE:
2859
233
    assert (opnd->imm.is_fp);
2860
233
    if (opnd->imm.value != 0x3f000000 && opnd->imm.value != 0x3f800000)
2861
0
      {
2862
0
        set_other_error (mismatch_detail, idx,
2863
0
             _("floating-point value must be 0.5 or 1.0"));
2864
0
        return 0;
2865
0
      }
2866
233
    break;
2867
2868
233
  case AARCH64_OPND_SVE_I1_HALF_TWO:
2869
27
    assert (opnd->imm.is_fp);
2870
27
    if (opnd->imm.value != 0x3f000000 && opnd->imm.value != 0x40000000)
2871
0
      {
2872
0
        set_other_error (mismatch_detail, idx,
2873
0
             _("floating-point value must be 0.5 or 2.0"));
2874
0
        return 0;
2875
0
      }
2876
27
    break;
2877
2878
177
  case AARCH64_OPND_SVE_I1_ZERO_ONE:
2879
177
    assert (opnd->imm.is_fp);
2880
177
    if (opnd->imm.value != 0 && opnd->imm.value != 0x3f800000)
2881
0
      {
2882
0
        set_other_error (mismatch_detail, idx,
2883
0
             _("floating-point value must be 0.0 or 1.0"));
2884
0
        return 0;
2885
0
      }
2886
177
    break;
2887
2888
177
  case AARCH64_OPND_SVE_INV_LIMM:
2889
0
    {
2890
0
      int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2891
0
      uint64_t uimm = ~opnd->imm.value;
2892
0
      if (!aarch64_logical_immediate_p (uimm, esize, NULL))
2893
0
        {
2894
0
    set_other_error (mismatch_detail, idx,
2895
0
         _("immediate out of range"));
2896
0
    return 0;
2897
0
        }
2898
0
    }
2899
0
    break;
2900
2901
2.56k
  case AARCH64_OPND_SVE_LIMM_MOV:
2902
2.56k
    {
2903
2.56k
      int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2904
2.56k
      uint64_t uimm = opnd->imm.value;
2905
2.56k
      if (!aarch64_logical_immediate_p (uimm, esize, NULL))
2906
0
        {
2907
0
    set_other_error (mismatch_detail, idx,
2908
0
         _("immediate out of range"));
2909
0
    return 0;
2910
0
        }
2911
2.56k
      if (!aarch64_sve_dupm_mov_immediate_p (uimm, esize))
2912
0
        {
2913
0
    set_other_error (mismatch_detail, idx,
2914
0
         _("invalid replicated MOV immediate"));
2915
0
    return 0;
2916
0
        }
2917
2.56k
    }
2918
2.56k
    break;
2919
2920
7.35k
  case AARCH64_OPND_SVE_PATTERN_SCALED:
2921
7.35k
    assert (opnd->shifter.kind == AARCH64_MOD_MUL);
2922
7.35k
    if (!value_in_range_p (opnd->shifter.amount, 1, 16))
2923
0
      {
2924
0
        set_multiplier_out_of_range_error (mismatch_detail, idx, 1, 16);
2925
0
        return 0;
2926
0
      }
2927
7.35k
    break;
2928
2929
7.35k
  case AARCH64_OPND_SVE_SHLIMM_PRED:
2930
1.28k
  case AARCH64_OPND_SVE_SHLIMM_UNPRED:
2931
2.08k
  case AARCH64_OPND_SVE_SHLIMM_UNPRED_22:
2932
2.08k
    size = aarch64_get_qualifier_esize (opnds[idx - 1].qualifier);
2933
2.08k
    if (!value_in_range_p (opnd->imm.value, 0, 8 * size - 1))
2934
0
      {
2935
0
        set_imm_out_of_range_error (mismatch_detail, idx,
2936
0
            0, 8 * size - 1);
2937
0
        return 0;
2938
0
      }
2939
2.08k
    break;
2940
2941
2.08k
  case AARCH64_OPND_SME_SHRIMM4:
2942
94
    size = 1 << get_operand_fields_width (get_operand_from_code (type));
2943
94
    if (!value_in_range_p (opnd->imm.value, 1, size))
2944
0
      {
2945
0
        set_imm_out_of_range_error (mismatch_detail, idx, 1, size);
2946
0
        return 0;
2947
0
      }
2948
94
    break;
2949
2950
127
  case AARCH64_OPND_SME_SHRIMM5:
2951
2.16k
  case AARCH64_OPND_SVE_SHRIMM_PRED:
2952
4.65k
  case AARCH64_OPND_SVE_SHRIMM_UNPRED:
2953
9.33k
  case AARCH64_OPND_SVE_SHRIMM_UNPRED_22:
2954
9.33k
    num = (type == AARCH64_OPND_SVE_SHRIMM_UNPRED_22) ? 2 : 1;
2955
9.33k
    size = aarch64_get_qualifier_esize (opnds[idx - num].qualifier);
2956
9.33k
    if (!value_in_range_p (opnd->imm.value, 1, 8 * size))
2957
0
      {
2958
0
        set_imm_out_of_range_error (mismatch_detail, idx, 1, 8*size);
2959
0
        return 0;
2960
0
      }
2961
9.33k
    break;
2962
2963
9.33k
  case AARCH64_OPND_SME_ZT0_INDEX:
2964
0
    if (!value_in_range_p (opnd->imm.value, 0, 56))
2965
0
      {
2966
0
        set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, 56);
2967
0
        return 0;
2968
0
      }
2969
0
    if (opnd->imm.value % 8 != 0)
2970
0
      {
2971
0
        set_other_error (mismatch_detail, idx,
2972
0
             _("byte index must be a multiple of 8"));
2973
0
        return 0;
2974
0
      }
2975
0
    break;
2976
2977
398k
  default:
2978
398k
    break;
2979
3.04M
  }
2980
3.01M
      break;
2981
2982
3.01M
    case AARCH64_OPND_CLASS_SYSTEM:
2983
72.8k
      switch (type)
2984
72.8k
  {
2985
496
  case AARCH64_OPND_PSTATEFIELD:
2986
1.74k
    for (i = 0; aarch64_pstatefields[i].name; ++i)
2987
1.74k
      if (aarch64_pstatefields[i].value == opnd->pstatefield)
2988
496
        break;
2989
496
    assert (aarch64_pstatefields[i].name);
2990
496
    assert (idx == 0 && opnds[1].type == AARCH64_OPND_UIMM4);
2991
496
    max_value = F_GET_REG_MAX_VALUE (aarch64_pstatefields[i].flags);
2992
496
    if (opnds[1].imm.value < 0 || opnds[1].imm.value > max_value)
2993
383
      {
2994
383
        set_imm_out_of_range_error (mismatch_detail, 1, 0, max_value);
2995
383
        return 0;
2996
383
      }
2997
113
    break;
2998
60.8k
  case AARCH64_OPND_PRFOP:
2999
60.8k
    if (opcode->iclass == ldst_regoff && opnd->prfop->value >= 24)
3000
286
      {
3001
286
        set_other_error (mismatch_detail, idx,
3002
286
             _("the register-index form of PRFM does"
3003
286
         " not accept opcodes in the range 24-31"));
3004
286
        return 0;
3005
286
      }
3006
60.5k
    break;
3007
60.5k
  default:
3008
11.5k
    break;
3009
72.8k
  }
3010
72.2k
      break;
3011
3012
72.2k
    case AARCH64_OPND_CLASS_SIMD_ELEMENT:
3013
      /* Get the upper bound for the element index.  */
3014
70.7k
      if (opcode->op == OP_FCMLA_ELEM)
3015
  /* FCMLA index range depends on the vector size of other operands
3016
     and is halfed because complex numbers take two elements.  */
3017
7.92k
  num = aarch64_get_qualifier_nelem (opnds[0].qualifier)
3018
7.92k
        * aarch64_get_qualifier_esize (opnds[0].qualifier) / 2;
3019
62.8k
      else
3020
62.8k
  num = 16;
3021
70.7k
      num = num / aarch64_get_qualifier_esize (qualifier) - 1;
3022
70.7k
      assert (aarch64_get_qualifier_nelem (qualifier) == 1);
3023
3024
      /* Index out-of-range.  */
3025
70.7k
      if (!value_in_range_p (opnd->reglane.index, 0, num))
3026
804
  {
3027
804
    set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, num);
3028
804
    return 0;
3029
804
  }
3030
      /* SMLAL<Q> <Vd>.<Ta>, <Vn>.<Tb>, <Vm>.<Ts>[<index>].
3031
   <Vm> Is the vector register (V0-V31) or (V0-V15), whose
3032
   number is encoded in "size:M:Rm":
3033
   size <Vm>
3034
   00   RESERVED
3035
   01   0:Rm
3036
   10   M:Rm
3037
   11   RESERVED  */
3038
69.9k
      if (type == AARCH64_OPND_Em16 && qualifier == AARCH64_OPND_QLF_S_H
3039
69.9k
    && !value_in_range_p (opnd->reglane.regno, 0, 15))
3040
0
  {
3041
0
    set_regno_out_of_range_error (mismatch_detail, idx, 0, 15);
3042
0
    return 0;
3043
0
  }
3044
69.9k
      break;
3045
3046
765k
    case AARCH64_OPND_CLASS_MODIFIED_REG:
3047
765k
      assert (idx == 1 || idx == 2);
3048
765k
      switch (type)
3049
765k
  {
3050
76.0k
  case AARCH64_OPND_Rm_EXT:
3051
76.0k
    if (!aarch64_extend_operator_p (opnd->shifter.kind)
3052
76.0k
        && opnd->shifter.kind != AARCH64_MOD_LSL)
3053
0
      {
3054
0
        set_other_error (mismatch_detail, idx,
3055
0
             _("extend operator expected"));
3056
0
        return 0;
3057
0
      }
3058
    /* It is not optional unless at least one of "Rd" or "Rn" is '11111'
3059
       (i.e. SP), in which case it defaults to LSL. The LSL alias is
3060
       only valid when "Rd" or "Rn" is '11111', and is preferred in that
3061
       case.  */
3062
76.0k
    if (!aarch64_stack_pointer_p (opnds + 0)
3063
76.0k
        && (idx != 2 || !aarch64_stack_pointer_p (opnds + 1)))
3064
72.4k
      {
3065
72.4k
        if (!opnd->shifter.operator_present)
3066
0
    {
3067
0
      set_other_error (mismatch_detail, idx,
3068
0
           _("missing extend operator"));
3069
0
      return 0;
3070
0
    }
3071
72.4k
        else if (opnd->shifter.kind == AARCH64_MOD_LSL)
3072
0
    {
3073
0
      set_other_error (mismatch_detail, idx,
3074
0
           _("'LSL' operator not allowed"));
3075
0
      return 0;
3076
0
    }
3077
72.4k
      }
3078
76.0k
    assert (opnd->shifter.operator_present  /* Default to LSL.  */
3079
76.0k
      || opnd->shifter.kind == AARCH64_MOD_LSL);
3080
76.0k
    if (!value_in_range_p (opnd->shifter.amount, 0, 4))
3081
12.1k
      {
3082
12.1k
        set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, 4);
3083
12.1k
        return 0;
3084
12.1k
      }
3085
    /* In the 64-bit form, the final register operand is written as Wm
3086
       for all but the (possibly omitted) UXTX/LSL and SXTX
3087
       operators.
3088
       N.B. GAS allows X register to be used with any operator as a
3089
       programming convenience.  */
3090
63.8k
    if (qualifier == AARCH64_OPND_QLF_X
3091
63.8k
        && opnd->shifter.kind != AARCH64_MOD_LSL
3092
63.8k
        && opnd->shifter.kind != AARCH64_MOD_UXTX
3093
63.8k
        && opnd->shifter.kind != AARCH64_MOD_SXTX)
3094
0
      {
3095
0
        set_other_error (mismatch_detail, idx, _("W register expected"));
3096
0
        return 0;
3097
0
      }
3098
63.8k
    break;
3099
3100
689k
  case AARCH64_OPND_Rm_SFT:
3101
    /* ROR is not available to the shifted register operand in
3102
       arithmetic instructions.  */
3103
689k
    if (!aarch64_shift_operator_p (opnd->shifter.kind))
3104
0
      {
3105
0
        set_other_error (mismatch_detail, idx,
3106
0
             _("shift operator expected"));
3107
0
        return 0;
3108
0
      }
3109
689k
    if (opnd->shifter.kind == AARCH64_MOD_ROR
3110
689k
        && opcode->iclass != log_shift)
3111
0
      {
3112
0
        set_other_error (mismatch_detail, idx,
3113
0
             _("'ROR' operator not allowed"));
3114
0
        return 0;
3115
0
      }
3116
689k
    num = qualifier == AARCH64_OPND_QLF_W ? 31 : 63;
3117
689k
    if (!value_in_range_p (opnd->shifter.amount, 0, num))
3118
84.0k
      {
3119
84.0k
        set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, num);
3120
84.0k
        return 0;
3121
84.0k
      }
3122
605k
    break;
3123
3124
605k
  default:
3125
0
    break;
3126
765k
  }
3127
668k
      break;
3128
3129
1.69M
    default:
3130
1.69M
      break;
3131
18.1M
    }
3132
3133
17.8M
  return 1;
3134
18.1M
}
3135
3136
/* Main entrypoint for the operand constraint checking.
3137
3138
   Return 1 if operands of *INST meet the constraint applied by the operand
3139
   codes and operand qualifiers; otherwise return 0 and if MISMATCH_DETAIL is
3140
   not NULL, return the detail of the error in *MISMATCH_DETAIL.  N.B. when
3141
   adding more constraint checking, make sure MISMATCH_DETAIL->KIND is set
3142
   with a proper error kind rather than AARCH64_OPDE_NIL (GAS asserts non-NIL
3143
   error kind when it is notified that an instruction does not pass the check).
3144
3145
   Un-determined operand qualifiers may get established during the process.  */
3146
3147
int
3148
aarch64_match_operands_constraint (aarch64_inst *inst,
3149
           aarch64_operand_error *mismatch_detail)
3150
7.71M
{
3151
7.71M
  int i;
3152
3153
7.71M
  DEBUG_TRACE ("enter");
3154
3155
7.71M
  i = inst->opcode->tied_operand;
3156
3157
7.71M
  if (i > 0)
3158
83.5k
    {
3159
      /* Check for tied_operands with specific opcode iclass.  */
3160
83.5k
      switch (inst->opcode->iclass)
3161
83.5k
        {
3162
        /* For SME LDR and STR instructions #imm must have the same numerical
3163
           value for both operands.
3164
        */
3165
1.36k
        case sme_ldr:
3166
1.36k
        case sme_str:
3167
1.36k
          assert (inst->operands[0].type == AARCH64_OPND_SME_ZA_array_off4);
3168
1.36k
          assert (inst->operands[1].type == AARCH64_OPND_SME_ADDR_RI_U4xVL);
3169
1.36k
          if (inst->operands[0].indexed_za.index.imm
3170
1.36k
              != inst->operands[1].addr.offset.imm)
3171
0
            {
3172
0
              if (mismatch_detail)
3173
0
                {
3174
0
                  mismatch_detail->kind = AARCH64_OPDE_UNTIED_IMMS;
3175
0
                  mismatch_detail->index = i;
3176
0
                }
3177
0
              return 0;
3178
0
            }
3179
1.36k
          break;
3180
3181
82.2k
        default:
3182
82.2k
    {
3183
      /* Check for cases where a source register needs to be the
3184
         same as the destination register.  Do this before
3185
         matching qualifiers since if an instruction has both
3186
         invalid tying and invalid qualifiers, the error about
3187
         qualifiers would suggest several alternative instructions
3188
         that also have invalid tying.  */
3189
82.2k
      enum aarch64_operand_class op_class1
3190
82.2k
         = aarch64_get_operand_class (inst->operands[0].type);
3191
82.2k
      enum aarch64_operand_class op_class2
3192
82.2k
         = aarch64_get_operand_class (inst->operands[i].type);
3193
82.2k
      assert (op_class1 == op_class2);
3194
82.2k
      if (op_class1 == AARCH64_OPND_CLASS_SVE_REGLIST
3195
82.2k
    ? ((inst->operands[0].reglist.first_regno
3196
355
        != inst->operands[i].reglist.first_regno)
3197
355
       || (inst->operands[0].reglist.num_regs
3198
355
           != inst->operands[i].reglist.num_regs)
3199
355
       || (inst->operands[0].reglist.stride
3200
355
           != inst->operands[i].reglist.stride))
3201
82.2k
    : (inst->operands[0].reg.regno
3202
81.8k
       != inst->operands[i].reg.regno))
3203
0
        {
3204
0
    if (mismatch_detail)
3205
0
      {
3206
0
        mismatch_detail->kind = AARCH64_OPDE_UNTIED_OPERAND;
3207
0
        mismatch_detail->index = i;
3208
0
        mismatch_detail->error = NULL;
3209
0
      }
3210
0
    return 0;
3211
0
        }
3212
82.2k
      break;
3213
82.2k
    }
3214
83.5k
        }
3215
83.5k
    }
3216
3217
  /* Match operands' qualifier.
3218
     *INST has already had qualifier establish for some, if not all, of
3219
     its operands; we need to find out whether these established
3220
     qualifiers match one of the qualifier sequence in
3221
     INST->OPCODE->QUALIFIERS_LIST.  If yes, we will assign each operand
3222
     with the corresponding qualifier in such a sequence.
3223
     Only basic operand constraint checking is done here; the more thorough
3224
     constraint checking will carried out by operand_general_constraint_met_p,
3225
     which has be to called after this in order to get all of the operands'
3226
     qualifiers established.  */
3227
7.71M
  int invalid_count;
3228
7.71M
  if (match_operands_qualifier (inst, true /* update_p */,
3229
7.71M
        &invalid_count) == 0)
3230
40.2k
    {
3231
40.2k
      DEBUG_TRACE ("FAIL on operand qualifier matching");
3232
40.2k
      if (mismatch_detail)
3233
0
  {
3234
    /* Return an error type to indicate that it is the qualifier
3235
       matching failure; we don't care about which operand as there
3236
       are enough information in the opcode table to reproduce it.  */
3237
0
    mismatch_detail->kind = AARCH64_OPDE_INVALID_VARIANT;
3238
0
    mismatch_detail->index = -1;
3239
0
    mismatch_detail->error = NULL;
3240
0
    mismatch_detail->data[0].i = invalid_count;
3241
0
  }
3242
40.2k
      return 0;
3243
40.2k
    }
3244
3245
  /* Match operands' constraint.  */
3246
25.6M
  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
3247
25.6M
    {
3248
25.6M
      enum aarch64_opnd type = inst->opcode->operands[i];
3249
25.6M
      if (type == AARCH64_OPND_NIL)
3250
7.42M
  break;
3251
18.1M
      if (inst->operands[i].skip)
3252
0
  {
3253
0
    DEBUG_TRACE ("skip the incomplete operand %d", i);
3254
0
    continue;
3255
0
  }
3256
18.1M
      if (operand_general_constraint_met_p (inst->operands, i, type,
3257
18.1M
              inst->opcode, mismatch_detail) == 0)
3258
259k
  {
3259
259k
    DEBUG_TRACE ("FAIL on operand %d", i);
3260
259k
    return 0;
3261
259k
  }
3262
18.1M
    }
3263
3264
7.42M
  DEBUG_TRACE ("PASS");
3265
3266
7.42M
  return 1;
3267
7.67M
}
3268
3269
/* Replace INST->OPCODE with OPCODE and return the replaced OPCODE.
3270
   Also updates the TYPE of each INST->OPERANDS with the corresponding
3271
   value of OPCODE->OPERANDS.
3272
3273
   Note that some operand qualifiers may need to be manually cleared by
3274
   the caller before it further calls the aarch64_opcode_encode; by
3275
   doing this, it helps the qualifier matching facilities work
3276
   properly.  */
3277
3278
const aarch64_opcode*
3279
aarch64_replace_opcode (aarch64_inst *inst, const aarch64_opcode *opcode)
3280
118k
{
3281
118k
  int i;
3282
118k
  const aarch64_opcode *old = inst->opcode;
3283
3284
118k
  inst->opcode = opcode;
3285
3286
  /* Update the operand types.  */
3287
436k
  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
3288
436k
    {
3289
436k
      inst->operands[i].type = opcode->operands[i];
3290
436k
      if (opcode->operands[i] == AARCH64_OPND_NIL)
3291
118k
  break;
3292
436k
    }
3293
3294
118k
  DEBUG_TRACE ("replace %s with %s", old->name, opcode->name);
3295
3296
118k
  return old;
3297
118k
}
3298
3299
int
3300
aarch64_operand_index (const enum aarch64_opnd *operands, enum aarch64_opnd operand)
3301
268k
{
3302
268k
  int i;
3303
293k
  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
3304
293k
    if (operands[i] == operand)
3305
266k
      return i;
3306
26.5k
    else if (operands[i] == AARCH64_OPND_NIL)
3307
2.22k
      break;
3308
2.22k
  return -1;
3309
268k
}
3310

3311
/* R0...R30, followed by FOR31.  */
3312
#define BANK(R, FOR31) \
3313
  { R  (0), R  (1), R  (2), R  (3), R  (4), R  (5), R  (6), R  (7), \
3314
    R  (8), R  (9), R (10), R (11), R (12), R (13), R (14), R (15), \
3315
    R (16), R (17), R (18), R (19), R (20), R (21), R (22), R (23), \
3316
    R (24), R (25), R (26), R (27), R (28), R (29), R (30),  FOR31 }
3317
/* [0][0]  32-bit integer regs with sp   Wn
3318
   [0][1]  64-bit integer regs with sp   Xn  sf=1
3319
   [1][0]  32-bit integer regs with #0   Wn
3320
   [1][1]  64-bit integer regs with #0   Xn  sf=1 */
3321
static const char *int_reg[2][2][32] = {
3322
#define R32(X) "w" #X
3323
#define R64(X) "x" #X
3324
  { BANK (R32, "wsp"), BANK (R64, "sp") },
3325
  { BANK (R32, "wzr"), BANK (R64, "xzr") }
3326
#undef R64
3327
#undef R32
3328
};
3329
3330
/* Names of the SVE vector registers, first with .S suffixes,
3331
   then with .D suffixes.  */
3332
3333
static const char *sve_reg[2][32] = {
3334
#define ZS(X) "z" #X ".s"
3335
#define ZD(X) "z" #X ".d"
3336
  BANK (ZS, ZS (31)), BANK (ZD, ZD (31))
3337
#undef ZD
3338
#undef ZS
3339
};
3340
#undef BANK
3341
3342
/* Return the integer register name.
3343
   if SP_REG_P is not 0, R31 is an SP reg, other R31 is the zero reg.  */
3344
3345
static inline const char *
3346
get_int_reg_name (int regno, aarch64_opnd_qualifier_t qualifier, int sp_reg_p)
3347
5.07M
{
3348
5.07M
  const int has_zr = sp_reg_p ? 0 : 1;
3349
5.07M
  const int is_64 = aarch64_get_qualifier_esize (qualifier) == 4 ? 0 : 1;
3350
5.07M
  return int_reg[has_zr][is_64][regno];
3351
5.07M
}
3352
3353
/* Like get_int_reg_name, but IS_64 is always 1.  */
3354
3355
static inline const char *
3356
get_64bit_int_reg_name (int regno, int sp_reg_p)
3357
1.69M
{
3358
1.69M
  const int has_zr = sp_reg_p ? 0 : 1;
3359
1.69M
  return int_reg[has_zr][1][regno];
3360
1.69M
}
3361
3362
/* Get the name of the integer offset register in OPND, using the shift type
3363
   to decide whether it's a word or doubleword.  */
3364
3365
static inline const char *
3366
get_offset_int_reg_name (const aarch64_opnd_info *opnd)
3367
146k
{
3368
146k
  switch (opnd->shifter.kind)
3369
146k
    {
3370
3.79k
    case AARCH64_MOD_UXTW:
3371
8.26k
    case AARCH64_MOD_SXTW:
3372
8.26k
      return get_int_reg_name (opnd->addr.offset.regno, AARCH64_OPND_QLF_W, 0);
3373
3374
132k
    case AARCH64_MOD_LSL:
3375
138k
    case AARCH64_MOD_SXTX:
3376
138k
      return get_int_reg_name (opnd->addr.offset.regno, AARCH64_OPND_QLF_X, 0);
3377
3378
0
    default:
3379
0
      abort ();
3380
146k
    }
3381
146k
}
3382
3383
/* Get the name of the SVE vector offset register in OPND, using the operand
3384
   qualifier to decide whether the suffix should be .S or .D.  */
3385
3386
static inline const char *
3387
get_addr_sve_reg_name (int regno, aarch64_opnd_qualifier_t qualifier)
3388
168k
{
3389
168k
  assert (qualifier == AARCH64_OPND_QLF_S_S
3390
168k
    || qualifier == AARCH64_OPND_QLF_S_D);
3391
168k
  return sve_reg[qualifier == AARCH64_OPND_QLF_S_D][regno];
3392
168k
}
3393
3394
/* Types for expanding an encoded 8-bit value to a floating-point value.  */
3395
3396
typedef union
3397
{
3398
  uint64_t i;
3399
  double   d;
3400
} double_conv_t;
3401
3402
typedef union
3403
{
3404
  uint32_t i;
3405
  float    f;
3406
} single_conv_t;
3407
3408
typedef union
3409
{
3410
  uint32_t i;
3411
  float    f;
3412
} half_conv_t;
3413
3414
/* IMM8 is an 8-bit floating-point constant with sign, 3-bit exponent and
3415
   normalized 4 bits of precision, encoded in "a:b:c:d:e:f:g:h" or FLD_imm8
3416
   (depending on the type of the instruction).  IMM8 will be expanded to a
3417
   single-precision floating-point value (SIZE == 4) or a double-precision
3418
   floating-point value (SIZE == 8).  A half-precision floating-point value
3419
   (SIZE == 2) is expanded to a single-precision floating-point value.  The
3420
   expanded value is returned.  */
3421
3422
static uint64_t
3423
expand_fp_imm (int size, uint32_t imm8)
3424
3.37k
{
3425
3.37k
  uint64_t imm = 0;
3426
3.37k
  uint32_t imm8_7, imm8_6_0, imm8_6, imm8_6_repl4;
3427
3428
3.37k
  imm8_7 = (imm8 >> 7) & 0x01;  /* imm8<7>   */
3429
3.37k
  imm8_6_0 = imm8 & 0x7f; /* imm8<6:0> */
3430
3.37k
  imm8_6 = imm8_6_0 >> 6; /* imm8<6>   */
3431
3.37k
  imm8_6_repl4 = (imm8_6 << 3) | (imm8_6 << 2)
3432
3.37k
    | (imm8_6 << 1) | imm8_6; /* Replicate(imm8<6>,4) */
3433
3.37k
  if (size == 8)
3434
710
    {
3435
710
      imm = (imm8_7 << (63-32))   /* imm8<7>  */
3436
710
  | ((imm8_6 ^ 1) << (62-32)) /* NOT(imm8<6)  */
3437
710
  | (imm8_6_repl4 << (58-32)) | (imm8_6 << (57-32))
3438
710
  | (imm8_6 << (56-32)) | (imm8_6 << (55-32)) /* Replicate(imm8<6>,7) */
3439
710
  | (imm8_6_0 << (48-32));  /* imm8<6>:imm8<5:0>    */
3440
710
      imm <<= 32;
3441
710
    }
3442
2.66k
  else if (size == 4 || size == 2)
3443
2.66k
    {
3444
2.66k
      imm = (imm8_7 << 31)  /* imm8<7>              */
3445
2.66k
  | ((imm8_6 ^ 1) << 30)  /* NOT(imm8<6>)         */
3446
2.66k
  | (imm8_6_repl4 << 26)  /* Replicate(imm8<6>,4) */
3447
2.66k
  | (imm8_6_0 << 19); /* imm8<6>:imm8<5:0>    */
3448
2.66k
    }
3449
0
  else
3450
0
    {
3451
      /* An unsupported size.  */
3452
0
      assert (0);
3453
0
    }
3454
3455
3.37k
  return imm;
3456
3.37k
}
3457
3458
/* Return a string based on FMT with the register style applied.  */
3459
3460
static const char *
3461
style_reg (struct aarch64_styler *styler, const char *fmt, ...)
3462
11.3M
{
3463
11.3M
  const char *txt;
3464
11.3M
  va_list ap;
3465
3466
11.3M
  va_start (ap, fmt);
3467
11.3M
  txt = styler->apply_style (styler, dis_style_register, fmt, ap);
3468
11.3M
  va_end (ap);
3469
3470
11.3M
  return txt;
3471
11.3M
}
3472
3473
/* Return a string based on FMT with the immediate style applied.  */
3474
3475
static const char *
3476
style_imm (struct aarch64_styler *styler, const char *fmt, ...)
3477
4.44M
{
3478
4.44M
  const char *txt;
3479
4.44M
  va_list ap;
3480
3481
4.44M
  va_start (ap, fmt);
3482
4.44M
  txt = styler->apply_style (styler, dis_style_immediate, fmt, ap);
3483
4.44M
  va_end (ap);
3484
3485
4.44M
  return txt;
3486
4.44M
}
3487
3488
/* Return a string based on FMT with the sub-mnemonic style applied.  */
3489
3490
static const char *
3491
style_sub_mnem (struct aarch64_styler *styler, const char *fmt, ...)
3492
877k
{
3493
877k
  const char *txt;
3494
877k
  va_list ap;
3495
3496
877k
  va_start (ap, fmt);
3497
877k
  txt = styler->apply_style (styler, dis_style_sub_mnemonic, fmt, ap);
3498
877k
  va_end (ap);
3499
3500
877k
  return txt;
3501
877k
}
3502
3503
/* Return a string based on FMT with the address style applied.  */
3504
3505
static const char *
3506
style_addr (struct aarch64_styler *styler, const char *fmt, ...)
3507
1.53M
{
3508
1.53M
  const char *txt;
3509
1.53M
  va_list ap;
3510
3511
1.53M
  va_start (ap, fmt);
3512
1.53M
  txt = styler->apply_style (styler, dis_style_address, fmt, ap);
3513
1.53M
  va_end (ap);
3514
3515
1.53M
  return txt;
3516
1.53M
}
3517
3518
/* Produce the string representation of the register list operand *OPND
3519
   in the buffer pointed by BUF of size SIZE.  PREFIX is the part of
3520
   the register name that comes before the register number, such as "v".  */
3521
static void
3522
print_register_list (char *buf, size_t size, const aarch64_opnd_info *opnd,
3523
         const char *prefix, struct aarch64_styler *styler)
3524
389k
{
3525
389k
  const int mask = (prefix[0] == 'p' ? 15 : 31);
3526
389k
  const int num_regs = opnd->reglist.num_regs;
3527
389k
  const int stride = opnd->reglist.stride;
3528
389k
  const int first_reg = opnd->reglist.first_regno;
3529
389k
  const int last_reg = (first_reg + (num_regs - 1) * stride) & mask;
3530
389k
  const char *qlf_name = aarch64_get_qualifier_name (opnd->qualifier);
3531
389k
  char tb[16];  /* Temporary buffer.  */
3532
3533
389k
  assert (opnd->type != AARCH64_OPND_LEt || opnd->reglist.has_index);
3534
389k
  assert (num_regs >= 1 && num_regs <= 4);
3535
3536
  /* Prepare the index if any.  */
3537
389k
  if (opnd->reglist.has_index)
3538
    /* PR 21096: The %100 is to silence a warning about possible truncation.  */
3539
23.9k
    snprintf (tb, sizeof (tb), "[%s]",
3540
23.9k
        style_imm (styler, "%" PRIi64, (opnd->reglist.index % 100)));
3541
365k
  else
3542
365k
    tb[0] = '\0';
3543
3544
  /* The hyphenated form is preferred for disassembly if there are
3545
     more than two registers in the list, and the register numbers
3546
     are monotonically increasing in increments of one.  */
3547
389k
  if (stride == 1 && num_regs > 1)
3548
96.3k
    snprintf (buf, size, "{%s-%s}%s",
3549
96.3k
        style_reg (styler, "%s%d.%s", prefix, first_reg, qlf_name),
3550
96.3k
        style_reg (styler, "%s%d.%s", prefix, last_reg, qlf_name), tb);
3551
293k
  else
3552
293k
    {
3553
293k
      const int reg0 = first_reg;
3554
293k
      const int reg1 = (first_reg + stride) & mask;
3555
293k
      const int reg2 = (first_reg + stride * 2) & mask;
3556
293k
      const int reg3 = (first_reg + stride * 3) & mask;
3557
3558
293k
      switch (num_regs)
3559
293k
  {
3560
283k
  case 1:
3561
283k
    snprintf (buf, size, "{%s}%s",
3562
283k
        style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name),
3563
283k
        tb);
3564
283k
    break;
3565
7.79k
  case 2:
3566
7.79k
    snprintf (buf, size, "{%s, %s}%s",
3567
7.79k
        style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name),
3568
7.79k
        style_reg (styler, "%s%d.%s", prefix, reg1, qlf_name),
3569
7.79k
        tb);
3570
7.79k
    break;
3571
0
  case 3:
3572
0
    snprintf (buf, size, "{%s, %s, %s}%s",
3573
0
        style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name),
3574
0
        style_reg (styler, "%s%d.%s", prefix, reg1, qlf_name),
3575
0
        style_reg (styler, "%s%d.%s", prefix, reg2, qlf_name),
3576
0
        tb);
3577
0
    break;
3578
2.15k
  case 4:
3579
2.15k
    snprintf (buf, size, "{%s, %s, %s, %s}%s",
3580
2.15k
        style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name),
3581
2.15k
        style_reg (styler, "%s%d.%s", prefix, reg1, qlf_name),
3582
2.15k
        style_reg (styler, "%s%d.%s", prefix, reg2, qlf_name),
3583
2.15k
        style_reg (styler, "%s%d.%s", prefix, reg3, qlf_name),
3584
2.15k
        tb);
3585
2.15k
    break;
3586
293k
  }
3587
293k
    }
3588
389k
}
3589
3590
/* Print the register+immediate address in OPND to BUF, which has SIZE
3591
   characters.  BASE is the name of the base register.  */
3592
3593
static void
3594
print_immediate_offset_address (char *buf, size_t size,
3595
        const aarch64_opnd_info *opnd,
3596
        const char *base,
3597
        struct aarch64_styler *styler)
3598
862k
{
3599
862k
  if (opnd->addr.writeback)
3600
303k
    {
3601
303k
      if (opnd->addr.preind)
3602
158k
        {
3603
158k
    if (opnd->type == AARCH64_OPND_ADDR_SIMM10 && !opnd->addr.offset.imm)
3604
98
      snprintf (buf, size, "[%s]!", style_reg (styler, base));
3605
158k
          else
3606
158k
      snprintf (buf, size, "[%s, %s]!",
3607
158k
          style_reg (styler, base),
3608
158k
          style_imm (styler, "#%d", opnd->addr.offset.imm));
3609
158k
        }
3610
144k
      else
3611
144k
  snprintf (buf, size, "[%s], %s",
3612
144k
      style_reg (styler, base),
3613
144k
      style_imm (styler, "#%d", opnd->addr.offset.imm));
3614
303k
    }
3615
558k
  else
3616
558k
    {
3617
558k
      if (opnd->shifter.operator_present)
3618
75.2k
  {
3619
75.2k
    assert (opnd->shifter.kind == AARCH64_MOD_MUL_VL);
3620
75.2k
    snprintf (buf, size, "[%s, %s, %s]",
3621
75.2k
        style_reg (styler, base),
3622
75.2k
        style_imm (styler, "#%d", opnd->addr.offset.imm),
3623
75.2k
        style_sub_mnem (styler, "mul vl"));
3624
75.2k
  }
3625
483k
      else if (opnd->addr.offset.imm)
3626
432k
  snprintf (buf, size, "[%s, %s]",
3627
432k
      style_reg (styler, base),
3628
432k
      style_imm (styler, "#%d", opnd->addr.offset.imm));
3629
51.2k
      else
3630
51.2k
  snprintf (buf, size, "[%s]", style_reg (styler, base));
3631
558k
    }
3632
862k
}
3633
3634
/* Produce the string representation of the register offset address operand
3635
   *OPND in the buffer pointed by BUF of size SIZE.  BASE and OFFSET are
3636
   the names of the base and offset registers.  */
3637
static void
3638
print_register_offset_address (char *buf, size_t size,
3639
             const aarch64_opnd_info *opnd,
3640
             const char *base, const char *offset,
3641
             struct aarch64_styler *styler)
3642
294k
{
3643
294k
  char tb[32];      /* Temporary buffer.  */
3644
294k
  bool print_extend_p = true;
3645
294k
  bool print_amount_p = true;
3646
294k
  const char *shift_name = aarch64_operand_modifiers[opnd->shifter.kind].name;
3647
3648
294k
  if (!opnd->shifter.amount && (opnd->qualifier != AARCH64_OPND_QLF_S_B
3649
155k
        || !opnd->shifter.amount_present))
3650
153k
    {
3651
      /* Not print the shift/extend amount when the amount is zero and
3652
         when it is not the special case of 8-bit load/store instruction.  */
3653
153k
      print_amount_p = false;
3654
      /* Likewise, no need to print the shift operator LSL in such a
3655
   situation.  */
3656
153k
      if (opnd->shifter.kind == AARCH64_MOD_LSL)
3657
88.4k
  print_extend_p = false;
3658
153k
    }
3659
3660
  /* Prepare for the extend/shift.  */
3661
294k
  if (print_extend_p)
3662
206k
    {
3663
206k
      if (print_amount_p)
3664
141k
  snprintf (tb, sizeof (tb), ", %s %s",
3665
141k
      style_sub_mnem (styler, shift_name),
3666
141k
      style_imm (styler, "#%" PRIi64,
3667
  /* PR 21096: The %100 is to silence a warning about possible truncation.  */
3668
141k
           (opnd->shifter.amount % 100)));
3669
64.9k
      else
3670
64.9k
  snprintf (tb, sizeof (tb), ", %s",
3671
64.9k
      style_sub_mnem (styler, shift_name));
3672
206k
    }
3673
88.4k
  else
3674
88.4k
    tb[0] = '\0';
3675
3676
294k
  snprintf (buf, size, "[%s, %s%s]", style_reg (styler, base),
3677
294k
      style_reg (styler, offset), tb);
3678
294k
}
3679
3680
/* Print ZA tiles from imm8 in ZERO instruction.
3681
3682
   The preferred disassembly of this instruction uses the shortest list of tile
3683
   names that represent the encoded immediate mask.
3684
3685
   For example:
3686
    * An all-ones immediate is disassembled as {ZA}.
3687
    * An all-zeros immediate is disassembled as an empty list { }.
3688
*/
3689
static void
3690
print_sme_za_list (char *buf, size_t size, int mask,
3691
       struct aarch64_styler *styler)
3692
212
{
3693
212
  const char* zan[] = { "za",    "za0.h", "za1.h", "za0.s",
3694
212
                        "za1.s", "za2.s", "za3.s", "za0.d",
3695
212
                        "za1.d", "za2.d", "za3.d", "za4.d",
3696
212
                        "za5.d", "za6.d", "za7.d", " " };
3697
212
  const int zan_v[] = { 0xff, 0x55, 0xaa, 0x11,
3698
212
                        0x22, 0x44, 0x88, 0x01,
3699
212
                        0x02, 0x04, 0x08, 0x10,
3700
212
                        0x20, 0x40, 0x80, 0x00 };
3701
212
  int i, k;
3702
212
  const int ZAN_SIZE = sizeof(zan) / sizeof(zan[0]);
3703
3704
212
  k = snprintf (buf, size, "{");
3705
2.21k
  for (i = 0; i < ZAN_SIZE; i++)
3706
2.21k
    {
3707
2.21k
      if ((mask & zan_v[i]) == zan_v[i])
3708
791
        {
3709
791
          mask &= ~zan_v[i];
3710
791
          if (k > 1)
3711
586
      k += snprintf (buf + k, size - k, ", ");
3712
3713
791
    k += snprintf (buf + k, size - k, "%s", style_reg (styler, zan[i]));
3714
791
        }
3715
2.21k
      if (mask == 0)
3716
212
        break;
3717
2.21k
    }
3718
212
  snprintf (buf + k, size - k, "}");
3719
212
}
3720
3721
/* Generate the string representation of the operand OPNDS[IDX] for OPCODE
3722
   in *BUF.  The caller should pass in the maximum size of *BUF in SIZE.
3723
   PC, PCREL_P and ADDRESS are used to pass in and return information about
3724
   the PC-relative address calculation, where the PC value is passed in
3725
   PC.  If the operand is pc-relative related, *PCREL_P (if PCREL_P non-NULL)
3726
   will return 1 and *ADDRESS (if ADDRESS non-NULL) will return the
3727
   calculated address; otherwise, *PCREL_P (if PCREL_P non-NULL) returns 0.
3728
3729
   The function serves both the disassembler and the assembler diagnostics
3730
   issuer, which is the reason why it lives in this file.  */
3731
3732
void
3733
aarch64_print_operand (char *buf, size_t size, bfd_vma pc,
3734
           const aarch64_opcode *opcode,
3735
           const aarch64_opnd_info *opnds, int idx, int *pcrel_p,
3736
           bfd_vma *address, char** notes,
3737
           char *comment, size_t comment_size,
3738
           aarch64_feature_set features,
3739
           struct aarch64_styler *styler)
3740
14.9M
{
3741
14.9M
  unsigned int i, num_conds;
3742
14.9M
  const char *name = NULL;
3743
14.9M
  const aarch64_opnd_info *opnd = opnds + idx;
3744
14.9M
  enum aarch64_modifier_kind kind;
3745
14.9M
  uint64_t addr, enum_value;
3746
3747
14.9M
  if (comment != NULL)
3748
14.9M
    {
3749
14.9M
      assert (comment_size > 0);
3750
14.9M
      comment[0] = '\0';
3751
14.9M
    }
3752
0
  else
3753
0
    assert (comment_size == 0);
3754
3755
14.9M
  buf[0] = '\0';
3756
14.9M
  if (pcrel_p)
3757
14.9M
    *pcrel_p = 0;
3758
3759
14.9M
  switch (opnd->type)
3760
14.9M
    {
3761
1.33M
    case AARCH64_OPND_Rd:
3762
2.03M
    case AARCH64_OPND_Rn:
3763
2.11M
    case AARCH64_OPND_Rm:
3764
3.42M
    case AARCH64_OPND_Rt:
3765
3.70M
    case AARCH64_OPND_Rt2:
3766
3.83M
    case AARCH64_OPND_Rs:
3767
3.86M
    case AARCH64_OPND_Ra:
3768
3.86M
    case AARCH64_OPND_Rt_LS64:
3769
3.86M
    case AARCH64_OPND_Rt_SYS:
3770
3.86M
    case AARCH64_OPND_PAIRREG:
3771
3.86M
    case AARCH64_OPND_SVE_Rm:
3772
      /* The optional-ness of <Xt> in e.g. IC <ic_op>{, <Xt>} is determined by
3773
   the <ic_op>, therefore we use opnd->present to override the
3774
   generic optional-ness information.  */
3775
3.86M
      if (opnd->type == AARCH64_OPND_Rt_SYS)
3776
377
  {
3777
377
    if (!opnd->present)
3778
338
      break;
3779
377
  }
3780
      /* Omit the operand, e.g. RET.  */
3781
3.86M
      else if (optional_operand_p (opcode, idx)
3782
3.86M
         && (opnd->reg.regno
3783
5.51k
       == get_optional_operand_default_value (opcode)))
3784
3.68k
  break;
3785
3.86M
      assert (opnd->qualifier == AARCH64_OPND_QLF_W
3786
3.86M
        || opnd->qualifier == AARCH64_OPND_QLF_X);
3787
3.86M
      snprintf (buf, size, "%s",
3788
3.86M
    style_reg (styler, get_int_reg_name (opnd->reg.regno,
3789
3.86M
                 opnd->qualifier, 0)));
3790
3.86M
      break;
3791
3792
272k
    case AARCH64_OPND_Rd_SP:
3793
570k
    case AARCH64_OPND_Rn_SP:
3794
581k
    case AARCH64_OPND_Rt_SP:
3795
582k
    case AARCH64_OPND_SVE_Rn_SP:
3796
583k
    case AARCH64_OPND_Rm_SP:
3797
583k
      assert (opnd->qualifier == AARCH64_OPND_QLF_W
3798
583k
        || opnd->qualifier == AARCH64_OPND_QLF_WSP
3799
583k
        || opnd->qualifier == AARCH64_OPND_QLF_X
3800
583k
        || opnd->qualifier == AARCH64_OPND_QLF_SP);
3801
583k
      snprintf (buf, size, "%s",
3802
583k
    style_reg (styler, get_int_reg_name (opnd->reg.regno,
3803
583k
                 opnd->qualifier, 1)));
3804
583k
      break;
3805
3806
38.0k
    case AARCH64_OPND_Rm_EXT:
3807
38.0k
      kind = opnd->shifter.kind;
3808
38.0k
      assert (idx == 1 || idx == 2);
3809
38.0k
      if ((aarch64_stack_pointer_p (opnds)
3810
38.0k
     || (idx == 2 && aarch64_stack_pointer_p (opnds + 1)))
3811
38.0k
    && ((opnd->qualifier == AARCH64_OPND_QLF_W
3812
1.94k
         && opnds[0].qualifier == AARCH64_OPND_QLF_W
3813
1.94k
         && kind == AARCH64_MOD_UXTW)
3814
1.94k
        || (opnd->qualifier == AARCH64_OPND_QLF_X
3815
1.69k
      && kind == AARCH64_MOD_UXTX)))
3816
408
  {
3817
    /* 'LSL' is the preferred form in this case.  */
3818
408
    kind = AARCH64_MOD_LSL;
3819
408
    if (opnd->shifter.amount == 0)
3820
254
      {
3821
        /* Shifter omitted.  */
3822
254
        snprintf (buf, size, "%s",
3823
254
      style_reg (styler,
3824
254
           get_int_reg_name (opnd->reg.regno,
3825
254
                 opnd->qualifier, 0)));
3826
254
        break;
3827
254
      }
3828
408
  }
3829
37.7k
      if (opnd->shifter.amount)
3830
31.4k
  snprintf (buf, size, "%s, %s %s",
3831
31.4k
      style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)),
3832
31.4k
      style_sub_mnem (styler, aarch64_operand_modifiers[kind].name),
3833
31.4k
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
3834
6.26k
      else
3835
6.26k
  snprintf (buf, size, "%s, %s",
3836
6.26k
      style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)),
3837
6.26k
      style_sub_mnem (styler, aarch64_operand_modifiers[kind].name));
3838
37.7k
      break;
3839
3840
419k
    case AARCH64_OPND_Rm_SFT:
3841
419k
      assert (opnd->qualifier == AARCH64_OPND_QLF_W
3842
419k
        || opnd->qualifier == AARCH64_OPND_QLF_X);
3843
419k
      if (opnd->shifter.amount == 0 && opnd->shifter.kind == AARCH64_MOD_LSL)
3844
59.5k
  snprintf (buf, size, "%s",
3845
59.5k
      style_reg (styler, get_int_reg_name (opnd->reg.regno,
3846
59.5k
                   opnd->qualifier, 0)));
3847
359k
      else
3848
359k
  snprintf (buf, size, "%s, %s %s",
3849
359k
      style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)),
3850
359k
      style_sub_mnem (styler, aarch64_operand_modifiers[opnd->shifter.kind].name),
3851
359k
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
3852
419k
      break;
3853
3854
42.5k
    case AARCH64_OPND_Fd:
3855
89.7k
    case AARCH64_OPND_Fn:
3856
132k
    case AARCH64_OPND_Fm:
3857
164k
    case AARCH64_OPND_Fa:
3858
737k
    case AARCH64_OPND_Ft:
3859
1.03M
    case AARCH64_OPND_Ft2:
3860
1.05M
    case AARCH64_OPND_Sd:
3861
1.08M
    case AARCH64_OPND_Sn:
3862
1.08M
    case AARCH64_OPND_Sm:
3863
1.08M
    case AARCH64_OPND_SVE_VZn:
3864
1.09M
    case AARCH64_OPND_SVE_Vd:
3865
1.09M
    case AARCH64_OPND_SVE_Vm:
3866
1.09M
    case AARCH64_OPND_SVE_Vn:
3867
1.09M
      snprintf (buf, size, "%s",
3868
1.09M
    style_reg (styler, "%s%d",
3869
1.09M
         aarch64_get_qualifier_name (opnd->qualifier),
3870
1.09M
         opnd->reg.regno));
3871
1.09M
      break;
3872
3873
12.9k
    case AARCH64_OPND_Va:
3874
237k
    case AARCH64_OPND_Vd:
3875
437k
    case AARCH64_OPND_Vn:
3876
586k
    case AARCH64_OPND_Vm:
3877
586k
      snprintf (buf, size, "%s",
3878
586k
    style_reg (styler, "v%d.%s", opnd->reg.regno,
3879
586k
         aarch64_get_qualifier_name (opnd->qualifier)));
3880
586k
      break;
3881
3882
2.39k
    case AARCH64_OPND_Ed:
3883
7.71k
    case AARCH64_OPND_En:
3884
22.8k
    case AARCH64_OPND_Em:
3885
63.9k
    case AARCH64_OPND_Em16:
3886
63.9k
    case AARCH64_OPND_SM3_IMM2:
3887
63.9k
      snprintf (buf, size, "%s[%s]",
3888
63.9k
    style_reg (styler, "v%d.%s", opnd->reglane.regno,
3889
63.9k
         aarch64_get_qualifier_name (opnd->qualifier)),
3890
63.9k
    style_imm (styler, "%" PRIi64, opnd->reglane.index));
3891
63.9k
      break;
3892
3893
61
    case AARCH64_OPND_VdD1:
3894
324
    case AARCH64_OPND_VnD1:
3895
324
      snprintf (buf, size, "%s[%s]",
3896
324
    style_reg (styler, "v%d.d", opnd->reg.regno),
3897
324
    style_imm (styler, "1"));
3898
324
      break;
3899
3900
14.1k
    case AARCH64_OPND_LVn:
3901
31.1k
    case AARCH64_OPND_LVt:
3902
32.8k
    case AARCH64_OPND_LVt_AL:
3903
56.7k
    case AARCH64_OPND_LEt:
3904
56.7k
      print_register_list (buf, size, opnd, "v", styler);
3905
56.7k
      break;
3906
3907
96.2k
    case AARCH64_OPND_SVE_Pd:
3908
723k
    case AARCH64_OPND_SVE_Pg3:
3909
724k
    case AARCH64_OPND_SVE_Pg4_5:
3910
742k
    case AARCH64_OPND_SVE_Pg4_10:
3911
752k
    case AARCH64_OPND_SVE_Pg4_16:
3912
759k
    case AARCH64_OPND_SVE_Pm:
3913
766k
    case AARCH64_OPND_SVE_Pn:
3914
770k
    case AARCH64_OPND_SVE_Pt:
3915
824k
    case AARCH64_OPND_SME_Pm:
3916
824k
      if (opnd->qualifier == AARCH64_OPND_QLF_NIL)
3917
138k
  snprintf (buf, size, "%s",
3918
138k
      style_reg (styler, "p%d", opnd->reg.regno));
3919
686k
      else if (opnd->qualifier == AARCH64_OPND_QLF_P_Z
3920
686k
         || opnd->qualifier == AARCH64_OPND_QLF_P_M)
3921
577k
  snprintf (buf, size, "%s",
3922
577k
      style_reg (styler, "p%d/%s", opnd->reg.regno,
3923
577k
           aarch64_get_qualifier_name (opnd->qualifier)));
3924
108k
      else
3925
108k
  snprintf (buf, size, "%s",
3926
108k
      style_reg (styler, "p%d.%s", opnd->reg.regno,
3927
108k
           aarch64_get_qualifier_name (opnd->qualifier)));
3928
824k
      break;
3929
3930
0
    case AARCH64_OPND_SVE_PNd:
3931
0
    case AARCH64_OPND_SVE_PNg4_10:
3932
0
    case AARCH64_OPND_SVE_PNn:
3933
0
    case AARCH64_OPND_SVE_PNt:
3934
2.05k
    case AARCH64_OPND_SME_PNd3:
3935
29.5k
    case AARCH64_OPND_SME_PNg3:
3936
29.5k
    case AARCH64_OPND_SME_PNn:
3937
29.5k
      if (opnd->qualifier == AARCH64_OPND_QLF_NIL)
3938
11.8k
  snprintf (buf, size, "%s",
3939
11.8k
      style_reg (styler, "pn%d", opnd->reg.regno));
3940
17.7k
      else if (opnd->qualifier == AARCH64_OPND_QLF_P_Z
3941
17.7k
         || opnd->qualifier == AARCH64_OPND_QLF_P_M)
3942
15.6k
  snprintf (buf, size, "%s",
3943
15.6k
      style_reg (styler, "pn%d/%s", opnd->reg.regno,
3944
15.6k
           aarch64_get_qualifier_name (opnd->qualifier)));
3945
2.07k
      else
3946
2.07k
  snprintf (buf, size, "%s",
3947
2.07k
      style_reg (styler, "pn%d.%s", opnd->reg.regno,
3948
2.07k
           aarch64_get_qualifier_name (opnd->qualifier)));
3949
29.5k
      break;
3950
3951
312
    case AARCH64_OPND_SME_Pdx2:
3952
319
    case AARCH64_OPND_SME_PdxN:
3953
319
      print_register_list (buf, size, opnd, "p", styler);
3954
319
      break;
3955
3956
7
    case AARCH64_OPND_SME_PNn3_INDEX1:
3957
38
    case AARCH64_OPND_SME_PNn3_INDEX2:
3958
38
      snprintf (buf, size, "%s[%s]",
3959
38
    style_reg (styler, "pn%d", opnd->reglane.regno),
3960
38
    style_imm (styler, "%" PRIi64, opnd->reglane.index));
3961
38
      break;
3962
3963
10.8k
    case AARCH64_OPND_SVE_Za_5:
3964
19.7k
    case AARCH64_OPND_SVE_Za_16:
3965
378k
    case AARCH64_OPND_SVE_Zd:
3966
418k
    case AARCH64_OPND_SVE_Zm_5:
3967
673k
    case AARCH64_OPND_SVE_Zm_16:
3968
1.02M
    case AARCH64_OPND_SVE_Zn:
3969
1.03M
    case AARCH64_OPND_SVE_Zt:
3970
1.03M
    case AARCH64_OPND_SME_Zm:
3971
1.03M
      if (opnd->qualifier == AARCH64_OPND_QLF_NIL)
3972
4.25k
  snprintf (buf, size, "%s", style_reg (styler, "z%d", opnd->reg.regno));
3973
1.03M
      else
3974
1.03M
  snprintf (buf, size, "%s",
3975
1.03M
      style_reg (styler, "z%d.%s", opnd->reg.regno,
3976
1.03M
           aarch64_get_qualifier_name (opnd->qualifier)));
3977
1.03M
      break;
3978
3979
6.98k
    case AARCH64_OPND_SVE_ZnxN:
3980
294k
    case AARCH64_OPND_SVE_ZtxN:
3981
309k
    case AARCH64_OPND_SME_Zdnx2:
3982
313k
    case AARCH64_OPND_SME_Zdnx4:
3983
314k
    case AARCH64_OPND_SME_Zmx2:
3984
315k
    case AARCH64_OPND_SME_Zmx4:
3985
320k
    case AARCH64_OPND_SME_Znx2:
3986
322k
    case AARCH64_OPND_SME_Znx4:
3987
330k
    case AARCH64_OPND_SME_Ztx2_STRIDED:
3988
332k
    case AARCH64_OPND_SME_Ztx4_STRIDED:
3989
332k
      print_register_list (buf, size, opnd, "z", styler);
3990
332k
      break;
3991
3992
4.24k
    case AARCH64_OPND_SVE_Zm3_INDEX:
3993
7.89k
    case AARCH64_OPND_SVE_Zm3_22_INDEX:
3994
8.14k
    case AARCH64_OPND_SVE_Zm3_19_INDEX:
3995
15.6k
    case AARCH64_OPND_SVE_Zm3_11_INDEX:
3996
19.5k
    case AARCH64_OPND_SVE_Zm4_11_INDEX:
3997
24.6k
    case AARCH64_OPND_SVE_Zm4_INDEX:
3998
25.8k
    case AARCH64_OPND_SVE_Zn_INDEX:
3999
26.2k
    case AARCH64_OPND_SME_Zm_INDEX1:
4000
27.7k
    case AARCH64_OPND_SME_Zm_INDEX2:
4001
29.3k
    case AARCH64_OPND_SME_Zm_INDEX3_1:
4002
30.5k
    case AARCH64_OPND_SME_Zm_INDEX3_2:
4003
34.7k
    case AARCH64_OPND_SME_Zm_INDEX3_10:
4004
35.4k
    case AARCH64_OPND_SME_Zm_INDEX4_1:
4005
39.3k
    case AARCH64_OPND_SME_Zm_INDEX4_10:
4006
39.3k
    case AARCH64_OPND_SME_Zn_INDEX1_16:
4007
39.3k
    case AARCH64_OPND_SME_Zn_INDEX2_15:
4008
39.3k
    case AARCH64_OPND_SME_Zn_INDEX2_16:
4009
39.3k
    case AARCH64_OPND_SME_Zn_INDEX3_14:
4010
39.4k
    case AARCH64_OPND_SME_Zn_INDEX3_15:
4011
40.0k
    case AARCH64_OPND_SME_Zn_INDEX4_14:
4012
40.0k
      snprintf (buf, size, "%s[%s]",
4013
40.0k
    (opnd->qualifier == AARCH64_OPND_QLF_NIL
4014
40.0k
     ? style_reg (styler, "z%d", opnd->reglane.regno)
4015
40.0k
     : style_reg (styler, "z%d.%s", opnd->reglane.regno,
4016
39.3k
            aarch64_get_qualifier_name (opnd->qualifier))),
4017
40.0k
    style_imm (styler, "%" PRIi64, opnd->reglane.index));
4018
40.0k
      break;
4019
4020
38.7k
    case AARCH64_OPND_SME_ZAda_2b:
4021
54.1k
    case AARCH64_OPND_SME_ZAda_3b:
4022
54.1k
      snprintf (buf, size, "%s",
4023
54.1k
    style_reg (styler, "za%d.%s", opnd->reg.regno,
4024
54.1k
         aarch64_get_qualifier_name (opnd->qualifier)));
4025
54.1k
      break;
4026
4027
799
    case AARCH64_OPND_SME_ZA_HV_idx_src:
4028
972
    case AARCH64_OPND_SME_ZA_HV_idx_srcxN:
4029
11.3k
    case AARCH64_OPND_SME_ZA_HV_idx_dest:
4030
11.6k
    case AARCH64_OPND_SME_ZA_HV_idx_destxN:
4031
50.6k
    case AARCH64_OPND_SME_ZA_HV_idx_ldstr:
4032
50.6k
      snprintf (buf, size, "%s%s[%s, %s%s%s%s%s]%s",
4033
50.6k
    opnd->type == AARCH64_OPND_SME_ZA_HV_idx_ldstr ? "{" : "",
4034
50.6k
    style_reg (styler, "za%d%c.%s",
4035
50.6k
         opnd->indexed_za.regno,
4036
50.6k
         opnd->indexed_za.v == 1 ? 'v' : 'h',
4037
50.6k
         aarch64_get_qualifier_name (opnd->qualifier)),
4038
50.6k
    style_reg (styler, "w%d", opnd->indexed_za.index.regno),
4039
50.6k
    style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm),
4040
50.6k
    opnd->indexed_za.index.countm1 ? ":" : "",
4041
50.6k
    (opnd->indexed_za.index.countm1
4042
50.6k
     ? style_imm (styler, "%d",
4043
434
            opnd->indexed_za.index.imm
4044
434
            + opnd->indexed_za.index.countm1)
4045
50.6k
     : ""),
4046
50.6k
    opnd->indexed_za.group_size ? ", " : "",
4047
50.6k
    opnd->indexed_za.group_size == 2
4048
50.6k
    ? style_sub_mnem (styler, "vgx2")
4049
50.6k
    : opnd->indexed_za.group_size == 4
4050
50.6k
    ? style_sub_mnem (styler, "vgx4") : "",
4051
50.6k
    opnd->type == AARCH64_OPND_SME_ZA_HV_idx_ldstr ? "}" : "");
4052
50.6k
      break;
4053
4054
212
    case AARCH64_OPND_SME_list_of_64bit_tiles:
4055
212
      print_sme_za_list (buf, size, opnd->reg.regno, styler);
4056
212
      break;
4057
4058
3.57k
    case AARCH64_OPND_SME_ZA_array_off1x4:
4059
5.64k
    case AARCH64_OPND_SME_ZA_array_off2x2:
4060
11.2k
    case AARCH64_OPND_SME_ZA_array_off2x4:
4061
15.1k
    case AARCH64_OPND_SME_ZA_array_off3_0:
4062
15.1k
    case AARCH64_OPND_SME_ZA_array_off3_5:
4063
17.9k
    case AARCH64_OPND_SME_ZA_array_off3x2:
4064
19.3k
    case AARCH64_OPND_SME_ZA_array_off4:
4065
19.3k
      snprintf (buf, size, "%s[%s, %s%s%s%s%s]",
4066
19.3k
    style_reg (styler, "za%s%s",
4067
19.3k
         opnd->qualifier == AARCH64_OPND_QLF_NIL ? "" : ".",
4068
19.3k
         (opnd->qualifier == AARCH64_OPND_QLF_NIL
4069
19.3k
          ? ""
4070
19.3k
          : aarch64_get_qualifier_name (opnd->qualifier))),
4071
19.3k
    style_reg (styler, "w%d", opnd->indexed_za.index.regno),
4072
19.3k
    style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm),
4073
19.3k
    opnd->indexed_za.index.countm1 ? ":" : "",
4074
19.3k
    (opnd->indexed_za.index.countm1
4075
19.3k
     ? style_imm (styler, "%d",
4076
14.0k
            opnd->indexed_za.index.imm
4077
14.0k
            + opnd->indexed_za.index.countm1)
4078
19.3k
     : ""),
4079
19.3k
    opnd->indexed_za.group_size ? ", " : "",
4080
19.3k
    opnd->indexed_za.group_size == 2
4081
19.3k
    ? style_sub_mnem (styler, "vgx2")
4082
19.3k
    : opnd->indexed_za.group_size == 4
4083
12.8k
    ? style_sub_mnem (styler, "vgx4") : "");
4084
19.3k
      break;
4085
4086
256
    case AARCH64_OPND_SME_SM_ZA:
4087
256
      snprintf (buf, size, "%s",
4088
256
    style_reg (styler, opnd->reg.regno == 's' ? "sm" : "za"));
4089
256
      break;
4090
4091
1.64k
    case AARCH64_OPND_SME_PnT_Wm_imm:
4092
1.64k
      snprintf (buf, size, "%s[%s, %s]",
4093
1.64k
    style_reg (styler, "p%d.%s", opnd->indexed_za.regno,
4094
1.64k
         aarch64_get_qualifier_name (opnd->qualifier)),
4095
1.64k
    style_reg (styler, "w%d", opnd->indexed_za.index.regno),
4096
1.64k
    style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm));
4097
1.64k
      break;
4098
4099
21
    case AARCH64_OPND_SME_VLxN_10:
4100
2.07k
    case AARCH64_OPND_SME_VLxN_13:
4101
2.07k
      enum_value = opnd->imm.value;
4102
2.07k
      assert (enum_value < ARRAY_SIZE (aarch64_sme_vlxn_array));
4103
2.07k
      snprintf (buf, size, "%s",
4104
2.07k
    style_sub_mnem (styler, aarch64_sme_vlxn_array[enum_value]));
4105
2.07k
      break;
4106
4107
2.87k
    case AARCH64_OPND_CRn:
4108
5.74k
    case AARCH64_OPND_CRm:
4109
5.74k
      snprintf (buf, size, "%s",
4110
5.74k
    style_reg (styler, "C%" PRIi64, opnd->imm.value));
4111
5.74k
      break;
4112
4113
8.14k
    case AARCH64_OPND_IDX:
4114
8.83k
    case AARCH64_OPND_MASK:
4115
55.0k
    case AARCH64_OPND_IMM:
4116
55.7k
    case AARCH64_OPND_IMM_2:
4117
95.3k
    case AARCH64_OPND_WIDTH:
4118
98.2k
    case AARCH64_OPND_UIMM3_OP1:
4119
101k
    case AARCH64_OPND_UIMM3_OP2:
4120
302k
    case AARCH64_OPND_BIT_NUM:
4121
312k
    case AARCH64_OPND_IMM_VLSL:
4122
325k
    case AARCH64_OPND_IMM_VLSR:
4123
325k
    case AARCH64_OPND_SHLL_IMM:
4124
325k
    case AARCH64_OPND_IMM0:
4125
325k
    case AARCH64_OPND_IMMR:
4126
330k
    case AARCH64_OPND_IMMS:
4127
1.73M
    case AARCH64_OPND_UNDEFINED:
4128
1.74M
    case AARCH64_OPND_FBITS:
4129
1.74M
    case AARCH64_OPND_TME_UIMM16:
4130
1.75M
    case AARCH64_OPND_SIMM5:
4131
1.75M
    case AARCH64_OPND_SME_SHRIMM4:
4132
1.75M
    case AARCH64_OPND_SME_SHRIMM5:
4133
1.75M
    case AARCH64_OPND_SVE_SHLIMM_PRED:
4134
1.75M
    case AARCH64_OPND_SVE_SHLIMM_UNPRED:
4135
1.75M
    case AARCH64_OPND_SVE_SHLIMM_UNPRED_22:
4136
1.75M
    case AARCH64_OPND_SVE_SHRIMM_PRED:
4137
1.76M
    case AARCH64_OPND_SVE_SHRIMM_UNPRED:
4138
1.76M
    case AARCH64_OPND_SVE_SHRIMM_UNPRED_22:
4139
1.76M
    case AARCH64_OPND_SVE_SIMM5:
4140
1.76M
    case AARCH64_OPND_SVE_SIMM5B:
4141
1.77M
    case AARCH64_OPND_SVE_SIMM6:
4142
1.77M
    case AARCH64_OPND_SVE_SIMM8:
4143
1.77M
    case AARCH64_OPND_SVE_UIMM3:
4144
1.79M
    case AARCH64_OPND_SVE_UIMM7:
4145
1.79M
    case AARCH64_OPND_SVE_UIMM8:
4146
1.80M
    case AARCH64_OPND_SVE_UIMM8_53:
4147
1.80M
    case AARCH64_OPND_IMM_ROT1:
4148
1.82M
    case AARCH64_OPND_IMM_ROT2:
4149
1.82M
    case AARCH64_OPND_IMM_ROT3:
4150
1.82M
    case AARCH64_OPND_SVE_IMM_ROT1:
4151
1.83M
    case AARCH64_OPND_SVE_IMM_ROT2:
4152
1.83M
    case AARCH64_OPND_SVE_IMM_ROT3:
4153
1.83M
    case AARCH64_OPND_CSSC_SIMM8:
4154
1.83M
    case AARCH64_OPND_CSSC_UIMM8:
4155
1.83M
      snprintf (buf, size, "%s",
4156
1.83M
    style_imm (styler, "#%" PRIi64, opnd->imm.value));
4157
1.83M
      break;
4158
4159
233
    case AARCH64_OPND_SVE_I1_HALF_ONE:
4160
260
    case AARCH64_OPND_SVE_I1_HALF_TWO:
4161
437
    case AARCH64_OPND_SVE_I1_ZERO_ONE:
4162
437
      {
4163
437
  single_conv_t c;
4164
437
  c.i = opnd->imm.value;
4165
437
  snprintf (buf, size, "%s", style_imm (styler, "#%.1f", c.f));
4166
437
  break;
4167
260
      }
4168
4169
82
    case AARCH64_OPND_SVE_PATTERN:
4170
82
      if (optional_operand_p (opcode, idx)
4171
82
    && opnd->imm.value == get_optional_operand_default_value (opcode))
4172
26
  break;
4173
56
      enum_value = opnd->imm.value;
4174
56
      assert (enum_value < ARRAY_SIZE (aarch64_sve_pattern_array));
4175
56
      if (aarch64_sve_pattern_array[enum_value])
4176
44
  snprintf (buf, size, "%s",
4177
44
      style_reg (styler, aarch64_sve_pattern_array[enum_value]));
4178
12
      else
4179
12
  snprintf (buf, size, "%s",
4180
12
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4181
56
      break;
4182
4183
7.35k
    case AARCH64_OPND_SVE_PATTERN_SCALED:
4184
7.35k
      if (optional_operand_p (opcode, idx)
4185
7.35k
    && !opnd->shifter.operator_present
4186
7.35k
    && opnd->imm.value == get_optional_operand_default_value (opcode))
4187
107
  break;
4188
7.24k
      enum_value = opnd->imm.value;
4189
7.24k
      assert (enum_value < ARRAY_SIZE (aarch64_sve_pattern_array));
4190
7.24k
      if (aarch64_sve_pattern_array[opnd->imm.value])
4191
4.65k
  snprintf (buf, size, "%s",
4192
4.65k
      style_reg (styler,
4193
4.65k
           aarch64_sve_pattern_array[opnd->imm.value]));
4194
2.59k
      else
4195
2.59k
  snprintf (buf, size, "%s",
4196
2.59k
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4197
7.24k
      if (opnd->shifter.operator_present)
4198
6.02k
  {
4199
6.02k
    size_t len = strlen (buf);
4200
6.02k
    const char *shift_name
4201
6.02k
      = aarch64_operand_modifiers[opnd->shifter.kind].name;
4202
6.02k
    snprintf (buf + len, size - len, ", %s %s",
4203
6.02k
        style_sub_mnem (styler, shift_name),
4204
6.02k
        style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
4205
6.02k
  }
4206
7.24k
      break;
4207
4208
24.0k
    case AARCH64_OPND_SVE_PRFOP:
4209
24.0k
      enum_value = opnd->imm.value;
4210
24.0k
      assert (enum_value < ARRAY_SIZE (aarch64_sve_prfop_array));
4211
24.0k
      if (aarch64_sve_prfop_array[enum_value])
4212
16.7k
  snprintf (buf, size, "%s",
4213
16.7k
      style_reg (styler, aarch64_sve_prfop_array[enum_value]));
4214
7.33k
      else
4215
7.33k
  snprintf (buf, size, "%s",
4216
7.33k
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4217
24.0k
      break;
4218
4219
75.4k
    case AARCH64_OPND_IMM_MOV:
4220
75.4k
      switch (aarch64_get_qualifier_esize (opnds[0].qualifier))
4221
75.4k
  {
4222
25.1k
  case 4: /* e.g. MOV Wd, #<imm32>.  */
4223
25.1k
      {
4224
25.1k
        int imm32 = opnd->imm.value;
4225
25.1k
        snprintf (buf, size, "%s",
4226
25.1k
      style_imm (styler, "#0x%-20x", imm32));
4227
25.1k
        snprintf (comment, comment_size, "#%d", imm32);
4228
25.1k
      }
4229
25.1k
    break;
4230
50.2k
  case 8: /* e.g. MOV Xd, #<imm64>.  */
4231
50.2k
    snprintf (buf, size, "%s", style_imm (styler, "#0x%-20" PRIx64,
4232
50.2k
            opnd->imm.value));
4233
50.2k
    snprintf (comment, comment_size, "#%" PRIi64, opnd->imm.value);
4234
50.2k
    break;
4235
0
  default:
4236
0
    snprintf (buf, size, "<invalid>");
4237
0
    break;
4238
75.4k
  }
4239
75.4k
      break;
4240
4241
75.4k
    case AARCH64_OPND_FPIMM0:
4242
419
      snprintf (buf, size, "%s", style_imm (styler, "#0.0"));
4243
419
      break;
4244
4245
158k
    case AARCH64_OPND_LIMM:
4246
412k
    case AARCH64_OPND_AIMM:
4247
449k
    case AARCH64_OPND_HALF:
4248
449k
    case AARCH64_OPND_SVE_INV_LIMM:
4249
469k
    case AARCH64_OPND_SVE_LIMM:
4250
472k
    case AARCH64_OPND_SVE_LIMM_MOV:
4251
472k
      if (opnd->shifter.amount)
4252
121k
  snprintf (buf, size, "%s, %s %s",
4253
121k
      style_imm (styler, "#0x%" PRIx64, opnd->imm.value),
4254
121k
      style_sub_mnem (styler, "lsl"),
4255
121k
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
4256
351k
      else
4257
351k
  snprintf (buf, size, "%s",
4258
351k
      style_imm (styler, "#0x%" PRIx64, opnd->imm.value));
4259
472k
      break;
4260
4261
164
    case AARCH64_OPND_SIMD_IMM:
4262
2.81k
    case AARCH64_OPND_SIMD_IMM_SFT:
4263
2.81k
      if ((! opnd->shifter.amount && opnd->shifter.kind == AARCH64_MOD_LSL)
4264
2.81k
    || opnd->shifter.kind == AARCH64_MOD_NONE)
4265
1.29k
  snprintf (buf, size, "%s",
4266
1.29k
      style_imm (styler, "#0x%" PRIx64, opnd->imm.value));
4267
1.52k
      else
4268
1.52k
  snprintf (buf, size, "%s, %s %s",
4269
1.52k
      style_imm (styler, "#0x%" PRIx64, opnd->imm.value),
4270
1.52k
      style_sub_mnem (styler, aarch64_operand_modifiers[opnd->shifter.kind].name),
4271
1.52k
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
4272
2.81k
      break;
4273
4274
2.03k
    case AARCH64_OPND_SVE_AIMM:
4275
11.5k
    case AARCH64_OPND_SVE_ASIMM:
4276
11.5k
      if (opnd->shifter.amount)
4277
244
  snprintf (buf, size, "%s, %s %s",
4278
244
      style_imm (styler, "#%" PRIi64, opnd->imm.value),
4279
244
      style_sub_mnem (styler, "lsl"),
4280
244
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
4281
11.3k
      else
4282
11.3k
  snprintf (buf, size, "%s",
4283
11.3k
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4284
11.5k
      break;
4285
4286
317
    case AARCH64_OPND_FPIMM:
4287
2.27k
    case AARCH64_OPND_SIMD_FPIMM:
4288
3.37k
    case AARCH64_OPND_SVE_FPIMM8:
4289
3.37k
      switch (aarch64_get_qualifier_esize (opnds[0].qualifier))
4290
3.37k
  {
4291
1.75k
  case 2: /* e.g. FMOV <Hd>, #<imm>.  */
4292
1.75k
      {
4293
1.75k
        half_conv_t c;
4294
1.75k
        c.i = expand_fp_imm (2, opnd->imm.value);
4295
1.75k
        snprintf (buf, size, "%s", style_imm (styler, "#%.18e", c.f));
4296
1.75k
      }
4297
1.75k
    break;
4298
907
  case 4: /* e.g. FMOV <Vd>.4S, #<imm>.  */
4299
907
      {
4300
907
        single_conv_t c;
4301
907
        c.i = expand_fp_imm (4, opnd->imm.value);
4302
907
        snprintf (buf, size, "%s", style_imm (styler, "#%.18e", c.f));
4303
907
      }
4304
907
    break;
4305
710
  case 8: /* e.g. FMOV <Sd>, #<imm>.  */
4306
710
      {
4307
710
        double_conv_t c;
4308
710
        c.i = expand_fp_imm (8, opnd->imm.value);
4309
710
        snprintf (buf, size, "%s", style_imm (styler, "#%.18e", c.d));
4310
710
      }
4311
710
    break;
4312
0
  default:
4313
0
    snprintf (buf, size, "<invalid>");
4314
0
    break;
4315
3.37k
  }
4316
3.37k
      break;
4317
4318
3.37k
    case AARCH64_OPND_CCMP_IMM:
4319
10.8k
    case AARCH64_OPND_NZCV:
4320
11.7k
    case AARCH64_OPND_EXCEPTION:
4321
11.8k
    case AARCH64_OPND_UIMM4:
4322
15.3k
    case AARCH64_OPND_UIMM4_ADDG:
4323
15.3k
    case AARCH64_OPND_UIMM7:
4324
18.8k
    case AARCH64_OPND_UIMM10:
4325
18.8k
      if (optional_operand_p (opcode, idx)
4326
18.8k
    && (opnd->imm.value ==
4327
306
        (int64_t) get_optional_operand_default_value (opcode)))
4328
  /* Omit the operand, e.g. DCPS1.  */
4329
33
  break;
4330
18.7k
      snprintf (buf, size, "%s",
4331
18.7k
    style_imm (styler, "#0x%x", (unsigned int) opnd->imm.value));
4332
18.7k
      break;
4333
4334
24.7k
    case AARCH64_OPND_COND:
4335
26.0k
    case AARCH64_OPND_COND1:
4336
26.0k
      snprintf (buf, size, "%s",
4337
26.0k
    style_sub_mnem (styler, opnd->cond->names[0]));
4338
26.0k
      num_conds = ARRAY_SIZE (opnd->cond->names);
4339
49.1k
      for (i = 1; i < num_conds && opnd->cond->names[i]; ++i)
4340
23.1k
  {
4341
23.1k
    size_t len = comment != NULL ? strlen (comment) : 0;
4342
23.1k
    if (i == 1)
4343
17.8k
      snprintf (comment + len, comment_size - len, "%s = %s",
4344
17.8k
          opnd->cond->names[0], opnd->cond->names[i]);
4345
5.24k
    else
4346
5.24k
      snprintf (comment + len, comment_size - len, ", %s",
4347
5.24k
          opnd->cond->names[i]);
4348
23.1k
  }
4349
26.0k
      break;
4350
4351
212k
    case AARCH64_OPND_ADDR_ADRP:
4352
212k
      addr = ((pc + AARCH64_PCREL_OFFSET) & ~(uint64_t)0xfff)
4353
212k
  + opnd->imm.value;
4354
212k
      if (pcrel_p)
4355
212k
  *pcrel_p = 1;
4356
212k
      if (address)
4357
212k
  *address = addr;
4358
      /* This is not necessary during the disassembling, as print_address_func
4359
   in the disassemble_info will take care of the printing.  But some
4360
   other callers may be still interested in getting the string in *STR,
4361
   so here we do snprintf regardless.  */
4362
212k
      snprintf (buf, size, "%s", style_addr (styler, "#0x%" PRIx64 , addr));
4363
212k
      break;
4364
4365
201k
    case AARCH64_OPND_ADDR_PCREL14:
4366
709k
    case AARCH64_OPND_ADDR_PCREL19:
4367
1.00M
    case AARCH64_OPND_ADDR_PCREL21:
4368
1.32M
    case AARCH64_OPND_ADDR_PCREL26:
4369
1.32M
      addr = pc + AARCH64_PCREL_OFFSET + opnd->imm.value;
4370
1.32M
      if (pcrel_p)
4371
1.32M
  *pcrel_p = 1;
4372
1.32M
      if (address)
4373
1.32M
  *address = addr;
4374
      /* This is not necessary during the disassembling, as print_address_func
4375
   in the disassemble_info will take care of the printing.  But some
4376
   other callers may be still interested in getting the string in *STR,
4377
   so here we do snprintf regardless.  */
4378
1.32M
      snprintf (buf, size, "%s", style_addr (styler, "#0x%" PRIx64, addr));
4379
1.32M
      break;
4380
4381
209k
    case AARCH64_OPND_ADDR_SIMPLE:
4382
224k
    case AARCH64_OPND_SIMD_ADDR_SIMPLE:
4383
252k
    case AARCH64_OPND_SIMD_ADDR_POST:
4384
252k
      name = get_64bit_int_reg_name (opnd->addr.base_regno, 1);
4385
252k
      if (opnd->type == AARCH64_OPND_SIMD_ADDR_POST)
4386
27.9k
  {
4387
27.9k
    if (opnd->addr.offset.is_reg)
4388
26.8k
      snprintf (buf, size, "[%s], %s",
4389
26.8k
          style_reg (styler, name),
4390
26.8k
          style_reg (styler, "x%d", opnd->addr.offset.regno));
4391
1.12k
    else
4392
1.12k
      snprintf (buf, size, "[%s], %s",
4393
1.12k
          style_reg (styler, name),
4394
1.12k
          style_imm (styler, "#%d", opnd->addr.offset.imm));
4395
27.9k
  }
4396
224k
      else
4397
224k
  snprintf (buf, size, "[%s]", style_reg (styler, name));
4398
252k
      break;
4399
4400
28.1k
    case AARCH64_OPND_ADDR_REGOFF:
4401
28.1k
    case AARCH64_OPND_SVE_ADDR_R:
4402
50.8k
    case AARCH64_OPND_SVE_ADDR_RR:
4403
63.2k
    case AARCH64_OPND_SVE_ADDR_RR_LSL1:
4404
72.5k
    case AARCH64_OPND_SVE_ADDR_RR_LSL2:
4405
89.8k
    case AARCH64_OPND_SVE_ADDR_RR_LSL3:
4406
98.5k
    case AARCH64_OPND_SVE_ADDR_RR_LSL4:
4407
113k
    case AARCH64_OPND_SVE_ADDR_RX:
4408
125k
    case AARCH64_OPND_SVE_ADDR_RX_LSL1:
4409
138k
    case AARCH64_OPND_SVE_ADDR_RX_LSL2:
4410
146k
    case AARCH64_OPND_SVE_ADDR_RX_LSL3:
4411
146k
      print_register_offset_address
4412
146k
  (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1),
4413
146k
   get_offset_int_reg_name (opnd), styler);
4414
146k
      break;
4415
4416
18.1k
    case AARCH64_OPND_SVE_ADDR_ZX:
4417
18.1k
      print_register_offset_address
4418
18.1k
  (buf, size, opnd,
4419
18.1k
   get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier),
4420
18.1k
   get_64bit_int_reg_name (opnd->addr.offset.regno, 0), styler);
4421
18.1k
      break;
4422
4423
27.1k
    case AARCH64_OPND_SVE_ADDR_RZ:
4424
30.4k
    case AARCH64_OPND_SVE_ADDR_RZ_LSL1:
4425
33.1k
    case AARCH64_OPND_SVE_ADDR_RZ_LSL2:
4426
35.3k
    case AARCH64_OPND_SVE_ADDR_RZ_LSL3:
4427
43.6k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW_14:
4428
94.0k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW_22:
4429
95.6k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW1_14:
4430
107k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW1_22:
4431
108k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW2_14:
4432
118k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW2_22:
4433
119k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW3_14:
4434
128k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW3_22:
4435
128k
      print_register_offset_address
4436
128k
  (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1),
4437
128k
   get_addr_sve_reg_name (opnd->addr.offset.regno, opnd->qualifier),
4438
128k
   styler);
4439
128k
      break;
4440
4441
528k
    case AARCH64_OPND_ADDR_SIMM7:
4442
671k
    case AARCH64_OPND_ADDR_SIMM9:
4443
671k
    case AARCH64_OPND_ADDR_SIMM9_2:
4444
686k
    case AARCH64_OPND_ADDR_SIMM10:
4445
713k
    case AARCH64_OPND_ADDR_SIMM11:
4446
725k
    case AARCH64_OPND_ADDR_SIMM13:
4447
740k
    case AARCH64_OPND_ADDR_OFFSET:
4448
742k
    case AARCH64_OPND_SME_ADDR_RI_U4xVL:
4449
743k
    case AARCH64_OPND_SVE_ADDR_RI_S4x16:
4450
745k
    case AARCH64_OPND_SVE_ADDR_RI_S4x32:
4451
794k
    case AARCH64_OPND_SVE_ADDR_RI_S4xVL:
4452
802k
    case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL:
4453
806k
    case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL:
4454
813k
    case AARCH64_OPND_SVE_ADDR_RI_S4x4xVL:
4455
816k
    case AARCH64_OPND_SVE_ADDR_RI_S6xVL:
4456
823k
    case AARCH64_OPND_SVE_ADDR_RI_S9xVL:
4457
832k
    case AARCH64_OPND_SVE_ADDR_RI_U6:
4458
837k
    case AARCH64_OPND_SVE_ADDR_RI_U6x2:
4459
842k
    case AARCH64_OPND_SVE_ADDR_RI_U6x4:
4460
843k
    case AARCH64_OPND_SVE_ADDR_RI_U6x8:
4461
843k
      print_immediate_offset_address
4462
843k
  (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1),
4463
843k
   styler);
4464
843k
      break;
4465
4466
5.92k
    case AARCH64_OPND_SVE_ADDR_ZI_U5:
4467
12.4k
    case AARCH64_OPND_SVE_ADDR_ZI_U5x2:
4468
16.4k
    case AARCH64_OPND_SVE_ADDR_ZI_U5x4:
4469
18.6k
    case AARCH64_OPND_SVE_ADDR_ZI_U5x8:
4470
18.6k
      print_immediate_offset_address
4471
18.6k
  (buf, size, opnd,
4472
18.6k
   get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier),
4473
18.6k
   styler);
4474
18.6k
      break;
4475
4476
814
    case AARCH64_OPND_SVE_ADDR_ZZ_LSL:
4477
1.27k
    case AARCH64_OPND_SVE_ADDR_ZZ_SXTW:
4478
1.82k
    case AARCH64_OPND_SVE_ADDR_ZZ_UXTW:
4479
1.82k
      print_register_offset_address
4480
1.82k
  (buf, size, opnd,
4481
1.82k
   get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier),
4482
1.82k
   get_addr_sve_reg_name (opnd->addr.offset.regno, opnd->qualifier),
4483
1.82k
   styler);
4484
1.82k
      break;
4485
4486
309k
    case AARCH64_OPND_ADDR_UIMM12:
4487
309k
      name = get_64bit_int_reg_name (opnd->addr.base_regno, 1);
4488
309k
      if (opnd->addr.offset.imm)
4489
292k
  snprintf (buf, size, "[%s, %s]",
4490
292k
      style_reg (styler, name),
4491
292k
      style_imm (styler, "#%d", opnd->addr.offset.imm));
4492
16.1k
      else
4493
16.1k
  snprintf (buf, size, "[%s]", style_reg (styler, name));
4494
309k
      break;
4495
4496
8.72k
    case AARCH64_OPND_SYSREG:
4497
8.76M
      for (i = 0; aarch64_sys_regs[i].name; ++i)
4498
8.75M
  {
4499
8.75M
    const aarch64_sys_reg *sr = aarch64_sys_regs + i;
4500
4501
8.75M
    bool exact_match
4502
8.75M
      = (!(sr->flags & (F_REG_READ | F_REG_WRITE))
4503
8.75M
      || (sr->flags & opnd->sysreg.flags) == opnd->sysreg.flags)
4504
8.75M
      && AARCH64_CPU_HAS_FEATURE (features, sr->features);
4505
4506
    /* Try and find an exact match, But if that fails, return the first
4507
       partial match that was found.  */
4508
8.75M
    if (aarch64_sys_regs[i].value == opnd->sysreg.value
4509
8.75M
        && ! aarch64_sys_reg_deprecated_p (aarch64_sys_regs[i].flags)
4510
8.75M
        && (name == NULL || exact_match))
4511
684
      {
4512
684
        name = aarch64_sys_regs[i].name;
4513
684
        if (exact_match)
4514
397
    {
4515
397
      if (notes)
4516
397
        *notes = NULL;
4517
397
      break;
4518
397
    }
4519
4520
        /* If we didn't match exactly, that means the presense of a flag
4521
     indicates what we didn't want for this instruction.  e.g. If
4522
     F_REG_READ is there, that means we were looking for a write
4523
     register.  See aarch64_ext_sysreg.  */
4524
287
        if (aarch64_sys_regs[i].flags & F_REG_WRITE)
4525
1
    *notes = _("reading from a write-only register");
4526
286
        else if (aarch64_sys_regs[i].flags & F_REG_READ)
4527
77
    *notes = _("writing to a read-only register");
4528
287
      }
4529
8.75M
  }
4530
4531
8.72k
      if (name)
4532
662
  snprintf (buf, size, "%s", style_reg (styler, name));
4533
8.06k
      else
4534
8.06k
  {
4535
    /* Implementation defined system register.  */
4536
8.06k
    unsigned int value = opnd->sysreg.value;
4537
8.06k
    snprintf (buf, size, "%s",
4538
8.06k
        style_reg (styler, "s%u_%u_c%u_c%u_%u",
4539
8.06k
             (value >> 14) & 0x3, (value >> 11) & 0x7,
4540
8.06k
             (value >> 7) & 0xf, (value >> 3) & 0xf,
4541
8.06k
             value & 0x7));
4542
8.06k
  }
4543
8.72k
      break;
4544
4545
113
    case AARCH64_OPND_PSTATEFIELD:
4546
425
      for (i = 0; aarch64_pstatefields[i].name; ++i)
4547
425
        if (aarch64_pstatefields[i].value == opnd->pstatefield)
4548
113
          {
4549
            /* PSTATEFIELD name is encoded partially in CRm[3:1] for SVCRSM,
4550
               SVCRZA and SVCRSMZA.  */
4551
113
            uint32_t flags = aarch64_pstatefields[i].flags;
4552
113
            if (flags & F_REG_IN_CRM
4553
113
                && (PSTATE_DECODE_CRM (opnd->sysreg.flags)
4554
0
                    != PSTATE_DECODE_CRM (flags)))
4555
0
              continue;
4556
113
            break;
4557
113
          }
4558
113
      assert (aarch64_pstatefields[i].name);
4559
113
      snprintf (buf, size, "%s",
4560
113
    style_reg (styler, aarch64_pstatefields[i].name));
4561
113
      break;
4562
4563
26
    case AARCH64_OPND_SYSREG_AT:
4564
69
    case AARCH64_OPND_SYSREG_DC:
4565
404
    case AARCH64_OPND_SYSREG_IC:
4566
446
    case AARCH64_OPND_SYSREG_TLBI:
4567
515
    case AARCH64_OPND_SYSREG_SR:
4568
515
      snprintf (buf, size, "%s", style_reg (styler, opnd->sysins_op->name));
4569
515
      break;
4570
4571
325
    case AARCH64_OPND_BARRIER:
4572
380
    case AARCH64_OPND_BARRIER_DSB_NXS:
4573
380
      {
4574
380
  if (opnd->barrier->name[0] == '#')
4575
321
    snprintf (buf, size, "%s", style_imm (styler, opnd->barrier->name));
4576
59
  else
4577
59
    snprintf (buf, size, "%s",
4578
59
        style_sub_mnem (styler, opnd->barrier->name));
4579
380
      }
4580
380
      break;
4581
4582
170
    case AARCH64_OPND_BARRIER_ISB:
4583
      /* Operand can be omitted, e.g. in DCPS1.  */
4584
170
      if (! optional_operand_p (opcode, idx)
4585
170
    || (opnd->barrier->value
4586
170
        != get_optional_operand_default_value (opcode)))
4587
28
  snprintf (buf, size, "%s",
4588
28
      style_imm (styler, "#0x%x", opnd->barrier->value));
4589
170
      break;
4590
4591
60.1k
    case AARCH64_OPND_PRFOP:
4592
60.1k
      if (opnd->prfop->name != NULL)
4593
31.3k
  snprintf (buf, size, "%s", style_sub_mnem (styler, opnd->prfop->name));
4594
28.8k
      else
4595
28.8k
  snprintf (buf, size, "%s", style_imm (styler, "#0x%02x",
4596
28.8k
                opnd->prfop->value));
4597
60.1k
      break;
4598
4599
158
    case AARCH64_OPND_RPRFMOP:
4600
158
      enum_value = opnd->imm.value;
4601
158
      if (enum_value < ARRAY_SIZE (aarch64_rprfmop_array)
4602
158
    && aarch64_rprfmop_array[enum_value])
4603
18
  snprintf (buf, size, "%s",
4604
18
      style_reg (styler, aarch64_rprfmop_array[enum_value]));
4605
140
      else
4606
140
  snprintf (buf, size, "%s",
4607
140
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4608
158
      break;
4609
4610
53
    case AARCH64_OPND_BARRIER_PSB:
4611
53
      snprintf (buf, size, "%s", style_sub_mnem (styler, "csync"));
4612
53
      break;
4613
4614
736
    case AARCH64_OPND_SME_ZT0:
4615
736
      snprintf (buf, size, "%s", style_reg (styler, "zt0"));
4616
736
      break;
4617
4618
0
    case AARCH64_OPND_SME_ZT0_INDEX:
4619
0
      snprintf (buf, size, "%s[%s]", style_reg (styler, "zt0"),
4620
0
    style_imm (styler, "%d", (int) opnd->imm.value));
4621
0
      break;
4622
4623
0
    case AARCH64_OPND_SME_ZT0_LIST:
4624
0
      snprintf (buf, size, "{%s}", style_reg (styler, "zt0"));
4625
0
      break;
4626
4627
327
    case AARCH64_OPND_BTI_TARGET:
4628
327
      if ((HINT_FLAG (opnd->hint_option->value) & HINT_OPD_F_NOPRINT) == 0)
4629
324
  snprintf (buf, size, "%s",
4630
324
      style_sub_mnem (styler, opnd->hint_option->name));
4631
327
      break;
4632
4633
7.49k
    case AARCH64_OPND_MOPS_ADDR_Rd:
4634
13.7k
    case AARCH64_OPND_MOPS_ADDR_Rs:
4635
13.7k
      snprintf (buf, size, "[%s]!",
4636
13.7k
    style_reg (styler,
4637
13.7k
         get_int_reg_name (opnd->reg.regno,
4638
13.7k
               AARCH64_OPND_QLF_X, 0)));
4639
13.7k
      break;
4640
4641
7.49k
    case AARCH64_OPND_MOPS_WB_Rn:
4642
7.49k
      snprintf (buf, size, "%s!",
4643
7.49k
    style_reg (styler, get_int_reg_name (opnd->reg.regno,
4644
7.49k
                 AARCH64_OPND_QLF_X, 0)));
4645
7.49k
      break;
4646
4647
0
    default:
4648
0
      snprintf (buf, size, "<invalid>");
4649
0
      break;
4650
14.9M
    }
4651
14.9M
}
4652

4653
#define CPENC(op0,op1,crn,crm,op2) \
4654
0
  ((((op0) << 19) | ((op1) << 16) | ((crn) << 12) | ((crm) << 8) | ((op2) << 5)) >> 5)
4655
  /* for 3.9.3 Instructions for Accessing Special Purpose Registers */
4656
#define CPEN_(op1,crm,op2) CPENC(3,(op1),4,(crm),(op2))
4657
  /* for 3.9.10 System Instructions */
4658
0
#define CPENS(op1,crn,crm,op2) CPENC(1,(op1),(crn),(crm),(op2))
4659
4660
#define C0  0
4661
#define C1  1
4662
#define C2  2
4663
#define C3  3
4664
#define C4  4
4665
#define C5  5
4666
#define C6  6
4667
#define C7  7
4668
#define C8  8
4669
#define C9  9
4670
#define C10 10
4671
#define C11 11
4672
#define C12 12
4673
#define C13 13
4674
#define C14 14
4675
#define C15 15
4676
4677
#define SYSREG(name, encoding, flags, features) \
4678
  { name, encoding, flags, features }
4679
4680
#define SR_CORE(n,e,f) SYSREG (n,e,f,0)
4681
4682
#define SR_FEAT(n,e,f,feat) \
4683
  SYSREG ((n), (e), (f) | F_ARCHEXT, AARCH64_FEATURE_##feat)
4684
4685
#define SR_FEAT2(n,e,f,fe1,fe2) \
4686
  SYSREG ((n), (e), (f) | F_ARCHEXT, \
4687
    AARCH64_FEATURE_##fe1 | AARCH64_FEATURE_##fe2)
4688
4689
#define SR_V8_1_A(n,e,f) SR_FEAT2(n,e,f,V8_A,V8_1)
4690
#define SR_V8_4_A(n,e,f) SR_FEAT2(n,e,f,V8_A,V8_4)
4691
4692
#define SR_V8_A(n,e,f)    SR_FEAT (n,e,f,V8_A)
4693
#define SR_V8_R(n,e,f)    SR_FEAT (n,e,f,V8_R)
4694
#define SR_V8_1(n,e,f)    SR_FEAT (n,e,f,V8_1)
4695
#define SR_V8_2(n,e,f)    SR_FEAT (n,e,f,V8_2)
4696
#define SR_V8_3(n,e,f)    SR_FEAT (n,e,f,V8_3)
4697
#define SR_V8_4(n,e,f)    SR_FEAT (n,e,f,V8_4)
4698
#define SR_V8_6(n,e,f)    SR_FEAT (n,e,f,V8_6)
4699
#define SR_V8_7(n,e,f)    SR_FEAT (n,e,f,V8_7)
4700
#define SR_V8_8(n,e,f)    SR_FEAT (n,e,f,V8_8)
4701
/* Has no separate libopcodes feature flag, but separated out for clarity.  */
4702
#define SR_GIC(n,e,f)   SR_CORE (n,e,f)
4703
/* Has no separate libopcodes feature flag, but separated out for clarity.  */
4704
#define SR_AMU(n,e,f)   SR_FEAT (n,e,f,V8_4)
4705
#define SR_LOR(n,e,f)   SR_FEAT (n,e,f,LOR)
4706
#define SR_PAN(n,e,f)   SR_FEAT (n,e,f,PAN)
4707
#define SR_RAS(n,e,f)   SR_FEAT (n,e,f,RAS)
4708
#define SR_RNG(n,e,f)   SR_FEAT (n,e,f,RNG)
4709
#define SR_SME(n,e,f)   SR_FEAT (n,e,f,SME)
4710
#define SR_SSBS(n,e,f)    SR_FEAT (n,e,f,SSBS)
4711
#define SR_SVE(n,e,f)   SR_FEAT (n,e,f,SVE)
4712
#define SR_ID_PFR2(n,e,f) SR_FEAT (n,e,f,ID_PFR2)
4713
#define SR_PROFILE(n,e,f) SR_FEAT (n,e,f,PROFILE)
4714
#define SR_MEMTAG(n,e,f)  SR_FEAT (n,e,f,MEMTAG)
4715
#define SR_SCXTNUM(n,e,f) SR_FEAT (n,e,f,SCXTNUM)
4716
4717
#define SR_EXPAND_ELx(f,x) \
4718
  f (x, 1),  \
4719
  f (x, 2),  \
4720
  f (x, 3),  \
4721
  f (x, 4),  \
4722
  f (x, 5),  \
4723
  f (x, 6),  \
4724
  f (x, 7),  \
4725
  f (x, 8),  \
4726
  f (x, 9),  \
4727
  f (x, 10), \
4728
  f (x, 11), \
4729
  f (x, 12), \
4730
  f (x, 13), \
4731
  f (x, 14), \
4732
  f (x, 15),
4733
4734
#define SR_EXPAND_EL12(f) \
4735
  SR_EXPAND_ELx (f,1) \
4736
  SR_EXPAND_ELx (f,2)
4737
4738
/* TODO there is one more issues need to be resolved
4739
   1. handle cpu-implementation-defined system registers.
4740
4741
   Note that the F_REG_{READ,WRITE} flags mean read-only and write-only
4742
   respectively.  If neither of these are set then the register is read-write.  */
4743
const aarch64_sys_reg aarch64_sys_regs [] =
4744
{
4745
  SR_CORE ("spsr_el1",    CPEN_ (0,C0,0),   0), /* = spsr_svc.  */
4746
  SR_V8_1 ("spsr_el12",   CPEN_ (5,C0,0),   0),
4747
  SR_CORE ("elr_el1",   CPEN_ (0,C0,1),   0),
4748
  SR_V8_1 ("elr_el12",    CPEN_ (5,C0,1),   0),
4749
  SR_CORE ("sp_el0",    CPEN_ (0,C1,0),   0),
4750
  SR_CORE ("spsel",   CPEN_ (0,C2,0),   0),
4751
  SR_CORE ("daif",    CPEN_ (3,C2,1),   0),
4752
  SR_CORE ("currentel",   CPEN_ (0,C2,2),   F_REG_READ),
4753
  SR_PAN  ("pan",   CPEN_ (0,C2,3),   0),
4754
  SR_V8_2 ("uao",   CPEN_ (0,C2,4),   0),
4755
  SR_CORE ("nzcv",    CPEN_ (3,C2,0),   0),
4756
  SR_SSBS ("ssbs",    CPEN_ (3,C2,6),   0),
4757
  SR_CORE ("fpcr",    CPEN_ (3,C4,0),   0),
4758
  SR_CORE ("fpsr",    CPEN_ (3,C4,1),   0),
4759
  SR_CORE ("dspsr_el0",   CPEN_ (3,C5,0),   0),
4760
  SR_CORE ("dlr_el0",   CPEN_ (3,C5,1),   0),
4761
  SR_CORE ("spsr_el2",    CPEN_ (4,C0,0),   0), /* = spsr_hyp.  */
4762
  SR_CORE ("elr_el2",   CPEN_ (4,C0,1),   0),
4763
  SR_CORE ("sp_el1",    CPEN_ (4,C1,0),   0),
4764
  SR_CORE ("spsr_irq",    CPEN_ (4,C3,0),   0),
4765
  SR_CORE ("spsr_abt",    CPEN_ (4,C3,1),   0),
4766
  SR_CORE ("spsr_und",    CPEN_ (4,C3,2),   0),
4767
  SR_CORE ("spsr_fiq",    CPEN_ (4,C3,3),   0),
4768
  SR_CORE ("spsr_el3",    CPEN_ (6,C0,0),   0),
4769
  SR_CORE ("elr_el3",   CPEN_ (6,C0,1),   0),
4770
  SR_CORE ("sp_el2",    CPEN_ (6,C1,0),   0),
4771
  SR_CORE ("spsr_svc",    CPEN_ (0,C0,0),   F_DEPRECATED), /* = spsr_el1.  */
4772
  SR_CORE ("spsr_hyp",    CPEN_ (4,C0,0),   F_DEPRECATED), /* = spsr_el2.  */
4773
  SR_CORE ("midr_el1",    CPENC (3,0,C0,C0,0),  F_REG_READ),
4774
  SR_CORE ("ctr_el0",   CPENC (3,3,C0,C0,1),  F_REG_READ),
4775
  SR_CORE ("mpidr_el1",   CPENC (3,0,C0,C0,5),  F_REG_READ),
4776
  SR_CORE ("revidr_el1",  CPENC (3,0,C0,C0,6),  F_REG_READ),
4777
  SR_CORE ("aidr_el1",    CPENC (3,1,C0,C0,7),  F_REG_READ),
4778
  SR_CORE ("dczid_el0",   CPENC (3,3,C0,C0,7),  F_REG_READ),
4779
  SR_CORE ("id_dfr0_el1", CPENC (3,0,C0,C1,2),  F_REG_READ),
4780
  SR_CORE ("id_dfr1_el1", CPENC (3,0,C0,C3,5),  F_REG_READ),
4781
  SR_CORE ("id_pfr0_el1", CPENC (3,0,C0,C1,0),  F_REG_READ),
4782
  SR_CORE ("id_pfr1_el1", CPENC (3,0,C0,C1,1),  F_REG_READ),
4783
  SR_ID_PFR2 ("id_pfr2_el1",  CPENC (3,0,C0,C3,4),  F_REG_READ),
4784
  SR_CORE ("id_afr0_el1", CPENC (3,0,C0,C1,3),  F_REG_READ),
4785
  SR_CORE ("id_mmfr0_el1",  CPENC (3,0,C0,C1,4),  F_REG_READ),
4786
  SR_CORE ("id_mmfr1_el1",  CPENC (3,0,C0,C1,5),  F_REG_READ),
4787
  SR_CORE ("id_mmfr2_el1",  CPENC (3,0,C0,C1,6),  F_REG_READ),
4788
  SR_CORE ("id_mmfr3_el1",  CPENC (3,0,C0,C1,7),  F_REG_READ),
4789
  SR_CORE ("id_mmfr4_el1",  CPENC (3,0,C0,C2,6),  F_REG_READ),
4790
  SR_CORE ("id_mmfr5_el1",  CPENC (3,0,C0,C3,6),  F_REG_READ),
4791
  SR_CORE ("id_isar0_el1",  CPENC (3,0,C0,C2,0),  F_REG_READ),
4792
  SR_CORE ("id_isar1_el1",  CPENC (3,0,C0,C2,1),  F_REG_READ),
4793
  SR_CORE ("id_isar2_el1",  CPENC (3,0,C0,C2,2),  F_REG_READ),
4794
  SR_CORE ("id_isar3_el1",  CPENC (3,0,C0,C2,3),  F_REG_READ),
4795
  SR_CORE ("id_isar4_el1",  CPENC (3,0,C0,C2,4),  F_REG_READ),
4796
  SR_CORE ("id_isar5_el1",  CPENC (3,0,C0,C2,5),  F_REG_READ),
4797
  SR_CORE ("id_isar6_el1",  CPENC (3,0,C0,C2,7),  F_REG_READ),
4798
  SR_CORE ("mvfr0_el1",   CPENC (3,0,C0,C3,0),  F_REG_READ),
4799
  SR_CORE ("mvfr1_el1",   CPENC (3,0,C0,C3,1),  F_REG_READ),
4800
  SR_CORE ("mvfr2_el1",   CPENC (3,0,C0,C3,2),  F_REG_READ),
4801
  SR_CORE ("ccsidr_el1",  CPENC (3,1,C0,C0,0),  F_REG_READ),
4802
  SR_V8_3 ("ccsidr2_el1",       CPENC (3,1,C0,C0,2),    F_REG_READ),
4803
  SR_CORE ("id_aa64pfr0_el1", CPENC (3,0,C0,C4,0),  F_REG_READ),
4804
  SR_CORE ("id_aa64pfr1_el1", CPENC (3,0,C0,C4,1),  F_REG_READ),
4805
  SR_CORE ("id_aa64dfr0_el1", CPENC (3,0,C0,C5,0),  F_REG_READ),
4806
  SR_CORE ("id_aa64dfr1_el1", CPENC (3,0,C0,C5,1),  F_REG_READ),
4807
  SR_CORE ("id_aa64isar0_el1",  CPENC (3,0,C0,C6,0),  F_REG_READ),
4808
  SR_CORE ("id_aa64isar1_el1",  CPENC (3,0,C0,C6,1),  F_REG_READ),
4809
  SR_CORE ("id_aa64isar2_el1",  CPENC (3,0,C0,C6,2),  F_REG_READ),
4810
  SR_CORE ("id_aa64mmfr0_el1",  CPENC (3,0,C0,C7,0),  F_REG_READ),
4811
  SR_CORE ("id_aa64mmfr1_el1",  CPENC (3,0,C0,C7,1),  F_REG_READ),
4812
  SR_CORE ("id_aa64mmfr2_el1",  CPENC (3,0,C0,C7,2),  F_REG_READ),
4813
  SR_CORE ("id_aa64afr0_el1", CPENC (3,0,C0,C5,4),  F_REG_READ),
4814
  SR_CORE ("id_aa64afr1_el1", CPENC (3,0,C0,C5,5),  F_REG_READ),
4815
  SR_SVE  ("id_aa64zfr0_el1", CPENC (3,0,C0,C4,4),  F_REG_READ),
4816
  SR_CORE ("clidr_el1",   CPENC (3,1,C0,C0,1),  F_REG_READ),
4817
  SR_CORE ("csselr_el1",  CPENC (3,2,C0,C0,0),  0),
4818
  SR_CORE ("vpidr_el2",   CPENC (3,4,C0,C0,0),  0),
4819
  SR_CORE ("vmpidr_el2",  CPENC (3,4,C0,C0,5),  0),
4820
  SR_CORE ("sctlr_el1",   CPENC (3,0,C1,C0,0),  0),
4821
  SR_CORE ("sctlr_el2",   CPENC (3,4,C1,C0,0),  0),
4822
  SR_CORE ("sctlr_el3",   CPENC (3,6,C1,C0,0),  0),
4823
  SR_V8_1 ("sctlr_el12",  CPENC (3,5,C1,C0,0),  0),
4824
  SR_CORE ("actlr_el1",   CPENC (3,0,C1,C0,1),  0),
4825
  SR_CORE ("actlr_el2",   CPENC (3,4,C1,C0,1),  0),
4826
  SR_CORE ("actlr_el3",   CPENC (3,6,C1,C0,1),  0),
4827
  SR_CORE ("cpacr_el1",   CPENC (3,0,C1,C0,2),  0),
4828
  SR_V8_1 ("cpacr_el12",  CPENC (3,5,C1,C0,2),  0),
4829
  SR_CORE ("cptr_el2",    CPENC (3,4,C1,C1,2),  0),
4830
  SR_CORE ("cptr_el3",    CPENC (3,6,C1,C1,2),  0),
4831
  SR_CORE ("scr_el3",   CPENC (3,6,C1,C1,0),  0),
4832
  SR_CORE ("hcr_el2",   CPENC (3,4,C1,C1,0),  0),
4833
  SR_CORE ("mdcr_el2",    CPENC (3,4,C1,C1,1),  0),
4834
  SR_CORE ("mdcr_el3",    CPENC (3,6,C1,C3,1),  0),
4835
  SR_CORE ("hstr_el2",    CPENC (3,4,C1,C1,3),  0),
4836
  SR_CORE ("hacr_el2",    CPENC (3,4,C1,C1,7),  0),
4837
  SR_SVE  ("zcr_el1",   CPENC (3,0,C1,C2,0),  0),
4838
  SR_SVE  ("zcr_el12",    CPENC (3,5,C1,C2,0),  0),
4839
  SR_SVE  ("zcr_el2",   CPENC (3,4,C1,C2,0),  0),
4840
  SR_SVE  ("zcr_el3",   CPENC (3,6,C1,C2,0),  0),
4841
  SR_CORE ("ttbr0_el1",   CPENC (3,0,C2,C0,0),  0),
4842
  SR_CORE ("ttbr1_el1",   CPENC (3,0,C2,C0,1),  0),
4843
  SR_V8_A ("ttbr0_el2",   CPENC (3,4,C2,C0,0),  0),
4844
  SR_V8_1_A ("ttbr1_el2", CPENC (3,4,C2,C0,1),  0),
4845
  SR_CORE ("ttbr0_el3",   CPENC (3,6,C2,C0,0),  0),
4846
  SR_V8_1 ("ttbr0_el12",  CPENC (3,5,C2,C0,0),  0),
4847
  SR_V8_1 ("ttbr1_el12",  CPENC (3,5,C2,C0,1),  0),
4848
  SR_V8_A ("vttbr_el2",   CPENC (3,4,C2,C1,0),  0),
4849
  SR_CORE ("tcr_el1",   CPENC (3,0,C2,C0,2),  0),
4850
  SR_CORE ("tcr_el2",   CPENC (3,4,C2,C0,2),  0),
4851
  SR_CORE ("tcr_el3",   CPENC (3,6,C2,C0,2),  0),
4852
  SR_V8_1 ("tcr_el12",    CPENC (3,5,C2,C0,2),  0),
4853
  SR_CORE ("vtcr_el2",    CPENC (3,4,C2,C1,2),  0),
4854
  SR_V8_3 ("apiakeylo_el1", CPENC (3,0,C2,C1,0),  0),
4855
  SR_V8_3 ("apiakeyhi_el1", CPENC (3,0,C2,C1,1),  0),
4856
  SR_V8_3 ("apibkeylo_el1", CPENC (3,0,C2,C1,2),  0),
4857
  SR_V8_3 ("apibkeyhi_el1", CPENC (3,0,C2,C1,3),  0),
4858
  SR_V8_3 ("apdakeylo_el1", CPENC (3,0,C2,C2,0),  0),
4859
  SR_V8_3 ("apdakeyhi_el1", CPENC (3,0,C2,C2,1),  0),
4860
  SR_V8_3 ("apdbkeylo_el1", CPENC (3,0,C2,C2,2),  0),
4861
  SR_V8_3 ("apdbkeyhi_el1", CPENC (3,0,C2,C2,3),  0),
4862
  SR_V8_3 ("apgakeylo_el1", CPENC (3,0,C2,C3,0),  0),
4863
  SR_V8_3 ("apgakeyhi_el1", CPENC (3,0,C2,C3,1),  0),
4864
  SR_CORE ("afsr0_el1",   CPENC (3,0,C5,C1,0),  0),
4865
  SR_CORE ("afsr1_el1",   CPENC (3,0,C5,C1,1),  0),
4866
  SR_CORE ("afsr0_el2",   CPENC (3,4,C5,C1,0),  0),
4867
  SR_CORE ("afsr1_el2",   CPENC (3,4,C5,C1,1),  0),
4868
  SR_CORE ("afsr0_el3",   CPENC (3,6,C5,C1,0),  0),
4869
  SR_V8_1 ("afsr0_el12",  CPENC (3,5,C5,C1,0),  0),
4870
  SR_CORE ("afsr1_el3",   CPENC (3,6,C5,C1,1),  0),
4871
  SR_V8_1 ("afsr1_el12",  CPENC (3,5,C5,C1,1),  0),
4872
  SR_CORE ("esr_el1",   CPENC (3,0,C5,C2,0),  0),
4873
  SR_CORE ("esr_el2",   CPENC (3,4,C5,C2,0),  0),
4874
  SR_CORE ("esr_el3",   CPENC (3,6,C5,C2,0),  0),
4875
  SR_V8_1 ("esr_el12",    CPENC (3,5,C5,C2,0),  0),
4876
  SR_RAS  ("vsesr_el2",   CPENC (3,4,C5,C2,3),  0),
4877
  SR_CORE ("fpexc32_el2", CPENC (3,4,C5,C3,0),  0),
4878
  SR_RAS  ("erridr_el1",  CPENC (3,0,C5,C3,0),  F_REG_READ),
4879
  SR_RAS  ("errselr_el1", CPENC (3,0,C5,C3,1),  0),
4880
  SR_RAS  ("erxfr_el1",   CPENC (3,0,C5,C4,0),  F_REG_READ),
4881
  SR_RAS  ("erxctlr_el1", CPENC (3,0,C5,C4,1),  0),
4882
  SR_RAS  ("erxstatus_el1", CPENC (3,0,C5,C4,2),  0),
4883
  SR_RAS  ("erxaddr_el1", CPENC (3,0,C5,C4,3),  0),
4884
  SR_RAS  ("erxmisc0_el1",  CPENC (3,0,C5,C5,0),  0),
4885
  SR_RAS  ("erxmisc1_el1",  CPENC (3,0,C5,C5,1),  0),
4886
  SR_RAS  ("erxmisc2_el1",  CPENC (3,0,C5,C5,2),  0),
4887
  SR_RAS  ("erxmisc3_el1",  CPENC (3,0,C5,C5,3),  0),
4888
  SR_RAS  ("erxpfgcdn_el1", CPENC (3,0,C5,C4,6),  0),
4889
  SR_RAS  ("erxpfgctl_el1", CPENC (3,0,C5,C4,5),  0),
4890
  SR_RAS  ("erxpfgf_el1", CPENC (3,0,C5,C4,4),  F_REG_READ),
4891
  SR_CORE ("far_el1",   CPENC (3,0,C6,C0,0),  0),
4892
  SR_CORE ("far_el2",   CPENC (3,4,C6,C0,0),  0),
4893
  SR_CORE ("far_el3",   CPENC (3,6,C6,C0,0),  0),
4894
  SR_V8_1 ("far_el12",    CPENC (3,5,C6,C0,0),  0),
4895
  SR_CORE ("hpfar_el2",   CPENC (3,4,C6,C0,4),  0),
4896
  SR_CORE ("par_el1",   CPENC (3,0,C7,C4,0),  0),
4897
  SR_CORE ("mair_el1",    CPENC (3,0,C10,C2,0), 0),
4898
  SR_CORE ("mair_el2",    CPENC (3,4,C10,C2,0), 0),
4899
  SR_CORE ("mair_el3",    CPENC (3,6,C10,C2,0), 0),
4900
  SR_V8_1 ("mair_el12",   CPENC (3,5,C10,C2,0), 0),
4901
  SR_CORE ("amair_el1",   CPENC (3,0,C10,C3,0), 0),
4902
  SR_CORE ("amair_el2",   CPENC (3,4,C10,C3,0), 0),
4903
  SR_CORE ("amair_el3",   CPENC (3,6,C10,C3,0), 0),
4904
  SR_V8_1 ("amair_el12",  CPENC (3,5,C10,C3,0), 0),
4905
  SR_CORE ("vbar_el1",    CPENC (3,0,C12,C0,0), 0),
4906
  SR_CORE ("vbar_el2",    CPENC (3,4,C12,C0,0), 0),
4907
  SR_CORE ("vbar_el3",    CPENC (3,6,C12,C0,0), 0),
4908
  SR_V8_1 ("vbar_el12",   CPENC (3,5,C12,C0,0), 0),
4909
  SR_CORE ("rvbar_el1",   CPENC (3,0,C12,C0,1), F_REG_READ),
4910
  SR_CORE ("rvbar_el2",   CPENC (3,4,C12,C0,1), F_REG_READ),
4911
  SR_CORE ("rvbar_el3",   CPENC (3,6,C12,C0,1), F_REG_READ),
4912
  SR_CORE ("rmr_el1",   CPENC (3,0,C12,C0,2), 0),
4913
  SR_CORE ("rmr_el2",   CPENC (3,4,C12,C0,2), 0),
4914
  SR_CORE ("rmr_el3",   CPENC (3,6,C12,C0,2), 0),
4915
  SR_CORE ("isr_el1",   CPENC (3,0,C12,C1,0), F_REG_READ),
4916
  SR_RAS  ("disr_el1",    CPENC (3,0,C12,C1,1), 0),
4917
  SR_RAS  ("vdisr_el2",   CPENC (3,4,C12,C1,1), 0),
4918
  SR_CORE ("contextidr_el1",  CPENC (3,0,C13,C0,1), 0),
4919
  SR_V8_1 ("contextidr_el2",  CPENC (3,4,C13,C0,1), 0),
4920
  SR_V8_1 ("contextidr_el12", CPENC (3,5,C13,C0,1), 0),
4921
  SR_RNG  ("rndr",    CPENC (3,3,C2,C4,0),  F_REG_READ),
4922
  SR_RNG  ("rndrrs",    CPENC (3,3,C2,C4,1),  F_REG_READ),
4923
  SR_MEMTAG ("tco",   CPENC (3,3,C4,C2,7),  0),
4924
  SR_MEMTAG ("tfsre0_el1",  CPENC (3,0,C5,C6,1),  0),
4925
  SR_MEMTAG ("tfsr_el1",  CPENC (3,0,C5,C6,0),  0),
4926
  SR_MEMTAG ("tfsr_el2",  CPENC (3,4,C5,C6,0),  0),
4927
  SR_MEMTAG ("tfsr_el3",  CPENC (3,6,C5,C6,0),  0),
4928
  SR_MEMTAG ("tfsr_el12", CPENC (3,5,C5,C6,0),  0),
4929
  SR_MEMTAG ("rgsr_el1",  CPENC (3,0,C1,C0,5),  0),
4930
  SR_MEMTAG ("gcr_el1",   CPENC (3,0,C1,C0,6),  0),
4931
  SR_MEMTAG ("gmid_el1",  CPENC (3,1,C0,C0,4),  F_REG_READ),
4932
  SR_CORE ("tpidr_el0",   CPENC (3,3,C13,C0,2), 0),
4933
  SR_CORE ("tpidrro_el0",       CPENC (3,3,C13,C0,3), 0),
4934
  SR_CORE ("tpidr_el1",   CPENC (3,0,C13,C0,4), 0),
4935
  SR_CORE ("tpidr_el2",   CPENC (3,4,C13,C0,2), 0),
4936
  SR_CORE ("tpidr_el3",   CPENC (3,6,C13,C0,2), 0),
4937
  SR_SCXTNUM ("scxtnum_el0",  CPENC (3,3,C13,C0,7), 0),
4938
  SR_SCXTNUM ("scxtnum_el1",  CPENC (3,0,C13,C0,7), 0),
4939
  SR_SCXTNUM ("scxtnum_el2",  CPENC (3,4,C13,C0,7), 0),
4940
  SR_SCXTNUM ("scxtnum_el12",   CPENC (3,5,C13,C0,7), 0),
4941
  SR_SCXTNUM ("scxtnum_el3",    CPENC (3,6,C13,C0,7), 0),
4942
  SR_CORE ("teecr32_el1",       CPENC (2,2,C0, C0,0), 0), /* See section 3.9.7.1.  */
4943
  SR_CORE ("cntfrq_el0",  CPENC (3,3,C14,C0,0), 0),
4944
  SR_CORE ("cntpct_el0",  CPENC (3,3,C14,C0,1), F_REG_READ),
4945
  SR_CORE ("cntvct_el0",  CPENC (3,3,C14,C0,2), F_REG_READ),
4946
  SR_CORE ("cntvoff_el2",       CPENC (3,4,C14,C0,3), 0),
4947
  SR_CORE ("cntkctl_el1",       CPENC (3,0,C14,C1,0), 0),
4948
  SR_V8_1 ("cntkctl_el12",  CPENC (3,5,C14,C1,0), 0),
4949
  SR_CORE ("cnthctl_el2", CPENC (3,4,C14,C1,0), 0),
4950
  SR_CORE ("cntp_tval_el0", CPENC (3,3,C14,C2,0), 0),
4951
  SR_V8_1 ("cntp_tval_el02",  CPENC (3,5,C14,C2,0), 0),
4952
  SR_CORE ("cntp_ctl_el0",      CPENC (3,3,C14,C2,1), 0),
4953
  SR_V8_1 ("cntp_ctl_el02", CPENC (3,5,C14,C2,1), 0),
4954
  SR_CORE ("cntp_cval_el0",     CPENC (3,3,C14,C2,2), 0),
4955
  SR_V8_1 ("cntp_cval_el02",  CPENC (3,5,C14,C2,2), 0),
4956
  SR_CORE ("cntv_tval_el0",     CPENC (3,3,C14,C3,0), 0),
4957
  SR_V8_1 ("cntv_tval_el02",  CPENC (3,5,C14,C3,0), 0),
4958
  SR_CORE ("cntv_ctl_el0",      CPENC (3,3,C14,C3,1), 0),
4959
  SR_V8_1 ("cntv_ctl_el02", CPENC (3,5,C14,C3,1), 0),
4960
  SR_CORE ("cntv_cval_el0",     CPENC (3,3,C14,C3,2), 0),
4961
  SR_V8_1 ("cntv_cval_el02",  CPENC (3,5,C14,C3,2), 0),
4962
  SR_CORE ("cnthp_tval_el2",  CPENC (3,4,C14,C2,0), 0),
4963
  SR_CORE ("cnthp_ctl_el2", CPENC (3,4,C14,C2,1), 0),
4964
  SR_CORE ("cnthp_cval_el2",  CPENC (3,4,C14,C2,2), 0),
4965
  SR_CORE ("cntps_tval_el1",  CPENC (3,7,C14,C2,0), 0),
4966
  SR_CORE ("cntps_ctl_el1", CPENC (3,7,C14,C2,1), 0),
4967
  SR_CORE ("cntps_cval_el1",  CPENC (3,7,C14,C2,2), 0),
4968
  SR_V8_1 ("cnthv_tval_el2",  CPENC (3,4,C14,C3,0), 0),
4969
  SR_V8_1 ("cnthv_ctl_el2", CPENC (3,4,C14,C3,1), 0),
4970
  SR_V8_1 ("cnthv_cval_el2",  CPENC (3,4,C14,C3,2), 0),
4971
  SR_CORE ("dacr32_el2",  CPENC (3,4,C3,C0,0),  0),
4972
  SR_CORE ("ifsr32_el2",  CPENC (3,4,C5,C0,1),  0),
4973
  SR_CORE ("teehbr32_el1",  CPENC (2,2,C1,C0,0),  0),
4974
  SR_CORE ("sder32_el3",  CPENC (3,6,C1,C1,1),  0),
4975
  SR_CORE ("mdscr_el1",   CPENC (2,0,C0,C2,2),  0),
4976
  SR_CORE ("mdccsr_el0",  CPENC (2,3,C0,C1,0),  F_REG_READ),
4977
  SR_CORE ("mdccint_el1",       CPENC (2,0,C0,C2,0),  0),
4978
  SR_CORE ("dbgdtr_el0",  CPENC (2,3,C0,C4,0),  0),
4979
  SR_CORE ("dbgdtrrx_el0",  CPENC (2,3,C0,C5,0),  F_REG_READ),
4980
  SR_CORE ("dbgdtrtx_el0",  CPENC (2,3,C0,C5,0),  F_REG_WRITE),
4981
  SR_CORE ("osdtrrx_el1", CPENC (2,0,C0,C0,2),  0),
4982
  SR_CORE ("osdtrtx_el1", CPENC (2,0,C0,C3,2),  0),
4983
  SR_CORE ("oseccr_el1",  CPENC (2,0,C0,C6,2),  0),
4984
  SR_CORE ("dbgvcr32_el2",      CPENC (2,4,C0,C7,0),  0),
4985
  SR_CORE ("dbgbvr0_el1",       CPENC (2,0,C0,C0,4),  0),
4986
  SR_CORE ("dbgbvr1_el1",       CPENC (2,0,C0,C1,4),  0),
4987
  SR_CORE ("dbgbvr2_el1",       CPENC (2,0,C0,C2,4),  0),
4988
  SR_CORE ("dbgbvr3_el1",       CPENC (2,0,C0,C3,4),  0),
4989
  SR_CORE ("dbgbvr4_el1",       CPENC (2,0,C0,C4,4),  0),
4990
  SR_CORE ("dbgbvr5_el1",       CPENC (2,0,C0,C5,4),  0),
4991
  SR_CORE ("dbgbvr6_el1",       CPENC (2,0,C0,C6,4),  0),
4992
  SR_CORE ("dbgbvr7_el1",       CPENC (2,0,C0,C7,4),  0),
4993
  SR_CORE ("dbgbvr8_el1",       CPENC (2,0,C0,C8,4),  0),
4994
  SR_CORE ("dbgbvr9_el1",       CPENC (2,0,C0,C9,4),  0),
4995
  SR_CORE ("dbgbvr10_el1",      CPENC (2,0,C0,C10,4), 0),
4996
  SR_CORE ("dbgbvr11_el1",      CPENC (2,0,C0,C11,4), 0),
4997
  SR_CORE ("dbgbvr12_el1",      CPENC (2,0,C0,C12,4), 0),
4998
  SR_CORE ("dbgbvr13_el1",      CPENC (2,0,C0,C13,4), 0),
4999
  SR_CORE ("dbgbvr14_el1",      CPENC (2,0,C0,C14,4), 0),
5000
  SR_CORE ("dbgbvr15_el1",      CPENC (2,0,C0,C15,4), 0),
5001
  SR_CORE ("dbgbcr0_el1",       CPENC (2,0,C0,C0,5),  0),
5002
  SR_CORE ("dbgbcr1_el1",       CPENC (2,0,C0,C1,5),  0),
5003
  SR_CORE ("dbgbcr2_el1",       CPENC (2,0,C0,C2,5),  0),
5004
  SR_CORE ("dbgbcr3_el1",       CPENC (2,0,C0,C3,5),  0),
5005
  SR_CORE ("dbgbcr4_el1",       CPENC (2,0,C0,C4,5),  0),
5006
  SR_CORE ("dbgbcr5_el1",       CPENC (2,0,C0,C5,5),  0),
5007
  SR_CORE ("dbgbcr6_el1",       CPENC (2,0,C0,C6,5),  0),
5008
  SR_CORE ("dbgbcr7_el1",       CPENC (2,0,C0,C7,5),  0),
5009
  SR_CORE ("dbgbcr8_el1",       CPENC (2,0,C0,C8,5),  0),
5010
  SR_CORE ("dbgbcr9_el1",       CPENC (2,0,C0,C9,5),  0),
5011
  SR_CORE ("dbgbcr10_el1",      CPENC (2,0,C0,C10,5), 0),
5012
  SR_CORE ("dbgbcr11_el1",      CPENC (2,0,C0,C11,5), 0),
5013
  SR_CORE ("dbgbcr12_el1",      CPENC (2,0,C0,C12,5), 0),
5014
  SR_CORE ("dbgbcr13_el1",      CPENC (2,0,C0,C13,5), 0),
5015
  SR_CORE ("dbgbcr14_el1",      CPENC (2,0,C0,C14,5), 0),
5016
  SR_CORE ("dbgbcr15_el1",      CPENC (2,0,C0,C15,5), 0),
5017
  SR_CORE ("dbgwvr0_el1",       CPENC (2,0,C0,C0,6),  0),
5018
  SR_CORE ("dbgwvr1_el1",       CPENC (2,0,C0,C1,6),  0),
5019
  SR_CORE ("dbgwvr2_el1",       CPENC (2,0,C0,C2,6),  0),
5020
  SR_CORE ("dbgwvr3_el1",       CPENC (2,0,C0,C3,6),  0),
5021
  SR_CORE ("dbgwvr4_el1",       CPENC (2,0,C0,C4,6),  0),
5022
  SR_CORE ("dbgwvr5_el1",       CPENC (2,0,C0,C5,6),  0),
5023
  SR_CORE ("dbgwvr6_el1",       CPENC (2,0,C0,C6,6),  0),
5024
  SR_CORE ("dbgwvr7_el1",       CPENC (2,0,C0,C7,6),  0),
5025
  SR_CORE ("dbgwvr8_el1",       CPENC (2,0,C0,C8,6),  0),
5026
  SR_CORE ("dbgwvr9_el1",       CPENC (2,0,C0,C9,6),  0),
5027
  SR_CORE ("dbgwvr10_el1",      CPENC (2,0,C0,C10,6), 0),
5028
  SR_CORE ("dbgwvr11_el1",      CPENC (2,0,C0,C11,6), 0),
5029
  SR_CORE ("dbgwvr12_el1",      CPENC (2,0,C0,C12,6), 0),
5030
  SR_CORE ("dbgwvr13_el1",      CPENC (2,0,C0,C13,6), 0),
5031
  SR_CORE ("dbgwvr14_el1",      CPENC (2,0,C0,C14,6), 0),
5032
  SR_CORE ("dbgwvr15_el1",      CPENC (2,0,C0,C15,6), 0),
5033
  SR_CORE ("dbgwcr0_el1",       CPENC (2,0,C0,C0,7),  0),
5034
  SR_CORE ("dbgwcr1_el1",       CPENC (2,0,C0,C1,7),  0),
5035
  SR_CORE ("dbgwcr2_el1",       CPENC (2,0,C0,C2,7),  0),
5036
  SR_CORE ("dbgwcr3_el1",       CPENC (2,0,C0,C3,7),  0),
5037
  SR_CORE ("dbgwcr4_el1",       CPENC (2,0,C0,C4,7),  0),
5038
  SR_CORE ("dbgwcr5_el1",       CPENC (2,0,C0,C5,7),  0),
5039
  SR_CORE ("dbgwcr6_el1",       CPENC (2,0,C0,C6,7),  0),
5040
  SR_CORE ("dbgwcr7_el1",       CPENC (2,0,C0,C7,7),  0),
5041
  SR_CORE ("dbgwcr8_el1",       CPENC (2,0,C0,C8,7),  0),
5042
  SR_CORE ("dbgwcr9_el1",       CPENC (2,0,C0,C9,7),  0),
5043
  SR_CORE ("dbgwcr10_el1",      CPENC (2,0,C0,C10,7), 0),
5044
  SR_CORE ("dbgwcr11_el1",      CPENC (2,0,C0,C11,7), 0),
5045
  SR_CORE ("dbgwcr12_el1",      CPENC (2,0,C0,C12,7), 0),
5046
  SR_CORE ("dbgwcr13_el1",      CPENC (2,0,C0,C13,7), 0),
5047
  SR_CORE ("dbgwcr14_el1",      CPENC (2,0,C0,C14,7), 0),
5048
  SR_CORE ("dbgwcr15_el1",      CPENC (2,0,C0,C15,7), 0),
5049
  SR_CORE ("mdrar_el1",   CPENC (2,0,C1,C0,0),  F_REG_READ),
5050
  SR_CORE ("oslar_el1",   CPENC (2,0,C1,C0,4),  F_REG_WRITE),
5051
  SR_CORE ("oslsr_el1",   CPENC (2,0,C1,C1,4),  F_REG_READ),
5052
  SR_CORE ("osdlr_el1",   CPENC (2,0,C1,C3,4),  0),
5053
  SR_CORE ("dbgprcr_el1",       CPENC (2,0,C1,C4,4),  0),
5054
  SR_CORE ("dbgclaimset_el1",   CPENC (2,0,C7,C8,6),  0),
5055
  SR_CORE ("dbgclaimclr_el1",   CPENC (2,0,C7,C9,6),  0),
5056
  SR_CORE ("dbgauthstatus_el1", CPENC (2,0,C7,C14,6), F_REG_READ),
5057
  SR_PROFILE ("pmblimitr_el1",  CPENC (3,0,C9,C10,0), 0),
5058
  SR_PROFILE ("pmbptr_el1", CPENC (3,0,C9,C10,1), 0),
5059
  SR_PROFILE ("pmbsr_el1",  CPENC (3,0,C9,C10,3), 0),
5060
  SR_PROFILE ("pmbidr_el1", CPENC (3,0,C9,C10,7), F_REG_READ),
5061
  SR_PROFILE ("pmscr_el1",  CPENC (3,0,C9,C9,0),  0),
5062
  SR_PROFILE ("pmsicr_el1", CPENC (3,0,C9,C9,2),  0),
5063
  SR_PROFILE ("pmsirr_el1", CPENC (3,0,C9,C9,3),  0),
5064
  SR_PROFILE ("pmsfcr_el1", CPENC (3,0,C9,C9,4),  0),
5065
  SR_PROFILE ("pmsevfr_el1",  CPENC (3,0,C9,C9,5),  0),
5066
  SR_PROFILE ("pmslatfr_el1", CPENC (3,0,C9,C9,6),  0),
5067
  SR_PROFILE ("pmsidr_el1", CPENC (3,0,C9,C9,7),  F_REG_READ),
5068
  SR_PROFILE ("pmscr_el2",  CPENC (3,4,C9,C9,0),  0),
5069
  SR_PROFILE ("pmscr_el12", CPENC (3,5,C9,C9,0),  0),
5070
  SR_CORE ("pmcr_el0",    CPENC (3,3,C9,C12,0), 0),
5071
  SR_CORE ("pmcntenset_el0",    CPENC (3,3,C9,C12,1), 0),
5072
  SR_CORE ("pmcntenclr_el0",    CPENC (3,3,C9,C12,2), 0),
5073
  SR_CORE ("pmovsclr_el0",      CPENC (3,3,C9,C12,3), 0),
5074
  SR_CORE ("pmswinc_el0",       CPENC (3,3,C9,C12,4), F_REG_WRITE),
5075
  SR_CORE ("pmselr_el0",  CPENC (3,3,C9,C12,5), 0),
5076
  SR_CORE ("pmceid0_el0",       CPENC (3,3,C9,C12,6), F_REG_READ),
5077
  SR_CORE ("pmceid1_el0",       CPENC (3,3,C9,C12,7), F_REG_READ),
5078
  SR_CORE ("pmccntr_el0",       CPENC (3,3,C9,C13,0), 0),
5079
  SR_CORE ("pmxevtyper_el0",    CPENC (3,3,C9,C13,1), 0),
5080
  SR_CORE ("pmxevcntr_el0",     CPENC (3,3,C9,C13,2), 0),
5081
  SR_CORE ("pmuserenr_el0",     CPENC (3,3,C9,C14,0), 0),
5082
  SR_CORE ("pmintenset_el1",    CPENC (3,0,C9,C14,1), 0),
5083
  SR_CORE ("pmintenclr_el1",    CPENC (3,0,C9,C14,2), 0),
5084
  SR_CORE ("pmovsset_el0",      CPENC (3,3,C9,C14,3), 0),
5085
  SR_CORE ("pmevcntr0_el0",     CPENC (3,3,C14,C8,0), 0),
5086
  SR_CORE ("pmevcntr1_el0",     CPENC (3,3,C14,C8,1), 0),
5087
  SR_CORE ("pmevcntr2_el0",     CPENC (3,3,C14,C8,2), 0),
5088
  SR_CORE ("pmevcntr3_el0",     CPENC (3,3,C14,C8,3), 0),
5089
  SR_CORE ("pmevcntr4_el0",     CPENC (3,3,C14,C8,4), 0),
5090
  SR_CORE ("pmevcntr5_el0",     CPENC (3,3,C14,C8,5), 0),
5091
  SR_CORE ("pmevcntr6_el0",     CPENC (3,3,C14,C8,6), 0),
5092
  SR_CORE ("pmevcntr7_el0",     CPENC (3,3,C14,C8,7), 0),
5093
  SR_CORE ("pmevcntr8_el0",     CPENC (3,3,C14,C9,0), 0),
5094
  SR_CORE ("pmevcntr9_el0",     CPENC (3,3,C14,C9,1), 0),
5095
  SR_CORE ("pmevcntr10_el0",    CPENC (3,3,C14,C9,2), 0),
5096
  SR_CORE ("pmevcntr11_el0",    CPENC (3,3,C14,C9,3), 0),
5097
  SR_CORE ("pmevcntr12_el0",    CPENC (3,3,C14,C9,4), 0),
5098
  SR_CORE ("pmevcntr13_el0",    CPENC (3,3,C14,C9,5), 0),
5099
  SR_CORE ("pmevcntr14_el0",    CPENC (3,3,C14,C9,6), 0),
5100
  SR_CORE ("pmevcntr15_el0",    CPENC (3,3,C14,C9,7), 0),
5101
  SR_CORE ("pmevcntr16_el0",    CPENC (3,3,C14,C10,0),  0),
5102
  SR_CORE ("pmevcntr17_el0",    CPENC (3,3,C14,C10,1),  0),
5103
  SR_CORE ("pmevcntr18_el0",    CPENC (3,3,C14,C10,2),  0),
5104
  SR_CORE ("pmevcntr19_el0",    CPENC (3,3,C14,C10,3),  0),
5105
  SR_CORE ("pmevcntr20_el0",    CPENC (3,3,C14,C10,4),  0),
5106
  SR_CORE ("pmevcntr21_el0",    CPENC (3,3,C14,C10,5),  0),
5107
  SR_CORE ("pmevcntr22_el0",    CPENC (3,3,C14,C10,6),  0),
5108
  SR_CORE ("pmevcntr23_el0",    CPENC (3,3,C14,C10,7),  0),
5109
  SR_CORE ("pmevcntr24_el0",    CPENC (3,3,C14,C11,0),  0),
5110
  SR_CORE ("pmevcntr25_el0",    CPENC (3,3,C14,C11,1),  0),
5111
  SR_CORE ("pmevcntr26_el0",    CPENC (3,3,C14,C11,2),  0),
5112
  SR_CORE ("pmevcntr27_el0",    CPENC (3,3,C14,C11,3),  0),
5113
  SR_CORE ("pmevcntr28_el0",    CPENC (3,3,C14,C11,4),  0),
5114
  SR_CORE ("pmevcntr29_el0",    CPENC (3,3,C14,C11,5),  0),
5115
  SR_CORE ("pmevcntr30_el0",    CPENC (3,3,C14,C11,6),  0),
5116
  SR_CORE ("pmevtyper0_el0",    CPENC (3,3,C14,C12,0),  0),
5117
  SR_CORE ("pmevtyper1_el0",    CPENC (3,3,C14,C12,1),  0),
5118
  SR_CORE ("pmevtyper2_el0",    CPENC (3,3,C14,C12,2),  0),
5119
  SR_CORE ("pmevtyper3_el0",    CPENC (3,3,C14,C12,3),  0),
5120
  SR_CORE ("pmevtyper4_el0",    CPENC (3,3,C14,C12,4),  0),
5121
  SR_CORE ("pmevtyper5_el0",    CPENC (3,3,C14,C12,5),  0),
5122
  SR_CORE ("pmevtyper6_el0",    CPENC (3,3,C14,C12,6),  0),
5123
  SR_CORE ("pmevtyper7_el0",    CPENC (3,3,C14,C12,7),  0),
5124
  SR_CORE ("pmevtyper8_el0",    CPENC (3,3,C14,C13,0),  0),
5125
  SR_CORE ("pmevtyper9_el0",    CPENC (3,3,C14,C13,1),  0),
5126
  SR_CORE ("pmevtyper10_el0",   CPENC (3,3,C14,C13,2),  0),
5127
  SR_CORE ("pmevtyper11_el0",   CPENC (3,3,C14,C13,3),  0),
5128
  SR_CORE ("pmevtyper12_el0",   CPENC (3,3,C14,C13,4),  0),
5129
  SR_CORE ("pmevtyper13_el0",   CPENC (3,3,C14,C13,5),  0),
5130
  SR_CORE ("pmevtyper14_el0",   CPENC (3,3,C14,C13,6),  0),
5131
  SR_CORE ("pmevtyper15_el0",   CPENC (3,3,C14,C13,7),  0),
5132
  SR_CORE ("pmevtyper16_el0",   CPENC (3,3,C14,C14,0),  0),
5133
  SR_CORE ("pmevtyper17_el0",   CPENC (3,3,C14,C14,1),  0),
5134
  SR_CORE ("pmevtyper18_el0",   CPENC (3,3,C14,C14,2),  0),
5135
  SR_CORE ("pmevtyper19_el0",   CPENC (3,3,C14,C14,3),  0),
5136
  SR_CORE ("pmevtyper20_el0",   CPENC (3,3,C14,C14,4),  0),
5137
  SR_CORE ("pmevtyper21_el0",   CPENC (3,3,C14,C14,5),  0),
5138
  SR_CORE ("pmevtyper22_el0",   CPENC (3,3,C14,C14,6),  0),
5139
  SR_CORE ("pmevtyper23_el0",   CPENC (3,3,C14,C14,7),  0),
5140
  SR_CORE ("pmevtyper24_el0",   CPENC (3,3,C14,C15,0),  0),
5141
  SR_CORE ("pmevtyper25_el0",   CPENC (3,3,C14,C15,1),  0),
5142
  SR_CORE ("pmevtyper26_el0",   CPENC (3,3,C14,C15,2),  0),
5143
  SR_CORE ("pmevtyper27_el0",   CPENC (3,3,C14,C15,3),  0),
5144
  SR_CORE ("pmevtyper28_el0",   CPENC (3,3,C14,C15,4),  0),
5145
  SR_CORE ("pmevtyper29_el0",   CPENC (3,3,C14,C15,5),  0),
5146
  SR_CORE ("pmevtyper30_el0",   CPENC (3,3,C14,C15,6),  0),
5147
  SR_CORE ("pmccfiltr_el0",     CPENC (3,3,C14,C15,7),  0),
5148
5149
  SR_V8_4 ("dit",   CPEN_ (3,C2,5),   0),
5150
  SR_V8_4 ("trfcr_el1",   CPENC (3,0,C1,C2,1),  0),
5151
  SR_V8_4 ("pmmir_el1",   CPENC (3,0,C9,C14,6), F_REG_READ),
5152
  SR_V8_4 ("trfcr_el2",   CPENC (3,4,C1,C2,1),  0),
5153
  SR_V8_4 ("vstcr_el2",   CPENC (3,4,C2,C6,2),  0),
5154
  SR_V8_4_A ("vsttbr_el2",  CPENC (3,4,C2,C6,0),  0),
5155
  SR_V8_4 ("cnthvs_tval_el2", CPENC (3,4,C14,C4,0), 0),
5156
  SR_V8_4 ("cnthvs_cval_el2", CPENC (3,4,C14,C4,2), 0),
5157
  SR_V8_4 ("cnthvs_ctl_el2",  CPENC (3,4,C14,C4,1), 0),
5158
  SR_V8_4 ("cnthps_tval_el2", CPENC (3,4,C14,C5,0), 0),
5159
  SR_V8_4 ("cnthps_cval_el2", CPENC (3,4,C14,C5,2), 0),
5160
  SR_V8_4 ("cnthps_ctl_el2",  CPENC (3,4,C14,C5,1), 0),
5161
  SR_V8_4 ("sder32_el2",  CPENC (3,4,C1,C3,1),  0),
5162
  SR_V8_4 ("vncr_el2",    CPENC (3,4,C2,C2,0),  0),
5163
  SR_V8_4 ("trfcr_el12",  CPENC (3,5,C1,C2,1),  0),
5164
5165
  SR_CORE ("mpam0_el1",   CPENC (3,0,C10,C5,1), 0),
5166
  SR_CORE ("mpam1_el1",   CPENC (3,0,C10,C5,0), 0),
5167
  SR_CORE ("mpam1_el12",  CPENC (3,5,C10,C5,0), 0),
5168
  SR_CORE ("mpam2_el2",   CPENC (3,4,C10,C5,0), 0),
5169
  SR_CORE ("mpam3_el3",   CPENC (3,6,C10,C5,0), 0),
5170
  SR_CORE ("mpamhcr_el2", CPENC (3,4,C10,C4,0), 0),
5171
  SR_CORE ("mpamidr_el1", CPENC (3,0,C10,C4,4), F_REG_READ),
5172
  SR_CORE ("mpamvpm0_el2",  CPENC (3,4,C10,C6,0), 0),
5173
  SR_CORE ("mpamvpm1_el2",  CPENC (3,4,C10,C6,1), 0),
5174
  SR_CORE ("mpamvpm2_el2",  CPENC (3,4,C10,C6,2), 0),
5175
  SR_CORE ("mpamvpm3_el2",  CPENC (3,4,C10,C6,3), 0),
5176
  SR_CORE ("mpamvpm4_el2",  CPENC (3,4,C10,C6,4), 0),
5177
  SR_CORE ("mpamvpm5_el2",  CPENC (3,4,C10,C6,5), 0),
5178
  SR_CORE ("mpamvpm6_el2",  CPENC (3,4,C10,C6,6), 0),
5179
  SR_CORE ("mpamvpm7_el2",  CPENC (3,4,C10,C6,7), 0),
5180
  SR_CORE ("mpamvpmv_el2",  CPENC (3,4,C10,C4,1), 0),
5181
5182
  SR_V8_R ("mpuir_el1",   CPENC (3,0,C0,C0,4),  F_REG_READ),
5183
  SR_V8_R ("mpuir_el2",   CPENC (3,4,C0,C0,4),  F_REG_READ),
5184
  SR_V8_R ("prbar_el1",   CPENC (3,0,C6,C8,0),  0),
5185
  SR_V8_R ("prbar_el2",   CPENC (3,4,C6,C8,0),  0),
5186
5187
#define ENC_BARLAR(x,n,lar) \
5188
  CPENC (3, (x-1) << 2, C6, 8 | (n >> 1), ((n & 1) << 2) | lar)
5189
5190
#define PRBARn_ELx(x,n) SR_V8_R ("prbar" #n "_el" #x, ENC_BARLAR (x,n,0), 0)
5191
#define PRLARn_ELx(x,n) SR_V8_R ("prlar" #n "_el" #x, ENC_BARLAR (x,n,1), 0)
5192
5193
  SR_EXPAND_EL12 (PRBARn_ELx)
5194
  SR_V8_R ("prenr_el1",   CPENC (3,0,C6,C1,1),  0),
5195
  SR_V8_R ("prenr_el2",   CPENC (3,4,C6,C1,1),  0),
5196
  SR_V8_R ("prlar_el1",   CPENC (3,0,C6,C8,1),  0),
5197
  SR_V8_R ("prlar_el2",   CPENC (3,4,C6,C8,1),  0),
5198
  SR_EXPAND_EL12 (PRLARn_ELx)
5199
  SR_V8_R ("prselr_el1",  CPENC (3,0,C6,C2,1),  0),
5200
  SR_V8_R ("prselr_el2",  CPENC (3,4,C6,C2,1),  0),
5201
  SR_V8_R ("vsctlr_el2",  CPENC (3,4,C2,C0,0),  0),
5202
5203
  SR_CORE("trbbaser_el1",   CPENC (3,0,C9,C11,2), 0),
5204
  SR_CORE("trbidr_el1",   CPENC (3,0,C9,C11,7), F_REG_READ),
5205
  SR_CORE("trblimitr_el1",  CPENC (3,0,C9,C11,0), 0),
5206
  SR_CORE("trbmar_el1",   CPENC (3,0,C9,C11,4), 0),
5207
  SR_CORE("trbptr_el1",   CPENC (3,0,C9,C11,1), 0),
5208
  SR_CORE("trbsr_el1",    CPENC (3,0,C9,C11,3), 0),
5209
  SR_CORE("trbtrg_el1",   CPENC (3,0,C9,C11,6), 0),
5210
5211
  SR_CORE ("trcauthstatus", CPENC (2,1,C7,C14,6), F_REG_READ),
5212
  SR_CORE ("trccidr0",      CPENC (2,1,C7,C12,7), F_REG_READ),
5213
  SR_CORE ("trccidr1",      CPENC (2,1,C7,C13,7), F_REG_READ),
5214
  SR_CORE ("trccidr2",      CPENC (2,1,C7,C14,7), F_REG_READ),
5215
  SR_CORE ("trccidr3",      CPENC (2,1,C7,C15,7), F_REG_READ),
5216
  SR_CORE ("trcdevaff0",    CPENC (2,1,C7,C10,6), F_REG_READ),
5217
  SR_CORE ("trcdevaff1",    CPENC (2,1,C7,C11,6), F_REG_READ),
5218
  SR_CORE ("trcdevarch",    CPENC (2,1,C7,C15,6), F_REG_READ),
5219
  SR_CORE ("trcdevid",      CPENC (2,1,C7,C2,7),  F_REG_READ),
5220
  SR_CORE ("trcdevtype",    CPENC (2,1,C7,C3,7),  F_REG_READ),
5221
  SR_CORE ("trcidr0",       CPENC (2,1,C0,C8,7),  F_REG_READ),
5222
  SR_CORE ("trcidr1",       CPENC (2,1,C0,C9,7),  F_REG_READ),
5223
  SR_CORE ("trcidr2",       CPENC (2,1,C0,C10,7), F_REG_READ),
5224
  SR_CORE ("trcidr3",       CPENC (2,1,C0,C11,7), F_REG_READ),
5225
  SR_CORE ("trcidr4",       CPENC (2,1,C0,C12,7), F_REG_READ),
5226
  SR_CORE ("trcidr5",       CPENC (2,1,C0,C13,7), F_REG_READ),
5227
  SR_CORE ("trcidr6",       CPENC (2,1,C0,C14,7), F_REG_READ),
5228
  SR_CORE ("trcidr7",       CPENC (2,1,C0,C15,7), F_REG_READ),
5229
  SR_CORE ("trcidr8",       CPENC (2,1,C0,C0,6),  F_REG_READ),
5230
  SR_CORE ("trcidr9",       CPENC (2,1,C0,C1,6),  F_REG_READ),
5231
  SR_CORE ("trcidr10",      CPENC (2,1,C0,C2,6),  F_REG_READ),
5232
  SR_CORE ("trcidr11",      CPENC (2,1,C0,C3,6),  F_REG_READ),
5233
  SR_CORE ("trcidr12",      CPENC (2,1,C0,C4,6),  F_REG_READ),
5234
  SR_CORE ("trcidr13",      CPENC (2,1,C0,C5,6),  F_REG_READ),
5235
  SR_CORE ("trclsr",        CPENC (2,1,C7,C13,6), F_REG_READ),
5236
  SR_CORE ("trcoslsr",      CPENC (2,1,C1,C1,4),  F_REG_READ),
5237
  SR_CORE ("trcpdsr",       CPENC (2,1,C1,C5,4),  F_REG_READ),
5238
  SR_CORE ("trcpidr0",      CPENC (2,1,C7,C8,7),  F_REG_READ),
5239
  SR_CORE ("trcpidr1",      CPENC (2,1,C7,C9,7),  F_REG_READ),
5240
  SR_CORE ("trcpidr2",      CPENC (2,1,C7,C10,7), F_REG_READ),
5241
  SR_CORE ("trcpidr3",      CPENC (2,1,C7,C11,7), F_REG_READ),
5242
  SR_CORE ("trcpidr4",      CPENC (2,1,C7,C4,7),  F_REG_READ),
5243
  SR_CORE ("trcpidr5",      CPENC (2,1,C7,C5,7),  F_REG_READ),
5244
  SR_CORE ("trcpidr6",      CPENC (2,1,C7,C6,7),  F_REG_READ),
5245
  SR_CORE ("trcpidr7",      CPENC (2,1,C7,C7,7),  F_REG_READ),
5246
  SR_CORE ("trcstatr",      CPENC (2,1,C0,C3,0),  F_REG_READ),
5247
  SR_CORE ("trcacatr0",     CPENC (2,1,C2,C0,2),  0),
5248
  SR_CORE ("trcacatr1",     CPENC (2,1,C2,C2,2),  0),
5249
  SR_CORE ("trcacatr2",     CPENC (2,1,C2,C4,2),  0),
5250
  SR_CORE ("trcacatr3",     CPENC (2,1,C2,C6,2),  0),
5251
  SR_CORE ("trcacatr4",     CPENC (2,1,C2,C8,2),  0),
5252
  SR_CORE ("trcacatr5",     CPENC (2,1,C2,C10,2), 0),
5253
  SR_CORE ("trcacatr6",     CPENC (2,1,C2,C12,2), 0),
5254
  SR_CORE ("trcacatr7",     CPENC (2,1,C2,C14,2), 0),
5255
  SR_CORE ("trcacatr8",     CPENC (2,1,C2,C0,3),  0),
5256
  SR_CORE ("trcacatr9",     CPENC (2,1,C2,C2,3),  0),
5257
  SR_CORE ("trcacatr10",    CPENC (2,1,C2,C4,3),  0),
5258
  SR_CORE ("trcacatr11",    CPENC (2,1,C2,C6,3),  0),
5259
  SR_CORE ("trcacatr12",    CPENC (2,1,C2,C8,3),  0),
5260
  SR_CORE ("trcacatr13",    CPENC (2,1,C2,C10,3), 0),
5261
  SR_CORE ("trcacatr14",    CPENC (2,1,C2,C12,3), 0),
5262
  SR_CORE ("trcacatr15",    CPENC (2,1,C2,C14,3), 0),
5263
  SR_CORE ("trcacvr0",      CPENC (2,1,C2,C0,0),  0),
5264
  SR_CORE ("trcacvr1",      CPENC (2,1,C2,C2,0),  0),
5265
  SR_CORE ("trcacvr2",      CPENC (2,1,C2,C4,0),  0),
5266
  SR_CORE ("trcacvr3",      CPENC (2,1,C2,C6,0),  0),
5267
  SR_CORE ("trcacvr4",      CPENC (2,1,C2,C8,0),  0),
5268
  SR_CORE ("trcacvr5",      CPENC (2,1,C2,C10,0), 0),
5269
  SR_CORE ("trcacvr6",      CPENC (2,1,C2,C12,0), 0),
5270
  SR_CORE ("trcacvr7",      CPENC (2,1,C2,C14,0), 0),
5271
  SR_CORE ("trcacvr8",      CPENC (2,1,C2,C0,1),  0),
5272
  SR_CORE ("trcacvr9",      CPENC (2,1,C2,C2,1),  0),
5273
  SR_CORE ("trcacvr10",     CPENC (2,1,C2,C4,1),  0),
5274
  SR_CORE ("trcacvr11",     CPENC (2,1,C2,C6,1),  0),
5275
  SR_CORE ("trcacvr12",     CPENC (2,1,C2,C8,1),  0),
5276
  SR_CORE ("trcacvr13",     CPENC (2,1,C2,C10,1), 0),
5277
  SR_CORE ("trcacvr14",     CPENC (2,1,C2,C12,1), 0),
5278
  SR_CORE ("trcacvr15",     CPENC (2,1,C2,C14,1), 0),
5279
  SR_CORE ("trcauxctlr",    CPENC (2,1,C0,C6,0),  0),
5280
  SR_CORE ("trcbbctlr",     CPENC (2,1,C0,C15,0), 0),
5281
  SR_CORE ("trcccctlr",     CPENC (2,1,C0,C14,0), 0),
5282
  SR_CORE ("trccidcctlr0",  CPENC (2,1,C3,C0,2),  0),
5283
  SR_CORE ("trccidcctlr1",  CPENC (2,1,C3,C1,2),  0),
5284
  SR_CORE ("trccidcvr0",    CPENC (2,1,C3,C0,0),  0),
5285
  SR_CORE ("trccidcvr1",    CPENC (2,1,C3,C2,0),  0),
5286
  SR_CORE ("trccidcvr2",    CPENC (2,1,C3,C4,0),  0),
5287
  SR_CORE ("trccidcvr3",    CPENC (2,1,C3,C6,0),  0),
5288
  SR_CORE ("trccidcvr4",    CPENC (2,1,C3,C8,0),  0),
5289
  SR_CORE ("trccidcvr5",    CPENC (2,1,C3,C10,0), 0),
5290
  SR_CORE ("trccidcvr6",    CPENC (2,1,C3,C12,0), 0),
5291
  SR_CORE ("trccidcvr7",    CPENC (2,1,C3,C14,0), 0),
5292
  SR_CORE ("trcclaimclr",   CPENC (2,1,C7,C9,6),  0),
5293
  SR_CORE ("trcclaimset",   CPENC (2,1,C7,C8,6),  0),
5294
  SR_CORE ("trccntctlr0",   CPENC (2,1,C0,C4,5),  0),
5295
  SR_CORE ("trccntctlr1",   CPENC (2,1,C0,C5,5),  0),
5296
  SR_CORE ("trccntctlr2",   CPENC (2,1,C0,C6,5),  0),
5297
  SR_CORE ("trccntctlr3",   CPENC (2,1,C0,C7,5),  0),
5298
  SR_CORE ("trccntrldvr0",  CPENC (2,1,C0,C0,5),  0),
5299
  SR_CORE ("trccntrldvr1",  CPENC (2,1,C0,C1,5),  0),
5300
  SR_CORE ("trccntrldvr2",  CPENC (2,1,C0,C2,5),  0),
5301
  SR_CORE ("trccntrldvr3",  CPENC (2,1,C0,C3,5),  0),
5302
  SR_CORE ("trccntvr0",     CPENC (2,1,C0,C8,5),  0),
5303
  SR_CORE ("trccntvr1",     CPENC (2,1,C0,C9,5),  0),
5304
  SR_CORE ("trccntvr2",     CPENC (2,1,C0,C10,5), 0),
5305
  SR_CORE ("trccntvr3",     CPENC (2,1,C0,C11,5), 0),
5306
  SR_CORE ("trcconfigr",    CPENC (2,1,C0,C4,0),  0),
5307
  SR_CORE ("trcdvcmr0",     CPENC (2,1,C2,C0,6),  0),
5308
  SR_CORE ("trcdvcmr1",     CPENC (2,1,C2,C4,6),  0),
5309
  SR_CORE ("trcdvcmr2",     CPENC (2,1,C2,C8,6),  0),
5310
  SR_CORE ("trcdvcmr3",     CPENC (2,1,C2,C12,6), 0),
5311
  SR_CORE ("trcdvcmr4",     CPENC (2,1,C2,C0,7),  0),
5312
  SR_CORE ("trcdvcmr5",     CPENC (2,1,C2,C4,7),  0),
5313
  SR_CORE ("trcdvcmr6",     CPENC (2,1,C2,C8,7),  0),
5314
  SR_CORE ("trcdvcmr7",     CPENC (2,1,C2,C12,7), 0),
5315
  SR_CORE ("trcdvcvr0",     CPENC (2,1,C2,C0,4),  0),
5316
  SR_CORE ("trcdvcvr1",     CPENC (2,1,C2,C4,4),  0),
5317
  SR_CORE ("trcdvcvr2",     CPENC (2,1,C2,C8,4),  0),
5318
  SR_CORE ("trcdvcvr3",     CPENC (2,1,C2,C12,4), 0),
5319
  SR_CORE ("trcdvcvr4",     CPENC (2,1,C2,C0,5),  0),
5320
  SR_CORE ("trcdvcvr5",     CPENC (2,1,C2,C4,5),  0),
5321
  SR_CORE ("trcdvcvr6",     CPENC (2,1,C2,C8,5),  0),
5322
  SR_CORE ("trcdvcvr7",     CPENC (2,1,C2,C12,5), 0),
5323
  SR_CORE ("trceventctl0r", CPENC (2,1,C0,C8,0),  0),
5324
  SR_CORE ("trceventctl1r", CPENC (2,1,C0,C9,0),  0),
5325
  SR_CORE ("trcextinselr0", CPENC (2,1,C0,C8,4),  0),
5326
  SR_CORE ("trcextinselr",  CPENC (2,1,C0,C8,4),  0),
5327
  SR_CORE ("trcextinselr1", CPENC (2,1,C0,C9,4),  0),
5328
  SR_CORE ("trcextinselr2", CPENC (2,1,C0,C10,4), 0),
5329
  SR_CORE ("trcextinselr3", CPENC (2,1,C0,C11,4), 0),
5330
  SR_CORE ("trcimspec0",    CPENC (2,1,C0,C0,7),  0),
5331
  SR_CORE ("trcimspec1",    CPENC (2,1,C0,C1,7),  0),
5332
  SR_CORE ("trcimspec2",    CPENC (2,1,C0,C2,7),  0),
5333
  SR_CORE ("trcimspec3",    CPENC (2,1,C0,C3,7),  0),
5334
  SR_CORE ("trcimspec4",    CPENC (2,1,C0,C4,7),  0),
5335
  SR_CORE ("trcimspec5",    CPENC (2,1,C0,C5,7),  0),
5336
  SR_CORE ("trcimspec6",    CPENC (2,1,C0,C6,7),  0),
5337
  SR_CORE ("trcimspec7",    CPENC (2,1,C0,C7,7),  0),
5338
  SR_CORE ("trcitctrl",     CPENC (2,1,C7,C0,4),  0),
5339
  SR_CORE ("trcpdcr",       CPENC (2,1,C1,C4,4),  0),
5340
  SR_CORE ("trcprgctlr",    CPENC (2,1,C0,C1,0),  0),
5341
  SR_CORE ("trcprocselr",   CPENC (2,1,C0,C2,0),  0),
5342
  SR_CORE ("trcqctlr",      CPENC (2,1,C0,C1,1),  0),
5343
  SR_CORE ("trcrsr",        CPENC (2,1,C0,C10,0), 0),
5344
  SR_CORE ("trcrsctlr2",    CPENC (2,1,C1,C2,0),  0),
5345
  SR_CORE ("trcrsctlr3",    CPENC (2,1,C1,C3,0),  0),
5346
  SR_CORE ("trcrsctlr4",    CPENC (2,1,C1,C4,0),  0),
5347
  SR_CORE ("trcrsctlr5",    CPENC (2,1,C1,C5,0),  0),
5348
  SR_CORE ("trcrsctlr6",    CPENC (2,1,C1,C6,0),  0),
5349
  SR_CORE ("trcrsctlr7",    CPENC (2,1,C1,C7,0),  0),
5350
  SR_CORE ("trcrsctlr8",    CPENC (2,1,C1,C8,0),  0),
5351
  SR_CORE ("trcrsctlr9",    CPENC (2,1,C1,C9,0),  0),
5352
  SR_CORE ("trcrsctlr10",   CPENC (2,1,C1,C10,0), 0),
5353
  SR_CORE ("trcrsctlr11",   CPENC (2,1,C1,C11,0), 0),
5354
  SR_CORE ("trcrsctlr12",   CPENC (2,1,C1,C12,0), 0),
5355
  SR_CORE ("trcrsctlr13",   CPENC (2,1,C1,C13,0), 0),
5356
  SR_CORE ("trcrsctlr14",   CPENC (2,1,C1,C14,0), 0),
5357
  SR_CORE ("trcrsctlr15",   CPENC (2,1,C1,C15,0), 0),
5358
  SR_CORE ("trcrsctlr16",   CPENC (2,1,C1,C0,1),  0),
5359
  SR_CORE ("trcrsctlr17",   CPENC (2,1,C1,C1,1),  0),
5360
  SR_CORE ("trcrsctlr18",   CPENC (2,1,C1,C2,1),  0),
5361
  SR_CORE ("trcrsctlr19",   CPENC (2,1,C1,C3,1),  0),
5362
  SR_CORE ("trcrsctlr20",   CPENC (2,1,C1,C4,1),  0),
5363
  SR_CORE ("trcrsctlr21",   CPENC (2,1,C1,C5,1),  0),
5364
  SR_CORE ("trcrsctlr22",   CPENC (2,1,C1,C6,1),  0),
5365
  SR_CORE ("trcrsctlr23",   CPENC (2,1,C1,C7,1),  0),
5366
  SR_CORE ("trcrsctlr24",   CPENC (2,1,C1,C8,1),  0),
5367
  SR_CORE ("trcrsctlr25",   CPENC (2,1,C1,C9,1),  0),
5368
  SR_CORE ("trcrsctlr26",   CPENC (2,1,C1,C10,1), 0),
5369
  SR_CORE ("trcrsctlr27",   CPENC (2,1,C1,C11,1), 0),
5370
  SR_CORE ("trcrsctlr28",   CPENC (2,1,C1,C12,1), 0),
5371
  SR_CORE ("trcrsctlr29",   CPENC (2,1,C1,C13,1), 0),
5372
  SR_CORE ("trcrsctlr30",   CPENC (2,1,C1,C14,1), 0),
5373
  SR_CORE ("trcrsctlr31",   CPENC (2,1,C1,C15,1), 0),
5374
  SR_CORE ("trcseqevr0",    CPENC (2,1,C0,C0,4),  0),
5375
  SR_CORE ("trcseqevr1",    CPENC (2,1,C0,C1,4),  0),
5376
  SR_CORE ("trcseqevr2",    CPENC (2,1,C0,C2,4),  0),
5377
  SR_CORE ("trcseqrstevr",  CPENC (2,1,C0,C6,4),  0),
5378
  SR_CORE ("trcseqstr",     CPENC (2,1,C0,C7,4),  0),
5379
  SR_CORE ("trcssccr0",     CPENC (2,1,C1,C0,2),  0),
5380
  SR_CORE ("trcssccr1",     CPENC (2,1,C1,C1,2),  0),
5381
  SR_CORE ("trcssccr2",     CPENC (2,1,C1,C2,2),  0),
5382
  SR_CORE ("trcssccr3",     CPENC (2,1,C1,C3,2),  0),
5383
  SR_CORE ("trcssccr4",     CPENC (2,1,C1,C4,2),  0),
5384
  SR_CORE ("trcssccr5",     CPENC (2,1,C1,C5,2),  0),
5385
  SR_CORE ("trcssccr6",     CPENC (2,1,C1,C6,2),  0),
5386
  SR_CORE ("trcssccr7",     CPENC (2,1,C1,C7,2),  0),
5387
  SR_CORE ("trcsscsr0",     CPENC (2,1,C1,C8,2),  0),
5388
  SR_CORE ("trcsscsr1",     CPENC (2,1,C1,C9,2),  0),
5389
  SR_CORE ("trcsscsr2",     CPENC (2,1,C1,C10,2), 0),
5390
  SR_CORE ("trcsscsr3",     CPENC (2,1,C1,C11,2), 0),
5391
  SR_CORE ("trcsscsr4",     CPENC (2,1,C1,C12,2), 0),
5392
  SR_CORE ("trcsscsr5",     CPENC (2,1,C1,C13,2), 0),
5393
  SR_CORE ("trcsscsr6",     CPENC (2,1,C1,C14,2), 0),
5394
  SR_CORE ("trcsscsr7",     CPENC (2,1,C1,C15,2), 0),
5395
  SR_CORE ("trcsspcicr0",   CPENC (2,1,C1,C0,3),  0),
5396
  SR_CORE ("trcsspcicr1",   CPENC (2,1,C1,C1,3),  0),
5397
  SR_CORE ("trcsspcicr2",   CPENC (2,1,C1,C2,3),  0),
5398
  SR_CORE ("trcsspcicr3",   CPENC (2,1,C1,C3,3),  0),
5399
  SR_CORE ("trcsspcicr4",   CPENC (2,1,C1,C4,3),  0),
5400
  SR_CORE ("trcsspcicr5",   CPENC (2,1,C1,C5,3),  0),
5401
  SR_CORE ("trcsspcicr6",   CPENC (2,1,C1,C6,3),  0),
5402
  SR_CORE ("trcsspcicr7",   CPENC (2,1,C1,C7,3),  0),
5403
  SR_CORE ("trcstallctlr",  CPENC (2,1,C0,C11,0), 0),
5404
  SR_CORE ("trcsyncpr",     CPENC (2,1,C0,C13,0), 0),
5405
  SR_CORE ("trctraceidr",   CPENC (2,1,C0,C0,1),  0),
5406
  SR_CORE ("trctsctlr",     CPENC (2,1,C0,C12,0), 0),
5407
  SR_CORE ("trcvdarcctlr",  CPENC (2,1,C0,C10,2), 0),
5408
  SR_CORE ("trcvdctlr",     CPENC (2,1,C0,C8,2),  0),
5409
  SR_CORE ("trcvdsacctlr",  CPENC (2,1,C0,C9,2),  0),
5410
  SR_CORE ("trcvictlr",     CPENC (2,1,C0,C0,2),  0),
5411
  SR_CORE ("trcviiectlr",   CPENC (2,1,C0,C1,2),  0),
5412
  SR_CORE ("trcvipcssctlr", CPENC (2,1,C0,C3,2),  0),
5413
  SR_CORE ("trcvissctlr",   CPENC (2,1,C0,C2,2),  0),
5414
  SR_CORE ("trcvmidcctlr0", CPENC (2,1,C3,C2,2),  0),
5415
  SR_CORE ("trcvmidcctlr1", CPENC (2,1,C3,C3,2),  0),
5416
  SR_CORE ("trcvmidcvr0",   CPENC (2,1,C3,C0,1),  0),
5417
  SR_CORE ("trcvmidcvr1",   CPENC (2,1,C3,C2,1),  0),
5418
  SR_CORE ("trcvmidcvr2",   CPENC (2,1,C3,C4,1),  0),
5419
  SR_CORE ("trcvmidcvr3",   CPENC (2,1,C3,C6,1),  0),
5420
  SR_CORE ("trcvmidcvr4",   CPENC (2,1,C3,C8,1),  0),
5421
  SR_CORE ("trcvmidcvr5",   CPENC (2,1,C3,C10,1), 0),
5422
  SR_CORE ("trcvmidcvr6",   CPENC (2,1,C3,C12,1), 0),
5423
  SR_CORE ("trcvmidcvr7",   CPENC (2,1,C3,C14,1), 0),
5424
  SR_CORE ("trclar",        CPENC (2,1,C7,C12,6), F_REG_WRITE),
5425
  SR_CORE ("trcoslar",      CPENC (2,1,C1,C0,4),  F_REG_WRITE),
5426
5427
  SR_CORE ("csrcr_el0",     CPENC (2,3,C8,C0,0),  0),
5428
  SR_CORE ("csrptr_el0",    CPENC (2,3,C8,C0,1),  0),
5429
  SR_CORE ("csridr_el0",    CPENC (2,3,C8,C0,2),  F_REG_READ),
5430
  SR_CORE ("csrptridx_el0", CPENC (2,3,C8,C0,3),  F_REG_READ),
5431
  SR_CORE ("csrcr_el1",     CPENC (2,0,C8,C0,0),  0),
5432
  SR_CORE ("csrcr_el12",    CPENC (2,5,C8,C0,0),  0),
5433
  SR_CORE ("csrptr_el1",    CPENC (2,0,C8,C0,1),  0),
5434
  SR_CORE ("csrptr_el12",   CPENC (2,5,C8,C0,1),  0),
5435
  SR_CORE ("csrptridx_el1", CPENC (2,0,C8,C0,3),  F_REG_READ),
5436
  SR_CORE ("csrcr_el2",     CPENC (2,4,C8,C0,0),  0),
5437
  SR_CORE ("csrptr_el2",    CPENC (2,4,C8,C0,1),  0),
5438
  SR_CORE ("csrptridx_el2", CPENC (2,4,C8,C0,3),  F_REG_READ),
5439
5440
  SR_LOR ("lorid_el1",      CPENC (3,0,C10,C4,7),  F_REG_READ),
5441
  SR_LOR ("lorc_el1",       CPENC (3,0,C10,C4,3),  0),
5442
  SR_LOR ("lorea_el1",      CPENC (3,0,C10,C4,1),  0),
5443
  SR_LOR ("lorn_el1",       CPENC (3,0,C10,C4,2),  0),
5444
  SR_LOR ("lorsa_el1",      CPENC (3,0,C10,C4,0),  0),
5445
5446
  SR_CORE ("icc_ctlr_el3",  CPENC (3,6,C12,C12,4), 0),
5447
  SR_CORE ("icc_sre_el1",   CPENC (3,0,C12,C12,5), 0),
5448
  SR_CORE ("icc_sre_el2",   CPENC (3,4,C12,C9,5),  0),
5449
  SR_CORE ("icc_sre_el3",   CPENC (3,6,C12,C12,5), 0),
5450
  SR_CORE ("ich_vtr_el2",   CPENC (3,4,C12,C11,1), F_REG_READ),
5451
5452
  SR_CORE ("brbcr_el1",     CPENC (2,1,C9,C0,0),  0),
5453
  SR_CORE ("brbcr_el12",    CPENC (2,5,C9,C0,0),  0),
5454
  SR_CORE ("brbfcr_el1",    CPENC (2,1,C9,C0,1),  0),
5455
  SR_CORE ("brbts_el1",     CPENC (2,1,C9,C0,2),  0),
5456
  SR_CORE ("brbinfinj_el1", CPENC (2,1,C9,C1,0),  0),
5457
  SR_CORE ("brbsrcinj_el1", CPENC (2,1,C9,C1,1),  0),
5458
  SR_CORE ("brbtgtinj_el1", CPENC (2,1,C9,C1,2),  0),
5459
  SR_CORE ("brbidr0_el1",   CPENC (2,1,C9,C2,0),  F_REG_READ),
5460
  SR_CORE ("brbcr_el2",     CPENC (2,4,C9,C0,0),  0),
5461
  SR_CORE ("brbsrc0_el1",   CPENC (2,1,C8,C0,1),  F_REG_READ),
5462
  SR_CORE ("brbsrc1_el1",   CPENC (2,1,C8,C1,1),  F_REG_READ),
5463
  SR_CORE ("brbsrc2_el1",   CPENC (2,1,C8,C2,1),  F_REG_READ),
5464
  SR_CORE ("brbsrc3_el1",   CPENC (2,1,C8,C3,1),  F_REG_READ),
5465
  SR_CORE ("brbsrc4_el1",   CPENC (2,1,C8,C4,1),  F_REG_READ),
5466
  SR_CORE ("brbsrc5_el1",   CPENC (2,1,C8,C5,1),  F_REG_READ),
5467
  SR_CORE ("brbsrc6_el1",   CPENC (2,1,C8,C6,1),  F_REG_READ),
5468
  SR_CORE ("brbsrc7_el1",   CPENC (2,1,C8,C7,1),  F_REG_READ),
5469
  SR_CORE ("brbsrc8_el1",   CPENC (2,1,C8,C8,1),  F_REG_READ),
5470
  SR_CORE ("brbsrc9_el1",   CPENC (2,1,C8,C9,1),  F_REG_READ),
5471
  SR_CORE ("brbsrc10_el1",  CPENC (2,1,C8,C10,1), F_REG_READ),
5472
  SR_CORE ("brbsrc11_el1",  CPENC (2,1,C8,C11,1), F_REG_READ),
5473
  SR_CORE ("brbsrc12_el1",  CPENC (2,1,C8,C12,1), F_REG_READ),
5474
  SR_CORE ("brbsrc13_el1",  CPENC (2,1,C8,C13,1), F_REG_READ),
5475
  SR_CORE ("brbsrc14_el1",  CPENC (2,1,C8,C14,1), F_REG_READ),
5476
  SR_CORE ("brbsrc15_el1",  CPENC (2,1,C8,C15,1), F_REG_READ),
5477
  SR_CORE ("brbsrc16_el1",  CPENC (2,1,C8,C0,5),  F_REG_READ),
5478
  SR_CORE ("brbsrc17_el1",  CPENC (2,1,C8,C1,5),  F_REG_READ),
5479
  SR_CORE ("brbsrc18_el1",  CPENC (2,1,C8,C2,5),  F_REG_READ),
5480
  SR_CORE ("brbsrc19_el1",  CPENC (2,1,C8,C3,5),  F_REG_READ),
5481
  SR_CORE ("brbsrc20_el1",  CPENC (2,1,C8,C4,5),  F_REG_READ),
5482
  SR_CORE ("brbsrc21_el1",  CPENC (2,1,C8,C5,5),  F_REG_READ),
5483
  SR_CORE ("brbsrc22_el1",  CPENC (2,1,C8,C6,5),  F_REG_READ),
5484
  SR_CORE ("brbsrc23_el1",  CPENC (2,1,C8,C7,5),  F_REG_READ),
5485
  SR_CORE ("brbsrc24_el1",  CPENC (2,1,C8,C8,5),  F_REG_READ),
5486
  SR_CORE ("brbsrc25_el1",  CPENC (2,1,C8,C9,5),  F_REG_READ),
5487
  SR_CORE ("brbsrc26_el1",  CPENC (2,1,C8,C10,5), F_REG_READ),
5488
  SR_CORE ("brbsrc27_el1",  CPENC (2,1,C8,C11,5), F_REG_READ),
5489
  SR_CORE ("brbsrc28_el1",  CPENC (2,1,C8,C12,5), F_REG_READ),
5490
  SR_CORE ("brbsrc29_el1",  CPENC (2,1,C8,C13,5), F_REG_READ),
5491
  SR_CORE ("brbsrc30_el1",  CPENC (2,1,C8,C14,5), F_REG_READ),
5492
  SR_CORE ("brbsrc31_el1",  CPENC (2,1,C8,C15,5), F_REG_READ),
5493
  SR_CORE ("brbtgt0_el1",   CPENC (2,1,C8,C0,2),  F_REG_READ),
5494
  SR_CORE ("brbtgt1_el1",   CPENC (2,1,C8,C1,2),  F_REG_READ),
5495
  SR_CORE ("brbtgt2_el1",   CPENC (2,1,C8,C2,2),  F_REG_READ),
5496
  SR_CORE ("brbtgt3_el1",   CPENC (2,1,C8,C3,2),  F_REG_READ),
5497
  SR_CORE ("brbtgt4_el1",   CPENC (2,1,C8,C4,2),  F_REG_READ),
5498
  SR_CORE ("brbtgt5_el1",   CPENC (2,1,C8,C5,2),  F_REG_READ),
5499
  SR_CORE ("brbtgt6_el1",   CPENC (2,1,C8,C6,2),  F_REG_READ),
5500
  SR_CORE ("brbtgt7_el1",   CPENC (2,1,C8,C7,2),  F_REG_READ),
5501
  SR_CORE ("brbtgt8_el1",   CPENC (2,1,C8,C8,2),  F_REG_READ),
5502
  SR_CORE ("brbtgt9_el1",   CPENC (2,1,C8,C9,2),  F_REG_READ),
5503
  SR_CORE ("brbtgt10_el1",  CPENC (2,1,C8,C10,2), F_REG_READ),
5504
  SR_CORE ("brbtgt11_el1",  CPENC (2,1,C8,C11,2), F_REG_READ),
5505
  SR_CORE ("brbtgt12_el1",  CPENC (2,1,C8,C12,2), F_REG_READ),
5506
  SR_CORE ("brbtgt13_el1",  CPENC (2,1,C8,C13,2), F_REG_READ),
5507
  SR_CORE ("brbtgt14_el1",  CPENC (2,1,C8,C14,2), F_REG_READ),
5508
  SR_CORE ("brbtgt15_el1",  CPENC (2,1,C8,C15,2), F_REG_READ),
5509
  SR_CORE ("brbtgt16_el1",  CPENC (2,1,C8,C0,6),  F_REG_READ),
5510
  SR_CORE ("brbtgt17_el1",  CPENC (2,1,C8,C1,6),  F_REG_READ),
5511
  SR_CORE ("brbtgt18_el1",  CPENC (2,1,C8,C2,6),  F_REG_READ),
5512
  SR_CORE ("brbtgt19_el1",  CPENC (2,1,C8,C3,6),  F_REG_READ),
5513
  SR_CORE ("brbtgt20_el1",  CPENC (2,1,C8,C4,6),  F_REG_READ),
5514
  SR_CORE ("brbtgt21_el1",  CPENC (2,1,C8,C5,6),  F_REG_READ),
5515
  SR_CORE ("brbtgt22_el1",  CPENC (2,1,C8,C6,6),  F_REG_READ),
5516
  SR_CORE ("brbtgt23_el1",  CPENC (2,1,C8,C7,6),  F_REG_READ),
5517
  SR_CORE ("brbtgt24_el1",  CPENC (2,1,C8,C8,6),  F_REG_READ),
5518
  SR_CORE ("brbtgt25_el1",  CPENC (2,1,C8,C9,6),  F_REG_READ),
5519
  SR_CORE ("brbtgt26_el1",  CPENC (2,1,C8,C10,6), F_REG_READ),
5520
  SR_CORE ("brbtgt27_el1",  CPENC (2,1,C8,C11,6), F_REG_READ),
5521
  SR_CORE ("brbtgt28_el1",  CPENC (2,1,C8,C12,6), F_REG_READ),
5522
  SR_CORE ("brbtgt29_el1",  CPENC (2,1,C8,C13,6), F_REG_READ),
5523
  SR_CORE ("brbtgt30_el1",  CPENC (2,1,C8,C14,6), F_REG_READ),
5524
  SR_CORE ("brbtgt31_el1",  CPENC (2,1,C8,C15,6), F_REG_READ),
5525
  SR_CORE ("brbinf0_el1",   CPENC (2,1,C8,C0,0),  F_REG_READ),
5526
  SR_CORE ("brbinf1_el1",   CPENC (2,1,C8,C1,0),  F_REG_READ),
5527
  SR_CORE ("brbinf2_el1",   CPENC (2,1,C8,C2,0),  F_REG_READ),
5528
  SR_CORE ("brbinf3_el1",   CPENC (2,1,C8,C3,0),  F_REG_READ),
5529
  SR_CORE ("brbinf4_el1",   CPENC (2,1,C8,C4,0),  F_REG_READ),
5530
  SR_CORE ("brbinf5_el1",   CPENC (2,1,C8,C5,0),  F_REG_READ),
5531
  SR_CORE ("brbinf6_el1",   CPENC (2,1,C8,C6,0),  F_REG_READ),
5532
  SR_CORE ("brbinf7_el1",   CPENC (2,1,C8,C7,0),  F_REG_READ),
5533
  SR_CORE ("brbinf8_el1",   CPENC (2,1,C8,C8,0),  F_REG_READ),
5534
  SR_CORE ("brbinf9_el1",   CPENC (2,1,C8,C9,0),  F_REG_READ),
5535
  SR_CORE ("brbinf10_el1",  CPENC (2,1,C8,C10,0), F_REG_READ),
5536
  SR_CORE ("brbinf11_el1",  CPENC (2,1,C8,C11,0), F_REG_READ),
5537
  SR_CORE ("brbinf12_el1",  CPENC (2,1,C8,C12,0), F_REG_READ),
5538
  SR_CORE ("brbinf13_el1",  CPENC (2,1,C8,C13,0), F_REG_READ),
5539
  SR_CORE ("brbinf14_el1",  CPENC (2,1,C8,C14,0), F_REG_READ),
5540
  SR_CORE ("brbinf15_el1",  CPENC (2,1,C8,C15,0), F_REG_READ),
5541
  SR_CORE ("brbinf16_el1",  CPENC (2,1,C8,C0,4),  F_REG_READ),
5542
  SR_CORE ("brbinf17_el1",  CPENC (2,1,C8,C1,4),  F_REG_READ),
5543
  SR_CORE ("brbinf18_el1",  CPENC (2,1,C8,C2,4),  F_REG_READ),
5544
  SR_CORE ("brbinf19_el1",  CPENC (2,1,C8,C3,4),  F_REG_READ),
5545
  SR_CORE ("brbinf20_el1",  CPENC (2,1,C8,C4,4),  F_REG_READ),
5546
  SR_CORE ("brbinf21_el1",  CPENC (2,1,C8,C5,4),  F_REG_READ),
5547
  SR_CORE ("brbinf22_el1",  CPENC (2,1,C8,C6,4),  F_REG_READ),
5548
  SR_CORE ("brbinf23_el1",  CPENC (2,1,C8,C7,4),  F_REG_READ),
5549
  SR_CORE ("brbinf24_el1",  CPENC (2,1,C8,C8,4),  F_REG_READ),
5550
  SR_CORE ("brbinf25_el1",  CPENC (2,1,C8,C9,4),  F_REG_READ),
5551
  SR_CORE ("brbinf26_el1",  CPENC (2,1,C8,C10,4), F_REG_READ),
5552
  SR_CORE ("brbinf27_el1",  CPENC (2,1,C8,C11,4), F_REG_READ),
5553
  SR_CORE ("brbinf28_el1",  CPENC (2,1,C8,C12,4), F_REG_READ),
5554
  SR_CORE ("brbinf29_el1",  CPENC (2,1,C8,C13,4), F_REG_READ),
5555
  SR_CORE ("brbinf30_el1",  CPENC (2,1,C8,C14,4), F_REG_READ),
5556
  SR_CORE ("brbinf31_el1",  CPENC (2,1,C8,C15,4), F_REG_READ),
5557
5558
  SR_CORE ("accdata_el1",   CPENC (3,0,C13,C0,5), 0),
5559
5560
  SR_CORE ("mfar_el3",      CPENC (3,6,C6,C0,5), 0),
5561
  SR_CORE ("gpccr_el3",     CPENC (3,6,C2,C1,6), 0),
5562
  SR_CORE ("gptbr_el3",     CPENC (3,6,C2,C1,4), 0),
5563
5564
  SR_CORE ("mecidr_el2",    CPENC (3,4,C10,C8,7),  F_REG_READ),
5565
  SR_CORE ("mecid_p0_el2",  CPENC (3,4,C10,C8,0),  0),
5566
  SR_CORE ("mecid_a0_el2",  CPENC (3,4,C10,C8,1),  0),
5567
  SR_CORE ("mecid_p1_el2",  CPENC (3,4,C10,C8,2),  0),
5568
  SR_CORE ("mecid_a1_el2",  CPENC (3,4,C10,C8,3),  0),
5569
  SR_CORE ("vmecid_p_el2",  CPENC (3,4,C10,C9,0),  0),
5570
  SR_CORE ("vmecid_a_el2",  CPENC (3,4,C10,C9,1),  0),
5571
  SR_CORE ("mecid_rl_a_el3",CPENC (3,6,C10,C10,1), 0),
5572
5573
  SR_SME ("svcr",             CPENC (3,3,C4,C2,2),  0),
5574
  SR_SME ("id_aa64smfr0_el1", CPENC (3,0,C0,C4,5),  F_REG_READ),
5575
  SR_SME ("smcr_el1",         CPENC (3,0,C1,C2,6),  0),
5576
  SR_SME ("smcr_el12",        CPENC (3,5,C1,C2,6),  0),
5577
  SR_SME ("smcr_el2",         CPENC (3,4,C1,C2,6),  0),
5578
  SR_SME ("smcr_el3",         CPENC (3,6,C1,C2,6),  0),
5579
  SR_SME ("smpri_el1",        CPENC (3,0,C1,C2,4),  0),
5580
  SR_SME ("smprimap_el2",     CPENC (3,4,C1,C2,5),  0),
5581
  SR_SME ("smidr_el1",        CPENC (3,1,C0,C0,6),  F_REG_READ),
5582
  SR_SME ("tpidr2_el0",       CPENC (3,3,C13,C0,5), 0),
5583
  SR_SME ("mpamsm_el1",       CPENC (3,0,C10,C5,3), 0),
5584
5585
  SR_AMU ("amcr_el0",           CPENC (3,3,C13,C2,0),   0),
5586
  SR_AMU ("amcfgr_el0",         CPENC (3,3,C13,C2,1),   F_REG_READ),
5587
  SR_AMU ("amcgcr_el0",         CPENC (3,3,C13,C2,2),   F_REG_READ),
5588
  SR_AMU ("amuserenr_el0",      CPENC (3,3,C13,C2,3),   0),
5589
  SR_AMU ("amcntenclr0_el0",    CPENC (3,3,C13,C2,4),   0),
5590
  SR_AMU ("amcntenset0_el0",    CPENC (3,3,C13,C2,5),   0),
5591
  SR_AMU ("amcntenclr1_el0",    CPENC (3,3,C13,C3,0),   0),
5592
  SR_AMU ("amcntenset1_el0",    CPENC (3,3,C13,C3,1),   0),
5593
  SR_AMU ("amevcntr00_el0",     CPENC (3,3,C13,C4,0),   0),
5594
  SR_AMU ("amevcntr01_el0",     CPENC (3,3,C13,C4,1),   0),
5595
  SR_AMU ("amevcntr02_el0",     CPENC (3,3,C13,C4,2),   0),
5596
  SR_AMU ("amevcntr03_el0",     CPENC (3,3,C13,C4,3),   0),
5597
  SR_AMU ("amevtyper00_el0",    CPENC (3,3,C13,C6,0),   F_REG_READ),
5598
  SR_AMU ("amevtyper01_el0",    CPENC (3,3,C13,C6,1),   F_REG_READ),
5599
  SR_AMU ("amevtyper02_el0",    CPENC (3,3,C13,C6,2),   F_REG_READ),
5600
  SR_AMU ("amevtyper03_el0",    CPENC (3,3,C13,C6,3),   F_REG_READ),
5601
  SR_AMU ("amevcntr10_el0",     CPENC (3,3,C13,C12,0),  0),
5602
  SR_AMU ("amevcntr11_el0",     CPENC (3,3,C13,C12,1),  0),
5603
  SR_AMU ("amevcntr12_el0",     CPENC (3,3,C13,C12,2),  0),
5604
  SR_AMU ("amevcntr13_el0",     CPENC (3,3,C13,C12,3),  0),
5605
  SR_AMU ("amevcntr14_el0",     CPENC (3,3,C13,C12,4),  0),
5606
  SR_AMU ("amevcntr15_el0",     CPENC (3,3,C13,C12,5),  0),
5607
  SR_AMU ("amevcntr16_el0",     CPENC (3,3,C13,C12,6),  0),
5608
  SR_AMU ("amevcntr17_el0",     CPENC (3,3,C13,C12,7),  0),
5609
  SR_AMU ("amevcntr18_el0",     CPENC (3,3,C13,C13,0),  0),
5610
  SR_AMU ("amevcntr19_el0",     CPENC (3,3,C13,C13,1),  0),
5611
  SR_AMU ("amevcntr110_el0",    CPENC (3,3,C13,C13,2),  0),
5612
  SR_AMU ("amevcntr111_el0",    CPENC (3,3,C13,C13,3),  0),
5613
  SR_AMU ("amevcntr112_el0",    CPENC (3,3,C13,C13,4),  0),
5614
  SR_AMU ("amevcntr113_el0",    CPENC (3,3,C13,C13,5),  0),
5615
  SR_AMU ("amevcntr114_el0",    CPENC (3,3,C13,C13,6),  0),
5616
  SR_AMU ("amevcntr115_el0",    CPENC (3,3,C13,C13,7),  0),
5617
  SR_AMU ("amevtyper10_el0",    CPENC (3,3,C13,C14,0),  0),
5618
  SR_AMU ("amevtyper11_el0",    CPENC (3,3,C13,C14,1),  0),
5619
  SR_AMU ("amevtyper12_el0",    CPENC (3,3,C13,C14,2),  0),
5620
  SR_AMU ("amevtyper13_el0",    CPENC (3,3,C13,C14,3),  0),
5621
  SR_AMU ("amevtyper14_el0",    CPENC (3,3,C13,C14,4),  0),
5622
  SR_AMU ("amevtyper15_el0",    CPENC (3,3,C13,C14,5),  0),
5623
  SR_AMU ("amevtyper16_el0",    CPENC (3,3,C13,C14,6),  0),
5624
  SR_AMU ("amevtyper17_el0",    CPENC (3,3,C13,C14,7),  0),
5625
  SR_AMU ("amevtyper18_el0",    CPENC (3,3,C13,C15,0),  0),
5626
  SR_AMU ("amevtyper19_el0",    CPENC (3,3,C13,C15,1),  0),
5627
  SR_AMU ("amevtyper110_el0",   CPENC (3,3,C13,C15,2),  0),
5628
  SR_AMU ("amevtyper111_el0",   CPENC (3,3,C13,C15,3),  0),
5629
  SR_AMU ("amevtyper112_el0",   CPENC (3,3,C13,C15,4),  0),
5630
  SR_AMU ("amevtyper113_el0",   CPENC (3,3,C13,C15,5),  0),
5631
  SR_AMU ("amevtyper114_el0",   CPENC (3,3,C13,C15,6),  0),
5632
  SR_AMU ("amevtyper115_el0",   CPENC (3,3,C13,C15,7),  0),
5633
5634
  SR_GIC ("icc_pmr_el1",        CPENC (3,0,C4,C6,0),    0),
5635
  SR_GIC ("icc_iar0_el1",       CPENC (3,0,C12,C8,0),   F_REG_READ),
5636
  SR_GIC ("icc_eoir0_el1",      CPENC (3,0,C12,C8,1),   F_REG_WRITE),
5637
  SR_GIC ("icc_hppir0_el1",     CPENC (3,0,C12,C8,2),   F_REG_READ),
5638
  SR_GIC ("icc_bpr0_el1",       CPENC (3,0,C12,C8,3),   0),
5639
  SR_GIC ("icc_ap0r0_el1",      CPENC (3,0,C12,C8,4),   0),
5640
  SR_GIC ("icc_ap0r1_el1",      CPENC (3,0,C12,C8,5),   0),
5641
  SR_GIC ("icc_ap0r2_el1",      CPENC (3,0,C12,C8,6),   0),
5642
  SR_GIC ("icc_ap0r3_el1",      CPENC (3,0,C12,C8,7),   0),
5643
  SR_GIC ("icc_ap1r0_el1",      CPENC (3,0,C12,C9,0),   0),
5644
  SR_GIC ("icc_ap1r1_el1",      CPENC (3,0,C12,C9,1),   0),
5645
  SR_GIC ("icc_ap1r2_el1",      CPENC (3,0,C12,C9,2),   0),
5646
  SR_GIC ("icc_ap1r3_el1",      CPENC (3,0,C12,C9,3),   0),
5647
  SR_GIC ("icc_dir_el1",        CPENC (3,0,C12,C11,1),  F_REG_WRITE),
5648
  SR_GIC ("icc_rpr_el1",        CPENC (3,0,C12,C11,3),  F_REG_READ),
5649
  SR_GIC ("icc_sgi1r_el1",      CPENC (3,0,C12,C11,5),  F_REG_WRITE),
5650
  SR_GIC ("icc_asgi1r_el1",     CPENC (3,0,C12,C11,6),  F_REG_WRITE),
5651
  SR_GIC ("icc_sgi0r_el1",      CPENC (3,0,C12,C11,7),  F_REG_WRITE),
5652
  SR_GIC ("icc_iar1_el1",       CPENC (3,0,C12,C12,0),  F_REG_READ),
5653
  SR_GIC ("icc_eoir1_el1",      CPENC (3,0,C12,C12,1),  F_REG_WRITE),
5654
  SR_GIC ("icc_hppir1_el1",     CPENC (3,0,C12,C12,2),  F_REG_READ),
5655
  SR_GIC ("icc_bpr1_el1",       CPENC (3,0,C12,C12,3),  0),
5656
  SR_GIC ("icc_ctlr_el1",       CPENC (3,0,C12,C12,4),  0),
5657
  SR_GIC ("icc_igrpen0_el1",    CPENC (3,0,C12,C12,6),  0),
5658
  SR_GIC ("icc_igrpen1_el1",    CPENC (3,0,C12,C12,7),  0),
5659
  SR_GIC ("ich_ap0r0_el2",      CPENC (3,4,C12,C8,0),   0),
5660
  SR_GIC ("ich_ap0r1_el2",      CPENC (3,4,C12,C8,1),   0),
5661
  SR_GIC ("ich_ap0r2_el2",      CPENC (3,4,C12,C8,2),   0),
5662
  SR_GIC ("ich_ap0r3_el2",      CPENC (3,4,C12,C8,3),   0),
5663
  SR_GIC ("ich_ap1r0_el2",      CPENC (3,4,C12,C9,0),   0),
5664
  SR_GIC ("ich_ap1r1_el2",      CPENC (3,4,C12,C9,1),   0),
5665
  SR_GIC ("ich_ap1r2_el2",      CPENC (3,4,C12,C9,2),   0),
5666
  SR_GIC ("ich_ap1r3_el2",      CPENC (3,4,C12,C9,3),   0),
5667
  SR_GIC ("ich_hcr_el2",        CPENC (3,4,C12,C11,0),  0),
5668
  SR_GIC ("ich_misr_el2",       CPENC (3,4,C12,C11,2),  F_REG_READ),
5669
  SR_GIC ("ich_eisr_el2",       CPENC (3,4,C12,C11,3),  F_REG_READ),
5670
  SR_GIC ("ich_elrsr_el2",      CPENC (3,4,C12,C11,5),  F_REG_READ),
5671
  SR_GIC ("ich_vmcr_el2",       CPENC (3,4,C12,C11,7),  0),
5672
  SR_GIC ("ich_lr0_el2",        CPENC (3,4,C12,C12,0),  0),
5673
  SR_GIC ("ich_lr1_el2",        CPENC (3,4,C12,C12,1),  0),
5674
  SR_GIC ("ich_lr2_el2",        CPENC (3,4,C12,C12,2),  0),
5675
  SR_GIC ("ich_lr3_el2",        CPENC (3,4,C12,C12,3),  0),
5676
  SR_GIC ("ich_lr4_el2",        CPENC (3,4,C12,C12,4),  0),
5677
  SR_GIC ("ich_lr5_el2",        CPENC (3,4,C12,C12,5),  0),
5678
  SR_GIC ("ich_lr6_el2",        CPENC (3,4,C12,C12,6),  0),
5679
  SR_GIC ("ich_lr7_el2",        CPENC (3,4,C12,C12,7),  0),
5680
  SR_GIC ("ich_lr8_el2",        CPENC (3,4,C12,C13,0),  0),
5681
  SR_GIC ("ich_lr9_el2",        CPENC (3,4,C12,C13,1),  0),
5682
  SR_GIC ("ich_lr10_el2",       CPENC (3,4,C12,C13,2),  0),
5683
  SR_GIC ("ich_lr11_el2",       CPENC (3,4,C12,C13,3),  0),
5684
  SR_GIC ("ich_lr12_el2",       CPENC (3,4,C12,C13,4),  0),
5685
  SR_GIC ("ich_lr13_el2",       CPENC (3,4,C12,C13,5),  0),
5686
  SR_GIC ("ich_lr14_el2",       CPENC (3,4,C12,C13,6),  0),
5687
  SR_GIC ("ich_lr15_el2",       CPENC (3,4,C12,C13,7),  0),
5688
  SR_GIC ("icc_igrpen1_el3",    CPENC (3,6,C12,C12,7),  0),
5689
5690
  SR_V8_6 ("amcg1idr_el0",      CPENC (3,3,C13,C2,6),   F_REG_READ),
5691
  SR_V8_6 ("cntpctss_el0",      CPENC (3,3,C14,C0,5),   F_REG_READ),
5692
  SR_V8_6 ("cntvctss_el0",      CPENC (3,3,C14,C0,6),   F_REG_READ),
5693
  SR_V8_6 ("hfgrtr_el2",        CPENC (3,4,C1,C1,4),    0),
5694
  SR_V8_6 ("hfgwtr_el2",        CPENC (3,4,C1,C1,5),    0),
5695
  SR_V8_6 ("hfgitr_el2",        CPENC (3,4,C1,C1,6),    0),
5696
  SR_V8_6 ("hdfgrtr_el2",       CPENC (3,4,C3,C1,4),    0),
5697
  SR_V8_6 ("hdfgwtr_el2",       CPENC (3,4,C3,C1,5),    0),
5698
  SR_V8_6 ("hafgrtr_el2",       CPENC (3,4,C3,C1,6),    0),
5699
  SR_V8_6 ("amevcntvoff00_el2", CPENC (3,4,C13,C8,0),   0),
5700
  SR_V8_6 ("amevcntvoff01_el2", CPENC (3,4,C13,C8,1),   0),
5701
  SR_V8_6 ("amevcntvoff02_el2", CPENC (3,4,C13,C8,2),   0),
5702
  SR_V8_6 ("amevcntvoff03_el2", CPENC (3,4,C13,C8,3),   0),
5703
  SR_V8_6 ("amevcntvoff04_el2", CPENC (3,4,C13,C8,4),   0),
5704
  SR_V8_6 ("amevcntvoff05_el2", CPENC (3,4,C13,C8,5),   0),
5705
  SR_V8_6 ("amevcntvoff06_el2", CPENC (3,4,C13,C8,6),   0),
5706
  SR_V8_6 ("amevcntvoff07_el2", CPENC (3,4,C13,C8,7),   0),
5707
  SR_V8_6 ("amevcntvoff08_el2", CPENC (3,4,C13,C9,0),   0),
5708
  SR_V8_6 ("amevcntvoff09_el2", CPENC (3,4,C13,C9,1),   0),
5709
  SR_V8_6 ("amevcntvoff010_el2", CPENC (3,4,C13,C9,2),  0),
5710
  SR_V8_6 ("amevcntvoff011_el2", CPENC (3,4,C13,C9,3),  0),
5711
  SR_V8_6 ("amevcntvoff012_el2", CPENC (3,4,C13,C9,4),  0),
5712
  SR_V8_6 ("amevcntvoff013_el2", CPENC (3,4,C13,C9,5),  0),
5713
  SR_V8_6 ("amevcntvoff014_el2", CPENC (3,4,C13,C9,6),  0),
5714
  SR_V8_6 ("amevcntvoff015_el2", CPENC (3,4,C13,C9,7),  0),
5715
  SR_V8_6 ("amevcntvoff10_el2", CPENC (3,4,C13,C10,0),  0),
5716
  SR_V8_6 ("amevcntvoff11_el2", CPENC (3,4,C13,C10,1),  0),
5717
  SR_V8_6 ("amevcntvoff12_el2", CPENC (3,4,C13,C10,2),  0),
5718
  SR_V8_6 ("amevcntvoff13_el2", CPENC (3,4,C13,C10,3),  0),
5719
  SR_V8_6 ("amevcntvoff14_el2", CPENC (3,4,C13,C10,4),  0),
5720
  SR_V8_6 ("amevcntvoff15_el2", CPENC (3,4,C13,C10,5),  0),
5721
  SR_V8_6 ("amevcntvoff16_el2", CPENC (3,4,C13,C10,6),  0),
5722
  SR_V8_6 ("amevcntvoff17_el2", CPENC (3,4,C13,C10,7),  0),
5723
  SR_V8_6 ("amevcntvoff18_el2", CPENC (3,4,C13,C11,0),  0),
5724
  SR_V8_6 ("amevcntvoff19_el2", CPENC (3,4,C13,C11,1),  0),
5725
  SR_V8_6 ("amevcntvoff110_el2", CPENC (3,4,C13,C11,2), 0),
5726
  SR_V8_6 ("amevcntvoff111_el2", CPENC (3,4,C13,C11,3), 0),
5727
  SR_V8_6 ("amevcntvoff112_el2", CPENC (3,4,C13,C11,4), 0),
5728
  SR_V8_6 ("amevcntvoff113_el2", CPENC (3,4,C13,C11,5), 0),
5729
  SR_V8_6 ("amevcntvoff114_el2", CPENC (3,4,C13,C11,6), 0),
5730
  SR_V8_6 ("amevcntvoff115_el2", CPENC (3,4,C13,C11,7), 0),
5731
  SR_V8_6 ("cntpoff_el2",       CPENC (3,4,C14,C0,6),   0),
5732
5733
  SR_V8_7 ("pmsnevfr_el1",      CPENC (3,0,C9,C9,1),    0),
5734
  SR_V8_7 ("hcrx_el2",          CPENC (3,4,C1,C2,2),    0),
5735
5736
  SR_V8_8 ("allint",            CPENC (3,0,C4,C3,0),    0),
5737
  SR_V8_8 ("icc_nmiar1_el1",    CPENC (3,0,C12,C9,5),   F_REG_READ),
5738
5739
  { 0, CPENC (0,0,0,0,0), 0, 0 }
5740
};
5741
5742
bool
5743
aarch64_sys_reg_deprecated_p (const uint32_t reg_flags)
5744
684
{
5745
684
  return (reg_flags & F_DEPRECATED) != 0;
5746
684
}
5747
5748
/* The CPENC below is fairly misleading, the fields
5749
   here are not in CPENC form. They are in op2op1 form. The fields are encoded
5750
   by ins_pstatefield, which just shifts the value by the width of the fields
5751
   in a loop. So if you CPENC them only the first value will be set, the rest
5752
   are masked out to 0. As an example. op2 = 3, op1=2. CPENC would produce a
5753
   value of 0b110000000001000000 (0x30040) while what you want is
5754
   0b011010 (0x1a).  */
5755
const aarch64_sys_reg aarch64_pstatefields [] =
5756
{
5757
  SR_CORE ("spsel",   0x05, F_REG_MAX_VALUE (1)),
5758
  SR_CORE ("daifset",   0x1e, F_REG_MAX_VALUE (15)),
5759
  SR_CORE ("daifclr",   0x1f, F_REG_MAX_VALUE (15)),
5760
  SR_PAN  ("pan",   0x04, F_REG_MAX_VALUE (1)),
5761
  SR_V8_2 ("uao",   0x03, F_REG_MAX_VALUE (1)),
5762
  SR_SSBS ("ssbs",    0x19, F_REG_MAX_VALUE (1)),
5763
  SR_V8_4 ("dit",   0x1a, F_REG_MAX_VALUE (1)),
5764
  SR_MEMTAG ("tco",   0x1c, F_REG_MAX_VALUE (1)),
5765
  SR_SME  ("svcrsm",    0x1b, PSTATE_ENCODE_CRM_AND_IMM(0x2,0x1)
5766
        | F_REG_MAX_VALUE (1)),
5767
  SR_SME  ("svcrza",    0x1b, PSTATE_ENCODE_CRM_AND_IMM(0x4,0x1)
5768
        | F_REG_MAX_VALUE (1)),
5769
  SR_SME  ("svcrsmza",    0x1b, PSTATE_ENCODE_CRM_AND_IMM(0x6,0x1)
5770
        | F_REG_MAX_VALUE (1)),
5771
  SR_V8_8 ("allint",    0x08, F_REG_MAX_VALUE (1)),
5772
  { 0,    CPENC (0,0,0,0,0), 0, 0 },
5773
};
5774
5775
bool
5776
aarch64_pstatefield_supported_p (const aarch64_feature_set features,
5777
         const aarch64_sys_reg *reg)
5778
0
{
5779
0
  if (!(reg->flags & F_ARCHEXT))
5780
0
    return true;
5781
5782
0
  return AARCH64_CPU_HAS_ALL_FEATURES (features, reg->features);
5783
0
}
5784
5785
const aarch64_sys_ins_reg aarch64_sys_regs_ic[] =
5786
{
5787
    { "ialluis", CPENS(0,C7,C1,0), 0 },
5788
    { "iallu",   CPENS(0,C7,C5,0), 0 },
5789
    { "ivau",    CPENS (3, C7, C5, 1), F_HASXT },
5790
    { 0, CPENS(0,0,0,0), 0 }
5791
};
5792
5793
const aarch64_sys_ins_reg aarch64_sys_regs_dc[] =
5794
{
5795
    { "zva",      CPENS (3, C7, C4, 1),  F_HASXT },
5796
    { "gva",      CPENS (3, C7, C4, 3),  F_HASXT | F_ARCHEXT },
5797
    { "gzva",     CPENS (3, C7, C4, 4),  F_HASXT | F_ARCHEXT },
5798
    { "ivac",       CPENS (0, C7, C6, 1),  F_HASXT },
5799
    { "igvac",      CPENS (0, C7, C6, 3),  F_HASXT | F_ARCHEXT },
5800
    { "igsw",       CPENS (0, C7, C6, 4),  F_HASXT | F_ARCHEXT },
5801
    { "isw",      CPENS (0, C7, C6, 2),  F_HASXT },
5802
    { "igdvac",     CPENS (0, C7, C6, 5),  F_HASXT | F_ARCHEXT },
5803
    { "igdsw",      CPENS (0, C7, C6, 6),  F_HASXT | F_ARCHEXT },
5804
    { "cvac",       CPENS (3, C7, C10, 1), F_HASXT },
5805
    { "cgvac",      CPENS (3, C7, C10, 3), F_HASXT | F_ARCHEXT },
5806
    { "cgdvac",     CPENS (3, C7, C10, 5), F_HASXT | F_ARCHEXT },
5807
    { "csw",      CPENS (0, C7, C10, 2), F_HASXT },
5808
    { "cgsw",       CPENS (0, C7, C10, 4), F_HASXT | F_ARCHEXT },
5809
    { "cgdsw",      CPENS (0, C7, C10, 6), F_HASXT | F_ARCHEXT },
5810
    { "cvau",       CPENS (3, C7, C11, 1), F_HASXT },
5811
    { "cvap",       CPENS (3, C7, C12, 1), F_HASXT | F_ARCHEXT },
5812
    { "cgvap",      CPENS (3, C7, C12, 3), F_HASXT | F_ARCHEXT },
5813
    { "cgdvap",     CPENS (3, C7, C12, 5), F_HASXT | F_ARCHEXT },
5814
    { "cvadp",      CPENS (3, C7, C13, 1), F_HASXT | F_ARCHEXT },
5815
    { "cgvadp",     CPENS (3, C7, C13, 3), F_HASXT | F_ARCHEXT },
5816
    { "cgdvadp",    CPENS (3, C7, C13, 5), F_HASXT | F_ARCHEXT },
5817
    { "civac",      CPENS (3, C7, C14, 1), F_HASXT },
5818
    { "cigvac",     CPENS (3, C7, C14, 3), F_HASXT | F_ARCHEXT },
5819
    { "cigdvac",    CPENS (3, C7, C14, 5), F_HASXT | F_ARCHEXT },
5820
    { "cisw",       CPENS (0, C7, C14, 2), F_HASXT },
5821
    { "cigsw",      CPENS (0, C7, C14, 4), F_HASXT | F_ARCHEXT },
5822
    { "cigdsw",     CPENS (0, C7, C14, 6), F_HASXT | F_ARCHEXT },
5823
    { "cipapa",     CPENS (6, C7, C14, 1), F_HASXT },
5824
    { "cigdpapa",   CPENS (6, C7, C14, 5), F_HASXT },
5825
    { 0,       CPENS(0,0,0,0), 0 }
5826
};
5827
5828
const aarch64_sys_ins_reg aarch64_sys_regs_at[] =
5829
{
5830
    { "s1e1r",      CPENS (0, C7, C8, 0), F_HASXT },
5831
    { "s1e1w",      CPENS (0, C7, C8, 1), F_HASXT },
5832
    { "s1e0r",      CPENS (0, C7, C8, 2), F_HASXT },
5833
    { "s1e0w",      CPENS (0, C7, C8, 3), F_HASXT },
5834
    { "s12e1r",     CPENS (4, C7, C8, 4), F_HASXT },
5835
    { "s12e1w",     CPENS (4, C7, C8, 5), F_HASXT },
5836
    { "s12e0r",     CPENS (4, C7, C8, 6), F_HASXT },
5837
    { "s12e0w",     CPENS (4, C7, C8, 7), F_HASXT },
5838
    { "s1e2r",      CPENS (4, C7, C8, 0), F_HASXT },
5839
    { "s1e2w",      CPENS (4, C7, C8, 1), F_HASXT },
5840
    { "s1e3r",      CPENS (6, C7, C8, 0), F_HASXT },
5841
    { "s1e3w",      CPENS (6, C7, C8, 1), F_HASXT },
5842
    { "s1e1rp",     CPENS (0, C7, C9, 0), F_HASXT | F_ARCHEXT },
5843
    { "s1e1wp",     CPENS (0, C7, C9, 1), F_HASXT | F_ARCHEXT },
5844
    { 0,       CPENS(0,0,0,0), 0 }
5845
};
5846
5847
const aarch64_sys_ins_reg aarch64_sys_regs_tlbi[] =
5848
{
5849
    { "vmalle1",   CPENS(0,C8,C7,0), 0 },
5850
    { "vae1",      CPENS (0, C8, C7, 1), F_HASXT },
5851
    { "aside1",    CPENS (0, C8, C7, 2), F_HASXT },
5852
    { "vaae1",     CPENS (0, C8, C7, 3), F_HASXT },
5853
    { "vmalle1is", CPENS(0,C8,C3,0), 0 },
5854
    { "vae1is",    CPENS (0, C8, C3, 1), F_HASXT },
5855
    { "aside1is",  CPENS (0, C8, C3, 2), F_HASXT },
5856
    { "vaae1is",   CPENS (0, C8, C3, 3), F_HASXT },
5857
    { "ipas2e1is", CPENS (4, C8, C0, 1), F_HASXT },
5858
    { "ipas2le1is",CPENS (4, C8, C0, 5), F_HASXT },
5859
    { "ipas2e1",   CPENS (4, C8, C4, 1), F_HASXT },
5860
    { "ipas2le1",  CPENS (4, C8, C4, 5), F_HASXT },
5861
    { "vae2",      CPENS (4, C8, C7, 1), F_HASXT },
5862
    { "vae2is",    CPENS (4, C8, C3, 1), F_HASXT },
5863
    { "vmalls12e1",CPENS(4,C8,C7,6), 0 },
5864
    { "vmalls12e1is",CPENS(4,C8,C3,6), 0 },
5865
    { "vae3",      CPENS (6, C8, C7, 1), F_HASXT },
5866
    { "vae3is",    CPENS (6, C8, C3, 1), F_HASXT },
5867
    { "alle2",     CPENS(4,C8,C7,0), 0 },
5868
    { "alle2is",   CPENS(4,C8,C3,0), 0 },
5869
    { "alle1",     CPENS(4,C8,C7,4), 0 },
5870
    { "alle1is",   CPENS(4,C8,C3,4), 0 },
5871
    { "alle3",     CPENS(6,C8,C7,0), 0 },
5872
    { "alle3is",   CPENS(6,C8,C3,0), 0 },
5873
    { "vale1is",   CPENS (0, C8, C3, 5), F_HASXT },
5874
    { "vale2is",   CPENS (4, C8, C3, 5), F_HASXT },
5875
    { "vale3is",   CPENS (6, C8, C3, 5), F_HASXT },
5876
    { "vaale1is",  CPENS (0, C8, C3, 7), F_HASXT },
5877
    { "vale1",     CPENS (0, C8, C7, 5), F_HASXT },
5878
    { "vale2",     CPENS (4, C8, C7, 5), F_HASXT },
5879
    { "vale3",     CPENS (6, C8, C7, 5), F_HASXT },
5880
    { "vaale1",    CPENS (0, C8, C7, 7), F_HASXT },
5881
5882
    { "vmalle1os",    CPENS (0, C8, C1, 0), F_ARCHEXT },
5883
    { "vae1os",       CPENS (0, C8, C1, 1), F_HASXT | F_ARCHEXT },
5884
    { "aside1os",     CPENS (0, C8, C1, 2), F_HASXT | F_ARCHEXT },
5885
    { "vaae1os",      CPENS (0, C8, C1, 3), F_HASXT | F_ARCHEXT },
5886
    { "vale1os",      CPENS (0, C8, C1, 5), F_HASXT | F_ARCHEXT },
5887
    { "vaale1os",     CPENS (0, C8, C1, 7), F_HASXT | F_ARCHEXT },
5888
    { "ipas2e1os",    CPENS (4, C8, C4, 0), F_HASXT | F_ARCHEXT },
5889
    { "ipas2le1os",   CPENS (4, C8, C4, 4), F_HASXT | F_ARCHEXT },
5890
    { "vae2os",       CPENS (4, C8, C1, 1), F_HASXT | F_ARCHEXT },
5891
    { "vale2os",      CPENS (4, C8, C1, 5), F_HASXT | F_ARCHEXT },
5892
    { "vmalls12e1os", CPENS (4, C8, C1, 6), F_ARCHEXT },
5893
    { "vae3os",       CPENS (6, C8, C1, 1), F_HASXT | F_ARCHEXT },
5894
    { "vale3os",      CPENS (6, C8, C1, 5), F_HASXT | F_ARCHEXT },
5895
    { "alle2os",      CPENS (4, C8, C1, 0), F_ARCHEXT },
5896
    { "alle1os",      CPENS (4, C8, C1, 4), F_ARCHEXT },
5897
    { "alle3os",      CPENS (6, C8, C1, 0), F_ARCHEXT },
5898
5899
    { "rvae1",      CPENS (0, C8, C6, 1), F_HASXT | F_ARCHEXT },
5900
    { "rvaae1",     CPENS (0, C8, C6, 3), F_HASXT | F_ARCHEXT },
5901
    { "rvale1",     CPENS (0, C8, C6, 5), F_HASXT | F_ARCHEXT },
5902
    { "rvaale1",    CPENS (0, C8, C6, 7), F_HASXT | F_ARCHEXT },
5903
    { "rvae1is",    CPENS (0, C8, C2, 1), F_HASXT | F_ARCHEXT },
5904
    { "rvaae1is",   CPENS (0, C8, C2, 3), F_HASXT | F_ARCHEXT },
5905
    { "rvale1is",   CPENS (0, C8, C2, 5), F_HASXT | F_ARCHEXT },
5906
    { "rvaale1is",  CPENS (0, C8, C2, 7), F_HASXT | F_ARCHEXT },
5907
    { "rvae1os",    CPENS (0, C8, C5, 1), F_HASXT | F_ARCHEXT },
5908
    { "rvaae1os",   CPENS (0, C8, C5, 3), F_HASXT | F_ARCHEXT },
5909
    { "rvale1os",   CPENS (0, C8, C5, 5), F_HASXT | F_ARCHEXT },
5910
    { "rvaale1os",  CPENS (0, C8, C5, 7), F_HASXT | F_ARCHEXT },
5911
    { "ripas2e1is", CPENS (4, C8, C0, 2), F_HASXT | F_ARCHEXT },
5912
    { "ripas2le1is",CPENS (4, C8, C0, 6), F_HASXT | F_ARCHEXT },
5913
    { "ripas2e1",   CPENS (4, C8, C4, 2), F_HASXT | F_ARCHEXT },
5914
    { "ripas2le1",  CPENS (4, C8, C4, 6), F_HASXT | F_ARCHEXT },
5915
    { "ripas2e1os", CPENS (4, C8, C4, 3), F_HASXT | F_ARCHEXT },
5916
    { "ripas2le1os",CPENS (4, C8, C4, 7), F_HASXT | F_ARCHEXT },
5917
    { "rvae2",      CPENS (4, C8, C6, 1), F_HASXT | F_ARCHEXT },
5918
    { "rvale2",     CPENS (4, C8, C6, 5), F_HASXT | F_ARCHEXT },
5919
    { "rvae2is",    CPENS (4, C8, C2, 1), F_HASXT | F_ARCHEXT },
5920
    { "rvale2is",   CPENS (4, C8, C2, 5), F_HASXT | F_ARCHEXT },
5921
    { "rvae2os",    CPENS (4, C8, C5, 1), F_HASXT | F_ARCHEXT },
5922
    { "rvale2os",   CPENS (4, C8, C5, 5), F_HASXT | F_ARCHEXT },
5923
    { "rvae3",      CPENS (6, C8, C6, 1), F_HASXT | F_ARCHEXT },
5924
    { "rvale3",     CPENS (6, C8, C6, 5), F_HASXT | F_ARCHEXT },
5925
    { "rvae3is",    CPENS (6, C8, C2, 1), F_HASXT | F_ARCHEXT },
5926
    { "rvale3is",   CPENS (6, C8, C2, 5), F_HASXT | F_ARCHEXT },
5927
    { "rvae3os",    CPENS (6, C8, C5, 1), F_HASXT | F_ARCHEXT },
5928
    { "rvale3os",   CPENS (6, C8, C5, 5), F_HASXT | F_ARCHEXT },
5929
5930
    { "rpaos",      CPENS (6, C8, C4, 3), F_HASXT },
5931
    { "rpalos",     CPENS (6, C8, C4, 7), F_HASXT },
5932
    { "paallos",    CPENS (6, C8, C1, 4), 0},
5933
    { "paall",      CPENS (6, C8, C7, 4), 0},
5934
5935
    { 0,       CPENS(0,0,0,0), 0 }
5936
};
5937
5938
const aarch64_sys_ins_reg aarch64_sys_regs_sr[] =
5939
{
5940
    /* RCTX is somewhat unique in a way that it has different values
5941
       (op2) based on the instruction in which it is used (cfp/dvp/cpp).
5942
       Thus op2 is masked out and instead encoded directly in the
5943
       aarch64_opcode_table entries for the respective instructions.  */
5944
    { "rctx",   CPENS(3,C7,C3,0), F_HASXT | F_ARCHEXT | F_REG_WRITE}, /* WO */
5945
5946
    { 0,       CPENS(0,0,0,0), 0 }
5947
};
5948
5949
bool
5950
aarch64_sys_ins_reg_has_xt (const aarch64_sys_ins_reg *sys_ins_reg)
5951
754
{
5952
754
  return (sys_ins_reg->flags & F_HASXT) != 0;
5953
754
}
5954
5955
extern bool
5956
aarch64_sys_ins_reg_supported_p (const aarch64_feature_set features,
5957
     const char *reg_name,
5958
                 aarch64_insn reg_value,
5959
                 uint32_t reg_flags,
5960
                 aarch64_feature_set reg_features)
5961
0
{
5962
  /* Armv8-R has no EL3.  */
5963
0
  if (AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8_R))
5964
0
    {
5965
0
      const char *suffix = strrchr (reg_name, '_');
5966
0
      if (suffix && !strcmp (suffix, "_el3"))
5967
0
  return false;
5968
0
    }
5969
5970
0
  if (!(reg_flags & F_ARCHEXT))
5971
0
    return true;
5972
5973
0
  if (reg_features
5974
0
      && AARCH64_CPU_HAS_ALL_FEATURES (features, reg_features))
5975
0
    return true;
5976
5977
  /* ARMv8.4 TLB instructions.  */
5978
0
  if ((reg_value == CPENS (0, C8, C1, 0)
5979
0
       || reg_value == CPENS (0, C8, C1, 1)
5980
0
       || reg_value == CPENS (0, C8, C1, 2)
5981
0
       || reg_value == CPENS (0, C8, C1, 3)
5982
0
       || reg_value == CPENS (0, C8, C1, 5)
5983
0
       || reg_value == CPENS (0, C8, C1, 7)
5984
0
       || reg_value == CPENS (4, C8, C4, 0)
5985
0
       || reg_value == CPENS (4, C8, C4, 4)
5986
0
       || reg_value == CPENS (4, C8, C1, 1)
5987
0
       || reg_value == CPENS (4, C8, C1, 5)
5988
0
       || reg_value == CPENS (4, C8, C1, 6)
5989
0
       || reg_value == CPENS (6, C8, C1, 1)
5990
0
       || reg_value == CPENS (6, C8, C1, 5)
5991
0
       || reg_value == CPENS (4, C8, C1, 0)
5992
0
       || reg_value == CPENS (4, C8, C1, 4)
5993
0
       || reg_value == CPENS (6, C8, C1, 0)
5994
0
       || reg_value == CPENS (0, C8, C6, 1)
5995
0
       || reg_value == CPENS (0, C8, C6, 3)
5996
0
       || reg_value == CPENS (0, C8, C6, 5)
5997
0
       || reg_value == CPENS (0, C8, C6, 7)
5998
0
       || reg_value == CPENS (0, C8, C2, 1)
5999
0
       || reg_value == CPENS (0, C8, C2, 3)
6000
0
       || reg_value == CPENS (0, C8, C2, 5)
6001
0
       || reg_value == CPENS (0, C8, C2, 7)
6002
0
       || reg_value == CPENS (0, C8, C5, 1)
6003
0
       || reg_value == CPENS (0, C8, C5, 3)
6004
0
       || reg_value == CPENS (0, C8, C5, 5)
6005
0
       || reg_value == CPENS (0, C8, C5, 7)
6006
0
       || reg_value == CPENS (4, C8, C0, 2)
6007
0
       || reg_value == CPENS (4, C8, C0, 6)
6008
0
       || reg_value == CPENS (4, C8, C4, 2)
6009
0
       || reg_value == CPENS (4, C8, C4, 6)
6010
0
       || reg_value == CPENS (4, C8, C4, 3)
6011
0
       || reg_value == CPENS (4, C8, C4, 7)
6012
0
       || reg_value == CPENS (4, C8, C6, 1)
6013
0
       || reg_value == CPENS (4, C8, C6, 5)
6014
0
       || reg_value == CPENS (4, C8, C2, 1)
6015
0
       || reg_value == CPENS (4, C8, C2, 5)
6016
0
       || reg_value == CPENS (4, C8, C5, 1)
6017
0
       || reg_value == CPENS (4, C8, C5, 5)
6018
0
       || reg_value == CPENS (6, C8, C6, 1)
6019
0
       || reg_value == CPENS (6, C8, C6, 5)
6020
0
       || reg_value == CPENS (6, C8, C2, 1)
6021
0
       || reg_value == CPENS (6, C8, C2, 5)
6022
0
       || reg_value == CPENS (6, C8, C5, 1)
6023
0
       || reg_value == CPENS (6, C8, C5, 5))
6024
0
      && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8_4))
6025
0
    return true;
6026
6027
  /* DC CVAP.  Values are from aarch64_sys_regs_dc.  */
6028
0
  if (reg_value == CPENS (3, C7, C12, 1)
6029
0
      && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8_2))
6030
0
    return true;
6031
6032
  /* DC CVADP.  Values are from aarch64_sys_regs_dc.  */
6033
0
  if (reg_value == CPENS (3, C7, C13, 1)
6034
0
      && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_CVADP))
6035
0
    return true;
6036
6037
  /* DC <dc_op> for ARMv8.5-A Memory Tagging Extension.  */
6038
0
  if ((reg_value == CPENS (0, C7, C6, 3)
6039
0
       || reg_value == CPENS (0, C7, C6, 4)
6040
0
       || reg_value == CPENS (0, C7, C10, 4)
6041
0
       || reg_value == CPENS (0, C7, C14, 4)
6042
0
       || reg_value == CPENS (3, C7, C10, 3)
6043
0
       || reg_value == CPENS (3, C7, C12, 3)
6044
0
       || reg_value == CPENS (3, C7, C13, 3)
6045
0
       || reg_value == CPENS (3, C7, C14, 3)
6046
0
       || reg_value == CPENS (3, C7, C4, 3)
6047
0
       || reg_value == CPENS (0, C7, C6, 5)
6048
0
       || reg_value == CPENS (0, C7, C6, 6)
6049
0
       || reg_value == CPENS (0, C7, C10, 6)
6050
0
       || reg_value == CPENS (0, C7, C14, 6)
6051
0
       || reg_value == CPENS (3, C7, C10, 5)
6052
0
       || reg_value == CPENS (3, C7, C12, 5)
6053
0
       || reg_value == CPENS (3, C7, C13, 5)
6054
0
       || reg_value == CPENS (3, C7, C14, 5)
6055
0
       || reg_value == CPENS (3, C7, C4, 4))
6056
0
      && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_MEMTAG))
6057
0
    return true;
6058
6059
  /* AT S1E1RP, AT S1E1WP.  Values are from aarch64_sys_regs_at.  */
6060
0
  if ((reg_value == CPENS (0, C7, C9, 0)
6061
0
       || reg_value == CPENS (0, C7, C9, 1))
6062
0
      && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8_2))
6063
0
    return true;
6064
6065
  /* CFP/DVP/CPP RCTX : Value are from aarch64_sys_regs_sr. */
6066
0
  if (reg_value == CPENS (3, C7, C3, 0)
6067
0
      && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_PREDRES))
6068
0
    return true;
6069
6070
0
  return false;
6071
0
}
6072
6073
#undef C0
6074
#undef C1
6075
#undef C2
6076
#undef C3
6077
#undef C4
6078
#undef C5
6079
#undef C6
6080
#undef C7
6081
#undef C8
6082
#undef C9
6083
#undef C10
6084
#undef C11
6085
#undef C12
6086
#undef C13
6087
#undef C14
6088
#undef C15
6089
6090
99.0k
#define BIT(INSN,BT)     (((INSN) >> (BT)) & 1)
6091
150k
#define BITS(INSN,HI,LO) (((INSN) >> (LO)) & ((1 << (((HI) - (LO)) + 1)) - 1))
6092
6093
static enum err_type
6094
verify_ldpsw (const struct aarch64_inst *inst ATTRIBUTE_UNUSED,
6095
        const aarch64_insn insn, bfd_vma pc ATTRIBUTE_UNUSED,
6096
        bool encoding ATTRIBUTE_UNUSED,
6097
        aarch64_operand_error *mismatch_detail ATTRIBUTE_UNUSED,
6098
        aarch64_instr_sequence *insn_sequence ATTRIBUTE_UNUSED)
6099
50.2k
{
6100
50.2k
  int t  = BITS (insn, 4, 0);
6101
50.2k
  int n  = BITS (insn, 9, 5);
6102
50.2k
  int t2 = BITS (insn, 14, 10);
6103
6104
50.2k
  if (BIT (insn, 23))
6105
17.4k
    {
6106
      /* Write back enabled.  */
6107
17.4k
      if ((t == n || t2 == n) && n != 31)
6108
1.38k
  return ERR_UND;
6109
17.4k
    }
6110
6111
48.8k
  if (BIT (insn, 22))
6112
48.8k
    {
6113
      /* Load */
6114
48.8k
      if (t == t2)
6115
2.68k
  return ERR_UND;
6116
48.8k
    }
6117
6118
46.1k
  return ERR_OK;
6119
48.8k
}
6120
6121
/* Verifier for vector by element 3 operands functions where the
6122
   conditions `if sz:L == 11 then UNDEFINED` holds.  */
6123
6124
static enum err_type
6125
verify_elem_sd (const struct aarch64_inst *inst, const aarch64_insn insn,
6126
    bfd_vma pc ATTRIBUTE_UNUSED, bool encoding,
6127
    aarch64_operand_error *mismatch_detail ATTRIBUTE_UNUSED,
6128
    aarch64_instr_sequence *insn_sequence ATTRIBUTE_UNUSED)
6129
4.58k
{
6130
4.58k
  const aarch64_insn undef_pattern = 0x3;
6131
4.58k
  aarch64_insn value;
6132
6133
4.58k
  assert (inst->opcode);
6134
4.58k
  assert (inst->opcode->operands[2] == AARCH64_OPND_Em);
6135
4.58k
  value = encoding ? inst->value : insn;
6136
4.58k
  assert (value);
6137
6138
4.58k
  if (undef_pattern == extract_fields (value, 0, 2, FLD_sz, FLD_L))
6139
1.24k
    return ERR_UND;
6140
6141
3.34k
  return ERR_OK;
6142
4.58k
}
6143
6144
/* Check an instruction that takes three register operands and that
6145
   requires the register numbers to be distinct from one another.  */
6146
6147
static enum err_type
6148
verify_three_different_regs (const struct aarch64_inst *inst,
6149
           const aarch64_insn insn ATTRIBUTE_UNUSED,
6150
           bfd_vma pc ATTRIBUTE_UNUSED,
6151
           bool encoding ATTRIBUTE_UNUSED,
6152
           aarch64_operand_error *mismatch_detail
6153
             ATTRIBUTE_UNUSED,
6154
           aarch64_instr_sequence *insn_sequence
6155
             ATTRIBUTE_UNUSED)
6156
8.50k
{
6157
8.50k
  int rd, rs, rn;
6158
6159
8.50k
  rd = inst->operands[0].reg.regno;
6160
8.50k
  rs = inst->operands[1].reg.regno;
6161
8.50k
  rn = inst->operands[2].reg.regno;
6162
8.50k
  if (rd == rs || rd == rn || rs == rn)
6163
1.00k
    {
6164
1.00k
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6165
1.00k
      mismatch_detail->error
6166
1.00k
  = _("the three register operands must be distinct from one another");
6167
1.00k
      mismatch_detail->index = -1;
6168
1.00k
      return ERR_UND;
6169
1.00k
    }
6170
6171
7.49k
  return ERR_OK;
6172
8.50k
}
6173
6174
/* Add INST to the end of INSN_SEQUENCE.  */
6175
6176
static void
6177
add_insn_to_sequence (const struct aarch64_inst *inst,
6178
          aarch64_instr_sequence *insn_sequence)
6179
4.87k
{
6180
4.87k
  insn_sequence->instr[insn_sequence->num_added_insns++] = *inst;
6181
4.87k
}
6182
6183
/* Initialize an instruction sequence insn_sequence with the instruction INST.
6184
   If INST is NULL the given insn_sequence is cleared and the sequence is left
6185
   uninitialized.  */
6186
6187
void
6188
init_insn_sequence (const struct aarch64_inst *inst,
6189
        aarch64_instr_sequence *insn_sequence)
6190
10.0k
{
6191
10.0k
  int num_req_entries = 0;
6192
6193
10.0k
  if (insn_sequence->instr)
6194
4.41k
    {
6195
4.41k
      XDELETE (insn_sequence->instr);
6196
4.41k
      insn_sequence->instr = NULL;
6197
4.41k
    }
6198
6199
  /* Handle all the cases here.  May need to think of something smarter than
6200
     a giant if/else chain if this grows.  At that time, a lookup table may be
6201
     best.  */
6202
10.0k
  if (inst && inst->opcode->constraints & C_SCAN_MOVPRFX)
6203
1.15k
    num_req_entries = 1;
6204
10.0k
  if (inst && (inst->opcode->constraints & C_SCAN_MOPS_PME) == C_SCAN_MOPS_P)
6205
3.26k
    num_req_entries = 2;
6206
6207
10.0k
  insn_sequence->num_added_insns = 0;
6208
10.0k
  insn_sequence->num_allocated_insns = num_req_entries;
6209
6210
10.0k
  if (num_req_entries != 0)
6211
4.41k
    {
6212
4.41k
      insn_sequence->instr = XCNEWVEC (aarch64_inst, num_req_entries);
6213
4.41k
      add_insn_to_sequence (inst, insn_sequence);
6214
4.41k
    }
6215
10.0k
}
6216
6217
/* Subroutine of verify_constraints.  Check whether the instruction
6218
   is part of a MOPS P/M/E sequence and, if so, whether sequencing
6219
   expectations are met.  Return true if the check passes, otherwise
6220
   describe the problem in MISMATCH_DETAIL.
6221
6222
   IS_NEW_SECTION is true if INST is assumed to start a new section.
6223
   The other arguments are as for verify_constraints.  */
6224
6225
static bool
6226
verify_mops_pme_sequence (const struct aarch64_inst *inst,
6227
        bool is_new_section,
6228
        aarch64_operand_error *mismatch_detail,
6229
        aarch64_instr_sequence *insn_sequence)
6230
214k
{
6231
214k
  const struct aarch64_opcode *opcode;
6232
214k
  const struct aarch64_inst *prev_insn;
6233
214k
  int i;
6234
6235
214k
  opcode = inst->opcode;
6236
214k
  if (insn_sequence->instr)
6237
4.67k
    prev_insn = insn_sequence->instr + (insn_sequence->num_added_insns - 1);
6238
209k
  else
6239
209k
    prev_insn = NULL;
6240
6241
214k
  if (prev_insn
6242
214k
      && (prev_insn->opcode->constraints & C_SCAN_MOPS_PME)
6243
214k
      && prev_insn->opcode != opcode - 1)
6244
3.11k
    {
6245
3.11k
      mismatch_detail->kind = AARCH64_OPDE_EXPECTED_A_AFTER_B;
6246
3.11k
      mismatch_detail->error = NULL;
6247
3.11k
      mismatch_detail->index = -1;
6248
3.11k
      mismatch_detail->data[0].s = prev_insn->opcode[1].name;
6249
3.11k
      mismatch_detail->data[1].s = prev_insn->opcode->name;
6250
3.11k
      mismatch_detail->non_fatal = true;
6251
3.11k
      return false;
6252
3.11k
    }
6253
6254
211k
  if (opcode->constraints & C_SCAN_MOPS_PME)
6255
4.20k
    {
6256
4.20k
      if (is_new_section || !prev_insn || prev_insn->opcode != opcode - 1)
6257
3.78k
  {
6258
3.78k
    mismatch_detail->kind = AARCH64_OPDE_A_SHOULD_FOLLOW_B;
6259
3.78k
    mismatch_detail->error = NULL;
6260
3.78k
    mismatch_detail->index = -1;
6261
3.78k
    mismatch_detail->data[0].s = opcode->name;
6262
3.78k
    mismatch_detail->data[1].s = opcode[-1].name;
6263
3.78k
    mismatch_detail->non_fatal = true;
6264
3.78k
    return false;
6265
3.78k
  }
6266
6267
783
      for (i = 0; i < 3; ++i)
6268
  /* There's no specific requirement for the data register to be
6269
     the same between consecutive SET* instructions.  */
6270
759
  if ((opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rd
6271
759
       || opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rs
6272
759
       || opcode->operands[i] == AARCH64_OPND_MOPS_WB_Rn)
6273
759
      && prev_insn->operands[i].reg.regno != inst->operands[i].reg.regno)
6274
401
    {
6275
401
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6276
401
      if (opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rd)
6277
213
        mismatch_detail->error = _("destination register differs from "
6278
188
           "preceding instruction");
6279
188
      else if (opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rs)
6280
0
        mismatch_detail->error = _("source register differs from "
6281
188
           "preceding instruction");
6282
188
      else
6283
188
        mismatch_detail->error = _("size register differs from "
6284
401
           "preceding instruction");
6285
401
      mismatch_detail->index = i;
6286
401
      mismatch_detail->non_fatal = true;
6287
401
      return false;
6288
401
    }
6289
425
    }
6290
6291
207k
  return true;
6292
211k
}
6293
6294
/*  This function verifies that the instruction INST adheres to its specified
6295
    constraints.  If it does then ERR_OK is returned, if not then ERR_VFI is
6296
    returned and MISMATCH_DETAIL contains the reason why verification failed.
6297
6298
    The function is called both during assembly and disassembly.  If assembling
6299
    then ENCODING will be TRUE, else FALSE.  If dissassembling PC will be set
6300
    and will contain the PC of the current instruction w.r.t to the section.
6301
6302
    If ENCODING and PC=0 then you are at a start of a section.  The constraints
6303
    are verified against the given state insn_sequence which is updated as it
6304
    transitions through the verification.  */
6305
6306
enum err_type
6307
verify_constraints (const struct aarch64_inst *inst,
6308
        const aarch64_insn insn ATTRIBUTE_UNUSED,
6309
        bfd_vma pc,
6310
        bool encoding,
6311
        aarch64_operand_error *mismatch_detail,
6312
        aarch64_instr_sequence *insn_sequence)
6313
6.59M
{
6314
6.59M
  assert (inst);
6315
6.59M
  assert (inst->opcode);
6316
6317
6.59M
  const struct aarch64_opcode *opcode = inst->opcode;
6318
6.59M
  if (!opcode->constraints && !insn_sequence->instr)
6319
6.37M
    return ERR_OK;
6320
6321
218k
  assert (insn_sequence);
6322
6323
218k
  enum err_type res = ERR_OK;
6324
6325
  /* This instruction puts a constraint on the insn_sequence.  */
6326
218k
  if (opcode->flags & F_SCAN)
6327
4.41k
    {
6328
4.41k
      if (insn_sequence->instr)
6329
195
  {
6330
195
    mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6331
195
    mismatch_detail->error = _("instruction opens new dependency "
6332
195
             "sequence without ending previous one");
6333
195
    mismatch_detail->index = -1;
6334
195
    mismatch_detail->non_fatal = true;
6335
195
    res = ERR_VFI;
6336
195
  }
6337
6338
4.41k
      init_insn_sequence (inst, insn_sequence);
6339
4.41k
      return res;
6340
4.41k
    }
6341
6342
214k
  bool is_new_section = (!encoding && pc == 0);
6343
214k
  if (!verify_mops_pme_sequence (inst, is_new_section, mismatch_detail,
6344
214k
         insn_sequence))
6345
7.29k
    {
6346
7.29k
      res = ERR_VFI;
6347
7.29k
      if ((opcode->constraints & C_SCAN_MOPS_PME) != C_SCAN_MOPS_M)
6348
4.52k
  init_insn_sequence (NULL, insn_sequence);
6349
7.29k
    }
6350
6351
  /* Verify constraints on an existing sequence.  */
6352
214k
  if (insn_sequence->instr)
6353
1.59k
    {
6354
1.59k
      const struct aarch64_opcode* inst_opcode = insn_sequence->instr->opcode;
6355
      /* If we're decoding and we hit PC=0 with an open sequence then we haven't
6356
   closed a previous one that we should have.  */
6357
1.59k
      if (is_new_section && res == ERR_OK)
6358
0
  {
6359
0
    mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6360
0
    mismatch_detail->error = _("previous `movprfx' sequence not closed");
6361
0
    mismatch_detail->index = -1;
6362
0
    mismatch_detail->non_fatal = true;
6363
0
    res = ERR_VFI;
6364
    /* Reset the sequence.  */
6365
0
    init_insn_sequence (NULL, insn_sequence);
6366
0
    return res;
6367
0
  }
6368
6369
      /* Validate C_SCAN_MOVPRFX constraints.  Move this to a lookup table.  */
6370
1.59k
      if (inst_opcode->constraints & C_SCAN_MOVPRFX)
6371
1.13k
  {
6372
    /* Check to see if the MOVPRFX SVE instruction is followed by an SVE
6373
       instruction for better error messages.  */
6374
1.13k
    if (!opcode->avariant
6375
1.13k
        || !(*opcode->avariant &
6376
1.13k
       (AARCH64_FEATURE_SVE | AARCH64_FEATURE_SVE2)))
6377
738
      {
6378
738
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6379
738
        mismatch_detail->error = _("SVE instruction expected after "
6380
738
           "`movprfx'");
6381
738
        mismatch_detail->index = -1;
6382
738
        mismatch_detail->non_fatal = true;
6383
738
        res = ERR_VFI;
6384
738
        goto done;
6385
738
      }
6386
6387
    /* Check to see if the MOVPRFX SVE instruction is followed by an SVE
6388
       instruction that is allowed to be used with a MOVPRFX.  */
6389
400
    if (!(opcode->constraints & C_SCAN_MOVPRFX))
6390
50
      {
6391
50
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6392
50
        mismatch_detail->error = _("SVE `movprfx' compatible instruction "
6393
50
           "expected");
6394
50
        mismatch_detail->index = -1;
6395
50
        mismatch_detail->non_fatal = true;
6396
50
        res = ERR_VFI;
6397
50
        goto done;
6398
50
      }
6399
6400
    /* Next check for usage of the predicate register.  */
6401
350
    aarch64_opnd_info blk_dest = insn_sequence->instr->operands[0];
6402
350
    aarch64_opnd_info blk_pred, inst_pred;
6403
350
    memset (&blk_pred, 0, sizeof (aarch64_opnd_info));
6404
350
    memset (&inst_pred, 0, sizeof (aarch64_opnd_info));
6405
350
    bool predicated = false;
6406
350
    assert (blk_dest.type == AARCH64_OPND_SVE_Zd);
6407
6408
    /* Determine if the movprfx instruction used is predicated or not.  */
6409
350
    if (insn_sequence->instr->operands[1].type == AARCH64_OPND_SVE_Pg3)
6410
350
      {
6411
350
        predicated = true;
6412
350
        blk_pred = insn_sequence->instr->operands[1];
6413
350
      }
6414
6415
350
    unsigned char max_elem_size = 0;
6416
350
    unsigned char current_elem_size;
6417
350
    int num_op_used = 0, last_op_usage = 0;
6418
350
    int i, inst_pred_idx = -1;
6419
350
    int num_ops = aarch64_num_of_operands (opcode);
6420
1.71k
    for (i = 0; i < num_ops; i++)
6421
1.36k
      {
6422
1.36k
        aarch64_opnd_info inst_op = inst->operands[i];
6423
1.36k
        switch (inst_op.type)
6424
1.36k
    {
6425
578
      case AARCH64_OPND_SVE_Zd:
6426
804
      case AARCH64_OPND_SVE_Zm_5:
6427
888
      case AARCH64_OPND_SVE_Zm_16:
6428
968
      case AARCH64_OPND_SVE_Zn:
6429
968
      case AARCH64_OPND_SVE_Zt:
6430
968
      case AARCH64_OPND_SVE_Vm:
6431
968
      case AARCH64_OPND_SVE_Vn:
6432
968
      case AARCH64_OPND_Va:
6433
968
      case AARCH64_OPND_Vn:
6434
968
      case AARCH64_OPND_Vm:
6435
968
      case AARCH64_OPND_Sn:
6436
968
      case AARCH64_OPND_Sm:
6437
968
        if (inst_op.reg.regno == blk_dest.reg.regno)
6438
602
          {
6439
602
      num_op_used++;
6440
602
      last_op_usage = i;
6441
602
          }
6442
968
        current_elem_size
6443
968
          = aarch64_get_qualifier_esize (inst_op.qualifier);
6444
968
        if (current_elem_size > max_elem_size)
6445
350
          max_elem_size = current_elem_size;
6446
968
        break;
6447
0
      case AARCH64_OPND_SVE_Pd:
6448
311
      case AARCH64_OPND_SVE_Pg3:
6449
311
      case AARCH64_OPND_SVE_Pg4_5:
6450
311
      case AARCH64_OPND_SVE_Pg4_10:
6451
337
      case AARCH64_OPND_SVE_Pg4_16:
6452
337
      case AARCH64_OPND_SVE_Pm:
6453
337
      case AARCH64_OPND_SVE_Pn:
6454
337
      case AARCH64_OPND_SVE_Pt:
6455
337
      case AARCH64_OPND_SME_Pm:
6456
337
        inst_pred = inst_op;
6457
337
        inst_pred_idx = i;
6458
337
        break;
6459
55
      default:
6460
55
        break;
6461
1.36k
    }
6462
1.36k
      }
6463
6464
350
     assert (max_elem_size != 0);
6465
350
     aarch64_opnd_info inst_dest = inst->operands[0];
6466
     /* Determine the size that should be used to compare against the
6467
        movprfx size.  */
6468
350
     current_elem_size
6469
350
       = opcode->constraints & C_MAX_ELEM
6470
350
         ? max_elem_size
6471
350
         : aarch64_get_qualifier_esize (inst_dest.qualifier);
6472
6473
    /* If movprfx is predicated do some extra checks.  */
6474
350
    if (predicated)
6475
350
      {
6476
        /* The instruction must be predicated.  */
6477
350
        if (inst_pred_idx < 0)
6478
13
    {
6479
13
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6480
13
      mismatch_detail->error = _("predicated instruction expected "
6481
13
               "after `movprfx'");
6482
13
      mismatch_detail->index = -1;
6483
13
      mismatch_detail->non_fatal = true;
6484
13
      res = ERR_VFI;
6485
13
      goto done;
6486
13
    }
6487
6488
        /* The instruction must have a merging predicate.  */
6489
337
        if (inst_pred.qualifier != AARCH64_OPND_QLF_P_M)
6490
23
    {
6491
23
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6492
23
      mismatch_detail->error = _("merging predicate expected due "
6493
23
               "to preceding `movprfx'");
6494
23
      mismatch_detail->index = inst_pred_idx;
6495
23
      mismatch_detail->non_fatal = true;
6496
23
      res = ERR_VFI;
6497
23
      goto done;
6498
23
    }
6499
6500
        /* The same register must be used in instruction.  */
6501
314
        if (blk_pred.reg.regno != inst_pred.reg.regno)
6502
21
    {
6503
21
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6504
21
      mismatch_detail->error = _("predicate register differs "
6505
21
               "from that in preceding "
6506
21
               "`movprfx'");
6507
21
      mismatch_detail->index = inst_pred_idx;
6508
21
      mismatch_detail->non_fatal = true;
6509
21
      res = ERR_VFI;
6510
21
      goto done;
6511
21
    }
6512
314
      }
6513
6514
    /* Destructive operations by definition must allow one usage of the
6515
       same register.  */
6516
293
    int allowed_usage
6517
293
      = aarch64_is_destructive_by_operands (opcode) ? 2 : 1;
6518
6519
    /* Operand is not used at all.  */
6520
293
    if (num_op_used == 0)
6521
85
      {
6522
85
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6523
85
        mismatch_detail->error = _("output register of preceding "
6524
85
           "`movprfx' not used in current "
6525
85
           "instruction");
6526
85
        mismatch_detail->index = 0;
6527
85
        mismatch_detail->non_fatal = true;
6528
85
        res = ERR_VFI;
6529
85
        goto done;
6530
85
      }
6531
6532
    /* We now know it's used, now determine exactly where it's used.  */
6533
208
    if (blk_dest.reg.regno != inst_dest.reg.regno)
6534
3
      {
6535
3
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6536
3
        mismatch_detail->error = _("output register of preceding "
6537
3
           "`movprfx' expected as output");
6538
3
        mismatch_detail->index = 0;
6539
3
        mismatch_detail->non_fatal = true;
6540
3
        res = ERR_VFI;
6541
3
        goto done;
6542
3
      }
6543
6544
    /* Operand used more than allowed for the specific opcode type.  */
6545
205
    if (num_op_used > allowed_usage)
6546
195
      {
6547
195
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6548
195
        mismatch_detail->error = _("output register of preceding "
6549
195
           "`movprfx' used as input");
6550
195
        mismatch_detail->index = last_op_usage;
6551
195
        mismatch_detail->non_fatal = true;
6552
195
        res = ERR_VFI;
6553
195
        goto done;
6554
195
      }
6555
6556
    /* Now the only thing left is the qualifiers checks.  The register
6557
       must have the same maximum element size.  */
6558
10
    if (inst_dest.qualifier
6559
10
        && blk_dest.qualifier
6560
10
        && current_elem_size
6561
10
     != aarch64_get_qualifier_esize (blk_dest.qualifier))
6562
9
      {
6563
9
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6564
9
        mismatch_detail->error = _("register size not compatible with "
6565
9
           "previous `movprfx'");
6566
9
        mismatch_detail->index = 0;
6567
9
        mismatch_detail->non_fatal = true;
6568
9
        res = ERR_VFI;
6569
9
        goto done;
6570
9
      }
6571
10
  }
6572
6573
1.59k
    done:
6574
1.59k
      if (insn_sequence->num_added_insns == insn_sequence->num_allocated_insns)
6575
  /* We've checked the last instruction in the sequence and so
6576
     don't need the sequence any more.  */
6577
1.13k
  init_insn_sequence (NULL, insn_sequence);
6578
454
      else
6579
454
  add_insn_to_sequence (inst, insn_sequence);
6580
1.59k
    }
6581
6582
214k
  return res;
6583
214k
}
6584
6585
6586
/* Return true if VALUE cannot be moved into an SVE register using DUP
6587
   (with any element size, not just ESIZE) and if using DUPM would
6588
   therefore be OK.  ESIZE is the number of bytes in the immediate.  */
6589
6590
bool
6591
aarch64_sve_dupm_mov_immediate_p (uint64_t uvalue, int esize)
6592
6.71k
{
6593
6.71k
  int64_t svalue = uvalue;
6594
6.71k
  uint64_t upper = (uint64_t) -1 << (esize * 4) << (esize * 4);
6595
6596
6.71k
  if ((uvalue & ~upper) != uvalue && (uvalue | upper) != uvalue)
6597
0
    return false;
6598
6.71k
  if (esize <= 4 || (uint32_t) uvalue == (uint32_t) (uvalue >> 32))
6599
6.18k
    {
6600
6.18k
      svalue = (int32_t) uvalue;
6601
6.18k
      if (esize <= 2 || (uint16_t) uvalue == (uint16_t) (uvalue >> 16))
6602
1.57k
  {
6603
1.57k
    svalue = (int16_t) uvalue;
6604
1.57k
    if (esize == 1 || (uint8_t) uvalue == (uint8_t) (uvalue >> 8))
6605
1.05k
      return false;
6606
1.57k
  }
6607
6.18k
    }
6608
5.65k
  if ((svalue & 0xff) == 0)
6609
3.29k
    svalue /= 256;
6610
5.65k
  return svalue < -128 || svalue >= 128;
6611
6.71k
}
6612
6613
/* Return true if a CPU with the AARCH64_FEATURE_* bits in CPU_VARIANT
6614
   supports the instruction described by INST.  */
6615
6616
bool
6617
aarch64_cpu_supports_inst_p (uint64_t cpu_variant, aarch64_inst *inst)
6618
0
{
6619
0
  if (!inst->opcode->avariant
6620
0
      || !AARCH64_CPU_HAS_ALL_FEATURES (cpu_variant, *inst->opcode->avariant))
6621
0
    return false;
6622
6623
0
  if (inst->opcode->iclass == sme_fp_sd
6624
0
      && inst->operands[0].qualifier == AARCH64_OPND_QLF_S_D
6625
0
      && !AARCH64_CPU_HAS_ALL_FEATURES (cpu_variant,
6626
0
          AARCH64_FEATURE_SME_F64F64))
6627
0
    return false;
6628
6629
0
  if (inst->opcode->iclass == sme_int_sd
6630
0
      && inst->operands[0].qualifier == AARCH64_OPND_QLF_S_D
6631
0
      && !AARCH64_CPU_HAS_ALL_FEATURES (cpu_variant,
6632
0
          AARCH64_FEATURE_SME_I16I64))
6633
0
    return false;
6634
6635
0
  return true;
6636
0
}
6637
6638
/* Include the opcode description table as well as the operand description
6639
   table.  */
6640
#define VERIFIER(x) verify_##x
6641
#include "aarch64-tbl.h"