Skip to content
Snippets Groups Projects
Commit 5352a533 authored by Aaron Councilman's avatar Aaron Councilman
Browse files

Add set ops to scheduler

parent 6cb6c003
No related branches found
No related tags found
1 merge request!197Add set ops to scheduler
...@@ -1459,6 +1459,7 @@ dependencies = [ ...@@ -1459,6 +1459,7 @@ dependencies = [
name = "juno_scheduler" name = "juno_scheduler"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"bitvec",
"cfgrammar", "cfgrammar",
"hercules_cg", "hercules_cg",
"hercules_ir", "hercules_ir",
......
...@@ -108,9 +108,8 @@ impl<'a: 'b, 'b> FunctionEditor<'a> { ...@@ -108,9 +108,8 @@ impl<'a: 'b, 'b> FunctionEditor<'a> {
} }
} }
// Constructs an editor but only makes the nodes with at least one of the // Constructs an editor with a specified mask determining which nodes are mutable
// set of labels as mutable. pub fn new_mask(
pub fn new_labeled(
function: &'a mut Function, function: &'a mut Function,
function_id: FunctionID, function_id: FunctionID,
constants: &'a RefCell<Vec<Constant>>, constants: &'a RefCell<Vec<Constant>>,
...@@ -118,7 +117,7 @@ impl<'a: 'b, 'b> FunctionEditor<'a> { ...@@ -118,7 +117,7 @@ impl<'a: 'b, 'b> FunctionEditor<'a> {
types: &'a RefCell<Vec<Type>>, types: &'a RefCell<Vec<Type>>,
labels: &'a RefCell<Vec<String>>, labels: &'a RefCell<Vec<String>>,
def_use: &ImmutableDefUseMap, def_use: &ImmutableDefUseMap,
with_labels: &HashSet<LabelID>, mask: BitVec<u8, Lsb0>,
) -> Self { ) -> Self {
let mut_def_use = (0..function.nodes.len()) let mut_def_use = (0..function.nodes.len())
.map(|idx| { .map(|idx| {
...@@ -130,14 +129,6 @@ impl<'a: 'b, 'b> FunctionEditor<'a> { ...@@ -130,14 +129,6 @@ impl<'a: 'b, 'b> FunctionEditor<'a> {
}) })
.collect(); .collect();
let mut mutable_nodes = bitvec![u8, Lsb0; 0; function.nodes.len()];
// Add all nodes which have some label which is in the with_labels set
for (idx, labels) in function.labels.iter().enumerate() {
if !labels.is_disjoint(with_labels) {
mutable_nodes.set(idx, true);
}
}
FunctionEditor { FunctionEditor {
function, function,
function_id, function_id,
...@@ -146,7 +137,7 @@ impl<'a: 'b, 'b> FunctionEditor<'a> { ...@@ -146,7 +137,7 @@ impl<'a: 'b, 'b> FunctionEditor<'a> {
types, types,
labels, labels,
mut_def_use, mut_def_use,
mutable_nodes, mutable_nodes: mask,
modified: false, modified: false,
} }
} }
......
...@@ -24,4 +24,5 @@ hercules_ir = { path = "../hercules_ir" } ...@@ -24,4 +24,5 @@ hercules_ir = { path = "../hercules_ir" }
hercules_opt = { path = "../hercules_opt" } hercules_opt = { path = "../hercules_opt" }
juno_utils = { path = "../juno_utils" } juno_utils = { path = "../juno_utils" }
postcard = { version = "*", features = ["alloc"] } postcard = { version = "*", features = ["alloc"] }
serde = { version = "*", features = ["derive"] } serde = { version = "*", features = ["derive"] }
\ No newline at end of file bitvec = "*"
...@@ -473,6 +473,20 @@ fn compile_expr( ...@@ -473,6 +473,20 @@ fn compile_expr(
} }
Ok(ExprResult::Expr(ir::ScheduleExp::Record { fields: result })) Ok(ExprResult::Expr(ir::ScheduleExp::Record { fields: result }))
} }
parser::Expr::SetOp {
span: _,
op,
lhs,
rhs,
} => {
let lhs = compile_exp_as_expr(*lhs, lexer, macrostab, macros)?;
let rhs = compile_exp_as_expr(*rhs, lexer, macrostab, macros)?;
Ok(ExprResult::Expr(ir::ScheduleExp::SetOp {
op,
lhs: Box::new(lhs),
rhs: Box::new(rhs),
}))
}
} }
} }
......
use hercules_ir::ir::{Device, Schedule}; use hercules_ir::ir::{Device, Schedule};
use crate::parser;
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub enum Pass { pub enum Pass {
ArraySLF, ArraySLF,
...@@ -117,6 +119,11 @@ pub enum ScheduleExp { ...@@ -117,6 +119,11 @@ pub enum ScheduleExp {
body: Vec<ScheduleStmt>, body: Vec<ScheduleStmt>,
res: Box<ScheduleExp>, res: Box<ScheduleExp>,
}, },
SetOp {
op: parser::SetOp,
lhs: Box<ScheduleExp>,
rhs: Box<ScheduleExp>,
},
// This is used to "box" a selection by evaluating it at one point and then // This is used to "box" a selection by evaluating it at one point and then
// allowing it to be used as a selector later on // allowing it to be used as a selector later on
Selection { Selection {
......
...@@ -39,6 +39,10 @@ false "false" ...@@ -39,6 +39,10 @@ false "false"
\{ "{" \{ "{"
\} "}" \} "}"
\\ "\\"
\| "|"
& "&"
panic[\t \n\r]+after "panic_after" panic[\t \n\r]+after "panic_after"
print[\t \n\r]+iter "print_iter" print[\t \n\r]+iter "print_iter"
stop[\t \n\r]+after "stop_after" stop[\t \n\r]+after "stop_after"
......
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
%avoid_insert "ID" "INT" "STRING" %avoid_insert "ID" "INT" "STRING"
%expect-unused Unmatched 'UNMATCHED' %expect-unused Unmatched 'UNMATCHED'
%left '\\'
%left '|'
%left '&'
%left '.' '@'
%% %%
Schedule -> OperationList Schedule -> OperationList
...@@ -59,6 +64,12 @@ Expr -> Expr ...@@ -59,6 +64,12 @@ Expr -> Expr
{ Expr::BlockExpr { span: $span, body: Box::new($2) } } { Expr::BlockExpr { span: $span, body: Box::new($2) } }
| '<' Fields '>' | '<' Fields '>'
{ Expr::Record { span: $span, fields: rev($2) } } { Expr::Record { span: $span, fields: rev($2) } }
| Expr '\\' Expr
{ Expr::SetOp { span: $span, op: SetOp::Difference, lhs: Box::new($1), rhs: Box::new($3) } }
| Expr '|' Expr
{ Expr::SetOp { span: $span, op: SetOp::Union, lhs: Box::new($1), rhs: Box::new($3) } }
| Expr '&' Expr
{ Expr::SetOp { span: $span, op: SetOp::Intersection, lhs: Box::new($1), rhs: Box::new($3) } }
; ;
Args -> Vec<Expr> Args -> Vec<Expr>
...@@ -151,6 +162,13 @@ pub enum FixpointLimit { ...@@ -151,6 +162,13 @@ pub enum FixpointLimit {
PrintIter { span: Span }, PrintIter { span: Span },
} }
#[derive(Copy, Clone, Debug)]
pub enum SetOp {
Difference,
Union,
Intersection,
}
pub enum Expr { pub enum Expr {
Function { span: Span, name: Span, args: Vec<Expr>, selection: Selector }, Function { span: Span, name: Span, args: Vec<Expr>, selection: Selector },
Macro { span: Span, name: Span, args: Vec<Expr>, selection: Selector }, Macro { span: Span, name: Span, args: Vec<Expr>, selection: Selector },
...@@ -161,6 +179,7 @@ pub enum Expr { ...@@ -161,6 +179,7 @@ pub enum Expr {
Field { span: Span, lhs: Box<Expr>, field: Span }, Field { span: Span, lhs: Box<Expr>, field: Span },
BlockExpr { span: Span, body: Box<OperationList> }, BlockExpr { span: Span, body: Box<OperationList> },
Record { span: Span, fields: Vec<(Span, Expr)> }, Record { span: Span, fields: Vec<(Span, Expr)> },
SetOp { span: Span, op: SetOp, lhs: Box<Expr>, rhs: Box<Expr> },
} }
pub enum Selector { pub enum Selector {
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment