1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<div class="subsection-level-extent" id="MSP430-Function-Attributes"> <div class="nav-panel"> <p> Next: <a href="nds32-function-attributes" accesskey="n" rel="next">NDS32 Function Attributes</a>, Previous: <a href="mips-function-attributes" accesskey="p" rel="prev">MIPS 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="MSP430-Function-Attributes-1"><span>6.33.20 MSP430 Function Attributes<a class="copiable-link" href="#MSP430-Function-Attributes-1"> ¶</a></span></h1> <p>These function attributes are supported by the MSP430 back end: </p> <dl class="table"> <dt>
<span><code class="code">critical</code><a class="copiable-link" href="#index-critical-function-attribute_002c-MSP430"> ¶</a></span>
</dt> <dd>
<p>Critical functions disable interrupts upon entry and restore the previous interrupt state upon exit. Critical functions cannot also have the <code class="code">naked</code>, <code class="code">reentrant</code> or <code class="code">interrupt</code> attributes. </p> <p>The MSP430 hardware ensures that interrupts are disabled on entry to <code class="code">interrupt</code> functions, and restores the previous interrupt state on exit. The <code class="code">critical</code> attribute is therefore redundant on <code class="code">interrupt</code> functions. </p> </dd> <dt>
<span><code class="code">interrupt</code><a class="copiable-link" href="#index-interrupt-function-attribute_002c-MSP430"> ¶</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 provide an argument to the interrupt attribute which specifies a name or number. If the argument is a number it indicates the slot in the interrupt vector table (0 - 31) to which this handler should be assigned. If the argument is a name it is treated as a symbolic name for the vector slot. These names should match up with appropriate entries in the linker script. By default the names <code class="code">watchdog</code> for vector 26, <code class="code">nmi</code> for vector 30 and <code class="code">reset</code> for vector 31 are recognized. </p> </dd> <dt>
<span><code class="code">naked</code><a class="copiable-link" href="#index-naked-function-attribute_002c-MSP430"> ¶</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">reentrant</code><a class="copiable-link" href="#index-reentrant-function-attribute_002c-MSP430"> ¶</a></span>
</dt> <dd>
<p>Reentrant functions disable interrupts upon entry and enable them upon exit. Reentrant functions cannot also have the <code class="code">naked</code> or <code class="code">critical</code> attributes. They can have the <code class="code">interrupt</code> attribute. </p> </dd> <dt>
<span><code class="code">wakeup</code><a class="copiable-link" href="#index-wakeup-function-attribute_002c-MSP430"> ¶</a></span>
</dt> <dd>
<p>This attribute only applies to interrupt functions. It is silently ignored if applied to a non-interrupt function. A wakeup interrupt function will rouse the processor from any low-power state that it might be in when the function exits. </p> </dd> <dt>
<span><code class="code">lower</code><a class="copiable-link" href="#index-lower-function-attribute_002c-MSP430"> ¶</a></span>
</dt> <dt><code class="code">upper</code></dt> <dt><code class="code">either</code></dt> <dd>
<p>On the MSP430 target these attributes can be used to specify whether the function or variable should be placed into low memory, high memory, or the placement should be left to the linker to decide. The attributes are only significant if compiling for the MSP430X architecture in the large memory model. </p> <p>The attributes work in conjunction with a linker script that has been augmented to specify where to place sections with a <code class="code">.lower</code> and a <code class="code">.upper</code> prefix. So, for example, as well as placing the <code class="code">.data</code> section, the script also specifies the placement of a <code class="code">.lower.data</code> and a <code class="code">.upper.data</code> section. The intention is that <code class="code">lower</code> sections are placed into a small but easier to access memory region and the upper sections are placed into a larger, but slower to access, region. </p> <p>The <code class="code">either</code> attribute is special. It tells the linker to place the object into the corresponding <code class="code">lower</code> section if there is room for it. If there is insufficient room then the object is placed into the corresponding <code class="code">upper</code> section instead. Note that the placement algorithm is not very sophisticated. It does not attempt to find an optimal packing of the <code class="code">lower</code> sections. It just makes one pass over the objects and does the best that it can. Using the <samp class="option">-ffunction-sections</samp> and <samp class="option">-fdata-sections</samp> command-line options can help the packing, however, since they produce smaller, easier to pack regions. </p>
</dd> </dl> </div> <div class="nav-panel"> <p> Next: <a href="nds32-function-attributes">NDS32 Function Attributes</a>, Previous: <a href="mips-function-attributes">MIPS 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/MSP430-Function-Attributes.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/MSP430-Function-Attributes.html</a>
</p>
</div>
|