6.31.19 MSP430 Function Attributes
These function attributes are supported by the MSP430 back end:
critical-
Critical functions disable interrupts upon entry and restore the previous interrupt state upon exit. Critical functions cannot also have the
nakedorreentrantattributes. They can have theinterruptattribute. interrupt-
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.
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
watchdogfor vector 26,nmifor vector 30 andresetfor vector 31 are recognized. naked-
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
asmstatements can safely be included in naked functions (see Basic Asm). While using extendedasmor a mixture of basicasmand C code may appear to work, they cannot be depended upon to work reliably and are not supported. reentrant-
Reentrant functions disable interrupts upon entry and enable them upon exit. Reentrant functions cannot also have the
nakedorcriticalattributes. They can have theinterruptattribute. wakeup-
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.
loweruppereither-
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.
The attributes work in conjunction with a linker script that has been augmented to specify where to place sections with a
.lowerand a.upperprefix. So, for example, as well as placing the.datasection, the script also specifies the placement of a.lower.dataand a.upper.datasection. The intention is thatlowersections 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.The
eitherattribute is special. It tells the linker to place the object into the correspondinglowersection if there is room for it. If there is insufficient room then the object is placed into the correspondinguppersection instead. Note that the placement algorithm is not very sophisticated. It does not attempt to find an optimal packing of thelowersections. It just makes one pass over the objects and does the best that it can. Using the -ffunction-sections and -fdata-sections command-line options can help the packing, however, since they produce smaller, easier to pack regions.
Next: NDS32 Function Attributes, Previous: MIPS Function Attributes, Up: Function Attributes [Contents][Index]
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/MSP430-Function-Attributes.html