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 node

  • AccessSequence: This class stores a list with all accesses to one variable.

class psyclone.core.access_sequence.AccessInfo(access_type, node)[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 (Union[Node, Symbol]) – Node in PSyIR in which the access happens, can also be a DataSymbol.

Inheritance

Inheritance diagram of AccessInfo
property access_type: AccessType#
Returns:

the access type.

component_indices()[source]#
Returns:

a tuple of tuples of index expressions; one for every component in the accessor. For example, for a scalar it returns (()), for a%b it returns ((),()) - two components with 0 indices in each, and for a(i)%b(j,k+1) it returns ((i,),(j,k+1)).

property description: str#
Returns:

a textual description of this access for use in error messages.

has_indices()[source]#

Check if the expression is a reference that has indices in any of its components.

Return type:

bool

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: Node | Symbol#
Returns:

the PSyIR node at which this access happens.

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

Inheritance diagram of AccessSequence
add_access(access_type, node)[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.

Return type:

None

property all_read_accesses: list[AccessInfo]#
Returns:

a list with all AccessInfo data for this variable that involve reading this variable.

property all_write_accesses: list[AccessInfo]#
Returns:

a list with all AccessInfo data for this variable that involve writing this variable.

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 (Optional[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()[source]#
Return type:

bool

Returns:

True if this variable is read (at least once).

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()[source]#
Return type:

bool

Returns:

True if this variable is written (at least once).

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: Signature#
Returns:

the signature for which the accesses are stored.

str_access_summary()[source]#
Return type:

str

Returns:

a string of the accesstypes but removing duplicates.

update(access_seq)[source]#

This function adds all accesses from the given access sequence to this access sequence.

Parameters:

access_seq (AccessSequence) – the accesses to add to this object.

Raises:

ValueError – if the given access sequence is for a different signature.

Return type:

None

property var_name: str#
Returns:

the name of the variable whose access info is managed.