Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart seq split #2217

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions calyx-ir/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ impl Control {
matches!(self, Control::Static(_))
}

pub fn is_seq(&self) -> bool {
matches!(self, Self::Seq(..))
}

pub fn is_empty(&self) -> bool {
matches!(self, Control::Static(StaticControl::Empty(_)))
|| matches!(self, Control::Empty(_))
Expand Down
10 changes: 10 additions & 0 deletions calyx-ir/src/guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,16 @@ impl<T> Guard<T> {
}
}

/// Collapses a list of guards into a single guard by left-applying a
/// two-argument function `f` to the list, starting with the initial value
/// `self`: i.e. `f(...f(f(self, g0), g1)...gn)`.
pub fn fold<F>(self, mut guards: Vec<Self>, f: F) -> Self
where
F: Fn(Self, Self) -> Self,
{
guards.drain(..).fold(self, f)
}

/// Returns all the ports used by this guard.
pub fn all_ports(&self) -> Vec<RRC<Port>> {
match self {
Expand Down
Loading
Loading