Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
Hercules
Commits
4feea45d
Commit
4feea45d
authored
1 year ago
by
Aaron Councilman
Browse files
Options
Downloads
Patches
Plain Diff
New scheduler syntax
parent
1c8a4869
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
juno_scheduler/src/lang.l
+8
-2
8 additions, 2 deletions
juno_scheduler/src/lang.l
juno_scheduler/src/lang.y
+72
-31
72 additions, 31 deletions
juno_scheduler/src/lang.y
with
80 additions
and
33 deletions
juno_scheduler/src/lang.l
+
8
−
2
View file @
4feea45d
...
...
@@ -42,8 +42,11 @@ false "false"
/ "/"
% "%"
\|\| "||"
&& "&&"
\| "|"
:: "::"
\. "."
, ","
_ "_"
...
...
@@ -51,7 +54,10 @@ _ "_"
\) ")"
\{ "{"
\} "}"
\| "|"
if "if"
on "on"
partition "partition"
[a-zA-Z][a-zA-Z0-9_]* "ID"
[0-9]+ "INT"
...
...
This diff is collapsed.
Click to expand it.
juno_scheduler/src/lang.y
+
72
−
31
View file @
4feea45d
...
...
@@ -3,57 +3,84 @@
%avoid_insert "ID" "INT" "HEX_INT" "BIN_INT" "OCT_INT" "LABEL"
%expect-unused Unmatched 'UNMATCHED'
%left '||'
%left '&&'
%nonassoc '==' '!=' '<' '<=' '>' '>='
%left '+' '-'
%left '*' '/' '%'
%%
Schedule -> Vec<
Inst> : Inst
List {
rev(
$1
)
};
Schedule -> Vec<
Partition> : Partition
List { $1 };
Inst
List -> Vec<
Inst
>
Partition
List -> Vec<
Partition
>
: { vec![] }
|
Instruction Schedule { cons
($1, $2) }
|
PartitionList Partition { snoc
($1, $2) }
;
Instruction -> Inst : Base '.' Commands { Inst { span : $span, base : $1, commands : $3 }};
Partition -> Partition
: 'partition' Func '{' Labels '}' Directives
{ Partition { span : $span, func : $2, labels : $4, directs : $6 } };
Commands -> Vec<Command>
:
Command { vec![$1]
}
| '
{' CommandList
'
}
' {
rev
($
2
) }
Func -> Func
:
'ID' { Func { span : $span, name : $span, args : None }
}
| '
ID' '::' '<' TypeExprs
'
>
' {
Func { span : $span, name : span_of_tok($1), args : Some
($
4
) }
}
;
CommandList -> Vec<Command>
Labels -> Vec<Span> : LabelsRev { rev($1) };
LabelsRev -> Vec<Span>
: { vec![] }
|
Command
{ vec![$1] }
|
Command ',' CommandList { cons
($1, $3) }
|
'LABEL'
{ vec![
span_of_tok(
$1
)
] }
|
'LABEL' ',' LabelsRev { cons(span_of_tok
($1
)
, $3) }
;
Command -> Command
:
'ID' { Command { span : $span, name : $span, args :
vec![] }
}
|
'ID' '(' Values ')' { Command { span : $span, nam
e
:
s
pan_of_tok
($1
)
,
args : rev($3
) }
}
Directives -> Vec<Directive>
:
{
vec![] }
|
Directives Directiv
e
{
s
noc
($1,
$2
) }
;
Base -> Base
: Func { Base::Function { span : $span, func : $1 }}
| Func 'LABEL' { Base::Label { span : $span, func : $1, label : span_of_tok($2) }}
Directive -> Directive
: 'on' Device '{' Directives '}'
{ Directive::OnDevice { span : $span, device : $2, directs : $4 } }
| 'if' Expr '{' Directives '}'
{ Directive::IfExpr { span : $span, cond : $2, directs : $4 } }
| 'LABEL' '{' Commands '}'
{ Directive::Command { span : $span, label : span_of_tok($1), commands : $3 } }
;
Func -> Func
: 'ID' { Func { span : $span, name : $span, args : None }}
| 'ID' '::' '<' TypeVals '>' { Func { span : $span, name : span_of_tok($1), args : Some(rev($4)) }}
Device -> Device
: 'ID'
{ Device { span : $span, name : span_of_tok($1), args : vec![] } }
| 'ID' '(' Exprs ')'
{ Device { span : $span, name : span_of_tok($1), args : $3 } }
;
Values -> Vec<Expr>
Commands -> Vec<Command> : CommandsRev { rev($1) };
CommandsRev -> Vec<Command>
: { vec![] }
| Command { vec![$1] }
| Command ',' CommandsRev { cons($1, $3) }
;
Command -> Command
: 'ID'
{ Command { span : $span, name : span_of_tok($1), args : vec![] } }
| 'ID' '(' Exprs ')'
{ Command { span : $span, name : span_of_tok($1), args : $3 } }
;
Exprs -> Vec<Expr> : ExprsRev { rev($1) };
ExprsRev -> Vec<Expr>
: { vec![] }
| Expr { vec![$1] }
| Expr ','
Values
{ cons($1, $3) }
| Expr ','
ExprsRev
{ cons($1, $3) }
;
TypeVals -> Vec<TypExp>
TypeExprs -> Vec<TypExp> : TypeExprsRev { rev($1) };
TypeExprsRev -> Vec<TypExp>
: { vec![] }
| TypeExp { vec![$1] }
| TypeExp ',' Type
Vals
{ cons($1, $3) }
| TypeExp ',' Type
ExprsRev
{ cons($1, $3) }
;
Expr -> Expr
...
...
@@ -75,6 +102,8 @@ Expr -> Expr
| Expr '<=' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Le, rhs : Box::new($3) }}
| Expr '>' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Gt, rhs : Box::new($3) }}
| Expr '>=' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Ge, rhs : Box::new($3) }}
| Expr '&&' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::And, rhs : Box::new($3) }}
| Expr '||' Expr { Expr::BinOp { span : $span, lhs : Box::new($1), op : BinOp::Or, rhs : Box::new($3) }}
;
TypeExp -> TypExp
...
...
@@ -93,7 +122,7 @@ TypeExp -> TypExp
| 'f32' { TypExp::Primitive { span : $span, typ : Primitive::F32 }}
| 'f64' { TypExp::Primitive { span : $span, typ : Primitive::F64 }}
| 'void' { TypExp::Primitive { span : $span, typ : Primitive::Void }}
| '(' Type
Val
s ')'
{ TypExp::Tuple { span : $span, elems :
rev(
$2
)
}}
| '(' Type
Expr
s ')' { TypExp::Tuple { span : $span, elems : $2 }}
| '{' 'ID' '|' Expr '}' { TypExp::Set { span : $span, nm : span_of_tok($2), cond : $4 }}
;
...
...
@@ -113,19 +142,26 @@ fn cons<A>(hd : A, mut tl : Vec<A>) -> Vec<A> {
tl
}
fn snoc<A>(mut hd : Vec<A>, tl : A) -> Vec<A> {
hd.push(tl);
hd
}
fn rev<A>(mut lst : Vec<A>) -> Vec<A> {
lst.reverse();
lst
}
pub struct Inst { pub span : Span, pub base : Base, pub commands : Vec<Command>, }
pub struct Command { pub span : Span, pub name : Span, pub args : Vec<Expr>, }
pub struct Partition {
pub span : Span,
pub func : Func,
pub labels : Vec<Span>,
pub directs : Vec<Directive>,
}
pub struct Func { pub span : Span, pub name : Span, pub args : Option<Vec<TypExp>>, }
pub struct Device { pub span : Span, pub name : Span, pub args : Vec<Expr>, }
pub struct Command { pub span : Span, pub name : Span, pub args : Vec<Expr>, }
pub enum Base {
Function { span : Span, func : Func },
Label { span : Span, func : Func, label : Span },
}
pub enum Expr {
Id { span : Span },
Int { span : Span, base : IntBase },
...
...
@@ -139,7 +175,12 @@ pub enum TypExp {
Tuple { span : Span, elems : Vec<TypExp> },
Set { span : Span, nm : Span, cond : Expr },
}
pub enum Directive {
OnDevice { span : Span, device : Device, directs : Vec<Directive> },
IfExpr { span : Span, cond : Expr, directs : Vec<Directive> },
Command { span : Span, label : Span, commands : Vec<Command> },
}
pub enum IntBase { Bin, Oct, Dec, Hex }
pub enum BinOp { Add, Sub, Mul, Div, Mod, Eq, Ne, Lt, Le, Gt, Ge }
pub enum BinOp { Add, Sub, Mul, Div, Mod, Eq, Ne, Lt, Le, Gt, Ge
, And, Or
}
pub enum Primitive { Bool, I8, I16, I32, I64, U8, U16, U32, U64, USize, F32, F64, Void }
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment