Revert "add support for pseudocode being a [[!inline]] directive"
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 1 Oct 2023 09:40:43 +0000 (10:40 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 1 Oct 2023 10:19:52 +0000 (11:19 +0100)
This reverts commit 43152e91f4530ddaef5cef2614b41e022c57fced.

src/openpower/decoder/pseudo/pagereader.py
src/openpower/decoder/pseudo/pywriter.py

index 5cab669cc4be7afad1cecef0ffc15f1ad0206854..9bb234de2f6bcb8e65e0b154779a4fc1b52ce622 100644 (file)
@@ -52,7 +52,7 @@ import os
 import re
 
 opfields = ("desc", "form", "opcode", "regs", "pcode", "sregs", "page",
-            "extra_uninit_regs", "pcode_fname")
+            "extra_uninit_regs")
 Ops = namedtuple("Ops", opfields)
 
 
@@ -223,7 +223,6 @@ class ISA:
         l = lines.pop(0).rstrip()  # get first line
         prefix_lines = 0
         while lines:
-            pcode_fname = fname
             if self.verbose:
                 print(l)
             # look for HTML comment, if starting, skip line.
@@ -312,7 +311,8 @@ class ISA:
 
             # fix parser line numbers by prepending the right number of
             # blank lines to the parser input
-            li = [""] * (prefix_lines + 1)
+            li = [""] * prefix_lines
+            li += [l[4:]]  # first line detected with 4-space
             while True:
                 l = lines.pop(0).rstrip()
                 prefix_lines += 1
@@ -326,50 +326,13 @@ class ISA:
                             extra_uninit_regs.add(i)
                     li.append("")
                     continue
-                if l.startswith("[[!inline "):
-                    li.append(l)
-                    continue
                 if l.strip().startswith('<!--'):
                     li.append("")
                     continue
                 assert l.startswith('    '), ("4spcs not found in line %s" % l)
                 l = l[4:]  # lose 4 spaces
                 li.append(l)
-            inline_line = None
-            other = False
-            for l in li:
-                if l.startswith("[[!inline "):
-                    assert inline_line is None, \
-                        "can't use multiple [[!inline]] directives"
-                    inline_line = l
-                elif l != "":
-                    other = True
-            if inline_line is not None:
-                assert not other, \
-                    "can't use [[!inline]] directive with other content"
-
-                re_match = re.fullmatch(
-                    r'\[\[!inline pagenames="openpower/isa/([^" ]*[^"/ ])" '
-                    r'raw="yes"]]', inline_line)
-                assert re_match, (
-                    'invalid [[!inline]] directive, must be of the form:\n'
-                    '[[!inline pagenames="openpower/isa/foo/bar" '
-                    'raw="yes"]]')
-                pcode_fname = re_match[1] + ".mdwn"
-                pcode_fname = os.path.join(get_isa_dir(), pcode_fname)
-                with open(pcode_fname) as f:
-                    li = f.readlines()
-                for i, l in enumerate(li):
-                    l = l.rstrip()
-                    if l.startswith("<!--"):
-                        l = ""
-                    elif l != "":
-                        assert l.startswith("    "), \
-                            "line must start with 4 spaces"
-                        l = l[4:]
-                    li[i] = l
             d['pcode'] = li
-            d['pcode_fname'] = pcode_fname
             d['extra_uninit_regs'] = extra_uninit_regs
 
             # "Special Registers Altered" expected
index bb92e92d31c79daca6adfb818f1b70f7bb277e34..6d436eef2f8f9877322bd6e91d2022f6c36a09b9 100644 (file)
@@ -112,8 +112,9 @@ class PyISAWriter(ISA):
                 pcode = '\n'.join(d.pcode) + '\n'
                 print(pcode)
                 incl_carry = pagename == 'fixedshift'
+                filename = os.path.join(get_isa_dir(), pagename + ".mdwn")
                 pycode, rused = convert_to_python(pcode, d.form, incl_carry,
-                                                  filename=d.pcode_fname)
+                                                  filename=filename)
                 rused['uninit_regs'] |= d.extra_uninit_regs
                 # create list of arguments to call
                 regs = list(rused['read_regs']) + list(rused['uninit_regs'])