[flang-commits] [PATCH] D115289: [flang] Add CALL FLUSH(n) legacy extension

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Dec 7 14:43:48 PST 2021


klausler created this revision.
klausler added a reviewer: pmccormick.
klausler added a project: Flang.
Herald added subscribers: jdoerfert, mgorny.
Herald added a reviewer: sscalpone.
klausler requested review of this revision.

Prior to the introduction of the FLUSH statement in Fortran 2003,
implementations provided a FLUSH subroutine.

We can't yet put Fortran code into the runtime, so this subroutine
is in C++ with a Fortran-mangled entry point name.


https://reviews.llvm.org/D115289

Files:
  flang/include/flang/Runtime/extensions.h
  flang/runtime/CMakeLists.txt
  flang/runtime/extensions.cpp


Index: flang/runtime/extensions.cpp
===================================================================
--- /dev/null
+++ flang/runtime/extensions.cpp
@@ -0,0 +1,26 @@
+//===-- runtime/extensions.cpp --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// These C-coded entry points with Fortran-mangled names implement legacy
+// extensions that will eventually be implemented in Fortran.
+
+#include "flang/Runtime/extensions.h"
+#include "flang/Runtime/io-api.h"
+
+extern "C" {
+
+// SUBROUTINE FLUSH(N)
+//   FLUSH N
+// END
+namespace Fortran::runtime::io {
+void FORTRAN_SUBROUTINE_NAME(flush)(int unit) {
+  Cookie cookie{IONAME(BeginFlush)(unit, __FILE__, __LINE__)};
+  IONAME(EndIoStatement)(cookie);
+}
+} // namespace Fortran::runtime::io
+} // extern "C"
Index: flang/runtime/CMakeLists.txt
===================================================================
--- flang/runtime/CMakeLists.txt
+++ flang/runtime/CMakeLists.txt
@@ -48,6 +48,7 @@
   edit-input.cpp
   edit-output.cpp
   environment.cpp
+  extensions.cpp
   extrema.cpp
   file.cpp
   findloc.cpp
Index: flang/include/flang/Runtime/extensions.h
===================================================================
--- /dev/null
+++ flang/include/flang/Runtime/extensions.h
@@ -0,0 +1,23 @@
+//===-- include/flang/Runtime/extensions.h ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// These C-coded entry points with Fortran-mangled names implement legacy
+// extensions that will eventually be implemented in Fortran.
+
+#ifndef FORTRAN_RUNTIME_EXTENSIONS_H_
+#define FORTRAN_RUNTIME_EXTENSIONS_H_
+
+#define FORTRAN_SUBROUTINE_NAME(name) _QP##name
+
+extern "C" {
+
+// CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement.
+void FORTRAN_SUBROUTINE_NAME(flush)(int unit);
+
+} // extern "C"
+#endif // FORTRAN_RUNTIME_EXTENSIONS_H_


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115289.392546.patch
Type: text/x-patch
Size: 2394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211207/03f790bb/attachment.bin>


More information about the flang-commits mailing list