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.

261 lines
12KB

  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>Stack Arguments (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Stack Arguments (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Stack Arguments (GNU Compiler Collection (GCC) Internals)">
  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="Stack-and-Calling.html#Stack-and-Calling" rel="up" title="Stack and Calling">
  30. <link href="Register-Arguments.html#Register-Arguments" rel="next" title="Register Arguments">
  31. <link href="Elimination.html#Elimination" rel="prev" title="Elimination">
  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="Stack-Arguments"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Register-Arguments.html#Register-Arguments" accesskey="n" rel="next">Register Arguments</a>, Previous: <a href="Elimination.html#Elimination" accesskey="p" rel="prev">Elimination</a>, Up: <a href="Stack-and-Calling.html#Stack-and-Calling" accesskey="u" rel="up">Stack and Calling</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="Passing-Function-Arguments-on-the-Stack"></a>
  68. <h4 class="subsection">18.9.6 Passing Function Arguments on the Stack</h4>
  69. <a name="index-arguments-on-stack"></a>
  70. <a name="index-stack-arguments"></a>
  71. <p>The macros in this section control how arguments are passed
  72. on the stack. See the following section for other macros that
  73. control passing certain arguments in registers.
  74. </p>
  75. <dl>
  76. <dt><a name="index-TARGET_005fPROMOTE_005fPROTOTYPES"></a>Target Hook: <em>bool</em> <strong>TARGET_PROMOTE_PROTOTYPES</strong> <em>(const_tree <var>fntype</var>)</em></dt>
  77. <dd><p>This target hook returns <code>true</code> if an argument declared in a
  78. prototype as an integral type smaller than <code>int</code> should actually be
  79. passed as an <code>int</code>. In addition to avoiding errors in certain
  80. cases of mismatch, it also makes for better code on certain machines.
  81. The default is to not promote prototypes.
  82. </p></dd></dl>
  83. <dl>
  84. <dt><a name="index-PUSH_005fARGS"></a>Macro: <strong>PUSH_ARGS</strong></dt>
  85. <dd><p>A C expression. If nonzero, push insns will be used to pass
  86. outgoing arguments.
  87. If the target machine does not have a push instruction, set it to zero.
  88. That directs GCC to use an alternate strategy: to
  89. allocate the entire argument block and then store the arguments into
  90. it. When <code>PUSH_ARGS</code> is nonzero, <code>PUSH_ROUNDING</code> must be defined too.
  91. </p></dd></dl>
  92. <dl>
  93. <dt><a name="index-PUSH_005fARGS_005fREVERSED"></a>Macro: <strong>PUSH_ARGS_REVERSED</strong></dt>
  94. <dd><p>A C expression. If nonzero, function arguments will be evaluated from
  95. last to first, rather than from first to last. If this macro is not
  96. defined, it defaults to <code>PUSH_ARGS</code> on targets where the stack
  97. and args grow in opposite directions, and 0 otherwise.
  98. </p></dd></dl>
  99. <dl>
  100. <dt><a name="index-PUSH_005fROUNDING"></a>Macro: <strong>PUSH_ROUNDING</strong> <em>(<var>npushed</var>)</em></dt>
  101. <dd><p>A C expression that is the number of bytes actually pushed onto the
  102. stack when an instruction attempts to push <var>npushed</var> bytes.
  103. </p>
  104. <p>On some machines, the definition
  105. </p>
  106. <div class="smallexample">
  107. <pre class="smallexample">#define PUSH_ROUNDING(BYTES) (BYTES)
  108. </pre></div>
  109. <p>will suffice. But on other machines, instructions that appear
  110. to push one byte actually push two bytes in an attempt to maintain
  111. alignment. Then the definition should be
  112. </p>
  113. <div class="smallexample">
  114. <pre class="smallexample">#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) &amp; ~1)
  115. </pre></div>
  116. <p>If the value of this macro has a type, it should be an unsigned type.
  117. </p></dd></dl>
  118. <a name="index-outgoing_005fargs_005fsize"></a>
  119. <a name="index-crtl_002d_003eoutgoing_005fargs_005fsize"></a>
  120. <dl>
  121. <dt><a name="index-ACCUMULATE_005fOUTGOING_005fARGS"></a>Macro: <strong>ACCUMULATE_OUTGOING_ARGS</strong></dt>
  122. <dd><p>A C expression. If nonzero, the maximum amount of space required for outgoing arguments
  123. will be computed and placed into
  124. <code>crtl-&gt;outgoing_args_size</code>. No space will be pushed
  125. onto the stack for each call; instead, the function prologue should
  126. increase the stack frame size by this amount.
  127. </p>
  128. <p>Setting both <code>PUSH_ARGS</code> and <code>ACCUMULATE_OUTGOING_ARGS</code>
  129. is not proper.
  130. </p></dd></dl>
  131. <dl>
  132. <dt><a name="index-REG_005fPARM_005fSTACK_005fSPACE"></a>Macro: <strong>REG_PARM_STACK_SPACE</strong> <em>(<var>fndecl</var>)</em></dt>
  133. <dd><p>Define this macro if functions should assume that stack space has been
  134. allocated for arguments even when their values are passed in
  135. registers.
  136. </p>
  137. <p>The value of this macro is the size, in bytes, of the area reserved for
  138. arguments passed in registers for the function represented by <var>fndecl</var>,
  139. which can be zero if GCC is calling a library function.
  140. The argument <var>fndecl</var> can be the FUNCTION_DECL, or the type itself
  141. of the function.
  142. </p>
  143. <p>This space can be allocated by the caller, or be a part of the
  144. machine-dependent stack frame: <code>OUTGOING_REG_PARM_STACK_SPACE</code> says
  145. which.
  146. </p></dd></dl>
  147. <dl>
  148. <dt><a name="index-INCOMING_005fREG_005fPARM_005fSTACK_005fSPACE"></a>Macro: <strong>INCOMING_REG_PARM_STACK_SPACE</strong> <em>(<var>fndecl</var>)</em></dt>
  149. <dd><p>Like <code>REG_PARM_STACK_SPACE</code>, but for incoming register arguments.
  150. Define this macro if space guaranteed when compiling a function body
  151. is different to space required when making a call, a situation that
  152. can arise with K&amp;R style function definitions.
  153. </p></dd></dl>
  154. <dl>
  155. <dt><a name="index-OUTGOING_005fREG_005fPARM_005fSTACK_005fSPACE"></a>Macro: <strong>OUTGOING_REG_PARM_STACK_SPACE</strong> <em>(<var>fntype</var>)</em></dt>
  156. <dd><p>Define this to a nonzero value if it is the responsibility of the
  157. caller to allocate the area reserved for arguments passed in registers
  158. when calling a function of <var>fntype</var>. <var>fntype</var> may be NULL
  159. if the function called is a library function.
  160. </p>
  161. <p>If <code>ACCUMULATE_OUTGOING_ARGS</code> is defined, this macro controls
  162. whether the space for these arguments counts in the value of
  163. <code>crtl-&gt;outgoing_args_size</code>.
  164. </p></dd></dl>
  165. <dl>
  166. <dt><a name="index-STACK_005fPARMS_005fIN_005fREG_005fPARM_005fAREA"></a>Macro: <strong>STACK_PARMS_IN_REG_PARM_AREA</strong></dt>
  167. <dd><p>Define this macro if <code>REG_PARM_STACK_SPACE</code> is defined, but the
  168. stack parameters don&rsquo;t skip the area specified by it.
  169. </p>
  170. <p>Normally, when a parameter is not passed in registers, it is placed on the
  171. stack beyond the <code>REG_PARM_STACK_SPACE</code> area. Defining this macro
  172. suppresses this behavior and causes the parameter to be passed on the
  173. stack in its natural location.
  174. </p></dd></dl>
  175. <dl>
  176. <dt><a name="index-TARGET_005fRETURN_005fPOPS_005fARGS"></a>Target Hook: <em>poly_int64</em> <strong>TARGET_RETURN_POPS_ARGS</strong> <em>(tree <var>fundecl</var>, tree <var>funtype</var>, poly_int64 <var>size</var>)</em></dt>
  177. <dd><p>This target hook returns the number of bytes of its own arguments that
  178. a function pops on returning, or 0 if the function pops no arguments
  179. and the caller must therefore pop them all after the function returns.
  180. </p>
  181. <p><var>fundecl</var> is a C variable whose value is a tree node that describes
  182. the function in question. Normally it is a node of type
  183. <code>FUNCTION_DECL</code> that describes the declaration of the function.
  184. From this you can obtain the <code>DECL_ATTRIBUTES</code> of the function.
  185. </p>
  186. <p><var>funtype</var> is a C variable whose value is a tree node that
  187. describes the function in question. Normally it is a node of type
  188. <code>FUNCTION_TYPE</code> that describes the data type of the function.
  189. From this it is possible to obtain the data types of the value and
  190. arguments (if known).
  191. </p>
  192. <p>When a call to a library function is being considered, <var>fundecl</var>
  193. will contain an identifier node for the library function. Thus, if
  194. you need to distinguish among various library functions, you can do so
  195. by their names. Note that &ldquo;library function&rdquo; in this context means
  196. a function used to perform arithmetic, whose name is known specially
  197. in the compiler and was not mentioned in the C code being compiled.
  198. </p>
  199. <p><var>size</var> is the number of bytes of arguments passed on the
  200. stack. If a variable number of bytes is passed, it is zero, and
  201. argument popping will always be the responsibility of the calling function.
  202. </p>
  203. <p>On the VAX, all functions always pop their arguments, so the definition
  204. of this macro is <var>size</var>. On the 68000, using the standard
  205. calling convention, no functions pop their arguments, so the value of
  206. the macro is always 0 in this case. But an alternative calling
  207. convention is available in which functions that take a fixed number of
  208. arguments pop them but other functions (such as <code>printf</code>) pop
  209. nothing (the caller pops all). When this convention is in use,
  210. <var>funtype</var> is examined to determine whether a function takes a fixed
  211. number of arguments.
  212. </p></dd></dl>
  213. <dl>
  214. <dt><a name="index-CALL_005fPOPS_005fARGS"></a>Macro: <strong>CALL_POPS_ARGS</strong> <em>(<var>cum</var>)</em></dt>
  215. <dd><p>A C expression that should indicate the number of bytes a call sequence
  216. pops off the stack. It is added to the value of <code>RETURN_POPS_ARGS</code>
  217. when compiling a function call.
  218. </p>
  219. <p><var>cum</var> is the variable in which all arguments to the called function
  220. have been accumulated.
  221. </p>
  222. <p>On certain architectures, such as the SH5, a call trampoline is used
  223. that pops certain registers off the stack, depending on the arguments
  224. that have been passed to the function. Since this is a property of the
  225. call site, not of the called function, <code>RETURN_POPS_ARGS</code> is not
  226. appropriate.
  227. </p></dd></dl>
  228. <hr>
  229. <div class="header">
  230. <p>
  231. Next: <a href="Register-Arguments.html#Register-Arguments" accesskey="n" rel="next">Register Arguments</a>, Previous: <a href="Elimination.html#Elimination" accesskey="p" rel="prev">Elimination</a>, Up: <a href="Stack-and-Calling.html#Stack-and-Calling" accesskey="u" rel="up">Stack and Calling</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>
  232. </div>
  233. </body>
  234. </html>