blob: 18fd8fc2a913298db9e17c0854df766a897b3797 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2015 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below). A copy of the license is included in the section entitled
"GNU Free Documentation License".
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development. -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Compiler Collection (GCC) Internals: Loop querying</title>
<meta name="description" content="GNU Compiler Collection (GCC) Internals: Loop querying">
<meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Loop querying">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Loop-Analysis-and-Representation.html#Loop-Analysis-and-Representation" rel="up" title="Loop Analysis and Representation">
<link href="Loop-manipulation.html#Loop-manipulation" rel="next" title="Loop manipulation">
<link href="Loop-representation.html#Loop-representation" rel="prev" title="Loop representation">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Loop-querying"></a>
<div class="header">
<p>
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>
</div>
<hr>
<a name="Loop-querying-1"></a>
<h3 class="section">15.2 Loop querying</h3>
<a name="index-Loop-querying"></a>
<p>The functions to query the information about loops are declared in
<samp>cfgloop.h</samp>. Some of the information can be taken directly from
the structures. <code>loop_father</code> field of each basic block contains
the innermost loop to that the block belongs. The most useful fields of
loop structure (that are kept up-to-date at all times) are:
</p>
<ul>
<li> <code>header</code>, <code>latch</code>: Header and latch basic blocks of the
loop.
</li><li> <code>num_nodes</code>: Number of basic blocks in the loop (including
the basic blocks of the sub-loops).
</li><li> <code>depth</code>: The depth of the loop in the loops tree, i.e., the
number of super-loops of the loop.
</li><li> <code>outer</code>, <code>inner</code>, <code>next</code>: The super-loop, the first
sub-loop, and the sibling of the loop in the loops tree.
</li></ul>
<p>There are other fields in the loop structures, many of them used only by
some of the passes, or not updated during CFG changes; in general, they
should not be accessed directly.
</p>
<p>The most important functions to query loop structures are:
</p>
<ul>
<li> <code>flow_loops_dump</code>: Dumps the information about loops to a
file.
</li><li> <code>verify_loop_structure</code>: Checks consistency of the loop
structures.
</li><li> <code>loop_latch_edge</code>: Returns the latch edge of a loop.
</li><li> <code>loop_preheader_edge</code>: If loops have preheaders, returns
the preheader edge of a loop.
</li><li> <code>flow_loop_nested_p</code>: Tests whether loop is a sub-loop of
another loop.
</li><li> <code>flow_bb_inside_loop_p</code>: Tests whether a basic block belongs
to a loop (including its sub-loops).
</li><li> <code>find_common_loop</code>: Finds the common super-loop of two loops.
</li><li> <code>superloop_at_depth</code>: Returns the super-loop of a loop with
the given depth.
</li><li> <code>tree_num_loop_insns</code>, <code>num_loop_insns</code>: Estimates the
number of insns in the loop, on GIMPLE and on RTL.
</li><li> <code>loop_exit_edge_p</code>: Tests whether edge is an exit from a
loop.
</li><li> <code>mark_loop_exit_edges</code>: Marks all exit edges of all loops
with <code>EDGE_LOOP_EXIT</code> flag.
</li><li> <code>get_loop_body</code>, <code>get_loop_body_in_dom_order</code>,
<code>get_loop_body_in_bfs_order</code>: Enumerates the basic blocks in the
loop in depth-first search order in reversed CFG, ordered by dominance
relation, and breath-first search order, respectively.
</li><li> <code>single_exit</code>: Returns the single exit edge of the loop, or
<code>NULL</code> if the loop has more than one exit. You can only use this
function if LOOPS_HAVE_MARKED_SINGLE_EXITS property is used.
</li><li> <code>get_loop_exit_edges</code>: Enumerates the exit edges of a loop.
</li><li> <code>just_once_each_iteration_p</code>: Returns true if the basic block
is executed exactly once during each iteration of a loop (that is, it
does not belong to a sub-loop, and it dominates the latch of the loop).
</li></ul>
<hr>
<div class="header">
<p>
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>
</div>
</body>
</html>