예제 #1
0
def mk_pairing(pre_pair, stack_bounds):
    asm_f = pre_pair['ASM']
    sz = stack_bounds[asm_f]
    c_fun = functions[pre_pair['C']]

    from logic import split_scalar_pairs
    (var_c_args, c_imem, glob_c_args) = split_scalar_pairs(c_fun.inputs)
    (var_c_rets, c_omem, glob_c_rets) = split_scalar_pairs(c_fun.outputs)

    eqs = logic.mk_eqs_arm_none_eabi_gnu(var_c_args, var_c_rets, c_imem,
                                         c_omem, sz)

    return logic.Pairing(['ASM', 'C'], {'ASM': asm_f, 'C': c_fun.name}, eqs)
예제 #2
0
def mk_pairing (pre_pair, stack_bounds):
	asm_f = pre_pair['ASM']
	sz = stack_bounds[asm_f]
	c_fun = functions[pre_pair['C']]

	from logic import split_scalar_pairs
	(var_c_args, c_imem, glob_c_args) = split_scalar_pairs (c_fun.inputs)
	(var_c_rets, c_omem, glob_c_rets) = split_scalar_pairs (c_fun.outputs)

	eqs = logic.mk_eqs_arm_none_eabi_gnu (var_c_args, var_c_rets,
		c_imem, c_omem, sz)

	return logic.Pairing (['ASM', 'C'],
		{'ASM': asm_f, 'C': c_fun.name}, eqs)
예제 #3
0
def get_asm_calling_convention (fname):
	if fname in asm_cc_cache:
		return asm_cc_cache[fname]
	pair = pre_pairings[fname]
	assert pair['ASM'] == fname
	c_fun = functions[pair['C']]
	from logic import split_scalar_pairs
	(var_c_args, c_imem, glob_c_args) = split_scalar_pairs (c_fun.inputs)
	(var_c_rets, c_omem, glob_c_rets) = split_scalar_pairs (c_fun.outputs)

	num_args = len (var_c_args)
	num_rets = len (var_c_rets)
	const_mem = not (c_omem)

	cc = get_asm_calling_convention_inner (num_args, num_rets, const_mem)
	asm_cc_cache[fname] = cc
	return cc
예제 #4
0
def mk_asm_inst_spec (fname):
	if not fname.startswith ("asm_instruction'"):
		return
	if functions[fname].entry:
		return
	(_, ident) = fname.split ("'", 1)
        (args, ident) = split_inst_name_regs (ident)
	assert all ([arg.startswith ('%') for arg in args]), fname
	base_ident = ident.split ("_")[0]
	if base_ident not in instruction_fun_specs:
		return
	(impl_fname, regspecs) = instruction_fun_specs[base_ident]
	add_impl_fun (impl_fname, regspecs)
	(iscs, imems, _) = logic.split_scalar_pairs (functions[fname].inputs)
	(oscs, omems, _) = logic.split_scalar_pairs (functions[fname].outputs)
	call = syntax.Node ('Call', 'Ret', (impl_fname,
		iscs + [syntax.mk_token (ident)] + imems,
                [(v.name, v.typ) for v in oscs + omems]))
	assert not functions[fname].nodes
	functions[fname].nodes[1] = call
	functions[fname].entry = 1
예제 #5
0
def get_asm_calling_convention(fname):
    if fname in asm_cc_cache:
        return asm_cc_cache[fname]
    if fname not in pre_pairings:
        bits = fname.split("'")
        if not is_instruction(fname):
            trace("Warning: unusual unmatched function (%s, %s)." %
                  (fname, bits))
        return None
    pair = pre_pairings[fname]
    assert pair['ASM'] == fname
    c_fun = functions[pair['C']]
    from logic import split_scalar_pairs
    (var_c_args, c_imem, glob_c_args) = split_scalar_pairs(c_fun.inputs)
    (var_c_rets, c_omem, glob_c_rets) = split_scalar_pairs(c_fun.outputs)

    num_args = len(var_c_args)
    num_rets = len(var_c_rets)
    const_mem = not (c_omem)

    cc = get_asm_calling_convention_inner(num_args, num_rets, const_mem)
    asm_cc_cache[fname] = cc
    return cc
예제 #6
0
def get_asm_calling_convention (fname):
	if fname in asm_cc_cache:
		return asm_cc_cache[fname]
	if fname not in pre_pairings:
		bits = fname.split ("'")
		if bits[:1] not in [["impl"], ["instruction"]]:
			trace ("Warning: unusual unmatched function (%s, %s)."
				% (fname, bits))
		return None
	pair = pre_pairings[fname]
	assert pair['ASM'] == fname
	c_fun = functions[pair['C']]
	from logic import split_scalar_pairs
	(var_c_args, c_imem, glob_c_args) = split_scalar_pairs (c_fun.inputs)
	(var_c_rets, c_omem, glob_c_rets) = split_scalar_pairs (c_fun.outputs)

	num_args = len (var_c_args)
	num_rets = len (var_c_rets)
	const_mem = not (c_omem)

	cc = get_asm_calling_convention_inner (num_args, num_rets, const_mem)
	asm_cc_cache[fname] = cc
	return cc
예제 #7
0
def mk_asm_inst_spec(fname):
    if not fname.startswith("asm_instruction'"):
        return
    if functions[fname].entry:
        return
    (_, ident) = fname.split("'", 1)
    (args, ident) = split_inst_name_regs(ident)
    if not all([arg.startswith('%') for arg in args]):
        printout('Warning: asm instruction name: formatting: %r' % fname)
        return
    base_ident = ident.split("_")[0]
    if base_ident not in instruction_fun_specs:
        return
    (impl_fname, regspecs) = instruction_fun_specs[base_ident]
    add_impl_fun(impl_fname, regspecs)
    (iscs, imems, _) = logic.split_scalar_pairs(functions[fname].inputs)
    (oscs, omems, _) = logic.split_scalar_pairs(functions[fname].outputs)
    call = syntax.Node('Call', 'Ret',
                       ('r_' + impl_fname, iscs + [syntax.mk_token(ident)] +
                        imems, [(v.name, v.typ) for v in oscs + omems]))
    assert not functions[fname].nodes
    functions[fname].nodes[1] = call
    functions[fname].entry = 1