Skip to content

Commit

Permalink
#2271 extend ScopingNode.reference_accesses to handle UnsupportedFort…
Browse files Browse the repository at this point in the history
…ranType
  • Loading branch information
arporter committed Jan 8, 2025
1 parent 8541f08 commit ce58e0c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/psyclone/psyir/nodes/scoping_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from psyclone.psyir.nodes.node import Node
from psyclone.psyir.symbols import (
ArrayType, DataType, DataTypeSymbol, RoutineSymbol, StructureType, Symbol,
SymbolError, SymbolTable)
SymbolError, SymbolTable, UnsupportedFortranType)


class ScopingNode(Node):
Expand Down Expand Up @@ -217,6 +217,10 @@ def _get_accesses(dtype: DataType, info: VariablesAccessInfo):
if isinstance(dim, ArrayType.ArrayBounds):
dim.lower.reference_accesses(access_info)
dim.upper.reference_accesses(access_info)
elif (isinstance(dtype, UnsupportedFortranType) and
dtype.partial_datatype):
# Recurse to examine partial datatype information.
_get_accesses(dtype.partial_datatype, info)

# Examine the datatypes and initial values of all DataSymbols.
for sym in self._symbol_table.datasymbols:
Expand Down
30 changes: 28 additions & 2 deletions src/psyclone/tests/psyir/nodes/scoping_node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
Routine, ArrayReference)
from psyclone.psyir.symbols import (
ArrayType, ArgumentInterface, DataSymbol, DataTypeSymbol, INTEGER_TYPE,
ScalarType, StructureType, Symbol, SymbolTable, REAL_TYPE)
REAL_TYPE, ScalarType, StructureType, Symbol, SymbolTable,
UnsupportedFortranType)
from psyclone.tests.utilities import Compile


Expand Down Expand Up @@ -345,7 +346,7 @@ def test_reference_accesses_struct():


def test_reference_accesses_array():
'''Test reference_accesses() with the associated SymbolTable contains
'''Test reference_accesses() when the associated SymbolTable contains
an array with dimensions that make reference to another Symbol.
'''
Expand All @@ -367,3 +368,28 @@ def test_reference_accesses_array():
assert Signature("i_def") in vai.all_signatures
assert Signature("r_def") in vai.all_signatures
assert Signature("var2") in vai.all_signatures


def test_reference_accesses_unknown_type():
'''Test reference_accesses() when the symbol table contains a symbol
of UnsupportedFortranType but with partial type information.
'''
sched = Schedule()
table = sched.symbol_table
# Create partial type information - an array of specified precision
# with an extent specified by another symbol.
rdef = table.new_symbol("r_def", symbol_type=DataSymbol,
datatype=INTEGER_TYPE)
big_sym = table.new_symbol("big", symbol_type=DataSymbol,
datatype=INTEGER_TYPE)
real_type = ScalarType(ScalarType.Intrinsic.REAL, rdef)
ptype = ArrayType(real_type, [Reference(big_sym)])
utype = UnsupportedFortranType(
"real(r_def), dimension(big), target :: array",
partial_datatype=ptype)
table.new_symbol("array", symbol_type=DataSymbol, datatype=utype)
vai = VariablesAccessInfo()
sched.reference_accesses(vai)
assert Signature("r_def") in vai.all_signatures
assert Signature("big") in vai.all_signatures

0 comments on commit ce58e0c

Please sign in to comment.