Skip to content

Commit

Permalink
Revert "Improve handling of noEvent (#7871)" (#7876)
Browse files Browse the repository at this point in the history
- Revert #7871 since it causes regressions and seemingly no
  improvements.
  • Loading branch information
perost committed Sep 7, 2021
1 parent c442389 commit 371f2e1
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 108 deletions.
5 changes: 0 additions & 5 deletions OMCompiler/Compiler/NFFrontEnd/NFBuiltinFuncs.mo
Expand Up @@ -294,11 +294,6 @@ constant Function SUM = Function.FUNCTION(Path.IDENT("sum"),
Type.UNKNOWN(), DAE.FUNCTION_ATTRIBUTES_BUILTIN, {}, listArray({}),
Pointer.createImmutable(FunctionStatus.BUILTIN), Pointer.createImmutable(0));

constant Function NO_EVENT = Function.FUNCTION(Path.IDENT("noEvent"),
InstNode.EMPTY_NODE(), {}, {}, {}, {},
Type.UNKNOWN(), DAE.FUNCTION_ATTRIBUTES_BUILTIN, {}, listArray({}),
Pointer.createImmutable(FunctionStatus.BUILTIN), Pointer.createImmutable(0));


constant Component CLOCK_COMPONENT = Component.TYPED_COMPONENT(NFInstNode.EMPTY_NODE(),
Type.CLOCK(), NFBinding.EMPTY_BINDING, NFBinding.EMPTY_BINDING, NFComponent.DEFAULT_ATTR, NONE(), NONE(), AbsynUtil.dummyInfo);
Expand Down
32 changes: 0 additions & 32 deletions OMCompiler/Compiler/NFFrontEnd/NFCall.mo
Expand Up @@ -1041,14 +1041,6 @@ public
then
Expression.CALL(call);

// For noEvent we can type cast the argument instead of the whole call.
case "noEvent"
algorithm
call.arguments := list(Expression.typeCast(a, ty) for a in call.arguments);
call.ty := cast_ty;
then
Expression.CALL(call);

else Expression.CAST(cast_ty, callExp);
end match;

Expand Down Expand Up @@ -2209,30 +2201,6 @@ public
call := TYPED_REDUCTION(fn, ty, var, purity, arg, iters, default_exp, fold_tuple);
end makeTypedReduction;

function isEventTriggeringFunction
input Call call;
output Boolean triggering;
protected
Absyn.Path fn_name;
algorithm
fn_name := functionName(call);
triggering := AbsynUtil.pathIsIdent(fn_name);

if not triggering then
return;
end if;

triggering := match AbsynUtil.pathFirstIdent(fn_name)
case "div" then true;
case "mod" then true;
case "rem" then true;
case "ceil" then true;
case "floor" then true;
case "integer" then true;
else false;
end match;
end isEventTriggeringFunction;

protected
function reductionDefaultValue
input Function fn;
Expand Down
11 changes: 0 additions & 11 deletions OMCompiler/Compiler/NFFrontEnd/NFExpression.mo
Expand Up @@ -4945,16 +4945,5 @@ public
end match;
end hasNonArrayIteratorSubscript;

function isEventTriggering
input Expression exp;
output Boolean triggering;
algorithm
triggering := match exp
case RELATION() then true;
case CALL() then Call.isEventTriggeringFunction(exp.call);
else false;
end match;
end isEventTriggering;

annotation(__OpenModelica_Interface="frontend");
end NFExpression;
42 changes: 0 additions & 42 deletions OMCompiler/Compiler/NFFrontEnd/NFSimplifyExp.mo
Expand Up @@ -55,7 +55,6 @@ import ErrorExt;
import Flags;
import Debug;
import MetaModelica.Dangerous.listReverseInPlace;
import BuiltinFuncs = NFBuiltinFuncs;

public

Expand Down Expand Up @@ -245,7 +244,6 @@ algorithm
case "homotopy" then simplifyHomotopy(args, call);
case "max" guard listLength(args) == 1 then simplifyReducedArrayConstructor(listHead(args), call);
case "min" guard listLength(args) == 1 then simplifyReducedArrayConstructor(listHead(args), call);
case "noEvent" then simplifyNoEvent(listHead(args), call);
case "ones" then simplifyFill(Expression.INTEGER(1), args, call);
case "product" then simplifySumProduct(listHead(args), call, isSum = false);
case "sum" then simplifySumProduct(listHead(args), call, isSum = true);
Expand Down Expand Up @@ -382,46 +380,6 @@ algorithm
end match;
end simplifyHomotopy;

function simplifyNoEvent
input Expression arg;
input Call call;
output Expression exp;
algorithm
// If the argument is an event triggering expression, do nothing.
if Expression.isEventTriggering(arg) then
exp := Expression.CALL(call);
return;
end if;

// Otherwise push noEvent down to only where it's required.
exp := Expression.map(arg, stripNoEvent);
exp := Expression.map(arg, addNoEvent);
end simplifyNoEvent;

function stripNoEvent
input Expression exp;
output Expression outExp;
algorithm
outExp := match exp
case Expression.CALL()
guard Call.isNamed(exp.call, "noEvent")
then listHead(Call.arguments(exp.call));
else exp;
end match;
end stripNoEvent;

function addNoEvent
input Expression exp;
output Expression outExp;
algorithm
if Expression.isEventTriggering(exp) then
outExp := Expression.CALL(Call.makeTypedCall(NFBuiltinFuncs.NO_EVENT, {exp},
Expression.variability(exp), Expression.purity(exp), Expression.typeOf(exp)));
else
outExp := exp;
end if;
end addNoEvent;

function simplifyArrayConstructor
input Call call;
output Expression outExp;
Expand Down
1 change: 0 additions & 1 deletion testsuite/flattening/modelica/scodeinst/Makefile
Expand Up @@ -733,7 +733,6 @@ MultiInheritanceRedeclare1.mo \
MultiInheritanceRedeclare2.mo \
NoEvent1.mo \
NoEvent2.mo \
NoEvent3.mo \
NonConnectorFlow1.mo \
NonexistentRedeclareModifier1.mo \
NonexistentRedeclareModifier2.mo \
Expand Down
17 changes: 0 additions & 17 deletions testsuite/flattening/modelica/scodeinst/NoEvent3.mo

This file was deleted.

0 comments on commit 371f2e1

Please sign in to comment.