diff --git a/osaca/semantics/arch_semantics.py b/osaca/semantics/arch_semantics.py index 10b3a97..e37a674 100755 --- a/osaca/semantics/arch_semantics.py +++ b/osaca/semantics/arch_semantics.py @@ -192,11 +192,25 @@ class ArchSemantics(ISASemantics): instruction_data = self._machine_model.get_instruction( instruction_form["instruction"], instruction_form["operands"] ) - if not instruction_data and instruction_form["instruction"][-1] in self.GAS_SUFFIXES: + if ( + not instruction_data + and self._isa == "x86" + and instruction_form["instruction"][-1] in self.GAS_SUFFIXES + ): # check for instruction without GAS suffix instruction_data = self._machine_model.get_instruction( instruction_form["instruction"][:-1], instruction_form["operands"] ) + if ( + instruction_data is None + and self._isa == "aarch64" + and "." in instruction_form["instruction"] + ): + # Check for instruction without shape/cc suffix + suffix_start = instruction_form["instruction"].index(".") + instruction_data = self._machine_model.get_instruction( + instruction_form["instruction"][:suffix_start], instruction_form["operands"] + ) if instruction_data: # instruction form in DB ( @@ -223,12 +237,23 @@ class ArchSemantics(ISASemantics): ) if ( not instruction_data_reg + and self._isa == "x86" and instruction_form["instruction"][-1] in self.GAS_SUFFIXES ): # check for instruction without GAS suffix instruction_data_reg = self._machine_model.get_instruction( instruction_form["instruction"][:-1], operands ) + if ( + instruction_data_reg is None + and self._isa == "aarch64" + and "." in instruction_form["instruction"] + ): + # Check for instruction without shape/cc suffix + suffix_start = instruction_form["instruction"].index(".") + instruction_data_reg = self._machine_model.get_instruction( + instruction_form["instruction"][:suffix_start], operands + ) if instruction_data_reg: assign_unknown = False reg_type = self._parser.get_reg_type( diff --git a/osaca/semantics/isa_semantics.py b/osaca/semantics/isa_semantics.py index fca5955..15b6a49 100755 --- a/osaca/semantics/isa_semantics.py +++ b/osaca/semantics/isa_semantics.py @@ -55,11 +55,25 @@ class ISASemantics(object): isa_data = self._isa_model.get_instruction( instruction_form["instruction"], instruction_form["operands"] ) - if isa_data is None and instruction_form["instruction"][-1] in self.GAS_SUFFIXES: + if ( + isa_data is None + and self._isa == "x86" + and instruction_form["instruction"][-1] in self.GAS_SUFFIXES + ): # Check for instruction without GAS suffix isa_data = self._isa_model.get_instruction( instruction_form["instruction"][:-1], instruction_form["operands"] ) + if ( + isa_data is None + and self._isa == "aarch64" + and "." in instruction_form["instruction"] + ): + # Check for instruction without shape/cc suffix + suffix_start = instruction_form["instruction"].index(".") + isa_data = self._isa_model.get_instruction( + instruction_form["instruction"][:suffix_start], instruction_form["operands"] + ) operands = instruction_form["operands"] op_dict = {} assign_default = False @@ -77,12 +91,23 @@ class ISASemantics(object): ) if ( isa_data_reg is None + and self._isa == "x86" and instruction_form["instruction"][-1] in self.GAS_SUFFIXES ): # Check for instruction without GAS suffix isa_data_reg = self._isa_model.get_instruction( instruction_form["instruction"][:-1], operands_reg ) + if ( + isa_data_reg is None + and self._isa == "aarch64" + and "." in instruction_form["instruction"] + ): + # Check for instruction without shape/cc suffix + suffix_start = instruction_form["instruction"].index(".") + isa_data_reg = self._isa_model.get_instruction( + instruction_form["instruction"][:suffix_start], operands_reg + ) if isa_data_reg: assign_default = False op_dict = self._apply_found_ISA_data(isa_data_reg, operands) @@ -159,11 +184,25 @@ class ISASemantics(object): isa_data = self._isa_model.get_instruction( instruction_form["instruction"], instruction_form["operands"] ) - if isa_data is None and instruction_form["instruction"][-1] in self.GAS_SUFFIXES: + if ( + isa_data is None + and self._isa == "x86" + and instruction_form["instruction"][-1] in self.GAS_SUFFIXES + ): # Check for instruction without GAS suffix isa_data = self._isa_model.get_instruction( instruction_form["instruction"][:-1], instruction_form["operands"] ) + if ( + isa_data is None + and self._isa == "aarch64" + and "." in instruction_form["instruction"] + ): + # Check for instruction without shape/cc suffix + suffix_start = instruction_form["instruction"].index(".") + isa_data = self._isa_model.get_instruction( + instruction_form["instruction"][:suffix_start], instruction_form["operands"] + ) if only_postindexed: for o in instruction_form.operands: diff --git a/tests/test_semantics.py b/tests/test_semantics.py index 327f173..35daf47 100755 --- a/tests/test_semantics.py +++ b/tests/test_semantics.py @@ -159,6 +159,10 @@ class TestSemanticTools(unittest.TestCase): test_mm_arm.get_instruction("b.ne", [{"class": "identifier"}]), test_mm_arm.get_instruction("b.ne", [{"class": "identifier"}]), ) + self.assertEqual( + test_mm_arm.get_instruction("b.someNameThatDoesNotExist", [{"class": "identifier"}]), + test_mm_arm.get_instruction("b.someOtherName", [{"class": "identifier"}]), + ) # test full instruction name self.assertEqual(