aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorazidar2015-08-03 11:51:50 -0700
committerazidar2015-08-03 11:51:50 -0700
commit6f098fb5328ebfe3137ff449e9905bdf0f668859 (patch)
tree92c5386f1696920dd9667ffa96f442fce1c44c3c /src
parent342e7760582280d6106a57891d9ea3374551bf77 (diff)
Fixed performance bug in Split Expressions. Changed delin for connect indexed. Fixed various broken tests.
Diffstat (limited to 'src')
-rw-r--r--src/main/stanza/firrtl-ir.stanza1
-rw-r--r--src/main/stanza/ir-utils.stanza29
-rw-r--r--src/main/stanza/passes.stanza35
3 files changed, 37 insertions, 28 deletions
diff --git a/src/main/stanza/firrtl-ir.stanza b/src/main/stanza/firrtl-ir.stanza
index 8de688d7..79057791 100644
--- a/src/main/stanza/firrtl-ir.stanza
+++ b/src/main/stanza/firrtl-ir.stanza
@@ -11,6 +11,7 @@ public val bundle-expand-delin = `$
public val module-expand-delin = `$
public val scope-delin = `%
public val temp-delin = `!
+public val sub-delin = `*
public val inline-delin = `^
public definterface PortDirection
diff --git a/src/main/stanza/ir-utils.stanza b/src/main/stanza/ir-utils.stanza
index 7bb7ff01..f3fb5a53 100644
--- a/src/main/stanza/ir-utils.stanza
+++ b/src/main/stanza/ir-utils.stanza
@@ -10,22 +10,27 @@ public defmulti print-debug (o:OutputStream, e:Expression|Stmt|Type|Port|Field|M
;============== GENSYM STUFF ======================
-public defn firrtl-gensym (s:Symbol) -> Symbol : firrtl-gensym(s,HashTable<Symbol,Int>(symbol-hash))
-
+public defn firrtl-gensym (s:Symbol) -> Symbol :
+ firrtl-gensym(s,HashTable<Symbol,Int>(symbol-hash))
public defn firrtl-gensym (s:Symbol,sym-hash:HashTable<Symbol,Int>) -> Symbol :
- defn get-new (s:Symbol, i:Int) -> Symbol :
- val s* = symbol-join([s i])
- if key?(sym-hash,s*) :
- get-new(s,i + 1)
- else :
- sym-hash[s] = i
- sym-hash[s*] = 0
- s*
- get-new(s,0)
-
+ firrtl-gensym(s,sym-hash,temp-delin)
public defn firrtl-gensym (sym-hash:HashTable<Symbol,Int>) -> Symbol :
firrtl-gensym(`gen,sym-hash)
+public defn firrtl-gensym (s:Symbol,sym-hash:HashTable<Symbol,Int>,delin:Symbol) -> Symbol :
+ val num = get?(sym-hash,s,0)
+ sym-hash[s] = num + 1
+ symbol-join([s delin num])
+ ;defn get-new (s:Symbol, i:Int) -> Symbol :
+ ; val s* = symbol-join([s i])
+ ; if key?(sym-hash,s*) :
+ ; get-new(s,i + 1)
+ ; else :
+ ; sym-hash[s] = i
+ ; sym-hash[s*] = 0
+ ; s*
+ ;get-new(s,0)
+
public defn get-sym-hash (m:InModule) -> HashTable<Symbol,Int> :
val sym-hash = HashTable<Symbol,Int>(symbol-hash)
defn add-name (s:Symbol) -> False :
diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza
index d5034f8a..4b99a4f8 100644
--- a/src/main/stanza/passes.stanza
+++ b/src/main/stanza/passes.stanza
@@ -1140,15 +1140,15 @@ defn expand-connect-indexed-stmt (s: Stmt,sh:HashTable<Symbol,Int>) -> Stmt :
DoPrim(EQUIV-OP,list(e1,e2),List(),UIntType(UnknownWidth()))
defn get-name (e:Expression) -> Symbol :
match(e) :
- (e:WRef) : symbol-join([name(e) temp-delin])
- (e:WSubfield) : symbol-join([get-name(exp(e)) `. name(e) temp-delin])
- (e:WIndex) : symbol-join([get-name(exp(e)) `. to-symbol(value(e)) temp-delin])
+ (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
match(s) :
(s:ConnectToIndexed) : Begin $
if length(locs(s)) == 0 : list(EmptyStmt())
else :
- val ref = WRef(firrtl-gensym(get-name(index(s)),sh),type(index(s)),NodeKind(),UNKNOWN-GENDER)
+ val ref = WRef(firrtl-gensym(get-name(index(s)),sh,sub-delin),type(index(s)),NodeKind(),UNKNOWN-GENDER)
append(
list(DefNode(info(s),name(ref),index(s)))
to-list $
@@ -1162,7 +1162,7 @@ defn expand-connect-indexed-stmt (s: Stmt,sh:HashTable<Symbol,Int>) -> Stmt :
(s:ConnectFromIndexed) : Begin $
if length(exps(s)) == 0 : list(EmptyStmt())
else :
- val ref = WRef(firrtl-gensym(get-name(index(s)),sh),type(index(s)),NodeKind(),UNKNOWN-GENDER)
+ val ref = WRef(firrtl-gensym(get-name(index(s)),sh,sub-delin),type(index(s)),NodeKind(),UNKNOWN-GENDER)
append(
list(Connect(info(s),loc(s),head(exps(s))),DefNode(info(s),name(ref),index(s)))
to-list $
@@ -2165,20 +2165,23 @@ defn full-name (e:Expression) -> Symbol|False :
defn split-exp (c:Circuit) :
defn split-exp-s (s:Stmt,v:Vector<Stmt>,sh:HashTable<Symbol,Int>) -> False :
defn split-exp-e (e:Expression,n:Symbol|False,info:FileInfo) -> Expression :
- match(map(split-exp-e{_,n,info},e)) :
+ match(e) :
(e:DoPrim) :
- var all-same-type? = true
- for x in args(e) do :
- if type(x) != type(e) : all-same-type? = false
- all-same-type? = false
- if not all-same-type? :
+ ;var all-same-type? = true
+ ;for x in args(e) do :
+ ; if type(x) != type(e) : all-same-type? = false
+ ;all-same-type? = false
+ ;if not all-same-type? :
+ ;val n* =
+ ; if n typeof False : firrtl-gensym(`T,sh)
+ ; else : firrtl-gensym(symbol-join([n as Symbol temp-delin]),sh)
val n* =
- if n typeof False : firrtl-gensym(`T,sh)
- else : firrtl-gensym(symbol-join([n as Symbol temp-delin]),sh)
- add(v,DefNode(info,n*,e))
+ if n typeof False : firrtl-gensym(`T,sh,temp-delin)
+ else : firrtl-gensym(n as Symbol,sh,temp-delin)
+ add(v,DefNode(info,n*,map(split-exp-e{_,n,info},e)))
WRef(n*,type(e),NodeKind(),UNKNOWN-GENDER)
- else : e
- (e) : e
+ ;else : e
+ (e) : map(split-exp-e{_,n,info},e)
defn f (s:Stmt) -> False: split-exp-s(s,v,sh)
match(s) :
(s:Begin) :