diff --git a/slothy/targets/arm_v7m/arch_v7m.py b/slothy/targets/arm_v7m/arch_v7m.py index 1de96011..7b3a9bd1 100644 --- a/slothy/targets/arm_v7m/arch_v7m.py +++ b/slothy/targets/arm_v7m/arch_v7m.py @@ -1167,6 +1167,20 @@ class movt_imm(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,inval pattern = "movt , " in_outs = ["Rd"] +class mov(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "mov ," + inputs = ["Ra"] + outputs = ["Rd"] + +class mov_imm(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "mov ," + outputs = ["Rd"] + +class movs_imm(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "movs ," + outputs = ["Rd"] + modifiesFlags=True + # Addition class add(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name pattern = "add , , " @@ -1198,6 +1212,18 @@ class adds(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-n outputs = ["Rd"] modifiesFlags=True +class adds_short(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "adds ," + inputs = ["Ra"] + in_outs = ["Rd"] + modifiesFlags=True + +class adds_imm(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "adds ,," + inputs = ["Ra"] + outputs = ["Rd"] + modifiesFlags=True + class uadd16(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name pattern = "uadd16 , , " inputs = ["Ra","Rb"] @@ -1208,6 +1234,32 @@ class sadd16(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid inputs = ["Ra","Rb"] outputs = ["Rd"] +class adc(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "adc ,," + inputs = ["Ra", "Rb"] + outputs = ["Rd"] + dependsOnFlags=True + +class adcs(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "adcs ,," + inputs = ["Ra", "Rb"] + outputs = ["Rd"] + dependsOnFlags=True + modifiesFlags=True + +class adcs_short(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "adcs ," + inputs = ["Ra"] + in_outs = ["Rd"] + dependsOnFlags=True + modifiesFlags=True + +class adcs_imm_short(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "adcs ," + in_outs = ["Rd"] + dependsOnFlags=True + modifiesFlags=True + # Subtraction class sub(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name pattern = "sub , , " @@ -1234,11 +1286,30 @@ class subs_imm(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,inval outputs = ["Rd"] modifiesFlags = True +class subs_short(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "subs ," + inputs = ["Ra"] + in_outs = ["Rd"] + modifiesFlags = True + class subs_imm_short(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name pattern = "subs , " in_outs = ["Ra"] modifiesFlags = True +class sbc_short(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "sbc ," + inputs = ["Ra"] + in_outs = ["Rd"] + dependsOnFlags=True + +class sbcs_short(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name + pattern = "sbcs ," + inputs = ["Ra"] + in_outs = ["Rd"] + modifiesFlags = True + dependsOnFlags=True + class usub16(Armv7mBasicArithmetic): # pylint: disable=missing-docstring,invalid-name pattern = "usub16 , , " inputs = ["Ra","Rb"] @@ -1354,6 +1425,16 @@ class smuadx(Armv7mMultiplication): # pylint: disable=missing-docstring,invalid- # Logical +class umaal(Armv7mMultiplication): # pylint: disable=missing-docstring,invalid-name + pattern = "umaal ,,," + inputs = ["Rc","Rd"] + in_outs = ["Ra", "Rb"] + +class umull(Armv7mMultiplication): # pylint: disable=missing-docstring,invalid-name + pattern = "umull ,,," + inputs = ["Rc","Rd"] + outputs = ["Ra", "Rb"] + class neg_short(Armv7mLogical): # pylint: disable=missing-docstring,invalid-name pattern = "neg , " inputs = ["Ra"] @@ -1368,6 +1449,11 @@ class log_and_shifted(Armv7mShiftedLogical): # pylint: disable=missing-docstring inputs = ["Ra", "Rb"] outputs = ["Rd"] +class log_and_imm(Armv7mLogical): # pylint: disable=missing-docstring,invalid-name + pattern = "and ,," + inputs = ["Ra"] + outputs = ["Rd"] + class log_or(Armv7mLogical): # pylint: disable=missing-docstring,invalid-name pattern = "orr , , " inputs = ["Ra", "Rb"] @@ -1414,6 +1500,11 @@ class bic(Armv7mLogical): # pylint: disable=missing-docstring,invalid-name inputs = ["Ra", "Rb"] outputs = ["Rd"] +class bic_imm(Armv7mLogical): # pylint: disable=missing-docstring,invalid-name + pattern = "bic ,," + inputs = ["Ra"] + outputs = ["Rd"] + class bics(Armv7mLogical): # pylint: disable=missing-docstring,invalid-name pattern = "bics , , " inputs = ["Ra", "Rb"] @@ -1486,7 +1577,6 @@ def make(cls, src): obj.increment = None obj.pre_index = 0 obj.addr = obj.args_in[0] - obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra return obj def write(self): @@ -1505,7 +1595,6 @@ def make(cls, src): obj.increment = None obj.pre_index = obj.immediate obj.addr = obj.args_in[0] - obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra return obj def write(self): @@ -1528,7 +1617,6 @@ def make(cls, src): obj = Armv7mInstruction.build(cls, src) obj.increment = None obj.pre_index = obj.immediate - obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra obj.addr = obj.args_in[0] return obj @@ -1545,7 +1633,6 @@ def make(cls, src): obj = Armv7mInstruction.build(cls, src) obj.increment = None obj.pre_index = obj.immediate - obj.args_in_out_different = [(0,0)] # Can't have Rd==Ra obj.addr = obj.args_in[0] return obj @@ -1625,6 +1712,17 @@ def make(cls, src): obj.addr = obj.args_in_out[0] return obj +class ldrd_with_imm_stack(Ldrd): # pylint: disable=missing-docstring,invalid-name + pattern = "ldrd ,,[sp,]" + outputs = ["Rd","Ra"] + @classmethod + def make(cls, src): + obj = Armv7mInstruction.build(cls, src) + obj.increment = None + obj.pre_index = obj.immediate + obj.addr = "sp" + return obj + class ldrd_with_postinc(Ldrd): # pylint: disable=missing-docstring,invalid-name pattern = "ldrd , , [], " in_outs = [ "Rc" ] @@ -1828,6 +1926,22 @@ def write(self): self.immediate = simplify(self.pre_index) return super().write() +class strd_with_imm_stack(Armv7mStoreInstruction): # pylint: disable=missing-docstring,invalid-name + pattern = "strd ,,[sp,]" + inputs = ["Rd","Ra"] + outputs = [] + @classmethod + def make(cls, src): + obj = Armv7mInstruction.build(cls, src) + obj.increment = None + obj.pre_index = obj.immediate + obj.addr = "sp" + return obj + + def write(self): + self.immediate = simplify(self.pre_index) + return super().write() + class str_with_postinc(Armv7mStoreInstruction): # pylint: disable=missing-docstring,invalid-name pattern = "str , [], " inputs = ["Rd"] @@ -1893,6 +2007,61 @@ class bne(Armv7mBranch): # pylint: disable=missing-docstring,invalid-name pattern = "bne