Coverage Report

Created: 2023-08-28 06:30

/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
688k
{
126
688k
  return (qualifier >= AARCH64_OPND_QLF_V_8B
127
688k
    && qualifier <= AARCH64_OPND_QLF_V_1Q);
128
688k
}
129
130
static inline bool
131
fp_qualifier_p (enum aarch64_opnd_qualifier qualifier)
132
220
{
133
220
  return (qualifier >= AARCH64_OPND_QLF_S_B
134
220
    && qualifier <= AARCH64_OPND_QLF_S_Q);
135
220
}
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
296k
{
163
296k
  if (vector_qualifier_p (qualifiers[0]))
164
296k
    {
165
      /* e.g. v.4s, v.4s, v.4s
166
     or v.4h, v.4h, v.h[3].  */
167
296k
      if (qualifiers[0] == qualifiers[1]
168
296k
    && vector_qualifier_p (qualifiers[2])
169
296k
    && (aarch64_get_qualifier_esize (qualifiers[0])
170
83.0k
        == aarch64_get_qualifier_esize (qualifiers[1]))
171
296k
    && (aarch64_get_qualifier_esize (qualifiers[0])
172
83.0k
        == aarch64_get_qualifier_esize (qualifiers[2])))
173
79.9k
  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
216k
      if (vector_qualifier_p (qualifiers[1])
178
216k
    && aarch64_get_qualifier_esize (qualifiers[0]) != 0
179
216k
    && (aarch64_get_qualifier_esize (qualifiers[0])
180
123k
        == aarch64_get_qualifier_esize (qualifiers[1]) << 1))
181
52.4k
  return DP_VECTOR_LONG;
182
      /* e.g. v.8h, v.8h, v.8b.  */
183
163k
      if (qualifiers[0] == qualifiers[1]
184
163k
    && vector_qualifier_p (qualifiers[2])
185
163k
    && aarch64_get_qualifier_esize (qualifiers[0]) != 0
186
163k
    && (aarch64_get_qualifier_esize (qualifiers[0])
187
3.12k
        == aarch64_get_qualifier_esize (qualifiers[2]) << 1)
188
163k
    && (aarch64_get_qualifier_esize (qualifiers[0])
189
3.12k
        == aarch64_get_qualifier_esize (qualifiers[1])))
190
3.12k
  return DP_VECTOR_WIDE;
191
163k
    }
192
220
  else if (fp_qualifier_p (qualifiers[0]))
193
220
    {
194
      /* e.g. SADDLV <V><d>, <Vn>.<T>.  */
195
220
      if (vector_qualifier_p (qualifiers[1])
196
220
    && qualifiers[2] == AARCH64_OPND_QLF_NIL)
197
213
  return DP_VECTOR_ACROSS_LANES;
198
220
    }
199
200
160k
  return DP_UNKNOWN;
201
296k
}
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
296k
{
214
296k
  return
215
296k
    significant_operand_index [get_data_pattern (opcode->qualifiers_list[0])];
216
296k
}
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.03M
{
406
3.03M
  return aarch64_operands[type].op_class;
407
3.03M
}
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
89.5k
{
447
89.5k
  assert (value < 16);
448
89.5k
  return &aarch64_conds[(unsigned int) value];
449
89.5k
}
450
451
const aarch64_cond *
452
get_inverted_cond (const aarch64_cond *cond)
453
891
{
454
891
  return &aarch64_conds[cond->value ^ 0x1];
455
891
}
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
865k
{
499
865k
  if (extend_p)
500
93.9k
    return AARCH64_MOD_UXTB + value;
501
771k
  else
502
771k
    return AARCH64_MOD_LSL - value;
503
865k
}
504
505
bool
506
aarch64_extend_operator_p (enum aarch64_modifier_kind kind)
507
54.7k
{
508
54.7k
  return kind > AARCH64_MOD_LSL && kind <= AARCH64_MOD_SXTX;
509
54.7k
}
510
511
static inline bool
512
aarch64_shift_operator_p (enum aarch64_modifier_kind kind)
513
734k
{
514
734k
  return kind >= AARCH64_MOD_ROR && kind <= AARCH64_MOD_LSL;
515
734k
}
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.03M
{
609
3.03M
  return (value >= low && value <= high) ? 1 : 0;
610
3.03M
}
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.39M
{
623
1.39M
  assert (width < 32);
624
1.39M
  if (width < sizeof (value) * 8)
625
1.39M
    {
626
1.39M
      int64_t lim = (uint64_t) 1 << (width - 1);
627
1.39M
      if (value >= -lim && value < lim)
628
1.39M
  return 1;
629
1.39M
    }
630
0
  return 0;
631
1.39M
}
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
1.62M
{
637
1.62M
  assert (width < 32);
638
1.62M
  if (width < sizeof (value) * 8)
639
1.62M
    {
640
1.62M
      int64_t lim = (uint64_t) 1 << width;
641
1.62M
      if (value >= 0 && value < lim)
642
1.62M
  return 1;
643
1.62M
    }
644
0
  return 0;
645
1.62M
}
646
647
/* Return 1 if OPERAND is SP or WSP.  */
648
int
649
aarch64_stack_pointer_p (const aarch64_opnd_info *operand)
650
170k
{
651
170k
  return ((aarch64_get_operand_class (operand->type)
652
170k
     == AARCH64_OPND_CLASS_INT_REG)
653
170k
    && operand_maybe_stack_pointer (aarch64_operands + operand->type)
654
170k
    && operand->reg.regno == 31);
655
170k
}
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.08M
{
675
5.08M
  switch (operand->qualifier)
676
5.08M
    {
677
2.78k
    case AARCH64_OPND_QLF_W:
678
2.78k
      if (target == AARCH64_OPND_QLF_WSP && aarch64_stack_pointer_p (operand))
679
85
  return 1;
680
2.69k
      break;
681
1.48M
    case AARCH64_OPND_QLF_X:
682
1.48M
      if (target == AARCH64_OPND_QLF_SP && aarch64_stack_pointer_p (operand))
683
62
  return 1;
684
1.48M
      break;
685
1.48M
    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.60M
    default:
696
3.60M
      break;
697
5.08M
    }
698
699
5.08M
  return 0;
700
5.08M
}
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
11.9M
{
837
11.9M
  return aarch64_opnd_qualifiers[qualifier].kind == OQK_OPD_VARIANT;
838
11.9M
}
839
840
static inline bool
841
qualifier_value_in_range_constraint_p (aarch64_opnd_qualifier_t qualifier)
842
4.23M
{
843
4.23M
  return aarch64_opnd_qualifiers[qualifier].kind == OQK_VALUE_IN_RANGE;
844
4.23M
}
845
846
const char*
847
aarch64_get_qualifier_name (aarch64_opnd_qualifier_t qualifier)
848
3.44M
{
849
3.44M
  return aarch64_opnd_qualifiers[qualifier].desc;
850
3.44M
}
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
8.46M
{
857
8.46M
  assert (operand_variant_qualifier_p (qualifier));
858
8.46M
  return aarch64_opnd_qualifiers[qualifier].data0;
859
8.46M
}
860
861
unsigned char
862
aarch64_get_qualifier_nelem (aarch64_opnd_qualifier_t qualifier)
863
67.2k
{
864
67.2k
  assert (operand_variant_qualifier_p (qualifier));
865
67.2k
  return aarch64_opnd_qualifiers[qualifier].data1;
866
67.2k
}
867
868
aarch64_insn
869
aarch64_get_qualifier_standard_value (aarch64_opnd_qualifier_t qualifier)
870
3.38M
{
871
3.38M
  assert (operand_variant_qualifier_p (qualifier));
872
3.38M
  return aarch64_opnd_qualifiers[qualifier].data2;
873
3.38M
}
874
875
static int
876
get_lower_bound (aarch64_opnd_qualifier_t qualifier)
877
715k
{
878
715k
  assert (qualifier_value_in_range_constraint_p (qualifier));
879
715k
  return aarch64_opnd_qualifiers[qualifier].data0;
880
715k
}
881
882
static int
883
get_upper_bound (aarch64_opnd_qualifier_t qualifier)
884
785k
{
885
785k
  assert (qualifier_value_in_range_constraint_p (qualifier));
886
785k
  return aarch64_opnd_qualifiers[qualifier].data1;
887
785k
}
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
4
{
933
4
  int i = 0;
934
4
  const enum aarch64_opnd *opnds = opcode->operands;
935
936
4
  if (opnds[0] == AARCH64_OPND_NIL)
937
0
    return false;
938
939
16
  while (opnds[++i] != AARCH64_OPND_NIL)
940
12
    if (opnds[i] == opnds[0])
941
0
      return true;
942
943
4
  return false;
944
4
}
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.18M
{
952
9.18M
  int i = 0;
953
9.18M
  const enum aarch64_opnd *opnds = opcode->operands;
954
32.2M
  while (opnds[i++] != AARCH64_OPND_NIL)
955
23.0M
    ;
956
9.18M
  --i;
957
9.18M
  assert (i >= 0 && i <= AARCH64_MAX_OPND_NUM);
958
9.18M
  return i;
959
9.18M
}
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.17M
{
992
8.17M
  int i, num_opnds, invalid, min_invalid;
993
8.17M
  const aarch64_opnd_qualifier_t *qualifiers;
994
995
8.17M
  num_opnds = aarch64_num_of_operands (inst->opcode);
996
8.17M
  if (num_opnds == 0)
997
0
    {
998
0
      DEBUG_TRACE ("SUCCEED: no operand");
999
0
      *invalid_count = 0;
1000
0
      return 1;
1001
0
    }
1002
1003
8.17M
  if (stop_at < 0 || stop_at >= num_opnds)
1004
7.03M
    stop_at = num_opnds - 1;
1005
1006
  /* For each pattern.  */
1007
8.17M
  min_invalid = num_opnds;
1008
11.9M
  for (i = 0; i < AARCH64_MAX_QLF_SEQ_NUM; ++i, ++qualifiers_list)
1009
11.9M
    {
1010
11.9M
      int j;
1011
11.9M
      qualifiers = *qualifiers_list;
1012
1013
      /* Start as positive.  */
1014
11.9M
      invalid = 0;
1015
1016
11.9M
      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
11.9M
      if (i > 0 && empty_qualifier_sequence_p (qualifiers))
1026
62.4k
  break;
1027
1028
41.8M
      for (j = 0; j < num_opnds && j <= stop_at; ++j, ++qualifiers)
1029
29.9M
  {
1030
29.9M
    if (inst->operands[j].qualifier == AARCH64_OPND_QLF_NIL
1031
29.9M
        && !(inst->opcode->flags & F_STRICT))
1032
16.1M
      {
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.1M
        continue;
1040
16.1M
      }
1041
13.7M
    else if (*qualifiers != inst->operands[j].qualifier)
1042
5.08M
      {
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.08M
        if (operand_also_qualified_p (inst->operands + j, *qualifiers))
1047
147
    continue;
1048
5.08M
        else
1049
5.08M
    invalid += 1;
1050
5.08M
      }
1051
8.70M
    else
1052
8.70M
      continue; /* Equal qualifiers are certainly matched.  */
1053
29.9M
  }
1054
1055
11.8M
      if (min_invalid > invalid)
1056
10.5M
  min_invalid = invalid;
1057
1058
      /* Qualifiers established.  */
1059
11.8M
      if (min_invalid == 0)
1060
8.10M
  break;
1061
11.8M
    }
1062
1063
8.17M
  *invalid_count = min_invalid;
1064
8.17M
  if (min_invalid == 0)
1065
8.10M
    {
1066
      /* Fill the result in *RET.  */
1067
8.10M
      int j;
1068
8.10M
      qualifiers = *qualifiers_list;
1069
1070
8.10M
      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
27.7M
      for (j = 0; j <= stop_at; ++j, ++qualifiers)
1077
19.6M
  ret[j] = *qualifiers;
1078
37.1M
      for (; j < AARCH64_MAX_OPND_NUM; ++j)
1079
29.0M
  ret[j] = AARCH64_OPND_QLF_NIL;
1080
1081
8.10M
      DEBUG_TRACE ("SUCCESS");
1082
8.10M
      return 1;
1083
8.10M
    }
1084
1085
62.4k
  DEBUG_TRACE ("FAIL");
1086
62.4k
  return 0;
1087
8.17M
}
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.03M
{
1104
7.03M
  int i;
1105
7.03M
  aarch64_opnd_qualifier_seq_t qualifiers;
1106
1107
7.03M
  if (!aarch64_find_best_match (inst, inst->opcode->qualifiers_list, -1,
1108
7.03M
        qualifiers, invalid_count))
1109
35.1k
    {
1110
35.1k
      DEBUG_TRACE ("matching FAIL");
1111
35.1k
      return 0;
1112
35.1k
    }
1113
1114
  /* Update the qualifiers.  */
1115
6.99M
  if (update_p)
1116
23.7M
    for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
1117
23.7M
      {
1118
23.7M
  if (inst->opcode->operands[i] == AARCH64_OPND_NIL)
1119
6.99M
    break;
1120
16.7M
  DEBUG_TRACE_IF (inst->operands[i].qualifier != qualifiers[i],
1121
16.7M
      "update %s with %s for operand %d",
1122
16.7M
      aarch64_get_qualifier_name (inst->operands[i].qualifier),
1123
16.7M
      aarch64_get_qualifier_name (qualifiers[i]), i);
1124
16.7M
  inst->operands[i].qualifier = qualifiers[i];
1125
16.7M
      }
1126
1127
6.99M
  DEBUG_TRACE ("matching SUCCESS");
1128
6.99M
  return 1;
1129
7.03M
}
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
104k
{
1141
104k
  int amount;
1142
1143
104k
  DEBUG_TRACE ("enter with 0x%" PRIx64 "(%" PRIi64 ")", value, value);
1144
1145
104k
  if (is32)
1146
41.8k
    {
1147
      /* Allow all zeros or all ones in top 32-bits, so that
1148
   32-bit constant expressions like ~0x80000000 are
1149
   permitted.  */
1150
41.8k
      if (value >> 32 != 0 && value >> 32 != 0xffffffff)
1151
  /* Immediate out of range.  */
1152
0
  return false;
1153
41.8k
      value &= 0xffffffff;
1154
41.8k
    }
1155
1156
  /* first, try movz then movn */
1157
104k
  amount = -1;
1158
104k
  if ((value & ((uint64_t) 0xffff << 0)) == value)
1159
33.0k
    amount = 0;
1160
71.1k
  else if ((value & ((uint64_t) 0xffff << 16)) == value)
1161
19.2k
    amount = 16;
1162
51.8k
  else if (!is32 && (value & ((uint64_t) 0xffff << 32)) == value)
1163
9.81k
    amount = 32;
1164
42.0k
  else if (!is32 && (value & ((uint64_t) 0xffff << 48)) == value)
1165
9.93k
    amount = 48;
1166
1167
104k
  if (amount == -1)
1168
32.1k
    {
1169
32.1k
      DEBUG_TRACE ("exit false with 0x%" PRIx64 "(%" PRIi64 ")", value, value);
1170
32.1k
      return false;
1171
32.1k
    }
1172
1173
72.0k
  if (shift_amount != NULL)
1174
0
    *shift_amount = amount;
1175
1176
72.0k
  DEBUG_TRACE ("exit true with amount %d", amount);
1177
1178
72.0k
  return true;
1179
104k
}
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
261k
#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.06M
{
1213
3.06M
  const simd_imm_encoding *imm1 = (const simd_imm_encoding *)i1;
1214
3.06M
  const simd_imm_encoding *imm2 = (const simd_imm_encoding *)i2;
1215
1216
3.06M
  if (imm1->imm < imm2->imm)
1217
1.51M
    return -1;
1218
1.55M
  if (imm1->imm > imm2->imm)
1219
1.29M
    return +1;
1220
261k
  return 0;
1221
1.55M
}
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
5.33k
{
1234
5.33k
  return (is64 << 12) | (r << 6) | s;
1235
5.33k
}
1236
1237
static void
1238
build_immediate_table (void)
1239
1
{
1240
1
  uint32_t log_e, e, s, r, s_mask;
1241
1
  uint64_t mask, imm;
1242
1
  int nb_imms;
1243
1
  int is64;
1244
1245
1
  nb_imms = 0;
1246
7
  for (log_e = 1; log_e <= 6; log_e++)
1247
6
    {
1248
      /* Get element size.  */
1249
6
      e = 1u << log_e;
1250
6
      if (log_e == 6)
1251
1
  {
1252
1
    is64 = 1;
1253
1
    mask = 0xffffffffffffffffull;
1254
1
    s_mask = 0;
1255
1
  }
1256
5
      else
1257
5
  {
1258
5
    is64 = 0;
1259
5
    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
5
    s_mask = ((1u << (5 - log_e)) - 1) << (log_e + 1);
1267
5
  }
1268
126
      for (s = 0; s < e - 1; s++)
1269
5.45k
  for (r = 0; r < e; r++)
1270
5.33k
    {
1271
      /* s+1 consecutive bits to 1 (s < 63) */
1272
5.33k
      imm = (1ull << (s + 1)) - 1;
1273
      /* rotate right by r */
1274
5.33k
      if (r != 0)
1275
5.21k
        imm = (imm >> r) | ((imm << (e - r)) & mask);
1276
      /* replicate the constant depending on SIMD size */
1277
5.33k
      switch (log_e)
1278
5.33k
        {
1279
2
        case 1: imm = (imm <<  2) | imm;
1280
    /* Fall through.  */
1281
14
        case 2: imm = (imm <<  4) | imm;
1282
    /* Fall through.  */
1283
70
        case 3: imm = (imm <<  8) | imm;
1284
    /* Fall through.  */
1285
310
        case 4: imm = (imm << 16) | imm;
1286
    /* Fall through.  */
1287
1.30k
        case 5: imm = (imm << 32) | imm;
1288
    /* Fall through.  */
1289
5.33k
        case 6: break;
1290
0
        default: abort ();
1291
5.33k
        }
1292
5.33k
      simd_immediates[nb_imms].imm = imm;
1293
5.33k
      simd_immediates[nb_imms].encoding =
1294
5.33k
        encode_immediate_bitfield(is64, s | s_mask, r);
1295
5.33k
      nb_imms++;
1296
5.33k
    }
1297
6
    }
1298
1
  assert (nb_imms == TOTAL_IMM_NB);
1299
1
  qsort(simd_immediates, nb_imms,
1300
1
  sizeof(simd_immediates[0]), simd_imm_encoding_cmp);
1301
1
}
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
261k
{
1314
261k
  simd_imm_encoding imm_enc;
1315
261k
  const simd_imm_encoding *imm_encoding;
1316
261k
  static bool initialized = false;
1317
261k
  uint64_t upper;
1318
261k
  int i;
1319
1320
261k
  DEBUG_TRACE ("enter with 0x%" PRIx64 "(%" PRIi64 "), esize: %d", value,
1321
261k
         value, esize);
1322
1323
261k
  if (!initialized)
1324
1
    {
1325
1
      build_immediate_table ();
1326
1
      initialized = true;
1327
1
    }
1328
1329
  /* Allow all zeros or all ones in top bits, so that
1330
     constant expressions like ~1 are permitted.  */
1331
261k
  upper = (uint64_t) -1 << (esize * 4) << (esize * 4);
1332
261k
  if ((value & ~upper) != value && (value | upper) != value)
1333
0
    return false;
1334
1335
  /* Replicate to a full 64-bit value.  */
1336
261k
  value &= ~upper;
1337
402k
  for (i = esize * 8; i < 64; i *= 2)
1338
141k
    value |= (value << i);
1339
1340
261k
  imm_enc.imm = value;
1341
261k
  imm_encoding = (const simd_imm_encoding *)
1342
261k
    bsearch(&imm_enc, simd_immediates, TOTAL_IMM_NB,
1343
261k
            sizeof(simd_immediates[0]), simd_imm_encoding_cmp);
1344
261k
  if (imm_encoding == NULL)
1345
0
    {
1346
0
      DEBUG_TRACE ("exit with false");
1347
0
      return false;
1348
0
    }
1349
261k
  if (encoding != NULL)
1350
0
    *encoding = imm_encoding->encoding;
1351
261k
  DEBUG_TRACE ("exit with true");
1352
261k
  return true;
1353
261k
}
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
29
{
1362
29
  int i, ret;
1363
29
  uint32_t byte;
1364
1365
29
  ret = 0;
1366
261
  for (i = 0; i < 8; i++)
1367
232
    {
1368
232
      byte = (imm >> (8 * i)) & 0xff;
1369
232
      if (byte == 0xff)
1370
104
  ret |= 1 << i;
1371
128
      else if (byte != 0x00)
1372
0
  return -1;
1373
232
    }
1374
29
  return ret;
1375
29
}
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.19k
{
1395
1.19k
  if (mismatch_detail == NULL)
1396
1.19k
    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
92.8k
{
1428
92.8k
  if (mismatch_detail == NULL)
1429
92.8k
    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
1.08k
{
1458
1.08k
  if (mismatch_detail == NULL)
1459
1.08k
    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
142k
{
1468
142k
  if (mismatch_detail == NULL)
1469
142k
    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
739
{
1500
739
  if (mismatch_detail == NULL)
1501
739
    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
22.8k
{
1530
22.8k
  if (mismatch_detail == NULL)
1531
22.8k
    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
24.9k
{
1545
24.9k
  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
24.9k
  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
24.9k
  return true;
1558
24.9k
}
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
321k
{
1568
321k
  if (opnd->reglist.num_regs != num_regs)
1569
739
    {
1570
739
      set_reg_list_length_error (mismatch_detail, idx, num_regs);
1571
739
      return false;
1572
739
    }
1573
320k
  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
320k
  return true;
1579
320k
}
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
56.8k
{
1598
56.8k
  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
56.8k
  int max_index = max_value * range_size;
1614
56.8k
  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
56.8k
  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
56.8k
  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
56.8k
  if (opnd->indexed_za.group_size != 0
1649
56.8k
      && 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
56.8k
  return true;
1656
56.8k
}
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
16.7M
{
1680
16.7M
  unsigned num, modifiers, shift;
1681
16.7M
  unsigned char size;
1682
16.7M
  int64_t imm, min_value, max_value;
1683
16.7M
  uint64_t uvalue, mask;
1684
16.7M
  const aarch64_opnd_info *opnd = opnds + idx;
1685
16.7M
  aarch64_opnd_qualifier_t qualifier = opnd->qualifier;
1686
16.7M
  int i;
1687
1688
16.7M
  assert (opcode->operands[idx] == opnd->type && opnd->type == type);
1689
1690
16.7M
  switch (aarch64_operands[type].op_class)
1691
16.7M
    {
1692
6.08M
    case AARCH64_OPND_CLASS_INT_REG:
1693
      /* Check pair reg constraints for cas* instructions.  */
1694
6.08M
      if (type == AARCH64_OPND_PAIRREG)
1695
2.62k
  {
1696
2.62k
    assert (idx == 1 || idx == 3);
1697
2.62k
    if (opnds[idx - 1].reg.regno % 2 != 0)
1698
1.19k
      {
1699
1.19k
        set_syntax_error (mismatch_detail, idx - 1,
1700
1.19k
        _("reg pair must start from even reg"));
1701
1.19k
        return 0;
1702
1.19k
      }
1703
1.43k
    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
1.43k
    break;
1710
1.43k
  }
1711
1712
      /* <Xt> may be optional in some IC and TLBI instructions.  */
1713
6.07M
      if (type == AARCH64_OPND_Rt_SYS)
1714
5
  {
1715
5
    assert (idx == 1 && (aarch64_get_operand_class (opnds[0].type)
1716
5
             == AARCH64_OPND_CLASS_SYSTEM));
1717
5
    if (opnds[1].present
1718
5
        && !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
5
    if (!opnds[1].present
1724
5
        && 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
5
  }
1730
6.07M
      switch (qualifier)
1731
6.07M
  {
1732
1.15k
  case AARCH64_OPND_QLF_WSP:
1733
3.79k
  case AARCH64_OPND_QLF_SP:
1734
3.79k
    if (!aarch64_stack_pointer_p (opnd))
1735
1.42k
      {
1736
1.42k
        set_other_error (mismatch_detail, idx,
1737
1.42k
           _("stack pointer register expected"));
1738
1.42k
        return 0;
1739
1.42k
      }
1740
2.36k
    break;
1741
6.07M
  default:
1742
6.07M
    break;
1743
6.07M
  }
1744
6.07M
      break;
1745
1746
6.07M
    case AARCH64_OPND_CLASS_SVE_REG:
1747
975k
      switch (type)
1748
975k
  {
1749
2.61k
  case AARCH64_OPND_SVE_Zm3_INDEX:
1750
4.80k
  case AARCH64_OPND_SVE_Zm3_22_INDEX:
1751
4.98k
  case AARCH64_OPND_SVE_Zm3_19_INDEX:
1752
8.21k
  case AARCH64_OPND_SVE_Zm3_11_INDEX:
1753
11.9k
  case AARCH64_OPND_SVE_Zm4_11_INDEX:
1754
14.0k
  case AARCH64_OPND_SVE_Zm4_INDEX:
1755
14.0k
    size = get_operand_fields_width (get_operand_from_code (type));
1756
14.0k
    shift = get_operand_specific_data (&aarch64_operands[type]);
1757
14.0k
    if (!check_reglane (opnd, mismatch_detail, idx,
1758
14.0k
            "z", 0, (1 << shift) - 1,
1759
14.0k
            0, (1u << (size - shift)) - 1))
1760
0
      return 0;
1761
14.0k
    break;
1762
1763
14.0k
  case AARCH64_OPND_SVE_Zn_INDEX:
1764
550
    size = aarch64_get_qualifier_esize (opnd->qualifier);
1765
550
    if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 31,
1766
550
            0, 64 / size - 1))
1767
0
      return 0;
1768
550
    break;
1769
1770
550
  case AARCH64_OPND_SME_PNn3_INDEX1:
1771
14
  case AARCH64_OPND_SME_PNn3_INDEX2:
1772
14
    size = get_operand_field_width (get_operand_from_code (type), 1);
1773
14
    if (!check_reglane (opnd, mismatch_detail, idx, "pn", 8, 15,
1774
14
            0, (1 << size) - 1))
1775
0
      return 0;
1776
14
    break;
1777
1778
14
  case AARCH64_OPND_SME_Zn_INDEX1_16:
1779
18
  case AARCH64_OPND_SME_Zn_INDEX2_15:
1780
18
  case AARCH64_OPND_SME_Zn_INDEX2_16:
1781
24
  case AARCH64_OPND_SME_Zn_INDEX3_14:
1782
99
  case AARCH64_OPND_SME_Zn_INDEX3_15:
1783
132
  case AARCH64_OPND_SME_Zn_INDEX4_14:
1784
132
    size = get_operand_fields_width (get_operand_from_code (type)) - 5;
1785
132
    if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 31,
1786
132
            0, (1 << size) - 1))
1787
0
      return 0;
1788
132
    break;
1789
1790
155
  case AARCH64_OPND_SME_Zm_INDEX1:
1791
1.45k
  case AARCH64_OPND_SME_Zm_INDEX2:
1792
1.57k
  case AARCH64_OPND_SME_Zm_INDEX3_1:
1793
3.04k
  case AARCH64_OPND_SME_Zm_INDEX3_2:
1794
7.38k
  case AARCH64_OPND_SME_Zm_INDEX3_10:
1795
8.11k
  case AARCH64_OPND_SME_Zm_INDEX4_1:
1796
10.2k
  case AARCH64_OPND_SME_Zm_INDEX4_10:
1797
10.2k
    size = get_operand_fields_width (get_operand_from_code (type)) - 4;
1798
10.2k
    if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 15,
1799
10.2k
            0, (1 << size) - 1))
1800
0
      return 0;
1801
10.2k
    break;
1802
1803
10.2k
  case AARCH64_OPND_SME_Zm:
1804
2.86k
    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
2.86k
    break;
1810
1811
2.86k
  case AARCH64_OPND_SME_PnT_Wm_imm:
1812
797
    size = aarch64_get_qualifier_esize (opnd->qualifier);
1813
797
    max_value = 16 / size - 1;
1814
797
    if (!check_za_access (opnd, mismatch_detail, idx,
1815
797
        12, max_value, 1, 0))
1816
0
      return 0;
1817
797
    break;
1818
1819
947k
  default:
1820
947k
    break;
1821
975k
  }
1822
975k
      break;
1823
1824
975k
    case AARCH64_OPND_CLASS_SVE_REGLIST:
1825
274k
      switch (type)
1826
274k
  {
1827
378
  case AARCH64_OPND_SME_Pdx2:
1828
14.1k
  case AARCH64_OPND_SME_Zdnx2:
1829
18.4k
  case AARCH64_OPND_SME_Zdnx4:
1830
19.1k
  case AARCH64_OPND_SME_Zmx2:
1831
19.3k
  case AARCH64_OPND_SME_Zmx4:
1832
23.0k
  case AARCH64_OPND_SME_Znx2:
1833
24.6k
  case AARCH64_OPND_SME_Znx4:
1834
24.6k
    num = get_operand_specific_data (&aarch64_operands[type]);
1835
24.6k
    if (!check_reglist (opnd, mismatch_detail, idx, num, 1))
1836
0
      return 0;
1837
24.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
24.6k
    break;
1844
1845
24.6k
  case AARCH64_OPND_SME_Ztx2_STRIDED:
1846
10.0k
  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
10.0k
    num = get_operand_specific_data (&aarch64_operands[type]);
1850
10.0k
    if (!check_reglist (opnd, mismatch_detail, idx, num, 16 / num))
1851
0
      return 0;
1852
10.0k
    num = 16 | (opnd->reglist.stride - 1);
1853
10.0k
    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
10.0k
    break;
1860
1861
10.0k
  case AARCH64_OPND_SME_PdxN:
1862
5.25k
  case AARCH64_OPND_SVE_ZnxN:
1863
239k
  case AARCH64_OPND_SVE_ZtxN:
1864
239k
    num = get_opcode_dependent_value (opcode);
1865
239k
    if (!check_reglist (opnd, mismatch_detail, idx, num, 1))
1866
0
      return 0;
1867
239k
    break;
1868
1869
239k
  default:
1870
0
    abort ();
1871
274k
  }
1872
274k
      break;
1873
1874
274k
    case AARCH64_OPND_CLASS_ZA_ACCESS:
1875
56.0k
      switch (type)
1876
56.0k
  {
1877
574
  case AARCH64_OPND_SME_ZA_HV_idx_src:
1878
4.56k
  case AARCH64_OPND_SME_ZA_HV_idx_dest:
1879
41.4k
  case AARCH64_OPND_SME_ZA_HV_idx_ldstr:
1880
41.4k
    size = aarch64_get_qualifier_esize (opnd->qualifier);
1881
41.4k
    max_value = 16 / size - 1;
1882
41.4k
    if (!check_za_access (opnd, mismatch_detail, idx, 12, max_value, 1,
1883
41.4k
        get_opcode_dependent_value (opcode)))
1884
0
      return 0;
1885
41.4k
    break;
1886
1887
41.4k
  case AARCH64_OPND_SME_ZA_array_off4:
1888
144
    if (!check_za_access (opnd, mismatch_detail, idx, 12, 15, 1,
1889
144
        get_opcode_dependent_value (opcode)))
1890
0
      return 0;
1891
144
    break;
1892
1893
3.00k
  case AARCH64_OPND_SME_ZA_array_off3_0:
1894
3.04k
  case AARCH64_OPND_SME_ZA_array_off3_5:
1895
3.04k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 7, 1,
1896
3.04k
        get_opcode_dependent_value (opcode)))
1897
0
      return 0;
1898
3.04k
    break;
1899
1900
3.04k
  case AARCH64_OPND_SME_ZA_array_off1x4:
1901
1.64k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 1, 4,
1902
1.64k
        get_opcode_dependent_value (opcode)))
1903
0
      return 0;
1904
1.64k
    break;
1905
1906
2.10k
  case AARCH64_OPND_SME_ZA_array_off2x2:
1907
2.10k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 3, 2,
1908
2.10k
        get_opcode_dependent_value (opcode)))
