#pragma once // // This file is distributed under the MIT License. See LICENSE.md for details. // #include #include "revng/ADT/ConstantRangeSet.h" #include "revng/MFP/Graph.h" #include "revng/MFP/MFP.h" #include "revng/ValueMaterializer/ControlFlowEdgesGraph.h" #include "revng/ValueMaterializer/DataFlowRangeAnalysis.h" namespace llvm { class Instruction; class LazyValueInfo; class DominatorTree; } // namespace llvm class DataFlowGraph; class AdvancedValueInfoMFI { public: using LatticeElement = std::map; using GraphType = const ControlFlowEdgesGraph *; using Label = const ControlFlowEdgesGraph::Node *; using ResultsMap = std::map>; using InstructionsSet = llvm::SmallPtrSetImpl; using ExtraStateType = mfp::NoExtraState; private: llvm::LazyValueInfo &LVI; DataFlowRangeAnalysis &DFRA; const llvm::DominatorTree &DT; llvm::Instruction *Context; llvm::SmallPtrSetImpl &Instructions; bool ZeroExtendConstraints = false; public: AdvancedValueInfoMFI(llvm::LazyValueInfo &LVI, DataFlowRangeAnalysis &DFRA, const llvm::DominatorTree &DT, llvm::Instruction *Context, InstructionsSet &Instructions, bool ZeroExtendConstraints) : LVI(LVI), DFRA(DFRA), DT(DT), Context(Context), Instructions(Instructions), ZeroExtendConstraints(ZeroExtendConstraints) {} public: LatticeElement combineValues(const LatticeElement &LHS, const LatticeElement &RHS) const; bool isLessOrEqual(const LatticeElement &LHS, const LatticeElement &RHS) const; LatticeElement applyTransferFunction(Label L, const LatticeElement &E, mfp::NoExtraState &) const; public: static void dump(GraphType CFEG, const ResultsMap &AllResults); }; static_assert(mfp::MonotoneFrameworkInstance); /// \p DFG the data flow graph containing the instructions we're interested in. /// \p Context the position in the function for the current query. std::tuple< std::map, ControlFlowEdgesGraph, std::map *, mfp::MFPResult>>> runAVI(const DataFlowGraph &DFG, llvm::Instruction *Context, const llvm::DominatorTree &DT, llvm::LazyValueInfo &LVI, DataFlowRangeAnalysis &DFRA, bool ZeroExtendConstraints); template<> void mfp::dump(llvm::raw_ostream &Stream, unsigned Indent, const std::map &Element); template<> void mfp::dumpLabel(llvm::raw_ostream &Stream, const ControlFlowEdgesGraph::Node *const &Label);