1 @c Copyright (C) 2009-2024 Free Software Foundation, Inc.
2 @c Contributed by ARM Ltd.
3 @c This is part of the GAS manual.
4 @c For copying conditions, see the file as.texinfo.
9 @node AArch64-Dependent
10 @chapter AArch64 Dependent Features
14 @node Machine Dependencies
15 @chapter AArch64 Dependent Features
18 @cindex AArch64 support
20 * AArch64 Options:: Options
21 * AArch64 Extensions:: Extensions
22 * AArch64 Syntax:: Syntax
23 * AArch64 Floating Point:: Floating Point
24 * AArch64 Directives:: AArch64 Machine Directives
25 * AArch64 Opcodes:: Opcodes
26 * AArch64 Mapping Symbols:: Mapping Symbols
31 @cindex AArch64 options (none)
32 @cindex options for AArch64 (none)
37 @cindex @option{-EB} command-line option, AArch64
39 This option specifies that the output generated by the assembler should
40 be marked as being encoded for a big-endian processor.
42 @cindex @option{-EL} command-line option, AArch64
44 This option specifies that the output generated by the assembler should
45 be marked as being encoded for a little-endian processor.
47 @cindex @option{-mabi=} command-line option, AArch64
49 Specify which ABI the source code uses. The recognized arguments
50 are: @code{ilp32} and @code{lp64}, which decides the generated object
51 file in ELF32 and ELF64 format respectively. The default is @code{lp64}.
53 @cindex @option{-mcpu=} command-line option, AArch64
54 @item -mcpu=@var{processor}[+@var{extension}@dots{}]
55 This option specifies the target processor. The assembler will issue an error
56 message if an attempt is made to assemble an instruction which will not execute
57 on the target processor. The following processor names are recognized:
97 The special name @code{all} may be used to allow the assembler to accept
98 instructions valid for any supported processor, including all optional
101 In addition to the basic instruction set, the assembler can be told to
102 accept, or restrict, various extension mnemonics that extend the
103 processor. @xref{AArch64 Extensions}.
105 If some implementations of a particular processor can have an
106 extension, then then those extensions are automatically enabled.
107 Consequently, you will not normally have to specify any additional
110 @cindex @option{-march=} command-line option, AArch64
111 @item -march=@var{architecture}[+@var{extension}@dots{}]
112 This option specifies the target architecture. The assembler will
113 issue an error message if an attempt is made to assemble an
114 instruction which will not execute on the target architecture. The
115 following architecture names are recognized: @code{armv8-a},
116 @code{armv8.1-a}, @code{armv8.2-a}, @code{armv8.3-a}, @code{armv8.4-a}
117 @code{armv8.5-a}, @code{armv8.6-a}, @code{armv8.7-a}, @code{armv8.8-a},
118 @code{armv8.9-a}, @code{armv8-r}, @code{armv9-a}, @code{armv9.1-a},
119 @code{armv9.2-a}, @code{armv9.3-a}, @code{armv9.4-a} and @code{armv9.5-a}.
121 If both @option{-mcpu} and @option{-march} are specified, the
122 assembler will use the setting for @option{-mcpu}. If neither are
123 specified, the assembler will default to @option{-mcpu=all}.
125 The architecture option can be extended with the same instruction set
126 extension options as the @option{-mcpu} option. Unlike
127 @option{-mcpu}, extensions are not always enabled by default.
128 @xref{AArch64 Extensions}.
130 @cindex @code{-mverbose-error} command-line option, AArch64
131 @item -mverbose-error
132 This option enables verbose error messages for AArch64 gas. This option
133 is enabled by default.
135 @cindex @code{-mno-verbose-error} command-line option, AArch64
136 @item -mno-verbose-error
137 This option disables verbose error messages in AArch64 gas.
142 @node AArch64 Extensions
143 @section Architecture Extensions
145 The tables below lists the permitted architecture extensions and architecture
146 versions that are supported by the assembler, including a brief description and
147 a list of other extensions that they depend upon.
149 Multiple extensions may be specified, separated by a @code{+}.
150 Extension mnemonics may also be removed from those the assembler
151 accepts. This is done by prepending @code{no} to the option that adds
152 the extension. Extensions that are removed must be listed after all
153 extensions that have been added.
155 Enabling an extension that depends upon other extensions (either directly or
156 recursively) will automatically cause those extensions to be enabled.
157 Similarly, disabling an extension that is required by other extensions will
158 automatically cause those extensions to be disabled.
160 @multitable @columnfractions .16 .22 .62
161 @headitem Extension @tab Depends upon @tab Description
162 @item @code{aes} @tab @code{simd}
163 @tab Enable the AES and PMULL cryptographic extensions.
164 @c @item @code{b16b16} @tab @code{sve2}
165 @c @tab Enable BFloat16 to BFloat16 arithmetic for SVE2 and SME2.
166 @item @code{bf16} @tab @code{fp}
167 @tab Enable BFloat16 extension.
168 @item @code{brbe} @tab
169 @tab Enable the Branch Record Buffer extension.
170 @item @code{chk} @tab
171 @tab Enable the Check Feature Status Extension.
172 @item @code{compnum} @tab @code{simd}
173 @tab Enable the complex number SIMD extensions. An alias of @code{fcma}.
174 @item @code{cpa} @tab
175 @tab Enable the Checked Pointer Arithmetic extension.
176 @item @code{crc} @tab
177 @tab Enable CRC instructions.
178 @item @code{crypto} @tab @code{simd}
179 @tab Enable cryptographic extensions. This is equivalent to @code{aes+sha2}.
180 @item @code{cssc} @tab
181 @tab Enable the Armv8.9-A Common Short Sequence Compression instructions.
182 @item @code{d128} @tab @code{lse128}
183 @tab Enable the 128-bit Page Descriptor Extension. This implies @code{lse128}.
184 @item @code{dotprod} @tab @code{simd}
185 @tab Enable the Dot Product extension.
186 @item @code{f32mm} @tab @code{sve}
187 @tab Enable the F32 Matrix Multiply extension
188 @item @code{f64mm} @tab @code{sve}
189 @tab Enable the F64 Matrix Multiply extension.
190 @item @code{fcma} @tab @code{fp16}, @code{simd}
191 @tab Enable the complex number SIMD extensions.
192 @item @code{flagm} @tab
193 @tab Enable Flag Manipulation instructions.
194 @item @code{flagm2} @tab @code{flagm}
195 @tab Enable FlagM2 flag conversion instructions.
197 @tab Enable floating-point extensions.
198 @item @code{fp8} @tab
199 @tab Enable the Floating Point 8 (FP8) extension.
200 @item @code{fp8dot2} @tab @code{fp8dot4}
201 @tab Enable the FP8 2-way dot product instructions.
202 @item @code{fp8dot4} @tab @code{fp8fma}
203 @tab Enable the FP8 4-way dot product instructions.
204 @item @code{fp8fma} @tab @code{fp8}
205 @tab Enable the FP8 FMA instructions.
206 @item @code{fp16fml} @tab @code{fp16}
207 @tab Enable Armv8.2 16-bit floating-point multiplication variant support.
208 @item @code{fp16} @tab @code{fp}
209 @tab Enable Armv8.2 16-bit floating-point support.
210 @item @code{frintts} @tab @code{simd}
211 @tab Enable floating-point round to integral value instructions.
212 @item @code{gcs} @tab
213 @tab Enable the Guarded Control Stack Extension.
214 @item @code{hbc} @tab
215 @tab Enable Armv8.8-A hinted conditional branch instructions
216 @item @code{i8mm} @tab @code{simd}
217 @tab Enable the Int8 Matrix Multiply extension.
218 @item @code{ite} @tab
219 @tab Enable the TRCIT instruction.
220 @item @code{jscvt} @tab @code{fp}
221 @tab Enable the @code{fjcvtzs} JavaScript conversion instruction.
222 @item @code{lor} @tab
223 @tab Enable Limited Ordering Regions extensions.
224 @item @code{ls64} @tab
225 @tab Enable the 64 Byte Loads/Stores extensions.
226 @item @code{lse} @tab
227 @tab Enable Large System extensions.
228 @item @code{lse128} @tab @code{lse}
229 @tab Enable the 128-bit Atomic Instructions extension.
230 @item @code{lut} @tab
231 @tab Enable the Lookup Table (LUT) extension.
232 @item @code{memtag} @tab
233 @tab Enable Armv8.5-A Memory Tagging Extensions.
234 @item @code{mops} @tab
235 @tab Enable Armv8.8-A memcpy and memset acceleration instructions
236 @item @code{pan} @tab
237 @tab Enable Privileged Access Never support.
238 @item @code{pauth} @tab
239 @tab Enable Pointer Authentication.
240 @item @code{predres} @tab
241 @tab Enable the Execution and Data and Prediction instructions.
242 @item @code{predres2} @tab @code{predres}
243 @tab Enable Prediction instructions.
244 @item @code{profile} @tab
245 @tab Enable statistical profiling extensions.
246 @item @code{ras} @tab
247 @tab Enable the Reliability, Availability and Serviceability extension.
248 @item @code{rasv2} @tab @code{ras}
249 @tab Enable the Reliability, Availability and Serviceability extension v2.
250 @item @code{rcpc} @tab
251 @tab Enable the Load-Acquire RCpc instructions extension.
252 @item @code{rcpc2} @tab @code{rcpc}
253 @tab Enable the Load-Acquire RCpc instructions extension v2.
254 @item @code{rcpc3} @tab @code{rcpc2}
255 @tab Enable the Load-Acquire RCpc instructions extension v3.
256 @item @code{rdma} @tab @code{simd}
257 @tab Enable rounding doubling multiply accumulate instructions.
258 @item @code{rdm} @tab @code{simd}
259 @tab An alias of @code{rdma}.
260 @item @code{rng} @tab
261 @tab Enable Armv8.5-A random number instructions.
263 @tab Enable the speculation barrier instruction sb.
264 @item @code{sha2} @tab @code{simd}
265 @tab Enable the SHA1 and SHA256 cryptographic extensions.
266 @item @code{sha3} @tab @code{sha2}
267 @tab Enable the SHA512 and SHA3 cryptographic extensions.
268 @item @code{simd} @tab @code{fp}
269 @tab Enable Advanced SIMD extensions.
270 @item @code{sm4} @tab @code{simd}
271 @tab Enable the SM3 and SM4 cryptographic extensions.
272 @item @code{sme} @tab @code{sve2}, @code{bf16}
273 @tab Enable the Scalable Matrix Extension.
274 @item @code{sme-f8f16} @tab @code{sme-f8f32}
275 @tab Enable the SME F8F16 Extension.
276 @item @code{sme-f8f32} @tab @code{sme2}, @code{fp8}
277 @tab Enable the SME F8F32 Extension.
278 @item @code{sme-f64f64} @tab @code{sme}
279 @tab Enable SME F64F64 Extension.
280 @item @code{sme-i16i64} @tab @code{sme}
281 @tab Enable SME I16I64 Extension.
282 @item @code{sme-lutv2} @tab
283 @tab Enable SME Lookup Table v2 (LUTv2) extension.
284 @item @code{sme2} @tab @code{sme}
286 @item @code{sme2p1} @tab @code{sme2}
288 @item @code{ssbs} @tab
289 @tab Enable Speculative Store Bypassing Safe state read and write.
290 @item @code{ssve-fp8dot2} @tab @code{ssve-fp8dot4}
291 @tab Enable the Streaming SVE FP8 2-way dot product instructions. These can also be enabled using @code{+fp8dot2+sme2}.
292 @item @code{ssve-fp8dot4} @tab @code{ssve-fp8fma}
293 @tab Enable the Streaming SVE FP8 4-way dot product instructions. These can also be enabled using @code{+fp8dot4+sme2}.
294 @item @code{ssve-fp8fma} @tab @code{sme2}, @code{fp8}
295 @tab Enable the Streaming SVE FP8 FMA instructions. These can also be enabled using @code{+fp8fma+sme2}.
296 @item @code{sve} @tab @code{fcma}
297 @tab Enable the Scalable Vector Extension.
298 @item @code{sve2} @tab @code{sve}
300 @item @code{sve2-aes} @tab @code{sve2}, @code{aes}
301 @tab Enable the SVE2 AES and PMULL Extensions.
302 @item @code{sve2-bitperm} @tab @code{sve2}
303 @tab Enable the SVE2 BITPERM Extension.
304 @item @code{sve2-sha3} @tab @code{sve2}, @code{sha3}
305 @tab Enable the SVE2 SHA3 Extension.
306 @item @code{sve2-sm4} @tab @code{sve2}, @code{sm4}
307 @tab Enable the SVE2 SM4 Extension.
308 @item @code{sve2p1} @tab @code{sve2}
310 @item @code{the} @tab
311 @tab Enable the Translation Hardening Extension.
312 @item @code{tme} @tab
313 @tab Enable the Transactional Memory Extension.
314 @item @code{wfxt} @tab
315 @tab Enable @code{wfet} and @code{wfit} instructions.
317 @tab Enable the XS memory attribute extension.
320 @multitable @columnfractions .20 .80
321 @headitem Architecture Version @tab Includes
322 @item @code{armv8-a} @tab @code{simd}, @code{chk}, @code{ras}
323 @item @code{armv8.1-a} @tab @code{armv8-a}, @code{crc}, @code{lse}, @code{rdma}, @code{pan}, @code{lor}
324 @item @code{armv8.2-a} @tab @code{armv8.1-a}
325 @item @code{armv8.3-a} @tab @code{armv8.2-a}, @code{fcma}, @code{jscvt}, @code{pauth}, @code{rcpc}
326 @item @code{armv8.4-a} @tab @code{armv8.3-a}, @code{fp16fml}, @code{dotprod}, @code{flagm}, @code{rcpc2}
327 @item @code{armv8.5-a} @tab @code{armv8.4-a}, @code{frintts}, @code{flagm2}, @code{predres}, @code{sb}, @code{ssbs}
328 @item @code{armv8.6-a} @tab @code{armv8.5-a}, @code{bf16}, @code{i8mm}
329 @item @code{armv8.7-a} @tab @code{armv8.6-a}, @code{ls64}, @code{xs}, @code{wfxt}
330 @item @code{armv8.8-a} @tab @code{armv8.7-a}, @code{hbc}, @code{mops}
331 @item @code{armv8.9-a} @tab @code{armv8.8-a}, @code{rasv2}, @code{predres2}
332 @item @code{armv9-a} @tab @code{armv8.5-a}, @code{sve2}
333 @item @code{armv9.1-a} @tab @code{armv9-a}, @code{armv8.6-a}
334 @item @code{armv9.2-a} @tab @code{armv9.1-a}, @code{armv8.7-a}
335 @item @code{armv9.3-a} @tab @code{armv9.2-a}, @code{armv8.8-a}
336 @item @code{armv9.4-a} @tab @code{armv9.3-a}, @code{armv8.9-a}
337 @item @code{armv9.5-a} @tab @code{armv9.4-a}, @code{cpa}, @code{lut}, @code{faminmax}
338 @item @code{armv8-r} @tab @code{armv8.4-a+nolor}
344 * AArch64-Chars:: Special Characters
345 * AArch64-Regs:: Register Names
346 * AArch64-Relocations:: Relocations
350 @subsection Special Characters
352 @cindex line comment character, AArch64
353 @cindex AArch64 line comment character
354 The presence of a @samp{//} on a line indicates the start of a comment
355 that extends to the end of the current line. If a @samp{#} appears as
356 the first character of a line, the whole line is treated as a comment.
358 @cindex line separator, AArch64
359 @cindex statement separator, AArch64
360 @cindex AArch64 line separator
361 The @samp{;} character can be used instead of a newline to separate
364 @cindex immediate character, AArch64
365 @cindex AArch64 immediate character
366 The @samp{#} can be optionally used to indicate immediate operands.
369 @subsection Register Names
371 @cindex AArch64 register names
372 @cindex register names, AArch64
373 Please refer to the section @samp{4.4 Register Names} of
374 @samp{ARMv8 Instruction Set Overview}, which is available at
375 @uref{http://infocenter.arm.com}.
377 @node AArch64-Relocations
378 @subsection Relocations
380 @cindex relocations, AArch64
381 @cindex AArch64 relocations
382 @cindex MOVN, MOVZ and MOVK group relocations, AArch64
383 Relocations for @samp{MOVZ} and @samp{MOVK} instructions can be generated
384 by prefixing the label with @samp{#:abs_g2:} etc.
385 For example to load the 48-bit absolute address of @var{foo} into x0:
388 movz x0, #:abs_g2:foo // bits 32-47, overflow check
389 movk x0, #:abs_g1_nc:foo // bits 16-31, no overflow check
390 movk x0, #:abs_g0_nc:foo // bits 0-15, no overflow check
393 @cindex ADRP, ADD, LDR/STR group relocations, AArch64
394 Relocations for @samp{ADRP}, and @samp{ADD}, @samp{LDR} or @samp{STR}
395 instructions can be generated by prefixing the label with
396 @samp{:pg_hi21:} and @samp{#:lo12:} respectively.
398 For example to use 33-bit (+/-4GB) pc-relative addressing to
399 load the address of @var{foo} into x0:
402 adrp x0, :pg_hi21:foo
403 add x0, x0, #:lo12:foo
406 Or to load the value of @var{foo} into x0:
409 adrp x0, :pg_hi21:foo
410 ldr x0, [x0, #:lo12:foo]
413 Note that @samp{:pg_hi21:} is optional.
422 adrp x0, :pg_hi21:foo
425 @node AArch64 Floating Point
426 @section Floating Point
428 @cindex floating point, AArch64 (@sc{ieee})
429 @cindex AArch64 floating point (@sc{ieee})
430 The AArch64 architecture uses @sc{ieee} floating-point numbers.
432 @node AArch64 Directives
433 @section AArch64 Machine Directives
435 @cindex machine directives, AArch64
436 @cindex AArch64 machine directives
439 @c AAAAAAAAAAAAAAAAAAAAAAAAA
441 @cindex @code{.arch} directive, AArch64
442 @item .arch @var{name}
443 Select the target architecture. Valid values for @var{name} are the same as
444 for the @option{-march} command-line option.
446 Specifying @code{.arch} clears any previously selected architecture
449 @cindex @code{.arch_extension} directive, AArch64
450 @item .arch_extension @var{name}
451 Add or remove an architecture extension to the target architecture. Valid
452 values for @var{name} are the same as those accepted as architectural
453 extensions by the @option{-mcpu} command-line option.
455 @code{.arch_extension} may be used multiple times to add or remove extensions
456 incrementally to the architecture being compiled for.
458 @c BBBBBBBBBBBBBBBBBBBBBBBBBB
459 @c CCCCCCCCCCCCCCCCCCCCCCCCCC
461 @cindex @code{.cpu} directive, AArch64
462 @item .cpu @var{name}
463 Set the target processor. Valid values for @var{name} are the same as
464 those accepted by the @option{-mcpu=} command-line option.
466 @c DDDDDDDDDDDDDDDDDDDDDDDDDD
468 @cindex @code{.dword} directive, AArch64
469 @item .dword @var{expressions}
470 The @code{.dword} directive produces 64 bit values.
472 @c EEEEEEEEEEEEEEEEEEEEEEEEEE
474 @cindex @code{.even} directive, AArch64
476 The @code{.even} directive aligns the output on the next even byte
479 @c FFFFFFFFFFFFFFFFFFFFFFFFFF
481 @cindex @code{.float16} directive, AArch64
482 @item .float16 @var{value [,...,value_n]}
483 Place the half precision floating point representation of one or more
484 floating-point values into the current section.
485 The format used to encode the floating point values is always the
486 IEEE 754-2008 half precision floating point format.
488 @c GGGGGGGGGGGGGGGGGGGGGGGGGG
489 @c HHHHHHHHHHHHHHHHHHHHHHHHHH
490 @c IIIIIIIIIIIIIIIIIIIIIIIIII
492 @cindex @code{.inst} directive, AArch64
493 @item .inst @var{expressions}
494 Inserts the expressions into the output as if they were instructions,
497 @c JJJJJJJJJJJJJJJJJJJJJJJJJJ
498 @c KKKKKKKKKKKKKKKKKKKKKKKKKK
499 @c LLLLLLLLLLLLLLLLLLLLLLLLLL
501 @cindex @code{.ltorg} directive, AArch64
503 This directive causes the current contents of the literal pool to be
504 dumped into the current section (which is assumed to be the .text
505 section) at the current location (aligned to a word boundary).
506 GAS maintains a separate literal pool for each section and each
507 sub-section. The @code{.ltorg} directive will only affect the literal
508 pool of the current section and sub-section. At the end of assembly
509 all remaining, un-empty literal pools will automatically be dumped.
511 Note - older versions of GAS would dump the current literal
512 pool any time a section change occurred. This is no longer done, since
513 it prevents accurate control of the placement of literal pools.
515 @c MMMMMMMMMMMMMMMMMMMMMMMMMM
517 @c NNNNNNNNNNNNNNNNNNNNNNNNNN
518 @c OOOOOOOOOOOOOOOOOOOOOOOOOO
520 @c PPPPPPPPPPPPPPPPPPPPPPPPPP
522 @cindex @code{.pool} directive, AArch64
524 This is a synonym for .ltorg.
526 @c QQQQQQQQQQQQQQQQQQQQQQQQQQ
527 @c RRRRRRRRRRRRRRRRRRRRRRRRRR
529 @cindex @code{.req} directive, AArch64
530 @item @var{name} .req @var{register name}
531 This creates an alias for @var{register name} called @var{name}. For
538 ip0, ip1, lr and fp are automatically defined to
539 alias to X16, X17, X30 and X29 respectively.
541 @c SSSSSSSSSSSSSSSSSSSSSSSSSS
543 @c TTTTTTTTTTTTTTTTTTTTTTTTTT
545 @cindex @code{.tlsdescadd} directive, AArch64
546 @item @code{.tlsdescadd}
547 Emits a TLSDESC_ADD reloc on the next instruction.
549 @cindex @code{.tlsdesccall} directive, AArch64
550 @item @code{.tlsdesccall}
551 Emits a TLSDESC_CALL reloc on the next instruction.
553 @cindex @code{.tlsdescldr} directive, AArch64
554 @item @code{.tlsdescldr}
555 Emits a TLSDESC_LDR reloc on the next instruction.
557 @c UUUUUUUUUUUUUUUUUUUUUUUUUU
559 @cindex @code{.unreq} directive, AArch64
560 @item .unreq @var{alias-name}
561 This undefines a register alias which was previously defined using the
562 @code{req} directive. For example:
569 An error occurs if the name is undefined. Note - this pseudo op can
570 be used to delete builtin in register name aliases (eg 'w0'). This
571 should only be done if it is really necessary.
573 @c VVVVVVVVVVVVVVVVVVVVVVVVVV
575 @cindex @code{.variant_pcs} directive, AArch64
576 @item .variant_pcs @var{symbol}
577 This directive marks @var{symbol} referencing a function that may
578 follow a variant procedure call standard with different register
579 usage convention from the base procedure call standard.
581 @c WWWWWWWWWWWWWWWWWWWWWWWWWW
582 @c XXXXXXXXXXXXXXXXXXXXXXXXXX
584 @cindex @code{.xword} directive, AArch64
585 @item .xword @var{expressions}
586 The @code{.xword} directive produces 64 bit values. This is the same
587 as the @code{.dword} directive.
589 @c YYYYYYYYYYYYYYYYYYYYYYYYYY
590 @c ZZZZZZZZZZZZZZZZZZZZZZZZZZ
592 @cindex @code{.cfi_b_key_frame} directive, AArch64
593 @item @code{.cfi_b_key_frame}
594 The @code{.cfi_b_key_frame} directive inserts a 'B' character into the CIE
595 corresponding to the current frame's FDE, meaning that its return address has
596 been signed with the B-key. If two frames are signed with differing keys then
597 they will not share the same CIE. This information is intended to be used by
598 the stack unwinder in order to properly authenticate return addresses.
602 @node AArch64 Opcodes
605 @cindex AArch64 opcodes
606 @cindex opcodes for AArch64
607 GAS implements all the standard AArch64 opcodes. It also
608 implements several pseudo opcodes, including several synthetic load
613 @cindex @code{LDR reg,=<expr>} pseudo op, AArch64
616 ldr <register> , =<expression>
619 The constant expression will be placed into the nearest literal pool (if it not
620 already there) and a PC-relative LDR instruction will be generated.
624 For more information on the AArch64 instruction set and assembly language
625 notation, see @samp{ARMv8 Instruction Set Overview} available at
626 @uref{http://infocenter.arm.com}.
629 @node AArch64 Mapping Symbols
630 @section Mapping Symbols
632 The AArch64 ELF specification requires that special symbols be inserted
633 into object files to mark certain features:
639 At the start of a region of code containing AArch64 instructions.
643 At the start of a region of data.