From: Dmitry Selyutin Date: Sun, 3 Dec 2023 11:56:10 +0000 (+0300) Subject: pyfnwriter: introduce C mode X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=048d784412613dea5da41d2c1d7f50ee9902bd4d;p=openpower-isa.git pyfnwriter: introduce C mode --- diff --git a/src/openpower/decoder/pseudo/pyfnwriter.py b/src/openpower/decoder/pseudo/pyfnwriter.py index ebb9158f..01c1ea8f 100644 --- a/src/openpower/decoder/pseudo/pyfnwriter.py +++ b/src/openpower/decoder/pseudo/pyfnwriter.py @@ -35,12 +35,12 @@ class PyISAFnWriter(ISAFunctions): ISAFunctions.__init__(self) self.pages_written = [] - def write_pysource(self, pagename): + def write_code(self, pagename, ext): self.pages_written.append(pagename) function = self.fns[pagename] isadir = get_isafn_src_dir() os.makedirs(isadir, exist_ok=True) - fname = os.path.join(isadir, "%s.py" % pagename) + fname = os.path.join(isadir, (pagename + ext)) sourcecache = dict() check_in_gitignore(fname) with open(fname, "w") as f: @@ -92,17 +92,24 @@ class PyISAFnWriter(ISAFunctions): def pyfnwriter(): isa = PyISAFnWriter() write_isa_class = True - if len(sys.argv) == 1: # quick way to do it + args = dict.fromkeys(sys.argv[1:]) + ext = ".py" + if "--c" in args: + ext = ".c" + del args["--c"] + if len(args) == 0: # quick way to do it log(dir(isa)) sources = isa.fns.keys() else: - sources = sys.argv[1:] + sources = list(args) if sources[0] == "noall": # don't rewrite all.py write_isa_class = False sources.pop(0) + if ext == ".c": + raise NotImplementedError("C mode is not supported yet") log("sources", write_isa_class, sources) for source in sources: - isa.write_pysource(source) + isa.write_code(pagename=source, ext=ext) if write_isa_class: isa.write_isa_class()