diff --git a/mlir/include/mlir/Analysis/CFGLoopInfo.h b/mlir/include/mlir/Analysis/CFGLoopInfo.h --- a/mlir/include/mlir/Analysis/CFGLoopInfo.h +++ b/mlir/include/mlir/Analysis/CFGLoopInfo.h @@ -18,7 +18,17 @@ #include "mlir/IR/Dominance.h" #include "mlir/IR/RegionGraphTraits.h" #include "llvm/Analysis/LoopInfo.h" -#include "llvm/Analysis/LoopInfoImpl.h" + +namespace mlir { +class CFGLoop; +class CFGLoopInfo; +} // namespace mlir + +namespace llvm { +// Implementation in LLVM's LoopInfoImpl.h +extern template class LoopBase; +extern template class LoopInfoBase; +} // namespace llvm namespace mlir { @@ -38,6 +48,9 @@ public: CFGLoopInfo(const llvm::DominatorTreeBase &domTree); }; + +raw_ostream &operator<<(raw_ostream &os, mlir::Block &block); + } // namespace mlir #endif // MLIR_ANALYSIS_LOOPINFO_H diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -351,6 +351,10 @@ void printAsOperand(raw_ostream &os, bool printType = true); void printAsOperand(raw_ostream &os, AsmState &state); + /// NOTE: Do not call this function, it is only used to be compatible with the + /// LLVM loop analysis machinery. + bool isLegalToHoistInto() const { return false; }; + private: /// Pair of the parent object that owns this block and a bit that signifies if /// the operations within this block have a valid ordering. diff --git a/mlir/lib/Analysis/CFGLoopInfo.cpp b/mlir/lib/Analysis/CFGLoopInfo.cpp --- a/mlir/lib/Analysis/CFGLoopInfo.cpp +++ b/mlir/lib/Analysis/CFGLoopInfo.cpp @@ -7,6 +7,12 @@ //===----------------------------------------------------------------------===// #include "mlir/Analysis/CFGLoopInfo.h" +#include "llvm/Analysis/LoopInfoImpl.h" + +// Explicitly instantiate the LoopBase and LoopInfoBase classes defined in +// LoopInfoImpl.h for CFGLoops +template class llvm::LoopBase; +template class llvm::LoopInfoBase; using namespace mlir; @@ -17,3 +23,8 @@ const llvm::DominatorTreeBase &domTree) { analyze(domTree); } + +raw_ostream &mlir::operator<<(raw_ostream &os, mlir::Block &block) { + block.print(os); + return os; +}