docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
assumptions_analysis.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <unordered_map>
5
11
12namespace sdfg {
13namespace analysis {
14
16public:
17 std::string name() const override {
18 return "AssumptionsAnalysis";
19 }
20
21private:
23
24 std::unordered_map<Node*, symbolic::Assumptions> own_assumptions_;
25 std::unordered_map<Node*, Node*> parent_scope_;
26 std::unordered_map<Node*, Node*> scope_of_;
27
28 std::unordered_map<Node*, symbolic::Assumptions> assumptions_;
29 std::unordered_map<Node*, symbolic::Assumptions> assumptions_with_trivial_;
30 std::unordered_map<Node*, symbolic::SymbolSet> constant_symbols_;
31 std::unordered_map<Node*, symbolic::SymbolSet> constant_symbols_with_trivial_;
32
33 std::shared_ptr<const symbolic::Assumptions::Map> root_with_trivial_;
34
35 symbolic::SymbolSet parameters_;
36
37 // When false (default), IfElse branch conditions are not refined into
38 // per-branch assumption bounds / coupled constraints. The branch bodies
39 // simply inherit the outer scope's assumptions. This shortcut keeps the
40 // overall analysis pipeline cheap; analyses that need the precise
41 // branch-refined bounds (`MemoryLayoutAnalysis`,
42 // `LoopCarriedDependencyAnalysis`, detailed
43 // `DataDependencyAnalysis`) construct their own instance with this
44 // flag set to true rather than going through `AnalysisManager`.
45 bool with_branch_conditions_ = false;
46
47 void traverse(Node& current, Node& scope);
48
49 void traverse_structured_loop(structured_control_flow::StructuredLoop* loop, Node& scope);
50
51 void add_scope(Node& node, symbolic::Assumptions own, Node& parent);
52
53 const symbolic::Assumptions& materialize(Node& scope, bool include_trivial_bounds);
54
55 const symbolic::SymbolSet& materialize_constants(Node& scope, bool include_trivial_bounds);
56
57 void determine_parameters(analysis::AnalysisManager& analysis_manager);
58
59public:
61 AssumptionsAnalysis(StructuredSDFG& sdfg, bool with_branch_conditions);
62
63 void run(analysis::AnalysisManager& analysis_manager) override;
64
68
69 const symbolic::Assumptions& get(structured_control_flow::ControlFlowNode& node, bool include_trivial_bounds = false);
70
73 constant_symbols(structured_control_flow::ControlFlowNode& node, bool include_trivial_bounds = false);
74
76
77 bool is_parameter(const symbolic::Symbol& container);
78
79 bool is_parameter(const std::string& container);
80
82};
83
84} // namespace analysis
85} // namespace sdfg
Symbol assumptions for reasoning about bounds, constness, and evolution.
Definition structured_sdfg.h:30
Definition analysis.h:53
Analysis(StructuredSDFG &sdfg)
AssumptionsAnalysis(StructuredSDFG &sdfg, bool with_branch_conditions)
bool is_parameter(const std::string &container)
bool invalidate(structured_control_flow::ControlFlowNode &changed) override
Traverses the subtree of changed again in the scope around it; scopes elsewhere keep their assumption...
bool is_parameter(const symbolic::Symbol &container)
const symbolic::SymbolSet & parameters()
AssumptionsAnalysis(StructuredSDFG &sdfg)
const symbolic::SymbolSet & constant_symbols(structured_control_flow::ControlFlowNode &node, bool include_trivial_bounds=false)
Symbols whose assumption at node is constant(); equals filtering get(node, ...), without the scan.
static symbolic::SymbolSet per_symbol_refined_symbols(const symbolic::Condition &cond)
std::string name() const override
Definition assumptions_analysis.h:17
const symbolic::Assumptions & get(structured_control_flow::ControlFlowNode &node, bool include_trivial_bounds=false)
void run(analysis::AnalysisManager &analysis_manager) override
Base class for all structured control flow nodes in a StructuredSDFG.
Definition control_flow_node.h:44
Base class for structured loop constructs.
Definition structured_loop.h:244
Map from symbols to their assumptions.
Definition assumptions.h:313
SymEngine::RCP< const SymEngine::Symbol > Symbol
Reference-counted pointer to a SymEngine Symbol.
Definition symbolic.h:71
std::set< Symbol, SymEngine::RCPBasicKeyLess > SymbolSet
Ordered set of symbols.
Definition symbolic.h:95
SymEngine::RCP< const SymEngine::Boolean > Condition
Reference-counted pointer to a boolean condition expression.
Definition symbolic.h:86
Definition analysis.h:8
Definition analysis.h:7
Symbolic system for integer-based symbol analysis.