Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

297 lines
12KB

  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>Tuple representation (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Tuple representation (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Tuple representation (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="GIMPLE.html#GIMPLE" rel="up" title="GIMPLE">
  30. <link href="Class-hierarchy-of-GIMPLE-statements.html#Class-hierarchy-of-GIMPLE-statements" rel="next" title="Class hierarchy of GIMPLE statements">
  31. <link href="GIMPLE.html#GIMPLE" rel="prev" title="GIMPLE">
  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="Tuple-representation"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Class-hierarchy-of-GIMPLE-statements.html#Class-hierarchy-of-GIMPLE-statements" accesskey="n" rel="next">Class hierarchy of GIMPLE statements</a>, Up: <a href="GIMPLE.html#GIMPLE" accesskey="u" rel="up">GIMPLE</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="Tuple-representation-1"></a>
  68. <h3 class="section">12.1 Tuple representation</h3>
  69. <a name="index-tuples"></a>
  70. <p>GIMPLE instructions are tuples of variable size divided in two
  71. groups: a header describing the instruction and its locations,
  72. and a variable length body with all the operands. Tuples are
  73. organized into a hierarchy with 3 main classes of tuples.
  74. </p>
  75. <a name="gimple-_0028gsbase_0029"></a>
  76. <h4 class="subsection">12.1.1 <code>gimple</code> (gsbase)</h4>
  77. <a name="index-gimple"></a>
  78. <p>This is the root of the hierarchy, it holds basic information
  79. needed by most GIMPLE statements. There are some fields that
  80. may not be relevant to every GIMPLE statement, but those were
  81. moved into the base structure to take advantage of holes left by
  82. other fields (thus making the structure more compact). The
  83. structure takes 4 words (32 bytes) on 64 bit hosts:
  84. </p>
  85. <table>
  86. <tr><td>Field</td><td>Size (bits)</td></tr>
  87. <tr><td><code>code</code></td><td>8</td></tr>
  88. <tr><td><code>subcode</code></td><td>16</td></tr>
  89. <tr><td><code>no_warning</code></td><td>1</td></tr>
  90. <tr><td><code>visited</code></td><td>1</td></tr>
  91. <tr><td><code>nontemporal_move</code></td><td>1</td></tr>
  92. <tr><td><code>plf</code></td><td>2</td></tr>
  93. <tr><td><code>modified</code></td><td>1</td></tr>
  94. <tr><td><code>has_volatile_ops</code></td><td>1</td></tr>
  95. <tr><td><code>references_memory_p</code></td><td>1</td></tr>
  96. <tr><td><code>uid</code></td><td>32</td></tr>
  97. <tr><td><code>location</code></td><td>32</td></tr>
  98. <tr><td><code>num_ops</code></td><td>32</td></tr>
  99. <tr><td><code>bb</code></td><td>64</td></tr>
  100. <tr><td><code>block</code></td><td>63</td></tr>
  101. <tr><td>Total size</td><td>32 bytes</td></tr>
  102. </table>
  103. <ul>
  104. <li> <code>code</code>
  105. Main identifier for a GIMPLE instruction.
  106. </li><li> <code>subcode</code>
  107. Used to distinguish different variants of the same basic
  108. instruction or provide flags applicable to a given code. The
  109. <code>subcode</code> flags field has different uses depending on the code of
  110. the instruction, but mostly it distinguishes instructions of the
  111. same family. The most prominent use of this field is in
  112. assignments, where subcode indicates the operation done on the
  113. RHS of the assignment. For example, a = b + c is encoded as
  114. <code>GIMPLE_ASSIGN &lt;PLUS_EXPR, a, b, c&gt;</code>.
  115. </li><li> <code>no_warning</code>
  116. Bitflag to indicate whether a warning has already been issued on
  117. this statement.
  118. </li><li> <code>visited</code>
  119. General purpose &ldquo;visited&rdquo; marker. Set and cleared by each pass
  120. when needed.
  121. </li><li> <code>nontemporal_move</code>
  122. Bitflag used in assignments that represent non-temporal moves.
  123. Although this bitflag is only used in assignments, it was moved
  124. into the base to take advantage of the bit holes left by the
  125. previous fields.
  126. </li><li> <code>plf</code>
  127. Pass Local Flags. This 2-bit mask can be used as general purpose
  128. markers by any pass. Passes are responsible for clearing and
  129. setting these two flags accordingly.
  130. </li><li> <code>modified</code>
  131. Bitflag to indicate whether the statement has been modified.
  132. Used mainly by the operand scanner to determine when to re-scan a
  133. statement for operands.
  134. </li><li> <code>has_volatile_ops</code>
  135. Bitflag to indicate whether this statement contains operands that
  136. have been marked volatile.
  137. </li><li> <code>references_memory_p</code>
  138. Bitflag to indicate whether this statement contains memory
  139. references (i.e., its operands are either global variables, or
  140. pointer dereferences or anything that must reside in memory).
  141. </li><li> <code>uid</code>
  142. This is an unsigned integer used by passes that want to assign
  143. IDs to every statement. These IDs must be assigned and used by
  144. each pass.
  145. </li><li> <code>location</code>
  146. This is a <code>location_t</code> identifier to specify source code
  147. location for this statement. It is inherited from the front
  148. end.
  149. </li><li> <code>num_ops</code>
  150. Number of operands that this statement has. This specifies the
  151. size of the operand vector embedded in the tuple. Only used in
  152. some tuples, but it is declared in the base tuple to take
  153. advantage of the 32-bit hole left by the previous fields.
  154. </li><li> <code>bb</code>
  155. Basic block holding the instruction.
  156. </li><li> <code>block</code>
  157. Lexical block holding this statement. Also used for debug
  158. information generation.
  159. </li></ul>
  160. <a name="gimple_005fstatement_005fwith_005fops"></a>
  161. <h4 class="subsection">12.1.2 <code>gimple_statement_with_ops</code></h4>
  162. <a name="index-gimple_005fstatement_005fwith_005fops"></a>
  163. <p>This tuple is actually split in two:
  164. <code>gimple_statement_with_ops_base</code> and
  165. <code>gimple_statement_with_ops</code>. This is needed to accommodate the
  166. way the operand vector is allocated. The operand vector is
  167. defined to be an array of 1 element. So, to allocate a dynamic
  168. number of operands, the memory allocator (<code>gimple_alloc</code>) simply
  169. allocates enough memory to hold the structure itself plus <code>N
  170. - 1</code> operands which run &ldquo;off the end&rdquo; of the structure. For
  171. example, to allocate space for a tuple with 3 operands,
  172. <code>gimple_alloc</code> reserves <code>sizeof (struct
  173. gimple_statement_with_ops) + 2 * sizeof (tree)</code> bytes.
  174. </p>
  175. <p>On the other hand, several fields in this tuple need to be shared
  176. with the <code>gimple_statement_with_memory_ops</code> tuple. So, these
  177. common fields are placed in <code>gimple_statement_with_ops_base</code> which
  178. is then inherited from the other two tuples.
  179. </p>
  180. <table>
  181. <tr><td><code>gsbase</code></td><td>256</td></tr>
  182. <tr><td><code>def_ops</code></td><td>64</td></tr>
  183. <tr><td><code>use_ops</code></td><td>64</td></tr>
  184. <tr><td><code>op</code></td><td><code>num_ops</code> * 64</td></tr>
  185. <tr><td>Total size</td><td>48 + 8 * <code>num_ops</code> bytes</td></tr>
  186. </table>
  187. <ul>
  188. <li> <code>gsbase</code>
  189. Inherited from <code>struct gimple</code>.
  190. </li><li> <code>def_ops</code>
  191. Array of pointers into the operand array indicating all the slots that
  192. contain a variable written-to by the statement. This array is
  193. also used for immediate use chaining. Note that it would be
  194. possible to not rely on this array, but the changes required to
  195. implement this are pretty invasive.
  196. </li><li> <code>use_ops</code>
  197. Similar to <code>def_ops</code> but for variables read by the statement.
  198. </li><li> <code>op</code>
  199. Array of trees with <code>num_ops</code> slots.
  200. </li></ul>
  201. <a name="gimple_005fstatement_005fwith_005fmemory_005fops"></a>
  202. <h4 class="subsection">12.1.3 <code>gimple_statement_with_memory_ops</code></h4>
  203. <p>This tuple is essentially identical to <code>gimple_statement_with_ops</code>,
  204. except that it contains 4 additional fields to hold vectors
  205. related memory stores and loads. Similar to the previous case,
  206. the structure is split in two to accommodate for the operand
  207. vector (<code>gimple_statement_with_memory_ops_base</code> and
  208. <code>gimple_statement_with_memory_ops</code>).
  209. </p>
  210. <table>
  211. <tr><td>Field</td><td>Size (bits)</td></tr>
  212. <tr><td><code>gsbase</code></td><td>256</td></tr>
  213. <tr><td><code>def_ops</code></td><td>64</td></tr>
  214. <tr><td><code>use_ops</code></td><td>64</td></tr>
  215. <tr><td><code>vdef_ops</code></td><td>64</td></tr>
  216. <tr><td><code>vuse_ops</code></td><td>64</td></tr>
  217. <tr><td><code>stores</code></td><td>64</td></tr>
  218. <tr><td><code>loads</code></td><td>64</td></tr>
  219. <tr><td><code>op</code></td><td><code>num_ops</code> * 64</td></tr>
  220. <tr><td>Total size</td><td>80 + 8 * <code>num_ops</code> bytes</td></tr>
  221. </table>
  222. <ul>
  223. <li> <code>vdef_ops</code>
  224. Similar to <code>def_ops</code> but for <code>VDEF</code> operators. There is
  225. one entry per memory symbol written by this statement. This is
  226. used to maintain the memory SSA use-def and def-def chains.
  227. </li><li> <code>vuse_ops</code>
  228. Similar to <code>use_ops</code> but for <code>VUSE</code> operators. There is
  229. one entry per memory symbol loaded by this statement. This is
  230. used to maintain the memory SSA use-def chains.
  231. </li><li> <code>stores</code>
  232. Bitset with all the UIDs for the symbols written-to by the
  233. statement. This is different than <code>vdef_ops</code> in that all the
  234. affected symbols are mentioned in this set. If memory
  235. partitioning is enabled, the <code>vdef_ops</code> vector will refer to memory
  236. partitions. Furthermore, no SSA information is stored in this
  237. set.
  238. </li><li> <code>loads</code>
  239. Similar to <code>stores</code>, but for memory loads. (Note that there
  240. is some amount of redundancy here, it should be possible to
  241. reduce memory utilization further by removing these sets).
  242. </li></ul>
  243. <p>All the other tuples are defined in terms of these three basic
  244. ones. Each tuple will add some fields.
  245. </p>
  246. <hr>
  247. <div class="header">
  248. <p>
  249. Next: <a href="Class-hierarchy-of-GIMPLE-statements.html#Class-hierarchy-of-GIMPLE-statements" accesskey="n" rel="next">Class hierarchy of GIMPLE statements</a>, Up: <a href="GIMPLE.html#GIMPLE" accesskey="u" rel="up">GIMPLE</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>
  250. </div>
  251. </body>
  252. </html>