Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

164 lines
7.8KB

  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>Parsing pass (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Parsing pass (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Parsing pass (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="Passes.html#Passes" rel="up" title="Passes">
  30. <link href="Gimplification-pass.html#Gimplification-pass" rel="next" title="Gimplification pass">
  31. <link href="Passes.html#Passes" rel="prev" title="Passes">
  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="Parsing-pass"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Gimplification-pass.html#Gimplification-pass" accesskey="n" rel="next">Gimplification pass</a>, Up: <a href="Passes.html#Passes" accesskey="u" rel="up">Passes</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="Parsing-pass-1"></a>
  68. <h3 class="section">9.1 Parsing pass</h3>
  69. <a name="index-GENERIC"></a>
  70. <a name="index-lang_005fhooks_002eparse_005ffile"></a>
  71. <p>The language front end is invoked only once, via
  72. <code>lang_hooks.parse_file</code>, to parse the entire input. The language
  73. front end may use any intermediate language representation deemed
  74. appropriate. The C front end uses GENERIC trees (see <a href="GENERIC.html#GENERIC">GENERIC</a>), plus
  75. a double handful of language specific tree codes defined in
  76. <samp>c-common.def</samp>. The Fortran front end uses a completely different
  77. private representation.
  78. </p>
  79. <a name="index-GIMPLE"></a>
  80. <a name="index-gimplification"></a>
  81. <a name="index-gimplifier"></a>
  82. <a name="index-language_002dindependent-intermediate-representation"></a>
  83. <a name="index-intermediate-representation-lowering"></a>
  84. <a name="index-lowering_002c-language_002ddependent-intermediate-representation"></a>
  85. <p>At some point the front end must translate the representation used in the
  86. front end to a representation understood by the language-independent
  87. portions of the compiler. Current practice takes one of two forms.
  88. The C front end manually invokes the gimplifier (see <a href="GIMPLE.html#GIMPLE">GIMPLE</a>) on each function,
  89. and uses the gimplifier callbacks to convert the language-specific tree
  90. nodes directly to GIMPLE before passing the function off to be compiled.
  91. The Fortran front end converts from a private representation to GENERIC,
  92. which is later lowered to GIMPLE when the function is compiled. Which
  93. route to choose probably depends on how well GENERIC (plus extensions)
  94. can be made to match up with the source language and necessary parsing
  95. data structures.
  96. </p>
  97. <p>BUG: Gimplification must occur before nested function lowering,
  98. and nested function lowering must be done by the front end before
  99. passing the data off to cgraph.
  100. </p>
  101. <p>TODO: Cgraph should control nested function lowering. It would
  102. only be invoked when it is certain that the outer-most function
  103. is used.
  104. </p>
  105. <p>TODO: Cgraph needs a gimplify_function callback. It should be
  106. invoked when (1) it is certain that the function is used, (2)
  107. warning flags specified by the user require some amount of
  108. compilation in order to honor, (3) the language indicates that
  109. semantic analysis is not complete until gimplification occurs.
  110. Hum&hellip; this sounds overly complicated. Perhaps we should just
  111. have the front end gimplify always; in most cases it&rsquo;s only one
  112. function call.
  113. </p>
  114. <p>The front end needs to pass all function definitions and top level
  115. declarations off to the middle-end so that they can be compiled and
  116. emitted to the object file. For a simple procedural language, it is
  117. usually most convenient to do this as each top level declaration or
  118. definition is seen. There is also a distinction to be made between
  119. generating functional code and generating complete debug information.
  120. The only thing that is absolutely required for functional code is that
  121. function and data <em>definitions</em> be passed to the middle-end. For
  122. complete debug information, function, data and type declarations
  123. should all be passed as well.
  124. </p>
  125. <a name="index-rest_005fof_005fdecl_005fcompilation"></a>
  126. <a name="index-rest_005fof_005ftype_005fcompilation"></a>
  127. <a name="index-cgraph_005ffinalize_005ffunction"></a>
  128. <p>In any case, the front end needs each complete top-level function or
  129. data declaration, and each data definition should be passed to
  130. <code>rest_of_decl_compilation</code>. Each complete type definition should
  131. be passed to <code>rest_of_type_compilation</code>. Each function definition
  132. should be passed to <code>cgraph_finalize_function</code>.
  133. </p>
  134. <p>TODO: I know rest_of_compilation currently has all sorts of
  135. RTL generation semantics. I plan to move all code generation
  136. bits (both Tree and RTL) to compile_function. Should we hide
  137. cgraph from the front ends and move back to rest_of_compilation
  138. as the official interface? Possibly we should rename all three
  139. interfaces such that the names match in some meaningful way and
  140. that is more descriptive than &quot;rest_of&quot;.
  141. </p>
  142. <p>The middle-end will, at its option, emit the function and data
  143. definitions immediately or queue them for later processing.
  144. </p>
  145. <hr>
  146. <div class="header">
  147. <p>
  148. Next: <a href="Gimplification-pass.html#Gimplification-pass" accesskey="n" rel="next">Gimplification pass</a>, Up: <a href="Passes.html#Passes" accesskey="u" rel="up">Passes</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>
  149. </div>
  150. </body>
  151. </html>