psyclone.domain.common.algorithm.psyir

This module contains PSyclone Algorithm-layer-specific PSyIR classes.

Classes

class psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall(invoke_routine_symbol, index, parent=None, name=None)

An invoke call in a PSyclone Algorithm layer.

Parameters:
  • invoke_routine_symbol (py:class:psyclone.psyir.symbols.RoutineSymbol) – the routine that this call calls.

  • index (int) – the position of this invoke call relative to other invokes in the algorithm layer.

  • parent (sub-class of psyclone.psyir.nodes.Node or NoneType) – optional parent of this node in the PSyIR. Defaults to None.

  • name (Optional[str]) – an optional name, describing the AlgorithmInvokeCall. Defaults to None.

Raises:
  • TypeError – if the index argument is not an integer.

  • ValueError – if the index argument is negative.

  • ValueError – if an invalid name is supplied.

Inheritance

Inheritance diagram of AlgorithmInvokeCall
classmethod create(routine, arguments, index, name=None)

Create an instance of the calling class given valid instances of a routine symbol, a list of child nodes for its arguments, an index and an optional name.

Parameters:
  • routine (py:class:psyclone.psyir.symbols.RoutineSymbol) – the routine that the calling class calls.

  • arguments (list of psyclone.psyir.nodes.DataNode) – the arguments to this routine. These are added as child nodes.

  • index (int) – the position of this invoke call relative to other invokes in the algorithm layer.

  • name (Optional[str]) – a string naming/describing the invoke or None if one is not provided. This is converted to lower case and used to create the name of the routine that replaces the invoke. It must be a valid Fortran name. Defaults to None.

Raises:

GenerationError – if the arguments argument is not a list.

Returns:

an instance of the calling class.

Return type:

psyclone.psyir.nodes.AlgorithmInvokeCall or a subclass thereof.

create_psylayer_symbol_root_names()

If the PSy-layer routine and container root names have not been created, then create them. The invoke root name is based on the position of this node (compared to other nodes of the same type) in the PSyIR tree. Note, we do not create and store symbols, as the container name needs to be consistent between different invoke calls and we have no way of knowing whether one has already been created without the symbol being stored in the symbol table, and we don’t want to add anything related to the lower level PSyIR to the symbol table before lowering.

Raises:

InternalError – if no Routine or Container is found in the PSyIR tree containing this node.

node_str(colour=True)

Construct a text representation of this node, optionally containing colour control codes. Specialise as this node has an additional name argument.

Parameters:

colour (bool) – whether or not to include colour control codes. Optional argument that defaults to True.

Returns:

description of this PSyIR node.

Return type:

str

class psyclone.domain.common.algorithm.psyir.KernelFunctor(symbol, parent=None)

Object containing a kernel call, a description of its required interface and the arguments to be passed to it.

Parameters:

Inheritance

Inheritance diagram of KernelFunctor
classmethod create(symbol, arguments)

Create an instance of the calling class given valid instances of a DataTypeSymbol and a list of child nodes for its arguments.

Parameters:
  • symbol (py:class:psyclone.psyir.symbols.DataTypeSymbol) – the name of the kernel type that this object references.

  • arguments (list of psyclone.psyir.nodes.DataNode) – the arguments to this routine. These are added as child nodes.

Returns:

an instance of the calling class.

Return type:

psyclone.psyir.nodes.Call or subclass thereof.