(no commit message)
[libreriscv.git] / openpower / power_trans_ops_copy_from_PO59_table.py
index c569f407c1c35e0efc025661c6d66f4d8dff519f..e41166c1ce94f61057e429b814fa11d577a3cf49 100644 (file)
@@ -11,8 +11,6 @@ PO_59_63_HEADER = "# Opcode Tables for PO=59/63 XO=1---011--"
 MNEMONIC_COLUMN_NAME = "opcode"
 XO_COLUMN_NAME = "Major 59 and 63"
 
-# TODO: copy PO=59 table to PO=63 table
-
 
 class LineReader:
     def __init__(self, lines):
@@ -89,20 +87,23 @@ def process(lr):
             row = line_parts[1].strip()
             if row.startswith('`') and row.endswith('`'):
                 row = row[1:-1].strip()
-            assert row.lstrip(" 01") == "", (f"invalid table line header-cell "
-                                             f"contents -- must be a "
-                                             f"binary string: {row}")
+            assert row.lstrip(" 01/.") == "", (
+                f"invalid table line header-cell contents -- must be a "
+                f"binary string: {row}")
             for i, column in zip(columns_range, columns):
                 cell = line_parts[i]
+                if cell.strip() == "":
+                    continue
                 match = re.fullmatch(
-                    r" *<small> *` *(?P<xo>[01][01 ]*[01]) *` *</small>"
+                    r" *<small> *` *(?P<xo>[01./][01 ./]*[01./]) *` *</small>"
                     r" *<br/?> *(?P<mnemonic>[a-zA-Z0-9_.][a-zA-Z0-9_.()]*)?"
-                    r"(?(mnemonic)|(?:\([a-zA-Z0-9_.()]+\)|\*\*TBD\*\*|))"
+                    r"(?(mnemonic)|(?:\([a-zA-Z0-9_.()]+\)|"
+                    r"\*\*TBD\*\*|&nbsp;|))"
                     r"(?: *\(draft\))? *", cell)
                 assert match is not None, f"invalid table cell: {cell!r}"
                 xo, mnemonic = match.group("xo", "mnemonic")
-                shrunk_xo = xo.replace(" ", "")
-                expected_xo = (row + column).replace(" ", "")
+                shrunk_xo = xo.replace(" ", "").replace('.', '/')
+                expected_xo = (row + column).replace(" ", "").replace('.', '/')
                 assert shrunk_xo == expected_xo, \
                     f"incorrect XO: found {shrunk_xo} expected {expected_xo}"
                 if mnemonic is None:
@@ -138,7 +139,7 @@ def process(lr):
             yield line
             line, lineno = lr.read()
 
-        for _ in range(2):
+        for _ in range(3):
             yield from parse_single_mnemonic_to_opcode_map()
 
     def skip_table():