Skip to content

Commit

Permalink
- SimCode.mo
Browse files Browse the repository at this point in the history
  - do lateInline
- Inline.mo
  - also inline start expressions
- SimCodeC
  - implement more cases for daeExpBinary

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5723 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jun 25, 2010
1 parent 0844ddf commit fe0d83a
Show file tree
Hide file tree
Showing 8 changed files with 1,143 additions and 417 deletions.
2 changes: 1 addition & 1 deletion Compiler/DAELow.mo
Expand Up @@ -5705,7 +5705,7 @@ algorithm
equation
e1 = Exp.simplify(e);
(expl,_) = extendExp(e1);
ty = Exp.typeof(e1);
ty = Exp.typeof(e);
then
DAE.ARRAY(ty,true,expl);
end matchcontinue;
Expand Down
11 changes: 11 additions & 0 deletions Compiler/Exp.mo
Expand Up @@ -1672,6 +1672,17 @@ algorithm
then
DAE.CALL(path,exps_1,b,b2,t,b3);

/* {-e[1],-e[2],-e[3]} = -{e[1],e[2],e[3]} */
case DAE.ARRAY( t, b,exps as ((DAE.UNARY(DAE.UMINUS(_),_) :: _)))
equation
(f::exps_1) = Util.listMap(exps, expStripLastSubs); //Strip last subscripts
bls = Util.listMap1(exps_1, expEqual,f);
true = Util.boolAndList(bls);
expl_1 = Util.listMap(exps,abs);
expl_1 = Util.listMap(expl_1,simplify1);
e = DAE.ARRAY(t,b,expl_1);
then
DAE.UNARY(DAE.UMINUS_ARR(t),e);
case DAE.ARRAY( t, b,exps_1)
equation
exps_1 = Util.listMap(exps_1,simplify1);
Expand Down
24 changes: 20 additions & 4 deletions Compiler/Inline.mo
Expand Up @@ -285,20 +285,35 @@ algorithm
DAELow.VarKind varKind;
DAE.VarDirection varDirection;
DAELow.Type varType;
DAE.Exp e,e_1;
DAE.Exp e,e_1,startv,startv_1;
Option<Values.Value> bindValue;
DAE.InstDims arrayDim;
Integer index;
DAE.ComponentRef origVarName;
list<Absyn.Path> className;
Option<DAE.VariableAttributes> values;
Option<DAE.VariableAttributes> values,values1;
Option<SCode.Comment> comment;
DAE.Flow flowPrefix;
DAE.Stream streamPrefix;
Option<DAELow.Var> var;
DAE.ElementSource source "the origin of the element";

case(NONE,_) then NONE;
case(SOME(DAELow.VAR(varName,varKind,varDirection,varType,SOME(e),bindValue,arrayDim,index,source,values,comment,flowPrefix,streamPrefix)),fns)
equation
e_1 = inlineExp(e,fns);
startv = DAEUtil.getStartAttrFail(values);
startv_1 = inlineExp(startv,fns);
values1 = DAEUtil.setStartAttr(values,startv_1);
then
SOME(DAELow.VAR(varName,varKind,varDirection,varType,SOME(e_1),bindValue,arrayDim,index,source,values1,comment,flowPrefix,streamPrefix));
case(SOME(DAELow.VAR(varName,varKind,varDirection,varType,NONE(),bindValue,arrayDim,index,source,values,comment,flowPrefix,streamPrefix)),fns)
equation
startv = DAEUtil.getStartAttrFail(values);
startv_1 = inlineExp(startv,fns);
values1 = DAEUtil.setStartAttr(values,startv_1);
then
SOME(DAELow.VAR(varName,varKind,varDirection,varType,NONE(),bindValue,arrayDim,index,source,values1,comment,flowPrefix,streamPrefix));
case(SOME(DAELow.VAR(varName,varKind,varDirection,varType,SOME(e),bindValue,arrayDim,index,source,values,comment,flowPrefix,streamPrefix)),fns)
equation
e_1 = inlineExp(e,fns);
Expand Down Expand Up @@ -900,12 +915,13 @@ algorithm
outExp := matchcontinue(inExp,inElementList)
local
Functiontuple fns;
DAE.Exp e,e_1;
DAE.Exp e,e_1,e_2;
case(e,fns)
equation
((e_1,fns)) = Exp.traverseExp(e,inlineCall,fns);
e_2 = Exp.simplify(e_1);
then
e_1;
e_2;
case(e,_) then e;
end matchcontinue;
end inlineExp;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Main.mo
Expand Up @@ -895,7 +895,7 @@ algorithm
list<list<Integer>> comps;
Env.Cache cache;
Env.Env env;
list<DAE.Element> funcelems;

