Rizin
unix-like reverse engineering framework and cli tools
aarch64-opc.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2018 Free Software Foundation, Inc.
2 // SPDX-License-Identifier: GPL-3.0-or-later
3 
4 /* aarch64-opc.c -- AArch64 opcode support.
5  Copyright (C) 2009-2018 Free Software Foundation, Inc.
6  Contributed by ARM Ltd.
7 
8  This file is part of the GNU opcodes library.
9 
10  This library is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 3, or (at your option)
13  any later version.
14 
15  It is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18  License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; see the file COPYING3. If not,
22  see <http://www.gnu.org/licenses/>. */
23 
24 #include "sysdep.h"
25 #include <assert.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <stdarg.h>
30 #include <inttypes.h>
31 
32 #include "opintl.h"
33 #include "libiberty.h"
34 
35 #include "aarch64-opc.h"
36 
37 #ifdef DEBUG_AARCH64
38 int debug_dump = FALSE;
39 #endif /* DEBUG_AARCH64 */
40 
41 /* The enumeration strings associated with each value of a 5-bit SVE
42  pattern operand. A null entry indicates a reserved meaning. */
43 const char *const aarch64_sve_pattern_array[32] = {
44  /* 0-7. */
45  "pow2",
46  "vl1",
47  "vl2",
48  "vl3",
49  "vl4",
50  "vl5",
51  "vl6",
52  "vl7",
53  /* 8-15. */
54  "vl8",
55  "vl16",
56  "vl32",
57  "vl64",
58  "vl128",
59  "vl256",
60  0,
61  0,
62  /* 16-23. */
63  0,
64  0,
65  0,
66  0,
67  0,
68  0,
69  0,
70  0,
71  /* 24-31. */
72  0,
73  0,
74  0,
75  0,
76  0,
77  "mul4",
78  "mul3",
79  "all"
80 };
81 
82 /* The enumeration strings associated with each value of a 4-bit SVE
83  prefetch operand. A null entry indicates a reserved meaning. */
84 const char *const aarch64_sve_prfop_array[16] = {
85  /* 0-7. */
86  "pldl1keep",
87  "pldl1strm",
88  "pldl2keep",
89  "pldl2strm",
90  "pldl3keep",
91  "pldl3strm",
92  0,
93  0,
94  /* 8-15. */
95  "pstl1keep",
96  "pstl1strm",
97  "pstl2keep",
98  "pstl2strm",
99  "pstl3keep",
100  "pstl3strm",
101  0,
102  0
103 };
104 
105 /* Helper functions to determine which operand to be used to encode/decode
106  the size:Q fields for AdvSIMD instructions. */
107 
108 static inline bfd_boolean
110 {
111  return ((qualifier >= AARCH64_OPND_QLF_V_8B
112  && qualifier <= AARCH64_OPND_QLF_V_1Q) ? TRUE
113  : FALSE);
114 }
115 
116 static inline bfd_boolean
118 {
119  return ((qualifier >= AARCH64_OPND_QLF_S_B
120  && qualifier <= AARCH64_OPND_QLF_S_Q) ? TRUE
121  : FALSE);
122 }
123 
125 {
131 };
132 
133 static const char significant_operand_index [] =
134 {
135  0, /* DP_UNKNOWN, by default using operand 0. */
136  0, /* DP_VECTOR_3SAME */
137  1, /* DP_VECTOR_LONG */
138  2, /* DP_VECTOR_WIDE */
139  1, /* DP_VECTOR_ACROSS_LANES */
140 };
141 
142 /* Given a sequence of qualifiers in QUALIFIERS, determine and return
143  the data pattern.
144  N.B. QUALIFIERS is a possible sequence of qualifiers each of which
145  corresponds to one of a sequence of operands. */
146 
147 static enum data_pattern
149 {
150  if (vector_qualifier_p (qualifiers[0]) == TRUE)
151  {
152  /* e.g. v.4s, v.4s, v.4s
153  or v.4h, v.4h, v.h[3]. */
154  if (qualifiers[0] == qualifiers[1]
155  && vector_qualifier_p (qualifiers[2]) == TRUE
156  && (aarch64_get_qualifier_esize (qualifiers[0])
157  == aarch64_get_qualifier_esize (qualifiers[1]))
158  && (aarch64_get_qualifier_esize (qualifiers[0])
159  == aarch64_get_qualifier_esize (qualifiers[2])))
160  return DP_VECTOR_3SAME;
161  /* e.g. v.8h, v.8b, v.8b.
162  or v.4s, v.4h, v.h[2].
163  or v.8h, v.16b. */
164  if (vector_qualifier_p (qualifiers[1]) == TRUE
165  && aarch64_get_qualifier_esize (qualifiers[0]) != 0
166  && (aarch64_get_qualifier_esize (qualifiers[0])
167  == aarch64_get_qualifier_esize (qualifiers[1]) << 1))
168  return DP_VECTOR_LONG;
169  /* e.g. v.8h, v.8h, v.8b. */
170  if (qualifiers[0] == qualifiers[1]
171  && vector_qualifier_p (qualifiers[2]) == TRUE
172  && aarch64_get_qualifier_esize (qualifiers[0]) != 0
173  && (aarch64_get_qualifier_esize (qualifiers[0])
174  == aarch64_get_qualifier_esize (qualifiers[2]) << 1)
175  && (aarch64_get_qualifier_esize (qualifiers[0])
176  == aarch64_get_qualifier_esize (qualifiers[1])))
177  return DP_VECTOR_WIDE;
178  }
179  else if (fp_qualifier_p (qualifiers[0]) == TRUE)
180  {
181  /* e.g. SADDLV <V><d>, <Vn>.<T>. */
182  if (vector_qualifier_p (qualifiers[1]) == TRUE
183  && qualifiers[2] == AARCH64_OPND_QLF_NIL)
184  return DP_VECTOR_ACROSS_LANES;
185  }
186 
187  return DP_UNKNOWN;
188 }
189 
190 /* Select the operand to do the encoding/decoding of the 'size:Q' fields in
191  the AdvSIMD instructions. */
192 /* N.B. it is possible to do some optimization that doesn't call
193  get_data_pattern each time when we need to select an operand. We can
194  either buffer the caculated the result or statically generate the data,
195  however, it is not obvious that the optimization will bring significant
196  benefit. */
197 
198 int
200 {
201  return
203 }
204 ␌
206 {
207  { 0, 0 }, /* NIL. */
208  { 0, 4 }, /* cond2: condition in truly conditional-executed inst. */
209  { 0, 4 }, /* nzcv: flag bit specifier, encoded in the "nzcv" field. */
210  { 5, 5 }, /* defgh: d:e:f:g:h bits in AdvSIMD modified immediate. */
211  { 16, 3 }, /* abc: a:b:c bits in AdvSIMD modified immediate. */
212  { 5, 19 }, /* imm19: e.g. in CBZ. */
213  { 5, 19 }, /* immhi: e.g. in ADRP. */
214  { 29, 2 }, /* immlo: e.g. in ADRP. */
215  { 22, 2 }, /* size: in most AdvSIMD and floating-point instructions. */
216  { 10, 2 }, /* vldst_size: size field in the AdvSIMD load/store inst. */
217  { 29, 1 }, /* op: in AdvSIMD modified immediate instructions. */
218  { 30, 1 }, /* Q: in most AdvSIMD instructions. */
219  { 0, 5 }, /* Rt: in load/store instructions. */
220  { 0, 5 }, /* Rd: in many integer instructions. */
221  { 5, 5 }, /* Rn: in many integer instructions. */
222  { 10, 5 }, /* Rt2: in load/store pair instructions. */
223  { 10, 5 }, /* Ra: in fp instructions. */
224  { 5, 3 }, /* op2: in the system instructions. */
225  { 8, 4 }, /* CRm: in the system instructions. */
226  { 12, 4 }, /* CRn: in the system instructions. */
227  { 16, 3 }, /* op1: in the system instructions. */
228  { 19, 2 }, /* op0: in the system instructions. */
229  { 10, 3 }, /* imm3: in add/sub extended reg instructions. */
230  { 12, 4 }, /* cond: condition flags as a source operand. */
231  { 12, 4 }, /* opcode: in advsimd load/store instructions. */
232  { 12, 4 }, /* cmode: in advsimd modified immediate instructions. */
233  { 13, 3 }, /* asisdlso_opcode: opcode in advsimd ld/st single element. */
234  { 13, 2 }, /* len: in advsimd tbl/tbx instructions. */
235  { 16, 5 }, /* Rm: in ld/st reg offset and some integer inst. */
236  { 16, 5 }, /* Rs: in load/store exclusive instructions. */
237  { 13, 3 }, /* option: in ld/st reg offset + add/sub extended reg inst. */
238  { 12, 1 }, /* S: in load/store reg offset instructions. */
239  { 21, 2 }, /* hw: in move wide constant instructions. */
240  { 22, 2 }, /* opc: in load/store reg offset instructions. */
241  { 23, 1 }, /* opc1: in load/store reg offset instructions. */
242  { 22, 2 }, /* shift: in add/sub reg/imm shifted instructions. */
243  { 22, 2 }, /* type: floating point type field in fp data inst. */
244  { 30, 2 }, /* ldst_size: size field in ld/st reg offset inst. */
245  { 10, 6 }, /* imm6: in add/sub reg shifted instructions. */
246  { 15, 6 }, /* imm6_2: in rmif instructions. */
247  { 11, 4 }, /* imm4: in advsimd ext and advsimd ins instructions. */
248  { 0, 4 }, /* imm4_2: in rmif instructions. */
249  { 16, 5 }, /* imm5: in conditional compare (immediate) instructions. */
250  { 15, 7 }, /* imm7: in load/store pair pre/post index instructions. */
251  { 13, 8 }, /* imm8: in floating-point scalar move immediate inst. */
252  { 12, 9 }, /* imm9: in load/store pre/post index instructions. */
253  { 10, 12 }, /* imm12: in ld/st unsigned imm or add/sub shifted inst. */
254  { 5, 14 }, /* imm14: in test bit and branch instructions. */
255  { 5, 16 }, /* imm16: in exception instructions. */
256  { 0, 26 }, /* imm26: in unconditional branch instructions. */
257  { 10, 6 }, /* imms: in bitfield and logical immediate instructions. */
258  { 16, 6 }, /* immr: in bitfield and logical immediate instructions. */
259  { 16, 3 }, /* immb: in advsimd shift by immediate instructions. */
260  { 19, 4 }, /* immh: in advsimd shift by immediate instructions. */
261  { 22, 1 }, /* S: in LDRAA and LDRAB instructions. */
262  { 22, 1 }, /* N: in logical (immediate) instructions. */
263  { 11, 1 }, /* index: in ld/st inst deciding the pre/post-index. */
264  { 24, 1 }, /* index2: in ld/st pair inst deciding the pre/post-index. */
265  { 31, 1 }, /* sf: in integer data processing instructions. */
266  { 30, 1 }, /* lse_size: in LSE extension atomic instructions. */
267  { 11, 1 }, /* H: in advsimd scalar x indexed element instructions. */
268  { 21, 1 }, /* L: in advsimd scalar x indexed element instructions. */
269  { 20, 1 }, /* M: in advsimd scalar x indexed element instructions. */
270  { 31, 1 }, /* b5: in the test bit and branch instructions. */
271  { 19, 5 }, /* b40: in the test bit and branch instructions. */
272  { 10, 6 }, /* scale: in the fixed-point scalar to fp converting inst. */
273  { 4, 1 }, /* SVE_M_4: Merge/zero select, bit 4. */
274  { 14, 1 }, /* SVE_M_14: Merge/zero select, bit 14. */
275  { 16, 1 }, /* SVE_M_16: Merge/zero select, bit 16. */
276  { 17, 1 }, /* SVE_N: SVE equivalent of N. */
277  { 0, 4 }, /* SVE_Pd: p0-p15, bits [3,0]. */
278  { 10, 3 }, /* SVE_Pg3: p0-p7, bits [12,10]. */
279  { 5, 4 }, /* SVE_Pg4_5: p0-p15, bits [8,5]. */
280  { 10, 4 }, /* SVE_Pg4_10: p0-p15, bits [13,10]. */
281  { 16, 4 }, /* SVE_Pg4_16: p0-p15, bits [19,16]. */
282  { 16, 4 }, /* SVE_Pm: p0-p15, bits [19,16]. */
283  { 5, 4 }, /* SVE_Pn: p0-p15, bits [8,5]. */
284  { 0, 4 }, /* SVE_Pt: p0-p15, bits [3,0]. */
285  { 5, 5 }, /* SVE_Rm: SVE alternative position for Rm. */
286  { 16, 5 }, /* SVE_Rn: SVE alternative position for Rn. */
287  { 0, 5 }, /* SVE_Vd: Scalar SIMD&FP register, bits [4,0]. */
288  { 5, 5 }, /* SVE_Vm: Scalar SIMD&FP register, bits [9,5]. */
289  { 5, 5 }, /* SVE_Vn: Scalar SIMD&FP register, bits [9,5]. */
290  { 5, 5 }, /* SVE_Za_5: SVE vector register, bits [9,5]. */
291  { 16, 5 }, /* SVE_Za_16: SVE vector register, bits [20,16]. */
292  { 0, 5 }, /* SVE_Zd: SVE vector register. bits [4,0]. */
293  { 5, 5 }, /* SVE_Zm_5: SVE vector register, bits [9,5]. */
294  { 16, 5 }, /* SVE_Zm_16: SVE vector register, bits [20,16]. */
295  { 5, 5 }, /* SVE_Zn: SVE vector register, bits [9,5]. */
296  { 0, 5 }, /* SVE_Zt: SVE vector register, bits [4,0]. */
297  { 5, 1 }, /* SVE_i1: single-bit immediate. */
298  { 22, 1 }, /* SVE_i3h: high 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  { 22, 1 }, /* SVE_sz: 1-bit element size select. */
315  { 16, 4 }, /* SVE_tsz: triangular size select. */
316  { 22, 2 }, /* SVE_tszh: triangular size select high, bits [23,22]. */
317  { 8, 2 }, /* SVE_tszl_8: triangular size select low, bits [9,8]. */
318  { 19, 2 }, /* SVE_tszl_19: triangular size select low, bits [20,19]. */
319  { 14, 1 }, /* SVE_xs_14: UXTW/SXTW select (bit 14). */
320  { 22, 1 }, /* SVE_xs_22: UXTW/SXTW select (bit 22). */
321  { 11, 2 }, /* rotate1: FCMLA immediate rotate. */
322  { 13, 2 }, /* rotate2: Indexed element FCMLA immediate rotate. */
323  { 12, 1 }, /* rotate3: FCADD immediate rotate. */
324  { 12, 2 }, /* SM3: Indexed element SM3 2 bits index immediate. */
325 };
326 
329 {
331 }
332 
333 const char *
335 {
336  return aarch64_operands[type].name;
337 }
338 
339 /* Get operand description string.
340  This is usually for the diagnosis purpose. */
341 const char *
343 {
344  return aarch64_operands[type].desc;
345 }
346 
347 /* Table of all conditional affixes. */
349 {
350  {{"eq", "none"}, 0x0},
351  {{"ne", "any"}, 0x1},
352  {{"cs", "hs", "nlast"}, 0x2},
353  {{"cc", "lo", "ul", "last"}, 0x3},
354  {{"mi", "first"}, 0x4},
355  {{"pl", "nfrst"}, 0x5},
356  {{"vs"}, 0x6},
357  {{"vc"}, 0x7},
358  {{"hi", "pmore"}, 0x8},
359  {{"ls", "plast"}, 0x9},
360  {{"ge", "tcont"}, 0xa},
361  {{"lt", "tstop"}, 0xb},
362  {{"gt"}, 0xc},
363  {{"le"}, 0xd},
364  {{"al"}, 0xe},
365  {{"nv"}, 0xf},
366 };
367 
368 const aarch64_cond *
370 {
371  assert (value < 16);
372  return &aarch64_conds[(unsigned int) value];
373 }
374 
375 const aarch64_cond *
377 {
378  return &aarch64_conds[cond->value ^ 0x1];
379 }
380 
381 /* Table describing the operand extension/shifting operators; indexed by
382  enum aarch64_modifier_kind.
383 
384  The value column provides the most common values for encoding modifiers,
385  which enables table-driven encoding/decoding for the modifiers. */
387 {
388  {"none", 0x0},
389  {"msl", 0x0},
390  {"ror", 0x3},
391  {"asr", 0x2},
392  {"lsr", 0x1},
393  {"lsl", 0x0},
394  {"uxtb", 0x0},
395  {"uxth", 0x1},
396  {"uxtw", 0x2},
397  {"uxtx", 0x3},
398  {"sxtb", 0x4},
399  {"sxth", 0x5},
400  {"sxtw", 0x6},
401  {"sxtx", 0x7},
402  {"mul", 0x0},
403  {"mul vl", 0x0},
404  {NULL, 0},
405 };
406 
409 {
411 }
412 
415 {
416  return aarch64_operand_modifiers[kind].value;
417 }
418 
421  bfd_boolean extend_p)
422 {
423  if (extend_p == TRUE)
424  return AARCH64_MOD_UXTB + value;
425  else
426  return AARCH64_MOD_LSL - value;
427 }
428 
431 {
432  return (kind > AARCH64_MOD_LSL && kind <= AARCH64_MOD_SXTX)
433  ? TRUE : FALSE;
434 }
435 
436 static inline bfd_boolean
438 {
439  return (kind >= AARCH64_MOD_ROR && kind <= AARCH64_MOD_LSL)
440  ? TRUE : FALSE;
441 }
442 
444 {
445  { "#0x00", 0x0 },
446  { "oshld", 0x1 },
447  { "oshst", 0x2 },
448  { "osh", 0x3 },
449  { "#0x04", 0x4 },
450  { "nshld", 0x5 },
451  { "nshst", 0x6 },
452  { "nsh", 0x7 },
453  { "#0x08", 0x8 },
454  { "ishld", 0x9 },
455  { "ishst", 0xa },
456  { "ish", 0xb },
457  { "#0x0c", 0xc },
458  { "ld", 0xd },
459  { "st", 0xe },
460  { "sy", 0xf },
461 };
462 
463 /* Table describing the operands supported by the aliases of the HINT
464  instruction.
465 
466  The name column is the operand that is accepted for the alias. The value
467  column is the hint number of the alias. The list of operands is terminated
468  by NULL in the name column. */
469 
471 {
472  { "csync", 0x11 }, /* PSB CSYNC. */
473  { NULL, 0x0 },
474 };
475 
476 /* op -> op: load = 0 instruction = 1 store = 2
477  l -> level: 1-3
478  t -> temporal: temporal (retained) = 0 non-temporal (streaming) = 1 */
479 #define B(op,l,t) (((op) << 3) | (((l) - 1) << 1) | (t))
480 const struct aarch64_name_value_pair aarch64_prfops[32] =
481 {
482  { "pldl1keep", B(0, 1, 0) },
483  { "pldl1strm", B(0, 1, 1) },
484  { "pldl2keep", B(0, 2, 0) },
485  { "pldl2strm", B(0, 2, 1) },
486  { "pldl3keep", B(0, 3, 0) },
487  { "pldl3strm", B(0, 3, 1) },
488  { NULL, 0x06 },
489  { NULL, 0x07 },
490  { "plil1keep", B(1, 1, 0) },
491  { "plil1strm", B(1, 1, 1) },
492  { "plil2keep", B(1, 2, 0) },
493  { "plil2strm", B(1, 2, 1) },
494  { "plil3keep", B(1, 3, 0) },
495  { "plil3strm", B(1, 3, 1) },
496  { NULL, 0x0e },
497  { NULL, 0x0f },
498  { "pstl1keep", B(2, 1, 0) },
499  { "pstl1strm", B(2, 1, 1) },
500  { "pstl2keep", B(2, 2, 0) },
501  { "pstl2strm", B(2, 2, 1) },
502  { "pstl3keep", B(2, 3, 0) },
503  { "pstl3strm", B(2, 3, 1) },
504  { NULL, 0x16 },
505  { NULL, 0x17 },
506  { NULL, 0x18 },
507  { NULL, 0x19 },
508  { NULL, 0x1a },
509  { NULL, 0x1b },
510  { NULL, 0x1c },
511  { NULL, 0x1d },
512  { NULL, 0x1e },
513  { NULL, 0x1f },
514 };
515 #undef B
516 ␌
517 /* Utilities on value constraint. */
518 
519 static inline int
520 value_in_range_p (int64_t value, int low, int high)
521 {
522  return (value >= low && value <= high) ? 1 : 0;
523 }
524 
525 /* Return true if VALUE is a multiple of ALIGN. */
526 static inline int
528 {
529  return (value % align) == 0;
530 }
531 
532 /* A signed value fits in a field. */
533 static inline int
535 {
536  assert (width < 32);
537  if (width < sizeof (value) * 8)
538  {
539  int64_t lim = (int64_t)1 << (width - 1);
540  if (value >= -lim && value < lim)
541  return 1;
542  }
543  return 0;
544 }
545 
546 /* An unsigned value fits in a field. */
547 static inline int
549 {
550  assert (width < 32);
551  if (width < sizeof (value) * 8)
552  {
553  int64_t lim = (int64_t)1 << width;
554  if (value >= 0 && value < lim)
555  return 1;
556  }
557  return 0;
558 }
559 
560 /* Return 1 if OPERAND is SP or WSP. */
561 int
563 {
564  return ((aarch64_get_operand_class (operand->type)
567  && operand->reg.regno == 31);
568 }
569 
570 /* Return 1 if OPERAND is XZR or WZP. */
571 int
573 {
574  return ((aarch64_get_operand_class (operand->type)
577  && operand->reg.regno == 31);
578 }
579 
580 /* Return true if the operand *OPERAND that has the operand code
581  OPERAND->TYPE and been qualified by OPERAND->QUALIFIER can be also
582  qualified by the qualifier TARGET. */
583 
584 static inline int
587 {
588  switch (operand->qualifier)
589  {
590  case AARCH64_OPND_QLF_W:
592  return 1;
593  break;
594  case AARCH64_OPND_QLF_X:
596  return 1;
597  break;
599  if (target == AARCH64_OPND_QLF_W
601  return 1;
602  break;
603  case AARCH64_OPND_QLF_SP:
604  if (target == AARCH64_OPND_QLF_X
606  return 1;
607  break;
608  default:
609  break;
610  }
611 
612  return 0;
613 }
614 
615 /* Given qualifier sequence list QSEQ_LIST and the known qualifier KNOWN_QLF
616  for operand KNOWN_IDX, return the expected qualifier for operand IDX.
617 
618  Return NIL if more than one expected qualifiers are found. */
619 
622  int idx,
623  const aarch64_opnd_qualifier_t known_qlf,
624  int known_idx)
625 {
626  int i, saved_i;
627 
628  /* Special case.
629 
630  When the known qualifier is NIL, we have to assume that there is only
631  one qualifier sequence in the *QSEQ_LIST and return the corresponding
632  qualifier directly. One scenario is that for instruction
633  PRFM <prfop>, [<Xn|SP>, #:lo12:<symbol>]
634  which has only one possible valid qualifier sequence
635  NIL, S_D
636  the caller may pass NIL in KNOWN_QLF to obtain S_D so that it can
637  determine the correct relocation type (i.e. LDST64_LO12) for PRFM.
638 
639  Because the qualifier NIL has dual roles in the qualifier sequence:
640  it can mean no qualifier for the operand, or the qualifer sequence is
641  not in use (when all qualifiers in the sequence are NILs), we have to
642  handle this special case here. */
643  if (known_qlf == AARCH64_OPND_NIL)
644  {
645  assert (qseq_list[0][known_idx] == AARCH64_OPND_NIL);
646  return qseq_list[0][idx];
647  }
648 
649  for (i = 0, saved_i = -1; i < AARCH64_MAX_QLF_SEQ_NUM; i++)
650  {
651  if (qseq_list[i][known_idx] == known_qlf)
652  {
653  if (saved_i != -1)
654  /* More than one sequences are found to have KNOWN_QLF at
655  KNOWN_IDX. */
656  return AARCH64_OPND_NIL;
657  saved_i = i;
658  }
659  }
660 
661  return qseq_list[saved_i][idx];
662 }
663 
665 {
670 };
671 
672 /* Operand qualifier description. */
674 {
675  /* The usage of the three data fields depends on the qualifier kind. */
676  int data0;
677  int data1;
678  int data2;
679  /* Description. */
680  const char *desc;
681  /* Kind. */
683 };
684 
685 /* Indexed by the operand qualifier enumerators. */
687 {
688  {0, 0, 0, "NIL", OQK_NIL},
689 
690  /* Operand variant qualifiers.
691  First 3 fields:
692  element size, number of elements and common value for encoding. */
693 
694  {4, 1, 0x0, "w", OQK_OPD_VARIANT},
695  {8, 1, 0x1, "x", OQK_OPD_VARIANT},
696  {4, 1, 0x0, "wsp", OQK_OPD_VARIANT},
697  {8, 1, 0x1, "sp", OQK_OPD_VARIANT},
698 
699  {1, 1, 0x0, "b", OQK_OPD_VARIANT},
700  {2, 1, 0x1, "h", OQK_OPD_VARIANT},
701  {4, 1, 0x2, "s", OQK_OPD_VARIANT},
702  {8, 1, 0x3, "d", OQK_OPD_VARIANT},
703  {16, 1, 0x4, "q", OQK_OPD_VARIANT},
704  {1, 4, 0x0, "4b", OQK_OPD_VARIANT},
705 
706  {1, 4, 0x0, "4b", OQK_OPD_VARIANT},
707  {1, 8, 0x0, "8b", OQK_OPD_VARIANT},
708  {1, 16, 0x1, "16b", OQK_OPD_VARIANT},
709  {2, 2, 0x0, "2h", OQK_OPD_VARIANT},
710  {2, 4, 0x2, "4h", OQK_OPD_VARIANT},
711  {2, 8, 0x3, "8h", OQK_OPD_VARIANT},
712  {4, 2, 0x4, "2s", OQK_OPD_VARIANT},
713  {4, 4, 0x5, "4s", OQK_OPD_VARIANT},
714  {8, 1, 0x6, "1d", OQK_OPD_VARIANT},
715  {8, 2, 0x7, "2d", OQK_OPD_VARIANT},
716  {16, 1, 0x8, "1q", OQK_OPD_VARIANT},
717 
718  {0, 0, 0, "z", OQK_OPD_VARIANT},
719  {0, 0, 0, "m", OQK_OPD_VARIANT},
720 
721  /* Qualifiers constraining the value range.
722  First 3 fields:
723  Lower bound, higher bound, unused. */
724 
725  {0, 15, 0, "CR", OQK_VALUE_IN_RANGE},
726  {0, 7, 0, "imm_0_7" , OQK_VALUE_IN_RANGE},
727  {0, 15, 0, "imm_0_15", OQK_VALUE_IN_RANGE},
728  {0, 31, 0, "imm_0_31", OQK_VALUE_IN_RANGE},
729  {0, 63, 0, "imm_0_63", OQK_VALUE_IN_RANGE},
730  {1, 32, 0, "imm_1_32", OQK_VALUE_IN_RANGE},
731  {1, 64, 0, "imm_1_64", OQK_VALUE_IN_RANGE},
732 
733  /* Qualifiers for miscellaneous purpose.
734  First 3 fields:
735  unused, unused and unused. */
736 
737  {0, 0, 0, "lsl", 0},
738  {0, 0, 0, "msl", 0},
739 
740  {0, 0, 0, "retrieving", 0},
741 };
742 
743 static inline bfd_boolean
745 {
746  return (aarch64_opnd_qualifiers[qualifier].kind == OQK_OPD_VARIANT)
747  ? TRUE : FALSE;
748 }
749 
750 static inline bfd_boolean
752 {
753  return (aarch64_opnd_qualifiers[qualifier].kind == OQK_VALUE_IN_RANGE)
754  ? TRUE : FALSE;
755 }
756 
757 const char*
759 {
760  return aarch64_opnd_qualifiers[qualifier].desc;
761 }
762 
763 /* Given an operand qualifier, return the expected data element size
764  of a qualified operand. */
765 unsigned char
767 {
768  assert (operand_variant_qualifier_p (qualifier) == TRUE);
769  return aarch64_opnd_qualifiers[qualifier].data0;
770 }
771 
772 unsigned char
774 {
775  assert (operand_variant_qualifier_p (qualifier) == TRUE);
776  return aarch64_opnd_qualifiers[qualifier].data1;
777 }
778 
781 {
782  assert (operand_variant_qualifier_p (qualifier) == TRUE);
783  return aarch64_opnd_qualifiers[qualifier].data2;
784 }
785 
786 static int
788 {
790  return aarch64_opnd_qualifiers[qualifier].data0;
791 }
792 
793 static int
795 {
797  return aarch64_opnd_qualifiers[qualifier].data1;
798 }
799 
800 #ifdef DEBUG_AARCH64
801 void
802 aarch64_verbose (const char *str, ...)
803 {
804  va_list ap;
805  va_start (ap, str);
806  printf ("#### ");
807  vprintf (str, ap);
808  printf ("\n");
809  va_end (ap);
810 }
811 
812 static inline void
813 dump_qualifier_sequence (const aarch64_opnd_qualifier_t *qualifier)
814 {
815  int i;
816  printf ("#### ");
817  for (i = 0; i < AARCH64_MAX_OPND_NUM; i++, ++qualifier)
818  printf ("%s,", aarch64_get_qualifier_name (*qualifier));
819  printf ("\n");
820 }
821 
822 static void
823 dump_match_qualifiers (const struct aarch64_opnd_info *opnd,
824  const aarch64_opnd_qualifier_t *qualifier)
825 {
826  int i;
828 
829  aarch64_verbose ("dump_match_qualifiers:");
830  for (i = 0; i < AARCH64_MAX_OPND_NUM; i++)
831  curr[i] = opnd[i].qualifier;
832  dump_qualifier_sequence (curr);
833  aarch64_verbose ("against");
834  dump_qualifier_sequence (qualifier);
835 }
836 #endif /* DEBUG_AARCH64 */
837 
838 /* TODO improve this, we can have an extra field at the runtime to
839  store the number of operands rather than calculating it every time. */
840 
841 int
843 {
844  int i = 0;
845  const enum aarch64_opnd *opnds = opcode->operands;
846  while (opnds[i++] != AARCH64_OPND_NIL)
847  ;
848  --i;
849  assert (i >= 0 && i <= AARCH64_MAX_OPND_NUM);
850  return i;
851 }
852 
853 /* Find the best matched qualifier sequence in *QUALIFIERS_LIST for INST.
854  If succeeds, fill the found sequence in *RET, return 1; otherwise return 0.
855 
856  N.B. on the entry, it is very likely that only some operands in *INST
857  have had their qualifiers been established.
858 
859  If STOP_AT is not -1, the function will only try to match
860  the qualifier sequence for operands before and including the operand
861  of index STOP_AT; and on success *RET will only be filled with the first
862  (STOP_AT+1) qualifiers.
863 
864  A couple examples of the matching algorithm:
865 
866  X,W,NIL should match
867  X,W,NIL
868 
869  NIL,NIL should match
870  X ,NIL
871 
872  Apart from serving the main encoding routine, this can also be called
873  during or after the operand decoding. */
874 
875 int
877  const aarch64_opnd_qualifier_seq_t *qualifiers_list,
878  int stop_at, aarch64_opnd_qualifier_t *ret)
879 {
880  int found = 0;
881  int i, num_opnds;
882  const aarch64_opnd_qualifier_t *qualifiers;
883 
884  num_opnds = aarch64_num_of_operands (inst->opcode);
885  if (num_opnds == 0)
886  {
887  DEBUG_TRACE ("SUCCEED: no operand");
888  return 1;
889  }
890 
891  if (stop_at < 0 || stop_at >= num_opnds)
892  stop_at = num_opnds - 1;
893 
894  /* For each pattern. */
895  for (i = 0; i < AARCH64_MAX_QLF_SEQ_NUM; ++i, ++qualifiers_list)
896  {
897  int j;
898  qualifiers = *qualifiers_list;
899 
900  /* Start as positive. */
901  found = 1;
902 
903  DEBUG_TRACE ("%d", i);
904 #ifdef DEBUG_AARCH64
905  if (debug_dump)
906  dump_match_qualifiers (inst->operands, qualifiers);
907 #endif
908 
909  /* Most opcodes has much fewer patterns in the list.
910  First NIL qualifier indicates the end in the list. */
911  if (empty_qualifier_sequence_p (qualifiers) == TRUE)
912  {
913  DEBUG_TRACE_IF (i == 0, "SUCCEED: empty qualifier list");
914  if (i)
915  found = 0;
916  break;
917  }
918 
919  for (j = 0; j < num_opnds && j <= stop_at; ++j, ++qualifiers)
920  {
921  if (inst->operands[j].qualifier == AARCH64_OPND_QLF_NIL)
922  {
923  /* Either the operand does not have qualifier, or the qualifier
924  for the operand needs to be deduced from the qualifier
925  sequence.
926  In the latter case, any constraint checking related with
927  the obtained qualifier should be done later in
928  operand_general_constraint_met_p. */
929  continue;
930  }
931  else if (*qualifiers != inst->operands[j].qualifier)
932  {
933  /* Unless the target qualifier can also qualify the operand
934  (which has already had a non-nil qualifier), non-equal
935  qualifiers are generally un-matched. */
936  if (operand_also_qualified_p (inst->operands + j, *qualifiers))
937  continue;
938  else
939  {
940  found = 0;
941  break;
942  }
943  }
944  else
945  continue; /* Equal qualifiers are certainly matched. */
946  }
947 
948  /* Qualifiers established. */
949  if (found == 1)
950  break;
951  }
952 
953  if (found == 1)
954  {
955  /* Fill the result in *RET. */
956  int j;
957  qualifiers = *qualifiers_list;
958 
959  DEBUG_TRACE ("complete qualifiers using list %d", i);
960 #ifdef DEBUG_AARCH64
961  if (debug_dump)
962  dump_qualifier_sequence (qualifiers);
963 #endif
964 
965  for (j = 0; j <= stop_at; ++j, ++qualifiers)
966  ret[j] = *qualifiers;
967  for (; j < AARCH64_MAX_OPND_NUM; ++j)
968  ret[j] = AARCH64_OPND_QLF_NIL;
969 
970  DEBUG_TRACE ("SUCCESS");
971  return 1;
972  }
973 
974  DEBUG_TRACE ("FAIL");
975  return 0;
976 }
977 
978 /* Operand qualifier matching and resolving.
979 
980  Return 1 if the operand qualifier(s) in *INST match one of the qualifier
981  sequences in INST->OPCODE->qualifiers_list; otherwise return 0.
982 
983  if UPDATE_P == TRUE, update the qualifier(s) in *INST after the matching
984  succeeds. */
985 
986 static int
988 {
989  int i, nops;
990  aarch64_opnd_qualifier_seq_t qualifiers = {0};
991 
992  if (!aarch64_find_best_match (inst, inst->opcode->qualifiers_list, -1,
993  qualifiers))
994  {
995  DEBUG_TRACE ("matching FAIL");
996  return 0;
997  }
998 
999  if (inst->opcode->flags & F_STRICT)
1000  {
1001  /* Require an exact qualifier match, even for NIL qualifiers. */
1002  nops = aarch64_num_of_operands (inst->opcode);
1003  for (i = 0; i < nops; ++i)
1004  if (inst->operands[i].qualifier != qualifiers[i])
1005  return FALSE;
1006  }
1007 
1008  /* Update the qualifiers. */
1009  if (update_p == TRUE)
1010  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
1011  {
1012  if (inst->opcode->operands[i] == AARCH64_OPND_NIL)
1013  break;
1014  DEBUG_TRACE_IF (inst->operands[i].qualifier != qualifiers[i],
1015  "update %s with %s for operand %d",
1017  aarch64_get_qualifier_name (qualifiers[i]), i);
1018  inst->operands[i].qualifier = qualifiers[i];
1019  }
1020 
1021  DEBUG_TRACE ("matching SUCCESS");
1022  return 1;
1023 }
1024 
1025 /* Return TRUE if VALUE is a wide constant that can be moved into a general
1026  register by MOVZ.
1027 
1028  IS32 indicates whether value is a 32-bit immediate or not.
1029  If SHIFT_AMOUNT is not NULL, on the return of TRUE, the logical left shift
1030  amount will be returned in *SHIFT_AMOUNT. */
1031 
1033 aarch64_wide_constant_p (int64_t value, int is32, unsigned int *shift_amount)
1034 {
1035  int amount;
1036 
1037  DEBUG_TRACE ("enter with 0x%" PRIx64 "(%" PRIi64 ")", value, value);
1038 
1039  if (is32)
1040  {
1041  /* Allow all zeros or all ones in top 32-bits, so that
1042  32-bit constant expressions like ~0x80000000 are
1043  permitted. */
1044  uint64_t ext = value;
1045  if (ext >> 32 != 0 && ext >> 32 != (uint64_t) 0xffffffff)
1046  /* Immediate out of range. */
1047  return FALSE;
1048  value &= (int64_t) 0xffffffff;
1049  }
1050 
1051  /* first, try movz then movn */
1052  amount = -1;
1053  if ((value & ((int64_t) 0xffff << 0)) == value)
1054  amount = 0;
1055  else if ((value & ((int64_t) 0xffff << 16)) == value)
1056  amount = 16;
1057  else if (!is32 && (value & ((int64_t) 0xffff << 32)) == value)
1058  amount = 32;
1059  else if (!is32 && (value & ((int64_t) 0xffff << 48)) == value)
1060  amount = 48;
1061 
1062  if (amount == -1)
1063  {
1064  DEBUG_TRACE ("exit FALSE with 0x%" PRIx64 "(%" PRIi64 ")", value, value);
1065  return FALSE;
1066  }
1067 
1068  if (shift_amount != NULL)
1069  *shift_amount = amount;
1070 
1071  DEBUG_TRACE ("exit TRUE with amount %d", amount);
1072 
1073  return TRUE;
1074 }
1075 
1076 /* Build the accepted values for immediate logical SIMD instructions.
1077 
1078  The standard encodings of the immediate value are:
1079  N imms immr SIMD size R S
1080  1 ssssss rrrrrr 64 UInt(rrrrrr) UInt(ssssss)
1081  0 0sssss 0rrrrr 32 UInt(rrrrr) UInt(sssss)
1082  0 10ssss 00rrrr 16 UInt(rrrr) UInt(ssss)
1083  0 110sss 000rrr 8 UInt(rrr) UInt(sss)
1084  0 1110ss 0000rr 4 UInt(rr) UInt(ss)
1085  0 11110s 00000r 2 UInt(r) UInt(s)
1086  where all-ones value of S is reserved.
1087 
1088  Let's call E the SIMD size.
1089 
1090  The immediate value is: S+1 bits '1' rotated to the right by R.
1091 
1092  The total of valid encodings is 64*63 + 32*31 + ... + 2*1 = 5334
1093  (remember S != E - 1). */
1094 
1095 #define TOTAL_IMM_NB 5334
1096 
1097 typedef struct
1098 {
1102 
1104 
1105 static int
1106 simd_imm_encoding_cmp(const void *i1, const void *i2)
1107 {
1108  const simd_imm_encoding *imm1 = (const simd_imm_encoding *)i1;
1109  const simd_imm_encoding *imm2 = (const simd_imm_encoding *)i2;
1110 
1111  if (imm1->imm < imm2->imm)
1112  return -1;
1113  if (imm1->imm > imm2->imm)
1114  return +1;
1115  return 0;
1116 }
1117 
1118 /* immediate bitfield standard encoding
1119  imm13<12> imm13<5:0> imm13<11:6> SIMD size R S
1120  1 ssssss rrrrrr 64 rrrrrr ssssss
1121  0 0sssss 0rrrrr 32 rrrrr sssss
1122  0 10ssss 00rrrr 16 rrrr ssss
1123  0 110sss 000rrr 8 rrr sss
1124  0 1110ss 0000rr 4 rr ss
1125  0 11110s 00000r 2 r s */
1126 static inline int
1128 {
1129  return (is64 << 12) | (r << 6) | s;
1130 }
1131 
1132 static void
1134 {
1135  uint32_t log_e, e, s, r, s_mask;
1136  uint64_t mask, imm;
1137  int nb_imms;
1138  int is64;
1139 
1140  nb_imms = 0;
1141  for (log_e = 1; log_e <= 6; log_e++)
1142  {
1143  /* Get element size. */
1144  e = 1u << log_e;
1145  if (log_e == 6)
1146  {
1147  is64 = 1;
1148  mask = 0xffffffffffffffffull;
1149  s_mask = 0;
1150  }
1151  else
1152  {
1153  is64 = 0;
1154  mask = (1ull << e) - 1;
1155  /* log_e s_mask
1156  1 ((1 << 4) - 1) << 2 = 111100
1157  2 ((1 << 3) - 1) << 3 = 111000
1158  3 ((1 << 2) - 1) << 4 = 110000
1159  4 ((1 << 1) - 1) << 5 = 100000
1160  5 ((1 << 0) - 1) << 6 = 000000 */
1161  s_mask = ((1u << (5 - log_e)) - 1) << (log_e + 1);
1162  }
1163  for (s = 0; s < e - 1; s++)
1164  for (r = 0; r < e; r++)
1165  {
1166  /* s+1 consecutive bits to 1 (s < 63) */
1167  imm = (1ull << (s + 1)) - 1;
1168  /* rotate right by r */
1169  if (r != 0)
1170  imm = (imm >> r) | ((imm << (e - r)) & mask);
1171  /* replicate the constant depending on SIMD size */
1172  switch (log_e)
1173  {
1174  case 1: imm = (imm << 2) | imm;
1175  /* Fall through. */
1176  case 2: imm = (imm << 4) | imm;
1177  /* Fall through. */
1178  case 3: imm = (imm << 8) | imm;
1179  /* Fall through. */
1180  case 4: imm = (imm << 16) | imm;
1181  /* Fall through. */
1182  case 5: imm = (imm << 32) | imm;
1183  /* Fall through. */
1184  case 6: break;
1185  default: abort ();
1186  }
1187  simd_immediates[nb_imms].imm = imm;
1188  simd_immediates[nb_imms].encoding =
1189  encode_immediate_bitfield(is64, s | s_mask, r);
1190  nb_imms++;
1191  }
1192  }
1193  assert (nb_imms == TOTAL_IMM_NB);
1194  qsort(simd_immediates, nb_imms,
1196 }
1197 
1198 /* Return TRUE if VALUE is a valid logical immediate, i.e. bitmask, that can
1199  be accepted by logical (immediate) instructions
1200  e.g. ORR <Xd|SP>, <Xn>, #<imm>.
1201 
1202  ESIZE is the number of bytes in the decoded immediate value.
1203  If ENCODING is not NULL, on the return of TRUE, the standard encoding for
1204  VALUE will be returned in *ENCODING. */
1205 
1208 {
1209  simd_imm_encoding imm_enc;
1210  const simd_imm_encoding *imm_encoding;
1211  static bfd_boolean initialized = FALSE;
1212  uint64_t upper;
1213  int i;
1214 
1215  DEBUG_TRACE ("enter with 0x%" PRIx64 "(%" PRIi64 "), esize: %d", value,
1216  value, esize);
1217 
1218  if (!initialized)
1219  {
1221  initialized = TRUE;
1222  }
1223 
1224  /* Allow all zeros or all ones in top bits, so that
1225  constant expressions like ~1 are permitted. */
1226  upper = (uint64_t) -1 << (esize * 4) << (esize * 4);
1227  if ((value & ~upper) != value && (value | upper) != value)
1228  return FALSE;
1229 
1230  /* Replicate to a full 64-bit value. */
1231  value &= ~upper;
1232  for (i = esize * 8; i < 64; i *= 2)
1233  value |= (value << i);
1234 
1235  imm_enc.imm = value;
1236  imm_encoding = (const simd_imm_encoding *)
1237  bsearch(&imm_enc, simd_immediates, TOTAL_IMM_NB,
1239  if (imm_encoding == NULL)
1240  {
1241  DEBUG_TRACE ("exit with FALSE");
1242  return FALSE;
1243  }
1244  if (encoding != NULL)
1245  *encoding = imm_encoding->encoding;
1246  DEBUG_TRACE ("exit with TRUE");
1247  return TRUE;
1248 }
1249 
1250 /* If 64-bit immediate IMM is in the format of
1251  "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffgggggggghhhhhhhh",
1252  where a, b, c, d, e, f, g and h are independently 0 or 1, return an integer
1253  of value "abcdefgh". Otherwise return -1. */
1254 int
1256 {
1257  int i, ret;
1258  uint32_t byte;
1259 
1260  ret = 0;
1261  for (i = 0; i < 8; i++)
1262  {
1263  byte = (imm >> (8 * i)) & 0xff;
1264  if (byte == 0xff)
1265  ret |= 1 << i;
1266  else if (byte != 0x00)
1267  return -1;
1268  }
1269  return ret;
1270 }
1271 
1272 /* Utility inline functions for operand_general_constraint_met_p. */
1273 
1274 static inline void
1277  const char* error)
1278 {
1279  if (mismatch_detail == NULL)
1280  return;
1281  mismatch_detail->kind = kind;
1282  mismatch_detail->index = idx;
1283  mismatch_detail->error = error;
1284 }
1285 
1286 static inline void
1288  const char* error)
1289 {
1290  if (mismatch_detail == NULL)
1291  return;
1292  set_error (mismatch_detail, AARCH64_OPDE_SYNTAX_ERROR, idx, error);
1293 }
1294 
1295 static inline void
1297  int idx, int lower_bound, int upper_bound,
1298  const char* error)
1299 {
1300  if (mismatch_detail == NULL)
1301  return;
1302  set_error (mismatch_detail, AARCH64_OPDE_OUT_OF_RANGE, idx, error);
1303  mismatch_detail->data[0] = lower_bound;
1304  mismatch_detail->data[1] = upper_bound;
1305 }
1306 
1307 static inline void
1309  int idx, int lower_bound, int upper_bound)
1310 {
1311  if (mismatch_detail == NULL)
1312  return;
1313  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1314  _("immediate value"));
1315 }
1316 
1317 static inline void
1319  int idx, int lower_bound, int upper_bound)
1320 {
1321  if (mismatch_detail == NULL)
1322  return;
1323  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1324  _("immediate offset"));
1325 }
1326 
1327 static inline void
1329  int idx, int lower_bound, int upper_bound)
1330 {
1331  if (mismatch_detail == NULL)
1332  return;
1333  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1334  _("register number"));
1335 }
1336 
1337 static inline void
1339  int idx, int lower_bound, int upper_bound)
1340 {
1341  if (mismatch_detail == NULL)
1342  return;
1343  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1344  _("register element index"));
1345 }
1346 
1347 static inline void
1349  int idx, int lower_bound, int upper_bound)
1350 {
1351  if (mismatch_detail == NULL)
1352  return;
1353  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1354  _("shift amount"));
1355 }
1356 
1357 /* Report that the MUL modifier in operand IDX should be in the range
1358  [LOWER_BOUND, UPPER_BOUND]. */
1359 static inline void
1361  int idx, int lower_bound, int upper_bound)
1362 {
1363  if (mismatch_detail == NULL)
1364  return;
1365  set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
1366  _("multiplier"));
1367 }
1368 
1369 static inline void
1371  int alignment)
1372 {
1373  if (mismatch_detail == NULL)
1374  return;
1375  set_error (mismatch_detail, AARCH64_OPDE_UNALIGNED, idx, NULL);
1376  mismatch_detail->data[0] = alignment;
1377 }
1378 
1379 static inline void
1381  int expected_num)
1382 {
1383  if (mismatch_detail == NULL)
1384  return;
1385  set_error (mismatch_detail, AARCH64_OPDE_REG_LIST, idx, NULL);
1386  mismatch_detail->data[0] = expected_num;
1387 }
1388 
1389 static inline void
1391  const char* error)
1392 {
1393  if (mismatch_detail == NULL)
1394  return;
1395  set_error (mismatch_detail, AARCH64_OPDE_OTHER_ERROR, idx, error);
1396 }
1397 
1398 /* General constraint checking based on operand code.
1399 
1400  Return 1 if OPNDS[IDX] meets the general constraint of operand code TYPE
1401  as the IDXth operand of opcode OPCODE. Otherwise return 0.
1402 
1403  This function has to be called after the qualifiers for all operands
1404  have been resolved.
1405 
1406  Mismatching error message is returned in *MISMATCH_DETAIL upon request,
1407  i.e. when MISMATCH_DETAIL is non-NULL. This avoids the generation
1408  of error message during the disassembling where error message is not
1409  wanted. We avoid the dynamic construction of strings of error messages
1410  here (i.e. in libopcodes), as it is costly and complicated; instead, we
1411  use a combination of error code, static string and some integer data to
1412  represent an error. */
1413 
1414 static int
1416  enum aarch64_opnd type,
1417  const aarch64_opcode *opcode,
1418  aarch64_operand_error *mismatch_detail)
1419 {
1420  unsigned num, modifiers, shift;
1421  unsigned char size;
1422  int64_t imm, min_value, max_value;
1423  uint64_t uvalue, mask;
1424  const aarch64_opnd_info *opnd = opnds + idx;
1425  aarch64_opnd_qualifier_t qualifier = opnd->qualifier;
1426 
1427  assert (opcode->operands[idx] == opnd->type && opnd->type == type);
1428 
1429  switch (aarch64_operands[type].op_class)
1430  {
1432  /* Check pair reg constraints for cas* instructions. */
1433  if (type == AARCH64_OPND_PAIRREG)
1434  {
1435  assert (idx == 1 || idx == 3);
1436  if (opnds[idx - 1].reg.regno % 2 != 0)
1437  {
1438  set_syntax_error (mismatch_detail, idx - 1,
1439  _("reg pair must start from even reg"));
1440  return 0;
1441  }
1442  if (opnds[idx].reg.regno != opnds[idx - 1].reg.regno + 1)
1443  {
1444  set_syntax_error (mismatch_detail, idx,
1445  _("reg pair must be contiguous"));
1446  return 0;
1447  }
1448  break;
1449  }
1450 
1451  /* <Xt> may be optional in some IC and TLBI instructions. */
1452  if (type == AARCH64_OPND_Rt_SYS)
1453  {
1454  assert (idx == 1 && (aarch64_get_operand_class (opnds[0].type)
1456  if (opnds[1].present
1457  && !aarch64_sys_ins_reg_has_xt (opnds[0].sysins_op))
1458  {
1459  set_other_error (mismatch_detail, idx, _("extraneous register"));
1460  return 0;
1461  }
1462  if (!opnds[1].present
1463  && aarch64_sys_ins_reg_has_xt (opnds[0].sysins_op))
1464  {
1465  set_other_error (mismatch_detail, idx, _("missing register"));
1466  return 0;
1467  }
1468  }
1469  switch (qualifier)
1470  {
1471  case AARCH64_OPND_QLF_WSP:
1472  case AARCH64_OPND_QLF_SP:
1473  if (!aarch64_stack_pointer_p (opnd))
1474  {
1475  set_other_error (mismatch_detail, idx,
1476  _("stack pointer register expected"));
1477  return 0;
1478  }
1479  break;
1480  default:
1481  break;
1482  }
1483  break;
1484 
1486  switch (type)
1487  {
1493  mask = (1 << shift) - 1;
1494  if (opnd->reg.regno > mask)
1495  {
1496  assert (mask == 7 || mask == 15);
1497  set_other_error (mismatch_detail, idx,
1498  mask == 15
1499  ? _("z0-z15 expected")
1500  : _("z0-z7 expected"));
1501  return 0;
1502  }
1503  mask = (1 << (size - shift)) - 1;
1504  if (!value_in_range_p (opnd->reglane.index, 0, mask))
1505  {
1506  set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, mask);
1507  return 0;
1508  }
1509  break;
1510 
1513  if (!value_in_range_p (opnd->reglane.index, 0, 64 / size - 1))
1514  {
1515  set_elem_idx_out_of_range_error (mismatch_detail, idx,
1516  0, 64 / size - 1);
1517  return 0;
1518  }
1519  break;
1520 
1521  case AARCH64_OPND_SVE_ZnxN:
1522  case AARCH64_OPND_SVE_ZtxN:
1523  if (opnd->reglist.num_regs != get_opcode_dependent_value (opcode))
1524  {
1525  set_other_error (mismatch_detail, idx,
1526  _("invalid register list"));
1527  return 0;
1528  }
1529  break;
1530 
1531  default:
1532  break;
1533  }
1534  break;
1535 
1537  if (opnd->reg.regno >= 8
1539  {
1540  set_other_error (mismatch_detail, idx, _("p0-p7 expected"));
1541  return 0;
1542  }
1543  break;
1544 
1546  if (type == AARCH64_OPND_COND1
1547  && (opnds[idx].cond->value & 0xe) == 0xe)
1548  {
1549  /* Not allow AL or NV. */
1550  set_syntax_error (mismatch_detail, idx, NULL);
1551  }
1552  break;
1553 
1555  /* Check writeback. */
1556  switch (opcode->iclass)
1557  {
1558  case ldst_pos:
1559  case ldst_unscaled:
1560  case ldstnapair_offs:
1561  case ldstpair_off:
1562  case ldst_unpriv:
1563  if (opnd->addr.writeback == 1)
1564  {
1565  set_syntax_error (mismatch_detail, idx,
1566  _("unexpected address writeback"));
1567  return 0;
1568  }
1569  break;
1570  case ldst_imm10:
1571  if (opnd->addr.writeback == 1 && opnd->addr.preind != 1)
1572  {
1573  set_syntax_error (mismatch_detail, idx,
1574  _("unexpected address writeback"));
1575  return 0;
1576  }
1577  break;
1578  case ldst_imm9:
1579  case ldstpair_indexed:
1580  case asisdlsep:
1581  case asisdlsop:
1582  if (opnd->addr.writeback == 0)
1583  {
1584  set_syntax_error (mismatch_detail, idx,
1585  _("address writeback expected"));
1586  return 0;
1587  }
1588  break;
1589  default:
1590  assert (opnd->addr.writeback == 0);
1591  break;
1592  }
1593  switch (type)
1594  {
1596  /* Scaled signed 7 bits immediate offset. */
1597  /* Get the size of the data element that is accessed, which may be
1598  different from that of the source register size,
1599  e.g. in strb/ldrb. */
1601  if (!value_in_range_p (opnd->addr.offset.imm, -64 * size, 63 * size))
1602  {
1603  set_offset_out_of_range_error (mismatch_detail, idx,
1604  -64 * size, 63 * size);
1605  return 0;
1606  }
1607  if (!value_aligned_p (opnd->addr.offset.imm, size))
1608  {
1609  set_unaligned_error (mismatch_detail, idx, size);
1610  return 0;
1611  }
1612  break;
1615  /* Unscaled signed 9 bits immediate offset. */
1616  if (!value_in_range_p (opnd->addr.offset.imm, -256, 255))
1617  {
1618  set_offset_out_of_range_error (mismatch_detail, idx, -256, 255);
1619  return 0;
1620  }
1621  break;
1622 
1624  /* Unscaled signed 9 bits immediate offset, which has to be negative
1625  or unaligned. */
1626  size = aarch64_get_qualifier_esize (qualifier);
1627  if ((value_in_range_p (opnd->addr.offset.imm, 0, 255)
1628  && !value_aligned_p (opnd->addr.offset.imm, size))
1629  || value_in_range_p (opnd->addr.offset.imm, -256, -1))
1630  return 1;
1631  set_other_error (mismatch_detail, idx,
1632  _("negative or unaligned offset expected"));
1633  return 0;
1634 
1636  /* Scaled signed 10 bits immediate offset. */
1637  if (!value_in_range_p (opnd->addr.offset.imm, -4096, 4088))
1638  {
1639  set_offset_out_of_range_error (mismatch_detail, idx, -4096, 4088);
1640  return 0;
1641  }
1642  if (!value_aligned_p (opnd->addr.offset.imm, 8))
1643  {
1644  set_unaligned_error (mismatch_detail, idx, 8);
1645  return 0;
1646  }
1647  break;
1648 
1650  /* AdvSIMD load/store multiple structures, post-index. */
1651  assert (idx == 1);
1652  if (opnd->addr.offset.is_reg)
1653  {
1654  if (value_in_range_p (opnd->addr.offset.regno, 0, 30))
1655  return 1;
1656  else
1657  {
1658  set_other_error (mismatch_detail, idx,
1659  _("invalid register offset"));
1660  return 0;
1661  }
1662  }
1663  else
1664  {
1665  const aarch64_opnd_info *prev = &opnds[idx-1];
1666  unsigned num_bytes; /* total number of bytes transferred. */
1667  /* The opcode dependent area stores the number of elements in
1668  each structure to be loaded/stored. */
1669  int is_ld1r = get_opcode_dependent_value (opcode) == 1;
1670  if (opcode->operands[0] == AARCH64_OPND_LVt_AL)
1671  /* Special handling of loading single structure to all lane. */
1672  num_bytes = (is_ld1r ? 1 : prev->reglist.num_regs)
1674  else
1675  num_bytes = prev->reglist.num_regs
1678  if ((int) num_bytes != opnd->addr.offset.imm)
1679  {
1680  set_other_error (mismatch_detail, idx,
1681  _("invalid post-increment amount"));
1682  return 0;
1683  }
1684  }
1685  break;
1686 
1688  /* Get the size of the data element that is accessed, which may be
1689  different from that of the source register size,
1690  e.g. in strb/ldrb. */
1692  /* It is either no shift or shift by the binary logarithm of SIZE. */
1693  if (opnd->shifter.amount != 0
1694  && opnd->shifter.amount != (int)get_logsz (size))
1695  {
1696  set_other_error (mismatch_detail, idx,
1697  _("invalid shift amount"));
1698  return 0;
1699  }
1700  /* Only UXTW, LSL, SXTW and SXTX are the accepted extending
1701  operators. */
1702  switch (opnd->shifter.kind)
1703  {
1704  case AARCH64_MOD_UXTW:
1705  case AARCH64_MOD_LSL:
1706  case AARCH64_MOD_SXTW:
1707  case AARCH64_MOD_SXTX: break;
1708  default:
1709  set_other_error (mismatch_detail, idx,
1710  _("invalid extend/shift operator"));
1711  return 0;
1712  }
1713  break;
1714 
1716  imm = opnd->addr.offset.imm;
1717  /* Get the size of the data element that is accessed, which may be
1718  different from that of the source register size,
1719  e.g. in strb/ldrb. */
1720  size = aarch64_get_qualifier_esize (qualifier);
1721  if (!value_in_range_p (imm, 0, 4095 * size))
1722  {
1723  set_offset_out_of_range_error (mismatch_detail, idx,
1724  0, 4095 * size);
1725  return 0;
1726  }
1727  if (!value_aligned_p (imm, size))
1728  {
1729  set_unaligned_error (mismatch_detail, idx, size);
1730  return 0;
1731  }
1732  break;
1733 
1738  imm = opnd->imm.value;
1740  {
1741  /* The offset value in a PC-relative branch instruction is alway
1742  4-byte aligned and is encoded without the lowest 2 bits. */
1743  if (!value_aligned_p (imm, 4))
1744  {
1745  set_unaligned_error (mismatch_detail, idx, 4);
1746  return 0;
1747  }
1748  /* Right shift by 2 so that we can carry out the following check
1749  canonically. */
1750  imm >>= 2;
1751  }
1754  {
1755  set_other_error (mismatch_detail, idx,
1756  _("immediate out of range"));
1757  return 0;
1758  }
1759  break;
1760 
1765  min_value = -8;
1766  max_value = 7;
1767  sve_imm_offset_vl:
1768  assert (!opnd->addr.offset.is_reg);
1769  assert (opnd->addr.preind);
1771  min_value *= num;
1772  max_value *= num;
1773  if ((opnd->addr.offset.imm != 0 && !opnd->shifter.operator_present)
1774  || (opnd->shifter.operator_present
1775  && opnd->shifter.kind != AARCH64_MOD_MUL_VL))
1776  {
1777  set_other_error (mismatch_detail, idx,
1778  _("invalid addressing mode"));
1779  return 0;
1780  }
1781  if (!value_in_range_p (opnd->addr.offset.imm, min_value, max_value))
1782  {
1783  set_offset_out_of_range_error (mismatch_detail, idx,
1784  min_value, max_value);
1785  return 0;
1786  }
1787  if (!value_aligned_p (opnd->addr.offset.imm, num))
1788  {
1789  set_unaligned_error (mismatch_detail, idx, num);
1790  return 0;
1791  }
1792  break;
1793 
1795  min_value = -32;
1796  max_value = 31;
1797  goto sve_imm_offset_vl;
1798 
1800  min_value = -256;
1801  max_value = 255;
1802  goto sve_imm_offset_vl;
1803 
1808  min_value = 0;
1809  max_value = 63;
1810  sve_imm_offset:
1811  assert (!opnd->addr.offset.is_reg);
1812  assert (opnd->addr.preind);
1814  min_value *= num;
1815  max_value *= num;
1816  if (opnd->shifter.operator_present
1817  || opnd->shifter.amount_present)
1818  {
1819  set_other_error (mismatch_detail, idx,
1820  _("invalid addressing mode"));
1821  return 0;
1822  }
1823  if (!value_in_range_p (opnd->addr.offset.imm, min_value, max_value))
1824  {
1825  set_offset_out_of_range_error (mismatch_detail, idx,
1826  min_value, max_value);
1827  return 0;
1828  }
1829  if (!value_aligned_p (opnd->addr.offset.imm, num))
1830  {
1831  set_unaligned_error (mismatch_detail, idx, num);
1832  return 0;
1833  }
1834  break;
1835 
1837  min_value = -8;
1838  max_value = 7;
1839  goto sve_imm_offset;
1840 
1854  modifiers = 1 << AARCH64_MOD_LSL;
1855  sve_rr_operand:
1856  assert (opnd->addr.offset.is_reg);
1857  assert (opnd->addr.preind);
1858  if ((aarch64_operands[type].flags & OPD_F_NO_ZR) != 0
1859  && opnd->addr.offset.regno == 31)
1860  {
1861  set_other_error (mismatch_detail, idx,
1862  _("index register xzr is not allowed"));
1863  return 0;
1864  }
1865  if (((1 << opnd->shifter.kind) & modifiers) == 0
1866  || (opnd->shifter.amount
1868  {
1869  set_other_error (mismatch_detail, idx,
1870  _("invalid addressing mode"));
1871  return 0;
1872  }
1873  break;
1874 
1883  modifiers = (1 << AARCH64_MOD_SXTW) | (1 << AARCH64_MOD_UXTW);
1884  goto sve_rr_operand;
1885 
1890  min_value = 0;
1891  max_value = 31;
1892  goto sve_imm_offset;
1893 
1895  modifiers = 1 << AARCH64_MOD_LSL;
1896  sve_zz_operand:
1897  assert (opnd->addr.offset.is_reg);
1898  assert (opnd->addr.preind);
1899  if (((1 << opnd->shifter.kind) & modifiers) == 0
1900  || opnd->shifter.amount < 0
1901  || opnd->shifter.amount > 3)
1902  {
1903  set_other_error (mismatch_detail, idx,
1904  _("invalid addressing mode"));
1905  return 0;
1906  }
1907  break;
1908 
1910  modifiers = (1 << AARCH64_MOD_SXTW);
1911  goto sve_zz_operand;
1912 
1914  modifiers = 1 << AARCH64_MOD_UXTW;
1915  goto sve_zz_operand;
1916 
1917  default:
1918  break;
1919  }
1920  break;
1921 
1923  if (type == AARCH64_OPND_LEt)
1924  {
1925  /* Get the upper bound for the element index. */
1926  num = 16 / aarch64_get_qualifier_esize (qualifier) - 1;
1927  if (!value_in_range_p (opnd->reglist.index, 0, num))
1928  {
1929  set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, num);
1930  return 0;
1931  }
1932  }
1933  /* The opcode dependent area stores the number of elements in
1934  each structure to be loaded/stored. */
1935  num = get_opcode_dependent_value (opcode);
1936  switch (type)
1937  {
1938  case AARCH64_OPND_LVt:
1939  assert (num >= 1 && num <= 4);
1940  /* Unless LD1/ST1, the number of registers should be equal to that
1941  of the structure elements. */
1942  if (num != 1 && opnd->reglist.num_regs != num)
1943  {
1944  set_reg_list_error (mismatch_detail, idx, num);
1945  return 0;
1946  }
1947  break;
1948  case AARCH64_OPND_LVt_AL:
1949  case AARCH64_OPND_LEt:
1950  assert (num >= 1 && num <= 4);
1951  /* The number of registers should be equal to that of the structure
1952  elements. */
1953  if (opnd->reglist.num_regs != num)
1954  {
1955  set_reg_list_error (mismatch_detail, idx, num);
1956  return 0;
1957  }
1958  break;
1959  default:
1960  break;
1961  }
1962  break;
1963 
1965  /* Constraint check on immediate operand. */
1966  imm = opnd->imm.value;
1967  /* E.g. imm_0_31 constrains value to be 0..31. */
1969  && !value_in_range_p (imm, get_lower_bound (qualifier),
1970  get_upper_bound (qualifier)))
1971  {
1972  set_imm_out_of_range_error (mismatch_detail, idx,
1973  get_lower_bound (qualifier),
1974  get_upper_bound (qualifier));
1975  return 0;
1976  }
1977 
1978  switch (type)
1979  {
1980  case AARCH64_OPND_AIMM:
1981  if (opnd->shifter.kind != AARCH64_MOD_LSL)
1982  {
1983  set_other_error (mismatch_detail, idx,
1984  _("invalid shift operator"));
1985  return 0;
1986  }
1987  if (opnd->shifter.amount != 0 && opnd->shifter.amount != 12)
1988  {
1989  set_other_error (mismatch_detail, idx,
1990  _("shift amount must be 0 or 12"));
1991  return 0;
1992  }
1993  if (!value_fit_unsigned_field_p (opnd->imm.value, 12))
1994  {
1995  set_other_error (mismatch_detail, idx,
1996  _("immediate out of range"));
1997  return 0;
1998  }
1999  break;
2000 
2001  case AARCH64_OPND_HALF:
2002  assert (idx == 1 && opnds[0].type == AARCH64_OPND_Rd);
2003  if (opnd->shifter.kind != AARCH64_MOD_LSL)
2004  {
2005  set_other_error (mismatch_detail, idx,
2006  _("invalid shift operator"));
2007  return 0;
2008  }
2009  size = aarch64_get_qualifier_esize (opnds[0].qualifier);
2010  if (!value_aligned_p (opnd->shifter.amount, 16))
2011  {
2012  set_other_error (mismatch_detail, idx,
2013  _("shift amount must be a multiple of 16"));
2014  return 0;
2015  }
2016  if (!value_in_range_p (opnd->shifter.amount, 0, size * 8 - 16))
2017  {
2018  set_sft_amount_out_of_range_error (mismatch_detail, idx,
2019  0, size * 8 - 16);
2020  return 0;
2021  }
2022  if (opnd->imm.value < 0)
2023  {
2024  set_other_error (mismatch_detail, idx,
2025  _("negative immediate value not allowed"));
2026  return 0;
2027  }
2028  if (!value_fit_unsigned_field_p (opnd->imm.value, 16))
2029  {
2030  set_other_error (mismatch_detail, idx,
2031  _("immediate out of range"));
2032  return 0;
2033  }
2034  break;
2035 
2036  case AARCH64_OPND_IMM_MOV:
2037  {
2038  int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2039  imm = opnd->imm.value;
2040  assert (idx == 1);
2041  switch (opcode->op)
2042  {
2043  case OP_MOV_IMM_WIDEN:
2044  imm = ~imm;
2045  /* Fall through. */
2046  case OP_MOV_IMM_WIDE:
2047  if (!aarch64_wide_constant_p (imm, esize == 4, NULL))
2048  {
2049  set_other_error (mismatch_detail, idx,
2050  _("immediate out of range"));
2051  return 0;
2052  }
2053  break;
2054  case OP_MOV_IMM_LOG:
2055  if (!aarch64_logical_immediate_p (imm, esize, NULL))
2056  {
2057  set_other_error (mismatch_detail, idx,
2058  _("immediate out of range"));
2059  return 0;
2060  }
2061  break;
2062  default:
2063  assert (0);
2064  return 0;
2065  }
2066  }
2067  break;
2068 
2069  case AARCH64_OPND_NZCV:
2070  case AARCH64_OPND_CCMP_IMM:
2072  case AARCH64_OPND_UIMM4:
2073  case AARCH64_OPND_UIMM7:
2081  assert (size < 32);
2082  if (!value_fit_unsigned_field_p (opnd->imm.value, size))
2083  {
2084  set_imm_out_of_range_error (mismatch_detail, idx, 0,
2085  (1 << size) - 1);
2086  return 0;
2087  }
2088  break;
2089 
2090  case AARCH64_OPND_SIMM5:
2096  assert (size < 32);
2097  if (!value_fit_signed_field_p (opnd->imm.value, size))
2098  {
2099  set_imm_out_of_range_error (mismatch_detail, idx,
2100  -(1 << (size - 1)),
2101  (1 << (size - 1)) - 1);
2102  return 0;
2103  }
2104  break;
2105 
2106  case AARCH64_OPND_WIDTH:
2107  assert (idx > 1 && opnds[idx-1].type == AARCH64_OPND_IMM
2108  && opnds[0].type == AARCH64_OPND_Rd);
2109  size = get_upper_bound (qualifier);
2110  if (opnd->imm.value + opnds[idx-1].imm.value > size)
2111  /* lsb+width <= reg.size */
2112  {
2113  set_imm_out_of_range_error (mismatch_detail, idx, 1,
2114  size - opnds[idx-1].imm.value);
2115  return 0;
2116  }
2117  break;
2118 
2119  case AARCH64_OPND_LIMM:
2120  case AARCH64_OPND_SVE_LIMM:
2121  {
2122  int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2123  uint64_t uimm = opnd->imm.value;
2124  if (opcode->op == OP_BIC)
2125  uimm = ~uimm;
2126  if (!aarch64_logical_immediate_p (uimm, esize, NULL))
2127  {
2128  set_other_error (mismatch_detail, idx,
2129  _("immediate out of range"));
2130  return 0;
2131  }
2132  }
2133  break;
2134 
2135  case AARCH64_OPND_IMM0:
2136  case AARCH64_OPND_FPIMM0:
2137  if (opnd->imm.value != 0)
2138  {
2139  set_other_error (mismatch_detail, idx,
2140  _("immediate zero expected"));
2141  return 0;
2142  }
2143  break;
2144 
2145  case AARCH64_OPND_IMM_ROT1:
2146  case AARCH64_OPND_IMM_ROT2:
2148  if (opnd->imm.value != 0
2149  && opnd->imm.value != 90
2150  && opnd->imm.value != 180
2151  && opnd->imm.value != 270)
2152  {
2153  set_other_error (mismatch_detail, idx,
2154  _("rotate expected to be 0, 90, 180 or 270"));
2155  return 0;
2156  }
2157  break;
2158 
2159  case AARCH64_OPND_IMM_ROT3:
2161  if (opnd->imm.value != 90 && opnd->imm.value != 270)
2162  {
2163  set_other_error (mismatch_detail, idx,
2164  _("rotate expected to be 90 or 270"));
2165  return 0;
2166  }
2167  break;
2168 
2169  case AARCH64_OPND_SHLL_IMM:
2170  assert (idx == 2);
2171  size = 8 * aarch64_get_qualifier_esize (opnds[idx - 1].qualifier);
2172  if (opnd->imm.value != size)
2173  {
2174  set_other_error (mismatch_detail, idx,
2175  _("invalid shift amount"));
2176  return 0;
2177  }
2178  break;
2179 
2180  case AARCH64_OPND_IMM_VLSL:
2181  size = aarch64_get_qualifier_esize (qualifier);
2182  if (!value_in_range_p (opnd->imm.value, 0, size * 8 - 1))
2183  {
2184  set_imm_out_of_range_error (mismatch_detail, idx, 0,
2185  size * 8 - 1);
2186  return 0;
2187  }
2188  break;
2189 
2190  case AARCH64_OPND_IMM_VLSR:
2191  size = aarch64_get_qualifier_esize (qualifier);
2192  if (!value_in_range_p (opnd->imm.value, 1, size * 8))
2193  {
2194  set_imm_out_of_range_error (mismatch_detail, idx, 1, size * 8);
2195  return 0;
2196  }
2197  break;
2198 
2199  case AARCH64_OPND_SIMD_IMM:
2201  /* Qualifier check. */
2202  switch (qualifier)
2203  {
2204  case AARCH64_OPND_QLF_LSL:
2205  if (opnd->shifter.kind != AARCH64_MOD_LSL)
2206  {
2207  set_other_error (mismatch_detail, idx,
2208  _("invalid shift operator"));
2209  return 0;
2210  }
2211  break;
2212  case AARCH64_OPND_QLF_MSL:
2213  if (opnd->shifter.kind != AARCH64_MOD_MSL)
2214  {
2215  set_other_error (mismatch_detail, idx,
2216  _("invalid shift operator"));
2217  return 0;
2218  }
2219  break;
2220  case AARCH64_OPND_QLF_NIL:
2221  if (opnd->shifter.kind != AARCH64_MOD_NONE)
2222  {
2223  set_other_error (mismatch_detail, idx,
2224  _("shift is not permitted"));
2225  return 0;
2226  }
2227  break;
2228  default:
2229  assert (0);
2230  return 0;
2231  }
2232  /* Is the immediate valid? */
2233  assert (idx == 1);
2234  if (aarch64_get_qualifier_esize (opnds[0].qualifier) != 8)
2235  {
2236  /* uimm8 or simm8 */
2237  if (!value_in_range_p (opnd->imm.value, -128, 255))
2238  {
2239  set_imm_out_of_range_error (mismatch_detail, idx, -128, 255);
2240  return 0;
2241  }
2242  }
2243  else if (aarch64_shrink_expanded_imm8 (opnd->imm.value) < 0)
2244  {
2245  /* uimm64 is not
2246  'aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
2247  ffffffffgggggggghhhhhhhh'. */
2248  set_other_error (mismatch_detail, idx,
2249  _("invalid value for immediate"));
2250  return 0;
2251  }
2252  /* Is the shift amount valid? */
2253  switch (opnd->shifter.kind)
2254  {
2255  case AARCH64_MOD_LSL:
2256  size = aarch64_get_qualifier_esize (opnds[0].qualifier);
2257  if (!value_in_range_p (opnd->shifter.amount, 0, (size - 1) * 8))
2258  {
2259  set_sft_amount_out_of_range_error (mismatch_detail, idx, 0,
2260  (size - 1) * 8);
2261  return 0;
2262  }
2263  if (!value_aligned_p (opnd->shifter.amount, 8))
2264  {
2265  set_unaligned_error (mismatch_detail, idx, 8);
2266  return 0;
2267  }
2268  break;
2269  case AARCH64_MOD_MSL:
2270  /* Only 8 and 16 are valid shift amount. */
2271  if (opnd->shifter.amount != 8 && opnd->shifter.amount != 16)
2272  {
2273  set_other_error (mismatch_detail, idx,
2274  _("shift amount must be 0 or 16"));
2275  return 0;
2276  }
2277  break;
2278  default:
2279  if (opnd->shifter.kind != AARCH64_MOD_NONE)
2280  {
2281  set_other_error (mismatch_detail, idx,
2282  _("invalid shift operator"));
2283  return 0;
2284  }
2285  break;
2286  }
2287  break;
2288 
2289  case AARCH64_OPND_FPIMM:
2292  if (opnd->imm.is_fp == 0)
2293  {
2294  set_other_error (mismatch_detail, idx,
2295  _("floating-point immediate expected"));
2296  return 0;
2297  }
2298  /* The value is expected to be an 8-bit floating-point constant with
2299  sign, 3-bit exponent and normalized 4 bits of precision, encoded
2300  in "a:b:c:d:e:f:g:h" or FLD_imm8 (depending on the type of the
2301  instruction). */
2302  if (!value_in_range_p (opnd->imm.value, 0, 255))
2303  {
2304  set_other_error (mismatch_detail, idx,
2305  _("immediate out of range"));
2306  return 0;
2307  }
2308  if (opnd->shifter.kind != AARCH64_MOD_NONE)
2309  {
2310  set_other_error (mismatch_detail, idx,
2311  _("invalid shift operator"));
2312  return 0;
2313  }
2314  break;
2315 
2316  case AARCH64_OPND_SVE_AIMM:
2317  min_value = 0;
2318  sve_aimm:
2319  assert (opnd->shifter.kind == AARCH64_MOD_LSL);
2320  size = aarch64_get_qualifier_esize (opnds[0].qualifier);
2321  mask = ~((uint64_t) -1 << (size * 4) << (size * 4));
2322  uvalue = opnd->imm.value;
2323  shift = opnd->shifter.amount;
2324  if (size == 1)
2325  {
2326  if (shift != 0)
2327  {
2328  set_other_error (mismatch_detail, idx,
2329  _("no shift amount allowed for"
2330  " 8-bit constants"));
2331  return 0;
2332  }
2333  }
2334  else
2335  {
2336  if (shift != 0 && shift != 8)
2337  {
2338  set_other_error (mismatch_detail, idx,
2339  _("shift amount must be 0 or 8"));
2340  return 0;
2341  }
2342  if (shift == 0 && (uvalue & 0xff) == 0)
2343  {
2344  shift = 8;
2345  uvalue = (int64_t) uvalue / 256;
2346  }
2347  }
2348  mask >>= shift;
2349  if ((uvalue & mask) != uvalue && (uvalue | ~mask) != uvalue)
2350  {
2351  set_other_error (mismatch_detail, idx,
2352  _("immediate too big for element size"));
2353  return 0;
2354  }
2355  uvalue = (uvalue - min_value) & mask;
2356  if (uvalue > 0xff)
2357  {
2358  set_other_error (mismatch_detail, idx,
2359  _("invalid arithmetic immediate"));
2360  return 0;
2361  }
2362  break;
2363 
2365  min_value = -128;
2366  goto sve_aimm;
2367 
2369  assert (opnd->imm.is_fp);
2370  if (opnd->imm.value != 0x3f000000 && opnd->imm.value != 0x3f800000)
2371  {
2372  set_other_error (mismatch_detail, idx,
2373  _("floating-point value must be 0.5 or 1.0"));
2374  return 0;
2375  }
2376  break;
2377 
2379  assert (opnd->imm.is_fp);
2380  if (opnd->imm.value != 0x3f000000 && opnd->imm.value != 0x40000000)
2381  {
2382  set_other_error (mismatch_detail, idx,
2383  _("floating-point value must be 0.5 or 2.0"));
2384  return 0;
2385  }
2386  break;
2387 
2389  assert (opnd->imm.is_fp);
2390  if (opnd->imm.value != 0 && opnd->imm.value != 0x3f800000)
2391  {
2392  set_other_error (mismatch_detail, idx,
2393  _("floating-point value must be 0.0 or 1.0"));
2394  return 0;
2395  }
2396  break;
2397 
2399  {
2400  int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2401  uint64_t uimm = ~opnd->imm.value;
2402  if (!aarch64_logical_immediate_p (uimm, esize, NULL))
2403  {
2404  set_other_error (mismatch_detail, idx,
2405  _("immediate out of range"));
2406  return 0;
2407  }
2408  }
2409  break;
2410 
2412  {
2413  int esize = aarch64_get_qualifier_esize (opnds[0].qualifier);
2414  uint64_t uimm = opnd->imm.value;
2415  if (!aarch64_logical_immediate_p (uimm, esize, NULL))
2416  {
2417  set_other_error (mismatch_detail, idx,
2418  _("immediate out of range"));
2419  return 0;
2420  }
2421  if (!aarch64_sve_dupm_mov_immediate_p (uimm, esize))
2422  {
2423  set_other_error (mismatch_detail, idx,
2424  _("invalid replicated MOV immediate"));
2425  return 0;
2426  }
2427  }
2428  break;
2429 
2431  assert (opnd->shifter.kind == AARCH64_MOD_MUL);
2432  if (!value_in_range_p (opnd->shifter.amount, 1, 16))
2433  {
2434  set_multiplier_out_of_range_error (mismatch_detail, idx, 1, 16);
2435  return 0;
2436  }
2437  break;
2438 
2441  size = aarch64_get_qualifier_esize (opnds[idx - 1].qualifier);
2442  if (!value_in_range_p (opnd->imm.value, 0, 8 * size - 1))
2443  {
2444  set_imm_out_of_range_error (mismatch_detail, idx,
2445  0, 8 * size - 1);
2446  return 0;
2447  }
2448  break;
2449 
2452  size = aarch64_get_qualifier_esize (opnds[idx - 1].qualifier);
2453  if (!value_in_range_p (opnd->imm.value, 1, 8 * size))
2454  {
2455  set_imm_out_of_range_error (mismatch_detail, idx, 1, 8 * size);
2456  return 0;
2457  }
2458  break;
2459 
2460  default:
2461  break;
2462  }
2463  break;
2464 
2466  switch (type)
2467  {
2469  assert (idx == 0 && opnds[1].type == AARCH64_OPND_UIMM4);
2470  /* MSR UAO, #uimm4
2471  MSR PAN, #uimm4
2472  The immediate must be #0 or #1. */
2473  if ((opnd->pstatefield == 0x03 /* UAO. */
2474  || opnd->pstatefield == 0x04 /* PAN. */
2475  || opnd->pstatefield == 0x1a) /* DIT. */
2476  && opnds[1].imm.value > 1)
2477  {
2478  set_imm_out_of_range_error (mismatch_detail, idx, 0, 1);
2479  return 0;
2480  }
2481  /* MSR SPSel, #uimm4
2482  Uses uimm4 as a control value to select the stack pointer: if
2483  bit 0 is set it selects the current exception level's stack
2484  pointer, if bit 0 is clear it selects shared EL0 stack pointer.
2485  Bits 1 to 3 of uimm4 are reserved and should be zero. */
2486  if (opnd->pstatefield == 0x05 /* spsel */ && opnds[1].imm.value > 1)
2487  {
2488  set_imm_out_of_range_error (mismatch_detail, idx, 0, 1);
2489  return 0;
2490  }
2491  break;
2492  default:
2493  break;
2494  }
2495  break;
2496 
2498  /* Get the upper bound for the element index. */
2499  if (opcode->op == OP_FCMLA_ELEM)
2500  /* FCMLA index range depends on the vector size of other operands
2501  and is halfed because complex numbers take two elements. */
2502  num = aarch64_get_qualifier_nelem (opnds[0].qualifier)
2503  * aarch64_get_qualifier_esize (opnds[0].qualifier) / 2;
2504  else
2505  num = 16;
2506  num = num / aarch64_get_qualifier_esize (qualifier) - 1;
2507 
2508  /* Index out-of-range. */
2509  if (!value_in_range_p (opnd->reglane.index, 0, num))
2510  {
2511  set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, num);
2512  return 0;
2513  }
2514  /* SMLAL<Q> <Vd>.<Ta>, <Vn>.<Tb>, <Vm>.<Ts>[<index>].
2515  <Vm> Is the vector register (V0-V31) or (V0-V15), whose
2516  number is encoded in "size:M:Rm":
2517  size <Vm>
2518  00 RESERVED
2519  01 0:Rm
2520  10 M:Rm
2521  11 RESERVED */
2522  if (type == AARCH64_OPND_Em16 && qualifier == AARCH64_OPND_QLF_S_H
2523  && !value_in_range_p (opnd->reglane.regno, 0, 15))
2524  {
2525  set_regno_out_of_range_error (mismatch_detail, idx, 0, 15);
2526  return 0;
2527  }
2528  break;
2529 
2531  assert (idx == 1 || idx == 2);
2532  switch (type)
2533  {
2534  case AARCH64_OPND_Rm_EXT:
2536  && opnd->shifter.kind != AARCH64_MOD_LSL)
2537  {
2538  set_other_error (mismatch_detail, idx,
2539  _("extend operator expected"));
2540  return 0;
2541  }
2542  /* It is not optional unless at least one of "Rd" or "Rn" is '11111'
2543  (i.e. SP), in which case it defaults to LSL. The LSL alias is
2544  only valid when "Rd" or "Rn" is '11111', and is preferred in that
2545  case. */
2546  if (!aarch64_stack_pointer_p (opnds + 0)
2547  && (idx != 2 || !aarch64_stack_pointer_p (opnds + 1)))
2548  {
2549  if (!opnd->shifter.operator_present)
2550  {
2551  set_other_error (mismatch_detail, idx,
2552  _("missing extend operator"));
2553  return 0;
2554  }
2555  else if (opnd->shifter.kind == AARCH64_MOD_LSL)
2556  {
2557  set_other_error (mismatch_detail, idx,
2558  _("'LSL' operator not allowed"));
2559  return 0;
2560  }
2561  }
2562  assert (opnd->shifter.operator_present /* Default to LSL. */
2563  || opnd->shifter.kind == AARCH64_MOD_LSL);
2564  if (!value_in_range_p (opnd->shifter.amount, 0, 4))
2565  {
2566  set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, 4);
2567  return 0;
2568  }
2569  /* In the 64-bit form, the final register operand is written as Wm
2570  for all but the (possibly omitted) UXTX/LSL and SXTX
2571  operators.
2572  N.B. GAS allows X register to be used with any operator as a
2573  programming convenience. */
2574  if (qualifier == AARCH64_OPND_QLF_X
2575  && opnd->shifter.kind != AARCH64_MOD_LSL
2576  && opnd->shifter.kind != AARCH64_MOD_UXTX
2577  && opnd->shifter.kind != AARCH64_MOD_SXTX)
2578  {
2579  set_other_error (mismatch_detail, idx, _("W register expected"));
2580  return 0;
2581  }
2582  break;
2583 
2584  case AARCH64_OPND_Rm_SFT:
2585  /* ROR is not available to the shifted register operand in
2586  arithmetic instructions. */
2587  if (!aarch64_shift_operator_p (opnd->shifter.kind))
2588  {
2589  set_other_error (mismatch_detail, idx,
2590  _("shift operator expected"));
2591  return 0;
2592  }
2593  if (opnd->shifter.kind == AARCH64_MOD_ROR
2594  && opcode->iclass != log_shift)
2595  {
2596  set_other_error (mismatch_detail, idx,
2597  _("'ROR' operator not allowed"));
2598  return 0;
2599  }
2600  num = qualifier == AARCH64_OPND_QLF_W ? 31 : 63;
2601  if (!value_in_range_p (opnd->shifter.amount, 0, num))
2602  {
2603  set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, num);
2604  return 0;
2605  }
2606  break;
2607 
2608  default:
2609  break;
2610  }
2611  break;
2612 
2613  default:
2614  break;
2615  }
2616 
2617  return 1;
2618 }
2619 
2620 /* Main entrypoint for the operand constraint checking.
2621 
2622  Return 1 if operands of *INST meet the constraint applied by the operand
2623  codes and operand qualifiers; otherwise return 0 and if MISMATCH_DETAIL is
2624  not NULL, return the detail of the error in *MISMATCH_DETAIL. N.B. when
2625  adding more constraint checking, make sure MISMATCH_DETAIL->KIND is set
2626  with a proper error kind rather than AARCH64_OPDE_NIL (GAS asserts non-NIL
2627  error kind when it is notified that an instruction does not pass the check).
2628 
2629  Un-determined operand qualifiers may get established during the process. */
2630 
2631 int
2633  aarch64_operand_error *mismatch_detail)
2634 {
2635  int i;
2636 
2637  DEBUG_TRACE ("enter");
2638 
2639  /* Check for cases where a source register needs to be the same as the
2640  destination register. Do this before matching qualifiers since if
2641  an instruction has both invalid tying and invalid qualifiers,
2642  the error about qualifiers would suggest several alternative
2643  instructions that also have invalid tying. */
2644  i = inst->opcode->tied_operand;
2645  if (i > 0 && (inst->operands[0].reg.regno != inst->operands[i].reg.regno))
2646  {
2647  if (mismatch_detail)
2648  {
2649  mismatch_detail->kind = AARCH64_OPDE_UNTIED_OPERAND;
2650  mismatch_detail->index = i;
2651  mismatch_detail->error = NULL;
2652  }
2653  return 0;
2654  }
2655 
2656  /* Match operands' qualifier.
2657  *INST has already had qualifier establish for some, if not all, of
2658  its operands; we need to find out whether these established
2659  qualifiers match one of the qualifier sequence in
2660  INST->OPCODE->QUALIFIERS_LIST. If yes, we will assign each operand
2661  with the corresponding qualifier in such a sequence.
2662  Only basic operand constraint checking is done here; the more thorough
2663  constraint checking will carried out by operand_general_constraint_met_p,
2664  which has be to called after this in order to get all of the operands'
2665  qualifiers established. */
2666  if (match_operands_qualifier (inst, TRUE /* update_p */) == 0)
2667  {
2668  DEBUG_TRACE ("FAIL on operand qualifier matching");
2669  if (mismatch_detail)
2670  {
2671  /* Return an error type to indicate that it is the qualifier
2672  matching failure; we don't care about which operand as there
2673  are enough information in the opcode table to reproduce it. */
2674  mismatch_detail->kind = AARCH64_OPDE_INVALID_VARIANT;
2675  mismatch_detail->index = -1;
2676  mismatch_detail->error = NULL;
2677  }
2678  return 0;
2679  }
2680 
2681  /* Match operands' constraint. */
2682  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
2683  {
2684  enum aarch64_opnd type = inst->opcode->operands[i];
2685  if (type == AARCH64_OPND_NIL)
2686  break;
2687  if (inst->operands[i].skip)
2688  {
2689  DEBUG_TRACE ("skip the incomplete operand %d", i);
2690  continue;
2691  }
2693  inst->opcode, mismatch_detail) == 0)
2694  {
2695  DEBUG_TRACE ("FAIL on operand %d", i);
2696  return 0;
2697  }
2698  }
2699 
2700  DEBUG_TRACE ("PASS");
2701 
2702  return 1;
2703 }
2704 
2705 /* Replace INST->OPCODE with OPCODE and return the replaced OPCODE.
2706  Also updates the TYPE of each INST->OPERANDS with the corresponding
2707  value of OPCODE->OPERANDS.
2708 
2709  Note that some operand qualifiers may need to be manually cleared by
2710  the caller before it further calls the aarch64_opcode_encode; by
2711  doing this, it helps the qualifier matching facilities work
2712  properly. */
2713 
2714 const aarch64_opcode*
2716 {
2717  int i;
2718  const aarch64_opcode *old = inst->opcode;
2719 
2720  inst->opcode = opcode;
2721 
2722  /* Update the operand types. */
2723  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
2724  {
2725  inst->operands[i].type = opcode->operands[i];
2726  if (opcode->operands[i] == AARCH64_OPND_NIL)
2727  break;
2728  }
2729 
2730  DEBUG_TRACE ("replace %s with %s", old->name, opcode->name);
2731 
2732  return old;
2733 }
2734 
2735 int
2737 {
2738  int i;
2739  for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)
2740  if (operands[i] == operand)
2741  return i;
2742  else if (operands[i] == AARCH64_OPND_NIL)
2743  break;
2744  return -1;
2745 }
2746 ␌
2747 /* R0...R30, followed by FOR31. */
2748 #define BANK(R, FOR31) \
2749  { R (0), R (1), R (2), R (3), R (4), R (5), R (6), R (7), \
2750  R (8), R (9), R (10), R (11), R (12), R (13), R (14), R (15), \
2751  R (16), R (17), R (18), R (19), R (20), R (21), R (22), R (23), \
2752  R (24), R (25), R (26), R (27), R (28), R (29), R (30), FOR31 }
2753 /* [0][0] 32-bit integer regs with sp Wn
2754  [0][1] 64-bit integer regs with sp Xn sf=1
2755  [1][0] 32-bit integer regs with #0 Wn
2756  [1][1] 64-bit integer regs with #0 Xn sf=1 */
2757 static const char *int_reg[2][2][32] = {
2758 #define R32(X) "w" #X
2759 #define R64(X) "x" #X
2760  { BANK (R32, "wsp"), BANK (R64, "sp") },
2761  { BANK (R32, "wzr"), BANK (R64, "xzr") }
2762 #undef R64
2763 #undef R32
2764 };
2765 
2766 /* Names of the SVE vector registers, first with .S suffixes,
2767  then with .D suffixes. */
2768 
2769 static const char *sve_reg[2][32] = {
2770 #define ZS(X) "z" #X ".s"
2771 #define ZD(X) "z" #X ".d"
2772  BANK (ZS, ZS (31)), BANK (ZD, ZD (31))
2773 #undef ZD
2774 #undef ZS
2775 };
2776 #undef BANK
2777 
2778 /* Return the integer register name.
2779  if SP_REG_P is not 0, R31 is an SP reg, other R31 is the zero reg. */
2780 
2781 static inline const char *
2782 get_int_reg_name (int regno, aarch64_opnd_qualifier_t qualifier, int sp_reg_p)
2783 {
2784  const int has_zr = sp_reg_p ? 0 : 1;
2785  const int is_64 = aarch64_get_qualifier_esize (qualifier) == 4 ? 0 : 1;
2786  return int_reg[has_zr][is_64][regno];
2787 }
2788 
2789 /* Like get_int_reg_name, but IS_64 is always 1. */
2790 
2791 static inline const char *
2792 get_64bit_int_reg_name (int regno, int sp_reg_p)
2793 {
2794  const int has_zr = sp_reg_p ? 0 : 1;
2795  return int_reg[has_zr][1][regno];
2796 }
2797 
2798 /* Get the name of the integer offset register in OPND, using the shift type
2799  to decide whether it's a word or doubleword. */
2800 
2801 static inline const char *
2803 {
2804  switch (opnd->shifter.kind)
2805  {
2806  case AARCH64_MOD_UXTW:
2807  case AARCH64_MOD_SXTW:
2808  return get_int_reg_name (opnd->addr.offset.regno, AARCH64_OPND_QLF_W, 0);
2809 
2810  case AARCH64_MOD_LSL:
2811  case AARCH64_MOD_SXTX:
2812  return get_int_reg_name (opnd->addr.offset.regno, AARCH64_OPND_QLF_X, 0);
2813 
2814  default:
2815  abort ();
2816  }
2817 }
2818 
2819 /* Get the name of the SVE vector offset register in OPND, using the operand
2820  qualifier to decide whether the suffix should be .S or .D. */
2821 
2822 static inline const char *
2824 {
2825  assert (qualifier == AARCH64_OPND_QLF_S_S
2826  || qualifier == AARCH64_OPND_QLF_S_D);
2827  return sve_reg[qualifier == AARCH64_OPND_QLF_S_D][regno];
2828 }
2829 
2830 /* Types for expanding an encoded 8-bit value to a floating-point value. */
2831 
2832 typedef union
2833 {
2835  double d;
2836 } double_conv_t;
2837 
2838 typedef union
2839 {
2841  float f;
2842 } single_conv_t;
2843 
2844 typedef union
2845 {
2847  float f;
2848 } half_conv_t;
2849 
2850 /* IMM8 is an 8-bit floating-point constant with sign, 3-bit exponent and
2851  normalized 4 bits of precision, encoded in "a:b:c:d:e:f:g:h" or FLD_imm8
2852  (depending on the type of the instruction). IMM8 will be expanded to a
2853  single-precision floating-point value (SIZE == 4) or a double-precision
2854  floating-point value (SIZE == 8). A half-precision floating-point value
2855  (SIZE == 2) is expanded to a single-precision floating-point value. The
2856  expanded value is returned. */
2857 
2858 static uint64_t
2860 {
2861  uint64_t imm = 0;
2862  uint32_t imm8_7, imm8_6_0, imm8_6, imm8_6_repl4;
2863 
2864  imm8_7 = (imm8 >> 7) & 0x01; /* imm8<7> */
2865  imm8_6_0 = imm8 & 0x7f; /* imm8<6:0> */
2866  imm8_6 = imm8_6_0 >> 6; /* imm8<6> */
2867  imm8_6_repl4 = (imm8_6 << 3) | (imm8_6 << 2)
2868  | (imm8_6 << 1) | imm8_6; /* Replicate(imm8<6>,4) */
2869  if (size == 8)
2870  {
2871  imm = (imm8_7 << (63-32)) /* imm8<7> */
2872  | ((imm8_6 ^ 1) << (62-32)) /* NOT(imm8<6) */
2873  | (imm8_6_repl4 << (58-32)) | (imm8_6 << (57-32))
2874  | (imm8_6 << (56-32)) | (imm8_6 << (55-32)) /* Replicate(imm8<6>,7) */
2875  | (imm8_6_0 << (48-32)); /* imm8<6>:imm8<5:0> */
2876  imm <<= 32;
2877  }
2878  else if (size == 4 || size == 2)
2879  {
2880  imm = (imm8_7 << 31) /* imm8<7> */
2881  | ((imm8_6 ^ 1) << 30) /* NOT(imm8<6>) */
2882  | (imm8_6_repl4 << 26) /* Replicate(imm8<6>,4) */
2883  | (imm8_6_0 << 19); /* imm8<6>:imm8<5:0> */
2884  }
2885  else
2886  {
2887  /* An unsupported size. */
2888  assert (0);
2889  }
2890 
2891  return imm;
2892 }
2893 
2894 /* Produce the string representation of the register list operand *OPND
2895  in the buffer pointed by BUF of size SIZE. PREFIX is the part of
2896  the register name that comes before the register number, such as "v". */
2897 static void
2898 print_register_list (char *buf, size_t size, const aarch64_opnd_info *opnd,
2899  const char *prefix)
2900 {
2901  const int num_regs = opnd->reglist.num_regs;
2902  const int first_reg = opnd->reglist.first_regno;
2903  const int last_reg = (first_reg + num_regs - 1) & 0x1f;
2904  const char *qlf_name = aarch64_get_qualifier_name (opnd->qualifier);
2905  char tb[8]; /* Temporary buffer. */
2906 
2907  assert (opnd->type != AARCH64_OPND_LEt || opnd->reglist.has_index);
2908  assert (num_regs >= 1 && num_regs <= 4);
2909 
2910  /* Prepare the index if any. */
2911  if (opnd->reglist.has_index)
2912  /* PR 21096: The %100 is to silence a warning about possible truncation. */
2913  snprintf (tb, 8, "[%" PRIi64 "]", (opnd->reglist.index % 100));
2914  else
2915  tb[0] = '\0';
2916 
2917  /* The hyphenated form is preferred for disassembly if there are
2918  more than two registers in the list, and the register numbers
2919  are monotonically increasing in increments of one. */
2920  if (num_regs > 2 && last_reg > first_reg)
2921  snprintf (buf, size, "{%s%d.%s-%s%d.%s}%s", prefix, first_reg, qlf_name,
2922  prefix, last_reg, qlf_name, tb);
2923  else
2924  {
2925  const int reg0 = first_reg;
2926  const int reg1 = (first_reg + 1) & 0x1f;
2927  const int reg2 = (first_reg + 2) & 0x1f;
2928  const int reg3 = (first_reg + 3) & 0x1f;
2929 
2930  switch (num_regs)
2931  {
2932  case 1:
2933  snprintf (buf, size, "{%s%d.%s}%s", prefix, reg0, qlf_name, tb);
2934  break;
2935  case 2:
2936  snprintf (buf, size, "{%s%d.%s, %s%d.%s}%s", prefix, reg0, qlf_name,
2937  prefix, reg1, qlf_name, tb);
2938  break;
2939  case 3:
2940  snprintf (buf, size, "{%s%d.%s, %s%d.%s, %s%d.%s}%s",
2941  prefix, reg0, qlf_name, prefix, reg1, qlf_name,
2942  prefix, reg2, qlf_name, tb);
2943  break;
2944  case 4:
2945  snprintf (buf, size, "{%s%d.%s, %s%d.%s, %s%d.%s, %s%d.%s}%s",
2946  prefix, reg0, qlf_name, prefix, reg1, qlf_name,
2947  prefix, reg2, qlf_name, prefix, reg3, qlf_name, tb);
2948  break;
2949  }
2950  }
2951 }
2952 
2953 /* Print the register+immediate address in OPND to BUF, which has SIZE
2954  characters. BASE is the name of the base register. */
2955 
2956 static void
2958  const aarch64_opnd_info *opnd,
2959  const char *base)
2960 {
2961  if (opnd->addr.writeback)
2962  {
2963  if (opnd->addr.preind)
2964  snprintf (buf, size, "[%s, #%d]!", base, opnd->addr.offset.imm);
2965  else
2966  snprintf (buf, size, "[%s], #%d", base, opnd->addr.offset.imm);
2967  }
2968  else
2969  {
2970  if (opnd->shifter.operator_present)
2971  {
2973  snprintf (buf, size, "[%s, #%d, mul vl]",
2974  base, opnd->addr.offset.imm);
2975  }
2976  else if (opnd->addr.offset.imm)
2977  snprintf (buf, size, "[%s, #%d]", base, opnd->addr.offset.imm);
2978  else
2979  snprintf (buf, size, "[%s]", base);
2980  }
2981 }
2982 
2983 /* Produce the string representation of the register offset address operand
2984  *OPND in the buffer pointed by BUF of size SIZE. BASE and OFFSET are
2985  the names of the base and offset registers. */
2986 static void
2988  const aarch64_opnd_info *opnd,
2989  const char *base, const char *offset)
2990 {
2991  char tb[16]; /* Temporary buffer. */
2992  bfd_boolean print_extend_p = TRUE;
2993  bfd_boolean print_amount_p = TRUE;
2994  const char *shift_name = aarch64_operand_modifiers[opnd->shifter.kind].name;
2995 
2996  if (!opnd->shifter.amount && (opnd->qualifier != AARCH64_OPND_QLF_S_B
2997  || !opnd->shifter.amount_present))
2998  {
2999  /* Not print the shift/extend amount when the amount is zero and
3000  when it is not the special case of 8-bit load/store instruction. */
3001  print_amount_p = FALSE;
3002  /* Likewise, no need to print the shift operator LSL in such a
3003  situation. */
3004  if (opnd->shifter.kind == AARCH64_MOD_LSL)
3005  print_extend_p = FALSE;
3006  }
3007 
3008  /* Prepare for the extend/shift. */
3009  if (print_extend_p)
3010  {
3011  if (print_amount_p)
3012  snprintf (tb, sizeof (tb), ", %s #%" PRIi64, shift_name,
3013  /* PR 21096: The %100 is to silence a warning about possible truncation. */
3014  (opnd->shifter.amount % 100));
3015  else
3016  snprintf (tb, sizeof (tb), ", %s", shift_name);
3017  }
3018  else
3019  tb[0] = '\0';
3020 
3021  snprintf (buf, size, "[%s, %s%s]", base, offset, tb);
3022 }
3023 
3024 /* Generate the string representation of the operand OPNDS[IDX] for OPCODE
3025  in *BUF. The caller should pass in the maximum size of *BUF in SIZE.
3026  PC, PCREL_P and ADDRESS are used to pass in and return information about
3027  the PC-relative address calculation, where the PC value is passed in
3028  PC. If the operand is pc-relative related, *PCREL_P (if PCREL_P non-NULL)
3029  will return 1 and *ADDRESS (if ADDRESS non-NULL) will return the
3030  calculated address; otherwise, *PCREL_P (if PCREL_P non-NULL) returns 0.
3031 
3032  The function serves both the disassembler and the assembler diagnostics
3033  issuer, which is the reason why it lives in this file. */
3034 
3035 void
3037  const aarch64_opcode *opcode,
3038  const aarch64_opnd_info *opnds, int idx, int *pcrel_p,
3039  bfd_vma *address, char** notes ATTRIBUTE_UNUSED)
3040 {
3041  unsigned int i, num_conds;
3042  const char *name = NULL;
3043  const aarch64_opnd_info *opnd = opnds + idx;
3045  uint64_t addr, enum_value;
3046 
3047  buf[0] = '\0';
3048  if (pcrel_p)
3049  *pcrel_p = 0;
3050 
3051  switch (opnd->type)
3052  {
3053  case AARCH64_OPND_Rd:
3054  case AARCH64_OPND_Rn:
3055  case AARCH64_OPND_Rm:
3056  case AARCH64_OPND_Rt:
3057  case AARCH64_OPND_Rt2:
3058  case AARCH64_OPND_Rs:
3059  case AARCH64_OPND_Ra:
3060  case AARCH64_OPND_Rt_SYS:
3061  case AARCH64_OPND_PAIRREG:
3062  case AARCH64_OPND_SVE_Rm:
3063  /* The optional-ness of <Xt> in e.g. IC <ic_op>{, <Xt>} is determined by
3064  the <ic_op>, therefore we use opnd->present to override the
3065  generic optional-ness information. */
3066  if (opnd->type == AARCH64_OPND_Rt_SYS)
3067  {
3068  if (!opnd->present)
3069  break;
3070  }
3071  /* Omit the operand, e.g. RET. */
3072  else if (optional_operand_p (opcode, idx)
3073  && (opnd->reg.regno
3075  break;
3077  || opnd->qualifier == AARCH64_OPND_QLF_X);
3078  snprintf (buf, size, "%s",
3079  get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0));
3080  break;
3081 
3082  case AARCH64_OPND_Rd_SP:
3083  case AARCH64_OPND_Rn_SP:
3085  case AARCH64_OPND_Rm_SP:
3087  || opnd->qualifier == AARCH64_OPND_QLF_WSP
3088  || opnd->qualifier == AARCH64_OPND_QLF_X
3089  || opnd->qualifier == AARCH64_OPND_QLF_SP);
3090  snprintf (buf, size, "%s",
3091  get_int_reg_name (opnd->reg.regno, opnd->qualifier, 1));
3092  break;
3093 
3094  case AARCH64_OPND_Rm_EXT:
3095  kind = opnd->shifter.kind;
3096  assert (idx == 1 || idx == 2);
3097  if ((aarch64_stack_pointer_p (opnds)
3098  || (idx == 2 && aarch64_stack_pointer_p (opnds + 1)))
3099  && ((opnd->qualifier == AARCH64_OPND_QLF_W
3100  && opnds[0].qualifier == AARCH64_OPND_QLF_W
3101  && kind == AARCH64_MOD_UXTW)
3102  || (opnd->qualifier == AARCH64_OPND_QLF_X
3103  && kind == AARCH64_MOD_UXTX)))
3104  {
3105  /* 'LSL' is the preferred form in this case. */
3107  if (opnd->shifter.amount == 0)
3108  {
3109  /* Shifter omitted. */
3110  snprintf (buf, size, "%s",
3111  get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0));
3112  break;
3113  }
3114  }
3115  if (opnd->shifter.amount)
3116  snprintf (buf, size, "%s, %s #%" PRIi64,
3117  get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0),
3119  opnd->shifter.amount);
3120  else
3121  snprintf (buf, size, "%s, %s",
3122  get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0),
3124  break;
3125 
3126  case AARCH64_OPND_Rm_SFT:
3128  || opnd->qualifier == AARCH64_OPND_QLF_X);
3129  if (opnd->shifter.amount == 0 && opnd->shifter.kind == AARCH64_MOD_LSL)
3130  snprintf (buf, size, "%s",
3131  get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0));
3132  else
3133  snprintf (buf, size, "%s, %s #%" PRIi64,
3134  get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0),
3136  opnd->shifter.amount);
3137  break;
3138 
3139  case AARCH64_OPND_Fd:
3140  case AARCH64_OPND_Fn:
3141  case AARCH64_OPND_Fm:
3142  case AARCH64_OPND_Fa:
3143  case AARCH64_OPND_Ft:
3144  case AARCH64_OPND_Ft2:
3145  case AARCH64_OPND_Sd:
3146  case AARCH64_OPND_Sn:
3147  case AARCH64_OPND_Sm:
3148  case AARCH64_OPND_SVE_VZn:
3149  case AARCH64_OPND_SVE_Vd:
3150  case AARCH64_OPND_SVE_Vm:
3151  case AARCH64_OPND_SVE_Vn:
3153  opnd->reg.regno);
3154  break;
3155 
3156  case AARCH64_OPND_Va:
3157  case AARCH64_OPND_Vd:
3158  case AARCH64_OPND_Vn:
3159  case AARCH64_OPND_Vm:
3160  snprintf (buf, size, "v%d.%s", opnd->reg.regno,
3162  break;
3163 
3164  case AARCH64_OPND_Ed:
3165  case AARCH64_OPND_En:
3166  case AARCH64_OPND_Em:
3167  case AARCH64_OPND_Em16:
3168  case AARCH64_OPND_SM3_IMM2:
3169  snprintf (buf, size, "v%d.%s[%" PRIi64 "]", opnd->reglane.regno,
3171  opnd->reglane.index);
3172  break;
3173 
3174  case AARCH64_OPND_VdD1:
3175  case AARCH64_OPND_VnD1:
3176  snprintf (buf, size, "v%d.d[1]", opnd->reg.regno);
3177  break;
3178 
3179  case AARCH64_OPND_LVn:
3180  case AARCH64_OPND_LVt:
3181  case AARCH64_OPND_LVt_AL:
3182  case AARCH64_OPND_LEt:
3183  print_register_list (buf, size, opnd, "v");
3184  break;
3185 
3186  case AARCH64_OPND_SVE_Pd:
3187  case AARCH64_OPND_SVE_Pg3:
3191  case AARCH64_OPND_SVE_Pm:
3192  case AARCH64_OPND_SVE_Pn:
3193  case AARCH64_OPND_SVE_Pt:
3194  if (opnd->qualifier == AARCH64_OPND_QLF_NIL)
3195  snprintf (buf, size, "p%d", opnd->reg.regno);
3196  else if (opnd->qualifier == AARCH64_OPND_QLF_P_Z
3197  || opnd->qualifier == AARCH64_OPND_QLF_P_M)
3198  snprintf (buf, size, "p%d/%s", opnd->reg.regno,
3200  else
3201  snprintf (buf, size, "p%d.%s", opnd->reg.regno,
3203  break;
3204 
3205  case AARCH64_OPND_SVE_Za_5:
3207  case AARCH64_OPND_SVE_Zd:
3208  case AARCH64_OPND_SVE_Zm_5:
3210  case AARCH64_OPND_SVE_Zn:
3211  case AARCH64_OPND_SVE_Zt:
3212  if (opnd->qualifier == AARCH64_OPND_QLF_NIL)
3213  snprintf (buf, size, "z%d", opnd->reg.regno);
3214  else
3215  snprintf (buf, size, "z%d.%s", opnd->reg.regno,
3217  break;
3218 
3219  case AARCH64_OPND_SVE_ZnxN:
3220  case AARCH64_OPND_SVE_ZtxN:
3221  print_register_list (buf, size, opnd, "z");
3222  break;
3223 
3228  snprintf (buf, size, "z%d.%s[%" PRIi64 "]", opnd->reglane.regno,
3230  opnd->reglane.index);
3231  break;
3232 
3233  case AARCH64_OPND_CRn:
3234  case AARCH64_OPND_CRm:
3235  snprintf (buf, size, "C%" PRIi64, opnd->imm.value);
3236  break;
3237 
3238  case AARCH64_OPND_IDX:
3239  case AARCH64_OPND_MASK:
3240  case AARCH64_OPND_IMM:
3241  case AARCH64_OPND_IMM_2:
3242  case AARCH64_OPND_WIDTH:
3245  case AARCH64_OPND_BIT_NUM:
3246  case AARCH64_OPND_IMM_VLSL:
3247  case AARCH64_OPND_IMM_VLSR:
3248  case AARCH64_OPND_SHLL_IMM:
3249  case AARCH64_OPND_IMM0:
3250  case AARCH64_OPND_IMMR:
3251  case AARCH64_OPND_IMMS:
3252  case AARCH64_OPND_FBITS:
3253  case AARCH64_OPND_SIMM5:
3266  case AARCH64_OPND_IMM_ROT1:
3267  case AARCH64_OPND_IMM_ROT2:
3268  case AARCH64_OPND_IMM_ROT3:
3271  snprintf (buf, size, "#%" PRIi64, opnd->imm.value);
3272  break;
3273 
3277  {
3278  single_conv_t c;
3279  c.i = opnd->imm.value;
3280  snprintf (buf, size, "#%.1f", c.f);
3281  break;
3282  }
3283 
3285  if (optional_operand_p (opcode, idx)
3286  && opnd->imm.value == get_optional_operand_default_value (opcode))
3287  break;
3288  enum_value = opnd->imm.value;
3289  assert (enum_value < ARRAY_SIZE (aarch64_sve_pattern_array));
3290  if (aarch64_sve_pattern_array[enum_value])
3291  snprintf (buf, size, "%s", aarch64_sve_pattern_array[enum_value]);
3292  else
3293  snprintf (buf, size, "#%" PRIi64, opnd->imm.value);
3294  break;
3295 
3297  if (optional_operand_p (opcode, idx)
3298  && !opnd->shifter.operator_present
3299  && opnd->imm.value == get_optional_operand_default_value (opcode))
3300  break;
3301  enum_value = opnd->imm.value;
3302  assert (enum_value < ARRAY_SIZE (aarch64_sve_pattern_array));
3303  if (aarch64_sve_pattern_array[opnd->imm.value])
3304  snprintf (buf, size, "%s", aarch64_sve_pattern_array[opnd->imm.value]);
3305  else
3306  snprintf (buf, size, "#%" PRIi64, opnd->imm.value);
3307  if (opnd->shifter.operator_present)
3308  {
3309  size_t len = strlen (buf);
3310  snprintf (buf + len, size - len, ", %s #%" PRIi64,
3312  opnd->shifter.amount);
3313  }
3314  break;
3315 
3317  enum_value = opnd->imm.value;
3318  assert (enum_value < ARRAY_SIZE (aarch64_sve_prfop_array));
3319  if (aarch64_sve_prfop_array[enum_value])
3320  snprintf (buf, size, "%s", aarch64_sve_prfop_array[enum_value]);
3321  else
3322  snprintf (buf, size, "#%" PRIi64, opnd->imm.value);
3323  break;
3324 
3325  case AARCH64_OPND_IMM_MOV:
3326  switch (aarch64_get_qualifier_esize (opnds[0].qualifier))
3327  {
3328  case 4: /* e.g. MOV Wd, #<imm32>. */
3329  {
3330  int imm32 = opnd->imm.value;
3331  snprintf (buf, size, "0x%x", imm32);
3332  }
3333  break;
3334  case 8: /* e.g. MOV Xd, #<imm64>. */
3335  snprintf (buf, size, "0x%" PRIx64, opnd->imm.value);
3336  break;
3337  default: assert (0);
3338  }
3339  break;
3340 
3341  case AARCH64_OPND_FPIMM0:
3342  snprintf (buf, size, "0.0");
3343  break;
3344 
3345  case AARCH64_OPND_LIMM:
3346  case AARCH64_OPND_AIMM:
3347  case AARCH64_OPND_HALF:
3349  case AARCH64_OPND_SVE_LIMM:
3351  if (opnd->shifter.amount)
3352  snprintf (buf, size, "0x%" PRIx64 ", lsl #%" PRIi64, opnd->imm.value,
3353  opnd->shifter.amount);
3354  else
3355  snprintf (buf, size, "0x%" PRIx64, opnd->imm.value);
3356  break;
3357 
3358  case AARCH64_OPND_SIMD_IMM:
3360  if ((! opnd->shifter.amount && opnd->shifter.kind == AARCH64_MOD_LSL)
3361  || opnd->shifter.kind == AARCH64_MOD_NONE)
3362  snprintf (buf, size, "0x%" PRIx64, opnd->imm.value);
3363  else
3364  snprintf (buf, size, "0x%" PRIx64 ", %s #%" PRIi64, opnd->imm.value,
3366  opnd->shifter.amount);
3367  break;
3368 
3369  case AARCH64_OPND_SVE_AIMM:
3371  if (opnd->shifter.amount)
3372  snprintf (buf, size, "#%" PRIi64 ", lsl #%" PRIi64, opnd->imm.value,
3373  opnd->shifter.amount);
3374  else
3375  snprintf (buf, size, "#%" PRIi64, opnd->imm.value);
3376  break;
3377 
3378  case AARCH64_OPND_FPIMM:
3381  switch (aarch64_get_qualifier_esize (opnds[0].qualifier))
3382  {
3383  case 2: /* e.g. FMOV <Hd>, #<imm>. */
3384  {
3385  half_conv_t c;
3386  c.i = expand_fp_imm (2, opnd->imm.value);
3387  snprintf (buf, size, "#%.18e", c.f);
3388  }
3389  break;
3390  case 4: /* e.g. FMOV <Vd>.4S, #<imm>. */
3391  {
3392  single_conv_t c;
3393  c.i = expand_fp_imm (4, opnd->imm.value);
3394  snprintf (buf, size, "#%.18e", c.f);
3395  }
3396  break;
3397  case 8: /* e.g. FMOV <Sd>, #<imm>. */
3398  {
3399  double_conv_t c;
3400  c.i = expand_fp_imm (8, opnd->imm.value);
3401  snprintf (buf, size, "#%.18e", c.d);
3402  }
3403  break;
3404  default: assert (0);
3405  }
3406  break;
3407 
3408  case AARCH64_OPND_CCMP_IMM:
3409  case AARCH64_OPND_NZCV:
3411  case AARCH64_OPND_UIMM4:
3412  case AARCH64_OPND_UIMM7:
3413  if (optional_operand_p (opcode, idx) == TRUE
3414  && (opnd->imm.value ==
3416  /* Omit the operand, e.g. DCPS1. */
3417  break;
3418  snprintf (buf, size, "0x%x", (unsigned int)opnd->imm.value);
3419  break;
3420 
3421  case AARCH64_OPND_COND:
3422  case AARCH64_OPND_COND1:
3423  snprintf (buf, size, "%s", opnd->cond->names[0]);
3424  num_conds = ARRAY_SIZE (opnd->cond->names);
3425  for (i = 1; i < num_conds && opnd->cond->names[i]; ++i)
3426  {
3427  size_t len = strlen (buf);
3428  if (i == 1)
3429  snprintf (buf + len, size - len, " // %s = %s",
3430  opnd->cond->names[0], opnd->cond->names[i]);
3431  else
3432  snprintf (buf + len, size - len, ", %s",
3433  opnd->cond->names[i]);
3434  }
3435  break;
3436 
3438  addr = ((pc + AARCH64_PCREL_OFFSET) & ~(uint64_t)0xfff)
3439  + opnd->imm.value;
3440  if (pcrel_p)
3441  *pcrel_p = 1;
3442  if (address)
3443  *address = addr;
3444  /* This is not necessary during the disassembling, as print_address_func
3445  in the disassemble_info will take care of the printing. But some
3446  other callers may be still interested in getting the string in *STR,
3447  so here we do snprintf regardless. */
3448  snprintf (buf, size, "0x%" PRIx64, addr);
3449  break;
3450 
3455  addr = pc + AARCH64_PCREL_OFFSET + opnd->imm.value;
3456  if (pcrel_p)
3457  *pcrel_p = 1;
3458  if (address)
3459  *address = addr;
3460  /* This is not necessary during the disassembling, as print_address_func
3461  in the disassemble_info will take care of the printing. But some
3462  other callers may be still interested in getting the string in *STR,
3463  so here we do snprintf regardless. */
3464  snprintf (buf, size, "0x%" PRIx64, addr);
3465  break;
3466 
3470  name = get_64bit_int_reg_name (opnd->addr.base_regno, 1);
3471  if (opnd->type == AARCH64_OPND_SIMD_ADDR_POST)
3472  {
3473  if (opnd->addr.offset.is_reg)
3474  snprintf (buf, size, "[%s], x%d", name, opnd->addr.offset.regno);
3475  else
3476  snprintf (buf, size, "[%s], #%d", name, opnd->addr.offset.imm);
3477  }
3478  else
3479  snprintf (buf, size, "[%s]", name);
3480  break;
3481 
3493  (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1),
3494  get_offset_int_reg_name (opnd));
3495  break;
3496 
3510  (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1),
3511  get_addr_sve_reg_name (opnd->addr.offset.regno, opnd->qualifier));
3512  break;
3513 
3531  (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1));
3532  break;
3533 
3539  (buf, size, opnd,
3540  get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier));
3541  break;
3542 
3547  (buf, size, opnd,
3548  get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier),
3549  get_addr_sve_reg_name (opnd->addr.offset.regno, opnd->qualifier));
3550  break;
3551 
3553  name = get_64bit_int_reg_name (opnd->addr.base_regno, 1);
3554  if (opnd->addr.offset.imm)
3555  snprintf (buf, size, "[%s, #%d]", name, opnd->addr.offset.imm);
3556  else
3557  snprintf (buf, size, "[%s]", name);
3558  break;
3559 
3560  case AARCH64_OPND_SYSREG:
3561  for (i = 0; aarch64_sys_regs[i].name; ++i)
3562  {
3563  bfd_boolean exact_match
3564  = (aarch64_sys_regs[i].flags & opnd->sysreg.flags)
3565  == opnd->sysreg.flags;
3566 
3567  /* Try and find an exact match, But if that fails, return the first
3568  partial match that was found. */
3569  if (aarch64_sys_regs[i].value == opnd->sysreg.value
3571  && (name == NULL || exact_match))
3572  {
3574  if (exact_match)
3575  {
3576  if (notes)
3577  *notes = NULL;
3578  break;
3579  }
3580 
3581  /* If we didn't match exactly, that means the presense of a flag
3582  indicates what we didn't want for this instruction. e.g. If
3583  F_REG_READ is there, that means we were looking for a write
3584  register. See aarch64_ext_sysreg. */
3586  *notes = _("reading from a write-only register.");
3587  else if (aarch64_sys_regs[i].flags & F_REG_READ)
3588  *notes = _("writing to a read-only register.");
3589  }
3590  }
3591 
3592  if (name)
3593  snprintf (buf, size, "%s", name);
3594  else
3595  {
3596  /* Implementation defined system register. */
3597  unsigned int value = opnd->sysreg.value;
3598  snprintf (buf, size, "s%u_%u_c%u_c%u_%u", (value >> 14) & 0x3,
3599  (value >> 11) & 0x7, (value >> 7) & 0xf, (value >> 3) & 0xf,
3600  value & 0x7);
3601  }
3602  break;
3603 
3605  for (i = 0; aarch64_pstatefields[i].name; ++i)
3606  if (aarch64_pstatefields[i].value == opnd->pstatefield)
3607  break;
3610  break;
3611 
3616  snprintf (buf, size, "%s", opnd->sysins_op->name);
3617  break;
3618 
3619  case AARCH64_OPND_BARRIER:
3620  snprintf (buf, size, "%s", opnd->barrier->name);
3621  break;
3622 
3624  /* Operand can be omitted, e.g. in DCPS1. */
3625  if (! optional_operand_p (opcode, idx)
3626  || (opnd->barrier->value
3628  snprintf (buf, size, "0x%x", opnd->barrier->value);
3629  break;
3630 
3631  case AARCH64_OPND_PRFOP:
3632  if (opnd->prfop->name != NULL)
3633  snprintf (buf, size, "%s", opnd->prfop->name);
3634  else
3635  snprintf (buf, size, "0x%02x", opnd->prfop->value);
3636  break;
3637 
3639  snprintf (buf, size, "%s", opnd->hint_option->name);
3640  break;
3641 
3642  default:
3643  assert (0);
3644  }
3645 }
3646 ␌
3647 #define CPENC(op0,op1,crn,crm,op2) \
3648  ((((op0) << 19) | ((op1) << 16) | ((crn) << 12) | ((crm) << 8) | ((op2) << 5)) >> 5)
3649  /* for 3.9.3 Instructions for Accessing Special Purpose Registers */
3650 #define CPEN_(op1,crm,op2) CPENC(3,(op1),4,(crm),(op2))
3651  /* for 3.9.10 System Instructions */
3652 #define CPENS(op1,crn,crm,op2) CPENC(1,(op1),(crn),(crm),(op2))
3653 
3654 #define C0 0
3655 #define C1 1
3656 #define C2 2
3657 #define C3 3
3658 #define C4 4
3659 #define C5 5
3660 #define C6 6
3661 #define C7 7
3662 #define C8 8
3663 #define C9 9
3664 #define C10 10
3665 #define C11 11
3666 #define C12 12
3667 #define C13 13
3668 #define C14 14
3669 #define C15 15
3670 
3671 /* TODO there is one more issues need to be resolved
3672  1. handle cpu-implementation-defined system registers. */
3674 {
3675  { "spsr_el1", CPEN_(0,C0,0), 0 }, /* = spsr_svc */
3676  { "spsr_el12", CPEN_ (5, C0, 0), F_ARCHEXT },
3677  { "elr_el1", CPEN_(0,C0,1), 0 },
3678  { "elr_el12", CPEN_ (5, C0, 1), F_ARCHEXT },
3679  { "sp_el0", CPEN_(0,C1,0), 0 },
3680  { "spsel", CPEN_(0,C2,0), 0 },
3681  { "daif", CPEN_(3,C2,1), 0 },
3682  { "currentel", CPEN_(0,C2,2), F_REG_READ }, /* RO */
3683  { "pan", CPEN_(0,C2,3), F_ARCHEXT },
3684  { "uao", CPEN_ (0, C2, 4), F_ARCHEXT },
3685  { "nzcv", CPEN_(3,C2,0), 0 },
3686  { "fpcr", CPEN_(3,C4,0), 0 },
3687  { "fpsr", CPEN_(3,C4,1), 0 },
3688  { "dspsr_el0", CPEN_(3,C5,0), 0 },
3689  { "dlr_el0", CPEN_(3,C5,1), 0 },
3690  { "spsr_el2", CPEN_(4,C0,0), 0 }, /* = spsr_hyp */
3691  { "elr_el2", CPEN_(4,C0,1), 0 },
3692  { "sp_el1", CPEN_(4,C1,0), 0 },
3693  { "spsr_irq", CPEN_(4,C3,0), 0 },
3694  { "spsr_abt", CPEN_(4,C3,1), 0 },
3695  { "spsr_und", CPEN_(4,C3,2), 0 },
3696  { "spsr_fiq", CPEN_(4,C3,3), 0 },
3697  { "spsr_el3", CPEN_(6,C0,0), 0 },
3698  { "elr_el3", CPEN_(6,C0,1), 0 },
3699  { "sp_el2", CPEN_(6,C1,0), 0 },
3700  { "spsr_svc", CPEN_(0,C0,0), F_DEPRECATED }, /* = spsr_el1 */
3701  { "spsr_hyp", CPEN_(4,C0,0), F_DEPRECATED }, /* = spsr_el2 */
3702  { "midr_el1", CPENC(3,0,C0,C0,0), F_REG_READ }, /* RO */
3703  { "ctr_el0", CPENC(3,3,C0,C0,1), F_REG_READ }, /* RO */
3704  { "mpidr_el1", CPENC(3,0,C0,C0,5), F_REG_READ }, /* RO */
3705  { "revidr_el1", CPENC(3,0,C0,C0,6), F_REG_READ }, /* RO */
3706  { "aidr_el1", CPENC(3,1,C0,C0,7), F_REG_READ }, /* RO */
3707  { "dczid_el0", CPENC(3,3,C0,C0,7), F_REG_READ }, /* RO */
3708  { "id_dfr0_el1", CPENC(3,0,C0,C1,2), F_REG_READ }, /* RO */
3709  { "id_pfr0_el1", CPENC(3,0,C0,C1,0), F_REG_READ }, /* RO */
3710  { "id_pfr1_el1", CPENC(3,0,C0,C1,1), F_REG_READ }, /* RO */
3711  { "id_afr0_el1", CPENC(3,0,C0,C1,3), F_REG_READ }, /* RO */
3712  { "id_mmfr0_el1", CPENC(3,0,C0,C1,4), F_REG_READ }, /* RO */
3713  { "id_mmfr1_el1", CPENC(3,0,C0,C1,5), F_REG_READ }, /* RO */
3714  { "id_mmfr2_el1", CPENC(3,0,C0,C1,6), F_REG_READ }, /* RO */
3715  { "id_mmfr3_el1", CPENC(3,0,C0,C1,7), F_REG_READ }, /* RO */
3716  { "id_mmfr4_el1", CPENC(3,0,C0,C2,6), F_REG_READ }, /* RO */
3717  { "id_isar0_el1", CPENC(3,0,C0,C2,0), F_REG_READ }, /* RO */
3718  { "id_isar1_el1", CPENC(3,0,C0,C2,1), F_REG_READ }, /* RO */
3719  { "id_isar2_el1", CPENC(3,0,C0,C2,2), F_REG_READ }, /* RO */
3720  { "id_isar3_el1", CPENC(3,0,C0,C2,3), F_REG_READ }, /* RO */
3721  { "id_isar4_el1", CPENC(3,0,C0,C2,4), F_REG_READ }, /* RO */
3722  { "id_isar5_el1", CPENC(3,0,C0,C2,5), F_REG_READ }, /* RO */
3723  { "mvfr0_el1", CPENC(3,0,C0,C3,0), F_REG_READ }, /* RO */
3724  { "mvfr1_el1", CPENC(3,0,C0,C3,1), F_REG_READ }, /* RO */
3725  { "mvfr2_el1", CPENC(3,0,C0,C3,2), F_REG_READ }, /* RO */
3726  { "ccsidr_el1", CPENC(3,1,C0,C0,0), F_REG_READ }, /* RO */
3727  { "id_aa64pfr0_el1", CPENC(3,0,C0,C4,0), F_REG_READ }, /* RO */
3728  { "id_aa64pfr1_el1", CPENC(3,0,C0,C4,1), F_REG_READ }, /* RO */
3729  { "id_aa64dfr0_el1", CPENC(3,0,C0,C5,0), F_REG_READ }, /* RO */
3730  { "id_aa64dfr1_el1", CPENC(3,0,C0,C5,1), F_REG_READ }, /* RO */
3731  { "id_aa64isar0_el1", CPENC(3,0,C0,C6,0), F_REG_READ }, /* RO */
3732  { "id_aa64isar1_el1", CPENC(3,0,C0,C6,1), F_REG_READ }, /* RO */
3733  { "id_aa64mmfr0_el1", CPENC(3,0,C0,C7,0), F_REG_READ }, /* RO */
3734  { "id_aa64mmfr1_el1", CPENC(3,0,C0,C7,1), F_REG_READ }, /* RO */
3735  { "id_aa64mmfr2_el1", CPENC (3, 0, C0, C7, 2), F_ARCHEXT | F_REG_READ }, /* RO */
3736  { "id_aa64afr0_el1", CPENC(3,0,C0,C5,4), F_REG_READ }, /* RO */
3737  { "id_aa64afr1_el1", CPENC(3,0,C0,C5,5), F_REG_READ }, /* RO */
3738  { "id_aa64zfr0_el1", CPENC (3, 0, C0, C4, 4), F_ARCHEXT | F_REG_READ }, /* RO */
3739  { "clidr_el1", CPENC(3,1,C0,C0,1), F_REG_READ }, /* RO */
3740  { "csselr_el1", CPENC(3,2,C0,C0,0), 0 },
3741  { "vpidr_el2", CPENC(3,4,C0,C0,0), 0 },
3742  { "vmpidr_el2", CPENC(3,4,C0,C0,5), 0 },
3743  { "sctlr_el1", CPENC(3,0,C1,C0,0), 0 },
3744  { "sctlr_el2", CPENC(3,4,C1,C0,0), 0 },
3745  { "sctlr_el3", CPENC(3,6,C1,C0,0), 0 },
3746  { "sctlr_el12", CPENC (3, 5, C1, C0, 0), F_ARCHEXT },
3747  { "actlr_el1", CPENC(3,0,C1,C0,1), 0 },
3748  { "actlr_el2", CPENC(3,4,C1,C0,1), 0 },
3749  { "actlr_el3", CPENC(3,6,C1,C0,1), 0 },
3750  { "cpacr_el1", CPENC(3,0,C1,C0,2), 0 },
3751  { "cpacr_el12", CPENC (3, 5, C1, C0, 2), F_ARCHEXT },
3752  { "cptr_el2", CPENC(3,4,C1,C1,2), 0 },
3753  { "cptr_el3", CPENC(3,6,C1,C1,2), 0 },
3754  { "scr_el3", CPENC(3,6,C1,C1,0), 0 },
3755  { "hcr_el2", CPENC(3,4,C1,C1,0), 0 },
3756  { "mdcr_el2", CPENC(3,4,C1,C1,1), 0 },
3757  { "mdcr_el3", CPENC(3,6,C1,C3,1), 0 },
3758  { "hstr_el2", CPENC(3,4,C1,C1,3), 0 },
3759  { "hacr_el2", CPENC(3,4,C1,C1,7), 0 },
3760  { "zcr_el1", CPENC (3, 0, C1, C2, 0), F_ARCHEXT },
3761  { "zcr_el12", CPENC (3, 5, C1, C2, 0), F_ARCHEXT },
3762  { "zcr_el2", CPENC (3, 4, C1, C2, 0), F_ARCHEXT },
3763  { "zcr_el3", CPENC (3, 6, C1, C2, 0), F_ARCHEXT },
3764  { "zidr_el1", CPENC (3, 0, C0, C0, 7), F_ARCHEXT },
3765  { "ttbr0_el1", CPENC(3,0,C2,C0,0), 0 },
3766  { "ttbr1_el1", CPENC(3,0,C2,C0,1), 0 },
3767  { "ttbr0_el2", CPENC(3,4,C2,C0,0), 0 },
3768  { "ttbr1_el2", CPENC (3, 4, C2, C0, 1), F_ARCHEXT },
3769  { "ttbr0_el3", CPENC(3,6,C2,C0,0), 0 },
3770  { "ttbr0_el12", CPENC (3, 5, C2, C0, 0), F_ARCHEXT },
3771  { "ttbr1_el12", CPENC (3, 5, C2, C0, 1), F_ARCHEXT },
3772  { "vttbr_el2", CPENC(3,4,C2,C1,0), 0 },
3773  { "tcr_el1", CPENC(3,0,C2,C0,2), 0 },
3774  { "tcr_el2", CPENC(3,4,C2,C0,2), 0 },
3775  { "tcr_el3", CPENC(3,6,C2,C0,2), 0 },
3776  { "tcr_el12", CPENC (3, 5, C2, C0, 2), F_ARCHEXT },
3777  { "vtcr_el2", CPENC(3,4,C2,C1,2), 0 },
3778  { "apiakeylo_el1", CPENC (3, 0, C2, C1, 0), F_ARCHEXT },
3779  { "apiakeyhi_el1", CPENC (3, 0, C2, C1, 1), F_ARCHEXT },
3780  { "apibkeylo_el1", CPENC (3, 0, C2, C1, 2), F_ARCHEXT },
3781  { "apibkeyhi_el1", CPENC (3, 0, C2, C1, 3), F_ARCHEXT },
3782  { "apdakeylo_el1", CPENC (3, 0, C2, C2, 0), F_ARCHEXT },
3783  { "apdakeyhi_el1", CPENC (3, 0, C2, C2, 1), F_ARCHEXT },
3784  { "apdbkeylo_el1", CPENC (3, 0, C2, C2, 2), F_ARCHEXT },
3785  { "apdbkeyhi_el1", CPENC (3, 0, C2, C2, 3), F_ARCHEXT },
3786  { "apgakeylo_el1", CPENC (3, 0, C2, C3, 0), F_ARCHEXT },
3787  { "apgakeyhi_el1", CPENC (3, 0, C2, C3, 1), F_ARCHEXT },
3788  { "afsr0_el1", CPENC(3,0,C5,C1,0), 0 },
3789  { "afsr1_el1", CPENC(3,0,C5,C1,1), 0 },
3790  { "afsr0_el2", CPENC(3,4,C5,C1,0), 0 },
3791  { "afsr1_el2", CPENC(3,4,C5,C1,1), 0 },
3792  { "afsr0_el3", CPENC(3,6,C5,C1,0), 0 },
3793  { "afsr0_el12", CPENC (3, 5, C5, C1, 0), F_ARCHEXT },
3794  { "afsr1_el3", CPENC(3,6,C5,C1,1), 0 },
3795  { "afsr1_el12", CPENC (3, 5, C5, C1, 1), F_ARCHEXT },
3796  { "esr_el1", CPENC(3,0,C5,C2,0), 0 },
3797  { "esr_el2", CPENC(3,4,C5,C2,0), 0 },
3798  { "esr_el3", CPENC(3,6,C5,C2,0), 0 },
3799  { "esr_el12", CPENC (3, 5, C5, C2, 0), F_ARCHEXT },
3800  { "vsesr_el2", CPENC (3, 4, C5, C2, 3), F_ARCHEXT },
3801  { "fpexc32_el2", CPENC(3,4,C5,C3,0), 0 },
3802  { "erridr_el1", CPENC (3, 0, C5, C3, 0), F_ARCHEXT | F_REG_READ }, /* RO */
3803  { "errselr_el1", CPENC (3, 0, C5, C3, 1), F_ARCHEXT },
3804  { "erxfr_el1", CPENC (3, 0, C5, C4, 0), F_ARCHEXT | F_REG_READ }, /* RO */
3805  { "erxctlr_el1", CPENC (3, 0, C5, C4, 1), F_ARCHEXT },
3806  { "erxstatus_el1", CPENC (3, 0, C5, C4, 2), F_ARCHEXT },
3807  { "erxaddr_el1", CPENC (3, 0, C5, C4, 3), F_ARCHEXT },
3808  { "erxmisc0_el1", CPENC (3, 0, C5, C5, 0), F_ARCHEXT },
3809  { "erxmisc1_el1", CPENC (3, 0, C5, C5, 1), F_ARCHEXT },
3810  { "far_el1", CPENC(3,0,C6,C0,0), 0 },
3811  { "far_el2", CPENC(3,4,C6,C0,0), 0 },
3812  { "far_el3", CPENC(3,6,C6,C0,0), 0 },
3813  { "far_el12", CPENC (3, 5, C6, C0, 0), F_ARCHEXT },
3814  { "hpfar_el2", CPENC(3,4,C6,C0,4), 0 },
3815  { "par_el1", CPENC(3,0,C7,C4,0), 0 },
3816  { "mair_el1", CPENC(3,0,C10,C2,0), 0 },
3817  { "mair_el2", CPENC(3,4,C10,C2,0), 0 },
3818  { "mair_el3", CPENC(3,6,C10,C2,0), 0 },
3819  { "mair_el12", CPENC (3, 5, C10, C2, 0), F_ARCHEXT },
3820  { "amair_el1", CPENC(3,0,C10,C3,0), 0 },
3821  { "amair_el2", CPENC(3,4,C10,C3,0), 0 },
3822  { "amair_el3", CPENC(3,6,C10,C3,0), 0 },
3823  { "amair_el12", CPENC (3, 5, C10, C3, 0), F_ARCHEXT },
3824  { "vbar_el1", CPENC(3,0,C12,C0,0), 0 },
3825  { "vbar_el2", CPENC(3,4,C12,C0,0), 0 },
3826  { "vbar_el3", CPENC(3,6,C12,C0,0), 0 },
3827  { "vbar_el12", CPENC (3, 5, C12, C0, 0), F_ARCHEXT },
3828  { "rvbar_el1", CPENC(3,0,C12,C0,1), F_REG_READ }, /* RO */
3829  { "rvbar_el2", CPENC(3,4,C12,C0,1), F_REG_READ }, /* RO */
3830  { "rvbar_el3", CPENC(3,6,C12,C0,1), F_REG_READ }, /* RO */
3831  { "rmr_el1", CPENC(3,0,C12,C0,2), 0 },
3832  { "rmr_el2", CPENC(3,4,C12,C0,2), 0 },
3833  { "rmr_el3", CPENC(3,6,C12,C0,2), 0 },
3834  { "isr_el1", CPENC(3,0,C12,C1,0), F_REG_READ }, /* RO */
3835  { "disr_el1", CPENC (3, 0, C12, C1, 1), F_ARCHEXT },
3836  { "vdisr_el2", CPENC (3, 4, C12, C1, 1), F_ARCHEXT },
3837  { "contextidr_el1", CPENC(3,0,C13,C0,1), 0 },
3838  { "contextidr_el2", CPENC (3, 4, C13, C0, 1), F_ARCHEXT },
3839  { "contextidr_el12", CPENC (3, 5, C13, C0, 1), F_ARCHEXT },
3840  { "tpidr_el0", CPENC(3,3,C13,C0,2), 0 },
3841  { "tpidrro_el0", CPENC(3,3,C13,C0,3), 0 }, /* RW */
3842  { "tpidr_el1", CPENC(3,0,C13,C0,4), 0 },
3843  { "tpidr_el2", CPENC(3,4,C13,C0,2), 0 },
3844  { "tpidr_el3", CPENC(3,6,C13,C0,2), 0 },
3845  { "teecr32_el1", CPENC(2,2,C0, C0,0), 0 }, /* See section 3.9.7.1 */
3846  { "cntfrq_el0", CPENC(3,3,C14,C0,0), 0 }, /* RW */
3847  { "cntpct_el0", CPENC(3,3,C14,C0,1), F_REG_READ }, /* RO */
3848  { "cntvct_el0", CPENC(3,3,C14,C0,2), F_REG_READ }, /* RO */
3849  { "cntvoff_el2", CPENC(3,4,C14,C0,3), 0 },
3850  { "cntkctl_el1", CPENC(3,0,C14,C1,0), 0 },
3851  { "cntkctl_el12", CPENC (3, 5, C14, C1, 0), F_ARCHEXT },
3852  { "cnthctl_el2", CPENC(3,4,C14,C1,0), 0 },
3853  { "cntp_tval_el0", CPENC(3,3,C14,C2,0), 0 },
3854  { "cntp_tval_el02", CPENC (3, 5, C14, C2, 0), F_ARCHEXT },
3855  { "cntp_ctl_el0", CPENC(3,3,C14,C2,1), 0 },
3856  { "cntp_ctl_el02", CPENC (3, 5, C14, C2, 1), F_ARCHEXT },
3857  { "cntp_cval_el0", CPENC(3,3,C14,C2,2), 0 },
3858  { "cntp_cval_el02", CPENC (3, 5, C14, C2, 2), F_ARCHEXT },
3859  { "cntv_tval_el0", CPENC(3,3,C14,C3,0), 0 },
3860  { "cntv_tval_el02", CPENC (3, 5, C14, C3, 0), F_ARCHEXT },
3861  { "cntv_ctl_el0", CPENC(3,3,C14,C3,1), 0 },
3862  { "cntv_ctl_el02", CPENC (3, 5, C14, C3, 1), F_ARCHEXT },
3863  { "cntv_cval_el0", CPENC(3,3,C14,C3,2), 0 },
3864  { "cntv_cval_el02", CPENC (3, 5, C14, C3, 2), F_ARCHEXT },
3865  { "cnthp_tval_el2", CPENC(3,4,C14,C2,0), 0 },
3866  { "cnthp_ctl_el2", CPENC(3,4,C14,C2,1), 0 },
3867  { "cnthp_cval_el2", CPENC(3,4,C14,C2,2), 0 },
3868  { "cntps_tval_el1", CPENC(3,7,C14,C2,0), 0 },
3869  { "cntps_ctl_el1", CPENC(3,7,C14,C2,1), 0 },
3870  { "cntps_cval_el1", CPENC(3,7,C14,C2,2), 0 },
3871  { "cnthv_tval_el2", CPENC (3, 4, C14, C3, 0), F_ARCHEXT },
3872  { "cnthv_ctl_el2", CPENC (3, 4, C14, C3, 1), F_ARCHEXT },
3873  { "cnthv_cval_el2", CPENC (3, 4, C14, C3, 2), F_ARCHEXT },
3874  { "dacr32_el2", CPENC(3,4,C3,C0,0), 0 },
3875  { "ifsr32_el2", CPENC(3,4,C5,C0,1), 0 },
3876  { "teehbr32_el1", CPENC(2,2,C1,C0,0), 0 },
3877  { "sder32_el3", CPENC(3,6,C1,C1,1), 0 },
3878  { "mdscr_el1", CPENC(2,0,C0, C2, 2), 0 },
3879  { "mdccsr_el0", CPENC(2,3,C0, C1, 0), F_REG_READ }, /* r */
3880  { "mdccint_el1", CPENC(2,0,C0, C2, 0), 0 },
3881  { "dbgdtr_el0", CPENC(2,3,C0, C4, 0), 0 },
3882  { "dbgdtrrx_el0", CPENC(2,3,C0, C5, 0), F_REG_READ }, /* r */
3883  { "dbgdtrtx_el0", CPENC(2,3,C0, C5, 0), F_REG_WRITE }, /* w */
3884  { "osdtrrx_el1", CPENC(2,0,C0, C0, 2), 0 },
3885  { "osdtrtx_el1", CPENC(2,0,C0, C3, 2), 0 },
3886  { "oseccr_el1", CPENC(2,0,C0, C6, 2), 0 },
3887  { "dbgvcr32_el2", CPENC(2,4,C0, C7, 0), 0 },
3888  { "dbgbvr0_el1", CPENC(2,0,C0, C0, 4), 0 },
3889  { "dbgbvr1_el1", CPENC(2,0,C0, C1, 4), 0 },
3890  { "dbgbvr2_el1", CPENC(2,0,C0, C2, 4), 0 },
3891  { "dbgbvr3_el1", CPENC(2,0,C0, C3, 4), 0 },
3892  { "dbgbvr4_el1", CPENC(2,0,C0, C4, 4), 0 },
3893  { "dbgbvr5_el1", CPENC(2,0,C0, C5, 4), 0 },
3894  { "dbgbvr6_el1", CPENC(2,0,C0, C6, 4), 0 },
3895  { "dbgbvr7_el1", CPENC(2,0,C0, C7, 4), 0 },
3896  { "dbgbvr8_el1", CPENC(2,0,C0, C8, 4), 0 },
3897  { "dbgbvr9_el1", CPENC(2,0,C0, C9, 4), 0 },
3898  { "dbgbvr10_el1", CPENC(2,0,C0, C10,4), 0 },
3899  { "dbgbvr11_el1", CPENC(2,0,C0, C11,4), 0 },
3900  { "dbgbvr12_el1", CPENC(2,0,C0, C12,4), 0 },
3901  { "dbgbvr13_el1", CPENC(2,0,C0, C13,4), 0 },
3902  { "dbgbvr14_el1", CPENC(2,0,C0, C14,4), 0 },
3903  { "dbgbvr15_el1", CPENC(2,0,C0, C15,4), 0 },
3904  { "dbgbcr0_el1", CPENC(2,0,C0, C0, 5), 0 },
3905  { "dbgbcr1_el1", CPENC(2,0,C0, C1, 5), 0 },
3906  { "dbgbcr2_el1", CPENC(2,0,C0, C2, 5), 0 },
3907  { "dbgbcr3_el1", CPENC(2,0,C0, C3, 5), 0 },
3908  { "dbgbcr4_el1", CPENC(2,0,C0, C4, 5), 0 },
3909  { "dbgbcr5_el1", CPENC(2,0,C0, C5, 5), 0 },
3910  { "dbgbcr6_el1", CPENC(2,0,C0, C6, 5), 0 },
3911  { "dbgbcr7_el1", CPENC(2,0,C0, C7, 5), 0 },
3912  { "dbgbcr8_el1", CPENC(2,0,C0, C8, 5), 0 },
3913  { "dbgbcr9_el1", CPENC(2,0,C0, C9, 5), 0 },
3914  { "dbgbcr10_el1", CPENC(2,0,C0, C10,5), 0 },
3915  { "dbgbcr11_el1", CPENC(2,0,C0, C11,5), 0 },
3916  { "dbgbcr12_el1", CPENC(2,0,C0, C12,5), 0 },
3917  { "dbgbcr13_el1", CPENC(2,0,C0, C13,5), 0 },
3918  { "dbgbcr14_el1", CPENC(2,0,C0, C14,5), 0 },
3919  { "dbgbcr15_el1", CPENC(2,0,C0, C15,5), 0 },
3920  { "dbgwvr0_el1", CPENC(2,0,C0, C0, 6), 0 },
3921  { "dbgwvr1_el1", CPENC(2,0,C0, C1, 6), 0 },
3922  { "dbgwvr2_el1", CPENC(2,0,C0, C2, 6), 0 },
3923  { "dbgwvr3_el1", CPENC(2,0,C0, C3, 6), 0 },
3924  { "dbgwvr4_el1", CPENC(2,0,C0, C4, 6), 0 },
3925  { "dbgwvr5_el1", CPENC(2,0,C0, C5, 6), 0 },
3926  { "dbgwvr6_el1", CPENC(2,0,C0, C6, 6), 0 },
3927  { "dbgwvr7_el1", CPENC(2,0,C0, C7, 6), 0 },
3928  { "dbgwvr8_el1", CPENC(2,0,C0, C8, 6), 0 },
3929  { "dbgwvr9_el1", CPENC(2,0,C0, C9, 6), 0 },
3930  { "dbgwvr10_el1", CPENC(2,0,C0, C10,6), 0 },
3931  { "dbgwvr11_el1", CPENC(2,0,C0, C11,6), 0 },
3932  { "dbgwvr12_el1", CPENC(2,0,C0, C12,6), 0 },
3933  { "dbgwvr13_el1", CPENC(2,0,C0, C13,6), 0 },
3934  { "dbgwvr14_el1", CPENC(2,0,C0, C14,6), 0 },
3935  { "dbgwvr15_el1", CPENC(2,0,C0, C15,6), 0 },
3936  { "dbgwcr0_el1", CPENC(2,0,C0, C0, 7), 0 },
3937  { "dbgwcr1_el1", CPENC(2,0,C0, C1, 7), 0 },
3938  { "dbgwcr2_el1", CPENC(2,0,C0, C2, 7), 0 },
3939  { "dbgwcr3_el1", CPENC(2,0,C0, C3, 7), 0 },
3940  { "dbgwcr4_el1", CPENC(2,0,C0, C4, 7), 0 },
3941  { "dbgwcr5_el1", CPENC(2,0,C0, C5, 7), 0 },
3942  { "dbgwcr6_el1", CPENC(2,0,C0, C6, 7), 0 },
3943  { "dbgwcr7_el1", CPENC(2,0,C0, C7, 7), 0 },
3944  { "dbgwcr8_el1", CPENC(2,0,C0, C8, 7), 0 },
3945  { "dbgwcr9_el1", CPENC(2,0,C0, C9, 7), 0 },
3946  { "dbgwcr10_el1", CPENC(2,0,C0, C10,7), 0 },
3947  { "dbgwcr11_el1", CPENC(2,0,C0, C11,7), 0 },
3948  { "dbgwcr12_el1", CPENC(2,0,C0, C12,7), 0 },
3949  { "dbgwcr13_el1", CPENC(2,0,C0, C13,7), 0 },
3950  { "dbgwcr14_el1", CPENC(2,0,C0, C14,7), 0 },
3951  { "dbgwcr15_el1", CPENC(2,0,C0, C15,7), 0 },
3952  { "mdrar_el1", CPENC(2,0,C1, C0, 0), F_REG_READ }, /* r */
3953  { "oslar_el1", CPENC(2,0,C1, C0, 4), F_REG_WRITE }, /* w */
3954  { "oslsr_el1", CPENC(2,0,C1, C1, 4), F_REG_READ }, /* r */
3955  { "osdlr_el1", CPENC(2,0,C1, C3, 4), 0 },
3956  { "dbgprcr_el1", CPENC(2,0,C1, C4, 4), 0 },
3957  { "dbgclaimset_el1", CPENC(2,0,C7, C8, 6), 0 },
3958  { "dbgclaimclr_el1", CPENC(2,0,C7, C9, 6), 0 },
3959  { "dbgauthstatus_el1", CPENC(2,0,C7, C14,6), F_REG_READ }, /* r */
3960  { "pmblimitr_el1", CPENC (3, 0, C9, C10, 0), F_ARCHEXT }, /* rw */
3961  { "pmbptr_el1", CPENC (3, 0, C9, C10, 1), F_ARCHEXT }, /* rw */
3962  { "pmbsr_el1", CPENC (3, 0, C9, C10, 3), F_ARCHEXT }, /* rw */
3963  { "pmbidr_el1", CPENC (3, 0, C9, C10, 7), F_ARCHEXT | F_REG_READ }, /* ro */
3964  { "pmscr_el1", CPENC (3, 0, C9, C9, 0), F_ARCHEXT }, /* rw */
3965  { "pmsicr_el1", CPENC (3, 0, C9, C9, 2), F_ARCHEXT }, /* rw */
3966  { "pmsirr_el1", CPENC (3, 0, C9, C9, 3), F_ARCHEXT }, /* rw */
3967  { "pmsfcr_el1", CPENC (3, 0, C9, C9, 4), F_ARCHEXT }, /* rw */
3968  { "pmsevfr_el1", CPENC (3, 0, C9, C9, 5), F_ARCHEXT }, /* rw */
3969  { "pmslatfr_el1", CPENC (3, 0, C9, C9, 6), F_ARCHEXT }, /* rw */
3970  { "pmsidr_el1", CPENC (3, 0, C9, C9, 7), F_ARCHEXT }, /* rw */
3971  { "pmscr_el2", CPENC (3, 4, C9, C9, 0), F_ARCHEXT }, /* rw */
3972  { "pmscr_el12", CPENC (3, 5, C9, C9, 0), F_ARCHEXT }, /* rw */
3973  { "pmcr_el0", CPENC(3,3,C9,C12, 0), 0 },
3974  { "pmcntenset_el0", CPENC(3,3,C9,C12, 1), 0 },
3975  { "pmcntenclr_el0", CPENC(3,3,C9,C12, 2), 0 },
3976  { "pmovsclr_el0", CPENC(3,3,C9,C12, 3), 0 },
3977  { "pmswinc_el0", CPENC(3,3,C9,C12, 4), F_REG_WRITE }, /* w */
3978  { "pmselr_el0", CPENC(3,3,C9,C12, 5), 0 },
3979  { "pmceid0_el0", CPENC(3,3,C9,C12, 6), F_REG_READ }, /* r */
3980  { "pmceid1_el0", CPENC(3,3,C9,C12, 7), F_REG_READ }, /* r */
3981  { "pmccntr_el0", CPENC(3,3,C9,C13, 0), 0 },
3982  { "pmxevtyper_el0", CPENC(3,3,C9,C13, 1), 0 },
3983  { "pmxevcntr_el0", CPENC(3,3,C9,C13, 2), 0 },
3984  { "pmuserenr_el0", CPENC(3,3,C9,C14, 0), 0 },
3985  { "pmintenset_el1", CPENC(3,0,C9,C14, 1), 0 },
3986  { "pmintenclr_el1", CPENC(3,0,C9,C14, 2), 0 },
3987  { "pmovsset_el0", CPENC(3,3,C9,C14, 3), 0 },
3988  { "pmevcntr0_el0", CPENC(3,3,C14,C8, 0), 0 },
3989  { "pmevcntr1_el0", CPENC(3,3,C14,C8, 1), 0 },
3990  { "pmevcntr2_el0", CPENC(3,3,C14,C8, 2), 0 },
3991  { "pmevcntr3_el0", CPENC(3,3,C14,C8, 3), 0 },
3992  { "pmevcntr4_el0", CPENC(3,3,C14,C8, 4), 0 },
3993  { "pmevcntr5_el0", CPENC(3,3,C14,C8, 5), 0 },
3994  { "pmevcntr6_el0", CPENC(3,3,C14,C8, 6), 0 },
3995  { "pmevcntr7_el0", CPENC(3,3,C14,C8, 7), 0 },
3996  { "pmevcntr8_el0", CPENC(3,3,C14,C9, 0), 0 },
3997  { "pmevcntr9_el0", CPENC(3,3,C14,C9, 1), 0 },
3998  { "pmevcntr10_el0", CPENC(3,3,C14,C9, 2), 0 },
3999  { "pmevcntr11_el0", CPENC(3,3,C14,C9, 3), 0 },
4000  { "pmevcntr12_el0", CPENC(3,3,C14,C9, 4), 0 },
4001  { "pmevcntr13_el0", CPENC(3,3,C14,C9, 5), 0 },
4002  { "pmevcntr14_el0", CPENC(3,3,C14,C9, 6), 0 },
4003  { "pmevcntr15_el0", CPENC(3,3,C14,C9, 7), 0 },
4004  { "pmevcntr16_el0", CPENC(3,3,C14,C10,0), 0 },
4005  { "pmevcntr17_el0", CPENC(3,3,C14,C10,1), 0 },
4006  { "pmevcntr18_el0", CPENC(3,3,C14,C10,2), 0 },
4007  { "pmevcntr19_el0", CPENC(3,3,C14,C10,3), 0 },
4008  { "pmevcntr20_el0", CPENC(3,3,C14,C10,4), 0 },
4009  { "pmevcntr21_el0", CPENC(3,3,C14,C10,5), 0 },
4010  { "pmevcntr22_el0", CPENC(3,3,C14,C10,6), 0 },
4011  { "pmevcntr23_el0", CPENC(3,3,C14,C10,7), 0 },
4012  { "pmevcntr24_el0", CPENC(3,3,C14,C11,0), 0 },
4013  { "pmevcntr25_el0", CPENC(3,3,C14,C11,1), 0 },
4014  { "pmevcntr26_el0", CPENC(3,3,C14,C11,2), 0 },
4015  { "pmevcntr27_el0", CPENC(3,3,C14,C11,3), 0 },
4016  { "pmevcntr28_el0", CPENC(3,3,C14,C11,4), 0 },
4017  { "pmevcntr29_el0", CPENC(3,3,C14,C11,5), 0 },
4018  { "pmevcntr30_el0", CPENC(3,3,C14,C11,6), 0 },
4019  { "pmevtyper0_el0", CPENC(3,3,C14,C12,0), 0 },
4020  { "pmevtyper1_el0", CPENC(3,3,C14,C12,1), 0 },
4021  { "pmevtyper2_el0", CPENC(3,3,C14,C12,2), 0 },
4022  { "pmevtyper3_el0", CPENC(3,3,C14,C12,3), 0 },
4023  { "pmevtyper4_el0", CPENC(3,3,C14,C12,4), 0 },
4024  { "pmevtyper5_el0", CPENC(3,3,C14,C12,5), 0 },
4025  { "pmevtyper6_el0", CPENC(3,3,C14,C12,6), 0 },
4026  { "pmevtyper7_el0", CPENC(3,3,C14,C12,7), 0 },
4027  { "pmevtyper8_el0", CPENC(3,3,C14,C13,0), 0 },
4028  { "pmevtyper9_el0", CPENC(3,3,C14,C13,1), 0 },
4029  { "pmevtyper10_el0", CPENC(3,3,C14,C13,2), 0 },
4030  { "pmevtyper11_el0", CPENC(3,3,C14,C13,3), 0 },
4031  { "pmevtyper12_el0", CPENC(3,3,C14,C13,4), 0 },
4032  { "pmevtyper13_el0", CPENC(3,3,C14,C13,5), 0 },
4033  { "pmevtyper14_el0", CPENC(3,3,C14,C13,6), 0 },
4034  { "pmevtyper15_el0", CPENC(3,3,C14,C13,7), 0 },
4035  { "pmevtyper16_el0", CPENC(3,3,C14,C14,0), 0 },
4036  { "pmevtyper17_el0", CPENC(3,3,C14,C14,1), 0 },
4037  { "pmevtyper18_el0", CPENC(3,3,C14,C14,2), 0 },
4038  { "pmevtyper19_el0", CPENC(3,3,C14,C14,3), 0 },
4039  { "pmevtyper20_el0", CPENC(3,3,C14,C14,4), 0 },
4040  { "pmevtyper21_el0", CPENC(3,3,C14,C14,5), 0 },
4041  { "pmevtyper22_el0", CPENC(3,3,C14,C14,6), 0 },
4042  { "pmevtyper23_el0", CPENC(3,3,C14,C14,7), 0 },
4043  { "pmevtyper24_el0", CPENC(3,3,C14,C15,0), 0 },
4044  { "pmevtyper25_el0", CPENC(3,3,C14,C15,1), 0 },
4045  { "pmevtyper26_el0", CPENC(3,3,C14,C15,2), 0 },
4046  { "pmevtyper27_el0", CPENC(3,3,C14,C15,3), 0 },
4047  { "pmevtyper28_el0", CPENC(3,3,C14,C15,4), 0 },
4048  { "pmevtyper29_el0", CPENC(3,3,C14,C15,5), 0 },
4049  { "pmevtyper30_el0", CPENC(3,3,C14,C15,6), 0 },
4050  { "pmccfiltr_el0", CPENC(3,3,C14,C15,7), 0 },
4051 
4052  { "dit", CPEN_ (3, C2, 5), F_ARCHEXT },
4053  { "vstcr_el2", CPENC(3, 4, C2, C6, 2), F_ARCHEXT },
4054  { "vsttbr_el2", CPENC(3, 4, C2, C6, 0), F_ARCHEXT },
4055  { "cnthvs_tval_el2", CPENC(3, 4, C14, C4, 0), F_ARCHEXT },
4056  { "cnthvs_cval_el2", CPENC(3, 4, C14, C4, 2), F_ARCHEXT },
4057  { "cnthvs_ctl_el2", CPENC(3, 4, C14, C4, 1), F_ARCHEXT },
4058  { "cnthps_tval_el2", CPENC(3, 4, C14, C5, 0), F_ARCHEXT },
4059  { "cnthps_cval_el2", CPENC(3, 4, C14, C5, 2), F_ARCHEXT },
4060  { "cnthps_ctl_el2", CPENC(3, 4, C14, C5, 1), F_ARCHEXT },
4061  { "sder32_el2", CPENC(3, 4, C1, C3, 1), F_ARCHEXT },
4062  { "vncr_el2", CPENC(3, 4, C2, C2, 0), F_ARCHEXT },
4063  { 0, CPENC(0,0,0,0,0), 0 },
4064 };
4065 
4068 {
4069  return (reg->flags & F_DEPRECATED) != 0;
4070 }
4071 
4074  const aarch64_sys_reg *reg)
4075 {
4076  if (!(reg->flags & F_ARCHEXT))
4077  return TRUE;
4078 
4079  /* PAN. Values are from aarch64_sys_regs. */
4080  if (reg->value == CPEN_(0,C2,3)
4082  return FALSE;
4083 
4084  /* Virtualization host extensions: system registers. */
4085  if ((reg->value == CPENC (3, 4, C2, C0, 1)
4086  || reg->value == CPENC (3, 4, C13, C0, 1)
4087  || reg->value == CPENC (3, 4, C14, C3, 0)
4088  || reg->value == CPENC (3, 4, C14, C3, 1)
4089  || reg->value == CPENC (3, 4, C14, C3, 2))
4091  return FALSE;
4092 
4093  /* Virtualization host extensions: *_el12 names of *_el1 registers. */
4094  if ((reg->value == CPEN_ (5, C0, 0)
4095  || reg->value == CPEN_ (5, C0, 1)
4096  || reg->value == CPENC (3, 5, C1, C0, 0)
4097  || reg->value == CPENC (3, 5, C1, C0, 2)
4098  || reg->value == CPENC (3, 5, C2, C0, 0)
4099  || reg->value == CPENC (3, 5, C2, C0, 1)
4100  || reg->value == CPENC (3, 5, C2, C0, 2)
4101  || reg->value == CPENC (3, 5, C5, C1, 0)
4102  || reg->value == CPENC (3, 5, C5, C1, 1)
4103  || reg->value == CPENC (3, 5, C5, C2, 0)
4104  || reg->value == CPENC (3, 5, C6, C0, 0)
4105  || reg->value == CPENC (3, 5, C10, C2, 0)
4106  || reg->value == CPENC (3, 5, C10, C3, 0)
4107  || reg->value == CPENC (3, 5, C12, C0, 0)
4108  || reg->value == CPENC (3, 5, C13, C0, 1)
4109  || reg->value == CPENC (3, 5, C14, C1, 0))
4111  return FALSE;
4112 
4113  /* Virtualization host extensions: *_el02 names of *_el0 registers. */
4114  if ((reg->value == CPENC (3, 5, C14, C2, 0)
4115  || reg->value == CPENC (3, 5, C14, C2, 1)
4116  || reg->value == CPENC (3, 5, C14, C2, 2)
4117  || reg->value == CPENC (3, 5, C14, C3, 0)
4118  || reg->value == CPENC (3, 5, C14, C3, 1)
4119  || reg->value == CPENC (3, 5, C14, C3, 2))
4121  return FALSE;
4122 
4123  /* ARMv8.2 features. */
4124 
4125  /* ID_AA64MMFR2_EL1. */
4126  if (reg->value == CPENC (3, 0, C0, C7, 2)
4128  return FALSE;
4129 
4130  /* PSTATE.UAO. */
4131  if (reg->value == CPEN_ (0, C2, 4)
4133  return FALSE;
4134 
4135  /* RAS extension. */
4136 
4137  /* ERRIDR_EL1, ERRSELR_EL1, ERXFR_EL1, ERXCTLR_EL1, ERXSTATUS_EL, ERXADDR_EL1,
4138  ERXMISC0_EL1 AND ERXMISC1_EL1. */
4139  if ((reg->value == CPENC (3, 0, C5, C3, 0)
4140  || reg->value == CPENC (3, 0, C5, C3, 1)
4141  || reg->value == CPENC (3, 0, C5, C3, 2)
4142  || reg->value == CPENC (3, 0, C5, C3, 3)
4143  || reg->value == CPENC (3, 0, C5, C4, 0)
4144  || reg->value == CPENC (3, 0, C5, C4, 1)
4145  || reg->value == CPENC (3, 0, C5, C4, 2)
4146  || reg->value == CPENC (3, 0, C5, C4, 3)
4147  || reg->value == CPENC (3, 0, C5, C5, 0)
4148  || reg->value == CPENC (3, 0, C5, C5, 1))
4150  return FALSE;
4151 
4152  /* VSESR_EL2, DISR_EL1 and VDISR_EL2. */
4153  if ((reg->value == CPENC (3, 4, C5, C2, 3)
4154  || reg->value == CPENC (3, 0, C12, C1, 1)
4155  || reg->value == CPENC (3, 4, C12, C1, 1))
4157  return FALSE;
4158 
4159  /* Statistical Profiling extension. */
4160  if ((reg->value == CPENC (3, 0, C9, C10, 0)
4161  || reg->value == CPENC (3, 0, C9, C10, 1)
4162  || reg->value == CPENC (3, 0, C9, C10, 3)
4163  || reg->value == CPENC (3, 0, C9, C10, 7)
4164  || reg->value == CPENC (3, 0, C9, C9, 0)
4165  || reg->value == CPENC (3, 0, C9, C9, 2)
4166  || reg->value == CPENC (3, 0, C9, C9, 3)
4167  || reg->value == CPENC (3, 0, C9, C9, 4)
4168  || reg->value == CPENC (3, 0, C9, C9, 5)
4169  || reg->value == CPENC (3, 0, C9, C9, 6)
4170  || reg->value == CPENC (3, 0, C9, C9, 7)
4171  || reg->value == CPENC (3, 4, C9, C9, 0)
4172  || reg->value == CPENC (3, 5, C9, C9, 0))
4174  return FALSE;
4175 
4176  /* ARMv8.3 Pointer authentication keys. */
4177  if ((reg->value == CPENC (3, 0, C2, C1, 0)
4178  || reg->value == CPENC (3, 0, C2, C1, 1)
4179  || reg->value == CPENC (3, 0, C2, C1, 2)
4180  || reg->value == CPENC (3, 0, C2, C1, 3)
4181  || reg->value == CPENC (3, 0, C2, C2, 0)
4182  || reg->value == CPENC (3, 0, C2, C2, 1)
4183  || reg->value == CPENC (3, 0, C2, C2, 2)
4184  || reg->value == CPENC (3, 0, C2, C2, 3)
4185  || reg->value == CPENC (3, 0, C2, C3, 0)
4186  || reg->value == CPENC (3, 0, C2, C3, 1))
4188  return FALSE;
4189 
4190  /* SVE. */
4191  if ((reg->value == CPENC (3, 0, C0, C4, 4)
4192  || reg->value == CPENC (3, 0, C1, C2, 0)
4193  || reg->value == CPENC (3, 4, C1, C2, 0)
4194  || reg->value == CPENC (3, 6, C1, C2, 0)
4195  || reg->value == CPENC (3, 5, C1, C2, 0)
4196  || reg->value == CPENC (3, 0, C0, C0, 7))
4198  return FALSE;
4199 
4200  /* ARMv8.4 features. */
4201 
4202  /* PSTATE.DIT. */
4203  if (reg->value == CPEN_ (3, C2, 5)
4205  return FALSE;
4206 
4207  /* Virtualization extensions. */
4208  if ((reg->value == CPENC(3, 4, C2, C6, 2)
4209  || reg->value == CPENC(3, 4, C2, C6, 0)
4210  || reg->value == CPENC(3, 4, C14, C4, 0)
4211  || reg->value == CPENC(3, 4, C14, C4, 2)
4212  || reg->value == CPENC(3, 4, C14, C4, 1)
4213  || reg->value == CPENC(3, 4, C14, C5, 0)
4214  || reg->value == CPENC(3, 4, C14, C5, 2)
4215  || reg->value == CPENC(3, 4, C14, C5, 1)
4216  || reg->value == CPENC(3, 4, C1, C3, 1)
4217  || reg->value == CPENC(3, 4, C2, C2, 0))
4219  return FALSE;
4220 
4221  /* ARMv8.4 TLB instructions. */
4222  if ((reg->value == CPENS (0, C8, C1, 0)
4223  || reg->value == CPENS (0, C8, C1, 1)
4224  || reg->value == CPENS (0, C8, C1, 2)
4225  || reg->value == CPENS (0, C8, C1, 3)
4226  || reg->value == CPENS (0, C8, C1, 5)
4227  || reg->value == CPENS (0, C8, C1, 7)
4228  || reg->value == CPENS (4, C8, C4, 0)
4229  || reg->value == CPENS (4, C8, C4, 4)
4230  || reg->value == CPENS (4, C8, C1, 1)
4231  || reg->value == CPENS (4, C8, C1, 5)
4232  || reg->value == CPENS (4, C8, C1, 6)
4233  || reg->value == CPENS (6, C8, C1, 1)
4234  || reg->value == CPENS (6, C8, C1, 5)
4235  || reg->value == CPENS (4, C8, C1, 0)
4236  || reg->value == CPENS (4, C8, C1, 4)
4237  || reg->value == CPENS (6, C8, C1, 0)
4238  || reg->value == CPENS (0, C8, C6, 1)
4239  || reg->value == CPENS (0, C8, C6, 3)
4240  || reg->value == CPENS (0, C8, C6, 5)
4241  || reg->value == CPENS (0, C8, C6, 7)
4242  || reg->value == CPENS (0, C8, C2, 1)
4243  || reg->value == CPENS (0, C8, C2, 3)
4244  || reg->value == CPENS (0, C8, C2, 5)
4245  || reg->value == CPENS (0, C8, C2, 7)
4246  || reg->value == CPENS (0, C8, C5, 1)
4247  || reg->value == CPENS (0, C8, C5, 3)
4248  || reg->value == CPENS (0, C8, C5, 5)
4249  || reg->value == CPENS (0, C8, C5, 7)
4250  || reg->value == CPENS (4, C8, C0, 2)
4251  || reg->value == CPENS (4, C8, C0, 6)
4252  || reg->value == CPENS (4, C8, C4, 2)
4253  || reg->value == CPENS (4, C8, C4, 6)
4254  || reg->value == CPENS (4, C8, C4, 3)
4255  || reg->value == CPENS (4, C8, C4, 7)
4256  || reg->value == CPENS (4, C8, C6, 1)
4257  || reg->value == CPENS (4, C8, C6, 5)
4258  || reg->value == CPENS (4, C8, C2, 1)
4259  || reg->value == CPENS (4, C8, C2, 5)
4260  || reg->value == CPENS (4, C8, C5, 1)
4261  || reg->value == CPENS (4, C8, C5, 5)
4262  || reg->value == CPENS (6, C8, C6, 1)
4263  || reg->value == CPENS (6, C8, C6, 5)
4264  || reg->value == CPENS (6, C8, C2, 1)
4265  || reg->value == CPENS (6, C8, C2, 5)
4266  || reg->value == CPENS (6, C8, C5, 1)
4267  || reg->value == CPENS (6, C8, C5, 5))
4269  return FALSE;
4270 
4271  return TRUE;
4272 }
4273 
4274 /* The CPENC below is fairly misleading, the fields
4275  here are not in CPENC form. They are in op2op1 form. The fields are encoded
4276  by ins_pstatefield, which just shifts the value by the width of the fields
4277  in a loop. So if you CPENC them only the first value will be set, the rest
4278  are masked out to 0. As an example. op2 = 3, op1=2. CPENC would produce a
4279  value of 0b110000000001000000 (0x30040) while what you want is
4280  0b011010 (0x1a). */
4282 {
4283  { "spsel", 0x05, 0 },
4284  { "daifset", 0x1e, 0 },
4285  { "daifclr", 0x1f, 0 },
4286  { "pan", 0x04, F_ARCHEXT },
4287  { "uao", 0x03, F_ARCHEXT },
4288  { "dit", 0x1a, F_ARCHEXT },
4289  { 0, CPENC(0,0,0,0,0), 0 },
4290 };
4291 
4294  const aarch64_sys_reg *reg)
4295 {
4296  if (!(reg->flags & F_ARCHEXT))
4297  return TRUE;
4298 
4299  /* PAN. Values are from aarch64_pstatefields. */
4300  if (reg->value == 0x04
4302  return FALSE;
4303 
4304  /* UAO. Values are from aarch64_pstatefields. */
4305  if (reg->value == 0x03
4307  return FALSE;
4308 
4309  /* DIT. Values are from aarch64_pstatefields. */
4310  if (reg->value == 0x1a
4312  return FALSE;
4313 
4314  return TRUE;
4315 }
4316 
4318 {
4319  { "ialluis", CPENS(0,C7,C1,0), 0 },
4320  { "iallu", CPENS(0,C7,C5,0), 0 },
4321  { "ivau", CPENS (3, C7, C5, 1), F_HASXT },
4322  { 0, CPENS(0,0,0,0), 0 }
4323 };
4324 
4326 {
4327  { "zva", CPENS (3, C7, C4, 1), F_HASXT },
4328  { "ivac", CPENS (0, C7, C6, 1), F_HASXT },
4329  { "isw", CPENS (0, C7, C6, 2), F_HASXT },
4330  { "cvac", CPENS (3, C7, C10, 1), F_HASXT },
4331  { "csw", CPENS (0, C7, C10, 2), F_HASXT },
4332  { "cvau", CPENS (3, C7, C11, 1), F_HASXT },
4333  { "cvap", CPENS (3, C7, C12, 1), F_HASXT | F_ARCHEXT },
4334  { "civac", CPENS (3, C7, C14, 1), F_HASXT },
4335  { "cisw", CPENS (0, C7, C14, 2), F_HASXT },
4336  { 0, CPENS(0,0,0,0), 0 }
4337 };
4338 
4340 {
4341  { "s1e1r", CPENS (0, C7, C8, 0), F_HASXT },
4342  { "s1e1w", CPENS (0, C7, C8, 1), F_HASXT },
4343  { "s1e0r", CPENS (0, C7, C8, 2), F_HASXT },
4344  { "s1e0w", CPENS (0, C7, C8, 3), F_HASXT },
4345  { "s12e1r", CPENS (4, C7, C8, 4), F_HASXT },
4346  { "s12e1w", CPENS (4, C7, C8, 5), F_HASXT },
4347  { "s12e0r", CPENS (4, C7, C8, 6), F_HASXT },
4348  { "s12e0w", CPENS (4, C7, C8, 7), F_HASXT },
4349  { "s1e2r", CPENS (4, C7, C8, 0), F_HASXT },
4350  { "s1e2w", CPENS (4, C7, C8, 1), F_HASXT },
4351  { "s1e3r", CPENS (6, C7, C8, 0), F_HASXT },
4352  { "s1e3w", CPENS (6, C7, C8, 1), F_HASXT },
4353  { "s1e1rp", CPENS (0, C7, C9, 0), F_HASXT | F_ARCHEXT },
4354  { "s1e1wp", CPENS (0, C7, C9, 1), F_HASXT | F_ARCHEXT },
4355  { 0, CPENS(0,0,0,0), 0 }
4356 };
4357 
4359 {
4360  { "vmalle1", CPENS(0,C8,C7,0), 0 },
4361  { "vae1", CPENS (0, C8, C7, 1), F_HASXT },
4362  { "aside1", CPENS (0, C8, C7, 2), F_HASXT },
4363  { "vaae1", CPENS (0, C8, C7, 3), F_HASXT },
4364  { "vmalle1is", CPENS(0,C8,C3,0), 0 },
4365  { "vae1is", CPENS (0, C8, C3, 1), F_HASXT },
4366  { "aside1is", CPENS (0, C8, C3, 2), F_HASXT },
4367  { "vaae1is", CPENS (0, C8, C3, 3), F_HASXT },
4368  { "ipas2e1is", CPENS (4, C8, C0, 1), F_HASXT },
4369  { "ipas2le1is",CPENS (4, C8, C0, 5), F_HASXT },
4370  { "ipas2e1", CPENS (4, C8, C4, 1), F_HASXT },
4371  { "ipas2le1", CPENS (4, C8, C4, 5), F_HASXT },
4372  { "vae2", CPENS (4, C8, C7, 1), F_HASXT },
4373  { "vae2is", CPENS (4, C8, C3, 1), F_HASXT },
4374  { "vmalls12e1",CPENS(4,C8,C7,6), 0 },
4375  { "vmalls12e1is",CPENS(4,C8,C3,6), 0 },
4376  { "vae3", CPENS (6, C8, C7, 1), F_HASXT },
4377  { "vae3is", CPENS (6, C8, C3, 1), F_HASXT },
4378  { "alle2", CPENS(4,C8,C7,0), 0 },
4379  { "alle2is", CPENS(4,C8,C3,0), 0 },
4380  { "alle1", CPENS(4,C8,C7,4), 0 },
4381  { "alle1is", CPENS(4,C8,C3,4), 0 },
4382  { "alle3", CPENS(6,C8,C7,0), 0 },
4383  { "alle3is", CPENS(6,C8,C3,0), 0 },
4384  { "vale1is", CPENS (0, C8, C3, 5), F_HASXT },
4385  { "vale2is", CPENS (4, C8, C3, 5), F_HASXT },
4386  { "vale3is", CPENS (6, C8, C3, 5), F_HASXT },
4387  { "vaale1is", CPENS (0, C8, C3, 7), F_HASXT },
4388  { "vale1", CPENS (0, C8, C7, 5), F_HASXT },
4389  { "vale2", CPENS (4, C8, C7, 5), F_HASXT },
4390  { "vale3", CPENS (6, C8, C7, 5), F_HASXT },
4391  { "vaale1", CPENS (0, C8, C7, 7), F_HASXT },
4392 
4393  { "vmalle1os", CPENS (0, C8, C1, 0), F_ARCHEXT },
4394  { "vae1os", CPENS (0, C8, C1, 1), F_HASXT | F_ARCHEXT },
4395  { "aside1os", CPENS (0, C8, C1, 2), F_HASXT | F_ARCHEXT },
4396  { "vaae1os", CPENS (0, C8, C1, 3), F_HASXT | F_ARCHEXT },
4397  { "vale1os", CPENS (0, C8, C1, 5), F_HASXT | F_ARCHEXT },
4398  { "vaale1os", CPENS (0, C8, C1, 7), F_HASXT | F_ARCHEXT },
4399  { "ipas2e1os", CPENS (4, C8, C4, 0), F_HASXT | F_ARCHEXT },
4400  { "ipas2le1os", CPENS (4, C8, C4, 4), F_HASXT | F_ARCHEXT },
4401  { "vae2os", CPENS (4, C8, C1, 1), F_HASXT | F_ARCHEXT },
4402  { "vale2os", CPENS (4, C8, C1, 5), F_HASXT | F_ARCHEXT },
4403  { "vmalls12e1os", CPENS (4, C8, C1, 6), F_ARCHEXT },
4404  { "vae3os", CPENS (6, C8, C1, 1), F_HASXT | F_ARCHEXT },
4405  { "vale3os", CPENS (6, C8, C1, 5), F_HASXT | F_ARCHEXT },
4406  { "alle2os", CPENS (4, C8, C1, 0), F_ARCHEXT },
4407  { "alle1os", CPENS (4, C8, C1, 4), F_ARCHEXT },
4408  { "alle3os", CPENS (6, C8, C1, 0), F_ARCHEXT },
4409 
4410  { "rvae1", CPENS (0, C8, C6, 1), F_HASXT | F_ARCHEXT },
4411  { "rvaae1", CPENS (0, C8, C6, 3), F_HASXT | F_ARCHEXT },
4412  { "rvale1", CPENS (0, C8, C6, 5), F_HASXT | F_ARCHEXT },
4413  { "rvaale1", CPENS (0, C8, C6, 7), F_HASXT | F_ARCHEXT },
4414  { "rvae1is", CPENS (0, C8, C2, 1), F_HASXT | F_ARCHEXT },
4415  { "rvaae1is", CPENS (0, C8, C2, 3), F_HASXT | F_ARCHEXT },
4416  { "rvale1is", CPENS (0, C8, C2, 5), F_HASXT | F_ARCHEXT },
4417  { "rvaale1is", CPENS (0, C8, C2, 7), F_HASXT | F_ARCHEXT },
4418  { "rvae1os", CPENS (0, C8, C5, 1), F_HASXT | F_ARCHEXT },
4419  { "rvaae1os", CPENS (0, C8, C5, 3), F_HASXT | F_ARCHEXT },
4420  { "rvale1os", CPENS (0, C8, C5, 5), F_HASXT | F_ARCHEXT },
4421  { "rvaale1os", CPENS (0, C8, C5, 7), F_HASXT | F_ARCHEXT },
4422  { "ripas2e1is", CPENS (4, C8, C0, 2), F_HASXT | F_ARCHEXT },
4423  { "ripas2le1is",CPENS (4, C8, C0, 6), F_HASXT | F_ARCHEXT },
4424  { "ripas2e1", CPENS (4, C8, C4, 2), F_HASXT | F_ARCHEXT },
4425  { "ripas2le1", CPENS (4, C8, C4, 6), F_HASXT | F_ARCHEXT },
4426  { "ripas2e1os", CPENS (4, C8, C4, 3), F_HASXT | F_ARCHEXT },
4427  { "ripas2le1os",CPENS (4, C8, C4, 7), F_HASXT | F_ARCHEXT },
4428  { "rvae2", CPENS (4, C8, C6, 1), F_HASXT | F_ARCHEXT },
4429  { "rvale2", CPENS (4, C8, C6, 5), F_HASXT | F_ARCHEXT },
4430  { "rvae2is", CPENS (4, C8, C2, 1), F_HASXT | F_ARCHEXT },
4431  { "rvale2is", CPENS (4, C8, C2, 5), F_HASXT | F_ARCHEXT },
4432  { "rvae2os", CPENS (4, C8, C5, 1), F_HASXT | F_ARCHEXT },
4433  { "rvale2os", CPENS (4, C8, C5, 5), F_HASXT | F_ARCHEXT },
4434  { "rvae3", CPENS (6, C8, C6, 1), F_HASXT | F_ARCHEXT },
4435  { "rvale3", CPENS (6, C8, C6, 5), F_HASXT | F_ARCHEXT },
4436  { "rvae3is", CPENS (6, C8, C2, 1), F_HASXT | F_ARCHEXT },
4437  { "rvale3is", CPENS (6, C8, C2, 5), F_HASXT | F_ARCHEXT },
4438  { "rvae3os", CPENS (6, C8, C5, 1), F_HASXT | F_ARCHEXT },
4439  { "rvale3os", CPENS (6, C8, C5, 5), F_HASXT | F_ARCHEXT },
4440 
4441  { 0, CPENS(0,0,0,0), 0 }
4442 };
4443 
4446 {
4447  return (sys_ins_reg->flags & F_HASXT) != 0;
4448 }
4449 
4450 extern bfd_boolean
4452  const aarch64_sys_ins_reg *reg)
4453 {
4454  if (!(reg->flags & F_ARCHEXT))
4455  return TRUE;
4456 
4457  /* DC CVAP. Values are from aarch64_sys_regs_dc. */
4458  if (reg->value == CPENS (3, C7, C12, 1)
4460  return FALSE;
4461 
4462  /* AT S1E1RP, AT S1E1WP. Values are from aarch64_sys_regs_at. */
4463  if ((reg->value == CPENS (0, C7, C9, 0)
4464  || reg->value == CPENS (0, C7, C9, 1))
4466  return FALSE;
4467 
4468  return TRUE;
4469 }
4470 
4471 #undef C0
4472 #undef C1
4473 #undef C2
4474 #undef C3
4475 #undef C4
4476 #undef C5
4477 #undef C6
4478 #undef C7
4479 #undef C8
4480 #undef C9
4481 #undef C10
4482 #undef C11
4483 #undef C12
4484 #undef C13
4485 #undef C14
4486 #undef C15
4487 
4488 #define BIT(INSN,BT) (((INSN) >> (BT)) & 1)
4489 #define BITS(INSN,HI,LO) (((INSN) >> (LO)) & ((1 << (((HI) - (LO)) + 1)) - 1))
4490 
4491 static bfd_boolean
4493  const aarch64_insn insn)
4494 {
4495  int t = BITS (insn, 4, 0);
4496  int n = BITS (insn, 9, 5);
4497  int t2 = BITS (insn, 14, 10);
4498 
4499  if (BIT (insn, 23))
4500  {
4501  /* Write back enabled. */
4502  if ((t == n || t2 == n) && n != 31)
4503  return FALSE;
4504  }
4505 
4506  if (BIT (insn, 22))
4507  {
4508  /* Load */
4509  if (t == t2)
4510  return FALSE;
4511  }
4512 
4513  return TRUE;
4514 }
4515 
4516 /* Return true if VALUE cannot be moved into an SVE register using DUP
4517  (with any element size, not just ESIZE) and if using DUPM would
4518  therefore be OK. ESIZE is the number of bytes in the immediate. */
4519 
4522 {
4523  int64_t svalue = uvalue;
4524  uint64_t upper = (uint64_t) -1 << (esize * 4) << (esize * 4);
4525 
4526  if ((uvalue & ~upper) != uvalue && (uvalue | upper) != uvalue)
4527  return FALSE;
4528  if (esize <= 4 || (uint32_t) uvalue == (uint32_t) (uvalue >> 32))
4529  {
4530  svalue = (int32_t) uvalue;
4531  if (esize <= 2 || (uint16_t) uvalue == (uint16_t) (uvalue >> 16))
4532  {
4533  svalue = (int16_t) uvalue;
4534  if (esize == 1 || (uint8_t) uvalue == (uint8_t) (uvalue >> 8))
4535  return FALSE;
4536  }
4537  }
4538  if ((svalue & 0xff) == 0)
4539  svalue /= 256;
4540  return svalue < -128 || svalue >= 128;
4541 }
4542 
4543 /* Include the opcode description table as well as the operand description
4544  table. */
4545 #define VERIFIER(x) verify_##x
4546 #include "aarch64-tbl.h"
size_t len
Definition: 6502dis.c:15
const struct aarch64_operand aarch64_operands[]
Definition: aarch64-opc-2.c:28
bfd_boolean aarch64_sve_dupm_mov_immediate_p(uint64_t uvalue, int esize)
Definition: aarch64-opc.c:4521
#define C9
Definition: aarch64-opc.c:3663
#define CPENC(op0, op1, crn, crm, op2)
Definition: aarch64-opc.c:3647
static void set_imm_out_of_range_error(aarch64_operand_error *mismatch_detail, int idx, int lower_bound, int upper_bound)
Definition: aarch64-opc.c:1308
void aarch64_print_operand(char *buf, size_t size, bfd_vma pc, const aarch64_opcode *opcode, const aarch64_opnd_info *opnds, int idx, int *pcrel_p, bfd_vma *address, char **notes ATTRIBUTE_UNUSED)
Definition: aarch64-opc.c:3036
struct operand_qualifier_data aarch64_opnd_qualifiers[]
Definition: aarch64-opc.c:686
const aarch64_field fields[]
Definition: aarch64-opc.c:205
static void set_multiplier_out_of_range_error(aarch64_operand_error *mismatch_detail, int idx, int lower_bound, int upper_bound)
Definition: aarch64-opc.c:1360
static int get_upper_bound(aarch64_opnd_qualifier_t qualifier)
Definition: aarch64-opc.c:794
const aarch64_opcode * aarch64_replace_opcode(aarch64_inst *inst, const aarch64_opcode *opcode)
Definition: aarch64-opc.c:2715
const aarch64_sys_ins_reg aarch64_sys_regs_ic[]
Definition: aarch64-opc.c:4317
static bfd_boolean vector_qualifier_p(enum aarch64_opnd_qualifier qualifier)
Definition: aarch64-opc.c:109
unsigned char aarch64_get_qualifier_esize(aarch64_opnd_qualifier_t qualifier)
Definition: aarch64-opc.c:766
bfd_boolean aarch64_pstatefield_supported_p(const aarch64_feature_set features, const aarch64_sys_reg *reg)
Definition: aarch64-opc.c:4293
static simd_imm_encoding simd_immediates[TOTAL_IMM_NB]
Definition: aarch64-opc.c:1103
const aarch64_sys_ins_reg aarch64_sys_regs_at[]
Definition: aarch64-opc.c:4339
#define C15
Definition: aarch64-opc.c:3669
const aarch64_cond aarch64_conds[16]
Definition: aarch64-opc.c:348
#define C5
Definition: aarch64-opc.c:3659
#define C6
Definition: aarch64-opc.c:3660
static void set_other_error(aarch64_operand_error *mismatch_detail, int idx, const char *error)
Definition: aarch64-opc.c:1390
bfd_boolean aarch64_sys_reg_deprecated_p(const aarch64_sys_reg *reg)
Definition: aarch64-opc.c:4067
#define B(op, l, t)
Definition: aarch64-opc.c:479
#define R32(X)
#define C1
Definition: aarch64-opc.c:3655
const aarch64_sys_reg aarch64_sys_regs[]
Definition: aarch64-opc.c:3673
const struct aarch64_name_value_pair aarch64_prfops[32]
Definition: aarch64-opc.c:480
const char *const aarch64_sve_pattern_array[32]
Definition: aarch64-opc.c:43
enum aarch64_operand_class aarch64_get_operand_class(enum aarch64_opnd type)
Definition: aarch64-opc.c:328
static int operand_also_qualified_p(const struct aarch64_opnd_info *operand, aarch64_opnd_qualifier_t target)
Definition: aarch64-opc.c:585
static void set_syntax_error(aarch64_operand_error *mismatch_detail, int idx, const char *error)
Definition: aarch64-opc.c:1287
aarch64_insn aarch64_get_qualifier_standard_value(aarch64_opnd_qualifier_t qualifier)
Definition: aarch64-opc.c:780
aarch64_insn aarch64_get_operand_modifier_value(enum aarch64_modifier_kind kind)
Definition: aarch64-opc.c:414
bfd_boolean aarch64_sys_ins_reg_supported_p(const aarch64_feature_set features, const aarch64_sys_ins_reg *reg)
Definition: aarch64-opc.c:4451
#define C3
Definition: aarch64-opc.c:3657
int aarch64_num_of_operands(const aarch64_opcode *opcode)
Definition: aarch64-opc.c:842
static bfd_boolean fp_qualifier_p(enum aarch64_opnd_qualifier qualifier)
Definition: aarch64-opc.c:117
static void set_reg_list_error(aarch64_operand_error *mismatch_detail, int idx, int expected_num)
Definition: aarch64-opc.c:1380
const aarch64_sys_reg aarch64_pstatefields[]
Definition: aarch64-opc.c:4281
static void set_regno_out_of_range_error(aarch64_operand_error *mismatch_detail, int idx, int lower_bound, int upper_bound)
Definition: aarch64-opc.c:1328
const aarch64_sys_ins_reg aarch64_sys_regs_dc[]
Definition: aarch64-opc.c:4325
static bfd_boolean qualifier_value_in_range_constraint_p(aarch64_opnd_qualifier_t qualifier)
Definition: aarch64-opc.c:751
#define CPENS(op1, crn, crm, op2)
Definition: aarch64-opc.c:3652
#define BIT(INSN, BT)
Definition: aarch64-opc.c:4488
static int match_operands_qualifier(aarch64_inst *inst, bfd_boolean update_p)
Definition: aarch64-opc.c:987
static void print_register_offset_address(char *buf, size_t size, const aarch64_opnd_info *opnd, const char *base, const char *offset)
Definition: aarch64-opc.c:2987
int aarch64_stack_pointer_p(const aarch64_opnd_info *operand)
Definition: aarch64-opc.c:562
static void set_error(aarch64_operand_error *mismatch_detail, enum aarch64_operand_error_kind kind, int idx, const char *error)
Definition: aarch64-opc.c:1275
static const char * get_int_reg_name(int regno, aarch64_opnd_qualifier_t qualifier, int sp_reg_p)
Definition: aarch64-opc.c:2782
static int value_aligned_p(int64_t value, int align)
Definition: aarch64-opc.c:527
static bfd_boolean aarch64_shift_operator_p(enum aarch64_modifier_kind kind)
Definition: aarch64-opc.c:437
#define C8
Definition: aarch64-opc.c:3662
#define C10
Definition: aarch64-opc.c:3664
bfd_boolean aarch64_wide_constant_p(int64_t value, int is32, unsigned int *shift_amount)
Definition: aarch64-opc.c:1033
#define BANK(R, FOR31)
Definition: aarch64-opc.c:2748
static const char significant_operand_index[]
Definition: aarch64-opc.c:133
static int value_fit_unsigned_field_p(int64_t value, unsigned width)
Definition: aarch64-opc.c:548
static void build_immediate_table(void)
Definition: aarch64-opc.c:1133
static enum data_pattern get_data_pattern(const aarch64_opnd_qualifier_seq_t qualifiers)
Definition: aarch64-opc.c:148
const aarch64_sys_ins_reg aarch64_sys_regs_tlbi[]
Definition: aarch64-opc.c:4358
#define BITS(INSN, HI, LO)
Definition: aarch64-opc.c:4489
const struct aarch64_name_value_pair aarch64_operand_modifiers[]
Definition: aarch64-opc.c:386
#define R64(X)
int aarch64_shrink_expanded_imm8(uint64_t imm)
Definition: aarch64-opc.c:1255
static bfd_boolean verify_ldpsw(const struct aarch64_opcode *opcode ATTRIBUTE_UNUSED, const aarch64_insn insn)
Definition: aarch64-opc.c:4492
static int encode_immediate_bitfield(int is64, uint32_t s, uint32_t r)
Definition: aarch64-opc.c:1127
#define C12
Definition: aarch64-opc.c:3666
#define ZD(X)
bfd_boolean aarch64_sys_reg_supported_p(const aarch64_feature_set features, const aarch64_sys_reg *reg)
Definition: aarch64-opc.c:4073
static const char * get_offset_int_reg_name(const aarch64_opnd_info *opnd)
Definition: aarch64-opc.c:2802
operand_qualifier_kind
Definition: aarch64-opc.c:665
@ OQK_OPD_VARIANT
Definition: aarch64-opc.c:667
@ OQK_VALUE_IN_RANGE
Definition: aarch64-opc.c:668
@ OQK_NIL
Definition: aarch64-opc.c:666
@ OQK_MISC
Definition: aarch64-opc.c:669
aarch64_opnd_qualifier_t aarch64_get_expected_qualifier(const aarch64_opnd_qualifier_seq_t *qseq_list, int idx, const aarch64_opnd_qualifier_t known_qlf, int known_idx)
Definition: aarch64-opc.c:621
static bfd_boolean operand_variant_qualifier_p(aarch64_opnd_qualifier_t qualifier)
Definition: aarch64-opc.c:744
int aarch64_operand_index(const enum aarch64_opnd *operands, enum aarch64_opnd operand)
Definition: aarch64-opc.c:2736
int aarch64_match_operands_constraint(aarch64_inst *inst, aarch64_operand_error *mismatch_detail)
Definition: aarch64-opc.c:2632
static int operand_general_constraint_met_p(const aarch64_opnd_info *opnds, int idx, enum aarch64_opnd type, const aarch64_opcode *opcode, aarch64_operand_error *mismatch_detail)
Definition: aarch64-opc.c:1415
enum aarch64_modifier_kind aarch64_get_operand_modifier_from_value(aarch64_insn value, bfd_boolean extend_p)
Definition: aarch64-opc.c:420
static void set_sft_amount_out_of_range_error(aarch64_operand_error *mismatch_detail, int idx, int lower_bound, int upper_bound)
Definition: aarch64-opc.c:1348
#define ZS(X)
bfd_boolean aarch64_sys_ins_reg_has_xt(const aarch64_sys_ins_reg *sys_ins_reg)
Definition: aarch64-opc.c:4445
static const char * get_64bit_int_reg_name(int regno, int sp_reg_p)
Definition: aarch64-opc.c:2792
static int simd_imm_encoding_cmp(const void *i1, const void *i2)
Definition: aarch64-opc.c:1106
static void set_offset_out_of_range_error(aarch64_operand_error *mismatch_detail, int idx, int lower_bound, int upper_bound)
Definition: aarch64-opc.c:1318
static const char * int_reg[2][2][32]
Definition: aarch64-opc.c:2757
const char *const aarch64_sve_prfop_array[16]
Definition: aarch64-opc.c:84
enum aarch64_modifier_kind aarch64_get_operand_modifier(const struct aarch64_name_value_pair *desc)
Definition: aarch64-opc.c:408
bfd_boolean aarch64_extend_operator_p(enum aarch64_modifier_kind kind)
Definition: aarch64-opc.c:430
static int value_fit_signed_field_p(int64_t value, unsigned width)
Definition: aarch64-opc.c:534
const struct aarch64_name_value_pair aarch64_hint_options[]
Definition: aarch64-opc.c:470
const aarch64_cond * get_inverted_cond(const aarch64_cond *cond)
Definition: aarch64-opc.c:376
const char * aarch64_get_qualifier_name(aarch64_opnd_qualifier_t qualifier)
Definition: aarch64-opc.c:758
#define C13
Definition: aarch64-opc.c:3667
int aarch64_find_best_match(const aarch64_inst *inst, const aarch64_opnd_qualifier_seq_t *qualifiers_list, int stop_at, aarch64_opnd_qualifier_t *ret)
Definition: aarch64-opc.c:876
static const char * get_addr_sve_reg_name(int regno, aarch64_opnd_qualifier_t qualifier)
Definition: aarch64-opc.c:2823
static int value_in_range_p(int64_t value, int low, int high)
Definition: aarch64-opc.c:520
#define CPEN_(op1, crm, op2)
Definition: aarch64-opc.c:3650
#define C0
Definition: aarch64-opc.c:3654
const char * aarch64_get_operand_name(enum aarch64_opnd type)
Definition: aarch64-opc.c:334
bfd_boolean aarch64_logical_immediate_p(uint64_t value, int esize, aarch64_insn *encoding)
Definition: aarch64-opc.c:1207
#define TOTAL_IMM_NB
Definition: aarch64-opc.c:1095
static void set_out_of_range_error(aarch64_operand_error *mismatch_detail, int idx, int lower_bound, int upper_bound, const char *error)
Definition: aarch64-opc.c:1296
static void set_elem_idx_out_of_range_error(aarch64_operand_error *mismatch_detail, int idx, int lower_bound, int upper_bound)
Definition: aarch64-opc.c:1338
#define C14
Definition: aarch64-opc.c:3668
#define C4
Definition: aarch64-opc.c:3658
const aarch64_cond * get_cond_from_value(aarch64_insn value)
Definition: aarch64-opc.c:369
#define C11
Definition: aarch64-opc.c:3665
unsigned char aarch64_get_qualifier_nelem(aarch64_opnd_qualifier_t qualifier)
Definition: aarch64-opc.c:773
static void print_immediate_offset_address(char *buf, size_t size, const aarch64_opnd_info *opnd, const char *base)
Definition: aarch64-opc.c:2957
static const char * sve_reg[2][32]
Definition: aarch64-opc.c:2769
#define C2
Definition: aarch64-opc.c:3656
data_pattern
Definition: aarch64-opc.c:125
@ DP_VECTOR_3SAME
Definition: aarch64-opc.c:127
@ DP_UNKNOWN
Definition: aarch64-opc.c:126
@ DP_VECTOR_WIDE
Definition: aarch64-opc.c:129
@ DP_VECTOR_ACROSS_LANES
Definition: aarch64-opc.c:130
@ DP_VECTOR_LONG
Definition: aarch64-opc.c:128
static void print_register_list(char *buf, size_t size, const aarch64_opnd_info *opnd, const char *prefix)
Definition: aarch64-opc.c:2898
int aarch64_select_operand_for_sizeq_field_coding(const aarch64_opcode *opcode)
Definition: aarch64-opc.c:199
int aarch64_zero_register_p(const aarch64_opnd_info *operand)
Definition: aarch64-opc.c:572
static void set_unaligned_error(aarch64_operand_error *mismatch_detail, int idx, int alignment)
Definition: aarch64-opc.c:1370
const struct aarch64_name_value_pair aarch64_barrier_options[16]
Definition: aarch64-opc.c:443
#define C7
Definition: aarch64-opc.c:3661
const char * aarch64_get_operand_desc(enum aarch64_opnd type)
Definition: aarch64-opc.c:342
static int get_lower_bound(aarch64_opnd_qualifier_t qualifier)
Definition: aarch64-opc.c:787
static uint64_t expand_fp_imm(int size, uint32_t imm8)
Definition: aarch64-opc.c:2859
#define F_DEPRECATED
Definition: aarch64-opc.h:204
#define OPD_F_NO_ZR
Definition: aarch64-opc.h:199
#define F_REG_READ
Definition: aarch64-opc.h:213
static bfd_boolean operand_maybe_stack_pointer(const aarch64_operand *operand)
Definition: aarch64-opc.h:243
static unsigned int get_logsz(unsigned int size)
Definition: aarch64-opc.h:475
#define F_REG_WRITE
Definition: aarch64-opc.h:216
#define F_HASXT
Definition: aarch64-opc.h:210
#define F_ARCHEXT
Definition: aarch64-opc.h:207
static unsigned int get_operand_specific_data(const aarch64_operand *operand)
Definition: aarch64-opc.h:250
static const aarch64_operand * get_operand_from_code(enum aarch64_opnd code)
Definition: aarch64-opc.h:276
static unsigned get_operand_fields_width(const aarch64_operand *operand)
Definition: aarch64-opc.h:265
static bfd_boolean operand_need_shift_by_two(const aarch64_operand *operand)
Definition: aarch64-opc.h:237
#define DEBUG_TRACE(M,...)
Definition: aarch64.h:1198
#define DEBUG_TRACE_IF(C, M,...)
Definition: aarch64.h:1199
unsigned char aarch64_opnd_qualifier_t
Definition: aarch64.h:652
aarch64_modifier_kind
Definition: aarch64.h:877
@ AARCH64_MOD_NONE
Definition: aarch64.h:878
@ AARCH64_MOD_SXTW
Definition: aarch64.h:890
@ AARCH64_MOD_ROR
Definition: aarch64.h:880
@ AARCH64_MOD_SXTX
Definition: aarch64.h:891
@ AARCH64_MOD_UXTW
Definition: aarch64.h:886
@ AARCH64_MOD_LSL
Definition: aarch64.h:883
@ AARCH64_MOD_UXTX
Definition: aarch64.h:887
@ AARCH64_MOD_MUL
Definition: aarch64.h:892
@ AARCH64_MOD_MSL
Definition: aarch64.h:879
@ AARCH64_MOD_UXTB
Definition: aarch64.h:884
@ AARCH64_MOD_MUL_VL
Definition: aarch64.h:893
aarch64_opnd_qualifier
Definition: aarch64.h:378
@ AARCH64_OPND_QLF_W
Definition: aarch64.h:384
@ AARCH64_OPND_QLF_SP
Definition: aarch64.h:387
@ AARCH64_OPND_QLF_S_D
Definition: aarch64.h:403
@ AARCH64_OPND_QLF_S_Q
Definition: aarch64.h:404
@ AARCH64_OPND_QLF_S_B
Definition: aarch64.h:400
@ AARCH64_OPND_QLF_P_M
Definition: aarch64.h:430
@ AARCH64_OPND_QLF_LSL
Definition: aarch64.h:443
@ AARCH64_OPND_QLF_V_8B
Definition: aarch64.h:418
@ AARCH64_OPND_QLF_S_S
Definition: aarch64.h:402
@ AARCH64_OPND_QLF_V_1Q
Definition: aarch64.h:427
@ AARCH64_OPND_QLF_WSP
Definition: aarch64.h:386
@ AARCH64_OPND_QLF_S_H
Definition: aarch64.h:401
@ AARCH64_OPND_QLF_X
Definition: aarch64.h:385
@ AARCH64_OPND_QLF_P_Z
Definition: aarch64.h:429
@ AARCH64_OPND_QLF_NIL
Definition: aarch64.h:380
@ AARCH64_OPND_QLF_MSL
Definition: aarch64.h:444
#define AARCH64_MAX_QLF_SEQ_NUM
Definition: aarch64.h:650
static bfd_boolean optional_operand_p(const aarch64_opcode *opcode, unsigned int idx)
Definition: aarch64.h:805
aarch64_operand_class
Definition: aarch64.h:124
@ AARCH64_OPND_CLASS_MODIFIED_REG
Definition: aarch64.h:127
@ AARCH64_OPND_CLASS_SYSTEM
Definition: aarch64.h:137
@ AARCH64_OPND_CLASS_INT_REG
Definition: aarch64.h:126
@ AARCH64_OPND_CLASS_IMMEDIATE
Definition: aarch64.h:136
@ AARCH64_OPND_CLASS_SVE_REG
Definition: aarch64.h:133
@ AARCH64_OPND_CLASS_ADDRESS
Definition: aarch64.h:135
@ AARCH64_OPND_CLASS_COND
Definition: aarch64.h:138
@ AARCH64_OPND_CLASS_SIMD_REGLIST
Definition: aarch64.h:132
@ AARCH64_OPND_CLASS_PRED_REG
Definition: aarch64.h:134
@ AARCH64_OPND_CLASS_SIMD_ELEMENT
Definition: aarch64.h:130
static unsigned int get_opcode_dependent_value(const aarch64_opcode *opcode)
Definition: aarch64.h:818
#define AARCH64_FEATURE_PAN
Definition: aarch64.h:56
static aarch64_insn get_optional_operand_default_value(const aarch64_opcode *opcode)
Definition: aarch64.h:812
static bfd_boolean empty_qualifier_sequence_p(const aarch64_opnd_qualifier_t *qualifiers)
Definition: aarch64.h:659
@ ldst_unscaled
Definition: aarch64.h:513
@ log_shift
Definition: aarch64.h:520
@ ldst_imm9
Definition: aarch64.h:508
@ ldstpair_off
Definition: aarch64.h:516
@ ldstpair_indexed
Definition: aarch64.h:517
@ asisdlsep
Definition: aarch64.h:473
@ ldstnapair_offs
Definition: aarch64.h:515
@ ldst_pos
Definition: aarch64.h:510
@ ldst_imm10
Definition: aarch64.h:509
@ asisdlsop
Definition: aarch64.h:475
@ ldst_unpriv
Definition: aarch64.h:512
aarch64_opnd_qualifier_t aarch64_opnd_qualifier_seq_t[AARCH64_MAX_OPND_NUM]
Definition: aarch64.h:655
#define AARCH64_MAX_OPND_NUM
Definition: aarch64.h:648
#define AARCH64_FEATURE_V8_2
Definition: aarch64.h:49
aarch64_operand_error_kind
Definition: aarch64.h:1093
@ AARCH64_OPDE_OUT_OF_RANGE
Definition: aarch64.h:1100
@ AARCH64_OPDE_INVALID_VARIANT
Definition: aarch64.h:1098
@ AARCH64_OPDE_UNTIED_OPERAND
Definition: aarch64.h:1099
@ AARCH64_OPDE_UNALIGNED
Definition: aarch64.h:1101
@ AARCH64_OPDE_REG_LIST
Definition: aarch64.h:1102
@ AARCH64_OPDE_SYNTAX_ERROR
Definition: aarch64.h:1096
@ AARCH64_OPDE_OTHER_ERROR
Definition: aarch64.h:1103
aarch64_opnd
Definition: aarch64.h:145
@ AARCH64_OPND_ADDR_SIMM10
Definition: aarch64.h:252
@ AARCH64_OPND_SVE_UIMM8_53
Definition: aarch64.h:351
@ AARCH64_OPND_Rm_SFT
Definition: aarch64.h:162
@ AARCH64_OPND_SVE_Rn_SP
Definition: aarch64.h:339
@ AARCH64_OPND_Sm
Definition: aarch64.h:173
@ AARCH64_OPND_FPIMM
Definition: aarch64.h:206
@ AARCH64_OPND_SVE_UIMM3
Definition: aarch64.h:348
@ AARCH64_OPND_UIMM3_OP1
Definition: aarch64.h:212
@ AARCH64_OPND_SVE_Vm
Definition: aarch64.h:354
@ AARCH64_OPND_SVE_ADDR_ZI_U5
Definition: aarch64.h:309
@ AARCH64_OPND_SVE_Pg4_5
Definition: aarch64.h:332
@ AARCH64_OPND_PRFOP
Definition: aarch64.h:266
@ AARCH64_OPND_SM3_IMM2
Definition: aarch64.h:369
@ AARCH64_OPND_FBITS
Definition: aarch64.h:226
@ AARCH64_OPND_SIMD_IMM
Definition: aarch64.h:199
@ AARCH64_OPND_SVE_Pg3
Definition: aarch64.h:331
@ AARCH64_OPND_SVE_ADDR_RI_S4x16
Definition: aarch64.h:269
@ AARCH64_OPND_CRm
Definition: aarch64.h:193
@ AARCH64_OPND_SVE_Pg4_16
Definition: aarch64.h:334
@ AARCH64_OPND_SVE_SIMM6
Definition: aarch64.h:346
@ AARCH64_OPND_IMM_2
Definition: aarch64.h:211
@ AARCH64_OPND_SVE_LIMM
Definition: aarch64.h:325
@ AARCH64_OPND_SIMM5
Definition: aarch64.h:219
@ AARCH64_OPND_SVE_IMM_ROT1
Definition: aarch64.h:322
@ AARCH64_OPND_BIT_NUM
Definition: aarch64.h:216
@ AARCH64_OPND_Va
Definition: aarch64.h:175
@ AARCH64_OPND_SVE_ADDR_RX_LSL2
Definition: aarch64.h:287
@ AARCH64_OPND_Fa
Definition: aarch64.h:167
@ AARCH64_OPND_LEt
Definition: aarch64.h:190
@ AARCH64_OPND_SVE_SHRIMM_PRED
Definition: aarch64.h:342
@ AARCH64_OPND_SVE_ADDR_RI_U6x2
Definition: aarch64.h:277
@ AARCH64_OPND_SVE_ADDR_RI_S4x4xVL
Definition: aarch64.h:273
@ AARCH64_OPND_ADDR_SIMM9_2
Definition: aarch64.h:245
@ AARCH64_OPND_IMM_VLSL
Definition: aarch64.h:197
@ AARCH64_OPND_SVE_ADDR_RR_LSL3
Definition: aarch64.h:284
@ AARCH64_OPND_SVE_Zm3_22_INDEX
Definition: aarch64.h:362
@ AARCH64_OPND_SVE_ADDR_RR_LSL2
Definition: aarch64.h:283
@ AARCH64_OPND_SIMD_FPIMM
Definition: aarch64.h:201
@ AARCH64_OPND_SVE_SHRIMM_UNPRED
Definition: aarch64.h:343
@ AARCH64_OPND_IMM_VLSR
Definition: aarch64.h:198
@ AARCH64_OPND_SVE_ADDR_ZZ_LSL
Definition: aarch64.h:313
@ AARCH64_OPND_SYSREG_IC
Definition: aarch64.h:262
@ AARCH64_OPND_SVE_ADDR_RZ_XTW3_14
Definition: aarch64.h:305
@ AARCH64_OPND_LIMM
Definition: aarch64.h:223
@ AARCH64_OPND_COND1
Definition: aarch64.h:233
@ AARCH64_OPND_BARRIER_PSB
Definition: aarch64.h:267
@ AARCH64_OPND_SVE_Zm3_INDEX
Definition: aarch64.h:361
@ AARCH64_OPND_SVE_Rm
Definition: aarch64.h:338
@ AARCH64_OPND_SVE_ADDR_RZ_XTW1_22
Definition: aarch64.h:299
@ AARCH64_OPND_SVE_Zd
Definition: aarch64.h:358
@ AARCH64_OPND_SVE_ADDR_RZ_XTW_14
Definition: aarch64.h:293
@ AARCH64_OPND_ADDR_UIMM12
Definition: aarch64.h:253
@ AARCH64_OPND_SVE_SHLIMM_PRED
Definition: aarch64.h:340
@ AARCH64_OPND_Em16
Definition: aarch64.h:184
@ AARCH64_OPND_SVE_SIMM8
Definition: aarch64.h:347
@ AARCH64_OPND_SVE_Pn
Definition: aarch64.h:336
@ AARCH64_OPND_LVt
Definition: aarch64.h:187
@ AARCH64_OPND_SVE_ADDR_RX_LSL3
Definition: aarch64.h:288
@ AARCH64_OPND_ADDR_SIMM9
Definition: aarch64.h:244
@ AARCH64_OPND_UIMM3_OP2
Definition: aarch64.h:213
@ AARCH64_OPND_SYSREG
Definition: aarch64.h:258
@ AARCH64_OPND_Ft2
Definition: aarch64.h:169
@ AARCH64_OPND_PSTATEFIELD
Definition: aarch64.h:259
@ AARCH64_OPND_SVE_ADDR_RZ_LSL3
Definition: aarch64.h:292
@ AARCH64_OPND_SVE_Pt
Definition: aarch64.h:337
@ AARCH64_OPND_Sd
Definition: aarch64.h:171
@ AARCH64_OPND_SVE_ADDR_RI_S4x3xVL
Definition: aarch64.h:272
@ AARCH64_OPND_SVE_ADDR_RX_LSL1
Definition: aarch64.h:286
@ AARCH64_OPND_SVE_ADDR_RR
Definition: aarch64.h:281
@ AARCH64_OPND_SVE_Zm_5
Definition: aarch64.h:359
@ AARCH64_OPND_SYSREG_AT
Definition: aarch64.h:260
@ AARCH64_OPND_SVE_LIMM_MOV
Definition: aarch64.h:326
@ AARCH64_OPND_IDX
Definition: aarch64.h:195
@ AARCH64_OPND_SVE_ZnxN
Definition: aarch64.h:366
@ AARCH64_OPND_SVE_I1_HALF_ONE
Definition: aarch64.h:319
@ AARCH64_OPND_ADDR_PCREL26
Definition: aarch64.h:239
@ AARCH64_OPND_Rn_SP
Definition: aarch64.h:158
@ AARCH64_OPND_SVE_VZn
Definition: aarch64.h:352
@ AARCH64_OPND_SVE_Pg4_10
Definition: aarch64.h:333
@ AARCH64_OPND_SIMD_IMM_SFT
Definition: aarch64.h:200
@ AARCH64_OPND_IMM_ROT2
Definition: aarch64.h:229
@ AARCH64_OPND_HALF
Definition: aarch64.h:225
@ AARCH64_OPND_ADDR_PCREL19
Definition: aarch64.h:237
@ AARCH64_OPND_IMMS
Definition: aarch64.h:208
@ AARCH64_OPND_SYSREG_DC
Definition: aarch64.h:261
@ AARCH64_OPND_SVE_ADDR_RI_S9xVL
Definition: aarch64.h:275
@ AARCH64_OPND_LVt_AL
Definition: aarch64.h:188
@ AARCH64_OPND_Fn
Definition: aarch64.h:165
@ AARCH64_OPND_BARRIER_ISB
Definition: aarch64.h:265
@ AARCH64_OPND_SIMD_ADDR_SIMPLE
Definition: aarch64.h:254
@ AARCH64_OPND_IMM_MOV
Definition: aarch64.h:227
@ AARCH64_OPND_Rd
Definition: aarch64.h:148
@ AARCH64_OPND_Em
Definition: aarch64.h:183
@ AARCH64_OPND_SVE_ADDR_RI_S6xVL
Definition: aarch64.h:274
@ AARCH64_OPND_Ft
Definition: aarch64.h:168
@ AARCH64_OPND_SVE_PRFOP
Definition: aarch64.h:329
@ AARCH64_OPND_ADDR_ADRP
Definition: aarch64.h:235
@ AARCH64_OPND_SVE_ADDR_RZ_XTW2_22
Definition: aarch64.h:303
@ AARCH64_OPND_SVE_UIMM7
Definition: aarch64.h:349
@ AARCH64_OPND_SVE_ADDR_RZ_XTW1_14
Definition: aarch64.h:297
@ AARCH64_OPND_SVE_ADDR_RI_U6
Definition: aarch64.h:276
@ AARCH64_OPND_SVE_AIMM
Definition: aarch64.h:316
@ AARCH64_OPND_SVE_SIMM5B
Definition: aarch64.h:345
@ AARCH64_OPND_NIL
Definition: aarch64.h:146
@ AARCH64_OPND_SHLL_IMM
Definition: aarch64.h:202
@ AARCH64_OPND_SVE_ADDR_RI_U6x8
Definition: aarch64.h:279
@ AARCH64_OPND_SVE_PATTERN
Definition: aarch64.h:327
@ AARCH64_OPND_SVE_ADDR_RZ_LSL2
Definition: aarch64.h:291
@ AARCH64_OPND_SVE_FPIMM8
Definition: aarch64.h:318
@ AARCH64_OPND_SVE_Za_16
Definition: aarch64.h:357
@ AARCH64_OPND_SVE_ADDR_RX
Definition: aarch64.h:285
@ AARCH64_OPND_ADDR_SIMM7
Definition: aarch64.h:243
@ AARCH64_OPND_NZCV
Definition: aarch64.h:220
@ AARCH64_OPND_LVn
Definition: aarch64.h:186
@ AARCH64_OPND_SVE_ADDR_RZ_LSL1
Definition: aarch64.h:290
@ AARCH64_OPND_SVE_UIMM8
Definition: aarch64.h:350
@ AARCH64_OPND_ADDR_PCREL21
Definition: aarch64.h:238
@ AARCH64_OPND_Rd_SP
Definition: aarch64.h:157
@ AARCH64_OPND_VdD1
Definition: aarch64.h:179
@ AARCH64_OPND_SVE_ZtxN
Definition: aarch64.h:368
@ AARCH64_OPND_ADDR_REGOFF
Definition: aarch64.h:242
@ AARCH64_OPND_AIMM
Definition: aarch64.h:224
@ AARCH64_OPND_IMMR
Definition: aarch64.h:207
@ AARCH64_OPND_VnD1
Definition: aarch64.h:180
@ AARCH64_OPND_SVE_SIMM5
Definition: aarch64.h:344
@ AARCH64_OPND_SVE_ADDR_RI_S4xVL
Definition: aarch64.h:270
@ AARCH64_OPND_UIMM4
Definition: aarch64.h:214
@ AARCH64_OPND_Rs
Definition: aarch64.h:153
@ AARCH64_OPND_SVE_ADDR_RZ
Definition: aarch64.h:289
@ AARCH64_OPND_SVE_Pd
Definition: aarch64.h:330
@ AARCH64_OPND_Rt2
Definition: aarch64.h:152
@ AARCH64_OPND_ADDR_OFFSET
Definition: aarch64.h:255
@ AARCH64_OPND_SVE_I1_HALF_TWO
Definition: aarch64.h:320
@ AARCH64_OPND_SVE_ADDR_RI_S4x2xVL
Definition: aarch64.h:271
@ AARCH64_OPND_SVE_Zm4_INDEX
Definition: aarch64.h:363
@ AARCH64_OPND_EXCEPTION
Definition: aarch64.h:217
@ AARCH64_OPND_Vd
Definition: aarch64.h:176
@ AARCH64_OPND_SVE_I1_ZERO_ONE
Definition: aarch64.h:321
@ AARCH64_OPND_SVE_ASIMM
Definition: aarch64.h:317
@ AARCH64_OPND_SVE_Za_5
Definition: aarch64.h:356
@ AARCH64_OPND_SVE_PATTERN_SCALED
Definition: aarch64.h:328
@ AARCH64_OPND_SVE_Pm
Definition: aarch64.h:335
@ AARCH64_OPND_SVE_ADDR_ZI_U5x8
Definition: aarch64.h:312
@ AARCH64_OPND_SVE_ADDR_RZ_XTW_22
Definition: aarch64.h:295
@ AARCH64_OPND_Fd
Definition: aarch64.h:164
@ AARCH64_OPND_SVE_SHLIMM_UNPRED
Definition: aarch64.h:341
@ AARCH64_OPND_SIMD_ADDR_POST
Definition: aarch64.h:256
@ AARCH64_OPND_SVE_ADDR_ZI_U5x4
Definition: aarch64.h:311
@ AARCH64_OPND_SVE_IMM_ROT2
Definition: aarch64.h:323
@ AARCH64_OPND_Vm
Definition: aarch64.h:178
@ AARCH64_OPND_IMM
Definition: aarch64.h:210
@ AARCH64_OPND_CCMP_IMM
Definition: aarch64.h:218
@ AARCH64_OPND_Rt
Definition: aarch64.h:151
@ AARCH64_OPND_IMM_ROT1
Definition: aarch64.h:228
@ AARCH64_OPND_Rt_SYS
Definition: aarch64.h:155
@ AARCH64_OPND_Rm
Definition: aarch64.h:150
@ AARCH64_OPND_SVE_Zn
Definition: aarch64.h:364
@ AARCH64_OPND_BARRIER
Definition: aarch64.h:264
@ AARCH64_OPND_SVE_ADDR_ZZ_UXTW
Definition: aarch64.h:315
@ AARCH64_OPND_Rm_SP
Definition: aarch64.h:159
@ AARCH64_OPND_SVE_Zt
Definition: aarch64.h:367
@ AARCH64_OPND_SVE_Zn_INDEX
Definition: aarch64.h:365
@ AARCH64_OPND_SVE_ADDR_RR_LSL1
Definition: aarch64.h:282
@ AARCH64_OPND_Rn
Definition: aarch64.h:149
@ AARCH64_OPND_SVE_Vd
Definition: aarch64.h:353
@ AARCH64_OPND_En
Definition: aarch64.h:182
@ AARCH64_OPND_MASK
Definition: aarch64.h:196
@ AARCH64_OPND_Rm_EXT
Definition: aarch64.h:161
@ AARCH64_OPND_SVE_ADDR_ZZ_SXTW
Definition: aarch64.h:314
@ AARCH64_OPND_SVE_Zm_16
Definition: aarch64.h:360
@ AARCH64_OPND_COND
Definition: aarch64.h:232
@ AARCH64_OPND_Ed
Definition: aarch64.h:181
@ AARCH64_OPND_IMM0
Definition: aarch64.h:204
@ AARCH64_OPND_ADDR_PCREL14
Definition: aarch64.h:236
@ AARCH64_OPND_SVE_ADDR_R
Definition: aarch64.h:280
@ AARCH64_OPND_SVE_ADDR_RZ_XTW3_22
Definition: aarch64.h:307
@ AARCH64_OPND_ADDR_SIMPLE
Definition: aarch64.h:241
@ AARCH64_OPND_Ra
Definition: aarch64.h:154
@ AARCH64_OPND_Sn
Definition: aarch64.h:172
@ AARCH64_OPND_FPIMM0
Definition: aarch64.h:205
@ AARCH64_OPND_SVE_ADDR_RI_U6x4
Definition: aarch64.h:278
@ AARCH64_OPND_SYSREG_TLBI
Definition: aarch64.h:263
@ AARCH64_OPND_SVE_ADDR_ZI_U5x2
Definition: aarch64.h:310
@ AARCH64_OPND_CRn
Definition: aarch64.h:192
@ AARCH64_OPND_Fm
Definition: aarch64.h:166
@ AARCH64_OPND_IMM_ROT3
Definition: aarch64.h:230
@ AARCH64_OPND_WIDTH
Definition: aarch64.h:209
@ AARCH64_OPND_SVE_Vn
Definition: aarch64.h:355
@ AARCH64_OPND_SVE_ADDR_RZ_XTW2_14
Definition: aarch64.h:301
@ AARCH64_OPND_UIMM7
Definition: aarch64.h:215
@ AARCH64_OPND_Vn
Definition: aarch64.h:177
@ AARCH64_OPND_PAIRREG
Definition: aarch64.h:160
@ AARCH64_OPND_SVE_INV_LIMM
Definition: aarch64.h:324
unsigned long long aarch64_feature_set
Definition: aarch64.h:96
#define AARCH64_FEATURE_V8_3
Definition: aarch64.h:50
#define AARCH64_FEATURE_SVE
Definition: aarch64.h:63
#define AARCH64_PCREL_OFFSET
Definition: aarch64.h:38
uint32_t aarch64_insn
Definition: aarch64.h:40
#define AARCH64_FEATURE_PROFILE
Definition: aarch64.h:62
@ OP_FCMLA_ELEM
Definition: aarch64.h:642
@ OP_MOV_IMM_WIDEN
Definition: aarch64.h:589
@ OP_MOV_IMM_LOG
Definition: aarch64.h:587
@ OP_BIC
Definition: aarch64.h:597
@ OP_MOV_IMM_WIDE
Definition: aarch64.h:588
#define AARCH64_FEATURE_V8_4
Definition: aarch64.h:45
#define AARCH64_FEATURE_RAS
Definition: aarch64.h:61
#define AARCH64_CPU_HAS_FEATURE(CPU, FEAT)
Definition: aarch64.h:104
#define AARCH64_FEATURE_V8_1
Definition: aarch64.h:59
#define F_STRICT
Definition: aarch64.h:772
#define e(frag)
#define mask()
#define imm
#define ARRAY_SIZE(a)
lzma_index ** i
Definition: index.h:629
static const char ext[]
Definition: apprentice.c:1981
operand
Definition: arc-opc.c:39
static RZ_NULLABLE RzILOpBitVector * shift(RzILOpBitVector *val, RZ_NULLABLE RzILOpBool **carry_out, arm_shifter type, RZ_OWN RzILOpBitVector *dist)
Definition: arm_il32.c:190
const char * desc
Definition: bin_vsf.c:19
static int value
Definition: cmd_api.c:93
#define NULL
Definition: cris-opc.c:27
#define r
Definition: crypto_rc6.c:12
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
static const struct @646 features[]
unsigned short prefix[65536]
Definition: gun.c:163
RZ_API const KEY_TYPE bool * found
Definition: ht_inc.h:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
#define reg(n)
#define ATTRIBUTE_UNUSED
Definition: ansidecl.h:288
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
Definition: sflib.h:126
assert(limit<=UINT32_MAX/2)
int n
Definition: mipsasm.c:19
int type
Definition: mipsasm.c:17
BFD_HOST_U_64_BIT bfd_vma
Definition: mybfd.h:111
int bfd_boolean
Definition: mybfd.h:98
#define TRUE
Definition: mybfd.h:103
#define FALSE
Definition: mybfd.h:102
int idx
Definition: setup.py:197
#define _(String)
Definition: opintl.h:53
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
Definition: qsort.h:130
static RzSocket * s
Definition: rtr.c:28
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
static int
Definition: sfsocketcall.h:114
unsigned short uint16_t
Definition: sftypes.h:30
long int64_t
Definition: sftypes.h:32
int int32_t
Definition: sftypes.h:33
unsigned int uint32_t
Definition: sftypes.h:29
unsigned long uint64_t
Definition: sftypes.h:28
short int16_t
Definition: sftypes.h:34
unsigned char uint8_t
Definition: sftypes.h:31
#define c(i)
Definition: sha256.c:43
#define cond(bop, top, mask, flags)
const char * names[4]
Definition: aarch64.h:907
aarch64_opnd_info operands[AARCH64_MAX_OPND_NUM]
Definition: aarch64.h:1035
const aarch64_opcode * opcode
Definition: aarch64.h:1029
aarch64_insn value
Definition: aarch64.h:834
const char * name
Definition: aarch64.h:833
aarch64_opnd_qualifier_seq_t qualifiers_list[AARCH64_MAX_QLF_SEQ_NUM]
Definition: aarch64.h:703
enum aarch64_insn_class iclass
Definition: aarch64.h:686
unsigned char tied_operand
Definition: aarch64.h:710
uint32_t flags
Definition: aarch64.h:706
enum aarch64_opnd operands[AARCH64_MAX_OPND_NUM]
Definition: aarch64.h:697
enum aarch64_op op
Definition: aarch64.h:689
const char * name
Definition: aarch64.h:673
enum aarch64_operand_error_kind kind
Definition: aarch64.h:1109
const char * error
Definition: aarch64.h:1111
const char * desc
Definition: aarch64-opc.h:183
const char * name
Definition: aarch64-opc.h:174
enum aarch64_operand_class op_class
Definition: aarch64-opc.h:170
aarch64_insn pstatefield
Definition: aarch64.h:981
const aarch64_cond * cond
Definition: aarch64.h:979
aarch64_opnd_qualifier_t qualifier
Definition: aarch64.h:921
struct aarch64_opnd_info::@37 shifter
struct aarch64_opnd_info::@35::@43 sysreg
struct aarch64_opnd_info::@35::@42 addr
const struct aarch64_name_value_pair * prfop
Definition: aarch64.h:985
int64_t amount
Definition: aarch64.h:996
unsigned operator_present
Definition: aarch64.h:993
unsigned present
Definition: aarch64.h:1007
const struct aarch64_name_value_pair * barrier
Definition: aarch64.h:983
struct aarch64_opnd_info::@35::@39 reglane
enum aarch64_modifier_kind kind
Definition: aarch64.h:992
struct aarch64_opnd_info::@35::@38 reg
const aarch64_sys_ins_reg * sysins_op
Definition: aarch64.h:982
unsigned amount_present
Definition: aarch64.h:995
struct aarch64_opnd_info::@35::@41 imm
unsigned skip
Definition: aarch64.h:999
struct aarch64_opnd_info::@35::@40 reglist
enum aarch64_opnd type
Definition: aarch64.h:920
const struct aarch64_name_value_pair * hint_option
Definition: aarch64.h:984
uint32_t flags
Definition: aarch64.h:861
const char * name
Definition: aarch64.h:859
uint32_t flags
Definition: aarch64.h:846
const char * name
Definition: aarch64.h:844
Definition: z80asm.h:102
enum operand_qualifier_kind kind
Definition: aarch64-opc.c:682
aarch64_insn encoding
Definition: aarch64-opc.c:1100
int width
Definition: main.c:10
#define PRIx64
Definition: sysdefs.h:94
static int initialized
Definition: tricore-dis.c:96
uint32_t i
Definition: aarch64-opc.c:2846
void error(const char *msg)
Definition: untgz.c:593
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4
static int addr
Definition: z80asm.c:58