diff options
| author | azidar | 2015-09-30 09:28:08 -0700 |
|---|---|---|
| committer | azidar | 2015-09-30 09:28:08 -0700 |
| commit | 4fefd791eed5ede508a7d47a3f21bf7790d05514 (patch) | |
| tree | cd8e2d451037cd6d393ca8c41bb07e8a8fcdfafa /src | |
| parent | 794e5ada06401a79ea5545e80fb7896bd61e9481 (diff) | |
Fixed naming bug where __1 was matching. Caused lots o issues.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/stanza/ir-utils.stanza | 14 | ||||
| -rw-r--r-- | src/main/stanza/passes.stanza | 10 |
2 files changed, 14 insertions, 10 deletions
diff --git a/src/main/stanza/ir-utils.stanza b/src/main/stanza/ir-utils.stanza index a234ff81..27acedb3 100644 --- a/src/main/stanza/ir-utils.stanza +++ b/src/main/stanza/ir-utils.stanza @@ -9,6 +9,11 @@ public defmulti print-debug (o:OutputStream, e:Expression|Stmt|Type|Port|Field|M ;============== GENSYM STUFF ====================== +defn generated? (s:String) -> False|Int : + for i in 1 to length(s) - 1 find : + val sub = substring(s,i + 1) + s[i] == '_' and digits?(sub) and s[i - 1] != '_' + public defn firrtl-gensym (s:Symbol) -> Symbol : firrtl-gensym(s,HashTable<Symbol,Int>(symbol-hash)) public defn firrtl-gensym (sym-hash:HashTable<Symbol,Int>) -> Symbol : @@ -31,11 +36,11 @@ public defn firrtl-gensym (s:Symbol,sym-hash:HashTable<Symbol,Int>) -> Symbol : sym-hash[s] = 0 s val s* = to-string(s) - val i* = for i in 0 to length(s*) - 1 find : - s*[i] == '_' and digits?(substring(s*,i + 1)) - match(i*) : + val i* = generated?(s*) + val nex = match(i*) : (i:False) : get-name(s) (i:Int) : get-name(to-symbol(substring(s*,0,i))) + nex public defn get-sym-hash (m:InModule) -> HashTable<Symbol,Int> : get-sym-hash(m,list()) @@ -45,8 +50,7 @@ public defn get-sym-hash (m:InModule,keywords:Streamable<Symbol>) -> HashTable<S sym-hash[k] = 0 defn add-name (s:Symbol) -> False : val s* = to-string(s) - val i* = for i in 0 to length(s*) - 1 find : - s*[i] == '_' and digits?(substring(s*,i + 1)) + val i* = generated?(s*) match(i*) : (i:False) : if key?(sym-hash,s) : diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza index 9ac427db..5c045867 100644 --- a/src/main/stanza/passes.stanza +++ b/src/main/stanza/passes.stanza @@ -300,7 +300,7 @@ public defmethod short-name (b:RemoveSpecialChars) -> String : "rem-spec-chars" defn get-new-string (n:Char) -> String : switch {n == _} : - '_' : "_" + '_' : "__" '~' : "$A" '!' : "$B" '@' : "$C" @@ -1152,7 +1152,7 @@ defn lower-to-ground (c:Circuit) -> Circuit : ; (e:WRef) : name(e) ; (e:WSubfield) : symbol-join([get-name(exp(e)) `. name(e)]) ; (e:WIndex) : symbol-join([get-name(exp(e)) `. to-symbol(value(e))]) -; (e) : `T +; (e) : `F ; match(s) : ; (s:DecFromIndexer) : Begin $ ; if length(locs(s)) == 0 : list(EmptyStmt()) @@ -1212,7 +1212,7 @@ defn get-name (e:Expression) -> Symbol : (e:WRef) : name(e) (e:WSubfield) : symbol-join([get-name(exp(e)) `. name(e)]) (e:WIndex) : symbol-join([get-name(exp(e)) `. to-symbol(value(e))]) - (e) : `T + (e) : `F defn equality (e1:Expression,i:Int) -> Expression : DoPrim(EQUIV-OP,list(e1,UIntValue(BigIntLit(i),UnknownWidth())), @@ -2266,10 +2266,10 @@ defn split-exp (c:Circuit) : ;all-same-type? = false ;if not all-same-type? : ;val n* = - ; if n typeof False : firrtl-gensym(`T,sh) + ; if n typeof False : firrtl-gensym(`F,sh) ; else : firrtl-gensym(symbol-join([n as Symbol temp-delin]),sh) val n* = - if n typeof False : firrtl-gensym(`T,sh) + if n typeof False : firrtl-gensym(`F,sh) else : firrtl-gensym(n as Symbol,sh) add(v,DefNode(info,n*,map(split-exp-e{_,n,info},e))) WRef(n*,type(e),NodeKind(),UNKNOWN-GENDER) |
