Skip to content

Commit

Permalink
Merge pull request #304 from bmstu-iu9/kaelena-markup
Browse files Browse the repository at this point in the history
Авторазметка оптимизируемых функций (close #252)
  • Loading branch information
Mazdaywik authored Jun 29, 2020
2 parents f893b74 + c9990d0 commit e49ffe8
Show file tree
Hide file tree
Showing 5 changed files with 1,262 additions and 3 deletions.
194 changes: 194 additions & 0 deletions src/compiler/OptTree-AutoMarkup-BasisVertexesExtractor.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
$INCLUDE "LibraryEx";

*$FROM OptTree-AutoMarkup-Common
$EXTERN OptTree-AutoMarkup-GetSetDifference,
OptTree-AutoMarkup-Contains,
OptTree-AutoMarkup-GetElemByKey,
OptTree-AutoMarkup-GetParents,
OptTree-AutoMarkup-Equal;

/**
<OptTree-AutoMarkup-ExtractBasisVertexes e.ExtractedGraph>
= (e.BasisVertex)* (e.Graph)

e.BasisVertex = e.FuncName
*/

$ENTRY OptTree-AutoMarkup-ExtractBasisVertexes {
e.Graph
= <OptTree-AutoMarkup-GetGraphRoots (e.Graph)>
: (e.GraphRoots)
= <OptTree-AutoMarkup-GetBasisVertexes
(e.GraphRoots)
e.Graph
>
: (
(e.CurrentPath)
(e.Proccessed)
(e.BasisVertexes)
(e.Graph^)
)
= (e.BasisVertexes) (e.Graph);
}

OptTree-AutoMarkup-GetGraphRoots {
(e.Graph)
= <MapAccum
{
((e.Result) (e.Graph^))
(Func (Indirect function for implicit calls) Children (e.Children))
= ((e.Result) (e.Graph));

((e.Result) (e.Graph^))
(Func (e.FuncName) Children (e.Children))
, e.Graph
: e.GraphHead
(
Func (e.ParentName)
Children (e.ChildrenHead (e.FuncName) e.ChildrenTail)
)
e.GraphTail
, <OptTree-AutoMarkup-Equal (e.ParentName) (e.FuncName)> : False
= ((e.Result) (e.Graph));

((e.Result) (e.Graph^))
(Func (e.FuncName) Children (e.Children))
= ((e.Result (e.FuncName)) (e.Graph))
}
((/*result*/) (e.Graph)) e.Graph
>
: ((e.Roots) (e.Graph^))
= (e.Roots);
}

OptTree-AutoMarkup-GetBasisVertexes-GetResultByNode {
(Func (e.Name) Children (e.Children))
((e.CurrentPath) (e.Proccessed) (e.BasisVertexes) (e.Graph))
= <MapAccum
{
((e.CurrentPath^) (e.Proccessed^) (e.BasisVertexes^) (e.Graph^))
(e.ChildFunc)
, e.BasisVertexes : e._ (e.ChildFunc) e._
= (
(e.CurrentPath)
(e.Proccessed)
(e.BasisVertexes)
(e.Graph)
);

((e.CurrentPath^) (e.Proccessed^) (e.BasisVertexes^) (e.Graph^))
(e.Name)
, e.CurrentPath : e._ (e.ChildFunc) e._
= (
(e.CurrentPath)
(e.Proccessed)
(e.BasisVertexes (e.Name))
(e.Graph)
);

((e.CurrentPath^) (e.Proccessed^) (e.BasisVertexes^) (e.Graph^))
(e.ChildFunc)
, e.CurrentPath : e._ (e.ChildFunc) e._
= (
(e.CurrentPath)
(e.Proccessed)
(e.BasisVertexes (e.ChildFunc))
(e.Graph)
);

((e.CurrentPath^) (e.Proccessed^) (e.BasisVertexes^) (e.Graph^))
(e.ChildFunc)
, e.Proccessed : e._ (e.ChildFunc) e._
= (
(e.CurrentPath)
(e.Proccessed)
(e.BasisVertexes)
(e.Graph)
);

((e.CurrentPath^) (e.Proccessed^) (e.BasisVertexes^) (e.Graph^))
(e.ChildFunc)
= e.CurrentPath (e.ChildFunc) : e.NewCurrentPath
= <OptTree-AutoMarkup-GetBasisVertexes
((e.ChildFunc))
(
(e.NewCurrentPath)
(e.Proccessed)
(e.BasisVertexes)
(e.Graph)
)
>
: (
(e.NewCurrentPath^)
(e.Proccessed^)
(e.BasisVertexes^)
(e.Graph^)
)
= (
(e.CurrentPath)
(e.Proccessed)
(e.BasisVertexes)
(e.Graph)
);
}
((e.CurrentPath) (e.Proccessed) (e.BasisVertexes) (e.Graph))
e.Children
>
: ((e.CurrentPath^) (e.Proccessed^) (e.BasisVertexes^) (e.Graph^))
= e.Proccessed (e.Name) : e.NewProccessed
= (
(e.CurrentPath)
(e.NewProccessed)
(e.BasisVertexes)
(e.Graph)
);

(e.Other)
((e.CurrentPath) (e.Proccessed) (e.BasisVertexes) (e.Graph))
= ((e.CurrentPath) (e.Proccessed) (e.BasisVertexes) (e.Graph));
}


OptTree-AutoMarkup-GetBasisVertexes {
(e.NextGraphNodes)
(
(e.CurrentPath)
(e.Proccessed)
(e.BasisVertexes)
(e.Graph)
)
= <MapAccum
{
((e.CurrentPath^)(e.Proccessed^)(e.BasisVertexes^)(e.Graph^))
(e.FuncName)
= <OptTree-AutoMarkup-GetElemByKey
(e.FuncName)
(e.Graph)
>
: e.Node (e.Graph^)
= <OptTree-AutoMarkup-GetBasisVertexes-GetResultByNode
(e.Node)
((e.CurrentPath)(e.Proccessed)(e.BasisVertexes)(e.Graph))
>
}
(
(e.CurrentPath)
(e.Proccessed)
(e.BasisVertexes)
(e.Graph)
)
e.NextGraphNodes
>;

(e.RootNodes)
e.Graph
= <OptTree-AutoMarkup-GetBasisVertexes
(e.RootNodes)
(
()
()
()
(e.Graph)
)
>;
}
88 changes: 88 additions & 0 deletions src/compiler/OptTree-AutoMarkup-Common.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
$INCLUDE "LibraryEx";

/**
<OptTree-AutoMarkup-GetSetDifference (e.FirstSet) (e.SecondSet)> ==
(e.FirstSet\e.SecondSet)
*/

$ENTRY OptTree-AutoMarkup-GetSetDifference {
(e.FirstSet) (e.SecondSet)
= <Map
{
e.Node, <OptTree-AutoMarkup-Contains e.Node (e.SecondSet)> : False
= e.Node;

e.Other
= ;
}
e.FirstSet
>
: e.Res
= (e.Res);
}

/**
<OptTree-AutoMarkup-Contains (e.Elem) (e.Array)> == True|False
*/

$ENTRY OptTree-AutoMarkup-Contains {
(e.Elem) (e.ArrayHead (e.Elem) e.ArrayTail)
= True;

(e.Elem) (e.Array)
= False;
}

/**
<OptTree-AutoMarkup-Equal (e.First) (e.Second)> == True|False
*/

$ENTRY OptTree-AutoMarkup-Equal {
(e.X) (e.X)
= True;

(e.X) (e.Y)
= False;
}

/**
<OptTree-AutoMarkup-GetElemByKey (e.Key) (e.Graph)>
== e.GraphNode (e.Graph)

e.GraphNode = (Func (e.Key) Children (e.Children))
*/

$ENTRY OptTree-AutoMarkup-GetElemByKey {
(e.Key) (e.GraphHead (Func (e.Key) Children (e.Children)) e.GraphTail)
= Func (e.Key) Children (e.Children)
(e.GraphHead (Func (e.Key) Children (e.Children)) e.GraphTail);

(e.Key) (e.Graph)
= /* пусто */ (e.Graph);
}

/**
<OptTree-AutoMarkup-GetParents (e.ChildName) (e.Graph)> == e.GraphNode*

e.GraphNode = (Func (e.Key) Children (e.Children))

e.Children = (e._ (e.ChildName) e._)
*/

$ENTRY OptTree-AutoMarkup-GetParents {
(e.ChildName)
(e.Graph-B (Func (e.FuncName) Children (e._ (e.ChildName) e._)) e.Graph-E)
= (e.FuncName)
<OptTree-AutoMarkup-GetParents (e.ChildName) (e.Graph-E)>;

(e.ChildName) (e._)
= ;
}

$ENTRY OptTree-AutoMarkup-IsEmpty {
()
= True;

e.Other
= False;
}
Loading

0 comments on commit e49ffe8

Please sign in to comment.