]> Git Repo - binutils.git/blame - gas/doc/c-aarch64.texi
Add assembler and disassembler support for the new Armv8.4-a instructions for AArch64.
[binutils.git] / gas / doc / c-aarch64.texi
CommitLineData
2571583a 1@c Copyright (C) 2009-2017 Free Software Foundation, Inc.
a06ea964
NC
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.
5@c man end
6
7@ifset GENERIC
8@page
9@node AArch64-Dependent
10@chapter AArch64 Dependent Features
11@end ifset
12
13@ifclear GENERIC
14@node Machine Dependencies
15@chapter AArch64 Dependent Features
16@end ifclear
17
18@cindex AArch64 support
a06ea964
NC
19@menu
20* AArch64 Options:: Options
df359aa7 21* AArch64 Extensions:: Extensions
a06ea964
NC
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
27@end menu
28
29@node AArch64 Options
30@section Options
31@cindex AArch64 options (none)
32@cindex options for AArch64 (none)
33
34@c man begin OPTIONS
35@table @gcctabopt
36
df359aa7 37@cindex @option{-EB} command line option, AArch64
a06ea964
NC
38@item -EB
39This option specifies that the output generated by the assembler should
40be marked as being encoded for a big-endian processor.
41
df359aa7 42@cindex @option{-EL} command line option, AArch64
a06ea964
NC
43@item -EL
44This option specifies that the output generated by the assembler should
45be marked as being encoded for a little-endian processor.
46
df359aa7 47@cindex @option{-mabi=} command line option, AArch64
69091a2c
YZ
48@item -mabi=@var{abi}
49Specify which ABI the source code uses. The recognized arguments
50are: @code{ilp32} and @code{lp64}, which decides the generated object
51file in ELF32 and ELF64 format respectively. The default is @code{lp64}.
52
df359aa7
RE
53@cindex @option{-mcpu=} command line option, AArch64
54@item -mcpu=@var{processor}[+@var{extension}@dots{}]
55This option specifies the target processor. The assembler will issue an error
56message if an attempt is made to assemble an instruction which will not execute
57on the target processor. The following processor names are recognized:
9c352f1c 58@code{cortex-a35},
df359aa7 59@code{cortex-a53},
1e292627 60@code{cortex-a55},
df359aa7 61@code{cortex-a57},
2abdd192 62@code{cortex-a72},
1aa70332 63@code{cortex-a73},
1e292627 64@code{cortex-a75},
2412d878 65@code{exynos-m1},
2fe9c2a0 66@code{falkor},
6b21c2bf 67@code{qdf24xx},
7605d944 68@code{saphira},
55fbd992 69@code{thunderx},
0a8be2fe 70@code{vulcan},
0a9ce86d 71@code{xgene1}
df359aa7 72and
0a9ce86d 73@code{xgene2}.
df359aa7
RE
74The special name @code{all} may be used to allow the assembler to accept
75instructions valid for any supported processor, including all optional
76extensions.
77
78In addition to the basic instruction set, the assembler can be told to
79accept, or restrict, various extension mnemonics that extend the
80processor. @xref{AArch64 Extensions}.
81
82If some implementations of a particular processor can have an
83extension, then then those extensions are automatically enabled.
84Consequently, you will not normally have to specify any additional
85extensions.
86
87@cindex @option{-march=} command line option, AArch64
88@item -march=@var{architecture}[+@var{extension}@dots{}]
89This option specifies the target architecture. The assembler will
90issue an error message if an attempt is made to assemble an
91instruction which will not execute on the target architecture. The
acb787b0 92following architecture names are recognized: @code{armv8-a},
1924ff75 93@code{armv8.1-a}, @code{armv8.2-a} and @code{armv8.3-a}.
df359aa7
RE
94
95If both @option{-mcpu} and @option{-march} are specified, the
96assembler will use the setting for @option{-mcpu}. If neither are
97specified, the assembler will default to @option{-mcpu=all}.
98
99The architecture option can be extended with the same instruction set
100extension options as the @option{-mcpu} option. Unlike
101@option{-mcpu}, extensions are not always enabled by default,
102@xref{AArch64 Extensions}.
103
a52e6fd3
YZ
104@cindex @code{-mverbose-error} command line option, AArch64
105@item -mverbose-error
106This option enables verbose error messages for AArch64 gas. This option
107is enabled by default.
108
109@cindex @code{-mno-verbose-error} command line option, AArch64
110@item -mno-verbose-error
111This option disables verbose error messages in AArch64 gas.
112
a06ea964
NC
113@end table
114@c man end
115
df359aa7
RE
116@node AArch64 Extensions
117@section Architecture Extensions
118
119The table below lists the permitted architecture extensions that are
120supported by the assembler and the conditions under which they are
121automatically enabled.
122
123Multiple extensions may be specified, separated by a @code{+}.
124Extension mnemonics may also be removed from those the assembler
125accepts. This is done by prepending @code{no} to the option that adds
126the extension. Extensions that are removed must be listed after all
127extensions that have been added.
128
129Enabling an extension that requires other extensions will
130automatically cause those extensions to be enabled. Similarly,
131disabling an extension that is required by other extensions will
132automatically cause those extensions to be disabled.
133
134@multitable @columnfractions .12 .17 .17 .54
135@headitem Extension @tab Minimum Architecture @tab Enabled by default
136 @tab Description
f482d304
RS
137@item @code{compnum} @tab ARMv8.2-A @tab ARMv8.3-A or later
138 @tab Enable the complex number SIMD extensions. This implies
139 @code{fp16} and @code{simd}.
af117b3c 140@item @code{crc} @tab ARMv8-A @tab ARMv8.1-A or later
df359aa7
RE
141 @tab Enable CRC instructions.
142@item @code{crypto} @tab ARMv8-A @tab No
143 @tab Enable cryptographic extensions. This implies @code{fp} and @code{simd}.
144@item @code{fp} @tab ARMv8-A @tab ARMv8-A or later
145 @tab Enable floating-point extensions.
87018195
MW
146@item @code{fp16} @tab ARMv8.2-A @tab ARMv8.2-A or later
147 @tab Enable ARMv8.2 16-bit floating-point support. This implies
148 @code{fp}.
b607cde1
JG
149@item @code{lor} @tab ARMv8-A @tab ARMv8.1-A or later
150 @tab Enable Limited Ordering Regions extensions.
151@item @code{lse} @tab ARMv8-A @tab ARMv8.1-A or later
152 @tab Enable Large System extensions.
153@item @code{pan} @tab ARMv8-A @tab ARMv8.1-A or later
154 @tab Enable Privileged Access Never support.
73af8ed6
MW
155@item @code{profile} @tab ARMv8.2-A @tab No
156 @tab Enable statistical profiling extensions.
50cc854c
MW
157@item @code{ras} @tab ARMv8-A @tab ARMv8.2-A or later
158 @tab Enable the Reliability, Availability and Serviceability
159 extension.
01cca2f9
SN
160@item @code{rcpc} @tab ARMv8.2-A @tab ARMv8.3-A or later
161 @tab Enable the weak release consistency extension.
b607cde1
JG
162@item @code{rdma} @tab ARMv8-A @tab ARMv8.1-A or later
163 @tab Enable ARMv8.1 Advanced SIMD extensions. This implies @code{simd}.
164@item @code{simd} @tab ARMv8-A @tab ARMv8-A or later
165 @tab Enable Advanced SIMD extensions. This implies @code{fp}.
582e12bf
RS
166@item @code{sve} @tab ARMv8.2-A @tab No
167 @tab Enable the Scalable Vector Extensions. This implies @code{fp16},
168 @code{simd} and @code{compnum}.
65a55fbb
TC
169@item @code{dotprod} @tab ARMv8.2-A @tab No
170 @tab Enable the Dot Product extension. This implies @code{simd}.
df359aa7
RE
171@end multitable
172
a06ea964
NC
173@node AArch64 Syntax
174@section Syntax
175@menu
176* AArch64-Chars:: Special Characters
177* AArch64-Regs:: Register Names
178* AArch64-Relocations:: Relocations
179@end menu
180
181@node AArch64-Chars
182@subsection Special Characters
183
184@cindex line comment character, AArch64
185@cindex AArch64 line comment character
186The presence of a @samp{//} on a line indicates the start of a comment
187that extends to the end of the current line. If a @samp{#} appears as
188the first character of a line, the whole line is treated as a comment.
189
190@cindex line separator, AArch64
191@cindex statement separator, AArch64
192@cindex AArch64 line separator
193The @samp{;} character can be used instead of a newline to separate
194statements.
195
196@cindex immediate character, AArch64
197@cindex AArch64 immediate character
198The @samp{#} can be optionally used to indicate immediate operands.
199
200@node AArch64-Regs
201@subsection Register Names
202
203@cindex AArch64 register names
204@cindex register names, AArch64
205Please refer to the section @samp{4.4 Register Names} of
206@samp{ARMv8 Instruction Set Overview}, which is available at
207@uref{http://infocenter.arm.com}.
208
209@node AArch64-Relocations
210@subsection Relocations
211
212@cindex relocations, AArch64
213@cindex AArch64 relocations
214@cindex MOVN, MOVZ and MOVK group relocations, AArch64
215Relocations for @samp{MOVZ} and @samp{MOVK} instructions can be generated
216by prefixing the label with @samp{#:abs_g2:} etc.
217For example to load the 48-bit absolute address of @var{foo} into x0:
218
219@smallexample
220 movz x0, #:abs_g2:foo // bits 32-47, overflow check
221 movk x0, #:abs_g1_nc:foo // bits 16-31, no overflow check
222 movk x0, #:abs_g0_nc:foo // bits 0-15, no overflow check
223@end smallexample
224
225@cindex ADRP, ADD, LDR/STR group relocations, AArch64
226Relocations for @samp{ADRP}, and @samp{ADD}, @samp{LDR} or @samp{STR}
227instructions can be generated by prefixing the label with
34fd659b 228@samp{:pg_hi21:} and @samp{#:lo12:} respectively.
a06ea964 229
34bca508 230For example to use 33-bit (+/-4GB) pc-relative addressing to
a06ea964
NC
231load the address of @var{foo} into x0:
232
233@smallexample
34fd659b 234 adrp x0, :pg_hi21:foo
a06ea964
NC
235 add x0, x0, #:lo12:foo
236@end smallexample
237
238Or to load the value of @var{foo} into x0:
239
240@smallexample
34fd659b 241 adrp x0, :pg_hi21:foo
a06ea964
NC
242 ldr x0, [x0, #:lo12:foo]
243@end smallexample
244
34fd659b 245Note that @samp{:pg_hi21:} is optional.
a06ea964
NC
246
247@smallexample
248 adrp x0, foo
249@end smallexample
250
251is equivalent to
252
253@smallexample
34fd659b 254 adrp x0, :pg_hi21:foo
a06ea964
NC
255@end smallexample
256
257@node AArch64 Floating Point
258@section Floating Point
259
260@cindex floating point, AArch64 (@sc{ieee})
261@cindex AArch64 floating point (@sc{ieee})
262The AArch64 architecture uses @sc{ieee} floating-point numbers.
263
264@node AArch64 Directives
265@section AArch64 Machine Directives
266
267@cindex machine directives, AArch64
268@cindex AArch64 machine directives
269@table @code
270
271@c AAAAAAAAAAAAAAAAAAAAAAAAA
8e02d7f5
JW
272
273@cindex @code{.arch} directive, AArch64
274@item .arch @var{name}
275Select the target architecture. Valid values for @var{name} are the same as
276for the @option{-march} commandline option.
277
278Specifying @code{.arch} clears any previously selected architecture
279extensions.
280
281@cindex @code{.arch_extension} directive, AArch64
282@item .arch_extension @var{name}
283Add or remove an architecture extension to the target architecture. Valid
284values for @var{name} are the same as those accepted as architectural
285extensions by the @option{-mcpu} commandline option.
286
287@code{.arch_extension} may be used multiple times to add or remove extensions
288incrementally to the architecture being compiled for.
289
a06ea964
NC
290@c BBBBBBBBBBBBBBBBBBBBBBBBBB
291
292@cindex @code{.bss} directive, AArch64
293@item .bss
294This directive switches to the @code{.bss} section.
295
296@c CCCCCCCCCCCCCCCCCCCCCCCCCC
30fab421
NC
297
298@cindex @code{.cpu} directive, AArch64
299@item .cpu @var{name}
300Set the target processor. Valid values for @var{name} are the same as
301those accepted by the @option{-mcpu=} command line option.
302
a06ea964 303@c DDDDDDDDDDDDDDDDDDDDDDDDDD
30fab421
NC
304
305@cindex @code{.dword} directive, AArch64
306@item .dword @var{expressions}
307The @code{.dword} directive produces 64 bit values.
308
a06ea964 309@c EEEEEEEEEEEEEEEEEEEEEEEEEE
30fab421
NC
310
311@cindex @code{.even} directive, AArch64
312@item .even
313The @code{.even} directive aligns the output on the next even byte
314boundary.
315
a06ea964
NC
316@c FFFFFFFFFFFFFFFFFFFFFFFFFF
317@c GGGGGGGGGGGGGGGGGGGGGGGGGG
318@c HHHHHHHHHHHHHHHHHHHHHHHHHH
319@c IIIIIIIIIIIIIIIIIIIIIIIIII
30fab421
NC
320
321@cindex @code{.inst} directive, AArch64
322@item .inst @var{expressions}
323Inserts the expressions into the output as if they were instructions,
324rather than data.
325
a06ea964
NC
326@c JJJJJJJJJJJJJJJJJJJJJJJJJJ
327@c KKKKKKKKKKKKKKKKKKKKKKKKKK
328@c LLLLLLLLLLLLLLLLLLLLLLLLLL
329
330@cindex @code{.ltorg} directive, AArch64
331@item .ltorg
332This directive causes the current contents of the literal pool to be
333dumped into the current section (which is assumed to be the .text
334section) at the current location (aligned to a word boundary).
df359aa7 335GAS maintains a separate literal pool for each section and each
a06ea964
NC
336sub-section. The @code{.ltorg} directive will only affect the literal
337pool of the current section and sub-section. At the end of assembly
338all remaining, un-empty literal pools will automatically be dumped.
339
df359aa7 340Note - older versions of GAS would dump the current literal
a06ea964
NC
341pool any time a section change occurred. This is no longer done, since
342it prevents accurate control of the placement of literal pools.
343
344@c MMMMMMMMMMMMMMMMMMMMMMMMMM
345
346@c NNNNNNNNNNNNNNNNNNNNNNNNNN
347@c OOOOOOOOOOOOOOOOOOOOOOOOOO
348
349@c PPPPPPPPPPPPPPPPPPPPPPPPPP
350
351@cindex @code{.pool} directive, AArch64
352@item .pool
353This is a synonym for .ltorg.
354
355@c QQQQQQQQQQQQQQQQQQQQQQQQQQ
356@c RRRRRRRRRRRRRRRRRRRRRRRRRR
357
358@cindex @code{.req} directive, AArch64
359@item @var{name} .req @var{register name}
360This creates an alias for @var{register name} called @var{name}. For
361example:
362
363@smallexample
364 foo .req w0
365@end smallexample
366
8975f864
RR
367ip0, ip1, lr and fp are automatically defined to
368alias to X16, X17, X30 and X29 respectively.
369
a06ea964
NC
370@c SSSSSSSSSSSSSSSSSSSSSSSSSS
371
372@c TTTTTTTTTTTTTTTTTTTTTTTTTT
373
30fab421
NC
374@cindex @code{.tlsdescadd} directive, AArch64
375@item @code{.tlsdescadd}
376Emits a TLSDESC_ADD reloc on the next instruction.
377
378@cindex @code{.tlsdesccall} directive, AArch64
379@item @code{.tlsdesccall}
380Emits a TLSDESC_CALL reloc on the next instruction.
381
382@cindex @code{.tlsdescldr} directive, AArch64
383@item @code{.tlsdescldr}
384Emits a TLSDESC_LDR reloc on the next instruction.
385
a06ea964
NC
386@c UUUUUUUUUUUUUUUUUUUUUUUUUU
387
388@cindex @code{.unreq} directive, AArch64
389@item .unreq @var{alias-name}
390This undefines a register alias which was previously defined using the
391@code{req} directive. For example:
392
393@smallexample
394 foo .req w0
395 .unreq foo
396@end smallexample
397
398An error occurs if the name is undefined. Note - this pseudo op can
399be used to delete builtin in register name aliases (eg 'w0'). This
400should only be done if it is really necessary.
401
402@c VVVVVVVVVVVVVVVVVVVVVVVVVV
403
404@c WWWWWWWWWWWWWWWWWWWWWWWWWW
405@c XXXXXXXXXXXXXXXXXXXXXXXXXX
a06ea964 406
edc66de9 407@cindex @code{.xword} directive, AArch64
30fab421
NC
408@item .xword @var{expressions}
409The @code{.xword} directive produces 64 bit values. This is the same
410as the @code{.dword} directive.
411
412@c YYYYYYYYYYYYYYYYYYYYYYYYYY
413@c ZZZZZZZZZZZZZZZZZZZZZZZZZZ
edc66de9 414
a06ea964
NC
415@end table
416
417@node AArch64 Opcodes
418@section Opcodes
419
420@cindex AArch64 opcodes
421@cindex opcodes for AArch64
df359aa7 422GAS implements all the standard AArch64 opcodes. It also
a06ea964 423implements several pseudo opcodes, including several synthetic load
34bca508 424instructions.
a06ea964
NC
425
426@table @code
427
428@cindex @code{LDR reg,=<expr>} pseudo op, AArch64
429@item LDR =
430@smallexample
431 ldr <register> , =<expression>
432@end smallexample
433
434The constant expression will be placed into the nearest literal pool (if it not
435already there) and a PC-relative LDR instruction will be generated.
436
437@end table
438
439For more information on the AArch64 instruction set and assembly language
440notation, see @samp{ARMv8 Instruction Set Overview} available at
441@uref{http://infocenter.arm.com}.
442
443
444@node AArch64 Mapping Symbols
445@section Mapping Symbols
446
447The AArch64 ELF specification requires that special symbols be inserted
448into object files to mark certain features:
449
450@table @code
451
452@cindex @code{$x}
453@item $x
454At the start of a region of code containing AArch64 instructions.
455
456@cindex @code{$d}
457@item $d
458At the start of a region of data.
459
460@end table
This page took 0.510422 seconds and 4 git commands to generate.