Skip to content

Commit

Permalink
Merge branch 'master' into clocks
Browse files Browse the repository at this point in the history
  • Loading branch information
niklwors authored and niklwors committed Apr 8, 2016
2 parents 029e82e + dec8532 commit 1f4723e
Show file tree
Hide file tree
Showing 256 changed files with 15,051 additions and 11,184 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -96,6 +96,9 @@ SimulationRuntime/ParModelica/auto/Makefile
SimulationRuntime/ParModelica/explicit/Makefile
SimulationRuntime/ParModelica/explicit/openclrt/Makefile
SimulationRuntime/build_c/
SimulationRuntime/opc/ua/open62541.h
SimulationRuntime/opc/ua/open62541.c
SimulationRuntime/opc/ua/libomopcua.dll

# OpenModelicaSetup
Compiler/OpenModelicaSetup
Expand Down
2 changes: 1 addition & 1 deletion 3rdParty
3 changes: 3 additions & 0 deletions Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -252,6 +252,7 @@ uniontype VarKind "variable kind"
record EXTOBJ Absyn.Path fullClassName; end EXTOBJ;
record JAC_VAR end JAC_VAR;
record JAC_DIFF_VAR end JAC_DIFF_VAR;
record SEED_VAR end SEED_VAR;
record OPT_CONSTR end OPT_CONSTR;
record OPT_FCONSTR end OPT_FCONSTR;
record OPT_INPUT_WITH_DER end OPT_INPUT_WITH_DER;
Expand Down Expand Up @@ -474,6 +475,8 @@ uniontype StateOrder
HashTableCG.HashTable hashTable "x -> dx";
HashTable3.HashTable invHashTable "dx -> {x,y,z}";
end STATEORDER;
record NOSTATEORDER "Index reduction disabled; don't need big hashtables"
end NOSTATEORDER;
end StateOrder;

public
Expand Down
57 changes: 29 additions & 28 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -56,6 +56,7 @@ protected import DAEDump;
protected import DAEUtil;
protected import Debug;
protected import DynamicOptimization;
protected import ElementSource;
protected import Error;
protected import Expression;
protected import ExpressionDump;
Expand All @@ -68,7 +69,7 @@ protected import HashTable;
protected import HashTableCrToExpSourceTpl;
protected import Inline;
protected import List;
protected import SimCodeFunctionUtil;
protected import ExecStat.execStat;
protected import SCode;
protected import System;
protected import Types;
Expand Down Expand Up @@ -155,7 +156,7 @@ algorithm
neqStr := intString(BackendDAEUtil.equationSize(eqnarr));
nvarStr := intString(BackendVariable.varsSize(vars_1));
Error.assertionOrAddSourceMessage(not Flags.isSet(Flags.DUMP_BACKENDDAE_INFO),Error.BACKENDDAEINFO_LOWER,{neqStr,nvarStr},Absyn.dummyInfo);
SimCodeFunctionUtil.execStat("Generate backend data structure");
execStat("Generate backend data structure");
end lower;

protected function lower2
Expand Down Expand Up @@ -778,7 +779,7 @@ algorithm
equation
e1 = BaseHashTable.get(iExp,iInlineHT);
// print("use chache Inline\n" + ExpressionDump.printExpStr(iExp) + "\n");
source = DAEUtil.addSymbolicTransformation(iSource,DAE.OP_INLINE(DAE.PARTIAL_EQUATION(iExp),DAE.PARTIAL_EQUATION(e1)));
source = ElementSource.addSymbolicTransformation(iSource,DAE.OP_INLINE(DAE.PARTIAL_EQUATION(iExp),DAE.PARTIAL_EQUATION(e1)));
then (e1,source,iInlineHT,{});
case (DAE.CALL(),_,_,_)
equation
Expand All @@ -790,7 +791,7 @@ algorithm
equation
e1 = BaseHashTable.get(e,iInlineHT);
// print("use chache Inline\n" + ExpressionDump.printExpStr(iExp) + "\n");
source = DAEUtil.addSymbolicTransformation(iSource,DAE.OP_INLINE(DAE.PARTIAL_EQUATION(e),DAE.PARTIAL_EQUATION(e1)));
source = ElementSource.addSymbolicTransformation(iSource,DAE.OP_INLINE(DAE.PARTIAL_EQUATION(e),DAE.PARTIAL_EQUATION(e1)));
(e, source, _,_) = Inline.inlineExp(DAE.ASUB(e1,elst), fnstpl, source);
then (e,source,iInlineHT,{});
case (DAE.ASUB(e,elst),_,_,_)
Expand Down Expand Up @@ -1086,29 +1087,29 @@ algorithm

case(DAE.EQUATION(DAE.TUPLE(explst),e2 as DAE.CALL(),source),_,_,_,_)
equation
(DAE.EQUALITY_EXPS(_,e2_1), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(DAE.TUPLE(explst),e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.NO_INLINE()}), source);
(DAE.EQUALITY_EXPS(_,e2_1), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(DAE.TUPLE(explst),e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.DEFAULT_INLINE()}), source);
eqns = lowerExtendedRecordEqn(DAE.TUPLE(explst),e2_1,source,BackendDAE.DYNAMIC_EQUATION(),functionTree,inEquations);
then
(eqns,inREquations,inIEquations);

case(DAE.EQUATION(e2 as DAE.CALL(),DAE.TUPLE(explst),source),_,_,_,_)
equation
(DAE.EQUALITY_EXPS(e1,e2_1), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(DAE.TUPLE(explst),e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.NO_INLINE()}), source);
(DAE.EQUALITY_EXPS(e1,e2_1), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(DAE.TUPLE(explst),e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.DEFAULT_INLINE()}), source);
eqns = lowerExtendedRecordEqn(e1,e2_1,source,BackendDAE.DYNAMIC_EQUATION(),functionTree,inEquations);
then
(eqns,inREquations,inIEquations);

// Only succeds for initial tuple equations, i.e. (a,b,c) = foo(x,y,z) or foo(x,y,z) = (a,b,c)
case(DAE.INITIALEQUATION(DAE.TUPLE(explst),e2 as DAE.CALL(),source),_,_,_,_)
equation
(DAE.EQUALITY_EXPS(e1,e2_1), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(DAE.TUPLE(explst),e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.NO_INLINE()}), source);
(DAE.EQUALITY_EXPS(e1,e2_1), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(DAE.TUPLE(explst),e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.DEFAULT_INLINE()}), source);
eqns = lowerExtendedRecordEqn(e1,e2_1,source,BackendDAE.INITIAL_EQUATION(),functionTree,inIEquations);
then
(inEquations,inREquations,eqns);

case(DAE.INITIALEQUATION(e2 as DAE.CALL(),DAE.TUPLE(explst),source),_,_,_,_)
equation
(DAE.EQUALITY_EXPS(e1,e2_1), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(DAE.TUPLE(explst),e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.NO_INLINE()}), source);
(DAE.EQUALITY_EXPS(e1,e2_1), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(DAE.TUPLE(explst),e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.DEFAULT_INLINE()}), source);
eqns = lowerExtendedRecordEqn(e1,e2_1,source,BackendDAE.INITIAL_EQUATION(),functionTree,inIEquations);
then
(inEquations,inREquations,eqns);
Expand Down Expand Up @@ -1149,7 +1150,7 @@ algorithm

case (DAE.COMPLEX_EQUATION(lhs = e1,rhs = e2,source = source),_,_,_,_)
equation
(DAE.EQUALITY_EXPS(e1,e2), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(e1,e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.NO_INLINE()}), source);
(DAE.EQUALITY_EXPS(e1,e2), source) = Inline.simplifyAndForceInlineEquationExp(DAE.EQUALITY_EXPS(e1,e2), (SOME(functionTree), {DAE.NORM_INLINE(), DAE.DEFAULT_INLINE()}), source);
eqns = lowerExtendedRecordEqn(e1,e2,source,BackendDAE.DYNAMIC_EQUATION(),functionTree,inEquations);
then
(eqns,inREquations,inIEquations);
Expand Down Expand Up @@ -1248,7 +1249,7 @@ algorithm
case (_,_,_,_,_)
equation
s = "BackendDAECreate.lowerEqn failed for " + DAEDump.dumpElementsStr({inElement});
Error.addSourceMessage(Error.INTERNAL_ERROR, {s}, DAEUtil.getElementSourceFileInfo(DAEUtil.getElementSource(inElement)));
Error.addSourceMessage(Error.INTERNAL_ERROR, {s}, ElementSource.getElementSourceFileInfo(ElementSource.getElementSource(inElement)));
then fail();

end match;
Expand Down Expand Up @@ -1739,10 +1740,10 @@ algorithm

