Skip to content

Commit

Permalink
Start work on new calyx builder API (#17)
Browse files Browse the repository at this point in the history
* Start work on new calyx builder API

* In the middle of fixing but good progress

* It compiles

* Messy but works

* Some clean up
  • Loading branch information
ethanuppal authored Jun 8, 2024
1 parent 197b34a commit 5151bcc
Show file tree
Hide file tree
Showing 8 changed files with 1,351 additions and 679 deletions.
520 changes: 520 additions & 0 deletions crates/pulsar-backend/src/calyx.rs

Large diffs are not rendered by default.

758 changes: 758 additions & 0 deletions crates/pulsar-backend/src/calyx/builder.rs

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions crates/pulsar-backend/src/calyx/builder/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// calyx `build_assignments!` but for `CalyxCell`s.
#[macro_export(local_inner_macros)]
macro_rules! build_assignments_2_aux {
// Unguarded assignment.
(@base $builder:expr;
$dst_node:ident[$dst_port:expr] = ? $src_node:ident[$src_port:expr]) => {
$builder.build_assignment(
$dst_node.value.borrow().get($dst_port),
$src_node.value.borrow().get($src_port),
calyx_ir::Guard::True)
};

// Guarded assignment.
(@base $builder:expr;
$dst_node:ident[$dst_port:expr] =
$guard:ident ?
$src_node:ident[$src_port:expr]) => {
$builder.build_assignment(
$dst_node.value.borrow().get($dst_port),
$src_node.value.borrow().get($src_port),
$guard.clone())
};

($builder:expr;
$($dst_node:ident[$dst_port:expr] =
$($guard:ident)? ?
$src_node:ident[$src_port:expr];)*) => {
[$(
build_assignments_2_aux!(@base $builder;
$dst_node[$dst_port] = $($guard)? ? $src_node[$src_port])
),*]

};
}

/// Behaves like [`calyx_ir::build_assignments!`] but takes in a
/// [`CalyxComponent`] instead of a [`calyx_ir::Builder`] and uses
/// [`CalyxCell`]s instead of `RRC<calyx_ir::Cell>`s.
#[macro_export(local_inner_macros)]
macro_rules! build_assignments_2 {
($component:expr; $($args:tt)*) => {
$component.with_calyx_builder(|builder| {
build_assignments_2_aux!(builder; $($args)*)
})
}
}
Loading

0 comments on commit 5151bcc

Please sign in to comment.