[flang-commits] [flang] 77ff6f7 - [flang] Define & implement a lowering support API IsContiguous() in runtime

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Tue Nov 30 14:16:07 PST 2021


Author: Peter Klausler
Date: 2021-11-30T14:15:56-08:00
New Revision: 77ff6f7df8691a735a2dc979cdb44835dd2d41af

URL: https://github.com/llvm/llvm-project/commit/77ff6f7df8691a735a2dc979cdb44835dd2d41af
DIFF: https://github.com/llvm/llvm-project/commit/77ff6f7df8691a735a2dc979cdb44835dd2d41af.diff

LOG: [flang] Define & implement a lowering support API IsContiguous() in runtime

Create a new flang/runtime/support.cpp module to hold miscellaneous
runtime APIs to support lowering, and define an API IsContiguous() to
wrap the member function predicate Descriptor::IsContiguous().
And do a little clean-up of other API headers that don't need to expose
Runtime/descriptor.h.

Differential Revision: https://reviews.llvm.org/D114752

Added: 
    flang/include/flang/Runtime/support.h
    flang/runtime/support.cpp

Modified: 
    flang/include/flang/Runtime/reduction.h
    flang/include/flang/Runtime/transformational.h
    flang/runtime/CMakeLists.txt
    flang/runtime/reduction.cpp
    flang/runtime/terminator.h
    flang/runtime/transformational.cpp

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Runtime/reduction.h b/flang/include/flang/Runtime/reduction.h
index d70bb0df10a9a..b4aeaad6fe170 100644
--- a/flang/include/flang/Runtime/reduction.h
+++ b/flang/include/flang/Runtime/reduction.h
@@ -12,12 +12,15 @@
 #define FORTRAN_RUNTIME_REDUCTION_H_
 
 #include "flang/Common/uint128.h"
-#include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/entry-names.h"
+#include <cinttypes>
 #include <complex>
 #include <cstdint>
 
 namespace Fortran::runtime {
+
+class Descriptor;
+
 extern "C" {
 
 // Reductions that are known to return scalars have per-type entry

diff  --git a/flang/include/flang/Runtime/support.h b/flang/include/flang/Runtime/support.h
new file mode 100644
index 0000000000000..532fc538a2b2e
--- /dev/null
+++ b/flang/include/flang/Runtime/support.h
@@ -0,0 +1,26 @@
+//===-- include/flang/Runtime/support.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
+//
+//===----------------------------------------------------------------------===//
+
+// Defines APIs for runtime support code for lowering.
+#ifndef FORTRAN_RUNTIME_SUPPORT_H_
+#define FORTRAN_RUNTIME_SUPPORT_H_
+
+#include "flang/Runtime/entry-names.h"
+
+namespace Fortran::runtime {
+
+class Descriptor;
+
+extern "C" {
+
+// Predicate: is the storage described by a Descriptor contiguous in memory?
+bool RTNAME(IsContiguous)(const Descriptor &);
+
+} // extern "C"
+} // namespace Fortran::runtime
+#endif // FORTRAN_RUNTIME_SUPPORT_H_

diff  --git a/flang/include/flang/Runtime/transformational.h b/flang/include/flang/Runtime/transformational.h
index ad17d48096c94..21a44184b6228 100644
--- a/flang/include/flang/Runtime/transformational.h
+++ b/flang/include/flang/Runtime/transformational.h
@@ -17,12 +17,13 @@
 #ifndef FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
 #define FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
 
-#include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/entry-names.h"
-#include "flang/Runtime/memory.h"
+#include <cinttypes>
 
 namespace Fortran::runtime {
 
+class Descriptor;
+
 extern "C" {
 
 void RTNAME(Reshape)(Descriptor &result, const Descriptor &source,

diff  --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index b3e96faede706..8b3a7a96cae13 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -70,6 +70,7 @@ add_flang_library(FortranRuntime
   stat.cpp
   stop.cpp
   sum.cpp
+  support.cpp
   terminator.cpp
   time-intrinsic.cpp
   tools.cpp

diff  --git a/flang/runtime/reduction.cpp b/flang/runtime/reduction.cpp
index 0f858c888b6cd..dea25cf8dc764 100644
--- a/flang/runtime/reduction.cpp
+++ b/flang/runtime/reduction.cpp
@@ -15,6 +15,7 @@
 
 #include "flang/Runtime/reduction.h"
 #include "reduction-templates.h"
+#include "flang/Runtime/descriptor.h"
 #include <cinttypes>
 
 namespace Fortran::runtime {

diff  --git a/flang/runtime/support.cpp b/flang/runtime/support.cpp
new file mode 100644
index 0000000000000..88a3e79009f6c
--- /dev/null
+++ b/flang/runtime/support.cpp
@@ -0,0 +1,20 @@
+//===-- runtime/support.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
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Runtime/support.h"
+#include "flang/Runtime/descriptor.h"
+
+namespace Fortran::runtime {
+extern "C" {
+
+bool RTNAME(IsContiguous)(const Descriptor &descriptor) {
+  return descriptor.IsContiguous();
+}
+
+} // extern "C"
+} // namespace Fortran::runtime

diff  --git a/flang/runtime/terminator.h b/flang/runtime/terminator.h
index dbf08fec60c99..107bbc8d21a3d 100644
--- a/flang/runtime/terminator.h
+++ b/flang/runtime/terminator.h
@@ -11,7 +11,6 @@
 #ifndef FORTRAN_RUNTIME_TERMINATOR_H_
 #define FORTRAN_RUNTIME_TERMINATOR_H_
 
-#include "flang/Runtime/entry-names.h"
 #include <cstdarg>
 
 namespace Fortran::runtime {

diff  --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index 0ac1d46e64eb4..79d1373f79a51 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -20,6 +20,7 @@
 #include "copy.h"
 #include "terminator.h"
 #include "tools.h"
+#include "flang/Runtime/descriptor.h"
 #include <algorithm>
 
 namespace Fortran::runtime {


        


More information about the flang-commits mailing list