Skip to content

Commit

Permalink
Clean-up for bootstrapped compiler
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16371 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jun 14, 2013
1 parent 243917e commit 2db502c
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 1,697 deletions.
5 changes: 3 additions & 2 deletions Compiler/BackEnd/Tearing.mo
Expand Up @@ -2916,13 +2916,14 @@ author: Waurich TUD 2012-11"
input BackendDAE.IncidenceMatrix m,mt;
output list<Integer> potentials;
protected
list<list<Integer>> selectedcolsLst;
list<Integer> selectedcols1,selectedcols2,selectedrows;
BackendDAE.IncidenceMatrix mtsel,msel2,msel2t;
algorithm
// Cellier heuristic
// 1. choose rows(eqs) with most nonzero entries and write the column indexes(vars) for nonzeros in a list
((_,selectedcols1)) := Util.arrayFold(m,findMostEntries,(0,{}));
selectedcols1 := List.unique(List.flatten(selectedcols1));
((_,selectedcolsLst)) := Util.arrayFold(m,findMostEntries,(0,{}));
selectedcols1 := List.unique(List.flatten(selectedcolsLst));
//print("1st " +& stringDelimitList(List.map(selectedcols1,intString),", ") +& "\n");
// 2. gather these columns in a new array (reduced mt)
mtsel := Util.arraySelect(mt,selectedcols1);
Expand Down
104 changes: 6 additions & 98 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -3194,11 +3194,11 @@ public function crefPrefixOf
output Boolean out;
algorithm
out := matchcontinue(prefixCr, cr)
case(prefixCr, cr)
case(_, _)
equation
true = crefEqualNoSubs(prefixCr, cr);
then true;
case(prefixCr, cr)
case(_, _)
then crefPrefixOf(prefixCr, crefStripLast(cr));
case(_, _) then false;
end matchcontinue;
Expand Down Expand Up @@ -3377,20 +3377,20 @@ algorithm
Ident ident;
Path newPath,newSubPath;
// A suffix, e.g. C.D in A.B.C.D
case (subPath,path)
case (_,_)
equation
true=pathSuffixOf(subPath,path);
then path;
// strip last ident of path and recursively check if suffix.
case (subPath,path)
case (_,_)
equation
ident = pathLastIdent(path);
newPath = stripLast(path);
newPath=pathContainedIn(subPath,newPath);
then joinPaths(newPath,IDENT(ident));

// strip last ident of subpath and recursively check if suffix.
case (subPath,path)
case (_,_)
equation
ident = pathLastIdent(subPath);
newSubPath = stripLast(subPath);
Expand Down Expand Up @@ -4267,15 +4267,6 @@ algorithm
end match;
end restrString;

public function printRestr "function: printRestr
This is a utility function for printing an Absyn.Restriction."
input Restriction restr;
Ident str;
algorithm
str := restrString(restr);
Print.printBuf(str);
end printRestr;

public function lastClassname "function: lastClassname
Returns the path (=name) of the last class in a program"
input Program inProgram;
Expand Down Expand Up @@ -4351,7 +4342,7 @@ algorithm
Restriction r;
ClassDef body;
Info nfo;
case (CLASS(name = n,partialPrefix = p,finalPrefix = f,encapsulatedPrefix = e,restriction = r,body = body),newName)
case (CLASS(name = n,partialPrefix = p,finalPrefix = f,encapsulatedPrefix = e,restriction = r,body = body),_)
then CLASS(newName,p,f,e,r,body,INFO("",false,0,0,0,0, TIMESTAMP(0.0,0.0)) );
end matchcontinue;
end setClassName;
Expand Down Expand Up @@ -4558,89 +4549,6 @@ algorithm
CLASS(name=outName) := inClass;
end getClassName;