1909
0
      return 0;
1910
2.10k
    break;
1911
1912
4.22k
  case AARCH64_OPND_SME_ZA_array_off2x4:
1913
4.22k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 3, 4,
1914
4.22k
        get_opcode_dependent_value (opcode)))
1915
0
      return 0;
1916
4.22k
    break;
1917
1918
4.22k
  case AARCH64_OPND_SME_ZA_array_off3x2:
1919
2.70k
    if (!check_za_access (opnd, mismatch_detail, idx, 8, 7, 2,
1920
2.70k
        get_opcode_dependent_value (opcode)))
1921
0
      return 0;
1922
2.70k
    break;
1923
1924
2.70k
  case AARCH64_OPND_SME_ZA_HV_idx_srcxN:
1925
666
  case AARCH64_OPND_SME_ZA_HV_idx_destxN:
1926
666
    size = aarch64_get_qualifier_esize (opnd->qualifier);
1927
666
    num = get_opcode_dependent_value (opcode);
1928
666
    max_value = 16 / num / size;
1929
666
    if (max_value > 0)
1930
666
      max_value -= 1;
1931
666
    if (!check_za_access (opnd, mismatch_detail, idx,
1932
666
        12, max_value, num, 0))
1933
0
      return 0;
1934
666
    break;
1935
1936
666
  default:
1937
0
    abort ();
1938
56.0k
  }
1939
56.0k
      break;
1940
1941
766k
    case AARCH64_OPND_CLASS_PRED_REG:
1942
766k
      switch (type)
