[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
This commit is contained in:
Peter Klausler 2021-11-26 11:39:31 -08:00
parent 63f417ef39
commit 77ff6f7df8
8 changed files with 56 additions and 4 deletions

View File

@ -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

View File

@ -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_

View File

@ -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,

View File

@ -70,6 +70,7 @@ add_flang_library(FortranRuntime
stat.cpp
stop.cpp
sum.cpp
support.cpp
terminator.cpp
time-intrinsic.cpp
tools.cpp

View File

@ -15,6 +15,7 @@
#include "flang/Runtime/reduction.h"
#include "reduction-templates.h"
#include "flang/Runtime/descriptor.h"
#include <cinttypes>
namespace Fortran::runtime {

20
flang/runtime/support.cpp Normal file
View File

@ -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

View File

@ -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 {

View File

@ -20,6 +20,7 @@
#include "copy.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Runtime/descriptor.h"
#include <algorithm>
namespace Fortran::runtime {