Loop-querying.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: Loop querying</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Loop querying">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Loop querying">
  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="Loop-Analysis-and-Representation.html#Loop-Analysis-and-Representation" rel="up" title="Loop Analysis and Representation">
  30. <link href="Loop-manipulation.html#Loop-manipulation" rel="next" title="Loop manipulation">
  31. <link href="Loop-representation.html#Loop-representation" rel="prev" title="Loop representation">
  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="Loop-querying"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Loop-manipulation.html#Loop-manipulation" accesskey="n" rel="next">Loop manipulation</a>, Previous: <a href="Loop-representation.html#Loop-representation" accesskey="p" rel="prev">Loop representation</a>, Up: <a href="Loop-Analysis-and-Representation.html#Loop-Analysis-and-Representation" accesskey="u" rel="up">Loop Analysis and Representation</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="Loop-querying-1"></a>
  69. <h3 class="section">15.2 Loop querying</h3>
  70. <a name="index-Loop-querying"></a>
  71. <p>The functions to query the information about loops are declared in
  72. <samp>cfgloop.h</samp>. Some of the information can be taken directly from
  73. the structures. <code>loop_father</code> field of each basic block contains
  74. the innermost loop to that the block belongs. The most useful fields of
  75. loop structure (that are kept up-to-date at all times) are:
  76. </p>
  77. <ul>
  78. <li> <code>header</code>, <code>latch</code>: Header and latch basic blocks of the
  79. loop.
  80. </li><li> <code>num_nodes</code>: Number of basic blocks in the loop (including
  81. the basic blocks of the sub-loops).
  82. </li><li> <code>outer</code>, <code>inner</code>, <code>next</code>: The super-loop, the first
  83. sub-loop, and the sibling of the loop in the loops tree.
  84. </li></ul>
  85. <p>There are other fields in the loop structures, many of them used only by
  86. some of the passes, or not updated during CFG changes; in general, they
  87. should not be accessed directly.
  88. </p>
  89. <p>The most important functions to query loop structures are:
  90. </p>
  91. <ul>
  92. <li> <code>loop_depth</code>: The depth of the loop in the loops tree, i.e., the
  93. number of super-loops of the loop.
  94. </li><li> <code>flow_loops_dump</code>: Dumps the information about loops to a
  95. file.
  96. </li><li> <code>verify_loop_structure</code>: Checks consistency of the loop
  97. structures.
  98. </li><li> <code>loop_latch_edge</code>: Returns the latch edge of a loop.
  99. </li><li> <code>loop_preheader_edge</code>: If loops have preheaders, returns
  100. the preheader edge of a loop.
  101. </li><li> <code>flow_loop_nested_p</code>: Tests whether loop is a sub-loop of
  102. another loop.
  103. </li><li> <code>flow_bb_inside_loop_p</code>: Tests whether a basic block belongs
  104. to a loop (including its sub-loops).
  105. </li><li> <code>find_common_loop</code>: Finds the common super-loop of two loops.
  106. </li><li> <code>superloop_at_depth</code>: Returns the super-loop of a loop with
  107. the given depth.
  108. </li><li> <code>tree_num_loop_insns</code>, <code>num_loop_insns</code>: Estimates the
  109. number of insns in the loop, on GIMPLE and on RTL.
  110. </li><li> <code>loop_exit_edge_p</code>: Tests whether edge is an exit from a
  111. loop.
  112. </li><li> <code>mark_loop_exit_edges</code>: Marks all exit edges of all loops
  113. with <code>EDGE_LOOP_EXIT</code> flag.
  114. </li><li> <code>get_loop_body</code>, <code>get_loop_body_in_dom_order</code>,
  115. <code>get_loop_body_in_bfs_order</code>: Enumerates the basic blocks in the
  116. loop in depth-first search order in reversed CFG, ordered by dominance
  117. relation, and breath-first search order, respectively.
  118. </li><li> <code>single_exit</code>: Returns the single exit edge of the loop, or
  119. <code>NULL</code> if the loop has more than one exit. You can only use this
  120. function if LOOPS_HAVE_MARKED_SINGLE_EXITS property is used.
  121. </li><li> <code>get_loop_exit_edges</code>: Enumerates the exit edges of a loop.
  122. </li><li> <code>just_once_each_iteration_p</code>: Returns true if the basic block
  123. is executed exactly once during each iteration of a loop (that is, it
  124. does not belong to a sub-loop, and it dominates the latch of the loop).
  125. </li></ul>
  126. <hr>
  127. <div class="header">
  128. <p>
  129. Next: <a href="Loop-manipulation.html#Loop-manipulation" accesskey="n" rel="next">Loop manipulation</a>, Previous: <a href="Loop-representation.html#Loop-representation" accesskey="p" rel="prev">Loop representation</a>, Up: <a href="Loop-Analysis-and-Representation.html#Loop-Analysis-and-Representation" accesskey="u" rel="up">Loop Analysis and Representation</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>
  130. </div>
  131. </body>
  132. </html>