You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 line
11KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>MIPS Function Attributes (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="MIPS Function Attributes (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="MIPS Function Attributes (Using the GNU Compiler Collection (GCC))">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Function-Attributes.html#Function-Attributes" rel="up" title="Function Attributes">
  30. <link href="MSP430-Function-Attributes.html#MSP430-Function-Attributes" rel="next" title="MSP430 Function Attributes">
  31. <link href="Microsoft-Windows-Function-Attributes.html#Microsoft-Windows-Function-Attributes" rel="prev" title="Microsoft Windows Function Attributes">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="MIPS-Function-Attributes"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="MSP430-Function-Attributes.html#MSP430-Function-Attributes" accesskey="n" rel="next">MSP430 Function Attributes</a>, Previous: <a href="Microsoft-Windows-Function-Attributes.html#Microsoft-Windows-Function-Attributes" accesskey="p" rel="prev">Microsoft Windows Function Attributes</a>, Up: <a href="Function-Attributes.html#Function-Attributes" accesskey="u" rel="up">Function Attributes</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="MIPS-Function-Attributes-1"></a>
  68. <h4 class="subsection">6.33.21 MIPS Function Attributes</h4>
  69. <p>These function attributes are supported by the MIPS back end:
  70. </p>
  71. <dl compact="compact">
  72. <dt><code>interrupt</code></dt>
  73. <dd><a name="index-interrupt-function-attribute_002c-MIPS"></a>
  74. <p>Use this attribute to indicate that the specified function is an interrupt
  75. handler. The compiler generates function entry and exit sequences suitable
  76. for use in an interrupt handler when this attribute is present.
  77. An optional argument is supported for the interrupt attribute which allows
  78. the interrupt mode to be described. By default GCC assumes the external
  79. interrupt controller (EIC) mode is in use, this can be explicitly set using
  80. <code>eic</code>. When interrupts are non-masked then the requested Interrupt
  81. Priority Level (IPL) is copied to the current IPL which has the effect of only
  82. enabling higher priority interrupts. To use vectored interrupt mode use
  83. the argument <code>vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]</code>, this will change
  84. the behavior of the non-masked interrupt support and GCC will arrange to mask
  85. all interrupts from sw0 up to and including the specified interrupt vector.
  86. </p>
  87. <p>You can use the following attributes to modify the behavior
  88. of an interrupt handler:
  89. </p><dl compact="compact">
  90. <dt><code>use_shadow_register_set</code></dt>
  91. <dd><a name="index-use_005fshadow_005fregister_005fset-function-attribute_002c-MIPS"></a>
  92. <p>Assume that the handler uses a shadow register set, instead of
  93. the main general-purpose registers. An optional argument <code>intstack</code> is
  94. supported to indicate that the shadow register set contains a valid stack
  95. pointer.
  96. </p>
  97. </dd>
  98. <dt><code>keep_interrupts_masked</code></dt>
  99. <dd><a name="index-keep_005finterrupts_005fmasked-function-attribute_002c-MIPS"></a>
  100. <p>Keep interrupts masked for the whole function. Without this attribute,
  101. GCC tries to reenable interrupts for as much of the function as it can.
  102. </p>
  103. </dd>
  104. <dt><code>use_debug_exception_return</code></dt>
  105. <dd><a name="index-use_005fdebug_005fexception_005freturn-function-attribute_002c-MIPS"></a>
  106. <p>Return using the <code>deret</code> instruction. Interrupt handlers that don&rsquo;t
  107. have this attribute return using <code>eret</code> instead.
  108. </p></dd>
  109. </dl>
  110. <p>You can use any combination of these attributes, as shown below:
  111. </p><div class="smallexample">
  112. <pre class="smallexample">void __attribute__ ((interrupt)) v0 ();
  113. void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
  114. void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
  115. void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
  116. void __attribute__ ((interrupt, use_shadow_register_set,
  117. keep_interrupts_masked)) v4 ();
  118. void __attribute__ ((interrupt, use_shadow_register_set,
  119. use_debug_exception_return)) v5 ();
  120. void __attribute__ ((interrupt, keep_interrupts_masked,
  121. use_debug_exception_return)) v6 ();
  122. void __attribute__ ((interrupt, use_shadow_register_set,
  123. keep_interrupts_masked,
  124. use_debug_exception_return)) v7 ();
  125. void __attribute__ ((interrupt(&quot;eic&quot;))) v8 ();
  126. void __attribute__ ((interrupt(&quot;vector=hw3&quot;))) v9 ();
  127. </pre></div>
  128. </dd>
  129. <dt><code>long_call</code></dt>
  130. <dt><code>short_call</code></dt>
  131. <dt><code>near</code></dt>
  132. <dt><code>far</code></dt>
  133. <dd><a name="index-indirect-calls_002c-MIPS"></a>
  134. <a name="index-long_005fcall-function-attribute_002c-MIPS"></a>
  135. <a name="index-short_005fcall-function-attribute_002c-MIPS"></a>
  136. <a name="index-near-function-attribute_002c-MIPS"></a>
  137. <a name="index-far-function-attribute_002c-MIPS"></a>
  138. <p>These attributes specify how a particular function is called on MIPS.
  139. The attributes override the <samp>-mlong-calls</samp> (see <a href="MIPS-Options.html#MIPS-Options">MIPS Options</a>)
  140. command-line switch. The <code>long_call</code> and <code>far</code> attributes are
  141. synonyms, and cause the compiler to always call
  142. the function by first loading its address into a register, and then using
  143. the contents of that register. The <code>short_call</code> and <code>near</code>
  144. attributes are synonyms, and have the opposite
  145. effect; they specify that non-PIC calls should be made using the more
  146. efficient <code>jal</code> instruction.
  147. </p>
  148. </dd>
  149. <dt><code>mips16</code></dt>
  150. <dt><code>nomips16</code></dt>
  151. <dd><a name="index-mips16-function-attribute_002c-MIPS"></a>
  152. <a name="index-nomips16-function-attribute_002c-MIPS"></a>
  153. <p>On MIPS targets, you can use the <code>mips16</code> and <code>nomips16</code>
  154. function attributes to locally select or turn off MIPS16 code generation.
  155. A function with the <code>mips16</code> attribute is emitted as MIPS16 code,
  156. while MIPS16 code generation is disabled for functions with the
  157. <code>nomips16</code> attribute. These attributes override the
  158. <samp>-mips16</samp> and <samp>-mno-mips16</samp> options on the command line
  159. (see <a href="MIPS-Options.html#MIPS-Options">MIPS Options</a>).
  160. </p>
  161. <p>When compiling files containing mixed MIPS16 and non-MIPS16 code, the
  162. preprocessor symbol <code>__mips16</code> reflects the setting on the command line,
  163. not that within individual functions. Mixed MIPS16 and non-MIPS16 code
  164. may interact badly with some GCC extensions such as <code>__builtin_apply</code>
  165. (see <a href="Constructing-Calls.html#Constructing-Calls">Constructing Calls</a>).
  166. </p>
  167. </dd>
  168. <dt><code>micromips, MIPS</code></dt>
  169. <dt><code>nomicromips, MIPS</code></dt>
  170. <dd><a name="index-micromips-function-attribute"></a>
  171. <a name="index-nomicromips-function-attribute"></a>
  172. <p>On MIPS targets, you can use the <code>micromips</code> and <code>nomicromips</code>
  173. function attributes to locally select or turn off microMIPS code generation.
  174. A function with the <code>micromips</code> attribute is emitted as microMIPS code,
  175. while microMIPS code generation is disabled for functions with the
  176. <code>nomicromips</code> attribute. These attributes override the
  177. <samp>-mmicromips</samp> and <samp>-mno-micromips</samp> options on the command line
  178. (see <a href="MIPS-Options.html#MIPS-Options">MIPS Options</a>).
  179. </p>
  180. <p>When compiling files containing mixed microMIPS and non-microMIPS code, the
  181. preprocessor symbol <code>__mips_micromips</code> reflects the setting on the
  182. command line,
  183. not that within individual functions. Mixed microMIPS and non-microMIPS code
  184. may interact badly with some GCC extensions such as <code>__builtin_apply</code>
  185. (see <a href="Constructing-Calls.html#Constructing-Calls">Constructing Calls</a>).
  186. </p>
  187. </dd>
  188. <dt><code>nocompression</code></dt>
  189. <dd><a name="index-nocompression-function-attribute_002c-MIPS"></a>
  190. <p>On MIPS targets, you can use the <code>nocompression</code> function attribute
  191. to locally turn off MIPS16 and microMIPS code generation. This attribute
  192. overrides the <samp>-mips16</samp> and <samp>-mmicromips</samp> options on the
  193. command line (see <a href="MIPS-Options.html#MIPS-Options">MIPS Options</a>).
  194. </p></dd>
  195. </dl>
  196. <hr>
  197. <div class="header">
  198. <p>
  199. Next: <a href="MSP430-Function-Attributes.html#MSP430-Function-Attributes" accesskey="n" rel="next">MSP430 Function Attributes</a>, Previous: <a href="Microsoft-Windows-Function-Attributes.html#Microsoft-Windows-Function-Attributes" accesskey="p" rel="prev">Microsoft Windows Function Attributes</a>, Up: <a href="Function-Attributes.html#Function-Attributes" accesskey="u" rel="up">Function Attributes</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  200. </div>
  201. </body>
  202. </html>