Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Started the implementation of sharing constant literals
- It is a one-pass phase on list<DAE.Function>, right before code generation starts - For now, it is limited to string constants (not even boxed strings...) - It is also limited to function code (not simulations) as equation-systems in general don't use MetaModelica types, which will benefit the most from this change (gcc already shares string constants) git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7548 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Showing
10 changed files
with
224 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
encapsulated package HashTableExpToIndex " | ||
This file is an extension to OpenModelica. | ||
|
||
Copyright (c) 2007 MathCore Engineering AB | ||
|
||
All rights reserved. | ||
|
||
RCS: $Id$ | ||
|
||
" | ||
|
||
/* Below is the instance specific code. For each hashtable the user must define: | ||
Key - The key used to uniquely define elements in a hashtable | ||
Value - The data to associate with each key | ||
hashFunc - A function that maps a key to a positive integer. | ||
keyEqual - A comparison function between two keys, returns true if equal. | ||
*/ | ||
|
||
/* HashTable instance specific code */ | ||
|
||
public import BaseHashTable; | ||
public import DAE; | ||
protected import Expression; | ||
protected import ExpressionDump; | ||
|
||
public type Key = DAE.Exp; | ||
public type Value = Integer; | ||
|
||
public type HashTableCrefFunctionsType = tuple<FuncHashCref,FuncCrefEqual,FuncCrefStr,FuncExpStr>; | ||
public type HashTable = tuple< | ||
array<list<tuple<Key,Integer>>>, | ||
tuple<Integer,Integer,array<Option<tuple<Key,Value>>>>, | ||
Integer, | ||
Integer, | ||
HashTableCrefFunctionsType | ||
>; | ||
|
||
partial function FuncHashCref | ||
input Key cr; | ||
output Integer res; | ||
end FuncHashCref; | ||
|
||
partial function FuncCrefEqual | ||
input Key cr1; | ||
input Key cr2; | ||
output Boolean res; | ||
end FuncCrefEqual; | ||
|
||
partial function FuncCrefStr | ||
input Key cr; | ||
output String res; | ||
end FuncCrefStr; | ||
|
||
partial function FuncExpStr | ||
input Value exp; | ||
output String res; | ||
end FuncExpStr; | ||
|
||
protected function hashFunc | ||
"Calculates a hash value for Key" | ||
input Key cr; | ||
output Integer res; | ||
String crstr; | ||
algorithm | ||
crstr := ExpressionDump.printExpStr(cr); | ||
res := stringHashDjb2(crstr); | ||
end hashFunc; | ||
|
||
public function emptyHashTable | ||
" | ||
Returns an empty HashTable. | ||
Using the bucketsize 1000 and array size 100. | ||
" | ||
output HashTable hashTable; | ||
algorithm | ||
hashTable := emptyHashTableSized(BaseHashTable.defaultBucketSize); | ||
end emptyHashTable; | ||
|
||
public function emptyHashTableSized | ||
" | ||
Returns an empty HashTable. | ||
Using the bucketsize size and arraysize size/10. | ||
" | ||
input Integer size; | ||
output HashTable hashTable; | ||
algorithm | ||
hashTable := BaseHashTable.emptyHashTableWork(size,intDiv(size,10),(hashFunc,Expression.expEqual,ExpressionDump.printExpStr,intString)); | ||
end emptyHashTableSized; | ||
|
||
end HashTableExpToIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.