diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/gcc~13/mips-function-attributes.html | |
new repository
Diffstat (limited to 'devdocs/gcc~13/mips-function-attributes.html')
| -rw-r--r-- | devdocs/gcc~13/mips-function-attributes.html | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/devdocs/gcc~13/mips-function-attributes.html b/devdocs/gcc~13/mips-function-attributes.html new file mode 100644 index 00000000..a6f22e64 --- /dev/null +++ b/devdocs/gcc~13/mips-function-attributes.html @@ -0,0 +1,46 @@ +<div class="subsection-level-extent" id="MIPS-Function-Attributes"> <div class="nav-panel"> <p> Next: <a href="msp430-function-attributes" accesskey="n" rel="next">MSP430 Function Attributes</a>, Previous: <a href="microsoft-windows-function-attributes" accesskey="p" rel="prev">Microsoft Windows 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="MIPS-Function-Attributes-1"><span>6.33.19 MIPS Function Attributes<a class="copiable-link" href="#MIPS-Function-Attributes-1"> ¶</a></span></h1> <p>These function attributes are supported by the MIPS back end: </p> <dl class="table"> <dt> +<span><code class="code">interrupt</code><a class="copiable-link" href="#index-interrupt-function-attribute_002c-MIPS"> ¶</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. An optional argument is supported for the interrupt attribute which allows the interrupt mode to be described. By default GCC assumes the external interrupt controller (EIC) mode is in use, this can be explicitly set using <code class="code">eic</code>. When interrupts are non-masked then the requested Interrupt Priority Level (IPL) is copied to the current IPL which has the effect of only enabling higher priority interrupts. To use vectored interrupt mode use the argument <code class="code">vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]</code>, this will change the behavior of the non-masked interrupt support and GCC will arrange to mask all interrupts from sw0 up to and including the specified interrupt vector. </p> <p>You can use the following attributes to modify the behavior of an interrupt handler: </p> +<dl class="table"> <dt> +<span><code class="code">use_shadow_register_set</code><a class="copiable-link" href="#index-use_005fshadow_005fregister_005fset-function-attribute_002c-MIPS"> ¶</a></span> +</dt> <dd> +<p>Assume that the handler uses a shadow register set, instead of the main general-purpose registers. An optional argument <code class="code">intstack</code> is supported to indicate that the shadow register set contains a valid stack pointer. </p> </dd> <dt> +<span><code class="code">keep_interrupts_masked</code><a class="copiable-link" href="#index-keep_005finterrupts_005fmasked-function-attribute_002c-MIPS"> ¶</a></span> +</dt> <dd> +<p>Keep interrupts masked for the whole function. Without this attribute, GCC tries to reenable interrupts for as much of the function as it can. </p> </dd> <dt> +<span><code class="code">use_debug_exception_return</code><a class="copiable-link" href="#index-use_005fdebug_005fexception_005freturn-function-attribute_002c-MIPS"> ¶</a></span> +</dt> <dd><p>Return using the <code class="code">deret</code> instruction. Interrupt handlers that don’t have this attribute return using <code class="code">eret</code> instead. </p></dd> </dl> <p>You can use any combination of these attributes, as shown below: </p> +<div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">void __attribute__ ((interrupt)) v0 (); +void __attribute__ ((interrupt, use_shadow_register_set)) v1 (); +void __attribute__ ((interrupt, keep_interrupts_masked)) v2 (); +void __attribute__ ((interrupt, use_debug_exception_return)) v3 (); +void __attribute__ ((interrupt, use_shadow_register_set, + keep_interrupts_masked)) v4 (); +void __attribute__ ((interrupt, use_shadow_register_set, + use_debug_exception_return)) v5 (); +void __attribute__ ((interrupt, keep_interrupts_masked, + use_debug_exception_return)) v6 (); +void __attribute__ ((interrupt, use_shadow_register_set, + keep_interrupts_masked, + use_debug_exception_return)) v7 (); +void __attribute__ ((interrupt("eic"))) v8 (); +void __attribute__ ((interrupt("vector=hw3"))) v9 ();</pre> +</div> </dd> <dt> + <span><code class="code">long_call</code><a class="copiable-link" href="#index-indirect-calls_002c-MIPS"> ¶</a></span> +</dt> <dt><code class="code">short_call</code></dt> <dt><code class="code">near</code></dt> <dt><code class="code">far</code></dt> <dd> +<p>These attributes specify how a particular function is called on MIPS. The attributes override the <samp class="option">-mlong-calls</samp> (see <a class="pxref" href="mips-options">MIPS Options</a>) command-line switch. The <code class="code">long_call</code> and <code class="code">far</code> attributes are synonyms, and cause the compiler to always call the function by first loading its address into a register, and then using the contents of that register. The <code class="code">short_call</code> and <code class="code">near</code> attributes are synonyms, and have the opposite effect; they specify that non-PIC calls should be made using the more efficient <code class="code">jal</code> instruction. </p> </dd> <dt> + <span><code class="code">mips16</code><a class="copiable-link" href="#index-mips16-function-attribute_002c-MIPS"> ¶</a></span> +</dt> <dt><code class="code">nomips16</code></dt> <dd> <p>On MIPS targets, you can use the <code class="code">mips16</code> and <code class="code">nomips16</code> function attributes to locally select or turn off MIPS16 code generation. A function with the <code class="code">mips16</code> attribute is emitted as MIPS16 code, while MIPS16 code generation is disabled for functions with the <code class="code">nomips16</code> attribute. These attributes override the <samp class="option">-mips16</samp> and <samp class="option">-mno-mips16</samp> options on the command line (see <a class="pxref" href="mips-options">MIPS Options</a>). </p> <p>When compiling files containing mixed MIPS16 and non-MIPS16 code, the preprocessor symbol <code class="code">__mips16</code> reflects the setting on the command line, not that within individual functions. Mixed MIPS16 and non-MIPS16 code may interact badly with some GCC extensions such as <code class="code">__builtin_apply</code> (see <a class="pxref" href="constructing-calls">Constructing Function Calls</a>). </p> </dd> <dt> + <span><code class="code">micromips, MIPS</code><a class="copiable-link" href="#index-micromips-function-attribute"> ¶</a></span> +</dt> <dt><code class="code">nomicromips, MIPS</code></dt> <dd> <p>On MIPS targets, you can use the <code class="code">micromips</code> and <code class="code">nomicromips</code> function attributes to locally select or turn off microMIPS code generation. A function with the <code class="code">micromips</code> attribute is emitted as microMIPS code, while microMIPS code generation is disabled for functions with the <code class="code">nomicromips</code> attribute. These attributes override the <samp class="option">-mmicromips</samp> and <samp class="option">-mno-micromips</samp> options on the command line (see <a class="pxref" href="mips-options">MIPS Options</a>). </p> <p>When compiling files containing mixed microMIPS and non-microMIPS code, the preprocessor symbol <code class="code">__mips_micromips</code> reflects the setting on the command line, not that within individual functions. Mixed microMIPS and non-microMIPS code may interact badly with some GCC extensions such as <code class="code">__builtin_apply</code> (see <a class="pxref" href="constructing-calls">Constructing Function Calls</a>). </p> </dd> <dt> +<span><code class="code">nocompression</code><a class="copiable-link" href="#index-nocompression-function-attribute_002c-MIPS"> ¶</a></span> +</dt> <dd> +<p>On MIPS targets, you can use the <code class="code">nocompression</code> function attribute to locally turn off MIPS16 and microMIPS code generation. This attribute overrides the <samp class="option">-mips16</samp> and <samp class="option">-mmicromips</samp> options on the command line (see <a class="pxref" href="mips-options">MIPS Options</a>). </p> </dd> <dt> +<span><code class="code">use_hazard_barrier_return</code><a class="copiable-link" href="#index-use_005fhazard_005fbarrier_005freturn-function-attribute_002c-MIPS"> ¶</a></span> +</dt> <dd><p>This function attribute instructs the compiler to generate a hazard barrier return that clears all execution and instruction hazards while returning, instead of generating a normal return instruction. </p></dd> </dl> </div> <div class="nav-panel"> <p> Next: <a href="msp430-function-attributes">MSP430 Function Attributes</a>, Previous: <a href="microsoft-windows-function-attributes">Microsoft Windows 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/MIPS-Function-Attributes.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/MIPS-Function-Attributes.html</a> + </p> +</div> |
