Changeset 20893ab in OpenModelica
- Timestamp:
- 2021-04-06T15:07:08+02:00 (3 years ago)
- Children:
- 2d459fc8
- Parents:
- a94b02e4
- Location:
- OMCompiler/Compiler
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBRemoveSimpleEquations.mo
red22b43 r20893ab 2 2 * This file is part of OpenModelica. 3 3 * 4 * Copyright (c) 1998-202 0, Open Source Modelica Consortium (OSMC),4 * Copyright (c) 1998-2021, Open Source Modelica Consortium (OSMC), 5 5 * c/o Linköpings universitet, Department of Computer and Information Science, 6 6 * SE-58183 Linköping, Sweden. … … 46 46 import ComponentRef = NFComponentRef; 47 47 import Expression = NFExpression; 48 import HashSet = NFHashSet;49 import HashTableCrToExp = NFHashTableCrToExp;50 48 import Operator = NFOperator; 51 49 import Variable = NFVariable; -
OMCompiler/Compiler/NBackEnd/NBReplacements.mo
r6cc3f28b r20893ab 2 2 * This file is part of OpenModelica. 3 3 * 4 * Copyright (c) 1998-202 0, Open Source Modelica Consortium (OSMC),4 * Copyright (c) 1998-2021, Open Source Modelica Consortium (OSMC), 5 5 * c/o Linköpings universitet, Department of Computer and Information Science, 6 6 * SE-58183 Linköping, Sweden. … … 50 50 import Expression = NFExpression; 51 51 import NFFlatten.FunctionTreeImpl; 52 import HashSet = NFHashSet;53 52 import HashTableCrToExp = NFHashTableCrToExp; 54 53 import HashTableCrToLst = NFHashTable3; … … 58 57 // Backend imports 59 58 import BVariable = NBVariable; 60 import EqData = NBEquation.EqData; 61 import Equation = NBEquation.Equation; 62 import EquationPointers = NBEquation.EquationPointers; 63 import HashTableCrToCrEqLst = NBHashTableCrToCrEqLst; 59 import NBEquation.{EqData, Equation, EquationPointers}; 64 60 import Solve = NBSolve; 65 61 import StrongComponent = NBStrongComponent; 66 import VarData = NBVariable.VarData; 67 import VariablePointers = NBVariable.VariablePointers; 62 import NBVariable.{VarData, VariablePointers}; 68 63 69 64 // Util imports … … 261 256 function empty 262 257 "Returns an empty set of replacement rules" 263 input Integer size = BaseHashTable.defaultBucketSize;264 input Boolean simple = false;265 output Replacements variableReplacements;266 protected267 HashTableCrToExp.HashTable replacements;268 HashTableCrToCrEqLst.HashTable groups;269 algorithm270 // ToDo: remove all those sized calls, they are just duplicate functions271 replacements := HashTableCrToExp.emptyHashTableSized(size);272 groups := HashTableCrToCrEqLst.emptyHashTableSized(size);273 variableReplacements := SIMPLE_REPLACEMENTS(replacements, groups);274 end empty;275 276 function add277 input output Replacements replacements;278 input Expression src "for simple replacements src and dst are not yet determined";279 input Expression dst;280 input Equation eqn;281 algorithm282 // new (a -> b), existing (b -> c)283 // new (a -> b), existing (a -> c) (FAIL or REPLACE?)284 // new (a -> b), existing (c -> a) (how to detect for f(.., a, ...)?)285 replacements := match replacements286 case SIMPLE_REPLACEMENTS() algorithm287 then replacements;288 289 else algorithm290 Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed adding replacement for expressions: "291 + "\n\t 1. " + Expression.toString(src) + "\n\t 2. " + Expression.toString(dst) + "\n In equation: \n\t"292 + Equation.toString(eqn)});293 then fail();294 end match;295 end add;296 297 function addStatic298 input output Replacements repl;299 input ComponentRef src;300 input Expression dst;301 input Equation eqn;302 algorithm303 repl := match repl304 case SIMPLE_REPLACEMENTS() guard(not BaseHashTable.hasKey(src, repl.replacements)) algorithm305 repl.replacements := BaseHashTable.add((src, dst), repl.replacements);306 then repl;307 308 // need forward replacement309 310 else algorithm311 Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed adding replacement for componentRef: "312 + "\n\t - " + ComponentRef.toString(src) + "\n In equation: \n\t" + Equation.toString(eqn)});313 then fail();314 end match;315 316 end addStatic;317 318 function empty319 "Returns an empty set of replacement rules"320 258 output Replacements variableReplacements; 321 259 input Integer size = BaseHashTable.defaultBucketSize; -
OMCompiler/Compiler/NBackEnd/NBSolve.mo
refb3afa r20893ab 2 2 * This file is part of OpenModelica. 3 3 * 4 * Copyright (c) 1998-202 0, Open Source Modelica Consortium (OSMC),4 * Copyright (c) 1998-2021, Open Source Modelica Consortium (OSMC), 5 5 * c/o Linköpings universitet, Department of Computer and Information Science, 6 6 * SE-58183 Linköping, Sweden. … … 41 41 import ComponentRef = NFComponentRef; 42 42 import Expression = NFExpression; 43 import FunctionTree =NFFlatten.FunctionTree;43 import NFFlatten.FunctionTree; 44 44 import Operator = NFOperator; 45 45 import SimplifyExp = NFSimplifyExp; -
OMCompiler/Compiler/NBackEnd/NBStrongComponent.mo
ree2d45b4 r20893ab 2 2 * This file is part of OpenModelica. 3 3 * 4 * Copyright (c) 1998-202 0, Open Source Modelica Consortium (OSMC),4 * Copyright (c) 1998-2021, Open Source Modelica Consortium (OSMC), 5 5 * c/o Linköpings universitet, Department of Computer and Information Science, 6 6 * SE-58183 Linköping, Sweden. … … 50 50 import NBEquation.Equation; 51 51 import NBEquation.EquationAttributes; 52 import HashTableCrToCrLst = NBHashTableCrToCrLst;53 52 import Matching = NBMatching; 54 53 import Tearing = NBTearing; … … 255 254 function getDependentCrefs 256 255 "Collects dependent crefs in current comp and saves them in the 257 HashTable. Saves both directions."256 unordered map. Saves both directions." 258 257 input StrongComponent comp "strong component to be analyzed"; 259 258 input UnorderedMap<ComponentRef, list<ComponentRef>> map "unordered map to save the dependencies"; -
OMCompiler/Compiler/NBackEnd/NBVariable.mo
rc95dc3ca r20893ab 2 2 * This file is part of OpenModelica. 3 3 * 4 * Copyright (c) 1998-202 0, Open Source Modelica Consortium (OSMC),4 * Copyright (c) 1998-2021, Open Source Modelica Consortium (OSMC), 5 5 * c/o Linköpings universitet, Department of Computer and Information Science, 6 6 * SE-58183 Linköping, Sweden. … … 46 46 //NF Imports 47 47 import BackendExtension = NFBackendExtension; 48 import BackendInfo =NFBackendExtension.BackendInfo;49 import Binding =NFBinding.Binding;48 import NFBackendExtension.BackendInfo; 49 import NFBinding.Binding; 50 50 import Component = NFComponent; 51 51 import ComponentRef = NFComponentRef; 52 52 import Dimension = NFDimension; 53 53 import Expression = NFExpression; 54 import InstNode =NFInstNode.InstNode;54 import NFInstNode.InstNode; 55 55 import Prefixes = NFPrefixes; 56 56 import Subscript = NFSubscript; 57 57 import Type = NFType; 58 58 import Variable = NFVariable; 59 import VariableKind =NFBackendExtension.VariableKind;59 import NFBackendExtension.VariableKind; 60 60 61 61 // Backend Imports … … 1313 1313 end getMarkedVars; 1314 1314 1315 function compress "O(n)1315 function compress "O(n) 1316 1316 Reorders the elements in order to remove all the gaps. 1317 1317 Be careful: This changes the indices of the elements. … … 1338 1338 lastUsedIndex := lastUsedIndex-1; 1339 1339 end while; 1340 // udpate HashTable element1340 // udpate hash table element 1341 1341 UnorderedMap.add(getVarName(moved_var), i, vars.map); 1342 1342 end if; -
OMCompiler/Compiler/boot/LoadCompilerSources.mos
raddc6bc r20893ab 314 314 "../NBackEnd/Util/NBGraphUtil.mo", 315 315 "../NBackEnd/Util/NBHashTableCrToCr.mo", 316 "../NBackEnd/Util/NBHashTableCrToCrEqLst.mo",317 316 "../NBackEnd/Util/NBHashTableCrToCrLst.mo", 318 317
Note: See TracChangeset
for help on using the changeset viewer.