def main(): # type: () -> None parser = argparse.ArgumentParser( description='Generate sources for Cranelift.') parser.add_argument('--out-dir', help='set output directory') args = parser.parse_args() out_dir = args.out_dir isas = isa.all_isas() number_all_instructions(isas) gen_encoding.generate(isas, out_dir) gen_binemit.generate(isas, out_dir) gen_build_deps.generate()
def main(): # type: () -> None parser = argparse.ArgumentParser( description='Generate sources for Cretonne.') parser.add_argument('--out-dir', help='set output directory') args = parser.parse_args() out_dir = args.out_dir isas = isa.all_isas() gen_types.generate(out_dir) gen_instr.generate(isas, out_dir) gen_settings.generate(isas, out_dir) gen_encoding.generate(isas, out_dir) gen_legalizer.generate(isas, out_dir) gen_registers.generate(isas, out_dir) gen_binemit.generate(isas, out_dir) gen_build_deps.generate()
r = '\\n'.join(line.strip().replace('"', '\\"') for line in s.splitlines()) while r.startswith('\\n'): r = r[2:].strip() while r.endswith('\\n'): r = r[:-2].strip() return r with open(args.output, 'w', newline='\n') as file: # Instructions file.write('export const instructions = [\n') groups = list(set(g for isa in all_isas() for g in isa.instruction_groups)) instrs = [i for group in groups for i in group.instructions] for inst in instrs: ins = ', '.join([ f'{{ name: "{p.name}", descr: "{docstr(p)}" }}' for p in inst.ins ]) outs = ', '.join([ f'{{ name: "{p.name}", descr: "{docstr(p)}" }}' for p in inst.ins ]) file.write( f' {{\n name: "{inst.name}",\n ins: [{ins}],\n outs: [{outs}],\n descr: "{docstr(inst)}"\n }},\n' ) file.write('];\n\n')
# Second-level build script. # # This script is run from lib/cretonne/build.rs to generate Rust files. from __future__ import absolute_import import argparse import isa import gen_types import gen_instr import gen_settings import gen_build_deps import gen_encoding import gen_legalizer parser = argparse.ArgumentParser(description='Generate sources for Cretonne.') parser.add_argument('--out-dir', help='set output directory') args = parser.parse_args() out_dir = args.out_dir # type: ignore isas = isa.all_isas() gen_types.generate(out_dir) gen_instr.generate(isas, out_dir) gen_settings.generate(isas, out_dir) gen_encoding.generate(isas, out_dir) gen_legalizer.generate(isas, out_dir) gen_build_deps.generate()