aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorazidar2016-01-15 17:31:12 -0800
committerazidar2016-01-16 14:28:18 -0800
commitcf5c616fc8cfe17ac0c99f8fc0ece70e9ecc466d (patch)
treeda82eda8cddf95c2b937907e69c2f272bb848ccc /src
parent81cbc5923ead8af322d1b61e04df8cd026ef36aa (diff)
Sped up remove access by checking a condition
Diffstat (limited to 'src')
-rw-r--r--src/main/stanza/passes.stanza57
1 files changed, 36 insertions, 21 deletions
diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza
index 51564f95..7f469224 100644
--- a/src/main/stanza/passes.stanza
+++ b/src/main/stanza/passes.stanza
@@ -1070,6 +1070,16 @@ defn get-locations (e:Expression) -> List<Location> :
to-list(ls*)
hashed-locations[e] = x
x
+defn has-access? (e:Expression) -> True|False :
+ var ret = false
+ defn rec-has-access (e:Expression) -> Expression :
+ match(e) :
+ (e:WSubAccess) :
+ ret = true
+ e
+ (e) : map(rec-has-access,e)
+ rec-has-access(e)
+ ret
defn remove-access (c:Circuit) :
defn remove-m (m:InModule) -> InModule :
@@ -1086,29 +1096,34 @@ defn remove-access (c:Circuit) :
(e:DoPrim) : map(remove-e,e)
(e:UIntValue|SIntValue) : e
(e) :
- val rs = get-locations(e)
- val foo = for x in rs find :
- (guard(x)) != one
- if foo == false : e
- else :
- val temp = create-temp(e)
- for (x in rs, i in 0 to false) do :
- if i == 0 :
- add(stmts,Connect(info(s),temp,base(x)))
- else :
- add(stmts,Conditionally(info(s),guard(x),Connect(info(s),temp,base(x)),Empty()))
- temp
+ if has-access?(e) :
+ val rs = get-locations(e)
+ val foo = for x in rs find :
+ (guard(x)) != one
+ if foo == false : error("Shouldn't be here")
+ else :
+ val temp = create-temp(e)
+ for (x in rs, i in 0 to false) do :
+ if i == 0 :
+ add(stmts,Connect(info(s),temp,base(x)))
+ else :
+ add(stmts,Conditionally(info(s),guard(x),Connect(info(s),temp,base(x)),Empty()))
+ temp
+ else : e
val s* = match(s) :
(s:Connect) :
- val ls = get-locations(loc(s))
- val loc* =
- if length(ls) == 1 and guard(head(ls)) == one : loc(s)
- else :
- val temp = create-temp(loc(s))
- for x in ls do :
- add(stmts,Conditionally(info(s),guard(x),Connect(info(s),base(x),temp),Empty()))
- temp
- Connect(info(s),loc*,remove-e(exp(s)))
+ if has-access?(loc(s)) :
+ val ls = get-locations(loc(s))
+ val loc* =
+ if length(ls) == 1 and guard(head(ls)) == one : loc(s)
+ else :
+ val temp = create-temp(loc(s))
+ for x in ls do :
+ add(stmts,Conditionally(info(s),guard(x),Connect(info(s),base(x),temp),Empty()))
+ temp
+ Connect(info(s),loc*,remove-e(exp(s)))
+ else :
+ Connect(info(s),loc(s),remove-e(exp(s)))
(s) : map{remove-s,_} $ map(remove-e,s)
add(stmts,s*)
if length(stmts) != 1 : Begin(to-list(stmts))