psyclone.core.variables_access_map#
This module provides management of variable access information.
Classes#
VariablesAccessMap: This dictionary stores AccessSequence instances indexed by
- class psyclone.core.variables_access_map.VariablesAccessMap[source]#
This dictionary stores AccessSequence instances indexed by their signature.
Inheritance

- add_access(signature, access_type, node, component_indices=None)[source]#
Adds access information for the variable with the given signature. If the component_indices parameter is not an instance of ComponentIndices, it is used to construct an instance. Therefore it can be None, a list or a list of lists of PSyIR nodes. In the case of a list of lists, this will be used unmodified to construct the ComponentIndices structures. If it is a simple list, it is assumed that it contains the indices used in accessing the last component of the signature. For example, for a%b with component_indices=[i,j], it will create [[], [i,j] as component indices, indicating that no index is used in the first component a. If the access is supposed to be for a(i)%b(j), then the component_indices argument must be specified as a list of lists, i.e. [[i], [j]].
- Parameters:
signature (
psyclone.core.Signature) – the signature of the variable.access_type (
psyclone.core.access_type.AccessType) – the type of access (READ, WRITE, …)node (
psyclone.psyir.nodes.Nodeinstance) – Node in PSyIR in which the access happens.component_indices (
psyclone.core.component_indices.ComponentIndices, or any other type that can be used to construct a ComponentIndices instance (None, List[psyclone.psyir.nodes.Node] or List[List[psyclone.psyir.nodes.Node]])) – index information for the access.
- property all_data_accesses: List[Signature]#
- Returns:
all Signatures in this instance that have a data access (i.e. the data associated with them is read or written).
- property all_signatures#
- Returns:
all signatures contained in this instance, sorted (in order to make test results reproducible).
- Return type:
List[
psyclone.core.Signature]
- has_read_write(signature)[source]#
Checks if the specified variable signature has at least one READWRITE access (which is typically only used in a function call).
- Parameters:
signature (
psyclone.core.Signature) – signature of the variable- Returns:
True if the specified variable name has (at least one) READWRITE access.
- Return type:
bool
- Raises:
KeyError if the signature cannot be found.
- is_called(signature)[source]#
- Parameters:
signature (
Signature) – signature of the variable.- Return type:
bool- Returns:
True if the specified variable is called at least once.
- is_read(signature)[source]#
Checks if the specified variable signature is at least read once.
- Parameters:
signature (
psyclone.core.Signature) – signature of the variable- Return type:
bool- Returns:
True if the specified variable name is read (at least once).
- Raises:
KeyError if the signature cannot be found.
- is_written(signature)[source]#
Checks if the specified variable signature is at least written once.
- Parameters:
signature (
psyclone.core.Signature) – signature of the variable.- Returns:
True if the specified variable is written (at least once).
- Return type:
bool
- Raises:
KeyError if the signature name cannot be found.
- update(other_access_map)[source]#
Updates this dictionary with the entries in the provided VariablesAccessMap. If there are repeated signatures, the provided values are appended to the existing sequence of accesses.
- Parameters:
other_access_map (
psyclone.core.VariablesAccessMap) – the other VariablesAccessMap instance.