else
equation
source = DAEUtil.getElementSource(inElement);
source = ElementSource.getElementSource(inElement);
str = "BackendDAECreate.lowerWhenEqn: equation not handled:\n" +
DAEDump.dumpElementsStr({inElement});
Error.addSourceMessage(Error.INTERNAL_ERROR, {str}, DAEUtil.getElementSourceFileInfo(source));
Error.addSourceMessage(Error.INTERNAL_ERROR, {str}, ElementSource.getElementSourceFileInfo(source));
then
fail();
end matchcontinue;
Expand Down Expand Up @@ -1993,7 +1994,7 @@ algorithm
inEqns;
case ((cr, (e, source))::rest, _, _, _)
equation
source = DAEUtil.mergeSources(iSource, source);
source = ElementSource.mergeSources(iSource, source);
size = Expression.sizeOf(Expression.typeof(e));
whenOp = BackendDAE.ASSIGN(cr, e, source);
whenEq = BackendDAE.WHEN_STMTS(inCond, {whenOp}, NONE());
Expand Down Expand Up @@ -2059,7 +2060,7 @@ algorithm
(e, source, _,_) = Inline.inlineExp(e, (SOME(functionTree), {DAE.NORM_INLINE()}), source);
((exp, source1)) = BaseHashTable.get(cr, iHt);
exp = DAE.IFEXP(condition, e, exp);
source = DAEUtil.mergeSources(source, source1);
source = ElementSource.mergeSources(source, source1);
ht = BaseHashTable.add((cr, (exp, source)), iHt);
then
lowerWhenIfEqns1(condition, rest, functionTree, ht);
Expand All @@ -2069,7 +2070,7 @@ algorithm
(e, source, _,_) = Inline.inlineExp(e, (SOME(functionTree), {DAE.NORM_INLINE()}), source);
((exp, source1)) = BaseHashTable.get(cr, iHt);
exp = DAE.IFEXP(condition, e, exp);
source = DAEUtil.mergeSources(source, source1);
source = ElementSource.mergeSources(source, source1);
ht = BaseHashTable.add((cr, (exp, source)), iHt);
then
lowerWhenIfEqns1(condition, rest, functionTree, ht);
Expand All @@ -2079,7 +2080,7 @@ algorithm
(e, source, _,_) = Inline.inlineExp(e, (SOME(functionTree), {DAE.NORM_INLINE()}), source);
((exp, source1)) = BaseHashTable.get(cr, iHt);
exp = DAE.IFEXP(condition, e, exp);
source = DAEUtil.mergeSources(source, source1);
source = ElementSource.mergeSources(source, source1);
ht = BaseHashTable.add((cr, (exp, source)), iHt);
then
lowerWhenIfEqns1(condition, rest, functionTree, ht);
Expand All @@ -2089,7 +2090,7 @@ algorithm
(e, source, _,_) = Inline.inlineExp(e, (SOME(functionTree), {DAE.NORM_INLINE()}), source);
((exp, source1)) = BaseHashTable.get(cr, iHt);
exp = DAE.IFEXP(condition, e, exp);
source = DAEUtil.mergeSources(source, source1);
source = ElementSource.mergeSources(source, source1);
ht = BaseHashTable.add((cr, (exp, source)), iHt);
then
lowerWhenIfEqns1(condition, rest, functionTree, ht);
Expand All @@ -2099,7 +2100,7 @@ algorithm
(e, source, _,_) = Inline.inlineExp(e, (SOME(functionTree), {DAE.NORM_INLINE()}), source);
((exp, source1)) = BaseHashTable.get(cr, iHt);
exp = DAE.IFEXP(condition, e, exp);
source = DAEUtil.mergeSources(source, source1);
source = ElementSource.mergeSources(source, source1);
ht = BaseHashTable.add((cr, (exp, source)), iHt);
then
lowerWhenIfEqns1(condition, rest, functionTree, ht);
Expand Down Expand Up @@ -2139,7 +2140,7 @@ algorithm
equation
((exp, _)) = BaseHashTable.get(cr, iHt);
exp = DAE.IFEXP(inCond, e, exp);
source = DAEUtil.mergeSources(iSource, source);
source = ElementSource.mergeSources(iSource, source);
ht = BaseHashTable.add((cr, (exp, source)), iHt);
then
lowerWhenIfEqnsMergeNestedIf(rest, inCond, iSource, ht);
Expand Down Expand Up @@ -2435,7 +2436,7 @@ algorithm
(cond, source, _,_) = Inline.inlineExp(cond, (SOME(functionTree), {DAE.NORM_INLINE()}), source);
(msg, source, _,_) = Inline.inlineExp(msg, (SOME(functionTree), {DAE.NORM_INLINE()}), source);
(level, source, _,_) = Inline.inlineExp(level, (SOME(functionTree), {DAE.NORM_INLINE()}), source);
BackendDAEUtil.checkAssertCondition(cond, msg, level, DAEUtil.getElementSourceFileInfo(source));
BackendDAEUtil.checkAssertCondition(cond, msg, level, ElementSource.getElementSourceFileInfo(source));
alg = DAE.ALGORITHM_STMTS({DAE.STMT_ASSERT(cond, msg, level, source)});
then (inEquations, BackendDAE.ALGORITHM(0, alg, source, inCrefExpansion, BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC)::inREquations, inIEquations);

