diff --git a/changelog b/changelog index c9f4885d50..2abfa78a08 100644 --- a/changelog +++ b/changelog @@ -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 diff --git a/src/psyclone/psyir/backend/fortran.py b/src/psyclone/psyir/backend/fortran.py index e42e77dc9c..743352628f 100644 --- a/src/psyclone/psyir/backend/fortran.py +++ b/src/psyclone/psyir/backend/fortran.py @@ -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 diff --git a/src/psyclone/tests/psyir/backend/fortran_test.py b/src/psyclone/tests/psyir/backend/fortran_test.py index 32c6b38074..d51fbfd52b 100644 --- a/src/psyclone/tests/psyir/backend/fortran_test.py +++ b/src/psyclone/tests/psyir/backend/fortran_test.py @@ -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