Statement-and-operand-traversals.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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: Statement and operand traversals</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Statement and operand traversals">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Statement and operand traversals">
  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="GIMPLE.html#GIMPLE" rel="up" title="GIMPLE">
  30. <link href="Tree-SSA.html#Tree-SSA" rel="next" title="Tree SSA">
  31. <link href="Adding-a-new-GIMPLE-statement-code.html#Adding-a-new-GIMPLE-statement-code" rel="prev" title="Adding a new GIMPLE statement code">
  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="Statement-and-operand-traversals"></a>
  63. <div class="header">
  64. <p>
  65. Previous: <a href="Adding-a-new-GIMPLE-statement-code.html#Adding-a-new-GIMPLE-statement-code" accesskey="p" rel="prev">Adding a new GIMPLE statement code</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>
  66. </div>
  67. <hr>
  68. <a name="Statement-and-operand-traversals-1"></a>
  69. <h3 class="section">11.12 Statement and operand traversals</h3>
  70. <a name="index-Statement-and-operand-traversals"></a>
  71. <p>There are two functions available for walking statements and
  72. sequences: <code>walk_gimple_stmt</code> and <code>walk_gimple_seq</code>,
  73. accordingly, and a third function for walking the operands in a
  74. statement: <code>walk_gimple_op</code>.
  75. </p>
  76. <dl>
  77. <dt><a name="index-walk_005fgimple_005fstmt"></a>GIMPLE function: <em>tree</em> <strong>walk_gimple_stmt</strong> <em>(gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)</em></dt>
  78. <dd><p>This function is used to walk the current statement in <code>GSI</code>,
  79. optionally using traversal state stored in <code>WI</code>. If <code>WI</code> is <code>NULL</code>, no
  80. state is kept during the traversal.
  81. </p>
  82. <p>The callback <code>CALLBACK_STMT</code> is called. If <code>CALLBACK_STMT</code> returns
  83. true, it means that the callback function has handled all the
  84. operands of the statement and it is not necessary to walk its
  85. operands.
  86. </p>
  87. <p>If <code>CALLBACK_STMT</code> is <code>NULL</code> or it returns false, <code>CALLBACK_OP</code> is
  88. called on each operand of the statement via <code>walk_gimple_op</code>. If
  89. <code>walk_gimple_op</code> returns non-<code>NULL</code> for any operand, the remaining
  90. operands are not scanned.
  91. </p>
  92. <p>The return value is that returned by the last call to
  93. <code>walk_gimple_op</code>, or <code>NULL_TREE</code> if no <code>CALLBACK_OP</code> is specified.
  94. </p></dd></dl>
  95. <dl>
  96. <dt><a name="index-walk_005fgimple_005fop"></a>GIMPLE function: <em>tree</em> <strong>walk_gimple_op</strong> <em>(gimple stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)</em></dt>
  97. <dd><p>Use this function to walk the operands of statement <code>STMT</code>. Every
  98. operand is walked via <code>walk_tree</code> with optional state information
  99. in <code>WI</code>.
  100. </p>
  101. <p><code>CALLBACK_OP</code> is called on each operand of <code>STMT</code> via <code>walk_tree</code>.
  102. Additional parameters to <code>walk_tree</code> must be stored in <code>WI</code>. For
  103. each operand <code>OP</code>, <code>walk_tree</code> is called as:
  104. </p>
  105. <div class="smallexample">
  106. <pre class="smallexample">walk_tree (&amp;<code>OP</code>, <code>CALLBACK_OP</code>, <code>WI</code>, <code>PSET</code>)
  107. </pre></div>
  108. <p>If <code>CALLBACK_OP</code> returns non-<code>NULL</code> for an operand, the remaining
  109. operands are not scanned. The return value is that returned by
  110. the last call to <code>walk_tree</code>, or <code>NULL_TREE</code> if no <code>CALLBACK_OP</code> is
  111. specified.
  112. </p></dd></dl>
  113. <dl>
  114. <dt><a name="index-walk_005fgimple_005fseq"></a>GIMPLE function: <em>tree</em> <strong>walk_gimple_seq</strong> <em>(gimple_seq seq, walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi)</em></dt>
  115. <dd><p>This function walks all the statements in the sequence <code>SEQ</code>
  116. calling <code>walk_gimple_stmt</code> on each one. <code>WI</code> is as in
  117. <code>walk_gimple_stmt</code>. If <code>walk_gimple_stmt</code> returns non-<code>NULL</code>, the walk
  118. is stopped and the value returned. Otherwise, all the statements
  119. are walked and <code>NULL_TREE</code> returned.
  120. </p></dd></dl>
  121. <hr>
  122. <div class="header">
  123. <p>
  124. Previous: <a href="Adding-a-new-GIMPLE-statement-code.html#Adding-a-new-GIMPLE-statement-code" accesskey="p" rel="prev">Adding a new GIMPLE statement code</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>
  125. </div>
  126. </body>
  127. </html>