Skip to content

Commit

Permalink
Comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
PapyChacal committed Aug 19, 2024
1 parent a6d9340 commit 8dceeaa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions xdsl/dialects/experimental/dmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,20 @@ def get_shape_inference_patterns(cls):


class SwapOpMemoryEffect(MemoryEffect):
"""
Side effect implementation of dmp.swap.
"""

@classmethod
def get_effects(cls, op: Operation) -> set[EffectInstance]:
op = cast(SwapOp, op)
# If it's operating in value-semantic mode, it has no side effects.
if op.swapped_values:
return set()
# If it's operating in reference-semantic mode, it reads and writes to its field.
# TODO: consider the empty swaps case at some point.
# Right now, it relies on it before inferring them, so not very safe.
# But it could be an elegant way to generically simplify those.
return {
EffectInstance(MemoryEffectKind.WRITE, op.input_stencil),
EffectInstance(MemoryEffectKind.READ, op.input_stencil),
Expand Down

0 comments on commit 8dceeaa

Please sign in to comment.