예제 #1
0
def mk_bin_inst_spec (fname):
	if not fname.startswith ("instruction'"):
		return
	if functions[fname].entry:
		return
	(_, ident) = fname.split ("'", 1)
	(ident, addr) = split_inst_name_addr (ident)
	(regs, ident) = split_inst_name_regs (ident)
	ident = instruction_name_aliases.get (ident, ident)
	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)
	assert len (regspecs) == len (regs), (fname, regs, regspecs)
	inp_regs = [reg for (reg, d) in zip (regs, regspecs) if d == 'I']
	out_regs = [reg for (reg, d) in zip (regs, regspecs) if d == 'O']
	call = syntax.Node ('Call', 'Ret', (impl_fname,
		[syntax.mk_var (reg, syntax.word32T) for reg in inp_regs]
			+ [syntax.mk_token (ident)]
			+ [syntax.mk_var (nm, typ) for (nm, typ) in bin_globs],
		[(reg, syntax.word32T) for reg in out_regs] + bin_globs))
	assert not functions[fname].nodes
	functions[fname].nodes[1] = call
	functions[fname].entry = 1
예제 #2
0
def mk_bin_inst_spec(fname):
    if not fname.startswith("instruction'"):
        return
    if functions[fname].entry:
        return
    (_, ident) = fname.split("'", 1)
    (ident, addr) = split_inst_name_addr(ident)
    (regs, ident) = split_inst_name_regs(ident)
    ident = instruction_name_aliases.get(ident, ident)
    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)
    assert len(regspecs) == len(regs), (fname, regs, regspecs)
    inp_regs = [reg for (reg, d) in zip(regs, regspecs) if d == 'I']
    out_regs = [reg for (reg, d) in zip(regs, regspecs) if d == 'O']
    call = syntax.Node(
        'Call', 'Ret',
        ('l_' + impl_fname,
         [syntax.mk_var(reg, syntax.word32T)
          for reg in inp_regs] + [syntax.mk_token(ident)] +
         [syntax.mk_var(nm, typ)
          for (nm, typ) in bin_globs], [(reg, syntax.word32T)
                                        for reg in out_regs] + bin_globs))
    assert not functions[fname].nodes
    functions[fname].nodes[1] = call
    functions[fname].entry = 1
예제 #3
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
예제 #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)
    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