-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start work on new calyx builder API (#17)
* 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
1 parent
197b34a
commit 5151bcc
Showing
8 changed files
with
1,351 additions
and
679 deletions.
There are no files selected for viewing
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)*) | ||
}) | ||
} | ||
} |
Oops, something went wrong.