From 35d93c0a61866cc98e9946c701da35b2b291759f Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 6 Sep 2022 03:59:29 -0700 Subject: [PATCH] working on fptrans opcode table --- openpower/power_trans_ops.mdwn | 59 +++++++++---------- .../power_trans_ops_copy_from_PO59_table.py | 56 ++++++++++-------- 2 files changed, 62 insertions(+), 53 deletions(-) diff --git a/openpower/power_trans_ops.mdwn b/openpower/power_trans_ops.mdwn index c1aa551f7..a3918bfd3 100644 --- a/openpower/power_trans_ops.mdwn +++ b/openpower/power_trans_ops.mdwn @@ -1,39 +1,38 @@ # Opcode Tables -## PO=59 XO=10--011-- +## PO=59/63 XO=1---011-- -Power ISA v3.1B opcodes extracted from Power ISA v3.1B Appendix D Table 23 sheet 2 of 4 page 1391 +Power ISA v3.1B opcodes extracted from: +* Power ISA v3.1B Appendix D Table 23 sheet 2 of 4 page 1391 +* Power ISA v3.1B Appendix D Table 25 sheet 2 of 4 page 1399 Parenthesized entries are not part of fptrans. - - -| XO LSB half →
XO MSB half ↓ | 01100 | 01101 | 01110 | 01111 | -|-----------------------------------------------|-----------------------------------|----------------------------------|------------------------------------|-----------------------------------| -| 10000 | `10000 01100`
(ffadds) (draft) | `10000 01101`
fsinpis (draft) | `10000 01110`
fatan2pis (draft) | `10000 01111`
fasinpis (draft) | -| 10001 | `10001 01100`
fcospis (draft) | `10001 01101`
ftanpis (draft) | `10001 01110`
facospis (draft) | `10001 01111`
fatanpis (draft) | -| 10010 | `10010 01100`
**TBD** (draft) | `10010 01101`
fsins (draft) | `10010 01110`
fatan2s (draft) | `10010 01111`
fasins (draft) | -| 10011 | `10011 01100`
fcoss (draft) | `10011 01101`
ftans (draft) | `10011 01110`
facoss (draft) | `10011 01111`
fatans (draft) | -| 10100 | `10100 01100`
**TBD** (draft) | `10100 01101`
fsinhs (draft) | `10100 01110`
fhypots (draft) | `10100 01111`
fasinhs (draft) | -| 10101 | `10101 01100`
fcoshs (draft) | `10101 01101`
ftanhs (draft) | `10101 01110`
facoshs (draft) | `10101 01111`
fatanhs (draft) | -| 10110 | `10110 01100`
**TBD** (draft) | `10110 01101`
**TBD** (draft) | `10110 01110`
**TBD** (draft) | `10110 01111`
**TBD** (draft) | -| 10111 | `10111 01100`
**TBD** (draft) | `10111 01101`
**TBD** (draft) | `10111 01110`
**TBD** (draft) | `10111 01111`
**TBD** (draft) | - -## PO=63 XO=10--011-- - -Power ISA v3.1B opcodes extracted from Power ISA v3.1B Appendix D Table 25 sheet 2 of 4 page 1399 - -| XO LSB half →
XO MSB half ↓ | 01100 | 01101 | 01110 | 01111 | -|-------------------------------------------------|-------|-------|-------|-------| -| 10000 | | | | | -| 10001 | | | | | -| 10010 | | | | | -| 10011 | | | | | -| 10100 | | | | | -| 10101 | | | | | -| 10110 | | | | | -| 10111 | | | | | +Entries whose mnemonic ends in `s` are only in PO=59. +Entries whose mnemonic doesn't end in `s` are only in PO=63. +Entries whose mnemonic ends in `(s)` are in both PO=59 and PO=63. + +| XO LSB half →
XO MSB half ↓ | 01100 | 01101 | 01110 | 01111 | +|-----------------------------------------------|------------------------------------|------------------------------------|--------------------------------------|-------------------------------------| +| 10000 | `10000 01100`
(ffadds) (draft) | `10000 01101`
fsinpi(s) (draft) | `10000 01110`
fatan2pi(s) (draft) | `10000 01111`
fasinpi(s) (draft) | +| 10001 | `10001 01100`
fcospi(s) (draft) | `10001 01101`
ftanpi(s) (draft) | `10001 01110`
facospi(s) (draft) | `10001 01111`
fatanpi(s) (draft) | +| 10010 | `10010 01100`
**TBD** (draft) | `10010 01101`
fsin(s) (draft) | `10010 01110`
fatan2(s) (draft) | `10010 01111`
fasin(s) (draft) | +| 10011 | `10011 01100`
fcos(s) (draft) | `10011 01101`
ftan(s) (draft) | `10011 01110`
facos(s) (draft) | `10011 01111`
fatan(s) (draft) | +| 10100 | `10100 01100`
**TBD** (draft) | `10100 01101`
fsinh(s) (draft) | `10100 01110`
fhypot(s) (draft) | `10100 01111`
fasinh(s) (draft) | +| 10101 | `10101 01100`
fcosh(s) (draft) | `10101 01101`
ftanh(s) (draft) | `10101 01110`
facosh(s) (draft) | `10101 01111`
fatanh(s) (draft) | +| 10110 | `10110 01100`
**TBD** (draft) | `10110 01101`
**TBD** (draft) | `10110 01110`
**TBD** (draft) | `10110 01111`
**TBD** (draft) | +| 10111 | `10111 01100`
**TBD** (draft) | `10111 01101`
**TBD** (draft) | `10111 01110`
**TBD** (draft) | `10111 01111`
**TBD** (draft) | + +| XO LSB half →
XO MSB half ↓ | 01100 | 01101 | 01110 | 01111 | +|-----------------------------------------------|------------------------------------|------------------------------------|--------------------------------------|-------------------------------------| +| 11000 | `11000 01100`
**TBD** (draft) | `11000 01101`
**TBD** (draft) | `11000 01110`
**TBD** (draft) | `11000 01111`
**TBD** (draft) | +| 11001 | `11001 01100`
**TBD** (draft) | `11001 01101`
**TBD** (draft) | `11001 01110`
(fctid) | `11001 01111`
(fctidz) | +| 11010 | `11010 01100`
**TBD** (draft) | `11010 01101`
**TBD** (draft) | `11010 01110`
(fcfid(s)) | `11010 01111`
**TBD** (draft) | +| 11011 | `11011 01100`
**TBD** (draft) | `11011 01101`
**TBD** (draft) | `11011 01110`
**TBD** (draft) | `11011 01111`
**TBD** (draft) | +| 11100 | `11100 01100`
**TBD** (draft) | `11100 01101`
**TBD** (draft) | `11100 01110`
**TBD** (draft) | `11100 01111`
**TBD** (draft) | +| 11101 | `11101 01100`
**TBD** (draft) | `11101 01101`
**TBD** (draft) | `11101 01110`
(fctidu) | `11101 01111`
(fctiduz) | +| 11110 | `11110 01100`
**TBD** (draft) | `11110 01101`
**TBD** (draft) | `11110 01110`
(fcfidu(s)) | `11110 01111`
**TBD** (draft) | +| 11111 | `11111 01100`
**TBD** (draft) | `11111 01101`
**TBD** (draft) | `11111 01110`
**TBD** (draft) | `11111 01111`
**TBD** (draft) | # DRAFT List of 2-arg opcodes diff --git a/openpower/power_trans_ops_copy_from_PO59_table.py b/openpower/power_trans_ops_copy_from_PO59_table.py index 061b7e5f3..91a97e588 100644 --- a/openpower/power_trans_ops_copy_from_PO59_table.py +++ b/openpower/power_trans_ops_copy_from_PO59_table.py @@ -7,12 +7,13 @@ 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 = "## 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): # type: (list[str]) -> None @@ -52,28 +53,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: @@ -107,8 +96,8 @@ def process(lr): cell = line_parts[i] 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 == "": -- 2.30.2