Elimination.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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: Elimination</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Elimination">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Elimination">
  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="Stack-and-Calling.html#Stack-and-Calling" rel="up" title="Stack and Calling">
  30. <link href="Stack-Arguments.html#Stack-Arguments" rel="next" title="Stack Arguments">
  31. <link href="Frame-Registers.html#Frame-Registers" rel="prev" title="Frame Registers">
  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="Elimination"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Stack-Arguments.html#Stack-Arguments" accesskey="n" rel="next">Stack Arguments</a>, Previous: <a href="Frame-Registers.html#Frame-Registers" accesskey="p" rel="prev">Frame Registers</a>, Up: <a href="Stack-and-Calling.html#Stack-and-Calling" accesskey="u" rel="up">Stack and Calling</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="Eliminating-Frame-Pointer-and-Arg-Pointer"></a>
  69. <h4 class="subsection">17.9.5 Eliminating Frame Pointer and Arg Pointer</h4>
  70. <p>This is about eliminating the frame pointer and arg pointer.
  71. </p>
  72. <dl>
  73. <dt><a name="index-TARGET_005fFRAME_005fPOINTER_005fREQUIRED"></a>Target Hook: <em>bool</em> <strong>TARGET_FRAME_POINTER_REQUIRED</strong> <em>(void)</em></dt>
  74. <dd><p>This target hook should return <code>true</code> if a function must have and use
  75. a frame pointer. This target hook is called in the reload pass. If its return
  76. value is <code>true</code> the function will have a frame pointer.
  77. </p>
  78. <p>This target hook can in principle examine the current function and decide
  79. according to the facts, but on most machines the constant <code>false</code> or the
  80. constant <code>true</code> suffices. Use <code>false</code> when the machine allows code
  81. to be generated with no frame pointer, and doing so saves some time or space.
  82. Use <code>true</code> when there is no possible advantage to avoiding a frame
  83. pointer.
  84. </p>
  85. <p>In certain cases, the compiler does not know how to produce valid code
  86. without a frame pointer. The compiler recognizes those cases and
  87. automatically gives the function a frame pointer regardless of what
  88. <code>targetm.frame_pointer_required</code> returns. You don&rsquo;t need to worry about
  89. them.
  90. </p>
  91. <p>In a function that does not require a frame pointer, the frame pointer
  92. register can be allocated for ordinary usage, unless you mark it as a
  93. fixed register. See <code>FIXED_REGISTERS</code> for more information.
  94. </p>
  95. <p>Default return value is <code>false</code>.
  96. </p></dd></dl>
  97. <dl>
  98. <dt><a name="index-ELIMINABLE_005fREGS"></a>Macro: <strong>ELIMINABLE_REGS</strong></dt>
  99. <dd><p>This macro specifies a table of register pairs used to eliminate
  100. unneeded registers that point into the stack frame.
  101. </p>
  102. <p>The definition of this macro is a list of structure initializations, each
  103. of which specifies an original and replacement register.
  104. </p>
  105. <p>On some machines, the position of the argument pointer is not known until
  106. the compilation is completed. In such a case, a separate hard register
  107. must be used for the argument pointer. This register can be eliminated by
  108. replacing it with either the frame pointer or the argument pointer,
  109. depending on whether or not the frame pointer has been eliminated.
  110. </p>
  111. <p>In this case, you might specify:
  112. </p><div class="smallexample">
  113. <pre class="smallexample">#define ELIMINABLE_REGS \
  114. {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  115. {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
  116. {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
  117. </pre></div>
  118. <p>Note that the elimination of the argument pointer with the stack pointer is
  119. specified first since that is the preferred elimination.
  120. </p></dd></dl>
  121. <dl>
  122. <dt><a name="index-TARGET_005fCAN_005fELIMINATE"></a>Target Hook: <em>bool</em> <strong>TARGET_CAN_ELIMINATE</strong> <em>(const int <var>from_reg</var>, const int <var>to_reg</var>)</em></dt>
  123. <dd><p>This target hook should return <code>true</code> if the compiler is allowed to
  124. try to replace register number <var>from_reg</var> with register number
  125. <var>to_reg</var>. This target hook will usually be <code>true</code>, since most of the
  126. cases preventing register elimination are things that the compiler already
  127. knows about.
  128. </p>
  129. <p>Default return value is <code>true</code>.
  130. </p></dd></dl>
  131. <dl>
  132. <dt><a name="index-INITIAL_005fELIMINATION_005fOFFSET"></a>Macro: <strong>INITIAL_ELIMINATION_OFFSET</strong> <em>(<var>from-reg</var>, <var>to-reg</var>, <var>offset-var</var>)</em></dt>
  133. <dd><p>This macro returns the initial difference between the specified pair
  134. of registers. The value would be computed from information
  135. such as the result of <code>get_frame_size ()</code> and the tables of
  136. registers <code>df_regs_ever_live_p</code> and <code>call_used_regs</code>.
  137. </p></dd></dl>
  138. <dl>
  139. <dt><a name="index-TARGET_005fCOMPUTE_005fFRAME_005fLAYOUT"></a>Target Hook: <em>void</em> <strong>TARGET_COMPUTE_FRAME_LAYOUT</strong> <em>(void)</em></dt>
  140. <dd><p>This target hook is called once each time the frame layout needs to be
  141. recalculated. The calculations can be cached by the target and can then
  142. be used by <code>INITIAL_ELIMINATION_OFFSET</code> instead of re-computing the
  143. layout on every invocation of that hook. This is particularly useful
  144. for targets that have an expensive frame layout function. Implementing
  145. this callback is optional.
  146. </p></dd></dl>
  147. <hr>
  148. <div class="header">
  149. <p>
  150. Next: <a href="Stack-Arguments.html#Stack-Arguments" accesskey="n" rel="next">Stack Arguments</a>, Previous: <a href="Frame-Registers.html#Frame-Registers" accesskey="p" rel="prev">Frame Registers</a>, Up: <a href="Stack-and-Calling.html#Stack-and-Calling" accesskey="u" rel="up">Stack and Calling</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>
  151. </div>
  152. </body>
  153. </html>