docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::control_flow::InterstateEdge Class Reference

An edge connecting two states in an SDFG control-flow graph. More...

#include <sdfg/control_flow/interstate_edge.h>

Inheritance diagram for sdfg::control_flow::InterstateEdge:
[legend]

Public Member Functions

 InterstateEdge (const InterstateEdge &state)=delete
InterstateEdge & operator= (const InterstateEdge &)=delete
ElementType type_id () const override
 Returns the type of the element.
void validate (const Function &function) const override
 Validates the interstate edge within the context of a function.
const graph::Edge edge () const
 Returns the graph edge representing this interstate edge.
const control_flow::State & src () const
 Returns the source state of this edge.
const control_flow::State & dst () const
 Returns the destination state of this edge.
const symbolic::Condition condition () const
 Returns the condition guarding this transition.
bool is_unconditional () const
 Checks if this edge represents an unconditional transition.
const control_flow::Assignments & assignments () const
 Returns the symbol assignments for this edge.
void replace (const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
 Replaces symbolic expressions in the edge's condition and assignments.
Public Member Functions inherited from sdfg::Element
 Element (size_t element_id, const DebugInfo &debug_info)
virtual ~Element ()=default
size_t element_id () const
const DebugInfo & debug_info () const
void set_debug_info (const DebugInfo &debug_info)
void add_metadata (const std::string &key, const std::string &value)
void remove_metadata (const std::string &key)
const std::string & metadata (const std::string &key) const
const std::string * metadata_if_exists (const std::string &key) const
const std::unordered_map< std::string, std::string > & metadata () const
std::string_view element_type () const
 Returns the type of the element as a human-readable string.
virtual void replace (const symbolic::ExpressionMapping &replacements)

Static Public Member Functions

static bool classof (const Element &element)

Friends

class builder::SDFGBuilder

Additional Inherited Members

Protected Attributes inherited from sdfg::Element
size_t element_id_
DebugInfo debug_info_
std::unordered_map< std::string, std::string > metadata_

Detailed Description

An edge connecting two states in an SDFG control-flow graph.

InterstateEdge represents a transition between states in a Stateful DataFlow Graph. Each edge can have:

  • A condition: A boolean expression that guards the transition
  • Assignments: Updates to symbols that occur during the transition

Execution Semantics

IMPORTANT: When an interstate edge is traversed, the execution order is:

  1. First, the condition is evaluated using the current symbol values
  2. Then, if the condition is true, the assignments are executed to update symbols
  3. Finally, control transfers to the destination state

This means:

  • The condition sees symbol values BEFORE any assignments on this edge
  • Assignments cannot affect the condition evaluation on the same edge
  • Assignments affect symbol values for subsequent edges and states

Examples

// Example 1: Loop counter increment
// Condition uses current value of i, then i is incremented
auto condition = symbolic::Lt(i, symbolic::integer(10)); // Check i < 10
assignments[i] = symbolic::add(i, symbolic::integer(1)); // Then i = i + 1
// Example 2: Unconditional transition with assignment
Assignments assignments2;
assignments2[i] = symbolic::integer(0); // Initialize i = 0
const control_flow::Assignments & assignments() const
Returns the symbol assignments for this edge.
const symbolic::Condition condition() const
Returns the condition guarding this transition.
Expression add(const Expression lhs, const Expression rhs)
Addition of two expressions.
Condition Lt(const Expression lhs, const Expression rhs)
Less-than comparison.
Integer integer(int64_t value)
Creates an integer constant.
Symbol symbol(const std::string &name)
Creates a symbolic variable with the given name.
Condition __true__()
Creates a boolean true condition.
SymEngine::RCP< const SymEngine::Symbol > Symbol
Reference-counted pointer to a SymEngine Symbol.
Definition symbolic.h:71
symbolic::SymbolMap Assignments
Type alias for symbol assignments on interstate edges.
Definition interstate_edge.h:30
See also
State for the source and destination of transitions
symbolic::Condition for the condition expressions

Constructor & Destructor Documentation

◆ InterstateEdge()

sdfg::control_flow::InterstateEdge::InterstateEdge ( const InterstateEdge & state)
delete

Member Function Documentation

◆ assignments()

const control_flow::Assignments & sdfg::control_flow::InterstateEdge::assignments ( ) const

Returns the symbol assignments for this edge.

Assignments are executed AFTER the condition is evaluated and found to be true. The assignments update symbol values that will be visible in the destination state and subsequent edges.

Returns
Map of symbols to their assigned expressions

◆ classof()

bool sdfg::control_flow::InterstateEdge::classof ( const Element & element)
inlinestatic

◆ condition()

const symbolic::Condition sdfg::control_flow::InterstateEdge::condition ( ) const

Returns the condition guarding this transition.

The condition is evaluated BEFORE any assignments are executed. The condition uses the symbol values as they exist when entering the edge.

Returns
The boolean condition expression
See also
is_unconditional() to check if this is an unconditional transition

◆ dst()

const control_flow::State & sdfg::control_flow::InterstateEdge::dst ( ) const

Returns the destination state of this edge.

Returns
Reference to the destination state

◆ edge()

const graph::Edge sdfg::control_flow::InterstateEdge::edge ( ) const

Returns the graph edge representing this interstate edge.

Returns
The graph edge

◆ is_unconditional()

bool sdfg::control_flow::InterstateEdge::is_unconditional ( ) const

Checks if this edge represents an unconditional transition.

Returns
true if the condition is always true, false otherwise

◆ operator=()

InterstateEdge & sdfg::control_flow::InterstateEdge::operator= ( const InterstateEdge & )
delete

◆ replace()

void sdfg::control_flow::InterstateEdge::replace ( const symbolic::Expression old_expression,
const symbolic::Expression new_expression )
overridevirtual

Replaces symbolic expressions in the edge's condition and assignments.

Parameters
old_expressionThe expression to replace
new_expressionThe replacement expression

Implements sdfg::Element.

◆ src()

const control_flow::State & sdfg::control_flow::InterstateEdge::src ( ) const

Returns the source state of this edge.

Returns
Reference to the source state

◆ type_id()

ElementType sdfg::control_flow::InterstateEdge::type_id ( ) const
inlineoverridevirtual

Returns the type of the element.

Implements sdfg::Element.

◆ validate()

void sdfg::control_flow::InterstateEdge::validate ( const Function & function) const
overridevirtual

Validates the interstate edge within the context of a function.

Validates that:

  • The condition is a valid boolean expression
  • All symbols in the condition and assignments are properly typed
  • Assignment targets are integer scalar types
  • Assignment sources evaluate to integer or pointer types
Parameters
functionThe function containing this edge
Exceptions
InvalidSDFGExceptionif validation fails

Implements sdfg::Element.

◆ builder::SDFGBuilder

friend class builder::SDFGBuilder
friend

The documentation for this class was generated from the following file: