Skip to content

Commit

Permalink
Extend support for symbolic assembly via spilling
Browse files Browse the repository at this point in the history
SLOTHY has long supported assembly which uses symbolic register
names instead of architectural ones. This commit improves the
compatibility of this feature with both (a) complex workloads
using numerous symbolic regisrters, and (b) architectures offering
only a small register file, by adding experimental support for
a simplified form of register spilling.
  • Loading branch information
hanno-becker committed Jul 29, 2024
1 parent 5b4c09a commit 99a951f
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 15 deletions.
33 changes: 31 additions & 2 deletions slothy/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,12 @@ def objective_precision(self):

@property
def has_objective(self):
"""Indicates whether a secondary objective (beyond minimization of stalls)
"""Indicates whether a different objective than minimization of stalls
has been registered."""
objectives = sum([self.sw_pipelining.enabled and
self.sw_pipelining.minimize_overlapping is True,
self.constraints.maximize_register_lifetimes is True,
self.constraints.minimize_spills is True,
self.constraints.move_stalls_to_top is True,
self.constraints.move_stalls_to_bottom is True,
self.constraints.minimize_register_usage is not None,
Expand Down Expand Up @@ -896,6 +897,27 @@ def allow_renaming(self):
in order to find the number of model violations in a piece of code."""
return self._allow_renaming

@property
def allow_spills(self):
"""Allow Slothy to introduce stack spills
When this option is enabled, Slothy will consider the introduction
of stack spills to reduce register pressure.
This option should only be disabled if it is known that the input
assembly suffers from high register pressure. For example, this can
be the case for symbolic input assembly."""
return self._allow_spills

@property
def minimize_spills(self):
"""Minimize number of stack spills
When this option is enabled, the Slothy will pass minimization of
stack spills as the optimization objective to the solver.
"""
return self._minimize_spills

@property
def max_displacement(self):
"""The maximum relative displacement of an instruction.
Expand Down Expand Up @@ -926,7 +948,7 @@ def __init__(self):
self._max_displacement = 1.0

self.maximize_register_lifetimes = False

self.minimize_spills = False
self.move_stalls_to_top = False
self.move_stalls_to_bottom = False
self.minimize_register_usage = None
Expand All @@ -944,6 +966,7 @@ def __init__(self):
self._model_functional_units = True
self._allow_reordering = True
self._allow_renaming = True
self._allow_spills = False

self.lock()

Expand Down Expand Up @@ -980,6 +1003,12 @@ def allow_reordering(self,val):
@allow_renaming.setter
def allow_renaming(self,val):
self._allow_renaming = val
@allow_spills.setter
def allow_spills(self,val):
self._allow_spills = val
@minimize_spills.setter
def minimize_spills(self,val):
self._minimize_spills = val
@functional_only.setter
def functional_only(self,val):
self._model_latencies = val is False
Expand Down
Loading

0 comments on commit 99a951f

Please sign in to comment.