Skip to main content

Crate rvsdg

Crate rvsdg 

Source
Expand description

§rust-rvsdg

This crate provides a mostly type-safe way of constructing and analyzing a RVSDG

For developer familiarity, most node kinds have been renamed.

  • Gamma -> Switch
  • Theta -> DoWhile
  • Delta -> GlobalV
  • Phi -> RecEnv
  • Omega -> TranslationUnit

RecEnv nodes are created automatically when cyclic Lambda connections are made.

§Constructing an RVSDG

use rvsdg::{Context, nodes::Add};

let mut ctx = Context::new("my testing graph");

let (f_output, f_region) = ctx.add_lambda_node();
ctx.in_region(f_region, |ctx| {
    let one = ctx.add_number_node(1);
    let two = ctx.add_number_node(2);

    let ([x, y], addition) = ctx.add_binop_node::<Add>();

    ctx.connect(one, x);
    ctx.connect(two, y);

    let returned = ctx.add_result();

    ctx.connect(addition, returned);
});

let apply_input = ctx.add_apply_node();
ctx.connect(f_output, apply_input);

§Status

Currently this crate is in an highly experimental phase.

§Exporting an RVSDG

If rvsdg-viewer is installed, you can use Context::open_rvsdg_viewer.

Re-exports§

pub use nodes::BinOpKind;
pub use nodes::NodeKind;

Modules§

id
Raw ID types mapping to vectors in crate::Context
nodes
Default Node kinds and traits for declaring your own

Macros§

binop_node_kind_impl
node_kind_impl

Structs§

Argument
Argument id belonging to region
Context
The context for a whole translation unit and the core struct of this crate.
EntityIter
Input
Input id belonging to node
NodeHooks
Event handlers for changes being made to the node or its contained regions.
Output
Output id belonging to node
Result
Result id belonging to region

Enums§

Connection
The result of attempting to connect an origin to a user
Origin
An origin port
User
An user port