diff --git a/slothy/core/slothy.py b/slothy/core/slothy.py index d2880ded..83bfe85b 100644 --- a/slothy/core/slothy.py +++ b/slothy/core/slothy.py @@ -472,7 +472,10 @@ def optimize_loop(self, loop_lbl, postamble_label=None, forced_loop_type=None): early, body, late, _, other_data, loop = \ self.arch.Loop.extract(self.source, loop_lbl, forced_loop_type=forced_loop_type) - loop_cnt = other_data['cnt'] + try: + loop_cnt = other_data['cnt'] + except KeyError: + loop_cnt = None # Check if the body has a dominant indentation indentation = AsmHelper.find_indentation(body) diff --git a/slothy/targets/arm_v7m/arch_v7m.py b/slothy/targets/arm_v7m/arch_v7m.py index abac28ac..57eca424 100644 --- a/slothy/targets/arm_v7m/arch_v7m.py +++ b/slothy/targets/arm_v7m/arch_v7m.py @@ -297,6 +297,97 @@ def end(self, other, indentation=0): yield f'{indent}cmp {other["cnt"]}, {other["end"]}' yield f'{indent}bne {lbl_start}' + +class BranchLoop(Loop): + def __init__(self, lbl="lbl", lbl_start="1", lbl_end="2", loop_init="lr") -> None: + super().__init__(lbl_start=lbl_start, lbl_end=lbl_end, loop_init=loop_init) + self.lbl = lbl + self.lbl_regex = r"^\s*(?P