//===- GenericLoopInfo - Generic Loop Info for graphs -----------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file defines the LoopInfoBase class that is used to identify natural // loops and determine the loop depth of various nodes in a generic graph of // blocks. A natural loop has exactly one entry-point, which is called the // header. Note that natural loops may actually be several loops that share the // same header node. // // This analysis calculates the nesting structure of loops in a function. For // each natural loop identified, this analysis identifies natural loops // contained entirely within the loop and the basic blocks that make up the // loop. // // It can calculate on the fly various bits of information, for example: // // * whether there is a preheader for the loop // * the number of back edges to the header // * whether or not a particular block branches out of the loop // * the successor blocks of the loop // * the loop depth // * etc... // // Note that this analysis specifically identifies *Loops* not cycles or SCCs // in the graph. There can be strongly connected components in the graph which // this analysis will not recognize and that will not be represented by a Loop // instance. In particular, a Loop might be inside such a non-loop SCC, or a // non-loop SCC might contain a sub-SCC which is a Loop. // // For an overview of terminology used in this API (and thus all of our loop // analyses or transforms), see docs/LoopTerminology.rst. // //===----------------------------------------------------------------------===// #ifndef LLVM_SUPPORT_GENERICLOOPINFO_H #define LLVM_SUPPORT_GENERICLOOPINFO_H #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SetOperations.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/GenericDomTree.h" namespace llvm { template <class N, class M> class LoopInfoBase; template <class N, class M> class LoopBase; //===----------------------------------------------------------------------===// /// Instances of this class are used to represent loops that are detected in the /// flow graph. /// template <class BlockT, class LoopT> class LoopBase { … }; template <class BlockT, class LoopT> raw_ostream &operator<<(raw_ostream &OS, const LoopBase<BlockT, LoopT> &Loop) { … } //===----------------------------------------------------------------------===// /// This class builds and contains all of the top-level loop /// structures in the specified function. /// template <class BlockT, class LoopT> class LoopInfoBase { … }; } // namespace llvm #endif // LLVM_SUPPORT_GENERICLOOPINFO_H