docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
if_else.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <optional>
5
8
9namespace sdfg {
10
11namespace builder {
13}
14
16
47class IfElse : public ControlFlowNode {
49
50private:
51 std::vector<std::unique_ptr<Sequence>> cases_;
52 std::vector<symbolic::Condition> conditions_;
53 // Lazily computed; reset whenever `conditions_` changes.
54 mutable std::optional<bool> is_complete_;
55
56 IfElse(size_t element_id, const DebugInfo& debug_info, ControlFlowNode* parent);
57
58 bool compute_is_complete() const;
59
60 static constexpr size_t REQUIRED_ELEMENT_IDS = 1;
61
62public:
63 IfElse(const IfElse& node) = delete;
64 IfElse& operator=(const IfElse&) = delete;
65
66 ElementType type_id() const override {
68 }
69
70 static bool classof(const Element& element) {
71 return element.type_id() == ElementType::IfElse;
72 }
73
75
76 void validate(const Function& function) const override;
77
82 size_t size() const;
83
90 std::pair<const Sequence&, const symbolic::Condition> at(size_t i) const;
91
98 std::pair<Sequence&, const symbolic::Condition> at(size_t i);
99
105 int index(const Sequence& child) const;
106
129 bool is_complete() const;
130
136 void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override;
137 void replace(const symbolic::ExpressionMapping& replacements) override;
138};
139
140} // namespace structured_control_flow
141} // 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
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
ControlFlowNode(size_t element_id, const DebugInfo &debug_info, ControlFlowNode *parent)
Protected constructor for control flow nodes with parent.
IfElse(const IfElse &node)=delete
bool accept(visitor::ActualStructuredSDFGVisitor &visitor) override
void validate(const Function &function) const override
Validates the element.
std::pair< const Sequence &, const symbolic::Condition > at(size_t i) const
Access a case by index (const version).
ElementType type_id() const override
Returns the type of the element.
Definition if_else.h:66
size_t size() const
Returns the number of cases (if/else-if branches) in this IfElse.
std::pair< Sequence &, const symbolic::Condition > at(size_t i)
Access a case by index (non-const version).
int index(const Sequence &child) const
Find the index of a child sequence (the root seq of one of our branches).
void replace(const symbolic::ExpressionMapping &replacements) override
IfElse & operator=(const IfElse &)=delete
static bool classof(const Element &element)
Definition if_else.h:70
void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
Replace occurrences of an expression in all conditions and sequences.
bool is_complete() const
Checks if this IfElse is complete (all cases are covered).
A sequential container of control flow nodes.
Definition sequence.h:52
Visitor for Structured SDFG (not a builder).
Definition structured_sdfg_visitor.h:71
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
SymEngine::map_basic_basic ExpressionMapping
Definition symbolic.h:109
Definition function_builder.h:10
Definition language_extension.h:18
Definition control_flow_node.h:16
Definition analysis.h:7
ElementType
Definition element.h:72
@ IfElse
Definition element.h:84
Symbolic system for integer-based symbol analysis.