| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <html> |
| <!-- Copyright (C) 1988-2015 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being "Funding Free Software", the Front-Cover |
| Texts being (a) (see below), and with the Back-Cover Texts being (b) |
| (see below). A copy of the license is included in the section entitled |
| "GNU Free Documentation License". |
| |
| (a) The FSF's Front-Cover Text is: |
| |
| A GNU Manual |
| |
| (b) The FSF's Back-Cover Text is: |
| |
| You have freedom to copy and modify this GNU Manual, like GNU |
| software. Copies published by the Free Software Foundation raise |
| funds for GNU development. --> |
| <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ --> |
| <head> |
| <title>GNU Compiler Collection (GCC) Internals: Stack Arguments</title> |
| |
| <meta name="description" content="GNU Compiler Collection (GCC) Internals: Stack Arguments"> |
| <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Stack Arguments"> |
| <meta name="resource-type" content="document"> |
| <meta name="distribution" content="global"> |
| <meta name="Generator" content="makeinfo"> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| <link href="index.html#Top" rel="start" title="Top"> |
| <link href="Option-Index.html#Option-Index" rel="index" title="Option Index"> |
| <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> |
| <link href="Stack-and-Calling.html#Stack-and-Calling" rel="up" title="Stack and Calling"> |
| <link href="Register-Arguments.html#Register-Arguments" rel="next" title="Register Arguments"> |
| <link href="Elimination.html#Elimination" rel="prev" title="Elimination"> |
| <style type="text/css"> |
| <!-- |
| a.summary-letter {text-decoration: none} |
| blockquote.smallquotation {font-size: smaller} |
| div.display {margin-left: 3.2em} |
| div.example {margin-left: 3.2em} |
| div.indentedblock {margin-left: 3.2em} |
| div.lisp {margin-left: 3.2em} |
| div.smalldisplay {margin-left: 3.2em} |
| div.smallexample {margin-left: 3.2em} |
| div.smallindentedblock {margin-left: 3.2em; font-size: smaller} |
| div.smalllisp {margin-left: 3.2em} |
| kbd {font-style:oblique} |
| pre.display {font-family: inherit} |
| pre.format {font-family: inherit} |
| pre.menu-comment {font-family: serif} |
| pre.menu-preformatted {font-family: serif} |
| pre.smalldisplay {font-family: inherit; font-size: smaller} |
| pre.smallexample {font-size: smaller} |
| pre.smallformat {font-family: inherit; font-size: smaller} |
| pre.smalllisp {font-size: smaller} |
| span.nocodebreak {white-space:nowrap} |
| span.nolinebreak {white-space:nowrap} |
| span.roman {font-family:serif; font-weight:normal} |
| span.sansserif {font-family:sans-serif; font-weight:normal} |
| ul.no-bullet {list-style: none} |
| --> |
| </style> |
| |
| |
| </head> |
| |
| <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> |
| <a name="Stack-Arguments"></a> |
| <div class="header"> |
| <p> |
| 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> [<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> |
| </div> |
| <hr> |
| <a name="Passing-Function-Arguments-on-the-Stack"></a> |
| <h4 class="subsection">17.10.6 Passing Function Arguments on the Stack</h4> |
| <a name="index-arguments-on-stack"></a> |
| <a name="index-stack-arguments"></a> |
| |
| <p>The macros in this section control how arguments are passed |
| on the stack. See the following section for other macros that |
| control passing certain arguments in registers. |
| </p> |
| <dl> |
| <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> |
| <dd><p>This target hook returns <code>true</code> if an argument declared in a |
| prototype as an integral type smaller than <code>int</code> should actually be |
| passed as an <code>int</code>. In addition to avoiding errors in certain |
| cases of mismatch, it also makes for better code on certain machines. |
| The default is to not promote prototypes. |
| </p></dd></dl> |
| |
| <dl> |
| <dt><a name="index-PUSH_005fARGS"></a>Macro: <strong>PUSH_ARGS</strong></dt> |
| <dd><p>A C expression. If nonzero, push insns will be used to pass |
| outgoing arguments. |
| If the target machine does not have a push instruction, set it to zero. |
| That directs GCC to use an alternate strategy: to |
| allocate the entire argument block and then store the arguments into |
| it. When <code>PUSH_ARGS</code> is nonzero, <code>PUSH_ROUNDING</code> must be defined too. |
| </p></dd></dl> |
| |
| <dl> |
| <dt><a name="index-PUSH_005fARGS_005fREVERSED"></a>Macro: <strong>PUSH_ARGS_REVERSED</strong></dt> |
| <dd><p>A C expression. If nonzero, function arguments will be evaluated from |
| last to first, rather than from first to last. If this macro is not |
| defined, it defaults to <code>PUSH_ARGS</code> on targets where the stack |
| and args grow in opposite directions, and 0 otherwise. |
| </p></dd></dl> |
| |
| <dl> |
| <dt><a name="index-PUSH_005fROUNDING"></a>Macro: <strong>PUSH_ROUNDING</strong> <em>(<var>npushed</var>)</em></dt> |
| <dd><p>A C expression that is the number of bytes actually pushed onto the |
| stack when an instruction attempts to push <var>npushed</var> bytes. |
| </p> |
| <p>On some machines, the definition |
| </p> |
| <div class="smallexample"> |
| <pre class="smallexample">#define PUSH_ROUNDING(BYTES) (BYTES) |
| </pre></div> |
| |
| <p>will suffice. But on other machines, instructions that appear |
| to push one byte actually push two bytes in an attempt to maintain |
| alignment. Then the definition should be |
| </p> |
| <div class="smallexample"> |
| <pre class="smallexample">#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) |
| </pre></div> |
| |
| <p>If the value of this macro has a type, it should be an unsigned type. |
| </p></dd></dl> |
| |
| <a name="index-outgoing_005fargs_005fsize"></a> |
| <a name="index-crtl_002d_003eoutgoing_005fargs_005fsize"></a> |
| <dl> |
| <dt><a name="index-ACCUMULATE_005fOUTGOING_005fARGS"></a>Macro: <strong>ACCUMULATE_OUTGOING_ARGS</strong></dt> |
| <dd><p>A C expression. If nonzero, the maximum amount of space required for outgoing arguments |
| will be computed and placed into |
| <code>crtl->outgoing_args_size</code>. No space will be pushed |
| onto the stack for each call; instead, the function prologue should |
| increase the stack frame size by this amount. |
| </p> |
| <p>Setting both <code>PUSH_ARGS</code> and <code>ACCUMULATE_OUTGOING_ARGS</code> |
| is not proper. |
| </p></dd></dl> |
| |
| <dl> |
| <dt><a name="index-REG_005fPARM_005fSTACK_005fSPACE"></a>Macro: <strong>REG_PARM_STACK_SPACE</strong> <em>(<var>fndecl</var>)</em></dt> |
| <dd><p>Define this macro if functions should assume that stack space has been |
| allocated for arguments even when their values are passed in |
| registers. |
| </p> |
| <p>The value of this macro is the size, in bytes, of the area reserved for |
| arguments passed in registers for the function represented by <var>fndecl</var>, |
| which can be zero if GCC is calling a library function. |
| The argument <var>fndecl</var> can be the FUNCTION_DECL, or the type itself |
| of the function. |
| </p> |
| <p>This space can be allocated by the caller, or be a part of the |
| machine-dependent stack frame: <code>OUTGOING_REG_PARM_STACK_SPACE</code> says |
| which. |
| </p></dd></dl> |
| |
| <dl> |
| <dt><a name="index-INCOMING_005fREG_005fPARM_005fSTACK_005fSPACE"></a>Macro: <strong>INCOMING_REG_PARM_STACK_SPACE</strong> <em>(<var>fndecl</var>)</em></dt> |
| <dd><p>Like <code>REG_PARM_STACK_SPACE</code>, but for incoming register arguments. |
| Define this macro if space guaranteed when compiling a function body |
| is different to space required when making a call, a situation that |
| can arise with K&R style function definitions. |
| </p></dd></dl> |
| |
| <dl> |
| <dt><a name="index-OUTGOING_005fREG_005fPARM_005fSTACK_005fSPACE"></a>Macro: <strong>OUTGOING_REG_PARM_STACK_SPACE</strong> <em>(<var>fntype</var>)</em></dt> |
| <dd><p>Define this to a nonzero value if it is the responsibility of the |
| caller to allocate the area reserved for arguments passed in registers |
| when calling a function of <var>fntype</var>. <var>fntype</var> may be NULL |
| if the function called is a library function. |
| </p> |
| <p>If <code>ACCUMULATE_OUTGOING_ARGS</code> is defined, this macro controls |
| whether the space for these arguments counts in the value of |
| <code>crtl->outgoing_args_size</code>. |
| </p></dd></dl> |
| |
| <dl> |
| <dt><a name="index-STACK_005fPARMS_005fIN_005fREG_005fPARM_005fAREA"></a>Macro: <strong>STACK_PARMS_IN_REG_PARM_AREA</strong></dt> |
| <dd><p>Define this macro if <code>REG_PARM_STACK_SPACE</code> is defined, but the |
| stack parameters don’t skip the area specified by it. |
| </p> |
| <p>Normally, when a parameter is not passed in registers, it is placed on the |
| stack beyond the <code>REG_PARM_STACK_SPACE</code> area. Defining this macro |
| suppresses this behavior and causes the parameter to be passed on the |
| stack in its natural location. |
| </p></dd></dl> |
| |
| <dl> |
| <dt><a name="index-TARGET_005fRETURN_005fPOPS_005fARGS"></a>Target Hook: <em>int</em> <strong>TARGET_RETURN_POPS_ARGS</strong> <em>(tree <var>fundecl</var>, tree <var>funtype</var>, int <var>size</var>)</em></dt> |
| <dd><p>This target hook returns the number of bytes of its own arguments that |
| a function pops on returning, or 0 if the function pops no arguments |
| and the caller must therefore pop them all after the function returns. |
| </p> |
| <p><var>fundecl</var> is a C variable whose value is a tree node that describes |
| the function in question. Normally it is a node of type |
| <code>FUNCTION_DECL</code> that describes the declaration of the function. |
| From this you can obtain the <code>DECL_ATTRIBUTES</code> of the function. |
| </p> |
| <p><var>funtype</var> is a C variable whose value is a tree node that |
| describes the function in question. Normally it is a node of type |
| <code>FUNCTION_TYPE</code> that describes the data type of the function. |
| From this it is possible to obtain the data types of the value and |
| arguments (if known). |
| </p> |
| <p>When a call to a library function is being considered, <var>fundecl</var> |
| will contain an identifier node for the library function. Thus, if |
| you need to distinguish among various library functions, you can do so |
| by their names. Note that “library function” in this context means |
| a function used to perform arithmetic, whose name is known specially |
| in the compiler and was not mentioned in the C code being compiled. |
| </p> |
| <p><var>size</var> is the number of bytes of arguments passed on the |
| stack. If a variable number of bytes is passed, it is zero, and |
| argument popping will always be the responsibility of the calling function. |
| </p> |
| <p>On the VAX, all functions always pop their arguments, so the definition |
| of this macro is <var>size</var>. On the 68000, using the standard |
| calling convention, no functions pop their arguments, so the value of |
| the macro is always 0 in this case. But an alternative calling |
| convention is available in which functions that take a fixed number of |
| arguments pop them but other functions (such as <code>printf</code>) pop |
| nothing (the caller pops all). When this convention is in use, |
| <var>funtype</var> is examined to determine whether a function takes a fixed |
| number of arguments. |
| </p></dd></dl> |
| |
| <dl> |
| <dt><a name="index-CALL_005fPOPS_005fARGS"></a>Macro: <strong>CALL_POPS_ARGS</strong> <em>(<var>cum</var>)</em></dt> |
| <dd><p>A C expression that should indicate the number of bytes a call sequence |
| pops off the stack. It is added to the value of <code>RETURN_POPS_ARGS</code> |
| when compiling a function call. |
| </p> |
| <p><var>cum</var> is the variable in which all arguments to the called function |
| have been accumulated. |
| </p> |
| <p>On certain architectures, such as the SH5, a call trampoline is used |
| that pops certain registers off the stack, depending on the arguments |
| that have been passed to the function. Since this is a property of the |
| call site, not of the called function, <code>RETURN_POPS_ARGS</code> is not |
| appropriate. |
| </p></dd></dl> |
| |
| <hr> |
| <div class="header"> |
| <p> |
| 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> [<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> |
| </div> |
| |
| |
| |
| </body> |
| </html> |