docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
state.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/lexical_cast.hpp>
4#include <nlohmann/json.hpp>
5#include <string>
6
8#include "sdfg/element.h"
9#include "sdfg/graph/graph.h"
10
11using json = nlohmann::json;
12
13namespace sdfg {
14
15namespace builder {
16class SDFGBuilder;
17}
18
19namespace control_flow {
20
38class State : public Element {
40
41private:
42 // Remark: Exclusive resource
43 const graph::Vertex vertex_;
44 std::unique_ptr<data_flow::DataFlowGraph> dataflow_;
45
46protected:
48
49public:
50 // Remark: Exclusive resource
51 State(const State& state) = delete;
52 State& operator=(const State&) = delete;
53
54 ElementType type_id() const override {
55 return ElementType::State;
56 }
57
58 static bool classof(const Element& element) {
59 return element.type_id() == ElementType::State;
60 }
61
67 void validate(const Function& function) const override;
68
74
80
86
92 void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override;
93};
94
107class ReturnState : public State {
109
110private:
111 std::string data_;
112 std::unique_ptr<types::IType> type_;
113
114 ReturnState(size_t element_id, const DebugInfo& debug_info, const graph::Vertex vertex, const std::string& data);
115
116 ReturnState(
117 size_t element_id,
118 const DebugInfo& debug_info,
119 const graph::Vertex vertex,
120 const std::string& data,
121 const types::IType& type
122 );
123
124public:
125 // Remark: Exclusive resource
126 ReturnState(const ReturnState& state) = delete;
127 ReturnState& operator=(const ReturnState&) = delete;
128
133 const std::string& data() const;
134
139 const types::IType& type() const;
140
145 bool is_data() const;
146
151 bool is_constant() const;
152
158 void validate(const Function& function) const override;
159
165 void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override;
166};
167
168} // namespace control_flow
169} // 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
const types::IType & type() const
Returns the type of the constant being returned.
void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
Replaces symbolic expressions in the return state.
bool is_data() const
Checks if this return state returns a data container.
bool is_constant() const
Checks if this return state returns a constant value.
ReturnState(const ReturnState &state)=delete
ReturnState & operator=(const ReturnState &)=delete
void validate(const Function &function) const override
Validates the return state within the context of a function.
const std::string & data() const
Returns the data or constant value being returned.
ElementType type_id() const override
Returns the type of the element.
Definition state.h:54
void validate(const Function &function) const override
Validates the state within the context of a function.
State & operator=(const State &)=delete
State(size_t element_id, const DebugInfo &debug_info, const graph::Vertex vertex)
const data_flow::DataFlowGraph & dataflow() const
Returns the data-flow graph of this state (const version).
graph::Vertex vertex() const
Returns the graph vertex representing this state.
void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
Replaces symbolic expressions in the state's data-flow graph.
data_flow::DataFlowGraph & dataflow()
Returns the data-flow graph of this state (mutable version).
static bool classof(const Element &element)
Definition state.h:58
State(const State &state)=delete
Definition data_flow_graph.h:29
Abstract base interface for all types in the sdfglib type system.
Definition type.h:625
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
nlohmann::json json
Definition interstate_edge.h:14
Definition function_builder.h:10
Definition interstate_edge.h:22
boost::graph_traits< Graph >::vertex_descriptor Vertex
Definition graph.h:25
Definition analysis.h:7
ElementType
Definition element.h:72
@ State
Definition element.h:73