Skip to content

Commit fd6b07b

Browse files
committed
AArch64: Add support for repeated .<dt> specifiers
- Add support for using repeated .<dt> in instruction patterns, while keeping backward compatibility. - Introduce a new static method `_replace_duplicate_mnemonicKey()` in `AArch64Instruction` to handle duplicate <dt> specifiers during parsing and writing. Signed-off-by: willieyz <willie.zhao@chelpis.com>
1 parent 3c6e3f4 commit fd6b07b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

slothy/targets/aarch64/aarch64_neon.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,16 @@ class AArch64Instruction(Instruction):
806806

807807
PARSERS = {}
808808

809+
@staticmethod
810+
def _replace_duplicate_mnemonicKey(src, mnemonic_key):
811+
pattern = f"<{mnemonic_key}>"
812+
813+
cnt = src.count(pattern)
814+
if cnt > 1:
815+
for i in range(cnt):
816+
src = re.sub(pattern, f"<{mnemonic_key}{i}>", src, count=1)
817+
return src
818+
809819
@staticmethod
810820
def _unfold_pattern(src):
811821

@@ -882,6 +892,7 @@ def pattern_i(i):
882892
index_pattern = "[0-9]+"
883893

884894
src = replace_placeholders(src, "imm", imm_pattern, "imm")
895+
src = AArch64Instruction._replace_duplicate_mnemonicKey(src, "dt")
885896
src = replace_placeholders(src, "dt", dt_pattern, "datatype")
886897
src = replace_placeholders(src, "index", index_pattern, "index")
887898
src = replace_placeholders(src, "flag", flag_pattern, "flag")
@@ -1131,6 +1142,7 @@ def t_default(x):
11311142
return txt
11321143

11331144
out = replace_pattern(out, "immediate", "imm", lambda x: f"#{x}")
1145+
out = AArch64Instruction._replace_duplicate_mnemonicKey(out, "dt")
11341146
out = replace_pattern(out, "datatype", "dt", lambda x: x.upper())
11351147
out = replace_pattern(out, "flag", "flag")
11361148
out = replace_pattern(out, "index", "index", str)
@@ -3497,7 +3509,7 @@ class vumlsl2(Vmlal):
34973509

34983510

34993511
class vsmlsl(Vmlal):
3500-
pattern = "smlsl <Vd>.<dt0>, <Va>.<dt1>, <Vb>.<dt2>"
3512+
pattern = "smlsl <Vd>.<dt>, <Va>.<dt>, <Vb>.<dt>"
35013513
inputs = ["Va", "Vb"]
35023514
in_outs = ["Vd"]
35033515

0 commit comments

Comments
 (0)