//===- DenseAnalysis.h - Dense data-flow analysis -------------------------===// // // 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 implements dense data-flow analysis using the data-flow analysis // framework. The analysis is forward and conditional and uses the results of // dead code analysis to prune dead code during the analysis. // //===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_DENSEDATAFLOWANALYSIS_H #define MLIR_ANALYSIS_DENSEDATAFLOWANALYSIS_H #include "mlir/Analysis/DataFlowFramework.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" namespace mlir { namespace dataflow { //===----------------------------------------------------------------------===// // CallControlFlowAction //===----------------------------------------------------------------------===// /// Indicates whether the control enters, exits, or skips over the callee (in /// the case of external functions). enum class CallControlFlowAction { … }; //===----------------------------------------------------------------------===// // AbstractDenseLattice //===----------------------------------------------------------------------===// /// This class represents a dense lattice. A dense lattice is attached to /// program point to represent the program state at the program point. /// lattice is propagated through the IR by dense data-flow analysis. class AbstractDenseLattice : public AnalysisState { … }; //===----------------------------------------------------------------------===// // AbstractDenseForwardDataFlowAnalysis //===----------------------------------------------------------------------===// /// Base class for dense forward data-flow analyses. Dense data-flow analysis /// attaches a lattice to program points and implements a transfer function from /// the lattice before each operation to the lattice after. The lattice contains /// information about the state of the program at that program point. /// /// Visit a program point in forward dense data-flow analysis will invoke the /// transfer function of the operation preceding the program point iterator. /// Visit a program point at the begining of block will visit the block itself. class AbstractDenseForwardDataFlowAnalysis : public DataFlowAnalysis { … }; //===----------------------------------------------------------------------===// // DenseForwardDataFlowAnalysis //===----------------------------------------------------------------------===// /// A dense forward data-flow analysis for propagating lattices before and /// after the execution of every operation across the IR by implementing /// transfer functions for operations. /// /// `LatticeT` is expected to be a subclass of `AbstractDenseLattice`. template <typename LatticeT> class DenseForwardDataFlowAnalysis : public AbstractDenseForwardDataFlowAnalysis { … }; //===----------------------------------------------------------------------===// // AbstractDenseBackwardDataFlowAnalysis //===----------------------------------------------------------------------===// /// Base class for dense backward dataflow analyses. Such analyses attach a /// lattice to program point and implement a transfer function from the lattice /// after the operation to the lattice before it, thus propagating backward. /// /// Visit a program point in dense backward data-flow analysis will invoke the /// transfer function of the operation following the program point iterator. /// Visit a program point at the end of block will visit the block itself. class AbstractDenseBackwardDataFlowAnalysis : public DataFlowAnalysis { … }; //===----------------------------------------------------------------------===// // DenseBackwardDataFlowAnalysis //===----------------------------------------------------------------------===// /// A dense backward dataflow analysis propagating lattices after and before the /// execution of every operation across the IR by implementing transfer /// functions for opreations. /// /// `LatticeT` is expected to be a subclass of `AbstractDenseLattice`. template <typename LatticeT> class DenseBackwardDataFlowAnalysis : public AbstractDenseBackwardDataFlowAnalysis { … }; } // end namespace dataflow } // end namespace mlir #endif // MLIR_ANALYSIS_DENSEDATAFLOWANALYSIS_H