c-aarch64.texi 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. @c Copyright (C) 2009-2015 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.
  5. @c man end
  6. @ifset GENERIC
  7. @page
  8. @node AArch64-Dependent
  9. @chapter AArch64 Dependent Features
  10. @end ifset
  11. @ifclear GENERIC
  12. @node Machine Dependencies
  13. @chapter AArch64 Dependent Features
  14. @end ifclear
  15. @cindex AArch64 support
  16. @menu
  17. * AArch64 Options:: Options
  18. * AArch64 Extensions:: Extensions
  19. * AArch64 Syntax:: Syntax
  20. * AArch64 Floating Point:: Floating Point
  21. * AArch64 Directives:: AArch64 Machine Directives
  22. * AArch64 Opcodes:: Opcodes
  23. * AArch64 Mapping Symbols:: Mapping Symbols
  24. @end menu
  25. @node AArch64 Options
  26. @section Options
  27. @cindex AArch64 options (none)
  28. @cindex options for AArch64 (none)
  29. @c man begin OPTIONS
  30. @table @gcctabopt
  31. @cindex @option{-EB} command line option, AArch64
  32. @item -EB
  33. This option specifies that the output generated by the assembler should
  34. be marked as being encoded for a big-endian processor.
  35. @cindex @option{-EL} command line option, AArch64
  36. @item -EL
  37. This option specifies that the output generated by the assembler should
  38. be marked as being encoded for a little-endian processor.
  39. @cindex @option{-mabi=} command line option, AArch64
  40. @item -mabi=@var{abi}
  41. Specify which ABI the source code uses. The recognized arguments
  42. are: @code{ilp32} and @code{lp64}, which decides the generated object
  43. file in ELF32 and ELF64 format respectively. The default is @code{lp64}.
  44. @cindex @option{-mcpu=} command line option, AArch64
  45. @item -mcpu=@var{processor}[+@var{extension}@dots{}]
  46. This option specifies the target processor. The assembler will issue an error
  47. message if an attempt is made to assemble an instruction which will not execute
  48. on the target processor. The following processor names are recognized:
  49. @code{cortex-a53},
  50. @code{cortex-a57},
  51. @code{cortex-a72},
  52. @code{exynos-m1},
  53. @code{thunderx},
  54. @code{xgene1}
  55. and
  56. @code{xgene2}.
  57. The special name @code{all} may be used to allow the assembler to accept
  58. instructions valid for any supported processor, including all optional
  59. extensions.
  60. In addition to the basic instruction set, the assembler can be told to
  61. accept, or restrict, various extension mnemonics that extend the
  62. processor. @xref{AArch64 Extensions}.
  63. If some implementations of a particular processor can have an
  64. extension, then then those extensions are automatically enabled.
  65. Consequently, you will not normally have to specify any additional
  66. extensions.
  67. @cindex @option{-march=} command line option, AArch64
  68. @item -march=@var{architecture}[+@var{extension}@dots{}]
  69. This option specifies the target architecture. The assembler will
  70. issue an error message if an attempt is made to assemble an
  71. instruction which will not execute on the target architecture. The
  72. following architecture names are recognized: @code{armv8-a} and
  73. @code{armv8.1-a}.
  74. If both @option{-mcpu} and @option{-march} are specified, the
  75. assembler will use the setting for @option{-mcpu}. If neither are
  76. specified, the assembler will default to @option{-mcpu=all}.
  77. The architecture option can be extended with the same instruction set
  78. extension options as the @option{-mcpu} option. Unlike
  79. @option{-mcpu}, extensions are not always enabled by default,
  80. @xref{AArch64 Extensions}.
  81. @cindex @code{-mverbose-error} command line option, AArch64
  82. @item -mverbose-error
  83. This option enables verbose error messages for AArch64 gas. This option
  84. is enabled by default.
  85. @cindex @code{-mno-verbose-error} command line option, AArch64
  86. @item -mno-verbose-error
  87. This option disables verbose error messages in AArch64 gas.
  88. @end table
  89. @c man end
  90. @node AArch64 Extensions
  91. @section Architecture Extensions
  92. The table below lists the permitted architecture extensions that are
  93. supported by the assembler and the conditions under which they are
  94. automatically enabled.
  95. Multiple extensions may be specified, separated by a @code{+}.
  96. Extension mnemonics may also be removed from those the assembler
  97. accepts. This is done by prepending @code{no} to the option that adds
  98. the extension. Extensions that are removed must be listed after all
  99. extensions that have been added.
  100. Enabling an extension that requires other extensions will
  101. automatically cause those extensions to be enabled. Similarly,
  102. disabling an extension that is required by other extensions will
  103. automatically cause those extensions to be disabled.
  104. @multitable @columnfractions .12 .17 .17 .54
  105. @headitem Extension @tab Minimum Architecture @tab Enabled by default
  106. @tab Description
  107. @item @code{crc} @tab ARMv8-A @tab No
  108. @tab Enable CRC instructions.
  109. @item @code{crypto} @tab ARMv8-A @tab No
  110. @tab Enable cryptographic extensions. This implies @code{fp} and @code{simd}.
  111. @item @code{fp} @tab ARMv8-A @tab ARMv8-A or later
  112. @tab Enable floating-point extensions.
  113. @item @code{simd} @tab ARMv8-A @tab ARMv8-A or later
  114. @tab Enable Advanced SIMD extensions. This implies @code{fp}.
  115. @item @code{pan} @tab ARMv8-A @tab ARMv8-A or later
  116. @tab Enable Privileged Access Never support.
  117. @item @code{lor} @tab ARMv8-A @tab ARMv8-A or later
  118. @tab Enable Limited Ordering Regions extensions.
  119. @item @code{rdma} @tab ARMv8-A @tab ARMv8-A or later
  120. @tab Enable ARMv8.1 Advanced SIMD extensions. This implies @code{simd}.
  121. @end multitable
  122. @node AArch64 Syntax
  123. @section Syntax
  124. @menu
  125. * AArch64-Chars:: Special Characters
  126. * AArch64-Regs:: Register Names
  127. * AArch64-Relocations:: Relocations
  128. @end menu
  129. @node AArch64-Chars
  130. @subsection Special Characters
  131. @cindex line comment character, AArch64
  132. @cindex AArch64 line comment character
  133. The presence of a @samp{//} on a line indicates the start of a comment
  134. that extends to the end of the current line. If a @samp{#} appears as
  135. the first character of a line, the whole line is treated as a comment.
  136. @cindex line separator, AArch64
  137. @cindex statement separator, AArch64
  138. @cindex AArch64 line separator
  139. The @samp{;} character can be used instead of a newline to separate
  140. statements.
  141. @cindex immediate character, AArch64
  142. @cindex AArch64 immediate character
  143. The @samp{#} can be optionally used to indicate immediate operands.
  144. @node AArch64-Regs
  145. @subsection Register Names
  146. @cindex AArch64 register names
  147. @cindex register names, AArch64
  148. Please refer to the section @samp{4.4 Register Names} of
  149. @samp{ARMv8 Instruction Set Overview}, which is available at
  150. @uref{http://infocenter.arm.com}.
  151. @node AArch64-Relocations
  152. @subsection Relocations
  153. @cindex relocations, AArch64
  154. @cindex AArch64 relocations
  155. @cindex MOVN, MOVZ and MOVK group relocations, AArch64
  156. Relocations for @samp{MOVZ} and @samp{MOVK} instructions can be generated
  157. by prefixing the label with @samp{#:abs_g2:} etc.
  158. For example to load the 48-bit absolute address of @var{foo} into x0:
  159. @smallexample
  160. movz x0, #:abs_g2:foo // bits 32-47, overflow check
  161. movk x0, #:abs_g1_nc:foo // bits 16-31, no overflow check
  162. movk x0, #:abs_g0_nc:foo // bits 0-15, no overflow check
  163. @end smallexample
  164. @cindex ADRP, ADD, LDR/STR group relocations, AArch64
  165. Relocations for @samp{ADRP}, and @samp{ADD}, @samp{LDR} or @samp{STR}
  166. instructions can be generated by prefixing the label with
  167. @samp{:pg_hi21:} and @samp{#:lo12:} respectively.
  168. For example to use 33-bit (+/-4GB) pc-relative addressing to
  169. load the address of @var{foo} into x0:
  170. @smallexample
  171. adrp x0, :pg_hi21:foo
  172. add x0, x0, #:lo12:foo
  173. @end smallexample
  174. Or to load the value of @var{foo} into x0:
  175. @smallexample
  176. adrp x0, :pg_hi21:foo
  177. ldr x0, [x0, #:lo12:foo]
  178. @end smallexample
  179. Note that @samp{:pg_hi21:} is optional.
  180. @smallexample
  181. adrp x0, foo
  182. @end smallexample
  183. is equivalent to
  184. @smallexample
  185. adrp x0, :pg_hi21:foo
  186. @end smallexample
  187. @node AArch64 Floating Point
  188. @section Floating Point
  189. @cindex floating point, AArch64 (@sc{ieee})
  190. @cindex AArch64 floating point (@sc{ieee})
  191. The AArch64 architecture uses @sc{ieee} floating-point numbers.
  192. @node AArch64 Directives
  193. @section AArch64 Machine Directives
  194. @cindex machine directives, AArch64
  195. @cindex AArch64 machine directives
  196. @table @code
  197. @c AAAAAAAAAAAAAAAAAAAAAAAAA
  198. @cindex @code{.arch} directive, AArch64
  199. @item .arch @var{name}
  200. Select the target architecture. Valid values for @var{name} are the same as
  201. for the @option{-march} commandline option.
  202. Specifying @code{.arch} clears any previously selected architecture
  203. extensions.
  204. @cindex @code{.arch_extension} directive, AArch64
  205. @item .arch_extension @var{name}
  206. Add or remove an architecture extension to the target architecture. Valid
  207. values for @var{name} are the same as those accepted as architectural
  208. extensions by the @option{-mcpu} commandline option.
  209. @code{.arch_extension} may be used multiple times to add or remove extensions
  210. incrementally to the architecture being compiled for.
  211. @c BBBBBBBBBBBBBBBBBBBBBBBBBB
  212. @cindex @code{.bss} directive, AArch64
  213. @item .bss
  214. This directive switches to the @code{.bss} section.
  215. @c CCCCCCCCCCCCCCCCCCCCCCCCCC
  216. @c DDDDDDDDDDDDDDDDDDDDDDDDDD
  217. @c EEEEEEEEEEEEEEEEEEEEEEEEEE
  218. @c FFFFFFFFFFFFFFFFFFFFFFFFFF
  219. @c GGGGGGGGGGGGGGGGGGGGGGGGGG
  220. @c HHHHHHHHHHHHHHHHHHHHHHHHHH
  221. @c IIIIIIIIIIIIIIIIIIIIIIIIII
  222. @c JJJJJJJJJJJJJJJJJJJJJJJJJJ
  223. @c KKKKKKKKKKKKKKKKKKKKKKKKKK
  224. @c LLLLLLLLLLLLLLLLLLLLLLLLLL
  225. @cindex @code{.ltorg} directive, AArch64
  226. @item .ltorg
  227. This directive causes the current contents of the literal pool to be
  228. dumped into the current section (which is assumed to be the .text
  229. section) at the current location (aligned to a word boundary).
  230. GAS maintains a separate literal pool for each section and each
  231. sub-section. The @code{.ltorg} directive will only affect the literal
  232. pool of the current section and sub-section. At the end of assembly
  233. all remaining, un-empty literal pools will automatically be dumped.
  234. Note - older versions of GAS would dump the current literal
  235. pool any time a section change occurred. This is no longer done, since
  236. it prevents accurate control of the placement of literal pools.
  237. @c MMMMMMMMMMMMMMMMMMMMMMMMMM
  238. @c NNNNNNNNNNNNNNNNNNNNNNNNNN
  239. @c OOOOOOOOOOOOOOOOOOOOOOOOOO
  240. @c PPPPPPPPPPPPPPPPPPPPPPPPPP
  241. @cindex @code{.pool} directive, AArch64
  242. @item .pool
  243. This is a synonym for .ltorg.
  244. @c QQQQQQQQQQQQQQQQQQQQQQQQQQ
  245. @c RRRRRRRRRRRRRRRRRRRRRRRRRR
  246. @cindex @code{.req} directive, AArch64
  247. @item @var{name} .req @var{register name}
  248. This creates an alias for @var{register name} called @var{name}. For
  249. example:
  250. @smallexample
  251. foo .req w0
  252. @end smallexample
  253. @c SSSSSSSSSSSSSSSSSSSSSSSSSS
  254. @c TTTTTTTTTTTTTTTTTTTTTTTTTT
  255. @c UUUUUUUUUUUUUUUUUUUUUUUUUU
  256. @cindex @code{.unreq} directive, AArch64
  257. @item .unreq @var{alias-name}
  258. This undefines a register alias which was previously defined using the
  259. @code{req} directive. For example:
  260. @smallexample
  261. foo .req w0
  262. .unreq foo
  263. @end smallexample
  264. An error occurs if the name is undefined. Note - this pseudo op can
  265. be used to delete builtin in register name aliases (eg 'w0'). This
  266. should only be done if it is really necessary.
  267. @c VVVVVVVVVVVVVVVVVVVVVVVVVV
  268. @c WWWWWWWWWWWWWWWWWWWWWWWWWW
  269. @c XXXXXXXXXXXXXXXXXXXXXXXXXX
  270. @c YYYYYYYYYYYYYYYYYYYYYYYYYY
  271. @c ZZZZZZZZZZZZZZZZZZZZZZZZZZ
  272. @cindex @code{.xword} directive, AArch64
  273. @item .xword
  274. The @code{.xword} directive produces 64 bit values.
  275. @end table
  276. @node AArch64 Opcodes
  277. @section Opcodes
  278. @cindex AArch64 opcodes
  279. @cindex opcodes for AArch64
  280. GAS implements all the standard AArch64 opcodes. It also
  281. implements several pseudo opcodes, including several synthetic load
  282. instructions.
  283. @table @code
  284. @cindex @code{LDR reg,=<expr>} pseudo op, AArch64
  285. @item LDR =
  286. @smallexample
  287. ldr <register> , =<expression>
  288. @end smallexample
  289. The constant expression will be placed into the nearest literal pool (if it not
  290. already there) and a PC-relative LDR instruction will be generated.
  291. @end table
  292. For more information on the AArch64 instruction set and assembly language
  293. notation, see @samp{ARMv8 Instruction Set Overview} available at
  294. @uref{http://infocenter.arm.com}.
  295. @node AArch64 Mapping Symbols
  296. @section Mapping Symbols
  297. The AArch64 ELF specification requires that special symbols be inserted
  298. into object files to mark certain features:
  299. @table @code
  300. @cindex @code{$x}
  301. @item $x
  302. At the start of a region of code containing AArch64 instructions.
  303. @cindex @code{$d}
  304. @item $d
  305. At the start of a region of data.
  306. @end table