選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

180 行
8.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>Tree overview (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Tree overview (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Tree overview (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="GENERIC.html#GENERIC" rel="up" title="GENERIC">
  30. <link href="Macros-and-Functions.html#Macros-and-Functions" rel="next" title="Macros and Functions">
  31. <link href="Deficiencies.html#Deficiencies" rel="prev" title="Deficiencies">
  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="Tree-overview"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Types.html#Types" accesskey="n" rel="next">Types</a>, Previous: <a href="Deficiencies.html#Deficiencies" accesskey="p" rel="prev">Deficiencies</a>, Up: <a href="GENERIC.html#GENERIC" accesskey="u" rel="up">GENERIC</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="Overview-1"></a>
  68. <h3 class="section">11.2 Overview</h3>
  69. <a name="index-tree"></a>
  70. <a name="index-TREE_005fCODE"></a>
  71. <p>The central data structure used by the internal representation is the
  72. <code>tree</code>. These nodes, while all of the C type <code>tree</code>, are of
  73. many varieties. A <code>tree</code> is a pointer type, but the object to
  74. which it points may be of a variety of types. From this point forward,
  75. we will refer to trees in ordinary type, rather than in <code>this
  76. font</code>, except when talking about the actual C type <code>tree</code>.
  77. </p>
  78. <p>You can tell what kind of node a particular tree is by using the
  79. <code>TREE_CODE</code> macro. Many, many macros take trees as input and
  80. return trees as output. However, most macros require a certain kind of
  81. tree node as input. In other words, there is a type-system for trees,
  82. but it is not reflected in the C type-system.
  83. </p>
  84. <p>For safety, it is useful to configure GCC with <samp>--enable-checking</samp>.
  85. Although this results in a significant performance penalty (since all
  86. tree types are checked at run-time), and is therefore inappropriate in a
  87. release version, it is extremely helpful during the development process.
  88. </p>
  89. <p>Many macros behave as predicates. Many, although not all, of these
  90. predicates end in &lsquo;<samp>_P</samp>&rsquo;. Do not rely on the result type of these
  91. macros being of any particular type. You may, however, rely on the fact
  92. that the type can be compared to <code>0</code>, so that statements like
  93. </p><div class="smallexample">
  94. <pre class="smallexample">if (TEST_P (t) &amp;&amp; !TEST_P (y))
  95. x = 1;
  96. </pre></div>
  97. <p>and
  98. </p><div class="smallexample">
  99. <pre class="smallexample">int i = (TEST_P (t) != 0);
  100. </pre></div>
  101. <p>are legal. Macros that return <code>int</code> values now may be changed to
  102. return <code>tree</code> values, or other pointers in the future. Even those
  103. that continue to return <code>int</code> may return multiple nonzero codes
  104. where previously they returned only zero and one. Therefore, you should
  105. not write code like
  106. </p><div class="smallexample">
  107. <pre class="smallexample">if (TEST_P (t) == 1)
  108. </pre></div>
  109. <p>as this code is not guaranteed to work correctly in the future.
  110. </p>
  111. <p>You should not take the address of values returned by the macros or
  112. functions described here. In particular, no guarantee is given that the
  113. values are lvalues.
  114. </p>
  115. <p>In general, the names of macros are all in uppercase, while the names of
  116. functions are entirely in lowercase. There are rare exceptions to this
  117. rule. You should assume that any macro or function whose name is made
  118. up entirely of uppercase letters may evaluate its arguments more than
  119. once. You may assume that a macro or function whose name is made up
  120. entirely of lowercase letters will evaluate its arguments only once.
  121. </p>
  122. <p>The <code>error_mark_node</code> is a special tree. Its tree code is
  123. <code>ERROR_MARK</code>, but since there is only ever one node with that code,
  124. the usual practice is to compare the tree against
  125. <code>error_mark_node</code>. (This test is just a test for pointer
  126. equality.) If an error has occurred during front-end processing the
  127. flag <code>errorcount</code> will be set. If the front end has encountered
  128. code it cannot handle, it will issue a message to the user and set
  129. <code>sorrycount</code>. When these flags are set, any macro or function
  130. which normally returns a tree of a particular kind may instead return
  131. the <code>error_mark_node</code>. Thus, if you intend to do any processing of
  132. erroneous code, you must be prepared to deal with the
  133. <code>error_mark_node</code>.
  134. </p>
  135. <p>Occasionally, a particular tree slot (like an operand to an expression,
  136. or a particular field in a declaration) will be referred to as
  137. &ldquo;reserved for the back end&rdquo;. These slots are used to store RTL when
  138. the tree is converted to RTL for use by the GCC back end. However, if
  139. that process is not taking place (e.g., if the front end is being hooked
  140. up to an intelligent editor), then those slots may be used by the
  141. back end presently in use.
  142. </p>
  143. <p>If you encounter situations that do not match this documentation, such
  144. as tree nodes of types not mentioned here, or macros documented to
  145. return entities of a particular kind that instead return entities of
  146. some different kind, you have found a bug, either in the front end or in
  147. the documentation. Please report these bugs as you would any other
  148. bug.
  149. </p>
  150. <table class="menu" border="0" cellspacing="0">
  151. <tr><td align="left" valign="top">&bull; <a href="Macros-and-Functions.html#Macros-and-Functions" accesskey="1">Macros and Functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Macros and functions that can be used with all trees.
  152. </td></tr>
  153. <tr><td align="left" valign="top">&bull; <a href="Identifiers.html#Identifiers" accesskey="2">Identifiers</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The names of things.
  154. </td></tr>
  155. <tr><td align="left" valign="top">&bull; <a href="Containers.html#Containers" accesskey="3">Containers</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Lists and vectors.
  156. </td></tr>
  157. </table>
  158. <hr>
  159. <div class="header">
  160. <p>
  161. Next: <a href="Types.html#Types" accesskey="n" rel="next">Types</a>, Previous: <a href="Deficiencies.html#Deficiencies" accesskey="p" rel="prev">Deficiencies</a>, Up: <a href="GENERIC.html#GENERIC" accesskey="u" rel="up">GENERIC</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>
  162. </div>
  163. </body>
  164. </html>