Add Rtl.free_vars()
This commit is contained in:
committed by
Jakob Stoklund Olesen
parent
ec9e9bd1ca
commit
3fd43fd006
@@ -68,6 +68,17 @@ class Rtl(object):
|
|||||||
[d.definitions() for d in self.rtl],
|
[d.definitions() for d in self.rtl],
|
||||||
set([]))
|
set([]))
|
||||||
|
|
||||||
|
def free_vars(self):
|
||||||
|
# type: () -> Set[Var]
|
||||||
|
""" Return the set of free Vars used in self"""
|
||||||
|
def flow_f(s, d):
|
||||||
|
# type: (Set[Var], Def): Set[Var]
|
||||||
|
"""Compute the change in the set of free vars across a Def"""
|
||||||
|
s = s.difference(set(d.defs))
|
||||||
|
return s.union(set(a for a in d.expr.args if isinstance(a, Var)))
|
||||||
|
|
||||||
|
return reduce(flow_f, reversed(self.rtl), set([]))
|
||||||
|
|
||||||
def substitution(self, other, s):
|
def substitution(self, other, s):
|
||||||
# type: (Rtl, VarMap) -> Optional[VarMap]
|
# type: (Rtl, VarMap) -> Optional[VarMap]
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user