17#include <llvm/ADT/PointerUnion.h>
23 std::unordered_map<ConstrainRef, ConstrainRefLatticeValue, ConstrainRef::Hash>;
38 using ArrayTy = std::vector<std::unique_ptr<ConstrainRefLatticeValue>>;
61 std::pair<ConstrainRefLatticeValue, mlir::ChangeResult>
70 std::pair<ConstrainRefLatticeValue, mlir::ChangeResult>
75 std::pair<ConstrainRefLatticeValue, mlir::ChangeResult>
76 extract(
const std::vector<ConstrainRefIndex> &indices)
const;
85 virtual std::pair<ConstrainRefLatticeValue, mlir::ChangeResult>
94 using ValueTy = llvm::PointerUnion<mlir::Value, mlir::Operation *>;
95 using ValueMap = mlir::DenseMap<ValueTy, ConstrainRefLatticeValue>;
99 using Ref2Val = mlir::DenseMap<ConstrainRef, mlir::DenseSet<ValueTy>>;
100 using AbstractDenseLattice::AbstractDenseLattice;
108 static mlir::FailureOr<ConstrainRef>
getSourceRef(mlir::Value val);
113 mlir::ChangeResult
join(
const AbstractDenseLattice &rhs)
override {
117 llvm::report_fatal_error(
"invalid join lattice type");
118 return mlir::ChangeResult::NoChange;
122 virtual mlir::ChangeResult
meet(
const AbstractDenseLattice &rhs)
override {
123 llvm::report_fatal_error(
"meet operation is not supported for ConstrainRefLattice");
124 return mlir::ChangeResult::NoChange;
127 void print(mlir::raw_ostream &os)
const override;
143 size_t size()
const {
return valMap.size(); }
149 ValueMap::iterator
begin() {
return valMap.begin(); }
150 ValueMap::iterator
end() {
return valMap.end(); }
151 ValueMap::const_iterator
begin()
const {
return valMap.begin(); }
152 ValueMap::const_iterator
end()
const {
return valMap.end(); }
166raw_ostream &
operator<<(raw_ostream &os, llvm::PointerUnion<mlir::Value, mlir::Operation *> ptr);
This file implements (LLZK-tailored) dense data-flow analysis using the data-flow analysis framework.
A value at a given point of the ConstrainRefLattice.
mlir::ChangeResult insert(const ConstrainRef &rhs)
Directly insert the ref into this value.
ConstrainRefLatticeValue(ScalarTy s)
std::pair< ConstrainRefLatticeValue, mlir::ChangeResult > extract(const std::vector< ConstrainRefIndex > &indices) const
Perform an array.extract or array.read operation, depending on how many indices are provided.
mlir::ChangeResult translateScalar(const TranslationMap &translation)
Translate this value using the translation map, assuming this value is a scalar.
virtual ~ConstrainRefLatticeValue()=default
const ConstrainRef & getSingleValue() const
ConstrainRefLatticeValue(ConstrainRef r)
std::pair< ConstrainRefLatticeValue, mlir::ChangeResult > referenceField(SymbolLookupResult< component::FieldDefOp > fieldRef) const
Add the given fieldRef to the constrain refs contained within this value.
ConstrainRefLatticeValue()
std::pair< ConstrainRefLatticeValue, mlir::ChangeResult > translate(const TranslationMap &translation) const
For the refs contained in this value, translate them given the translation map and return the transfo...
ConstrainRefLatticeValue(mlir::ArrayRef< int64_t > shape)
virtual std::pair< ConstrainRefLatticeValue, mlir::ChangeResult > elementwiseTransform(llvm::function_ref< ConstrainRef(const ConstrainRef &)> transform) const
Perform a recursive transformation over all elements of this value and return a new value with the mo...
A lattice for use in dense analysis.
mlir::DenseMap< ValueTy, ConstrainRefLatticeValue > ValueMap
mlir::ChangeResult join(const AbstractDenseLattice &rhs) override
Maximum upper bound.
const Ref2Val & getRef2Val() const
virtual mlir::ChangeResult meet(const AbstractDenseLattice &rhs) override
Minimum lower bound.
ValueMap::const_iterator begin() const
ValueSet lookupValues(const ConstrainRef &r) const
ConstrainRefLatticeValue getReturnValue(unsigned i) const
mlir::DenseSet< ValueTy > ValueSet
static mlir::FailureOr< ConstrainRef > getSourceRef(mlir::Value val)
If val is the source of other values (i.e., a block argument from the function args or a constant),...
mlir::ChangeResult setValues(const ValueMap &rhs)
ValueMap::const_iterator end() const
void print(mlir::raw_ostream &os) const override
ValueMap::iterator begin()
friend mlir::raw_ostream & operator<<(mlir::raw_ostream &os, const ConstrainRefLattice &v)
mlir::ChangeResult setValue(ValueTy v, const ConstrainRefLatticeValue &rhs)
ConstrainRefLatticeValue getOrDefault(ValueTy v) const
const ValueMap & getMap() const
llvm::PointerUnion< mlir::Value, mlir::Operation * > ValueTy
mlir::DenseMap< ConstrainRef, mlir::DenseSet< ValueTy > > Ref2Val
Defines a reference to a llzk object within a constrain function call.
bool isSingleValue() const
const ScalarTy & getScalarValue() const
raw_ostream & operator<<(raw_ostream &os, llvm::PointerUnion< mlir::Value, mlir::Operation * > ptr)
mlir::dataflow::AbstractDenseLattice AbstractDenseLattice
void ensure(bool condition, llvm::Twine errMsg)
std::unordered_map< ConstrainRef, ConstrainRefLatticeValue, ConstrainRef::Hash > TranslationMap