17#include <mlir/Analysis/DataFlow/DenseAnalysis.h>
19#include <llvm/ADT/PointerUnion.h>
24using TranslationMap = std::unordered_map<SourceRef, SourceRefLatticeValue, SourceRef::Hash>;
39 using ArrayTy = std::vector<std::unique_ptr<SourceRefLatticeValue>>;
62 std::pair<SourceRefLatticeValue, mlir::ChangeResult>
71 mlir::FailureOr<std::pair<SourceRefLatticeValue, mlir::ChangeResult>>
76 mlir::FailureOr<std::pair<SourceRefLatticeValue, mlir::ChangeResult>>
77 extract(
const std::vector<SourceRefIndex> &indices)
const;
86 virtual mlir::FailureOr<std::pair<SourceRefLatticeValue, mlir::ChangeResult>>
88 llvm::function_ref<mlir::FailureOr<SourceRef>(
const SourceRef &)> transform
98 using ValueTy = llvm::PointerUnion<mlir::Value, mlir::Operation *>;
99 using Ref2Val = mlir::DenseMap<SourceRef, mlir::DenseSet<ValueTy>>;
107 static mlir::FailureOr<SourceRef>
getSourceRef(mlir::Value val);
110 using AbstractSparseLattice::AbstractSparseLattice;
112 mlir::ChangeResult
join(
const AbstractSparseLattice &rhs)
override;
113 mlir::ChangeResult
meet(
const AbstractSparseLattice &rhs)
override;
114 void print(mlir::raw_ostream &os)
const override;
130raw_ostream &
operator<<(raw_ostream &os, llvm::PointerUnion<mlir::Value, mlir::Operation *> ptr);
This file implements sparse data-flow analysis using the data-flow analysis framework.
A value at a given point of the SourceRefLattice.
virtual ~SourceRefLatticeValue()=default
SourceRefLatticeValue(mlir::ArrayRef< int64_t > shape)
mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > referenceMember(SymbolLookupResult< component::MemberDefOp > memberRef) const
Add the given memberRef to the SourceRefs contained within this value.
virtual mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > elementwiseTransform(llvm::function_ref< mlir::FailureOr< SourceRef >(const SourceRef &)> transform) const
Perform a recursive transformation over all elements of this value and return a new value with the mo...
const SourceRef & getSingleValue() const
mlir::ChangeResult insert(const SourceRef &rhs)
Directly insert the ref into this value.
std::pair< SourceRefLatticeValue, mlir::ChangeResult > translate(const TranslationMap &translation) const
For the refs contained in this value, translate them given the translation map and return the transfo...
mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > extract(const std::vector< SourceRefIndex > &indices) const
Perform an array.extract or array.read operation, depending on how many indices are provided.
SourceRefLatticeValue(ScalarTy s)
mlir::ChangeResult translateScalar(const TranslationMap &translation)
Translate this value using the translation map, assuming this value is a scalar.
SourceRefLatticeValue(SourceRef r)
Sparse SSA-value lattice for SourceRef propagation.
mlir::ChangeResult join(const AbstractSparseLattice &rhs) override
mlir::ChangeResult setValue(const LatticeValue &newValue)
mlir::DenseMap< SourceRef, mlir::DenseSet< ValueTy > > Ref2Val
mlir::ChangeResult meet(const AbstractSparseLattice &rhs) override
static SourceRefLatticeValue getDefaultValue(ValueTy v)
void print(mlir::raw_ostream &os) const override
static mlir::FailureOr< SourceRef > getSourceRef(mlir::Value val)
If val is the source of other values (i.e., a block argument, an allocation-like op result,...
const LatticeValue & getValue() const
llvm::PointerUnion< mlir::Value, mlir::Operation * > ValueTy
SourceRefLatticeValue LatticeValue
A reference to a "source", which is the base value from which other SSA values are derived.
bool isSingleValue() const
const ScalarTy & getScalarValue() const
raw_ostream & operator<<(raw_ostream &os, llvm::PointerUnion< mlir::Value, mlir::Operation * > ptr)
mlir::dataflow::AbstractSparseLattice AbstractSparseLattice
void ensure(bool condition, const llvm::Twine &errMsg)
std::unordered_map< SourceRef, SourceRefLatticeValue, SourceRef::Hash > TranslationMap