diff --git a/suite/auto-sync/src/autosync/MCUpdater.py b/suite/auto-sync/src/autosync/MCUpdater.py index 96da2b2f50..9d6b5adeb0 100755 --- a/suite/auto-sync/src/autosync/MCUpdater.py +++ b/suite/auto-sync/src/autosync/MCUpdater.py @@ -16,12 +16,11 @@ class LLVM_MC_Command: - def __init__(self, cmd_line: str, mattr: str, mattr_map: dict = dict()): + def __init__(self, cmd_line: str, mattr: str): self.cmd: str = "" self.opts: str = "" self.file: Path | None = None self.additional_mattr: str = mattr - self.mattr_map: dict = mattr_map self.cmd, self.opts, self.file = self.parse_llvm_mc_line(cmd_line) if not (self.cmd and self.opts and self.file): @@ -48,10 +47,7 @@ def parse_llvm_mc_line(self, line: str) -> tuple[str, str, Path]: processed_attr = list() for m in mattr: attribute = m.group(2).strip("+") - if attribute in self.mattr_map: - processed_attr.append(self.mattr_map[attribute]) - else: - processed_attr.append(attribute) + processed_attr.append(attribute) opts += ",".join(processed_attr) return cmd, opts, Path(test_file) @@ -90,11 +86,7 @@ class MCTest: def __init__(self, arch: str, opts: list[str], encoding: str, asm_text: str): self.arch = arch - if arch.lower() in ["arm", "powerpc", "ppc", "aarch64"]: - # Arch and PPC require this option for MC tests. - self.opts = ["CS_OPT_NO_BRANCH_OFFSET"] + opts - else: - self.opts = opts + self.opts = opts self.encoding: list[str] = [encoding] self.asm_text: list[str] = [asm_text] @@ -275,7 +267,7 @@ def __init__( else "" ) # A list of options which are always added. - self.mandatory_options: str = ( + self.mandatory_options: list[str] = ( self.conf["mandatory_options"][self.arch] if self.arch in self.conf["mandatory_options"] else list() @@ -286,13 +278,15 @@ def __init__( else list() ) self.remove_options = [x.lower() for x in self.remove_options] - self.replace_option_map: str = ( + self.replace_option_map: dict = ( self.conf["replace_option_map"][self.arch] if self.arch in self.conf["replace_option_map"] else {} ) self.replace_option_map = { - k.lower(): v for k, v in self.replace_option_map.items() + k.lower(): v + for k, v in self.replace_option_map.items() + if k.lower not in self.remove_options } self.multi_mode = multi_mode @@ -471,15 +465,7 @@ def extract_llvm_mc_cmds(self, cmds: str) -> list[LLVM_MC_Command]: continue if any(re.search(x, match) is not None for x in self.excluded): continue - llvm_mc_cmd = LLVM_MC_Command( - match, - self.mattr, - ( - self.conf["mode_map"][self.arch] - if self.arch in self.conf["mode_map"] - else dict() - ), - ) + llvm_mc_cmd = LLVM_MC_Command(match, self.mattr) if not llvm_mc_cmd.cmd: # Invalid continue diff --git a/suite/auto-sync/src/autosync/Tests/MCUpdaterTests/expected/mode_mapping/test_systemz_mapping.txt.yaml b/suite/auto-sync/src/autosync/Tests/MCUpdaterTests/expected/mode_mapping/test_systemz_mapping.txt.yaml index f7f636e5cc..7289cc256a 100644 --- a/suite/auto-sync/src/autosync/Tests/MCUpdaterTests/expected/mode_mapping/test_systemz_mapping.txt.yaml +++ b/suite/auto-sync/src/autosync/Tests/MCUpdaterTests/expected/mode_mapping/test_systemz_mapping.txt.yaml @@ -3,7 +3,7 @@ test_cases: input: bytes: [ 0xed, 0x00, 0x00, 0x00, 0x00, 0xae ] arch: "CS_ARCH_SYSTEMZ" - options: [ "s390x-linux-gnu", "CS_MODE_SYSTEMZ_Z13", "CS_MODE_BIG_ENDIAN" ] + options: [ "CS_MODE_BIG_ENDIAN", "s390x-linux-gnu", "CS_MODE_SYSTEMZ_Z13" ] expected: insns: - @@ -13,7 +13,7 @@ test_cases: input: bytes: [ 0xed, 0x00, 0x00, 0x00, 0xf0, 0xae ] arch: "CS_ARCH_SYSTEMZ" - options: [ "s390x-linux-gnu", "CS_MODE_SYSTEMZ_Z13", "CS_MODE_BIG_ENDIAN" ] + options: [ "CS_MODE_BIG_ENDIAN", "s390x-linux-gnu", "CS_MODE_SYSTEMZ_Z13" ] expected: insns: - @@ -23,7 +23,7 @@ test_cases: input: bytes: [ 0xed, 0x00, 0x00, 0x00, 0x0f, 0xae ] arch: "CS_ARCH_SYSTEMZ" - options: [ "s390x-linux-gnu", "CS_MODE_SYSTEMZ_Z13", "CS_MODE_BIG_ENDIAN" ] + options: [ "CS_MODE_BIG_ENDIAN", "s390x-linux-gnu", "CS_MODE_SYSTEMZ_Z13" ] expected: insns: - @@ -33,7 +33,7 @@ test_cases: input: bytes: [ 0xed, 0x00, 0x10, 0x00, 0x00, 0xae ] arch: "CS_ARCH_SYSTEMZ" - options: [ "s390x-linux-gnu", "CS_MODE_SYSTEMZ_Z13", "CS_MODE_BIG_ENDIAN" ] + options: [ "CS_MODE_BIG_ENDIAN", "s390x-linux-gnu", "CS_MODE_SYSTEMZ_Z13" ] expected: insns: - @@ -43,7 +43,7 @@ test_cases: input: bytes: [ 0xed, 0x00, 0x00, 0x00, 0x00, 0xae ] arch: "CS_ARCH_SYSTEMZ" - options: [ "s390x-linux-gnu", "CS_MODE_SYSTEMZ_ARCH11", "CS_MODE_BIG_ENDIAN" ] + options: [ "CS_MODE_BIG_ENDIAN", "s390x-linux-gnu", "CS_MODE_SYSTEMZ_ARCH11" ] expected: insns: - @@ -53,7 +53,7 @@ test_cases: input: bytes: [ 0xed, 0x00, 0x00, 0x00, 0xf0, 0xae ] arch: "CS_ARCH_SYSTEMZ" - options: [ "s390x-linux-gnu", "CS_MODE_SYSTEMZ_ARCH11", "CS_MODE_BIG_ENDIAN" ] + options: [ "CS_MODE_BIG_ENDIAN", "s390x-linux-gnu", "CS_MODE_SYSTEMZ_ARCH11" ] expected: insns: - @@ -63,7 +63,7 @@ test_cases: input: bytes: [ 0xed, 0x00, 0x00, 0x00, 0x0f, 0xae ] arch: "CS_ARCH_SYSTEMZ" - options: [ "s390x-linux-gnu", "CS_MODE_SYSTEMZ_ARCH11", "CS_MODE_BIG_ENDIAN" ] + options: [ "CS_MODE_BIG_ENDIAN", "s390x-linux-gnu", "CS_MODE_SYSTEMZ_ARCH11" ] expected: insns: - @@ -73,7 +73,7 @@ test_cases: input: bytes: [ 0xed, 0x00, 0x10, 0x00, 0x00, 0xae ] arch: "CS_ARCH_SYSTEMZ" - options: [ "s390x-linux-gnu", "CS_MODE_SYSTEMZ_ARCH11", "CS_MODE_BIG_ENDIAN" ] + options: [ "CS_MODE_BIG_ENDIAN", "s390x-linux-gnu", "CS_MODE_SYSTEMZ_ARCH11" ] expected: insns: - diff --git a/suite/auto-sync/src/autosync/cpptranslator/arch_config.json b/suite/auto-sync/src/autosync/cpptranslator/arch_config.json index 6b0d449a2b..d75297de79 100644 --- a/suite/auto-sync/src/autosync/cpptranslator/arch_config.json +++ b/suite/auto-sync/src/autosync/cpptranslator/arch_config.json @@ -212,7 +212,8 @@ "DecodeDEXT", "DecodeCRC", "isReg" - ] + ], + "manually_edited_files": [] }, "SystemZ": { "files_to_translate": [ diff --git a/suite/auto-sync/src/autosync/mcupdater.json b/suite/auto-sync/src/autosync/mcupdater.json index c558323635..92a6fb9651 100644 --- a/suite/auto-sync/src/autosync/mcupdater.json +++ b/suite/auto-sync/src/autosync/mcupdater.json @@ -1,4 +1,7 @@ { + "unify_test_cases": [ + "ARM" + ], "additional_mattr": { "AArch64": @@ -15,6 +18,18 @@ "Mips": [ "CS_OPT_SYNTAX_NOREGNAME" + ], + "PPC": + [ + "CS_OPT_NO_BRANCH_OFFSET" + ], + "ARM": + [ + "CS_OPT_NO_BRANCH_OFFSET" + ], + "AArch64": + [ + "CS_OPT_NO_BRANCH_OFFSET" ] }, "remove_options":