MIPS-Function-Attributes.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>Using the GNU Compiler Collection (GCC): MIPS Function Attributes</title>
  20. <meta name="description" content="Using the GNU Compiler Collection (GCC): MIPS Function Attributes">
  21. <meta name="keywords" content="Using the GNU Compiler Collection (GCC): MIPS Function Attributes">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="MIPS-Function-Attributes"></a>
  63. <div class="header">
  64. <p>
  65. 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>
  66. </div>
  67. <hr>
  68. <a name="MIPS-Function-Attributes-1"></a>
  69. <h4 class="subsection">6.31.18 MIPS Function Attributes</h4>
  70. <p>These function attributes are supported by the MIPS back end:
  71. </p>
  72. <dl compact="compact">
  73. <dt><code>interrupt</code></dt>
  74. <dd><a name="index-interrupt-function-attribute_002c-MIPS"></a>
  75. <p>Use this attribute to indicate that the specified function is an interrupt
  76. handler. The compiler generates function entry and exit sequences suitable
  77. for use in an interrupt handler when this attribute is present.
  78. An optional argument is supported for the interrupt attribute which allows
  79. the interrupt mode to be described. By default GCC assumes the external
  80. interrupt controller (EIC) mode is in use, this can be explicitly set using
  81. <code>eic</code>. When interrupts are non-masked then the requested Interrupt
  82. Priority Level (IPL) is copied to the current IPL which has the effect of only
  83. enabling higher priority interrupts. To use vectored interrupt mode use
  84. the argument <code>vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]</code>, this will change
  85. the behavior of the non-masked interrupt support and GCC will arrange to mask
  86. all interrupts from sw0 up to and including the specified interrupt vector.
  87. </p>
  88. <p>You can use the following attributes to modify the behavior
  89. of an interrupt handler:
  90. </p><dl compact="compact">
  91. <dt><code>use_shadow_register_set</code></dt>
  92. <dd><a name="index-use_005fshadow_005fregister_005fset-function-attribute_002c-MIPS"></a>
  93. <p>Assume that the handler uses a shadow register set, instead of
  94. the main general-purpose registers. An optional argument <code>intstack</code> is
  95. supported to indicate that the shadow register set contains a valid stack
  96. pointer.
  97. </p>
  98. </dd>
  99. <dt><code>keep_interrupts_masked</code></dt>
  100. <dd><a name="index-keep_005finterrupts_005fmasked-function-attribute_002c-MIPS"></a>
  101. <p>Keep interrupts masked for the whole function. Without this attribute,
  102. GCC tries to reenable interrupts for as much of the function as it can.
  103. </p>
  104. </dd>
  105. <dt><code>use_debug_exception_return</code></dt>
  106. <dd><a name="index-use_005fdebug_005fexception_005freturn-function-attribute_002c-MIPS"></a>
  107. <p>Return using the <code>deret</code> instruction. Interrupt handlers that don&rsquo;t
  108. have this attribute return using <code>eret</code> instead.
  109. </p></dd>
  110. </dl>
  111. <p>You can use any combination of these attributes, as shown below:
  112. </p><div class="smallexample">
  113. <pre class="smallexample">void __attribute__ ((interrupt)) v0 ();
  114. void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
  115. void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
  116. void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
  117. void __attribute__ ((interrupt, use_shadow_register_set,
  118. keep_interrupts_masked)) v4 ();
  119. void __attribute__ ((interrupt, use_shadow_register_set,
  120. use_debug_exception_return)) v5 ();
  121. void __attribute__ ((interrupt, keep_interrupts_masked,
  122. use_debug_exception_return)) v6 ();
  123. void __attribute__ ((interrupt, use_shadow_register_set,
  124. keep_interrupts_masked,
  125. use_debug_exception_return)) v7 ();
  126. void __attribute__ ((interrupt(&quot;eic&quot;))) v8 ();
  127. void __attribute__ ((interrupt(&quot;vector=hw3&quot;))) v9 ();
  128. </pre></div>
  129. </dd>
  130. <dt><code>long_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-near-function-attribute_002c-MIPS"></a>
  136. <a name="index-far-function-attribute_002c-MIPS"></a>
  137. <p>These attributes specify how a particular function is called on MIPS.
  138. The attributes override the <samp>-mlong-calls</samp> (see <a href="MIPS-Options.html#MIPS-Options">MIPS Options</a>)
  139. command-line switch. The <code>long_call</code> and <code>far</code> attributes are
  140. synonyms, and cause the compiler to always call
  141. the function by first loading its address into a register, and then using
  142. the contents of that register. The <code>near</code> attribute has the opposite
  143. effect; it specifies that non-PIC calls should be made using the more
  144. efficient <code>jal</code> instruction.
  145. </p>
  146. </dd>
  147. <dt><code>mips16</code></dt>
  148. <dt><code>nomips16</code></dt>
  149. <dd><a name="index-mips16-function-attribute_002c-MIPS"></a>
  150. <a name="index-nomips16-function-attribute_002c-MIPS"></a>
  151. <p>On MIPS targets, you can use the <code>mips16</code> and <code>nomips16</code>
  152. function attributes to locally select or turn off MIPS16 code generation.
  153. A function with the <code>mips16</code> attribute is emitted as MIPS16 code,
  154. while MIPS16 code generation is disabled for functions with the
  155. <code>nomips16</code> attribute. These attributes override the
  156. <samp>-mips16</samp> and <samp>-mno-mips16</samp> options on the command line
  157. (see <a href="MIPS-Options.html#MIPS-Options">MIPS Options</a>).
  158. </p>
  159. <p>When compiling files containing mixed MIPS16 and non-MIPS16 code, the
  160. preprocessor symbol <code>__mips16</code> reflects the setting on the command line,
  161. not that within individual functions. Mixed MIPS16 and non-MIPS16 code
  162. may interact badly with some GCC extensions such as <code>__builtin_apply</code>
  163. (see <a href="Constructing-Calls.html#Constructing-Calls">Constructing Calls</a>).
  164. </p>
  165. </dd>
  166. <dt><code>micromips, MIPS</code></dt>
  167. <dt><code>nomicromips, MIPS</code></dt>
  168. <dd><a name="index-micromips-function-attribute"></a>
  169. <a name="index-nomicromips-function-attribute"></a>
  170. <p>On MIPS targets, you can use the <code>micromips</code> and <code>nomicromips</code>
  171. function attributes to locally select or turn off microMIPS code generation.
  172. A function with the <code>micromips</code> attribute is emitted as microMIPS code,
  173. while microMIPS code generation is disabled for functions with the
  174. <code>nomicromips</code> attribute. These attributes override the
  175. <samp>-mmicromips</samp> and <samp>-mno-micromips</samp> options on the command line
  176. (see <a href="MIPS-Options.html#MIPS-Options">MIPS Options</a>).
  177. </p>
  178. <p>When compiling files containing mixed microMIPS and non-microMIPS code, the
  179. preprocessor symbol <code>__mips_micromips</code> reflects the setting on the
  180. command line,
  181. not that within individual functions. Mixed microMIPS and non-microMIPS code
  182. may interact badly with some GCC extensions such as <code>__builtin_apply</code>
  183. (see <a href="Constructing-Calls.html#Constructing-Calls">Constructing Calls</a>).
  184. </p>
  185. </dd>
  186. <dt><code>nocompression</code></dt>
  187. <dd><a name="index-nocompression-function-attribute_002c-MIPS"></a>
  188. <p>On MIPS targets, you can use the <code>nocompression</code> function attribute
  189. to locally turn off MIPS16 and microMIPS code generation. This attribute
  190. overrides the <samp>-mips16</samp> and <samp>-mmicromips</samp> options on the
  191. command line (see <a href="MIPS-Options.html#MIPS-Options">MIPS Options</a>).
  192. </p></dd>
  193. </dl>
  194. <hr>
  195. <div class="header">
  196. <p>
  197. 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>
  198. </div>
  199. </body>
  200. </html>