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 lines
7.1KB

  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>Leaf Functions (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Leaf Functions (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Leaf Functions (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="Registers.html#Registers" rel="up" title="Registers">
  30. <link href="Stack-Registers.html#Stack-Registers" rel="next" title="Stack Registers">
  31. <link href="Values-in-Registers.html#Values-in-Registers" rel="prev" title="Values in Registers">
  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="Leaf-Functions"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Stack-Registers.html#Stack-Registers" accesskey="n" rel="next">Stack Registers</a>, Previous: <a href="Values-in-Registers.html#Values-in-Registers" accesskey="p" rel="prev">Values in Registers</a>, Up: <a href="Registers.html#Registers" accesskey="u" rel="up">Registers</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="Handling-Leaf-Functions"></a>
  68. <h4 class="subsection">18.7.4 Handling Leaf Functions</h4>
  69. <a name="index-leaf-functions"></a>
  70. <a name="index-functions_002c-leaf"></a>
  71. <p>On some machines, a leaf function (i.e., one which makes no calls) can run
  72. more efficiently if it does not make its own register window. Often this
  73. means it is required to receive its arguments in the registers where they
  74. are passed by the caller, instead of the registers where they would
  75. normally arrive.
  76. </p>
  77. <p>The special treatment for leaf functions generally applies only when
  78. other conditions are met; for example, often they may use only those
  79. registers for its own variables and temporaries. We use the term &ldquo;leaf
  80. function&rdquo; to mean a function that is suitable for this special
  81. handling, so that functions with no calls are not necessarily &ldquo;leaf
  82. functions&rdquo;.
  83. </p>
  84. <p>GCC assigns register numbers before it knows whether the function is
  85. suitable for leaf function treatment. So it needs to renumber the
  86. registers in order to output a leaf function. The following macros
  87. accomplish this.
  88. </p>
  89. <dl>
  90. <dt><a name="index-LEAF_005fREGISTERS"></a>Macro: <strong>LEAF_REGISTERS</strong></dt>
  91. <dd><p>Name of a char vector, indexed by hard register number, which
  92. contains 1 for a register that is allowable in a candidate for leaf
  93. function treatment.
  94. </p>
  95. <p>If leaf function treatment involves renumbering the registers, then the
  96. registers marked here should be the ones before renumbering&mdash;those that
  97. GCC would ordinarily allocate. The registers which will actually be
  98. used in the assembler code, after renumbering, should not be marked with 1
  99. in this vector.
  100. </p>
  101. <p>Define this macro only if the target machine offers a way to optimize
  102. the treatment of leaf functions.
  103. </p></dd></dl>
  104. <dl>
  105. <dt><a name="index-LEAF_005fREG_005fREMAP"></a>Macro: <strong>LEAF_REG_REMAP</strong> <em>(<var>regno</var>)</em></dt>
  106. <dd><p>A C expression whose value is the register number to which <var>regno</var>
  107. should be renumbered, when a function is treated as a leaf function.
  108. </p>
  109. <p>If <var>regno</var> is a register number which should not appear in a leaf
  110. function before renumbering, then the expression should yield -1, which
  111. will cause the compiler to abort.
  112. </p>
  113. <p>Define this macro only if the target machine offers a way to optimize the
  114. treatment of leaf functions, and registers need to be renumbered to do
  115. this.
  116. </p></dd></dl>
  117. <a name="index-current_005ffunction_005fis_005fleaf"></a>
  118. <a name="index-current_005ffunction_005fuses_005fonly_005fleaf_005fregs"></a>
  119. <p><code>TARGET_ASM_FUNCTION_PROLOGUE</code> and
  120. <code>TARGET_ASM_FUNCTION_EPILOGUE</code> must usually treat leaf functions
  121. specially. They can test the C variable <code>current_function_is_leaf</code>
  122. which is nonzero for leaf functions. <code>current_function_is_leaf</code> is
  123. set prior to local register allocation and is valid for the remaining
  124. compiler passes. They can also test the C variable
  125. <code>current_function_uses_only_leaf_regs</code> which is nonzero for leaf
  126. functions which only use leaf registers.
  127. <code>current_function_uses_only_leaf_regs</code> is valid after all passes
  128. that modify the instructions have been run and is only useful if
  129. <code>LEAF_REGISTERS</code> is defined.
  130. </p>
  131. <hr>
  132. <div class="header">
  133. <p>
  134. Next: <a href="Stack-Registers.html#Stack-Registers" accesskey="n" rel="next">Stack Registers</a>, Previous: <a href="Values-in-Registers.html#Values-in-Registers" accesskey="p" rel="prev">Values in Registers</a>, Up: <a href="Registers.html#Registers" accesskey="u" rel="up">Registers</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>
  135. </div>
  136. </body>
  137. </html>