public function mergeElementAttributes "
Author BZ 2008-05
Function that is used with Derived classes,
merge the derived ElementAttributes with the optional ElementAttributes returned from ~instClass~.
"
input ElementAttributes ele;
input Option<ElementAttributes> oEle;
output Option<ElementAttributes> outoEle;
algorithm outoEle := match(ele, oEle)
local
Boolean b1,b2,bStream1,bStream2,bStream;
Parallelism p1,p2;
Variability v1,v2;
Direction d1,d2;
ArrayDim ad1,ad2;
case(ele,NONE()) then SOME(ele);
case(ATTR(b1,bStream1,p1,v1,d1,ad1), SOME(ATTR(b2,bStream2,p2,v2,d2,ad2)))
equation
b1 = boolOr(b1,b2);
bStream = boolOr(bStream1,bStream2);
p1 = propagateAbsynParallelism(p1,p2);
v1 = propagateAbsynVariability(v1,v2);
d1 = propagateAbsynDirection(d1,d2);
then
SOME(ATTR(b1,bStream,p1,v1,d1,ad1));
end match;
end mergeElementAttributes;

//mahge930: Not sure what to do here for now.
protected function propagateAbsynParallelism "
Helper function for mergeElementAttributes
"
input Parallelism p1;
input Parallelism p2;
output Parallelism p3;
algorithm p3 := matchcontinue(p1,p2)
case(p1,NON_PARALLEL()) then p1;
case(NON_PARALLEL(),p2) then p2;
case(p1,p2)
equation
equality(p1 = p2);
then p1;
case(_,_)
equation
print(" failure in propagateAbsynParallelism, parglobal-parlocal mismatch");
then
fail();
end matchcontinue;
end propagateAbsynParallelism;

protected function propagateAbsynVariability "
Helper function for mergeElementAttributes
"
input Variability v1;
input Variability v2;
output Variability v3;
algorithm v3 := matchcontinue(v1,v2)
case(v1,VAR()) then v1;
case(v1,_) then v1;
end matchcontinue;
end propagateAbsynVariability;

protected function propagateAbsynDirection "
Helper function for mergeElementAttributes
"
input Direction v1;
input Direction v2;
output Direction v3;
algorithm v3 := matchcontinue(v1,v2)
case(BIDIR(),v2) then v2;
case(v1,BIDIR()) then v1;
case(v1,v2)
equation
equality(v1 = v2);
then v1;
case(_,_)
equation
print(" failure in propagateAbsynDirection, input-output mismatch");
then
fail();
end matchcontinue;
end propagateAbsynDirection;

protected function findIteratorInElseIfExpBranch //This function is not tail-recursive, and I don't know how to fix it -- alleb
input String inString;
input list<tuple<Exp, Exp>> inElseIfBranch;
Expand Down
49 changes: 28 additions & 21 deletions Compiler/FrontEnd/AbsynDep.mo
Expand Up @@ -90,12 +90,14 @@ public function dumpAvlTreeKeys "prints all keys in an Avltree to stdout"
input AvlTree used;
algorithm
_ := matchcontinue(used)
local AvlTree usedBy;
list<tuple<AvlKey,AvlValue>> usedLst;
case(used) equation
usedLst = avlTreeToList(used);
print(stringDelimitList(List.map(usedLst, printKeyValueTupleStr),"\n"));
then ();
local
AvlTree usedBy;
list<tuple<AvlKey,AvlValue>> usedLst;
case _
equation
usedLst = avlTreeToList(used);
print(stringDelimitList(List.map(usedLst, printKeyValueTupleStr),"\n"));
then ();
end matchcontinue;
end dumpAvlTreeKeys;

Expand Down Expand Up @@ -277,14 +279,16 @@ public function getUsedBy "returns the classes that uses the class 'cl' e.g. as
input Depends depends;
input Absyn.Path cl;
output AvlTree usedBy;
algorithm
usedBy := matchcontinue(depends,cl)
local AvlValue v;
case(DEPENDS(_,usedBy),cl) equation
v = avlTreeGet(usedBy,cl);
usedBy= avlAddUses(avlTreeNew(),v);
then usedBy;
end matchcontinue;
algorithm
usedBy := matchcontinue(depends,cl)
local
AvlValue v;
case(DEPENDS(_,usedBy),_)
equation
v = avlTreeGet(usedBy,cl);
usedBy= avlAddUses(avlTreeNew(),v);
then usedBy;
end matchcontinue;
end getUsedBy;