Expand All @@ -2456,7 +2457,7 @@ algorithm
// only report error if no other error is in the queue!
0 = Error.getNumErrorMessages();
str = "BackendDAECreate.lowerAlgorithm failed for:\n" + DAEDump.dumpElementsStr({inElement});
Error.addSourceMessage(Error.INTERNAL_ERROR, {str}, DAEUtil.getElementSourceFileInfo(DAEUtil.getElementSource(inElement)));
Error.addSourceMessage(Error.INTERNAL_ERROR, {str}, ElementSource.getElementSourceFileInfo(ElementSource.getElementSource(inElement)));
then fail();
end matchcontinue;
end lowerAlgorithm;
Expand Down Expand Up @@ -2799,7 +2800,7 @@ algorithm
// merge fixed, start, nominal
var = BackendVariable.mergeAliasVars(v1, v2, false, iKnVars);
// setAliasType
ops = DAEUtil.getSymbolicTransformations(source);
ops = ElementSource.getSymbolicTransformations(source);
avar = BackendVariable.mergeVariableOperations(v2, DAE.SOLVED(cr2, e1)::ops);
avar = BackendVariable.setBindExp(avar, SOME(e1));
// remove from vars
Expand All @@ -2825,7 +2826,7 @@ algorithm
// merge fixed, start, nominal
var = BackendVariable.mergeAliasVars(v2, v1, false, iKnVars);
// setAliasType
ops = DAEUtil.getSymbolicTransformations(source);
ops = ElementSource.getSymbolicTransformations(source);
avar = BackendVariable.mergeVariableOperations(v1, DAE.SOLVED(cr1, e2)::ops);
avar = BackendVariable.setBindExp(avar, SOME(e2));
// remove from vars
Expand Down Expand Up @@ -2860,7 +2861,7 @@ algorithm
// merge fixed, start, nominal
var = BackendVariable.mergeAliasVars(var, avar, false, iKnVars);
// setAliasType
ops = DAEUtil.getSymbolicTransformations(source);
ops = ElementSource.getSymbolicTransformations(source);
avar = BackendVariable.mergeVariableOperations(avar, DAE.SOLVED(acr, e)::ops);
avar = BackendVariable.setBindExp(avar, SOME(e));
avar = if b1 then BackendVariable.setVarKind(avar, BackendDAE.DUMMY_STATE()) else avar;
Expand All @@ -2886,7 +2887,7 @@ algorithm
// merge fixed, start, nominal
var = BackendVariable.mergeAliasVars(v2, v1, false, iKnVars);
// setAliasType
ops = DAEUtil.getSymbolicTransformations(source);
ops = ElementSource.getSymbolicTransformations(source);
avar = BackendVariable.mergeVariableOperations(v1, DAE.SOLVED(cr1, e2)::ops);
avar = BackendVariable.setBindExp(avar, SOME(e2));
avar = if BackendVariable.isStateVar(v1) then BackendVariable.setVarKind(avar, BackendDAE.DUMMY_STATE()) else avar;
Expand All @@ -2912,7 +2913,7 @@ algorithm
// merge fixed, start, nominal
var = BackendVariable.mergeAliasVars(v1, v2, false, iKnVars);
// setAliasType
ops = DAEUtil.getSymbolicTransformations(source);
ops = ElementSource.getSymbolicTransformations(source);
avar = BackendVariable.mergeVariableOperations(v2, DAE.SOLVED(cr2, e1)::ops);
avar = BackendVariable.setBindExp(avar, SOME(e1));
avar = if BackendVariable.isStateVar(v2) then BackendVariable.setVarKind(avar, BackendDAE.DUMMY_STATE()) else avar;
Expand All @@ -2938,7 +2939,7 @@ algorithm
// merge fixed, start, nominal
var = BackendVariable.mergeAliasVars(v2, v1, false, iKnVars);
// setAliasType
ops = DAEUtil.getSymbolicTransformations(source);
ops = ElementSource.getSymbolicTransformations(source);
avar = BackendVariable.mergeVariableOperations(v1, DAE.SOLVED(cr1, e2)::ops);
avar = BackendVariable.setBindExp(avar, SOME(e2));
avar = if BackendVariable.isStateVar(v1) then BackendVariable.setVarKind(avar, BackendDAE.DUMMY_STATE()) else avar;
Expand All @@ -2964,7 +2965,7 @@ algorithm
// merge fixed, start, nominal
var = BackendVariable.mergeAliasVars(v1, v2, false, iKnVars);
// setAliasType
ops = DAEUtil.getSymbolicTransformations(source);
ops = ElementSource.getSymbolicTransformations(source);
avar = BackendVariable.mergeVariableOperations(v2, DAE.SOLVED(cr2, e1)::ops);
avar = BackendVariable.setBindExp(avar, SOME(e1));
avar = if BackendVariable.isStateVar(v2) then BackendVariable.setVarKind(avar, BackendDAE.DUMMY_STATE()) else avar;
Expand Down

0 comments on commit 1f4723e

Please sign in to comment.