1943
766k
  {
1944
1.65k
  case AARCH64_OPND_SME_PNd3:
1945
28.0k
  case AARCH64_OPND_SME_PNg3:
1946
28.0k
    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
28.0k
    break;
1952
1953
738k
  default:
1954
738k
    if (opnd->reg.regno >= 8
1955
738k
        && 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
738k
    break;
1961
766k
  }
1962
766k
      break;
1963
1964
766k
    case AARCH64_OPND_CLASS_COND:
1965
27.9k
      if (type == AARCH64_OPND_COND1
1966
27.9k
    && (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
27.9k
      break;
1972
1973
3.24M
    case AARCH64_OPND_CLASS_ADDRESS:
1974
      /* Check writeback.  */
1975
3.24M
      switch (opcode->iclass)
1976
3.24M
  {
1977
304k
  case ldst_pos:
1978
387k
  case ldst_unscaled:
1979
531k
  case ldstnapair_offs:
1980
701k
  case ldstpair_off:
1981
717k
  case ldst_unpriv:
1982
717k
    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
717k
    break;
1989
717k
  case ldst_imm10:
1990
11.1k
    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
11.1k
    break;
1997
68.9k
  case ldst_imm9:
1998
298k
  case ldstpair_indexed:
1999
308k
  case asisdlsep:
2000
333k
  case asisdlsop:
2001
333k
    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
333k
    break;
2008
2.17M
  default:
2009
2.17M
    assert (opnd->addr.writeback == 0);
2010
2.17M
    break;
2011
3.24M
  }
2012
3.24M
      switch (type)
2013
3.24M
  {
2014
513k
  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
513k
    size = aarch64_get_qualifier_esize (opnd->qualifier);
2020
513k
    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
513k
    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
513k
    break;
2032
513k
  case AARCH64_OPND_ADDR_OFFSET:
2033
155k
  case AARCH64_OPND_ADDR_SIMM9:
2034
    /* Unscaled signed 9 bits immediate offset.  */
2035
155k
    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
155k
    break;
2041
2042
155k
  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
11.1k
  case AARCH64_OPND_ADDR_SIMM10:
2055
    /* Scaled signed 10 bits immediate offset.  */
2056
11.1k
    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
11.1k
    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
11.1k
    break;
2067
2068
30.3k
  case AARCH64_OPND_ADDR_SIMM11:
2069
    /* Signed 11 bits immediate offset (multiple of 16).  */
2070
30.3k
    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
30.3k
    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
30.3k
    break;
2082
2083
30.3k
  case AARCH64_OPND_ADDR_SIMM13:
2084
    /* Signed 13 bits immediate offset (multiple of 16).  */
2085
12.7k
    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
12.7k
    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
12.7k
    break;
2097
2098
34.2k
  case AARCH64_OPND_SIMD_ADDR_POST:
2099
    /* AdvSIMD load/store multiple structures, post-index.  */
2100
34.2k
    assert (idx == 1);
2101
34.2k
    if (opnd->addr.offset.is_reg)
2102
33.2k
      {
2103
33.2k
        if (value_in_range_p (opnd->addr.offset.regno, 0, 30))
2104
33.2k
    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
33.2k
      }
2112
1.08k
    else
2113
1.08k
      {
2114
1.08k
        const aarch64_opnd_info *prev = &opnds[idx-1];
2115
1.08k
        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.08k
        int is_ld1r = get_opcode_dependent_value (opcode) == 1;
2119
1.08k
        if (opcode->operands[0] == AARCH64_OPND_LVt_AL)
2120
    /* Special handling of loading single structure to all lane.  */
2121
27
    num_bytes = (is_ld1r ? 1 : prev->reglist.num_regs)
2122
27
      * aarch64_get_qualifier_esize (prev->qualifier);
2123
1.06k
        else
2124
1.06k
    num_bytes = prev->reglist.num_regs
2125
1.06k
      * aarch64_get_qualifier_esize (prev->qualifier)
2126
1.06k
      * aarch64_get_qualifier_nelem (prev->qualifier);
2127
1.08k
        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.08k
      }
2134
1.08k
    break;
2135
2136
38.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
38.8k
    size = aarch64_get_qualifier_esize (opnd->qualifier);
2141
    /* It is either no shift or shift by the binary logarithm of SIZE.  */
2142
38.8k
    if (opnd->shifter.amount != 0
2143
38.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
38.8k
    switch (opnd->shifter.kind)
2152
38.8k
      {
2153
3.59k
      case AARCH64_MOD_UXTW:
2154
10.1k
      case AARCH64_MOD_LSL:
2155
14.7k
      case AARCH64_MOD_SXTW:
2156
18.5k
      case AARCH64_MOD_SXTX: break;
2157
20.3k
      default:
2158
20.3k
        set_other_error (mismatch_detail, idx,
2159
20.3k
             _("invalid extend/shift operator"));
2160
20.3k
        return 0;
2161
38.8k
      }
2162
18.5k
    break;
2163
2164
304k
  case AARCH64_OPND_ADDR_UIMM12:
2165
304k
    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
304k
    size = aarch64_get_qualifier_esize (qualifier);
2170
304k
    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
304k
    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
304k
    break;
2182
2183
304k
  case AARCH64_OPND_ADDR_PCREL14:
2184
723k
  case AARCH64_OPND_ADDR_PCREL19:
2185
1.03M
  case AARCH64_OPND_ADDR_PCREL21:
2186
1.38M
  case AARCH64_OPND_ADDR_PCREL26:
2187
1.38M
    imm = opnd->imm.value;
2188
1.38M
    if (operand_need_shift_by_two (get_operand_from_code (type)))
2189
1.06M
      {
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.06M
        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.06M
        imm >>= 2;
2200
1.06M
      }
2201
1.38M
    size = get_operand_fields_width (get_operand_from_code (type));
2202
1.38M
    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.38M
    break;
2209
2210
1.38M
  case AARCH64_OPND_SME_ADDR_RI_U4xVL:
2211
144
    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
144
    break;
2217
2218
32.6k
  case AARCH64_OPND_SVE_ADDR_RI_S4xVL:
2219
40.6k
  case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL:
2220
42.5k
  case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL:
2221
48.1k
  case AARCH64_OPND_SVE_ADDR_RI_S4x4xVL:
2222
48.1k
    min_value = -8;
2223
48.1k
    max_value = 7;
2224
58.9k
  sve_imm_offset_vl:
2225
58.9k
    assert (!opnd->addr.offset.is_reg);
2226
58.9k
    assert (opnd->addr.preind);
2227
58.9k
    num = 1 + get_operand_specific_data (&aarch64_operands[type]);
2228
58.9k
    min_value *= num;
2229
58.9k
    max_value *= num;
2230
58.9k
    if ((opnd->addr.offset.imm != 0 && !opnd->shifter.operator_present)
2231
58.9k
        || (opnd->shifter.operator_present
2232
58.9k
      && 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
58.9k
    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
58.9k
    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
58.9k
    break;
2250
2251
58.9k
  case AARCH64_OPND_SVE_ADDR_RI_S6xVL:
2252
2.86k
    min_value = -32;
2253
2.86k
    max_value = 31;
2254
2.86k
    goto sve_imm_offset_vl;
2255
2256
7.89k
  case AARCH64_OPND_SVE_ADDR_RI_S9xVL:
2257
7.89k
    min_value = -256;
2258
7.89k
    max_value = 255;
2259
7.89k
    goto sve_imm_offset_vl;
2260
2261
14.0k
  case AARCH64_OPND_SVE_ADDR_RI_U6:
2262
19.4k
  case AARCH64_OPND_SVE_ADDR_RI_U6x2:
2263
25.0k
  case AARCH64_OPND_SVE_ADDR_RI_U6x4:
2264
26.5k
  case AARCH64_OPND_SVE_ADDR_RI_U6x8:
2265
26.5k
    min_value = 0;
2266
26.5k
    max_value = 63;
2267
48.3k
  sve_imm_offset:
2268
48.3k
    assert (!opnd->addr.offset.is_reg);
2269
48.3k
    assert (opnd->addr.preind);
2270
48.3k
    num = 1 << get_operand_specific_data (&aarch64_operands[type]);
2271
48.3k
    min_value *= num;
2272
48.3k
    max_value *= num;
2273
48.3k
    if (opnd->shifter.operator_present
2274
48.3k
        || 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
48.3k
    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
48.3k
    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
48.3k
    break;
2292
2293
48.3k
  case AARCH64_OPND_SVE_ADDR_RI_S4x16:
2294
2.09k
  case AARCH64_OPND_SVE_ADDR_RI_S4x32:
2295
2.09k
    min_value = -8;
2296
2.09k
    max_value = 7;
2297
2.09k
    goto sve_imm_offset;
2298
2299
11.9k
  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
11.9k
    assert (opnd->addr.offset.is_reg);
2304
11.9k
    assert (opnd->addr.preind);
2305
11.9k
    assert ((aarch64_operands[type].flags & OPD_F_NO_ZR) == 0);
2306
11.9k
    assert (opnd->shifter.kind == AARCH64_MOD_LSL);
2307
11.9k
    assert (opnd->shifter.operator_present == 0);
2308
11.9k
    break;
2309
2310
11.9k
  case AARCH64_OPND_SVE_ADDR_R:
2311
21.6k
  case AARCH64_OPND_SVE_ADDR_RR:
2312
33.9k
  case AARCH64_OPND_SVE_ADDR_RR_LSL1:
2313
43.7k
  case AARCH64_OPND_SVE_ADDR_RR_LSL2:
2314
60.0k
  case AARCH64_OPND_SVE_ADDR_RR_LSL3:
2315
64.5k
  case AARCH64_OPND_SVE_ADDR_RR_LSL4:
2316
77.1k
  case AARCH64_OPND_SVE_ADDR_RX:
2317
87.4k
  case AARCH64_OPND_SVE_ADDR_RX_LSL1:
2318
100k
  case AARCH64_OPND_SVE_ADDR_RX_LSL2:
2319
108k
  case AARCH64_OPND_SVE_ADDR_RX_LSL3:
2320
121k
  case AARCH64_OPND_SVE_ADDR_RZ:
2321
124k
  case AARCH64_OPND_SVE_ADDR_RZ_LSL1:
2322
127k
  case AARCH64_OPND_SVE_ADDR_RZ_LSL2:
2323
129k
  case AARCH64_OPND_SVE_ADDR_RZ_LSL3:
2324
129k
    modifiers = 1 << AARCH64_MOD_LSL;
2325
212k
  sve_rr_operand:
2326
212k
    assert (opnd->addr.offset.is_reg);
2327
212k
    assert (opnd->addr.preind);
2328
212k
    if ((aarch64_operands[type].flags & OPD_F_NO_ZR) != 0
2329
212k
        && 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
212k
    if (((1 << opnd->shifter.kind) & modifiers) == 0
2336
212k
        || (opnd->shifter.amount
2337
212k
      != 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
212k
    break;
2344
2345
212k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW_14:
2346
47.5k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW_22:
2347
50.0k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW1_14:
2348
59.2k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW1_22:
2349
61.3k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW2_14:
2350
69.9k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW2_22:
2351
71.4k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW3_14:
2352
82.6k
  case AARCH64_OPND_SVE_ADDR_RZ_XTW3_22:
2353
82.6k
    modifiers = (1 << AARCH64_MOD_SXTW) | (1 << AARCH64_MOD_UXTW);
2354
82.6k
    goto sve_rr_operand;
2355
2356
6.17k
  case AARCH64_OPND_SVE_ADDR_ZI_U5:
2357
12.5k
  case AARCH64_OPND_SVE_ADDR_ZI_U5x2:
2358
17.1k
  case AARCH64_OPND_SVE_ADDR_ZI_U5x4:
2359
19.7k
  case AARCH64_OPND_SVE_ADDR_ZI_U5x8:
2360
19.7k
    min_value = 0;
2361
19.7k
    max_value = 31;
2362
19.7k
    goto sve_imm_offset;
2363
2364
864
  case AARCH64_OPND_SVE_ADDR_ZZ_LSL:
2365
864
    modifiers = 1 << AARCH64_MOD_LSL;
2366
1.20k
  sve_zz_operand:
2367
1.20k
    assert (opnd->addr.offset.is_reg);
2368
1.20k
    assert (opnd->addr.preind);
2369
1.20k
    if (((1 << opnd->shifter.kind) & modifiers) == 0
2370
1.20k
        || opnd->shifter.amount < 0
2371
1.20k
        || 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.20k
    break;
2378
2379
1.20k
  case AARCH64_OPND_SVE_ADDR_ZZ_SXTW:
2380
192
    modifiers = (1 << AARCH64_MOD_SXTW);
2381
192
    goto sve_zz_operand;
2382
2383
151
  case AARCH64_OPND_SVE_ADDR_ZZ_UXTW:
2384
151
    modifiers = 1 << AARCH64_MOD_UXTW;
2385
151
    goto sve_zz_operand;
2386
2387
424k
  default:
2388
424k
    break;
2389
3.24M
  }
2390
3.18M
      break;
2391
2392
3.18M
    case AARCH64_OPND_CLASS_SIMD_REGLIST:
2393
62.8k
      if (type == AARCH64_OPND_LEt)
2394
30.3k
  {
2395
    /* Get the upper bound for the element index.  */
2396
30.3k
    num = 16 / aarch64_get_qualifier_esize (qualifier) - 1;
2397
30.3k
    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
30.3k
  }
2403
      /* The opcode dependent area stores the number of elements in
2404
   each structure to be loaded/stored.  */
2405
62.8k
      num = get_opcode_dependent_value (opcode);
2406
62.8k
      switch (type)
2407
62.8k
  {
2408
18.6k
  case AARCH64_OPND_LVt:
2409
18.6k
    assert (num >= 1 && num <= 4);
2410
    /* Unless LD1/ST1, the number of registers should be equal to that
2411
       of the structure elements.  */
2412
18.6k
    if (num != 1 && !check_reglist (opnd, mismatch_detail, idx, num, 1))
2413
739
      return 0;
2414
17.9k
    break;
2415
17.9k
  case AARCH64_OPND_LVt_AL:
2416
32.4k
  case AARCH64_OPND_LEt:
2417
32.4k
    assert (num >= 1 && num <= 4);
2418
    /* The number of registers should be equal to that of the structure
2419
       elements.  */
2420
32.4k
    if (!check_reglist (opnd, mismatch_detail, idx, num, 1))
2421
0
      return 0;
2422
32.4k
    break;
2423
32.4k
  default:
2424
11.7k
    break;
2425
62.8k
  }
2426
62.0k
      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
62.0k
      break;
2432
2433
2.73M
    case AARCH64_OPND_CLASS_IMMEDIATE:
2434
      /* Constraint check on immediate operand.  */
2435
2.73M
      imm = opnd->imm.value;
2436
      /* E.g. imm_0_31 constrains value to be 0..31.  */
2437
2.73M
      if (qualifier_value_in_range_constraint_p (qualifier)
2438
2.73M
    && !value_in_range_p (imm, get_lower_bound (qualifier),
2439
622k
        get_upper_bound (qualifier)))
2440
92.8k
  {
2441
92.8k
    set_imm_out_of_range_error (mismatch_detail, idx,
2442
92.8k
              get_lower_bound (qualifier),
2443
92.8k
              get_upper_bound (qualifier));
2444
92.8k
    return 0;
2445
92.8k
  }
2446
2447
2.64M
      switch (type)
2448
2.64M
  {
2449
364k
  case AARCH64_OPND_AIMM:
2450
364k
    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
364k
    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
364k
    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
364k
    break;
2469
2470
364k
  case AARCH64_OPND_HALF:
2471
129k
    assert (idx == 1 && opnds[0].type == AARCH64_OPND_Rd);
2472
129k
    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
129k
    size = aarch64_get_qualifier_esize (opnds[0].qualifier);
2479
129k
    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
129k
    if (!value_in_range_p (opnd->shifter.amount, 0, size * 8 - 16))
2486
24.7k
      {
2487
24.7k
        set_sft_amount_out_of_range_error (mismatch_detail, idx,
2488
24.7k
             0, size * 8 - 16);
2489
24.7k
        return 0;
2490
24.7k
      }
2491
105k
    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
105k
    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
105k
    break;
2504
2505
105k
  case AARCH64_OPND_IMM_MOV:
2506
72.6k
      {
2507
72.6k
        int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2508
72.6k
        imm = opnd->imm.value;
2509
72.6k
        assert (idx == 1);
2510
72.6k
        switch (opcode->op)
2511
72.6k
    {
2512
30.9k
    case OP_MOV_IMM_WIDEN:
2513
30.9k
      imm = ~imm;
2514
      /* Fall through.  */
2515
71.8k
    case OP_MOV_IMM_WIDE:
2516
71.8k
      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
71.8k
      break;
2523
71.8k
    case OP_MOV_IMM_LOG:
2524
789
      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
789
      break;
2531
789
    default:
2532
0
      assert (0);
2533
0
      return 0;
2534
72.6k
    }
2535
72.6k
      }
2536
72.6k
    break;
2537
2538
72.6k
  case AARCH64_OPND_NZCV:
2539
11.3k
  case AARCH64_OPND_CCMP_IMM:
2540
12.2k
  case AARCH64_OPND_EXCEPTION:
2541
1.10M
  case AARCH64_OPND_UNDEFINED:
2542
1.10M
  case AARCH64_OPND_TME_UIMM16:
2543
1.10M
  case AARCH64_OPND_UIMM4:
2544
1.11M
  case AARCH64_OPND_UIMM4_ADDG:
2545
1.11M
  case AARCH64_OPND_UIMM7:
2546
1.11M
  case AARCH64_OPND_UIMM3_OP1:
2547
1.11M
  case AARCH64_OPND_UIMM3_OP2:
2548
1.11M
  case AARCH64_OPND_SVE_UIMM3:
2549
1.14M
  case AARCH64_OPND_SVE_UIMM7:
2550
1.14M
  case AARCH64_OPND_SVE_UIMM8:
2551
1.15M
  case AARCH64_OPND_SVE_UIMM8_53:
2552
1.15M
  case AARCH64_OPND_CSSC_UIMM8:
2553
1.15M
    size = get_operand_fields_width (get_operand_from_code (type));
2554
1.15M
    assert (size < 32);
2555
1.15M
    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.15M
    break;
2562
2563
1.15M
  case AARCH64_OPND_UIMM10:
2564
    /* Scaled unsigned 10 bits immediate offset.  */
2565
4.82k
    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
4.82k
    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
4.82k
    break;
2577
2578
9.51k
  case AARCH64_OPND_SIMM5:
2579
10.1k
  case AARCH64_OPND_SVE_SIMM5:
2580
10.5k
  case AARCH64_OPND_SVE_SIMM5B:
2581
12.3k
  case AARCH64_OPND_SVE_SIMM6:
2582
13.0k
  case AARCH64_OPND_SVE_SIMM8:
2583
14.7k
  case AARCH64_OPND_CSSC_SIMM8:
2584
14.7k
    size = get_operand_fields_width (get_operand_from_code (type));
2585
14.7k
    assert (size < 32);
2586
14.7k
    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
14.7k
    break;
2594
2595
70.5k
  case AARCH64_OPND_WIDTH:
2596
70.5k
    assert (idx > 1 && opnds[idx-1].type == AARCH64_OPND_IMM
2597
70.5k
      && opnds[0].type == AARCH64_OPND_Rd);
2598
70.5k
    size = get_upper_bound (qualifier);
2599
70.5k
    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
70.5k
    break;
2607
2608
228k
  case AARCH64_OPND_LIMM:
2609
260k
  case AARCH64_OPND_SVE_LIMM:
2610
260k
    {
2611
260k
      int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2612
260k
      uint64_t uimm = opnd->imm.value;
2613
260k
      if (opcode->op == OP_BIC)
2614
0
        uimm = ~uimm;
2615
260k
      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
260k
    }
2622
260k
    break;
2623
2624
260k
  case AARCH64_OPND_IMM0:
2625
594
  case AARCH64_OPND_FPIMM0:
2626
594
    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
594
    break;
2633
2634
1.07k
  case AARCH64_OPND_IMM_ROT1:
2635
15.3k
  case AARCH64_OPND_IMM_ROT2:
2636
21.3k
  case AARCH64_OPND_SVE_IMM_ROT2:
2637
21.3k
    if (opnd->imm.value != 0
2638
21.3k
        && opnd->imm.value != 90
2639
21.3k
        && opnd->imm.value != 180
2640
21.3k
        && 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
21.3k
    break;
2647
2648
21.3k
  case AARCH64_OPND_IMM_ROT3:
2649
1.14k
  case AARCH64_OPND_SVE_IMM_ROT1:
2650
1.15k
  case AARCH64_OPND_SVE_IMM_ROT3:
2651
1.15k
    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.15k
    break;
2658
2659
1.15k
  case AARCH64_OPND_SHLL_IMM:
2660
30
    assert (idx == 2);
2661
30
    size = 8 * aarch64_get_qualifier_esize (opnds[idx - 1].qualifier);
2662
30
    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
30
    break;
2669
2670
9.96k
  case AARCH64_OPND_IMM_VLSL:
2671
9.96k
    size = aarch64_get_qualifier_esize (qualifier);
2672
9.96k
    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
9.96k
    break;
2679
2680
11.9k
  case AARCH64_OPND_IMM_VLSR:
2681
11.9k
    size = aarch64_get_qualifier_esize (qualifier);
2682
11.9k
    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
11.9k
    break;
2688
2689
11.9k
  case AARCH64_OPND_SIMD_IMM:
2690
1.85k
  case AARCH64_OPND_SIMD_IMM_SFT:
2691
    /* Qualifier check.  */
2692
1.85k
    switch (qualifier)
2693
1.85k
      {
2694
1.72k
      case AARCH64_OPND_QLF_LSL:
2695
1.72k
        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
1.72k
        break;
2702
1.72k
      case AARCH64_OPND_QLF_MSL:
2703
108
        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
108
        break;
2710
108
      case AARCH64_OPND_QLF_NIL:
2711
29
        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
29
        break;
2718
29
      default:
2719
0
        assert (0);
2720
0
        return 0;
2721
1.85k
      }
2722
    /* Is the immediate valid?  */
2723
1.85k
    assert (idx == 1);
2724
1.85k
    if (aarch64_get_qualifier_esize (opnds[0].qualifier) != 8)
2725
1.82k
      {
2726
        /* uimm8 or simm8 */
2727
1.82k
        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
1.82k
      }
2733
29
    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
1.85k
    switch (opnd->shifter.kind)
2744
1.85k
      {
2745
1.72k
      case AARCH64_MOD_LSL:
2746
1.72k
        size = aarch64_get_qualifier_esize (opnds[0].qualifier);
2747
1.72k
        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
1.72k
        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
1.72k
        break;
2759
1.72k
      case AARCH64_MOD_MSL:
2760
        /* Only 8 and 16 are valid shift amount.  */
2761
108
        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
108
        break;
2768
108
      default:
2769
29
        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
29
        break;
2776
1.85k
      }
2777
1.85k
    break;
2778
2779
1.85k
  case AARCH64_OPND_FPIMM:
2780
299
  case AARCH64_OPND_SIMD_FPIMM:
2781
2.32k
  case AARCH64_OPND_SVE_FPIMM8:
2782
2.32k
    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
2.32k
    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
2.32k
    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
2.32k
    break;
2805
2806
2.32k
  case AARCH64_OPND_SVE_AIMM:
2807
870
    min_value = 0;
2808
29.5k
  sve_aimm:
2809
29.5k
    assert (opnd->shifter.kind == AARCH64_MOD_LSL);
2810
29.5k
    size = aarch64_get_qualifier_esize (opnds[0].qualifier);
2811
29.5k
    mask = ~((uint64_t) -1 << (size * 4) << (size * 4));
2812
29.5k
    uvalue = opnd->imm.value;
2813
29.5k
    shift = opnd->shifter.amount;
2814
29.5k
    if (size == 1)
2815
2.85k
      {
2816
2.85k
        if (shift != 0)
2817
1
    {
2818
1
      set_other_error (mismatch_detail, idx,
2819
1
           _("no shift amount allowed for"
2820
1
             " 8-bit constants"));
2821
1
      return 0;
2822
1
    }
2823
2.85k
      }
2824
26.6k
    else
2825
26.6k
      {
2826
26.6k
        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
26.6k
        if (shift == 0 && (uvalue & 0xff) == 0)
2833
14.1k
    {
2834
14.1k
      shift = 8;
2835
14.1k
      uvalue = (int64_t) uvalue / 256;
2836
14.1k
    }
2837
26.6k
      }
2838
29.5k
    mask >>= shift;
2839
29.5k
    if ((uvalue & mask) != uvalue && (uvalue | ~mask) != uvalue)
2840
805
      {
2841
805
        set_other_error (mismatch_detail, idx,
2842
805
             _("immediate too big for element size"));
2843
805
        return 0;
2844
805
      }
2845
28.7k
    uvalue = (uvalue - min_value) & mask;
2846
28.7k
    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
28.7k
    break;
2853
2854
28.7k
  case AARCH64_OPND_SVE_ASIMM:
2855
28.6k
    min_value = -128;
2856
28.6k
    goto sve_aimm;
2857
2858
0
  case AARCH64_OPND_SVE_I1_HALF_ONE:
2859
0
    assert (opnd->imm.is_fp);
2860
0
    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
0
    break;
2867
2868
1
  case AARCH64_OPND_SVE_I1_HALF_TWO:
2869
1
    assert (opnd->imm.is_fp);
2870
1
    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
1
    break;
2877
2878
1
  case AARCH64_OPND_SVE_I1_ZERO_ONE:
2879
0
    assert (opnd->imm.is_fp);
2880
0
    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
0
    break;
2887
2888
0
  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
453
  case AARCH64_OPND_SVE_LIMM_MOV:
2902
453
    {
2903
453
      int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2904
453
      uint64_t uimm = opnd->imm.value;
2905
453
      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
453
      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
453
    }
2918
453
    break;
2919
2920
3.35k
  case AARCH64_OPND_SVE_PATTERN_SCALED:
2921
3.35k
    assert (opnd->shifter.kind == AARCH64_MOD_MUL);
2922
3.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
3.35k
    break;
2928
2929
3.35k
  case AARCH64_OPND_SVE_SHLIMM_PRED:
2930
1.11k
  case AARCH64_OPND_SVE_SHLIMM_UNPRED:
2931
1.47k
  case AARCH64_OPND_SVE_SHLIMM_UNPRED_22:
2932
1.47k
    size = aarch64_get_qualifier_esize (opnds[idx - 1].qualifier);
2933
1.47k
    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
1.47k
    break;
2940
2941
1.47k
  case AARCH64_OPND_SME_SHRIMM4:
2942
90
    size = 1 << get_operand_fields_width (get_operand_from_code (type));
2943
90
    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
90
    break;
2949
2950
141
  case AARCH64_OPND_SME_SHRIMM5:
2951
2.10k
  case AARCH64_OPND_SVE_SHRIMM_PRED:
2952
4.79k
  case AARCH64_OPND_SVE_SHRIMM_UNPRED:
2953
10.2k
  case AARCH64_OPND_SVE_SHRIMM_UNPRED_22:
2954
10.2k
    num = (type == AARCH64_OPND_SVE_SHRIMM_UNPRED_22) ? 2 : 1;
2955
10.2k
    size = aarch64_get_qualifier_esize (opnds[idx - num].qualifier);
2956
10.2k
    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
10.2k
    break;
2962
2963
10.2k
  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
481k
  default:
2978
481k
    break;
2979
2.64M
  }
2980
2.61M
      break;
2981
2982
2.61M
    case AARCH64_OPND_CLASS_SYSTEM:
2983
60.8k
      switch (type)
2984
60.8k
  {
2985
0
  case AARCH64_OPND_PSTATEFIELD:
2986
0
    for (i = 0; aarch64_pstatefields[i].name; ++i)
2987
0
      if (aarch64_pstatefields[i].value == opnd->pstatefield)
2988
0
        break;
2989
0
    assert (aarch64_pstatefields[i].name);
2990
0
    assert (idx == 0 && opnds[1].type == AARCH64_OPND_UIMM4);
2991
0
    max_value = F_GET_REG_MAX_VALUE (aarch64_pstatefields[i].flags);
2992
0
    if (opnds[1].imm.value < 0 || opnds[1].imm.value > max_value)
2993
0
      {
2994
0
        set_imm_out_of_range_error (mismatch_detail, 1, 0, max_value);
2995
0
        return 0;
2996
0
      }
2997
0
    break;
2998
53.5k
  case AARCH64_OPND_PRFOP:
2999
53.5k
    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
53.2k
    break;
3007
53.2k
  default:
3008
7.36k
    break;
3009
60.8k
  }
3010
60.5k
      break;
3011
3012
60.5k
    case AARCH64_OPND_CLASS_SIMD_ELEMENT:
3013
      /* Get the upper bound for the element index.  */
3014
57.4k
      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.73k
  num = aarch64_get_qualifier_nelem (opnds[0].qualifier)
3018
7.73k
        * aarch64_get_qualifier_esize (opnds[0].qualifier) / 2;
3019
49.6k
      else
3020
49.6k
  num = 16;
3021
57.4k
      num = num / aarch64_get_qualifier_esize (qualifier) - 1;
3022
57.4k
      assert (aarch64_get_qualifier_nelem (qualifier) == 1);
3023
3024
      /* Index out-of-range.  */
3025
57.4k
      if (!value_in_range_p (opnd->reglane.index, 0, num))
3026
1.08k
  {
3027
1.08k
    set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, num);
3028
1.08k
    return 0;
3029
1.08k
  }
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
56.3k
      if (type == AARCH64_OPND_Em16 && qualifier == AARCH64_OPND_QLF_S_H
3039
56.3k
    && !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
56.3k
      break;
3045
3046
789k
    case AARCH64_OPND_CLASS_MODIFIED_REG:
3047
789k
      assert (idx == 1 || idx == 2);
3048
789k
      switch (type)
3049
789k
  {
3050
54.7k
  case AARCH64_OPND_Rm_EXT:
3051
54.7k
    if (!aarch64_extend_operator_p (opnd->shifter.kind)
3052
54.7k
        && 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
54.7k
    if (!aarch64_stack_pointer_p (opnds + 0)
3063
54.7k
        && (idx != 2 || !aarch64_stack_pointer_p (opnds + 1)))
3064
53.0k
      {
3065
53.0k
        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
53.0k
        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
53.0k
      }
3078
54.7k
    assert (opnd->shifter.operator_present  /* Default to LSL.  */
3079
54.7k
      || opnd->shifter.kind == AARCH64_MOD_LSL);
3080
54.7k
    if (!value_in_range_p (opnd->shifter.amount, 0, 4))
3081
14.7k
      {
3082
14.7k
        set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, 4);
3083
14.7k
        return 0;
3084
14.7k
      }
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
40.0k
    if (qualifier == AARCH64_OPND_QLF_X
3091
40.0k
        && opnd->shifter.kind != AARCH64_MOD_LSL
3092
40.0k
        && opnd->shifter.kind != AARCH64_MOD_UXTX
3093
40.0k
        && 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
40.0k
    break;
3099
3100
734k
  case AARCH64_OPND_Rm_SFT:
3101
    /* ROR is not available to the shifted register operand in
3102
       arithmetic instructions.  */
3103
734k
    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
734k
    if (opnd->shifter.kind == AARCH64_MOD_ROR
3110
734k
        && 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
734k
    num = qualifier == AARCH64_OPND_QLF_W ? 31 : 63;
3117
734k
    if (!value_in_range_p (opnd->shifter.amount, 0, num))
3118
102k
      {
3119
102k
        set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, num);
3120
102k
        return 0;
3121
102k
      }
3122
631k
    break;
3123
3124
631k
  default:
3125
0
    break;
3126
789k
  }
3127
671k
      break;
3128
3129
1.57M
    default:
3130
1.57M
      break;
3131
16.7M
    }
3132
3133
16.4M
  return 1;
3134
16.7M
}
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.03M
{
3151
7.03M
  int i;
3152
3153
7.03M
  DEBUG_TRACE ("enter");
3154
3155
7.03M
  i = inst->opcode->tied_operand;
3156
3157
7.03M
  if (i > 0)
3158
69.3k
    {
3159
      /* Check for tied_operands with specific opcode iclass.  */
3160
69.3k
      switch (inst->opcode->iclass)
3161
69.3k
        {
3162
        /* For SME LDR and STR instructions #imm must have the same numerical
3163
           value for both operands.
3164
        */
3165
143
        case sme_ldr:
3166
144
        case sme_str:
3167
144
          assert (inst->operands[0].type == AARCH64_OPND_SME_ZA_array_off4);
3168
144
          assert (inst->operands[1].type == AARCH64_OPND_SME_ADDR_RI_U4xVL);
3169
144
          if (inst->operands[0].indexed_za.index.imm
3170
144
              != 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
144
          break;
3180
3181
69.1k
        default:
3182
69.1k
    {
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
69.1k
      enum aarch64_operand_class op_class1
3190
69.1k
         = aarch64_get_operand_class (inst->operands[0].type);
3191
69.1k
      enum aarch64_operand_class op_class2
3192
69.1k
         = aarch64_get_operand_class (inst->operands[i].type);
3193
69.1k
      assert (op_class1 == op_class2);
3194
69.1k
      if (op_class1 == AARCH64_OPND_CLASS_SVE_REGLIST
3195
69.1k
    ? ((inst->operands[0].reglist.first_regno
3196
110
        != inst->operands[i].reglist.first_regno)
3197
110
       || (inst->operands[0].reglist.num_regs
3198
110
           != inst->operands[i].reglist.num_regs)
3199
110
       || (inst->operands[0].reglist.stride
3200
110
           != inst->operands[i].reglist.stride))
3201
69.1k
    : (inst->operands[0].reg.regno
3202
69.0k
       != 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
69.1k
      break;
3213
69.1k
    }
3214
69.3k
        }
3215
69.3k
    }
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.03M
  int invalid_count;
3228
7.03M
  if (match_operands_qualifier (inst, true /* update_p */,
3229
7.03M
        &invalid_count) == 0)
3230
35.1k
    {
3231
35.1k
      DEBUG_TRACE ("FAIL on operand qualifier matching");
3232
35.1k
      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
35.1k
      return 0;
3243
35.1k
    }
3244
3245
  /* Match operands' constraint.  */
3246
23.4M
  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
3247
23.4M
    {
3248
23.4M
      enum aarch64_opnd type = inst->opcode->operands[i];
3249
23.4M
      if (type == AARCH64_OPND_NIL)
3250
6.73M
  break;
3251
16.7M
      if (inst->operands[i].skip)
3252
0
  {
3253
0
    DEBUG_TRACE ("skip the incomplete operand %d", i);
3254
0
    continue;
3255
0
  }
3256
16.7M
      if (operand_general_constraint_met_p (inst->operands, i, type,
3257
16.7M
              inst->opcode, mismatch_detail) == 0)
3258
261k
  {
3259
261k
    DEBUG_TRACE ("FAIL on operand %d", i);
3260
261k
    return 0;
3261
261k
  }
3262
16.7M
    }
3263
3264
6.73M
  DEBUG_TRACE ("PASS");
3265
3266
6.73M
  return 1;
3267
6.99M
}
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
145k
{
3281
145k
  int i;
3282
145k
  const aarch64_opcode *old = inst->opcode;
3283
3284
145k
  inst->opcode = opcode;
3285
3286
  /* Update the operand types.  */
3287
580k
  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
3288
580k
    {
3289
580k
      inst->operands[i].type = opcode->operands[i];
3290
580k
      if (opcode->operands[i] == AARCH64_OPND_NIL)
3291
145k
  break;
3292
580k
    }
3293
3294
145k
  DEBUG_TRACE ("replace %s with %s", old->name, opcode->name);
3295
3296
145k
  return old;
3297
145k
}
3298
3299
int
3300
aarch64_operand_index (const enum aarch64_opnd *operands, enum aarch64_opnd operand)
3301
269k
{
3302
269k
  int i;
3303
294k
  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
3304
294k
    if (operands[i] == operand)
3305
268k
      return i;
3306
26.0k
    else if (operands[i] == AARCH64_OPND_NIL)
3307
411
      break;
3308
411
  return -1;
3309
269k
}
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
4.85M
{
3348
4.85M
  const int has_zr = sp_reg_p ? 0 : 1;
3349
4.85M
  const int is_64 = aarch64_get_qualifier_esize (qualifier) == 4 ? 0 : 1;
3350
4.85M
  return int_reg[has_zr][is_64][regno];
3351
4.85M
}
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.60M
{
3358
1.60M
  const int has_zr = sp_reg_p ? 0 : 1;
3359
1.60M
  return int_reg[has_zr][1][regno];
3360
1.60M
}
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
126k
{
3368
126k
  switch (opnd->shifter.kind)
3369
126k
    {
3370
3.59k
    case AARCH64_MOD_UXTW:
3371
8.22k
    case AARCH64_MOD_SXTW:
3372
8.22k
      return get_int_reg_name (opnd->addr.offset.regno, AARCH64_OPND_QLF_W, 0);
3373
3374
114k
    case AARCH64_MOD_LSL:
3375
118k
    case AARCH64_MOD_SXTX:
3376
118k
      return get_int_reg_name (opnd->addr.offset.regno, AARCH64_OPND_QLF_X, 0);
3377
3378
0
    default:
3379
0
      abort ();
3380
126k
    }
3381
126k
}
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
137k
{
3389
137k
  assert (qualifier == AARCH64_OPND_QLF_S_S
3390
137k
    || qualifier == AARCH64_OPND_QLF_S_D);
3391
137k
  return sve_reg[qualifier == AARCH64_OPND_QLF_S_D][regno];
3392
137k
}
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
1.31k
{
3425
1.31k
  uint64_t imm = 0;
3426
1.31k
  uint32_t imm8_7, imm8_6_0, imm8_6, imm8_6_repl4;
3427
3428
1.31k
  imm8_7 = (imm8 >> 7) & 0x01;  /* imm8<7>   */
3429
1.31k
  imm8_6_0 = imm8 & 0x7f; /* imm8<6:0> */
3430
1.31k
  imm8_6 = imm8_6_0 >> 6; /* imm8<6>   */
3431
1.31k
  imm8_6_repl4 = (imm8_6 << 3) | (imm8_6 << 2)
3432
1.31k
    | (imm8_6 << 1) | imm8_6; /* Replicate(imm8<6>,4) */
3433
1.31k
  if (size == 8)
3434
260
    {
3435
260
      imm = (imm8_7 << (63-32))   /* imm8<7>  */
3436
260
  | ((imm8_6 ^ 1) << (62-32)) /* NOT(imm8<6)  */
3437
260
  | (imm8_6_repl4 << (58-32)) | (imm8_6 << (57-32))
3438
260
  | (imm8_6 << (56-32)) | (imm8_6 << (55-32)) /* Replicate(imm8<6>,7) */
3439
260
  | (imm8_6_0 << (48-32));  /* imm8<6>:imm8<5:0>    */
3440
260
      imm <<= 32;
3441
260
    }
3442
1.05k
  else if (size == 4 || size == 2)
3443
1.05k
    {
3444
1.05k
      imm = (imm8_7 << 31)  /* imm8<7>              */
3445
1.05k
  | ((imm8_6 ^ 1) << 30)  /* NOT(imm8<6>)         */
3446
1.05k
  | (imm8_6_repl4 << 26)  /* Replicate(imm8<6>,4) */
3447
1.05k
  | (imm8_6_0 << 19); /* imm8<6>:imm8<5:0>    */
3448
1.05k
    }
3449
0
  else
3450
0
    {
3451
      /* An unsupported size.  */
3452
0
      assert (0);
3453
0
    }
3454
3455
1.31k
  return imm;
3456
1.31k
}
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
10.3M
{
3463
10.3M
  const char *txt;
3464
10.3M
  va_list ap;
3465
3466
10.3M
  va_start (ap, fmt);
3467
10.3M
  txt = styler->apply_style (styler, dis_style_register, fmt, ap);
3468
10.3M
  va_end (ap);
3469
3470
10.3M
  return txt;
3471
10.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
3.97M
{
3478
3.97M
  const char *txt;
3479
3.97M
  va_list ap;
3480
3481
3.97M
  va_start (ap, fmt);
3482
3.97M
  txt = styler->apply_style (styler, dis_style_immediate, fmt, ap);
3483
3.97M
  va_end (ap);
3484
3485
3.97M
  return txt;
3486
3.97M
}
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
812k
{
3493
812k
  const char *txt;
3494
812k
  va_list ap;
3495
3496
812k
  va_start (ap, fmt);
3497
812k
  txt = styler->apply_style (styler, dis_style_sub_mnemonic, fmt, ap);
3498
812k
  va_end (ap);
3499
3500
812k
  return txt;
3501
812k
}
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.58M
{
3508
1.58M
  const char *txt;
3509
1.58M
  va_list ap;
3510
3511
1.58M
  va_start (ap, fmt);
3512
1.58M
  txt = styler->apply_style (styler, dis_style_address, fmt, ap);
3513
1.58M
  va_end (ap);
3514
3515
1.58M
  return txt;
3516
1.58M
}
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
336k
{
3525
336k
  const int mask = (prefix[0] == 'p' ? 15 : 31);
3526
336k
  const int num_regs = opnd->reglist.num_regs;
3527
336k
  const int stride = opnd->reglist.stride;
3528
336k
  const int first_reg = opnd->reglist.first_regno;
3529
336k
  const int last_reg = (first_reg + (num_regs - 1) * stride) & mask;
3530
336k
  const char *qlf_name = aarch64_get_qualifier_name (opnd->qualifier);
3531
336k
  char tb[16];  /* Temporary buffer.  */
3532
3533
336k
  assert (opnd->type != AARCH64_OPND_LEt || opnd->reglist.has_index);
3534
336k
  assert (num_regs >= 1 && num_regs <= 4);
3535
3536
  /* Prepare the index if any.  */
3537
336k
  if (opnd->reglist.has_index)
3538
    /* PR 21096: The %100 is to silence a warning about possible truncation.  */
3539
30.3k
    snprintf (tb, sizeof (tb), "[%s]",
3540
30.3k
        style_imm (styler, "%" PRIi64, (opnd->reglist.index % 100)));
3541
306k
  else
3542
306k
    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
336k
  if (stride == 1 && num_regs > 1)
3548
87.1k
    snprintf (buf, size, "{%s-%s}%s",
3549
87.1k
        style_reg (styler, "%s%d.%s", prefix, first_reg, qlf_name),
3550
87.1k
        style_reg (styler, "%s%d.%s", prefix, last_reg, qlf_name), tb);
3551
249k
  else
3552
249k
    {
3553
249k
      const int reg0 = first_reg;
3554
249k
      const int reg1 = (first_reg + stride) & mask;
3555
249k
      const int reg2 = (first_reg + stride * 2) & mask;
3556
249k
      const int reg3 = (first_reg + stride * 3) & mask;
3557
3558
249k
      switch (num_regs)
3559
249k
  {
3560
239k
  case 1:
3561
239k
    snprintf (buf, size, "{%s}%s",
3562
239k
        style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name),
3563
239k
        tb);
3564
239k
    break;
3565
7.14k
  case 2:
3566
7.14k
    snprintf (buf, size, "{%s, %s}%s",
3567
7.14k
        style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name),
3568
7.14k
        style_reg (styler, "%s%d.%s", prefix, reg1, qlf_name),
3569
7.14k
        tb);
3570
7.14k
    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.91k
  case 4:
3579
2.91k
    snprintf (buf, size, "{%s, %s, %s, %s}%s",
3580
2.91k
        style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name),
3581
2.91k
        style_reg (styler, "%s%d.%s", prefix, reg1, qlf_name),
3582
2.91k
        style_reg (styler, "%s%d.%s", prefix, reg2, qlf_name),
3583
2.91k
        style_reg (styler, "%s%d.%s", prefix, reg3, qlf_name),
3584
2.91k
        tb);
3585
2.91k
    break;
3586
249k
  }
3587
249k
    }
3588
336k
}
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
830k
{
3599
830k
  if (opnd->addr.writeback)
3600
304k
    {
3601
304k
      if (opnd->addr.preind)
3602
154k
        {
3603
154k
    if (opnd->type == AARCH64_OPND_ADDR_SIMM10 && !opnd->addr.offset.imm)
3604
0
      snprintf (buf, size, "[%s]!", style_reg (styler, base));
3605
154k
          else
3606
154k
      snprintf (buf, size, "[%s, %s]!",
3607
154k
          style_reg (styler, base),
3608
154k
          style_imm (styler, "#%d", opnd->addr.offset.imm));
3609
154k
        }
3610
150k
      else
3611
150k
  snprintf (buf, size, "[%s], %s",
3612
150k
      style_reg (styler, base),
3613
150k
      style_imm (styler, "#%d", opnd->addr.offset.imm));
3614
304k
    }
3615
525k
  else
3616
525k
    {
3617
525k
      if (opnd->shifter.operator_present)
3618
56.4k
  {
3619
56.4k
    assert (opnd->shifter.kind == AARCH64_MOD_MUL_VL);
3620
56.4k
    snprintf (buf, size, "[%s, %s, %s]",
3621
56.4k
        style_reg (styler, base),
3622
56.4k
        style_imm (styler, "#%d", opnd->addr.offset.imm),
3623
56.4k
        style_sub_mnem (styler, "mul vl"));
3624
56.4k
  }
3625
469k
      else if (opnd->addr.offset.imm)
3626
424k
  snprintf (buf, size, "[%s, %s]",
3627
424k
      style_reg (styler, base),
3628
424k
      style_imm (styler, "#%d", opnd->addr.offset.imm));
3629
44.1k
      else
3630
44.1k
  snprintf (buf, size, "[%s]", style_reg (styler, base));
3631
525k
    }
3632
830k
}
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
243k
{
3643
243k
  char tb[32];      /* Temporary buffer.  */
3644
243k
  bool print_extend_p = true;
3645
243k
  bool print_amount_p = true;
3646
243k
  const char *shift_name = aarch64_operand_modifiers[opnd->shifter.kind].name;
3647
3648
243k
  if (!opnd->shifter.amount && (opnd->qualifier != AARCH64_OPND_QLF_S_B
3649
118k
        || !opnd->shifter.amount_present))
3650
117k
    {
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
117k
      print_amount_p = false;
3654
      /* Likewise, no need to print the shift operator LSL in such a
3655
   situation.  */
3656
117k
      if (opnd->shifter.kind == AARCH64_MOD_LSL)
3657
63.7k
  print_extend_p = false;
3658
117k
    }
3659
3660
  /* Prepare for the extend/shift.  */
3661
243k
  if (print_extend_p)
3662
179k
    {
3663
179k
      if (print_amount_p)
3664
126k
  snprintf (tb, sizeof (tb), ", %s %s",
3665
126k
      style_sub_mnem (styler, shift_name),
3666
126k
      style_imm (styler, "#%" PRIi64,
3667
  /* PR 21096: The %100 is to silence a warning about possible truncation.  */
3668
126k
           (opnd->shifter.amount % 100)));
3669
53.5k
      else
3670
53.5k
  snprintf (tb, sizeof (tb), ", %s",
3671
53.5k
      style_sub_mnem (styler, shift_name));
3672
179k
    }
3673
63.7k
  else
3674
63.7k
    tb[0] = '\0';
3675
3676
243k
  snprintf (buf, size, "[%s, %s%s]", style_reg (styler, base),
3677
243k
      style_reg (styler, offset), tb);
3678
243k
}
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
6
{
3693
6
  const char* zan[] = { "za",    "za0.h", "za1.h", "za0.s",
3694
6
                        "za1.s", "za2.s", "za3.s", "za0.d",
3695
6
                        "za1.d", "za2.d", "za3.d", "za4.d",
3696
6
                        "za5.d", "za6.d", "za7.d", " " };
3697
6
  const int zan_v[] = { 0xff, 0x55, 0xaa, 0x11,
3698
6
                        0x22, 0x44, 0x88, 0x01,
3699
6
                        0x02, 0x04, 0x08, 0x10,
3700
6
                        0x20, 0x40, 0x80, 0x00 };
3701
6
  int i, k;
3702
6
  const int ZAN_SIZE = sizeof(zan) / sizeof(zan[0]);
3703
3704
6
  k = snprintf (buf, size, "{");
3705
33
  for (i = 0; i < ZAN_SIZE; i++)
3706
33
    {
3707
33
      if ((mask & zan_v[i]) == zan_v[i])
3708
6
        {
3709
6
          mask &= ~zan_v[i];
3710
6
          if (k > 1)
3711
3
      k += snprintf (buf + k, size - k, ", ");
3712
3713
6
    k += snprintf (buf + k, size - k, "%s", style_reg (styler, zan[i]));
3714
6
        }
3715
33
      if (mask == 0)
3716
6
        break;
3717
33
    }
3718
6
  snprintf (buf + k, size - k, "}");
3719
6
}
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
13.6M
{
3741
13.6M
  unsigned int i, num_conds;
3742
13.6M
  const char *name = NULL;
3743
13.6M
  const aarch64_opnd_info *opnd = opnds + idx;
3744
13.6M
  enum aarch64_modifier_kind kind;
3745
13.6M
  uint64_t addr, enum_value;
3746
3747
13.6M
  if (comment != NULL)
3748
13.6M
    {
3749
13.6M
      assert (comment_size > 0);
3750
13.6M
      comment[0] = '\0';
3751
13.6M
    }
3752
0
  else
3753
0
    assert (comment_size == 0);
3754
3755
13.6M
  buf[0] = '\0';
3756
13.6M
  if (pcrel_p)
3757
13.6M
    *pcrel_p = 0;
3758
3759
13.6M
  switch (opnd->type)
3760
13.6M
    {
3761
1.32M
    case AARCH64_OPND_Rd:
3762
2.01M
    case AARCH64_OPND_Rn:
3763
2.08M
    case AARCH64_OPND_Rm:
3764
3.36M
    case AARCH64_OPND_Rt:
3765
3.63M
    case AARCH64_OPND_Rt2:
3766
3.74M
    case AARCH64_OPND_Rs:
3767
3.77M
    case AARCH64_OPND_Ra:
3768
3.77M
    case AARCH64_OPND_Rt_LS64:
3769
3.77M
    case AARCH64_OPND_Rt_SYS:
3770
3.77M
    case AARCH64_OPND_PAIRREG:
3771
3.77M
    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.77M
      if (opnd->type == AARCH64_OPND_Rt_SYS)
3776
5
  {
3777
5
    if (!opnd->present)
3778
5
      break;
3779
5
  }
3780
      /* Omit the operand, e.g. RET.  */
3781
3.77M
      else if (optional_operand_p (opcode, idx)
3782
3.77M
         && (opnd->reg.regno
3783
4.15k
       == get_optional_operand_default_value (opcode)))
3784
3.51k
  break;
3785
3.77M
      assert (opnd->qualifier == AARCH64_OPND_QLF_W
3786
3.77M
        || opnd->qualifier == AARCH64_OPND_QLF_X);
3787
3.77M
      snprintf (buf, size, "%s",
3788
3.77M
    style_reg (styler, get_int_reg_name (opnd->reg.regno,
3789
3.77M
                 opnd->qualifier, 0)));
3790
3.77M
      break;
3791
3792
221k
    case AARCH64_OPND_Rd_SP:
3793
457k
    case AARCH64_OPND_Rn_SP:
3794
469k
    case AARCH64_OPND_Rt_SP:
3795
471k
    case AARCH64_OPND_SVE_Rn_SP:
3796
472k
    case AARCH64_OPND_Rm_SP:
3797
472k
      assert (opnd->qualifier == AARCH64_OPND_QLF_W
3798
472k
        || opnd->qualifier == AARCH64_OPND_QLF_WSP
3799
472k
        || opnd->qualifier == AARCH64_OPND_QLF_X
3800
472k
        || opnd->qualifier == AARCH64_OPND_QLF_SP);
3801
472k
      snprintf (buf, size, "%s",
3802
472k
    style_reg (styler, get_int_reg_name (opnd->reg.regno,
3803
472k
                 opnd->qualifier, 1)));
3804
472k
      break;
3805
3806
27.3k
    case AARCH64_OPND_Rm_EXT:
3807
27.3k
      kind = opnd->shifter.kind;
3808
27.3k
      assert (idx == 1 || idx == 2);
3809
27.3k
      if ((aarch64_stack_pointer_p (opnds)
3810
27.3k
     || (idx == 2 && aarch64_stack_pointer_p (opnds + 1)))
3811
27.3k
    && ((opnd->qualifier == AARCH64_OPND_QLF_W
3812
802
         && opnds[0].qualifier == AARCH64_OPND_QLF_W
3813
802
         && kind == AARCH64_MOD_UXTW)
3814
802
        || (opnd->qualifier == AARCH64_OPND_QLF_X
3815
766
      && kind == AARCH64_MOD_UXTX)))
3816
226
  {
3817
    /* 'LSL' is the preferred form in this case.  */
3818
226
    kind = AARCH64_MOD_LSL;
3819
226
    if (opnd->shifter.amount == 0)
3820
37
      {
3821
        /* Shifter omitted.  */
3822
37
        snprintf (buf, size, "%s",
3823
37
      style_reg (styler,
3824
37
           get_int_reg_name (opnd->reg.regno,
3825
37
                 opnd->qualifier, 0)));
3826
37
        break;
3827
37
      }
3828
226
  }
3829
27.2k
      if (opnd->shifter.amount)
3830
20.8k
  snprintf (buf, size, "%s, %s %s",
3831
20.8k
      style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)),
3832
20.8k
      style_sub_mnem (styler, aarch64_operand_modifiers[kind].name),
3833
20.8k
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
3834
6.38k
      else
3835
6.38k
  snprintf (buf, size, "%s, %s",
3836
6.38k
      style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)),
3837
6.38k
      style_sub_mnem (styler, aarch64_operand_modifiers[kind].name));
3838
27.2k
      break;
3839
3840
433k
    case AARCH64_OPND_Rm_SFT:
3841
433k
      assert (opnd->qualifier == AARCH64_OPND_QLF_W
3842
433k
        || opnd->qualifier == AARCH64_OPND_QLF_X);
3843
433k
      if (opnd->shifter.amount == 0 && opnd->shifter.kind == AARCH64_MOD_LSL)
3844
52.4k
  snprintf (buf, size, "%s",
3845
52.4k
      style_reg (styler, get_int_reg_name (opnd->reg.regno,
3846
52.4k
                   opnd->qualifier, 0)));
3847
381k
      else
3848
381k
  snprintf (buf, size, "%s, %s %s",
3849
381k
      style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)),
3850
381k
      style_sub_mnem (styler, aarch64_operand_modifiers[opnd->shifter.kind].name),
3851
381k
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
3852
433k
      break;
3853
3854
44.9k
    case AARCH64_OPND_Fd:
3855
92.4k
    case AARCH64_OPND_Fn:
3856
136k
    case AARCH64_OPND_Fm:
3857
173k
    case AARCH64_OPND_Fa:
3858
741k
    case AARCH64_OPND_Ft:
3859
1.03M
    case AARCH64_OPND_Ft2:
3860
1.05M
    case AARCH64_OPND_Sd:
3861
1.07M
    case AARCH64_OPND_Sn:
3862
1.07M
    case AARCH64_OPND_Sm:
3863
1.07M
    case AARCH64_OPND_SVE_VZn:
3864
1.08M
    case AARCH64_OPND_SVE_Vd:
3865
1.08M
    case AARCH64_OPND_SVE_Vm:
3866
1.08M
    case AARCH64_OPND_SVE_Vn:
3867
1.08M
      snprintf (buf, size, "%s",
3868
1.08M
    style_reg (styler, "%s%d",
3869
1.08M
         aarch64_get_qualifier_name (opnd->qualifier),
3870
1.08M
         opnd->reg.regno));
3871
1.08M
      break;
3872
3873
7.40k
    case AARCH64_OPND_Va:
3874
189k
    case AARCH64_OPND_Vd:
3875
357k
    case AARCH64_OPND_Vn:
3876
477k
    case AARCH64_OPND_Vm:
3877
477k
      snprintf (buf, size, "%s",
3878
477k
    style_reg (styler, "v%d.%s", opnd->reg.regno,
3879
477k
         aarch64_get_qualifier_name (opnd->qualifier)));
3880
477k
      break;
3881
3882
1.03k
    case AARCH64_OPND_Ed:
3883
2.56k
    case AARCH64_OPND_En:
3884
17.8k
    case AARCH64_OPND_Em:
3885
54.1k
    case AARCH64_OPND_Em16:
3886
54.1k
    case AARCH64_OPND_SM3_IMM2:
3887
54.1k
      snprintf (buf, size, "%s[%s]",
3888
54.1k
    style_reg (styler, "v%d.%s", opnd->reglane.regno,
3889
54.1k
         aarch64_get_qualifier_name (opnd->qualifier)),
3890
54.1k
    style_imm (styler, "%" PRIi64, opnd->reglane.index));
3891
54.1k
      break;
3892
3893
3
    case AARCH64_OPND_VdD1:
3894
4
    case AARCH64_OPND_VnD1:
3895
4
      snprintf (buf, size, "%s[%s]",
3896
4
    style_reg (styler, "v%d.d", opnd->reg.regno),
3897
4
    style_imm (styler, "1"));
3898
4
      break;
3899
3900
11.7k
    case AARCH64_OPND_LVn:
3901
29.6k
    case AARCH64_OPND_LVt:
3902
31.7k
    case AARCH64_OPND_LVt_AL:
3903
62.0k
    case AARCH64_OPND_LEt:
3904
62.0k
      print_register_list (buf, size, opnd, "v", styler);
3905
62.0k
      break;
3906
3907
81.9k
    case AARCH64_OPND_SVE_Pd:
3908
597k
    case AARCH64_OPND_SVE_Pg3:
3909
597k
    case AARCH64_OPND_SVE_Pg4_5:
3910
608k
    case AARCH64_OPND_SVE_Pg4_10:
3911
623k
    case AARCH64_OPND_SVE_Pg4_16:
3912
627k
    case AARCH64_OPND_SVE_Pm:
3913
632k
    case AARCH64_OPND_SVE_Pn:
3914
634k
    case AARCH64_OPND_SVE_Pt:
3915
669k
    case AARCH64_OPND_SME_Pm:
3916
669k
      if (opnd->qualifier == AARCH64_OPND_QLF_NIL)
3917
110k
  snprintf (buf, size, "%s",
3918
110k
      style_reg (styler, "p%d", opnd->reg.regno));
3919
559k
      else if (opnd->qualifier == AARCH64_OPND_QLF_P_Z
3920
559k
         || opnd->qualifier == AARCH64_OPND_QLF_P_M)
3921
469k
  snprintf (buf, size, "%s",
3922
469k
      style_reg (styler, "p%d/%s", opnd->reg.regno,
3923
469k
           aarch64_get_qualifier_name (opnd->qualifier)));
3924
89.8k
      else
3925
89.8k
  snprintf (buf, size, "%s",
3926
89.8k
      style_reg (styler, "p%d.%s", opnd->reg.regno,
3927
89.8k
           aarch64_get_qualifier_name (opnd->qualifier)));
3928
669k
      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
1.65k
    case AARCH64_OPND_SME_PNd3:
3935
28.0k
    case AARCH64_OPND_SME_PNg3:
3936
28.0k
    case AARCH64_OPND_SME_PNn:
3937
28.0k
      if (opnd->qualifier == AARCH64_OPND_QLF_NIL)
3938
11.6k
  snprintf (buf, size, "%s",
3939
11.6k
      style_reg (styler, "pn%d", opnd->reg.regno));
3940
16.4k
      else if (opnd->qualifier == AARCH64_OPND_QLF_P_Z
3941
16.4k
         || opnd->qualifier == AARCH64_OPND_QLF_P_M)
3942
14.7k
  snprintf (buf, size, "%s",
3943
14.7k
      style_reg (styler, "pn%d/%s", opnd->reg.regno,
3944
14.7k
           aarch64_get_qualifier_name (opnd->qualifier)));
3945
1.65k
      else
3946
1.65k
  snprintf (buf, size, "%s",
3947
1.65k
      style_reg (styler, "pn%d.%s", opnd->reg.regno,
3948
1.65k
           aarch64_get_qualifier_name (opnd->qualifier)));
3949
28.0k
      break;
3950
3951
378
    case AARCH64_OPND_SME_Pdx2:
3952
386
    case AARCH64_OPND_SME_PdxN:
3953
386
      print_register_list (buf, size, opnd, "p", styler);
3954
386
      break;
3955
3956
8
    case AARCH64_OPND_SME_PNn3_INDEX1:
3957
14
    case AARCH64_OPND_SME_PNn3_INDEX2:
3958
14
      snprintf (buf, size, "%s[%s]",
3959
14
    style_reg (styler, "pn%d", opnd->reglane.regno),
3960
14
    style_imm (styler, "%" PRIi64, opnd->reglane.index));
3961
14
      break;
3962
3963
9.31k
    case AARCH64_OPND_SVE_Za_5:
3964
15.2k
    case AARCH64_OPND_SVE_Za_16:
3965
299k
    case AARCH64_OPND_SVE_Zd:
3966
335k
    case AARCH64_OPND_SVE_Zm_5:
3967
532k
    case AARCH64_OPND_SVE_Zm_16:
3968
797k
    case AARCH64_OPND_SVE_Zn:
3969
803k
    case AARCH64_OPND_SVE_Zt:
3970
806k
    case AARCH64_OPND_SME_Zm:
3971
806k
      if (opnd->qualifier == AARCH64_OPND_QLF_NIL)
3972
5.81k
  snprintf (buf, size, "%s", style_reg (styler, "z%d", opnd->reg.regno));
3973
800k
      else
3974
800k
  snprintf (buf, size, "%s",
3975
800k
      style_reg (styler, "z%d.%s", opnd->reg.regno,
3976
800k
           aarch64_get_qualifier_name (opnd->qualifier)));
3977
806k
      break;
3978
3979
5.24k
    case AARCH64_OPND_SVE_ZnxN:
3980
239k
    case AARCH64_OPND_SVE_ZtxN:
3981
253k
    case AARCH64_OPND_SME_Zdnx2:
3982
257k
    case AARCH64_OPND_SME_Zdnx4:
3983
258k
    case AARCH64_OPND_SME_Zmx2:
3984
258k
    case AARCH64_OPND_SME_Zmx4:
3985
262k
    case AARCH64_OPND_SME_Znx2:
3986
264k
    case AARCH64_OPND_SME_Znx4:
3987
271k
    case AARCH64_OPND_SME_Ztx2_STRIDED:
3988
274k
    case AARCH64_OPND_SME_Ztx4_STRIDED:
3989
274k
      print_register_list (buf, size, opnd, "z", styler);
3990
274k
      break;
3991
3992
2.61k
    case AARCH64_OPND_SVE_Zm3_INDEX:
3993
4.80k
    case AARCH64_OPND_SVE_Zm3_22_INDEX:
3994
4.98k
    case AARCH64_OPND_SVE_Zm3_19_INDEX:
3995
8.21k
    case AARCH64_OPND_SVE_Zm3_11_INDEX:
3996
11.9k
    case AARCH64_OPND_SVE_Zm4_11_INDEX:
3997
14.0k
    case AARCH64_OPND_SVE_Zm4_INDEX:
3998
14.2k
    case AARCH64_OPND_SVE_Zn_INDEX:
3999
14.4k
    case AARCH64_OPND_SME_Zm_INDEX1:
4000
15.7k
    case AARCH64_OPND_SME_Zm_INDEX2:
4001
15.8k
    case AARCH64_OPND_SME_Zm_INDEX3_1:
4002
17.3k
    case AARCH64_OPND_SME_Zm_INDEX3_2:
4003
21.6k
    case AARCH64_OPND_SME_Zm_INDEX3_10:
4004
22.3k
    case AARCH64_OPND_SME_Zm_INDEX4_1:
4005
24.5k
    case AARCH64_OPND_SME_Zm_INDEX4_10:
4006
24.5k
    case AARCH64_OPND_SME_Zn_INDEX1_16:
4007
24.5k
    case AARCH64_OPND_SME_Zn_INDEX2_15:
4008
24.5k
    case AARCH64_OPND_SME_Zn_INDEX2_16:
4009
24.5k
    case AARCH64_OPND_SME_Zn_INDEX3_14:
4010
24.6k
    case AARCH64_OPND_SME_Zn_INDEX3_15:
4011
24.6k
    case AARCH64_OPND_SME_Zn_INDEX4_14:
4012
24.6k
      snprintf (buf, size, "%s[%s]",
4013
24.6k
    (opnd->qualifier == AARCH64_OPND_QLF_NIL
4014
24.6k
     ? style_reg (styler, "z%d", opnd->reglane.regno)
4015
24.6k
     : style_reg (styler, "z%d.%s", opnd->reglane.regno,
4016
24.5k
            aarch64_get_qualifier_name (opnd->qualifier))),
4017
24.6k
    style_imm (styler, "%" PRIi64, opnd->reglane.index));
4018
24.6k
      break;
4019
4020
21.2k
    case AARCH64_OPND_SME_ZAda_2b:
4021
35.0k
    case AARCH64_OPND_SME_ZAda_3b:
4022
35.0k
      snprintf (buf, size, "%s",
4023
35.0k
    style_reg (styler, "za%d.%s", opnd->reg.regno,
4024
35.0k
         aarch64_get_qualifier_name (opnd->qualifier)));
4025
35.0k
      break;
4026
4027
574
    case AARCH64_OPND_SME_ZA_HV_idx_src:
4028
863
    case AARCH64_OPND_SME_ZA_HV_idx_srcxN:
4029
4.85k
    case AARCH64_OPND_SME_ZA_HV_idx_dest:
4030
5.22k
    case AARCH64_OPND_SME_ZA_HV_idx_destxN:
4031
42.1k
    case AARCH64_OPND_SME_ZA_HV_idx_ldstr:
4032
42.1k
      snprintf (buf, size, "%s%s[%s, %s%s%s%s%s]%s",
4033
42.1k
    opnd->type == AARCH64_OPND_SME_ZA_HV_idx_ldstr ? "{" : "",
4034
42.1k
    style_reg (styler, "za%d%c.%s",
4035
42.1k
         opnd->indexed_za.regno,
4036
42.1k
         opnd->indexed_za.v == 1 ? 'v' : 'h',
4037
42.1k
         aarch64_get_qualifier_name (opnd->qualifier)),
4038
42.1k
    style_reg (styler, "w%d", opnd->indexed_za.index.regno),
4039
42.1k
    style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm),
4040
42.1k
    opnd->indexed_za.index.countm1 ? ":" : "",
4041
42.1k
    (opnd->indexed_za.index.countm1
4042
42.1k
     ? style_imm (styler, "%d",
4043
666
            opnd->indexed_za.index.imm
4044
666
            + opnd->indexed_za.index.countm1)
4045
42.1k
     : ""),
4046
42.1k
    opnd->indexed_za.group_size ? ", " : "",
4047
42.1k
    opnd->indexed_za.group_size == 2
4048
42.1k
    ? style_sub_mnem (styler, "vgx2")
4049
42.1k
    : opnd->indexed_za.group_size == 4
4050
42.1k
    ? style_sub_mnem (styler, "vgx4") : "",
4051
42.1k
    opnd->type == AARCH64_OPND_SME_ZA_HV_idx_ldstr ? "}" : "");
4052
42.1k
      break;
4053
4054
6
    case AARCH64_OPND_SME_list_of_64bit_tiles:
4055
6
      print_sme_za_list (buf, size, opnd->reg.regno, styler);
4056
6
      break;
4057
4058
1.64k
    case AARCH64_OPND_SME_ZA_array_off1x4:
4059
3.75k
    case AARCH64_OPND_SME_ZA_array_off2x2:
4060
7.98k
    case AARCH64_OPND_SME_ZA_array_off2x4:
4061
10.9k
    case AARCH64_OPND_SME_ZA_array_off3_0:
4062
11.0k
    case AARCH64_OPND_SME_ZA_array_off3_5:
4063
13.7k
    case AARCH64_OPND_SME_ZA_array_off3x2:
4064
13.8k
    case AARCH64_OPND_SME_ZA_array_off4:
4065
13.8k
      snprintf (buf, size, "%s[%s, %s%s%s%s%s]",
4066
13.8k
    style_reg (styler, "za%s%s",
4067
13.8k
         opnd->qualifier == AARCH64_OPND_QLF_NIL ? "" : ".",
4068
13.8k
         (opnd->qualifier == AARCH64_OPND_QLF_NIL
4069
13.8k
          ? ""
4070
13.8k
          : aarch64_get_qualifier_name (opnd->qualifier))),
4071
13.8k
    style_reg (styler, "w%d", opnd->indexed_za.index.regno),
4072
13.8k
    style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm),
4073
13.8k
    opnd->indexed_za.index.countm1 ? ":" : "",
4074
13.8k
    (opnd->indexed_za.index.countm1
4075
13.8k
     ? style_imm (styler, "%d",
4076
10.6k
            opnd->indexed_za.index.imm
4077
10.6k
            + opnd->indexed_za.index.countm1)
4078
13.8k
     : ""),
4079
13.8k
    opnd->indexed_za.group_size ? ", " : "",
4080
13.8k
    opnd->indexed_za.group_size == 2
4081
13.8k
    ? style_sub_mnem (styler, "vgx2")
4082
13.8k
    : opnd->indexed_za.group_size == 4
4083
9.88k
    ? style_sub_mnem (styler, "vgx4") : "");
4084
13.8k
      break;
4085
4086
0
    case AARCH64_OPND_SME_SM_ZA:
4087
0
      snprintf (buf, size, "%s",
4088
0
    style_reg (styler, opnd->reg.regno == 's' ? "sm" : "za"));
4089
0
      break;
4090
4091
797
    case AARCH64_OPND_SME_PnT_Wm_imm:
4092
797
      snprintf (buf, size, "%s[%s, %s]",
4093
797
    style_reg (styler, "p%d.%s", opnd->indexed_za.regno,
4094
797
         aarch64_get_qualifier_name (opnd->qualifier)),
4095
797
    style_reg (styler, "w%d", opnd->indexed_za.index.regno),
4096
797
    style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm));
4097
797
      break;
4098
4099
0
    case AARCH64_OPND_SME_VLxN_10:
4100
1.65k
    case AARCH64_OPND_SME_VLxN_13:
4101
1.65k
      enum_value = opnd->imm.value;
4102
1.65k
      assert (enum_value < ARRAY_SIZE (aarch64_sme_vlxn_array));
4103
1.65k
      snprintf (buf, size, "%s",
4104
1.65k
    style_sub_mnem (styler, aarch64_sme_vlxn_array[enum_value]));
4105
1.65k
      break;
4106
4107
1.89k
    case AARCH64_OPND_CRn:
4108
3.78k
    case AARCH64_OPND_CRm:
4109
3.78k
      snprintf (buf, size, "%s",
4110
3.78k
    style_reg (styler, "C%" PRIi64, opnd->imm.value));
4111
3.78k
      break;
4112
4113
5.67k
    case AARCH64_OPND_IDX:
4114
7.03k
    case AARCH64_OPND_MASK:
4115
84.8k
    case AARCH64_OPND_IMM:
4116
86.2k
    case AARCH64_OPND_IMM_2:
4117
156k
    case AARCH64_OPND_WIDTH:
4118
158k
    case AARCH64_OPND_UIMM3_OP1:
4119
160k
    case AARCH64_OPND_UIMM3_OP2:
4120
351k
    case AARCH64_OPND_BIT_NUM:
4121
361k
    case AARCH64_OPND_IMM_VLSL:
4122
373k
    case AARCH64_OPND_IMM_VLSR:
4123
373k
    case AARCH64_OPND_SHLL_IMM:
4124
373k
    case AARCH64_OPND_IMM0:
4125
373k
    case AARCH64_OPND_IMMR:
4126
379k
    case AARCH64_OPND_IMMS:
4127
1.47M
    case AARCH64_OPND_UNDEFINED:
4128
1.47M
    case AARCH64_OPND_FBITS:
4129
1.47M
    case AARCH64_OPND_TME_UIMM16:
4130
1.48M
    case AARCH64_OPND_SIMM5:
4131
1.48M
    case AARCH64_OPND_SME_SHRIMM4:
4132
1.48M
    case AARCH64_OPND_SME_SHRIMM5:
4133
1.48M
    case AARCH64_OPND_SVE_SHLIMM_PRED:
4134
1.48M
    case AARCH64_OPND_SVE_SHLIMM_UNPRED:
4135
1.48M
    case AARCH64_OPND_SVE_SHLIMM_UNPRED_22:
4136
1.48M
    case AARCH64_OPND_SVE_SHRIMM_PRED:
4137
1.49M
    case AARCH64_OPND_SVE_SHRIMM_UNPRED:
4138
1.49M
    case AARCH64_OPND_SVE_SHRIMM_UNPRED_22:
4139
1.49M
    case AARCH64_OPND_SVE_SIMM5:
4140
1.49M
    case AARCH64_OPND_SVE_SIMM5B:
4141
1.50M
    case AARCH64_OPND_SVE_SIMM6:
4142
1.50M
    case AARCH64_OPND_SVE_SIMM8:
4143
1.50M
    case AARCH64_OPND_SVE_UIMM3:
4144
1.52M
    case AARCH64_OPND_SVE_UIMM7:
4145
1.52M
    case AARCH64_OPND_SVE_UIMM8:
4146
1.53M
    case AARCH64_OPND_SVE_UIMM8_53:
4147
1.53M
    case AARCH64_OPND_IMM_ROT1:
4148
1.55M
    case AARCH64_OPND_IMM_ROT2:
4149
1.55M
    case AARCH64_OPND_IMM_ROT3:
4150
1.55M
    case AARCH64_OPND_SVE_IMM_ROT1:
4151
1.55M
    case AARCH64_OPND_SVE_IMM_ROT2:
4152
1.55M
    case AARCH64_OPND_SVE_IMM_ROT3:
4153
1.55M
    case AARCH64_OPND_CSSC_SIMM8:
4154
1.56M
    case AARCH64_OPND_CSSC_UIMM8:
4155
1.56M
      snprintf (buf, size, "%s",
4156
1.56M
    style_imm (styler, "#%" PRIi64, opnd->imm.value));
4157
1.56M
      break;
4158
4159
0
    case AARCH64_OPND_SVE_I1_HALF_ONE:
4160
1
    case AARCH64_OPND_SVE_I1_HALF_TWO:
4161
1
    case AARCH64_OPND_SVE_I1_ZERO_ONE:
4162
1
      {
4163
1
  single_conv_t c;
4164
1
  c.i = opnd->imm.value;
4165
1
  snprintf (buf, size, "%s", style_imm (styler, "#%.1f", c.f));
4166
1
  break;
4167
1
      }
4168
4169
5
    case AARCH64_OPND_SVE_PATTERN:
4170
5
      if (optional_operand_p (opcode, idx)
4171
5
    && opnd->imm.value == get_optional_operand_default_value (opcode))
4172
0
  break;
4173
5
      enum_value = opnd->imm.value;
4174
5
      assert (enum_value < ARRAY_SIZE (aarch64_sve_pattern_array));
4175
5
      if (aarch64_sve_pattern_array[enum_value])
4176
2
  snprintf (buf, size, "%s",
4177
2
      style_reg (styler, aarch64_sve_pattern_array[enum_value]));
4178
3
      else
4179
3
  snprintf (buf, size, "%s",
4180
3
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4181
5
      break;
4182
4183
3.35k
    case AARCH64_OPND_SVE_PATTERN_SCALED:
4184
3.35k
      if (optional_operand_p (opcode, idx)
4185
3.35k
    && !opnd->shifter.operator_present
4186
3.35k
    && opnd->imm.value == get_optional_operand_default_value (opcode))
4187
3
  break;
4188
3.35k
      enum_value = opnd->imm.value;
4189
3.35k
      assert (enum_value < ARRAY_SIZE (aarch64_sve_pattern_array));
4190
3.35k
      if (aarch64_sve_pattern_array[opnd->imm.value])
4191
2.07k
  snprintf (buf, size, "%s",
4192
2.07k
      style_reg (styler,
4193
2.07k
           aarch64_sve_pattern_array[opnd->imm.value]));
4194
1.28k
      else
4195
1.28k
  snprintf (buf, size, "%s",
4196
1.28k
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4197
3.35k
      if (opnd->shifter.operator_present)
4198
3.13k
  {
4199
3.13k
    size_t len = strlen (buf);
4200
3.13k
    const char *shift_name
4201
3.13k
      = aarch64_operand_modifiers[opnd->shifter.kind].name;
4202
3.13k
    snprintf (buf + len, size - len, ", %s %s",
4203
3.13k
        style_sub_mnem (styler, shift_name),
4204
3.13k
        style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
4205
3.13k
  }
4206
3.35k
      break;
4207
4208
25.6k
    case AARCH64_OPND_SVE_PRFOP:
4209
25.6k
      enum_value = opnd->imm.value;
4210
25.6k
      assert (enum_value < ARRAY_SIZE (aarch64_sve_prfop_array));
4211
25.6k
      if (aarch64_sve_prfop_array[enum_value])
4212
15.9k
  snprintf (buf, size, "%s",
4213
15.9k
      style_reg (styler, aarch64_sve_prfop_array[enum_value]));
4214
9.63k
      else
4215
9.63k
  snprintf (buf, size, "%s",
4216
9.63k
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4217
25.6k
      break;
4218
4219
72.6k
    case AARCH64_OPND_IMM_MOV:
4220
72.6k
      switch (aarch64_get_qualifier_esize (opnds[0].qualifier))
4221
72.6k
  {
4222
30.3k
  case 4: /* e.g. MOV Wd, #<imm32>.  */
4223
30.3k
      {
4224
30.3k
        int imm32 = opnd->imm.value;
4225
30.3k
        snprintf (buf, size, "%s",
4226
30.3k
      style_imm (styler, "#0x%-20x", imm32));
4227
30.3k
        snprintf (comment, comment_size, "#%d", imm32);
4228
30.3k
      }
4229
30.3k
    break;
4230
42.2k
  case 8: /* e.g. MOV Xd, #<imm64>.  */
4231
42.2k
    snprintf (buf, size, "%s", style_imm (styler, "#0x%-20" PRIx64,
4232
42.2k
            opnd->imm.value));
4233
42.2k
    snprintf (comment, comment_size, "#%" PRIi64, opnd->imm.value);
4234
42.2k
    break;
4235
0
  default:
4236
0
    snprintf (buf, size, "<invalid>");
4237
0
    break;
4238
72.6k
  }
4239
72.6k
      break;
4240
4241
72.6k
    case AARCH64_OPND_FPIMM0:
4242
447
      snprintf (buf, size, "%s", style_imm (styler, "#0.0"));
4243
447
      break;
4244
4245
126k
    case AARCH64_OPND_LIMM:
4246
328k
    case AARCH64_OPND_AIMM:
4247
361k
    case AARCH64_OPND_HALF:
4248
361k
    case AARCH64_OPND_SVE_INV_LIMM:
4249
377k
    case AARCH64_OPND_SVE_LIMM:
4250
377k
    case AARCH64_OPND_SVE_LIMM_MOV:
4251
377k
      if (opnd->shifter.amount)
4252
101k
  snprintf (buf, size, "%s, %s %s",
4253
101k
      style_imm (styler, "#0x%" PRIx64, opnd->imm.value),
4254
101k
      style_sub_mnem (styler, "lsl"),
4255
101k
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
4256
276k
      else
4257
276k
  snprintf (buf, size, "%s",
4258
276k
      style_imm (styler, "#0x%" PRIx64, opnd->imm.value));
4259
377k
      break;
4260
4261
29
    case AARCH64_OPND_SIMD_IMM:
4262
1.85k
    case AARCH64_OPND_SIMD_IMM_SFT:
4263
1.85k
      if ((! opnd->shifter.amount && opnd->shifter.kind == AARCH64_MOD_LSL)
4264
1.85k
    || opnd->shifter.kind == AARCH64_MOD_NONE)
4265
837
  snprintf (buf, size, "%s",
4266
837
      style_imm (styler, "#0x%" PRIx64, opnd->imm.value));
4267
1.02k
      else
4268
1.02k
  snprintf (buf, size, "%s, %s %s",
4269
1.02k
      style_imm (styler, "#0x%" PRIx64, opnd->imm.value),
4270
1.02k
      style_sub_mnem (styler, aarch64_operand_modifiers[opnd->shifter.kind].name),
4271
1.02k
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
4272
1.85k
      break;
4273
4274
815
    case AARCH64_OPND_SVE_AIMM:
4275
14.7k
    case AARCH64_OPND_SVE_ASIMM:
4276
14.7k
      if (opnd->shifter.amount)
4277
0
  snprintf (buf, size, "%s, %s %s",
4278
0
      style_imm (styler, "#%" PRIi64, opnd->imm.value),
4279
0
      style_sub_mnem (styler, "lsl"),
4280
0
      style_imm (styler, "#%" PRIi64, opnd->shifter.amount));
4281
14.7k
      else
4282
14.7k
  snprintf (buf, size, "%s",
4283
14.7k
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4284
14.7k
      break;
4285
4286
105
    case AARCH64_OPND_FPIMM:
4287
299
    case AARCH64_OPND_SIMD_FPIMM:
4288
1.31k
    case AARCH64_OPND_SVE_FPIMM8:
4289
1.31k
      switch (aarch64_get_qualifier_esize (opnds[0].qualifier))
4290
1.31k
  {
4291
550
  case 2: /* e.g. FMOV <Hd>, #<imm>.  */
4292
550
      {
4293
550
        half_conv_t c;
4294
550
        c.i = expand_fp_imm (2, opnd->imm.value);
4295
550
        snprintf (buf, size, "%s", style_imm (styler, "#%.18e", c.f));
4296
550
      }
4297
550
    break;
4298
503
  case 4: /* e.g. FMOV <Vd>.4S, #<imm>.  */
4299
503
      {
4300
503
        single_conv_t c;
4301
503
        c.i = expand_fp_imm (4, opnd->imm.value);
4302
503
        snprintf (buf, size, "%s", style_imm (styler, "#%.18e", c.f));
4303
503
      }
4304
503
    break;
4305
260
  case 8: /* e.g. FMOV <Sd>, #<imm>.  */
4306
260
      {
4307
260
        double_conv_t c;
4308
260
        c.i = expand_fp_imm (8, opnd->imm.value);
4309
260
        snprintf (buf, size, "%s", style_imm (styler, "#%.18e", c.d));
4310
260
      }
4311
260
    break;
4312
0
  default:
4313
0
    snprintf (buf, size, "<invalid>");
4314
0
    break;
4315
1.31k
  }
4316
1.31k
      break;
4317
4318
2.23k
    case AARCH64_OPND_CCMP_IMM:
4319
11.3k
    case AARCH64_OPND_NZCV:
4320
12.2k
    case AARCH64_OPND_EXCEPTION:
4321
12.2k
    case AARCH64_OPND_UIMM4:
4322
17.0k
    case AARCH64_OPND_UIMM4_ADDG:
4323
17.0k
    case AARCH64_OPND_UIMM7:
4324
21.9k
    case AARCH64_OPND_UIMM10:
4325
21.9k
      if (optional_operand_p (opcode, idx)
4326
21.9k
    && (opnd->imm.value ==
4327
209
        (int64_t) get_optional_operand_default_value (opcode)))
4328
  /* Omit the operand, e.g. DCPS1.  */
4329
0
  break;
4330
21.9k
      snprintf (buf, size, "%s",
4331
21.9k
    style_imm (styler, "#0x%x", (unsigned int) opnd->imm.value));
4332
21.9k
      break;
4333
4334
20.9k
    case AARCH64_OPND_COND:
4335
21.8k
    case AARCH64_OPND_COND1:
4336
21.8k
      snprintf (buf, size, "%s",
4337
21.8k
    style_sub_mnem (styler, opnd->cond->names[0]));
4338
21.8k
      num_conds = ARRAY_SIZE (opnd->cond->names);
4339
39.9k
      for (i = 1; i < num_conds && opnd->cond->names[i]; ++i)
4340
18.0k
  {
4341
18.0k
    size_t len = comment != NULL ? strlen (comment) : 0;
4342
18.0k
    if (i == 1)
4343
14.2k
      snprintf (comment + len, comment_size - len, "%s = %s",
4344
14.2k
          opnd->cond->names[0], opnd->cond->names[i]);
4345
3.87k
    else
4346
3.87k
      snprintf (comment + len, comment_size - len, ", %s",
4347
3.87k
          opnd->cond->names[i]);
4348
18.0k
  }
4349
21.8k
      break;
4350
4351
203k
    case AARCH64_OPND_ADDR_ADRP:
4352
203k
      addr = ((pc + AARCH64_PCREL_OFFSET) & ~(uint64_t)0xfff)
4353
203k
  + opnd->imm.value;
4354
203k
      if (pcrel_p)
4355
203k
  *pcrel_p = 1;
4356
203k
      if (address)
4357
203k
  *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
203k
      snprintf (buf, size, "%s", style_addr (styler, "#0x%" PRIx64 , addr));
4363
203k
      break;
4364
4365
191k
    case AARCH64_OPND_ADDR_PCREL14:
4366
723k
    case AARCH64_OPND_ADDR_PCREL19:
4367
1.03M
    case AARCH64_OPND_ADDR_PCREL21:
4368
1.38M
    case AARCH64_OPND_ADDR_PCREL26:
4369
1.38M
      addr = pc + AARCH64_PCREL_OFFSET + opnd->imm.value;
4370
1.38M
      if (pcrel_p)
4371
1.38M
  *pcrel_p = 1;
4372
1.38M
      if (address)
4373
1.38M
  *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.38M
      snprintf (buf, size, "%s", style_addr (styler, "#0x%" PRIx64, addr));
4379
1.38M
      break;
4380
4381
195k
    case AARCH64_OPND_ADDR_SIMPLE:
4382
212k
    case AARCH64_OPND_SIMD_ADDR_SIMPLE:
4383
246k
    case AARCH64_OPND_SIMD_ADDR_POST:
4384
246k
      name = get_64bit_int_reg_name (opnd->addr.base_regno, 1);
4385
246k
      if (opnd->type == AARCH64_OPND_SIMD_ADDR_POST)
4386
34.2k
  {
4387
34.2k
    if (opnd->addr.offset.is_reg)
4388
33.2k
      snprintf (buf, size, "[%s], %s",
4389
33.2k
          style_reg (styler, name),
4390
33.2k
          style_reg (styler, "x%d", opnd->addr.offset.regno));
4391
1.08k
    else
4392
1.08k
      snprintf (buf, size, "[%s], %s",
4393
1.08k
          style_reg (styler, name),
4394
1.08k
          style_imm (styler, "#%d", opnd->addr.offset.imm));
4395
34.2k
  }
4396
212k
      else
4397
212k
  snprintf (buf, size, "[%s]", style_reg (styler, name));
4398
246k
      break;
4399
4400
18.5k
    case AARCH64_OPND_ADDR_REGOFF:
4401
18.5k
    case AARCH64_OPND_SVE_ADDR_R:
4402
40.1k
    case AARCH64_OPND_SVE_ADDR_RR:
4403
52.4k
    case AARCH64_OPND_SVE_ADDR_RR_LSL1:
4404
62.2k
    case AARCH64_OPND_SVE_ADDR_RR_LSL2:
4405
78.5k
    case AARCH64_OPND_SVE_ADDR_RR_LSL3:
4406
83.0k
    case AARCH64_OPND_SVE_ADDR_RR_LSL4:
4407
95.6k
    case AARCH64_OPND_SVE_ADDR_RX:
4408
105k
    case AARCH64_OPND_SVE_ADDR_RX_LSL1:
4409
118k
    case AARCH64_OPND_SVE_ADDR_RX_LSL2:
4410
126k
    case AARCH64_OPND_SVE_ADDR_RX_LSL3:
4411
126k
      print_register_offset_address
4412
126k
  (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1),
4413
126k
   get_offset_int_reg_name (opnd), styler);
4414
126k
      break;
4415
4416
11.9k
    case AARCH64_OPND_SVE_ADDR_ZX:
4417
11.9k
      print_register_offset_address
4418
11.9k
  (buf, size, opnd,
4419
11.9k
   get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier),
4420
11.9k
   get_64bit_int_reg_name (opnd->addr.offset.regno, 0), styler);
4421
11.9k
      break;
4422
4423
13.2k
    case AARCH64_OPND_SVE_ADDR_RZ:
4424
16.6k
    case AARCH64_OPND_SVE_ADDR_RZ_LSL1:
4425
19.3k
    case AARCH64_OPND_SVE_ADDR_RZ_LSL2:
4426
21.1k
    case AARCH64_OPND_SVE_ADDR_RZ_LSL3:
4427
28.9k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW_14:
4428
68.7k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW_22:
4429
71.2k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW1_14:
4430
80.4k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW1_22:
4431
82.5k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW2_14:
4432
91.1k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW2_22:
4433
92.6k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW3_14:
4434
103k
    case AARCH64_OPND_SVE_ADDR_RZ_XTW3_22:
4435
103k
      print_register_offset_address
4436
103k
  (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1),
4437
103k
   get_addr_sve_reg_name (opnd->addr.offset.regno, opnd->qualifier),
4438
103k
   styler);
4439
103k
      break;
4440
4441
513k
    case AARCH64_OPND_ADDR_SIMM7:
4442
650k
    case AARCH64_OPND_ADDR_SIMM9:
4443
650k
    case AARCH64_OPND_ADDR_SIMM9_2:
4444
661k
    case AARCH64_OPND_ADDR_SIMM10:
4445
691k
    case AARCH64_OPND_ADDR_SIMM11:
4446
704k
    case AARCH64_OPND_ADDR_SIMM13:
4447
723k
    case AARCH64_OPND_ADDR_OFFSET:
4448
723k
    case AARCH64_OPND_SME_ADDR_RI_U4xVL:
4449
723k
    case AARCH64_OPND_SVE_ADDR_RI_S4x16:
4450
725k
    case AARCH64_OPND_SVE_ADDR_RI_S4x32:
4451
757k
    case AARCH64_OPND_SVE_ADDR_RI_S4xVL:
4452
765k
    case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL:
4453
767k
    case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL:
4454
773k
    case AARCH64_OPND_SVE_ADDR_RI_S4x4xVL:
4455
776k
    case AARCH64_OPND_SVE_ADDR_RI_S6xVL:
4456
784k
    case AARCH64_OPND_SVE_ADDR_RI_S9xVL:
4457
798k
    case AARCH64_OPND_SVE_ADDR_RI_U6:
4458
803k
    case AARCH64_OPND_SVE_ADDR_RI_U6x2:
4459
809k
    case AARCH64_OPND_SVE_ADDR_RI_U6x4:
4460
810k
    case AARCH64_OPND_SVE_ADDR_RI_U6x8:
4461
810k
      print_immediate_offset_address
4462
810k
  (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1),
4463
810k
   styler);
4464
810k
      break;
4465
4466
6.17k
    case AARCH64_OPND_SVE_ADDR_ZI_U5:
4467
12.5k
    case AARCH64_OPND_SVE_ADDR_ZI_U5x2:
4468
17.1k
    case AARCH64_OPND_SVE_ADDR_ZI_U5x4:
4469
19.7k
    case AARCH64_OPND_SVE_ADDR_ZI_U5x8:
4470
19.7k
      print_immediate_offset_address
4471
19.7k
  (buf, size, opnd,
4472
19.7k
   get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier),
4473
19.7k
   styler);
4474
19.7k
      break;
4475
4476
864
    case AARCH64_OPND_SVE_ADDR_ZZ_LSL:
4477
1.05k
    case AARCH64_OPND_SVE_ADDR_ZZ_SXTW:
4478
1.20k
    case AARCH64_OPND_SVE_ADDR_ZZ_UXTW:
4479
1.20k
      print_register_offset_address
4480
1.20k
  (buf, size, opnd,
4481
1.20k
   get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier),
4482
1.20k
   get_addr_sve_reg_name (opnd->addr.offset.regno, opnd->qualifier),
4483
1.20k
   styler);
4484
1.20k
      break;
4485
4486
304k
    case AARCH64_OPND_ADDR_UIMM12:
4487
304k
      name = get_64bit_int_reg_name (opnd->addr.base_regno, 1);
4488
304k
      if (opnd->addr.offset.imm)
4489
290k
  snprintf (buf, size, "[%s, %s]",
4490
290k
      style_reg (styler, name),
4491
290k
      style_imm (styler, "#%d", opnd->addr.offset.imm));
4492
14.5k
      else
4493
14.5k
  snprintf (buf, size, "[%s]", style_reg (styler, name));
4494
304k
      break;
4495
4496
7.03k
    case AARCH64_OPND_SYSREG:
4497
7.16M
      for (i = 0; aarch64_sys_regs[i].name; ++i)
4498
7.15M
  {
4499
7.15M
    const aarch64_sys_reg *sr = aarch64_sys_regs + i;
4500
4501
7.15M
    bool exact_match
4502
7.15M
      = (!(sr->flags & (F_REG_READ | F_REG_WRITE))
4503
7.15M
      || (sr->flags & opnd->sysreg.flags) == opnd->sysreg.flags)
4504
7.15M
      && 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
7.15M
    if (aarch64_sys_regs[i].value == opnd->sysreg.value
4509
7.15M
        && ! aarch64_sys_reg_deprecated_p (aarch64_sys_regs[i].flags)
4510
7.15M
        && (name == NULL || exact_match))
4511
168
      {
4512
168
        name = aarch64_sys_regs[i].name;
4513
168
        if (exact_match)
4514
102
    {
4515
102
      if (notes)
4516
102
        *notes = NULL;
4517
102
      break;
4518
102
    }
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
66
        if (aarch64_sys_regs[i].flags & F_REG_WRITE)
4525
0
    *notes = _("reading from a write-only register");
4526
66
        else if (aarch64_sys_regs[i].flags & F_REG_READ)
4527
38
    *notes = _("writing to a read-only register");
4528
66
      }
4529
7.15M
  }
4530
4531
7.03k
      if (name)
4532
168
  snprintf (buf, size, "%s", style_reg (styler, name));
4533
6.86k
      else
4534
6.86k
  {
4535
    /* Implementation defined system register.  */
4536
6.86k
    unsigned int value = opnd->sysreg.value;
4537
6.86k
    snprintf (buf, size, "%s",
4538
6.86k
        style_reg (styler, "s%u_%u_c%u_c%u_%u",
4539
6.86k
             (value >> 14) & 0x3, (value >> 11) & 0x7,
4540
6.86k
             (value >> 7) & 0xf, (value >> 3) & 0xf,
4541
6.86k
             value & 0x7));
4542
6.86k
  }
4543
7.03k
      break;
4544
4545
0
    case AARCH64_OPND_PSTATEFIELD:
4546
0
      for (i = 0; aarch64_pstatefields[i].name; ++i)
4547
0
        if (aarch64_pstatefields[i].value == opnd->pstatefield)
4548
0
          {
4549
            /* PSTATEFIELD name is encoded partially in CRm[3:1] for SVCRSM,
4550
               SVCRZA and SVCRSMZA.  */
4551
0
            uint32_t flags = aarch64_pstatefields[i].flags;
4552
0
            if (flags & F_REG_IN_CRM
4553
0
                && (PSTATE_DECODE_CRM (opnd->sysreg.flags)
4554
0
                    != PSTATE_DECODE_CRM (flags)))
4555
0
              continue;
4556
0
            break;
4557
0
          }
4558
0
      assert (aarch64_pstatefields[i].name);
4559
0
      snprintf (buf, size, "%s",
4560
0
    style_reg (styler, aarch64_pstatefields[i].name));
4561
0
      break;
4562
4563
10
    case AARCH64_OPND_SYSREG_AT:
4564
12
    case AARCH64_OPND_SYSREG_DC:
4565
12
    case AARCH64_OPND_SYSREG_IC:
4566
17
    case AARCH64_OPND_SYSREG_TLBI:
4567
17
    case AARCH64_OPND_SYSREG_SR:
4568
17
      snprintf (buf, size, "%s", style_reg (styler, opnd->sysins_op->name));
4569
17
      break;
4570
4571
0
    case AARCH64_OPND_BARRIER:
4572
0
    case AARCH64_OPND_BARRIER_DSB_NXS:
4573
0
      {
4574
0
  if (opnd->barrier->name[0] == '#')
4575
0
    snprintf (buf, size, "%s", style_imm (styler, opnd->barrier->name));
4576
0
  else
4577
0
    snprintf (buf, size, "%s",
4578
0
        style_sub_mnem (styler, opnd->barrier->name));
4579
0
      }
4580
0
      break;
4581
4582
0
    case AARCH64_OPND_BARRIER_ISB:
4583
      /* Operand can be omitted, e.g. in DCPS1.  */
4584
0
      if (! optional_operand_p (opcode, idx)
4585
0
    || (opnd->barrier->value
4586
0
        != get_optional_operand_default_value (opcode)))
4587
0
  snprintf (buf, size, "%s",
4588
0
      style_imm (styler, "#0x%x", opnd->barrier->value));
4589
0
      break;
4590
4591
52.7k
    case AARCH64_OPND_PRFOP:
4592
52.7k
      if (opnd->prfop->name != NULL)
4593
31.3k
  snprintf (buf, size, "%s", style_sub_mnem (styler, opnd->prfop->name));
4594
21.4k
      else
4595
21.4k
  snprintf (buf, size, "%s", style_imm (styler, "#0x%02x",
4596
21.4k
                opnd->prfop->value));
4597
52.7k
      break;
4598
4599
185
    case AARCH64_OPND_RPRFMOP:
4600
185
      enum_value = opnd->imm.value;
4601
185
      if (enum_value < ARRAY_SIZE (aarch64_rprfmop_array)
4602
185
    && aarch64_rprfmop_array[enum_value])
4603
8
  snprintf (buf, size, "%s",
4604
8
      style_reg (styler, aarch64_rprfmop_array[enum_value]));
4605
177
      else
4606
177
  snprintf (buf, size, "%s",
4607
177
      style_imm (styler, "#%" PRIi64, opnd->imm.value));
4608
185
      break;
4609
4610
0
    case AARCH64_OPND_BARRIER_PSB:
4611
0
      snprintf (buf, size, "%s", style_sub_mnem (styler, "csync"));
4612
0
      break;
4613
4614
132
    case AARCH64_OPND_SME_ZT0:
4615
132
      snprintf (buf, size, "%s", style_reg (styler, "zt0"));
4616
132
      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
0
    case AARCH64_OPND_BTI_TARGET:
4628
0
      if ((HINT_FLAG (opnd->hint_option->value) & HINT_OPD_F_NOPRINT) == 0)
4629
0
  snprintf (buf, size, "%s",
4630
0
      style_sub_mnem (styler, opnd->hint_option->name));
4631
0
      break;
4632
4633
8.96k
    case AARCH64_OPND_MOPS_ADDR_Rd:
4634
15.8k
    case AARCH64_OPND_MOPS_ADDR_Rs:
4635
15.8k
      snprintf (buf, size, "[%s]!",
4636
15.8k
    style_reg (styler,
4637
15.8k
         get_int_reg_name (opnd->reg.regno,
4638
15.8k
               AARCH64_OPND_QLF_X, 0)));
4639
15.8k
      break;
4640
4641
8.96k
    case AARCH64_OPND_MOPS_WB_Rn:
4642
8.96k
      snprintf (buf, size, "%s!",
4643
8.96k
    style_reg (styler, get_int_reg_name (opnd->reg.regno,
4644
8.96k
                 AARCH64_OPND_QLF_X, 0)));
4645
8.96k
      break;
4646
4647
0
    default:
4648
0
      snprintf (buf, size, "<invalid>");
4649
0
      break;
4650
13.6M
    }
4651
13.6M
}
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,V8A,V8_1A)
4690
#define SR_V8_4_A(n,e,f) SR_FEAT2(n,e,f,V8A,V8_4A)
4691
4692
#define SR_V8A(n,e,f)   SR_FEAT (n,e,f,V8A)
4693
#define SR_V8R(n,e,f)   SR_FEAT (n,e,f,V8R)
4694
#define SR_V8_1A(n,e,f)   SR_FEAT (n,e,f,V8_1A)
4695
#define SR_V8_2A(n,e,f)   SR_FEAT (n,e,f,V8_2A)
4696
#define SR_V8_3A(n,e,f)   SR_FEAT (n,e,f,V8_3A)
4697
#define SR_V8_4A(n,e,f)   SR_FEAT (n,e,f,V8_4A)
4698
#define SR_V8_6A(n,e,f)   SR_FEAT (n,e,f,V8_6A)
4699
#define SR_V8_7A(n,e,f)   SR_FEAT (n,e,f,V8_7A)
4700
#define SR_V8_8A(n,e,f)   SR_FEAT (n,e,f,V8_8A)
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_4A)
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_1A ("spsr_el12",    CPEN_ (5,C0,0),   0),
4747
  SR_CORE ("elr_el1",   CPEN_ (0,C0,1),   0),
4748
  SR_V8_1A ("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_2A ("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_3A ("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_1A ("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_1A ("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_V8A ("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_1A ("ttbr0_el12", CPENC (3,5,C2,C0,0),  0),
4847
  SR_V8_1A ("ttbr1_el12", CPENC (3,5,C2,C0,1),  0),
4848
  SR_V8A ("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_1A ("tcr_el12",   CPENC (3,5,C2,C0,2),  0),
4853
  SR_CORE ("vtcr_el2",    CPENC (3,4,C2,C1,2),  0),
4854
  SR_V8_3A ("apiakeylo_el1",  CPENC (3,0,C2,C1,0),  0),
4855
  SR_V8_3A ("apiakeyhi_el1",  CPENC (3,0,C2,C1,1),  0),
4856
  SR_V8_3A ("apibkeylo_el1",  CPENC (3,0,C2,C1,2),  0),
4857
  SR_V8_3A ("apibkeyhi_el1",  CPENC (3,0,C2,C1,3),  0),
4858
  SR_V8_3A ("apdakeylo_el1",  CPENC (3,0,C2,C2,0),  0),
4859
  SR_V8_3A ("apdakeyhi_el1",  CPENC (3,0,C2,C2,1),  0),
4860
  SR_V8_3A ("apdbkeylo_el1",  CPENC (3,0,C2,C2,2),  0),
4861
  SR_V8_3A ("apdbkeyhi_el1",  CPENC (3,0,C2,C2,3),  0),
4862
  SR_V8_3A ("apgakeylo_el1",  CPENC (3,0,C2,C3,0),  0),
4863
  SR_V8_3A ("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_1A ("afsr0_el12", CPENC (3,5,C5,C1,0),  0),
4870
  SR_CORE ("afsr1_el3",   CPENC (3,6,C5,C1,1),  0),
4871
  SR_V8_1A ("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_1A ("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_1A ("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_1A ("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_1A ("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_1A ("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_1A ("contextidr_el2", CPENC (3,4,C13,C0,1), 0),
4920
  SR_V8_1A ("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_1A ("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_1A ("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_1A ("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_1A ("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_1A ("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_1A ("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_1A ("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_1A ("cnthv_tval_el2", CPENC (3,4,C14,C3,0), 0),
4969
  SR_V8_1A ("cnthv_ctl_el2",  CPENC (3,4,C14,C3,1), 0),
4970
  SR_V8_1A ("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_4A ("dit",    CPEN_ (3,C2,5),   0),
5150
  SR_V8_4A ("trfcr_el1",    CPENC (3,0,C1,C2,1),  0),
5151
  SR_V8_4A ("pmmir_el1",    CPENC (3,0,C9,C14,6), F_REG_READ),
5152
  SR_V8_4A ("trfcr_el2",    CPENC (3,4,C1,C2,1),  0),
5153
  SR_V8_4A ("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_4A ("cnthvs_tval_el2",  CPENC (3,4,C14,C4,0), 0),
5156
  SR_V8_4A ("cnthvs_cval_el2",  CPENC (3,4,C14,C4,2), 0),
5157
  SR_V8_4A ("cnthvs_ctl_el2", CPENC (3,4,C14,C4,1), 0),
5158
  SR_V8_4A ("cnthps_tval_el2",  CPENC (3,4,C14,C5,0), 0),
5159
  SR_V8_4A ("cnthps_cval_el2",  CPENC (3,4,C14,C5,2), 0),
5160
  SR_V8_4A ("cnthps_ctl_el2", CPENC (3,4,C14,C5,1), 0),
5161
  SR_V8_4A ("sder32_el2", CPENC (3,4,C1,C3,1),  0),
5162
  SR_V8_4A ("vncr_el2",   CPENC (3,4,C2,C2,0),  0),
5163
  SR_V8_4A ("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_V8R ("mpuir_el1",    CPENC (3,0,C0,C0,4),  F_REG_READ),
5183
  SR_V8R ("mpuir_el2",    CPENC (3,4,C0,C0,4),  F_REG_READ),
5184
  SR_V8R ("prbar_el1",    CPENC (3,0,C6,C8,0),  0),
5185
  SR_V8R ("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_V8R ("prbar" #n "_el" #x, ENC_BARLAR (x,n,0), 0)
5191
#define PRLARn_ELx(x,n) SR_V8R ("prlar" #n "_el" #x, ENC_BARLAR (x,n,1), 0)
5192
5193
  SR_EXPAND_EL12 (PRBARn_ELx)
5194
  SR_V8R ("prenr_el1",    CPENC (3,0,C6,C1,1),  0),
5195
  SR_V8R ("prenr_el2",    CPENC (3,4,C6,C1,1),  0),
5196
  SR_V8R ("prlar_el1",    CPENC (3,0,C6,C8,1),  0),
5197
  SR_V8R ("prlar_el2",    CPENC (3,4,C6,C8,1),  0),
5198
  SR_EXPAND_EL12 (PRLARn_ELx)
5199
  SR_V8R ("prselr_el1", CPENC (3,0,C6,C2,1),  0),
5200
  SR_V8R ("prselr_el2", CPENC (3,4,C6,C2,1),  0),
5201
  SR_V8R ("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_6A ("amcg1idr_el0",      CPENC (3,3,C13,C2,6),   F_REG_READ),
5691
  SR_V8_6A ("cntpctss_el0",      CPENC (3,3,C14,C0,5),   F_REG_READ),
5692
  SR_V8_6A ("cntvctss_el0",      CPENC (3,3,C14,C0,6),   F_REG_READ),
5693
  SR_V8_6A ("hfgrtr_el2",        CPENC (3,4,C1,C1,4),    0),
5694
  SR_V8_6A ("hfgwtr_el2",        CPENC (3,4,C1,C1,5),    0),
5695
  SR_V8_6A ("hfgitr_el2",        CPENC (3,4,C1,C1,6),    0),
5696
  SR_V8_6A ("hdfgrtr_el2",       CPENC (3,4,C3,C1,4),    0),
5697
  SR_V8_6A ("hdfgwtr_el2",       CPENC (3,4,C3,C1,5),    0),
5698
  SR_V8_6A ("hafgrtr_el2",       CPENC (3,4,C3,C1,6),    0),
5699
  SR_V8_6A ("amevcntvoff00_el2", CPENC (3,4,C13,C8,0),   0),
5700
  SR_V8_6A ("amevcntvoff01_el2", CPENC (3,4,C13,C8,1),   0),
5701
  SR_V8_6A ("amevcntvoff02_el2", CPENC (3,4,C13,C8,2),   0),
5702
  SR_V8_6A ("amevcntvoff03_el2", CPENC (3,4,C13,C8,3),   0),
5703
  SR_V8_6A ("amevcntvoff04_el2", CPENC (3,4,C13,C8,4),   0),
5704
  SR_V8_6A ("amevcntvoff05_el2", CPENC (3,4,C13,C8,5),   0),
5705
  SR_V8_6A ("amevcntvoff06_el2", CPENC (3,4,C13,C8,6),   0),
5706
  SR_V8_6A ("amevcntvoff07_el2", CPENC (3,4,C13,C8,7),   0),
5707
  SR_V8_6A ("amevcntvoff08_el2", CPENC (3,4,C13,C9,0),   0),
5708
  SR_V8_6A ("amevcntvoff09_el2", CPENC (3,4,C13,C9,1),   0),
5709
  SR_V8_6A ("amevcntvoff010_el2", CPENC (3,4,C13,C9,2),  0),
5710
  SR_V8_6A ("amevcntvoff011_el2", CPENC (3,4,C13,C9,3),  0),
5711
  SR_V8_6A ("amevcntvoff012_el2", CPENC (3,4,C13,C9,4),  0),
5712
  SR_V8_6A ("amevcntvoff013_el2", CPENC (3,4,C13,C9,5),  0),
5713
  SR_V8_6A ("amevcntvoff014_el2", CPENC (3,4,C13,C9,6),  0),
5714
  SR_V8_6A ("amevcntvoff015_el2", CPENC (3,4,C13,C9,7),  0),
5715
  SR_V8_6A ("amevcntvoff10_el2", CPENC (3,4,C13,C10,0),  0),
5716
  SR_V8_6A ("amevcntvoff11_el2", CPENC (3,4,C13,C10,1),  0),
5717
  SR_V8_6A ("amevcntvoff12_el2", CPENC (3,4,C13,C10,2),  0),
5718
  SR_V8_6A ("amevcntvoff13_el2", CPENC (3,4,C13,C10,3),  0),
5719
  SR_V8_6A ("amevcntvoff14_el2", CPENC (3,4,C13,C10,4),  0),
5720
  SR_V8_6A ("amevcntvoff15_el2", CPENC (3,4,C13,C10,5),  0),
5721
  SR_V8_6A ("amevcntvoff16_el2", CPENC (3,4,C13,C10,6),  0),
5722
  SR_V8_6A ("amevcntvoff17_el2", CPENC (3,4,C13,C10,7),  0),
5723
  SR_V8_6A ("amevcntvoff18_el2", CPENC (3,4,C13,C11,0),  0),
5724
  SR_V8_6A ("amevcntvoff19_el2", CPENC (3,4,C13,C11,1),  0),
5725
  SR_V8_6A ("amevcntvoff110_el2", CPENC (3,4,C13,C11,2), 0),
5726
  SR_V8_6A ("amevcntvoff111_el2", CPENC (3,4,C13,C11,3), 0),
5727
  SR_V8_6A ("amevcntvoff112_el2", CPENC (3,4,C13,C11,4), 0),
5728
  SR_V8_6A ("amevcntvoff113_el2", CPENC (3,4,C13,C11,5), 0),
5729
  SR_V8_6A ("amevcntvoff114_el2", CPENC (3,4,C13,C11,6), 0),
5730
  SR_V8_6A ("amevcntvoff115_el2", CPENC (3,4,C13,C11,7), 0),
5731
  SR_V8_6A ("cntpoff_el2",       CPENC (3,4,C14,C0,6),   0),
5732
5733
  SR_V8_7A ("pmsnevfr_el1",      CPENC (3,0,C9,C9,1),    0),
5734
  SR_V8_7A ("hcrx_el2",          CPENC (3,4,C1,C2,2),    0),
5735
5736
  SR_V8_8A ("allint",            CPENC (3,0,C4,C3,0),    0),
5737
  SR_V8_8A ("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
168
{
5745
168
  return (reg_flags & F_DEPRECATED) != 0;
5746
168
}
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_2A ("uao",    0x03, F_REG_MAX_VALUE (1)),
5762
  SR_SSBS ("ssbs",    0x19, F_REG_MAX_VALUE (1)),
5763
  SR_V8_4A ("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_8A ("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
10
{
5952
10
  return (sys_ins_reg->flags & F_HASXT) != 0;
5953
10
}
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_V8R))
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_4A))
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_2A))
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_2A))
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
100k
#define BIT(INSN,BT)     (((INSN) >> (BT)) & 1)
6091
152k
#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.8k
{
6100
50.8k
  int t  = BITS (insn, 4, 0);
6101
50.8k
  int n  = BITS (insn, 9, 5);
6102
50.8k
  int t2 = BITS (insn, 14, 10);
6103
6104
50.8k
  if (BIT (insn, 23))
6105
17.5k
    {
6106
      /* Write back enabled.  */
6107
17.5k
      if ((t == n || t2 == n) && n != 31)
6108
1.08k
  return ERR_UND;
6109
17.5k
    }
6110
6111
49.7k
  if (BIT (insn, 22))
6112
49.7k
    {
6113
      /* Load */
6114
49.7k
      if (t == t2)
6115
1.75k
  return ERR_UND;
6116
49.7k
    }
6117
6118
47.9k
  return ERR_OK;
6119
49.7k
}
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.87k
{
6130
4.87k
  const aarch64_insn undef_pattern = 0x3;
6131
4.87k
  aarch64_insn value;
6132
6133
4.87k
  assert (inst->opcode);
6134
4.87k
  assert (inst->opcode->operands[2] == AARCH64_OPND_Em);
6135
4.87k
  value = encoding ? inst->value : insn;
6136
4.87k
  assert (value);
6137
6138
4.87k
  if (undef_pattern == extract_fields (value, 0, 2, FLD_sz, FLD_L))
6139
1.08k
    return ERR_UND;
6140
6141
3.78k
  return ERR_OK;
6142
4.87k
}
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
9.75k
{
6157
9.75k
  int rd, rs, rn;
6158
6159
9.75k
  rd = inst->operands[0].reg.regno;
6160
9.75k
  rs = inst->operands[1].reg.regno;
6161
9.75k
  rn = inst->operands[2].reg.regno;
6162
9.75k
  if (rd == rs || rd == rn || rs == rn)
6163
787
    {
6164
787
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6165
787
      mismatch_detail->error
6166
787
  = _("the three register operands must be distinct from one another");
6167
787
      mismatch_detail->index = -1;
6168
787
      return ERR_UND;
6169
787
    }
6170
6171
8.96k
  return ERR_OK;
6172
9.75k
}
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
2.87k
{
6180
2.87k
  insn_sequence->instr[insn_sequence->num_added_insns++] = *inst;
6181
2.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
7.83k
{
6191
7.83k
  int num_req_entries = 0;
6192
6193
7.83k
  if (insn_sequence->instr)
6194
2.85k
    {
6195
2.85k
      XDELETE (insn_sequence->instr);
6196
2.85k
      insn_sequence->instr = NULL;
6197
2.85k
    }
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
7.83k
  if (inst && inst->opcode->constraints & C_SCAN_MOVPRFX)
6203
157
    num_req_entries = 1;
6204
7.83k
  if (inst && (inst->opcode->constraints & C_SCAN_MOPS_PME) == C_SCAN_MOPS_P)
6205
2.69k
    num_req_entries = 2;
6206
6207
7.83k
  insn_sequence->num_added_insns = 0;
6208
7.83k
  insn_sequence->num_allocated_insns = num_req_entries;
6209
6210
7.83k
  if (num_req_entries != 0)
6211
2.85k
    {
6212
2.85k
      insn_sequence->instr = XCNEWVEC (aarch64_inst, num_req_entries);
6213
2.85k
      add_insn_to_sequence (inst, insn_sequence);
6214
2.85k
    }
6215
7.83k
}
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
177k
{
6231
177k
  const struct aarch64_opcode *opcode;
6232
177k
  const struct aarch64_inst *prev_insn;
6233
177k
  int i;
6234
6235
177k
  opcode = inst->opcode;
6236
177k
  if (insn_sequence->instr)
6237
2.87k
    prev_insn = insn_sequence->instr + (insn_sequence->num_added_insns - 1);
6238
174k
  else
6239
174k
    prev_insn = NULL;
6240
6241
177k
  if (prev_insn
6242
177k
      && (prev_insn->opcode->constraints & C_SCAN_MOPS_PME)
6243
177k
      && prev_insn->opcode != opcode - 1)
6244
2.71k
    {
6245
2.71k
      mismatch_detail->kind = AARCH64_OPDE_EXPECTED_A_AFTER_B;
6246
2.71k
      mismatch_detail->error = NULL;
6247
2.71k
      mismatch_detail->index = -1;
6248
2.71k
      mismatch_detail->data[0].s = prev_insn->opcode[1].name;
6249
2.71k
      mismatch_detail->data[1].s = prev_insn->opcode->name;
6250
2.71k
      mismatch_detail->non_fatal = true;
6251
2.71k
      return false;
6252
2.71k
    }
6253
6254
174k
  if (opcode->constraints & C_SCAN_MOPS_PME)
6255
6.25k
    {
6256
6.25k
      if (is_new_section || !prev_insn || prev_insn->opcode != opcode - 1)
6257
6.25k
  {
6258
6.25k
    mismatch_detail->kind = AARCH64_OPDE_A_SHOULD_FOLLOW_B;
6259
6.25k
    mismatch_detail->error = NULL;
6260
6.25k
    mismatch_detail->index = -1;
6261
6.25k
    mismatch_detail->data[0].s = opcode->name;
6262
6.25k
    mismatch_detail->data[1].s = opcode[-1].name;
6263
6.25k
    mismatch_detail->non_fatal = true;
6264
6.25k
    return false;
6265
6.25k
  }
6266
6267
0
      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
0
  if ((opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rd
6271
0
       || opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rs
6272
0
       || opcode->operands[i] == AARCH64_OPND_MOPS_WB_Rn)
6273
0
      && prev_insn->operands[i].reg.regno != inst->operands[i].reg.regno)
6274
0
    {
6275
0
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6276
0
      if (opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rd)
6277
0
        mismatch_detail->error = _("destination register differs from "
6278
0
           "preceding instruction");
6279
0
      else if (opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rs)
6280
0
        mismatch_detail->error = _("source register differs from "
6281
0
           "preceding instruction");
6282
0
      else
6283
0
        mismatch_detail->error = _("size register differs from "
6284
0
           "preceding instruction");
6285
0
      mismatch_detail->index = i;
6286
0
      mismatch_detail->non_fatal = true;
6287
0
      return false;
6288
0
    }
6289
0
    }
6290
6291
168k
  return true;
6292
174k
}
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.00M
{
6314
6.00M
  assert (inst);
6315
6.00M
  assert (inst->opcode);
6316
6317
6.00M
  const struct aarch64_opcode *opcode = inst->opcode;
6318
6.00M
  if (!opcode->constraints && !insn_sequence->instr)
6319
5.82M
    return ERR_OK;
6320
6321
180k
  assert (insn_sequence);
6322
6323
180k
  enum err_type res = ERR_OK;
6324
6325
  /* This instruction puts a constraint on the insn_sequence.  */
6326
180k
  if (opcode->flags & F_SCAN)
6327
2.85k
    {
6328
2.85k
      if (insn_sequence->instr)
6329
2
  {
6330
2
    mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6331
2
    mismatch_detail->error = _("instruction opens new dependency "
6332
2
             "sequence without ending previous one");
6333
2
    mismatch_detail->index = -1;
6334
2
    mismatch_detail->non_fatal = true;
6335
2
    res = ERR_VFI;
6336
2
  }
6337
6338
2.85k
      init_insn_sequence (inst, insn_sequence);
6339
2.85k
      return res;
6340
2.85k
    }
6341
6342
177k
  bool is_new_section = (!encoding && pc == 0);
6343
177k
  if (!verify_mops_pme_sequence (inst, is_new_section, mismatch_detail,
6344
177k
         insn_sequence))
6345
8.96k
    {
6346
8.96k
      res = ERR_VFI;
6347
8.96k
      if ((opcode->constraints & C_SCAN_MOPS_PME) != C_SCAN_MOPS_M)
6348
4.82k
  init_insn_sequence (NULL, insn_sequence);
6349
8.96k
    }
6350
6351
  /* Verify constraints on an existing sequence.  */
6352
177k
  if (insn_sequence->instr)
6353
177
    {
6354
177
      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
177
      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
177
      if (inst_opcode->constraints & C_SCAN_MOVPRFX)
6371
157
  {
6372
    /* Check to see if the MOVPRFX SVE instruction is followed by an SVE
6373
       instruction for better error messages.  */
6374
157
    if (!opcode->avariant
6375
157
        || !(*opcode->avariant &
6376
157
       (AARCH64_FEATURE_SVE | AARCH64_FEATURE_SVE2)))
6377
132
      {
6378
132
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6379
132
        mismatch_detail->error = _("SVE instruction expected after "
6380
132
           "`movprfx'");
6381
132
        mismatch_detail->index = -1;
6382
132
        mismatch_detail->non_fatal = true;
6383
132
        res = ERR_VFI;
6384
132
        goto done;
6385
132
      }
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
25
    if (!(opcode->constraints & C_SCAN_MOVPRFX))
6390
15
      {
6391
15
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6392
15
        mismatch_detail->error = _("SVE `movprfx' compatible instruction "
6393
15
           "expected");
6394
15
        mismatch_detail->index = -1;
6395
15
        mismatch_detail->non_fatal = true;
6396
15
        res = ERR_VFI;
6397
15
        goto done;
6398
15
      }
6399
6400
    /* Next check for usage of the predicate register.  */
6401
10
    aarch64_opnd_info blk_dest = insn_sequence->instr->operands[0];
6402
10
    aarch64_opnd_info blk_pred, inst_pred;
6403
10
    memset (&blk_pred, 0, sizeof (aarch64_opnd_info));
6404
10
    memset (&inst_pred, 0, sizeof (aarch64_opnd_info));
6405
10
    bool predicated = false;
6406
10
    assert (blk_dest.type == AARCH64_OPND_SVE_Zd);
6407
6408
    /* Determine if the movprfx instruction used is predicated or not.  */
6409
10
    if (insn_sequence->instr->operands[1].type == AARCH64_OPND_SVE_Pg3)
6410
10
      {
6411
10
        predicated = true;
6412
10
        blk_pred = insn_sequence->instr->operands[1];
6413
10
      }
6414
6415
10
    unsigned char max_elem_size = 0;
6416
10
    unsigned char current_elem_size;
6417
10
    int num_op_used = 0, last_op_usage = 0;
6418
10
    int i, inst_pred_idx = -1;
6419
10
    int num_ops = aarch64_num_of_operands (opcode);
6420
50
    for (i = 0; i < num_ops; i++)
6421
40
      {
6422
40
        aarch64_opnd_info inst_op = inst->operands[i];
6423
40
        switch (inst_op.type)
6424
40
    {
6425
10
      case AARCH64_OPND_SVE_Zd:
6426
12
      case AARCH64_OPND_SVE_Zm_5:
6427
20
      case AARCH64_OPND_SVE_Zm_16:
6428
24
      case AARCH64_OPND_SVE_Zn:
6429
24
      case AARCH64_OPND_SVE_Zt:
6430
24
      case AARCH64_OPND_SVE_Vm:
6431
24
      case AARCH64_OPND_SVE_Vn:
6432
24
      case AARCH64_OPND_Va:
6433
24
      case AARCH64_OPND_Vn:
6434
24
      case AARCH64_OPND_Vm:
6435
24
      case AARCH64_OPND_Sn:
6436
24
      case AARCH64_OPND_Sm:
6437
24
        if (inst_op.reg.regno == blk_dest.reg.regno)
6438
2
          {
6439
2
      num_op_used++;
6440
2
      last_op_usage = i;
6441
2
          }
6442
24
        current_elem_size
6443
24
          = aarch64_get_qualifier_esize (inst_op.qualifier);
6444
24
        if (current_elem_size > max_elem_size)
6445
10
          max_elem_size = current_elem_size;
6446
24
        break;
6447
0
      case AARCH64_OPND_SVE_Pd:
6448
10
      case AARCH64_OPND_SVE_Pg3:
6449
10
      case AARCH64_OPND_SVE_Pg4_5:
6450
10
      case AARCH64_OPND_SVE_Pg4_10:
6451
10
      case AARCH64_OPND_SVE_Pg4_16:
6452
10
      case AARCH64_OPND_SVE_Pm:
6453
10
      case AARCH64_OPND_SVE_Pn:
6454
10
      case AARCH64_OPND_SVE_Pt:
6455
10
      case AARCH64_OPND_SME_Pm:
6456
10
        inst_pred = inst_op;
6457
10
        inst_pred_idx = i;
6458
10
        break;
6459
6
      default:
6460
6
        break;
6461
40
    }
6462
40
      }
6463
6464
10
     assert (max_elem_size != 0);
6465
10
     aarch64_opnd_info inst_dest = inst->operands[0];
6466
     /* Determine the size that should be used to compare against the
6467
        movprfx size.  */
6468
10
     current_elem_size
6469
10
       = opcode->constraints & C_MAX_ELEM
6470
10
         ? max_elem_size
6471
10
         : aarch64_get_qualifier_esize (inst_dest.qualifier);
6472
6473
    /* If movprfx is predicated do some extra checks.  */
6474
10
    if (predicated)
6475
10
      {
6476
        /* The instruction must be predicated.  */
6477
10
        if (inst_pred_idx < 0)
6478
0
    {
6479
0
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6480
0
      mismatch_detail->error = _("predicated instruction expected "
6481
0
               "after `movprfx'");
6482
0
      mismatch_detail->index = -1;
6483
0
      mismatch_detail->non_fatal = true;
6484
0
      res = ERR_VFI;
6485
0
      goto done;
6486
0
    }
6487
6488
        /* The instruction must have a merging predicate.  */
6489
10
        if (inst_pred.qualifier != AARCH64_OPND_QLF_P_M)
6490
0
    {
6491
0
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6492
0
      mismatch_detail->error = _("merging predicate expected due "
6493
0
               "to preceding `movprfx'");
6494
0
      mismatch_detail->index = inst_pred_idx;
6495
0
      mismatch_detail->non_fatal = true;
6496
0
      res = ERR_VFI;
6497
0
      goto done;
6498
0
    }
6499
6500
        /* The same register must be used in instruction.  */
6501
10
        if (blk_pred.reg.regno != inst_pred.reg.regno)
6502
6
    {
6503
6
      mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6504
6
      mismatch_detail->error = _("predicate register differs "
6505
6
               "from that in preceding "
6506
6
               "`movprfx'");
6507
6
      mismatch_detail->index = inst_pred_idx;
6508
6
      mismatch_detail->non_fatal = true;
6509
6
      res = ERR_VFI;
6510
6
      goto done;
6511
6
    }
6512
10
      }
6513
6514
    /* Destructive operations by definition must allow one usage of the
6515
       same register.  */
6516
4
    int allowed_usage
6517
4
      = aarch64_is_destructive_by_operands (opcode) ? 2 : 1;
6518
6519
    /* Operand is not used at all.  */
6520
4
    if (num_op_used == 0)
6521
4
      {
6522
4
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6523
4
        mismatch_detail->error = _("output register of preceding "
6524
4
           "`movprfx' not used in current "
6525
4
           "instruction");
6526
4
        mismatch_detail->index = 0;
6527
4
        mismatch_detail->non_fatal = true;
6528
4
        res = ERR_VFI;
6529
4
        goto done;
6530
4
      }
6531
6532
    /* We now know it's used, now determine exactly where it's used.  */
6533
0
    if (blk_dest.reg.regno != inst_dest.reg.regno)
6534
0
      {
6535
0
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6536
0
        mismatch_detail->error = _("output register of preceding "
6537
0
           "`movprfx' expected as output");
6538
0
        mismatch_detail->index = 0;
6539
0
        mismatch_detail->non_fatal = true;
6540
0
        res = ERR_VFI;
6541
0
        goto done;
6542
0
      }
6543
6544
    /* Operand used more than allowed for the specific opcode type.  */
6545
0
    if (num_op_used > allowed_usage)
6546
0
      {
6547
0
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6548
0
        mismatch_detail->error = _("output register of preceding "
6549
0
           "`movprfx' used as input");
6550
0
        mismatch_detail->index = last_op_usage;
6551
0
        mismatch_detail->non_fatal = true;
6552
0
        res = ERR_VFI;
6553
0
        goto done;
6554
0
      }
6555
6556
    /* Now the only thing left is the qualifiers checks.  The register
6557
       must have the same maximum element size.  */
6558
0
    if (inst_dest.qualifier
6559
0
        && blk_dest.qualifier
6560
0
        && current_elem_size
6561
0
     != aarch64_get_qualifier_esize (blk_dest.qualifier))
6562
0
      {
6563
0
        mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR;
6564
0
        mismatch_detail->error = _("register size not compatible with "
6565
0
           "previous `movprfx'");
6566
0
        mismatch_detail->index = 0;
6567
0
        mismatch_detail->non_fatal = true;
6568
0
        res = ERR_VFI;
6569
0
        goto done;
6570
0
      }
6571
0
  }
6572
6573
177
    done:
6574
177
      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
157
  init_insn_sequence (NULL, insn_sequence);
6578
20
      else
6579
20
  add_insn_to_sequence (inst, insn_sequence);
6580
177
    }
6581
6582
177k
  return res;
6583
177k
}
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
1.03k
{
6593
1.03k
  int64_t svalue = uvalue;
6594
1.03k
  uint64_t upper = (uint64_t) -1 << (esize * 4) << (esize * 4);
6595
6596
1.03k
  if ((uvalue & ~upper) != uvalue && (uvalue | upper) != uvalue)
6597
0
    return false;
6598
1.03k
  if (esize <= 4 || (uint32_t) uvalue == (uint32_t) (uvalue >> 32))
6599
798
    {
6600
798
      svalue = (int32_t) uvalue;
6601
798
      if (esize <= 2 || (uint16_t) uvalue == (uint16_t) (uvalue >> 16))
6602
52
  {
6603
52
    svalue = (int16_t) uvalue;
6604
52
    if (esize == 1 || (uint8_t) uvalue == (uint8_t) (uvalue >> 8))
6605
39
      return false;
6606
52
  }
6607
798
    }
6608
996
  if ((svalue & 0xff) == 0)
6609
679
    svalue /= 256;
6610
996
  return svalue < -128 || svalue >= 128;
6611
1.03k
}
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"