Reference Guide
2.5.0
|
Public Member Functions | |
def | __init__ (self, skip_nodes=False, indent_string=" ", initial_indent_depth=0, check_global_constraints=True) |
def | get_operator (self, operator) |
def | gen_indices (self, indices, var_name=None) |
def | gen_use (self, symbol, symbol_table) |
def | gen_vardecl (self, symbol, include_visibility=False) |
def | gen_interfacedecl (self, symbol) |
def | gen_typedecl (self, symbol, include_visibility=True) |
def | gen_default_access_stmt (self, symbol_table) |
def | gen_access_stmts (self, symbol_table) |
def | gen_decls (self, symbol_table, is_module_scope=False) |
def | filecontainer_node (self, node) |
def | container_node (self, node) |
def | routine_node (self, node) |
def | assignment_node (self, node) |
def | binaryoperation_node (self, node) |
def | range_node (self, node) |
def | literal_node (self, node) |
def | ifblock_node (self, node) |
def | whileloop_node (self, node) |
def | loop_node (self, node) |
def | unaryoperation_node (self, node) |
def | return_node (self, _) |
def | codeblock_node (self, node) |
def | operandclause_node (self, node) |
def | regiondirective_node (self, node) |
def | standalonedirective_node (self, node) |
def | call_node (self, node) |
def | kernelfunctor_node (self, node) |
Public Member Functions inherited from psyclone.psyir.backend.language_writer.LanguageWriter | |
def | __init__ (self, array_parenthesis, structure_character, skip_nodes=False, indent_string=" ", initial_indent_depth=0, check_global_constraints=True) |
def | array_parenthesis (self) |
def | structure_character (self) |
def | arrayreference_node (self, node) |
def | structurereference_node (self, node) |
def | member_node (self, node) |
def | arrayofstructuresreference_node (self, node) |
def | clause_node (self, node) |
Public Member Functions inherited from psyclone.psyir.backend.visitor.PSyIRVisitor | |
def | reference_node (self, node) |
def | __call__ (self, node) |
Implements a PSyIR-to-Fortran back end for PSyIR kernel code (not currently PSyIR algorithm code which has its own gen method for generating Fortran). :param bool skip_nodes: If skip_nodes is False then an exception \ is raised if a visitor method for a PSyIR node has not been \ implemented, otherwise the visitor silently continues. This is an \ optional argument which defaults to False. :param str indent_string: Specifies what to use for indentation. This \ is an optional argument that defaults to two spaces. :param int initial_indent_depth: Specifies how much indentation to \ start with. This is an optional argument that defaults to 0. :param bool check_global_constraints: whether or not to validate all \ global constraints when walking the tree. Defaults to True.
Definition at line 302 of file fortran.py.
def psyclone.psyir.backend.fortran.FortranWriter.assignment_node | ( | self, | |
node | |||
) |
This method is called when an Assignment instance is found in the PSyIR tree. :param node: an Assignment PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.Assignment`` :returns: the Fortran code as a string. :rtype: str
Definition at line 1229 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.binaryoperation_node | ( | self, | |
node | |||
) |
This method is called when a BinaryOperation instance is found in the PSyIR tree. :param node: a BinaryOperation PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.BinaryOperation` :returns: the Fortran code as a string. :rtype: str
Definition at line 1245 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit(), and psyclone.psyir.backend.fortran.FortranWriter.get_operator().
def psyclone.psyir.backend.fortran.FortranWriter.call_node | ( | self, | |
node | |||
) |
Translate the PSyIR call node to Fortran. :param node: a Call PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.Call` :returns: the equivalent Fortran code. :rtype: str
Definition at line 1704 of file fortran.py.
References psyclone.psyir.backend.fortran.FortranWriter._gen_arguments().
def psyclone.psyir.backend.fortran.FortranWriter.codeblock_node | ( | self, | |
node | |||
) |
This method is called when a CodeBlock instance is found in the PSyIR tree. It returns the content of the CodeBlock as a Fortran string, indenting as appropriate. :param node: a CodeBlock PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.CodeBlock` :returns: the Fortran code as a string. :rtype: str
Definition at line 1546 of file fortran.py.
def psyclone.psyir.backend.fortran.FortranWriter.container_node | ( | self, | |
node | |||
) |
This method is called when a Container instance is found in the PSyIR tree. A container node is mapped to a module in the Fortran back end. :param node: a Container PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.Container` :returns: the Fortran code as a string. :rtype: str :raises VisitorError: if the name attribute of the supplied \ node is empty or None. :raises VisitorError: if any of the children of the supplied \ Container node are not Routines or CodeBlocks.
Definition at line 1076 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._depth, psyclone.psyir.backend.visitor.PSyIRVisitor._visit(), psyclone.psyir.backend.fortran.FortranWriter.gen_access_stmts(), psyclone.psyir.backend.fortran.FortranWriter.gen_decls(), psyclone.psyir.backend.fortran.FortranWriter.gen_default_access_stmt(), and psyclone.psyir.backend.fortran.FortranWriter.gen_use().
def psyclone.psyir.backend.fortran.FortranWriter.filecontainer_node | ( | self, | |
node | |||
) |
This method is called when a FileContainer instance is found in the PSyIR tree. A file container node requires no explicit text in the Fortran back end. :param node: a Container PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.FileContainer` :returns: the Fortran code as a string. :rtype: str :raises VisitorError: if the attached symbol table contains \ any data symbols. :raises VisitorError: if more than one child is a Routine Node \ with is_program set to True.
Definition at line 1038 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.gen_access_stmts | ( | self, | |
symbol_table | |||
) |
Creates the accessibility statements (R518) for any routine or imported symbols in the supplied symbol table. :param symbol_table: the symbol table for which to generate \ accessibility statements. :type symbol_table: :py:class:`psyclone.psyir.symbols.SymbolTable` :returns: the accessibility statements for any routine or imported \ symbols. :rtype: str
Definition at line 768 of file fortran.py.
References psyclone.psyir.backend.fortran.FortranWriter._call_tree_utils, and psyclone.psyir.backend.fortran.FortranWriter.gen_vardecl().
def psyclone.psyir.backend.fortran.FortranWriter.gen_decls | ( | self, | |
symbol_table, | |||
is_module_scope = False |
|||
) |
Create and return the Fortran declarations for the supplied SymbolTable. :param symbol_table: the SymbolTable instance. :type symbol_table: :py:class:`psyclone.psyir.symbols.SymbolTable` :param bool is_module_scope: whether or not the declarations are in a module scoping unit. Default is False. :returns: the Fortran declarations for the table. :rtype: str :raises VisitorError: if one of the symbols is a RoutineSymbol which does not have an ImportInterface or UnresolvedInterface ( representing named and unqualified imports respectively) or ModuleDefaultInterface (representing routines declared in the same module) or is not a Fortran intrinsic. :raises VisitorError: if args_allowed is False and one or more argument declarations exist in symbol_table. :raises VisitorError: if there are any symbols (other than RoutineSymbols) in the supplied table that do not have an explicit declaration (UnresolvedInterface) and there are no wildcard imports or unknown interfaces.
Definition at line 903 of file fortran.py.
References psyclone.psyir.backend.fortran.FortranWriter._gen_parameter_decls(), psyclone.psyir.backend.fortran.FortranWriter.gen_interfacedecl(), psyclone.psyir.backend.fortran.FortranWriter.gen_typedecl(), and psyclone.psyir.backend.fortran.FortranWriter.gen_vardecl().
def psyclone.psyir.backend.fortran.FortranWriter.gen_default_access_stmt | ( | self, | |
symbol_table | |||
) |
Generates the access statement for a module - either "private" or "public". Although the PSyIR captures the visibility of every Symbol explicitly, this information is required in order to ensure the correct visibility of symbols that have been imported into the current module from another one using a wildcard import (i.e. a `use` without an `only` clause) and also for those Symbols that are of UnsupportedFortranType (because their declaration may or may not include visibility information). :returns: text containing the access statement line. :rtype: str :raises InternalError: if the symbol table has an invalid default \ visibility.
Definition at line 738 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._nindent().
def psyclone.psyir.backend.fortran.FortranWriter.gen_indices | ( | self, | |
indices, | |||
var_name = None |
|||
) |
Given a list of PSyIR nodes representing the dimensions of an array, return a list of strings representing those array dimensions. This is used both for array references and array declarations. Note that 'indices' can also be a shape in case of Fortran. :param indices: list of PSyIR nodes. :type indices: list of :py:class:`psyclone.psyir.symbols.Node` :param str var_name: name of the variable for which the dimensions \ are created. Not used in the Fortran implementation. :returns: the Fortran representation of the dimensions. :rtype: list of str :raises NotImplementedError: if the format of the dimension is not \ supported.
Reimplemented from psyclone.psyir.backend.language_writer.LanguageWriter.
Reimplemented in psyclone.psyir.backend.sympy_writer.SymPyWriter.
Definition at line 389 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.gen_interfacedecl | ( | self, | |
symbol | |||
) |
Generate the declaration for a generic interface. Since a GenericInterfaceSymbol is a subclass of RoutineSymbol, any necessary accessibility statement will be generated in gen_access_stmts(). :param symbol: the GenericInterfaceSymbol to be declared. :type symbol: :py:class:`psyclone.psyir.symbols.GenericInterfaceSymbol` :returns: the corresponding Fortran declaration. :rtype: str :raises InternalError: if passed something that is not a GenericInterfaceSymbol.
Definition at line 627 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._depth.
def psyclone.psyir.backend.fortran.FortranWriter.gen_typedecl | ( | self, | |
symbol, | |||
include_visibility = True |
|||
) |
Creates a derived-type declaration for the supplied DataTypeSymbol. :param symbol: the derived-type to declare. :type symbol: :py:class:`psyclone.psyir.symbols.DataTypeSymbol` :param bool include_visibility: whether or not to include visibility information in the declaration. (Default is True.) :returns: the Fortran declaration of the derived type. :rtype: str :raises VisitorError: if the supplied symbol is not a DataTypeSymbol. :raises VisitorError: if the datatype of the symbol is of UnsupportedType but is not of UnsupportedFortranType. :raises InternalError: if include_visibility is True and the visibility of the symbol is not of the correct type. :raises VisitorError: if the supplied symbol is of UnresolvedType.
Definition at line 665 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._depth, and psyclone.psyir.backend.fortran.FortranWriter.gen_vardecl().
def psyclone.psyir.backend.fortran.FortranWriter.gen_use | ( | self, | |
symbol, | |||
symbol_table | |||
) |
Performs consistency checks and then creates and returns the Fortran use statement(s) for this ContainerSymbol as required for the supplied symbol table. :param symbol: the container symbol instance. :type symbol: :py:class:`psyclone.psyir.symbols.ContainerSymbol` :param symbol_table: the symbol table containing this container symbol. :type symbol_table: :py:class:`psyclone.psyir.symbols.SymbolTable` :returns: the Fortran use statement(s) as a string. :rtype: str :raises VisitorError: if the symbol argument is not a ContainerSymbol. :raises VisitorError: if the symbol_table argument is not a \ SymbolTable. :raises VisitorError: if the supplied symbol is not in the supplied \ SymbolTable. :raises VisitorError: if the supplied symbol has the same name as an \ entry in the SymbolTable but is a different object.
Definition at line 437 of file fortran.py.
def psyclone.psyir.backend.fortran.FortranWriter.gen_vardecl | ( | self, | |
symbol, | |||
include_visibility = False |
|||
) |
Create and return the Fortran variable declaration for this Symbol or derived-type member. :param symbol: the symbol or member instance. :type symbol: :py:class:`psyclone.psyir.symbols.DataSymbol` or :py:class:`psyclone.psyir.nodes.MemberReference` :param bool include_visibility: whether to include the visibility of the symbol in the generated declaration (default False). :returns: the Fortran variable declaration as a string. :rtype: str :raises VisitorError: if the symbol is of UnresolvedType. :raises VisitorError: if the symbol is of UnsupportedType other than UnsupportedFortranType. :raises VisitorError: if the symbol is of known type but does not specify a variable declaration (it is not a local declaration or an argument declaration). :raises VisitorError: if the symbol is a runtime constant but does not have a StaticInterface. :raises InternalError: if the symbol is a ContainerSymbol or an import. :raises InternalError: if the symbol is a RoutineSymbol other than UnsupportedFortranType. :raises InternalError: if visibility is to be included but is not either PUBLIC or PRIVATE.
Definition at line 497 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit(), psyclone.psyir.backend.c.CWriter.gen_indices(), psyclone.psyir.backend.fortran.FortranWriter.gen_indices(), psyclone.psyir.backend.language_writer.LanguageWriter.gen_indices(), and psyclone.psyir.backend.sympy_writer.SymPyWriter.gen_indices().
def psyclone.psyir.backend.fortran.FortranWriter.get_operator | ( | self, | |
operator | |||
) |
Determine the Fortran operator that is equivalent to the provided PSyIR operator. This is achieved by reversing the Fparser2Reader maps that are used to convert from Fortran operator names to PSyIR operator names. :param operator: a PSyIR operator. :type operator: :py:class:`psyclone.psyir.nodes.Operation.Operator` :returns: the Fortran operator. :rtype: str :raises KeyError: if the supplied operator is not known.
Definition at line 372 of file fortran.py.
References psyclone.psyir.backend.fortran.FortranWriter._operator_2_str.
def psyclone.psyir.backend.fortran.FortranWriter.ifblock_node | ( | self, | |
node | |||
) |
This method is called when an IfBlock instance is found in the PSyIR tree. :param node: an IfBlock PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.IfBlock` :returns: the Fortran code as a string. :rtype: str
Definition at line 1384 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._depth, and psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.kernelfunctor_node | ( | self, | |
node | |||
) |
Translate the Kernel functor into Fortran. :param node: the PSyIR node to translate. :type node: :py:class:`psyclone.domain.common.algorithm.KernelFunctor` :returns: the equivalent Fortran code. :rtype: str
Definition at line 1725 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.literal_node | ( | self, | |
node | |||
) |
This method is called when a Literal instance is found in the PSyIR tree. :param node: a Literal PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.Literal` :returns: the Fortran code for the literal. :rtype: str
Reimplemented in psyclone.psyir.backend.sympy_writer.SymPyWriter.
Definition at line 1324 of file fortran.py.
def psyclone.psyir.backend.fortran.FortranWriter.loop_node | ( | self, | |
node | |||
) |
This method is called when a Loop instance is found in the PSyIR tree. :param node: a Loop PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.Loop` :returns: the loop node converted into a (language specific) string. :rtype: str
Definition at line 1447 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._depth, and psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.operandclause_node | ( | self, | |
node | |||
) |
This method is called when a OperandClause is found in the PSyIR tree. It returns the clause and its children as a string. :param node: an OperandClause PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.OperandClause` :returns: the Fortran code for this node. :rtype: str
Definition at line 1574 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.range_node | ( | self, | |
node | |||
) |
This method is called when a Range instance is found in the PSyIR tree. :param node: a Range PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.Range` :returns: the Fortran code as a string. :rtype: str
Reimplemented in psyclone.psyir.backend.sympy_writer.SymPyWriter.
Definition at line 1283 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.regiondirective_node | ( | self, | |
node | |||
) |
This method is called when a RegionDirective instance is found in the PSyIR tree. It returns the opening and closing directives, and the statements in between as a string. :param node: a RegionDirective PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.RegionDirective` :returns: the Fortran code for this node. :rtype: str
Definition at line 1601 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.return_node | ( | self, | |
_ | |||
) |
This method is called when a Return instance is found in the PSyIR tree. :param node: a Return PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.Return` :returns: the Fortran code as a string. :rtype: str
Definition at line 1533 of file fortran.py.
def psyclone.psyir.backend.fortran.FortranWriter.routine_node | ( | self, | |
node | |||
) |
This method is called when a Routine node is found in the PSyIR tree. :param node: a Routine PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.Routine` :returns: the Fortran code for this node. :rtype: str :raises VisitorError: if the name attribute of the supplied \ node is empty or None.
Definition at line 1140 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._depth, psyclone.psyir.backend.debug_writer.DebugWriter._DISABLE_LOWERING, psyclone.psyir.backend.sympy_writer.SymPyWriter._DISABLE_LOWERING, psyclone.psyir.backend.visitor.PSyIRVisitor._DISABLE_LOWERING, psyclone.psyir.backend.visitor.PSyIRVisitor._visit(), psyclone.psyir.backend.fortran.FortranWriter.gen_decls(), and psyclone.psyir.backend.fortran.FortranWriter.gen_use().
def psyclone.psyir.backend.fortran.FortranWriter.standalonedirective_node | ( | self, | |
node | |||
) |
This method is called when a StandaloneDirective instance is found in the PSyIR tree. It returns the directive as a string. :param node: a StandaloneDirective PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.StandloneDirective` :returns: the Fortran code for this node. :rtype: str
Definition at line 1636 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit().
def psyclone.psyir.backend.fortran.FortranWriter.unaryoperation_node | ( | self, | |
node | |||
) |
This method is called when a UnaryOperation instance is found in the PSyIR tree. :param node: a UnaryOperation PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.UnaryOperation` :returns: the Fortran code as a string. :rtype: str :raises VisitorError: if an unexpected Unary op is encountered.
Definition at line 1483 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._visit(), and psyclone.psyir.backend.fortran.FortranWriter.get_operator().
def psyclone.psyir.backend.fortran.FortranWriter.whileloop_node | ( | self, | |
node | |||
) |
This method is called when a WhileLoop instance is found in the PSyIR tree. :param node: a WhileLoop PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.WhileLoop` :returns: the Fortran code. :rtype: str
Definition at line 1422 of file fortran.py.
References psyclone.psyir.backend.visitor.PSyIRVisitor._depth, and psyclone.psyir.backend.visitor.PSyIRVisitor._visit().