From 6c88fdf3b681be4727e5523179d10de2d62e587a Mon Sep 17 00:00:00 2001 From: "Matthias J. Kannwischer" Date: Thu, 17 Oct 2024 19:42:17 +0800 Subject: [PATCH] allow more powerful expressions in immediate --- slothy/targets/arm_v7m/cortex_m7.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/slothy/targets/arm_v7m/cortex_m7.py b/slothy/targets/arm_v7m/cortex_m7.py index 3520850e..17d43c05 100644 --- a/slothy/targets/arm_v7m/cortex_m7.py +++ b/slothy/targets/arm_v7m/cortex_m7.py @@ -82,11 +82,11 @@ def is_ldr_pair(inst_a, inst_b): def evaluate_immediate(string_expr): if string_expr is None: return 0 - if re.fullmatch(r"[*+\-0-9 ]+", string_expr): + if re.fullmatch(r"[*+\-/0-9 ()]+", string_expr): + # TODO: use something safer here return int(eval(string_expr)) else: raise Exception(f"could not parse {string_expr}") - # The Cortex-M7 has two memory banks # If two loads use the same memory bank, they cannot dual issue # There are no constraints which load can go to which issue slot @@ -94,6 +94,7 @@ def evaluate_immediate(string_expr): for t0, t1 in slothy.get_inst_pairs(cond=is_ldr_pair): if t0 == t1: continue + imm0 = evaluate_immediate(t0.inst.immediate) imm1 = evaluate_immediate(t1.inst.immediate) if (imm0 % 8) // 4 == (imm1 % 8) // 4: