Skip to content

Commit

Permalink
M7: fix kyber matacc - reserve fpu registers
Browse files Browse the repository at this point in the history
Before the SLOTHY configuration was missing
marking the FPU registers as reserved.
Due to that SLOTHY would pick other registers
than the ones on the original code.
If those happen to be callee-save registers and
are not saved by the function, it won't work.
This was the case for the Kyber mataccs.
  • Loading branch information
mkannwischer committed Jan 6, 2025
1 parent 1bd43b4 commit 2e9a4dd
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 254 deletions.
10 changes: 9 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@ def core(self, slothy):
slothy.config.unsafe_address_offset_fixup = False
r = slothy.config.reserved_regs
r.add("r14")
r = r.union(f"s{i}" for i in range(31)) # reserve FPR
r = r.union(f"s{i}" for i in range(32)) # reserve FPR
slothy.config.reserved_regs = r

slothy.config.sw_pipelining.enabled = True
Expand All @@ -2431,6 +2431,10 @@ def core(self, slothy):
slothy.config.inputs_are_outputs = True
slothy.config.variable_size = True

r = slothy.config.reserved_regs
r = r.union(f"s{i}" for i in range(32)) # reserve FPR
slothy.config.reserved_regs = r

slothy.config.outputs = ["r9"]
slothy.optimize(start="slothy_start_1", end="slothy_end_1")
slothy.config.outputs = ["r9"]
Expand All @@ -2454,6 +2458,10 @@ def core(self, slothy):
slothy.config.inputs_are_outputs = True
slothy.config.variable_size = True

r = slothy.config.reserved_regs
r = r.union(f"s{i}" for i in range(32)) # reserve FPR
slothy.config.reserved_regs = r

slothy.config.outputs = ["r9"]
slothy.optimize(start="slothy_start_1", end="slothy_end_1")
slothy.config.outputs = ["r9"]
Expand Down
Loading

0 comments on commit 2e9a4dd

Please sign in to comment.