You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
11KB

  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-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>ARM Function Attributes (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="ARM Function Attributes (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="ARM Function Attributes (Using the GNU Compiler Collection (GCC))">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  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="AVR-Function-Attributes.html#AVR-Function-Attributes" rel="next" title="AVR Function Attributes">
  31. <link href="ARC-Function-Attributes.html#ARC-Function-Attributes" rel="prev" title="ARC Function Attributes">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="ARM-Function-Attributes"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="AVR-Function-Attributes.html#AVR-Function-Attributes" accesskey="n" rel="next">AVR Function Attributes</a>, Previous: <a href="ARC-Function-Attributes.html#ARC-Function-Attributes" accesskey="p" rel="prev">ARC 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>
  65. </div>
  66. <hr>
  67. <a name="ARM-Function-Attributes-1"></a>
  68. <h4 class="subsection">6.33.5 ARM Function Attributes</h4>
  69. <p>These function attributes are supported for ARM targets:
  70. </p>
  71. <dl compact="compact">
  72. <dt><code>general-regs-only</code></dt>
  73. <dd><a name="index-general_002dregs_002donly-function-attribute_002c-ARM"></a>
  74. <p>Indicates that no floating-point or Advanced SIMD registers should be
  75. used when generating code for this function. If the function explicitly
  76. uses floating-point code, then the compiler gives an error. This is
  77. the same behavior as that of the command-line option
  78. <samp>-mgeneral-regs-only</samp>.
  79. </p>
  80. </dd>
  81. <dt><code>interrupt</code></dt>
  82. <dd><a name="index-interrupt-function-attribute_002c-ARM"></a>
  83. <p>Use this attribute to indicate
  84. that the specified function is an interrupt handler. The compiler generates
  85. function entry and exit sequences suitable for use in an interrupt handler
  86. when this attribute is present.
  87. </p>
  88. <p>You can specify the kind of interrupt to be handled by
  89. adding an optional parameter to the interrupt attribute like this:
  90. </p>
  91. <div class="smallexample">
  92. <pre class="smallexample">void f () __attribute__ ((interrupt (&quot;IRQ&quot;)));
  93. </pre></div>
  94. <p>Permissible values for this parameter are: <code>IRQ</code>, <code>FIQ</code>,
  95. <code>SWI</code>, <code>ABORT</code> and <code>UNDEF</code>.
  96. </p>
  97. <p>On ARMv7-M the interrupt type is ignored, and the attribute means the function
  98. may be called with a word-aligned stack pointer.
  99. </p>
  100. </dd>
  101. <dt><code>isr</code></dt>
  102. <dd><a name="index-isr-function-attribute_002c-ARM"></a>
  103. <p>Use this attribute on ARM to write Interrupt Service Routines. This is an
  104. alias to the <code>interrupt</code> attribute above.
  105. </p>
  106. </dd>
  107. <dt><code>long_call</code></dt>
  108. <dt><code>short_call</code></dt>
  109. <dd><a name="index-long_005fcall-function-attribute_002c-ARM"></a>
  110. <a name="index-short_005fcall-function-attribute_002c-ARM"></a>
  111. <a name="index-indirect-calls_002c-ARM"></a>
  112. <p>These attributes specify how a particular function is called.
  113. These attributes override the
  114. <samp>-mlong-calls</samp> (see <a href="ARM-Options.html#ARM-Options">ARM Options</a>)
  115. command-line switch and <code>#pragma long_calls</code> settings. For ARM, the
  116. <code>long_call</code> attribute indicates that the function might be far
  117. away from the call site and require a different (more expensive)
  118. calling sequence. The <code>short_call</code> attribute always places
  119. the offset to the function from the call site into the &lsquo;<samp>BL</samp>&rsquo;
  120. instruction directly.
  121. </p>
  122. </dd>
  123. <dt><code>naked</code></dt>
  124. <dd><a name="index-naked-function-attribute_002c-ARM"></a>
  125. <p>This attribute allows the compiler to construct the
  126. requisite function declaration, while allowing the body of the
  127. function to be assembly code. The specified function will not have
  128. prologue/epilogue sequences generated by the compiler. Only basic
  129. <code>asm</code> statements can safely be included in naked functions
  130. (see <a href="Basic-Asm.html#Basic-Asm">Basic Asm</a>). While using extended <code>asm</code> or a mixture of
  131. basic <code>asm</code> and C code may appear to work, they cannot be
  132. depended upon to work reliably and are not supported.
  133. </p>
  134. </dd>
  135. <dt><code>pcs</code></dt>
  136. <dd><a name="index-pcs-function-attribute_002c-ARM"></a>
  137. <p>The <code>pcs</code> attribute can be used to control the calling convention
  138. used for a function on ARM. The attribute takes an argument that specifies
  139. the calling convention to use.
  140. </p>
  141. <p>When compiling using the AAPCS ABI (or a variant of it) then valid
  142. values for the argument are <code>&quot;aapcs&quot;</code> and <code>&quot;aapcs-vfp&quot;</code>. In
  143. order to use a variant other than <code>&quot;aapcs&quot;</code> then the compiler must
  144. be permitted to use the appropriate co-processor registers (i.e., the
  145. VFP registers must be available in order to use <code>&quot;aapcs-vfp&quot;</code>).
  146. For example,
  147. </p>
  148. <div class="smallexample">
  149. <pre class="smallexample">/* Argument passed in r0, and result returned in r0+r1. */
  150. double f2d (float) __attribute__((pcs(&quot;aapcs&quot;)));
  151. </pre></div>
  152. <p>Variadic functions always use the <code>&quot;aapcs&quot;</code> calling convention and
  153. the compiler rejects attempts to specify an alternative.
  154. </p>
  155. </dd>
  156. <dt><code>target (<var>options</var>)</code></dt>
  157. <dd><a name="index-target-function-attribute-1"></a>
  158. <p>As discussed in <a href="Common-Function-Attributes.html#Common-Function-Attributes">Common Function Attributes</a>, this attribute
  159. allows specification of target-specific compilation options.
  160. </p>
  161. <p>On ARM, the following options are allowed:
  162. </p>
  163. <dl compact="compact">
  164. <dt>&lsquo;<samp>thumb</samp>&rsquo;</dt>
  165. <dd><a name="index-target_0028_0022thumb_0022_0029-function-attribute_002c-ARM"></a>
  166. <p>Force code generation in the Thumb (T16/T32) ISA, depending on the
  167. architecture level.
  168. </p>
  169. </dd>
  170. <dt>&lsquo;<samp>arm</samp>&rsquo;</dt>
  171. <dd><a name="index-target_0028_0022arm_0022_0029-function-attribute_002c-ARM"></a>
  172. <p>Force code generation in the ARM (A32) ISA.
  173. </p>
  174. <p>Functions from different modes can be inlined in the caller&rsquo;s mode.
  175. </p>
  176. </dd>
  177. <dt>&lsquo;<samp>fpu=</samp>&rsquo;</dt>
  178. <dd><a name="index-target_0028_0022fpu_003d_0022_0029-function-attribute_002c-ARM"></a>
  179. <p>Specifies the fpu for which to tune the performance of this function.
  180. The behavior and permissible arguments are the same as for the <samp>-mfpu=</samp>
  181. command-line option.
  182. </p>
  183. </dd>
  184. <dt>&lsquo;<samp>arch=</samp>&rsquo;</dt>
  185. <dd><a name="index-arch_003d-function-attribute_002c-ARM"></a>
  186. <p>Specifies the architecture version and architectural extensions to use
  187. for this function. The behavior and permissible arguments are the same as
  188. for the <samp>-march=</samp> command-line option.
  189. </p>
  190. <p>The above target attributes can be specified as follows:
  191. </p>
  192. <div class="smallexample">
  193. <pre class="smallexample">__attribute__((target(&quot;arch=armv8-a+crc&quot;)))
  194. int
  195. f (int a)
  196. {
  197. return a + 5;
  198. }
  199. </pre></div>
  200. <p>Additionally, the architectural extension string may be specified on its
  201. own. This can be used to turn on and off particular architectural extensions
  202. without having to specify a particular architecture version or core. Example:
  203. </p>
  204. <div class="smallexample">
  205. <pre class="smallexample">__attribute__((target(&quot;+crc+nocrypto&quot;)))
  206. int
  207. foo (int a)
  208. {
  209. return a + 5;
  210. }
  211. </pre></div>
  212. <p>In this example <code>target(&quot;+crc+nocrypto&quot;)</code> enables the <code>crc</code>
  213. extension and disables the <code>crypto</code> extension for the function <code>foo</code>
  214. without modifying an existing <samp>-march=</samp> or <samp>-mcpu</samp> option.
  215. </p>
  216. </dd>
  217. </dl>
  218. </dd>
  219. </dl>
  220. <hr>
  221. <div class="header">
  222. <p>
  223. Next: <a href="AVR-Function-Attributes.html#AVR-Function-Attributes" accesskey="n" rel="next">AVR Function Attributes</a>, Previous: <a href="ARC-Function-Attributes.html#ARC-Function-Attributes" accesskey="p" rel="prev">ARC 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>