docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
access_node.h
Go to the documentation of this file.
1
54
55#pragma once
56
58#include "sdfg/graph/graph.h"
59
60namespace sdfg {
61
62namespace builder {
63class SDFGBuilder;
65} // namespace builder
66
67namespace data_flow {
68
84class AccessNode : public DataFlowNode {
87
88protected:
89 std::string data_;
90
100 size_t element_id,
101 const DebugInfo& debug_info,
102 const graph::Vertex vertex,
103 DataFlowGraph& parent,
104 const std::string& data
105 );
106
107public:
108 AccessNode(const AccessNode& data_node) = delete;
109 AccessNode& operator=(const AccessNode&) = delete;
110
111 ElementType type_id() const override {
113 }
114
115 static bool classof(const Element& element) {
117 }
118
129 void validate(const Function& function) const override;
130
135 const std::string& data() const;
136
137 virtual bool is_constant() const {
138 return false;
139 }
140
145 void data(const std::string data);
146
150 [[nodiscard]] bool side_effect() const override;
151
159 virtual std::unique_ptr<DataFlowNode>
160 clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph& parent) const override;
161
170 void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override;
171
172 EdgeRemoveOption can_remove_out_edge(const DataFlowGraph& graph, const Memlet* memlet) const override;
173 EdgeRemoveOption can_remove_in_edge(const DataFlowGraph& graph, const Memlet* memlet) const override;
174
180 static bool identicalBackingData(const AccessNode& src1, const AccessNode& src2);
181
186 static bool has_constant_value(const AccessNode& node, long long constant_number);
187};
188
205class ConstantNode : public AccessNode {
208
209private:
210 std::unique_ptr<types::IType> type_;
211
221 ConstantNode(
222 size_t element_id,
223 const DebugInfo& debug_info,
224 const graph::Vertex vertex,
225 DataFlowGraph& parent,
226 const std::string& data,
227 const types::IType& type
228 );
229
230public:
231 ConstantNode(const ConstantNode& data_node) = delete;
232 ConstantNode& operator=(const ConstantNode&) = delete;
233
234 ElementType type_id() const override {
236 }
237
238 static bool classof(const Element& element) {
239 return element.type_id() == ElementType::ConstantNode;
240 }
241
246 const types::IType& type() const;
247
248 [[nodiscard]] bool side_effect() const override {
249 return false;
250 }
251
252 bool is_constant() const override {
253 return true;
254 }
255
266 void validate(const Function& function) const override;
267
275 virtual std::unique_ptr<DataFlowNode>
276 clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph& parent) const override;
277};
278
279
280} // namespace data_flow
281} // namespace sdfg
Definition element.h:30
Element(size_t element_id, const DebugInfo &debug_info)
size_t element_id() const
const DebugInfo & debug_info() const
virtual ElementType type_id() const =0
Returns the type of the element.
Definition function.h:43
Definition sdfg_builder.h:13
Note: Even though the class references unique_ptr, it will never delete an SDFG it has a reference to...
Definition structured_sdfg_builder.h:44
static bool identicalBackingData(const AccessNode &src1, const AccessNode &src2)
Checks if 2 access nodes refer to the same container / ptr Ready for when we identify them by sth mor...
void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
Replace symbolic expressions in this node.
virtual std::unique_ptr< DataFlowNode > clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph &parent) const override
Clone this access node for graph transformations.
AccessNode(const AccessNode &data_node)=delete
const std::string & data() const
Get the name of the data container.
std::string data_
Name of the data container this node accesses.
Definition access_node.h:89
ElementType type_id() const override
Returns the type of the element.
Definition access_node.h:111
AccessNode & operator=(const AccessNode &)=delete
static bool classof(const Element &element)
Definition access_node.h:115
void data(const std::string data)
Set the name of the data container.
bool side_effect() const override
An access node with incoming edges writes the container and therefore has side effects.
AccessNode(size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, DataFlowGraph &parent, const std::string &data)
Protected constructor for access nodes.
EdgeRemoveOption can_remove_out_edge(const DataFlowGraph &graph, const Memlet *memlet) const override
Is the edge in question removable, or will this make the node its an output on invalid?
void validate(const Function &function) const override
Validate the access node.
virtual bool is_constant() const
Definition access_node.h:137
EdgeRemoveOption can_remove_in_edge(const DataFlowGraph &graph, const Memlet *memlet) const override
static bool has_constant_value(const AccessNode &node, long long constant_number)
Checks if the access node is constant and matches the provided constant number.
virtual std::unique_ptr< DataFlowNode > clone(size_t element_id, const graph::Vertex vertex, DataFlowGraph &parent) const override
Clone this constant node for graph transformations.
bool side_effect() const override
An access node with incoming edges writes the container and therefore has side effects.
Definition access_node.h:248
const types::IType & type() const
Get the type of this constant.
bool is_constant() const override
Definition access_node.h:252
void validate(const Function &function) const override
Validate the constant node.
ElementType type_id() const override
Returns the type of the element.
Definition access_node.h:234
ConstantNode & operator=(const ConstantNode &)=delete
ConstantNode(const ConstantNode &data_node)=delete
static bool classof(const Element &element)
Definition access_node.h:238
Definition data_flow_graph.h:29
graph::Vertex vertex() const
Get the graph vertex for this node.
DataFlowNode(size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex, DataFlowGraph &parent)
Protected constructor for dataflow nodes.
Edge in the dataflow graph representing data movement.
Definition memlet.h:131
Abstract base interface for all types in the sdfglib type system.
Definition type.h:625
Base class for all nodes in the dataflow graph.
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
Definition function_builder.h:10
Definition access_node.h:67
EdgeRemoveOption
Definition data_flow_node.h:71
Definition graph.h:22
boost::graph_traits< Graph >::vertex_descriptor Vertex
Definition graph.h:25
Definition analysis.h:7
constexpr bool is_a(ElementType type, ElementType mask)
Tests whether type is contained in the category mask (efficient, branch-free type check).
Definition element.h:107
ElementType
Definition element.h:72
@ AccessNode
Definition element.h:75
@ ConstantNode
Definition element.h:76