-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added dynamic_to_static pass, and added functions to turn dynamic guards and assignments into static ones * added dynamic-to-static pass * separate new infer-static-timing pass from old one * fmt * fixed bug and changed pass name to group-static-promotion * fmt * addressed comments * fmt * clippy * fixed error message * got rid of infer-static-timing pass * modify group-static-promotion pass * merge conflict * temp * err * modified static-group-promotion, fixed test cases * fmt and rename * added group promotion tests * clippY * deleted @static attributes tests * rename tests * deleted all infer-static test cases * make changes * fixed non-frontend tests * changed frontend tests * redid dahlia test cases * implemented From<> without & * simplify-with-control uses static groups * fixed bug * improved test cases * removed debugging stmts * rewrite compiler test cases, add go-done port to static-promotion * attribute promotion, some small static promotion fixes * overwrite tests .expect files * code cleaning * further code cleaning * clippy * changed test cases * skip sync-dot-product-opt.futil --------- Co-authored-by: Caleb <[email protected]> Co-authored-by: calebmkim <[email protected]>
- Loading branch information
1 parent
8464a6a
commit 86c6762
Showing
116 changed files
with
1,231 additions
and
1,164 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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,87 @@ | ||
use crate::traversal::{Action, Named, VisResult, Visitor}; | ||
use calyx_ir::{self as ir, LibrarySignatures}; | ||
use std::collections::HashMap; | ||
|
||
#[derive(Default)] | ||
/// Removes NODE_ID, BEGIN_ID, and END_ID from each control statement | ||
pub struct AttributePromotion { | ||
/// maps dynamic group names its corresponding upgraded static group | ||
/// Then we use this to replace regular groups | ||
upgraded_groups: HashMap<ir::Id, ir::RRC<ir::StaticGroup>>, | ||
} | ||
|
||
impl Named for AttributePromotion { | ||
fn name() -> &'static str { | ||
"attr-promotion" | ||
} | ||
|
||
fn description() -> &'static str { | ||
"upgrades @static and @bound annotations to appropriate static control" | ||
} | ||
} | ||
|
||
impl Visitor for AttributePromotion { | ||
fn start( | ||
&mut self, | ||
comp: &mut ir::Component, | ||
sigs: &LibrarySignatures, | ||
_comps: &[ir::Component], | ||
) -> VisResult { | ||
// drain groups | ||
let comp_groups: Vec<ir::RRC<ir::Group>> = | ||
comp.get_groups_mut().drain().collect(); | ||
let mut builder = ir::Builder::new(comp, sigs); | ||
let mut non_upgraded_groups = Vec::new(); | ||
|
||
for group in comp_groups { | ||
let group_rc_clone = std::rc::Rc::clone(&group); | ||
let mut gr = group.borrow_mut(); | ||
// if group has static annotation, then create corresponding static group, and add to self.upgraded_groups | ||
// otherwise just add back to component.groups | ||
if let Some(lat) = gr.attributes.get(ir::NumAttr::Static) { | ||
let sg = builder.add_static_group(gr.name(), lat); | ||
for assignment in gr.assignments.drain(..) { | ||
// don't add done signal to static group | ||
if !(assignment.dst.borrow().is_hole() | ||
&& assignment.dst.borrow().name == "done") | ||
{ | ||
let static_s = ir::Assignment::from(assignment); | ||
sg.borrow_mut().assignments.push(static_s); | ||
} | ||
} | ||
self.upgraded_groups.insert(gr.name(), sg); | ||
} else { | ||
non_upgraded_groups.push(group_rc_clone); | ||
} | ||
} | ||
|
||
builder | ||
.component | ||
.get_groups_mut() | ||
.append(non_upgraded_groups.into_iter()); | ||
|
||
Ok(Action::Continue) | ||
} | ||
|
||
fn enable( | ||
&mut self, | ||
s: &mut ir::Enable, | ||
_comp: &mut ir::Component, | ||
_sigs: &LibrarySignatures, | ||
_comps: &[ir::Component], | ||
) -> VisResult { | ||
// check if this groups is indeed an "upgraded_group". If so, then change | ||
// to static enable. Otherwise continue. | ||
if let Some(static_group) = | ||
self.upgraded_groups.get(&s.group.borrow().name()) | ||
{ | ||
let static_enable = ir::StaticControl::Enable(ir::StaticEnable { | ||
group: std::rc::Rc::clone(static_group), | ||
attributes: s.attributes.clone(), | ||
}); | ||
Ok(Action::change(ir::Control::Static(static_enable))) | ||
} else { | ||
Ok(Action::Continue) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.