Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit eb0909d

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix function vectorization/cast conflict.
- Add the base type of match to vectorized functions, so that it's possible to differentiate between vectorized functions with exact or type cast arguments and choose the correct one. Belonging to [master]: - #2635 - OpenModelica/OpenModelica-testsuite#1025
1 parent cbc69f9 commit eb0909d

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Compiler/NFFrontEnd/NFCall.mo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,10 @@ protected
970970
if listLength(matchedFunctions) > 1 then
971971
exactMatches := MatchedFunction.getExactMatches(matchedFunctions);
972972

973+
if listEmpty(exactMatches) then
974+
exactMatches := MatchedFunction.getExactVectorizedMatches(matchedFunctions);
975+
end if;
976+
973977
if listLength(exactMatches) > 1 then
974978
Error.addSourceMessage(Error.AMBIGUOUS_MATCHING_FUNCTIONS_NFINST,
975979
{typedString(call), Function.candidateFuncListString(list(mfn.func for mfn in matchedFunctions))}, info);

Compiler/NFFrontEnd/NFFunction.mo

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ uniontype FunctionMatchKind
134134
// Instead they are added to each call as is.
135135
// This list represents which args should be vectorized.
136136
list<Boolean> is_vectorized;
137+
FunctionMatchKind baseMatch;
137138
end VECTORIZED;
138139

139140
record NOT_COMPATIBLE end NOT_COMPATIBLE;
@@ -168,6 +169,16 @@ uniontype FunctionMatchKind
168169
end match;
169170
end isVectorized;
170171

172+
function isExactVectorized
173+
input FunctionMatchKind mk;
174+
output Boolean b;
175+
algorithm
176+
b := match mk
177+
case VECTORIZED(baseMatch = EXACT()) then true;
178+
else false;
179+
end match;
180+
end isExactVectorized;
181+
171182
end FunctionMatchKind;
172183

173184
constant FunctionMatchKind EXACT_MATCH = FunctionMatchKind.EXACT();
@@ -192,6 +203,12 @@ uniontype MatchedFunction
192203
output list<MatchedFunction> outFuncs = list(mf for mf guard(FunctionMatchKind.isExact(mf.mk)) in matchedFunctions);
193204
end getExactMatches;
194205

206+
function getExactVectorizedMatches
207+
input list<MatchedFunction> matchedFunctions;
208+
output list<MatchedFunction> outFuncs =
209+
list(mf for mf guard(FunctionMatchKind.isExactVectorized(mf.mk)) in matchedFunctions);
210+
end getExactVectorizedMatches;
211+
195212
function isVectorized
196213
input MatchedFunction mf;
197214
output Boolean b = FunctionMatchKind.isVectorized(mf.mk);
@@ -736,6 +753,7 @@ uniontype Function
736753
list<Dimension> argdims, compdims, vectdims, tmpdims, outvectdims;
737754
Boolean has_cast;
738755
list<Boolean> vectorized;
756+
FunctionMatchKind base_mk = EXACT_MATCH;
739757
algorithm
740758

741759
checked_args := {};
@@ -806,13 +824,19 @@ uniontype Function
806824
return;
807825
end if;
808826

827+
if TypeCheck.isCastMatch(matchKind) then
828+
base_mk := CAST_MATCH;
829+
elseif TypeCheck.isGenericMatch(matchKind) then
830+
base_mk := GENERIC_MATCH;
831+
end if;
832+
809833
checked_args := (margexp,mty,var) :: checked_args;
810834
idx := idx + 1;
811835
end for;
812836

813837
correct := true;
814838
args := listReverse(checked_args);
815-
funcMatchKind := VECTORIZED(vectdims, listReverse(vectorized));
839+
funcMatchKind := VECTORIZED(vectdims, listReverse(vectorized), base_mk);
816840
end matchArgsVectorize;
817841

818842
function matchArgs

0 commit comments

Comments
 (0)