psyclone.core.access_sequence#
This module provides management of variable access information.
Classes#
AccessInfo: This class stores information about an access to a variable (the nodeAccessSequence: This class stores a list with all accesses to one variable.
- class psyclone.core.access_sequence.AccessInfo(access_type, node, component_indices=None)[source]#
This class stores information about an access to a variable (the node where it happens and the type of access, and the index accessed if available).
- Parameters:
access – the access type.
node (
Node) – Node in PSyIR in which the access happens.component_indices (
Union[list[list[Node]],ComponentIndices,None]) – indices used in the access, defaults to None.
Inheritance

- property access_type: AccessType#
- Returns:
the access type.
- change_read_to_write()[source]#
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.
- property component_indices#
This function returns the list of accesses used for each component as an instance of ComponentIndices. For example, a(i)%b(j,k)%c will return an instance of ComponentIndices representing [ [i], [j, k], [] ]. In the case of a simple scalar variable such as a, the component_indices will represent [ [] ].
- Returns:
the indices used in this access for each component.
- Return type:
- property description: str#
- Returns:
a textual description of this access for use in error messages.
- has_indices()[source]#
- Return type:
bool- Returns:
whether any of the access components uses an index.
- is_any_read()[source]#
- Return type:
bool- Returns:
whether this access represents a write of any kind.
- is_any_write()[source]#
- Return type:
bool- Returns:
whether this access represents a write of any kind.
- property is_data_access: bool#
- Returns:
whether or not this access is to the data associated with a signature (i.e. is not just an inquiry-type access).
- property node#
- Returns:
the PSyIR node at which this access happens.
- Return type:
- class psyclone.core.access_sequence.AccessSequence(signature)[source]#
This class stores a list with all accesses to one variable.
- Parameters:
signature (
psyclone.core.Signature) – signature of the variable.
Inheritance

- add_access(access_type, node, component_indices=None)[source]#
Adds access information to this variable.
- Parameters:
access_type (
AccessType) – the type of access (READ, WRITE, ….)node (
Node) – Node in PSyIR in which the access happens.component_indices (
Union[list[list[Node]],ComponentIndices,None]) – indices used for each component of the access.
- property all_read_accesses#
- Returns:
a list with all AccessInfo data for this variable that involve reading this variable.
- Return type:
List[
psyclone.core.AccessInfo]
- property all_write_accesses#
- Returns:
a list with all AccessInfo data for this variable that involve writing this variable.
- Return type:
List[
psyclone.core.AccessInfo]
- change_read_to_write()[source]#
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.
- has_data_access()[source]#
- Return type:
bool- Returns:
True if there is an access of the data associated with this signature (as opposed to a call or an inquiry), False otherwise.
- has_indices(index_variable=None)[source]#
Checks whether this variable accesses has any index. If the optional index_variable is provided, only indices involving the given variable are considered.
- Parameters:
index_variable (
str) – only consider index expressions that involve this variable.- Return type:
bool- Returns:
true if any of the accesses has an index.
- has_read_write()[source]#
Checks if this variable has at least one READWRITE access.
- Returns:
True if this variable is read (at least once).
- Return type:
bool
- is_called()[source]#
- Return type:
bool- Returns:
whether or not any accesses of this variable represent a call.
- is_read_only()[source]#
Checks if this variable is always read, and never written.
- Return type:
bool- Returns:
True if this variable is read only.
- is_written_first()[source]#
- Return type:
bool- Returns:
True if this variable is written in the first data access (which indicates that this variable is not an input variable for a kernel).
- property signature#
- Returns:
the signature for which the accesses are stored.
- Return type:
- str_access_summary()[source]#
- Return type:
str- Returns:
a string of the accesstypes but removing duplicates.
- property var_name#
- Returns:
the name of the variable whose access info is managed.
- Return type:
str