summaryrefslogtreecommitdiff
path: root/devdocs/gcc~13/avr-function-attributes.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/gcc~13/avr-function-attributes.html')
-rw-r--r--devdocs/gcc~13/avr-function-attributes.html36
1 files changed, 36 insertions, 0 deletions
diff --git a/devdocs/gcc~13/avr-function-attributes.html b/devdocs/gcc~13/avr-function-attributes.html
new file mode 100644
index 00000000..556c063d
--- /dev/null
+++ b/devdocs/gcc~13/avr-function-attributes.html
@@ -0,0 +1,36 @@
+<div class="subsection-level-extent" id="AVR-Function-Attributes"> <div class="nav-panel"> <p> Next: <a href="blackfin-function-attributes" accesskey="n" rel="next">Blackfin Function Attributes</a>, Previous: <a href="arm-function-attributes" accesskey="p" rel="prev">ARM 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="AVR-Function-Attributes-1"><span>6.33.6 AVR Function Attributes<a class="copiable-link" href="#AVR-Function-Attributes-1"> ¶</a></span></h1> <p>These function attributes are supported by the AVR back end: </p> <dl class="table"> <dt>
+<span><code class="code">interrupt</code><a class="copiable-link" href="#index-interrupt-function-attribute_002c-AVR"> ¶</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>On the AVR, the hardware globally disables interrupts when an interrupt is executed. The first instruction of an interrupt handler declared with this attribute is a <code class="code">SEI</code> instruction to re-enable interrupts. See also the <code class="code">signal</code> function attribute that does not insert a <code class="code">SEI</code> instruction. If both <code class="code">signal</code> and <code class="code">interrupt</code> are specified for the same function, <code class="code">signal</code> is silently ignored. </p> </dd> <dt>
+<span><code class="code">naked</code><a class="copiable-link" href="#index-naked-function-attribute_002c-AVR"> ¶</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">no_gccisr</code><a class="copiable-link" href="#index-no_005fgccisr-function-attribute_002c-AVR"> ¶</a></span>
+</dt> <dd>
+<p>Do not use <code class="code">__gcc_isr</code> pseudo instructions in a function with the <code class="code">interrupt</code> or <code class="code">signal</code> attribute aka. interrupt service routine (ISR). Use this attribute if the preamble of the ISR prologue should always read </p>
+<div class="example"> <pre class="example-preformatted" data-language="cpp">push __zero_reg__
+push __tmp_reg__
+in __tmp_reg__, __SREG__
+push __tmp_reg__
+clr __zero_reg__</pre>
+</div> <p>and accordingly for the postamble of the epilogue — no matter whether the mentioned registers are actually used in the ISR or not. Situations where you might want to use this attribute include: </p>
+<ul class="itemize mark-bullet"> <li>Code that (effectively) clobbers bits of <code class="code">SREG</code> other than the <code class="code">I</code>-flag by writing to the memory location of <code class="code">SREG</code>. </li>
+<li>Code that uses inline assembler to jump to a different function which expects (parts of) the prologue code as outlined above to be present. </li>
+</ul> <p>To disable <code class="code">__gcc_isr</code> generation for the whole compilation unit, there is option <samp class="option">-mno-gas-isr-prologues</samp>, see <a class="pxref" href="avr-options">AVR Options</a>. </p> </dd> <dt>
+ <span><code class="code">OS_main</code><a class="copiable-link" href="#index-OS_005fmain-function-attribute_002c-AVR"> ¶</a></span>
+</dt> <dt><code class="code">OS_task</code></dt> <dd>
+<p>On AVR, functions with the <code class="code">OS_main</code> or <code class="code">OS_task</code> attribute do not save/restore any call-saved register in their prologue/epilogue. </p> <p>The <code class="code">OS_main</code> attribute can be used when there <em class="emph">is guarantee</em> that interrupts are disabled at the time when the function is entered. This saves resources when the stack pointer has to be changed to set up a frame for local variables. </p> <p>The <code class="code">OS_task</code> attribute can be used when there is <em class="emph">no guarantee</em> that interrupts are disabled at that time when the function is entered like for, e.g. task functions in a multi-threading operating system. In that case, changing the stack pointer register is guarded by save/clear/restore of the global interrupt enable flag. </p> <p>The differences to the <code class="code">naked</code> function attribute are: </p>
+<ul class="itemize mark-bullet"> <li>
+<code class="code">naked</code> functions do not have a return instruction whereas <code class="code">OS_main</code> and <code class="code">OS_task</code> functions have a <code class="code">RET</code> or <code class="code">RETI</code> return instruction. </li>
+<li>
+<code class="code">naked</code> functions do not set up a frame for local variables or a frame pointer whereas <code class="code">OS_main</code> and <code class="code">OS_task</code> do this as needed. </li>
+</ul> </dd> <dt>
+<span><code class="code">signal</code><a class="copiable-link" href="#index-signal-function-attribute_002c-AVR"> ¶</a></span>
+</dt> <dd>
+<p>Use this attribute on the AVR 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>See also the <code class="code">interrupt</code> function attribute. </p> <p>The AVR hardware globally disables interrupts when an interrupt is executed. Interrupt handler functions defined with the <code class="code">signal</code> attribute do not re-enable interrupts. It is save to enable interrupts in a <code class="code">signal</code> handler. This “save” only applies to the code generated by the compiler and not to the IRQ layout of the application which is responsibility of the application. </p> <p>If both <code class="code">signal</code> and <code class="code">interrupt</code> are specified for the same function, <code class="code">signal</code> is silently ignored. </p>
+</dd> </dl> </div> <div class="nav-panel"> <p> Next: <a href="blackfin-function-attributes">Blackfin Function Attributes</a>, Previous: <a href="arm-function-attributes">ARM 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">
+ &copy; 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/AVR-Function-Attributes.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/AVR-Function-Attributes.html</a>
+ </p>
+</div>