Skip to content

Commit 1555280

Browse files
MeinersburIcohedron
authored andcommitted
[Flang] Move non-common headers to FortranSupport (llvm#124416)
Move non-common files from FortranCommon to FortranSupport (analogous to LLVMSupport) such that * declarations and definitions that are only used by the Flang compiler, but not by the runtime, are moved to FortranSupport * declarations and definitions that are used by both ("common"), the compiler and the runtime, remain in FortranCommon * generic STL-like/ADT/utility classes and algorithms remain in FortranCommon This allows a for cleaner separation between compiler and runtime components, which are compiled differently. For instance, runtime sources must not use STL's `<optional>` which causes problems with CUDA support. Instead, the surrogate header `flang/Common/optional.h` must be used. This PR fixes this for `fast-int-sel.h`. Declarations in include/Runtime are also used by both, but are header-only. `ISO_Fortran_binding_wrapper.h`, a header used by compiler and runtime, is also moved into FortranCommon.
1 parent 0d51eda commit 1555280

File tree

133 files changed

+268
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+268
-256
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
/*===-- include/flang/ISO_Fortran_binding_wrapper.h ---------------*- C++ -*-===
1+
/*===-- include/flang/Common/ISO_Fortran_binding_wrapper.h --------*- C++ -*-===
22
*
33
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
* See https://llvm.org/LICENSE.txt for license information.
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
*
7-
* ===-----------------------------------------------------------------------===
8-
*/
7+
*===----------------------------------------------------------------------===*/
98

10-
#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
11-
#define FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
9+
#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
10+
#define FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
1211

1312
/* A thin wrapper around flang/include/ISO_Fortran_binding.h
1413
* This header file must be included when ISO_Fortran_binding.h
@@ -23,17 +22,17 @@
2322

2423
/* clang-format off */
2524
#include <stddef.h>
26-
#include "Common/api-attrs.h"
25+
#include "api-attrs.h"
2726
#ifdef __cplusplus
2827
namespace Fortran {
2928
namespace ISO {
3029
#define FORTRAN_ISO_NAMESPACE_ ::Fortran::ISO
3130
#endif /* __cplusplus */
32-
#include "ISO_Fortran_binding.h"
31+
#include "flang/ISO_Fortran_binding.h"
3332
#ifdef __cplusplus
3433
} // namespace ISO
3534
} // namespace Fortran
3635
#endif /* __cplusplus */
3736
/* clang-format on */
3837

39-
#endif /* FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_ */
38+
#endif /* FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_ */

flang/include/flang/Common/erfc-scaled.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#ifndef FORTRAN_COMMON_ERFC_SCALED_H_
1010
#define FORTRAN_COMMON_ERFC_SCALED_H_
1111

12+
#include <cmath>
13+
#include <limits>
14+
1215
namespace Fortran::common {
1316
template <typename T> inline T ErfcScaled(T arg) {
1417
// Coefficients for approximation to erfc in the first interval.

flang/include/flang/Common/fast-int-set.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#ifndef FORTRAN_COMMON_FAST_INT_SET_H_
2525
#define FORTRAN_COMMON_FAST_INT_SET_H_
2626

27-
#include <optional>
27+
#include "optional.h"
2828

2929
namespace Fortran::common {
3030

@@ -83,9 +83,9 @@ template <int N> class FastIntSet {
8383
}
8484
}
8585

86-
std::optional<int> PopValue() {
86+
optional<int> PopValue() {
8787
if (IsEmpty()) {
88-
return std::nullopt;
88+
return nullopt;
8989
} else {
9090
return value_[--size_];
9191
}

flang/include/flang/Common/format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef FORTRAN_COMMON_FORMAT_H_
1010
#define FORTRAN_COMMON_FORMAT_H_
1111

12+
#include "Fortran-consts.h"
1213
#include "enum-set.h"
13-
#include "flang/Common/Fortran-consts.h"
1414
#include <cstring>
1515

1616
// Define a FormatValidator class template to validate a format expression

flang/include/flang/Common/optional.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#ifndef FORTRAN_COMMON_OPTIONAL_H
2727
#define FORTRAN_COMMON_OPTIONAL_H
2828

29-
#include "flang/Common/api-attrs.h"
29+
#include "api-attrs.h"
3030
#include <optional>
3131
#include <type_traits>
3232

flang/include/flang/Common/real.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// The various representations are distinguished by their binary precisions
1414
// (number of explicit significand bits and any implicit MSB in the fraction).
1515

16-
#include "flang/Common/api-attrs.h"
16+
#include "api-attrs.h"
1717
#include <cinttypes>
1818

1919
namespace Fortran::common {

flang/include/flang/Common/reference-wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#ifndef FORTRAN_COMMON_REFERENCE_WRAPPER_H
2626
#define FORTRAN_COMMON_REFERENCE_WRAPPER_H
2727

28-
#include "flang/Common/api-attrs.h"
28+
#include "api-attrs.h"
2929
#include <functional>
3030
#include <type_traits>
3131

flang/include/flang/Common/restorer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
#ifndef FORTRAN_COMMON_RESTORER_H_
2020
#define FORTRAN_COMMON_RESTORER_H_
21+
#include "api-attrs.h"
2122
#include "idioms.h"
22-
#include "flang/Common/api-attrs.h"
2323
namespace Fortran::common {
2424
template <typename A> class Restorer {
2525
public:

flang/include/flang/Common/target-rounding.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef FORTRAN_COMMON_TARGET_ROUNDING_H_
1010
#define FORTRAN_COMMON_TARGET_ROUNDING_H_
1111

12-
#include "flang/Common/Fortran-consts.h"
13-
#include "flang/Common/enum-set.h"
12+
#include "Fortran-consts.h"
13+
#include "enum-set.h"
1414

1515
namespace Fortran::common {
1616

flang/include/flang/Common/template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef FORTRAN_COMMON_TEMPLATE_H_
1010
#define FORTRAN_COMMON_TEMPLATE_H_
1111

12+
#include "idioms.h"
1213
#include "variant.h"
13-
#include "flang/Common/idioms.h"
1414
#include <functional>
1515
#include <optional>
1616
#include <tuple>

0 commit comments

Comments
 (0)