Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@
119) PR #2775. Adds Call.get_callee() which matches the arguments of
a Call against the signature of potential callees.

120) PR #2628 for #2624. Improves debug_string output for Schedules.

release 2.5.0 14th of February 2024

1) PR #2199 for #2189. Fix bugs with missing maps in enter data
Expand Down
16 changes: 16 additions & 0 deletions src/psyclone/psyir/backend/fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,3 +1742,19 @@ def kernelfunctor_node(self, node):
result_list.append(self._visit(child))
args = ", ".join(result_list)
return f"{node.name}({args})"

def schedule_node(self, node):
'''
Translate the Schedule node into Fortran.

:param node: the PSyIR node to translate.
:type node: :py:class:`psyclone.psyir.nodes.Schedule`

:returns: the equivalent Fortran code.
:rtype: str

'''
result = ""
for child in node.children:
result += self._visit(child)
return result
21 changes: 21 additions & 0 deletions src/psyclone/tests/psyir/backend/fortran_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2035,3 +2035,24 @@ def test_pointer_assignments(fortran_reader, fortran_writer):
assert "a = 4" in code
assert "b => a" in code
assert "field(3,c)%pointer => b" in code


def test_fw_schedule(fortran_reader, fortran_writer):
'''Test that the FortranWriter correctly handles a Schedule node.

'''
routine_header = ("subroutine foo()\n"
"real :: a, b, c\n")
test_code = (
"a = b\n"
"b = c\n"
"call bar(a)\n"
)
routine_end = "end subroutine foo\n"
routine_code = routine_header + test_code + routine_end
schedule = Schedule()
routine = fortran_reader.psyir_from_source(routine_code).children[0]
for child in routine.children:
schedule.addchild(child.copy().detach())
result = fortran_writer(schedule)
assert result == test_code