diff options
Diffstat (limited to 'devdocs/gcc~13/arm-function-attributes.html')
| -rw-r--r-- | devdocs/gcc~13/arm-function-attributes.html | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/devdocs/gcc~13/arm-function-attributes.html b/devdocs/gcc~13/arm-function-attributes.html new file mode 100644 index 00000000..f6f2a1e6 --- /dev/null +++ b/devdocs/gcc~13/arm-function-attributes.html @@ -0,0 +1,53 @@ +<div class="subsection-level-extent" id="ARM-Function-Attributes"> <div class="nav-panel"> <p> Next: <a href="avr-function-attributes" accesskey="n" rel="next">AVR Function Attributes</a>, Previous: <a href="arc-function-attributes" accesskey="p" rel="prev">ARC Function Attributes</a>, Up: <a href="function-attributes" accesskey="u" rel="up">Declaring Attributes of Functions</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div> <h1 class="subsection" id="ARM-Function-Attributes-1"><span>6.33.5 ARM Function Attributes<a class="copiable-link" href="#ARM-Function-Attributes-1"> ¶</a></span></h1> <p>These function attributes are supported for ARM targets: </p> <dl class="table"> <dt> +<span><code class="code">general-regs-only</code><a class="copiable-link" href="#index-general-regs-only-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dd> +<p>Indicates that no floating-point or Advanced SIMD registers should be used when generating code for this function. If the function explicitly uses floating-point code, then the compiler gives an error. This is the same behavior as that of the command-line option <samp class="option">-mgeneral-regs-only</samp>. </p> </dd> <dt> +<span><code class="code">interrupt</code><a class="copiable-link" href="#index-interrupt-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dd> +<p>Use this attribute to indicate that the specified function is an interrupt handler. The compiler generates function entry and exit sequences suitable for use in an interrupt handler when this attribute is present. </p> <p>You can specify the kind of interrupt to be handled by adding an optional parameter to the interrupt attribute like this: </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">void f () __attribute__ ((interrupt ("IRQ")));</pre> +</div> <p>Permissible values for this parameter are: <code class="code">IRQ</code>, <code class="code">FIQ</code>, <code class="code">SWI</code>, <code class="code">ABORT</code> and <code class="code">UNDEF</code>. </p> <p>On ARMv7-M the interrupt type is ignored, and the attribute means the function may be called with a word-aligned stack pointer. </p> </dd> <dt> +<span><code class="code">isr</code><a class="copiable-link" href="#index-isr-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dd> +<p>Use this attribute on ARM to write Interrupt Service Routines. This is an alias to the <code class="code">interrupt</code> attribute above. </p> </dd> <dt> + <span><code class="code">long_call</code><a class="copiable-link" href="#index-long_005fcall-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dt><code class="code">short_call</code></dt> <dd> +<p>These attributes specify how a particular function is called. These attributes override the <samp class="option">-mlong-calls</samp> (see <a class="pxref" href="arm-options">ARM Options</a>) command-line switch and <code class="code">#pragma long_calls</code> settings. For ARM, the <code class="code">long_call</code> attribute indicates that the function might be far away from the call site and require a different (more expensive) calling sequence. The <code class="code">short_call</code> attribute always places the offset to the function from the call site into the ‘<samp class="samp">BL</samp>’ instruction directly. </p> </dd> <dt> +<span><code class="code">naked</code><a class="copiable-link" href="#index-naked-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dd> +<p>This attribute allows the compiler to construct the requisite function declaration, while allowing the body of the function to be assembly code. The specified function will not have prologue/epilogue sequences generated by the compiler. Only basic <code class="code">asm</code> statements can safely be included in naked functions (see <a class="pxref" href="basic-asm">Basic Asm — Assembler Instructions Without Operands</a>). While using extended <code class="code">asm</code> or a mixture of basic <code class="code">asm</code> and C code may appear to work, they cannot be depended upon to work reliably and are not supported. </p> </dd> <dt> +<span><code class="code">pcs</code><a class="copiable-link" href="#index-pcs-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dd> <p>The <code class="code">pcs</code> attribute can be used to control the calling convention used for a function on ARM. The attribute takes an argument that specifies the calling convention to use. </p> <p>When compiling using the AAPCS ABI (or a variant of it) then valid values for the argument are <code class="code">"aapcs"</code> and <code class="code">"aapcs-vfp"</code>. In order to use a variant other than <code class="code">"aapcs"</code> then the compiler must be permitted to use the appropriate co-processor registers (i.e., the VFP registers must be available in order to use <code class="code">"aapcs-vfp"</code>). For example, </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">/* Argument passed in r0, and result returned in r0+r1. */ +double f2d (float) __attribute__((pcs("aapcs")));</pre> +</div> <p>Variadic functions always use the <code class="code">"aapcs"</code> calling convention and the compiler rejects attempts to specify an alternative. </p> </dd> <dt> +<span><code class="code">target (<var class="var">options</var>)</code><a class="copiable-link" href="#index-target-function-attribute-1"> ¶</a></span> +</dt> <dd> +<p>As discussed in <a class="ref" href="common-function-attributes">Common Function Attributes</a>, this attribute allows specification of target-specific compilation options. </p> <p>On ARM, the following options are allowed: </p> <dl class="table"> <dt> +<span>‘<samp class="samp">thumb</samp>’<a class="copiable-link" href="#index-target_0028_0022thumb_0022_0029-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dd> +<p>Force code generation in the Thumb (T16/T32) ISA, depending on the architecture level. </p> </dd> <dt> +<span>‘<samp class="samp">arm</samp>’<a class="copiable-link" href="#index-target_0028_0022arm_0022_0029-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dd> +<p>Force code generation in the ARM (A32) ISA. </p> <p>Functions from different modes can be inlined in the caller’s mode. </p> </dd> <dt> +<span>‘<samp class="samp">fpu=</samp>’<a class="copiable-link" href="#index-target_0028_0022fpu_003d_0022_0029-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dd> +<p>Specifies the fpu for which to tune the performance of this function. The behavior and permissible arguments are the same as for the <samp class="option">-mfpu=</samp> command-line option. </p> </dd> <dt> +<span>‘<samp class="samp">arch=</samp>’<a class="copiable-link" href="#index-arch_003d-function-attribute_002c-ARM"> ¶</a></span> +</dt> <dd> +<p>Specifies the architecture version and architectural extensions to use for this function. The behavior and permissible arguments are the same as for the <samp class="option">-march=</samp> command-line option. </p> <p>The above target attributes can be specified as follows: </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">__attribute__((target("arch=armv8-a+crc"))) +int +f (int a) +{ + return a + 5; +}</pre> +</div> <p>Additionally, the architectural extension string may be specified on its own. This can be used to turn on and off particular architectural extensions without having to specify a particular architecture version or core. Example: </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">__attribute__((target("+crc+nocrypto"))) +int +foo (int a) +{ + return a + 5; +}</pre> +</div> <p>In this example <code class="code">target("+crc+nocrypto")</code> enables the <code class="code">crc</code> extension and disables the <code class="code">crypto</code> extension for the function <code class="code">foo</code> without modifying an existing <samp class="option">-march=</samp> or <samp class="option">-mcpu</samp> option. </p> </dd> </dl> </dd> </dl> </div> <div class="nav-panel"> <p> Next: <a href="avr-function-attributes">AVR Function Attributes</a>, Previous: <a href="arc-function-attributes">ARC Function Attributes</a>, Up: <a href="function-attributes">Declaring Attributes of Functions</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br> + <a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/ARM-Function-Attributes.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/ARM-Function-Attributes.html</a> + </p> +</div> |
