summary refs log tree commit diff stats
path: root/target/hexagon/gen_decodetree.py
diff options
context:
space:
mode:
authorTaylor Simpson <ltaylorsimpson@gmail.com>2024-01-15 15:14:42 -0700
committerBrian Cain <bcain@quicinc.com>2024-01-21 22:02:40 -0800
commitf6c01009b5846b1e7c56b4be3413924d87a7bbea (patch)
tree1e6a19a0d909717eab5cb9d581205ef97dae74ef /target/hexagon/gen_decodetree.py
parent1547a2d3394d7ec87350ab8ca4022d5e0f20db01 (diff)
downloadfocaccia-qemu-f6c01009b5846b1e7c56b4be3413924d87a7bbea.tar.gz
focaccia-qemu-f6c01009b5846b1e7c56b4be3413924d87a7bbea.zip
Hexagon (target/hexagon) Use QEMU decodetree (16-bit instructions)
Section 10.3 of the Hexagon V73 Programmer's Reference Manual

A duplex is encoded as a 32-bit instruction with bits [15:14] set to 00.
The sub-instructions that comprise a duplex are encoded as 13-bit fields
in the duplex.

Create a decoder for each subinstruction class (a, l1, l2, s1, s2).

Extend gen_trans_funcs.py to handle all instructions rather than
filter by instruction class.

There is a g_assert_not_reached() in decode_insns() in decode.c to
verify we never try to use the old decoder on 16-bit instructions.

Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Reviewed-by: Brian Cain <bcain@quicinc.com>
Message-Id: <20240115221443.365287-3-ltaylorsimpson@gmail.com>
Signed-off-by: Brian Cain <bcain@quicinc.com>
Diffstat (limited to 'target/hexagon/gen_decodetree.py')
-rwxr-xr-xtarget/hexagon/gen_decodetree.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/target/hexagon/gen_decodetree.py b/target/hexagon/gen_decodetree.py
index 9634554142..a4fcd622c5 100755
--- a/target/hexagon/gen_decodetree.py
+++ b/target/hexagon/gen_decodetree.py
@@ -96,8 +96,10 @@ def skip_tag(tag, class_to_decode):
 ##     A2_add   ..................-.....---..... @A2_add
 ##
 def gen_decodetree_file(f, class_to_decode):
+    is_subinsn = class_to_decode.startswith("SUBINSN_")
     f.write(f"## DO NOT MODIFY - This file is generated by {sys.argv[0]}\n\n")
-    f.write("%PP\t14:2\n\n")
+    if not is_subinsn:
+        f.write("%PP\t14:2\n\n")
     for tag in sorted(encs.keys(), key=iset.tags.index):
         if skip_tag(tag, class_to_decode):
             continue
@@ -108,6 +110,10 @@ def gen_decodetree_file(f, class_to_decode):
                 f"## {tag}:\t{enc_str}\n"
                 "##\n")
 
+        # The subinstructions come with a 13-bit encoding, but
+        # decodetree.py needs 16 bits
+        if is_subinsn:
+            enc_str = "---" + enc_str
 
         regs = ordered_unique(regre.findall(iset.iset[tag]["syntax"]))
         imms = ordered_unique(immre.findall(iset.iset[tag]["syntax"]))
@@ -174,7 +180,9 @@ def gen_decodetree_file(f, class_to_decode):
             imm_letter = "i" if imm_type.islower() else "I"
             f.write(f" {imm_type}{imm_letter}=%{tag}_{imm_type}{imm_letter}")
 
-        f.write(" %PP\n")
+        if not is_subinsn:
+            f.write(" %PP")
+        f.write("\n")
 
          # Replace the 0s and 1s with .
         enc_str = enc_str.replace("0", ".").replace("1", ".")