Skip to content

Commit ff18e97

Browse files
klauslervdonaldson
authored andcommitted
[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
1 parent 2036011 commit ff18e97

File tree

8 files changed

+56
-4
lines changed

8 files changed

+56
-4
lines changed

flang/include/flang/Runtime/reduction.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
#define FORTRAN_RUNTIME_REDUCTION_H_
1313

1414
#include "flang/Common/uint128.h"
15-
#include "flang/Runtime/descriptor.h"
1615
#include "flang/Runtime/entry-names.h"
16+
#include <cinttypes>
1717
#include <complex>
1818
#include <cstdint>
1919

2020
namespace Fortran::runtime {
21+
22+
class Descriptor;
23+
2124
extern "C" {
2225

2326
// Reductions that are known to return scalars have per-type entry

flang/include/flang/Runtime/support.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===-- include/flang/Runtime/support.h -------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// Defines APIs for runtime support code for lowering.
10+
#ifndef FORTRAN_RUNTIME_SUPPORT_H_
11+
#define FORTRAN_RUNTIME_SUPPORT_H_
12+
13+
#include "flang/Runtime/entry-names.h"
14+
15+
namespace Fortran::runtime {
16+
17+
class Descriptor;
18+
19+
extern "C" {
20+
21+
// Predicate: is the storage described by a Descriptor contiguous in memory?
22+
bool RTNAME(IsContiguous)(const Descriptor &);
23+
24+
} // extern "C"
25+
} // namespace Fortran::runtime
26+
#endif // FORTRAN_RUNTIME_SUPPORT_H_

flang/include/flang/Runtime/transformational.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
#ifndef FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
1818
#define FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
1919

20-
#include "flang/Runtime/descriptor.h"
2120
#include "flang/Runtime/entry-names.h"
22-
#include "flang/Runtime/memory.h"
21+
#include <cinttypes>
2322

2423
namespace Fortran::runtime {
2524

25+
class Descriptor;
26+
2627
extern "C" {
2728

2829
void RTNAME(Reshape)(Descriptor &result, const Descriptor &source,

flang/runtime/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ add_flang_library(FortranRuntime PARTIAL_SOURCES_INTENDED
6565
stat.cpp
6666
stop.cpp
6767
sum.cpp
68+
support.cpp
6869
terminator.cpp
6970
time-intrinsic.cpp
7071
tools.cpp

flang/runtime/reduction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "flang/Runtime/reduction.h"
1717
#include "reduction-templates.h"
18+
#include "flang/Runtime/descriptor.h"
1819
#include <cinttypes>
1920

2021
namespace Fortran::runtime {

flang/runtime/support.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- runtime/support.cpp -----------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "flang/Runtime/support.h"
10+
#include "flang/Runtime/descriptor.h"
11+
12+
namespace Fortran::runtime {
13+
extern "C" {
14+
15+
bool RTNAME(IsContiguous)(const Descriptor &descriptor) {
16+
return descriptor.IsContiguous();
17+
}
18+
19+
} // extern "C"
20+
} // namespace Fortran::runtime

flang/runtime/terminator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#ifndef FORTRAN_RUNTIME_TERMINATOR_H_
1212
#define FORTRAN_RUNTIME_TERMINATOR_H_
1313

14-
#include "flang/Runtime/entry-names.h"
1514
#include <cstdarg>
1615

1716
namespace Fortran::runtime {

flang/runtime/transformational.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "copy.h"
2121
#include "terminator.h"
2222
#include "tools.h"
23+
#include "flang/Runtime/descriptor.h"
2324
#include <algorithm>
2425

2526
namespace Fortran::runtime {

0 commit comments

Comments
 (0)