X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=openpower%2Fpower_trans_ops_copy_from_PO59_table.py;h=f3a25c1a86b5ffdf43a61a2391039a54a59d0987;hb=7881bad4de0c9b5abc3fe7db2ae65181f7369bd4;hp=061b7e5f358c283430a11701eb7c8602c4599ddd;hpb=d07de16dd70b5d7a8f0cb75c7d510002c16c2628;p=libreriscv.git diff --git a/openpower/power_trans_ops_copy_from_PO59_table.py b/openpower/power_trans_ops_copy_from_PO59_table.py index 061b7e5f3..f3a25c1a8 100644 --- a/openpower/power_trans_ops_copy_from_PO59_table.py +++ b/openpower/power_trans_ops_copy_from_PO59_table.py @@ -7,11 +7,10 @@ FILENAME = Path("openpower/power_trans_ops.mdwn") NEW_FILENAME = FILENAME.with_suffix(".new.mdwn") OLD_FILENAME = FILENAME.with_suffix(".old.mdwn") -PO_59_HEADER = "## PO=59 XO=10--011--" +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): @@ -52,28 +51,16 @@ def process(lr): assert line is not None and line != "", "empty table" - def parse_mnemonic_to_opcode_map(): + def parse_single_mnemonic_to_opcode_map(): # type: () -> Iterable[str] nonlocal line, lineno, mnemonic_to_xo_map - while line != PO_59_HEADER: - assert line is not None, "missing PO=59 header" - yield line - line, lineno = lr.read() - - yield line - line, lineno = lr.read() - - while line is not None and not line.startswith(("#", "|")): - yield line - line, lineno = lr.read() - assert line is not None and line.startswith( - "| XO LSB half →
XO MSB half ↓ |"), \ - "can't find PO=59 table" + "| XO LSB half →
XO MSB half ↓ |"), \ + "can't find PO=59/63 table" line_parts = line.split('|') len_line_parts = len(line_parts) - assert line_parts[-1] == "", "invalid PO=59 table top row" + assert line_parts[-1] == "", "invalid PO=59/63 table top row" columns = [] # type: list[str] columns_range = range(2, len_line_parts - 1) for i in columns_range: @@ -105,10 +92,12 @@ def process(lr): f"binary string: {row}") for i, column in zip(columns_range, columns): cell = line_parts[i] + if cell.strip() == "": + continue match = re.fullmatch( r" * *` *(?P[01][01 ]*[01]) *` *" - r" *
*(?P[a-zA-Z0-9_.]+)?" - r"(?(mnemonic)|(?:\([a-zA-Z0-9_.]+\)|\*\*TBD\*\*|))" + r" *
*(?P[a-zA-Z0-9_.][a-zA-Z0-9_.()]*)?" + r"(?(mnemonic)|(?:\([a-zA-Z0-9_.()]+\)|\*\*TBD\*\*|))" r"(?: *\(draft\))? *", cell) assert match is not None, f"invalid table cell: {cell!r}" xo, mnemonic = match.group("xo", "mnemonic") @@ -118,8 +107,8 @@ def process(lr): f"incorrect XO: found {shrunk_xo} expected {expected_xo}" if mnemonic is None: continue - assert mnemonic.endswith('s'), \ - f"PO=59 fptrans mnemonic must end in `s`: {mnemonic}" + assert mnemonic.endswith('(s)'), \ + f"PO=59/63 fptrans mnemonic must end in `(s)`: {mnemonic}" assert mnemonic not in mnemonic_to_xo_map, ( f"duplicate mnemonic: {mnemonic} -- has opcode " f"{xo} and {mnemonic_to_xo_map[mnemonic]}") @@ -129,6 +118,29 @@ def process(lr): yield line line, lineno = lr.read() + while line == "": + yield line + line, lineno = lr.read() + + def parse_mnemonic_to_opcode_map(): + # type: () -> Iterable[str] + nonlocal line, lineno, mnemonic_to_xo_map + + while line != PO_59_63_HEADER: + assert line is not None, "missing PO=59/63 header" + yield line + line, lineno = lr.read() + + yield line + line, lineno = lr.read() + + while line is not None and not line.startswith(("#", "|")): + yield line + line, lineno = lr.read() + + for _ in range(2): + yield from parse_single_mnemonic_to_opcode_map() + def skip_table(): # type: () -> Iterable[str] nonlocal line, lineno @@ -205,8 +217,6 @@ def process(lr): mnemonic = line_parts[mnemonic_index].strip() xo = line_parts[xo_index].strip() - if mnemonic.endswith("(s)") or mnemonic.endswith("[s]"): - mnemonic = mnemonic[:-3] + "s" if mnemonic not in mnemonic_to_xo_map: print(f"mnemonic not assigned an XO value: {mnemonic!r}") elif xo == "":