docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
arguments_analysis.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <unordered_map>
9
10
11namespace sdfg {
12namespace analysis {
13
18
22 DataRwFlags() : is_explicit_input(false), is_input(false), is_output(false) {
23 }
24 DataRwFlags(const DataRwFlags& copy) = default;
25 ~DataRwFlags() = default;
26 DataRwFlags& operator=(const DataRwFlags& other) = default;
27
29 is_explicit_input = true;
30 is_input = true;
31 }
32
34 is_input = true;
35 is_output = true;
36 }
37
39 is_input = true;
40 is_output = true;
41 is_explicit_input = true;
42 }
43
44 void merge(DataRwFlags& other) {
46 is_input |= other.is_input;
47 is_output |= other.is_output;
48 }
49};
50
51struct RegionArgument : public DataRwFlags {
53 bool is_ptr;
54
55 RegionArgument(bool is_explicit_input, bool is_input, bool is_output, bool scalar, bool ptr)
57 }
58 RegionArgument(DataRwFlags rwFlags, bool scalar, bool ptr) : DataRwFlags(rwFlags), is_scalar(scalar), is_ptr(ptr) {
59 }
60
61 RegionArgument() : is_scalar(false), is_ptr(false) {
62 }
63
64 RegionArgument(const RegionArgument& copy) = default;
65
66 ~RegionArgument() = default;
67
68 RegionArgument& operator=(const RegionArgument& other) = default;
69
70 void merge(RegionArgument& other) {
71 DataRwFlags::merge(other);
72 is_scalar |= other.is_scalar;
73 is_ptr |= other.is_ptr;
74 }
75};
76
78private:
79 std::unordered_map<structured_control_flow::ControlFlowNode*, std::map<std::string, RegionArgument>> node_arguments_;
80 std::unordered_map<structured_control_flow::ControlFlowNode*, std::unordered_set<std::string>> node_locals_;
81 std::unordered_map<structured_control_flow::ControlFlowNode*, bool> node_inferred_types_;
82 std::unordered_map<structured_control_flow::ControlFlowNode*, std::unordered_map<std::string, symbolic::Expression>>
83 argument_sizes_;
84 std::unordered_map<structured_control_flow::ControlFlowNode*, std::unordered_map<std::string, symbolic::Expression>>
85 argument_element_sizes_;
86 std::unordered_map<structured_control_flow::ControlFlowNode*, bool> known_sizes_;
87 std::unordered_map<structured_control_flow::ControlFlowNode*, std::unique_ptr<TypeAnalysis>> node_type_analyses_;
88
89 void find_arguments_and_locals(
91 );
92
93 void collect_arg_sizes(
94 analysis::AnalysisManager& analysis_manager,
96 bool allow_dynamic_sizes_,
97 bool do_not_throw
98 );
99
100public:
102
103 std::string name() const override {
104 return "ArgumentsAnalysis";
105 }
106
107 void run(analysis::AnalysisManager& analysis_manager) override;
108
109 const std::map<std::string, RegionArgument>&
111
112 const std::unordered_set<std::string>&
114
116
118 const TypeAnalysis&
120
121 const std::unordered_map<std::string, symbolic::Expression>& argument_sizes(
122 analysis::AnalysisManager& analysis_manager,
124 bool allow_dynamic_sizes_
125 );
126
127 const std::unordered_map<std::string, symbolic::Expression>& argument_element_sizes(
128 analysis::AnalysisManager& analysis_manager,
130 bool allow_dynamic_sizes_
131 );
132
134 analysis::AnalysisManager& analysis_manager,
136 bool allow_dynamic_sizes_
137 );
138};
139
140} // namespace analysis
141} // namespace sdfg
Definition structured_sdfg.h:30
Definition analysis.h:53
Analysis(StructuredSDFG &sdfg)
const std::unordered_map< std::string, symbolic::Expression > & argument_element_sizes(analysis::AnalysisManager &analysis_manager, structured_control_flow::ControlFlowNode &node, bool allow_dynamic_sizes_)
const std::unordered_map< std::string, symbolic::Expression > & argument_sizes(analysis::AnalysisManager &analysis_manager, structured_control_flow::ControlFlowNode &node, bool allow_dynamic_sizes_)
void run(analysis::AnalysisManager &analysis_manager) override
bool argument_size_known(analysis::AnalysisManager &analysis_manager, structured_control_flow::ControlFlowNode &node, bool allow_dynamic_sizes_)
const TypeAnalysis & type_analysis(analysis::AnalysisManager &analysis_manager, structured_control_flow::ControlFlowNode &node)
Type analysis restricted to the uses inside node.
const std::unordered_set< std::string > & locals(analysis::AnalysisManager &analysis_manager, structured_control_flow::ControlFlowNode &node)
bool inferred_types(analysis::AnalysisManager &analysis_manager, structured_control_flow::ControlFlowNode &node)
std::string name() const override
Definition arguments_analysis.h:103
ArgumentsAnalysis(StructuredSDFG &sdfg)
const std::map< std::string, RegionArgument > & arguments(analysis::AnalysisManager &analysis_manager, structured_control_flow::ControlFlowNode &node)
Definition type_analysis.h:10
Base class for all structured control flow nodes in a StructuredSDFG.
Definition control_flow_node.h:44
Definition analysis.h:8
Definition analysis.h:7
void merge(DataRwFlags &other)
Definition arguments_analysis.h:44
bool is_output
Definition arguments_analysis.h:17
DataRwFlags(bool is_explicit_input, bool is_input, bool is_output)
Definition arguments_analysis.h:19
DataRwFlags()
Definition arguments_analysis.h:22
void found_explicit_read()
Definition arguments_analysis.h:28
bool is_input
Definition arguments_analysis.h:16
DataRwFlags & operator=(const DataRwFlags &other)=default
void found_explicit_write()
Definition arguments_analysis.h:33
void found_analysis_escape()
Definition arguments_analysis.h:38
bool is_explicit_input
Definition arguments_analysis.h:15
DataRwFlags(const DataRwFlags &copy)=default
RegionArgument()
Definition arguments_analysis.h:61
bool is_ptr
Definition arguments_analysis.h:53
RegionArgument & operator=(const RegionArgument &other)=default
void merge(RegionArgument &other)
Definition arguments_analysis.h:70
RegionArgument(bool is_explicit_input, bool is_input, bool is_output, bool scalar, bool ptr)
Definition arguments_analysis.h:55
RegionArgument(DataRwFlags rwFlags, bool scalar, bool ptr)
Definition arguments_analysis.h:58
bool is_scalar
Definition arguments_analysis.h:52
RegionArgument(const RegionArgument &copy)=default
Symbolic system for integer-based symbol analysis.