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.

153 line
7.2KB

  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>Interface (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Interface (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Interface (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="index.html#Top" rel="up" title="Top">
  30. <link href="Libgcc.html#Libgcc" rel="next" title="Libgcc">
  31. <link href="Portability.html#Portability" rel="prev" title="Portability">
  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="Interface"></a>
  62. <div class="header">
  63. <p>
  64. 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>
  65. </div>
  66. <hr>
  67. <a name="Interfacing-to-GCC-Output"></a>
  68. <h2 class="chapter">3 Interfacing to GCC Output</h2>
  69. <a name="index-interfacing-to-GCC-output"></a>
  70. <a name="index-run_002dtime-conventions"></a>
  71. <a name="index-function-call-conventions"></a>
  72. <a name="index-conventions_002c-run_002dtime"></a>
  73. <p>GCC is normally configured to use the same function calling convention
  74. normally in use on the target system. This is done with the
  75. machine-description macros described (see <a href="Target-Macros.html#Target-Macros">Target Macros</a>).
  76. </p>
  77. <a name="index-unions_002c-returning"></a>
  78. <a name="index-structures_002c-returning"></a>
  79. <a name="index-returning-structures-and-unions"></a>
  80. <p>However, returning of structure and union values is done differently on
  81. some target machines. As a result, functions compiled with PCC
  82. returning such types cannot be called from code compiled with GCC,
  83. and vice versa. This does not cause trouble often because few Unix
  84. library routines return structures or unions.
  85. </p>
  86. <p>GCC code returns structures and unions that are 1, 2, 4 or 8 bytes
  87. long in the same registers used for <code>int</code> or <code>double</code> return
  88. values. (GCC typically allocates variables of such types in
  89. registers also.) Structures and unions of other sizes are returned by
  90. storing them into an address passed by the caller (usually in a
  91. register). The target hook <code>TARGET_STRUCT_VALUE_RTX</code>
  92. tells GCC where to pass this address.
  93. </p>
  94. <p>By contrast, PCC on most target machines returns structures and unions
  95. of any size by copying the data into an area of static storage, and then
  96. returning the address of that storage as if it were a pointer value.
  97. The caller must copy the data from that memory area to the place where
  98. the value is wanted. This is slower than the method used by GCC, and
  99. fails to be reentrant.
  100. </p>
  101. <p>On some target machines, such as RISC machines and the 80386, the
  102. standard system convention is to pass to the subroutine the address of
  103. where to return the value. On these machines, GCC has been
  104. configured to be compatible with the standard compiler, when this method
  105. is used. It may not be compatible for structures of 1, 2, 4 or 8 bytes.
  106. </p>
  107. <a name="index-argument-passing"></a>
  108. <a name="index-passing-arguments"></a>
  109. <p>GCC uses the system&rsquo;s standard convention for passing arguments. On
  110. some machines, the first few arguments are passed in registers; in
  111. others, all are passed on the stack. It would be possible to use
  112. registers for argument passing on any machine, and this would probably
  113. result in a significant speedup. But the result would be complete
  114. incompatibility with code that follows the standard convention. So this
  115. change is practical only if you are switching to GCC as the sole C
  116. compiler for the system. We may implement register argument passing on
  117. certain machines once we have a complete GNU system so that we can
  118. compile the libraries with GCC.
  119. </p>
  120. <p>On some machines (particularly the SPARC), certain types of arguments
  121. are passed &ldquo;by invisible reference&rdquo;. This means that the value is
  122. stored in memory, and the address of the memory location is passed to
  123. the subroutine.
  124. </p>
  125. <a name="index-longjmp-and-automatic-variables"></a>
  126. <p>If you use <code>longjmp</code>, beware of automatic variables. ISO C says that
  127. automatic variables that are not declared <code>volatile</code> have undefined
  128. values after a <code>longjmp</code>. And this is all GCC promises to do,
  129. because it is very difficult to restore register variables correctly, and
  130. one of GCC&rsquo;s features is that it can put variables in registers without
  131. your asking it to.
  132. </p>
  133. <hr>
  134. <div class="header">
  135. <p>
  136. 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>
  137. </div>
  138. </body>
  139. </html>