Пример #1
0
def loop_var_analysis(p, split):
    """computes the same loop dataflow analysis as in the 'logic' module
	but with stack slots treated as virtual variables."""
    if not is_asm_node(p, split):
        return None
    head = p.loop_id(split)
    tag = p.node_tags[split][0]
    assert head

    key = ('loop_stack_virtual_var_cycle_analysis', split)
    if key in p.cached_analysis:
        return p.cached_analysis[key]

    (vds, adj_nodes, loc_offs, upd_offsets,
     _) = get_loop_virtual_stack_analysis(p, tag)
    loop = p.loop_body(head)

    va = logic.compute_loop_var_analysis(p,
                                         vds,
                                         split,
                                         override_nodes=adj_nodes)

    (stack, _) = get_stack_sp(p, tag)

    va2 = []
    uoffs = upd_offsets.get(head, [])
    for (v, data) in va:
        if v.kind == 'Var' and v.name[0] == 'Fake':
            (_, k, offs) = v.name
            if (k, offs) not in uoffs:
                continue
            v2 = loc_offs(split, 'MemAcc', offs, k)
            va2.append((v2, data))
        elif v.kind == 'Var' and v.name.startswith('stack'):
            assert v.typ == stack.typ
            continue
        else:
            va2.append((v, data))
    stack_const = stack
    for (k, off) in uoffs:
        stack_const = syntax.mk_memupd(stack_const,
                                       loc_offs(split, 'Ptr', off, k),
                                       syntax.mk_word32(0))
    sp = asm_stack_rep_hook(p, (stack.name, stack.typ), 'Loop', split)
    assert sp and sp[0] == 'SplitMem', (split, sp)
    (_, st_split) = sp
    stack_const = logic.mk_stack_wrapper(st_split, stack_const, [])
    stack_const = logic.mk_eq_selective_wrapper(stack_const, ([], [0]))

    va2.append((stack_const, 'LoopConst'))

    p.cached_analysis[key] = va2
    return va2
Пример #2
0
def loop_var_analysis (p, split):
	"""computes the same loop dataflow analysis as in the 'logic' module
	but with stack slots treated as virtual variables."""
	if not is_asm_node (p, split):
		return None
	head = p.loop_id (split)
	tag = p.node_tags[split][0]
	assert head

	key = ('loop_stack_virtual_var_cycle_analysis', split)
	if key in p.cached_analysis:
		return p.cached_analysis[key]

	(vds, adj_nodes, loc_offs,
		upd_offsets, _) = get_loop_virtual_stack_analysis (p, tag)
	loop = p.loop_body (head)

	va = logic.compute_loop_var_analysis (adj_nodes, vds, split, loop,
		p.preds)

	(stack, _) = get_stack_sp (p, tag)

	va2 = []
	uoffs = upd_offsets.get (head, [])
	for (v, data) in va:
		if v.kind == 'Var' and v.name[0] == 'Fake':
			(_, k, offs) = v.name
			if (k, offs) not in uoffs:
				continue
			v2 = loc_offs (split, 'MemAcc', offs, k)
			va2.append ((v2, data))
		elif v.kind == 'Var' and v.name.startswith ('stack'):
			assert v.typ == stack.typ
			continue
		else:
			va2.append ((v, data))
	stack_const = stack
	for (k, off) in uoffs:
		stack_const = syntax.mk_memupd (stack_const,
			loc_offs (split, 'Ptr', off, k),
			syntax.mk_word32 (0))
	sp = asm_stack_rep_hook (p, (stack.name, stack.typ), 'Loop', split)
	assert sp and sp[0] == 'SplitMem', (split, sp)
	(_, st_split) = sp
	stack_const = logic.mk_stack_wrapper (st_split, stack_const, [])
	stack_const = logic.mk_eq_selective_wrapper (stack_const,
		([], [0]))
	
	va2.append ((stack_const, 'LoopConst'))

	p.cached_analysis[key] = va2
	return va2
Пример #3
0
 def get_loop_var_analysis(self, var_deps, n):
     head = self.loop_id(n)
     assert head, n
     assert n in self.splittable_points(n)
     loop_sort = tuple(sorted(self.loop_body(head)))
     node_data = [(self.nodes[n2], sorted(self.preds[n]), sorted(var_deps[n2].keys())) for n2 in loop_sort]
     k = (n, loop_sort)
     data = (node_data, n)
     if k in self.loop_var_analysis_cache:
         for (data2, va) in self.loop_var_analysis_cache[k]:
             if data2 == data:
                 return va
     va = logic.compute_loop_var_analysis(self.nodes, var_deps, n, self.loop_body(head), self.preds)
     group = self.loop_var_analysis_cache.setdefault(k, [])
     group.append((data, va))
     del group[:-10]
     return va
Пример #4
0
 def get_loop_var_analysis(self, var_deps, n):
     head = self.loop_id(n)
     assert head, n
     assert n in self.splittable_points(n)
     loop_sort = tuple(sorted(self.loop_body(head)))
     node_data = [(self.nodes[n2], sorted(self.preds[n]),
                   sorted(var_deps[n2].keys())) for n2 in loop_sort]
     k = (n, loop_sort)
     data = (node_data, n)
     if k in self.loop_var_analysis_cache:
         for (data2, va) in self.loop_var_analysis_cache[k]:
             if data2 == data:
                 return va
     va = logic.compute_loop_var_analysis(self, var_deps, n)
     group = self.loop_var_analysis_cache.setdefault(k, [])
     group.append((data, va))
     del group[:-10]
     return va