case (cache,env,classname,p,ap,dae,dlow,ass1,ass2,m,mt,comps) /* classname ass1 ass2 blocks */
equation
Debug.fcall("execstat",print, "*** Main -> entering simcodgen: " +& realString(clock()) +& "\n" );
Expand Down
29 changes: 29 additions & 0 deletions Compiler/SimCode.mo
Expand Up @@ -1151,10 +1151,16 @@ algorithm
list<tuple<Integer, DAE.Exp>> delayedExps;
list<DAE.Exp> divLst;
list<DAE.Statement> allDivStmts;
DAE.FunctionTree funcs;
case (dae,dlow,ass1,ass2,m,mt,comps,class_,fileDir,functions,libs)
equation
cname = Absyn.pathString(class_);

// late Inline
funcs = DAEUtil.daeFunctionTree(dae);
dlow = Inline.inlineCalls(NONE(),SOME(funcs),{DAE.NORM_INLINE(),DAE.AFTER_INDEX_RED_INLINE()},dlow);
Debug.fcall("lateInline", DAELow.dump, dlow);

(blt_states, blt_no_states) = DAELow.generateStatePartition(comps, dlow, ass1, ass2, m, mt);

(helpVarInfo, dlow2) = generateHelpVarInfo(dlow, comps);
Expand Down Expand Up @@ -3567,6 +3573,7 @@ algorithm
Integer cg_id_1,cg_id;
DAE.ComponentRef cr,eltcr,cr2;
DAE.Exp e1,e2;
DAE.ExpType ty;
case (cr,eltcr,(e1 as DAE.CREF(componentRef = cr2)),e2)
equation
true = Exp.crefEqual(cr, cr2);
Expand All @@ -3577,6 +3584,28 @@ algorithm
true = Exp.crefEqual(cr, cr2);
then
SES_ARRAY_CALL_ASSIGN(eltcr, e1);
case (cr,eltcr,(e1 as DAE.UNARY(exp=DAE.CREF(componentRef = cr2))),e2)
equation
true = Exp.crefEqual(cr, cr2);
ty = Exp.typeof(e2);
then
SES_ARRAY_CALL_ASSIGN(eltcr, DAE.UNARY(DAE.UMINUS_ARR(ty),e2));
case (cr,eltcr,e1,(e2 as DAE.UNARY(exp=DAE.CREF(componentRef = cr2))))
equation
true = Exp.crefEqual(cr, cr2);
ty = Exp.typeof(e1);
then
SES_ARRAY_CALL_ASSIGN(eltcr, DAE.UNARY(DAE.UMINUS_ARR(ty),e1));
case (cr,eltcr,e1,DAE.UNARY(DAE.UMINUS_ARR(ty),e2))
equation
cr2 = getVectorizedCrefFromExp(e2);
then
SES_ARRAY_CALL_ASSIGN(cr2, DAE.UNARY(DAE.UMINUS_ARR(ty),e1));
case (cr,eltcr,DAE.UNARY(DAE.UMINUS_ARR(ty),e1),e2) /* e2 is array of crefs, {v{1},v{2},...v{n}} */
equation
cr2 = getVectorizedCrefFromExp(e1);
then
SES_ARRAY_CALL_ASSIGN(cr2, DAE.UNARY(DAE.UMINUS_ARR(ty),e2));
case (cr,eltcr,e1,e2) /* e2 is array of crefs, {v{1},v{2},...v{n}} */
equation
cr2 = getVectorizedCrefFromExp(e2);
Expand Down

0 comments on commit fe0d83a

Please sign in to comment.