Skip to content

Commit

Permalink
Improve fusion documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dop-amin committed Dec 13, 2024
1 parent bf2b151 commit c7a0d9a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
20 changes: 18 additions & 2 deletions slothy/core/slothy.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,17 @@ def _fusion_core(self, pre, body, post, logger, ssa=True):
return body

def fusion_region(self, start, end, **kwargs):
"""Run fusion callbacks on straightline code"""
""" Run fusion callbacks on straightline code replacing certain
instruction (sequences) with an alternative. These replacements are
defined in the architectural model by setting an instruction class'
global_fusion_cb.
Args:
start: The label marking the beginning of the part of the code to
apply fusion to.
end: The label marking the end of the part of the code to apply
fusion to.
"""
logger = self.logger.getChild(f"ssa_{start}_{end}")
pre, body, post = AsmHelper.extract(self.source, start, end)

Expand All @@ -365,7 +375,13 @@ def fusion_region(self, start, end, **kwargs):
assert SourceLine.is_source(self.source)

def fusion_loop(self, loop_lbl, **kwargs):
"""Run fusion callbacks on loop body"""
"""Run fusion callbacks on loop body replacing certain instruction
(sequences) with an alternative. These replacements are defined in the
architectural model by setting an instruction class' global_fusion_cb.
Args:
loop_lbl: Label of loop to which the fusions are applied to.
"""
logger = self.logger.getChild(f"ssa_loop_{loop_lbl}")

pre , body, post, _, other_data, loop = \
Expand Down
10 changes: 7 additions & 3 deletions slothy/targets/aarch64/aarch64_neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -3176,10 +3176,13 @@ def core(inst,t,log=None):

return core

# TODO: Test only...
# veor.global_fusion_cb = eor3_fusion_cb()

def eor3_splitting_cb():
"""
Example for a splitting call back. Allows to split one eor instruction with
three inputs into two eors with two inputs. Such technique can help perform
transformations in case of differences between uArchs.
Note: This is not used in any real (crypto) example. This is merely a PoC.
"""
def core(inst,t,log=None):

d = inst.args_out[0]
Expand Down Expand Up @@ -3219,6 +3222,7 @@ def core(inst,t,log=None):

return core

# Can alternatively set veor3.global_fusion_cb to eor3_fusion_cb() here
veor3.global_fusion_cb = eor3_splitting_cb()

def iter_aarch64_instructions():
Expand Down

0 comments on commit c7a0d9a

Please sign in to comment.