Only ld/sd "needed"

This commit is contained in:
augustin64 2024-10-21 13:44:40 +02:00
parent 4c7a2c85a2
commit 7479ee19d8

View File

@ -18,15 +18,15 @@ class AllInMemAllocator(Allocator):
s_index = 0 s_index = 0
for arg in old_instr.args(): for arg in old_instr.args():
if isinstance(arg, Temporary): if isinstance(arg, Temporary):
# TODO: don't ld/sd when nothing changed (eg don't ld a destination only,
# TODO: don't sd a source only)
s_index += 1 s_index += 1
before.append(RiscV.ld( if arg in old_instr.used(): # needs to be read first
S[s_index], arg.get_alloced_loc() before.append(RiscV.ld(
)) S[s_index], arg.get_alloced_loc()
after.append(RiscV.sd( ))
S[s_index], arg.get_alloced_loc() if arg in old_instr.defined(): # needs to be stored after
)) after.append(RiscV.sd(
S[s_index], arg.get_alloced_loc()
))
new_args.append(S[s_index]) new_args.append(S[s_index])
else: else:
new_args.append(arg) new_args.append(arg)