Calls.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Calls</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Calls">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Calls">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="RTL.html#RTL" rel="up" title="RTL">
  30. <link href="Sharing.html#Sharing" rel="next" title="Sharing">
  31. <link href="Insns.html#Insns" rel="prev" title="Insns">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Calls"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Sharing.html#Sharing" accesskey="n" rel="next">Sharing</a>, Previous: <a href="Insns.html#Insns" accesskey="p" rel="prev">Insns</a>, Up: <a href="RTL.html#RTL" accesskey="u" rel="up">RTL</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>
  66. </div>
  67. <hr>
  68. <a name="RTL-Representation-of-Function_002dCall-Insns"></a>
  69. <h3 class="section">13.20 RTL Representation of Function-Call Insns</h3>
  70. <a name="index-calling-functions-in-RTL"></a>
  71. <a name="index-RTL-function_002dcall-insns"></a>
  72. <a name="index-function_002dcall-insns"></a>
  73. <p>Insns that call subroutines have the RTL expression code <code>call_insn</code>.
  74. These insns must satisfy special rules, and their bodies must use a special
  75. RTL expression code, <code>call</code>.
  76. </p>
  77. <a name="index-call-usage"></a>
  78. <p>A <code>call</code> expression has two operands, as follows:
  79. </p>
  80. <div class="smallexample">
  81. <pre class="smallexample">(call (mem:<var>fm</var> <var>addr</var>) <var>nbytes</var>)
  82. </pre></div>
  83. <p>Here <var>nbytes</var> is an operand that represents the number of bytes of
  84. argument data being passed to the subroutine, <var>fm</var> is a machine mode
  85. (which must equal as the definition of the <code>FUNCTION_MODE</code> macro in
  86. the machine description) and <var>addr</var> represents the address of the
  87. subroutine.
  88. </p>
  89. <p>For a subroutine that returns no value, the <code>call</code> expression as
  90. shown above is the entire body of the insn, except that the insn might
  91. also contain <code>use</code> or <code>clobber</code> expressions.
  92. </p>
  93. <a name="index-BLKmode_002c-and-function-return-values"></a>
  94. <p>For a subroutine that returns a value whose mode is not <code>BLKmode</code>,
  95. the value is returned in a hard register. If this register&rsquo;s number is
  96. <var>r</var>, then the body of the call insn looks like this:
  97. </p>
  98. <div class="smallexample">
  99. <pre class="smallexample">(set (reg:<var>m</var> <var>r</var>)
  100. (call (mem:<var>fm</var> <var>addr</var>) <var>nbytes</var>))
  101. </pre></div>
  102. <p>This RTL expression makes it clear (to the optimizer passes) that the
  103. appropriate register receives a useful value in this insn.
  104. </p>
  105. <p>When a subroutine returns a <code>BLKmode</code> value, it is handled by
  106. passing to the subroutine the address of a place to store the value.
  107. So the call insn itself does not &ldquo;return&rdquo; any value, and it has the
  108. same RTL form as a call that returns nothing.
  109. </p>
  110. <p>On some machines, the call instruction itself clobbers some register,
  111. for example to contain the return address. <code>call_insn</code> insns
  112. on these machines should have a body which is a <code>parallel</code>
  113. that contains both the <code>call</code> expression and <code>clobber</code>
  114. expressions that indicate which registers are destroyed. Similarly,
  115. if the call instruction requires some register other than the stack
  116. pointer that is not explicitly mentioned in its RTL, a <code>use</code>
  117. subexpression should mention that register.
  118. </p>
  119. <p>Functions that are called are assumed to modify all registers listed in
  120. 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
  121. calls, to modify all of memory.
  122. </p>
  123. <p>Insns containing just <code>use</code> expressions directly precede the
  124. <code>call_insn</code> insn to indicate which registers contain inputs to the
  125. function. Similarly, if registers other than those in
  126. <code>CALL_USED_REGISTERS</code> are clobbered by the called function, insns
  127. containing a single <code>clobber</code> follow immediately after the call to
  128. indicate which registers.
  129. </p>
  130. <hr>
  131. <div class="header">
  132. <p>
  133. Next: <a href="Sharing.html#Sharing" accesskey="n" rel="next">Sharing</a>, Previous: <a href="Insns.html#Insns" accesskey="p" rel="prev">Insns</a>, Up: <a href="RTL.html#RTL" accesskey="u" rel="up">RTL</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>
  134. </div>
  135. </body>
  136. </html>