Skip to content

Commit

Permalink
allow more powerful expressions in immediate
Browse files Browse the repository at this point in the history
  • Loading branch information
mkannwischer committed Oct 17, 2024
1 parent 39c9c80 commit 6c88fdf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions slothy/targets/arm_v7m/cortex_m7.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,19 @@ 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
# Approximiation: Only look at immediates, i.e., assume all pointers are aligned to 8 bytes
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:
Expand Down

0 comments on commit 6c88fdf

Please sign in to comment.