Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
da4ef88
[skip-ci] Initial version of intrinsic call extension
LonelyCat124 Sep 2, 2025
9bdb1ed
[skip-ci] Initial version of intrinsic call extension
LonelyCat124 Sep 2, 2025
1293219
[skip-ci] Added more intrisic return types and applied black formatter
LonelyCat124 Sep 2, 2025
9f0799f
[skip-ci] linting
LonelyCat124 Sep 2, 2025
5c234ed
Finished intrinsic return types...
LonelyCat124 Sep 3, 2025
08fc22a
Finish failing tests
LonelyCat124 Sep 3, 2025
f2a7258
Fixed remaining possible coverage
LonelyCat124 Sep 4, 2025
45fffca
Missing coverage line
LonelyCat124 Sep 4, 2025
ce1c282
Added the ability to change READ access to TYPE_INFO
LonelyCat124 Sep 4, 2025
d108c89
Linting
LonelyCat124 Sep 4, 2025
421f9c2
Start of reference_accesses_changes
LonelyCat124 Sep 4, 2025
458180e
read to type_info implemented
LonelyCat124 Sep 5, 2025
c11c8e0
Moving reference_accesses to its own branch
LonelyCat124 Sep 8, 2025
60f12dc
Added support for all read-only reference_accesses
LonelyCat124 Sep 9, 2025
7012116
linting
LonelyCat124 Sep 9, 2025
9dc0619
Finish implementing reference accesses members of each intrinsic
LonelyCat124 Sep 10, 2025
ac42428
linting
LonelyCat124 Sep 10, 2025
144ef08
Fix failing test
LonelyCat124 Sep 10, 2025
47f46e9
Added test for compute_reference_accesses
LonelyCat124 Sep 10, 2025
ec75c1e
Fixed argument ordering and all named argument issues
LonelyCat124 Sep 11, 2025
9335f5e
Fixes to failing tests
LonelyCat124 Sep 11, 2025
0e133dc
Merge branch '3060_intrinsic_types' into 3060_reference_accesses
LonelyCat124 Dec 3, 2025
a7ccd0d
Fixed reference accesses to use argument names
LonelyCat124 Dec 3, 2025
c8e1a41
Merge branch 'master' into 3060_reference_accesses
LonelyCat124 Dec 11, 2025
117eb48
no idea
LonelyCat124 Dec 11, 2025
8ec676a
Merged master
LonelyCat124 Jan 16, 2026
9daccba
Merged master
LonelyCat124 Jan 16, 2026
d51d49a
Changes for first indirect changes
LonelyCat124 Jan 16, 2026
af2b4fc
Indirect coverage changes
LonelyCat124 Jan 19, 2026
34f5b68
indirect fixes
LonelyCat124 Jan 19, 2026
dec435e
Fixed failing test
LonelyCat124 Jan 19, 2026
24a1ecb
Merge branch 'master' into 3060_reference_accesses
LonelyCat124 Jan 19, 2026
4f02069
Renamed remaining bad function name
LonelyCat124 Jan 19, 2026
1e94a33
Merge branch '3060_reference_accesses' of github.com:stfc/PSyclone in…
LonelyCat124 Jan 19, 2026
f1fe6eb
Updates towards review
LonelyCat124 Jan 21, 2026
eaa2936
Additional test
LonelyCat124 Jan 21, 2026
0b0499f
Merge branch 'master' into 3060_reference_accesses
LonelyCat124 Jan 21, 2026
5430465
First review comment
LonelyCat124 Jan 23, 2026
f2bdc0e
Merge branch 'master' into 3060_reference_accesses
LonelyCat124 Jan 23, 2026
b22f1f3
Upload to check on git
LonelyCat124 Jan 23, 2026
37a19f1
changes for review
LonelyCat124 Jan 23, 2026
8278cf8
#3060 Remove change* access_type methods
sergisiso Jan 26, 2026
8e42593
#3060 Remove _convert_argument_to_constant
sergisiso Jan 26, 2026
f852614
#3060 Remove leftover comment
sergisiso Jan 26, 2026
2174e9a
#3060 Fix flake8
sergisiso Jan 26, 2026
d2661c5
Merge pull request #3300 from stfc/3060_change_access_methods
LonelyCat124 Jan 27, 2026
41aa9a2
Review updates
LonelyCat124 Jan 30, 2026
6191022
Rewrite of argument ordering in the variable access map to match argu…
LonelyCat124 Jan 30, 2026
9ab476b
Merge branch 'master' into 3060_reference_accesses
LonelyCat124 Jan 30, 2026
04c9602
Fixed access_sequence coverage
LonelyCat124 Jan 30, 2026
5f2bc4f
Merge branch '3060_reference_accesses' of github.com:stfc/PSyclone in…
LonelyCat124 Jan 30, 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
101 changes: 11 additions & 90 deletions src/psyclone/core/access_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

from psyclone.core.access_type import AccessType
from psyclone.core.signature import Signature
from psyclone.errors import InternalError

if TYPE_CHECKING:
from psyclone.psyir.nodes import Node
Expand Down Expand Up @@ -73,32 +72,6 @@ def __init__(
def __str__(self) -> str:
return f"{self._access_type}"

def change_read_to_write(self) -> None:
'''This changes the access mode from READ to WRITE.
This is used for processing assignment statements,
where the LHS is first considered to be READ,
and which is then changed to be WRITE.

:raises InternalError: if the variable originally does not have\
READ access.

'''
if self._access_type != AccessType.READ:
raise InternalError("Trying to change variable to 'WRITE' "
"which does not have 'READ' access.")
self._access_type = AccessType.WRITE

def change_read_to_constant(self):
'''This changes the access mode from READ to CONSTANT.

:raises InternalError: if the variable does not have READ access.
'''
if self._access_type != AccessType.READ:
raise InternalError(f"Trying to change variable access from "
f"'READ' to 'CONSTANT' but access type is "
f" '{self._access_type}'.")
self._access_type = AccessType.CONSTANT

def component_indices(self):
'''
:returns: a tuple of tuples of index expressions; one for every
Expand Down Expand Up @@ -134,6 +107,17 @@ def access_type(self) -> AccessType:
'''
return self._access_type

@access_type.setter
def access_type(self, value: AccessType) -> None:
'''
:param value: the new access type.
'''
if not isinstance(value, AccessType):
raise TypeError(
f"Expected AccessType but got '{type(value).__name__}'."
)
self._access_type = value

def is_any_write(self) -> bool:
'''
:returns: whether this access represents a write of any kind.
Expand Down Expand Up @@ -319,35 +303,6 @@ def add_access(self, access_type: AccessType, node: 'Node') -> None:
'''
self.append(AccessInfo(access_type, node))

def change_read_to_constant(self):
'''This function is used to change a READ into a CONSTANT.

:raises InternalError: if there is an access that is not READ or
INQUIRY or there is > 1 READ accesses.
'''
read_access = None
for acc in self:

if acc.access_type == AccessType.READ:
if read_access:
raise InternalError(
f"Trying to change variable '{self._signature}' to "
f"'CONSTANT' but it has more than one 'READ' access."
)
read_access = acc

elif acc.access_type not in AccessType.non_data_accesses():
raise InternalError(
f"Variable '{self._signature}' has a '{acc.access_type}' "
f"access. change_read_to_constant() expects only "
f"inquiry accesses and a single 'READ' access.")

if not read_access:
raise InternalError(
f"Trying to change variable '{self._signature}' to "
f"'CONSTANT' but it does not have a 'READ' access.")
read_access.change_read_to_constant()

def update(self, access_seq: AccessSequence) -> None:
'''
This function adds all accesses from the given access sequence
Expand All @@ -365,40 +320,6 @@ def update(self, access_seq: AccessSequence) -> None:
for access_info in access_seq:
self.add_access(access_info.access_type, access_info.node)

def change_read_to_write(self) -> None:
'''This function is only used when analysing an assignment statement.
The LHS has first all variables identified, which will be READ.
This function is then called to change the assigned-to variable
on the LHS to from READ to WRITE. Since the LHS is stored in a separate
AccessSequence class, it is guaranteed that there is only
one READ entry for the variable (although there maybe INQUIRY accesses
for array bounds).

:raises InternalError: if there is an access that is not READ or
INQUIRY or there is > 1 READ access.
'''
read_access = None
for acc in self:

if acc.access_type == AccessType.READ:
if read_access:
raise InternalError(
f"Trying to change variable '{self._signature}' to "
f"'WRITE' but it has more than one 'READ' access.")
read_access = acc

elif acc.access_type not in AccessType.non_data_accesses():
raise InternalError(
f"Variable '{self._signature}' has a '{acc.access_type}' "
f"access. change_read_to_write() expects only inquiry "
f"accesses and a single 'READ' access.")

if not read_access:
raise InternalError(
f"Trying to change variable '{self._signature}' to 'WRITE' but"
f" it does not have a 'READ' access.")
read_access.change_read_to_write()

def has_indices(self, index_variable: Optional[str] = None) -> bool:
''' Checks whether this variable accesses has any index. If the
optional `index_variable` is provided, only indices involving the given
Expand Down
22 changes: 5 additions & 17 deletions src/psyclone/psyir/nodes/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

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

from psyclone.core import VariablesAccessMap
from psyclone.core import VariablesAccessMap, AccessType
from psyclone.errors import InternalError
from psyclone.psyir.nodes.literal import Literal
from psyclone.psyir.nodes.array_reference import ArrayReference
Expand Down Expand Up @@ -180,27 +180,15 @@ def reference_accesses(self) -> VariablesAccessMap:
(a sequence of AccessTypes).

'''
# It is important that a new instance is used to handle the LHS,
# since a check in 'change_read_to_write' makes sure that there
# is only one access to the variable!
lhs_accesses = self.lhs.reference_accesses()
# Now change the (one) access to the assigned variable to be WRITE.
# Now change the top (last) access to be WRITE.
if isinstance(self.lhs, Reference):
sig, _ = self.lhs.get_signature_and_indices()
lhs_accesses[sig][-1].access_type = AccessType.WRITE
# Note that if the LHS is a CodeBlock then reference_accesses() will
# already have given all Signatures READWRITE access. This is not
# strictly correct (they should probably be UNKNOWN) and is the
# subject of #2863.
if isinstance(self.lhs, Reference):
sig, _ = self.lhs.get_signature_and_indices()
var_info = lhs_accesses[sig]
try:
var_info.change_read_to_write()
except InternalError as err:
# An internal error typically indicates that the same variable
# is used twice on the LHS, e.g.: g(g(1)) = ... This is not
# supported in PSyclone.
raise NotImplementedError(
f"The variable '{self.lhs.name}' appears more than once on"
f" the left-hand side of an assignment.") from err

# Merge the data (that shows now WRITE for the variable) with the
# parameter to this function. It is important that first the
Expand Down
Loading
Loading