1 /* aarch64-opc.c -- AArch64 opcode support.
2 Copyright (C) 2009-2016 Free Software Foundation, Inc.
3 Contributed by ARM Ltd.
5 This file is part of the GNU opcodes library.
7 This library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 It is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING3. If not,
19 see <http://www.gnu.org/licenses/>. */
30 #include "libiberty.h"
32 #include "aarch64-opc.h"
35 int debug_dump
= FALSE
;
36 #endif /* DEBUG_AARCH64 */
38 /* The enumeration strings associated with each value of a 5-bit SVE
39 pattern operand. A null entry indicates a reserved meaning. */
40 const char *const aarch64_sve_pattern_array
[32] = {
79 /* The enumeration strings associated with each value of a 4-bit SVE
80 prefetch operand. A null entry indicates a reserved meaning. */
81 const char *const aarch64_sve_prfop_array
[16] = {
102 /* Helper functions to determine which operand to be used to encode/decode
103 the size:Q fields for AdvSIMD instructions. */
105 static inline bfd_boolean
106 vector_qualifier_p (enum aarch64_opnd_qualifier qualifier
)
108 return ((qualifier
>= AARCH64_OPND_QLF_V_8B
109 && qualifier
<= AARCH64_OPND_QLF_V_1Q
) ? TRUE
113 static inline bfd_boolean
114 fp_qualifier_p (enum aarch64_opnd_qualifier qualifier
)
116 return ((qualifier
>= AARCH64_OPND_QLF_S_B
117 && qualifier
<= AARCH64_OPND_QLF_S_Q
) ? TRUE
127 DP_VECTOR_ACROSS_LANES
,
130 static const char significant_operand_index
[] =
132 0, /* DP_UNKNOWN, by default using operand 0. */
133 0, /* DP_VECTOR_3SAME */
134 1, /* DP_VECTOR_LONG */
135 2, /* DP_VECTOR_WIDE */
136 1, /* DP_VECTOR_ACROSS_LANES */
139 /* Given a sequence of qualifiers in QUALIFIERS, determine and return
141 N.B. QUALIFIERS is a possible sequence of qualifiers each of which
142 corresponds to one of a sequence of operands. */
144 static enum data_pattern
145 get_data_pattern (const aarch64_opnd_qualifier_seq_t qualifiers
)
147 if (vector_qualifier_p (qualifiers
[0]) == TRUE
)
149 /* e.g. v.4s, v.4s, v.4s
150 or v.4h, v.4h, v.h[3]. */
151 if (qualifiers
[0] == qualifiers
[1]
152 && vector_qualifier_p (qualifiers
[2]) == TRUE
153 && (aarch64_get_qualifier_esize (qualifiers
[0])
154 == aarch64_get_qualifier_esize (qualifiers
[1]))
155 && (aarch64_get_qualifier_esize (qualifiers
[0])
156 == aarch64_get_qualifier_esize (qualifiers
[2])))
157 return DP_VECTOR_3SAME
;
158 /* e.g. v.8h, v.8b, v.8b.
159 or v.4s, v.4h, v.h[2].
161 if (vector_qualifier_p (qualifiers
[1]) == TRUE
162 && aarch64_get_qualifier_esize (qualifiers
[0]) != 0
163 && (aarch64_get_qualifier_esize (qualifiers
[0])
164 == aarch64_get_qualifier_esize (qualifiers
[1]) << 1))
165 return DP_VECTOR_LONG
;
166 /* e.g. v.8h, v.8h, v.8b. */
167 if (qualifiers
[0] == qualifiers
[1]
168 && vector_qualifier_p (qualifiers
[2]) == TRUE
169 && aarch64_get_qualifier_esize (qualifiers
[0]) != 0
170 && (aarch64_get_qualifier_esize (qualifiers
[0])
171 == aarch64_get_qualifier_esize (qualifiers
[2]) << 1)
172 && (aarch64_get_qualifier_esize (qualifiers
[0])
173 == aarch64_get_qualifier_esize (qualifiers
[1])))
174 return DP_VECTOR_WIDE
;
176 else if (fp_qualifier_p (qualifiers
[0]) == TRUE
)
178 /* e.g. SADDLV <V><d>, <Vn>.<T>. */
179 if (vector_qualifier_p (qualifiers
[1]) == TRUE
180 && qualifiers
[2] == AARCH64_OPND_QLF_NIL
)
181 return DP_VECTOR_ACROSS_LANES
;
187 /* Select the operand to do the encoding/decoding of the 'size:Q' fields in
188 the AdvSIMD instructions. */
189 /* N.B. it is possible to do some optimization that doesn't call
190 get_data_pattern each time when we need to select an operand. We can
191 either buffer the caculated the result or statically generate the data,
192 however, it is not obvious that the optimization will bring significant
196 aarch64_select_operand_for_sizeq_field_coding (const aarch64_opcode
*opcode
)
199 significant_operand_index
[get_data_pattern (opcode
->qualifiers_list
[0])];
202 const aarch64_field fields
[] =
205 { 0, 4 }, /* cond2: condition in truly conditional-executed inst. */
206 { 0, 4 }, /* nzcv: flag bit specifier, encoded in the "nzcv" field. */
207 { 5, 5 }, /* defgh: d:e:f:g:h bits in AdvSIMD modified immediate. */
208 { 16, 3 }, /* abc: a:b:c bits in AdvSIMD modified immediate. */
209 { 5, 19 }, /* imm19: e.g. in CBZ. */
210 { 5, 19 }, /* immhi: e.g. in ADRP. */
211 { 29, 2 }, /* immlo: e.g. in ADRP. */
212 { 22, 2 }, /* size: in most AdvSIMD and floating-point instructions. */
213 { 10, 2 }, /* vldst_size: size field in the AdvSIMD load/store inst. */
214 { 29, 1 }, /* op: in AdvSIMD modified immediate instructions. */
215 { 30, 1 }, /* Q: in most AdvSIMD instructions. */
216 { 0, 5 }, /* Rt: in load/store instructions. */
217 { 0, 5 }, /* Rd: in many integer instructions. */
218 { 5, 5 }, /* Rn: in many integer instructions. */
219 { 10, 5 }, /* Rt2: in load/store pair instructions. */
220 { 10, 5 }, /* Ra: in fp instructions. */
221 { 5, 3 }, /* op2: in the system instructions. */
222 { 8, 4 }, /* CRm: in the system instructions. */
223 { 12, 4 }, /* CRn: in the system instructions. */
224 { 16, 3 }, /* op1: in the system instructions. */
225 { 19, 2 }, /* op0: in the system instructions. */
226 { 10, 3 }, /* imm3: in add/sub extended reg instructions. */
227 { 12, 4 }, /* cond: condition flags as a source operand. */
228 { 12, 4 }, /* opcode: in advsimd load/store instructions. */
229 { 12, 4 }, /* cmode: in advsimd modified immediate instructions. */
230 { 13, 3 }, /* asisdlso_opcode: opcode in advsimd ld/st single element. */
231 { 13, 2 }, /* len: in advsimd tbl/tbx instructions. */
232 { 16, 5 }, /* Rm: in ld/st reg offset and some integer inst. */
233 { 16, 5 }, /* Rs: in load/store exclusive instructions. */
234 { 13, 3 }, /* option: in ld/st reg offset + add/sub extended reg inst. */
235 { 12, 1 }, /* S: in load/store reg offset instructions. */
236 { 21, 2 }, /* hw: in move wide constant instructions. */
237 { 22, 2 }, /* opc: in load/store reg offset instructions. */
238 { 23, 1 }, /* opc1: in load/store reg offset instructions. */
239 { 22, 2 }, /* shift: in add/sub reg/imm shifted instructions. */
240 { 22, 2 }, /* type: floating point type field in fp data inst. */
241 { 30, 2 }, /* ldst_size: size field in ld/st reg offset inst. */
242 { 10, 6 }, /* imm6: in add/sub reg shifted instructions. */
243 { 11, 4 }, /* imm4: in advsimd ext and advsimd ins instructions. */
244 { 16, 5 }, /* imm5: in conditional compare (immediate) instructions. */
245 { 15, 7 }, /* imm7: in load/store pair pre/post index instructions. */
246 { 13, 8 }, /* imm8: in floating-point scalar move immediate inst. */
247 { 12, 9 }, /* imm9: in load/store pre/post index instructions. */
248 { 10, 12 }, /* imm12: in ld/st unsigned imm or add/sub shifted inst. */
249 { 5, 14 }, /* imm14: in test bit and branch instructions. */
250 { 5, 16 }, /* imm16: in exception instructions. */
251 { 0, 26 }, /* imm26: in unconditional branch instructions. */
252 { 10, 6 }, /* imms: in bitfield and logical immediate instructions. */
253 { 16, 6 }, /* immr: in bitfield and logical immediate instructions. */
254 { 16, 3 }, /* immb: in advsimd shift by immediate instructions. */
255 { 19, 4 }, /* immh: in advsimd shift by immediate instructions. */
256 { 22, 1 }, /* S: in LDRAA and LDRAB instructions. */
257 { 22, 1 }, /* N: in logical (immediate) instructions. */
258 { 11, 1 }, /* index: in ld/st inst deciding the pre/post-index. */
259 { 24, 1 }, /* index2: in ld/st pair inst deciding the pre/post-index. */
260 { 31, 1 }, /* sf: in integer data processing instructions. */
261 { 30, 1 }, /* lse_size: in LSE extension atomic instructions. */
262 { 11, 1 }, /* H: in advsimd scalar x indexed element instructions. */
263 { 21, 1 }, /* L: in advsimd scalar x indexed element instructions. */
264 { 20, 1 }, /* M: in advsimd scalar x indexed element instructions. */
265 { 31, 1 }, /* b5: in the test bit and branch instructions. */
266 { 19, 5 }, /* b40: in the test bit and branch instructions. */
267 { 10, 6 }, /* scale: in the fixed-point scalar to fp converting inst. */
268 { 4, 1 }, /* SVE_M_4: Merge/zero select, bit 4. */
269 { 14, 1 }, /* SVE_M_14: Merge/zero select, bit 14. */
270 { 16, 1 }, /* SVE_M_16: Merge/zero select, bit 16. */
271 { 17, 1 }, /* SVE_N: SVE equivalent of N. */
272 { 0, 4 }, /* SVE_Pd: p0-p15, bits [3,0]. */
273 { 10, 3 }, /* SVE_Pg3: p0-p7, bits [12,10]. */
274 { 5, 4 }, /* SVE_Pg4_5: p0-p15, bits [8,5]. */
275 { 10, 4 }, /* SVE_Pg4_10: p0-p15, bits [13,10]. */
276 { 16, 4 }, /* SVE_Pg4_16: p0-p15, bits [19,16]. */
277 { 16, 4 }, /* SVE_Pm: p0-p15, bits [19,16]. */
278 { 5, 4 }, /* SVE_Pn: p0-p15, bits [8,5]. */
279 { 0, 4 }, /* SVE_Pt: p0-p15, bits [3,0]. */
280 { 5, 5 }, /* SVE_Rm: SVE alternative position for Rm. */
281 { 16, 5 }, /* SVE_Rn: SVE alternative position for Rn. */
282 { 0, 5 }, /* SVE_Vd: Scalar SIMD&FP register, bits [4,0]. */
283 { 5, 5 }, /* SVE_Vm: Scalar SIMD&FP register, bits [9,5]. */
284 { 5, 5 }, /* SVE_Vn: Scalar SIMD&FP register, bits [9,5]. */
285 { 5, 5 }, /* SVE_Za_5: SVE vector register, bits [9,5]. */
286 { 16, 5 }, /* SVE_Za_16: SVE vector register, bits [20,16]. */
287 { 0, 5 }, /* SVE_Zd: SVE vector register. bits [4,0]. */
288 { 5, 5 }, /* SVE_Zm_5: SVE vector register, bits [9,5]. */
289 { 16, 5 }, /* SVE_Zm_16: SVE vector register, bits [20,16]. */
290 { 5, 5 }, /* SVE_Zn: SVE vector register, bits [9,5]. */
291 { 0, 5 }, /* SVE_Zt: SVE vector register, bits [4,0]. */
292 { 5, 1 }, /* SVE_i1: single-bit immediate. */
293 { 16, 3 }, /* SVE_imm3: 3-bit immediate field. */
294 { 16, 4 }, /* SVE_imm4: 4-bit immediate field. */
295 { 5, 5 }, /* SVE_imm5: 5-bit immediate field. */
296 { 16, 5 }, /* SVE_imm5b: secondary 5-bit immediate field. */
297 { 16, 6 }, /* SVE_imm6: 6-bit immediate field. */
298 { 14, 7 }, /* SVE_imm7: 7-bit immediate field. */
299 { 5, 8 }, /* SVE_imm8: 8-bit immediate field. */
300 { 5, 9 }, /* SVE_imm9: 9-bit immediate field. */
301 { 11, 6 }, /* SVE_immr: SVE equivalent of immr. */
302 { 5, 6 }, /* SVE_imms: SVE equivalent of imms. */
303 { 10, 2 }, /* SVE_msz: 2-bit shift amount for ADR. */
304 { 5, 5 }, /* SVE_pattern: vector pattern enumeration. */
305 { 0, 4 }, /* SVE_prfop: prefetch operation for SVE PRF[BHWD]. */
306 { 22, 1 }, /* SVE_sz: 1-bit element size select. */
307 { 16, 4 }, /* SVE_tsz: triangular size select. */
308 { 22, 2 }, /* SVE_tszh: triangular size select high, bits [23,22]. */
309 { 8, 2 }, /* SVE_tszl_8: triangular size select low, bits [9,8]. */
310 { 19, 2 }, /* SVE_tszl_19: triangular size select low, bits [20,19]. */
311 { 14, 1 }, /* SVE_xs_14: UXTW/SXTW select (bit 14). */
312 { 22, 1 }, /* SVE_xs_22: UXTW/SXTW select (bit 22). */
313 { 11, 2 }, /* rotate1: FCMLA immediate rotate. */
314 { 13, 2 }, /* rotate2: Indexed element FCMLA immediate rotate. */
315 { 12, 1 }, /* rotate3: FCADD immediate rotate. */
318 enum aarch64_operand_class
319 aarch64_get_operand_class (enum aarch64_opnd type
)
321 return aarch64_operands
[type
].op_class
;
325 aarch64_get_operand_name (enum aarch64_opnd type
)
327 return aarch64_operands
[type
].name
;
330 /* Get operand description string.
331 This is usually for the diagnosis purpose. */
333 aarch64_get_operand_desc (enum aarch64_opnd type
)
335 return aarch64_operands
[type
].desc
;
338 /* Table of all conditional affixes. */
339 const aarch64_cond aarch64_conds
[16] =
341 {{"eq", "none"}, 0x0},
342 {{"ne", "any"}, 0x1},
343 {{"cs", "hs", "nlast"}, 0x2},
344 {{"cc", "lo", "ul", "last"}, 0x3},
345 {{"mi", "first"}, 0x4},
346 {{"pl", "nfrst"}, 0x5},
349 {{"hi", "pmore"}, 0x8},
350 {{"ls", "plast"}, 0x9},
351 {{"ge", "tcont"}, 0xa},
352 {{"lt", "tstop"}, 0xb},
360 get_cond_from_value (aarch64_insn value
)
363 return &aarch64_conds
[(unsigned int) value
];
367 get_inverted_cond (const aarch64_cond
*cond
)
369 return &aarch64_conds
[cond
->value
^ 0x1];
372 /* Table describing the operand extension/shifting operators; indexed by
373 enum aarch64_modifier_kind.
375 The value column provides the most common values for encoding modifiers,
376 which enables table-driven encoding/decoding for the modifiers. */
377 const struct aarch64_name_value_pair aarch64_operand_modifiers
[] =
398 enum aarch64_modifier_kind
399 aarch64_get_operand_modifier (const struct aarch64_name_value_pair
*desc
)
401 return desc
- aarch64_operand_modifiers
;
405 aarch64_get_operand_modifier_value (enum aarch64_modifier_kind kind
)
407 return aarch64_operand_modifiers
[kind
].value
;
410 enum aarch64_modifier_kind
411 aarch64_get_operand_modifier_from_value (aarch64_insn value
,
412 bfd_boolean extend_p
)
414 if (extend_p
== TRUE
)
415 return AARCH64_MOD_UXTB
+ value
;
417 return AARCH64_MOD_LSL
- value
;
421 aarch64_extend_operator_p (enum aarch64_modifier_kind kind
)
423 return (kind
> AARCH64_MOD_LSL
&& kind
<= AARCH64_MOD_SXTX
)
427 static inline bfd_boolean
428 aarch64_shift_operator_p (enum aarch64_modifier_kind kind
)
430 return (kind
>= AARCH64_MOD_ROR
&& kind
<= AARCH64_MOD_LSL
)
434 const struct aarch64_name_value_pair aarch64_barrier_options
[16] =
454 /* Table describing the operands supported by the aliases of the HINT
457 The name column is the operand that is accepted for the alias. The value
458 column is the hint number of the alias. The list of operands is terminated
459 by NULL in the name column. */
461 const struct aarch64_name_value_pair aarch64_hint_options
[] =
463 { "csync", 0x11 }, /* PSB CSYNC. */
467 /* op -> op: load = 0 instruction = 1 store = 2
469 t -> temporal: temporal (retained) = 0 non-temporal (streaming) = 1 */
470 #define B(op,l,t) (((op) << 3) | (((l) - 1) << 1) | (t))
471 const struct aarch64_name_value_pair aarch64_prfops
[32] =
473 { "pldl1keep", B(0, 1, 0) },
474 { "pldl1strm", B(0, 1, 1) },
475 { "pldl2keep", B(0, 2, 0) },
476 { "pldl2strm", B(0, 2, 1) },
477 { "pldl3keep", B(0, 3, 0) },
478 { "pldl3strm", B(0, 3, 1) },
481 { "plil1keep", B(1, 1, 0) },
482 { "plil1strm", B(1, 1, 1) },
483 { "plil2keep", B(1, 2, 0) },
484 { "plil2strm", B(1, 2, 1) },
485 { "plil3keep", B(1, 3, 0) },
486 { "plil3strm", B(1, 3, 1) },
489 { "pstl1keep", B(2, 1, 0) },
490 { "pstl1strm", B(2, 1, 1) },
491 { "pstl2keep", B(2, 2, 0) },
492 { "pstl2strm", B(2, 2, 1) },
493 { "pstl3keep", B(2, 3, 0) },
494 { "pstl3strm", B(2, 3, 1) },
508 /* Utilities on value constraint. */
511 value_in_range_p (int64_t value
, int low
, int high
)
513 return (value
>= low
&& value
<= high
) ? 1 : 0;
516 /* Return true if VALUE is a multiple of ALIGN. */
518 value_aligned_p (int64_t value
, int align
)
520 return (value
% align
) == 0;
523 /* A signed value fits in a field. */
525 value_fit_signed_field_p (int64_t value
, unsigned width
)
528 if (width
< sizeof (value
) * 8)
530 int64_t lim
= (int64_t)1 << (width
- 1);
531 if (value
>= -lim
&& value
< lim
)
537 /* An unsigned value fits in a field. */
539 value_fit_unsigned_field_p (int64_t value
, unsigned width
)
542 if (width
< sizeof (value
) * 8)
544 int64_t lim
= (int64_t)1 << width
;
545 if (value
>= 0 && value
< lim
)
551 /* Return 1 if OPERAND is SP or WSP. */
553 aarch64_stack_pointer_p (const aarch64_opnd_info
*operand
)
555 return ((aarch64_get_operand_class (operand
->type
)
556 == AARCH64_OPND_CLASS_INT_REG
)
557 && operand_maybe_stack_pointer (aarch64_operands
+ operand
->type
)
558 && operand
->reg
.regno
== 31);
561 /* Return 1 if OPERAND is XZR or WZP. */
563 aarch64_zero_register_p (const aarch64_opnd_info
*operand
)
565 return ((aarch64_get_operand_class (operand
->type
)
566 == AARCH64_OPND_CLASS_INT_REG
)
567 && !operand_maybe_stack_pointer (aarch64_operands
+ operand
->type
)
568 && operand
->reg
.regno
== 31);
571 /* Return true if the operand *OPERAND that has the operand code
572 OPERAND->TYPE and been qualified by OPERAND->QUALIFIER can be also
573 qualified by the qualifier TARGET. */
576 operand_also_qualified_p (const struct aarch64_opnd_info
*operand
,
577 aarch64_opnd_qualifier_t target
)
579 switch (operand
->qualifier
)
581 case AARCH64_OPND_QLF_W
:
582 if (target
== AARCH64_OPND_QLF_WSP
&& aarch64_stack_pointer_p (operand
))
585 case AARCH64_OPND_QLF_X
:
586 if (target
== AARCH64_OPND_QLF_SP
&& aarch64_stack_pointer_p (operand
))
589 case AARCH64_OPND_QLF_WSP
:
590 if (target
== AARCH64_OPND_QLF_W
591 && operand_maybe_stack_pointer (aarch64_operands
+ operand
->type
))
594 case AARCH64_OPND_QLF_SP
:
595 if (target
== AARCH64_OPND_QLF_X
596 && operand_maybe_stack_pointer (aarch64_operands
+ operand
->type
))
606 /* Given qualifier sequence list QSEQ_LIST and the known qualifier KNOWN_QLF
607 for operand KNOWN_IDX, return the expected qualifier for operand IDX.
609 Return NIL if more than one expected qualifiers are found. */
611 aarch64_opnd_qualifier_t
612 aarch64_get_expected_qualifier (const aarch64_opnd_qualifier_seq_t
*qseq_list
,
614 const aarch64_opnd_qualifier_t known_qlf
,
621 When the known qualifier is NIL, we have to assume that there is only
622 one qualifier sequence in the *QSEQ_LIST and return the corresponding
623 qualifier directly. One scenario is that for instruction
624 PRFM <prfop>, [<Xn|SP>, #:lo12:<symbol>]
625 which has only one possible valid qualifier sequence
627 the caller may pass NIL in KNOWN_QLF to obtain S_D so that it can
628 determine the correct relocation type (i.e. LDST64_LO12) for PRFM.
630 Because the qualifier NIL has dual roles in the qualifier sequence:
631 it can mean no qualifier for the operand, or the qualifer sequence is
632 not in use (when all qualifiers in the sequence are NILs), we have to
633 handle this special case here. */
634 if (known_qlf
== AARCH64_OPND_NIL
)
636 assert (qseq_list
[0][known_idx
] == AARCH64_OPND_NIL
);
637 return qseq_list
[0][idx
];
640 for (i
= 0, saved_i
= -1; i
< AARCH64_MAX_QLF_SEQ_NUM
; ++i
)
642 if (qseq_list
[i
][known_idx
] == known_qlf
)
645 /* More than one sequences are found to have KNOWN_QLF at
647 return AARCH64_OPND_NIL
;
652 return qseq_list
[saved_i
][idx
];
655 enum operand_qualifier_kind
663 /* Operand qualifier description. */
664 struct operand_qualifier_data
666 /* The usage of the three data fields depends on the qualifier kind. */
673 enum operand_qualifier_kind kind
;
676 /* Indexed by the operand qualifier enumerators. */
677 struct operand_qualifier_data aarch64_opnd_qualifiers
[] =
679 {0, 0, 0, "NIL", OQK_NIL
},
681 /* Operand variant qualifiers.
683 element size, number of elements and common value for encoding. */
685 {4, 1, 0x0, "w", OQK_OPD_VARIANT
},
686 {8, 1, 0x1, "x", OQK_OPD_VARIANT
},
687 {4, 1, 0x0, "wsp", OQK_OPD_VARIANT
},
688 {8, 1, 0x1, "sp", OQK_OPD_VARIANT
},
690 {1, 1, 0x0, "b", OQK_OPD_VARIANT
},
691 {2, 1, 0x1, "h", OQK_OPD_VARIANT
},
692 {4, 1, 0x2, "s", OQK_OPD_VARIANT
},
693 {8, 1, 0x3, "d", OQK_OPD_VARIANT
},
694 {16, 1, 0x4, "q", OQK_OPD_VARIANT
},
696 {1, 8, 0x0, "8b", OQK_OPD_VARIANT
},
697 {1, 16, 0x1, "16b", OQK_OPD_VARIANT
},
698 {2, 2, 0x0, "2h", OQK_OPD_VARIANT
},
699 {2, 4, 0x2, "4h", OQK_OPD_VARIANT
},
700 {2, 8, 0x3, "8h", OQK_OPD_VARIANT
},
701 {4, 2, 0x4, "2s", OQK_OPD_VARIANT
},
702 {4, 4, 0x5, "4s", OQK_OPD_VARIANT
},
703 {8, 1, 0x6, "1d", OQK_OPD_VARIANT
},
704 {8, 2, 0x7, "2d", OQK_OPD_VARIANT
},
705 {16, 1, 0x8, "1q", OQK_OPD_VARIANT
},
707 {0, 0, 0, "z", OQK_OPD_VARIANT
},
708 {0, 0, 0, "m", OQK_OPD_VARIANT
},
710 /* Qualifiers constraining the value range.
712 Lower bound, higher bound, unused. */
714 {0, 7, 0, "imm_0_7" , OQK_VALUE_IN_RANGE
},
715 {0, 15, 0, "imm_0_15", OQK_VALUE_IN_RANGE
},
716 {0, 31, 0, "imm_0_31", OQK_VALUE_IN_RANGE
},
717 {0, 63, 0, "imm_0_63", OQK_VALUE_IN_RANGE
},
718 {1, 32, 0, "imm_1_32", OQK_VALUE_IN_RANGE
},
719 {1, 64, 0, "imm_1_64", OQK_VALUE_IN_RANGE
},
721 /* Qualifiers for miscellaneous purpose.
723 unused, unused and unused. */
728 {0, 0, 0, "retrieving", 0},
731 static inline bfd_boolean
732 operand_variant_qualifier_p (aarch64_opnd_qualifier_t qualifier
)
734 return (aarch64_opnd_qualifiers
[qualifier
].kind
== OQK_OPD_VARIANT
)
738 static inline bfd_boolean
739 qualifier_value_in_range_constraint_p (aarch64_opnd_qualifier_t qualifier
)
741 return (aarch64_opnd_qualifiers
[qualifier
].kind
== OQK_VALUE_IN_RANGE
)
746 aarch64_get_qualifier_name (aarch64_opnd_qualifier_t qualifier
)
748 return aarch64_opnd_qualifiers
[qualifier
].desc
;
751 /* Given an operand qualifier, return the expected data element size
752 of a qualified operand. */
754 aarch64_get_qualifier_esize (aarch64_opnd_qualifier_t qualifier
)
756 assert (operand_variant_qualifier_p (qualifier
) == TRUE
);
757 return aarch64_opnd_qualifiers
[qualifier
].data0
;
761 aarch64_get_qualifier_nelem (aarch64_opnd_qualifier_t qualifier
)
763 assert (operand_variant_qualifier_p (qualifier
) == TRUE
);
764 return aarch64_opnd_qualifiers
[qualifier
].data1
;
768 aarch64_get_qualifier_standard_value (aarch64_opnd_qualifier_t qualifier
)
770 assert (operand_variant_qualifier_p (qualifier
) == TRUE
);
771 return aarch64_opnd_qualifiers
[qualifier
].data2
;
775 get_lower_bound (aarch64_opnd_qualifier_t qualifier
)
777 assert (qualifier_value_in_range_constraint_p (qualifier
) == TRUE
);
778 return aarch64_opnd_qualifiers
[qualifier
].data0
;
782 get_upper_bound (aarch64_opnd_qualifier_t qualifier
)
784 assert (qualifier_value_in_range_constraint_p (qualifier
) == TRUE
);
785 return aarch64_opnd_qualifiers
[qualifier
].data1
;
790 aarch64_verbose (const char *str
, ...)
801 dump_qualifier_sequence (const aarch64_opnd_qualifier_t
*qualifier
)
805 for (i
= 0; i
< AARCH64_MAX_OPND_NUM
; ++i
, ++qualifier
)
806 printf ("%s,", aarch64_get_qualifier_name (*qualifier
));
811 dump_match_qualifiers (const struct aarch64_opnd_info
*opnd
,
812 const aarch64_opnd_qualifier_t
*qualifier
)
815 aarch64_opnd_qualifier_t curr
[AARCH64_MAX_OPND_NUM
];
817 aarch64_verbose ("dump_match_qualifiers:");
818 for (i
= 0; i
< AARCH64_MAX_OPND_NUM
; ++i
)
819 curr
[i
] = opnd
[i
].qualifier
;
820 dump_qualifier_sequence (curr
);
821 aarch64_verbose ("against");
822 dump_qualifier_sequence (qualifier
);
824 #endif /* DEBUG_AARCH64 */
826 /* TODO improve this, we can have an extra field at the runtime to
827 store the number of operands rather than calculating it every time. */
830 aarch64_num_of_operands (const aarch64_opcode
*opcode
)
833 const enum aarch64_opnd
*opnds
= opcode
->operands
;
834 while (opnds
[i
++] != AARCH64_OPND_NIL
)
837 assert (i
>= 0 && i
<= AARCH64_MAX_OPND_NUM
);
841 /* Find the best matched qualifier sequence in *QUALIFIERS_LIST for INST.
842 If succeeds, fill the found sequence in *RET, return 1; otherwise return 0.
844 N.B. on the entry, it is very likely that only some operands in *INST
845 have had their qualifiers been established.
847 If STOP_AT is not -1, the function will only try to match
848 the qualifier sequence for operands before and including the operand
849 of index STOP_AT; and on success *RET will only be filled with the first
850 (STOP_AT+1) qualifiers.
852 A couple examples of the matching algorithm:
860 Apart from serving the main encoding routine, this can also be called
861 during or after the operand decoding. */
864 aarch64_find_best_match (const aarch64_inst
*inst
,
865 const aarch64_opnd_qualifier_seq_t
*qualifiers_list
,
866 int stop_at
, aarch64_opnd_qualifier_t
*ret
)
870 const aarch64_opnd_qualifier_t
*qualifiers
;
872 num_opnds
= aarch64_num_of_operands (inst
->opcode
);
875 DEBUG_TRACE ("SUCCEED: no operand");
879 if (stop_at
< 0 || stop_at
>= num_opnds
)
880 stop_at
= num_opnds
- 1;
882 /* For each pattern. */
883 for (i
= 0; i
< AARCH64_MAX_QLF_SEQ_NUM
; ++i
, ++qualifiers_list
)
886 qualifiers
= *qualifiers_list
;
888 /* Start as positive. */
891 DEBUG_TRACE ("%d", i
);
894 dump_match_qualifiers (inst
->operands
, qualifiers
);
897 /* Most opcodes has much fewer patterns in the list.
898 First NIL qualifier indicates the end in the list. */
899 if (empty_qualifier_sequence_p (qualifiers
) == TRUE
)
901 DEBUG_TRACE_IF (i
== 0, "SUCCEED: empty qualifier list");
907 for (j
= 0; j
< num_opnds
&& j
<= stop_at
; ++j
, ++qualifiers
)
909 if (inst
->operands
[j
].qualifier
== AARCH64_OPND_QLF_NIL
)
911 /* Either the operand does not have qualifier, or the qualifier
912 for the operand needs to be deduced from the qualifier
914 In the latter case, any constraint checking related with
915 the obtained qualifier should be done later in
916 operand_general_constraint_met_p. */
919 else if (*qualifiers
!= inst
->operands
[j
].qualifier
)
921 /* Unless the target qualifier can also qualify the operand
922 (which has already had a non-nil qualifier), non-equal
923 qualifiers are generally un-matched. */
924 if (operand_also_qualified_p (inst
->operands
+ j
, *qualifiers
))
933 continue; /* Equal qualifiers are certainly matched. */
936 /* Qualifiers established. */
943 /* Fill the result in *RET. */
945 qualifiers
= *qualifiers_list
;
947 DEBUG_TRACE ("complete qualifiers using list %d", i
);
950 dump_qualifier_sequence (qualifiers
);
953 for (j
= 0; j
<= stop_at
; ++j
, ++qualifiers
)
954 ret
[j
] = *qualifiers
;
955 for (; j
< AARCH64_MAX_OPND_NUM
; ++j
)
956 ret
[j
] = AARCH64_OPND_QLF_NIL
;
958 DEBUG_TRACE ("SUCCESS");
962 DEBUG_TRACE ("FAIL");
966 /* Operand qualifier matching and resolving.
968 Return 1 if the operand qualifier(s) in *INST match one of the qualifier
969 sequences in INST->OPCODE->qualifiers_list; otherwise return 0.
971 if UPDATE_P == TRUE, update the qualifier(s) in *INST after the matching
975 match_operands_qualifier (aarch64_inst
*inst
, bfd_boolean update_p
)
978 aarch64_opnd_qualifier_seq_t qualifiers
;
980 if (!aarch64_find_best_match (inst
, inst
->opcode
->qualifiers_list
, -1,
983 DEBUG_TRACE ("matching FAIL");
987 if (inst
->opcode
->flags
& F_STRICT
)
989 /* Require an exact qualifier match, even for NIL qualifiers. */
990 nops
= aarch64_num_of_operands (inst
->opcode
);
991 for (i
= 0; i
< nops
; ++i
)
992 if (inst
->operands
[i
].qualifier
!= qualifiers
[i
])
996 /* Update the qualifiers. */
997 if (update_p
== TRUE
)
998 for (i
= 0; i
< AARCH64_MAX_OPND_NUM
; ++i
)
1000 if (inst
->opcode
->operands
[i
] == AARCH64_OPND_NIL
)
1002 DEBUG_TRACE_IF (inst
->operands
[i
].qualifier
!= qualifiers
[i
],
1003 "update %s with %s for operand %d",
1004 aarch64_get_qualifier_name (inst
->operands
[i
].qualifier
),
1005 aarch64_get_qualifier_name (qualifiers
[i
]), i
);
1006 inst
->operands
[i
].qualifier
= qualifiers
[i
];
1009 DEBUG_TRACE ("matching SUCCESS");
1013 /* Return TRUE if VALUE is a wide constant that can be moved into a general
1016 IS32 indicates whether value is a 32-bit immediate or not.
1017 If SHIFT_AMOUNT is not NULL, on the return of TRUE, the logical left shift
1018 amount will be returned in *SHIFT_AMOUNT. */
1021 aarch64_wide_constant_p (int64_t value
, int is32
, unsigned int *shift_amount
)
1025 DEBUG_TRACE ("enter with 0x%" PRIx64
"(%" PRIi64
")", value
, value
);
1029 /* Allow all zeros or all ones in top 32-bits, so that
1030 32-bit constant expressions like ~0x80000000 are
1032 uint64_t ext
= value
;
1033 if (ext
>> 32 != 0 && ext
>> 32 != (uint64_t) 0xffffffff)
1034 /* Immediate out of range. */
1036 value
&= (int64_t) 0xffffffff;
1039 /* first, try movz then movn */
1041 if ((value
& ((int64_t) 0xffff << 0)) == value
)
1043 else if ((value
& ((int64_t) 0xffff << 16)) == value
)
1045 else if (!is32
&& (value
& ((int64_t) 0xffff << 32)) == value
)
1047 else if (!is32
&& (value
& ((int64_t) 0xffff << 48)) == value
)
1052 DEBUG_TRACE ("exit FALSE with 0x%" PRIx64
"(%" PRIi64
")", value
, value
);
1056 if (shift_amount
!= NULL
)
1057 *shift_amount
= amount
;
1059 DEBUG_TRACE ("exit TRUE with amount %d", amount
);
1064 /* Build the accepted values for immediate logical SIMD instructions.
1066 The standard encodings of the immediate value are:
1067 N imms immr SIMD size R S
1068 1 ssssss rrrrrr 64 UInt(rrrrrr) UInt(ssssss)
1069 0 0sssss 0rrrrr 32 UInt(rrrrr) UInt(sssss)
1070 0 10ssss 00rrrr 16 UInt(rrrr) UInt(ssss)
1071 0 110sss 000rrr 8 UInt(rrr) UInt(sss)
1072 0 1110ss 0000rr 4 UInt(rr) UInt(ss)
1073 0 11110s 00000r 2 UInt(r) UInt(s)
1074 where all-ones value of S is reserved.
1076 Let's call E the SIMD size.
1078 The immediate value is: S+1 bits '1' rotated to the right by R.
1080 The total of valid encodings is 64*63 + 32*31 + ... + 2*1 = 5334
1081 (remember S != E - 1). */
1083 #define TOTAL_IMM_NB 5334
1088 aarch64_insn encoding
;
1089 } simd_imm_encoding
;
1091 static simd_imm_encoding simd_immediates
[TOTAL_IMM_NB
];
1094 simd_imm_encoding_cmp(const void *i1
, const void *i2
)
1096 const simd_imm_encoding
*imm1
= (const simd_imm_encoding
*)i1
;
1097 const simd_imm_encoding
*imm2
= (const simd_imm_encoding
*)i2
;
1099 if (imm1
->imm
< imm2
->imm
)
1101 if (imm1
->imm
> imm2
->imm
)
1106 /* immediate bitfield standard encoding
1107 imm13<12> imm13<5:0> imm13<11:6> SIMD size R S
1108 1 ssssss rrrrrr 64 rrrrrr ssssss
1109 0 0sssss 0rrrrr 32 rrrrr sssss
1110 0 10ssss 00rrrr 16 rrrr ssss
1111 0 110sss 000rrr 8 rrr sss
1112 0 1110ss 0000rr 4 rr ss
1113 0 11110s 00000r 2 r s */
1115 encode_immediate_bitfield (int is64
, uint32_t s
, uint32_t r
)
1117 return (is64
<< 12) | (r
<< 6) | s
;
1121 build_immediate_table (void)
1123 uint32_t log_e
, e
, s
, r
, s_mask
;
1129 for (log_e
= 1; log_e
<= 6; log_e
++)
1131 /* Get element size. */
1136 mask
= 0xffffffffffffffffull
;
1142 mask
= (1ull << e
) - 1;
1144 1 ((1 << 4) - 1) << 2 = 111100
1145 2 ((1 << 3) - 1) << 3 = 111000
1146 3 ((1 << 2) - 1) << 4 = 110000
1147 4 ((1 << 1) - 1) << 5 = 100000
1148 5 ((1 << 0) - 1) << 6 = 000000 */
1149 s_mask
= ((1u << (5 - log_e
)) - 1) << (log_e
+ 1);
1151 for (s
= 0; s
< e
- 1; s
++)
1152 for (r
= 0; r
< e
; r
++)
1154 /* s+1 consecutive bits to 1 (s < 63) */
1155 imm
= (1ull << (s
+ 1)) - 1;
1156 /* rotate right by r */
1158 imm
= (imm
>> r
) | ((imm
<< (e
- r
)) & mask
);
1159 /* replicate the constant depending on SIMD size */
1162 case 1: imm
= (imm
<< 2) | imm
;
1164 case 2: imm
= (imm
<< 4) | imm
;
1166 case 3: imm
= (imm
<< 8) | imm
;
1168 case 4: imm
= (imm
<< 16) | imm
;
1170 case 5: imm
= (imm
<< 32) | imm
;
1175 simd_immediates
[nb_imms
].imm
= imm
;
1176 simd_immediates
[nb_imms
].encoding
=
1177 encode_immediate_bitfield(is64
, s
| s_mask
, r
);
1181 assert (nb_imms
== TOTAL_IMM_NB
);
1182 qsort(simd_immediates
, nb_imms
,
1183 sizeof(simd_immediates
[0]), simd_imm_encoding_cmp
);
1186 /* Return TRUE if VALUE is a valid logical immediate, i.e. bitmask, that can
1187 be accepted by logical (immediate) instructions
1188 e.g. ORR <Xd|SP>, <Xn>, #<imm>.
1190 ESIZE is the number of bytes in the decoded immediate value.
1191 If ENCODING is not NULL, on the return of TRUE, the standard encoding for
1192 VALUE will be returned in *ENCODING. */
1195 aarch64_logical_immediate_p (uint64_t value
, int esize
, aarch64_insn
*encoding
)
1197 simd_imm_encoding imm_enc
;
1198 const simd_imm_encoding
*imm_encoding
;
1199 static bfd_boolean initialized
= FALSE
;
1203 DEBUG_TRACE ("enter with 0x%" PRIx64
"(%" PRIi64
"), is32: %d", value
,
1206 if (initialized
== FALSE
)
1208 build_immediate_table ();
1212 /* Allow all zeros or all ones in top bits, so that
1213 constant expressions like ~1 are permitted. */
1214 upper
= (uint64_t) -1 << (esize
* 4) << (esize
* 4);
1215 if ((value
& ~upper
) != value
&& (value
| upper
) != value
)
1218 /* Replicate to a full 64-bit value. */
1220 for (i
= esize
* 8; i
< 64; i
*= 2)
1221 value
|= (value
<< i
);
1223 imm_enc
.imm
= value
;
1224 imm_encoding
= (const simd_imm_encoding
*)
1225 bsearch(&imm_enc
, simd_immediates
, TOTAL_IMM_NB
,
1226 sizeof(simd_immediates
[0]), simd_imm_encoding_cmp
);
1227 if (imm_encoding
== NULL
)
1229 DEBUG_TRACE ("exit with FALSE");
1232 if (encoding
!= NULL
)
1233 *encoding
= imm_encoding
->encoding
;
1234 DEBUG_TRACE ("exit with TRUE");
1238 /* If 64-bit immediate IMM is in the format of
1239 "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffgggggggghhhhhhhh",
1240 where a, b, c, d, e, f, g and h are independently 0 or 1, return an integer
1241 of value "abcdefgh". Otherwise return -1. */
1243 aarch64_shrink_expanded_imm8 (uint64_t imm
)
1249 for (i
= 0; i
< 8; i
++)
1251 byte
= (imm
>> (8 * i
)) & 0xff;
1254 else if (byte
!= 0x00)
1260 /* Utility inline functions for operand_general_constraint_met_p. */
1263 set_error (aarch64_operand_error
*mismatch_detail
,
1264 enum aarch64_operand_error_kind kind
, int idx
,
1267 if (mismatch_detail
== NULL
)
1269 mismatch_detail
->kind
= kind
;
1270 mismatch_detail
->index
= idx
;
1271 mismatch_detail
->error
= error
;
1275 set_syntax_error (aarch64_operand_error
*mismatch_detail
, int idx
,
1278 if (mismatch_detail
== NULL
)
1280 set_error (mismatch_detail
, AARCH64_OPDE_SYNTAX_ERROR
, idx
, error
);
1284 set_out_of_range_error (aarch64_operand_error
*mismatch_detail
,
1285 int idx
, int lower_bound
, int upper_bound
,
1288 if (mismatch_detail
== NULL
)
1290 set_error (mismatch_detail
, AARCH64_OPDE_OUT_OF_RANGE
, idx
, error
);
1291 mismatch_detail
->data
[0] = lower_bound
;
1292 mismatch_detail
->data
[1] = upper_bound
;
1296 set_imm_out_of_range_error (aarch64_operand_error
*mismatch_detail
,
1297 int idx
, int lower_bound
, int upper_bound
)
1299 if (mismatch_detail
== NULL
)
1301 set_out_of_range_error (mismatch_detail
, idx
, lower_bound
, upper_bound
,
1302 _("immediate value"));
1306 set_offset_out_of_range_error (aarch64_operand_error
*mismatch_detail
,
1307 int idx
, int lower_bound
, int upper_bound
)
1309 if (mismatch_detail
== NULL
)
1311 set_out_of_range_error (mismatch_detail
, idx
, lower_bound
, upper_bound
,
1312 _("immediate offset"));
1316 set_regno_out_of_range_error (aarch64_operand_error
*mismatch_detail
,
1317 int idx
, int lower_bound
, int upper_bound
)
1319 if (mismatch_detail
== NULL
)
1321 set_out_of_range_error (mismatch_detail
, idx
, lower_bound
, upper_bound
,
1322 _("register number"));
1326 set_elem_idx_out_of_range_error (aarch64_operand_error
*mismatch_detail
,
1327 int idx
, int lower_bound
, int upper_bound
)
1329 if (mismatch_detail
== NULL
)
1331 set_out_of_range_error (mismatch_detail
, idx
, lower_bound
, upper_bound
,
1332 _("register element index"));
1336 set_sft_amount_out_of_range_error (aarch64_operand_error
*mismatch_detail
,
1337 int idx
, int lower_bound
, int upper_bound
)
1339 if (mismatch_detail
== NULL
)
1341 set_out_of_range_error (mismatch_detail
, idx
, lower_bound
, upper_bound
,
1345 /* Report that the MUL modifier in operand IDX should be in the range
1346 [LOWER_BOUND, UPPER_BOUND]. */
1348 set_multiplier_out_of_range_error (aarch64_operand_error
*mismatch_detail
,
1349 int idx
, int lower_bound
, int upper_bound
)
1351 if (mismatch_detail
== NULL
)
1353 set_out_of_range_error (mismatch_detail
, idx
, lower_bound
, upper_bound
,
1358 set_unaligned_error (aarch64_operand_error
*mismatch_detail
, int idx
,
1361 if (mismatch_detail
== NULL
)
1363 set_error (mismatch_detail
, AARCH64_OPDE_UNALIGNED
, idx
, NULL
);
1364 mismatch_detail
->data
[0] = alignment
;
1368 set_reg_list_error (aarch64_operand_error
*mismatch_detail
, int idx
,
1371 if (mismatch_detail
== NULL
)
1373 set_error (mismatch_detail
, AARCH64_OPDE_REG_LIST
, idx
, NULL
);
1374 mismatch_detail
->data
[0] = expected_num
;
1378 set_other_error (aarch64_operand_error
*mismatch_detail
, int idx
,
1381 if (mismatch_detail
== NULL
)
1383 set_error (mismatch_detail
, AARCH64_OPDE_OTHER_ERROR
, idx
, error
);
1386 /* General constraint checking based on operand code.
1388 Return 1 if OPNDS[IDX] meets the general constraint of operand code TYPE
1389 as the IDXth operand of opcode OPCODE. Otherwise return 0.
1391 This function has to be called after the qualifiers for all operands
1394 Mismatching error message is returned in *MISMATCH_DETAIL upon request,
1395 i.e. when MISMATCH_DETAIL is non-NULL. This avoids the generation
1396 of error message during the disassembling where error message is not
1397 wanted. We avoid the dynamic construction of strings of error messages
1398 here (i.e. in libopcodes), as it is costly and complicated; instead, we
1399 use a combination of error code, static string and some integer data to
1400 represent an error. */
1403 operand_general_constraint_met_p (const aarch64_opnd_info
*opnds
, int idx
,
1404 enum aarch64_opnd type
,
1405 const aarch64_opcode
*opcode
,
1406 aarch64_operand_error
*mismatch_detail
)
1408 unsigned num
, modifiers
, shift
;
1410 int64_t imm
, min_value
, max_value
;
1411 uint64_t uvalue
, mask
;
1412 const aarch64_opnd_info
*opnd
= opnds
+ idx
;
1413 aarch64_opnd_qualifier_t qualifier
= opnd
->qualifier
;
1415 assert (opcode
->operands
[idx
] == opnd
->type
&& opnd
->type
== type
);
1417 switch (aarch64_operands
[type
].op_class
)
1419 case AARCH64_OPND_CLASS_INT_REG
:
1420 /* Check pair reg constraints for cas* instructions. */
1421 if (type
== AARCH64_OPND_PAIRREG
)
1423 assert (idx
== 1 || idx
== 3);
1424 if (opnds
[idx
- 1].reg
.regno
% 2 != 0)
1426 set_syntax_error (mismatch_detail
, idx
- 1,
1427 _("reg pair must start from even reg"));
1430 if (opnds
[idx
].reg
.regno
!= opnds
[idx
- 1].reg
.regno
+ 1)
1432 set_syntax_error (mismatch_detail
, idx
,
1433 _("reg pair must be contiguous"));
1439 /* <Xt> may be optional in some IC and TLBI instructions. */
1440 if (type
== AARCH64_OPND_Rt_SYS
)
1442 assert (idx
== 1 && (aarch64_get_operand_class (opnds
[0].type
)
1443 == AARCH64_OPND_CLASS_SYSTEM
));
1444 if (opnds
[1].present
1445 && !aarch64_sys_ins_reg_has_xt (opnds
[0].sysins_op
))
1447 set_other_error (mismatch_detail
, idx
, _("extraneous register"));
1450 if (!opnds
[1].present
1451 && aarch64_sys_ins_reg_has_xt (opnds
[0].sysins_op
))
1453 set_other_error (mismatch_detail
, idx
, _("missing register"));
1459 case AARCH64_OPND_QLF_WSP
:
1460 case AARCH64_OPND_QLF_SP
:
1461 if (!aarch64_stack_pointer_p (opnd
))
1463 set_other_error (mismatch_detail
, idx
,
1464 _("stack pointer register expected"));
1473 case AARCH64_OPND_CLASS_SVE_REG
:
1476 case AARCH64_OPND_SVE_Zn_INDEX
:
1477 size
= aarch64_get_qualifier_esize (opnd
->qualifier
);
1478 if (!value_in_range_p (opnd
->reglane
.index
, 0, 64 / size
- 1))
1480 set_elem_idx_out_of_range_error (mismatch_detail
, idx
,
1486 case AARCH64_OPND_SVE_ZnxN
:
1487 case AARCH64_OPND_SVE_ZtxN
:
1488 if (opnd
->reglist
.num_regs
!= get_opcode_dependent_value (opcode
))
1490 set_other_error (mismatch_detail
, idx
,
1491 _("invalid register list"));
1501 case AARCH64_OPND_CLASS_PRED_REG
:
1502 if (opnd
->reg
.regno
>= 8
1503 && get_operand_fields_width (get_operand_from_code (type
)) == 3)
1505 set_other_error (mismatch_detail
, idx
, _("p0-p7 expected"));
1510 case AARCH64_OPND_CLASS_COND
:
1511 if (type
== AARCH64_OPND_COND1
1512 && (opnds
[idx
].cond
->value
& 0xe) == 0xe)
1514 /* Not allow AL or NV. */
1515 set_syntax_error (mismatch_detail
, idx
, NULL
);
1519 case AARCH64_OPND_CLASS_ADDRESS
:
1520 /* Check writeback. */
1521 switch (opcode
->iclass
)
1525 case ldstnapair_offs
:
1528 if (opnd
->addr
.writeback
== 1)
1530 set_syntax_error (mismatch_detail
, idx
,
1531 _("unexpected address writeback"));
1536 if (opnd
->addr
.writeback
== 1 && opnd
->addr
.preind
!= 1)
1538 set_syntax_error (mismatch_detail
, idx
,
1539 _("unexpected address writeback"));
1544 case ldstpair_indexed
:
1547 if (opnd
->addr
.writeback
== 0)
1549 set_syntax_error (mismatch_detail
, idx
,
1550 _("address writeback expected"));
1555 assert (opnd
->addr
.writeback
== 0);
1560 case AARCH64_OPND_ADDR_SIMM7
:
1561 /* Scaled signed 7 bits immediate offset. */
1562 /* Get the size of the data element that is accessed, which may be
1563 different from that of the source register size,
1564 e.g. in strb/ldrb. */
1565 size
= aarch64_get_qualifier_esize (opnd
->qualifier
);
1566 if (!value_in_range_p (opnd
->addr
.offset
.imm
, -64 * size
, 63 * size
))
1568 set_offset_out_of_range_error (mismatch_detail
, idx
,
1569 -64 * size
, 63 * size
);
1572 if (!value_aligned_p (opnd
->addr
.offset
.imm
, size
))
1574 set_unaligned_error (mismatch_detail
, idx
, size
);
1578 case AARCH64_OPND_ADDR_SIMM9
:
1579 /* Unscaled signed 9 bits immediate offset. */
1580 if (!value_in_range_p (opnd
->addr
.offset
.imm
, -256, 255))
1582 set_offset_out_of_range_error (mismatch_detail
, idx
, -256, 255);
1587 case AARCH64_OPND_ADDR_SIMM9_2
:
1588 /* Unscaled signed 9 bits immediate offset, which has to be negative
1590 size
= aarch64_get_qualifier_esize (qualifier
);
1591 if ((value_in_range_p (opnd
->addr
.offset
.imm
, 0, 255)
1592 && !value_aligned_p (opnd
->addr
.offset
.imm
, size
))
1593 || value_in_range_p (opnd
->addr
.offset
.imm
, -256, -1))
1595 set_other_error (mismatch_detail
, idx
,
1596 _("negative or unaligned offset expected"));
1599 case AARCH64_OPND_ADDR_SIMM10
:
1600 /* Scaled signed 10 bits immediate offset. */
1601 if (!value_in_range_p (opnd
->addr
.offset
.imm
, -4096, 4088))
1603 set_offset_out_of_range_error (mismatch_detail
, idx
, -4096, 4088);
1606 if (!value_aligned_p (opnd
->addr
.offset
.imm
, 8))
1608 set_unaligned_error (mismatch_detail
, idx
, 8);
1613 case AARCH64_OPND_SIMD_ADDR_POST
:
1614 /* AdvSIMD load/store multiple structures, post-index. */
1616 if (opnd
->addr
.offset
.is_reg
)
1618 if (value_in_range_p (opnd
->addr
.offset
.regno
, 0, 30))
1622 set_other_error (mismatch_detail
, idx
,
1623 _("invalid register offset"));
1629 const aarch64_opnd_info
*prev
= &opnds
[idx
-1];
1630 unsigned num_bytes
; /* total number of bytes transferred. */
1631 /* The opcode dependent area stores the number of elements in
1632 each structure to be loaded/stored. */
1633 int is_ld1r
= get_opcode_dependent_value (opcode
) == 1;
1634 if (opcode
->operands
[0] == AARCH64_OPND_LVt_AL
)
1635 /* Special handling of loading single structure to all lane. */
1636 num_bytes
= (is_ld1r
? 1 : prev
->reglist
.num_regs
)
1637 * aarch64_get_qualifier_esize (prev
->qualifier
);
1639 num_bytes
= prev
->reglist
.num_regs
1640 * aarch64_get_qualifier_esize (prev
->qualifier
)
1641 * aarch64_get_qualifier_nelem (prev
->qualifier
);
1642 if ((int) num_bytes
!= opnd
->addr
.offset
.imm
)
1644 set_other_error (mismatch_detail
, idx
,
1645 _("invalid post-increment amount"));
1651 case AARCH64_OPND_ADDR_REGOFF
:
1652 /* Get the size of the data element that is accessed, which may be
1653 different from that of the source register size,
1654 e.g. in strb/ldrb. */
1655 size
= aarch64_get_qualifier_esize (opnd
->qualifier
);
1656 /* It is either no shift or shift by the binary logarithm of SIZE. */
1657 if (opnd
->shifter
.amount
!= 0
1658 && opnd
->shifter
.amount
!= (int)get_logsz (size
))
1660 set_other_error (mismatch_detail
, idx
,
1661 _("invalid shift amount"));
1664 /* Only UXTW, LSL, SXTW and SXTX are the accepted extending
1666 switch (opnd
->shifter
.kind
)
1668 case AARCH64_MOD_UXTW
:
1669 case AARCH64_MOD_LSL
:
1670 case AARCH64_MOD_SXTW
:
1671 case AARCH64_MOD_SXTX
: break;
1673 set_other_error (mismatch_detail
, idx
,
1674 _("invalid extend/shift operator"));
1679 case AARCH64_OPND_ADDR_UIMM12
:
1680 imm
= opnd
->addr
.offset
.imm
;
1681 /* Get the size of the data element that is accessed, which may be
1682 different from that of the source register size,
1683 e.g. in strb/ldrb. */
1684 size
= aarch64_get_qualifier_esize (qualifier
);
1685 if (!value_in_range_p (opnd
->addr
.offset
.imm
, 0, 4095 * size
))
1687 set_offset_out_of_range_error (mismatch_detail
, idx
,
1691 if (!value_aligned_p (opnd
->addr
.offset
.imm
, size
))
1693 set_unaligned_error (mismatch_detail
, idx
, size
);
1698 case AARCH64_OPND_ADDR_PCREL14
:
1699 case AARCH64_OPND_ADDR_PCREL19
:
1700 case AARCH64_OPND_ADDR_PCREL21
:
1701 case AARCH64_OPND_ADDR_PCREL26
:
1702 imm
= opnd
->imm
.value
;
1703 if (operand_need_shift_by_two (get_operand_from_code (type
)))
1705 /* The offset value in a PC-relative branch instruction is alway
1706 4-byte aligned and is encoded without the lowest 2 bits. */
1707 if (!value_aligned_p (imm
, 4))
1709 set_unaligned_error (mismatch_detail
, idx
, 4);
1712 /* Right shift by 2 so that we can carry out the following check
1716 size
= get_operand_fields_width (get_operand_from_code (type
));
1717 if (!value_fit_signed_field_p (imm
, size
))
1719 set_other_error (mismatch_detail
, idx
,
1720 _("immediate out of range"));
1725 case AARCH64_OPND_SVE_ADDR_RI_S4xVL
:
1726 case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL
:
1727 case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL
:
1728 case AARCH64_OPND_SVE_ADDR_RI_S4x4xVL
:
1732 assert (!opnd
->addr
.offset
.is_reg
);
1733 assert (opnd
->addr
.preind
);
1734 num
= 1 + get_operand_specific_data (&aarch64_operands
[type
]);
1737 if ((opnd
->addr
.offset
.imm
!= 0 && !opnd
->shifter
.operator_present
)
1738 || (opnd
->shifter
.operator_present
1739 && opnd
->shifter
.kind
!= AARCH64_MOD_MUL_VL
))
1741 set_other_error (mismatch_detail
, idx
,
1742 _("invalid addressing mode"));
1745 if (!value_in_range_p (opnd
->addr
.offset
.imm
, min_value
, max_value
))
1747 set_offset_out_of_range_error (mismatch_detail
, idx
,
1748 min_value
, max_value
);
1751 if (!value_aligned_p (opnd
->addr
.offset
.imm
, num
))
1753 set_unaligned_error (mismatch_detail
, idx
, num
);
1758 case AARCH64_OPND_SVE_ADDR_RI_S6xVL
:
1761 goto sve_imm_offset_vl
;
1763 case AARCH64_OPND_SVE_ADDR_RI_S9xVL
:
1766 goto sve_imm_offset_vl
;
1768 case AARCH64_OPND_SVE_ADDR_RI_U6
:
1769 case AARCH64_OPND_SVE_ADDR_RI_U6x2
:
1770 case AARCH64_OPND_SVE_ADDR_RI_U6x4
:
1771 case AARCH64_OPND_SVE_ADDR_RI_U6x8
:
1775 assert (!opnd
->addr
.offset
.is_reg
);
1776 assert (opnd
->addr
.preind
);
1777 num
= 1 << get_operand_specific_data (&aarch64_operands
[type
]);
1780 if (opnd
->shifter
.operator_present
1781 || opnd
->shifter
.amount_present
)
1783 set_other_error (mismatch_detail
, idx
,
1784 _("invalid addressing mode"));
1787 if (!value_in_range_p (opnd
->addr
.offset
.imm
, min_value
, max_value
))
1789 set_offset_out_of_range_error (mismatch_detail
, idx
,
1790 min_value
, max_value
);
1793 if (!value_aligned_p (opnd
->addr
.offset
.imm
, num
))
1795 set_unaligned_error (mismatch_detail
, idx
, num
);
1800 case AARCH64_OPND_SVE_ADDR_RR
:
1801 case AARCH64_OPND_SVE_ADDR_RR_LSL1
:
1802 case AARCH64_OPND_SVE_ADDR_RR_LSL2
:
1803 case AARCH64_OPND_SVE_ADDR_RR_LSL3
:
1804 case AARCH64_OPND_SVE_ADDR_RX
:
1805 case AARCH64_OPND_SVE_ADDR_RX_LSL1
:
1806 case AARCH64_OPND_SVE_ADDR_RX_LSL2
:
1807 case AARCH64_OPND_SVE_ADDR_RX_LSL3
:
1808 case AARCH64_OPND_SVE_ADDR_RZ
:
1809 case AARCH64_OPND_SVE_ADDR_RZ_LSL1
:
1810 case AARCH64_OPND_SVE_ADDR_RZ_LSL2
:
1811 case AARCH64_OPND_SVE_ADDR_RZ_LSL3
:
1812 modifiers
= 1 << AARCH64_MOD_LSL
;
1814 assert (opnd
->addr
.offset
.is_reg
);
1815 assert (opnd
->addr
.preind
);
1816 if ((aarch64_operands
[type
].flags
& OPD_F_NO_ZR
) != 0
1817 && opnd
->addr
.offset
.regno
== 31)
1819 set_other_error (mismatch_detail
, idx
,
1820 _("index register xzr is not allowed"));
1823 if (((1 << opnd
->shifter
.kind
) & modifiers
) == 0
1824 || (opnd
->shifter
.amount
1825 != get_operand_specific_data (&aarch64_operands
[type
])))
1827 set_other_error (mismatch_detail
, idx
,
1828 _("invalid addressing mode"));
1833 case AARCH64_OPND_SVE_ADDR_RZ_XTW_14
:
1834 case AARCH64_OPND_SVE_ADDR_RZ_XTW_22
:
1835 case AARCH64_OPND_SVE_ADDR_RZ_XTW1_14
:
1836 case AARCH64_OPND_SVE_ADDR_RZ_XTW1_22
:
1837 case AARCH64_OPND_SVE_ADDR_RZ_XTW2_14
:
1838 case AARCH64_OPND_SVE_ADDR_RZ_XTW2_22
:
1839 case AARCH64_OPND_SVE_ADDR_RZ_XTW3_14
:
1840 case AARCH64_OPND_SVE_ADDR_RZ_XTW3_22
:
1841 modifiers
= (1 << AARCH64_MOD_SXTW
) | (1 << AARCH64_MOD_UXTW
);
1842 goto sve_rr_operand
;
1844 case AARCH64_OPND_SVE_ADDR_ZI_U5
:
1845 case AARCH64_OPND_SVE_ADDR_ZI_U5x2
:
1846 case AARCH64_OPND_SVE_ADDR_ZI_U5x4
:
1847 case AARCH64_OPND_SVE_ADDR_ZI_U5x8
:
1850 goto sve_imm_offset
;
1852 case AARCH64_OPND_SVE_ADDR_ZZ_LSL
:
1853 modifiers
= 1 << AARCH64_MOD_LSL
;
1855 assert (opnd
->addr
.offset
.is_reg
);
1856 assert (opnd
->addr
.preind
);
1857 if (((1 << opnd
->shifter
.kind
) & modifiers
) == 0
1858 || opnd
->shifter
.amount
< 0
1859 || opnd
->shifter
.amount
> 3)
1861 set_other_error (mismatch_detail
, idx
,
1862 _("invalid addressing mode"));
1867 case AARCH64_OPND_SVE_ADDR_ZZ_SXTW
:
1868 modifiers
= (1 << AARCH64_MOD_SXTW
);
1869 goto sve_zz_operand
;
1871 case AARCH64_OPND_SVE_ADDR_ZZ_UXTW
:
1872 modifiers
= 1 << AARCH64_MOD_UXTW
;
1873 goto sve_zz_operand
;
1880 case AARCH64_OPND_CLASS_SIMD_REGLIST
:
1881 if (type
== AARCH64_OPND_LEt
)
1883 /* Get the upper bound for the element index. */
1884 num
= 16 / aarch64_get_qualifier_esize (qualifier
) - 1;
1885 if (!value_in_range_p (opnd
->reglist
.index
, 0, num
))
1887 set_elem_idx_out_of_range_error (mismatch_detail
, idx
, 0, num
);
1891 /* The opcode dependent area stores the number of elements in
1892 each structure to be loaded/stored. */
1893 num
= get_opcode_dependent_value (opcode
);
1896 case AARCH64_OPND_LVt
:
1897 assert (num
>= 1 && num
<= 4);
1898 /* Unless LD1/ST1, the number of registers should be equal to that
1899 of the structure elements. */
1900 if (num
!= 1 && opnd
->reglist
.num_regs
!= num
)
1902 set_reg_list_error (mismatch_detail
, idx
, num
);
1906 case AARCH64_OPND_LVt_AL
:
1907 case AARCH64_OPND_LEt
:
1908 assert (num
>= 1 && num
<= 4);
1909 /* The number of registers should be equal to that of the structure
1911 if (opnd
->reglist
.num_regs
!= num
)
1913 set_reg_list_error (mismatch_detail
, idx
, num
);
1922 case AARCH64_OPND_CLASS_IMMEDIATE
:
1923 /* Constraint check on immediate operand. */
1924 imm
= opnd
->imm
.value
;
1925 /* E.g. imm_0_31 constrains value to be 0..31. */
1926 if (qualifier_value_in_range_constraint_p (qualifier
)
1927 && !value_in_range_p (imm
, get_lower_bound (qualifier
),
1928 get_upper_bound (qualifier
)))
1930 set_imm_out_of_range_error (mismatch_detail
, idx
,
1931 get_lower_bound (qualifier
),
1932 get_upper_bound (qualifier
));
1938 case AARCH64_OPND_AIMM
:
1939 if (opnd
->shifter
.kind
!= AARCH64_MOD_LSL
)
1941 set_other_error (mismatch_detail
, idx
,
1942 _("invalid shift operator"));
1945 if (opnd
->shifter
.amount
!= 0 && opnd
->shifter
.amount
!= 12)
1947 set_other_error (mismatch_detail
, idx
,
1948 _("shift amount must be 0 or 12"));
1951 if (!value_fit_unsigned_field_p (opnd
->imm
.value
, 12))
1953 set_other_error (mismatch_detail
, idx
,
1954 _("immediate out of range"));
1959 case AARCH64_OPND_HALF
:
1960 assert (idx
== 1 && opnds
[0].type
== AARCH64_OPND_Rd
);
1961 if (opnd
->shifter
.kind
!= AARCH64_MOD_LSL
)
1963 set_other_error (mismatch_detail
, idx
,
1964 _("invalid shift operator"));
1967 size
= aarch64_get_qualifier_esize (opnds
[0].qualifier
);
1968 if (!value_aligned_p (opnd
->shifter
.amount
, 16))
1970 set_other_error (mismatch_detail
, idx
,
1971 _("shift amount must be a multiple of 16"));
1974 if (!value_in_range_p (opnd
->shifter
.amount
, 0, size
* 8 - 16))
1976 set_sft_amount_out_of_range_error (mismatch_detail
, idx
,
1980 if (opnd
->imm
.value
< 0)
1982 set_other_error (mismatch_detail
, idx
,
1983 _("negative immediate value not allowed"));
1986 if (!value_fit_unsigned_field_p (opnd
->imm
.value
, 16))
1988 set_other_error (mismatch_detail
, idx
,
1989 _("immediate out of range"));
1994 case AARCH64_OPND_IMM_MOV
:
1996 int esize
= aarch64_get_qualifier_esize (opnds
[0].qualifier
);
1997 imm
= opnd
->imm
.value
;
2001 case OP_MOV_IMM_WIDEN
:
2004 case OP_MOV_IMM_WIDE
:
2005 if (!aarch64_wide_constant_p (imm
, esize
== 4, NULL
))
2007 set_other_error (mismatch_detail
, idx
,
2008 _("immediate out of range"));
2012 case OP_MOV_IMM_LOG
:
2013 if (!aarch64_logical_immediate_p (imm
, esize
, NULL
))
2015 set_other_error (mismatch_detail
, idx
,
2016 _("immediate out of range"));
2027 case AARCH64_OPND_NZCV
:
2028 case AARCH64_OPND_CCMP_IMM
:
2029 case AARCH64_OPND_EXCEPTION
:
2030 case AARCH64_OPND_UIMM4
:
2031 case AARCH64_OPND_UIMM7
:
2032 case AARCH64_OPND_UIMM3_OP1
:
2033 case AARCH64_OPND_UIMM3_OP2
:
2034 case AARCH64_OPND_SVE_UIMM3
:
2035 case AARCH64_OPND_SVE_UIMM7
:
2036 case AARCH64_OPND_SVE_UIMM8
:
2037 case AARCH64_OPND_SVE_UIMM8_53
:
2038 size
= get_operand_fields_width (get_operand_from_code (type
));
2040 if (!value_fit_unsigned_field_p (opnd
->imm
.value
, size
))
2042 set_imm_out_of_range_error (mismatch_detail
, idx
, 0,
2048 case AARCH64_OPND_SIMM5
:
2049 case AARCH64_OPND_SVE_SIMM5
:
2050 case AARCH64_OPND_SVE_SIMM5B
:
2051 case AARCH64_OPND_SVE_SIMM6
:
2052 case AARCH64_OPND_SVE_SIMM8
:
2053 size
= get_operand_fields_width (get_operand_from_code (type
));
2055 if (!value_fit_signed_field_p (opnd
->imm
.value
, size
))
2057 set_imm_out_of_range_error (mismatch_detail
, idx
,
2059 (1 << (size
- 1)) - 1);
2064 case AARCH64_OPND_WIDTH
:
2065 assert (idx
> 1 && opnds
[idx
-1].type
== AARCH64_OPND_IMM
2066 && opnds
[0].type
== AARCH64_OPND_Rd
);
2067 size
= get_upper_bound (qualifier
);
2068 if (opnd
->imm
.value
+ opnds
[idx
-1].imm
.value
> size
)
2069 /* lsb+width <= reg.size */
2071 set_imm_out_of_range_error (mismatch_detail
, idx
, 1,
2072 size
- opnds
[idx
-1].imm
.value
);
2077 case AARCH64_OPND_LIMM
:
2078 case AARCH64_OPND_SVE_LIMM
:
2080 int esize
= aarch64_get_qualifier_esize (opnds
[0].qualifier
);
2081 uint64_t uimm
= opnd
->imm
.value
;
2082 if (opcode
->op
== OP_BIC
)
2084 if (aarch64_logical_immediate_p (uimm
, esize
, NULL
) == FALSE
)
2086 set_other_error (mismatch_detail
, idx
,
2087 _("immediate out of range"));
2093 case AARCH64_OPND_IMM0
:
2094 case AARCH64_OPND_FPIMM0
:
2095 if (opnd
->imm
.value
!= 0)
2097 set_other_error (mismatch_detail
, idx
,
2098 _("immediate zero expected"));
2103 case AARCH64_OPND_IMM_ROT1
:
2104 case AARCH64_OPND_IMM_ROT2
:
2105 if (opnd
->imm
.value
!= 0
2106 && opnd
->imm
.value
!= 90
2107 && opnd
->imm
.value
!= 180
2108 && opnd
->imm
.value
!= 270)
2110 set_other_error (mismatch_detail
, idx
,
2111 _("rotate expected to be 0, 90, 180 or 270"));
2116 case AARCH64_OPND_IMM_ROT3
:
2117 if (opnd
->imm
.value
!= 90 && opnd
->imm
.value
!= 270)
2119 set_other_error (mismatch_detail
, idx
,
2120 _("rotate expected to be 90 or 270"));
2125 case AARCH64_OPND_SHLL_IMM
:
2127 size
= 8 * aarch64_get_qualifier_esize (opnds
[idx
- 1].qualifier
);
2128 if (opnd
->imm
.value
!= size
)
2130 set_other_error (mismatch_detail
, idx
,
2131 _("invalid shift amount"));
2136 case AARCH64_OPND_IMM_VLSL
:
2137 size
= aarch64_get_qualifier_esize (qualifier
);
2138 if (!value_in_range_p (opnd
->imm
.value
, 0, size
* 8 - 1))
2140 set_imm_out_of_range_error (mismatch_detail
, idx
, 0,
2146 case AARCH64_OPND_IMM_VLSR
:
2147 size
= aarch64_get_qualifier_esize (qualifier
);
2148 if (!value_in_range_p (opnd
->imm
.value
, 1, size
* 8))
2150 set_imm_out_of_range_error (mismatch_detail
, idx
, 1, size
* 8);
2155 case AARCH64_OPND_SIMD_IMM
:
2156 case AARCH64_OPND_SIMD_IMM_SFT
:
2157 /* Qualifier check. */
2160 case AARCH64_OPND_QLF_LSL
:
2161 if (opnd
->shifter
.kind
!= AARCH64_MOD_LSL
)
2163 set_other_error (mismatch_detail
, idx
,
2164 _("invalid shift operator"));
2168 case AARCH64_OPND_QLF_MSL
:
2169 if (opnd
->shifter
.kind
!= AARCH64_MOD_MSL
)
2171 set_other_error (mismatch_detail
, idx
,
2172 _("invalid shift operator"));
2176 case AARCH64_OPND_QLF_NIL
:
2177 if (opnd
->shifter
.kind
!= AARCH64_MOD_NONE
)
2179 set_other_error (mismatch_detail
, idx
,
2180 _("shift is not permitted"));
2188 /* Is the immediate valid? */
2190 if (aarch64_get_qualifier_esize (opnds
[0].qualifier
) != 8)
2192 /* uimm8 or simm8 */
2193 if (!value_in_range_p (opnd
->imm
.value
, -128, 255))
2195 set_imm_out_of_range_error (mismatch_detail
, idx
, -128, 255);
2199 else if (aarch64_shrink_expanded_imm8 (opnd
->imm
.value
) < 0)
2202 'aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
2203 ffffffffgggggggghhhhhhhh'. */
2204 set_other_error (mismatch_detail
, idx
,
2205 _("invalid value for immediate"));
2208 /* Is the shift amount valid? */
2209 switch (opnd
->shifter
.kind
)
2211 case AARCH64_MOD_LSL
:
2212 size
= aarch64_get_qualifier_esize (opnds
[0].qualifier
);
2213 if (!value_in_range_p (opnd
->shifter
.amount
, 0, (size
- 1) * 8))
2215 set_sft_amount_out_of_range_error (mismatch_detail
, idx
, 0,
2219 if (!value_aligned_p (opnd
->shifter
.amount
, 8))
2221 set_unaligned_error (mismatch_detail
, idx
, 8);
2225 case AARCH64_MOD_MSL
:
2226 /* Only 8 and 16 are valid shift amount. */
2227 if (opnd
->shifter
.amount
!= 8 && opnd
->shifter
.amount
!= 16)
2229 set_other_error (mismatch_detail
, idx
,
2230 _("shift amount must be 0 or 16"));
2235 if (opnd
->shifter
.kind
!= AARCH64_MOD_NONE
)
2237 set_other_error (mismatch_detail
, idx
,
2238 _("invalid shift operator"));
2245 case AARCH64_OPND_FPIMM
:
2246 case AARCH64_OPND_SIMD_FPIMM
:
2247 case AARCH64_OPND_SVE_FPIMM8
:
2248 if (opnd
->imm
.is_fp
== 0)
2250 set_other_error (mismatch_detail
, idx
,
2251 _("floating-point immediate expected"));
2254 /* The value is expected to be an 8-bit floating-point constant with
2255 sign, 3-bit exponent and normalized 4 bits of precision, encoded
2256 in "a:b:c:d:e:f:g:h" or FLD_imm8 (depending on the type of the
2258 if (!value_in_range_p (opnd
->imm
.value
, 0, 255))
2260 set_other_error (mismatch_detail
, idx
,
2261 _("immediate out of range"));
2264 if (opnd
->shifter
.kind
!= AARCH64_MOD_NONE
)
2266 set_other_error (mismatch_detail
, idx
,
2267 _("invalid shift operator"));
2272 case AARCH64_OPND_SVE_AIMM
:
2275 assert (opnd
->shifter
.kind
== AARCH64_MOD_LSL
);
2276 size
= aarch64_get_qualifier_esize (opnds
[0].qualifier
);
2277 mask
= ~((uint64_t) -1 << (size
* 4) << (size
* 4));
2278 uvalue
= opnd
->imm
.value
;
2279 shift
= opnd
->shifter
.amount
;
2284 set_other_error (mismatch_detail
, idx
,
2285 _("no shift amount allowed for"
2286 " 8-bit constants"));
2292 if (shift
!= 0 && shift
!= 8)
2294 set_other_error (mismatch_detail
, idx
,
2295 _("shift amount must be 0 or 8"));
2298 if (shift
== 0 && (uvalue
& 0xff) == 0)
2301 uvalue
= (int64_t) uvalue
/ 256;
2305 if ((uvalue
& mask
) != uvalue
&& (uvalue
| ~mask
) != uvalue
)
2307 set_other_error (mismatch_detail
, idx
,
2308 _("immediate too big for element size"));
2311 uvalue
= (uvalue
- min_value
) & mask
;
2314 set_other_error (mismatch_detail
, idx
,
2315 _("invalid arithmetic immediate"));
2320 case AARCH64_OPND_SVE_ASIMM
:
2324 case AARCH64_OPND_SVE_I1_HALF_ONE
:
2325 assert (opnd
->imm
.is_fp
);
2326 if (opnd
->imm
.value
!= 0x3f000000 && opnd
->imm
.value
!= 0x3f800000)
2328 set_other_error (mismatch_detail
, idx
,
2329 _("floating-point value must be 0.5 or 1.0"));
2334 case AARCH64_OPND_SVE_I1_HALF_TWO
:
2335 assert (opnd
->imm
.is_fp
);
2336 if (opnd
->imm
.value
!= 0x3f000000 && opnd
->imm
.value
!= 0x40000000)
2338 set_other_error (mismatch_detail
, idx
,
2339 _("floating-point value must be 0.5 or 2.0"));
2344 case AARCH64_OPND_SVE_I1_ZERO_ONE
:
2345 assert (opnd
->imm
.is_fp
);
2346 if (opnd
->imm
.value
!= 0 && opnd
->imm
.value
!= 0x3f800000)
2348 set_other_error (mismatch_detail
, idx
,
2349 _("floating-point value must be 0.0 or 1.0"));
2354 case AARCH64_OPND_SVE_INV_LIMM
:
2356 int esize
= aarch64_get_qualifier_esize (opnds
[0].qualifier
);
2357 uint64_t uimm
= ~opnd
->imm
.value
;
2358 if (!aarch64_logical_immediate_p (uimm
, esize
, NULL
))
2360 set_other_error (mismatch_detail
, idx
,
2361 _("immediate out of range"));
2367 case AARCH64_OPND_SVE_LIMM_MOV
:
2369 int esize
= aarch64_get_qualifier_esize (opnds
[0].qualifier
);
2370 uint64_t uimm
= opnd
->imm
.value
;
2371 if (!aarch64_logical_immediate_p (uimm
, esize
, NULL
))
2373 set_other_error (mismatch_detail
, idx
,
2374 _("immediate out of range"));
2377 if (!aarch64_sve_dupm_mov_immediate_p (uimm
, esize
))
2379 set_other_error (mismatch_detail
, idx
,
2380 _("invalid replicated MOV immediate"));
2386 case AARCH64_OPND_SVE_PATTERN_SCALED
:
2387 assert (opnd
->shifter
.kind
== AARCH64_MOD_MUL
);
2388 if (!value_in_range_p (opnd
->shifter
.amount
, 1, 16))
2390 set_multiplier_out_of_range_error (mismatch_detail
, idx
, 1, 16);
2395 case AARCH64_OPND_SVE_SHLIMM_PRED
:
2396 case AARCH64_OPND_SVE_SHLIMM_UNPRED
:
2397 size
= aarch64_get_qualifier_esize (opnds
[idx
- 1].qualifier
);
2398 if (!value_in_range_p (opnd
->imm
.value
, 0, 8 * size
- 1))
2400 set_imm_out_of_range_error (mismatch_detail
, idx
,
2406 case AARCH64_OPND_SVE_SHRIMM_PRED
:
2407 case AARCH64_OPND_SVE_SHRIMM_UNPRED
:
2408 size
= aarch64_get_qualifier_esize (opnds
[idx
- 1].qualifier
);
2409 if (!value_in_range_p (opnd
->imm
.value
, 1, 8 * size
))
2411 set_imm_out_of_range_error (mismatch_detail
, idx
, 1, 8 * size
);
2421 case AARCH64_OPND_CLASS_CP_REG
:
2422 /* Cn or Cm: 4-bit opcode field named for historical reasons.
2423 valid range: C0 - C15. */
2424 if (opnd
->reg
.regno
> 15)
2426 set_regno_out_of_range_error (mismatch_detail
, idx
, 0, 15);
2431 case AARCH64_OPND_CLASS_SYSTEM
:
2434 case AARCH64_OPND_PSTATEFIELD
:
2435 assert (idx
== 0 && opnds
[1].type
== AARCH64_OPND_UIMM4
);
2438 The immediate must be #0 or #1. */
2439 if ((opnd
->pstatefield
== 0x03 /* UAO. */
2440 || opnd
->pstatefield
== 0x04) /* PAN. */
2441 && opnds
[1].imm
.value
> 1)
2443 set_imm_out_of_range_error (mismatch_detail
, idx
, 0, 1);
2446 /* MSR SPSel, #uimm4
2447 Uses uimm4 as a control value to select the stack pointer: if
2448 bit 0 is set it selects the current exception level's stack
2449 pointer, if bit 0 is clear it selects shared EL0 stack pointer.
2450 Bits 1 to 3 of uimm4 are reserved and should be zero. */
2451 if (opnd
->pstatefield
== 0x05 /* spsel */ && opnds
[1].imm
.value
> 1)
2453 set_imm_out_of_range_error (mismatch_detail
, idx
, 0, 1);
2462 case AARCH64_OPND_CLASS_SIMD_ELEMENT
:
2463 /* Get the upper bound for the element index. */
2464 if (opcode
->op
== OP_FCMLA_ELEM
)
2465 /* FCMLA index range depends on the vector size of other operands
2466 and is halfed because complex numbers take two elements. */
2467 num
= aarch64_get_qualifier_nelem (opnds
[0].qualifier
)
2468 * aarch64_get_qualifier_esize (opnds
[0].qualifier
) / 2;
2471 num
= num
/ aarch64_get_qualifier_esize (qualifier
) - 1;
2473 /* Index out-of-range. */
2474 if (!value_in_range_p (opnd
->reglane
.index
, 0, num
))
2476 set_elem_idx_out_of_range_error (mismatch_detail
, idx
, 0, num
);
2479 /* SMLAL<Q> <Vd>.<Ta>, <Vn>.<Tb>, <Vm>.<Ts>[<index>].
2480 <Vm> Is the vector register (V0-V31) or (V0-V15), whose
2481 number is encoded in "size:M:Rm":
2487 if (type
== AARCH64_OPND_Em
&& qualifier
== AARCH64_OPND_QLF_S_H
2488 && !value_in_range_p (opnd
->reglane
.regno
, 0, 15))
2490 set_regno_out_of_range_error (mismatch_detail
, idx
, 0, 15);
2495 case AARCH64_OPND_CLASS_MODIFIED_REG
:
2496 assert (idx
== 1 || idx
== 2);
2499 case AARCH64_OPND_Rm_EXT
:
2500 if (aarch64_extend_operator_p (opnd
->shifter
.kind
) == FALSE
2501 && opnd
->shifter
.kind
!= AARCH64_MOD_LSL
)
2503 set_other_error (mismatch_detail
, idx
,
2504 _("extend operator expected"));
2507 /* It is not optional unless at least one of "Rd" or "Rn" is '11111'
2508 (i.e. SP), in which case it defaults to LSL. The LSL alias is
2509 only valid when "Rd" or "Rn" is '11111', and is preferred in that
2511 if (!aarch64_stack_pointer_p (opnds
+ 0)
2512 && (idx
!= 2 || !aarch64_stack_pointer_p (opnds
+ 1)))
2514 if (!opnd
->shifter
.operator_present
)
2516 set_other_error (mismatch_detail
, idx
,
2517 _("missing extend operator"));
2520 else if (opnd
->shifter
.kind
== AARCH64_MOD_LSL
)
2522 set_other_error (mismatch_detail
, idx
,
2523 _("'LSL' operator not allowed"));
2527 assert (opnd
->shifter
.operator_present
/* Default to LSL. */
2528 || opnd
->shifter
.kind
== AARCH64_MOD_LSL
);
2529 if (!value_in_range_p (opnd
->shifter
.amount
, 0, 4))
2531 set_sft_amount_out_of_range_error (mismatch_detail
, idx
, 0, 4);
2534 /* In the 64-bit form, the final register operand is written as Wm
2535 for all but the (possibly omitted) UXTX/LSL and SXTX
2537 N.B. GAS allows X register to be used with any operator as a
2538 programming convenience. */
2539 if (qualifier
== AARCH64_OPND_QLF_X
2540 && opnd
->shifter
.kind
!= AARCH64_MOD_LSL
2541 && opnd
->shifter
.kind
!= AARCH64_MOD_UXTX
2542 && opnd
->shifter
.kind
!= AARCH64_MOD_SXTX
)
2544 set_other_error (mismatch_detail
, idx
, _("W register expected"));
2549 case AARCH64_OPND_Rm_SFT
:
2550 /* ROR is not available to the shifted register operand in
2551 arithmetic instructions. */
2552 if (aarch64_shift_operator_p (opnd
->shifter
.kind
) == FALSE
)
2554 set_other_error (mismatch_detail
, idx
,
2555 _("shift operator expected"));
2558 if (opnd
->shifter
.kind
== AARCH64_MOD_ROR
2559 && opcode
->iclass
!= log_shift
)
2561 set_other_error (mismatch_detail
, idx
,
2562 _("'ROR' operator not allowed"));
2565 num
= qualifier
== AARCH64_OPND_QLF_W
? 31 : 63;
2566 if (!value_in_range_p (opnd
->shifter
.amount
, 0, num
))
2568 set_sft_amount_out_of_range_error (mismatch_detail
, idx
, 0, num
);
2585 /* Main entrypoint for the operand constraint checking.
2587 Return 1 if operands of *INST meet the constraint applied by the operand
2588 codes and operand qualifiers; otherwise return 0 and if MISMATCH_DETAIL is
2589 not NULL, return the detail of the error in *MISMATCH_DETAIL. N.B. when
2590 adding more constraint checking, make sure MISMATCH_DETAIL->KIND is set
2591 with a proper error kind rather than AARCH64_OPDE_NIL (GAS asserts non-NIL
2592 error kind when it is notified that an instruction does not pass the check).
2594 Un-determined operand qualifiers may get established during the process. */
2597 aarch64_match_operands_constraint (aarch64_inst
*inst
,
2598 aarch64_operand_error
*mismatch_detail
)
2602 DEBUG_TRACE ("enter");
2604 /* Check for cases where a source register needs to be the same as the
2605 destination register. Do this before matching qualifiers since if
2606 an instruction has both invalid tying and invalid qualifiers,
2607 the error about qualifiers would suggest several alternative
2608 instructions that also have invalid tying. */
2609 i
= inst
->opcode
->tied_operand
;
2610 if (i
> 0 && (inst
->operands
[0].reg
.regno
!= inst
->operands
[i
].reg
.regno
))
2612 if (mismatch_detail
)
2614 mismatch_detail
->kind
= AARCH64_OPDE_UNTIED_OPERAND
;
2615 mismatch_detail
->index
= i
;
2616 mismatch_detail
->error
= NULL
;
2621 /* Match operands' qualifier.
2622 *INST has already had qualifier establish for some, if not all, of
2623 its operands; we need to find out whether these established
2624 qualifiers match one of the qualifier sequence in
2625 INST->OPCODE->QUALIFIERS_LIST. If yes, we will assign each operand
2626 with the corresponding qualifier in such a sequence.
2627 Only basic operand constraint checking is done here; the more thorough
2628 constraint checking will carried out by operand_general_constraint_met_p,
2629 which has be to called after this in order to get all of the operands'
2630 qualifiers established. */
2631 if (match_operands_qualifier (inst
, TRUE
/* update_p */) == 0)
2633 DEBUG_TRACE ("FAIL on operand qualifier matching");
2634 if (mismatch_detail
)
2636 /* Return an error type to indicate that it is the qualifier
2637 matching failure; we don't care about which operand as there
2638 are enough information in the opcode table to reproduce it. */
2639 mismatch_detail
->kind
= AARCH64_OPDE_INVALID_VARIANT
;
2640 mismatch_detail
->index
= -1;
2641 mismatch_detail
->error
= NULL
;
2646 /* Match operands' constraint. */
2647 for (i
= 0; i
< AARCH64_MAX_OPND_NUM
; ++i
)
2649 enum aarch64_opnd type
= inst
->opcode
->operands
[i
];
2650 if (type
== AARCH64_OPND_NIL
)
2652 if (inst
->operands
[i
].skip
)
2654 DEBUG_TRACE ("skip the incomplete operand %d", i
);
2657 if (operand_general_constraint_met_p (inst
->operands
, i
, type
,
2658 inst
->opcode
, mismatch_detail
) == 0)
2660 DEBUG_TRACE ("FAIL on operand %d", i
);
2665 DEBUG_TRACE ("PASS");
2670 /* Replace INST->OPCODE with OPCODE and return the replaced OPCODE.
2671 Also updates the TYPE of each INST->OPERANDS with the corresponding
2672 value of OPCODE->OPERANDS.
2674 Note that some operand qualifiers may need to be manually cleared by
2675 the caller before it further calls the aarch64_opcode_encode; by
2676 doing this, it helps the qualifier matching facilities work
2679 const aarch64_opcode
*
2680 aarch64_replace_opcode (aarch64_inst
*inst
, const aarch64_opcode
*opcode
)
2683 const aarch64_opcode
*old
= inst
->opcode
;
2685 inst
->opcode
= opcode
;
2687 /* Update the operand types. */
2688 for (i
= 0; i
< AARCH64_MAX_OPND_NUM
; ++i
)
2690 inst
->operands
[i
].type
= opcode
->operands
[i
];
2691 if (opcode
->operands
[i
] == AARCH64_OPND_NIL
)
2695 DEBUG_TRACE ("replace %s with %s", old
->name
, opcode
->name
);
2701 aarch64_operand_index (const enum aarch64_opnd
*operands
, enum aarch64_opnd operand
)
2704 for (i
= 0; i
< AARCH64_MAX_OPND_NUM
; ++i
)
2705 if (operands
[i
] == operand
)
2707 else if (operands
[i
] == AARCH64_OPND_NIL
)
2712 /* R0...R30, followed by FOR31. */
2713 #define BANK(R, FOR31) \
2714 { R (0), R (1), R (2), R (3), R (4), R (5), R (6), R (7), \
2715 R (8), R (9), R (10), R (11), R (12), R (13), R (14), R (15), \
2716 R (16), R (17), R (18), R (19), R (20), R (21), R (22), R (23), \
2717 R (24), R (25), R (26), R (27), R (28), R (29), R (30), FOR31 }
2718 /* [0][0] 32-bit integer regs with sp Wn
2719 [0][1] 64-bit integer regs with sp Xn sf=1
2720 [1][0] 32-bit integer regs with #0 Wn
2721 [1][1] 64-bit integer regs with #0 Xn sf=1 */
2722 static const char *int_reg
[2][2][32] = {
2723 #define R32(X) "w" #X
2724 #define R64(X) "x" #X
2725 { BANK (R32
, "wsp"), BANK (R64
, "sp") },
2726 { BANK (R32
, "wzr"), BANK (R64
, "xzr") }
2731 /* Names of the SVE vector registers, first with .S suffixes,
2732 then with .D suffixes. */
2734 static const char *sve_reg
[2][32] = {
2735 #define ZS(X) "z" #X ".s"
2736 #define ZD(X) "z" #X ".d"
2737 BANK (ZS
, ZS (31)), BANK (ZD
, ZD (31))
2743 /* Return the integer register name.
2744 if SP_REG_P is not 0, R31 is an SP reg, other R31 is the zero reg. */
2746 static inline const char *
2747 get_int_reg_name (int regno
, aarch64_opnd_qualifier_t qualifier
, int sp_reg_p
)
2749 const int has_zr
= sp_reg_p
? 0 : 1;
2750 const int is_64
= aarch64_get_qualifier_esize (qualifier
) == 4 ? 0 : 1;
2751 return int_reg
[has_zr
][is_64
][regno
];
2754 /* Like get_int_reg_name, but IS_64 is always 1. */
2756 static inline const char *
2757 get_64bit_int_reg_name (int regno
, int sp_reg_p
)
2759 const int has_zr
= sp_reg_p
? 0 : 1;
2760 return int_reg
[has_zr
][1][regno
];
2763 /* Get the name of the integer offset register in OPND, using the shift type
2764 to decide whether it's a word or doubleword. */
2766 static inline const char *
2767 get_offset_int_reg_name (const aarch64_opnd_info
*opnd
)
2769 switch (opnd
->shifter
.kind
)
2771 case AARCH64_MOD_UXTW
:
2772 case AARCH64_MOD_SXTW
:
2773 return get_int_reg_name (opnd
->addr
.offset
.regno
, AARCH64_OPND_QLF_W
, 0);
2775 case AARCH64_MOD_LSL
:
2776 case AARCH64_MOD_SXTX
:
2777 return get_int_reg_name (opnd
->addr
.offset
.regno
, AARCH64_OPND_QLF_X
, 0);
2784 /* Get the name of the SVE vector offset register in OPND, using the operand
2785 qualifier to decide whether the suffix should be .S or .D. */
2787 static inline const char *
2788 get_addr_sve_reg_name (int regno
, aarch64_opnd_qualifier_t qualifier
)
2790 assert (qualifier
== AARCH64_OPND_QLF_S_S
2791 || qualifier
== AARCH64_OPND_QLF_S_D
);
2792 return sve_reg
[qualifier
== AARCH64_OPND_QLF_S_D
][regno
];
2795 /* Types for expanding an encoded 8-bit value to a floating-point value. */
2815 /* IMM8 is an 8-bit floating-point constant with sign, 3-bit exponent and
2816 normalized 4 bits of precision, encoded in "a:b:c:d:e:f:g:h" or FLD_imm8
2817 (depending on the type of the instruction). IMM8 will be expanded to a
2818 single-precision floating-point value (SIZE == 4) or a double-precision
2819 floating-point value (SIZE == 8). A half-precision floating-point value
2820 (SIZE == 2) is expanded to a single-precision floating-point value. The
2821 expanded value is returned. */
2824 expand_fp_imm (int size
, uint32_t imm8
)
2827 uint32_t imm8_7
, imm8_6_0
, imm8_6
, imm8_6_repl4
;
2829 imm8_7
= (imm8
>> 7) & 0x01; /* imm8<7> */
2830 imm8_6_0
= imm8
& 0x7f; /* imm8<6:0> */
2831 imm8_6
= imm8_6_0
>> 6; /* imm8<6> */
2832 imm8_6_repl4
= (imm8_6
<< 3) | (imm8_6
<< 2)
2833 | (imm8_6
<< 1) | imm8_6
; /* Replicate(imm8<6>,4) */
2836 imm
= (imm8_7
<< (63-32)) /* imm8<7> */
2837 | ((imm8_6
^ 1) << (62-32)) /* NOT(imm8<6) */
2838 | (imm8_6_repl4
<< (58-32)) | (imm8_6
<< (57-32))
2839 | (imm8_6
<< (56-32)) | (imm8_6
<< (55-32)) /* Replicate(imm8<6>,7) */
2840 | (imm8_6_0
<< (48-32)); /* imm8<6>:imm8<5:0> */
2843 else if (size
== 4 || size
== 2)
2845 imm
= (imm8_7
<< 31) /* imm8<7> */
2846 | ((imm8_6
^ 1) << 30) /* NOT(imm8<6>) */
2847 | (imm8_6_repl4
<< 26) /* Replicate(imm8<6>,4) */
2848 | (imm8_6_0
<< 19); /* imm8<6>:imm8<5:0> */
2852 /* An unsupported size. */
2859 /* Produce the string representation of the register list operand *OPND
2860 in the buffer pointed by BUF of size SIZE. PREFIX is the part of
2861 the register name that comes before the register number, such as "v". */
2863 print_register_list (char *buf
, size_t size
, const aarch64_opnd_info
*opnd
,
2866 const int num_regs
= opnd
->reglist
.num_regs
;
2867 const int first_reg
= opnd
->reglist
.first_regno
;
2868 const int last_reg
= (first_reg
+ num_regs
- 1) & 0x1f;
2869 const char *qlf_name
= aarch64_get_qualifier_name (opnd
->qualifier
);
2870 char tb
[8]; /* Temporary buffer. */
2872 assert (opnd
->type
!= AARCH64_OPND_LEt
|| opnd
->reglist
.has_index
);
2873 assert (num_regs
>= 1 && num_regs
<= 4);
2875 /* Prepare the index if any. */
2876 if (opnd
->reglist
.has_index
)
2877 snprintf (tb
, 8, "[%" PRIi64
"]", opnd
->reglist
.index
);
2881 /* The hyphenated form is preferred for disassembly if there are
2882 more than two registers in the list, and the register numbers
2883 are monotonically increasing in increments of one. */
2884 if (num_regs
> 2 && last_reg
> first_reg
)
2885 snprintf (buf
, size
, "{%s%d.%s-%s%d.%s}%s", prefix
, first_reg
, qlf_name
,
2886 prefix
, last_reg
, qlf_name
, tb
);
2889 const int reg0
= first_reg
;
2890 const int reg1
= (first_reg
+ 1) & 0x1f;
2891 const int reg2
= (first_reg
+ 2) & 0x1f;
2892 const int reg3
= (first_reg
+ 3) & 0x1f;
2897 snprintf (buf
, size
, "{%s%d.%s}%s", prefix
, reg0
, qlf_name
, tb
);
2900 snprintf (buf
, size
, "{%s%d.%s, %s%d.%s}%s", prefix
, reg0
, qlf_name
,
2901 prefix
, reg1
, qlf_name
, tb
);
2904 snprintf (buf
, size
, "{%s%d.%s, %s%d.%s, %s%d.%s}%s",
2905 prefix
, reg0
, qlf_name
, prefix
, reg1
, qlf_name
,
2906 prefix
, reg2
, qlf_name
, tb
);
2909 snprintf (buf
, size
, "{%s%d.%s, %s%d.%s, %s%d.%s, %s%d.%s}%s",
2910 prefix
, reg0
, qlf_name
, prefix
, reg1
, qlf_name
,
2911 prefix
, reg2
, qlf_name
, prefix
, reg3
, qlf_name
, tb
);
2917 /* Print the register+immediate address in OPND to BUF, which has SIZE
2918 characters. BASE is the name of the base register. */
2921 print_immediate_offset_address (char *buf
, size_t size
,
2922 const aarch64_opnd_info
*opnd
,
2925 if (opnd
->addr
.writeback
)
2927 if (opnd
->addr
.preind
)
2928 snprintf (buf
, size
, "[%s, #%d]!", base
, opnd
->addr
.offset
.imm
);
2930 snprintf (buf
, size
, "[%s], #%d", base
, opnd
->addr
.offset
.imm
);
2934 if (opnd
->shifter
.operator_present
)
2936 assert (opnd
->shifter
.kind
== AARCH64_MOD_MUL_VL
);
2937 snprintf (buf
, size
, "[%s, #%d, mul vl]",
2938 base
, opnd
->addr
.offset
.imm
);
2940 else if (opnd
->addr
.offset
.imm
)
2941 snprintf (buf
, size
, "[%s, #%d]", base
, opnd
->addr
.offset
.imm
);
2943 snprintf (buf
, size
, "[%s]", base
);
2947 /* Produce the string representation of the register offset address operand
2948 *OPND in the buffer pointed by BUF of size SIZE. BASE and OFFSET are
2949 the names of the base and offset registers. */
2951 print_register_offset_address (char *buf
, size_t size
,
2952 const aarch64_opnd_info
*opnd
,
2953 const char *base
, const char *offset
)
2955 char tb
[16]; /* Temporary buffer. */
2956 bfd_boolean print_extend_p
= TRUE
;
2957 bfd_boolean print_amount_p
= TRUE
;
2958 const char *shift_name
= aarch64_operand_modifiers
[opnd
->shifter
.kind
].name
;
2960 if (!opnd
->shifter
.amount
&& (opnd
->qualifier
!= AARCH64_OPND_QLF_S_B
2961 || !opnd
->shifter
.amount_present
))
2963 /* Not print the shift/extend amount when the amount is zero and
2964 when it is not the special case of 8-bit load/store instruction. */
2965 print_amount_p
= FALSE
;
2966 /* Likewise, no need to print the shift operator LSL in such a
2968 if (opnd
->shifter
.kind
== AARCH64_MOD_LSL
)
2969 print_extend_p
= FALSE
;
2972 /* Prepare for the extend/shift. */
2976 snprintf (tb
, sizeof (tb
), ", %s #%" PRIi64
, shift_name
,
2977 opnd
->shifter
.amount
);
2979 snprintf (tb
, sizeof (tb
), ", %s", shift_name
);
2984 snprintf (buf
, size
, "[%s, %s%s]", base
, offset
, tb
);
2987 /* Generate the string representation of the operand OPNDS[IDX] for OPCODE
2988 in *BUF. The caller should pass in the maximum size of *BUF in SIZE.
2989 PC, PCREL_P and ADDRESS are used to pass in and return information about
2990 the PC-relative address calculation, where the PC value is passed in
2991 PC. If the operand is pc-relative related, *PCREL_P (if PCREL_P non-NULL)
2992 will return 1 and *ADDRESS (if ADDRESS non-NULL) will return the
2993 calculated address; otherwise, *PCREL_P (if PCREL_P non-NULL) returns 0.
2995 The function serves both the disassembler and the assembler diagnostics
2996 issuer, which is the reason why it lives in this file. */
2999 aarch64_print_operand (char *buf
, size_t size
, bfd_vma pc
,
3000 const aarch64_opcode
*opcode
,
3001 const aarch64_opnd_info
*opnds
, int idx
, int *pcrel_p
,
3004 unsigned int i
, num_conds
;
3005 const char *name
= NULL
;
3006 const aarch64_opnd_info
*opnd
= opnds
+ idx
;
3007 enum aarch64_modifier_kind kind
;
3008 uint64_t addr
, enum_value
;
3016 case AARCH64_OPND_Rd
:
3017 case AARCH64_OPND_Rn
:
3018 case AARCH64_OPND_Rm
:
3019 case AARCH64_OPND_Rt
:
3020 case AARCH64_OPND_Rt2
:
3021 case AARCH64_OPND_Rs
:
3022 case AARCH64_OPND_Ra
:
3023 case AARCH64_OPND_Rt_SYS
:
3024 case AARCH64_OPND_PAIRREG
:
3025 case AARCH64_OPND_SVE_Rm
:
3026 /* The optional-ness of <Xt> in e.g. IC <ic_op>{, <Xt>} is determined by
3027 the <ic_op>, therefore we we use opnd->present to override the
3028 generic optional-ness information. */
3029 if (opnd
->type
== AARCH64_OPND_Rt_SYS
)
3034 /* Omit the operand, e.g. RET. */
3035 else if (optional_operand_p (opcode
, idx
)
3037 == get_optional_operand_default_value (opcode
)))
3039 assert (opnd
->qualifier
== AARCH64_OPND_QLF_W
3040 || opnd
->qualifier
== AARCH64_OPND_QLF_X
);
3041 snprintf (buf
, size
, "%s",
3042 get_int_reg_name (opnd
->reg
.regno
, opnd
->qualifier
, 0));
3045 case AARCH64_OPND_Rd_SP
:
3046 case AARCH64_OPND_Rn_SP
:
3047 case AARCH64_OPND_SVE_Rn_SP
:
3048 case AARCH64_OPND_Rm_SP
:
3049 assert (opnd
->qualifier
== AARCH64_OPND_QLF_W
3050 || opnd
->qualifier
== AARCH64_OPND_QLF_WSP
3051 || opnd
->qualifier
== AARCH64_OPND_QLF_X
3052 || opnd
->qualifier
== AARCH64_OPND_QLF_SP
);
3053 snprintf (buf
, size
, "%s",
3054 get_int_reg_name (opnd
->reg
.regno
, opnd
->qualifier
, 1));
3057 case AARCH64_OPND_Rm_EXT
:
3058 kind
= opnd
->shifter
.kind
;
3059 assert (idx
== 1 || idx
== 2);
3060 if ((aarch64_stack_pointer_p (opnds
)
3061 || (idx
== 2 && aarch64_stack_pointer_p (opnds
+ 1)))
3062 && ((opnd
->qualifier
== AARCH64_OPND_QLF_W
3063 && opnds
[0].qualifier
== AARCH64_OPND_QLF_W
3064 && kind
== AARCH64_MOD_UXTW
)
3065 || (opnd
->qualifier
== AARCH64_OPND_QLF_X
3066 && kind
== AARCH64_MOD_UXTX
)))
3068 /* 'LSL' is the preferred form in this case. */
3069 kind
= AARCH64_MOD_LSL
;
3070 if (opnd
->shifter
.amount
== 0)
3072 /* Shifter omitted. */
3073 snprintf (buf
, size
, "%s",
3074 get_int_reg_name (opnd
->reg
.regno
, opnd
->qualifier
, 0));
3078 if (opnd
->shifter
.amount
)
3079 snprintf (buf
, size
, "%s, %s #%" PRIi64
,
3080 get_int_reg_name (opnd
->reg
.regno
, opnd
->qualifier
, 0),
3081 aarch64_operand_modifiers
[kind
].name
,
3082 opnd
->shifter
.amount
);
3084 snprintf (buf
, size
, "%s, %s",
3085 get_int_reg_name (opnd
->reg
.regno
, opnd
->qualifier
, 0),
3086 aarch64_operand_modifiers
[kind
].name
);
3089 case AARCH64_OPND_Rm_SFT
:
3090 assert (opnd
->qualifier
== AARCH64_OPND_QLF_W
3091 || opnd
->qualifier
== AARCH64_OPND_QLF_X
);
3092 if (opnd
->shifter
.amount
== 0 && opnd
->shifter
.kind
== AARCH64_MOD_LSL
)
3093 snprintf (buf
, size
, "%s",
3094 get_int_reg_name (opnd
->reg
.regno
, opnd
->qualifier
, 0));
3096 snprintf (buf
, size
, "%s, %s #%" PRIi64
,
3097 get_int_reg_name (opnd
->reg
.regno
, opnd
->qualifier
, 0),
3098 aarch64_operand_modifiers
[opnd
->shifter
.kind
].name
,
3099 opnd
->shifter
.amount
);
3102 case AARCH64_OPND_Fd
:
3103 case AARCH64_OPND_Fn
:
3104 case AARCH64_OPND_Fm
:
3105 case AARCH64_OPND_Fa
:
3106 case AARCH64_OPND_Ft
:
3107 case AARCH64_OPND_Ft2
:
3108 case AARCH64_OPND_Sd
:
3109 case AARCH64_OPND_Sn
:
3110 case AARCH64_OPND_Sm
:
3111 case AARCH64_OPND_SVE_VZn
:
3112 case AARCH64_OPND_SVE_Vd
:
3113 case AARCH64_OPND_SVE_Vm
:
3114 case AARCH64_OPND_SVE_Vn
:
3115 snprintf (buf
, size
, "%s%d", aarch64_get_qualifier_name (opnd
->qualifier
),
3119 case AARCH64_OPND_Vd
:
3120 case AARCH64_OPND_Vn
:
3121 case AARCH64_OPND_Vm
:
3122 snprintf (buf
, size
, "v%d.%s", opnd
->reg
.regno
,
3123 aarch64_get_qualifier_name (opnd
->qualifier
));
3126 case AARCH64_OPND_Ed
:
3127 case AARCH64_OPND_En
:
3128 case AARCH64_OPND_Em
:
3129 snprintf (buf
, size
, "v%d.%s[%" PRIi64
"]", opnd
->reglane
.regno
,
3130 aarch64_get_qualifier_name (opnd
->qualifier
),
3131 opnd
->reglane
.index
);
3134 case AARCH64_OPND_VdD1
:
3135 case AARCH64_OPND_VnD1
:
3136 snprintf (buf
, size
, "v%d.d[1]", opnd
->reg
.regno
);
3139 case AARCH64_OPND_LVn
:
3140 case AARCH64_OPND_LVt
:
3141 case AARCH64_OPND_LVt_AL
:
3142 case AARCH64_OPND_LEt
:
3143 print_register_list (buf
, size
, opnd
, "v");
3146 case AARCH64_OPND_SVE_Pd
:
3147 case AARCH64_OPND_SVE_Pg3
:
3148 case AARCH64_OPND_SVE_Pg4_5
:
3149 case AARCH64_OPND_SVE_Pg4_10
:
3150 case AARCH64_OPND_SVE_Pg4_16
:
3151 case AARCH64_OPND_SVE_Pm
:
3152 case AARCH64_OPND_SVE_Pn
:
3153 case AARCH64_OPND_SVE_Pt
:
3154 if (opnd
->qualifier
== AARCH64_OPND_QLF_NIL
)
3155 snprintf (buf
, size
, "p%d", opnd
->reg
.regno
);
3156 else if (opnd
->qualifier
== AARCH64_OPND_QLF_P_Z
3157 || opnd
->qualifier
== AARCH64_OPND_QLF_P_M
)
3158 snprintf (buf
, size
, "p%d/%s", opnd
->reg
.regno
,
3159 aarch64_get_qualifier_name (opnd
->qualifier
));
3161 snprintf (buf
, size
, "p%d.%s", opnd
->reg
.regno
,
3162 aarch64_get_qualifier_name (opnd
->qualifier
));
3165 case AARCH64_OPND_SVE_Za_5
:
3166 case AARCH64_OPND_SVE_Za_16
:
3167 case AARCH64_OPND_SVE_Zd
:
3168 case AARCH64_OPND_SVE_Zm_5
:
3169 case AARCH64_OPND_SVE_Zm_16
:
3170 case AARCH64_OPND_SVE_Zn
:
3171 case AARCH64_OPND_SVE_Zt
:
3172 if (opnd
->qualifier
== AARCH64_OPND_QLF_NIL
)
3173 snprintf (buf
, size
, "z%d", opnd
->reg
.regno
);
3175 snprintf (buf
, size
, "z%d.%s", opnd
->reg
.regno
,
3176 aarch64_get_qualifier_name (opnd
->qualifier
));
3179 case AARCH64_OPND_SVE_ZnxN
:
3180 case AARCH64_OPND_SVE_ZtxN
:
3181 print_register_list (buf
, size
, opnd
, "z");
3184 case AARCH64_OPND_SVE_Zn_INDEX
:
3185 snprintf (buf
, size
, "z%d.%s[%" PRIi64
"]", opnd
->reglane
.regno
,
3186 aarch64_get_qualifier_name (opnd
->qualifier
),
3187 opnd
->reglane
.index
);
3190 case AARCH64_OPND_Cn
:
3191 case AARCH64_OPND_Cm
:
3192 snprintf (buf
, size
, "C%d", opnd
->reg
.regno
);
3195 case AARCH64_OPND_IDX
:
3196 case AARCH64_OPND_IMM
:
3197 case AARCH64_OPND_WIDTH
:
3198 case AARCH64_OPND_UIMM3_OP1
:
3199 case AARCH64_OPND_UIMM3_OP2
:
3200 case AARCH64_OPND_BIT_NUM
:
3201 case AARCH64_OPND_IMM_VLSL
:
3202 case AARCH64_OPND_IMM_VLSR
:
3203 case AARCH64_OPND_SHLL_IMM
:
3204 case AARCH64_OPND_IMM0
:
3205 case AARCH64_OPND_IMMR
:
3206 case AARCH64_OPND_IMMS
:
3207 case AARCH64_OPND_FBITS
:
3208 case AARCH64_OPND_SIMM5
:
3209 case AARCH64_OPND_SVE_SHLIMM_PRED
:
3210 case AARCH64_OPND_SVE_SHLIMM_UNPRED
:
3211 case AARCH64_OPND_SVE_SHRIMM_PRED
:
3212 case AARCH64_OPND_SVE_SHRIMM_UNPRED
:
3213 case AARCH64_OPND_SVE_SIMM5
:
3214 case AARCH64_OPND_SVE_SIMM5B
:
3215 case AARCH64_OPND_SVE_SIMM6
:
3216 case AARCH64_OPND_SVE_SIMM8
:
3217 case AARCH64_OPND_SVE_UIMM3
:
3218 case AARCH64_OPND_SVE_UIMM7
:
3219 case AARCH64_OPND_SVE_UIMM8
:
3220 case AARCH64_OPND_SVE_UIMM8_53
:
3221 case AARCH64_OPND_IMM_ROT1
:
3222 case AARCH64_OPND_IMM_ROT2
:
3223 case AARCH64_OPND_IMM_ROT3
:
3224 snprintf (buf
, size
, "#%" PRIi64
, opnd
->imm
.value
);
3227 case AARCH64_OPND_SVE_I1_HALF_ONE
:
3228 case AARCH64_OPND_SVE_I1_HALF_TWO
:
3229 case AARCH64_OPND_SVE_I1_ZERO_ONE
:
3232 c
.i
= opnd
->imm
.value
;
3233 snprintf (buf
, size
, "#%.1f", c
.f
);
3237 case AARCH64_OPND_SVE_PATTERN
:
3238 if (optional_operand_p (opcode
, idx
)
3239 && opnd
->imm
.value
== get_optional_operand_default_value (opcode
))
3241 enum_value
= opnd
->imm
.value
;
3242 assert (enum_value
< ARRAY_SIZE (aarch64_sve_pattern_array
));
3243 if (aarch64_sve_pattern_array
[enum_value
])
3244 snprintf (buf
, size
, "%s", aarch64_sve_pattern_array
[enum_value
]);
3246 snprintf (buf
, size
, "#%" PRIi64
, opnd
->imm
.value
);
3249 case AARCH64_OPND_SVE_PATTERN_SCALED
:
3250 if (optional_operand_p (opcode
, idx
)
3251 && !opnd
->shifter
.operator_present
3252 && opnd
->imm
.value
== get_optional_operand_default_value (opcode
))
3254 enum_value
= opnd
->imm
.value
;
3255 assert (enum_value
< ARRAY_SIZE (aarch64_sve_pattern_array
));
3256 if (aarch64_sve_pattern_array
[opnd
->imm
.value
])
3257 snprintf (buf
, size
, "%s", aarch64_sve_pattern_array
[opnd
->imm
.value
]);
3259 snprintf (buf
, size
, "#%" PRIi64
, opnd
->imm
.value
);
3260 if (opnd
->shifter
.operator_present
)
3262 size_t len
= strlen (buf
);
3263 snprintf (buf
+ len
, size
- len
, ", %s #%" PRIi64
,
3264 aarch64_operand_modifiers
[opnd
->shifter
.kind
].name
,
3265 opnd
->shifter
.amount
);
3269 case AARCH64_OPND_SVE_PRFOP
:
3270 enum_value
= opnd
->imm
.value
;
3271 assert (enum_value
< ARRAY_SIZE (aarch64_sve_prfop_array
));
3272 if (aarch64_sve_prfop_array
[enum_value
])
3273 snprintf (buf
, size
, "%s", aarch64_sve_prfop_array
[enum_value
]);
3275 snprintf (buf
, size
, "#%" PRIi64
, opnd
->imm
.value
);
3278 case AARCH64_OPND_IMM_MOV
:
3279 switch (aarch64_get_qualifier_esize (opnds
[0].qualifier
))
3281 case 4: /* e.g. MOV Wd, #<imm32>. */
3283 int imm32
= opnd
->imm
.value
;
3284 snprintf (buf
, size
, "#0x%-20x\t// #%d", imm32
, imm32
);
3287 case 8: /* e.g. MOV Xd, #<imm64>. */
3288 snprintf (buf
, size
, "#0x%-20" PRIx64
"\t// #%" PRIi64
,
3289 opnd
->imm
.value
, opnd
->imm
.value
);
3291 default: assert (0);
3295 case AARCH64_OPND_FPIMM0
:
3296 snprintf (buf
, size
, "#0.0");
3299 case AARCH64_OPND_LIMM
:
3300 case AARCH64_OPND_AIMM
:
3301 case AARCH64_OPND_HALF
:
3302 case AARCH64_OPND_SVE_INV_LIMM
:
3303 case AARCH64_OPND_SVE_LIMM
:
3304 case AARCH64_OPND_SVE_LIMM_MOV
:
3305 if (opnd
->shifter
.amount
)
3306 snprintf (buf
, size
, "#0x%" PRIx64
", lsl #%" PRIi64
, opnd
->imm
.value
,
3307 opnd
->shifter
.amount
);
3309 snprintf (buf
, size
, "#0x%" PRIx64
, opnd
->imm
.value
);
3312 case AARCH64_OPND_SIMD_IMM
:
3313 case AARCH64_OPND_SIMD_IMM_SFT
:
3314 if ((! opnd
->shifter
.amount
&& opnd
->shifter
.kind
== AARCH64_MOD_LSL
)
3315 || opnd
->shifter
.kind
== AARCH64_MOD_NONE
)
3316 snprintf (buf
, size
, "#0x%" PRIx64
, opnd
->imm
.value
);
3318 snprintf (buf
, size
, "#0x%" PRIx64
", %s #%" PRIi64
, opnd
->imm
.value
,
3319 aarch64_operand_modifiers
[opnd
->shifter
.kind
].name
,
3320 opnd
->shifter
.amount
);
3323 case AARCH64_OPND_SVE_AIMM
:
3324 case AARCH64_OPND_SVE_ASIMM
:
3325 if (opnd
->shifter
.amount
)
3326 snprintf (buf
, size
, "#%" PRIi64
", lsl #%" PRIi64
, opnd
->imm
.value
,
3327 opnd
->shifter
.amount
);
3329 snprintf (buf
, size
, "#%" PRIi64
, opnd
->imm
.value
);
3332 case AARCH64_OPND_FPIMM
:
3333 case AARCH64_OPND_SIMD_FPIMM
:
3334 case AARCH64_OPND_SVE_FPIMM8
:
3335 switch (aarch64_get_qualifier_esize (opnds
[0].qualifier
))
3337 case 2: /* e.g. FMOV <Hd>, #<imm>. */
3340 c
.i
= expand_fp_imm (2, opnd
->imm
.value
);
3341 snprintf (buf
, size
, "#%.18e", c
.f
);
3344 case 4: /* e.g. FMOV <Vd>.4S, #<imm>. */
3347 c
.i
= expand_fp_imm (4, opnd
->imm
.value
);
3348 snprintf (buf
, size
, "#%.18e", c
.f
);
3351 case 8: /* e.g. FMOV <Sd>, #<imm>. */
3354 c
.i
= expand_fp_imm (8, opnd
->imm
.value
);
3355 snprintf (buf
, size
, "#%.18e", c
.d
);
3358 default: assert (0);
3362 case AARCH64_OPND_CCMP_IMM
:
3363 case AARCH64_OPND_NZCV
:
3364 case AARCH64_OPND_EXCEPTION
:
3365 case AARCH64_OPND_UIMM4
:
3366 case AARCH64_OPND_UIMM7
:
3367 if (optional_operand_p (opcode
, idx
) == TRUE
3368 && (opnd
->imm
.value
==
3369 (int64_t) get_optional_operand_default_value (opcode
)))
3370 /* Omit the operand, e.g. DCPS1. */
3372 snprintf (buf
, size
, "#0x%x", (unsigned int)opnd
->imm
.value
);
3375 case AARCH64_OPND_COND
:
3376 case AARCH64_OPND_COND1
:
3377 snprintf (buf
, size
, "%s", opnd
->cond
->names
[0]);
3378 num_conds
= ARRAY_SIZE (opnd
->cond
->names
);
3379 for (i
= 1; i
< num_conds
&& opnd
->cond
->names
[i
]; ++i
)
3381 size_t len
= strlen (buf
);
3383 snprintf (buf
+ len
, size
- len
, " // %s = %s",
3384 opnd
->cond
->names
[0], opnd
->cond
->names
[i
]);
3386 snprintf (buf
+ len
, size
- len
, ", %s",
3387 opnd
->cond
->names
[i
]);
3391 case AARCH64_OPND_ADDR_ADRP
:
3392 addr
= ((pc
+ AARCH64_PCREL_OFFSET
) & ~(uint64_t)0xfff)
3398 /* This is not necessary during the disassembling, as print_address_func
3399 in the disassemble_info will take care of the printing. But some
3400 other callers may be still interested in getting the string in *STR,
3401 so here we do snprintf regardless. */
3402 snprintf (buf
, size
, "#0x%" PRIx64
, addr
);
3405 case AARCH64_OPND_ADDR_PCREL14
:
3406 case AARCH64_OPND_ADDR_PCREL19
:
3407 case AARCH64_OPND_ADDR_PCREL21
:
3408 case AARCH64_OPND_ADDR_PCREL26
:
3409 addr
= pc
+ AARCH64_PCREL_OFFSET
+ opnd
->imm
.value
;
3414 /* This is not necessary during the disassembling, as print_address_func
3415 in the disassemble_info will take care of the printing. But some
3416 other callers may be still interested in getting the string in *STR,
3417 so here we do snprintf regardless. */
3418 snprintf (buf
, size
, "#0x%" PRIx64
, addr
);
3421 case AARCH64_OPND_ADDR_SIMPLE
:
3422 case AARCH64_OPND_SIMD_ADDR_SIMPLE
:
3423 case AARCH64_OPND_SIMD_ADDR_POST
:
3424 name
= get_64bit_int_reg_name (opnd
->addr
.base_regno
, 1);
3425 if (opnd
->type
== AARCH64_OPND_SIMD_ADDR_POST
)
3427 if (opnd
->addr
.offset
.is_reg
)
3428 snprintf (buf
, size
, "[%s], x%d", name
, opnd
->addr
.offset
.regno
);
3430 snprintf (buf
, size
, "[%s], #%d", name
, opnd
->addr
.offset
.imm
);
3433 snprintf (buf
, size
, "[%s]", name
);
3436 case AARCH64_OPND_ADDR_REGOFF
:
3437 case AARCH64_OPND_SVE_ADDR_RR
:
3438 case AARCH64_OPND_SVE_ADDR_RR_LSL1
:
3439 case AARCH64_OPND_SVE_ADDR_RR_LSL2
:
3440 case AARCH64_OPND_SVE_ADDR_RR_LSL3
:
3441 case AARCH64_OPND_SVE_ADDR_RX
:
3442 case AARCH64_OPND_SVE_ADDR_RX_LSL1
:
3443 case AARCH64_OPND_SVE_ADDR_RX_LSL2
:
3444 case AARCH64_OPND_SVE_ADDR_RX_LSL3
:
3445 print_register_offset_address
3446 (buf
, size
, opnd
, get_64bit_int_reg_name (opnd
->addr
.base_regno
, 1),
3447 get_offset_int_reg_name (opnd
));
3450 case AARCH64_OPND_SVE_ADDR_RZ
:
3451 case AARCH64_OPND_SVE_ADDR_RZ_LSL1
:
3452 case AARCH64_OPND_SVE_ADDR_RZ_LSL2
:
3453 case AARCH64_OPND_SVE_ADDR_RZ_LSL3
:
3454 case AARCH64_OPND_SVE_ADDR_RZ_XTW_14
:
3455 case AARCH64_OPND_SVE_ADDR_RZ_XTW_22
:
3456 case AARCH64_OPND_SVE_ADDR_RZ_XTW1_14
:
3457 case AARCH64_OPND_SVE_ADDR_RZ_XTW1_22
:
3458 case AARCH64_OPND_SVE_ADDR_RZ_XTW2_14
:
3459 case AARCH64_OPND_SVE_ADDR_RZ_XTW2_22
:
3460 case AARCH64_OPND_SVE_ADDR_RZ_XTW3_14
:
3461 case AARCH64_OPND_SVE_ADDR_RZ_XTW3_22
:
3462 print_register_offset_address
3463 (buf
, size
, opnd
, get_64bit_int_reg_name (opnd
->addr
.base_regno
, 1),
3464 get_addr_sve_reg_name (opnd
->addr
.offset
.regno
, opnd
->qualifier
));
3467 case AARCH64_OPND_ADDR_SIMM7
:
3468 case AARCH64_OPND_ADDR_SIMM9
:
3469 case AARCH64_OPND_ADDR_SIMM9_2
:
3470 case AARCH64_OPND_ADDR_SIMM10
:
3471 case AARCH64_OPND_SVE_ADDR_RI_S4xVL
:
3472 case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL
:
3473 case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL
:
3474 case AARCH64_OPND_SVE_ADDR_RI_S4x4xVL
:
3475 case AARCH64_OPND_SVE_ADDR_RI_S6xVL
:
3476 case AARCH64_OPND_SVE_ADDR_RI_S9xVL
:
3477 case AARCH64_OPND_SVE_ADDR_RI_U6
:
3478 case AARCH64_OPND_SVE_ADDR_RI_U6x2
:
3479 case AARCH64_OPND_SVE_ADDR_RI_U6x4
:
3480 case AARCH64_OPND_SVE_ADDR_RI_U6x8
:
3481 print_immediate_offset_address
3482 (buf
, size
, opnd
, get_64bit_int_reg_name (opnd
->addr
.base_regno
, 1));
3485 case AARCH64_OPND_SVE_ADDR_ZI_U5
:
3486 case AARCH64_OPND_SVE_ADDR_ZI_U5x2
:
3487 case AARCH64_OPND_SVE_ADDR_ZI_U5x4
:
3488 case AARCH64_OPND_SVE_ADDR_ZI_U5x8
:
3489 print_immediate_offset_address
3491 get_addr_sve_reg_name (opnd
->addr
.base_regno
, opnd
->qualifier
));
3494 case AARCH64_OPND_SVE_ADDR_ZZ_LSL
:
3495 case AARCH64_OPND_SVE_ADDR_ZZ_SXTW
:
3496 case AARCH64_OPND_SVE_ADDR_ZZ_UXTW
:
3497 print_register_offset_address
3499 get_addr_sve_reg_name (opnd
->addr
.base_regno
, opnd
->qualifier
),
3500 get_addr_sve_reg_name (opnd
->addr
.offset
.regno
, opnd
->qualifier
));
3503 case AARCH64_OPND_ADDR_UIMM12
:
3504 name
= get_64bit_int_reg_name (opnd
->addr
.base_regno
, 1);
3505 if (opnd
->addr
.offset
.imm
)
3506 snprintf (buf
, size
, "[%s, #%d]", name
, opnd
->addr
.offset
.imm
);
3508 snprintf (buf
, size
, "[%s]", name
);
3511 case AARCH64_OPND_SYSREG
:
3512 for (i
= 0; aarch64_sys_regs
[i
].name
; ++i
)
3513 if (aarch64_sys_regs
[i
].value
== opnd
->sysreg
3514 && ! aarch64_sys_reg_deprecated_p (&aarch64_sys_regs
[i
]))
3516 if (aarch64_sys_regs
[i
].name
)
3517 snprintf (buf
, size
, "%s", aarch64_sys_regs
[i
].name
);
3520 /* Implementation defined system register. */
3521 unsigned int value
= opnd
->sysreg
;
3522 snprintf (buf
, size
, "s%u_%u_c%u_c%u_%u", (value
>> 14) & 0x3,
3523 (value
>> 11) & 0x7, (value
>> 7) & 0xf, (value
>> 3) & 0xf,
3528 case AARCH64_OPND_PSTATEFIELD
:
3529 for (i
= 0; aarch64_pstatefields
[i
].name
; ++i
)
3530 if (aarch64_pstatefields
[i
].value
== opnd
->pstatefield
)
3532 assert (aarch64_pstatefields
[i
].name
);
3533 snprintf (buf
, size
, "%s", aarch64_pstatefields
[i
].name
);
3536 case AARCH64_OPND_SYSREG_AT
:
3537 case AARCH64_OPND_SYSREG_DC
:
3538 case AARCH64_OPND_SYSREG_IC
:
3539 case AARCH64_OPND_SYSREG_TLBI
:
3540 snprintf (buf
, size
, "%s", opnd
->sysins_op
->name
);
3543 case AARCH64_OPND_BARRIER
:
3544 snprintf (buf
, size
, "%s", opnd
->barrier
->name
);
3547 case AARCH64_OPND_BARRIER_ISB
:
3548 /* Operand can be omitted, e.g. in DCPS1. */
3549 if (! optional_operand_p (opcode
, idx
)
3550 || (opnd
->barrier
->value
3551 != get_optional_operand_default_value (opcode
)))
3552 snprintf (buf
, size
, "#0x%x", opnd
->barrier
->value
);
3555 case AARCH64_OPND_PRFOP
:
3556 if (opnd
->prfop
->name
!= NULL
)
3557 snprintf (buf
, size
, "%s", opnd
->prfop
->name
);
3559 snprintf (buf
, size
, "#0x%02x", opnd
->prfop
->value
);
3562 case AARCH64_OPND_BARRIER_PSB
:
3563 snprintf (buf
, size
, "%s", opnd
->hint_option
->name
);
3571 #define CPENC(op0,op1,crn,crm,op2) \
3572 ((((op0) << 19) | ((op1) << 16) | ((crn) << 12) | ((crm) << 8) | ((op2) << 5)) >> 5)
3573 /* for 3.9.3 Instructions for Accessing Special Purpose Registers */
3574 #define CPEN_(op1,crm,op2) CPENC(3,(op1),4,(crm),(op2))
3575 /* for 3.9.10 System Instructions */
3576 #define CPENS(op1,crn,crm,op2) CPENC(1,(op1),(crn),(crm),(op2))
3598 #define F_DEPRECATED 0x1 /* Deprecated system register. */
3603 #define F_ARCHEXT 0x2 /* Architecture dependent system register. */
3608 #define F_HASXT 0x4 /* System instruction register <Xt>
3612 /* TODO there are two more issues need to be resolved
3613 1. handle read-only and write-only system registers
3614 2. handle cpu-implementation-defined system registers. */
3615 const aarch64_sys_reg aarch64_sys_regs
[] =
3617 { "spsr_el1", CPEN_(0,C0
,0), 0 }, /* = spsr_svc */
3618 { "spsr_el12", CPEN_ (5, C0
, 0), F_ARCHEXT
},
3619 { "elr_el1", CPEN_(0,C0
,1), 0 },
3620 { "elr_el12", CPEN_ (5, C0
, 1), F_ARCHEXT
},
3621 { "sp_el0", CPEN_(0,C1
,0), 0 },
3622 { "spsel", CPEN_(0,C2
,0), 0 },
3623 { "daif", CPEN_(3,C2
,1), 0 },
3624 { "currentel", CPEN_(0,C2
,2), 0 }, /* RO */
3625 { "pan", CPEN_(0,C2
,3), F_ARCHEXT
},
3626 { "uao", CPEN_ (0, C2
, 4), F_ARCHEXT
},
3627 { "nzcv", CPEN_(3,C2
,0), 0 },
3628 { "fpcr", CPEN_(3,C4
,0), 0 },
3629 { "fpsr", CPEN_(3,C4
,1), 0 },
3630 { "dspsr_el0", CPEN_(3,C5
,0), 0 },
3631 { "dlr_el0", CPEN_(3,C5
,1), 0 },
3632 { "spsr_el2", CPEN_(4,C0
,0), 0 }, /* = spsr_hyp */
3633 { "elr_el2", CPEN_(4,C0
,1), 0 },
3634 { "sp_el1", CPEN_(4,C1
,0), 0 },
3635 { "spsr_irq", CPEN_(4,C3
,0), 0 },
3636 { "spsr_abt", CPEN_(4,C3
,1), 0 },
3637 { "spsr_und", CPEN_(4,C3
,2), 0 },
3638 { "spsr_fiq", CPEN_(4,C3
,3), 0 },
3639 { "spsr_el3", CPEN_(6,C0
,0), 0 },
3640 { "elr_el3", CPEN_(6,C0
,1), 0 },
3641 { "sp_el2", CPEN_(6,C1
,0), 0 },
3642 { "spsr_svc", CPEN_(0,C0
,0), F_DEPRECATED
}, /* = spsr_el1 */
3643 { "spsr_hyp", CPEN_(4,C0
,0), F_DEPRECATED
}, /* = spsr_el2 */
3644 { "midr_el1", CPENC(3,0,C0
,C0
,0), 0 }, /* RO */
3645 { "ctr_el0", CPENC(3,3,C0
,C0
,1), 0 }, /* RO */
3646 { "mpidr_el1", CPENC(3,0,C0
,C0
,5), 0 }, /* RO */
3647 { "revidr_el1", CPENC(3,0,C0
,C0
,6), 0 }, /* RO */
3648 { "aidr_el1", CPENC(3,1,C0
,C0
,7), 0 }, /* RO */
3649 { "dczid_el0", CPENC(3,3,C0
,C0
,7), 0 }, /* RO */
3650 { "id_dfr0_el1", CPENC(3,0,C0
,C1
,2), 0 }, /* RO */
3651 { "id_pfr0_el1", CPENC(3,0,C0
,C1
,0), 0 }, /* RO */
3652 { "id_pfr1_el1", CPENC(3,0,C0
,C1
,1), 0 }, /* RO */
3653 { "id_afr0_el1", CPENC(3,0,C0
,C1
,3), 0 }, /* RO */
3654 { "id_mmfr0_el1", CPENC(3,0,C0
,C1
,4), 0 }, /* RO */
3655 { "id_mmfr1_el1", CPENC(3,0,C0
,C1
,5), 0 }, /* RO */
3656 { "id_mmfr2_el1", CPENC(3,0,C0
,C1
,6), 0 }, /* RO */
3657 { "id_mmfr3_el1", CPENC(3,0,C0
,C1
,7), 0 }, /* RO */
3658 { "id_mmfr4_el1", CPENC(3,0,C0
,C2
,6), 0 }, /* RO */
3659 { "id_isar0_el1", CPENC(3,0,C0
,C2
,0), 0 }, /* RO */
3660 { "id_isar1_el1", CPENC(3,0,C0
,C2
,1), 0 }, /* RO */
3661 { "id_isar2_el1", CPENC(3,0,C0
,C2
,2), 0 }, /* RO */
3662 { "id_isar3_el1", CPENC(3,0,C0
,C2
,3), 0 }, /* RO */
3663 { "id_isar4_el1", CPENC(3,0,C0
,C2
,4), 0 }, /* RO */
3664 { "id_isar5_el1", CPENC(3,0,C0
,C2
,5), 0 }, /* RO */
3665 { "mvfr0_el1", CPENC(3,0,C0
,C3
,0), 0 }, /* RO */
3666 { "mvfr1_el1", CPENC(3,0,C0
,C3
,1), 0 }, /* RO */
3667 { "mvfr2_el1", CPENC(3,0,C0
,C3
,2), 0 }, /* RO */
3668 { "ccsidr_el1", CPENC(3,1,C0
,C0
,0), 0 }, /* RO */
3669 { "id_aa64pfr0_el1", CPENC(3,0,C0
,C4
,0), 0 }, /* RO */
3670 { "id_aa64pfr1_el1", CPENC(3,0,C0
,C4
,1), 0 }, /* RO */
3671 { "id_aa64dfr0_el1", CPENC(3,0,C0
,C5
,0), 0 }, /* RO */
3672 { "id_aa64dfr1_el1", CPENC(3,0,C0
,C5
,1), 0 }, /* RO */
3673 { "id_aa64isar0_el1", CPENC(3,0,C0
,C6
,0), 0 }, /* RO */
3674 { "id_aa64isar1_el1", CPENC(3,0,C0
,C6
,1), 0 }, /* RO */
3675 { "id_aa64mmfr0_el1", CPENC(3,0,C0
,C7
,0), 0 }, /* RO */
3676 { "id_aa64mmfr1_el1", CPENC(3,0,C0
,C7
,1), 0 }, /* RO */
3677 { "id_aa64mmfr2_el1", CPENC (3, 0, C0
, C7
, 2), F_ARCHEXT
}, /* RO */
3678 { "id_aa64afr0_el1", CPENC(3,0,C0
,C5
,4), 0 }, /* RO */
3679 { "id_aa64afr1_el1", CPENC(3,0,C0
,C5
,5), 0 }, /* RO */
3680 { "clidr_el1", CPENC(3,1,C0
,C0
,1), 0 }, /* RO */
3681 { "csselr_el1", CPENC(3,2,C0
,C0
,0), 0 }, /* RO */
3682 { "vpidr_el2", CPENC(3,4,C0
,C0
,0), 0 },
3683 { "vmpidr_el2", CPENC(3,4,C0
,C0
,5), 0 },
3684 { "sctlr_el1", CPENC(3,0,C1
,C0
,0), 0 },
3685 { "sctlr_el2", CPENC(3,4,C1
,C0
,0), 0 },
3686 { "sctlr_el3", CPENC(3,6,C1
,C0
,0), 0 },
3687 { "sctlr_el12", CPENC (3, 5, C1
, C0
, 0), F_ARCHEXT
},
3688 { "actlr_el1", CPENC(3,0,C1
,C0
,1), 0 },
3689 { "actlr_el2", CPENC(3,4,C1
,C0
,1), 0 },
3690 { "actlr_el3", CPENC(3,6,C1
,C0
,1), 0 },
3691 { "cpacr_el1", CPENC(3,0,C1
,C0
,2), 0 },
3692 { "cpacr_el12", CPENC (3, 5, C1
, C0
, 2), F_ARCHEXT
},
3693 { "cptr_el2", CPENC(3,4,C1
,C1
,2), 0 },
3694 { "cptr_el3", CPENC(3,6,C1
,C1
,2), 0 },
3695 { "scr_el3", CPENC(3,6,C1
,C1
,0), 0 },
3696 { "hcr_el2", CPENC(3,4,C1
,C1
,0), 0 },
3697 { "mdcr_el2", CPENC(3,4,C1
,C1
,1), 0 },
3698 { "mdcr_el3", CPENC(3,6,C1
,C3
,1), 0 },
3699 { "hstr_el2", CPENC(3,4,C1
,C1
,3), 0 },
3700 { "hacr_el2", CPENC(3,4,C1
,C1
,7), 0 },
3701 { "ttbr0_el1", CPENC(3,0,C2
,C0
,0), 0 },
3702 { "ttbr1_el1", CPENC(3,0,C2
,C0
,1), 0 },
3703 { "ttbr0_el2", CPENC(3,4,C2
,C0
,0), 0 },
3704 { "ttbr1_el2", CPENC (3, 4, C2
, C0
, 1), F_ARCHEXT
},
3705 { "ttbr0_el3", CPENC(3,6,C2
,C0
,0), 0 },
3706 { "ttbr0_el12", CPENC (3, 5, C2
, C0
, 0), F_ARCHEXT
},
3707 { "ttbr1_el12", CPENC (3, 5, C2
, C0
, 1), F_ARCHEXT
},
3708 { "vttbr_el2", CPENC(3,4,C2
,C1
,0), 0 },
3709 { "tcr_el1", CPENC(3,0,C2
,C0
,2), 0 },
3710 { "tcr_el2", CPENC(3,4,C2
,C0
,2), 0 },
3711 { "tcr_el3", CPENC(3,6,C2
,C0
,2), 0 },
3712 { "tcr_el12", CPENC (3, 5, C2
, C0
, 2), F_ARCHEXT
},
3713 { "vtcr_el2", CPENC(3,4,C2
,C1
,2), 0 },
3714 { "apiakeylo_el1", CPENC (3, 0, C2
, C1
, 0), F_ARCHEXT
},
3715 { "apiakeyhi_el1", CPENC (3, 0, C2
, C1
, 1), F_ARCHEXT
},
3716 { "apibkeylo_el1", CPENC (3, 0, C2
, C1
, 2), F_ARCHEXT
},
3717 { "apibkeyhi_el1", CPENC (3, 0, C2
, C1
, 3), F_ARCHEXT
},
3718 { "apdakeylo_el1", CPENC (3, 0, C2
, C2
, 0), F_ARCHEXT
},
3719 { "apdakeyhi_el1", CPENC (3, 0, C2
, C2
, 1), F_ARCHEXT
},
3720 { "apdbkeylo_el1", CPENC (3, 0, C2
, C2
, 2), F_ARCHEXT
},
3721 { "apdbkeyhi_el1", CPENC (3, 0, C2
, C2
, 3), F_ARCHEXT
},
3722 { "apgakeylo_el1", CPENC (3, 0, C2
, C3
, 0), F_ARCHEXT
},
3723 { "apgakeyhi_el1", CPENC (3, 0, C2
, C3
, 1), F_ARCHEXT
},
3724 { "afsr0_el1", CPENC(3,0,C5
,C1
,0), 0 },
3725 { "afsr1_el1", CPENC(3,0,C5
,C1
,1), 0 },
3726 { "afsr0_el2", CPENC(3,4,C5
,C1
,0), 0 },
3727 { "afsr1_el2", CPENC(3,4,C5
,C1
,1), 0 },
3728 { "afsr0_el3", CPENC(3,6,C5
,C1
,0), 0 },
3729 { "afsr0_el12", CPENC (3, 5, C5
, C1
, 0), F_ARCHEXT
},
3730 { "afsr1_el3", CPENC(3,6,C5
,C1
,1), 0 },
3731 { "afsr1_el12", CPENC (3, 5, C5
, C1
, 1), F_ARCHEXT
},
3732 { "esr_el1", CPENC(3,0,C5
,C2
,0), 0 },
3733 { "esr_el2", CPENC(3,4,C5
,C2
,0), 0 },
3734 { "esr_el3", CPENC(3,6,C5
,C2
,0), 0 },
3735 { "esr_el12", CPENC (3, 5, C5
, C2
, 0), F_ARCHEXT
},
3736 { "vsesr_el2", CPENC (3, 4, C5
, C2
, 3), F_ARCHEXT
}, /* RO */
3737 { "fpexc32_el2", CPENC(3,4,C5
,C3
,0), 0 },
3738 { "erridr_el1", CPENC (3, 0, C5
, C3
, 0), F_ARCHEXT
}, /* RO */
3739 { "errselr_el1", CPENC (3, 0, C5
, C3
, 1), F_ARCHEXT
},
3740 { "erxfr_el1", CPENC (3, 0, C5
, C4
, 0), F_ARCHEXT
}, /* RO */
3741 { "erxctlr_el1", CPENC (3, 0, C5
, C4
, 1), F_ARCHEXT
},
3742 { "erxstatus_el1", CPENC (3, 0, C5
, C4
, 2), F_ARCHEXT
},
3743 { "erxaddr_el1", CPENC (3, 0, C5
, C4
, 3), F_ARCHEXT
},
3744 { "erxmisc0_el1", CPENC (3, 0, C5
, C5
, 0), F_ARCHEXT
},
3745 { "erxmisc1_el1", CPENC (3, 0, C5
, C5
, 1), F_ARCHEXT
},
3746 { "far_el1", CPENC(3,0,C6
,C0
,0), 0 },
3747 { "far_el2", CPENC(3,4,C6
,C0
,0), 0 },
3748 { "far_el3", CPENC(3,6,C6
,C0
,0), 0 },
3749 { "far_el12", CPENC (3, 5, C6
, C0
, 0), F_ARCHEXT
},
3750 { "hpfar_el2", CPENC(3,4,C6
,C0
,4), 0 },
3751 { "par_el1", CPENC(3,0,C7
,C4
,0), 0 },
3752 { "mair_el1", CPENC(3,0,C10
,C2
,0), 0 },
3753 { "mair_el2", CPENC(3,4,C10
,C2
,0), 0 },
3754 { "mair_el3", CPENC(3,6,C10
,C2
,0), 0 },
3755 { "mair_el12", CPENC (3, 5, C10
, C2
, 0), F_ARCHEXT
},
3756 { "amair_el1", CPENC(3,0,C10
,C3
,0), 0 },
3757 { "amair_el2", CPENC(3,4,C10
,C3
,0), 0 },
3758 { "amair_el3", CPENC(3,6,C10
,C3
,0), 0 },
3759 { "amair_el12", CPENC (3, 5, C10
, C3
, 0), F_ARCHEXT
},
3760 { "vbar_el1", CPENC(3,0,C12
,C0
,0), 0 },
3761 { "vbar_el2", CPENC(3,4,C12
,C0
,0), 0 },
3762 { "vbar_el3", CPENC(3,6,C12
,C0
,0), 0 },
3763 { "vbar_el12", CPENC (3, 5, C12
, C0
, 0), F_ARCHEXT
},
3764 { "rvbar_el1", CPENC(3,0,C12
,C0
,1), 0 }, /* RO */
3765 { "rvbar_el2", CPENC(3,4,C12
,C0
,1), 0 }, /* RO */
3766 { "rvbar_el3", CPENC(3,6,C12
,C0
,1), 0 }, /* RO */
3767 { "rmr_el1", CPENC(3,0,C12
,C0
,2), 0 },
3768 { "rmr_el2", CPENC(3,4,C12
,C0
,2), 0 },
3769 { "rmr_el3", CPENC(3,6,C12
,C0
,2), 0 },
3770 { "isr_el1", CPENC(3,0,C12
,C1
,0), 0 }, /* RO */
3771 { "disr_el1", CPENC (3, 0, C12
, C1
, 1), F_ARCHEXT
},
3772 { "vdisr_el2", CPENC (3, 4, C12
, C1
, 1), F_ARCHEXT
},
3773 { "contextidr_el1", CPENC(3,0,C13
,C0
,1), 0 },
3774 { "contextidr_el2", CPENC (3, 4, C13
, C0
, 1), F_ARCHEXT
},
3775 { "contextidr_el12", CPENC (3, 5, C13
, C0
, 1), F_ARCHEXT
},
3776 { "tpidr_el0", CPENC(3,3,C13
,C0
,2), 0 },
3777 { "tpidrro_el0", CPENC(3,3,C13
,C0
,3), 0 }, /* RO */
3778 { "tpidr_el1", CPENC(3,0,C13
,C0
,4), 0 },
3779 { "tpidr_el2", CPENC(3,4,C13
,C0
,2), 0 },
3780 { "tpidr_el3", CPENC(3,6,C13
,C0
,2), 0 },
3781 { "teecr32_el1", CPENC(2,2,C0
, C0
,0), 0 }, /* See section 3.9.7.1 */
3782 { "cntfrq_el0", CPENC(3,3,C14
,C0
,0), 0 }, /* RO */
3783 { "cntpct_el0", CPENC(3,3,C14
,C0
,1), 0 }, /* RO */
3784 { "cntvct_el0", CPENC(3,3,C14
,C0
,2), 0 }, /* RO */
3785 { "cntvoff_el2", CPENC(3,4,C14
,C0
,3), 0 },
3786 { "cntkctl_el1", CPENC(3,0,C14
,C1
,0), 0 },
3787 { "cntkctl_el12", CPENC (3, 5, C14
, C1
, 0), F_ARCHEXT
},
3788 { "cnthctl_el2", CPENC(3,4,C14
,C1
,0), 0 },
3789 { "cntp_tval_el0", CPENC(3,3,C14
,C2
,0), 0 },
3790 { "cntp_tval_el02", CPENC (3, 5, C14
, C2
, 0), F_ARCHEXT
},
3791 { "cntp_ctl_el0", CPENC(3,3,C14
,C2
,1), 0 },
3792 { "cntp_ctl_el02", CPENC (3, 5, C14
, C2
, 1), F_ARCHEXT
},
3793 { "cntp_cval_el0", CPENC(3,3,C14
,C2
,2), 0 },
3794 { "cntp_cval_el02", CPENC (3, 5, C14
, C2
, 2), F_ARCHEXT
},
3795 { "cntv_tval_el0", CPENC(3,3,C14
,C3
,0), 0 },
3796 { "cntv_tval_el02", CPENC (3, 5, C14
, C3
, 0), F_ARCHEXT
},
3797 { "cntv_ctl_el0", CPENC(3,3,C14
,C3
,1), 0 },
3798 { "cntv_ctl_el02", CPENC (3, 5, C14
, C3
, 1), F_ARCHEXT
},
3799 { "cntv_cval_el0", CPENC(3,3,C14
,C3
,2), 0 },
3800 { "cntv_cval_el02", CPENC (3, 5, C14
, C3
, 2), F_ARCHEXT
},
3801 { "cnthp_tval_el2", CPENC(3,4,C14
,C2
,0), 0 },
3802 { "cnthp_ctl_el2", CPENC(3,4,C14
,C2
,1), 0 },
3803 { "cnthp_cval_el2", CPENC(3,4,C14
,C2
,2), 0 },
3804 { "cntps_tval_el1", CPENC(3,7,C14
,C2
,0), 0 },
3805 { "cntps_ctl_el1", CPENC(3,7,C14
,C2
,1), 0 },
3806 { "cntps_cval_el1", CPENC(3,7,C14
,C2
,2), 0 },
3807 { "cnthv_tval_el2", CPENC (3, 4, C14
, C3
, 0), F_ARCHEXT
},
3808 { "cnthv_ctl_el2", CPENC (3, 4, C14
, C3
, 1), F_ARCHEXT
},
3809 { "cnthv_cval_el2", CPENC (3, 4, C14
, C3
, 2), F_ARCHEXT
},
3810 { "dacr32_el2", CPENC(3,4,C3
,C0
,0), 0 },
3811 { "ifsr32_el2", CPENC(3,4,C5
,C0
,1), 0 },
3812 { "teehbr32_el1", CPENC(2,2,C1
,C0
,0), 0 },
3813 { "sder32_el3", CPENC(3,6,C1
,C1
,1), 0 },
3814 { "mdscr_el1", CPENC(2,0,C0
, C2
, 2), 0 },
3815 { "mdccsr_el0", CPENC(2,3,C0
, C1
, 0), 0 }, /* r */
3816 { "mdccint_el1", CPENC(2,0,C0
, C2
, 0), 0 },
3817 { "dbgdtr_el0", CPENC(2,3,C0
, C4
, 0), 0 },
3818 { "dbgdtrrx_el0", CPENC(2,3,C0
, C5
, 0), 0 }, /* r */
3819 { "dbgdtrtx_el0", CPENC(2,3,C0
, C5
, 0), 0 }, /* w */
3820 { "osdtrrx_el1", CPENC(2,0,C0
, C0
, 2), 0 }, /* r */
3821 { "osdtrtx_el1", CPENC(2,0,C0
, C3
, 2), 0 }, /* w */
3822 { "oseccr_el1", CPENC(2,0,C0
, C6
, 2), 0 },
3823 { "dbgvcr32_el2", CPENC(2,4,C0
, C7
, 0), 0 },
3824 { "dbgbvr0_el1", CPENC(2,0,C0
, C0
, 4), 0 },
3825 { "dbgbvr1_el1", CPENC(2,0,C0
, C1
, 4), 0 },
3826 { "dbgbvr2_el1", CPENC(2,0,C0
, C2
, 4), 0 },
3827 { "dbgbvr3_el1", CPENC(2,0,C0
, C3
, 4), 0 },
3828 { "dbgbvr4_el1", CPENC(2,0,C0
, C4
, 4), 0 },
3829 { "dbgbvr5_el1", CPENC(2,0,C0
, C5
, 4), 0 },
3830 { "dbgbvr6_el1", CPENC(2,0,C0
, C6
, 4), 0 },
3831 { "dbgbvr7_el1", CPENC(2,0,C0
, C7
, 4), 0 },
3832 { "dbgbvr8_el1", CPENC(2,0,C0
, C8
, 4), 0 },
3833 { "dbgbvr9_el1", CPENC(2,0,C0
, C9
, 4), 0 },
3834 { "dbgbvr10_el1", CPENC(2,0,C0
, C10
,4), 0 },
3835 { "dbgbvr11_el1", CPENC(2,0,C0
, C11
,4), 0 },
3836 { "dbgbvr12_el1", CPENC(2,0,C0
, C12
,4), 0 },
3837 { "dbgbvr13_el1", CPENC(2,0,C0
, C13
,4), 0 },
3838 { "dbgbvr14_el1", CPENC(2,0,C0
, C14
,4), 0 },
3839 { "dbgbvr15_el1", CPENC(2,0,C0
, C15
,4), 0 },
3840 { "dbgbcr0_el1", CPENC(2,0,C0
, C0
, 5), 0 },
3841 { "dbgbcr1_el1", CPENC(2,0,C0
, C1
, 5), 0 },
3842 { "dbgbcr2_el1", CPENC(2,0,C0
, C2
, 5), 0 },
3843 { "dbgbcr3_el1", CPENC(2,0,C0
, C3
, 5), 0 },
3844 { "dbgbcr4_el1", CPENC(2,0,C0
, C4
, 5), 0 },
3845 { "dbgbcr5_el1", CPENC(2,0,C0
, C5
, 5), 0 },
3846 { "dbgbcr6_el1", CPENC(2,0,C0
, C6
, 5), 0 },
3847 { "dbgbcr7_el1", CPENC(2,0,C0
, C7
, 5), 0 },
3848 { "dbgbcr8_el1", CPENC(2,0,C0
, C8
, 5), 0 },
3849 { "dbgbcr9_el1", CPENC(2,0,C0
, C9
, 5), 0 },
3850 { "dbgbcr10_el1", CPENC(2,0,C0
, C10
,5), 0 },
3851 { "dbgbcr11_el1", CPENC(2,0,C0
, C11
,5), 0 },
3852 { "dbgbcr12_el1", CPENC(2,0,C0
, C12
,5), 0 },
3853 { "dbgbcr13_el1", CPENC(2,0,C0
, C13
,5), 0 },
3854 { "dbgbcr14_el1", CPENC(2,0,C0
, C14
,5), 0 },
3855 { "dbgbcr15_el1", CPENC(2,0,C0
, C15
,5), 0 },
3856 { "dbgwvr0_el1", CPENC(2,0,C0
, C0
, 6), 0 },
3857 { "dbgwvr1_el1", CPENC(2,0,C0
, C1
, 6), 0 },
3858 { "dbgwvr2_el1", CPENC(2,0,C0
, C2
, 6), 0 },
3859 { "dbgwvr3_el1", CPENC(2,0,C0
, C3
, 6), 0 },
3860 { "dbgwvr4_el1", CPENC(2,0,C0
, C4
, 6), 0 },
3861 { "dbgwvr5_el1", CPENC(2,0,C0
, C5
, 6), 0 },
3862 { "dbgwvr6_el1", CPENC(2,0,C0
, C6
, 6), 0 },
3863 { "dbgwvr7_el1", CPENC(2,0,C0
, C7
, 6), 0 },
3864 { "dbgwvr8_el1", CPENC(2,0,C0
, C8
, 6), 0 },
3865 { "dbgwvr9_el1", CPENC(2,0,C0
, C9
, 6), 0 },
3866 { "dbgwvr10_el1", CPENC(2,0,C0
, C10
,6), 0 },
3867 { "dbgwvr11_el1", CPENC(2,0,C0
, C11
,6), 0 },
3868 { "dbgwvr12_el1", CPENC(2,0,C0
, C12
,6), 0 },
3869 { "dbgwvr13_el1", CPENC(2,0,C0
, C13
,6), 0 },
3870 { "dbgwvr14_el1", CPENC(2,0,C0
, C14
,6), 0 },
3871 { "dbgwvr15_el1", CPENC(2,0,C0
, C15
,6), 0 },
3872 { "dbgwcr0_el1", CPENC(2,0,C0
, C0
, 7), 0 },
3873 { "dbgwcr1_el1", CPENC(2,0,C0
, C1
, 7), 0 },
3874 { "dbgwcr2_el1", CPENC(2,0,C0
, C2
, 7), 0 },
3875 { "dbgwcr3_el1", CPENC(2,0,C0
, C3
, 7), 0 },
3876 { "dbgwcr4_el1", CPENC(2,0,C0
, C4
, 7), 0 },
3877 { "dbgwcr5_el1", CPENC(2,0,C0
, C5
, 7), 0 },
3878 { "dbgwcr6_el1", CPENC(2,0,C0
, C6
, 7), 0 },
3879 { "dbgwcr7_el1", CPENC(2,0,C0
, C7
, 7), 0 },
3880 { "dbgwcr8_el1", CPENC(2,0,C0
, C8
, 7), 0 },
3881 { "dbgwcr9_el1", CPENC(2,0,C0
, C9
, 7), 0 },
3882 { "dbgwcr10_el1", CPENC(2,0,C0
, C10
,7), 0 },
3883 { "dbgwcr11_el1", CPENC(2,0,C0
, C11
,7), 0 },
3884 { "dbgwcr12_el1", CPENC(2,0,C0
, C12
,7), 0 },
3885 { "dbgwcr13_el1", CPENC(2,0,C0
, C13
,7), 0 },
3886 { "dbgwcr14_el1", CPENC(2,0,C0
, C14
,7), 0 },
3887 { "dbgwcr15_el1", CPENC(2,0,C0
, C15
,7), 0 },
3888 { "mdrar_el1", CPENC(2,0,C1
, C0
, 0), 0 }, /* r */
3889 { "oslar_el1", CPENC(2,0,C1
, C0
, 4), 0 }, /* w */
3890 { "oslsr_el1", CPENC(2,0,C1
, C1
, 4), 0 }, /* r */
3891 { "osdlr_el1", CPENC(2,0,C1
, C3
, 4), 0 },
3892 { "dbgprcr_el1", CPENC(2,0,C1
, C4
, 4), 0 },
3893 { "dbgclaimset_el1", CPENC(2,0,C7
, C8
, 6), 0 },
3894 { "dbgclaimclr_el1", CPENC(2,0,C7
, C9
, 6), 0 },
3895 { "dbgauthstatus_el1", CPENC(2,0,C7
, C14
,6), 0 }, /* r */
3896 { "pmblimitr_el1", CPENC (3, 0, C9
, C10
, 0), F_ARCHEXT
}, /* rw */
3897 { "pmbptr_el1", CPENC (3, 0, C9
, C10
, 1), F_ARCHEXT
}, /* rw */
3898 { "pmbsr_el1", CPENC (3, 0, C9
, C10
, 3), F_ARCHEXT
}, /* rw */
3899 { "pmbidr_el1", CPENC (3, 0, C9
, C10
, 7), F_ARCHEXT
}, /* ro */
3900 { "pmscr_el1", CPENC (3, 0, C9
, C9
, 0), F_ARCHEXT
}, /* rw */
3901 { "pmsicr_el1", CPENC (3, 0, C9
, C9
, 2), F_ARCHEXT
}, /* rw */
3902 { "pmsirr_el1", CPENC (3, 0, C9
, C9
, 3), F_ARCHEXT
}, /* rw */
3903 { "pmsfcr_el1", CPENC (3, 0, C9
, C9
, 4), F_ARCHEXT
}, /* rw */
3904 { "pmsevfr_el1", CPENC (3, 0, C9
, C9
, 5), F_ARCHEXT
}, /* rw */
3905 { "pmslatfr_el1", CPENC (3, 0, C9
, C9
, 6), F_ARCHEXT
}, /* rw */
3906 { "pmsidr_el1", CPENC (3, 0, C9
, C9
, 7), F_ARCHEXT
}, /* ro */
3907 { "pmscr_el2", CPENC (3, 4, C9
, C9
, 0), F_ARCHEXT
}, /* rw */
3908 { "pmscr_el12", CPENC (3, 5, C9
, C9
, 0), F_ARCHEXT
}, /* rw */
3909 { "pmcr_el0", CPENC(3,3,C9
,C12
, 0), 0 },
3910 { "pmcntenset_el0", CPENC(3,3,C9
,C12
, 1), 0 },
3911 { "pmcntenclr_el0", CPENC(3,3,C9
,C12
, 2), 0 },
3912 { "pmovsclr_el0", CPENC(3,3,C9
,C12
, 3), 0 },
3913 { "pmswinc_el0", CPENC(3,3,C9
,C12
, 4), 0 }, /* w */
3914 { "pmselr_el0", CPENC(3,3,C9
,C12
, 5), 0 },
3915 { "pmceid0_el0", CPENC(3,3,C9
,C12
, 6), 0 }, /* r */
3916 { "pmceid1_el0", CPENC(3,3,C9
,C12
, 7), 0 }, /* r */
3917 { "pmccntr_el0", CPENC(3,3,C9
,C13
, 0), 0 },
3918 { "pmxevtyper_el0", CPENC(3,3,C9
,C13
, 1), 0 },
3919 { "pmxevcntr_el0", CPENC(3,3,C9
,C13
, 2), 0 },
3920 { "pmuserenr_el0", CPENC(3,3,C9
,C14
, 0), 0 },
3921 { "pmintenset_el1", CPENC(3,0,C9
,C14
, 1), 0 },
3922 { "pmintenclr_el1", CPENC(3,0,C9
,C14
, 2), 0 },
3923 { "pmovsset_el0", CPENC(3,3,C9
,C14
, 3), 0 },
3924 { "pmevcntr0_el0", CPENC(3,3,C14
,C8
, 0), 0 },
3925 { "pmevcntr1_el0", CPENC(3,3,C14
,C8
, 1), 0 },
3926 { "pmevcntr2_el0", CPENC(3,3,C14
,C8
, 2), 0 },
3927 { "pmevcntr3_el0", CPENC(3,3,C14
,C8
, 3), 0 },
3928 { "pmevcntr4_el0", CPENC(3,3,C14
,C8
, 4), 0 },
3929 { "pmevcntr5_el0", CPENC(3,3,C14
,C8
, 5), 0 },
3930 { "pmevcntr6_el0", CPENC(3,3,C14
,C8
, 6), 0 },
3931 { "pmevcntr7_el0", CPENC(3,3,C14
,C8
, 7), 0 },
3932 { "pmevcntr8_el0", CPENC(3,3,C14
,C9
, 0), 0 },
3933 { "pmevcntr9_el0", CPENC(3,3,C14
,C9
, 1), 0 },
3934 { "pmevcntr10_el0", CPENC(3,3,C14
,C9
, 2), 0 },
3935 { "pmevcntr11_el0", CPENC(3,3,C14
,C9
, 3), 0 },
3936 { "pmevcntr12_el0", CPENC(3,3,C14
,C9
, 4), 0 },
3937 { "pmevcntr13_el0", CPENC(3,3,C14
,C9
, 5), 0 },
3938 { "pmevcntr14_el0", CPENC(3,3,C14
,C9
, 6), 0 },
3939 { "pmevcntr15_el0", CPENC(3,3,C14
,C9
, 7), 0 },
3940 { "pmevcntr16_el0", CPENC(3,3,C14
,C10
,0), 0 },
3941 { "pmevcntr17_el0", CPENC(3,3,C14
,C10
,1), 0 },
3942 { "pmevcntr18_el0", CPENC(3,3,C14
,C10
,2), 0 },
3943 { "pmevcntr19_el0", CPENC(3,3,C14
,C10
,3), 0 },
3944 { "pmevcntr20_el0", CPENC(3,3,C14
,C10
,4), 0 },
3945 { "pmevcntr21_el0", CPENC(3,3,C14
,C10
,5), 0 },
3946 { "pmevcntr22_el0", CPENC(3,3,C14
,C10
,6), 0 },
3947 { "pmevcntr23_el0", CPENC(3,3,C14
,C10
,7), 0 },
3948 { "pmevcntr24_el0", CPENC(3,3,C14
,C11
,0), 0 },
3949 { "pmevcntr25_el0", CPENC(3,3,C14
,C11
,1), 0 },
3950 { "pmevcntr26_el0", CPENC(3,3,C14
,C11
,2), 0 },
3951 { "pmevcntr27_el0", CPENC(3,3,C14
,C11
,3), 0 },
3952 { "pmevcntr28_el0", CPENC(3,3,C14
,C11
,4), 0 },
3953 { "pmevcntr29_el0", CPENC(3,3,C14
,C11
,5), 0 },
3954 { "pmevcntr30_el0", CPENC(3,3,C14
,C11
,6), 0 },
3955 { "pmevtyper0_el0", CPENC(3,3,C14
,C12
,0), 0 },
3956 { "pmevtyper1_el0", CPENC(3,3,C14
,C12
,1), 0 },
3957 { "pmevtyper2_el0", CPENC(3,3,C14
,C12
,2), 0 },
3958 { "pmevtyper3_el0", CPENC(3,3,C14
,C12
,3), 0 },
3959 { "pmevtyper4_el0", CPENC(3,3,C14
,C12
,4), 0 },
3960 { "pmevtyper5_el0", CPENC(3,3,C14
,C12
,5), 0 },
3961 { "pmevtyper6_el0", CPENC(3,3,C14
,C12
,6), 0 },
3962 { "pmevtyper7_el0", CPENC(3,3,C14
,C12
,7), 0 },
3963 { "pmevtyper8_el0", CPENC(3,3,C14
,C13
,0), 0 },
3964 { "pmevtyper9_el0", CPENC(3,3,C14
,C13
,1), 0 },
3965 { "pmevtyper10_el0", CPENC(3,3,C14
,C13
,2), 0 },
3966 { "pmevtyper11_el0", CPENC(3,3,C14
,C13
,3), 0 },
3967 { "pmevtyper12_el0", CPENC(3,3,C14
,C13
,4), 0 },
3968 { "pmevtyper13_el0", CPENC(3,3,C14
,C13
,5), 0 },
3969 { "pmevtyper14_el0", CPENC(3,3,C14
,C13
,6), 0 },
3970 { "pmevtyper15_el0", CPENC(3,3,C14
,C13
,7), 0 },
3971 { "pmevtyper16_el0", CPENC(3,3,C14
,C14
,0), 0 },
3972 { "pmevtyper17_el0", CPENC(3,3,C14
,C14
,1), 0 },
3973 { "pmevtyper18_el0", CPENC(3,3,C14
,C14
,2), 0 },
3974 { "pmevtyper19_el0", CPENC(3,3,C14
,C14
,3), 0 },
3975 { "pmevtyper20_el0", CPENC(3,3,C14
,C14
,4), 0 },
3976 { "pmevtyper21_el0", CPENC(3,3,C14
,C14
,5), 0 },
3977 { "pmevtyper22_el0", CPENC(3,3,C14
,C14
,6), 0 },
3978 { "pmevtyper23_el0", CPENC(3,3,C14
,C14
,7), 0 },
3979 { "pmevtyper24_el0", CPENC(3,3,C14
,C15
,0), 0 },
3980 { "pmevtyper25_el0", CPENC(3,3,C14
,C15
,1), 0 },
3981 { "pmevtyper26_el0", CPENC(3,3,C14
,C15
,2), 0 },
3982 { "pmevtyper27_el0", CPENC(3,3,C14
,C15
,3), 0 },
3983 { "pmevtyper28_el0", CPENC(3,3,C14
,C15
,4), 0 },
3984 { "pmevtyper29_el0", CPENC(3,3,C14
,C15
,5), 0 },
3985 { "pmevtyper30_el0", CPENC(3,3,C14
,C15
,6), 0 },
3986 { "pmccfiltr_el0", CPENC(3,3,C14
,C15
,7), 0 },
3987 { 0, CPENC(0,0,0,0,0), 0 },
3991 aarch64_sys_reg_deprecated_p (const aarch64_sys_reg
*reg
)
3993 return (reg
->flags
& F_DEPRECATED
) != 0;
3997 aarch64_sys_reg_supported_p (const aarch64_feature_set features
,
3998 const aarch64_sys_reg
*reg
)
4000 if (!(reg
->flags
& F_ARCHEXT
))
4003 /* PAN. Values are from aarch64_sys_regs. */
4004 if (reg
->value
== CPEN_(0,C2
,3)
4005 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_PAN
))
4008 /* Virtualization host extensions: system registers. */
4009 if ((reg
->value
== CPENC (3, 4, C2
, C0
, 1)
4010 || reg
->value
== CPENC (3, 4, C13
, C0
, 1)
4011 || reg
->value
== CPENC (3, 4, C14
, C3
, 0)
4012 || reg
->value
== CPENC (3, 4, C14
, C3
, 1)
4013 || reg
->value
== CPENC (3, 4, C14
, C3
, 2))
4014 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_V8_1
))
4017 /* Virtualization host extensions: *_el12 names of *_el1 registers. */
4018 if ((reg
->value
== CPEN_ (5, C0
, 0)
4019 || reg
->value
== CPEN_ (5, C0
, 1)
4020 || reg
->value
== CPENC (3, 5, C1
, C0
, 0)
4021 || reg
->value
== CPENC (3, 5, C1
, C0
, 2)
4022 || reg
->value
== CPENC (3, 5, C2
, C0
, 0)
4023 || reg
->value
== CPENC (3, 5, C2
, C0
, 1)
4024 || reg
->value
== CPENC (3, 5, C2
, C0
, 2)
4025 || reg
->value
== CPENC (3, 5, C5
, C1
, 0)
4026 || reg
->value
== CPENC (3, 5, C5
, C1
, 1)
4027 || reg
->value
== CPENC (3, 5, C5
, C2
, 0)
4028 || reg
->value
== CPENC (3, 5, C6
, C0
, 0)
4029 || reg
->value
== CPENC (3, 5, C10
, C2
, 0)
4030 || reg
->value
== CPENC (3, 5, C10
, C3
, 0)
4031 || reg
->value
== CPENC (3, 5, C12
, C0
, 0)
4032 || reg
->value
== CPENC (3, 5, C13
, C0
, 1)
4033 || reg
->value
== CPENC (3, 5, C14
, C1
, 0))
4034 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_V8_1
))
4037 /* Virtualization host extensions: *_el02 names of *_el0 registers. */
4038 if ((reg
->value
== CPENC (3, 5, C14
, C2
, 0)
4039 || reg
->value
== CPENC (3, 5, C14
, C2
, 1)
4040 || reg
->value
== CPENC (3, 5, C14
, C2
, 2)
4041 || reg
->value
== CPENC (3, 5, C14
, C3
, 0)
4042 || reg
->value
== CPENC (3, 5, C14
, C3
, 1)
4043 || reg
->value
== CPENC (3, 5, C14
, C3
, 2))
4044 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_V8_1
))
4047 /* ARMv8.2 features. */
4049 /* ID_AA64MMFR2_EL1. */
4050 if (reg
->value
== CPENC (3, 0, C0
, C7
, 2)
4051 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_V8_2
))
4055 if (reg
->value
== CPEN_ (0, C2
, 4)
4056 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_V8_2
))
4059 /* RAS extension. */
4061 /* ERRIDR_EL1, ERRSELR_EL1, ERXFR_EL1, ERXCTLR_EL1, ERXSTATUS_EL, ERXADDR_EL1,
4062 ERXMISC0_EL1 AND ERXMISC1_EL1. */
4063 if ((reg
->value
== CPENC (3, 0, C5
, C3
, 0)
4064 || reg
->value
== CPENC (3, 0, C5
, C3
, 1)
4065 || reg
->value
== CPENC (3, 0, C5
, C3
, 2)
4066 || reg
->value
== CPENC (3, 0, C5
, C3
, 3)
4067 || reg
->value
== CPENC (3, 0, C5
, C4
, 0)
4068 || reg
->value
== CPENC (3, 0, C5
, C4
, 1)
4069 || reg
->value
== CPENC (3, 0, C5
, C4
, 2)
4070 || reg
->value
== CPENC (3, 0, C5
, C4
, 3)
4071 || reg
->value
== CPENC (3, 0, C5
, C5
, 0)
4072 || reg
->value
== CPENC (3, 0, C5
, C5
, 1))
4073 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_RAS
))
4076 /* VSESR_EL2, DISR_EL1 and VDISR_EL2. */
4077 if ((reg
->value
== CPENC (3, 4, C5
, C2
, 3)
4078 || reg
->value
== CPENC (3, 0, C12
, C1
, 1)
4079 || reg
->value
== CPENC (3, 4, C12
, C1
, 1))
4080 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_RAS
))
4083 /* Statistical Profiling extension. */
4084 if ((reg
->value
== CPENC (3, 0, C9
, C10
, 0)
4085 || reg
->value
== CPENC (3, 0, C9
, C10
, 1)
4086 || reg
->value
== CPENC (3, 0, C9
, C10
, 3)
4087 || reg
->value
== CPENC (3, 0, C9
, C10
, 7)
4088 || reg
->value
== CPENC (3, 0, C9
, C9
, 0)
4089 || reg
->value
== CPENC (3, 0, C9
, C9
, 2)
4090 || reg
->value
== CPENC (3, 0, C9
, C9
, 3)
4091 || reg
->value
== CPENC (3, 0, C9
, C9
, 4)
4092 || reg
->value
== CPENC (3, 0, C9
, C9
, 5)
4093 || reg
->value
== CPENC (3, 0, C9
, C9
, 6)
4094 || reg
->value
== CPENC (3, 0, C9
, C9
, 7)
4095 || reg
->value
== CPENC (3, 4, C9
, C9
, 0)
4096 || reg
->value
== CPENC (3, 5, C9
, C9
, 0))
4097 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_PROFILE
))
4100 /* ARMv8.3 Pointer authentication keys. */
4101 if ((reg
->value
== CPENC (3, 0, C2
, C1
, 0)
4102 || reg
->value
== CPENC (3, 0, C2
, C1
, 1)
4103 || reg
->value
== CPENC (3, 0, C2
, C1
, 2)
4104 || reg
->value
== CPENC (3, 0, C2
, C1
, 3)
4105 || reg
->value
== CPENC (3, 0, C2
, C2
, 0)
4106 || reg
->value
== CPENC (3, 0, C2
, C2
, 1)
4107 || reg
->value
== CPENC (3, 0, C2
, C2
, 2)
4108 || reg
->value
== CPENC (3, 0, C2
, C2
, 3)
4109 || reg
->value
== CPENC (3, 0, C2
, C3
, 0)
4110 || reg
->value
== CPENC (3, 0, C2
, C3
, 1))
4111 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_V8_3
))
4117 const aarch64_sys_reg aarch64_pstatefields
[] =
4119 { "spsel", 0x05, 0 },
4120 { "daifset", 0x1e, 0 },
4121 { "daifclr", 0x1f, 0 },
4122 { "pan", 0x04, F_ARCHEXT
},
4123 { "uao", 0x03, F_ARCHEXT
},
4124 { 0, CPENC(0,0,0,0,0), 0 },
4128 aarch64_pstatefield_supported_p (const aarch64_feature_set features
,
4129 const aarch64_sys_reg
*reg
)
4131 if (!(reg
->flags
& F_ARCHEXT
))
4134 /* PAN. Values are from aarch64_pstatefields. */
4135 if (reg
->value
== 0x04
4136 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_PAN
))
4139 /* UAO. Values are from aarch64_pstatefields. */
4140 if (reg
->value
== 0x03
4141 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_V8_2
))
4147 const aarch64_sys_ins_reg aarch64_sys_regs_ic
[] =
4149 { "ialluis", CPENS(0,C7
,C1
,0), 0 },
4150 { "iallu", CPENS(0,C7
,C5
,0), 0 },
4151 { "ivau", CPENS (3, C7
, C5
, 1), F_HASXT
},
4152 { 0, CPENS(0,0,0,0), 0 }
4155 const aarch64_sys_ins_reg aarch64_sys_regs_dc
[] =
4157 { "zva", CPENS (3, C7
, C4
, 1), F_HASXT
},
4158 { "ivac", CPENS (0, C7
, C6
, 1), F_HASXT
},
4159 { "isw", CPENS (0, C7
, C6
, 2), F_HASXT
},
4160 { "cvac", CPENS (3, C7
, C10
, 1), F_HASXT
},
4161 { "csw", CPENS (0, C7
, C10
, 2), F_HASXT
},
4162 { "cvau", CPENS (3, C7
, C11
, 1), F_HASXT
},
4163 { "cvap", CPENS (3, C7
, C12
, 1), F_HASXT
| F_ARCHEXT
},
4164 { "civac", CPENS (3, C7
, C14
, 1), F_HASXT
},
4165 { "cisw", CPENS (0, C7
, C14
, 2), F_HASXT
},
4166 { 0, CPENS(0,0,0,0), 0 }
4169 const aarch64_sys_ins_reg aarch64_sys_regs_at
[] =
4171 { "s1e1r", CPENS (0, C7
, C8
, 0), F_HASXT
},
4172 { "s1e1w", CPENS (0, C7
, C8
, 1), F_HASXT
},
4173 { "s1e0r", CPENS (0, C7
, C8
, 2), F_HASXT
},
4174 { "s1e0w", CPENS (0, C7
, C8
, 3), F_HASXT
},
4175 { "s12e1r", CPENS (4, C7
, C8
, 4), F_HASXT
},
4176 { "s12e1w", CPENS (4, C7
, C8
, 5), F_HASXT
},
4177 { "s12e0r", CPENS (4, C7
, C8
, 6), F_HASXT
},
4178 { "s12e0w", CPENS (4, C7
, C8
, 7), F_HASXT
},
4179 { "s1e2r", CPENS (4, C7
, C8
, 0), F_HASXT
},
4180 { "s1e2w", CPENS (4, C7
, C8
, 1), F_HASXT
},
4181 { "s1e3r", CPENS (6, C7
, C8
, 0), F_HASXT
},
4182 { "s1e3w", CPENS (6, C7
, C8
, 1), F_HASXT
},
4183 { "s1e1rp", CPENS (0, C7
, C9
, 0), F_HASXT
| F_ARCHEXT
},
4184 { "s1e1wp", CPENS (0, C7
, C9
, 1), F_HASXT
| F_ARCHEXT
},
4185 { 0, CPENS(0,0,0,0), 0 }
4188 const aarch64_sys_ins_reg aarch64_sys_regs_tlbi
[] =
4190 { "vmalle1", CPENS(0,C8
,C7
,0), 0 },
4191 { "vae1", CPENS (0, C8
, C7
, 1), F_HASXT
},
4192 { "aside1", CPENS (0, C8
, C7
, 2), F_HASXT
},
4193 { "vaae1", CPENS (0, C8
, C7
, 3), F_HASXT
},
4194 { "vmalle1is", CPENS(0,C8
,C3
,0), 0 },
4195 { "vae1is", CPENS (0, C8
, C3
, 1), F_HASXT
},
4196 { "aside1is", CPENS (0, C8
, C3
, 2), F_HASXT
},
4197 { "vaae1is", CPENS (0, C8
, C3
, 3), F_HASXT
},
4198 { "ipas2e1is", CPENS (4, C8
, C0
, 1), F_HASXT
},
4199 { "ipas2le1is",CPENS (4, C8
, C0
, 5), F_HASXT
},
4200 { "ipas2e1", CPENS (4, C8
, C4
, 1), F_HASXT
},
4201 { "ipas2le1", CPENS (4, C8
, C4
, 5), F_HASXT
},
4202 { "vae2", CPENS (4, C8
, C7
, 1), F_HASXT
},
4203 { "vae2is", CPENS (4, C8
, C3
, 1), F_HASXT
},
4204 { "vmalls12e1",CPENS(4,C8
,C7
,6), 0 },
4205 { "vmalls12e1is",CPENS(4,C8
,C3
,6), 0 },
4206 { "vae3", CPENS (6, C8
, C7
, 1), F_HASXT
},
4207 { "vae3is", CPENS (6, C8
, C3
, 1), F_HASXT
},
4208 { "alle2", CPENS(4,C8
,C7
,0), 0 },
4209 { "alle2is", CPENS(4,C8
,C3
,0), 0 },
4210 { "alle1", CPENS(4,C8
,C7
,4), 0 },
4211 { "alle1is", CPENS(4,C8
,C3
,4), 0 },
4212 { "alle3", CPENS(6,C8
,C7
,0), 0 },
4213 { "alle3is", CPENS(6,C8
,C3
,0), 0 },
4214 { "vale1is", CPENS (0, C8
, C3
, 5), F_HASXT
},
4215 { "vale2is", CPENS (4, C8
, C3
, 5), F_HASXT
},
4216 { "vale3is", CPENS (6, C8
, C3
, 5), F_HASXT
},
4217 { "vaale1is", CPENS (0, C8
, C3
, 7), F_HASXT
},
4218 { "vale1", CPENS (0, C8
, C7
, 5), F_HASXT
},
4219 { "vale2", CPENS (4, C8
, C7
, 5), F_HASXT
},
4220 { "vale3", CPENS (6, C8
, C7
, 5), F_HASXT
},
4221 { "vaale1", CPENS (0, C8
, C7
, 7), F_HASXT
},
4222 { 0, CPENS(0,0,0,0), 0 }
4226 aarch64_sys_ins_reg_has_xt (const aarch64_sys_ins_reg
*sys_ins_reg
)
4228 return (sys_ins_reg
->flags
& F_HASXT
) != 0;
4232 aarch64_sys_ins_reg_supported_p (const aarch64_feature_set features
,
4233 const aarch64_sys_ins_reg
*reg
)
4235 if (!(reg
->flags
& F_ARCHEXT
))
4238 /* DC CVAP. Values are from aarch64_sys_regs_dc. */
4239 if (reg
->value
== CPENS (3, C7
, C12
, 1)
4240 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_V8_2
))
4243 /* AT S1E1RP, AT S1E1WP. Values are from aarch64_sys_regs_at. */
4244 if ((reg
->value
== CPENS (0, C7
, C9
, 0)
4245 || reg
->value
== CPENS (0, C7
, C9
, 1))
4246 && !AARCH64_CPU_HAS_FEATURE (features
, AARCH64_FEATURE_V8_2
))
4269 #define BIT(INSN,BT) (((INSN) >> (BT)) & 1)
4270 #define BITS(INSN,HI,LO) (((INSN) >> (LO)) & ((1 << (((HI) - (LO)) + 1)) - 1))
4273 verify_ldpsw (const struct aarch64_opcode
* opcode ATTRIBUTE_UNUSED
,
4274 const aarch64_insn insn
)
4276 int t
= BITS (insn
, 4, 0);
4277 int n
= BITS (insn
, 9, 5);
4278 int t2
= BITS (insn
, 14, 10);
4282 /* Write back enabled. */
4283 if ((t
== n
|| t2
== n
) && n
!= 31)
4297 /* Return true if VALUE cannot be moved into an SVE register using DUP
4298 (with any element size, not just ESIZE) and if using DUPM would
4299 therefore be OK. ESIZE is the number of bytes in the immediate. */
4302 aarch64_sve_dupm_mov_immediate_p (uint64_t uvalue
, int esize
)
4304 int64_t svalue
= uvalue
;
4305 uint64_t upper
= (uint64_t) -1 << (esize
* 4) << (esize
* 4);
4307 if ((uvalue
& ~upper
) != uvalue
&& (uvalue
| upper
) != uvalue
)
4309 if (esize
<= 4 || (uint32_t) uvalue
== (uint32_t) (uvalue
>> 32))
4311 svalue
= (int32_t) uvalue
;
4312 if (esize
<= 2 || (uint16_t) uvalue
== (uint16_t) (uvalue
>> 16))
4314 svalue
= (int16_t) uvalue
;
4315 if (esize
== 1 || (uint8_t) uvalue
== (uint8_t) (uvalue
>> 8))
4319 if ((svalue
& 0xff) == 0)
4321 return svalue
< -128 || svalue
>= 128;
4324 /* Include the opcode description table as well as the operand description
4326 #define VERIFIER(x) verify_##x
4327 #include "aarch64-tbl.h"