def __init__(self, fn): SyntaxVisitor.__init__(self) self.fn = fn self.call_stack.append(fn) self.bound = set(fn.arg_names) self.seen_return = False
def visit_While(self, stmt): self.volatile_vars.push(stmt.merge.keys()) SyntaxVisitor.visit_While(self, stmt) if self.does_block_return(stmt.body): self.block_contains_return() volatile_in_scope = self.volatile_vars.pop() self.mark_safe_assignments(stmt.body, volatile_in_scope)
def visit_block(self, stmts, branch_label = None): self.push_scope() if branch_label is not None: self.push_scope(branch_label) SyntaxVisitor.visit_block(self, stmts) if branch_label is not None: self.pop_scope() self.pop_scope()
def visit_If(self, stmt): self.volatile_vars.push(stmt.merge.keys()) self.visit_expr(stmt.cond) SyntaxVisitor.visit_If(self, stmt) if self.does_block_return(stmt.true) or self.does_block_return(stmt.false): self.mark_curr_block_returns() volatile_in_scope = self.volatile_vars.pop() self.mark_safe_assignments(stmt.true, volatile_in_scope) self.mark_safe_assignments(stmt.false, volatile_in_scope)
def __init__(self): SyntaxVisitor.__init__(self) self.mutable_types = None self.volatile_vars = ScopedSet() self.depends_on = {} self.safe_to_move = set([]) self.curr_block_id = None self.block_contains_return = set([]) self.may_alias = None
def visit_expr(self, expr): assert expr is not None assert expr.type is not None, \ "Missing type annotation on %s" % expr SyntaxVisitor.visit_expr(self, expr)
def visit_expr(self, expr): if isinstance(expr, Adverb): raise self.Yes() SyntaxVisitor.visit_expr(self, expr)
def __init__(self): SyntaxVisitor.__init__(self) self.mutable_types = set([])
def visit_fn(self, fn): escape_info = escape_analysis(fn, self.fresh_alloc_args) self.may_alias = escape_info.may_alias SyntaxVisitor.visit_fn(self, fn) self.writes = set([])
def visit_stmt(self, stmt): if stmt.__class__ is ParFor: raise Yes() SyntaxVisitor.visit_stmt(self, stmt)
def __init__(self, fn): SyntaxVisitor.__init__(self) self.fn = fn self.bound = set(fn.arg_names)
def __init__(self): SyntaxVisitor.__init__(self) self.bindings = {}
def __init__(self): SyntaxVisitor.__init__(self) self.live_vars = set([])
def visit_ForLoop(self, stmt): self.visit_Var(stmt.var) SyntaxVisitor.visit_ForLoop(self, stmt)
def __init__(self): SyntaxVisitor.__init__(self) self.counts = {}
def visit_expr(self, expr): if isinstance(expr, Adverb): raise Yes() SyntaxVisitor.visit_expr(self, expr)
def visit_expr(self, expr): if isinstance(expr, (UntypedFn, TypedFn, Closure)) or isinstance( expr.type, (FnT, ClosureT)): raise Yes() SyntaxVisitor.visit_expr(expr)
def visit_expr(self, expr): abstract_shape = SyntaxVisitor.visit_expr(self, expr) assert abstract_shape is not None, \ "Unsupported expression in shape inference: %s" % expr.node_type() return abstract_shape
def visit_fn(self, fn): for name in fn.arg_names: self.created_on[name] = 0 SyntaxVisitor.visit_fn(self, fn)
def __init__(self): SyntaxVisitor.__init__(self) self.ranges = {} self.old_values = ScopedDict() self.old_values.push()
def visit_block(self, stmts): self.curr_block_id = id(stmts) SyntaxVisitor.visit_block(self, stmts)
def visit_expr(self, expr): assert expr is not None SyntaxVisitor.visit_expr(self, expr)
def visit_stmt(self, stmt): assert stmt is not None, "Statement missing, must be a compiler bug" SyntaxVisitor.visit_stmt(self, stmt)
def visit_fn(self, fn): self.volatile_vars.push(fn.arg_names) self.may_alias = may_alias(fn) SyntaxVisitor.visit_fn(self, fn) return self.safe_to_move
def visit_expr(self, expr): assert expr is not None, "Expression missing, must be a compiler bug" assert expr.type is not None, \ "Missing type annotation on %s" % expr SyntaxVisitor.visit_expr(self, expr)
def visit_expr(self, expr): if isinstance(expr, (UntypedFn, TypedFn, Closure)) or isinstance(expr.type, (FnT, ClosureT)): raise Yes() SyntaxVisitor.visit_expr(expr)
def visit_stmt(self, stmt): self.inc_counter() self.stmt_paths[id(stmt)] = self.curr_path() SyntaxVisitor.visit_stmt(self, stmt)
def visit_fn(self, fn): SyntaxVisitor.visit_fn(self, fn) return self.known_offsets
def visit_stmt(self, stmt): SyntaxVisitor.visit_stmt(self, stmt)
def visit_stmt(self, stmt): assert stmt is not None SyntaxVisitor.visit_stmt(self, stmt)
def visit_ForLoop(self, stmt): self.value_env[stmt.var.name] = any_scalar SyntaxVisitor.visit_ForLoop(self, stmt)
def __init__(self): SyntaxVisitor.__init__(self) self.var_names = set([])