1 /* AArch64 assembler/disassembler support.
3 Copyright (C) 2009-2025 Free Software Foundation, Inc.
4 Contributed by ARM Ltd.
6 This file is part of GNU Binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the license, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING3. If not,
20 see <http://www.gnu.org/licenses/>. */
22 #ifndef OPCODE_AARCH64_H
23 #define OPCODE_AARCH64_H
36 /* The offset for pc-relative addressing is currently defined to be 0. */
37 #define AARCH64_PCREL_OFFSET 0
39 typedef uint32_t aarch64_insn
;
41 /* An enum containing all known CPU features. The values act as bit positions
42 into aarch64_feature_set. */
43 enum aarch64_feature_bit
{
46 /* ARMv8.6 processors. */
47 AARCH64_FEATURE_V8_6A
,
49 AARCH64_FEATURE_BFLOAT16
,
50 /* Armv8-A processors. */
52 /* SVE2 instructions. */
54 /* ARMv8.2 processors. */
55 AARCH64_FEATURE_V8_2A
,
56 /* ARMv8.3 processors. */
57 AARCH64_FEATURE_V8_3A
,
58 AARCH64_FEATURE_SVE2_AES
,
59 AARCH64_FEATURE_SVE2_BITPERM
,
60 AARCH64_FEATURE_SVE2_SM4
,
61 AARCH64_FEATURE_SVE2_SHA3
,
62 /* ARMv8.4 processors. */
63 AARCH64_FEATURE_V8_4A
,
64 /* Armv8-R processors. */
66 /* Armv8.7 processors. */
67 AARCH64_FEATURE_V8_7A
,
68 /* Scalable Matrix Extension. */
70 /* Atomic 64-byte load/store. */
72 /* v8.3 Pointer Authentication. */
73 AARCH64_FEATURE_PAUTH
,
74 /* FP instructions. */
76 /* SIMD instructions. */
78 /* CRC instructions. */
80 /* LSE instructions. */
82 /* PAN instructions. */
84 /* LOR instructions. */
86 /* v8.1 SIMD instructions. */
89 AARCH64_FEATURE_V8_1A
,
90 /* v8.2 FP16 instructions. */
94 /* Statistical Profiling. */
95 AARCH64_FEATURE_PROFILE
,
96 /* SVE instructions. */
98 /* RCPC instructions. */
100 /* RCPC2 instructions. */
101 AARCH64_FEATURE_RCPC2
,
102 /* Complex # instructions. */
103 AARCH64_FEATURE_COMPNUM
,
104 /* JavaScript conversion instructions. */
105 AARCH64_FEATURE_JSCVT
,
106 /* Dot Product instructions. */
107 AARCH64_FEATURE_DOTPROD
,
108 /* SM3 & SM4 instructions. */
110 /* SHA2 instructions. */
111 AARCH64_FEATURE_SHA2
,
112 /* SHA3 instructions. */
113 AARCH64_FEATURE_SHA3
,
114 /* AES instructions. */
116 /* v8.2 FP16FML ins. */
117 AARCH64_FEATURE_F16_FML
,
118 /* ARMv8.5 processors. */
119 AARCH64_FEATURE_V8_5A
,
120 /* v8.5 Flag Manipulation version 2. */
121 AARCH64_FEATURE_FLAGMANIP
,
122 /* FRINT[32,64][Z,X] insns. */
123 AARCH64_FEATURE_FRINTTS
,
124 /* SB instruction. */
126 /* Execution and Data Prediction Restriction instructions. */
127 AARCH64_FEATURE_PREDRES
,
129 AARCH64_FEATURE_CVADP
,
130 /* Random Number instructions. */
133 AARCH64_FEATURE_SCXTNUM
,
134 /* ID_PFR2 instructions. */
135 AARCH64_FEATURE_ID_PFR2
,
136 /* SSBS mechanism enabled. */
137 AARCH64_FEATURE_SSBS
,
138 /* Memory Tagging Extension. */
139 AARCH64_FEATURE_MEMTAG
,
140 /* Transactional Memory Extension. */
142 /* XS memory attribute. */
144 /* WFx instructions with timeout. */
145 AARCH64_FEATURE_WFXT
,
146 /* Standardization of memory operations. */
147 AARCH64_FEATURE_MOPS
,
148 /* Hinted conditional branches. */
150 /* Matrix Multiply instructions. */
151 AARCH64_FEATURE_I8MM
,
152 AARCH64_FEATURE_F32MM
,
153 AARCH64_FEATURE_F64MM
,
154 /* v8.4 Flag Manipulation. */
155 AARCH64_FEATURE_FLAGM
,
156 /* Armv9.0-A processors. */
159 AARCH64_FEATURE_SME_F64F64
,
161 AARCH64_FEATURE_SME_I16I64
,
162 /* Armv8.8 processors. */
163 AARCH64_FEATURE_V8_8A
,
164 /* Common Short Sequence Compression instructions. */
165 AARCH64_FEATURE_CSSC
,
166 /* Armv8.9-A processors. */
167 AARCH64_FEATURE_V8_9A
,
168 /* Check Feature Status Extension. */
170 /* Guarded Control Stack. */
172 /* SPE Call Return branch records. */
173 AARCH64_FEATURE_SPE_CRR
,
174 /* SPE Filter by data source. */
175 AARCH64_FEATURE_SPE_FDS
,
176 /* Additional SPE events. */
177 AARCH64_FEATURE_SPEv1p4
,
179 AARCH64_FEATURE_SME2
,
180 /* Translation Hardening Extension. */
183 AARCH64_FEATURE_LSE128
,
184 /* ARMv8.9-A RAS Extensions. */
185 AARCH64_FEATURE_RASv2
,
186 /* Delegated SError exceptions for EL3. */
187 AARCH64_FEATURE_E3DSE
,
188 /* System Control Register2. */
189 AARCH64_FEATURE_SCTLR2
,
190 /* Fine Grained Traps. */
191 AARCH64_FEATURE_FGT2
,
192 /* Physical Fault Address. */
193 AARCH64_FEATURE_PFAR
,
194 /* Address Translate Stage 1. */
195 AARCH64_FEATURE_ATS1A
,
196 /* Memory Attribute Index Enhancement. */
198 /* Stage 1 Permission Indirection Extension. */
199 AARCH64_FEATURE_S1PIE
,
200 /* Stage 2 Permission Indirection Extension. */
201 AARCH64_FEATURE_S2PIE
,
202 /* Stage 1 Permission Overlay Extension. */
203 AARCH64_FEATURE_S1POE
,
204 /* Stage 2 Permission Overlay Extension. */
205 AARCH64_FEATURE_S2POE
,
206 /* Extension to Translation Control Registers. */
207 AARCH64_FEATURE_TCR2
,
208 /* Speculation Prediction Restriction instructions. */
209 AARCH64_FEATURE_PREDRES2
,
210 /* Instrumentation Extension. */
212 /* 128-bit page table descriptor, system registers
214 AARCH64_FEATURE_D128
,
215 /* Armv8.9-A/Armv9.4-A architecture Debug extension. */
216 AARCH64_FEATURE_DEBUGv8p9
,
217 /* Performance Monitors Extension. */
218 AARCH64_FEATURE_PMUv3p9
,
219 /* Performance Monitors Snapshots Extension. */
220 AARCH64_FEATURE_PMUv3_SS
,
221 /* Performance Monitors Instruction Counter Extension. */
222 AARCH64_FEATURE_PMUv3_ICNTR
,
223 /* System Performance Monitors Extension */
224 AARCH64_FEATURE_SPMU
,
225 /* System Performance Monitors Extension version 2 */
226 AARCH64_FEATURE_SPMU2
,
227 /* Performance Monitors Synchronous-Exception-Based Event Extension. */
228 AARCH64_FEATURE_SEBEP
,
229 /* SME2.1 instructions. */
230 AARCH64_FEATURE_SME2p1
,
231 /* SVE2.1 instructions. */
232 AARCH64_FEATURE_SVE2p1
,
233 /* RCPC3 instructions. */
234 AARCH64_FEATURE_RCPC3
,
235 /* Enhanced Software Step Extension. */
236 AARCH64_FEATURE_STEP2
,
237 /* Checked Pointer Arithmetic instructions. */
239 /* FAMINMAX instructions. */
240 AARCH64_FEATURE_FAMINMAX
,
241 /* FP8 instructions. */
243 /* LUT instructions. */
245 /* Branch Record Buffer Extension */
246 AARCH64_FEATURE_BRBE
,
247 /* SME LUTv2 instructions. */
248 AARCH64_FEATURE_SME_LUTv2
,
249 /* FP8FMA instructions. */
250 AARCH64_FEATURE_FP8FMA
,
251 /* FP8DOT4 instructions. */
252 AARCH64_FEATURE_FP8DOT4
,
253 /* FP8DOT2 instructions. */
254 AARCH64_FEATURE_FP8DOT2
,
255 /* SSVE FP8FMA instructions. */
256 AARCH64_FEATURE_SSVE_FP8FMA
,
257 /* SSVE FP8DOT4 instructions. */
258 AARCH64_FEATURE_SSVE_FP8DOT4
,
259 /* SSVE FP8DOT2 instructions. */
260 AARCH64_FEATURE_SSVE_FP8DOT2
,
261 /* SME F8F32 instructions. */
262 AARCH64_FEATURE_SME_F8F32
,
263 /* SME F8F16 instructions. */
264 AARCH64_FEATURE_SME_F8F16
,
265 /* Non-widening half-precision FP16 to FP16 arithmetic for SME2. */
266 AARCH64_FEATURE_SME_F16F16
,
267 /* SVE Z-targeting non-widening BFloat16 instructions. */
268 AARCH64_FEATURE_SVE_B16B16
,
269 /* SME non-widening BFloat16 instructions. */
270 AARCH64_FEATURE_SME_B16B16
,
271 /* Armv9.5-A processors. */
272 AARCH64_FEATURE_V9_5A
,
274 /* Virtual features. These are used to gate instructions that are enabled
275 by either of two (or more) sets of command line flags. */
276 /* +fp8fma+sve or +ssve-fp8fma */
277 AARCH64_FEATURE_FP8FMA_SVE
,
278 /* +fp8dot4+sve or +ssve-fp8dot4 */
279 AARCH64_FEATURE_FP8DOT4_SVE
,
280 /* +fp8dot2+sve or +ssve-fp8dot2 */
281 AARCH64_FEATURE_FP8DOT2_SVE
,
282 /* +sme-f16f16 or +sme-f8f16 */
283 AARCH64_FEATURE_SME_F16F16_F8F16
,
284 /* +sve2p1 or +sme */
285 AARCH64_FEATURE_SVE2p1_SME
,
286 /* +sve2p1 or +sme2 */
287 AARCH64_FEATURE_SVE2p1_SME2
,
288 /* +sve2p1 or +sme2p1 */
289 AARCH64_FEATURE_SVE2p1_SME2p1
,
293 /* These macros take an initial argument X that gives the index into
294 an aarch64_feature_set. The macros then return the bitmask for
297 /* A mask in which feature bit BIT is set and all other bits are clear. */
298 #define AARCH64_UINT64_BIT(X, BIT) \
299 ((X) == (BIT) / 64 ? 1ULL << (BIT) % 64 : 0)
301 /* A mask that includes only AARCH64_FEATURE_<NAME>. */
302 #define AARCH64_FEATBIT(X, NAME) \
303 AARCH64_UINT64_BIT (X, AARCH64_FEATURE_##NAME)
305 /* A mask of the features that are enabled by each architecture version,
306 excluding those that are inherited from other architecture versions. */
307 #define AARCH64_ARCH_V8A_FEATURES(X) (AARCH64_FEATBIT (X, V8A) \
308 | AARCH64_FEATBIT (X, FP) \
309 | AARCH64_FEATBIT (X, RAS) \
310 | AARCH64_FEATBIT (X, SIMD) \
311 | AARCH64_FEATBIT (X, CHK))
312 #define AARCH64_ARCH_V8_1A_FEATURES(X) (AARCH64_FEATBIT (X, V8_1A) \
313 | AARCH64_FEATBIT (X, CRC) \
314 | AARCH64_FEATBIT (X, LSE) \
315 | AARCH64_FEATBIT (X, PAN) \
316 | AARCH64_FEATBIT (X, LOR) \
317 | AARCH64_FEATBIT (X, RDMA))
318 #define AARCH64_ARCH_V8_2A_FEATURES(X) (AARCH64_FEATBIT (X, V8_2A))
319 #define AARCH64_ARCH_V8_3A_FEATURES(X) (AARCH64_FEATBIT (X, V8_3A) \
320 | AARCH64_FEATBIT (X, PAUTH) \
321 | AARCH64_FEATBIT (X, RCPC) \
322 | AARCH64_FEATBIT (X, COMPNUM) \
323 | AARCH64_FEATBIT (X, JSCVT))
324 #define AARCH64_ARCH_V8_4A_FEATURES(X) (AARCH64_FEATBIT (X, V8_4A) \
325 | AARCH64_FEATBIT (X, RCPC2) \
326 | AARCH64_FEATBIT (X, DOTPROD) \
327 | AARCH64_FEATBIT (X, FLAGM) \
328 | AARCH64_FEATBIT (X, F16_FML))
329 #define AARCH64_ARCH_V8_5A_FEATURES(X) (AARCH64_FEATBIT (X, V8_5A) \
330 | AARCH64_FEATBIT (X, FLAGMANIP) \
331 | AARCH64_FEATBIT (X, FRINTTS) \
332 | AARCH64_FEATBIT (X, SB) \
333 | AARCH64_FEATBIT (X, PREDRES) \
334 | AARCH64_FEATBIT (X, CVADP) \
335 | AARCH64_FEATBIT (X, SCXTNUM) \
336 | AARCH64_FEATBIT (X, ID_PFR2) \
337 | AARCH64_FEATBIT (X, SSBS))
338 #define AARCH64_ARCH_V8_6A_FEATURES(X) (AARCH64_FEATBIT (X, V8_6A) \
339 | AARCH64_FEATBIT (X, BFLOAT16) \
340 | AARCH64_FEATBIT (X, I8MM))
341 #define AARCH64_ARCH_V8_7A_FEATURES(X) (AARCH64_FEATBIT (X, V8_7A) \
342 | AARCH64_FEATBIT (X, XS) \
343 | AARCH64_FEATBIT (X, WFXT) \
344 | AARCH64_FEATBIT (X, LS64))
345 #define AARCH64_ARCH_V8_8A_FEATURES(X) (AARCH64_FEATBIT (X, V8_8A) \
346 | AARCH64_FEATBIT (X, MOPS) \
347 | AARCH64_FEATBIT (X, HBC))
348 #define AARCH64_ARCH_V8_9A_FEATURES(X) (AARCH64_FEATBIT (X, V8_9A) \
349 | AARCH64_FEATBIT (X, CSSC) \
350 | AARCH64_FEATBIT (X, SPEv1p4) \
351 | AARCH64_FEATBIT (X, SPE_CRR) \
352 | AARCH64_FEATBIT (X, SPE_FDS) \
353 | AARCH64_FEATBIT (X, RASv2) \
354 | AARCH64_FEATBIT (X, SCTLR2) \
355 | AARCH64_FEATBIT (X, FGT2) \
356 | AARCH64_FEATBIT (X, PFAR) \
357 | AARCH64_FEATBIT (X, ATS1A) \
358 | AARCH64_FEATBIT (X, AIE) \
359 | AARCH64_FEATBIT (X, S1PIE) \
360 | AARCH64_FEATBIT (X, S2PIE) \
361 | AARCH64_FEATBIT (X, S1POE) \
362 | AARCH64_FEATBIT (X, S2POE) \
363 | AARCH64_FEATBIT (X, TCR2) \
364 | AARCH64_FEATBIT (X, DEBUGv8p9) \
365 | AARCH64_FEATBIT (X, PMUv3p9) \
366 | AARCH64_FEATBIT (X, PMUv3_SS) \
367 | AARCH64_FEATBIT (X, PMUv3_ICNTR) \
368 | AARCH64_FEATBIT (X, SPMU) \
369 | AARCH64_FEATBIT (X, SEBEP) \
370 | AARCH64_FEATBIT (X, PREDRES2) \
373 #define AARCH64_ARCH_V9A_FEATURES(X) (AARCH64_FEATBIT (X, V9A) \
374 | AARCH64_FEATBIT (X, F16) \
375 | AARCH64_FEATBIT (X, SVE) \
376 | AARCH64_FEATBIT (X, SVE2))
377 #define AARCH64_ARCH_V9_1A_FEATURES(X) AARCH64_ARCH_V8_6A_FEATURES (X)
378 #define AARCH64_ARCH_V9_2A_FEATURES(X) AARCH64_ARCH_V8_7A_FEATURES (X)
379 #define AARCH64_ARCH_V9_3A_FEATURES(X) AARCH64_ARCH_V8_8A_FEATURES (X)
380 #define AARCH64_ARCH_V9_4A_FEATURES(X) (AARCH64_ARCH_V8_9A_FEATURES (X) \
381 | AARCH64_FEATBIT (X, SVE2p1))
382 #define AARCH64_ARCH_V9_5A_FEATURES(X) (AARCH64_FEATBIT (X, V9_5A) \
383 | AARCH64_FEATBIT (X, CPA) \
384 | AARCH64_FEATBIT (X, LUT) \
385 | AARCH64_FEATBIT (X, FAMINMAX)\
386 | AARCH64_FEATBIT (X, E3DSE) \
387 | AARCH64_FEATBIT (X, SPMU2) \
388 | AARCH64_FEATBIT (X, STEP2) \
391 /* Architectures are the sum of the base and extensions. */
392 #define AARCH64_ARCH_V8A(X) (AARCH64_FEATBIT (X, V8) \
393 | AARCH64_ARCH_V8A_FEATURES (X))
394 #define AARCH64_ARCH_V8_1A(X) (AARCH64_ARCH_V8A (X) \
395 | AARCH64_ARCH_V8_1A_FEATURES (X))
396 #define AARCH64_ARCH_V8_2A(X) (AARCH64_ARCH_V8_1A (X) \
397 | AARCH64_ARCH_V8_2A_FEATURES (X))
398 #define AARCH64_ARCH_V8_3A(X) (AARCH64_ARCH_V8_2A (X) \
399 | AARCH64_ARCH_V8_3A_FEATURES (X))
400 #define AARCH64_ARCH_V8_4A(X) (AARCH64_ARCH_V8_3A (X) \
401 | AARCH64_ARCH_V8_4A_FEATURES (X))
402 #define AARCH64_ARCH_V8_5A(X) (AARCH64_ARCH_V8_4A (X) \
403 | AARCH64_ARCH_V8_5A_FEATURES (X))
404 #define AARCH64_ARCH_V8_6A(X) (AARCH64_ARCH_V8_5A (X) \
405 | AARCH64_ARCH_V8_6A_FEATURES (X))
406 #define AARCH64_ARCH_V8_7A(X) (AARCH64_ARCH_V8_6A (X) \
407 | AARCH64_ARCH_V8_7A_FEATURES (X))
408 #define AARCH64_ARCH_V8_8A(X) (AARCH64_ARCH_V8_7A (X) \
409 | AARCH64_ARCH_V8_8A_FEATURES (X))
410 #define AARCH64_ARCH_V8_9A(X) (AARCH64_ARCH_V8_8A (X) \
411 | AARCH64_ARCH_V8_9A_FEATURES (X))
412 #define AARCH64_ARCH_V8R(X) ((AARCH64_ARCH_V8_4A (X) \
413 | AARCH64_FEATBIT (X, V8R)) \
414 & ~AARCH64_FEATBIT (X, V8A) \
415 & ~AARCH64_FEATBIT (X, LOR))
417 #define AARCH64_ARCH_V9A(X) (AARCH64_ARCH_V8_5A (X) \
418 | AARCH64_ARCH_V9A_FEATURES (X))
419 #define AARCH64_ARCH_V9_1A(X) (AARCH64_ARCH_V9A (X) \
420 | AARCH64_ARCH_V9_1A_FEATURES (X))
421 #define AARCH64_ARCH_V9_2A(X) (AARCH64_ARCH_V9_1A (X) \
422 | AARCH64_ARCH_V9_2A_FEATURES (X))
423 #define AARCH64_ARCH_V9_3A(X) (AARCH64_ARCH_V9_2A (X) \
424 | AARCH64_ARCH_V9_3A_FEATURES (X))
425 #define AARCH64_ARCH_V9_4A(X) (AARCH64_ARCH_V9_3A (X) \
426 | AARCH64_ARCH_V9_4A_FEATURES (X))
427 #define AARCH64_ARCH_V9_5A(X) (AARCH64_ARCH_V9_4A (X) \
428 | AARCH64_ARCH_V9_5A_FEATURES (X))
430 #define AARCH64_ARCH_NONE(X) 0
432 /* CPU-specific features. */
434 uint64_t flags
[(AARCH64_NUM_FEATURES
+ 63) / 64];
435 } aarch64_feature_set
;
437 #define AARCH64_CPU_HAS_FEATURE(CPU,FEAT) \
438 ((~(CPU).flags[0] & AARCH64_FEATBIT (0, FEAT)) == 0 \
439 && (~(CPU).flags[1] & AARCH64_FEATBIT (1, FEAT)) == 0)
441 #define AARCH64_CPU_HAS_ALL_FEATURES(CPU,FEAT) \
442 ((~(CPU).flags[0] & (FEAT).flags[0]) == 0 \
443 && (~(CPU).flags[1] & (FEAT).flags[1]) == 0)
445 #define AARCH64_CPU_HAS_ANY_FEATURES(CPU,FEAT) \
446 (((CPU).flags[0] & (FEAT).flags[0]) != 0 \
447 || ((CPU).flags[1] & (FEAT).flags[1]) != 0)
449 #define AARCH64_SET_FEATURE(DEST, FEAT) \
450 ((DEST).flags[0] = FEAT (0), \
451 (DEST).flags[1] = FEAT (1))
453 #define AARCH64_CLEAR_FEATURE(DEST, SRC, FEAT) \
454 ((DEST).flags[0] = (SRC).flags[0] & ~AARCH64_FEATBIT (0, FEAT), \
455 (DEST).flags[1] = (SRC).flags[1] & ~AARCH64_FEATBIT (1, FEAT))
457 #define AARCH64_MERGE_FEATURE_SETS(TARG,F1,F2) \
460 (TARG).flags[0] = (F1).flags[0] | (F2).flags[0]; \
461 (TARG).flags[1] = (F1).flags[1] | (F2).flags[1]; \
465 #define AARCH64_CLEAR_FEATURES(TARG,F1,F2) \
468 (TARG).flags[0] = (F1).flags[0] &~ (F2).flags[0]; \
469 (TARG).flags[1] = (F1).flags[1] &~ (F2).flags[1]; \
473 /* aarch64_feature_set initializers for no features and all features,
475 #define AARCH64_NO_FEATURES { { 0, 0 } }
476 #define AARCH64_ALL_FEATURES { { -1, -1 } }
478 /* An aarch64_feature_set initializer for a single feature,
479 AARCH64_FEATURE_<FEAT>. */
480 #define AARCH64_FEATURE(FEAT) \
481 { { AARCH64_FEATBIT (0, FEAT), AARCH64_FEATBIT (1, FEAT) } }
483 /* An aarch64_feature_set initializer for a specific architecture version,
484 including all the features that are enabled by default for that architecture
486 #define AARCH64_ARCH_FEATURES(ARCH) \
487 { { AARCH64_ARCH_##ARCH (0), AARCH64_ARCH_##ARCH (1) } }
489 /* Used by AARCH64_CPU_FEATURES. */
490 #define AARCH64_OR_FEATURES_1(X, ARCH, F1) \
491 (AARCH64_FEATBIT (X, F1) | AARCH64_ARCH_##ARCH (X))
492 #define AARCH64_OR_FEATURES_2(X, ARCH, F1, F2) \
493 (AARCH64_FEATBIT (X, F1) | AARCH64_OR_FEATURES_1 (X, ARCH, F2))
494 #define AARCH64_OR_FEATURES_3(X, ARCH, F1, ...) \
495 (AARCH64_FEATBIT (X, F1) | AARCH64_OR_FEATURES_2 (X, ARCH, __VA_ARGS__))
496 #define AARCH64_OR_FEATURES_4(X, ARCH, F1, ...) \
497 (AARCH64_FEATBIT (X, F1) | AARCH64_OR_FEATURES_3 (X, ARCH, __VA_ARGS__))
498 #define AARCH64_OR_FEATURES_5(X, ARCH, F1, ...) \
499 (AARCH64_FEATBIT (X, F1) | AARCH64_OR_FEATURES_4 (X, ARCH, __VA_ARGS__))
500 #define AARCH64_OR_FEATURES_6(X, ARCH, F1, ...) \
501 (AARCH64_FEATBIT (X, F1) | AARCH64_OR_FEATURES_5 (X, ARCH, __VA_ARGS__))
502 #define AARCH64_OR_FEATURES_7(X, ARCH, F1, ...) \
503 (AARCH64_FEATBIT (X, F1) | AARCH64_OR_FEATURES_6 (X, ARCH, __VA_ARGS__))
504 #define AARCH64_OR_FEATURES_8(X, ARCH, F1, ...) \
505 (AARCH64_FEATBIT (X, F1) | AARCH64_OR_FEATURES_7 (X, ARCH, __VA_ARGS__))
506 #define AARCH64_OR_FEATURES_9(X, ARCH, F1, ...) \
507 (AARCH64_FEATBIT (X, F1) | AARCH64_OR_FEATURES_8 (X, ARCH, __VA_ARGS__))
509 /* An aarch64_feature_set initializer for a CPU that implements architecture
510 version ARCH, and additionally provides the N features listed in "...". */
511 #define AARCH64_CPU_FEATURES(ARCH, N, ...) \
512 { { AARCH64_OR_FEATURES_##N (0, ARCH, __VA_ARGS__), \
513 AARCH64_OR_FEATURES_##N (1, ARCH, __VA_ARGS__) } }
515 /* An aarch64_feature_set initializer for the N features listed in "...". */
516 #define AARCH64_FEATURES(N, ...) \
517 AARCH64_CPU_FEATURES (NONE, N, __VA_ARGS__)
519 enum aarch64_operand_class
521 AARCH64_OPND_CLASS_NIL
,
522 AARCH64_OPND_CLASS_INT_REG
,
523 AARCH64_OPND_CLASS_MODIFIED_REG
,
524 AARCH64_OPND_CLASS_FP_REG
,
525 AARCH64_OPND_CLASS_SIMD_REG
,
526 AARCH64_OPND_CLASS_SIMD_ELEMENT
,
527 AARCH64_OPND_CLASS_SISD_REG
,
528 AARCH64_OPND_CLASS_SIMD_REGLIST
,
529 AARCH64_OPND_CLASS_SVE_REG
,
530 AARCH64_OPND_CLASS_SVE_REGLIST
,
531 AARCH64_OPND_CLASS_PRED_REG
,
532 AARCH64_OPND_CLASS_ZA_ACCESS
,
533 AARCH64_OPND_CLASS_ADDRESS
,
534 AARCH64_OPND_CLASS_IMMEDIATE
,
535 AARCH64_OPND_CLASS_SYSTEM
,
536 AARCH64_OPND_CLASS_COND
,
539 /* Operand code that helps both parsing and coding.
540 Keep AARCH64_OPERANDS synced. */
544 AARCH64_OPND_NIL
, /* no operand---MUST BE FIRST!*/
546 AARCH64_OPND_Rd
, /* Integer register as destination. */
547 AARCH64_OPND_Rn
, /* Integer register as source. */
548 AARCH64_OPND_Rm
, /* Integer register as source. */
549 AARCH64_OPND_Rt
, /* Integer register used in ld/st instructions. */
550 AARCH64_OPND_Rt2
, /* Integer register used in ld/st pair instructions. */
551 AARCH64_OPND_X16
, /* Integer register x16 in chkfeat instruction. */
552 AARCH64_OPND_Rt_LS64
, /* Integer register used in LS64 instructions. */
553 AARCH64_OPND_Rt_SP
, /* Integer Rt or SP used in STG instructions. */
554 AARCH64_OPND_Rs
, /* Integer register used in ld/st exclusive. */
555 AARCH64_OPND_Ra
, /* Integer register used in ddp_3src instructions. */
556 AARCH64_OPND_Rt_SYS
, /* Integer register used in system instructions. */
558 AARCH64_OPND_Rd_SP
, /* Integer Rd or SP. */
559 AARCH64_OPND_Rn_SP
, /* Integer Rn or SP. */
560 AARCH64_OPND_Rm_SP
, /* Integer Rm or SP. */
561 AARCH64_OPND_PAIRREG
, /* Paired register operand. */
562 AARCH64_OPND_PAIRREG_OR_XZR
, /* Paired register operand, optionally xzr. */
563 AARCH64_OPND_Rm_EXT
, /* Integer Rm extended. */
564 AARCH64_OPND_Rm_SFT
, /* Integer Rm shifted. */
565 AARCH64_OPND_Rm_LSL
, /* Integer Rm shifted (LSL-only). */
567 AARCH64_OPND_Fd
, /* Floating-point Fd. */
568 AARCH64_OPND_Fn
, /* Floating-point Fn. */
569 AARCH64_OPND_Fm
, /* Floating-point Fm. */
570 AARCH64_OPND_Fa
, /* Floating-point Fa. */
571 AARCH64_OPND_Ft
, /* Floating-point Ft. */
572 AARCH64_OPND_Ft2
, /* Floating-point Ft2. */
574 AARCH64_OPND_Sd
, /* AdvSIMD Scalar Sd. */
575 AARCH64_OPND_Sn
, /* AdvSIMD Scalar Sn. */
576 AARCH64_OPND_Sm
, /* AdvSIMD Scalar Sm. */
578 AARCH64_OPND_Va
, /* AdvSIMD Vector Va. */
579 AARCH64_OPND_Vd
, /* AdvSIMD Vector Vd. */
580 AARCH64_OPND_Vn
, /* AdvSIMD Vector Vn. */
581 AARCH64_OPND_Vm
, /* AdvSIMD Vector Vm. */
582 AARCH64_OPND_VdD1
, /* AdvSIMD <Vd>.D[1]; for FMOV only. */
583 AARCH64_OPND_VnD1
, /* AdvSIMD <Vn>.D[1]; for FMOV only. */
584 AARCH64_OPND_Ed
, /* AdvSIMD Vector Element Vd. */
585 AARCH64_OPND_En
, /* AdvSIMD Vector Element Vn. */
586 AARCH64_OPND_Em
, /* AdvSIMD Vector Element Vm. */
587 AARCH64_OPND_Em16
, /* AdvSIMD Vector Element Vm restricted to V0 - V15 when
588 qualifier is S_H or S_2B. */
589 AARCH64_OPND_Em8
, /* AdvSIMD Vector Element Vm restricted to V0 - V7,
590 used only with qualifier S_B. */
591 AARCH64_OPND_Em_INDEX1_14
, /* AdvSIMD 1-bit encoded index in Vm at [14] */
592 AARCH64_OPND_Em_INDEX2_13
, /* AdvSIMD 2-bit encoded index in Vm at [14:13] */
593 AARCH64_OPND_Em_INDEX3_12
, /* AdvSIMD 3-bit encoded index in Vm at [14:12] */
594 AARCH64_OPND_LVn
, /* AdvSIMD Vector register list used in e.g. TBL. */
595 AARCH64_OPND_LVt
, /* AdvSIMD Vector register list used in ld/st. */
596 AARCH64_OPND_LVt_AL
, /* AdvSIMD Vector register list for loading single
597 structure to all lanes. */
598 AARCH64_OPND_LVn_LUT
, /* AdvSIMD Vector register list used in lut. */
599 AARCH64_OPND_LEt
, /* AdvSIMD Vector Element list. */
601 AARCH64_OPND_CRn
, /* Co-processor register in CRn field. */
602 AARCH64_OPND_CRm
, /* Co-processor register in CRm field. */
604 AARCH64_OPND_IDX
, /* AdvSIMD EXT index operand. */
605 AARCH64_OPND_MASK
, /* AdvSIMD EXT index operand. */
606 AARCH64_OPND_IMM_VLSL
,/* Immediate for shifting vector registers left. */
607 AARCH64_OPND_IMM_VLSR
,/* Immediate for shifting vector registers right. */
608 AARCH64_OPND_SIMD_IMM
,/* AdvSIMD modified immediate without shift. */
609 AARCH64_OPND_SIMD_IMM_SFT
, /* AdvSIMD modified immediate with shift. */
610 AARCH64_OPND_SIMD_FPIMM
,/* AdvSIMD 8-bit fp immediate. */
611 AARCH64_OPND_SHLL_IMM
,/* Immediate shift for AdvSIMD SHLL instruction
613 AARCH64_OPND_IMM0
, /* Immediate for #0. */
614 AARCH64_OPND_FPIMM0
, /* Immediate for #0.0. */
615 AARCH64_OPND_FPIMM
, /* Floating-point Immediate. */
616 AARCH64_OPND_IMMR
, /* Immediate #<immr> in e.g. BFM. */
617 AARCH64_OPND_IMMS
, /* Immediate #<imms> in e.g. BFM. */
618 AARCH64_OPND_WIDTH
, /* Immediate #<width> in e.g. BFI. */
619 AARCH64_OPND_IMM
, /* Immediate. */
620 AARCH64_OPND_IMM_2
, /* Immediate. */
621 AARCH64_OPND_UIMM3_OP1
,/* Unsigned 3-bit immediate in the op1 field. */
622 AARCH64_OPND_UIMM3_OP2
,/* Unsigned 3-bit immediate in the op2 field. */
623 AARCH64_OPND_UIMM4
, /* Unsigned 4-bit immediate in the CRm field. */
624 AARCH64_OPND_UIMM4_ADDG
,/* Unsigned 4-bit immediate in addg/subg. */
625 AARCH64_OPND_UIMM7
, /* Unsigned 7-bit immediate in the CRm:op2 fields. */
626 AARCH64_OPND_UIMM10
, /* Unsigned 10-bit immediate in addg/subg. */
627 AARCH64_OPND_BIT_NUM
, /* Immediate. */
628 AARCH64_OPND_EXCEPTION
,/* imm16 operand in exception instructions. */
629 AARCH64_OPND_UNDEFINED
,/* imm16 operand in undefined instruction. */
630 AARCH64_OPND_CCMP_IMM
,/* Immediate in conditional compare instructions. */
631 AARCH64_OPND_SIMM5
, /* 5-bit signed immediate in the imm5 field. */
632 AARCH64_OPND_NZCV
, /* Flag bit specifier giving an alternative value for
633 each condition flag. */
635 AARCH64_OPND_LIMM
, /* Logical Immediate. */
636 AARCH64_OPND_AIMM
, /* Arithmetic immediate. */
637 AARCH64_OPND_HALF
, /* #<imm16>{, LSL #<shift>} operand in move wide. */
638 AARCH64_OPND_FBITS
, /* FP #<fbits> operand in e.g. SCVTF */
639 AARCH64_OPND_IMM_MOV
, /* Immediate operand for the MOV alias. */
640 AARCH64_OPND_IMM_ROT1
, /* Immediate rotate operand for FCMLA. */
641 AARCH64_OPND_IMM_ROT2
, /* Immediate rotate operand for indexed FCMLA. */
642 AARCH64_OPND_IMM_ROT3
, /* Immediate rotate operand for FCADD. */
644 AARCH64_OPND_COND
, /* Standard condition as the last operand. */
645 AARCH64_OPND_COND1
, /* Same as the above, but excluding AL and NV. */
647 AARCH64_OPND_ADDR_ADRP
, /* Memory address for ADRP */
648 AARCH64_OPND_ADDR_PCREL14
, /* 14-bit PC-relative address for e.g. TBZ. */
649 AARCH64_OPND_ADDR_PCREL19
, /* 19-bit PC-relative address for e.g. LDR. */
650 AARCH64_OPND_ADDR_PCREL21
, /* 21-bit PC-relative address for e.g. ADR. */
651 AARCH64_OPND_ADDR_PCREL26
, /* 26-bit PC-relative address for e.g. BL. */
653 AARCH64_OPND_ADDR_SIMPLE
, /* Address of ld/st exclusive. */
654 AARCH64_OPND_ADDR_REGOFF
, /* Address of register offset. */
655 AARCH64_OPND_ADDR_SIMM7
, /* Address of signed 7-bit immediate. */
656 AARCH64_OPND_ADDR_SIMM9
, /* Address of signed 9-bit immediate. */
657 AARCH64_OPND_ADDR_SIMM9_2
, /* Same as the above, but the immediate is
658 negative or unaligned and there is
659 no writeback allowed. This operand code
660 is only used to support the programmer-
661 friendly feature of using LDR/STR as the
662 the mnemonic name for LDUR/STUR instructions
663 wherever there is no ambiguity. */
664 AARCH64_OPND_ADDR_SIMM10
, /* Address of signed 10-bit immediate. */
665 AARCH64_OPND_ADDR_SIMM11
, /* Address with a signed 11-bit (multiple of
667 AARCH64_OPND_ADDR_UIMM12
, /* Address of unsigned 12-bit immediate. */
668 AARCH64_OPND_ADDR_SIMM13
, /* Address with a signed 13-bit (multiple of
670 AARCH64_OPND_SIMD_ADDR_SIMPLE
,/* Address of ld/st multiple structures. */
671 AARCH64_OPND_ADDR_OFFSET
, /* Address with an optional 9-bit immediate. */
672 AARCH64_OPND_SIMD_ADDR_POST
, /* Address of ld/st multiple post-indexed. */
674 AARCH64_OPND_SYSREG
, /* System register operand. */
675 AARCH64_OPND_SYSREG128
, /* 128-bit system register operand. */
676 AARCH64_OPND_PSTATEFIELD
, /* PSTATE field name operand. */
677 AARCH64_OPND_SYSREG_AT
, /* System register <at_op> operand. */
678 AARCH64_OPND_SYSREG_DC
, /* System register <dc_op> operand. */
679 AARCH64_OPND_SYSREG_IC
, /* System register <ic_op> operand. */
680 AARCH64_OPND_SYSREG_TLBI
, /* System register <tlbi_op> operand. */
681 AARCH64_OPND_SYSREG_TLBIP
, /* System register <tlbip_op> operand. */
682 AARCH64_OPND_SYSREG_SR
, /* System register RCTX operand. */
683 AARCH64_OPND_BARRIER
, /* Barrier operand. */
684 AARCH64_OPND_BARRIER_DSB_NXS
, /* Barrier operand for DSB nXS variant. */
685 AARCH64_OPND_BARRIER_ISB
, /* Barrier operand for ISB. */
686 AARCH64_OPND_PRFOP
, /* Prefetch operation. */
687 AARCH64_OPND_RPRFMOP
, /* Range prefetch operation. */
688 AARCH64_OPND_BARRIER_PSB
, /* Barrier operand for PSB. */
689 AARCH64_OPND_BARRIER_GCSB
, /* Barrier operand for GCSB. */
690 AARCH64_OPND_BTI_TARGET
, /* BTI {<target>}. */
691 AARCH64_OPND_BRBOP
, /* BRB operation IALL or INJ in bit 5. */
692 AARCH64_OPND_Rt_IN_SYS_ALIASES
, /* Defaulted and omitted Rt used in SYS aliases such as brb. */
693 AARCH64_OPND_LSE128_Rt
, /* LSE128 <Xt1>. */
694 AARCH64_OPND_LSE128_Rt2
, /* LSE128 <Xt2>. */
695 AARCH64_OPND_SVE_ADDR_RI_S4x16
, /* SVE [<Xn|SP>, #<simm4>*16]. */
696 AARCH64_OPND_SVE_ADDR_RI_S4x32
, /* SVE [<Xn|SP>, #<simm4>*32]. */
697 AARCH64_OPND_SVE_ADDR_RI_S4xVL
, /* SVE [<Xn|SP>, #<simm4>, MUL VL]. */
698 AARCH64_OPND_SVE_ADDR_RI_S4x2xVL
, /* SVE [<Xn|SP>, #<simm4>*2, MUL VL]. */
699 AARCH64_OPND_SVE_ADDR_RI_S4x3xVL
, /* SVE [<Xn|SP>, #<simm4>*3, MUL VL]. */
700 AARCH64_OPND_SVE_ADDR_RI_S4x4xVL
, /* SVE [<Xn|SP>, #<simm4>*4, MUL VL]. */
701 AARCH64_OPND_SVE_ADDR_RI_S6xVL
, /* SVE [<Xn|SP>, #<simm6>, MUL VL]. */
702 AARCH64_OPND_SVE_ADDR_RI_S9xVL
, /* SVE [<Xn|SP>, #<simm9>, MUL VL]. */
703 AARCH64_OPND_SVE_ADDR_RI_U6
, /* SVE [<Xn|SP>, #<uimm6>]. */
704 AARCH64_OPND_SVE_ADDR_RI_U6x2
, /* SVE [<Xn|SP>, #<uimm6>*2]. */
705 AARCH64_OPND_SVE_ADDR_RI_U6x4
, /* SVE [<Xn|SP>, #<uimm6>*4]. */
706 AARCH64_OPND_SVE_ADDR_RI_U6x8
, /* SVE [<Xn|SP>, #<uimm6>*8]. */
707 AARCH64_OPND_SVE_ADDR_R
, /* SVE [<Xn|SP>]. */
708 AARCH64_OPND_SVE_ADDR_RR
, /* SVE [<Xn|SP>, <Xm|XZR>]. */
709 AARCH64_OPND_SVE_ADDR_RR_LSL1
, /* SVE [<Xn|SP>, <Xm|XZR>, LSL #1]. */
710 AARCH64_OPND_SVE_ADDR_RR_LSL2
, /* SVE [<Xn|SP>, <Xm|XZR>, LSL #2]. */
711 AARCH64_OPND_SVE_ADDR_RR_LSL3
, /* SVE [<Xn|SP>, <Xm|XZR>, LSL #3]. */
712 AARCH64_OPND_SVE_ADDR_RR_LSL4
, /* SVE [<Xn|SP>, <Xm|XZR>, LSL #4]. */
713 AARCH64_OPND_SVE_ADDR_RX
, /* SVE [<Xn|SP>, <Xm>]. */
714 AARCH64_OPND_SVE_ADDR_RX_LSL1
, /* SVE [<Xn|SP>, <Xm>, LSL #1]. */
715 AARCH64_OPND_SVE_ADDR_RX_LSL2
, /* SVE [<Xn|SP>, <Xm>, LSL #2]. */
716 AARCH64_OPND_SVE_ADDR_RX_LSL3
, /* SVE [<Xn|SP>, <Xm>, LSL #3]. */
717 AARCH64_OPND_SVE_ADDR_RX_LSL4
, /* SVE [<Xn|SP>, <Xm>, LSL #4]. */
718 AARCH64_OPND_SVE_ADDR_ZX
, /* SVE [Zn.<T>{, <Xm>}]. */
719 AARCH64_OPND_SVE_ADDR_RZ
, /* SVE [<Xn|SP>, Zm.D]. */
720 AARCH64_OPND_SVE_ADDR_RZ_LSL1
, /* SVE [<Xn|SP>, Zm.D, LSL #1]. */
721 AARCH64_OPND_SVE_ADDR_RZ_LSL2
, /* SVE [<Xn|SP>, Zm.D, LSL #2]. */
722 AARCH64_OPND_SVE_ADDR_RZ_LSL3
, /* SVE [<Xn|SP>, Zm.D, LSL #3]. */
723 AARCH64_OPND_SVE_ADDR_RZ_XTW_14
, /* SVE [<Xn|SP>, Zm.<T>, (S|U)XTW].
724 Bit 14 controls S/U choice. */
725 AARCH64_OPND_SVE_ADDR_RZ_XTW_22
, /* SVE [<Xn|SP>, Zm.<T>, (S|U)XTW].
726 Bit 22 controls S/U choice. */
727 AARCH64_OPND_SVE_ADDR_RZ_XTW1_14
, /* SVE [<Xn|SP>, Zm.<T>, (S|U)XTW #1].
728 Bit 14 controls S/U choice. */
729 AARCH64_OPND_SVE_ADDR_RZ_XTW1_22
, /* SVE [<Xn|SP>, Zm.<T>, (S|U)XTW #1].
730 Bit 22 controls S/U choice. */
731 AARCH64_OPND_SVE_ADDR_RZ_XTW2_14
, /* SVE [<Xn|SP>, Zm.<T>, (S|U)XTW #2].
732 Bit 14 controls S/U choice. */
733 AARCH64_OPND_SVE_ADDR_RZ_XTW2_22
, /* SVE [<Xn|SP>, Zm.<T>, (S|U)XTW #2].
734 Bit 22 controls S/U choice. */
735 AARCH64_OPND_SVE_ADDR_RZ_XTW3_14
, /* SVE [<Xn|SP>, Zm.<T>, (S|U)XTW #3].
736 Bit 14 controls S/U choice. */
737 AARCH64_OPND_SVE_ADDR_RZ_XTW3_22
, /* SVE [<Xn|SP>, Zm.<T>, (S|U)XTW #3].
738 Bit 22 controls S/U choice. */
739 AARCH64_OPND_SVE_ADDR_ZI_U5
, /* SVE [Zn.<T>, #<uimm5>]. */
740 AARCH64_OPND_SVE_ADDR_ZI_U5x2
, /* SVE [Zn.<T>, #<uimm5>*2]. */
741 AARCH64_OPND_SVE_ADDR_ZI_U5x4
, /* SVE [Zn.<T>, #<uimm5>*4]. */
742 AARCH64_OPND_SVE_ADDR_ZI_U5x8
, /* SVE [Zn.<T>, #<uimm5>*8]. */
743 AARCH64_OPND_SVE_ADDR_ZZ_LSL
, /* SVE [Zn.<T>, Zm,<T>, LSL #<msz>]. */
744 AARCH64_OPND_SVE_ADDR_ZZ_SXTW
, /* SVE [Zn.<T>, Zm,<T>, SXTW #<msz>]. */
745 AARCH64_OPND_SVE_ADDR_ZZ_UXTW
, /* SVE [Zn.<T>, Zm,<T>, UXTW #<msz>]. */
746 AARCH64_OPND_SVE_AIMM
, /* SVE unsigned arithmetic immediate. */
747 AARCH64_OPND_SVE_ASIMM
, /* SVE signed arithmetic immediate. */
748 AARCH64_OPND_SVE_FPIMM8
, /* SVE 8-bit floating-point immediate. */
749 AARCH64_OPND_SVE_I1_HALF_ONE
, /* SVE choice between 0.5 and 1.0. */
750 AARCH64_OPND_SVE_I1_HALF_TWO
, /* SVE choice between 0.5 and 2.0. */
751 AARCH64_OPND_SVE_I1_ZERO_ONE
, /* SVE choice between 0.0 and 1.0. */
752 AARCH64_OPND_SVE_IMM_ROT1
, /* SVE 1-bit rotate operand (90 or 270). */
753 AARCH64_OPND_SVE_IMM_ROT2
, /* SVE 2-bit rotate operand (N*90). */
754 AARCH64_OPND_SVE_IMM_ROT3
, /* SVE cadd 1-bit rotate (90 or 270). */
755 AARCH64_OPND_SVE_INV_LIMM
, /* SVE inverted logical immediate. */
756 AARCH64_OPND_SVE_LIMM
, /* SVE logical immediate. */
757 AARCH64_OPND_SVE_LIMM_MOV
, /* SVE logical immediate for MOV. */
758 AARCH64_OPND_SVE_PATTERN
, /* SVE vector pattern enumeration. */
759 AARCH64_OPND_SVE_PATTERN_SCALED
, /* Likewise, with additional MUL factor. */
760 AARCH64_OPND_SVE_PRFOP
, /* SVE prefetch operation. */
761 AARCH64_OPND_SVE_Pd
, /* SVE p0-p15 in Pd. */
762 AARCH64_OPND_SVE_PNd
, /* SVE pn0-pn15 in Pd. */
763 AARCH64_OPND_SVE_Pg3
, /* SVE p0-p7 in Pg. */
764 AARCH64_OPND_SVE_Pg4_5
, /* SVE p0-p15 in Pg, bits [8,5]. */
765 AARCH64_OPND_SVE_Pg4_10
, /* SVE p0-p15 in Pg, bits [13,10]. */
766 AARCH64_OPND_SVE_PNg4_10
, /* SVE pn0-pn15 in Pg, bits [13,10]. */
767 AARCH64_OPND_SVE_Pg4_16
, /* SVE p0-p15 in Pg, bits [19,16]. */
768 AARCH64_OPND_SVE_Pm
, /* SVE p0-p15 in Pm. */
769 AARCH64_OPND_SVE_Pn
, /* SVE p0-p15 in Pn. */
770 AARCH64_OPND_SVE_PNn
, /* SVE pn0-pn15 in Pn. */
771 AARCH64_OPND_SVE_Pt
, /* SVE p0-p15 in Pt. */
772 AARCH64_OPND_SVE_PNt
, /* SVE pn0-pn15 in Pt. */
773 AARCH64_OPND_SVE_Rm
, /* Integer Rm or ZR, alt. SVE position. */
774 AARCH64_OPND_SVE_Rn_SP
, /* Integer Rn or SP, alt. SVE position. */
775 AARCH64_OPND_SVE_SHLIMM_PRED
, /* SVE shift left amount (predicated). */
776 AARCH64_OPND_SVE_SHLIMM_UNPRED
, /* SVE shift left amount (unpredicated). */
777 AARCH64_OPND_SVE_SHLIMM_UNPRED_22
, /* SVE 3 bit shift left unpred. */
778 AARCH64_OPND_SVE_SHRIMM_PRED
, /* SVE shift right amount (predicated). */
779 AARCH64_OPND_SVE_SHRIMM_UNPRED
, /* SVE shift right amount (unpredicated). */
780 AARCH64_OPND_SVE_SHRIMM_UNPRED_22
, /* SVE 3 bit shift right unpred. */
781 AARCH64_OPND_SVE_SIMM5
, /* SVE signed 5-bit immediate. */
782 AARCH64_OPND_SVE_SIMM5B
, /* SVE secondary signed 5-bit immediate. */
783 AARCH64_OPND_SVE_SIMM6
, /* SVE signed 6-bit immediate. */
784 AARCH64_OPND_SVE_SIMM8
, /* SVE signed 8-bit immediate. */
785 AARCH64_OPND_SVE_UIMM3
, /* SVE unsigned 3-bit immediate. */
786 AARCH64_OPND_SVE_UIMM7
, /* SVE unsigned 7-bit immediate. */
787 AARCH64_OPND_SVE_UIMM8
, /* SVE unsigned 8-bit immediate. */
788 AARCH64_OPND_SVE_UIMM8_53
, /* SVE split unsigned 8-bit immediate. */
789 AARCH64_OPND_SVE_UIMM4
, /* SVE unsigned 4-bit immediate. */
790 AARCH64_OPND_SVE_VZn
, /* Scalar SIMD&FP register in Zn field. */
791 AARCH64_OPND_SVE_Vd
, /* Scalar SIMD&FP register in Vd. */
792 AARCH64_OPND_SVE_Vm
, /* Scalar SIMD&FP register in Vm. */
793 AARCH64_OPND_SVE_Vn
, /* Scalar SIMD&FP register in Vn. */
794 AARCH64_OPND_SME_ZA_array_vrsb_1
, /* Tile to vector, two registers (B). */
795 AARCH64_OPND_SME_ZA_array_vrsh_1
, /* Tile to vector, two registers (H). */
796 AARCH64_OPND_SME_ZA_array_vrss_1
, /* Tile to vector, two registers (S). */
797 AARCH64_OPND_SME_ZA_array_vrsd_1
, /* Tile to vector, two registers (D). */
798 AARCH64_OPND_SME_ZA_array_vrsb_2
, /* Tile to vector, four registers (B). */
799 AARCH64_OPND_SME_ZA_array_vrsh_2
, /* Tile to vector, four registers (H). */
800 AARCH64_OPND_SME_ZA_array_vrss_2
, /* Tile to vector, four registers (S). */
801 AARCH64_OPND_SME_ZA_array_vrsd_2
, /* Tile to vector, four registers (D). */
802 AARCH64_OPND_SME_ZA_ARRAY4
, /* Tile to vector, single (BHSDQ). */
803 AARCH64_OPND_SVE_Za_5
, /* SVE vector register in Za, bits [9,5]. */
804 AARCH64_OPND_SVE_Za_16
, /* SVE vector register in Za, bits [20,16]. */
805 AARCH64_OPND_SVE_Zd
, /* SVE vector register in Zd. */
806 AARCH64_OPND_SVE_Zm_5
, /* SVE vector register in Zm, bits [9,5]. */
807 AARCH64_OPND_SVE_Zm_16
, /* SVE vector register in Zm, bits [20,16]. */
808 AARCH64_OPND_SVE_Zm1_23_INDEX
, /* SVE bit index in Zm, bit 23. */
809 AARCH64_OPND_SVE_Zm2_22_INDEX
, /* SVE bit index in Zm, bits [23,22]. */
810 AARCH64_OPND_SVE_Zm3_INDEX
, /* z0-z7[0-3] in Zm, bits [20,16]. */
811 AARCH64_OPND_SVE_Zm3_11_INDEX
, /* z0-z7[0-7] in Zm3_INDEX plus bit 11. */
812 AARCH64_OPND_SVE_Zm3_12_INDEX
, /* SVE bit index in Zm, bits 12 plus bit [23,22]. */
813 AARCH64_OPND_SVE_Zm3_19_INDEX
, /* z0-z7[0-3] in Zm3_INDEX plus bit 19. */
814 AARCH64_OPND_SVE_Zm3_22_INDEX
, /* z0-z7[0-7] in Zm3_INDEX plus bit 22. */
815 AARCH64_OPND_SVE_Zm3_10_INDEX
, /* z0-z7[0-15] in Zm3_INDEX plus bit 11:10. */
816 AARCH64_OPND_SVE_Zm4_11_INDEX
, /* z0-z15[0-3] in Zm plus bit 11. */
817 AARCH64_OPND_SVE_Zm4_INDEX
, /* z0-z15[0-1] in Zm, bits [20,16]. */
818 AARCH64_OPND_SVE_Zn
, /* SVE vector register in Zn. */
819 AARCH64_OPND_SVE_Zn_INDEX
, /* Indexed SVE vector register, for DUP. */
820 AARCH64_OPND_SVE_Zn_5_INDEX
, /* Indexed SVE vector register, for DUPQ. */
821 AARCH64_OPND_SVE_ZnxN
, /* SVE vector register list in Zn. */
822 AARCH64_OPND_SVE_Zt
, /* SVE vector register in Zt. */
823 AARCH64_OPND_SVE_ZtxN
, /* SVE vector register list in Zt. */
824 AARCH64_OPND_SME_Zdnx2
, /* SVE vector register list from [4:1]*2. */
825 AARCH64_OPND_SME_Zdnx4
, /* SVE vector register list from [4:2]*4. */
826 AARCH64_OPND_SME_Zm
, /* SVE vector register list in 4-bit Zm. */
827 AARCH64_OPND_SME_Zmx2
, /* SVE vector register list from [20:17]*2. */
828 AARCH64_OPND_SME_Zmx4
, /* SVE vector register list from [20:18]*4. */
829 AARCH64_OPND_SME_Znx2
, /* SVE vector register list from [9:6]*2. */
830 AARCH64_OPND_SME_Znx2_BIT_INDEX
, /* SVE vector register list encoding a bit index from [9:6]*2. */
831 AARCH64_OPND_SME_Znx4
, /* SVE vector register list from [9:7]*4. */
832 AARCH64_OPND_SME_Ztx2_STRIDED
, /* SVE vector register list in [4:0]&23. */
833 AARCH64_OPND_SME_Ztx4_STRIDED
, /* SVE vector register list in [4:0]&19. */
834 AARCH64_OPND_SME_ZAda_1b
, /* SME <ZAda>.H, 1-bits. */
835 AARCH64_OPND_SME_ZAda_2b
, /* SME <ZAda>.S, 2-bits. */
836 AARCH64_OPND_SME_ZAda_3b
, /* SME <ZAda>.D, 3-bits. */
837 AARCH64_OPND_SME_ZA_HV_idx_src
, /* SME source ZA tile vector. */
838 AARCH64_OPND_SME_ZA_HV_idx_srcxN
, /* SME N source ZA tile vectors. */
839 AARCH64_OPND_SME_ZA_HV_idx_dest
, /* SME destination ZA tile vector. */
840 AARCH64_OPND_SME_ZA_HV_idx_destxN
, /* SME N dest ZA tile vectors. */
841 AARCH64_OPND_SME_Pdx2
, /* Predicate register list in [3:1]. */
842 AARCH64_OPND_SME_PdxN
, /* Predicate register list in [3:0]. */
843 AARCH64_OPND_SME_Pm
, /* SME scalable predicate register, bits [15:13]. */
844 AARCH64_OPND_SME_PNd3
, /* Predicate-as-counter register, bits [3:0]. */
845 AARCH64_OPND_SME_PNg3
, /* Predicate-as-counter register, bits [12:10]. */
846 AARCH64_OPND_SME_PNn
, /* Predicate-as-counter register, bits [8:5]. */
847 AARCH64_OPND_SME_PNn3_INDEX1
, /* Indexed pred-as-counter reg, bits [8:5]. */
848 AARCH64_OPND_SME_PNn3_INDEX2
, /* Indexed pred-as-counter reg, bits [9:5]. */
849 AARCH64_OPND_SME_list_of_64bit_tiles
, /* SME list of ZA tiles. */
850 AARCH64_OPND_SME_ZA_HV_idx_ldstr
, /* SME destination ZA tile vector. */
851 AARCH64_OPND_SME_ZA_array_off1x4
, /* SME ZA[<Wv>, #<imm1>*4:<imm1>*4+3]. */
852 AARCH64_OPND_SME_ZA_array_off2x2
, /* SME ZA[<Wv>, #<imm2>*2:<imm2>*2+1]. */
853 AARCH64_OPND_SME_ZA_array_off2x4
, /* SME ZA[<Wv>, #<imm2>*4:<imm2>*4+3]. */
854 AARCH64_OPND_SME_ZA_array_off3_0
, /* SME ZA[<Wv>{, #<imm3>}]. */
855 AARCH64_OPND_SME_ZA_array_off3_5
, /* SME ZA[<Wv>{, #<imm3>}]. */
856 AARCH64_OPND_SME_ZA_array_off3x2
, /* SME ZA[<Wv>, #<imm3>*2:<imm3>*2+1]. */
857 AARCH64_OPND_SME_ZA_array_off4
, /* SME ZA[<Wv>{, #<imm>}]. */
858 AARCH64_OPND_SME_ADDR_RI_U4xVL
, /* SME [<Xn|SP>{, #<imm>, MUL VL}]. */
859 AARCH64_OPND_SME_SM_ZA
, /* SME {SM | ZA}. */
860 AARCH64_OPND_SME_PnT_Wm_imm
, /* SME <Pn>.<T>[<Wm>, #<imm>]. */
861 AARCH64_OPND_SME_SHRIMM4
, /* 4-bit right shift, bits [19:16]. */
862 AARCH64_OPND_SME_SHRIMM5
, /* size + 5-bit right shift, bits [23:22,20:16]. */
863 AARCH64_OPND_SME_Zm_INDEX1
, /* Zn.T[index], bits [19:16,10]. */
864 AARCH64_OPND_SME_Zm_INDEX2
, /* Zn.T[index], bits [19:16,11:10]. */
865 AARCH64_OPND_SME_Zm_INDEX2_3
, /* Zn.T[index], bits [19:16,10,3]. */
866 AARCH64_OPND_SME_Zm_INDEX3_1
, /* Zn.T[index], bits [19:16,10,2:1]. */
867 AARCH64_OPND_SME_Zm_INDEX3_2
, /* Zn.T[index], bits [19:16,11:10,2]. */
868 AARCH64_OPND_SME_Zm_INDEX3_3
, /* Zn.T[index], bits [19:16,11:10,3]. */
869 AARCH64_OPND_SME_Zm_INDEX3_10
, /* Zn.T[index], bits [19:16,15,11:10]. */
870 AARCH64_OPND_SME_Zm_INDEX4_1
, /* Zn.T[index], bits [19:16,11:10,2:1]. */
871 AARCH64_OPND_SME_Zm_INDEX4_2
, /* Zn.T[index], bits [19:16,11:10,3:2]. */
872 AARCH64_OPND_SME_Zm_INDEX4_3
, /* Zn.T[index], bits [19:16,15,11,10,3]. */
873 AARCH64_OPND_SME_Zm_INDEX4_10
, /* Zn.T[index], bits [19:16,15,12:10]. */
874 AARCH64_OPND_SME_Zn_INDEX1_16
, /* Zn[index], bits [9:5] and [16:16]. */
875 AARCH64_OPND_SME_Zn_INDEX2_15
, /* Zn[index], bits [9:5] and [16:15]. */
876 AARCH64_OPND_SME_Zn_INDEX2_16
, /* Zn[index], bits [9:5] and [17:16]. */
877 AARCH64_OPND_SME_Zn_INDEX3_14
, /* Zn[index], bits [9:5] and [16:14]. */
878 AARCH64_OPND_SME_Zn_INDEX3_15
, /* Zn[index], bits [9:5] and [17:15]. */
879 AARCH64_OPND_SME_Zn_INDEX4_14
, /* Zn[index], bits [9:5] and [17:14]. */
880 AARCH64_OPND_SVE_Zn0_INDEX
, /* Zn[index], bits [9:5]. */
881 AARCH64_OPND_SVE_Zn1_17_INDEX
, /* Zn[index], bits [9:5,17]. */
882 AARCH64_OPND_SVE_Zn2_18_INDEX
, /* Zn[index], bits [9:5,18:17]. */
883 AARCH64_OPND_SVE_Zn3_22_INDEX
, /* Zn[index], bits [9:5,18:17,22]. */
884 AARCH64_OPND_SVE_Zd0_INDEX
, /* Zn[index], bits [4:0]. */
885 AARCH64_OPND_SVE_Zd1_17_INDEX
, /* Zn[index], bits [4:0,17]. */
886 AARCH64_OPND_SVE_Zd2_18_INDEX
, /* Zn[index], bits [4:0,18:17]. */
887 AARCH64_OPND_SVE_Zd3_22_INDEX
, /* Zn[index], bits [4:0,18:17,22]. */
888 AARCH64_OPND_SME_VLxN_10
, /* VLx2 or VLx4, in bit 10. */
889 AARCH64_OPND_SME_VLxN_13
, /* VLx2 or VLx4, in bit 13. */
890 AARCH64_OPND_SME_ZT0
, /* The fixed token zt0/ZT0 (not encoded). */
891 AARCH64_OPND_SME_ZT0_INDEX
, /* ZT0[<imm>], bits [14:12]. */
892 AARCH64_OPND_SME_ZT0_INDEX_MUL_VL
,/* ZT0[<imm>], bits [13:12]. */
893 AARCH64_OPND_SME_ZT0_LIST
, /* { zt0/ZT0 } (not encoded). */
894 AARCH64_OPND_TME_UIMM16
, /* TME unsigned 16-bit immediate. */
895 AARCH64_OPND_SM3_IMM2
, /* SM3 encodes lane in bits [13, 14]. */
896 AARCH64_OPND_MOPS_ADDR_Rd
, /* [Rd]!, in bits [0, 4]. */
897 AARCH64_OPND_MOPS_ADDR_Rs
, /* [Rs]!, in bits [16, 20]. */
898 AARCH64_OPND_MOPS_WB_Rn
, /* Rn!, in bits [5, 9]. */
899 AARCH64_OPND_CSSC_SIMM8
, /* CSSC signed 8-bit immediate. */
900 AARCH64_OPND_CSSC_UIMM8
, /* CSSC unsigned 8-bit immediate. */
901 AARCH64_OPND_RCPC3_ADDR_OPT_POSTIND
, /* [<Xn|SP>]{, #<imm>}. */
902 AARCH64_OPND_RCPC3_ADDR_OPT_PREIND_WB
, /* [<Xn|SP>] or [<Xn|SP>, #<imm>]!. */
903 AARCH64_OPND_RCPC3_ADDR_POSTIND
, /* [<Xn|SP>], #<imm>. */
904 AARCH64_OPND_RCPC3_ADDR_PREIND_WB
, /* [<Xn|SP>, #<imm>]!. */
905 AARCH64_OPND_RCPC3_ADDR_OFFSET
,
908 /* Qualifier constrains an operand. It either specifies a variant of an
909 operand type or limits values available to an operand type.
911 N.B. Order is important.
912 Keep aarch64_opnd_qualifiers (opcodes/aarch64-opc.c) synced. */
914 enum aarch64_opnd_qualifier
916 /* Indicating no further qualification on an operand. */
917 AARCH64_OPND_QLF_NIL
,
919 /* Qualifying an operand which is a general purpose (integer) register;
920 indicating the operand data size or a specific register. */
921 AARCH64_OPND_QLF_W
, /* Wn, WZR or WSP. */
922 AARCH64_OPND_QLF_X
, /* Xn, XZR or XSP. */
923 AARCH64_OPND_QLF_WSP
, /* WSP. */
924 AARCH64_OPND_QLF_SP
, /* SP. */
926 /* Qualifying an operand which is a floating-point register, a SIMD
927 vector element or a SIMD vector element list; indicating operand data
928 size or the size of each SIMD vector element in the case of a SIMD
930 These qualifiers are also used to qualify an address operand to
931 indicate the size of data element a load/store instruction is
933 They are also used for the immediate shift operand in e.g. SSHR. Such
934 a use is only for the ease of operand encoding/decoding and qualifier
935 sequence matching; such a use should not be applied widely; use the value
936 constraint qualifiers for immediate operands wherever possible. */
937 AARCH64_OPND_QLF_S_B
,
938 AARCH64_OPND_QLF_S_H
,
939 AARCH64_OPND_QLF_S_S
,
940 AARCH64_OPND_QLF_S_D
,
941 AARCH64_OPND_QLF_S_Q
,
942 /* These type qualifiers have a special meaning in that they mean 2 x 1 byte,
943 4 x 1 byte or 2 x 2 byte are selected by the instruction. Other than that
944 they have no difference with AARCH64_OPND_QLF_S_B in encoding. They are
945 here purely for syntactical reasons and is an exception from normal
946 AArch64 disassembly scheme. */
947 AARCH64_OPND_QLF_S_2B
,
948 AARCH64_OPND_QLF_S_4B
,
949 AARCH64_OPND_QLF_S_2H
,
951 /* Qualifying an operand which is a SIMD vector register or a SIMD vector
952 register list; indicating register shape.
953 They are also used for the immediate shift operand in e.g. SSHR. Such
954 a use is only for the ease of operand encoding/decoding and qualifier
955 sequence matching; such a use should not be applied widely; use the value
956 constraint qualifiers for immediate operands wherever possible. */
957 AARCH64_OPND_QLF_V_4B
,
958 AARCH64_OPND_QLF_V_8B
,
959 AARCH64_OPND_QLF_V_16B
,
960 AARCH64_OPND_QLF_V_2H
,
961 AARCH64_OPND_QLF_V_4H
,
962 AARCH64_OPND_QLF_V_8H
,
963 AARCH64_OPND_QLF_V_2S
,
964 AARCH64_OPND_QLF_V_4S
,
965 AARCH64_OPND_QLF_V_1D
,
966 AARCH64_OPND_QLF_V_2D
,
967 AARCH64_OPND_QLF_V_1Q
,
969 AARCH64_OPND_QLF_P_Z
,
970 AARCH64_OPND_QLF_P_M
,
972 /* Used in scaled signed immediate that are scaled by a Tag granule
973 like in stg, st2g, etc. */
974 AARCH64_OPND_QLF_imm_tag
,
976 /* Constraint on value. */
977 AARCH64_OPND_QLF_CR
, /* CRn, CRm. */
978 AARCH64_OPND_QLF_imm_0_7
,
979 AARCH64_OPND_QLF_imm_0_15
,
980 AARCH64_OPND_QLF_imm_0_31
,
981 AARCH64_OPND_QLF_imm_0_63
,
982 AARCH64_OPND_QLF_imm_1_32
,
983 AARCH64_OPND_QLF_imm_1_64
,
985 /* Indicate whether an AdvSIMD modified immediate operand is shift-zeros
987 AARCH64_OPND_QLF_LSL
,
988 AARCH64_OPND_QLF_MSL
,
990 /* Special qualifier helping retrieve qualifier information during the
991 decoding time (currently not in use). */
992 AARCH64_OPND_QLF_RETRIEVE
,
994 /* Special qualifier used for indicating error in qualifier retrieval. */
995 AARCH64_OPND_QLF_ERR
,
998 /* Instruction class. */
1000 enum aarch64_insn_class
1056 ldst_imm9
, /* immpost or immpre */
1057 ldst_imm10
, /* LDRAA/LDRAB */
1127 /* Opcode enumerators. */
1171 OP_MOV_IMM_LOG
, /* MOV alias for moving bitmask immediate. */
1172 OP_MOV_IMM_WIDE
, /* MOV alias for moving wide immediate. */
1173 OP_MOV_IMM_WIDEN
, /* MOV alias for moving wide immediate (negated). */
1175 OP_MOV_V
, /* MOV alias for moving vector register. */
1188 OP_BFC
, /* ARMv8.2. */
1205 OP_FCVTXN_S
, /* Scalar version. */
1227 OP_FCMLA_ELEM
, /* ARMv8.3, indexed element version. */
1229 OP_TOTAL_NUM
, /* Pseudo. */
1243 /* Maximum number of operands an instruction can have. */
1244 #define AARCH64_MAX_OPND_NUM 7
1245 /* Maximum number of qualifier sequences an instruction can have. */
1246 #define AARCH64_MAX_QLF_SEQ_NUM 10
1247 /* Operand qualifier typedef */
1248 typedef enum aarch64_opnd_qualifier aarch64_opnd_qualifier_t
;
1249 /* Operand qualifier sequence typedef. */
1250 typedef aarch64_opnd_qualifier_t \
1251 aarch64_opnd_qualifier_seq_t
[AARCH64_MAX_OPND_NUM
];
1253 /* FIXME: improve the efficiency. */
1255 empty_qualifier_sequence_p (const aarch64_opnd_qualifier_t
*qualifiers
)
1258 for (i
= 0; i
< AARCH64_MAX_OPND_NUM
; ++i
)
1259 if (qualifiers
[i
] != AARCH64_OPND_QLF_NIL
)
1264 /* Forward declare error reporting type. */
1265 typedef struct aarch64_operand_error aarch64_operand_error
;
1266 /* Forward declare instruction sequence type. */
1267 typedef struct aarch64_instr_sequence aarch64_instr_sequence
;
1268 /* Forward declare instruction definition. */
1269 typedef struct aarch64_inst aarch64_inst
;
1271 /* This structure holds information for a particular opcode. */
1273 struct aarch64_opcode
1275 /* The name of the mnemonic. */
1278 /* The opcode itself. Those bits which will be filled in with
1279 operands are zeroes. */
1280 aarch64_insn opcode
;
1282 /* The opcode mask. This is used by the disassembler. This is a
1283 mask containing ones indicating those bits which must match the
1284 opcode field, and zeroes indicating those bits which need not
1285 match (and are presumably filled in by operands). */
1288 /* Instruction class. */
1289 enum aarch64_insn_class iclass
;
1291 /* Enumerator identifier. */
1294 /* Which architecture variant provides this instruction. */
1295 const aarch64_feature_set
*avariant
;
1297 /* An array of operand codes. Each code is an index into the
1298 operand table. They appear in the order which the operands must
1299 appear in assembly code, and are terminated by a zero. */
1300 enum aarch64_opnd operands
[AARCH64_MAX_OPND_NUM
];
1302 /* A list of operand qualifier code sequence. Each operand qualifier
1303 code qualifies the corresponding operand code. Each operand
1304 qualifier sequence specifies a valid opcode variant and related
1305 constraint on operands. */
1306 aarch64_opnd_qualifier_seq_t qualifiers_list
[AARCH64_MAX_QLF_SEQ_NUM
];
1308 /* Flags providing information about this instruction */
1311 /* Extra constraints on the instruction that the verifier checks. */
1312 uint32_t constraints
;
1314 /* If nonzero, this operand and operand 0 are both registers and
1315 are required to have the same register number. */
1316 unsigned char tied_operand
;
1318 /* If non-NULL, a function to verify that a given instruction is valid. */
1319 enum err_type (* verifier
) (const struct aarch64_inst
*, const aarch64_insn
,
1320 bfd_vma
, bool, aarch64_operand_error
*,
1321 struct aarch64_instr_sequence
*);
1324 typedef struct aarch64_opcode aarch64_opcode
;
1326 /* Table describing all the AArch64 opcodes. */
1327 extern const aarch64_opcode aarch64_opcode_table
[];
1330 #define F_ALIAS (1 << 0)
1331 #define F_HAS_ALIAS (1 << 1)
1332 /* Disassembly preference priority 1-3 (the larger the higher). If nothing
1333 is specified, it is the priority 0 by default, i.e. the lowest priority. */
1334 #define F_P1 (1 << 2)
1335 #define F_P2 (2 << 2)
1336 #define F_P3 (3 << 2)
1337 /* Flag an instruction that is truly conditional executed, e.g. b.cond. */
1338 #define F_COND (1 << 4)
1339 /* Instruction has the field of 'sf'. */
1340 #define F_SF (1 << 5)
1341 /* Instruction has the field of 'size:Q'. */
1342 #define F_SIZEQ (1 << 6)
1343 /* Floating-point instruction has the field of 'type'. */
1344 #define F_FPTYPE (1 << 7)
1345 /* AdvSIMD scalar instruction has the field of 'size'. */
1346 #define F_SSIZE (1 << 8)
1347 /* AdvSIMD vector register arrangement specifier encoded in "imm5<3:0>:Q". */
1348 #define F_T (1 << 9)
1349 /* Size of GPR operand in AdvSIMD instructions encoded in Q. */
1350 #define F_GPRSIZE_IN_Q (1 << 10)
1351 /* Size of Rt load signed instruction encoded in opc[0], i.e. bit 22. */
1352 #define F_LDS_SIZE (1 << 11)
1353 /* Optional operand; assume maximum of 1 operand can be optional. */
1354 #define F_OPD0_OPT (1 << 12)
1355 #define F_OPD1_OPT (2 << 12)
1356 #define F_OPD2_OPT (3 << 12)
1357 #define F_OPD3_OPT (4 << 12)
1358 #define F_OPD4_OPT (5 << 12)
1359 /* Default value for the optional operand when omitted from the assembly. */
1360 #define F_DEFAULT(X) (((X) & 0x1f) << 15)
1361 /* Instruction that is an alias of another instruction needs to be
1362 encoded/decoded by converting it to/from the real form, followed by
1363 the encoding/decoding according to the rules of the real opcode.
1364 This compares to the direct coding using the alias's information.
1365 N.B. this flag requires F_ALIAS to be used together. */
1366 #define F_CONV (1 << 20)
1367 /* Use together with F_ALIAS to indicate an alias opcode is a programmer
1368 friendly pseudo instruction available only in the assembly code (thus will
1369 not show up in the disassembly). */
1370 #define F_PSEUDO (1 << 21)
1371 /* Instruction has miscellaneous encoding/decoding rules. */
1372 #define F_MISC (1 << 22)
1373 /* Instruction has the field of 'N'; used in conjunction with F_SF. */
1374 #define F_N (1 << 23)
1375 /* Opcode dependent field. */
1376 #define F_OD(X) (((X) & 0x7) << 24)
1377 /* Instruction has the field of 'sz'. */
1378 #define F_LSE_SZ (1 << 27)
1379 /* Require an exact qualifier match, even for NIL qualifiers. */
1380 #define F_STRICT (1ULL << 28)
1381 /* This system instruction is used to read system registers. */
1382 #define F_SYS_READ (1ULL << 29)
1383 /* This system instruction is used to write system registers. */
1384 #define F_SYS_WRITE (1ULL << 30)
1385 /* This instruction has an extra constraint on it that imposes a requirement on
1386 subsequent instructions. */
1387 #define F_SCAN (1ULL << 31)
1388 /* Instruction takes a pair of optional operands. If we specify the Nth operand
1389 to be optional, then we also implicitly specify (N+1)th operand to also be
1391 #define F_OPD_PAIR_OPT (1ULL << 32)
1392 /* This instruction does not allow the full range of values that the
1393 width of fields in the assembler instruction would theoretically
1394 allow. This impacts the constraintts on assembly but yelds no
1395 impact on disassembly. */
1396 #define F_OPD_NARROW (1ULL << 33)
1397 /* For the instruction with size[22:23] field. */
1398 #define F_OPD_SIZE (1ULL << 34)
1399 /* RCPC3 instruction has the field of 'size'. */
1400 #define F_RCPC3_SIZE (1ULL << 35)
1401 /* This instruction need VGx2 or VGx4 mandatorily in the operand passed to
1403 #define F_VG_REQ (1ULL << 36)
1405 /* 4-bit flag field to indicate subclass of instructions.
1406 Note the overlap between the set of subclass flags in each logical category
1407 (F_LDST_*, F_ARITH_*, F_BRANCH_* etc.); The usage of flags as
1408 iclass-specific enums is intentional. */
1409 #define F_SUBCLASS (15ULL << 37)
1411 #define F_LDST_LOAD (1ULL << 37)
1412 #define F_LDST_STORE (2ULL << 37)
1413 /* Subclasses to denote add, sub and mov insns. */
1414 #define F_ARITH_ADD (1ULL << 37)
1415 #define F_ARITH_SUB (2ULL << 37)
1416 #define F_ARITH_MOV (3ULL << 37)
1417 /* Subclasses to denote call and ret insns. */
1418 #define F_BRANCH_CALL (1ULL << 37)
1419 #define F_BRANCH_RET (2ULL << 37)
1420 /* Subclass to denote that only tag update is involved. */
1421 #define F_DP_TAG_ONLY (1ULL << 37)
1423 #define F_SUBCLASS_OTHER (F_SUBCLASS)
1424 /* Next bit is 41. */
1426 /* Instruction constraints. */
1427 /* This instruction has a predication constraint on the instruction at PC+4. */
1428 #define C_SCAN_MOVPRFX (1U << 0)
1429 /* This instruction's operation width is determined by the operand with the
1430 largest element size. */
1431 #define C_MAX_ELEM (1U << 1)
1432 #define C_SCAN_MOPS_P (1U << 2)
1433 #define C_SCAN_MOPS_M (2U << 2)
1434 #define C_SCAN_MOPS_E (3U << 2)
1435 #define C_SCAN_MOPS_PME (3U << 2)
1436 /* Next bit is 4. */
1439 alias_opcode_p (const aarch64_opcode
*opcode
)
1441 return (opcode
->flags
& F_ALIAS
) != 0;
1445 opcode_has_alias (const aarch64_opcode
*opcode
)
1447 return (opcode
->flags
& F_HAS_ALIAS
) != 0;
1450 /* Priority for disassembling preference. */
1452 opcode_priority (const aarch64_opcode
*opcode
)
1454 return (opcode
->flags
>> 2) & 0x3;
1458 pseudo_opcode_p (const aarch64_opcode
*opcode
)
1460 return (opcode
->flags
& F_PSEUDO
) != 0lu;
1463 /* Whether the opcode has the specific subclass flag.
1464 N.B. The overlap between F_LDST_*, F_ARITH_*, and F_BRANCH_* etc. subclass
1465 flags means that the callers of this function have the responsibility of
1466 checking for the flags appropriate for the specific iclass. */
1468 aarch64_opcode_subclass_p (const aarch64_opcode
*opcode
, uint64_t flag
)
1470 return ((opcode
->flags
& F_SUBCLASS
) == flag
);
1473 /* Deal with two possible scenarios: If F_OP_PAIR_OPT not set, as is the case
1474 by default, F_OPDn_OPT must equal IDX + 1, else F_OPDn_OPT must be in range
1477 optional_operand_p (const aarch64_opcode
*opcode
, unsigned int idx
)
1479 if (opcode
->flags
& F_OPD_PAIR_OPT
)
1480 return (((opcode
->flags
>> 12) & 0x7) == idx
1481 || ((opcode
->flags
>> 12) & 0x7) == idx
+ 1);
1482 return ((opcode
->flags
>> 12) & 0x7) == idx
+ 1;
1485 static inline aarch64_insn
1486 get_optional_operand_default_value (const aarch64_opcode
*opcode
)
1488 return (opcode
->flags
>> 15) & 0x1f;
1491 static inline unsigned int
1492 get_opcode_dependent_value (const aarch64_opcode
*opcode
)
1494 return (opcode
->flags
>> 24) & 0x7;
1498 get_opcode_dependent_vg_status (const aarch64_opcode
*opcode
)
1500 return (opcode
->flags
>> 36) & 0x1;
1504 opcode_has_special_coder (const aarch64_opcode
*opcode
)
1506 return (opcode
->flags
& (F_SF
| F_LSE_SZ
| F_SIZEQ
| F_FPTYPE
| F_SSIZE
| F_T
1507 | F_GPRSIZE_IN_Q
| F_LDS_SIZE
| F_MISC
| F_N
| F_COND
1508 | F_OPD_SIZE
| F_RCPC3_SIZE
)) != 0;
1511 struct aarch64_name_value_pair
1517 extern const struct aarch64_name_value_pair aarch64_operand_modifiers
[];
1518 extern const struct aarch64_name_value_pair aarch64_barrier_options
[16];
1519 extern const struct aarch64_name_value_pair aarch64_barrier_dsb_nxs_options
[4];
1520 extern const struct aarch64_name_value_pair aarch64_prfops
[32];
1521 extern const struct aarch64_name_value_pair aarch64_hint_options
[];
1523 #define AARCH64_MAX_SYSREG_NAME_LEN 32
1531 /* A set of features, all of which are required for this system register to be
1533 aarch64_feature_set features
;
1536 extern const aarch64_sys_reg aarch64_sys_regs
[];
1537 extern const aarch64_sys_reg aarch64_pstatefields
[];
1538 extern bool aarch64_sys_reg_deprecated_p (const uint32_t);
1539 extern bool aarch64_sys_reg_128bit_p (const uint32_t);
1540 extern bool aarch64_sys_reg_alias_p (const uint32_t);
1541 extern bool aarch64_pstatefield_supported_p (const aarch64_feature_set
,
1542 const aarch64_sys_reg
*);
1550 /* A set of features, all of which are required for this system instruction to be
1552 aarch64_feature_set features
;
1553 } aarch64_sys_ins_reg
;
1555 extern bool aarch64_sys_ins_reg_has_xt (const aarch64_sys_ins_reg
*);
1557 aarch64_sys_ins_reg_supported_p (const aarch64_feature_set
,
1558 const char *reg_name
,
1559 uint32_t, const aarch64_feature_set
*);
1561 extern const aarch64_sys_ins_reg aarch64_sys_regs_ic
[];
1562 extern const aarch64_sys_ins_reg aarch64_sys_regs_dc
[];
1563 extern const aarch64_sys_ins_reg aarch64_sys_regs_at
[];
1564 extern const aarch64_sys_ins_reg aarch64_sys_regs_tlbi
[];
1565 extern const aarch64_sys_ins_reg aarch64_sys_regs_sr
[];
1567 /* Shift/extending operator kinds.
1568 N.B. order is important; keep aarch64_operand_modifiers synced. */
1569 enum aarch64_modifier_kind
1590 aarch64_extend_operator_p (enum aarch64_modifier_kind
);
1592 enum aarch64_modifier_kind
1593 aarch64_get_operand_modifier (const struct aarch64_name_value_pair
*);
1598 /* A list of names with the first one as the disassembly preference;
1599 terminated by NULL if fewer than 3. */
1600 const char *names
[4];
1604 extern const aarch64_cond aarch64_conds
[16];
1606 const aarch64_cond
* get_cond_from_value (aarch64_insn value
);
1607 const aarch64_cond
* get_inverted_cond (const aarch64_cond
*cond
);
1609 /* Information about a reference to part of ZA. */
1610 struct aarch64_indexed_za
1612 /* Which tile is being accessed. Unused (and 0) for an index into ZA. */
1617 /* The 32-bit index register. */
1620 /* The first (or only) immediate offset. */
1623 /* The last immediate offset minus the first immediate offset.
1624 Unlike the range size, this is guaranteed not to overflow
1625 when the end offset > the start offset. */
1629 /* The vector group size, or 0 if none. */
1630 unsigned group_size
: 8;
1632 /* True if a tile access is vertical, false if it is horizontal.
1633 Unused (and 0) for an index into ZA. */
1637 /* Information about a list of registers. */
1638 struct aarch64_reglist
1640 unsigned first_regno
: 8;
1641 unsigned num_regs
: 8;
1642 /* The difference between the nth and the n+1th register. */
1643 unsigned stride
: 8;
1644 /* 1 if it is a list of reg element. */
1645 unsigned has_index
: 1;
1646 /* Lane index; valid only when has_index is 1. */
1650 /* Structure representing an operand. */
1652 struct aarch64_opnd_info
1654 enum aarch64_opnd type
;
1655 aarch64_opnd_qualifier_t qualifier
;
1670 struct aarch64_reglist reglist
;
1671 /* e.g. immediate or pc relative address offset. */
1677 /* e.g. address in STR (register offset). */
1680 unsigned base_regno
;
1690 unsigned pcrel
: 1; /* PC-relative. */
1691 unsigned writeback
: 1;
1692 unsigned preind
: 1; /* Pre-indexed. */
1693 unsigned postind
: 1; /* Post-indexed. */
1698 /* The encoding of the system register. */
1701 /* The system register flags. */
1705 /* ZA tile vector, e.g. <ZAn><HV>.D[<Wv>{, <imm>}] */
1706 struct aarch64_indexed_za indexed_za
;
1708 const aarch64_cond
*cond
;
1709 /* The encoding of the PSTATE field. */
1710 aarch64_insn pstatefield
;
1711 const aarch64_sys_ins_reg
*sysins_op
;
1712 const struct aarch64_name_value_pair
*barrier
;
1713 const struct aarch64_name_value_pair
*hint_option
;
1714 const struct aarch64_name_value_pair
*prfop
;
1717 /* Operand shifter; in use when the operand is a register offset address,
1718 add/sub extended reg, etc. e.g. <R><m>{, <extend> {#<amount>}}. */
1721 enum aarch64_modifier_kind kind
;
1722 unsigned operator_present
: 1; /* Only valid during encoding. */
1723 /* Value of the 'S' field in ld/st reg offset; used only in decoding. */
1724 unsigned amount_present
: 1;
1728 unsigned skip
:1; /* Operand is not completed if there is a fixup needed
1729 to be done on it. In some (but not all) of these
1730 cases, we need to tell libopcodes to skip the
1731 constraint checking and the encoding for this
1732 operand, so that the libopcodes can pick up the
1733 right opcode before the operand is fixed-up. This
1734 flag should only be used during the
1735 assembling/encoding. */
1736 unsigned present
:1; /* Whether this operand is present in the assembly
1737 line; not used during the disassembly. */
1740 typedef struct aarch64_opnd_info aarch64_opnd_info
;
1742 /* Structure representing an instruction.
1744 It is used during both the assembling and disassembling. The assembler
1745 fills an aarch64_inst after a successful parsing and then passes it to the
1746 encoding routine to do the encoding. During the disassembling, the
1747 disassembler calls the decoding routine to decode a binary instruction; on a
1748 successful return, such a structure will be filled with information of the
1749 instruction; then the disassembler uses the information to print out the
1754 /* The value of the binary instruction. */
1757 /* Corresponding opcode entry. */
1758 const aarch64_opcode
*opcode
;
1760 /* Condition for a truly conditional-executed instrutions, e.g. b.cond. */
1761 const aarch64_cond
*cond
;
1763 /* Operands information. */
1764 aarch64_opnd_info operands
[AARCH64_MAX_OPND_NUM
];
1767 /* Defining the HINT #imm values for the aarch64_hint_options. */
1768 #define HINT_OPD_CSYNC 0x11
1769 #define HINT_OPD_DSYNC 0x13
1770 #define HINT_OPD_C 0x22
1771 #define HINT_OPD_J 0x24
1772 #define HINT_OPD_JC 0x26
1773 #define HINT_OPD_NULL 0x00
1776 /* Diagnosis related declaration and interface. */
1778 /* Operand error kind enumerators.
1780 AARCH64_OPDE_RECOVERABLE
1781 Less severe error found during the parsing, very possibly because that
1782 GAS has picked up a wrong instruction template for the parsing.
1784 AARCH64_OPDE_A_SHOULD_FOLLOW_B
1785 The instruction forms (or is expected to form) part of a sequence,
1786 but the preceding instruction in the sequence wasn't the expected one.
1787 The message refers to two strings: the name of the current instruction,
1788 followed by the name of the expected preceding instruction.
1790 AARCH64_OPDE_EXPECTED_A_AFTER_B
1791 Same as AARCH64_OPDE_A_SHOULD_FOLLOW_B, but shifting the focus
1792 so that the current instruction is assumed to be the incorrect one:
1793 "since the previous instruction was B, the current one should be A".
1795 AARCH64_OPDE_SYNTAX_ERROR
1796 General syntax error; it can be either a user error, or simply because
1797 that GAS is trying a wrong instruction template.
1799 AARCH64_OPDE_FATAL_SYNTAX_ERROR
1800 Definitely a user syntax error.
1802 AARCH64_OPDE_INVALID_VARIANT
1803 No syntax error, but the operands are not a valid combination, e.g.
1806 The following errors are only reported against an asm string that is
1807 syntactically valid and that has valid operand qualifiers.
1809 AARCH64_OPDE_INVALID_VG_SIZE
1810 Error about a "VGx<n>" modifier in a ZA index not having the
1811 correct <n>. This error effectively forms a pair with
1812 AARCH64_OPDE_REG_LIST_LENGTH, since both errors relate to the number
1813 of vectors that an instruction operates on. However, the "VGx<n>"
1814 modifier is optional, whereas a register list always has a known
1815 and explicit length. It therefore seems better to place more
1816 importance on the register list length when selecting an opcode table
1817 entry. This in turn means that having an incorrect register length
1818 should be more severe than having an incorrect "VGx<n>".
1820 AARCH64_OPDE_REG_LIST_LENGTH
1821 Error about a register list operand having an unexpected number of
1822 registers. This error is low severity because there might be another
1823 opcode entry that supports the given number of registers.
1825 AARCH64_OPDE_REG_LIST_STRIDE
1826 Error about a register list operand having the correct number
1827 (and type) of registers, but an unexpected stride. This error is
1828 more severe than AARCH64_OPDE_REG_LIST_LENGTH because it implies
1829 that the length is known to be correct. However, it is lower than
1830 many other errors, since some instructions have forms that share
1831 the same number of registers but have different strides.
1833 AARCH64_OPDE_UNTIED_IMMS
1834 The asm failed to use the same immediate for a destination operand
1835 and a tied source operand.
1837 AARCH64_OPDE_UNTIED_OPERAND
1838 The asm failed to use the same register for a destination operand
1839 and a tied source operand.
1841 AARCH64_OPDE_OUT_OF_RANGE
1842 Error about some immediate value out of a valid range.
1844 AARCH64_OPDE_UNALIGNED
1845 Error about some immediate value not properly aligned (i.e. not being a
1846 multiple times of a certain value).
1848 AARCH64_OPDE_OTHER_ERROR
1849 Error of the highest severity and used for any severe issue that does not
1850 fall into any of the above categories.
1852 AARCH64_OPDE_INVALID_REGNO
1853 A register was syntactically valid and had the right type, but it was
1854 outside the range supported by the associated operand field. This is
1855 a high severity error because there are currently no instructions that
1856 would accept the operands that precede the erroneous one (if any) and
1857 yet still accept a wider range of registers.
1859 AARCH64_OPDE_RECOVERABLE, AARCH64_OPDE_SYNTAX_ERROR and
1860 AARCH64_OPDE_FATAL_SYNTAX_ERROR are only deteced by GAS while the
1861 AARCH64_OPDE_INVALID_VARIANT error can only be spotted by libopcodes as
1862 only libopcodes has the information about the valid variants of each
1865 The enumerators have an increasing severity. This is helpful when there are
1866 multiple instruction templates available for a given mnemonic name (e.g.
1867 FMOV); this mechanism will help choose the most suitable template from which
1868 the generated diagnostics can most closely describe the issues, if any.
1870 This enum needs to be kept up-to-date with operand_mismatch_kind_names
1873 enum aarch64_operand_error_kind
1876 AARCH64_OPDE_RECOVERABLE
,
1877 AARCH64_OPDE_A_SHOULD_FOLLOW_B
,
1878 AARCH64_OPDE_EXPECTED_A_AFTER_B
,
1879 AARCH64_OPDE_SYNTAX_ERROR
,
1880 AARCH64_OPDE_FATAL_SYNTAX_ERROR
,
1881 AARCH64_OPDE_INVALID_VARIANT
,
1882 AARCH64_OPDE_INVALID_VG_SIZE
,
1883 AARCH64_OPDE_REG_LIST_LENGTH
,
1884 AARCH64_OPDE_REG_LIST_STRIDE
,
1885 AARCH64_OPDE_UNTIED_IMMS
,
1886 AARCH64_OPDE_UNTIED_OPERAND
,
1887 AARCH64_OPDE_OUT_OF_RANGE
,
1888 AARCH64_OPDE_UNALIGNED
,
1889 AARCH64_OPDE_OTHER_ERROR
,
1890 AARCH64_OPDE_INVALID_REGNO
1893 /* N.B. GAS assumes that this structure work well with shallow copy. */
1894 struct aarch64_operand_error
1896 enum aarch64_operand_error_kind kind
;
1899 /* Some data for extra information. */
1907 /* AArch64 sequence structure used to track instructions with F_SCAN
1908 dependencies for both assembler and disassembler. */
1909 struct aarch64_instr_sequence
1911 /* The instructions in the sequence, starting with the one that
1912 caused it to be opened. */
1913 aarch64_inst
*instr
;
1914 /* The number of instructions already in the sequence. */
1915 int num_added_insns
;
1916 /* The number of instructions allocated to the sequence. */
1917 int num_allocated_insns
;
1920 /* Encoding entrypoint. */
1923 aarch64_opcode_encode (const aarch64_opcode
*, const aarch64_inst
*,
1924 aarch64_insn
*, aarch64_opnd_qualifier_t
*,
1925 aarch64_operand_error
*, aarch64_instr_sequence
*);
1927 extern const aarch64_opcode
*
1928 aarch64_replace_opcode (struct aarch64_inst
*,
1929 const aarch64_opcode
*);
1931 /* Given the opcode enumerator OP, return the pointer to the corresponding
1934 extern const aarch64_opcode
*
1935 aarch64_get_opcode (enum aarch64_op
);
1937 /* An instance of this structure is passed to aarch64_print_operand, and
1938 the callback within this structure is used to apply styling to the
1939 disassembler output. This structure encapsulates the callback and a
1942 struct aarch64_styler
1944 /* The callback used to apply styling. Returns a string created from FMT
1945 and ARGS with STYLE applied to the string. STYLER is a pointer back
1946 to this object so that the callback can access the state member.
1948 The string returned from this callback must remain valid until the
1949 call to aarch64_print_operand has completed. */
1950 const char *(*apply_style
) (struct aarch64_styler
*styler
,
1951 enum disassembler_style style
,
1955 /* A pointer to a state object which can be used by the apply_style
1956 callback function. */
1960 /* Generate the string representation of an operand. */
1962 aarch64_print_operand (char *, size_t, bfd_vma
, const aarch64_opcode
*,
1963 const aarch64_opnd_info
*, int, int *, bfd_vma
*,
1964 char **, char *, size_t,
1965 aarch64_feature_set features
,
1966 struct aarch64_styler
*styler
);
1968 /* Miscellaneous interface. */
1971 aarch64_operand_index (const enum aarch64_opnd
*, enum aarch64_opnd
);
1973 extern aarch64_opnd_qualifier_t
1974 aarch64_get_expected_qualifier (const aarch64_opnd_qualifier_seq_t
*, int,
1975 const aarch64_opnd_qualifier_t
, int);
1978 aarch64_is_destructive_by_operands (const aarch64_opcode
*);
1981 aarch64_num_of_operands (const aarch64_opcode
*);
1984 aarch64_stack_pointer_p (const aarch64_opnd_info
*);
1987 aarch64_zero_register_p (const aarch64_opnd_info
*);
1989 extern enum err_type
1990 aarch64_decode_insn (aarch64_insn
, aarch64_inst
*, bool,
1991 aarch64_operand_error
*);
1994 init_insn_sequence (const struct aarch64_inst
*, aarch64_instr_sequence
*);
1996 /* Given an operand qualifier, return the expected data element size
1997 of a qualified operand. */
1998 extern unsigned char
1999 aarch64_get_qualifier_esize (aarch64_opnd_qualifier_t
);
2001 extern enum aarch64_operand_class
2002 aarch64_get_operand_class (enum aarch64_opnd
);
2005 aarch64_get_operand_name (enum aarch64_opnd
);
2008 aarch64_get_operand_desc (enum aarch64_opnd
);
2011 aarch64_sve_dupm_mov_immediate_p (uint64_t, int);
2014 aarch64_cpu_supports_inst_p (aarch64_feature_set
, aarch64_inst
*);
2017 calc_ldst_datasize (const aarch64_opnd_info
*opnds
);
2019 #ifdef DEBUG_AARCH64
2020 extern int debug_dump
;
2023 aarch64_verbose (const char *, ...) __attribute__ ((format (printf
, 1, 2)));
2025 #define DEBUG_TRACE(M, ...) \
2028 aarch64_verbose ("%s: " M ".", __func__, ##__VA_ARGS__); \
2031 #define DEBUG_TRACE_IF(C, M, ...) \
2033 if (debug_dump && (C)) \
2034 aarch64_verbose ("%s: " M ".", __func__, ##__VA_ARGS__); \
2036 #else /* !DEBUG_AARCH64 */
2037 #define DEBUG_TRACE(M, ...) ;
2038 #define DEBUG_TRACE_IF(C, M, ...) ;
2039 #endif /* DEBUG_AARCH64 */
2041 extern const char *const aarch64_sve_pattern_array
[32];
2042 extern const char *const aarch64_sve_prfop_array
[16];
2043 extern const char *const aarch64_rprfmop_array
[64];
2044 extern const char *const aarch64_sme_vlxn_array
[2];
2045 extern const char *const aarch64_brbop_array
[2];
2051 #endif /* OPCODE_AARCH64_H */