Skip to content

Commit

Permalink
Fix *OptModules+ flags
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel committed Nov 12, 2015
1 parent ca73a56 commit 44a6be4
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -7202,16 +7202,14 @@ algorithm
if not Flags.getConfigBool(Flags.FORCE_RECOMMENDED_ORDERING) and not listEmpty(Flags.getConfigStringList(Flags.PRE_OPT_MODULES_ADD)) then
Error.addCompilerError("It's not possible to combine following flags: --preOptModules+=... and --" + Flags.configFlagName(Flags.FORCE_RECOMMENDED_ORDERING) + "=false");
fail();
else
preOptModules := listAppend(preOptModules, Flags.getConfigStringList(Flags.PRE_OPT_MODULES_ADD));
end if;

if not Flags.getConfigBool(Flags.FORCE_RECOMMENDED_ORDERING) and not listEmpty(Flags.getConfigStringList(Flags.POST_OPT_MODULES_SUB)) then
Error.addCompilerError("It's not possible to combine following flags: --postOptModules-=... and --" + Flags.configFlagName(Flags.FORCE_RECOMMENDED_ORDERING) + "=false");
fail();
end if;

outPreOptModules := selectOptModules(preOptModules, Flags.getConfigStringList(Flags.PRE_OPT_MODULES_SUB), allPreOptimizationModules());
outPreOptModules := selectOptModules(preOptModules, Flags.getConfigStringList(Flags.PRE_OPT_MODULES_ADD), Flags.getConfigStringList(Flags.PRE_OPT_MODULES_SUB), allPreOptimizationModules());
end getPreOptModules;

public function getPostOptModulesString
Expand All @@ -7232,16 +7230,14 @@ algorithm
if not Flags.getConfigBool(Flags.FORCE_RECOMMENDED_ORDERING) and not listEmpty(Flags.getConfigStringList(Flags.POST_OPT_MODULES_ADD)) then
Error.addCompilerError("It's not possible to combine following flags: --postOptModules+=... and --" + Flags.configFlagName(Flags.FORCE_RECOMMENDED_ORDERING) + "=false");
fail();
else
postOptModules := listAppend(postOptModules, Flags.getConfigStringList(Flags.POST_OPT_MODULES_ADD));
end if;

if not Flags.getConfigBool(Flags.FORCE_RECOMMENDED_ORDERING) and not listEmpty(Flags.getConfigStringList(Flags.POST_OPT_MODULES_SUB)) then
Error.addCompilerError("It's not possible to combine following flags: --postOptModules-=... and --" + Flags.configFlagName(Flags.FORCE_RECOMMENDED_ORDERING) + "=false");
fail();
end if;

outPostOptModules := selectOptModules(postOptModules, Flags.getConfigStringList(Flags.POST_OPT_MODULES_SUB), allPostOptimizationModules());
outPostOptModules := selectOptModules(postOptModules, Flags.getConfigStringList(Flags.POST_OPT_MODULES_ADD), Flags.getConfigStringList(Flags.POST_OPT_MODULES_SUB), allPostOptimizationModules());
end getPostOptModules;

public function getInitOptModules
Expand All @@ -7256,21 +7252,20 @@ algorithm
if not Flags.getConfigBool(Flags.FORCE_RECOMMENDED_ORDERING) and not listEmpty(Flags.getConfigStringList(Flags.INIT_OPT_MODULES_ADD)) then
Error.addCompilerError("It's not possible to combine following flags: --initOptModules+=... and --" + Flags.configFlagName(Flags.FORCE_RECOMMENDED_ORDERING) + "=false");
fail();
else
initOptModules := listAppend(initOptModules, Flags.getConfigStringList(Flags.INIT_OPT_MODULES_ADD));
end if;

if not Flags.getConfigBool(Flags.FORCE_RECOMMENDED_ORDERING) and not listEmpty(Flags.getConfigStringList(Flags.INIT_OPT_MODULES_SUB)) then
Error.addCompilerError("It's not possible to combine following flags: --initOptModules-=... and --" + Flags.configFlagName(Flags.FORCE_RECOMMENDED_ORDERING) + "=false");
fail();
end if;

outInitOptModules := selectOptModules(initOptModules, Flags.getConfigStringList(Flags.INIT_OPT_MODULES_SUB), allInitOptimizationModules());
outInitOptModules := selectOptModules(initOptModules, Flags.getConfigStringList(Flags.INIT_OPT_MODULES_ADD), Flags.getConfigStringList(Flags.INIT_OPT_MODULES_SUB), allInitOptimizationModules());
end getInitOptModules;

protected function selectOptModules
input list<String> inStrOptModules;
input list<String> inDisabledModules;
input list<String> inEnabledModules = {};
input list<String> inDisabledModules = {};
input list<tuple<BackendDAEFunc.optimizationModule, String>> inOptModules;
output list<tuple<BackendDAEFunc.optimizationModule, String>> outOptModules = {};
protected
Expand Down Expand Up @@ -7300,6 +7295,17 @@ algorithm
end if;
end for;

for name in inEnabledModules loop
index := getModuleIndex(name, inOptModules);

if index <> -1 then
activeModules[index] := true;
else
Error.addCompilerError("'" + name + "' is not a valid optimization module. Please check the flags carefully.");
fail();
end if;
end for;

for name in inDisabledModules loop
index := getModuleIndex(name, inOptModules);

Expand Down

0 comments on commit 44a6be4

Please sign in to comment.