Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
166c9b7
Some starting to def use chains update
LonelyCat124 Mar 18, 2026
23ddd68
[skip-ci] more duc improvements
LonelyCat124 Mar 18, 2026
e065541
[skip-ci] linting
LonelyCat124 Mar 18, 2026
eddd698
[skip-ci] More improvements to DUC to enable multi-reference usage
LonelyCat124 Apr 7, 2026
fdcd6ad
forward accesses first draft completed
LonelyCat124 Apr 8, 2026
010811a
Allow DUCs to handle multiple input References
LonelyCat124 Apr 9, 2026
120890f
Merge branch 'master' into 3367_def_use_chain_update
LonelyCat124 Apr 9, 2026
d12e7db
fix tutorial
LonelyCat124 Apr 9, 2026
fbdab62
Remove unnecessary uniqueness check
LonelyCat124 Apr 9, 2026
576210d
Remaining coverage misses
LonelyCat124 Apr 9, 2026
3f9da44
allow all nodes in one statement
LonelyCat124 Apr 9, 2026
63ef6b2
Update tests and add assignment.previous/next_accesses
LonelyCat124 Apr 10, 2026
4e72cac
Fixed bug in ancestor assignment for searching backwards
LonelyCat124 Apr 10, 2026
0194db8
Fix remaining FIXME
LonelyCat124 Apr 10, 2026
bfcda43
Merge branch 'master' into 3367_def_use_chain_update
LonelyCat124 Apr 10, 2026
7677af0
First identity test for DUC versions. This is still in development bu…
LonelyCat124 Apr 13, 2026
0fbe5f9
Fixed forward accesses issue. Still need to check it going backwards
LonelyCat124 Apr 13, 2026
b84bba6
Fixed backward accesses and tests added
LonelyCat124 Apr 14, 2026
b566193
fixed issue with ITs
LonelyCat124 Apr 14, 2026
d9c5cb5
Temporary addition
LonelyCat124 Apr 14, 2026
94a45c1
Fix error in DUCs resulting in nested if/else failures
LonelyCat124 Apr 16, 2026
55aff24
Merge branch 'master' into 3367_def_use_chain_update
LonelyCat124 Apr 16, 2026
b80b529
Merge branch 'master' into 3367_def_use_chain_update
LonelyCat124 Apr 20, 2026
533fe1c
Changes for review
LonelyCat124 Apr 20, 2026
b5e5088
Merge branch 'master' into 3367_def_use_chain_update
LonelyCat124 Apr 20, 2026
dc5901f
linting
LonelyCat124 Apr 20, 2026
4e9939d
Merge branch '3367_def_use_chain_update' of github.com:stfc/PSyclone …
LonelyCat124 Apr 20, 2026
32f950c
Merge branch 'master' into 3367_def_use_chain_update
LonelyCat124 Apr 21, 2026
12de6a7
Merge branch 'master' into 3367_def_use_chain_update
arporter May 1, 2026
ac8fb18
Changes from review
LonelyCat124 May 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion src/psyclone/psyir/nodes/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@

''' This module contains the Assignment node implementation.'''

from psyclone.core import VariablesAccessMap, AccessType
from psyclone.core import VariablesAccessMap, AccessType, Signature
from psyclone.errors import InternalError
from psyclone.psyir.nodes.literal import Literal
from psyclone.psyir.nodes.array_reference import ArrayReference
from psyclone.psyir.nodes.datanode import DataNode
from psyclone.psyir.nodes.intrinsic_call import (
IntrinsicCall, REDUCTION_INTRINSICS)
from psyclone.psyir.nodes.node import Node
from psyclone.psyir.nodes.ranges import Range
from psyclone.psyir.nodes.reference import Reference
from psyclone.psyir.nodes.statement import Statement
Expand Down Expand Up @@ -243,3 +244,39 @@ def is_literal_assignment(self):

'''
return isinstance(self.rhs, Literal)

def previous_accesses(self) -> dict[Signature, list[Node]]:
'''
:returns: the nodes containing the previous accesses of the symbols
accessed within this node. It can be multiple nodes for
each symbol if the control flow diverges and there are
multiple possible accesses.
'''
# Find all of the read/write References in this assignment.
refs = []
for ref in self.walk(Reference):
if ref.is_read or ref.is_write:
refs.append(ref)
# Avoid circular import
# pylint: disable=import-outside-toplevel
from psyclone.psyir.tools import DefinitionUseChain
chain = DefinitionUseChain(refs)
return chain.find_backward_accesses()

def next_accesses(self) -> dict[Signature, list[Node]]:
'''
:returns: the nodes containing the next accesses of the symbols
accessed within this node. It can be multiple nodes for
each symbol if the control flow diverges and there are
multiple possible accesses.
'''
# Find all of the read/write References in this assignment.
refs = []
for ref in self.walk(Reference):
if ref.is_read or ref.is_write:
refs.append(ref)
# Avoid circular import
# pylint: disable=import-outside-toplevel
from psyclone.psyir.tools import DefinitionUseChain
chain = DefinitionUseChain(refs)
return chain.find_forward_accesses()
25 changes: 18 additions & 7 deletions src/psyclone/psyir/nodes/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@
# We cannot import from 'nodes' directly due to circular import
from psyclone.psyir.nodes.datanode import DataNode
from psyclone.psyir.nodes.node import Node
from psyclone.psyir.symbols import Symbol, AutomaticInterface
from psyclone.psyir.symbols import (
Symbol,
AutomaticInterface,
RoutineSymbol,
IntrinsicSymbol
)
from psyclone.psyir.symbols.datatypes import UnresolvedType


Expand Down Expand Up @@ -95,6 +100,12 @@ def is_read(self):
# pylint: disable=import-outside-toplevel
from psyclone.psyir.nodes.assignment import Assignment
from psyclone.psyir.nodes.intrinsic_call import IntrinsicCall

# If the symbol is a RoutineSymbol or IntrinsicSymbol we don't read
# the symbol.
if isinstance(self.symbol, (RoutineSymbol, IntrinsicSymbol)):
return False

parent = self.parent
if isinstance(parent, Assignment):
if parent.lhs is self:
Expand Down Expand Up @@ -235,31 +246,31 @@ def datatype(self):
return super().datatype
return self.symbol.datatype

def previous_accesses(self):
def previous_accesses(self) -> list[Node]:
'''
:returns: the nodes accessing the same symbol directly before this
reference. It can be multiple nodes if the control flow
diverges and there are multiple possible accesses.
:rtype: List[:py:class:`psyclone.psyir.nodes.Node`]
'''
# Avoid circular import
# pylint: disable=import-outside-toplevel
from psyclone.psyir.tools import DefinitionUseChain
chain = DefinitionUseChain(self)
return chain.find_backward_accesses()
sig = self.get_signature_and_indices()[0]
return chain.find_backward_accesses()[sig]

def next_accesses(self):
def next_accesses(self) -> list[Node]:
'''
:returns: the nodes accessing the same symbol directly after this
reference. It can be multiple nodes if the control flow
diverges and there are multiple possible accesses.
:rtype: List[:py:class:`psyclone.psyir.nodes.Node`]
'''
# Avoid circular import
# pylint: disable=import-outside-toplevel
from psyclone.psyir.tools import DefinitionUseChain
chain = DefinitionUseChain(self)
return chain.find_forward_accesses()
sig = self.get_signature_and_indices()[0]
return chain.find_forward_accesses()[sig]

def escapes_scope(
self, scope: Node, visited_nodes: Optional[set] = None
Expand Down
Loading
Loading