AArch64-Function-Attributes.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>Using the GNU Compiler Collection (GCC): AArch64 Function Attributes</title>
  20. <meta name="description" content="Using the GNU Compiler Collection (GCC): AArch64 Function Attributes">
  21. <meta name="keywords" content="Using the GNU Compiler Collection (GCC): AArch64 Function Attributes">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Function-Attributes.html#Function-Attributes" rel="up" title="Function Attributes">
  30. <link href="ARC-Function-Attributes.html#ARC-Function-Attributes" rel="next" title="ARC Function Attributes">
  31. <link href="Common-Function-Attributes.html#Common-Function-Attributes" rel="prev" title="Common Function Attributes">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="AArch64-Function-Attributes"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="ARC-Function-Attributes.html#ARC-Function-Attributes" accesskey="n" rel="next">ARC Function Attributes</a>, Previous: <a href="Common-Function-Attributes.html#Common-Function-Attributes" accesskey="p" rel="prev">Common Function Attributes</a>, Up: <a href="Function-Attributes.html#Function-Attributes" accesskey="u" rel="up">Function Attributes</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="AArch64-Function-Attributes-1"></a>
  69. <h4 class="subsection">6.31.2 AArch64 Function Attributes</h4>
  70. <p>The following target-specific function attributes are available for the
  71. AArch64 target. For the most part, these options mirror the behavior of
  72. similar command-line options (see <a href="AArch64-Options.html#AArch64-Options">AArch64 Options</a>), but on a
  73. per-function basis.
  74. </p>
  75. <dl compact="compact">
  76. <dt><code>general-regs-only</code></dt>
  77. <dd><a name="index-general_002dregs_002donly-function-attribute_002c-AArch64"></a>
  78. <p>Indicates that no floating-point or Advanced SIMD registers should be
  79. used when generating code for this function. If the function explicitly
  80. uses floating-point code, then the compiler gives an error. This is
  81. the same behavior as that of the command-line option
  82. <samp>-mgeneral-regs-only</samp>.
  83. </p>
  84. </dd>
  85. <dt><code>fix-cortex-a53-835769</code></dt>
  86. <dd><a name="index-fix_002dcortex_002da53_002d835769-function-attribute_002c-AArch64"></a>
  87. <p>Indicates that the workaround for the Cortex-A53 erratum 835769 should be
  88. applied to this function. To explicitly disable the workaround for this
  89. function specify the negated form: <code>no-fix-cortex-a53-835769</code>.
  90. This corresponds to the behavior of the command line options
  91. <samp>-mfix-cortex-a53-835769</samp> and <samp>-mno-fix-cortex-a53-835769</samp>.
  92. </p>
  93. </dd>
  94. <dt><code>cmodel=</code></dt>
  95. <dd><a name="index-cmodel_003d-function-attribute_002c-AArch64"></a>
  96. <p>Indicates that code should be generated for a particular code model for
  97. this function. The behavior and permissible arguments are the same as
  98. for the command line option <samp>-mcmodel=</samp>.
  99. </p>
  100. </dd>
  101. <dt><code>strict-align</code></dt>
  102. <dd><a name="index-strict_002dalign-function-attribute_002c-AArch64"></a>
  103. <p>Indicates that the compiler should not assume that unaligned memory references
  104. are handled by the system. The behavior is the same as for the command-line
  105. option <samp>-mstrict-align</samp>.
  106. </p>
  107. </dd>
  108. <dt><code>omit-leaf-frame-pointer</code></dt>
  109. <dd><a name="index-omit_002dleaf_002dframe_002dpointer-function-attribute_002c-AArch64"></a>
  110. <p>Indicates that the frame pointer should be omitted for a leaf function call.
  111. To keep the frame pointer, the inverse attribute
  112. <code>no-omit-leaf-frame-pointer</code> can be specified. These attributes have
  113. the same behavior as the command-line options <samp>-momit-leaf-frame-pointer</samp>
  114. and <samp>-mno-omit-leaf-frame-pointer</samp>.
  115. </p>
  116. </dd>
  117. <dt><code>tls-dialect=</code></dt>
  118. <dd><a name="index-tls_002ddialect_003d-function-attribute_002c-AArch64"></a>
  119. <p>Specifies the TLS dialect to use for this function. The behavior and
  120. permissible arguments are the same as for the command-line option
  121. <samp>-mtls-dialect=</samp>.
  122. </p>
  123. </dd>
  124. <dt><code>arch=</code></dt>
  125. <dd><a name="index-arch_003d-function-attribute_002c-AArch64"></a>
  126. <p>Specifies the architecture version and architectural extensions to use
  127. for this function. The behavior and permissible arguments are the same as
  128. for the <samp>-march=</samp> command-line option.
  129. </p>
  130. </dd>
  131. <dt><code>tune=</code></dt>
  132. <dd><a name="index-tune_003d-function-attribute_002c-AArch64"></a>
  133. <p>Specifies the core for which to tune the performance of this function.
  134. The behavior and permissible arguments are the same as for the <samp>-mtune=</samp>
  135. command-line option.
  136. </p>
  137. </dd>
  138. <dt><code>cpu=</code></dt>
  139. <dd><a name="index-cpu_003d-function-attribute_002c-AArch64"></a>
  140. <p>Specifies the core for which to tune the performance of this function and also
  141. whose architectural features to use. The behavior and valid arguments are the
  142. same as for the <samp>-mcpu=</samp> command-line option.
  143. </p>
  144. </dd>
  145. <dt><code>sign-return-address</code></dt>
  146. <dd><a name="index-sign_002dreturn_002daddress-function-attribute_002c-AArch64"></a>
  147. <p>Select the function scope on which return address signing will be applied. The
  148. behavior and permissible arguments are the same as for the command-line option
  149. <samp>-msign-return-address=</samp>. The default value is <code>none</code>.
  150. </p>
  151. </dd>
  152. </dl>
  153. <p>The above target attributes can be specified as follows:
  154. </p>
  155. <div class="smallexample">
  156. <pre class="smallexample">__attribute__((target(&quot;<var>attr-string</var>&quot;)))
  157. int
  158. f (int a)
  159. {
  160. return a + 5;
  161. }
  162. </pre></div>
  163. <p>where <code><var>attr-string</var></code> is one of the attribute strings specified above.
  164. </p>
  165. <p>Additionally, the architectural extension string may be specified on its
  166. own. This can be used to turn on and off particular architectural extensions
  167. without having to specify a particular architecture version or core. Example:
  168. </p>
  169. <div class="smallexample">
  170. <pre class="smallexample">__attribute__((target(&quot;+crc+nocrypto&quot;)))
  171. int
  172. foo (int a)
  173. {
  174. return a + 5;
  175. }
  176. </pre></div>
  177. <p>In this example <code>target(&quot;+crc+nocrypto&quot;)</code> enables the <code>crc</code>
  178. extension and disables the <code>crypto</code> extension for the function <code>foo</code>
  179. without modifying an existing <samp>-march=</samp> or <samp>-mcpu</samp> option.
  180. </p>
  181. <p>Multiple target function attributes can be specified by separating them with
  182. a comma. For example:
  183. </p><div class="smallexample">
  184. <pre class="smallexample">__attribute__((target(&quot;arch=armv8-a+crc+crypto,tune=cortex-a53&quot;)))
  185. int
  186. foo (int a)
  187. {
  188. return a + 5;
  189. }
  190. </pre></div>
  191. <p>is valid and compiles function <code>foo</code> for ARMv8-A with <code>crc</code>
  192. and <code>crypto</code> extensions and tunes it for <code>cortex-a53</code>.
  193. </p>
  194. <a name="Inlining-rules"></a>
  195. <h4 class="subsubsection">6.31.2.1 Inlining rules</h4>
  196. <p>Specifying target attributes on individual functions or performing link-time
  197. optimization across translation units compiled with different target options
  198. can affect function inlining rules:
  199. </p>
  200. <p>In particular, a caller function can inline a callee function only if the
  201. architectural features available to the callee are a subset of the features
  202. available to the caller.
  203. For example: A function <code>foo</code> compiled with <samp>-march=armv8-a+crc</samp>,
  204. or tagged with the equivalent <code>arch=armv8-a+crc</code> attribute,
  205. can inline a function <code>bar</code> compiled with <samp>-march=armv8-a+nocrc</samp>
  206. because the all the architectural features that function <code>bar</code> requires
  207. are available to function <code>foo</code>. Conversely, function <code>bar</code> cannot
  208. inline function <code>foo</code>.
  209. </p>
  210. <p>Additionally inlining a function compiled with <samp>-mstrict-align</samp> into a
  211. function compiled without <code>-mstrict-align</code> is not allowed.
  212. However, inlining a function compiled without <samp>-mstrict-align</samp> into a
  213. function compiled with <samp>-mstrict-align</samp> is allowed.
  214. </p>
  215. <p>Note that CPU tuning options and attributes such as the <samp>-mcpu=</samp>,
  216. <samp>-mtune=</samp> do not inhibit inlining unless the CPU specified by the
  217. <samp>-mcpu=</samp> option or the <code>cpu=</code> attribute conflicts with the
  218. architectural feature rules specified above.
  219. </p>
  220. <hr>
  221. <div class="header">
  222. <p>
  223. Next: <a href="ARC-Function-Attributes.html#ARC-Function-Attributes" accesskey="n" rel="next">ARC Function Attributes</a>, Previous: <a href="Common-Function-Attributes.html#Common-Function-Attributes" accesskey="p" rel="prev">Common Function Attributes</a>, Up: <a href="Function-Attributes.html#Function-Attributes" accesskey="u" rel="up">Function Attributes</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  224. </div>
  225. </body>
  226. </html>