public function getUsedBySub "
Expand All @@ -296,12 +300,14 @@ If inpu cl is 'A.B' it returns classes using A.B, but also classes that uses A.B
output AvlTree usedBy;
algorithm
usedBy := matchcontinue(depends,cl)
local AvlValue v;
case(DEPENDS(_,usedBy),cl) equation
v = avlTreeGetSubs(usedBy,cl);
//print("included: " +& stringDelimitList(List.map(v,Absyn.pathString),", ") +& "\n");
usedBy= avlAddUses(avlTreeNew(),v);
then usedBy;
local
AvlValue v;
case(DEPENDS(_,usedBy),_)
equation
v = avlTreeGetSubs(usedBy,cl);
//print("included: " +& stringDelimitList(List.map(v,Absyn.pathString),", ") +& "\n");
usedBy= avlAddUses(avlTreeNew(),v);
then usedBy;
end matchcontinue;
end getUsedBySub;

Expand Down Expand Up @@ -723,11 +729,12 @@ protected function avlTreeGetSubsopt
input Option<AvlTree> inAvlTree;
input AvlKey inKey;
output AvlValue outValue;
protected
AvlTree item;
algorithm
outValue := matchcontinue(inAvlTree,inKey)
case(NONE(),_) then {};
case(SOME(item),inKey) then avlTreeGetSubs (item,inKey);
case(SOME(item),_) then avlTreeGetSubs (item,inKey);
end matchcontinue;
end avlTreeGetSubsopt;

Expand Down
28 changes: 0 additions & 28 deletions Compiler/FrontEnd/Algorithm.mo
Expand Up @@ -100,34 +100,6 @@ algorithm
end matchcontinue;
end isNotAssertStatement;

public function splitReinits ""
input list<Algorithm> inAlgs;
output list<Algorithm> reinits;
output list<Statement> rest;
algorithm (reinits, rest) := matchcontinue(inAlgs)
local
Statement a;
list<Statement> al;
case({}) then ({}, {});
case(DAE.ALGORITHM_STMTS(al as {a as DAE.STMT_REINIT(var = _)})::inAlgs)
equation
(reinits, rest) = splitReinits(inAlgs);
then
(DAE.ALGORITHM_STMTS({a})::reinits, rest);
case(DAE.ALGORITHM_STMTS(al as {a})::inAlgs)
equation
(reinits, rest) = splitReinits(inAlgs);
then
(reinits, a::rest);
case( DAE.ALGORITHM_STMTS((a::al)):: inAlgs )
equation
inAlgs = listAppend({DAE.ALGORITHM_STMTS({a}), DAE.ALGORITHM_STMTS(al)}, inAlgs);
(reinits, rest) = splitReinits(inAlgs);
then
(reinits, rest);
end matchcontinue;
end splitReinits;

public function makeAssignment
"function: makeAssignment
This function creates an `DAE.STMT_ASSIGN\' construct, and checks that the
Expand Down
11 changes: 0 additions & 11 deletions Compiler/FrontEnd/Builtin.mo
Expand Up @@ -557,17 +557,6 @@ algorithm
end match;
end variableIsBuiltin;

public function isSubstring
input Absyn.Path inPath;
algorithm
_:=
match (inPath)
case (Absyn.IDENT(name = "substring")) then ();
case (Absyn.QUALIFIED(name = "Modelica",path = Absyn.QUALIFIED(name = "Utilities", path = Absyn.QUALIFIED(name = "Strings",path = Absyn.IDENT(name = "substring"))))) then ();
case (Absyn.FULLYQUALIFIED(inPath)) equation isSubstring(inPath); then ();
end match;
end isSubstring;

public function isDer
input Absyn.Path inPath;
algorithm
Expand Down

0 comments on commit 2db502c

Please sign in to comment.