diff options
| author | azidar | 2016-01-15 14:34:18 -0800 |
|---|---|---|
| committer | azidar | 2016-01-16 14:28:18 -0800 |
| commit | a5c850beb0568c09b581f925aa5ca3bf561ac974 (patch) | |
| tree | 53c6d3902021f1ce9bb2c9fb302e9198cea691b9 /src | |
| parent | 03cf32b5e17eb306e8fe681ef245b5f528306e61 (diff) | |
Added hashed on get flip
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/stanza/ir-utils.stanza | 6 | ||||
| -rw-r--r-- | src/main/stanza/passes.stanza | 48 |
2 files changed, 34 insertions, 20 deletions
diff --git a/src/main/stanza/ir-utils.stanza b/src/main/stanza/ir-utils.stanza index 14383977..7a9cff31 100644 --- a/src/main/stanza/ir-utils.stanza +++ b/src/main/stanza/ir-utils.stanza @@ -142,6 +142,12 @@ public defn exp-hash (e:Expression) -> Int : public defn type-hash (t:Type) -> Int : symbol-hash(to-symbol(to-string(t))) +public defn list-hash (l:List) -> Int : + turn-off-debug(false) + val i = symbol-hash(to-symbol(string-join(map(to-string,l)))) + turn-on-debug(false) + i + ;============= Useful functions ============== public defn create-mask (n:Symbol,dt:Type) -> Field : Field{n,DEFAULT,_} $ match(dt) : diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza index a7b647d2..fea1a033 100644 --- a/src/main/stanza/passes.stanza +++ b/src/main/stanza/passes.stanza @@ -850,7 +850,7 @@ public defmethod short-name (b:ExpandConnects) -> String : "expand-connects" defn get-size (e:Expression) -> Int : get-size(type(e)) defn get-size (t:Type) -> Int : - match(t) : + val x = match(t) : (t:BundleType) : var sum = 0 for f in fields(t) do : @@ -858,26 +858,34 @@ defn get-size (t:Type) -> Int : sum (t:VectorType) : size(t) * get-size(type(t)) (t) : 1 + x + +val hashed-get-flip = HashTable<List,Flip>(list-hash) defn get-flip (t:Type, i:Int, f:Flip) -> Flip : - if i >= get-size(t) : error("Shouldn't be here") - match(t) : - (t:UIntType|SIntType|ClockType) : f - (t:BundleType) : label<Flip> ret : - var n = i - for x in fields(t) do : - if n < get-size(type(x)) : - ret(get-flip(type(x),n,flip(x) * f)) - else : - n = n - get-size(type(x)) - error("Shouldn't be here") - (t:VectorType) : label<Flip> ret : - var n = i - for j in 0 to size(t) do : - if n < get-size(type(t)) : - ret(get-flip(type(t),n,f)) - else : - n = n - get-size(type(t)) - error("Shouldn't be here") + if key?(hashed-get-flip,list(t,i,f)) : hashed-get-flip[list(t,i,f)] + else : + if i >= get-size(t) : error("Shouldn't be here") + val x = match(t) : + (t:UIntType|SIntType|ClockType) : f + (t:BundleType) : label<Flip> ret : + var n = i + for x in fields(t) do : + if n < get-size(type(x)) : + ret(get-flip(type(x),n,flip(x) * f)) + else : + n = n - get-size(type(x)) + error("Shouldn't be here") + (t:VectorType) : label<Flip> ret : + var n = i + for j in 0 to size(t) do : + if n < get-size(type(t)) : + ret(get-flip(type(t),n,f)) + else : + n = n - get-size(type(t)) + error("Shouldn't be here") + hashed-get-flip[list(t,i,f)] = x + x + defn get-point (e:Expression) -> Int : match(e) : (e:WRef) : 0 |
