Ejemplo n.º 1
0
def mk_seq_eqs (p, split, step, with_rodata):
	# eqs take the form of a number of constant expressions
	eqs = []

	# the variable 'loop' will be converted to the point in
	# the sequence - note this should be multiplied by the step size
	loop = mk_var ('%i', word32T)
	if step == 1:
		minus_loop_step = mk_uminus (loop)
	else:
		minus_loop_step = mk_times (loop, mk_word32 (- step))

	for (var, data) in get_loop_var_analysis_at (p, split):
		if data == 'LoopVariable':
			if with_rodata and var.typ == builtinTs['Mem']:
				eqs.append (logic.mk_rodata (var))
		elif data == 'LoopConst':
			if var.typ not in syntax.phantom_types:
				eqs.append (var)
		elif data == 'LoopLeaf':
			continue
		elif data[0] == 'LoopLinearSeries':
			(_, form, _) = data
			eqs.append (form (var, minus_loop_step))
		else:
			assert not 'var_deps type understood'

	return eqs
Ejemplo n.º 2
0
def candidate_additional_eqs(p, split):
    eq_vals = set()

    def visitor(expr):
        if expr.is_op('Equals') and expr.vals[0].typ.kind == 'Word':
            [x, y] = expr.vals
            eq_vals.update([(x, y), (y, x)])

    for n in p.loop_body(split):
        p.nodes[n].visit(lambda x: (), visitor)
    for (x, y) in list(eq_vals):
        if is_zero(x) and y.is_op('Plus'):
            [x, y] = y.vals
            eq_vals.add((x, syntax.mk_uminus(y)))
            eq_vals.add((y, syntax.mk_uminus(x)))
        elif is_zero(x) and y.is_op('Minus'):
            [x, y] = y.vals
            eq_vals.add((x, y))
            eq_vals.add((y, x))

    loop = syntax.mk_var('%i', syntax.word32T)
    minus_loop_step = syntax.mk_uminus(loop)

    vas = search.get_loop_var_analysis_at(p, split)
    ls_vas = dict([(var, [data]) for (var, data) in vas
                   if data[0] == 'LoopLinearSeries'])
    cmp_series = [(x, y, rew, offs) for (x, y) in eq_vals
                  for (_, rew, offs) in ls_vas.get(x, [])]
    odd_eqs = []
    for (x, y, rew, offs) in cmp_series:
        x_init_cmp1 = syntax.mk_less_eq(x, rew(x, minus_loop_step))
        x_init_cmp2 = syntax.mk_less_eq(rew(x, minus_loop_step), x)
        fin_cmp1 = syntax.mk_less(x, y)
        fin_cmp2 = syntax.mk_less(y, x)
        odd_eqs.append(syntax.mk_eq(x_init_cmp1, fin_cmp1))
        odd_eqs.append(syntax.mk_eq(x_init_cmp2, fin_cmp1))
        odd_eqs.append(syntax.mk_eq(x_init_cmp1, fin_cmp2))
        odd_eqs.append(syntax.mk_eq(x_init_cmp2, fin_cmp2))

    ass_eqs = []
    var_deps = p.compute_var_dependencies()
    for hook in target_objects.hooks('extra_wcet_assertions'):
        for assn in hook(var_deps[split]):
            ass_eqs.append(assn)

    return odd_eqs + ass_eqs
Ejemplo n.º 3
0
def candidate_additional_eqs(p, split):
    eq_vals = set()

    def visitor(expr):
        if expr.is_op("Equals") and expr.vals[0].typ.kind == "Word":
            [x, y] = expr.vals
            eq_vals.update([(x, y), (y, x)])

    for n in p.loop_body(split):
        p.nodes[n].visit(lambda x: (), visitor)
    for (x, y) in list(eq_vals):
        if is_zero(x) and y.is_op("Plus"):
            [x, y] = y.vals
            eq_vals.add((x, syntax.mk_uminus(y)))
            eq_vals.add((y, syntax.mk_uminus(x)))
        elif is_zero(x) and y.is_op("Minus"):
            [x, y] = y.vals
            eq_vals.add((x, y))
            eq_vals.add((y, x))

    loop = syntax.mk_var("%i", syntax.word32T)
    minus_loop_step = syntax.mk_uminus(loop)

    vas = search.get_loop_var_analysis_at(p, split)
    ls_vas = dict([(var, [data]) for (var, data) in vas if data[0] == "LoopLinearSeries"])
    cmp_series = [(x, y, rew, offs) for (x, y) in eq_vals for (_, rew, offs) in ls_vas.get(x, [])]
    odd_eqs = []
    for (x, y, rew, offs) in cmp_series:
        x_init_cmp1 = syntax.mk_less_eq(x, rew(x, minus_loop_step))
        x_init_cmp2 = syntax.mk_less_eq(rew(x, minus_loop_step), x)
        fin_cmp1 = syntax.mk_less(x, y)
        fin_cmp2 = syntax.mk_less(y, x)
        odd_eqs.append(syntax.mk_eq(x_init_cmp1, fin_cmp1))
        odd_eqs.append(syntax.mk_eq(x_init_cmp2, fin_cmp1))
        odd_eqs.append(syntax.mk_eq(x_init_cmp1, fin_cmp2))
        odd_eqs.append(syntax.mk_eq(x_init_cmp2, fin_cmp2))

    ass_eqs = []
    var_deps = p.compute_var_dependencies()
    for hook in target_objects.hooks("extra_wcet_assertions"):
        for assn in hook(var_deps[split]):
            ass_eqs.append(assn)

    return odd_eqs + ass_eqs