working on fptrans opcode table
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 6 Sep 2022 10:59:29 +0000 (03:59 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Tue, 6 Sep 2022 10:59:29 +0000 (03:59 -0700)
openpower/power_trans_ops.mdwn
openpower/power_trans_ops_copy_from_PO59_table.py

index c1aa551f7cc9245ed4cf9a5d296f8bd7aec38276..a3918bfd3c6ac52d747a27e60b9556b399582b98 100644 (file)
@@ -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.
 
-<!-- <template> is used to make html ignore what's inside it,
-needed since pandoc conversion to latex ignores <br> tags-->
-
-| XO LSB half &#x2192;<br> XO MSB half &#x2193; | 01100                             | 01101                            | 01110                              | 01111                             |
-|-----------------------------------------------|-----------------------------------|----------------------------------|------------------------------------|-----------------------------------|
-| 10000                                         | `10000 01100`<br>(ffadds) (draft) | `10000 01101`<br>fsinpis (draft) | `10000 01110`<br>fatan2pis (draft) | `10000 01111`<br>fasinpis (draft) |
-| 10001                                         | `10001 01100`<br>fcospis (draft)  | `10001 01101`<br>ftanpis (draft) | `10001 01110`<br>facospis (draft)  | `10001 01111`<br>fatanpis (draft) |
-| 10010                                         | `10010 01100`<br>**TBD** (draft)  | `10010 01101`<br>fsins (draft)   | `10010 01110`<br>fatan2s (draft)   | `10010 01111`<br>fasins (draft)   |
-| 10011                                         | `10011 01100`<br>fcoss (draft)    | `10011 01101`<br>ftans (draft)   | `10011 01110`<br>facoss (draft)    | `10011 01111`<br>fatans (draft)   |
-| 10100                                         | `10100 01100`<br>**TBD** (draft)  | `10100 01101`<br>fsinhs (draft)  | `10100 01110`<br>fhypots (draft)   | `10100 01111`<br>fasinhs (draft)  |
-| 10101                                         | `10101 01100`<br>fcoshs (draft)   | `10101 01101`<br>ftanhs (draft)  | `10101 01110`<br>facoshs (draft)   | `10101 01111`<br>fatanhs (draft)  |
-| 10110                                         | `10110 01100`<br>**TBD** (draft)  | `10110 01101`<br>**TBD** (draft) | `10110 01110`<br>**TBD** (draft)   | `10110 01111`<br>**TBD** (draft)  |
-| 10111                                         | `10111 01100`<br>**TBD** (draft)  | `10111 01101`<br>**TBD** (draft) | `10111 01110`<br>**TBD** (draft)   | `10111 01111`<br>**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 &#x2192; <br/> XO MSB half &#x2193; | 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 &#x2192;<br> XO MSB half &#x2193; | 01100                              | 01101                              | 01110                                | 01111                               |
+|-----------------------------------------------|------------------------------------|------------------------------------|--------------------------------------|-------------------------------------|
+| 10000                                         | <small>`10000 01100`</small><br>(ffadds) (draft)  | <small>`10000 01101`</small><br>fsinpi(s) (draft) | <small>`10000 01110`</small><br>fatan2pi(s) (draft) | <small>`10000 01111`</small><br>fasinpi(s) (draft) |
+| 10001                                         | <small>`10001 01100`</small><br>fcospi(s) (draft) | <small>`10001 01101`</small><br>ftanpi(s) (draft) | <small>`10001 01110`</small><br>facospi(s) (draft)  | <small>`10001 01111`</small><br>fatanpi(s) (draft) |
+| 10010                                         | <small>`10010 01100`</small><br>**TBD** (draft)   | <small>`10010 01101`</small><br>fsin(s) (draft)   | <small>`10010 01110`</small><br>fatan2(s) (draft)   | <small>`10010 01111`</small><br>fasin(s) (draft)   |
+| 10011                                         | <small>`10011 01100`</small><br>fcos(s) (draft)   | <small>`10011 01101`</small><br>ftan(s) (draft)   | <small>`10011 01110`</small><br>facos(s) (draft)    | <small>`10011 01111`</small><br>fatan(s) (draft)   |
+| 10100                                         | <small>`10100 01100`</small><br>**TBD** (draft)   | <small>`10100 01101`</small><br>fsinh(s) (draft)  | <small>`10100 01110`</small><br>fhypot(s) (draft)   | <small>`10100 01111`</small><br>fasinh(s) (draft)  |
+| 10101                                         | <small>`10101 01100`</small><br>fcosh(s) (draft)  | <small>`10101 01101`</small><br>ftanh(s) (draft)  | <small>`10101 01110`</small><br>facosh(s) (draft)   | <small>`10101 01111`</small><br>fatanh(s) (draft)  |
+| 10110                                         | <small>`10110 01100`</small><br>**TBD** (draft)   | <small>`10110 01101`</small><br>**TBD** (draft)   | <small>`10110 01110`</small><br>**TBD** (draft)     | <small>`10110 01111`</small><br>**TBD** (draft)    |
+| 10111                                         | <small>`10111 01100`</small><br>**TBD** (draft)   | <small>`10111 01101`</small><br>**TBD** (draft)   | <small>`10111 01110`</small><br>**TBD** (draft)     | <small>`10111 01111`</small><br>**TBD** (draft)    |
+
+| XO LSB half &#x2192;<br> XO MSB half &#x2193; | 01100                              | 01101                              | 01110                                | 01111                               |
+|-----------------------------------------------|------------------------------------|------------------------------------|--------------------------------------|-------------------------------------|
+| 11000                                         | <small>`11000 01100`</small><br>**TBD** (draft)   | <small>`11000 01101`</small><br>**TBD** (draft)   | <small>`11000 01110`</small><br>**TBD** (draft)     | <small>`11000 01111`</small><br>**TBD** (draft)    |
+| 11001                                         | <small>`11001 01100`</small><br>**TBD** (draft)   | <small>`11001 01101`</small><br>**TBD** (draft)   | <small>`11001 01110`</small><br>(fctid)             | <small>`11001 01111`</small><br>(fctidz)           |
+| 11010                                         | <small>`11010 01100`</small><br>**TBD** (draft)   | <small>`11010 01101`</small><br>**TBD** (draft)   | <small>`11010 01110`</small><br>(fcfid(s))          | <small>`11010 01111`</small><br>**TBD** (draft)    |
+| 11011                                         | <small>`11011 01100`</small><br>**TBD** (draft)   | <small>`11011 01101`</small><br>**TBD** (draft)   | <small>`11011 01110`</small><br>**TBD** (draft)     | <small>`11011 01111`</small><br>**TBD** (draft)    |
+| 11100                                         | <small>`11100 01100`</small><br>**TBD** (draft)   | <small>`11100 01101`</small><br>**TBD** (draft)   | <small>`11100 01110`</small><br>**TBD** (draft)     | <small>`11100 01111`</small><br>**TBD** (draft)    |
+| 11101                                         | <small>`11101 01100`</small><br>**TBD** (draft)   | <small>`11101 01101`</small><br>**TBD** (draft)   | <small>`11101 01110`</small><br>(fctidu)            | <small>`11101 01111`</small><br>(fctiduz)          |
+| 11110                                         | <small>`11110 01100`</small><br>**TBD** (draft)   | <small>`11110 01101`</small><br>**TBD** (draft)   | <small>`11110 01110`</small><br>(fcfidu(s))         | <small>`11110 01111`</small><br>**TBD** (draft)    |
+| 11111                                         | <small>`11111 01100`</small><br>**TBD** (draft)   | <small>`11111 01101`</small><br>**TBD** (draft)   | <small>`11111 01110`</small><br>**TBD** (draft)     | <small>`11111 01111`</small><br>**TBD** (draft)    |
 
 # DRAFT List of 2-arg opcodes
 
index 061b7e5f358c283430a11701eb7c8602c4599ddd..91a97e588c75663b009541b805daca8a63945bf6 100644 (file)
@@ -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 &#x2192; <br/> XO MSB half &#x2193; |"), \
-            "can't find PO=59 table"
+            "| XO LSB half &#x2192;<br> XO MSB half &#x2193; |"), \
+            "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" *<small> *` *(?P<xo>[01][01 ]*[01]) *` *</small>"
-                    r" *<br/> *(?P<mnemonic>[a-zA-Z0-9_.]+)?"
-                    r"(?(mnemonic)|(?:\([a-zA-Z0-9_.]+\)|\*\*TBD\*\*|))"
+                    r" *<br/?> *(?P<mnemonic>[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 == "":