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

113 lines
5.4 KiB
HTML

<html lang="en">
<head>
<title>Calls - GNU Compiler Collection (GCC) Internals</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Compiler Collection (GCC) Internals">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="RTL.html#RTL" title="RTL">
<link rel="prev" href="Insns.html#Insns" title="Insns">
<link rel="next" href="Sharing.html#Sharing" title="Sharing">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
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.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Calls"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Sharing.html#Sharing">Sharing</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Insns.html#Insns">Insns</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="RTL.html#RTL">RTL</a>
<hr>
</div>
<h3 class="section">13.20 RTL Representation of Function-Call Insns</h3>
<p><a name="index-calling-functions-in-RTL-3131"></a><a name="index-RTL-function_002dcall-insns-3132"></a><a name="index-function_002dcall-insns-3133"></a>
Insns that call subroutines have the RTL expression code <code>call_insn</code>.
These insns must satisfy special rules, and their bodies must use a special
RTL expression code, <code>call</code>.
<p><a name="index-g_t_0040code_007bcall_007d-usage-3134"></a>A <code>call</code> expression has two operands, as follows:
<pre class="smallexample"> (call (mem:<var>fm</var> <var>addr</var>) <var>nbytes</var>)
</pre>
<p class="noindent">Here <var>nbytes</var> is an operand that represents the number of bytes of
argument data being passed to the subroutine, <var>fm</var> is a machine mode
(which must equal as the definition of the <code>FUNCTION_MODE</code> macro in
the machine description) and <var>addr</var> represents the address of the
subroutine.
<p>For a subroutine that returns no value, the <code>call</code> expression as
shown above is the entire body of the insn, except that the insn might
also contain <code>use</code> or <code>clobber</code> expressions.
<p><a name="index-g_t_0040code_007bBLKmode_007d_002c-and-function-return-values-3135"></a>For a subroutine that returns a value whose mode is not <code>BLKmode</code>,
the value is returned in a hard register. If this register's number is
<var>r</var>, then the body of the call insn looks like this:
<pre class="smallexample"> (set (reg:<var>m</var> <var>r</var>)
(call (mem:<var>fm</var> <var>addr</var>) <var>nbytes</var>))
</pre>
<p class="noindent">This RTL expression makes it clear (to the optimizer passes) that the
appropriate register receives a useful value in this insn.
<p>When a subroutine returns a <code>BLKmode</code> value, it is handled by
passing to the subroutine the address of a place to store the value.
So the call insn itself does not &ldquo;return&rdquo; any value, and it has the
same RTL form as a call that returns nothing.
<p>On some machines, the call instruction itself clobbers some register,
for example to contain the return address. <code>call_insn</code> insns
on these machines should have a body which is a <code>parallel</code>
that contains both the <code>call</code> expression and <code>clobber</code>
expressions that indicate which registers are destroyed. Similarly,
if the call instruction requires some register other than the stack
pointer that is not explicitly mentioned in its RTL, a <code>use</code>
subexpression should mention that register.
<p>Functions that are called are assumed to modify all registers listed in
the configuration macro <code>CALL_USED_REGISTERS</code> (see <a href="Register-Basics.html#Register-Basics">Register Basics</a>) and, with the exception of <code>const</code> functions and library
calls, to modify all of memory.
<p>Insns containing just <code>use</code> expressions directly precede the
<code>call_insn</code> insn to indicate which registers contain inputs to the
function. Similarly, if registers other than those in
<code>CALL_USED_REGISTERS</code> are clobbered by the called function, insns
containing a single <code>clobber</code> follow immediately after the call to
indicate which registers.
</body></html>