diff --git a/flang/include/flang/Runtime/reduction.h b/flang/include/flang/Runtime/reduction.h --- 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 #include #include 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 --- /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 --- 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 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 --- a/flang/runtime/CMakeLists.txt +++ b/flang/runtime/CMakeLists.txt @@ -70,6 +70,7 @@ 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 --- 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 namespace Fortran::runtime { diff --git a/flang/runtime/support.cpp b/flang/runtime/support.cpp new file mode 100644 --- /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 --- 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 namespace Fortran::runtime { diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp --- 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 namespace Fortran::runtime {