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

@one_hot attribute #2042

Merged
merged 12 commits into from
May 22, 2024
Merged

@one_hot attribute #2042

merged 12 commits into from
May 22, 2024

Conversation

calebmkim
Copy link
Contributor

Support for a @one_hot attribute that can be attached to static control and tells the compiler to construct a one-hot FSM.
(Not a guarantee, since promotion and other optimizations that rewrite control could subsume the attribute).

Also add a pass called static-fsm-opts which attaches the @one_hot attribute, based on a "cutoff", i.e., if the number of cycles is less than the cutoff, then do one hot encoding, but switch to binary encoding if cycle count is greater than cutoff.I can imagine this pass being responsible for attaching all sorts of attributes as we implement more FSM optimizations.

(Also did some minor changes to optimization passes so that we copy over the @one_hot attribute).

/// keys: A, D
/// Then self gets: A->15 B->5. (D is ignored since it's not inpresent in other
/// and C is ignored since it's not keys.)
pub fn mirror_attributes<A>(&mut self, other: Self, keys: Vec<A>)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can call this copy_to instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to copy_from since technically we are copying attributes from other to self.

ir::Control::enable(init_group),
while_loop,
]);
let while_seq = ir::Control::Seq(ir::Seq {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an ir::Control::seq method to construct this nest of Seq { Seq { ... } } ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is, but it gives the seq ir::Attributes::default().

Copy link
Contributor

@rachitnigam rachitnigam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Couple of comments!

@calebmkim calebmkim merged commit b6eebb3 into main May 22, 2024
18 checks passed
@calebmkim calebmkim deleted the fsm-opt-attrs branch May 22, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants