1//===- CFGLoopInfo.h - LoopInfo analysis for region bodies ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the CFGLoopInfo analysis for MLIR. The CFGLoopInfo is used
10// to identify natural loops and determine the loop depth of various nodes of a
11// CFG.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef MLIR_ANALYSIS_LOOPINFO_H
16#define MLIR_ANALYSIS_LOOPINFO_H
17
18#include "mlir/IR/Dominance.h"
19#include "mlir/IR/RegionGraphTraits.h"
20#include "llvm/Support/GenericLoopInfo.h"
21
22namespace mlir {
23class CFGLoop;
24class CFGLoopInfo;
25} // namespace mlir
26
27namespace llvm {
28// Implementation in LLVM's LoopInfoImpl.h
29extern template class LoopBase<mlir::Block, mlir::CFGLoop>;
30extern template class LoopInfoBase<mlir::Block, mlir::CFGLoop>;
31} // namespace llvm
32
33namespace mlir {
34
35/// Representation of a single loop formed by blocks. The inherited LoopBase
36/// class provides accessors to the loop analysis.
37class CFGLoop : public llvm::LoopBase<mlir::Block, mlir::CFGLoop> {
38private:
39 explicit CFGLoop(mlir::Block *block);
40
41 friend class llvm::LoopBase<mlir::Block, CFGLoop>;
42 friend class llvm::LoopInfoBase<mlir::Block, CFGLoop>;
43};
44
45/// An LLVM LoopInfo instantiation for MLIR that provides access to CFG loops
46/// found in the dominator tree.
47class CFGLoopInfo : public llvm::LoopInfoBase<mlir::Block, mlir::CFGLoop> {
48public:
49 CFGLoopInfo(const llvm::DominatorTreeBase<mlir::Block, false> &domTree);
50};
51
52raw_ostream &operator<<(raw_ostream &os, mlir::Block &block);
53
54} // namespace mlir
55
56#endif // MLIR_ANALYSIS_LOOPINFO_H
57

source code of mlir/include/mlir/Analysis/CFGLoopInfo.h