FreeTensor
Loading...
Searching...
No Matches
comp_unique_bounds_pb.h
Go to the documentation of this file.
1#ifndef FREE_TENSOR_COMP_UNIQUE_BOUNDS_PB_H
2#define FREE_TENSOR_COMP_UNIQUE_BOUNDS_PB_H
3
4#include <optional>
5#include <unordered_map>
6#include <unordered_set>
7
9#include <math/gen_pb_expr.h>
10#include <math/presburger.h>
11
12namespace freetensor {
13
21 public:
23 public: // Visible to CompUniqueBoundsPB's subclasses
24 // isl var -> ft expr, the demangling map yielded from GenPBExpr
25 // shared from CompUniqueBoundsPB::cachedFreeVars_
27 // isl bounding set, multiple params being all outer variables and
28 // single output being the bounded expression
30
31 public:
32 Bound(Ref<std::unordered_map<std::string, Expr>> demangleMap,
33 PBSet bound)
34 : demangleMap_(std::move(demangleMap)), bound_(std::move(bound)) {}
35
36 BoundType type() const override { return BoundType::Presburger; }
37
38 int64_t lowerInt() const override;
39 int64_t upperInt() const override;
40 std::optional<int64_t> getInt() const override;
41
42 Expr lowerExpr() const override;
43 Expr upperExpr() const override;
44
49 std::tuple<Expr, Expr, Expr> lowerUpperDiffExpr() const;
50
52 const std::unordered_set<std::string> &scope) const override;
53
54 Expr simplestExpr(const Expr &reference,
55 const std::unordered_map<std::string, int>
56 &orderedScope) const override;
57 };
58
59 private:
60 const CompTransientBoundsInterface &transients_;
61 GenPBExpr genPBExpr_;
62 Ref<PBCtx> ctx_;
63
64 PBSet cachedConds_;
66 std::unordered_map<Expr, Ref<Bound>> cachedValues_;
67
68 protected:
70 unionBoundsAsBound(const std::vector<Ref<CompUniqueBounds::Bound>> &bounds);
71
72 public:
74
75 Ref<CompUniqueBounds::Bound> getBound(const Expr &op) override;
76 bool alwaysLE(const Expr &lhs, const Expr &rhs) override;
77 bool alwaysLT(const Expr &lhs, const Expr &rhs) override;
78 std::pair<Expr, Expr> unionBounds(
79 const std::vector<Ref<CompUniqueBounds::Bound>> &bounds) override;
80};
81
82} // namespace freetensor
83
84#endif // FREE_TENSOR_COMP_UNIQUE_BOUNDS_PB_H
Definition: comp_transient_bounds.h:24
Definition: comp_unique_bounds_pb.h:22
Ref< CompUniqueBounds::Bound > restrictScope(const std::unordered_set< std::string > &scope) const override
Definition: comp_unique_bounds_pb.cc:98
Ref< std::unordered_map< std::string, Expr > > demangleMap_
Definition: comp_unique_bounds_pb.h:26
Bound(Ref< std::unordered_map< std::string, Expr > > demangleMap, PBSet bound)
Definition: comp_unique_bounds_pb.h:32
int64_t lowerInt() const override
Definition: comp_unique_bounds_pb.cc:20
Expr upperExpr() const override
Definition: comp_unique_bounds_pb.cc:79
PBSet bound_
Definition: comp_unique_bounds_pb.h:29
std::optional< int64_t > getInt() const override
Definition: comp_unique_bounds_pb.cc:32
int64_t upperInt() const override
Definition: comp_unique_bounds_pb.cc:26
Expr simplestExpr(const Expr &reference, const std::unordered_map< std::string, int > &orderedScope) const override
Definition: comp_unique_bounds_pb.cc:115
BoundType type() const override
Definition: comp_unique_bounds_pb.h:36
Expr lowerExpr() const override
Definition: comp_unique_bounds_pb.cc:74
std::tuple< Expr, Expr, Expr > lowerUpperDiffExpr() const
Definition: comp_unique_bounds_pb.cc:85
Definition: comp_unique_bounds_pb.h:20
Ref< CompUniqueBoundsPB::Bound > unionBoundsAsBound(const std::vector< Ref< CompUniqueBounds::Bound > > &bounds)
Definition: comp_unique_bounds_pb.cc:267
Ref< CompUniqueBounds::Bound > getBound(const Expr &op) override
Definition: comp_unique_bounds_pb.cc:201
std::pair< Expr, Expr > unionBounds(const std::vector< Ref< CompUniqueBounds::Bound > > &bounds) override
Definition: comp_unique_bounds_pb.cc:310
bool alwaysLE(const Expr &lhs, const Expr &rhs) override
Definition: comp_unique_bounds_pb.cc:250
bool alwaysLT(const Expr &lhs, const Expr &rhs) override
Definition: comp_unique_bounds_pb.cc:259
Definition: comp_unique_bounds.h:17
Definition: comp_unique_bounds.h:13
BoundType
Definition: comp_unique_bounds.h:15
Definition: gen_pb_expr.h:34
Definition: presburger.h:223
Definition: ref.h:24
Definition: allocator.h:9
auto && lhs
Definition: const_fold.cc:70
auto auto && rhs
Definition: const_fold.cc:70
STL namespace.