toolchain/gcc-linaro-6.3.1-2017.02-x8.../share/doc/gccint/Interface.html

154 lines
7.3 KiB
HTML
Raw Normal View History

2024-03-22 05:10:17 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2016 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: Interface</title>
<meta name="description" content="GNU Compiler Collection (GCC) Internals: Interface">
<meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Interface">
<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="index.html#Top" rel="up" title="Top">
<link href="Libgcc.html#Libgcc" rel="next" title="Libgcc">
<link href="Portability.html#Portability" rel="prev" title="Portability">
<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="Interface"></a>
<div class="header">
<p>
Next: <a href="Libgcc.html#Libgcc" accesskey="n" rel="next">Libgcc</a>, Previous: <a href="Portability.html#Portability" accesskey="p" rel="prev">Portability</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</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>
</div>
<hr>
<a name="Interfacing-to-GCC-Output"></a>
<h2 class="chapter">3 Interfacing to GCC Output</h2>
<a name="index-interfacing-to-GCC-output"></a>
<a name="index-run_002dtime-conventions"></a>
<a name="index-function-call-conventions"></a>
<a name="index-conventions_002c-run_002dtime"></a>
<p>GCC is normally configured to use the same function calling convention
normally in use on the target system. This is done with the
machine-description macros described (see <a href="Target-Macros.html#Target-Macros">Target Macros</a>).
</p>
<a name="index-unions_002c-returning"></a>
<a name="index-structures_002c-returning"></a>
<a name="index-returning-structures-and-unions"></a>
<p>However, returning of structure and union values is done differently on
some target machines. As a result, functions compiled with PCC
returning such types cannot be called from code compiled with GCC,
and vice versa. This does not cause trouble often because few Unix
library routines return structures or unions.
</p>
<p>GCC code returns structures and unions that are 1, 2, 4 or 8 bytes
long in the same registers used for <code>int</code> or <code>double</code> return
values. (GCC typically allocates variables of such types in
registers also.) Structures and unions of other sizes are returned by
storing them into an address passed by the caller (usually in a
register). The target hook <code>TARGET_STRUCT_VALUE_RTX</code>
tells GCC where to pass this address.
</p>
<p>By contrast, PCC on most target machines returns structures and unions
of any size by copying the data into an area of static storage, and then
returning the address of that storage as if it were a pointer value.
The caller must copy the data from that memory area to the place where
the value is wanted. This is slower than the method used by GCC, and
fails to be reentrant.
</p>
<p>On some target machines, such as RISC machines and the 80386, the
standard system convention is to pass to the subroutine the address of
where to return the value. On these machines, GCC has been
configured to be compatible with the standard compiler, when this method
is used. It may not be compatible for structures of 1, 2, 4 or 8 bytes.
</p>
<a name="index-argument-passing"></a>
<a name="index-passing-arguments"></a>
<p>GCC uses the system&rsquo;s standard convention for passing arguments. On
some machines, the first few arguments are passed in registers; in
others, all are passed on the stack. It would be possible to use
registers for argument passing on any machine, and this would probably
result in a significant speedup. But the result would be complete
incompatibility with code that follows the standard convention. So this
change is practical only if you are switching to GCC as the sole C
compiler for the system. We may implement register argument passing on
certain machines once we have a complete GNU system so that we can
compile the libraries with GCC.
</p>
<p>On some machines (particularly the SPARC), certain types of arguments
are passed &ldquo;by invisible reference&rdquo;. This means that the value is
stored in memory, and the address of the memory location is passed to
the subroutine.
</p>
<a name="index-longjmp-and-automatic-variables"></a>
<p>If you use <code>longjmp</code>, beware of automatic variables. ISO C says that
automatic variables that are not declared <code>volatile</code> have undefined
values after a <code>longjmp</code>. And this is all GCC promises to do,
because it is very difficult to restore register variables correctly, and
one of GCC&rsquo;s features is that it can put variables in registers without
your asking it to.
</p>
<hr>
<div class="header">
<p>
Next: <a href="Libgcc.html#Libgcc" accesskey="n" rel="next">Libgcc</a>, Previous: <a href="Portability.html#Portability" accesskey="p" rel="prev">Portability</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</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>
</div>
</body>
</html>