[clang] [flang] [lld] [llvm] [Flang-RT] Build libflang_rt.so (PR #121782)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 01:13:32 PST 2025
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/121782
>From 72e3c5dedb2f76ae0500befe5963d032bc9c48c8 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 24 Jan 2025 16:24:02 +0100
Subject: [PATCH 01/41] [Flang] Introduce FortranSupport
---
.../ISO_Fortran_binding_wrapper.h | 15 +++---
flang/include/flang/Common/fast-int-set.h | 6 +--
flang/include/flang/Evaluate/call.h | 6 +--
.../include/flang/Evaluate/characteristics.h | 6 +--
flang/include/flang/Evaluate/common.h | 8 +--
flang/include/flang/Evaluate/constant.h | 4 +-
flang/include/flang/Evaluate/expression.h | 6 +--
flang/include/flang/Evaluate/formatting.h | 2 +-
flang/include/flang/Evaluate/intrinsics.h | 2 +-
flang/include/flang/Evaluate/shape.h | 2 +-
flang/include/flang/Evaluate/target.h | 2 +-
flang/include/flang/Evaluate/tools.h | 4 +-
flang/include/flang/Evaluate/traverse.h | 2 +-
flang/include/flang/Evaluate/type.h | 6 +--
flang/include/flang/Evaluate/variable.h | 4 +-
.../flang/Frontend/CompilerInvocation.h | 2 +-
.../include/flang/Frontend/FrontendOptions.h | 2 +-
flang/include/flang/ISO_Fortran_binding.h | 2 +-
flang/include/flang/Lower/AbstractConverter.h | 2 +-
flang/include/flang/Lower/Bridge.h | 2 +-
flang/include/flang/Lower/CallInterface.h | 2 +-
flang/include/flang/Lower/ConvertType.h | 2 +-
flang/include/flang/Lower/LoweringOptions.h | 2 +-
flang/include/flang/Lower/PFTBuilder.h | 4 +-
flang/include/flang/Lower/Support/Utils.h | 2 +-
flang/include/flang/Lower/SymbolMap.h | 2 +-
.../flang/Optimizer/Builder/FIRBuilder.h | 2 +-
.../Optimizer/Builder/PPCIntrinsicCall.h | 2 +-
.../Optimizer/Builder/Runtime/RTBuilder.h | 2 +-
.../flang/Optimizer/CodeGen/DescriptorModel.h | 2 +-
.../Dialect/CUF/Attributes/CUFAttr.h | 2 +-
.../flang/Optimizer/Support/TypeCode.h | 2 +-
flang/include/flang/Optimizer/Support/Utils.h | 2 +-
flang/include/flang/Parser/char-block.h | 2 +-
flang/include/flang/Parser/dump-parse-tree.h | 4 +-
flang/include/flang/Parser/message.h | 4 +-
flang/include/flang/Parser/parse-state.h | 2 +-
flang/include/flang/Parser/parse-tree.h | 4 +-
flang/include/flang/Parser/parsing.h | 2 +-
flang/include/flang/Parser/provenance.h | 2 +-
flang/include/flang/Parser/source.h | 2 +-
flang/include/flang/Parser/user-state.h | 2 +-
.../include/flang/Runtime/descriptor-consts.h | 2 +-
flang/include/flang/Runtime/descriptor.h | 2 +-
flang/include/flang/Runtime/random.h | 5 ++
flang/include/flang/Runtime/support.h | 2 +-
flang/include/flang/Runtime/type-code.h | 2 +-
flang/include/flang/Semantics/expression.h | 4 +-
.../flang/Semantics/runtime-type-info.h | 2 +-
flang/include/flang/Semantics/scope.h | 4 +-
flang/include/flang/Semantics/semantics.h | 4 +-
flang/include/flang/Semantics/symbol.h | 4 +-
flang/include/flang/Semantics/tools.h | 2 +-
flang/include/flang/Semantics/type.h | 2 +-
.../{Common => Support}/Fortran-features.h | 10 ++--
.../flang/{Common => Support}/Fortran.h | 12 ++---
.../flang/{Common => Support}/LangOptions.def | 0
.../flang/{Common => Support}/LangOptions.h | 14 ++---
.../{Common => Support}/MathOptionsBase.def | 0
.../{Common => Support}/MathOptionsBase.h | 14 ++---
.../{Common => Support}/OpenMP-features.h | 8 +--
flang/include/flang/Support/Timing.h | 8 +--
.../flang/{Common => Support}/Version.h | 8 +--
.../flang/{Common => Support}/default-kinds.h | 10 ++--
.../flang/{Common => Support}/indirection.h | 10 ++--
.../flang/{Common => Support}/interval.h | 10 ++--
.../{Common => Support}/reference-counted.h | 8 +--
.../flang/{Common => Support}/reference.h | 8 +--
.../static-multimap-view.h | 8 +--
.../flang/{Common => Support}/template.h | 10 ++--
.../flang/{Common => Support}/unwrap.h | 12 ++---
flang/include/flang/Tools/CrossToolHelpers.h | 4 +-
flang/lib/CMakeLists.txt | 1 -
flang/lib/Common/CMakeLists.txt | 52 ------------------
flang/lib/Evaluate/CMakeLists.txt | 2 +-
flang/lib/Evaluate/call.cpp | 2 +-
flang/lib/Evaluate/characteristics.cpp | 2 +-
flang/lib/Evaluate/fold-implementation.h | 6 +--
flang/lib/Evaluate/formatting.cpp | 2 +-
flang/lib/Evaluate/intrinsics-library.cpp | 2 +-
flang/lib/Evaluate/intrinsics.cpp | 2 +-
flang/lib/Evaluate/shape.cpp | 2 +-
flang/lib/Evaluate/target.cpp | 2 +-
flang/lib/Frontend/CMakeLists.txt | 2 +-
flang/lib/Frontend/CompilerInstance.cpp | 2 +-
flang/lib/Frontend/CompilerInvocation.cpp | 6 +--
flang/lib/Frontend/FrontendActions.cpp | 2 +-
flang/lib/Lower/Bridge.cpp | 2 +-
flang/lib/Lower/CMakeLists.txt | 2 +-
flang/lib/Lower/CallInterface.cpp | 2 +-
flang/lib/Lower/ConvertExpr.cpp | 4 +-
flang/lib/Lower/Mangler.cpp | 2 +-
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +-
flang/lib/Optimizer/CodeGen/TypeConverter.cpp | 2 +-
flang/lib/Optimizer/Dialect/FIRType.cpp | 2 +-
flang/lib/Optimizer/OpenMP/CMakeLists.txt | 2 +-
flang/lib/Optimizer/Passes/CMakeLists.txt | 5 +-
.../lib/Optimizer/Transforms/AddDebugInfo.cpp | 2 +-
.../Transforms/AssumedRankOpConversion.cpp | 2 +-
flang/lib/Optimizer/Transforms/CMakeLists.txt | 2 +-
.../Optimizer/Transforms/CUFDeviceGlobal.cpp | 2 +-
.../Transforms/CUFGPUToLLVMConversion.cpp | 2 +-
.../Optimizer/Transforms/CUFOpConversion.cpp | 2 +-
.../Transforms/ExternalNameConversion.cpp | 2 +-
.../Optimizer/Transforms/LoopVersioning.cpp | 2 +-
.../Transforms/SimplifyIntrinsics.cpp | 2 +-
.../lib/Optimizer/Transforms/StackReclaim.cpp | 2 +-
flang/lib/Optimizer/Transforms/VScaleAttr.cpp | 2 +-
flang/lib/Parser/CMakeLists.txt | 2 +-
flang/lib/Parser/basic-parsers.h | 4 +-
flang/lib/Parser/parse-tree.cpp | 2 +-
flang/lib/Parser/prescan.h | 2 +-
flang/lib/Parser/unparse.cpp | 4 +-
flang/lib/Semantics/CMakeLists.txt | 2 +-
flang/lib/Semantics/assignment.h | 2 +-
flang/lib/Semantics/check-case.cpp | 4 +-
flang/lib/Semantics/check-coarray.cpp | 2 +-
flang/lib/Semantics/check-cuda.cpp | 2 +-
flang/lib/Semantics/check-data.h | 2 +-
flang/lib/Semantics/check-do-forall.cpp | 2 +-
flang/lib/Semantics/check-return.cpp | 2 +-
flang/lib/Semantics/check-select-rank.cpp | 2 +-
flang/lib/Semantics/check-select-type.cpp | 2 +-
flang/lib/Semantics/check-stop.cpp | 2 +-
flang/lib/Semantics/data-to-inits.h | 4 +-
flang/lib/Semantics/expression.cpp | 2 +-
flang/lib/Semantics/pointer-assignment.cpp | 2 +-
flang/lib/Semantics/resolve-labels.cpp | 2 +-
flang/lib/Semantics/resolve-names-utils.cpp | 6 +--
flang/lib/Semantics/resolve-names.cpp | 6 +--
flang/lib/Semantics/rewrite-parse-tree.cpp | 2 +-
flang/lib/Semantics/semantics.cpp | 2 +-
flang/lib/Semantics/tools.cpp | 4 +-
flang/lib/Support/CMakeLists.txt | 53 +++++++++++++++++++
.../{Common => Support}/Fortran-features.cpp | 6 +--
flang/lib/{Common => Support}/Fortran.cpp | 6 +--
flang/lib/{Common => Support}/LangOptions.cpp | 6 +--
.../lib/{Common => Support}/OpenMP-utils.cpp | 2 +-
flang/lib/Support/Timing.cpp | 2 +-
flang/lib/{Common => Support}/Version.cpp | 4 +-
.../lib/{Common => Support}/default-kinds.cpp | 4 +-
flang/lib/{Common => Support}/idioms.cpp | 2 +-
flang/runtime/CUDA/allocator.cpp | 4 +-
flang/runtime/ISO_Fortran_binding.cpp | 2 +-
flang/runtime/ISO_Fortran_util.h | 2 +-
flang/runtime/allocatable.cpp | 2 +-
flang/runtime/stat.h | 2 +-
flang/runtime/temporary-stack.cpp | 2 +-
flang/tools/bbc/CMakeLists.txt | 2 +-
flang/tools/bbc/bbc.cpp | 10 ++--
flang/tools/f18-parse-demo/CMakeLists.txt | 2 +-
flang/tools/f18-parse-demo/f18-parse-demo.cpp | 4 +-
flang/tools/tco/CMakeLists.txt | 2 +-
flang/unittests/Evaluate/CMakeLists.txt | 6 +--
.../Evaluate/ISO-Fortran-binding.cpp | 2 +-
flang/unittests/Frontend/CMakeLists.txt | 2 +-
flang/unittests/Runtime/CUDA/Allocatable.cpp | 2 +-
flang/unittests/Runtime/CUDA/AllocatorCUF.cpp | 2 +-
flang/unittests/Runtime/CUDA/Memory.cpp | 2 +-
flang/unittests/Runtime/TemporaryStack.cpp | 2 +-
160 files changed, 333 insertions(+), 332 deletions(-)
rename flang/include/flang/{ => Common}/ISO_Fortran_binding_wrapper.h (70%)
rename flang/include/flang/{Common => Support}/Fortran-features.h (96%)
rename flang/include/flang/{Common => Support}/Fortran.h (94%)
rename flang/include/flang/{Common => Support}/LangOptions.def (100%)
rename flang/include/flang/{Common => Support}/LangOptions.h (87%)
rename flang/include/flang/{Common => Support}/MathOptionsBase.def (100%)
rename flang/include/flang/{Common => Support}/MathOptionsBase.h (77%)
rename flang/include/flang/{Common => Support}/OpenMP-features.h (85%)
rename flang/include/flang/{Common => Support}/Version.h (90%)
rename flang/include/flang/{Common => Support}/default-kinds.h (91%)
rename flang/include/flang/{Common => Support}/indirection.h (95%)
rename flang/include/flang/{Common => Support}/interval.h (94%)
rename flang/include/flang/{Common => Support}/reference-counted.h (90%)
rename flang/include/flang/{Common => Support}/reference.h (91%)
rename flang/include/flang/{Common => Support}/static-multimap-view.h (91%)
rename flang/include/flang/{Common => Support}/template.h (98%)
rename flang/include/flang/{Common => Support}/unwrap.h (94%)
delete mode 100644 flang/lib/Common/CMakeLists.txt
rename flang/lib/{Common => Support}/Fortran-features.cpp (97%)
rename flang/lib/{Common => Support}/Fortran.cpp (96%)
rename flang/lib/{Common => Support}/LangOptions.cpp (80%)
rename flang/lib/{Common => Support}/OpenMP-utils.cpp (95%)
rename flang/lib/{Common => Support}/Version.cpp (95%)
rename flang/lib/{Common => Support}/default-kinds.cpp (94%)
rename flang/lib/{Common => Support}/idioms.cpp (89%)
diff --git a/flang/include/flang/ISO_Fortran_binding_wrapper.h b/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
similarity index 70%
rename from flang/include/flang/ISO_Fortran_binding_wrapper.h
rename to flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
index 37289bdbabd03..7a8a8a9787bd0 100644
--- a/flang/include/flang/ISO_Fortran_binding_wrapper.h
+++ b/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -1,14 +1,13 @@
-/*===-- include/flang/ISO_Fortran_binding_wrapper.h ---------------*- C++ -*-===
+/*===-- include/flang/Common/ISO_Fortran_binding_wrapper.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
*
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
-#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
-#define FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
+#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
+#define FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
/* A thin wrapper around flang/include/ISO_Fortran_binding.h
* This header file must be included when ISO_Fortran_binding.h
@@ -23,17 +22,17 @@
/* clang-format off */
#include <stddef.h>
-#include "Common/api-attrs.h"
+#include "flang/Common/api-attrs.h"
#ifdef __cplusplus
namespace Fortran {
namespace ISO {
#define FORTRAN_ISO_NAMESPACE_ ::Fortran::ISO
#endif /* __cplusplus */
-#include "ISO_Fortran_binding.h"
+#include "flang/ISO_Fortran_binding.h"
#ifdef __cplusplus
} // namespace ISO
} // namespace Fortran
#endif /* __cplusplus */
/* clang-format on */
-#endif /* FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_ */
+#endif /* FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_ */
diff --git a/flang/include/flang/Common/fast-int-set.h b/flang/include/flang/Common/fast-int-set.h
index d1c9c756a44a6..1214bac75a4bf 100644
--- a/flang/include/flang/Common/fast-int-set.h
+++ b/flang/include/flang/Common/fast-int-set.h
@@ -24,7 +24,7 @@
#ifndef FORTRAN_COMMON_FAST_INT_SET_H_
#define FORTRAN_COMMON_FAST_INT_SET_H_
-#include <optional>
+#include "optional.h"
namespace Fortran::common {
@@ -83,9 +83,9 @@ template <int N> class FastIntSet {
}
}
- std::optional<int> PopValue() {
+ optional<int> PopValue() {
if (IsEmpty()) {
- return std::nullopt;
+ return nullopt;
} else {
return value_[--size_];
}
diff --git a/flang/include/flang/Evaluate/call.h b/flang/include/flang/Evaluate/call.h
index 63277438128eb..4d8ca28cf329a 100644
--- a/flang/include/flang/Evaluate/call.h
+++ b/flang/include/flang/Evaluate/call.h
@@ -13,11 +13,11 @@
#include "constant.h"
#include "formatting.h"
#include "type.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/indirection.h"
-#include "flang/Common/reference.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/attr.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/reference.h"
#include <optional>
#include <vector>
diff --git a/flang/include/flang/Evaluate/characteristics.h b/flang/include/flang/Evaluate/characteristics.h
index 357fc3e595243..ccd584b5ee6aa 100644
--- a/flang/include/flang/Evaluate/characteristics.h
+++ b/flang/include/flang/Evaluate/characteristics.h
@@ -18,13 +18,13 @@
#include "shape.h"
#include "tools.h"
#include "type.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
#include <optional>
#include <string>
#include <variant>
diff --git a/flang/include/flang/Evaluate/common.h b/flang/include/flang/Evaluate/common.h
index 915e95169c7f8..91d38748f5a57 100644
--- a/flang/include/flang/Evaluate/common.h
+++ b/flang/include/flang/Evaluate/common.h
@@ -9,16 +9,16 @@
#ifndef FORTRAN_EVALUATE_COMMON_H_
#define FORTRAN_EVALUATE_COMMON_H_
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/default-kinds.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/target-rounding.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/indirection.h"
#include <cinttypes>
#include <map>
#include <set>
diff --git a/flang/include/flang/Evaluate/constant.h b/flang/include/flang/Evaluate/constant.h
index 61a814446bbfd..63e8ed4119cdf 100644
--- a/flang/include/flang/Evaluate/constant.h
+++ b/flang/include/flang/Evaluate/constant.h
@@ -11,8 +11,8 @@
#include "formatting.h"
#include "type.h"
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/reference.h"
#include <map>
#include <vector>
diff --git a/flang/include/flang/Evaluate/expression.h b/flang/include/flang/Evaluate/expression.h
index 04f4406fc8a2c..ec71550d2a50c 100644
--- a/flang/include/flang/Evaluate/expression.h
+++ b/flang/include/flang/Evaluate/expression.h
@@ -21,11 +21,11 @@
#include "formatting.h"
#include "type.h"
#include "variable.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
-#include "flang/Common/template.h"
#include "flang/Parser/char-block.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/template.h"
#include <algorithm>
#include <list>
#include <tuple>
diff --git a/flang/include/flang/Evaluate/formatting.h b/flang/include/flang/Evaluate/formatting.h
index aa82f56107fdd..ae9351139b193 100644
--- a/flang/include/flang/Evaluate/formatting.h
+++ b/flang/include/flang/Evaluate/formatting.h
@@ -19,7 +19,7 @@
// This header is meant to be included by the headers that define the several
// representational class templates that need it, not by external clients.
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <type_traits>
diff --git a/flang/include/flang/Evaluate/intrinsics.h b/flang/include/flang/Evaluate/intrinsics.h
index 15afb772ae767..dbe1ba7fe7ec1 100644
--- a/flang/include/flang/Evaluate/intrinsics.h
+++ b/flang/include/flang/Evaluate/intrinsics.h
@@ -12,9 +12,9 @@
#include "call.h"
#include "characteristics.h"
#include "type.h"
-#include "flang/Common/default-kinds.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
+#include "flang/Support/default-kinds.h"
#include <memory>
#include <optional>
#include <string>
diff --git a/flang/include/flang/Evaluate/shape.h b/flang/include/flang/Evaluate/shape.h
index 3e42ec691158b..18dca71379e0d 100644
--- a/flang/include/flang/Evaluate/shape.h
+++ b/flang/include/flang/Evaluate/shape.h
@@ -15,8 +15,8 @@
#include "expression.h"
#include "traverse.h"
#include "variable.h"
-#include "flang/Common/indirection.h"
#include "flang/Evaluate/type.h"
+#include "flang/Support/indirection.h"
#include <optional>
#include <variant>
diff --git a/flang/include/flang/Evaluate/target.h b/flang/include/flang/Evaluate/target.h
index e07f916b875e0..f4595dfe4e433 100644
--- a/flang/include/flang/Evaluate/target.h
+++ b/flang/include/flang/Evaluate/target.h
@@ -12,11 +12,11 @@
#ifndef FORTRAN_EVALUATE_TARGET_H_
#define FORTRAN_EVALUATE_TARGET_H_
-#include "flang/Common/Fortran.h"
#include "flang/Common/enum-class.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/target-rounding.h"
#include "flang/Evaluate/common.h"
+#include "flang/Support/Fortran.h"
#include <cstdint>
namespace Fortran::evaluate {
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index 669efb41b0344..fbe905168d253 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -11,8 +11,6 @@
#include "traverse.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/template.h"
-#include "flang/Common/unwrap.h"
#include "flang/Evaluate/constant.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/shape.h"
@@ -21,6 +19,8 @@
#include "flang/Semantics/attr.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
#include <array>
#include <optional>
#include <set>
diff --git a/flang/include/flang/Evaluate/traverse.h b/flang/include/flang/Evaluate/traverse.h
index dd38d64bff63f..58f188a409249 100644
--- a/flang/include/flang/Evaluate/traverse.h
+++ b/flang/include/flang/Evaluate/traverse.h
@@ -38,9 +38,9 @@
// expression of an ASSOCIATE (or related) construct entity.
#include "expression.h"
-#include "flang/Common/indirection.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/type.h"
+#include "flang/Support/indirection.h"
#include <set>
#include <type_traits>
diff --git a/flang/include/flang/Evaluate/type.h b/flang/include/flang/Evaluate/type.h
index 1f9296ac4fea7..ab7e4723152d7 100644
--- a/flang/include/flang/Evaluate/type.h
+++ b/flang/include/flang/Evaluate/type.h
@@ -22,11 +22,11 @@
#include "integer.h"
#include "logical.h"
#include "real.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/real.h"
-#include "flang/Common/template.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/template.h"
#include <cinttypes>
#include <optional>
#include <string>
diff --git a/flang/include/flang/Evaluate/variable.h b/flang/include/flang/Evaluate/variable.h
index 9b597d29813da..bb4150613c81d 100644
--- a/flang/include/flang/Evaluate/variable.h
+++ b/flang/include/flang/Evaluate/variable.h
@@ -21,9 +21,9 @@
#include "static-data.h"
#include "type.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
-#include "flang/Common/template.h"
#include "flang/Parser/char-block.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
#include <optional>
#include <variant>
#include <vector>
diff --git a/flang/include/flang/Frontend/CompilerInvocation.h b/flang/include/flang/Frontend/CompilerInvocation.h
index 7d3f0bdf2e510..b3b7297f6f7f1 100644
--- a/flang/include/flang/Frontend/CompilerInvocation.h
+++ b/flang/include/flang/Frontend/CompilerInvocation.h
@@ -13,7 +13,6 @@
#ifndef FORTRAN_FRONTEND_COMPILERINVOCATION_H
#define FORTRAN_FRONTEND_COMPILERINVOCATION_H
-#include "flang/Common/LangOptions.h"
#include "flang/Frontend/CodeGenOptions.h"
#include "flang/Frontend/FrontendOptions.h"
#include "flang/Frontend/PreprocessorOptions.h"
@@ -22,6 +21,7 @@
#include "flang/Parser/parsing.h"
#include "flang/Semantics/semantics.h"
#include "mlir/Support/Timing.h"
+#include "flang/Support/LangOptions.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "llvm/Option/ArgList.h"
diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h
index a4cb021e309d4..0bd2e621813ca 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -13,10 +13,10 @@
#ifndef FORTRAN_FRONTEND_FRONTENDOPTIONS_H
#define FORTRAN_FRONTEND_FRONTENDOPTIONS_H
-#include "flang/Common/Fortran-features.h"
#include "flang/Lower/EnvironmentDefault.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/unparse.h"
+#include "flang/Support/Fortran-features.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include <cstdint>
diff --git a/flang/include/flang/ISO_Fortran_binding.h b/flang/include/flang/ISO_Fortran_binding.h
index 945f8fef89f0b..f5b8d0d2ea610 100644
--- a/flang/include/flang/ISO_Fortran_binding.h
+++ b/flang/include/flang/ISO_Fortran_binding.h
@@ -14,7 +14,7 @@
* it does so by means of a wrapper header that establishes namespaces and
* a macro for extra function attributes (RT_API_ATTRS).
*/
-#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
+#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
#include <stddef.h>
#define FORTRAN_ISO_NAMESPACE_
#endif
diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index c24f43737df50..3d2b805da6f47 100644
--- a/flang/include/flang/Lower/AbstractConverter.h
+++ b/flang/include/flang/Lower/AbstractConverter.h
@@ -13,12 +13,12 @@
#ifndef FORTRAN_LOWER_ABSTRACTCONVERTER_H
#define FORTRAN_LOWER_ABSTRACTCONVERTER_H
-#include "flang/Common/Fortran.h"
#include "flang/Lower/LoweringOptions.h"
#include "flang/Lower/PFTDefs.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Dialect/FIRAttr.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Operation.h"
diff --git a/flang/include/flang/Lower/Bridge.h b/flang/include/flang/Lower/Bridge.h
index 6404a16f7785a..a8c2bcfda31c1 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -13,7 +13,6 @@
#ifndef FORTRAN_LOWER_BRIDGE_H
#define FORTRAN_LOWER_BRIDGE_H
-#include "flang/Common/Fortran.h"
#include "flang/Frontend/CodeGenOptions.h"
#include "flang/Frontend/TargetOptions.h"
#include "flang/Lower/AbstractConverter.h"
@@ -22,6 +21,7 @@
#include "flang/Lower/StatementContext.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "flang/Support/Fortran.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/OwningOpRef.h"
#include <set>
diff --git a/flang/include/flang/Lower/CallInterface.h b/flang/include/flang/Lower/CallInterface.h
index 72bc9dd890a94..c15edf62df388 100644
--- a/flang/include/flang/Lower/CallInterface.h
+++ b/flang/include/flang/Lower/CallInterface.h
@@ -27,8 +27,8 @@
#ifndef FORTRAN_LOWER_CALLINTERFACE_H
#define FORTRAN_LOWER_CALLINTERFACE_H
-#include "flang/Common/reference.h"
#include "flang/Evaluate/characteristics.h"
+#include "flang/Support/reference.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinOps.h"
#include <memory>
diff --git a/flang/include/flang/Lower/ConvertType.h b/flang/include/flang/Lower/ConvertType.h
index 7a3f92649a4e4..179a682584046 100644
--- a/flang/include/flang/Lower/ConvertType.h
+++ b/flang/include/flang/Lower/ConvertType.h
@@ -21,8 +21,8 @@
#ifndef FORTRAN_LOWER_CONVERT_TYPE_H
#define FORTRAN_LOWER_CONVERT_TYPE_H
-#include "flang/Common/Fortran.h"
#include "flang/Evaluate/type.h"
+#include "flang/Support/Fortran.h"
#include "mlir/IR/BuiltinTypes.h"
namespace mlir {
diff --git a/flang/include/flang/Lower/LoweringOptions.h b/flang/include/flang/Lower/LoweringOptions.h
index 8105ccd7ef6b1..171510393b816 100644
--- a/flang/include/flang/Lower/LoweringOptions.h
+++ b/flang/include/flang/Lower/LoweringOptions.h
@@ -15,7 +15,7 @@
#ifndef FLANG_LOWER_LOWERINGOPTIONS_H
#define FLANG_LOWER_LOWERINGOPTIONS_H
-#include "flang/Common/MathOptionsBase.h"
+#include "flang/Support/MathOptionsBase.h"
namespace Fortran::lower {
diff --git a/flang/include/flang/Lower/PFTBuilder.h b/flang/include/flang/Lower/PFTBuilder.h
index 42d6546b77553..05da17faf2dd7 100644
--- a/flang/include/flang/Lower/PFTBuilder.h
+++ b/flang/include/flang/Lower/PFTBuilder.h
@@ -17,8 +17,6 @@
#ifndef FORTRAN_LOWER_PFTBUILDER_H
#define FORTRAN_LOWER_PFTBUILDER_H
-#include "flang/Common/reference.h"
-#include "flang/Common/template.h"
#include "flang/Lower/HostAssociations.h"
#include "flang/Lower/PFTDefs.h"
#include "flang/Parser/parse-tree.h"
@@ -26,6 +24,8 @@
#include "flang/Semantics/scope.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h
index 1cc74521e22d8..08a872b228691 100644
--- a/flang/include/flang/Lower/Support/Utils.h
+++ b/flang/include/flang/Lower/Support/Utils.h
@@ -13,9 +13,9 @@
#ifndef FORTRAN_LOWER_SUPPORT_UTILS_H
#define FORTRAN_LOWER_SUPPORT_UTILS_H
-#include "flang/Common/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinAttributes.h"
diff --git a/flang/include/flang/Lower/SymbolMap.h b/flang/include/flang/Lower/SymbolMap.h
index c03f9afd40801..fb64db407708a 100644
--- a/flang/include/flang/Lower/SymbolMap.h
+++ b/flang/include/flang/Lower/SymbolMap.h
@@ -13,12 +13,12 @@
#ifndef FORTRAN_LOWER_SYMBOLMAP_H
#define FORTRAN_LOWER_SYMBOLMAP_H
-#include "flang/Common/reference.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Dialect/FortranVariableInterface.h"
#include "flang/Optimizer/Support/Matcher.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/reference.h"
#include "mlir/IR/Value.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index ea658fb16a36c..805667bfe502b 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -16,12 +16,12 @@
#ifndef FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
#define FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
-#include "flang/Common/MathOptionsBase.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Dialect/Support/FIRContext.h"
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "flang/Support/MathOptionsBase.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "llvm/ADT/DenseMap.h"
diff --git a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
index 5ae32f70a11a7..8374b18b8a17d 100644
--- a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
@@ -9,8 +9,8 @@
#ifndef FORTRAN_LOWER_PPCINTRINSICCALL_H
#define FORTRAN_LOWER_PPCINTRINSICCALL_H
-#include "flang/Common/static-multimap-view.h"
#include "flang/Optimizer/Builder/IntrinsicCall.h"
+#include "flang/Support/static-multimap-view.h"
#include "mlir/Dialect/Math/IR/Math.h"
namespace fir {
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index eaa1de76154d9..be07e8d2a9390 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -17,12 +17,12 @@
#ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H
#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H
-#include "flang/Common/Fortran.h"
#include "flang/Common/uint128.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Runtime/reduce.h"
+#include "flang/Support/Fortran.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
#include "llvm/ADT/SmallVector.h"
diff --git a/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h b/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
index 9cccf8db87270..b9a8a670d0793 100644
--- a/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
+++ b/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
@@ -22,7 +22,7 @@
#ifndef OPTIMIZER_DESCRIPTOR_MODEL_H
#define OPTIMIZER_DESCRIPTOR_MODEL_H
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor-consts.h"
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
#include "mlir/IR/BuiltinTypes.h"
diff --git a/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h b/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h
index f32e39b543e3f..85615a4d69157 100644
--- a/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h
+++ b/flang/include/flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_OPTIMIZER_DIALECT_CUF_CUFATTR_H
#define FORTRAN_OPTIMIZER_DIALECT_CUF_CUFATTR_H
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "mlir/IR/BuiltinAttributes.h"
namespace llvm {
diff --git a/flang/include/flang/Optimizer/Support/TypeCode.h b/flang/include/flang/Optimizer/Support/TypeCode.h
index 308c82118d502..ec21d672287e6 100644
--- a/flang/include/flang/Optimizer/Support/TypeCode.h
+++ b/flang/include/flang/Optimizer/Support/TypeCode.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H
#define FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "llvm/Support/ErrorHandling.h"
namespace fir {
diff --git a/flang/include/flang/Optimizer/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h
index d507f4116efb7..ec73af6ec72e9 100644
--- a/flang/include/flang/Optimizer/Support/Utils.h
+++ b/flang/include/flang/Optimizer/Support/Utils.h
@@ -13,13 +13,13 @@
#ifndef FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
#define FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
-#include "flang/Common/default-kinds.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Support/FatalError.h"
+#include "flang/Support/default-kinds.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinAttributes.h"
diff --git a/flang/include/flang/Parser/char-block.h b/flang/include/flang/Parser/char-block.h
index 38f4f7b82e1ea..4541b31e566f9 100644
--- a/flang/include/flang/Parser/char-block.h
+++ b/flang/include/flang/Parser/char-block.h
@@ -11,7 +11,7 @@
// Describes a contiguous block of characters; does not own their storage.
-#include "flang/Common/interval.h"
+#include "flang/Support/interval.h"
#include <algorithm>
#include <cstddef>
#include <cstring>
diff --git a/flang/include/flang/Parser/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h
index 11725991e9c9a..13e367e725a54 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -14,9 +14,9 @@
#include "parse-tree.h"
#include "tools.h"
#include "unparse.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
#include <type_traits>
diff --git a/flang/include/flang/Parser/message.h b/flang/include/flang/Parser/message.h
index bc38f571ca3df..bfbc985b8b91a 100644
--- a/flang/include/flang/Parser/message.h
+++ b/flang/include/flang/Parser/message.h
@@ -15,10 +15,10 @@
#include "char-block.h"
#include "char-set.h"
#include "provenance.h"
-#include "flang/Common/Fortran-features.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference-counted.h"
#include "flang/Common/restorer.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/reference-counted.h"
#include <cstddef>
#include <cstring>
#include <forward_list>
diff --git a/flang/include/flang/Parser/parse-state.h b/flang/include/flang/Parser/parse-state.h
index 76cbb3470dc08..36d70b81b7923 100644
--- a/flang/include/flang/Parser/parse-state.h
+++ b/flang/include/flang/Parser/parse-state.h
@@ -16,11 +16,11 @@
// and recovery during parsing!
#include "user-state.h"
-#include "flang/Common/Fortran-features.h"
#include "flang/Common/idioms.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/message.h"
#include "flang/Parser/provenance.h"
+#include "flang/Support/Fortran-features.h"
#include <cstddef>
#include <cstring>
#include <list>
diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h
index 00d85aa05fb3a..217328b792844 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -22,9 +22,9 @@
#include "format-specification.h"
#include "message.h"
#include "provenance.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
#include "llvm/Frontend/OpenACC/ACC.h.inc"
#include "llvm/Frontend/OpenMP/OMP.h"
#include "llvm/Frontend/OpenMP/OMPConstants.h"
diff --git a/flang/include/flang/Parser/parsing.h b/flang/include/flang/Parser/parsing.h
index 0c774decb16d3..116b6bd6f191f 100644
--- a/flang/include/flang/Parser/parsing.h
+++ b/flang/include/flang/Parser/parsing.h
@@ -14,8 +14,8 @@
#include "message.h"
#include "parse-tree.h"
#include "provenance.h"
-#include "flang/Common/Fortran-features.h"
#include "flang/Parser/preprocessor.h"
+#include "flang/Support/Fortran-features.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <string>
diff --git a/flang/include/flang/Parser/provenance.h b/flang/include/flang/Parser/provenance.h
index a9224b727fd05..7f29fb272c942 100644
--- a/flang/include/flang/Parser/provenance.h
+++ b/flang/include/flang/Parser/provenance.h
@@ -14,7 +14,7 @@
#include "characters.h"
#include "source.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/interval.h"
+#include "flang/Support/interval.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
#include <list>
diff --git a/flang/include/flang/Parser/source.h b/flang/include/flang/Parser/source.h
index a6efdf9546c7f..a67fd66045a3d 100644
--- a/flang/include/flang/Parser/source.h
+++ b/flang/include/flang/Parser/source.h
@@ -15,7 +15,7 @@
// - A Unicode byte order mark is recognized if present.
#include "characters.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
diff --git a/flang/include/flang/Parser/user-state.h b/flang/include/flang/Parser/user-state.h
index 61745a833c715..129f9fb8fee05 100644
--- a/flang/include/flang/Parser/user-state.h
+++ b/flang/include/flang/Parser/user-state.h
@@ -14,10 +14,10 @@
// parse tree construction so as to avoid any need for representing
// state in static data.
-#include "flang/Common/Fortran-features.h"
#include "flang/Common/idioms.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/parse-tree.h"
+#include "flang/Support/Fortran-features.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
#include <optional>
diff --git a/flang/include/flang/Runtime/descriptor-consts.h b/flang/include/flang/Runtime/descriptor-consts.h
index 3b2537579d586..abcdbc4a12002 100644
--- a/flang/include/flang/Runtime/descriptor-consts.h
+++ b/flang/include/flang/Runtime/descriptor-consts.h
@@ -9,8 +9,8 @@
#ifndef FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_
#define FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/api-attrs.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
#include <cstddef>
#include <cstdint>
diff --git a/flang/include/flang/Runtime/descriptor.h b/flang/include/flang/Runtime/descriptor.h
index dd36fba157ca9..628ac8c927a51 100644
--- a/flang/include/flang/Runtime/descriptor.h
+++ b/flang/include/flang/Runtime/descriptor.h
@@ -18,7 +18,7 @@
// User C code is welcome to depend on that ISO_Fortran_binding.h file,
// but should never reference this internal header.
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/memory.h"
#include "flang/Runtime/type-code.h"
diff --git a/flang/include/flang/Runtime/random.h b/flang/include/flang/Runtime/random.h
index 269297dff47db..bb6dcb3873f21 100644
--- a/flang/include/flang/Runtime/random.h
+++ b/flang/include/flang/Runtime/random.h
@@ -8,6 +8,9 @@
// Intrinsic subroutines RANDOM_INIT, RANDOM_NUMBER, and RANDOM_SEED.
+#ifndef FORTRAN_RUNTIME_RANDOM_H_
+#define FORTRAN_RUNTIME_RANDOM_H_
+
#include "flang/Runtime/entry-names.h"
#include <cstdint>
@@ -35,3 +38,5 @@ void RTNAME(RandomSeed)(const Descriptor *size, const Descriptor *put,
} // extern "C"
} // namespace Fortran::runtime
+
+#endif /* FORTRAN_RUNTIME_RANDOM_H_ */
diff --git a/flang/include/flang/Runtime/support.h b/flang/include/flang/Runtime/support.h
index ba9c2598bb0dd..4a6d4357e8710 100644
--- a/flang/include/flang/Runtime/support.h
+++ b/flang/include/flang/Runtime/support.h
@@ -10,7 +10,7 @@
#ifndef FORTRAN_RUNTIME_SUPPORT_H_
#define FORTRAN_RUNTIME_SUPPORT_H_
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/entry-names.h"
#include <cstddef>
#include <cstdint>
diff --git a/flang/include/flang/Runtime/type-code.h b/flang/include/flang/Runtime/type-code.h
index dd3a9f2690ee7..ae854ed2145e4 100644
--- a/flang/include/flang/Runtime/type-code.h
+++ b/flang/include/flang/Runtime/type-code.h
@@ -10,8 +10,8 @@
#define FORTRAN_RUNTIME_TYPE_CODE_H_
#include "flang/Common/Fortran-consts.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/optional.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
#include <utility>
namespace Fortran::runtime {
diff --git a/flang/include/flang/Semantics/expression.h b/flang/include/flang/Semantics/expression.h
index bb1674a9f8877..8ea33902bd213 100644
--- a/flang/include/flang/Semantics/expression.h
+++ b/flang/include/flang/Semantics/expression.h
@@ -10,8 +10,6 @@
#define FORTRAN_SEMANTICS_EXPRESSION_H_
#include "semantics.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/characteristics.h"
@@ -24,6 +22,8 @@
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
#include <map>
#include <optional>
#include <type_traits>
diff --git a/flang/include/flang/Semantics/runtime-type-info.h b/flang/include/flang/Semantics/runtime-type-info.h
index e90d3ae8baf1e..94c50aab69681 100644
--- a/flang/include/flang/Semantics/runtime-type-info.h
+++ b/flang/include/flang/Semantics/runtime-type-info.h
@@ -14,8 +14,8 @@
#ifndef FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
#define FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
-#include "flang/Common/reference.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/reference.h"
#include <map>
#include <set>
#include <string>
diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index b3b033a5a3ae3..b7d115ec2bca4 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -11,11 +11,11 @@
#include "attr.h"
#include "symbol.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
#include "flang/Parser/message.h"
#include "flang/Parser/provenance.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/reference.h"
#include <list>
#include <map>
#include <optional>
diff --git a/flang/include/flang/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h
index c981d86fbd94c..c03a0bad24a6e 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -13,12 +13,12 @@
#include "program-tree.h"
#include "scope.h"
#include "symbol.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/LangOptions.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
#include "flang/Parser/message.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/LangOptions.h"
#include <iosfwd>
#include <set>
#include <string>
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index bc6abccac1bb8..dfe323acbd490 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -10,11 +10,11 @@
#define FORTRAN_SEMANTICS_SYMBOL_H_
#include "type.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/enum-set.h"
-#include "flang/Common/reference.h"
#include "flang/Common/visit.h"
#include "flang/Semantics/module-dependences.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/reference.h"
#include "llvm/ADT/DenseMapInfo.h"
#include <array>
diff --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index 07103f98ff041..012223ef9a098 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -12,7 +12,6 @@
// Simple predicates and look-up functions that are best defined
// canonically for use in semantic checking.
-#include "flang/Common/Fortran.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/shape.h"
@@ -23,6 +22,7 @@
#include "flang/Semantics/attr.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/semantics.h"
+#include "flang/Support/Fortran.h"
#include <functional>
namespace Fortran::semantics {
diff --git a/flang/include/flang/Semantics/type.h b/flang/include/flang/Semantics/type.h
index 3522191502059..5d96f1e89bf52 100644
--- a/flang/include/flang/Semantics/type.h
+++ b/flang/include/flang/Semantics/type.h
@@ -9,10 +9,10 @@
#ifndef FORTRAN_SEMANTICS_TYPE_H_
#define FORTRAN_SEMANTICS_TYPE_H_
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/char-block.h"
+#include "flang/Support/Fortran.h"
#include <algorithm>
#include <iosfwd>
#include <map>
diff --git a/flang/include/flang/Common/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
similarity index 96%
rename from flang/include/flang/Common/Fortran-features.h
rename to flang/include/flang/Support/Fortran-features.h
index 44f88009f8f2c..690329411dc50 100644
--- a/flang/include/flang/Common/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/Fortran-features.h -----------------*- C++ -*-===//
+//===-- include/flang/Support/Fortran-features.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.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_FORTRAN_FEATURES_H_
-#define FORTRAN_COMMON_FORTRAN_FEATURES_H_
+#ifndef FORTRAN_SUPPORT_FORTRAN_FEATURES_H_
+#define FORTRAN_SUPPORT_FORTRAN_FEATURES_H_
-#include "flang/Common/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
#include <optional>
#include <vector>
@@ -125,4 +125,4 @@ class LanguageFeatureControl {
bool warnAllUsage_{false};
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORTRAN_FEATURES_H_
+#endif /* FORTRAN_SUPPORT_FORTRAN_FEATURES_H_ */
diff --git a/flang/include/flang/Common/Fortran.h b/flang/include/flang/Support/Fortran.h
similarity index 94%
rename from flang/include/flang/Common/Fortran.h
rename to flang/include/flang/Support/Fortran.h
index e1922f7654bb1..4e6bdbb67f5f3 100644
--- a/flang/include/flang/Common/Fortran.h
+++ b/flang/include/flang/Support/Fortran.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/Fortran.h --------------------------*- C++ -*-===//
+//===-- include/flang/Support/Fortran.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.
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_FORTRAN_H_
-#define FORTRAN_COMMON_FORTRAN_H_
+#ifndef FORTRAN_SUPPORT_FORTRAN_H_
+#define FORTRAN_SUPPORT_FORTRAN_H_
// Fortran language concepts that are used in many phases are defined
// once here to avoid redundancy and needless translation.
-#include "enum-set.h"
-#include "idioms.h"
#include "flang/Common/Fortran-consts.h"
+#include "flang/Common/enum-set.h"
+#include "flang/Common/idioms.h"
#include <cinttypes>
#include <optional>
#include <string>
@@ -109,4 +109,4 @@ inline std::string GetExternalAssemblyName(
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORTRAN_H_
+#endif /* FORTRAN_SUPPORT_FORTRAN_H_ */
diff --git a/flang/include/flang/Common/LangOptions.def b/flang/include/flang/Support/LangOptions.def
similarity index 100%
rename from flang/include/flang/Common/LangOptions.def
rename to flang/include/flang/Support/LangOptions.def
diff --git a/flang/include/flang/Common/LangOptions.h b/flang/include/flang/Support/LangOptions.h
similarity index 87%
rename from flang/include/flang/Common/LangOptions.h
rename to flang/include/flang/Support/LangOptions.h
index 83f25cfbe2614..3c6094c9a9c87 100644
--- a/flang/include/flang/Common/LangOptions.h
+++ b/flang/include/flang/Support/LangOptions.h
@@ -1,4 +1,4 @@
-//===------ LangOptions.h ---------------------------------------*- C++ -*-===//
+//===-- include/flang/Support/LangOptions.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.
@@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_LANGOPTIONS_H
-#define FORTRAN_COMMON_LANGOPTIONS_H
+#ifndef FORTRAN_SUPPORT_LANGOPTIONS_H_
+#define FORTRAN_SUPPORT_LANGOPTIONS_H_
#include <string>
#include <vector>
@@ -45,12 +45,12 @@ class LangOptionsBase {
#define LANGOPT(Name, Bits, Default) unsigned Name : Bits;
#define ENUM_LANGOPT(Name, Type, Bits, Default)
-#include "flang/Common/LangOptions.def"
+#include "flang/Support/LangOptions.def"
protected:
#define LANGOPT(Name, Bits, Default)
#define ENUM_LANGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "flang/Common/LangOptions.def"
+#include "flang/Support/LangOptions.def"
};
/// Tracks various options which control the dialect of Fortran that is
@@ -63,7 +63,7 @@ class LangOptions : public LangOptionsBase {
#define ENUM_LANGOPT(Name, Type, Bits, Default) \
Type get##Name() const { return static_cast<Type>(Name); } \
void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
-#include "flang/Common/LangOptions.def"
+#include "flang/Support/LangOptions.def"
/// Name of the IR file that contains the result of the OpenMP target
/// host code generation.
@@ -77,4 +77,4 @@ class LangOptions : public LangOptionsBase {
} // end namespace Fortran::common
-#endif // FORTRAN_COMMON_LANGOPTIONS_H
+#endif /* FORTRAN_SUPPORT_LANGOPTIONS_H_ */
diff --git a/flang/include/flang/Common/MathOptionsBase.def b/flang/include/flang/Support/MathOptionsBase.def
similarity index 100%
rename from flang/include/flang/Common/MathOptionsBase.def
rename to flang/include/flang/Support/MathOptionsBase.def
diff --git a/flang/include/flang/Common/MathOptionsBase.h b/flang/include/flang/Support/MathOptionsBase.h
similarity index 77%
rename from flang/include/flang/Common/MathOptionsBase.h
rename to flang/include/flang/Support/MathOptionsBase.h
index 7f8ebdbee1987..072aed20da470 100644
--- a/flang/include/flang/Common/MathOptionsBase.h
+++ b/flang/include/flang/Support/MathOptionsBase.h
@@ -1,4 +1,4 @@
-//===- MathOptionsBase.h - Math options config ------------------*- C++ -*-===//
+//===-- include/flang/Support/MathOptionsBase.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.
@@ -14,8 +14,8 @@
///
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_MATHOPTIONSBASE_H
-#define FORTRAN_COMMON_MATHOPTIONSBASE_H
+#ifndef FORTRAN_SUPPORT_MATHOPTIONSBASE_H_
+#define FORTRAN_SUPPORT_MATHOPTIONSBASE_H_
namespace Fortran::common {
@@ -27,18 +27,18 @@ class MathOptionsBase {
Name = static_cast<unsigned>(Value); \
return *this; \
}
-#include "flang/Common/MathOptionsBase.def"
+#include "flang/Support/MathOptionsBase.def"
MathOptionsBase() {
#define ENUM_MATHOPT(Name, Type, Bits, Default) set##Name(Default);
-#include "flang/Common/MathOptionsBase.def"
+#include "flang/Support/MathOptionsBase.def"
}
private:
#define ENUM_MATHOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "flang/Common/MathOptionsBase.def"
+#include "flang/Support/MathOptionsBase.def"
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_MATHOPTIONSBASE_H
+#endif /* FORTRAN_SUPPORT_MATHOPTIONSBASE_H_ */
diff --git a/flang/include/flang/Common/OpenMP-features.h b/flang/include/flang/Support/OpenMP-features.h
similarity index 85%
rename from flang/include/flang/Common/OpenMP-features.h
rename to flang/include/flang/Support/OpenMP-features.h
index 480c8b4c1013f..85c901e7fdb82 100644
--- a/flang/include/flang/Common/OpenMP-features.h
+++ b/flang/include/flang/Support/OpenMP-features.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/OpenMP-features.h -----------------*- C++ -*-====//
+//===-- include/flang/Support/OpenMP-features.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_OPENMP_FEATURES_H_
-#define FORTRAN_COMMON_OPENMP_FEATURES_H_
+#ifndef FORTRAN_SUPPORT_OPENMP_FEATURES_H_
+#define FORTRAN_SUPPORT_OPENMP_FEATURES_H_
namespace Fortran::common {
@@ -49,4 +49,4 @@ void setOpenMPMacro(int version, FortranPredefinitions &predefinitions) {
}
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_OPENMP_FEATURES_H_
+#endif /* FORTRAN_SUPPORT_OPENMP_FEATURES_H_ */
diff --git a/flang/include/flang/Support/Timing.h b/flang/include/flang/Support/Timing.h
index 75ba2a8d85f39..5d66831d6c1c2 100644
--- a/flang/include/flang/Support/Timing.h
+++ b/flang/include/flang/Support/Timing.h
@@ -1,4 +1,4 @@
-//===- Timing.h - Execution time measurement facilities ---------*- C++ -*-===//
+//===-- include/flang/Support/Timing.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.
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_SUPPORT_TIMING_H
-#define FORTRAN_SUPPORT_TIMING_H
+#ifndef FORTRAN_SUPPORT_TIMING_H_
+#define FORTRAN_SUPPORT_TIMING_H_
#include "mlir/Support/Timing.h"
@@ -24,4 +24,4 @@ std::unique_ptr<mlir::OutputStrategy> createTimingFormatterText(
} // namespace Fortran::support
-#endif // FORTRAN_SUPPORT_TIMING_H
+#endif /* FORTRAN_SUPPORT_TIMING_H_ */
diff --git a/flang/include/flang/Common/Version.h b/flang/include/flang/Support/Version.h
similarity index 90%
rename from flang/include/flang/Common/Version.h
rename to flang/include/flang/Support/Version.h
index 3257d4a4f6459..4ceb19e7f4d71 100644
--- a/flang/include/flang/Common/Version.h
+++ b/flang/include/flang/Support/Version.h
@@ -1,4 +1,4 @@
-//===- Version.h - Flang Version Number ---------------------*- Fortran -*-===//
+//===-- include/flang/Support/Version.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.
@@ -12,8 +12,8 @@
///
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_VERSION_H
-#define FORTRAN_COMMON_VERSION_H
+#ifndef FORTRAN_SUPPORT_VERSION_H_
+#define FORTRAN_SUPPORT_VERSION_H_
#include "flang/Version.inc"
#include "llvm/ADT/StringRef.h"
@@ -53,4 +53,4 @@ std::string getFlangFullVersion();
std::string getFlangToolFullVersion(llvm::StringRef ToolName);
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_VERSION_H
+#endif /* FORTRAN_SUPPORT_VERSION_H_ */
diff --git a/flang/include/flang/Common/default-kinds.h b/flang/include/flang/Support/default-kinds.h
similarity index 91%
rename from flang/include/flang/Common/default-kinds.h
rename to flang/include/flang/Support/default-kinds.h
index 6c66b98e98a05..92f06e6fe2d27 100644
--- a/flang/include/flang/Common/default-kinds.h
+++ b/flang/include/flang/Support/default-kinds.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/default-kinds.h --------------------*- C++ -*-===//
+//===-- include/flang/Support/default-kinds.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.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_DEFAULT_KINDS_H_
-#define FORTRAN_COMMON_DEFAULT_KINDS_H_
+#ifndef FORTRAN_SUPPORT_DEFAULT_KINDS_H_
+#define FORTRAN_SUPPORT_DEFAULT_KINDS_H_
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include <cstdint>
namespace Fortran::common {
@@ -58,4 +58,4 @@ class IntrinsicTypeDefaultKinds {
int defaultLogicalKind_{defaultIntegerKind_};
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_DEFAULT_KINDS_H_
+#endif /* FORTRAN_SUPPORT_DEFAULT_KINDS_H_ */
diff --git a/flang/include/flang/Common/indirection.h b/flang/include/flang/Support/indirection.h
similarity index 95%
rename from flang/include/flang/Common/indirection.h
rename to flang/include/flang/Support/indirection.h
index 7348eb0473f07..aeb1698516bae 100644
--- a/flang/include/flang/Common/indirection.h
+++ b/flang/include/flang/Support/indirection.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/indirection.h ----------------------*- C++ -*-===//
+//===-- include/flang/Support/indirection.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_INDIRECTION_H_
-#define FORTRAN_COMMON_INDIRECTION_H_
+#ifndef FORTRAN_SUPPORT_INDIRECTION_H_
+#define FORTRAN_SUPPORT_INDIRECTION_H_
// Define a smart pointer class template that is rather like
// non-nullable std::unique_ptr<>. Indirection<> is, like a C++ reference
@@ -20,7 +20,7 @@
// template class Fortran::common::Indirection<FORWARD_TYPE>;
// in one C++ source file later where a definition of the type is visible.
-#include "idioms.h"
+#include "flang/Common/idioms.h"
#include <memory>
#include <type_traits>
#include <utility>
@@ -171,4 +171,4 @@ template <typename A> class ForwardOwningPointer {
void (*deleter_)(A *){nullptr};
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_INDIRECTION_H_
+#endif /* FORTRAN_SUPPORT_INDIRECTION_H_ */
diff --git a/flang/include/flang/Common/interval.h b/flang/include/flang/Support/interval.h
similarity index 94%
rename from flang/include/flang/Common/interval.h
rename to flang/include/flang/Support/interval.h
index c4cab0ccf1130..99c0784f006a8 100644
--- a/flang/include/flang/Common/interval.h
+++ b/flang/include/flang/Support/interval.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/interval.h -------------------------*- C++ -*-===//
+//===-- include/flang/Support/interval.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.
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_INTERVAL_H_
-#define FORTRAN_COMMON_INTERVAL_H_
+#ifndef FORTRAN_SUPPORT_INTERVAL_H_
+#define FORTRAN_SUPPORT_INTERVAL_H_
// Defines a generalized template class Interval<A> to represent
// the half-open interval [x .. x+n).
-#include "idioms.h"
+#include "flang/Common/idioms.h"
#include <algorithm>
#include <cstddef>
#include <utility>
@@ -126,4 +126,4 @@ template <typename A> class Interval {
std::size_t size_{0};
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_INTERVAL_H_
+#endif /* FORTRAN_SUPPORT_INTERVAL_H_ */
diff --git a/flang/include/flang/Common/reference-counted.h b/flang/include/flang/Support/reference-counted.h
similarity index 90%
rename from flang/include/flang/Common/reference-counted.h
rename to flang/include/flang/Support/reference-counted.h
index de91d4fb6ee8b..636613d93d80c 100644
--- a/flang/include/flang/Common/reference-counted.h
+++ b/flang/include/flang/Support/reference-counted.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/reference-counted.h ----------------*- C++ -*-===//
+//===-- include/flang/Support/reference-counted.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_REFERENCE_COUNTED_H_
-#define FORTRAN_COMMON_REFERENCE_COUNTED_H_
+#ifndef FORTRAN_SUPPORT_REFERENCE_COUNTED_H_
+#define FORTRAN_SUPPORT_REFERENCE_COUNTED_H_
// A class template of smart pointers to objects with their own
// reference counting object lifetimes that's lighter weight
@@ -74,4 +74,4 @@ template <typename A> class CountedReference {
type *p_{nullptr};
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_REFERENCE_COUNTED_H_
+#endif /* FORTRAN_SUPPORT_REFERENCE_COUNTED_H_ */
diff --git a/flang/include/flang/Common/reference.h b/flang/include/flang/Support/reference.h
similarity index 91%
rename from flang/include/flang/Common/reference.h
rename to flang/include/flang/Support/reference.h
index 0c579de44bd7f..c0b0e048ae04a 100644
--- a/flang/include/flang/Common/reference.h
+++ b/flang/include/flang/Support/reference.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/reference.h ------------------------*- C++ -*-===//
+//===-- include/flang/Support/reference.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.
@@ -11,8 +11,8 @@
// Use Reference<A> in place of a real A& reference when assignability is
// required; safer than a bare pointer because it's guaranteed to not be null.
-#ifndef FORTRAN_COMMON_REFERENCE_H_
-#define FORTRAN_COMMON_REFERENCE_H_
+#ifndef FORTRAN_SUPPORT_REFERENCE_H_
+#define FORTRAN_SUPPORT_REFERENCE_H_
#include <type_traits>
namespace Fortran::common {
template <typename A> class Reference {
@@ -60,4 +60,4 @@ template <typename A> class Reference {
};
template <typename A> Reference(A &) -> Reference<A>;
} // namespace Fortran::common
-#endif
+#endif /* FORTRAN_SUPPORT_REFERENCE_H_ */
diff --git a/flang/include/flang/Common/static-multimap-view.h b/flang/include/flang/Support/static-multimap-view.h
similarity index 91%
rename from flang/include/flang/Common/static-multimap-view.h
rename to flang/include/flang/Support/static-multimap-view.h
index 27d2ba89c8009..8928fab6bfb6f 100644
--- a/flang/include/flang/Common/static-multimap-view.h
+++ b/flang/include/flang/Support/static-multimap-view.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/static-multimap-view.h -------------*- C++ -*-===//
+//===-- include/flang/Support/static-multimap-view.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_STATIC_MULTIMAP_VIEW_H_
-#define FORTRAN_COMMON_STATIC_MULTIMAP_VIEW_H_
+#ifndef FORTRAN_SUPPORT_STATIC_MULTIMAP_VIEW_H_
+#define FORTRAN_SUPPORT_STATIC_MULTIMAP_VIEW_H_
#include <algorithm>
#include <utility>
@@ -59,4 +59,4 @@ template <typename V> class StaticMultimapView {
const_iterator end_{nullptr};
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_STATIC_MULTIMAP_VIEW_H_
+#endif /* FORTRAN_SUPPORT_STATIC_MULTIMAP_VIEW_H_ */
diff --git a/flang/include/flang/Common/template.h b/flang/include/flang/Support/template.h
similarity index 98%
rename from flang/include/flang/Common/template.h
rename to flang/include/flang/Support/template.h
index 51d09fb42ce36..36fa6f7072b40 100644
--- a/flang/include/flang/Common/template.h
+++ b/flang/include/flang/Support/template.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/template.h -------------------------*- C++ -*-===//
+//===-- include/flang/Support/template.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_TEMPLATE_H_
-#define FORTRAN_COMMON_TEMPLATE_H_
+#ifndef FORTRAN_SUPPORT_TEMPLATE_H_
+#define FORTRAN_SUPPORT_TEMPLATE_H_
-#include "variant.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/variant.h"
#include <functional>
#include <optional>
#include <tuple>
@@ -322,4 +322,4 @@ common::IfNoLvalue<typename VISITOR::Result, VISITOR> SearchTypes(
std::move(visitor), std::move(defaultResult));
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_TEMPLATE_H_
+#endif /* FORTRAN_SUPPORT_TEMPLATE_H_ */
diff --git a/flang/include/flang/Common/unwrap.h b/flang/include/flang/Support/unwrap.h
similarity index 94%
rename from flang/include/flang/Common/unwrap.h
rename to flang/include/flang/Support/unwrap.h
index 84582174e4b30..e890753499d1a 100644
--- a/flang/include/flang/Common/unwrap.h
+++ b/flang/include/flang/Support/unwrap.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/unwrap.h ---------------------------*- C++ -*-===//
+//===-- include/flang/Support/unwrap.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.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_UNWRAP_H_
-#define FORTRAN_COMMON_UNWRAP_H_
+#ifndef FORTRAN_SUPPORT_UNWRAP_H_
+#define FORTRAN_SUPPORT_UNWRAP_H_
#include "indirection.h"
#include "reference-counted.h"
#include "reference.h"
-#include "variant.h"
-#include "visit.h"
+#include "flang/Common/variant.h"
+#include "flang/Common/visit.h"
#include <memory>
#include <optional>
#include <type_traits>
@@ -155,4 +155,4 @@ template <typename A, typename B> std::optional<A> UnwrapCopy(const B &x) {
}
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_UNWRAP_H_
+#endif /* FORTRAN_SUPPORT_UNWRAP_H_ */
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h
index 0286f2aa14519..d9401e753fb79 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -13,9 +13,9 @@
#ifndef FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
#define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
-#include "flang/Common/LangOptions.h"
-#include "flang/Common/MathOptionsBase.h"
#include "flang/Frontend/CodeGenOptions.h"
+#include "flang/Support/LangOptions.h"
+#include "flang/Support/MathOptionsBase.h"
#include <cstdint>
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index 2182e845b6a79..05c3535b09b3d 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -1,4 +1,3 @@
-add_subdirectory(Common)
add_subdirectory(Evaluate)
add_subdirectory(Decimal)
add_subdirectory(Lower)
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
deleted file mode 100644
index 4b5df0a49f403..0000000000000
--- a/flang/lib/Common/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
-find_first_existing_vc_file("${FLANG_SOURCE_DIR}" flang_vc)
-
-# The VC revision include that we want to generate.
-set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-
-set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
-
-if(llvm_vc AND LLVM_APPEND_VC_REV)
- set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
-endif()
-if(flang_vc AND LLVM_APPEND_VC_REV)
- set(flang_source_dir ${FLANG_SOURCE_DIR})
-endif()
-
-# Create custom target to generate the VC revision include.
-add_custom_command(OUTPUT "${version_inc}"
- DEPENDS "${llvm_vc}" "${flang_vc}" "${generate_vcs_version_script}"
- COMMAND ${CMAKE_COMMAND} "-DNAMES=\"LLVM;FLANG\""
- "-DLLVM_SOURCE_DIR=${llvm_source_dir}"
- "-DFLANG_SOURCE_DIR=${flang_source_dir}"
- "-DHEADER_FILE=${version_inc}"
- "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
- "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
- -P "${generate_vcs_version_script}")
-
-# Mark the generated header as being generated.
-set_source_files_properties("${version_inc}"
- PROPERTIES GENERATED TRUE
- HEADER_FILE_ONLY TRUE)
-
-if(FLANG_VENDOR)
- set_source_files_properties(Version.cpp
- PROPERTIES COMPILE_DEFINITIONS "FLANG_VENDOR=\"${FLANG_VENDOR} \"")
-endif()
-
-add_flang_library(FortranCommon
- Fortran.cpp
- Fortran-features.cpp
- default-kinds.cpp
- idioms.cpp
- LangOptions.cpp
- OpenMP-utils.cpp
- Version.cpp
- ${version_inc}
-
- LINK_COMPONENTS
- Support
-
- MLIR_LIBS
- MLIRIR
-)
diff --git a/flang/lib/Evaluate/CMakeLists.txt b/flang/lib/Evaluate/CMakeLists.txt
index b38f450d746ea..e0bdb6b2d24d8 100644
--- a/flang/lib/Evaluate/CMakeLists.txt
+++ b/flang/lib/Evaluate/CMakeLists.txt
@@ -60,7 +60,7 @@ add_flang_library(FortranEvaluate
variable.cpp
LINK_LIBS
- FortranCommon
+ FortranSupport
FortranDecimal
FortranParser
${LIBPGMATH}
diff --git a/flang/lib/Evaluate/call.cpp b/flang/lib/Evaluate/call.cpp
index c5b50e806d249..f77df92a7597a 100644
--- a/flang/lib/Evaluate/call.cpp
+++ b/flang/lib/Evaluate/call.cpp
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/call.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/tools.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran.h"
namespace Fortran::evaluate {
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index 3912d1c4b4771..49d11f41ea4ca 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/characteristics.h"
-#include "flang/Common/indirection.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/intrinsics.h"
@@ -17,6 +16,7 @@
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <initializer_list>
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index 31d043f490fd8..723bb8d97f68e 100644
--- a/flang/lib/Evaluate/fold-implementation.h
+++ b/flang/lib/Evaluate/fold-implementation.h
@@ -12,9 +12,6 @@
#include "character.h"
#include "host.h"
#include "int-power.h"
-#include "flang/Common/indirection.h"
-#include "flang/Common/template.h"
-#include "flang/Common/unwrap.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/constant.h"
@@ -31,6 +28,9 @@
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
#include <algorithm>
#include <cmath>
#include <complex>
diff --git a/flang/lib/Evaluate/formatting.cpp b/flang/lib/Evaluate/formatting.cpp
index f3a53c1f983df..c4c3998257830 100644
--- a/flang/lib/Evaluate/formatting.cpp
+++ b/flang/lib/Evaluate/formatting.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/formatting.h"
-#include "flang/Common/Fortran.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/constant.h"
#include "flang/Evaluate/expression.h"
@@ -16,6 +15,7 @@
#include "flang/Parser/characters.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/Fortran.h"
#include "llvm/Support/raw_ostream.h"
namespace Fortran::evaluate {
diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index c1b270f518c0e..fa2c931b21f0a 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -16,8 +16,8 @@
#include "host.h"
#include "flang/Common/erfc-scaled.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/static-multimap-view.h"
#include "flang/Evaluate/expression.h"
+#include "flang/Support/static-multimap-view.h"
#include <cfloat>
#include <cmath>
#include <complex>
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index f234241cfe14a..2881d9942af7e 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/intrinsics.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/check-expression.h"
@@ -19,6 +18,7 @@
#include "flang/Evaluate/type.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cmath>
diff --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp
index 58b824d9b8e64..ab7c357fa78a8 100644
--- a/flang/lib/Evaluate/shape.cpp
+++ b/flang/lib/Evaluate/shape.cpp
@@ -8,7 +8,6 @@
#include "flang/Evaluate/shape.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/template.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/fold.h"
@@ -17,6 +16,7 @@
#include "flang/Evaluate/type.h"
#include "flang/Parser/message.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/template.h"
#include <functional>
using namespace std::placeholders; // _1, _2, &c. for std::bind()
diff --git a/flang/lib/Evaluate/target.cpp b/flang/lib/Evaluate/target.cpp
index 94dc35ecd5900..f87cce8b32005 100644
--- a/flang/lib/Evaluate/target.cpp
+++ b/flang/lib/Evaluate/target.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/target.h"
-#include "flang/Common/template.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/type.h"
+#include "flang/Support/template.h"
namespace Fortran::evaluate {
diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index d063ed36d00b4..81eef2d468d8c 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -27,7 +27,7 @@ add_flang_library(flangFrontend
FortranParser
FortranSemantics
FortranEvaluate
- FortranCommon
+ FortranSupport
FortranLower
FortranSupport
FIRDialect
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index 298790bae6655..7888bab5ffb42 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -11,12 +11,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/CompilerInstance.h"
-#include "flang/Common/Fortran-features.h"
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/TextDiagnosticPrinter.h"
#include "flang/Parser/parsing.h"
#include "flang/Parser/provenance.h"
#include "flang/Semantics/semantics.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Support/Timing.h"
#include "mlir/Support/RawOstreamExtras.h"
#include "clang/Basic/DiagnosticFrontend.h"
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 15b1e1e0a2488..e89c7f3daaf42 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -11,13 +11,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/CompilerInvocation.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/OpenMP-features.h"
-#include "flang/Common/Version.h"
#include "flang/Frontend/CodeGenOptions.h"
#include "flang/Frontend/PreprocessorOptions.h"
#include "flang/Frontend/TargetOptions.h"
#include "flang/Semantics/semantics.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
#include "flang/Tools/TargetSetup.h"
#include "flang/Version.inc"
#include "clang/Basic/AllDiagnostics.h"
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index b0545a7ac2f99..b7674bd093f68 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/FrontendActions.h"
-#include "flang/Common/default-kinds.h"
#include "flang/Frontend/CompilerInstance.h"
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/FrontendOptions.h"
@@ -34,6 +33,7 @@
#include "flang/Semantics/runtime-type-info.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/unparse-with-symbols.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Tools/CrossToolHelpers.h"
#include "mlir/IR/Dialect.h"
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 700ca56141a32..708b6e7be5d8a 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -12,7 +12,6 @@
#include "flang/Lower/Bridge.h"
-#include "flang/Common/Version.h"
#include "flang/Lower/Allocatable.h"
#include "flang/Lower/CallInterface.h"
#include "flang/Lower/Coarray.h"
@@ -62,6 +61,7 @@
#include "flang/Semantics/runtime-type-info.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/Version.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt
index f611010765cb5..0bc708a163638 100644
--- a/flang/lib/Lower/CMakeLists.txt
+++ b/flang/lib/Lower/CMakeLists.txt
@@ -55,7 +55,7 @@ add_flang_library(FortranLower
FIRSupport
FIRTransforms
HLFIRDialect
- FortranCommon
+ FortranSupport
FortranParser
FortranEvaluate
FortranSemantics
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index e20b90b2ff1bc..c8314fac9054c 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/CallInterface.h"
-#include "flang/Common/Fortran.h"
#include "flang/Evaluate/fold.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/Mangler.h"
@@ -23,6 +22,7 @@
#include "flang/Optimizer/Support/Utils.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
#include <optional>
static mlir::FunctionType
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index d9ae502edbafa..04df137ce566f 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -11,8 +11,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/ConvertExpr.h"
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/unwrap.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/real.h"
#include "flang/Evaluate/traverse.h"
@@ -52,6 +50,8 @@
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/unwrap.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/CommandLine.h"
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index 1165417ef89a2..aa40b12196520 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/Mangler.h"
-#include "flang/Common/reference.h"
#include "flang/Lower/Support/Utils.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/reference.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 6a343645ab878..77256a51fa7f7 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -14,7 +14,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Optimizer/Builder/IntrinsicCall.h"
-#include "flang/Common/static-multimap-view.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/Character.h"
#include "flang/Optimizer/Builder/Complex.h"
@@ -42,6 +41,7 @@
#include "flang/Optimizer/Support/Utils.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/iostat-consts.h"
+#include "flang/Support/static-multimap-view.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Math/IR/Math.h"
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
index 0eace903720f0..89f498433806e 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
@@ -13,7 +13,6 @@
#define DEBUG_TYPE "flang-type-conversion"
#include "flang/Optimizer/CodeGen/TypeConverter.h"
-#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/Todo.h" // remove when TODO's are done
#include "flang/Optimizer/CodeGen/DescriptorModel.h"
#include "flang/Optimizer/CodeGen/TBAABuilder.h"
@@ -22,6 +21,7 @@
#include "flang/Optimizer/Dialect/Support/FIRContext.h"
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
#include "flang/Optimizer/Support/InternalNames.h"
+#include "flang/Support/Fortran.h"
#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/Debug.h"
diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index 0b57a10a6c493..67d918cc0f41c 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Optimizer/Dialect/FIRType.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
diff --git a/flang/lib/Optimizer/OpenMP/CMakeLists.txt b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
index 9fe2d3947c26d..f3412e32326de 100644
--- a/flang/lib/Optimizer/OpenMP/CMakeLists.txt
+++ b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
@@ -21,7 +21,7 @@ add_flang_library(FlangOpenMPTransforms
FIRDialect
FIRDialectSupport
FIRSupport
- FortranCommon
+ FortranSupport
FortranEvaluate
HLFIRDialect
diff --git a/flang/lib/Optimizer/Passes/CMakeLists.txt b/flang/lib/Optimizer/Passes/CMakeLists.txt
index eb25beba309bf..1c19a5765aff1 100644
--- a/flang/lib/Optimizer/Passes/CMakeLists.txt
+++ b/flang/lib/Optimizer/Passes/CMakeLists.txt
@@ -5,14 +5,11 @@ add_flang_library(flangPasses
CommandLineOpts.cpp
Pipelines.cpp
- DEPENDS
- FortranCommon
-
LINK_LIBS
FIRCodeGen
FIRTransforms
FlangOpenMPTransforms
- FortranCommon
+ FortranSupport
HLFIRTransforms
LINK_COMPONENTS
diff --git a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index a8e9d198ccb97..79e2b360018c1 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//
#include "DebugTypeGenerator.h"
-#include "flang/Common/Version.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/CodeGen/CGOps.h"
@@ -23,6 +22,7 @@
#include "flang/Optimizer/Dialect/Support/FIRContext.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Version.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Matchers.h"
diff --git a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
index eb59045a5fde7..d0bd67a236419 100644
--- a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
#include "flang/Lower/BuiltinModules.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Runtime/Support.h"
@@ -17,6 +16,7 @@
#include "flang/Optimizer/Support/Utils.h"
#include "flang/Optimizer/Transforms/Passes.h"
#include "flang/Runtime/support.h"
+#include "flang/Support/Fortran.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
diff --git a/flang/lib/Optimizer/Transforms/CMakeLists.txt b/flang/lib/Optimizer/Transforms/CMakeLists.txt
index 9c550f983434a..50994fbb21700 100644
--- a/flang/lib/Optimizer/Transforms/CMakeLists.txt
+++ b/flang/lib/Optimizer/Transforms/CMakeLists.txt
@@ -46,7 +46,7 @@ add_flang_library(FIRTransforms
FIRDialect
FIRDialectSupport
FIRSupport
- FortranCommon
+ FortranSupport
HLFIRDialect
MLIR_LIBS
diff --git a/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp b/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp
index 5ce39f99bbb12..1aeb59b1d669e 100644
--- a/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp
+++ b/flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/CUFCommon.h"
#include "flang/Optimizer/Dialect/CUF/CUFOps.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
@@ -15,6 +14,7 @@
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/allocatable.h"
+#include "flang/Support/Fortran.h"
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Pass/Pass.h"
diff --git a/flang/lib/Optimizer/Transforms/CUFGPUToLLVMConversion.cpp b/flang/lib/Optimizer/Transforms/CUFGPUToLLVMConversion.cpp
index 60aa401e1cc8c..5a3d38722ecd3 100644
--- a/flang/lib/Optimizer/Transforms/CUFGPUToLLVMConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CUFGPUToLLVMConversion.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Optimizer/Transforms/CUFGPUToLLVMConversion.h"
-#include "flang/Common/Fortran.h"
#include "flang/Optimizer/CodeGen/TypeConverter.h"
#include "flang/Optimizer/Support/DataLayout.h"
#include "flang/Runtime/CUDA/common.h"
+#include "flang/Support/Fortran.h"
#include "mlir/Conversion/LLVMCommon/Pattern.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Pass/Pass.h"
diff --git a/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp b/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
index 8b8c00fa7ecfc..88b23b92336b5 100644
--- a/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Optimizer/Transforms/CUFOpConversion.h"
-#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/CUFCommon.h"
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
#include "flang/Optimizer/CodeGen/TypeConverter.h"
@@ -21,6 +20,7 @@
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memory.h"
#include "flang/Runtime/allocatable.h"
+#include "flang/Support/Fortran.h"
#include "mlir/Conversion/LLVMCommon/Pattern.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/IR/Matchers.h"
diff --git a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
index 4f6974ee52695..3d84eaa4c1595 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Fortran.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/SymbolTable.h"
diff --git a/flang/lib/Optimizer/Transforms/LoopVersioning.cpp b/flang/lib/Optimizer/Transforms/LoopVersioning.cpp
index b534ec160ce21..343cc6ff28950 100644
--- a/flang/lib/Optimizer/Transforms/LoopVersioning.cpp
+++ b/flang/lib/Optimizer/Transforms/LoopVersioning.cpp
@@ -40,7 +40,7 @@
/// could be part of the cost analysis above.
//===----------------------------------------------------------------------===//
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Runtime/Inquiry.h"
diff --git a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
index fa6a7b23624e8..df2887ff1422e 100644
--- a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
+++ b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
@@ -22,7 +22,6 @@
/// and small in size.
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/CUFCommon.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
@@ -35,6 +34,7 @@
#include "flang/Optimizer/Transforms/Passes.h"
#include "flang/Optimizer/Transforms/Utils.h"
#include "flang/Runtime/entry-names.h"
+#include "flang/Support/Fortran.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/Operation.h"
diff --git a/flang/lib/Optimizer/Transforms/StackReclaim.cpp b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
index bd3e49a47bc39..acb685850d173 100644
--- a/flang/lib/Optimizer/Transforms/StackReclaim.cpp
+++ b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Transforms/Passes.h"
+#include "flang/Support/Fortran.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Matchers.h"
#include "mlir/Pass/Pass.h"
diff --git a/flang/lib/Optimizer/Transforms/VScaleAttr.cpp b/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
index d311167c58b4d..54a2456e77366 100644
--- a/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
+++ b/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
@@ -14,7 +14,7 @@
/// likely harmless to run it on something else, but it is also not valuable].
//===----------------------------------------------------------------------===//
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Runtime/Inquiry.h"
diff --git a/flang/lib/Parser/CMakeLists.txt b/flang/lib/Parser/CMakeLists.txt
index d364671d7a322..76fe3d7ce6ba4 100644
--- a/flang/lib/Parser/CMakeLists.txt
+++ b/flang/lib/Parser/CMakeLists.txt
@@ -25,7 +25,7 @@ add_flang_library(FortranParser
user-state.cpp
LINK_LIBS
- FortranCommon
+ FortranSupport
LINK_COMPONENTS
Support
diff --git a/flang/lib/Parser/basic-parsers.h b/flang/lib/Parser/basic-parsers.h
index 1a8c14e7048f6..d739102b8464f 100644
--- a/flang/lib/Parser/basic-parsers.h
+++ b/flang/lib/Parser/basic-parsers.h
@@ -22,14 +22,14 @@
// This header defines the fundamental parser class templates and helper
// template functions. See parser-combinators.txt for documentation.
-#include "flang/Common/Fortran-features.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-state.h"
#include "flang/Parser/provenance.h"
#include "flang/Parser/user-state.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/indirection.h"
#include <cstring>
#include <functional>
#include <list>
diff --git a/flang/lib/Parser/parse-tree.cpp b/flang/lib/Parser/parse-tree.cpp
index a414f226058e3..89491fd2fa2a7 100644
--- a/flang/lib/Parser/parse-tree.cpp
+++ b/flang/lib/Parser/parse-tree.cpp
@@ -8,9 +8,9 @@
#include "flang/Parser/parse-tree.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
#include "flang/Parser/tools.h"
#include "flang/Parser/user-state.h"
+#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
diff --git a/flang/lib/Parser/prescan.h b/flang/lib/Parser/prescan.h
index 08041f93b14b6..e2440ad6fbc42 100644
--- a/flang/lib/Parser/prescan.h
+++ b/flang/lib/Parser/prescan.h
@@ -16,11 +16,11 @@
// fixed form character literals on truncated card images, file
// inclusion, and driving the Fortran source preprocessor.
-#include "flang/Common/Fortran-features.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/message.h"
#include "flang/Parser/provenance.h"
#include "flang/Parser/token-sequence.h"
+#include "flang/Support/Fortran-features.h"
#include <bitset>
#include <optional>
#include <string>
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 7bf404bba2c3e..6cd18abbdff0c 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -10,13 +10,13 @@
// traversal templates in parse-tree-visitor.h.
#include "flang/Parser/unparse.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cinttypes>
diff --git a/flang/lib/Semantics/CMakeLists.txt b/flang/lib/Semantics/CMakeLists.txt
index 7855ae7eed138..00108dde49dbd 100644
--- a/flang/lib/Semantics/CMakeLists.txt
+++ b/flang/lib/Semantics/CMakeLists.txt
@@ -53,7 +53,7 @@ add_flang_library(FortranSemantics
omp_gen
LINK_LIBS
- FortranCommon
+ FortranSupport
FortranParser
FortranEvaluate
diff --git a/flang/lib/Semantics/assignment.h b/flang/lib/Semantics/assignment.h
index 95d7b3cf91b17..ba0c70f7d224c 100644
--- a/flang/lib/Semantics/assignment.h
+++ b/flang/lib/Semantics/assignment.h
@@ -9,9 +9,9 @@
#ifndef FORTRAN_SEMANTICS_ASSIGNMENT_H_
#define FORTRAN_SEMANTICS_ASSIGNMENT_H_
-#include "flang/Common/indirection.h"
#include "flang/Evaluate/expression.h"
#include "flang/Semantics/semantics.h"
+#include "flang/Support/indirection.h"
namespace Fortran::parser {
class ContextualMessages;
diff --git a/flang/lib/Semantics/check-case.cpp b/flang/lib/Semantics/check-case.cpp
index 5ce143c9aec91..c81d3b16ab313 100644
--- a/flang/lib/Semantics/check-case.cpp
+++ b/flang/lib/Semantics/check-case.cpp
@@ -8,13 +8,13 @@
#include "check-case.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
-#include "flang/Common/template.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/type.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
#include <tuple>
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-coarray.cpp b/flang/lib/Semantics/check-coarray.cpp
index 6cf61a6b923db..ac1f38801cee7 100644
--- a/flang/lib/Semantics/check-coarray.cpp
+++ b/flang/lib/Semantics/check-coarray.cpp
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "check-coarray.h"
-#include "flang/Common/indirection.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index d8a5639227648..d079f5b6aa530 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "check-cuda.h"
-#include "flang/Common/template.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/tools.h"
#include "flang/Evaluate/traverse.h"
@@ -17,6 +16,7 @@
#include "flang/Semantics/expression.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/template.h"
// Once labeled DO constructs have been canonicalized and their parse subtrees
// transformed into parser::DoConstructs, scan the parser::Blocks of the program
diff --git a/flang/lib/Semantics/check-data.h b/flang/lib/Semantics/check-data.h
index 479d32568fa66..6da316cccc4a7 100644
--- a/flang/lib/Semantics/check-data.h
+++ b/flang/lib/Semantics/check-data.h
@@ -10,11 +10,11 @@
#define FORTRAN_SEMANTICS_CHECK_DATA_H_
#include "data-to-inits.h"
-#include "flang/Common/interval.h"
#include "flang/Evaluate/fold-designator.h"
#include "flang/Evaluate/initial-image.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/semantics.h"
+#include "flang/Support/interval.h"
#include <list>
#include <map>
#include <vector>
diff --git a/flang/lib/Semantics/check-do-forall.cpp b/flang/lib/Semantics/check-do-forall.cpp
index 84e6b6455cc61..ddba4c04b1ee3 100644
--- a/flang/lib/Semantics/check-do-forall.cpp
+++ b/flang/lib/Semantics/check-do-forall.cpp
@@ -8,7 +8,6 @@
#include "check-do-forall.h"
#include "definable.h"
-#include "flang/Common/template.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/tools.h"
@@ -22,6 +21,7 @@
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
+#include "flang/Support/template.h"
namespace Fortran::evaluate {
using ActualArgumentRef = common::Reference<const ActualArgument>;
diff --git a/flang/lib/Semantics/check-return.cpp b/flang/lib/Semantics/check-return.cpp
index 22729f659ed5b..52220a566bbdc 100644
--- a/flang/lib/Semantics/check-return.cpp
+++ b/flang/lib/Semantics/check-return.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "check-return.h"
-#include "flang/Common/Fortran-features.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran-features.h"
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-select-rank.cpp b/flang/lib/Semantics/check-select-rank.cpp
index 2e602d307013c..b227bbaaef4ba 100644
--- a/flang/lib/Semantics/check-select-rank.cpp
+++ b/flang/lib/Semantics/check-select-rank.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "check-select-rank.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Parser/message.h"
#include "flang/Parser/tools.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
#include <list>
#include <optional>
#include <set>
diff --git a/flang/lib/Semantics/check-select-type.cpp b/flang/lib/Semantics/check-select-type.cpp
index 94d16a719277a..b86a95492b21c 100644
--- a/flang/lib/Semantics/check-select-type.cpp
+++ b/flang/lib/Semantics/check-select-type.cpp
@@ -8,12 +8,12 @@
#include "check-select-type.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/type.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/reference.h"
#include <optional>
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-stop.cpp b/flang/lib/Semantics/check-stop.cpp
index 43535b07f029e..aabd52098e63b 100644
--- a/flang/lib/Semantics/check-stop.cpp
+++ b/flang/lib/Semantics/check-stop.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "check-stop.h"
-#include "flang/Common/Fortran.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
#include <optional>
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/data-to-inits.h b/flang/lib/Semantics/data-to-inits.h
index d8cc4601de26f..e99a02cc79db1 100644
--- a/flang/lib/Semantics/data-to-inits.h
+++ b/flang/lib/Semantics/data-to-inits.h
@@ -9,10 +9,10 @@
#ifndef FORTRAN_SEMANTICS_DATA_TO_INITS_H_
#define FORTRAN_SEMANTICS_DATA_TO_INITS_H_
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/interval.h"
#include "flang/Evaluate/fold-designator.h"
#include "flang/Evaluate/initial-image.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/interval.h"
#include <list>
#include <map>
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 3ec6f385ceb86..1dd603412f42d 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -11,7 +11,6 @@
#include "pointer-assignment.h"
#include "resolve-names-utils.h"
#include "resolve-names.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/fold.h"
@@ -24,6 +23,7 @@
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <functional>
diff --git a/flang/lib/Semantics/pointer-assignment.cpp b/flang/lib/Semantics/pointer-assignment.cpp
index 7f4548c7327e3..49684ffd5f804 100644
--- a/flang/lib/Semantics/pointer-assignment.cpp
+++ b/flang/lib/Semantics/pointer-assignment.cpp
@@ -10,7 +10,6 @@
#include "definable.h"
#include "flang/Common/idioms.h"
#include "flang/Common/restorer.h"
-#include "flang/Common/template.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/fold.h"
@@ -21,6 +20,7 @@
#include "flang/Semantics/expression.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/template.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <set>
diff --git a/flang/lib/Semantics/resolve-labels.cpp b/flang/lib/Semantics/resolve-labels.cpp
index 04e4b142efedf..584319b8abdf6 100644
--- a/flang/lib/Semantics/resolve-labels.cpp
+++ b/flang/lib/Semantics/resolve-labels.cpp
@@ -8,9 +8,9 @@
#include "resolve-labels.h"
#include "flang/Common/enum-set.h"
-#include "flang/Common/template.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Semantics/semantics.h"
+#include "flang/Support/template.h"
#include <cstdarg>
#include <type_traits>
diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp
index a838d49c06104..065090ed03b6a 100644
--- a/flang/lib/Semantics/resolve-names-utils.cpp
+++ b/flang/lib/Semantics/resolve-names-utils.cpp
@@ -7,10 +7,7 @@
//===----------------------------------------------------------------------===//
#include "resolve-names-utils.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/tools.h"
#include "flang/Evaluate/traverse.h"
@@ -20,6 +17,9 @@
#include "flang/Semantics/expression.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
#include <initializer_list>
#include <variant>
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index f3c2a5bf094d0..2175d5edea0c0 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -13,9 +13,6 @@
#include "resolve-directives.h"
#include "resolve-names-utils.h"
#include "rewrite-parse-tree.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/characteristics.h"
@@ -38,6 +35,9 @@
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <list>
#include <map>
diff --git a/flang/lib/Semantics/rewrite-parse-tree.cpp b/flang/lib/Semantics/rewrite-parse-tree.cpp
index 577558e7e33b2..171c0021fba08 100644
--- a/flang/lib/Semantics/rewrite-parse-tree.cpp
+++ b/flang/lib/Semantics/rewrite-parse-tree.cpp
@@ -8,7 +8,6 @@
#include "rewrite-parse-tree.h"
#include "rewrite-directives.h"
-#include "flang/Common/indirection.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
@@ -16,6 +15,7 @@
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/indirection.h"
#include <list>
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp
index 58dc1f218b56f..10a01039ea0ae 100644
--- a/flang/lib/Semantics/semantics.cpp
+++ b/flang/lib/Semantics/semantics.cpp
@@ -37,12 +37,12 @@
#include "resolve-labels.h"
#include "resolve-names.h"
#include "rewrite-parse-tree.h"
-#include "flang/Common/default-kinds.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/tools.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
+#include "flang/Support/default-kinds.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 052d71be43472..64e4c9d7e194d 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Parser/tools.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/indirection.h"
#include "flang/Parser/dump-parse-tree.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
@@ -17,6 +15,8 @@
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <set>
diff --git a/flang/lib/Support/CMakeLists.txt b/flang/lib/Support/CMakeLists.txt
index 12183f590316d..809266960a02d 100644
--- a/flang/lib/Support/CMakeLists.txt
+++ b/flang/lib/Support/CMakeLists.txt
@@ -1,9 +1,62 @@
+#===-- lib/Support/CMakeLists.txt ------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
+find_first_existing_vc_file("${FLANG_SOURCE_DIR}" flang_vc)
+
+# The VC revision include that we want to generate.
+set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
+
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
+
+if(llvm_vc AND LLVM_APPEND_VC_REV)
+ set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
+endif()
+if(flang_vc AND LLVM_APPEND_VC_REV)
+ set(flang_source_dir ${FLANG_SOURCE_DIR})
+endif()
+
+# Create custom target to generate the VC revision include.
+add_custom_command(OUTPUT "${version_inc}"
+ DEPENDS "${llvm_vc}" "${flang_vc}" "${generate_vcs_version_script}"
+ COMMAND ${CMAKE_COMMAND} "-DNAMES=\"LLVM;FLANG\""
+ "-DLLVM_SOURCE_DIR=${llvm_source_dir}"
+ "-DFLANG_SOURCE_DIR=${flang_source_dir}"
+ "-DHEADER_FILE=${version_inc}"
+ "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+ "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
+ -P "${generate_vcs_version_script}")
+
+# Mark the generated header as being generated.
+set_source_files_properties("${version_inc}"
+ PROPERTIES GENERATED TRUE
+ HEADER_FILE_ONLY TRUE)
+
+if(FLANG_VENDOR)
+ set_source_files_properties(Version.cpp
+ PROPERTIES COMPILE_DEFINITIONS "FLANG_VENDOR=\"${FLANG_VENDOR} \"")
+endif()
+
add_flang_library(FortranSupport
+ Fortran.cpp
+ Fortran-features.cpp
+ default-kinds.cpp
+ idioms.cpp
+ LangOptions.cpp
+ OpenMP-utils.cpp
+ Version.cpp
Timing.cpp
+ ${version_inc}
LINK_COMPONENTS
Support
MLIR_LIBS
+ MLIRIR
MLIRSupport
)
diff --git a/flang/lib/Common/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
similarity index 97%
rename from flang/lib/Common/Fortran-features.cpp
rename to flang/lib/Support/Fortran-features.cpp
index 3565275915a31..be84072ae6a5b 100644
--- a/flang/lib/Common/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/Fortran-features.cpp -----------------------------------===//
+//===-- lib/Support/Fortran-features.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
namespace Fortran::common {
diff --git a/flang/lib/Common/Fortran.cpp b/flang/lib/Support/Fortran.cpp
similarity index 96%
rename from flang/lib/Common/Fortran.cpp
rename to flang/lib/Support/Fortran.cpp
index eec83419f9eb2..746b7c9740728 100644
--- a/flang/lib/Common/Fortran.cpp
+++ b/flang/lib/Support/Fortran.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/Fortran.cpp --------------------------------------------===//
+//===-- lib/Support/Fortran.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/Fortran-features.h"
namespace Fortran::common {
diff --git a/flang/lib/Common/LangOptions.cpp b/flang/lib/Support/LangOptions.cpp
similarity index 80%
rename from flang/lib/Common/LangOptions.cpp
rename to flang/lib/Support/LangOptions.cpp
index 415c715156e7b..273274fc07215 100644
--- a/flang/lib/Common/LangOptions.cpp
+++ b/flang/lib/Support/LangOptions.cpp
@@ -1,4 +1,4 @@
-//===------ LangOptions.cpp -----------------------------------------------===//
+//===-- lib/Support/LangOptions.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/LangOptions.h"
+#include "flang/Support/LangOptions.h"
#include <string.h>
namespace Fortran::common {
@@ -18,7 +18,7 @@ namespace Fortran::common {
LangOptions::LangOptions() {
#define LANGOPT(Name, Bits, Default) Name = Default;
#define ENUM_LANGOPT(Name, Type, Bits, Default) set##Name(Default);
-#include "flang/Common/LangOptions.def"
+#include "flang/Support/LangOptions.def"
}
} // end namespace Fortran::common
diff --git a/flang/lib/Common/OpenMP-utils.cpp b/flang/lib/Support/OpenMP-utils.cpp
similarity index 95%
rename from flang/lib/Common/OpenMP-utils.cpp
rename to flang/lib/Support/OpenMP-utils.cpp
index 47e89fe6dd1ee..b3cab763aca30 100644
--- a/flang/lib/Common/OpenMP-utils.cpp
+++ b/flang/lib/Support/OpenMP-utils.cpp
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/OpenMP-utils.cpp ------------------*- C++ -*-====//
+//===-- lib/Support/OpenMP-utils.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/lib/Support/Timing.cpp b/flang/lib/Support/Timing.cpp
index ee8309a950eec..41cb2be826907 100644
--- a/flang/lib/Support/Timing.cpp
+++ b/flang/lib/Support/Timing.cpp
@@ -1,4 +1,4 @@
-//===- Timing.cpp - Execution time measurement facilities -----------------===//
+//===-- lib/Support/Timing.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/lib/Common/Version.cpp b/flang/lib/Support/Version.cpp
similarity index 95%
rename from flang/lib/Common/Version.cpp
rename to flang/lib/Support/Version.cpp
index d67255f353dfd..8ee4908f28f62 100644
--- a/flang/lib/Common/Version.cpp
+++ b/flang/lib/Support/Version.cpp
@@ -1,4 +1,4 @@
-//===- Version.cpp - Flang Version Number -------------------*- Fortran -*-===//
+//===-- lib/Support/Version.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Version.h"
+#include "flang/Support/Version.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdlib>
#include <cstring>
diff --git a/flang/lib/Common/default-kinds.cpp b/flang/lib/Support/default-kinds.cpp
similarity index 94%
rename from flang/lib/Common/default-kinds.cpp
rename to flang/lib/Support/default-kinds.cpp
index fbafd827ff0d0..c6d7759097be1 100644
--- a/flang/lib/Common/default-kinds.cpp
+++ b/flang/lib/Support/default-kinds.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/default-kinds.cpp --------------------------------------===//
+//===-- lib/Support/default-kinds.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Common/idioms.h"
namespace Fortran::common {
diff --git a/flang/lib/Common/idioms.cpp b/flang/lib/Support/idioms.cpp
similarity index 89%
rename from flang/lib/Common/idioms.cpp
rename to flang/lib/Support/idioms.cpp
index 536a5c2e5479d..906a4c1bcd9b0 100644
--- a/flang/lib/Common/idioms.cpp
+++ b/flang/lib/Support/idioms.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Common/idioms.cpp ---------------------------------------------===//
+//===-- lib/Support/idioms.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/CUDA/allocator.cpp b/flang/runtime/CUDA/allocator.cpp
index 85b3daf65a8ba..368c1124ef70a 100644
--- a/flang/runtime/CUDA/allocator.cpp
+++ b/flang/runtime/CUDA/allocator.cpp
@@ -11,10 +11,10 @@
#include "../stat.h"
#include "../terminator.h"
#include "../type-info.h"
-#include "flang/Common/Fortran.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
#include "cuda_runtime.h"
diff --git a/flang/runtime/ISO_Fortran_binding.cpp b/flang/runtime/ISO_Fortran_binding.cpp
index fe22026f31f55..64e239f498230 100644
--- a/flang/runtime/ISO_Fortran_binding.cpp
+++ b/flang/runtime/ISO_Fortran_binding.cpp
@@ -11,7 +11,7 @@
#include "ISO_Fortran_util.h"
#include "terminator.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/pointer.h"
#include "flang/Runtime/type-code.h"
diff --git a/flang/runtime/ISO_Fortran_util.h b/flang/runtime/ISO_Fortran_util.h
index dd0eeef80bb89..aca9aee8c5718 100644
--- a/flang/runtime/ISO_Fortran_util.h
+++ b/flang/runtime/ISO_Fortran_util.h
@@ -12,7 +12,7 @@
// Internal utils for establishing CFI_cdesc_t descriptors.
#include "terminator.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/type-code.h"
#include <cstdlib>
diff --git a/flang/runtime/allocatable.cpp b/flang/runtime/allocatable.cpp
index 5e065f47636a8..686114bf86eaf 100644
--- a/flang/runtime/allocatable.cpp
+++ b/flang/runtime/allocatable.cpp
@@ -12,7 +12,7 @@
#include "stat.h"
#include "terminator.h"
#include "type-info.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
#include "flang/Runtime/descriptor.h"
diff --git a/flang/runtime/stat.h b/flang/runtime/stat.h
index 71faeb027d908..572cb6d10b489 100644
--- a/flang/runtime/stat.h
+++ b/flang/runtime/stat.h
@@ -11,8 +11,8 @@
#ifndef FORTRAN_RUNTIME_STAT_H_
#define FORTRAN_RUNTIME_STAT_H_
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/api-attrs.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/magic-numbers.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/temporary-stack.cpp b/flang/runtime/temporary-stack.cpp
index 667b10e04dbd2..93340266b1b44 100644
--- a/flang/runtime/temporary-stack.cpp
+++ b/flang/runtime/temporary-stack.cpp
@@ -11,7 +11,7 @@
#include "flang/Runtime/temporary-stack.h"
#include "terminator.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/memory.h"
diff --git a/flang/tools/bbc/CMakeLists.txt b/flang/tools/bbc/CMakeLists.txt
index 85aeb85e0c530..f950f03920d3f 100644
--- a/flang/tools/bbc/CMakeLists.txt
+++ b/flang/tools/bbc/CMakeLists.txt
@@ -36,7 +36,7 @@ mlir_target_link_libraries(bbc PRIVATE
${extension_libs}
MLIRAffineToStandard
MLIRSCFToControlFlow
- FortranCommon
+ FortranSupport
FortranParser
FortranEvaluate
FortranSemantics
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index 7efc460be8679..4499e44711bd3 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -14,11 +14,6 @@
///
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/LangOptions.h"
-#include "flang/Common/OpenMP-features.h"
-#include "flang/Common/Version.h"
-#include "flang/Common/default-kinds.h"
#include "flang/Frontend/CodeGenOptions.h"
#include "flang/Frontend/TargetOptions.h"
#include "flang/Lower/Bridge.h"
@@ -42,6 +37,11 @@
#include "flang/Semantics/runtime-type-info.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/unparse-with-symbols.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/LangOptions.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Tools/CrossToolHelpers.h"
#include "flang/Tools/TargetSetup.h"
#include "flang/Version.inc"
diff --git a/flang/tools/f18-parse-demo/CMakeLists.txt b/flang/tools/f18-parse-demo/CMakeLists.txt
index df1f1d24a55e5..743a44017e8a5 100644
--- a/flang/tools/f18-parse-demo/CMakeLists.txt
+++ b/flang/tools/f18-parse-demo/CMakeLists.txt
@@ -11,6 +11,6 @@ add_flang_tool(f18-parse-demo
target_link_libraries(f18-parse-demo
PRIVATE
- FortranCommon
+ FortranSupport
FortranParser
)
diff --git a/flang/tools/f18-parse-demo/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
index 3025dbd4dca4a..a50c88dc84064 100644
--- a/flang/tools/f18-parse-demo/f18-parse-demo.cpp
+++ b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
@@ -21,8 +21,6 @@
// scaffolding compiler driver that can test some semantic passes of the
// F18 compiler under development.
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/default-kinds.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/dump-parse-tree.h"
#include "flang/Parser/message.h"
@@ -31,6 +29,8 @@
#include "flang/Parser/parsing.h"
#include "flang/Parser/provenance.h"
#include "flang/Parser/unparse.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/default-kinds.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
diff --git a/flang/tools/tco/CMakeLists.txt b/flang/tools/tco/CMakeLists.txt
index 220f908d2f108..c277cdbf167b6 100644
--- a/flang/tools/tco/CMakeLists.txt
+++ b/flang/tools/tco/CMakeLists.txt
@@ -20,7 +20,7 @@ target_link_libraries(tco PRIVATE
flangPasses
FIROpenACCSupport
FlangOpenMPTransforms
- FortranCommon
+ FortranSupport
)
mlir_target_link_libraries(tco PRIVATE
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 52eb385f4763f..0ea02ad7f7115 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -26,7 +26,7 @@ add_flang_nongtest_unittest(uint128
)
add_flang_nongtest_unittest(expression
- FortranCommon
+ FortranSupport
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
@@ -40,7 +40,7 @@ add_flang_nongtest_unittest(integer
)
add_flang_nongtest_unittest(intrinsics
- FortranCommon
+ FortranSupport
FortranEvaluateTesting
FortranEvaluate
FortranDecimal
@@ -84,7 +84,7 @@ add_flang_nongtest_unittest(ISO-Fortran-binding
)
add_flang_nongtest_unittest(folding
- FortranCommon
+ FortranSupport
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
diff --git a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp b/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
index 3c98363f90046..38688b404876f 100644
--- a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -1,5 +1,5 @@
#include "testing.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor.h"
#include "llvm/Support/raw_ostream.h"
#include <type_traits>
diff --git a/flang/unittests/Frontend/CMakeLists.txt b/flang/unittests/Frontend/CMakeLists.txt
index 9177997f41f53..3cbc2cf148511 100644
--- a/flang/unittests/Frontend/CMakeLists.txt
+++ b/flang/unittests/Frontend/CMakeLists.txt
@@ -18,7 +18,7 @@ target_link_libraries(FlangFrontendTests
FortranLower
FortranParser
FortranSemantics
- FortranCommon
+ FortranSupport
FortranEvaluate
)
diff --git a/flang/unittests/Runtime/CUDA/Allocatable.cpp b/flang/unittests/Runtime/CUDA/Allocatable.cpp
index 0f7eb27789316..bdfa8f5cc3213 100644
--- a/flang/unittests/Runtime/CUDA/Allocatable.cpp
+++ b/flang/unittests/Runtime/CUDA/Allocatable.cpp
@@ -9,11 +9,11 @@
#include "flang/Runtime/allocatable.h"
#include "gtest/gtest.h"
#include "../../../runtime/terminator.h"
-#include "flang/Common/Fortran.h"
#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
#include "cuda_runtime.h"
diff --git a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp b/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 7cb25787e7797..5ec122e4c5777 100644
--- a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -8,11 +8,11 @@
#include "gtest/gtest.h"
#include "../../../runtime/terminator.h"
-#include "flang/Common/Fortran.h"
#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
#include "cuda_runtime.h"
diff --git a/flang/unittests/Runtime/CUDA/Memory.cpp b/flang/unittests/Runtime/CUDA/Memory.cpp
index 7c8b7aa5a4d78..61c9d1131ee56 100644
--- a/flang/unittests/Runtime/CUDA/Memory.cpp
+++ b/flang/unittests/Runtime/CUDA/Memory.cpp
@@ -10,12 +10,12 @@
#include "gtest/gtest.h"
#include "../../../runtime/terminator.h"
#include "../tools.h"
-#include "flang/Common/Fortran.h"
#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
#include "cuda_runtime.h"
diff --git a/flang/unittests/Runtime/TemporaryStack.cpp b/flang/unittests/Runtime/TemporaryStack.cpp
index 0a9344969ca6b..4f701e09b2945 100644
--- a/flang/unittests/Runtime/TemporaryStack.cpp
+++ b/flang/unittests/Runtime/TemporaryStack.cpp
@@ -8,7 +8,7 @@
#include "gtest/gtest.h"
#include "tools.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
>From 71015c8f9ab17431d052472aec99dc67929a166e Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 24 Jan 2025 16:30:47 +0100
Subject: [PATCH 02/41] [Flang] Promote FortranEvaluateTesting library
---
.../flang/Testing}/fp-testing.h | 14 ++++++--
.../flang/Testing}/testing.h | 14 ++++++--
flang/lib/CMakeLists.txt | 4 +++
flang/lib/Testing/CMakeLists.txt | 20 +++++++++++
.../Evaluate => lib/Testing}/fp-testing.cpp | 10 +++++-
.../Evaluate => lib/Testing}/testing.cpp | 10 +++++-
flang/unittests/Evaluate/CMakeLists.txt | 35 ++++++-------------
.../Evaluate/ISO-Fortran-binding.cpp | 2 +-
.../Evaluate/bit-population-count.cpp | 2 +-
flang/unittests/Evaluate/expression.cpp | 2 +-
flang/unittests/Evaluate/folding.cpp | 2 +-
flang/unittests/Evaluate/integer.cpp | 2 +-
flang/unittests/Evaluate/intrinsics.cpp | 2 +-
.../Evaluate/leading-zero-bit-count.cpp | 2 +-
flang/unittests/Evaluate/logical.cpp | 2 +-
flang/unittests/Evaluate/real.cpp | 4 +--
flang/unittests/Evaluate/reshape.cpp | 2 +-
flang/unittests/Evaluate/uint128.cpp | 2 +-
18 files changed, 87 insertions(+), 44 deletions(-)
rename flang/{unittests/Evaluate => include/flang/Testing}/fp-testing.h (54%)
rename flang/{unittests/Evaluate => include/flang/Testing}/testing.h (74%)
create mode 100644 flang/lib/Testing/CMakeLists.txt
rename flang/{unittests/Evaluate => lib/Testing}/fp-testing.cpp (87%)
rename flang/{unittests/Evaluate => lib/Testing}/testing.cpp (88%)
diff --git a/flang/unittests/Evaluate/fp-testing.h b/flang/include/flang/Testing/fp-testing.h
similarity index 54%
rename from flang/unittests/Evaluate/fp-testing.h
rename to flang/include/flang/Testing/fp-testing.h
index 9091963a99b32..e223d2ef7d1b8 100644
--- a/flang/unittests/Evaluate/fp-testing.h
+++ b/flang/include/flang/Testing/fp-testing.h
@@ -1,5 +1,13 @@
-#ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_
-#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
+//===-- include/flang/Testing/fp-testing.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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_TESTING_FP_TESTING_H_
+#define FORTRAN_TESTING_FP_TESTING_H_
#include "flang/Common/target-rounding.h"
#include <fenv.h>
@@ -24,4 +32,4 @@ class ScopedHostFloatingPointEnvironment {
#endif
};
-#endif // FORTRAN_TEST_EVALUATE_FP_TESTING_H_
+#endif /* FORTRAN_TESTING_FP_TESTING_H_ */
diff --git a/flang/unittests/Evaluate/testing.h b/flang/include/flang/Testing/testing.h
similarity index 74%
rename from flang/unittests/Evaluate/testing.h
rename to flang/include/flang/Testing/testing.h
index 422e2853c05bc..404650c9a89f2 100644
--- a/flang/unittests/Evaluate/testing.h
+++ b/flang/include/flang/Testing/testing.h
@@ -1,5 +1,13 @@
-#ifndef FORTRAN_EVALUATE_TESTING_H_
-#define FORTRAN_EVALUATE_TESTING_H_
+//===-- include/flang/Testing/testing.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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_TESTING_TESTING_H_
+#define FORTRAN_TESTING_TESTING_H_
#include <cinttypes>
#include <string>
@@ -33,4 +41,4 @@ FailureDetailPrinter Match(const char *file, int line, const std::string &want,
FailureDetailPrinter Compare(const char *file, int line, const char *xs,
const char *rel, const char *ys, std::uint64_t x, std::uint64_t y);
} // namespace testing
-#endif // FORTRAN_EVALUATE_TESTING_H_
+#endif /* FORTRAN_TESTING_TESTING_H_ */
diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index 05c3535b09b3d..8b201d9a758a8 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -8,3 +8,7 @@ add_subdirectory(Frontend)
add_subdirectory(FrontendTool)
add_subdirectory(Optimizer)
+
+if (FLANG_INCLUDE_TESTS)
+ add_subdirectory(Testing)
+endif ()
diff --git a/flang/lib/Testing/CMakeLists.txt b/flang/lib/Testing/CMakeLists.txt
new file mode 100644
index 0000000000000..8051bc09736d1
--- /dev/null
+++ b/flang/lib/Testing/CMakeLists.txt
@@ -0,0 +1,20 @@
+#===-- lib/Testing/CMakeLists.txt ------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+add_library(NonGTestTesting EXCLUDE_FROM_ALL
+ testing.cpp
+ fp-testing.cpp
+)
+set_target_properties(NonGTestTesting PROPERTIES FOLDER "Flang/Tests")
+
+if (LLVM_LINK_LLVM_DYLIB)
+ set(llvm_libs LLVM)
+else()
+ llvm_map_components_to_libnames(llvm_libs Support)
+endif()
+target_link_libraries(NonGTestTesting ${llvm_libs})
diff --git a/flang/unittests/Evaluate/fp-testing.cpp b/flang/lib/Testing/fp-testing.cpp
similarity index 87%
rename from flang/unittests/Evaluate/fp-testing.cpp
rename to flang/lib/Testing/fp-testing.cpp
index 1a1d7425d5824..5e1728e8df5e4 100644
--- a/flang/unittests/Evaluate/fp-testing.cpp
+++ b/flang/lib/Testing/fp-testing.cpp
@@ -1,4 +1,12 @@
-#include "fp-testing.h"
+//===-- lib/Testing/fp-testing.cpp ------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Testing/fp-testing.h"
#include "llvm/Support/Errno.h"
#include <cstdio>
#include <cstdlib>
diff --git a/flang/unittests/Evaluate/testing.cpp b/flang/lib/Testing/testing.cpp
similarity index 88%
rename from flang/unittests/Evaluate/testing.cpp
rename to flang/lib/Testing/testing.cpp
index b2f73bf1b265a..37f9d88f4886b 100644
--- a/flang/unittests/Evaluate/testing.cpp
+++ b/flang/lib/Testing/testing.cpp
@@ -1,4 +1,12 @@
-#include "testing.h"
+//===-- lib/Testing/testing.cpp ---------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdarg>
#include <cstdio>
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 0ea02ad7f7115..8111ecd72cfc7 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -1,47 +1,34 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-add_library(FortranEvaluateTesting
- testing.cpp
- fp-testing.cpp
-)
-set_target_properties(FortranEvaluateTesting PROPERTIES FOLDER "Flang/Tests")
-if (LLVM_LINK_LLVM_DYLIB)
- set(llvm_libs LLVM)
-else()
- llvm_map_components_to_libnames(llvm_libs Support)
-endif()
-
-target_link_libraries(FortranEvaluateTesting
- ${llvm_libs})
add_flang_nongtest_unittest(leading-zero-bit-count
- FortranEvaluateTesting
+ NonGTestTesting
)
add_flang_nongtest_unittest(bit-population-count
- FortranEvaluateTesting
+ NonGTestTesting
)
add_flang_nongtest_unittest(uint128
- FortranEvaluateTesting
+ NonGTestTesting
)
add_flang_nongtest_unittest(expression
FortranSupport
- FortranEvaluateTesting
+ NonGTestTesting
FortranEvaluate
FortranSemantics
FortranParser
)
add_flang_nongtest_unittest(integer
- FortranEvaluateTesting
+ NonGTestTesting
FortranEvaluate
FortranSemantics
)
add_flang_nongtest_unittest(intrinsics
FortranSupport
- FortranEvaluateTesting
+ NonGTestTesting
FortranEvaluate
FortranDecimal
FortranSemantics
@@ -50,7 +37,7 @@ add_flang_nongtest_unittest(intrinsics
)
add_flang_nongtest_unittest(logical
- FortranEvaluateTesting
+ NonGTestTesting
FortranEvaluate
FortranSemantics
)
@@ -62,7 +49,7 @@ add_flang_nongtest_unittest(logical
set(LLVM_REQUIRES_EH ON)
set(LLVM_REQUIRES_RTTI ON)
add_flang_nongtest_unittest(real
- FortranEvaluateTesting
+ NonGTestTesting
FortranEvaluate
FortranDecimal
FortranSemantics
@@ -70,14 +57,14 @@ add_flang_nongtest_unittest(real
llvm_update_compile_flags(real.test)
add_flang_nongtest_unittest(reshape
- FortranEvaluateTesting
+ NonGTestTesting
FortranSemantics
FortranEvaluate
FortranRuntime
)
add_flang_nongtest_unittest(ISO-Fortran-binding
- FortranEvaluateTesting
+ NonGTestTesting
FortranEvaluate
FortranSemantics
FortranRuntime
@@ -85,7 +72,7 @@ add_flang_nongtest_unittest(ISO-Fortran-binding
add_flang_nongtest_unittest(folding
FortranSupport
- FortranEvaluateTesting
+ NonGTestTesting
FortranEvaluate
FortranSemantics
)
diff --git a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp b/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
index 38688b404876f..2884686b3f26e 100644
--- a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -1,6 +1,6 @@
-#include "testing.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor.h"
+#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
#include <type_traits>
diff --git a/flang/unittests/Evaluate/bit-population-count.cpp b/flang/unittests/Evaluate/bit-population-count.cpp
index 24e721c14f94a..0c9529a92e572 100644
--- a/flang/unittests/Evaluate/bit-population-count.cpp
+++ b/flang/unittests/Evaluate/bit-population-count.cpp
@@ -1,5 +1,5 @@
#include "flang/Common/bit-population-count.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
using Fortran::common::BitPopulationCount;
using Fortran::common::Parity;
diff --git a/flang/unittests/Evaluate/expression.cpp b/flang/unittests/Evaluate/expression.cpp
index f03a6bc2a4e23..d575f36def287 100644
--- a/flang/unittests/Evaluate/expression.cpp
+++ b/flang/unittests/Evaluate/expression.cpp
@@ -1,10 +1,10 @@
#include "flang/Evaluate/expression.h"
-#include "testing.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
#include "flang/Evaluate/tools.h"
#include "flang/Parser/message.h"
+#include "flang/Testing/testing.h"
#include <cstdio>
#include <cstdlib>
#include <string>
diff --git a/flang/unittests/Evaluate/folding.cpp b/flang/unittests/Evaluate/folding.cpp
index 4e8ff9754e4cc..832e55d44316d 100644
--- a/flang/unittests/Evaluate/folding.cpp
+++ b/flang/unittests/Evaluate/folding.cpp
@@ -1,4 +1,3 @@
-#include "testing.h"
#include "../../lib/Evaluate/host.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/expression.h"
@@ -7,6 +6,7 @@
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
#include "flang/Evaluate/tools.h"
+#include "flang/Testing/testing.h"
#include <tuple>
using namespace Fortran::evaluate;
diff --git a/flang/unittests/Evaluate/integer.cpp b/flang/unittests/Evaluate/integer.cpp
index 3eabb2434cce6..5ab22cc6443a7 100644
--- a/flang/unittests/Evaluate/integer.cpp
+++ b/flang/unittests/Evaluate/integer.cpp
@@ -1,5 +1,5 @@
#include "flang/Evaluate/integer.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
#include <cstdio>
#include <string>
diff --git a/flang/unittests/Evaluate/intrinsics.cpp b/flang/unittests/Evaluate/intrinsics.cpp
index 86c471d2c6295..cca2f8c30247e 100644
--- a/flang/unittests/Evaluate/intrinsics.cpp
+++ b/flang/unittests/Evaluate/intrinsics.cpp
@@ -1,10 +1,10 @@
#include "flang/Evaluate/intrinsics.h"
-#include "testing.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/target.h"
#include "flang/Evaluate/tools.h"
#include "flang/Parser/provenance.h"
+#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
#include <initializer_list>
#include <map>
diff --git a/flang/unittests/Evaluate/leading-zero-bit-count.cpp b/flang/unittests/Evaluate/leading-zero-bit-count.cpp
index 968946b69f27e..25e2664e76df0 100644
--- a/flang/unittests/Evaluate/leading-zero-bit-count.cpp
+++ b/flang/unittests/Evaluate/leading-zero-bit-count.cpp
@@ -1,5 +1,5 @@
#include "flang/Common/leading-zero-bit-count.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
using Fortran::common::LeadingZeroBitCount;
diff --git a/flang/unittests/Evaluate/logical.cpp b/flang/unittests/Evaluate/logical.cpp
index d79aff8448712..ba7d0d8d0c0e3 100644
--- a/flang/unittests/Evaluate/logical.cpp
+++ b/flang/unittests/Evaluate/logical.cpp
@@ -1,5 +1,5 @@
-#include "testing.h"
#include "flang/Evaluate/type.h"
+#include "flang/Testing/testing.h"
#include <cstdio>
template <int KIND> void testKind() {
diff --git a/flang/unittests/Evaluate/real.cpp b/flang/unittests/Evaluate/real.cpp
index 1bf7fa1016a9e..a28da5c3273ce 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -1,6 +1,6 @@
-#include "fp-testing.h"
-#include "testing.h"
#include "flang/Evaluate/type.h"
+#include "flang/Testing/fp-testing.h"
+#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
#include <cmath>
#include <cstdio>
diff --git a/flang/unittests/Evaluate/reshape.cpp b/flang/unittests/Evaluate/reshape.cpp
index 5d138cd3d88d9..16cba15dcef60 100644
--- a/flang/unittests/Evaluate/reshape.cpp
+++ b/flang/unittests/Evaluate/reshape.cpp
@@ -1,6 +1,6 @@
-#include "testing.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/transformational.h"
+#include "flang/Testing/testing.h"
#include <cinttypes>
using namespace Fortran::common;
diff --git a/flang/unittests/Evaluate/uint128.cpp b/flang/unittests/Evaluate/uint128.cpp
index f05c1c96a7e8b..0b749abe1c080 100644
--- a/flang/unittests/Evaluate/uint128.cpp
+++ b/flang/unittests/Evaluate/uint128.cpp
@@ -1,6 +1,6 @@
#define AVOID_NATIVE_UINT128_T 1
#include "flang/Common/uint128.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
>From 2e50a1f563dcfec3dae1a5770ed4c90189cf7ba8 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 24 Jan 2025 16:28:55 +0100
Subject: [PATCH 03/41] [Flang] Don't use FortranDecimal for runtime
---
clang/lib/Driver/ToolChains/CommonArgs.cpp | 3 +-
clang/lib/Driver/ToolChains/Flang.cpp | 4 -
flang/docs/FlangDriver.md | 7 +-
flang/lib/Decimal/CMakeLists.txt | 92 ++-----------------
flang/runtime/CMakeLists.txt | 14 +--
flang/test/Driver/linker-flags.f90 | 6 +-
.../test/Driver/msvc-dependent-lib-flags.f90 | 4 -
flang/test/Driver/nostdlib.f90 | 1 -
flang/test/Runtime/no-cpp-dep.c | 2 +-
flang/test/lit.cfg.py | 3 -
lld/COFF/MinGW.cpp | 1 -
11 files changed, 18 insertions(+), 119 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index f8967890f722c..b5273dd8cf1e3 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1321,7 +1321,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
/// Add Fortran runtime libs
void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) {
- // Link FortranRuntime and FortranDecimal
+ // Link FortranRuntime
// These are handled earlier on Windows by telling the frontend driver to
// add the correct libraries to link against as dependents in the object
// file.
@@ -1338,7 +1338,6 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
}
CmdArgs.push_back("-lFortranRuntime");
- CmdArgs.push_back("-lFortranDecimal");
addArchSpecificRPath(TC, Args, CmdArgs);
}
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 86ed25badfa2b..f1bf32b323827 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -361,21 +361,18 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("--dependent-lib=libcmt");
CmdArgs.push_back("--dependent-lib=FortranRuntime.static.lib");
- CmdArgs.push_back("--dependent-lib=FortranDecimal.static.lib");
break;
case options::OPT__SLASH_MTd:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DEBUG");
CmdArgs.push_back("--dependent-lib=libcmtd");
CmdArgs.push_back("--dependent-lib=FortranRuntime.static_dbg.lib");
- CmdArgs.push_back("--dependent-lib=FortranDecimal.static_dbg.lib");
break;
case options::OPT__SLASH_MD:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrt");
CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic.lib");
- CmdArgs.push_back("--dependent-lib=FortranDecimal.dynamic.lib");
break;
case options::OPT__SLASH_MDd:
CmdArgs.push_back("-D_MT");
@@ -383,7 +380,6 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrtd");
CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic_dbg.lib");
- CmdArgs.push_back("--dependent-lib=FortranDecimal.dynamic_dbg.lib");
break;
}
}
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index 23cbab30ee903..be5633529f50c 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -175,19 +175,18 @@ like this:
```
$ flang -v -o example example.o
-"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" "-lFortranDecimal" [...]
+"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" [...]
```
The automatically added libraries are:
* `FortranRuntime`: Provides most of the Flang runtime library.
-* `FortranDecimal`: Provides operations for decimal numbers.
If the code is C/C++ based and invokes Fortran routines, one can either use Clang
or Flang as the linker driver. If Clang is used, it will automatically all
required runtime libraries needed by C++ (e.g., for STL) to the linker invocation.
-In this case, one has to explicitly provide the Fortran runtime libraries
-`FortranRuntime` and/or `FortranDecimal`. An alternative is to use Flang to link.
+In this case, one has to explicitly provide the Fortran runtime library
+`FortranRuntime`. An alternative is to use Flang to link.
In this case, it may be required to explicitly supply C++ runtime libraries.
On Darwin, the logical root where the system libraries are located (sysroot)
diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt
index 880b190f1c581..477d44e0565eb 100644
--- a/flang/lib/Decimal/CMakeLists.txt
+++ b/flang/lib/Decimal/CMakeLists.txt
@@ -1,86 +1,12 @@
-if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
- cmake_minimum_required(VERSION 3.20.0)
-
- project(FortranDecimal C CXX)
-
- set(CMAKE_CXX_STANDARD 17)
- set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
- set(CMAKE_CXX_EXTENSIONS OFF)
-
- set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
-
- set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
- set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
- set(CLANG_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../clang/cmake")
-
- # Add path for custom modules
- list(INSERT CMAKE_MODULE_PATH 0
- "${FLANG_SOURCE_DIR}/cmake"
- "${FLANG_SOURCE_DIR}/cmake/modules"
- "${LLVM_COMMON_CMAKE_UTILS}"
- "${LLVM_COMMON_CMAKE_UTILS}/Modules"
- "${LLVM_CMAKE_UTILS}"
- "${LLVM_CMAKE_UTILS}/modules"
- "${CLANG_CMAKE_UTILS}/modules"
- )
-
- include(AddClang)
- include(AddLLVM)
- include(AddFlang)
- include(HandleLLVMOptions)
-
- include(TestBigEndian)
- test_big_endian(IS_BIGENDIAN)
- if (IS_BIGENDIAN)
- add_compile_definitions(FLANG_BIG_ENDIAN=1)
- else ()
- add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
- endif ()
- include_directories(BEFORE
- ${FLANG_SOURCE_DIR}/include)
-endif()
-
-check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
-if (FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
- append("-fno-lto" CMAKE_CXX_FLAGS)
-endif()
-
-# Disable libstdc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build, to
-# avoid an unwanted dependency on libstdc++.so.
-add_definitions(-U_GLIBCXX_ASSERTIONS)
-
-set(sources
+#===-- lib/Decimal/CMakeLists.txt ------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+add_flang_library(FortranDecimal
binary-to-decimal.cpp
decimal-to-binary.cpp
)
-
-include(AddFlangOffloadRuntime)
-enable_cuda_compilation(FortranDecimal "${sources}")
-enable_omp_offload_compilation("${sources}")
-
-add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN ${sources})
-
-if (DEFINED MSVC)
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
- add_flang_library(FortranDecimal.static INSTALL_WITH_TOOLCHAIN
- binary-to-decimal.cpp
- decimal-to-binary.cpp
- )
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
- add_flang_library(FortranDecimal.dynamic INSTALL_WITH_TOOLCHAIN
- binary-to-decimal.cpp
- decimal-to-binary.cpp
- )
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
- add_flang_library(FortranDecimal.static_dbg INSTALL_WITH_TOOLCHAIN
- binary-to-decimal.cpp
- decimal-to-binary.cpp
- )
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
- add_flang_library(FortranDecimal.dynamic_dbg INSTALL_WITH_TOOLCHAIN
- binary-to-decimal.cpp
- decimal-to-binary.cpp
- )
- add_dependencies(FortranDecimal FortranDecimal.static FortranDecimal.dynamic
- FortranDecimal.static_dbg FortranDecimal.dynamic_dbg)
-endif()
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index fbfaae9a88064..6343c4276f0e3 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -111,6 +111,8 @@ add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
add_subdirectory(Float128Math)
set(sources
+ ${FLANG_SOURCE_DIR}/lib/Decimal/binary-to-decimal.cpp
+ ${FLANG_SOURCE_DIR}/lib/Decimal/decimal-to-binary.cpp
ISO_Fortran_binding.cpp
allocator-registry.cpp
allocatable.cpp
@@ -270,39 +272,27 @@ endif()
if (NOT DEFINED MSVC)
add_flang_library(FortranRuntime
${sources}
- LINK_LIBS
- FortranDecimal
INSTALL_WITH_TOOLCHAIN
)
else()
add_flang_library(FortranRuntime
${sources}
- LINK_LIBS
- FortranDecimal
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_flang_library(FortranRuntime.static ${sources}
- LINK_LIBS
- FortranDecimal.static
INSTALL_WITH_TOOLCHAIN)
set_target_properties(FortranRuntime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
add_flang_library(FortranRuntime.dynamic ${sources}
- LINK_LIBS
- FortranDecimal.dynamic
INSTALL_WITH_TOOLCHAIN)
set_target_properties(FortranRuntime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
add_flang_library(FortranRuntime.static_dbg ${sources}
- LINK_LIBS
- FortranDecimal.static_dbg
INSTALL_WITH_TOOLCHAIN)
set_target_properties(FortranRuntime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
add_flang_library(FortranRuntime.dynamic_dbg ${sources}
- LINK_LIBS
- FortranDecimal.dynamic_dbg
INSTALL_WITH_TOOLCHAIN)
set_target_properties(FortranRuntime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
add_dependencies(FortranRuntime FortranRuntime.static FortranRuntime.dynamic
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index ac9500d7c45ce..fdeb95e4dd97c 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -33,7 +33,7 @@
! SOLARIS-F128NONE-NOT: FortranFloat128Math
! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
-! UNIX-SAME: "-lFortranRuntime" "-lFortranDecimal" "-lm"
+! UNIX-SAME: "-lFortranRuntime" "-lm"
! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
@@ -41,20 +41,18 @@
! DARWIN-F128NONE-NOT: FortranFloat128Math
! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
! DARWIN-SAME: -lFortranRuntime
-! DARWIN-SAME: -lFortranDecimal
! HAIKU-LABEL: "{{.*}}ld{{(\.exe)?}}"
! HAIKU-SAME: "[[object_file]]"
! HAIKU-F128NONE-NOT: FortranFloat128Math
! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! HAIKU-SAME: "-lFortranRuntime" "-lFortranDecimal"
+! HAIKU-SAME: "-lFortranRuntime"
! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}"
! MINGW-SAME: "[[object_file]]"
! MINGW-F128NONE-NOT: FortranFloat128Math
! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
! MINGW-SAME: -lFortranRuntime
-! MINGW-SAME: -lFortranDecimal
! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
! any .exe suffix that is added when resolving to the full path of
diff --git a/flang/test/Driver/msvc-dependent-lib-flags.f90 b/flang/test/Driver/msvc-dependent-lib-flags.f90
index 765917f07d8e7..befe61fdadcd1 100644
--- a/flang/test/Driver/msvc-dependent-lib-flags.f90
+++ b/flang/test/Driver/msvc-dependent-lib-flags.f90
@@ -8,7 +8,6 @@
! MSVC-SAME: -D_MT
! MSVC-SAME: --dependent-lib=libcmt
! MSVC-SAME: --dependent-lib=FortranRuntime.static.lib
-! MSVC-SAME: --dependent-lib=FortranDecimal.static.lib
! MSVC-DEBUG: -fc1
! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -16,7 +15,6 @@
! MSVC-DEBUG-SAME: -D_DEBUG
! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
! MSVC-DEBUG-SAME: --dependent-lib=FortranRuntime.static_dbg.lib
-! MSVC-DEBUG-SAME: --dependent-lib=FortranDecimal.static_dbg.lib
! MSVC-DLL: -fc1
! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -24,7 +22,6 @@
! MSVC-DLL-SAME: -D_DLL
! MSVC-DLL-SAME: --dependent-lib=msvcrt
! MSVC-DLL-SAME: --dependent-lib=FortranRuntime.dynamic.lib
-! MSVC-DLL-SAME: --dependent-lib=FortranDecimal.dynamic.lib
! MSVC-DLL-DEBUG: -fc1
! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -33,4 +30,3 @@
! MSVC-DLL-DEBUG-SAME: -D_DLL
! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranRuntime.dynamic_dbg.lib
-! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranDecimal.dynamic_dbg.lib
diff --git a/flang/test/Driver/nostdlib.f90 b/flang/test/Driver/nostdlib.f90
index cd707e632a45f..ab7c675fe7b77 100644
--- a/flang/test/Driver/nostdlib.f90
+++ b/flang/test/Driver/nostdlib.f90
@@ -25,5 +25,4 @@
! platform individually.
! CHECK-NOT: "-lFortranRuntime"
-! CHECK-NOT: "-lFortranDecimal"
! CHECK-NOT: "-lgcc"
diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang/test/Runtime/no-cpp-dep.c
index 606a5d189f719..b1a5fa004014c 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/flang/test/Runtime/no-cpp-dep.c
@@ -6,7 +6,7 @@ a C compiler.
REQUIRES: c-compiler
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
-RUN: %cc -std=c99 %s -I%include %libruntime %libdecimal -lm \
+RUN: %cc -std=c99 %s -I%include %libruntime -lm \
RUN: %if system-aix %{-lpthread %}
RUN: rm a.out
*/
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index f43234fb125b7..c452b6d231c89 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -168,12 +168,10 @@
# we don't have one, we can just disable the test.
if config.cc:
libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
- libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecimal.a")
include = os.path.join(config.flang_src_dir, "include")
if (
os.path.isfile(libruntime)
- and os.path.isfile(libdecimal)
and os.path.isdir(include)
):
config.available_features.add("c-compiler")
@@ -183,7 +181,6 @@
)
)
tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
- tools.append(ToolSubst("%libdecimal", command=libdecimal, unresolved="fatal"))
tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
# Add all the tools and their substitutions (if applicable). Use the search paths provided for
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index 76f5a0a7500b9..797ab37f06981 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -51,7 +51,6 @@ AutoExporter::AutoExporter(
"libc++",
"libc++abi",
"libFortranRuntime",
- "libFortranDecimal",
"libunwind",
"libmsvcrt",
"libucrtbase",
>From 4c676f468ba344ac0c388583a4ed28035d05ae89 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 24 Jan 2025 15:00:16 +0100
Subject: [PATCH 04/41] users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME
---
flang/CMakeLists.txt | 6 +++++-
flang/test/CMakeLists.txt | 6 +++++-
flang/test/Driver/ctofortran.f90 | 1 +
flang/test/Driver/exec.f90 | 1 +
flang/test/Runtime/no-cpp-dep.c | 2 +-
flang/test/lit.cfg.py | 5 ++++-
flang/test/lit.site.cfg.py.in | 2 ++
flang/tools/f18/CMakeLists.txt | 2 +-
flang/unittests/CMakeLists.txt | 11 +++++++++-
flang/unittests/Evaluate/CMakeLists.txt | 27 +++++++++++++------------
10 files changed, 44 insertions(+), 19 deletions(-)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index b619553ef8302..7d6dcb5c184a5 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -247,6 +247,8 @@ else()
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
endif()
+option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" ON)
+
set(FLANG_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
mark_as_advanced(FLANG_TOOLS_INSTALL_DIR)
@@ -487,7 +489,9 @@ if (FLANG_CUF_RUNTIME)
find_package(CUDAToolkit REQUIRED)
endif()
-add_subdirectory(runtime)
+if (FLANG_INCLUDE_RUNTIME)
+ add_subdirectory(runtime)
+endif ()
if (LLVM_INCLUDE_EXAMPLES)
add_subdirectory(examples)
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index cab214c2ef4c8..e398e0786147a 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -71,9 +71,13 @@ set(FLANG_TEST_DEPENDS
llvm-objdump
llvm-readobj
split-file
- FortranRuntime
FortranDecimal
)
+
+if (FLANG_INCLUDE_RUNTIME)
+ list(APPEND FLANG_TEST_DEPENDS FortranRuntime)
+endif ()
+
if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
list(APPEND FLANG_TEST_DEPENDS Bye)
endif()
diff --git a/flang/test/Driver/ctofortran.f90 b/flang/test/Driver/ctofortran.f90
index 78eac32133b18..10c7adaccc958 100644
--- a/flang/test/Driver/ctofortran.f90
+++ b/flang/test/Driver/ctofortran.f90
@@ -1,4 +1,5 @@
! UNSUPPORTED: system-windows
+! REQUIRES: flang-rt
! RUN: split-file %s %t
! RUN: chmod +x %t/runtest.sh
! RUN: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang | FileCheck %s
diff --git a/flang/test/Driver/exec.f90 b/flang/test/Driver/exec.f90
index fd174005ddf62..9ca91ee24011c 100644
--- a/flang/test/Driver/exec.f90
+++ b/flang/test/Driver/exec.f90
@@ -1,4 +1,5 @@
! UNSUPPORTED: system-windows
+! REQUIRES: flang-rt
! Verify that flang can correctly build executables.
! RUN: %flang %s -o %t
diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang/test/Runtime/no-cpp-dep.c
index b1a5fa004014c..7303ce63fdec4 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/flang/test/Runtime/no-cpp-dep.c
@@ -3,7 +3,7 @@ This test makes sure that flang's runtime does not depend on the C++ runtime
library. It tries to link this simple file against libFortranRuntime.a with
a C compiler.
-REQUIRES: c-compiler
+REQUIRES: c-compiler, flang-rt
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
RUN: %cc -std=c99 %s -I%include %libruntime -lm \
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index c452b6d231c89..f4580afc8c47b 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -163,10 +163,13 @@
ToolSubst("%not_todo_abort_cmd", command=FindTool("not"), unresolved="fatal")
)
+if config.flang_include_runtime:
+ config.available_features.add("flang-rt")
+
# Define some variables to help us test that the flang runtime doesn't depend on
# the C++ runtime libraries. For this we need a C compiler. If for some reason
# we don't have one, we can just disable the test.
-if config.cc:
+if config.flang_include_runtime and config.cc:
libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
include = os.path.join(config.flang_src_dir, "include")
diff --git a/flang/test/lit.site.cfg.py.in b/flang/test/lit.site.cfg.py.in
index d1a0ac763cf8a..697ba3fa79763 100644
--- a/flang/test/lit.site.cfg.py.in
+++ b/flang/test/lit.site.cfg.py.in
@@ -1,6 +1,7 @@
@LIT_SITE_CFG_IN_HEADER@
import sys
+import lit.util
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
config.llvm_shlib_dir = lit_config.substitute(path(r"@SHLIBDIR@"))
@@ -32,6 +33,7 @@ else:
config.openmp_module_dir = None
config.flang_runtime_f128_math_lib = "@FLANG_RUNTIME_F128_MATH_LIB@"
config.have_ldbl_mant_dig_113 = "@HAVE_LDBL_MANT_DIG_113@"
+config.flang_include_runtime = lit.util.pythonize_bool("@FLANG_INCLUDE_RUNTIME@")
import lit.llvm
lit.llvm.initialize(lit_config, config)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index cc2bc5b8eb5ce..85ba2c74cdeb5 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -109,7 +109,7 @@ if (NOT CMAKE_CROSSCOMPILING)
set(compile_with "-fsyntax-only")
set(object_output "")
set(include_in_link FALSE)
- if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION)
+ if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION AND FLANG_INCLUDE_RUNTIME)
set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}")
set(compile_with -c -o ${object_output})
set(include_in_link TRUE)
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index 945067fed4f82..ecb7d68d8f729 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -1,3 +1,5 @@
+include(AddFlangOffloadRuntime)
+
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
# If Fortran runtime is built as CUDA library, the linking
# of targets that link FortranRuntime must be done
@@ -11,6 +13,11 @@ add_custom_target(FlangUnitTests)
set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests")
function(add_flang_unittest_offload_properties target)
+ # Do not apply runtime properties if not even compiling the runtime.
+ if (NOT FLANG_INCLUDE_RUNTIME)
+ return ()
+ endif ()
+
# Set CUDA_RESOLVE_DEVICE_SYMBOLS.
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
set_target_properties(${target}
@@ -75,5 +82,7 @@ add_subdirectory(Optimizer)
add_subdirectory(Common)
add_subdirectory(Decimal)
add_subdirectory(Evaluate)
-add_subdirectory(Runtime)
+if (FLANG_INCLUDE_RUNTIME)
+ add_subdirectory(Runtime)
+endif ()
add_subdirectory(Frontend)
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 8111ecd72cfc7..1c3fac29cd298 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -33,7 +33,6 @@ add_flang_nongtest_unittest(intrinsics
FortranDecimal
FortranSemantics
FortranParser
- FortranRuntime
)
add_flang_nongtest_unittest(logical
@@ -56,19 +55,21 @@ add_flang_nongtest_unittest(real
)
llvm_update_compile_flags(real.test)
-add_flang_nongtest_unittest(reshape
- NonGTestTesting
- FortranSemantics
- FortranEvaluate
- FortranRuntime
-)
+if (FLANG_INCLUDE_RUNTIME)
+ add_flang_nongtest_unittest(reshape
+ NonGTestTesting
+ FortranSemantics
+ FortranEvaluate
+ FortranRuntime
+ )
-add_flang_nongtest_unittest(ISO-Fortran-binding
- NonGTestTesting
- FortranEvaluate
- FortranSemantics
- FortranRuntime
-)
+ add_flang_nongtest_unittest(ISO-Fortran-binding
+ NonGTestTesting
+ FortranEvaluate
+ FortranSemantics
+ FortranRuntime
+ )
+endif ()
add_flang_nongtest_unittest(folding
FortranSupport
>From 875607fdecfada90a80ec732637ea9595fe72ba3 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 24 Jan 2025 16:42:24 +0100
Subject: [PATCH 05/41] [Flang] Rename libFortranRuntime.a to libflang_rt.a
---
clang/lib/Driver/ToolChains/CommonArgs.cpp | 4 +-
clang/lib/Driver/ToolChains/Flang.cpp | 8 ++--
flang/CMakeLists.txt | 2 +-
flang/docs/FlangDriver.md | 6 +--
flang/docs/GettingStarted.md | 6 +--
flang/docs/OpenACC-descriptor-management.md | 2 +-
flang/docs/ReleaseNotes.md | 2 +
.../ExternalHelloWorld/CMakeLists.txt | 2 +-
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +-
flang/runtime/CMakeLists.txt | 40 +++++++++++--------
flang/runtime/CUDA/CMakeLists.txt | 2 +-
flang/runtime/Float128Math/CMakeLists.txt | 2 +-
flang/runtime/time-intrinsic.cpp | 2 +-
flang/test/CMakeLists.txt | 8 +++-
.../test/Driver/gcc-toolchain-install-dir.f90 | 2 +-
flang/test/Driver/linker-flags.f90 | 8 ++--
.../test/Driver/msvc-dependent-lib-flags.f90 | 8 ++--
flang/test/Driver/nostdlib.f90 | 2 +-
flang/test/Runtime/no-cpp-dep.c | 2 +-
flang/test/lit.cfg.py | 2 +-
flang/tools/f18/CMakeLists.txt | 8 ++--
flang/unittests/CMakeLists.txt | 2 +-
flang/unittests/Evaluate/CMakeLists.txt | 4 +-
flang/unittests/Runtime/CMakeLists.txt | 2 +-
flang/unittests/Runtime/CUDA/CMakeLists.txt | 2 +-
lld/COFF/MinGW.cpp | 2 +-
26 files changed, 73 insertions(+), 59 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b5273dd8cf1e3..c7b0a660ee021 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1321,7 +1321,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
/// Add Fortran runtime libs
void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) {
- // Link FortranRuntime
+ // Link flang_rt
// These are handled earlier on Windows by telling the frontend driver to
// add the correct libraries to link against as dependents in the object
// file.
@@ -1337,7 +1337,7 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
if (AsNeeded)
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
}
- CmdArgs.push_back("-lFortranRuntime");
+ CmdArgs.push_back("-lflang_rt");
addArchSpecificRPath(TC, Args, CmdArgs);
}
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index f1bf32b323827..68a17edf8ca34 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -360,26 +360,26 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
case options::OPT__SLASH_MT:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("--dependent-lib=libcmt");
- CmdArgs.push_back("--dependent-lib=FortranRuntime.static.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.static.lib");
break;
case options::OPT__SLASH_MTd:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DEBUG");
CmdArgs.push_back("--dependent-lib=libcmtd");
- CmdArgs.push_back("--dependent-lib=FortranRuntime.static_dbg.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.static_dbg.lib");
break;
case options::OPT__SLASH_MD:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrt");
- CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.dynamic.lib");
break;
case options::OPT__SLASH_MDd:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DEBUG");
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrtd");
- CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic_dbg.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.dynamic_dbg.lib");
break;
}
}
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 7d6dcb5c184a5..8a8b8bfa73b00 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -301,7 +301,7 @@ set(FLANG_DEFAULT_LINKER "" CACHE STRING
"Default linker to use (linker name or absolute path, empty for platform default)")
set(FLANG_DEFAULT_RTLIB "" CACHE STRING
- "Default Fortran runtime library to use (\"libFortranRuntime\"), leave empty for platform default.")
+ "Default Fortran runtime library to use (\"libflang_rt\"), leave empty for platform default.")
if (NOT(FLANG_DEFAULT_RTLIB STREQUAL ""))
message(WARNING "Resetting Flang's default runtime library to use platform default.")
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index be5633529f50c..f3a732b039890 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -175,18 +175,18 @@ like this:
```
$ flang -v -o example example.o
-"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" [...]
+"/usr/bin/ld" [...] example.o [...] "-lflang_rt" [...]
```
The automatically added libraries are:
-* `FortranRuntime`: Provides most of the Flang runtime library.
+* `flang_rt`: Provides most of the Flang runtime library.
If the code is C/C++ based and invokes Fortran routines, one can either use Clang
or Flang as the linker driver. If Clang is used, it will automatically all
required runtime libraries needed by C++ (e.g., for STL) to the linker invocation.
In this case, one has to explicitly provide the Fortran runtime library
-`FortranRuntime`. An alternative is to use Flang to link.
+`flang_rt`. An alternative is to use Flang to link.
In this case, it may be required to explicitly supply C++ runtime libraries.
On Darwin, the logical root where the system libraries are located (sysroot)
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index 1c85a6754b155..ffde50b6f481e 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -216,7 +216,7 @@ cmake \
-DCMAKE_CUDA_COMPILER=clang \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
../runtime/
-make -j FortranRuntime
+make -j flang-rt
```
Note that the used version of `clang` must [support](https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#cuda-support)
@@ -239,7 +239,7 @@ cmake \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
../runtime/
-make -j FortranRuntime
+make -j flang-rt
```
Note that `nvcc` might limit support to certain
@@ -294,7 +294,7 @@ cmake \
-DFLANG_OMP_DEVICE_ARCHITECTURES="all" \
../runtime/
-make -j FortranRuntime
+make -j flang-rt
```
The result of the build is a "device-only" library, i.e. the host
diff --git a/flang/docs/OpenACC-descriptor-management.md b/flang/docs/OpenACC-descriptor-management.md
index 52d00ae4daef8..6c147a56894c8 100644
--- a/flang/docs/OpenACC-descriptor-management.md
+++ b/flang/docs/OpenACC-descriptor-management.md
@@ -427,7 +427,7 @@ The implementation's behavior may be described as (OpenACC 2.7.2):
All the "is-present" checks and the data actions for the auxiliary pointers must be performed atomically with regards to the present counters bookkeeping.
-The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `FortranRuntime` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).
+The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `flang_rt` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).
## TODOs:
diff --git a/flang/docs/ReleaseNotes.md b/flang/docs/ReleaseNotes.md
index f0c956281915f..a163b4f4ed67d 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -36,6 +36,8 @@ page](https://llvm.org/releases/).
## Build System Changes
+ * FortranRuntime has been renamed to `flang_rt`.
+
## New Issues Found
diff --git a/flang/examples/ExternalHelloWorld/CMakeLists.txt b/flang/examples/ExternalHelloWorld/CMakeLists.txt
index 042d4b6238ba4..213fc462ac2b1 100644
--- a/flang/examples/ExternalHelloWorld/CMakeLists.txt
+++ b/flang/examples/ExternalHelloWorld/CMakeLists.txt
@@ -5,5 +5,5 @@ add_llvm_example(external-hello-world
target_link_libraries(external-hello-world
PRIVATE
- FortranRuntime
+ flang_rt
)
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 77256a51fa7f7..29ab0ab9a75f3 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -784,7 +784,7 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
// Generate a call to the Fortran runtime library providing
// support for 128-bit float math.
// On 'HAS_LDBL128' targets the implementation
-// is provided by FortranRuntime, otherwise, it is done via
+// is provided by flang_rt, otherwise, it is done via
// FortranFloat128Math library. In the latter case the compiler
// has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee
// proper linking actions in the driver.
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 6343c4276f0e3..3e32daba52a81 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -236,13 +236,13 @@ set(supported_files
utf.cpp
)
-enable_cuda_compilation(FortranRuntime "${supported_files}")
+enable_cuda_compilation(flang_rt "${supported_files}")
enable_omp_offload_compilation("${supported_files}")
if (NOT TARGET FortranFloat128Math)
# If FortranFloat128Math is not defined, then we are not building
# standalone FortranFloat128Math library. Instead, include
- # the relevant sources into FortranRuntime itself.
+ # the relevant sources into flang_rt itself.
# The information is provided via FortranFloat128MathILib
# interface library.
get_target_property(f128_sources
@@ -270,37 +270,37 @@ if (NOT TARGET FortranFloat128Math)
endif()
if (NOT DEFINED MSVC)
- add_flang_library(FortranRuntime
+ add_flang_library(flang_rt
${sources}
INSTALL_WITH_TOOLCHAIN
)
else()
- add_flang_library(FortranRuntime
+ add_flang_library(flang_rt
${sources}
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
- add_flang_library(FortranRuntime.static ${sources}
+ add_flang_library(flang_rt.static ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(FortranRuntime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
+ set_target_properties(flang_rt.static PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
- add_flang_library(FortranRuntime.dynamic ${sources}
+ add_flang_library(flang_rt.dynamic ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(FortranRuntime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
+ set_target_properties(flang_rt.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
- add_flang_library(FortranRuntime.static_dbg ${sources}
+ add_flang_library(flang_rt.static_dbg ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(FortranRuntime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+ set_target_properties(flang_rt.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
- add_flang_library(FortranRuntime.dynamic_dbg ${sources}
+ add_flang_library(flang_rt.dynamic_dbg ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(FortranRuntime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
- add_dependencies(FortranRuntime FortranRuntime.static FortranRuntime.dynamic
- FortranRuntime.static_dbg FortranRuntime.dynamic_dbg)
+ set_target_properties(flang_rt.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+ add_dependencies(flang_rt flang_rt.static flang_rt.dynamic
+ flang_rt.static_dbg flang_rt.dynamic_dbg)
endif()
-set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries")
+set_target_properties(flang_rt PROPERTIES FOLDER "Flang/Runtime Libraries")
-# If FortranRuntime is part of a Flang build (and not a separate build) then
+# If flang_rt is part of a Flang build (and not a separate build) then
# add dependency to make sure that Fortran runtime library is being built after
# we have the Flang compiler available. This also includes the MODULE files
# that compile when the 'flang' target is built.
@@ -308,9 +308,15 @@ set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries"
# TODO: This is a workaround and should be updated when runtime build procedure
# is changed to a regular runtime build. See discussion in PR #95388.
if (TARGET flang AND TARGET module_files)
- add_dependencies(FortranRuntime flang module_files)
+ add_dependencies(flang_rt flang module_files)
endif()
if (FLANG_CUF_RUNTIME)
add_subdirectory(CUDA)
endif()
+
+# Compatibility targets.
+add_custom_target(flang-rt)
+add_dependencies(flang-rt flang_rt)
+add_custom_target(FortranRuntime)
+add_dependencies(FortranRuntime flang_rt)
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt
index 3a88824826de3..744df95267e6f 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/flang/runtime/CUDA/CMakeLists.txt
@@ -31,6 +31,6 @@ endif()
target_link_libraries(${CUFRT_LIBNAME}
PRIVATE
- FortranRuntime
+ flang_rt
${CUDA_RT_TARGET}
)
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt
index 703f85fcaf8da..d65193be05ab5 100644
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ b/flang/runtime/Float128Math/CMakeLists.txt
@@ -118,7 +118,7 @@ elseif (HAVE_LDBL_MANT_DIG_113)
)
target_sources(FortranFloat128MathILib INTERFACE ${sources})
else()
- message(FATAL_ERROR "FortranRuntime cannot build without libm")
+ message(FATAL_ERROR "flang_rt cannot build without libm")
endif()
else()
# We can use '__float128' version from libc, if it has them.
diff --git a/flang/runtime/time-intrinsic.cpp b/flang/runtime/time-intrinsic.cpp
index e6f6e81c7b50c..942604a92aaad 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/flang/runtime/time-intrinsic.cpp
@@ -62,7 +62,7 @@ template <typename Unused = void> double GetCpuTime(fallback_implementation) {
#if defined __MINGW32__
// clock_gettime is implemented in the pthread library for MinGW.
-// Using it here would mean that all programs that link libFortranRuntime are
+// Using it here would mean that all programs that link libflang_rt are
// required to also link to pthread. Instead, don't use the function.
#undef CLOCKID_CPU_TIME
#undef CLOCKID_ELAPSED_TIME
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index e398e0786147a..e8e8099d4eaf7 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -75,7 +75,7 @@ set(FLANG_TEST_DEPENDS
)
if (FLANG_INCLUDE_RUNTIME)
- list(APPEND FLANG_TEST_DEPENDS FortranRuntime)
+ list(APPEND FLANG_TEST_DEPENDS flang_rt)
endif ()
if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
@@ -124,3 +124,9 @@ if (DEFINED FLANG_TEST_TARGET_TRIPLE)
"to use FLANG_TEST_TARGET_TRIPLE.")
endif()
endif()
+
+# Compatibility targets.
+if (FLANG_INCLUDE_RUNTIME)
+ add_custom_target(check-flang-rt)
+ add_dependencies(check-flang-rt check-flang)
+endif ()
diff --git a/flang/test/Driver/gcc-toolchain-install-dir.f90 b/flang/test/Driver/gcc-toolchain-install-dir.f90
index 5a073b0c51712..d9160e1971250 100644
--- a/flang/test/Driver/gcc-toolchain-install-dir.f90
+++ b/flang/test/Driver/gcc-toolchain-install-dir.f90
@@ -1,5 +1,5 @@
!! Test that --gcc-toolchain and --gcc-install-dir options are working as expected.
-!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libFortranRuntime, etc. are not supposed to be affected.
+!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libflang_rt, etc. are not supposed to be affected.
!! PREFIX is captured twice because the driver escapes backslashes (occuring in Windows paths) in the -### output, but not on the "Selected GCC installation:" line.
! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=i386-unknown-linux-gnu --gcc-install-dir=%S/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0 | FileCheck %s --check-prefix=CHECK-I386
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index fdeb95e4dd97c..5dc89fe45c8cc 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -33,26 +33,26 @@
! SOLARIS-F128NONE-NOT: FortranFloat128Math
! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
-! UNIX-SAME: "-lFortranRuntime" "-lm"
+! UNIX-SAME: "-lflang_rt" "-lm"
! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
! DARWIN-SAME: "[[object_file]]"
! DARWIN-F128NONE-NOT: FortranFloat128Math
! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! DARWIN-SAME: -lFortranRuntime
+! DARWIN-SAME: -lflang_rt
! HAIKU-LABEL: "{{.*}}ld{{(\.exe)?}}"
! HAIKU-SAME: "[[object_file]]"
! HAIKU-F128NONE-NOT: FortranFloat128Math
! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! HAIKU-SAME: "-lFortranRuntime"
+! HAIKU-SAME: "-lflang_rt"
! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}"
! MINGW-SAME: "[[object_file]]"
! MINGW-F128NONE-NOT: FortranFloat128Math
! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! MINGW-SAME: -lFortranRuntime
+! MINGW-SAME: -lflang_rt
! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
! any .exe suffix that is added when resolving to the full path of
diff --git a/flang/test/Driver/msvc-dependent-lib-flags.f90 b/flang/test/Driver/msvc-dependent-lib-flags.f90
index befe61fdadcd1..dabac56d602d1 100644
--- a/flang/test/Driver/msvc-dependent-lib-flags.f90
+++ b/flang/test/Driver/msvc-dependent-lib-flags.f90
@@ -7,21 +7,21 @@
! MSVC-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-SAME: -D_MT
! MSVC-SAME: --dependent-lib=libcmt
-! MSVC-SAME: --dependent-lib=FortranRuntime.static.lib
+! MSVC-SAME: --dependent-lib=flang_rt.static.lib
! MSVC-DEBUG: -fc1
! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DEBUG-SAME: -D_MT
! MSVC-DEBUG-SAME: -D_DEBUG
! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
-! MSVC-DEBUG-SAME: --dependent-lib=FortranRuntime.static_dbg.lib
+! MSVC-DEBUG-SAME: --dependent-lib=flang_rt.static_dbg.lib
! MSVC-DLL: -fc1
! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DLL-SAME: -D_MT
! MSVC-DLL-SAME: -D_DLL
! MSVC-DLL-SAME: --dependent-lib=msvcrt
-! MSVC-DLL-SAME: --dependent-lib=FortranRuntime.dynamic.lib
+! MSVC-DLL-SAME: --dependent-lib=flang_rt.dynamic.lib
! MSVC-DLL-DEBUG: -fc1
! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -29,4 +29,4 @@
! MSVC-DLL-DEBUG-SAME: -D_DEBUG
! MSVC-DLL-DEBUG-SAME: -D_DLL
! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
-! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranRuntime.dynamic_dbg.lib
+! MSVC-DLL-DEBUG-SAME: --dependent-lib=flang_rt.dynamic_dbg.lib
diff --git a/flang/test/Driver/nostdlib.f90 b/flang/test/Driver/nostdlib.f90
index ab7c675fe7b77..17ed10fa0615d 100644
--- a/flang/test/Driver/nostdlib.f90
+++ b/flang/test/Driver/nostdlib.f90
@@ -24,5 +24,5 @@
! in certain cases. But it is not clear that it is worth checking for each
! platform individually.
-! CHECK-NOT: "-lFortranRuntime"
+! CHECK-NOT: "-lflang_rt"
! CHECK-NOT: "-lgcc"
diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang/test/Runtime/no-cpp-dep.c
index 7303ce63fdec4..c03029f0f3c26 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/flang/test/Runtime/no-cpp-dep.c
@@ -1,6 +1,6 @@
/*
This test makes sure that flang's runtime does not depend on the C++ runtime
-library. It tries to link this simple file against libFortranRuntime.a with
+library. It tries to link this simple file against libflang_rt.a with
a C compiler.
REQUIRES: c-compiler, flang-rt
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index f4580afc8c47b..08ba586e1226d 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -170,7 +170,7 @@
# the C++ runtime libraries. For this we need a C compiler. If for some reason
# we don't have one, we can just disable the test.
if config.flang_include_runtime and config.cc:
- libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
+ libruntime = os.path.join(config.flang_lib_dir, "libflang_rt.a")
include = os.path.join(config.flang_src_dir, "include")
if (
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 85ba2c74cdeb5..a849e95df31c1 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
)
# Define the list of Fortran module files that need to be compiled
-# to produce an object file for inclusion into the FortranRuntime
+# to produce an object file for inclusion into the flang_rt
# library.
set(MODULES_WITH_IMPLEMENTATION
"iso_fortran_env_impl"
@@ -105,7 +105,7 @@ if (NOT CMAKE_CROSSCOMPILING)
endif()
# Some modules have an implementation part that needs to be added to the
- # FortranRuntime library.
+ # flang_rt library.
set(compile_with "-fsyntax-only")
set(object_output "")
set(include_in_link FALSE)
@@ -127,14 +127,14 @@ if (NOT CMAKE_CROSSCOMPILING)
install(FILES ${base}.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
# If a module has been compiled into an object file, add the file to
- # the link line for the FortranRuntime library.
+ # the link line for the flang_rt library.
if(include_in_link)
list(APPEND module_objects ${object_output})
endif()
endforeach()
# Set a CACHE variable that is visible to the CMakeLists.txt in runtime/, so that
- # the compiled Fortran modules can be added to the link line of the FortranRuntime
+ # the compiled Fortran modules can be added to the link line of the flang_rt
# library.
set(FORTRAN_MODULE_OBJECTS ${module_objects} CACHE INTERNAL "" FORCE)
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index ecb7d68d8f729..7b0f85638f14e 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -2,7 +2,7 @@ include(AddFlangOffloadRuntime)
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
# If Fortran runtime is built as CUDA library, the linking
- # of targets that link FortranRuntime must be done
+ # of targets that link flang_rt must be done
# with CUDA_RESOLVE_DEVICE_SYMBOLS.
# CUDA language must be enabled for CUDA_RESOLVE_DEVICE_SYMBOLS
# to take effect.
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 1c3fac29cd298..9e19b2cdfbb90 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -60,14 +60,14 @@ if (FLANG_INCLUDE_RUNTIME)
NonGTestTesting
FortranSemantics
FortranEvaluate
- FortranRuntime
+ flang_rt
)
add_flang_nongtest_unittest(ISO-Fortran-binding
NonGTestTesting
FortranEvaluate
FortranSemantics
- FortranRuntime
+ flang_rt
)
endif ()
diff --git a/flang/unittests/Runtime/CMakeLists.txt b/flang/unittests/Runtime/CMakeLists.txt
index 179e439917ff2..a60b43d422878 100644
--- a/flang/unittests/Runtime/CMakeLists.txt
+++ b/flang/unittests/Runtime/CMakeLists.txt
@@ -33,7 +33,7 @@ add_flang_unittest(FlangRuntimeTests
target_link_libraries(FlangRuntimeTests
PRIVATE
- FortranRuntime
+ flang_rt
)
target_compile_definitions(FlangRuntimeTests PRIVATE NOT_EXE="$<TARGET_FILE:not>")
diff --git a/flang/unittests/Runtime/CUDA/CMakeLists.txt b/flang/unittests/Runtime/CUDA/CMakeLists.txt
index a7fe604d687bd..38888e32e6ed8 100644
--- a/flang/unittests/Runtime/CUDA/CMakeLists.txt
+++ b/flang/unittests/Runtime/CUDA/CMakeLists.txt
@@ -16,7 +16,7 @@ target_link_libraries(FlangCufRuntimeTests
PRIVATE
${CUDA_RT_TARGET}
CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
- FortranRuntime
+ flang_rt
)
target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index 797ab37f06981..e188dfb503c1a 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -50,7 +50,7 @@ AutoExporter::AutoExporter(
"libclang_rt.profile-x86_64",
"libc++",
"libc++abi",
- "libFortranRuntime",
+ "libflang_rt",
"libunwind",
"libmsvcrt",
"libucrtbase",
>From 7e369b5626b6de43de394212efe5024a4fdebf48 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 24 Jan 2025 16:47:29 +0100
Subject: [PATCH 06/41] [Flang][NFC] Move runtime library files to flang-rt
---
flang-rt/.clang-format | 25 +++++
flang-rt/cmake/config.h.cmake.in | 19 ++++
.../include/flang-rt}/CUDA/allocator.h | 10 +-
.../include/flang-rt}/allocator-registry.h | 8 +-
.../include/flang-rt}/array-constructor.h | 10 +-
.../include/flang-rt}/assign-impl.h | 8 +-
.../include/flang-rt}/buffer.h | 10 +-
.../include/flang-rt}/connection.h | 8 +-
.../include/flang-rt}/derived.h | 8 +-
.../include/flang-rt}/descriptor.h | 12 +--
.../include/flang-rt}/emit-encoded.h | 8 +-
.../include/flang-rt}/environment.h | 8 +-
.../include/flang-rt}/file.h | 10 +-
.../include/flang-rt}/format-implementation.h | 8 +-
.../include/flang-rt}/format.h | 8 +-
.../include/flang-rt}/internal-unit.h | 10 +-
.../include/flang-rt}/io-error.h | 10 +-
.../include/flang-rt}/io-stmt.h | 10 +-
.../include/flang-rt}/lock.h | 8 +-
.../include/flang-rt}/memory.h | 8 +-
.../include/flang-rt}/namelist.h | 8 +-
.../include/flang-rt}/non-tbp-dio.h | 8 +-
.../include/flang-rt}/numeric-templates.h | 8 +-
.../include/flang-rt}/random-templates.h | 10 +-
.../include/flang-rt}/reduction-templates.h | 10 +-
.../include/flang-rt}/stat.h | 8 +-
.../include/flang-rt}/terminator.h | 8 +-
.../include/flang-rt}/tools.h | 12 +--
.../include/flang-rt}/type-code.h | 8 +-
.../include/flang-rt}/type-info.h | 10 +-
.../include/flang-rt}/utf.h | 8 +-
.../lib/FortranFloat128Math}/acos.cpp | 2 +-
.../lib/FortranFloat128Math}/acosh.cpp | 2 +-
.../lib/FortranFloat128Math}/asin.cpp | 2 +-
.../lib/FortranFloat128Math}/asinh.cpp | 2 +-
.../lib/FortranFloat128Math}/atan.cpp | 2 +-
.../lib/FortranFloat128Math}/atan2.cpp | 2 +-
.../lib/FortranFloat128Math}/atanh.cpp | 2 +-
.../lib/FortranFloat128Math}/ceil.cpp | 2 +-
.../lib/FortranFloat128Math}/complex-math.c | 5 +-
.../lib/FortranFloat128Math}/complex-math.h | 8 +-
.../lib/FortranFloat128Math}/cos.cpp | 2 +-
.../lib/FortranFloat128Math}/cosh.cpp | 2 +-
.../lib/FortranFloat128Math}/erf.cpp | 2 +-
.../lib/FortranFloat128Math}/erfc.cpp | 2 +-
.../lib/FortranFloat128Math}/exp.cpp | 2 +-
.../lib/FortranFloat128Math}/exponent.cpp | 2 +-
.../lib/FortranFloat128Math}/floor.cpp | 2 +-
.../lib/FortranFloat128Math}/fma.cpp | 2 +-
.../lib/FortranFloat128Math}/fraction.cpp | 2 +-
.../lib/FortranFloat128Math}/hypot.cpp | 2 +-
.../lib/FortranFloat128Math}/j0.cpp | 2 +-
.../lib/FortranFloat128Math}/j1.cpp | 2 +-
.../lib/FortranFloat128Math}/jn.cpp | 2 +-
.../lib/FortranFloat128Math}/lgamma.cpp | 2 +-
.../lib/FortranFloat128Math}/llround.cpp | 2 +-
.../lib/FortranFloat128Math}/log.cpp | 2 +-
.../lib/FortranFloat128Math}/log10.cpp | 2 +-
.../lib/FortranFloat128Math}/lround.cpp | 2 +-
.../lib/FortranFloat128Math}/math-entries.h | 13 +--
.../lib/FortranFloat128Math}/mod-real.cpp | 2 +-
.../lib/FortranFloat128Math}/modulo-real.cpp | 2 +-
.../lib/FortranFloat128Math}/nearbyint.cpp | 2 +-
.../lib/FortranFloat128Math}/nearest.cpp | 2 +-
.../lib/FortranFloat128Math}/norm2.cpp | 4 +-
.../numeric-template-specs.h | 10 +-
.../lib/FortranFloat128Math}/pow.cpp | 2 +-
.../lib/FortranFloat128Math}/random.cpp | 4 +-
.../lib/FortranFloat128Math}/remainder.cpp | 2 +-
.../lib/FortranFloat128Math}/round.cpp | 2 +-
.../lib/FortranFloat128Math}/rrspacing.cpp | 2 +-
.../lib/FortranFloat128Math}/scale.cpp | 2 +-
.../lib/FortranFloat128Math}/set-exponent.cpp | 2 +-
.../lib/FortranFloat128Math}/sin.cpp | 2 +-
.../lib/FortranFloat128Math}/sinh.cpp | 2 +-
.../lib/FortranFloat128Math}/spacing.cpp | 2 +-
.../lib/FortranFloat128Math}/sqrt.cpp | 2 +-
.../lib/FortranFloat128Math}/tan.cpp | 2 +-
.../lib/FortranFloat128Math}/tanh.cpp | 2 +-
.../lib/FortranFloat128Math}/tgamma.cpp | 2 +-
.../lib/FortranFloat128Math}/trunc.cpp | 2 +-
.../lib/FortranFloat128Math}/y0.cpp | 2 +-
.../lib/FortranFloat128Math}/y1.cpp | 2 +-
.../lib/FortranFloat128Math}/yn.cpp | 2 +-
.../lib/flang_rt}/CUDA/allocatable.cpp | 9 +-
.../lib/flang_rt}/CUDA/allocator.cpp | 14 +--
.../lib/flang_rt}/CUDA/descriptor.cpp | 8 +-
.../lib/flang_rt}/CUDA/kernel.cpp | 4 +-
.../lib/flang_rt}/CUDA/memmove-function.cpp | 4 +-
.../lib/flang_rt}/CUDA/memory.cpp | 6 +-
.../lib/flang_rt}/CUDA/registration.cpp | 4 +-
.../lib/flang_rt}/ISO_Fortran_binding.cpp | 8 +-
.../lib/flang_rt}/ISO_Fortran_util.h | 14 +--
.../lib/flang_rt}/allocatable.cpp | 14 +--
.../lib/flang_rt}/allocator-registry.cpp | 6 +-
.../lib/flang_rt}/array-constructor.cpp | 14 +--
.../lib/flang_rt}/assign.cpp | 16 +--
.../lib/flang_rt}/buffer.cpp | 4 +-
.../lib/flang_rt}/character.cpp | 8 +-
.../lib/flang_rt}/command.cpp | 12 +--
.../lib/flang_rt}/complex-powi.cpp | 16 +--
.../lib/flang_rt}/complex-reduction.c | 5 +-
.../lib/flang_rt}/complex-reduction.h | 11 +-
.../lib/flang_rt}/connection.cpp | 8 +-
.../lib/flang_rt}/copy.cpp | 8 +-
.../runtime => flang-rt/lib/flang_rt}/copy.h | 10 +-
.../lib/flang_rt}/derived-api.cpp | 13 ++-
.../lib/flang_rt}/derived.cpp | 14 +--
.../lib/flang_rt}/descriptor-io.cpp | 2 +-
.../lib/flang_rt}/descriptor-io.h | 18 ++--
.../lib/flang_rt}/descriptor.cpp | 22 ++--
.../lib/flang_rt}/dot-product.cpp | 8 +-
.../lib/flang_rt}/edit-input.cpp | 6 +-
.../lib/flang_rt}/edit-input.h | 12 +--
.../lib/flang_rt}/edit-output.cpp | 6 +-
.../lib/flang_rt}/edit-output.h | 12 +--
.../lib/flang_rt}/environment-default-list.h | 11 +-
.../lib/flang_rt}/environment.cpp | 6 +-
.../lib/flang_rt}/exceptions.cpp | 4 +-
.../lib/flang_rt}/execute.cpp | 12 +--
.../lib/flang_rt}/extensions.cpp | 8 +-
.../lib/flang_rt}/external-unit.cpp | 8 +-
.../lib/flang_rt}/extrema.cpp | 4 +-
.../lib/flang_rt}/file.cpp | 8 +-
.../lib/flang_rt}/findloc.cpp | 4 +-
.../lib/flang_rt}/format.cpp | 4 +-
.../lib/flang_rt}/inquiry.cpp | 8 +-
.../lib/flang_rt}/internal-unit.cpp | 8 +-
.../lib/flang_rt}/io-api-common.h | 12 +--
.../lib/flang_rt}/io-api-minimal.cpp | 10 +-
.../lib/flang_rt}/io-api.cpp | 16 +--
.../lib/flang_rt}/io-error.cpp | 6 +-
.../lib/flang_rt}/io-stmt.cpp | 16 +--
.../lib/flang_rt}/iostat.cpp | 2 +-
.../lib/flang_rt}/main.cpp | 6 +-
.../lib/flang_rt}/matmul-transpose.cpp | 8 +-
.../lib/flang_rt}/matmul.cpp | 8 +-
.../lib/flang_rt}/memory.cpp | 8 +-
.../lib/flang_rt}/misc-intrinsic.cpp | 8 +-
.../lib/flang_rt}/namelist.cpp | 8 +-
.../lib/flang_rt}/non-tbp-dio.cpp | 6 +-
.../lib/flang_rt}/numeric.cpp | 8 +-
.../lib/flang_rt}/pointer.cpp | 16 +--
.../lib/flang_rt}/product.cpp | 4 +-
.../lib/flang_rt}/pseudo-unit.cpp | 6 +-
.../lib/flang_rt}/ragged.cpp | 4 +-
.../lib/flang_rt}/random.cpp | 10 +-
.../lib/flang_rt}/reduce.cpp | 10 +-
.../lib/flang_rt}/reduction.cpp | 6 +-
.../runtime => flang-rt/lib/flang_rt}/stack.h | 12 +--
.../lib/flang_rt}/stat.cpp | 10 +-
.../lib/flang_rt}/stop.cpp | 10 +-
.../runtime => flang-rt/lib/flang_rt}/sum.cpp | 4 +-
.../lib/flang_rt}/support.cpp | 6 +-
.../lib/flang_rt}/temporary-stack.cpp | 8 +-
.../lib/flang_rt}/terminator.cpp | 4 +-
.../lib/flang_rt}/time-intrinsic.cpp | 8 +-
.../lib/flang_rt}/tools.cpp | 6 +-
.../lib/flang_rt}/transformational.cpp | 8 +-
.../lib/flang_rt}/type-code.cpp | 4 +-
.../lib/flang_rt}/type-info.cpp | 10 +-
.../lib/flang_rt}/unit-map.cpp | 2 +-
.../lib/flang_rt}/unit-map.h | 12 +--
.../lib/flang_rt}/unit.cpp | 8 +-
.../runtime => flang-rt/lib/flang_rt}/unit.h | 30 +++---
.../runtime => flang-rt/lib/flang_rt}/utf.cpp | 4 +-
.../test/Driver/ctofortran.f90 | 0
{flang => flang-rt}/test/Driver/exec.f90 | 0
{flang => flang-rt}/test/Runtime/no-cpp-dep.c | 0
.../Evaluate/ISO-Fortran-binding.cpp | 10 +-
.../unittests/Evaluate/reshape.cpp | 10 +-
.../unittests/Runtime/AccessTest.cpp | 2 +-
.../unittests/Runtime/Allocatable.cpp | 4 +-
.../unittests/Runtime/ArrayConstructor.cpp | 10 +-
.../unittests/Runtime/BufferTest.cpp | 4 +-
.../unittests/Runtime/CUDA/Allocatable.cpp | 12 +--
.../unittests/Runtime/CUDA/AllocatorCUF.cpp | 12 +--
.../unittests/Runtime/CUDA/Memory.cpp | 13 ++-
.../unittests/Runtime/CharacterTest.cpp | 4 +-
.../unittests/Runtime/CommandTest.cpp | 4 +-
.../unittests/Runtime/Complex.cpp | 3 +-
.../unittests/Runtime/CrashHandlerFixture.cpp | 5 +-
.../unittests/Runtime/CrashHandlerFixture.h | 9 +-
.../unittests/Runtime/Derived.cpp | 6 +-
.../unittests/Runtime/ExternalIOTest.cpp | 4 +-
.../unittests/Runtime/Format.cpp | 8 +-
.../unittests/Runtime/Inquiry.cpp | 6 +-
.../unittests/Runtime/ListInputTest.cpp | 6 +-
.../unittests/Runtime/LogicalFormatTest.cpp | 4 +-
.../unittests/Runtime/Matmul.cpp | 8 +-
.../unittests/Runtime/MatmulTranspose.cpp | 8 +-
.../unittests/Runtime/MiscIntrinsic.cpp | 8 +-
.../unittests/Runtime/Namelist.cpp | 6 +-
.../unittests/Runtime/Numeric.cpp | 2 +-
.../unittests/Runtime/NumericalFormatTest.cpp | 4 +-
.../unittests/Runtime/Pointer.cpp | 6 +-
.../unittests/Runtime/Ragged.cpp | 2 +-
.../unittests/Runtime/Random.cpp | 8 +-
.../unittests/Runtime/Reduction.cpp | 8 +-
.../unittests/Runtime/RuntimeCrashTest.cpp | 4 +-
.../unittests/Runtime/Stop.cpp | 5 +-
.../unittests/Runtime/Support.cpp | 6 +-
.../unittests/Runtime/TemporaryStack.cpp | 8 +-
.../unittests/Runtime/Time.cpp | 2 +-
.../unittests/Runtime/Transformational.cpp | 6 +-
{flang => flang-rt}/unittests/Runtime/tools.h | 12 +--
flang/CMakeLists.txt | 1 +
flang/include/flang/Runtime/allocatable.h | 2 +-
.../include/flang/Runtime/descriptor-consts.h | 2 +
flang/include/flang/Runtime/pointer.h | 2 +-
flang/runtime/CMakeLists.txt | 30 +++++-
flang/runtime/CUDA/CMakeLists.txt | 7 +-
flang/runtime/Float128Math/CMakeLists.txt | 100 +++++++++---------
flang/runtime/config.h.cmake | 16 ---
flang/unittests/CMakeLists.txt | 10 +-
flang/unittests/Runtime/CMakeLists.txt | 60 +++++------
flang/unittests/Runtime/CUDA/CMakeLists.txt | 6 +-
217 files changed, 866 insertions(+), 776 deletions(-)
create mode 100644 flang-rt/.clang-format
create mode 100644 flang-rt/cmake/config.h.cmake.in
rename {flang/include/flang/Runtime => flang-rt/include/flang-rt}/CUDA/allocator.h (78%)
rename {flang/include/flang/Runtime => flang-rt/include/flang-rt}/allocator-registry.h (88%)
rename {flang/include/flang/Runtime => flang-rt/include/flang-rt}/array-constructor.h (89%)
rename {flang/runtime => flang-rt/include/flang-rt}/assign-impl.h (85%)
rename {flang/runtime => flang-rt/include/flang-rt}/buffer.h (97%)
rename {flang/runtime => flang-rt/include/flang-rt}/connection.h (96%)
rename {flang/runtime => flang-rt/include/flang-rt}/derived.h (90%)
rename {flang/include/flang/Runtime => flang-rt/include/flang-rt}/descriptor.h (98%)
rename {flang/runtime => flang-rt/include/flang-rt}/emit-encoded.h (94%)
rename {flang/runtime => flang-rt/include/flang-rt}/environment.h (91%)
rename {flang/runtime => flang-rt/include/flang-rt}/file.h (95%)
rename {flang/runtime => flang-rt/include/flang-rt}/format-implementation.h (98%)
rename {flang/runtime => flang-rt/include/flang-rt}/format.h (97%)
rename {flang/runtime => flang-rt/include/flang-rt}/internal-unit.h (89%)
rename {flang/runtime => flang-rt/include/flang-rt}/io-error.h (92%)
rename {flang/runtime => flang-rt/include/flang-rt}/io-stmt.h (99%)
rename {flang/runtime => flang-rt/include/flang-rt}/lock.h (94%)
rename {flang/include/flang/Runtime => flang-rt/include/flang-rt}/memory.h (96%)
rename {flang/runtime => flang-rt/include/flang-rt}/namelist.h (91%)
rename {flang/runtime => flang-rt/include/flang-rt}/non-tbp-dio.h (91%)
rename {flang/runtime => flang-rt/include/flang-rt}/numeric-templates.h (98%)
rename {flang/runtime => flang-rt/include/flang-rt}/random-templates.h (93%)
rename {flang/runtime => flang-rt/include/flang-rt}/reduction-templates.h (98%)
rename {flang/runtime => flang-rt/include/flang-rt}/stat.h (93%)
rename {flang/runtime => flang-rt/include/flang-rt}/terminator.h (95%)
rename {flang/runtime => flang-rt/include/flang-rt}/tools.h (98%)
rename {flang/include/flang/Runtime => flang-rt/include/flang-rt}/type-code.h (93%)
rename {flang/runtime => flang-rt/include/flang-rt}/type-info.h (98%)
rename {flang/runtime => flang-rt/include/flang-rt}/utf.h (94%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/acos.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/acosh.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/asin.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/asinh.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/atan.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/atan2.cpp (88%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/atanh.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/ceil.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/complex-math.c (92%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/complex-math.h (88%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/cos.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/cosh.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/erf.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/erfc.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/exp.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/exponent.cpp (90%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/floor.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/fma.cpp (89%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/fraction.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/hypot.cpp (88%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/j0.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/j1.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/jn.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/lgamma.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/llround.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/log.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/log10.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/lround.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/math-entries.h (96%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/mod-real.cpp (88%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/modulo-real.cpp (89%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/nearbyint.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/nearest.cpp (88%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/norm2.cpp (90%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/numeric-template-specs.h (82%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/pow.cpp (88%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/random.cpp (84%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/remainder.cpp (88%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/round.cpp (89%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/rrspacing.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/scale.cpp (90%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/set-exponent.cpp (88%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/sin.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/sinh.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/spacing.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/sqrt.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/tan.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/tanh.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/tgamma.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/trunc.cpp (89%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/y0.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/y1.cpp (87%)
rename {flang/runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/yn.cpp (87%)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/allocatable.cpp (94%)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/allocator.cpp (86%)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/descriptor.cpp (90%)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/kernel.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/memmove-function.cpp (91%)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/memory.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/registration.cpp (93%)
rename {flang/runtime => flang-rt/lib/flang_rt}/ISO_Fortran_binding.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/ISO_Fortran_util.h (91%)
rename {flang/runtime => flang-rt/lib/flang_rt}/allocatable.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/allocator-registry.cpp (88%)
rename {flang/runtime => flang-rt/lib/flang_rt}/array-constructor.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/assign.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/buffer.cpp (89%)
rename {flang/runtime => flang-rt/lib/flang_rt}/character.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/command.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/complex-powi.cpp (92%)
rename {flang/runtime => flang-rt/lib/flang_rt}/complex-reduction.c (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/complex-reduction.h (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/connection.cpp (91%)
rename {flang/runtime => flang-rt/lib/flang_rt}/copy.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/copy.h (79%)
rename {flang/runtime => flang-rt/lib/flang_rt}/derived-api.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/derived.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/descriptor-io.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/descriptor-io.h (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/descriptor.cpp (95%)
rename {flang/runtime => flang-rt/lib/flang_rt}/dot-product.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/edit-input.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/edit-input.h (89%)
rename {flang/runtime => flang-rt/lib/flang_rt}/edit-output.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/edit-output.h (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/environment-default-list.h (70%)
rename {flang/runtime => flang-rt/lib/flang_rt}/environment.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/exceptions.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/execute.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/extensions.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/external-unit.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/extrema.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/file.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/findloc.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/format.cpp (88%)
rename {flang/runtime => flang-rt/lib/flang_rt}/inquiry.cpp (94%)
rename {flang/runtime => flang-rt/lib/flang_rt}/internal-unit.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/io-api-common.h (93%)
rename {flang/runtime => flang-rt/lib/flang_rt}/io-api-minimal.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/io-api.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/io-error.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/io-stmt.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/iostat.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/main.cpp (90%)
rename {flang/runtime => flang-rt/lib/flang_rt}/matmul-transpose.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/matmul.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/memory.cpp (87%)
rename {flang/runtime => flang-rt/lib/flang_rt}/misc-intrinsic.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/namelist.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/non-tbp-dio.cpp (87%)
rename {flang/runtime => flang-rt/lib/flang_rt}/numeric.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/pointer.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/product.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/pseudo-unit.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/ragged.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/random.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/reduce.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/reduction.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/stack.h (94%)
rename {flang/runtime => flang-rt/lib/flang_rt}/stat.cpp (93%)
rename {flang/runtime => flang-rt/lib/flang_rt}/stop.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/sum.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/support.cpp (90%)
rename {flang/runtime => flang-rt/lib/flang_rt}/temporary-stack.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/terminator.cpp (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/time-intrinsic.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/tools.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/transformational.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/type-code.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/type-info.cpp (98%)
rename {flang/runtime => flang-rt/lib/flang_rt}/unit-map.cpp (97%)
rename {flang/runtime => flang-rt/lib/flang_rt}/unit-map.h (92%)
rename {flang/runtime => flang-rt/lib/flang_rt}/unit.cpp (99%)
rename {flang/runtime => flang-rt/lib/flang_rt}/unit.h (96%)
rename {flang/runtime => flang-rt/lib/flang_rt}/utf.cpp (97%)
rename {flang => flang-rt}/test/Driver/ctofortran.f90 (100%)
rename {flang => flang-rt}/test/Driver/exec.f90 (100%)
rename {flang => flang-rt}/test/Runtime/no-cpp-dep.c (100%)
rename {flang => flang-rt}/unittests/Evaluate/ISO-Fortran-binding.cpp (98%)
rename {flang => flang-rt}/unittests/Evaluate/reshape.cpp (88%)
rename {flang => flang-rt}/unittests/Runtime/AccessTest.cpp (99%)
rename {flang => flang-rt}/unittests/Runtime/Allocatable.cpp (97%)
rename {flang => flang-rt}/unittests/Runtime/ArrayConstructor.cpp (97%)
rename {flang => flang-rt}/unittests/Runtime/BufferTest.cpp (97%)
rename {flang => flang-rt}/unittests/Runtime/CUDA/Allocatable.cpp (89%)
rename {flang => flang-rt}/unittests/Runtime/CUDA/AllocatorCUF.cpp (91%)
rename {flang => flang-rt}/unittests/Runtime/CUDA/Memory.cpp (92%)
rename {flang => flang-rt}/unittests/Runtime/CharacterTest.cpp (99%)
rename {flang => flang-rt}/unittests/Runtime/CommandTest.cpp (99%)
rename {flang => flang-rt}/unittests/Runtime/Complex.cpp (98%)
rename {flang => flang-rt}/unittests/Runtime/CrashHandlerFixture.cpp (92%)
rename {flang => flang-rt}/unittests/Runtime/CrashHandlerFixture.h (70%)
rename {flang => flang-rt}/unittests/Runtime/Derived.cpp (94%)
rename {flang => flang-rt}/unittests/Runtime/ExternalIOTest.cpp (99%)
rename {flang => flang-rt}/unittests/Runtime/Format.cpp (96%)
rename {flang => flang-rt}/unittests/Runtime/Inquiry.cpp (98%)
rename {flang => flang-rt}/unittests/Runtime/ListInputTest.cpp (98%)
rename {flang => flang-rt}/unittests/Runtime/LogicalFormatTest.cpp (95%)
rename {flang => flang-rt}/unittests/Runtime/Matmul.cpp (98%)
rename {flang => flang-rt}/unittests/Runtime/MatmulTranspose.cpp (98%)
rename {flang => flang-rt}/unittests/Runtime/MiscIntrinsic.cpp (96%)
rename {flang => flang-rt}/unittests/Runtime/Namelist.cpp (99%)
rename {flang => flang-rt}/unittests/Runtime/Numeric.cpp (99%)
rename {flang => flang-rt}/unittests/Runtime/NumericalFormatTest.cpp (99%)
rename {flang => flang-rt}/unittests/Runtime/Pointer.cpp (96%)
rename {flang => flang-rt}/unittests/Runtime/Ragged.cpp (94%)
rename {flang => flang-rt}/unittests/Runtime/Random.cpp (92%)
rename {flang => flang-rt}/unittests/Runtime/Reduction.cpp (99%)
rename {flang => flang-rt}/unittests/Runtime/RuntimeCrashTest.cpp (98%)
rename {flang => flang-rt}/unittests/Runtime/Stop.cpp (96%)
rename {flang => flang-rt}/unittests/Runtime/Support.cpp (96%)
rename {flang => flang-rt}/unittests/Runtime/TemporaryStack.cpp (98%)
rename {flang => flang-rt}/unittests/Runtime/Time.cpp (98%)
rename {flang => flang-rt}/unittests/Runtime/Transformational.cpp (99%)
rename {flang => flang-rt}/unittests/Runtime/tools.h (85%)
delete mode 100644 flang/runtime/config.h.cmake
diff --git a/flang-rt/.clang-format b/flang-rt/.clang-format
new file mode 100644
index 0000000000000..23f4c5ae2dcf2
--- /dev/null
+++ b/flang-rt/.clang-format
@@ -0,0 +1,25 @@
+---
+# See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+BasedOnStyle: LLVM
+AlignAfterOpenBracket: DontAlign
+AlignEscapedNewlines: DontAlign
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignOperands: false
+AlignTrailingComments: false
+IncludeCategories:
+ - Regex: '^<'
+ Priority: 6
+ - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
+ Priority: 5
+ - Regex: '^"flang/' # Headers shared with Flang
+ Priority: 4
+ - Regex: '^"flang-rt/' # Public Flang-RT headers
+ Priority: 3
+ - Regex: '^[^/]*$' # Private headers from same library
+ Priority: 1
+ - Regex: '.*' # Private headers from sibling libraries
+ Priority: 2
+...
+
+# vim:set filetype=yaml:
diff --git a/flang-rt/cmake/config.h.cmake.in b/flang-rt/cmake/config.h.cmake.in
new file mode 100644
index 0000000000000..8a4668b90addd
--- /dev/null
+++ b/flang-rt/cmake/config.h.cmake.in
@@ -0,0 +1,19 @@
+/*===-- cmake/config.cmake.in ---------------------------------------*- 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
+ *
+ *===----------------------------------------------------------------------===*/
+
+#ifndef FORTRAN_RUNTIME_CONFIG_H
+#define FORTRAN_RUNTIME_CONFIG_H
+
+/* Define to 1 if you have the `strerror_r' function. */
+#cmakedefine01 HAVE_STRERROR_R
+
+/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you
+ don't. */
+#cmakedefine01 HAVE_DECL_STRERROR_S
+
+#endif
diff --git a/flang/include/flang/Runtime/CUDA/allocator.h b/flang-rt/include/flang-rt/CUDA/allocator.h
similarity index 78%
rename from flang/include/flang/Runtime/CUDA/allocator.h
rename to flang-rt/include/flang-rt/CUDA/allocator.h
index 4fb4c94c5e9b0..fb09b5ff2402a 100644
--- a/flang/include/flang/Runtime/CUDA/allocator.h
+++ b/flang-rt/include/flang-rt/CUDA/allocator.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/CUDA/allocator.h ------------------*- C++ -*-===//
+//===-- include/flang-rt/CUDA/allocator.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.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
-#define FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
+#ifndef FLANG_RT_CUDA_ALLOCATOR_H_
+#define FLANG_RT_CUDA_ALLOCATOR_H_
-#include "common.h"
+#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
@@ -33,4 +33,4 @@ void *CUFAllocUnified(std::size_t);
void CUFFreeUnified(void *);
} // namespace Fortran::runtime::cuda
-#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
+#endif /* FLANG_RT_CUDA_ALLOCATOR_H_ */
diff --git a/flang/include/flang/Runtime/allocator-registry.h b/flang-rt/include/flang-rt/allocator-registry.h
similarity index 88%
rename from flang/include/flang/Runtime/allocator-registry.h
rename to flang-rt/include/flang-rt/allocator-registry.h
index 29302c5d825bc..1f004462ca624 100644
--- a/flang/include/flang/Runtime/allocator-registry.h
+++ b/flang-rt/include/flang-rt/allocator-registry.h
@@ -1,4 +1,4 @@
-//===-- runtime/allocator-registry.h ----------------------------*- C++ -*-===//
+//===-- include/flang-rt/allocator-registry.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
-#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
+#ifndef FLANG_RT_ALLOCATOR_REGISTRY_H_
+#define FLANG_RT_ALLOCATOR_REGISTRY_H_
#include "flang/Common/api-attrs.h"
#include "flang/Runtime/allocator-registry-consts.h"
@@ -55,4 +55,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
+#endif /* FLANG_RT_ALLOCATOR_REGISTRY_H_ */
diff --git a/flang/include/flang/Runtime/array-constructor.h b/flang-rt/include/flang-rt/array-constructor.h
similarity index 89%
rename from flang/include/flang/Runtime/array-constructor.h
rename to flang-rt/include/flang-rt/array-constructor.h
index 2f6aaae17c650..7ff0779e46c6a 100644
--- a/flang/include/flang/Runtime/array-constructor.h
+++ b/flang-rt/include/flang-rt/array-constructor.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/array-constructor.h ---------------*- C++ -*-===//
+//===-- include/flang-rt/array-constructor.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.
@@ -9,11 +9,11 @@
// External APIs to create temporary storage for array constructors when their
// final extents or length parameters cannot be pre-computed.
-#ifndef FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
-#define FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
+#ifndef FLANG_RT_ARRAY_CONSTRUCTOR_H_
+#define FLANG_RT_ARRAY_CONSTRUCTOR_H_
+#include "descriptor.h"
#include "flang/Runtime/array-constructor-consts.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/entry-names.h"
#include <cstdint>
@@ -54,4 +54,4 @@ static_assert(alignof(Fortran::runtime::ArrayConstructorVector) <=
"MaxArrayConstructorVectorAlignInBytes");
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
+#endif /* FLANG_RT_ARRAY_CONSTRUCTOR_H_ */
diff --git a/flang/runtime/assign-impl.h b/flang-rt/include/flang-rt/assign-impl.h
similarity index 85%
rename from flang/runtime/assign-impl.h
rename to flang-rt/include/flang-rt/assign-impl.h
index aaa320ef7f959..7e2cef9df753b 100644
--- a/flang/runtime/assign-impl.h
+++ b/flang-rt/include/flang-rt/assign-impl.h
@@ -1,4 +1,4 @@
-//===-- runtime/assign-impl.h -----------------------------------*- C++ -*-===//
+//===-- include/flang-rt/assign-impl.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_ASSIGN_IMPL_H_
-#define FORTRAN_RUNTIME_ASSIGN_IMPL_H_
+#ifndef FLANG_RT_ASSIGN_IMPL_H_
+#define FLANG_RT_ASSIGN_IMPL_H_
#include "flang/Runtime/freestanding-tools.h"
@@ -28,4 +28,4 @@ RT_API_ATTRS void DoFromSourceAssign(Descriptor &, const Descriptor &,
#endif
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ASSIGN_IMPL_H_
+#endif /* FLANG_RT_ASSIGN_IMPL_H_ */
diff --git a/flang/runtime/buffer.h b/flang-rt/include/flang-rt/buffer.h
similarity index 97%
rename from flang/runtime/buffer.h
rename to flang-rt/include/flang-rt/buffer.h
index 41a1abb1b2d90..ba172448a93a5 100644
--- a/flang/runtime/buffer.h
+++ b/flang-rt/include/flang-rt/buffer.h
@@ -1,4 +1,4 @@
-//===-- runtime/buffer.h ----------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/buffer.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.
@@ -8,12 +8,12 @@
// External file buffering
-#ifndef FORTRAN_RUNTIME_BUFFER_H_
-#define FORTRAN_RUNTIME_BUFFER_H_
+#ifndef FLANG_RT_BUFFER_H_
+#define FLANG_RT_BUFFER_H_
#include "io-error.h"
+#include "memory.h"
#include "flang/Runtime/freestanding-tools.h"
-#include "flang/Runtime/memory.h"
#include <algorithm>
#include <cinttypes>
#include <cstring>
@@ -221,4 +221,4 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
bool dirty_{false};
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_BUFFER_H_
+#endif /* FLANG_RT_BUFFER_H_ */
diff --git a/flang/runtime/connection.h b/flang-rt/include/flang-rt/connection.h
similarity index 96%
rename from flang/runtime/connection.h
rename to flang-rt/include/flang-rt/connection.h
index 6f1ea90a160e5..7f594deee69c6 100644
--- a/flang/runtime/connection.h
+++ b/flang-rt/include/flang-rt/connection.h
@@ -1,4 +1,4 @@
-//===-- runtime/connection.h ------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/connection.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.
@@ -8,8 +8,8 @@
// Fortran I/O connection state (abstracted over internal & external units)
-#ifndef FORTRAN_RUNTIME_IO_CONNECTION_H_
-#define FORTRAN_RUNTIME_IO_CONNECTION_H_
+#ifndef FLANG_RT_CONNECTION_H_
+#define FLANG_RT_CONNECTION_H_
#include "format.h"
#include "flang/Common/optional.h"
@@ -124,4 +124,4 @@ class SavedPosition {
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_CONNECTION_H_
+#endif /* FLANG_RT_CONNECTION_H_ */
diff --git a/flang/runtime/derived.h b/flang-rt/include/flang-rt/derived.h
similarity index 90%
rename from flang/runtime/derived.h
rename to flang-rt/include/flang-rt/derived.h
index f5a1e219b848c..797a089e767c4 100644
--- a/flang/runtime/derived.h
+++ b/flang-rt/include/flang-rt/derived.h
@@ -1,4 +1,4 @@
-//===-- runtime/derived.h -------------------------------------------------===//
+//===-- include/flang-rt/derived.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.
@@ -8,8 +8,8 @@
// Internal runtime utilities for derived type operations.
-#ifndef FORTRAN_RUNTIME_DERIVED_H_
-#define FORTRAN_RUNTIME_DERIVED_H_
+#ifndef FLANG_RT_DERIVED_H_
+#define FLANG_RT_DERIVED_H_
#include "flang/Common/api-attrs.h"
@@ -48,4 +48,4 @@ RT_API_ATTRS void Destroy(const Descriptor &, bool finalize,
RT_API_ATTRS bool HasDynamicComponent(const Descriptor &);
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_DERIVED_H_
+#endif /* FLANG_RT_DERIVED_H_ */
diff --git a/flang/include/flang/Runtime/descriptor.h b/flang-rt/include/flang-rt/descriptor.h
similarity index 98%
rename from flang/include/flang/Runtime/descriptor.h
rename to flang-rt/include/flang-rt/descriptor.h
index 628ac8c927a51..27f80bec4ba93 100644
--- a/flang/include/flang/Runtime/descriptor.h
+++ b/flang-rt/include/flang-rt/descriptor.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/descriptor.h ----------------------*- C++ -*-===//
+//===-- include/flang-rt/descriptor.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_DESCRIPTOR_H_
-#define FORTRAN_RUNTIME_DESCRIPTOR_H_
+#ifndef FLANG_RT_DESCRIPTOR_H_
+#define FLANG_RT_DESCRIPTOR_H_
// Defines data structures used during execution of a Fortran program
// to implement nontrivial dummy arguments, pointers, allocatables,
@@ -18,10 +18,10 @@
// User C code is welcome to depend on that ISO_Fortran_binding.h file,
// but should never reference this internal header.
+#include "memory.h"
+#include "type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor-consts.h"
-#include "flang/Runtime/memory.h"
-#include "flang/Runtime/type-code.h"
#include <algorithm>
#include <cassert>
#include <cinttypes>
@@ -482,4 +482,4 @@ class alignas(Descriptor) StaticDescriptor {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_DESCRIPTOR_H_
+#endif /* FLANG_RT_DESCRIPTOR_H_ */
diff --git a/flang/runtime/emit-encoded.h b/flang-rt/include/flang-rt/emit-encoded.h
similarity index 94%
rename from flang/runtime/emit-encoded.h
rename to flang-rt/include/flang-rt/emit-encoded.h
index 4b5e390078835..f3cb7a9f790e4 100644
--- a/flang/runtime/emit-encoded.h
+++ b/flang-rt/include/flang-rt/emit-encoded.h
@@ -1,4 +1,4 @@
-//===-- runtime/emit-encoded.h ----------------------------------*- C++ -*-===//
+//===-- include/flang-rt/emit-encoded.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.
@@ -8,8 +8,8 @@
// Templates for emitting CHARACTER values with conversion
-#ifndef FORTRAN_RUNTIME_EMIT_ENCODED_H_
-#define FORTRAN_RUNTIME_EMIT_ENCODED_H_
+#ifndef FLANG_RT_EMIT_ENCODED_H_
+#define FLANG_RT_EMIT_ENCODED_H_
#include "connection.h"
#include "environment.h"
@@ -114,4 +114,4 @@ RT_API_ATTRS bool EmitRepeated(CONTEXT &to, char ch, std::size_t n) {
}
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_EMIT_ENCODED_H_
+#endif /* FLANG_RT_EMIT_ENCODED_H_ */
diff --git a/flang/runtime/environment.h b/flang-rt/include/flang-rt/environment.h
similarity index 91%
rename from flang/runtime/environment.h
rename to flang-rt/include/flang-rt/environment.h
index b8b9f10e4e57f..55e896b0e0861 100644
--- a/flang/runtime/environment.h
+++ b/flang-rt/include/flang-rt/environment.h
@@ -1,4 +1,4 @@
-//===-- runtime/environment.h -----------------------------------*- C++ -*-===//
+//===-- include/flang-rt/environment.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_ENVIRONMENT_H_
-#define FORTRAN_RUNTIME_ENVIRONMENT_H_
+#ifndef FLANG_RT_ENVIRONMENT_H_
+#define FLANG_RT_ENVIRONMENT_H_
#include "flang/Common/optional.h"
#include "flang/Decimal/decimal.h"
@@ -64,4 +64,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ENVIRONMENT_H_
+#endif /* FLANG_RT_ENVIRONMENT_H_ */
diff --git a/flang/runtime/file.h b/flang-rt/include/flang-rt/file.h
similarity index 95%
rename from flang/runtime/file.h
rename to flang-rt/include/flang-rt/file.h
index c06acbb9904cc..ca95156e1fba4 100644
--- a/flang/runtime/file.h
+++ b/flang-rt/include/flang-rt/file.h
@@ -1,4 +1,4 @@
-//===-- runtime/file.h ------------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/file.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.
@@ -8,12 +8,12 @@
// Raw system I/O wrappers
-#ifndef FORTRAN_RUNTIME_FILE_H_
-#define FORTRAN_RUNTIME_FILE_H_
+#ifndef FLANG_RT_FILE_H_
+#define FLANG_RT_FILE_H_
#include "io-error.h"
+#include "memory.h"
#include "flang/Common/optional.h"
-#include "flang/Runtime/memory.h"
#include <cinttypes>
namespace Fortran::runtime::io {
@@ -113,4 +113,4 @@ RT_API_ATTRS bool MayWrite(const char *path);
RT_API_ATTRS bool MayReadAndWrite(const char *path);
RT_API_ATTRS std::int64_t SizeInBytes(const char *path);
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_FILE_H_
+#endif /* FLANG_RT_FILE_H_ */
diff --git a/flang/runtime/format-implementation.h b/flang-rt/include/flang-rt/format-implementation.h
similarity index 98%
rename from flang/runtime/format-implementation.h
rename to flang-rt/include/flang-rt/format-implementation.h
index 46204ca927c13..52f265d06f9bf 100644
--- a/flang/runtime/format-implementation.h
+++ b/flang-rt/include/flang-rt/format-implementation.h
@@ -1,4 +1,4 @@
-//===-- runtime/format-implementation.h -------------------------*- C++ -*-===//
+//===-- include/flang-rt/format-implementation.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.
@@ -8,8 +8,8 @@
// Implements out-of-line member functions of template class FormatControl
-#ifndef FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
-#define FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
+#ifndef FLANG_RT_FORMAT_IMPLEMENTATION_H_
+#define FLANG_RT_FORMAT_IMPLEMENTATION_H_
#include "emit-encoded.h"
#include "format.h"
@@ -601,4 +601,4 @@ RT_API_ATTRS void FormatControl<CONTEXT>::Finish(Context &context) {
}
}
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
+#endif /* FLANG_RT_FORMAT_IMPLEMENTATION_H_ */
diff --git a/flang/runtime/format.h b/flang-rt/include/flang-rt/format.h
similarity index 97%
rename from flang/runtime/format.h
rename to flang-rt/include/flang-rt/format.h
index 815bf70685e64..d81241e41877c 100644
--- a/flang/runtime/format.h
+++ b/flang-rt/include/flang-rt/format.h
@@ -1,4 +1,4 @@
-//===-- runtime/format.h ----------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/format.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.
@@ -8,8 +8,8 @@
// FORMAT string processing
-#ifndef FORTRAN_RUNTIME_FORMAT_H_
-#define FORTRAN_RUNTIME_FORMAT_H_
+#ifndef FLANG_RT_FORMAT_H_
+#define FLANG_RT_FORMAT_H_
#include "environment.h"
#include "io-error.h"
@@ -201,4 +201,4 @@ template <typename CONTEXT> class FormatControl {
Iteration stack_[maxMaxHeight];
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_FORMAT_H_
+#endif /* FLANG_RT_FORMAT_H_ */
diff --git a/flang/runtime/internal-unit.h b/flang-rt/include/flang-rt/internal-unit.h
similarity index 89%
rename from flang/runtime/internal-unit.h
rename to flang-rt/include/flang-rt/internal-unit.h
index a0ee6353eeda3..21e64b5624196 100644
--- a/flang/runtime/internal-unit.h
+++ b/flang-rt/include/flang-rt/internal-unit.h
@@ -1,4 +1,4 @@
-//===-- runtime/internal-unit.h ---------------------------------*- C++ -*-===//
+//===-- include/flang-rt/internal-unit.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.
@@ -8,11 +8,11 @@
// Fortran internal I/O "units"
-#ifndef FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
-#define FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
+#ifndef FLANG_RT_INTERNAL_UNIT_H_
+#define FLANG_RT_INTERNAL_UNIT_H_
#include "connection.h"
-#include "flang/Runtime/descriptor.h"
+#include "descriptor.h"
#include <cinttypes>
#include <type_traits>
@@ -56,4 +56,4 @@ template <Direction DIR> class InternalDescriptorUnit : public ConnectionState {
extern template class InternalDescriptorUnit<Direction::Output>;
extern template class InternalDescriptorUnit<Direction::Input>;
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
+#endif /* FLANG_RT_INTERNAL_UNIT_H_ */
diff --git a/flang/runtime/io-error.h b/flang-rt/include/flang-rt/io-error.h
similarity index 92%
rename from flang/runtime/io-error.h
rename to flang-rt/include/flang-rt/io-error.h
index 39a343c8e0a51..c74c08970f94a 100644
--- a/flang/runtime/io-error.h
+++ b/flang-rt/include/flang-rt/io-error.h
@@ -1,4 +1,4 @@
-//===-- runtime/io-error.h --------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/io-error.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.
@@ -12,12 +12,12 @@
// IOSTAT error codes are raw errno values augmented with values for
// Fortran-specific errors.
-#ifndef FORTRAN_RUNTIME_IO_ERROR_H_
-#define FORTRAN_RUNTIME_IO_ERROR_H_
+#ifndef FLANG_RT_IO_ERROR_H_
+#define FLANG_RT_IO_ERROR_H_
+#include "memory.h"
#include "terminator.h"
#include "flang/Runtime/iostat.h"
-#include "flang/Runtime/memory.h"
#include <cinttypes>
namespace Fortran::runtime::io {
@@ -80,4 +80,4 @@ class IoErrorHandler : public Terminator {
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_ERROR_H_
+#endif /* FLANG_RT_IO_ERROR_H_ */
diff --git a/flang/runtime/io-stmt.h b/flang-rt/include/flang-rt/io-stmt.h
similarity index 99%
rename from flang/runtime/io-stmt.h
rename to flang-rt/include/flang-rt/io-stmt.h
index 1f1419b249e5e..87fd93c353d76 100644
--- a/flang/runtime/io-stmt.h
+++ b/flang-rt/include/flang-rt/io-stmt.h
@@ -1,4 +1,4 @@
-//===-- runtime/io-stmt.h ---------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/io-stmt.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.
@@ -8,10 +8,11 @@
// Representations of the state of an I/O statement in progress
-#ifndef FORTRAN_RUNTIME_IO_STMT_H_
-#define FORTRAN_RUNTIME_IO_STMT_H_
+#ifndef FLANG_RT_IO_STMT_H_
+#define FLANG_RT_IO_STMT_H_
#include "connection.h"
+#include "descriptor.h"
#include "file.h"
#include "format.h"
#include "internal-unit.h"
@@ -19,7 +20,6 @@
#include "flang/Common/optional.h"
#include "flang/Common/reference-wrapper.h"
#include "flang/Common/visit.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"
#include <flang/Common/variant.h>
#include <functional>
@@ -791,4 +791,4 @@ class ErroneousIoStatementState : public IoStatementBase {
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_STMT_H_
+#endif /* FLANG_RT_IO_STMT_H_ */
diff --git a/flang/runtime/lock.h b/flang-rt/include/flang-rt/lock.h
similarity index 94%
rename from flang/runtime/lock.h
rename to flang-rt/include/flang-rt/lock.h
index 46ca28703a45b..f57e97184edd5 100644
--- a/flang/runtime/lock.h
+++ b/flang-rt/include/flang-rt/lock.h
@@ -1,4 +1,4 @@
-//===-- runtime/lock.h ------------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/lock.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.
@@ -8,8 +8,8 @@
// Wraps a mutex
-#ifndef FORTRAN_RUNTIME_LOCK_H_
-#define FORTRAN_RUNTIME_LOCK_H_
+#ifndef FLANG_RT_LOCK_H_
+#define FLANG_RT_LOCK_H_
#include "terminator.h"
#include "tools.h"
@@ -113,4 +113,4 @@ class CriticalSection {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_LOCK_H_
+#endif /* FLANG_RT_LOCK_H_ */
diff --git a/flang/include/flang/Runtime/memory.h b/flang-rt/include/flang-rt/memory.h
similarity index 96%
rename from flang/include/flang/Runtime/memory.h
rename to flang-rt/include/flang-rt/memory.h
index 98412a989f890..afbb1b34c1d2c 100644
--- a/flang/include/flang/Runtime/memory.h
+++ b/flang-rt/include/flang-rt/memory.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/memory.h --------------------------*- C++ -*-===//
+//===-- include/flang-rt/memory.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.
@@ -9,8 +9,8 @@
// Thin wrapper around malloc()/free() to isolate the dependency,
// ease porting, and provide an owning pointer.
-#ifndef FORTRAN_RUNTIME_MEMORY_H_
-#define FORTRAN_RUNTIME_MEMORY_H_
+#ifndef FLANG_RT_MEMORY_H_
+#define FLANG_RT_MEMORY_H_
#include "flang/Common/api-attrs.h"
#include <cassert>
@@ -170,4 +170,4 @@ template <typename A> struct Allocator {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_MEMORY_H_
+#endif /* FLANG_RT_MEMORY_H_ */
diff --git a/flang/runtime/namelist.h b/flang-rt/include/flang-rt/namelist.h
similarity index 91%
rename from flang/runtime/namelist.h
rename to flang-rt/include/flang-rt/namelist.h
index 25216a75e9367..5757bfb3b7109 100644
--- a/flang/runtime/namelist.h
+++ b/flang-rt/include/flang-rt/namelist.h
@@ -1,4 +1,4 @@
-//===-- runtime/namelist.h --------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/namelist.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.
@@ -8,8 +8,8 @@
// Defines the data structure used for NAMELIST I/O
-#ifndef FORTRAN_RUNTIME_NAMELIST_H_
-#define FORTRAN_RUNTIME_NAMELIST_H_
+#ifndef FLANG_RT_NAMELIST_H_
+#define FLANG_RT_NAMELIST_H_
#include "non-tbp-dio.h"
#include "flang/Common/api-attrs.h"
@@ -51,4 +51,4 @@ class NamelistGroup {
RT_API_ATTRS bool IsNamelistNameOrSlash(IoStatementState &);
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_NAMELIST_H_
+#endif /* FLANG_RT_NAMELIST_H_ */
diff --git a/flang/runtime/non-tbp-dio.h b/flang-rt/include/flang-rt/non-tbp-dio.h
similarity index 91%
rename from flang/runtime/non-tbp-dio.h
rename to flang-rt/include/flang-rt/non-tbp-dio.h
index 8429d790fea57..58ed29ba7a102 100644
--- a/flang/runtime/non-tbp-dio.h
+++ b/flang-rt/include/flang-rt/non-tbp-dio.h
@@ -1,4 +1,4 @@
-//===-- flang/runtime/non-tbp-dio.h -----------------------------*- C++ -*-===//
+//===-- include/flang-rt/non-tbp-dio.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.
@@ -19,8 +19,8 @@
// a containing scope has become inaccessible in a nested scope due
// to the use of "IMPORT, NONE" or "IMPORT, ONLY:".
-#ifndef FORTRAN_RUNTIME_NON_TBP_DIO_H_
-#define FORTRAN_RUNTIME_NON_TBP_DIO_H_
+#ifndef FLANG_RT_NON_TBP_DIO_H_
+#define FLANG_RT_NON_TBP_DIO_H_
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/api-attrs.h"
@@ -53,4 +53,4 @@ struct NonTbpDefinedIoTable {
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_NON_TBP_DIO_H_
+#endif /* FLANG_RT_NON_TBP_DIO_H_ */
diff --git a/flang/runtime/numeric-templates.h b/flang-rt/include/flang-rt/numeric-templates.h
similarity index 98%
rename from flang/runtime/numeric-templates.h
rename to flang-rt/include/flang-rt/numeric-templates.h
index fbb371bffc27a..7019151c3a207 100644
--- a/flang/runtime/numeric-templates.h
+++ b/flang-rt/include/flang-rt/numeric-templates.h
@@ -1,4 +1,4 @@
-//===-- runtime/numeric-templates.h -----------------------------*- C++ -*-===//
+//===-- include/flang-rt/numeric-templates.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.
@@ -15,8 +15,8 @@
// for the data type corresponding to CppTypeFor<TypeCategory::Real, 16>
// on the target.
-#ifndef FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
-#define FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
+#ifndef FLANG_RT_NUMERIC_TEMPLATES_H_
+#define FLANG_RT_NUMERIC_TEMPLATES_H_
#include "terminator.h"
#include "tools.h"
@@ -368,4 +368,4 @@ template <typename T> inline RT_API_ATTRS T ErfcScaled(T arg) {
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
+#endif /* FLANG_RT_NUMERIC_TEMPLATES_H_ */
diff --git a/flang/runtime/random-templates.h b/flang-rt/include/flang-rt/random-templates.h
similarity index 93%
rename from flang/runtime/random-templates.h
rename to flang-rt/include/flang-rt/random-templates.h
index 3885941704d4a..f320f2cd328f5 100644
--- a/flang/runtime/random-templates.h
+++ b/flang-rt/include/flang-rt/random-templates.h
@@ -1,4 +1,4 @@
-//===-- runtime/random-templates.h ------------------------------*- C++ -*-===//
+//===-- include/flang-rt/random-templates.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.
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
-#define FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
+#ifndef FLANG_RT_RANDOM_TEMPLATES_H_
+#define FLANG_RT_RANDOM_TEMPLATES_H_
+#include "descriptor.h"
#include "lock.h"
#include "numeric-templates.h"
#include "flang/Common/optional.h"
-#include "flang/Runtime/descriptor.h"
#include <algorithm>
#include <random>
@@ -108,4 +108,4 @@ inline void GenerateUnsigned(const Descriptor &harvest) {
} // namespace Fortran::runtime::random
-#endif // FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
+#endif /* FLANG_RT_RANDOM_TEMPLATES_H_ */
diff --git a/flang/runtime/reduction-templates.h b/flang-rt/include/flang-rt/reduction-templates.h
similarity index 98%
rename from flang/runtime/reduction-templates.h
rename to flang-rt/include/flang-rt/reduction-templates.h
index b20b03655c3d0..513b3e4478498 100644
--- a/flang/runtime/reduction-templates.h
+++ b/flang-rt/include/flang-rt/reduction-templates.h
@@ -1,4 +1,4 @@
-//===-- runtime/reduction-templates.h ---------------------------*- C++ -*-===//
+//===-- include/flang-rt/reduction-templates.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.
@@ -18,14 +18,14 @@
// * Character-valued reductions (MAXVAL & MINVAL) return arbitrary
// length results, dynamically allocated in a caller-supplied descriptor
-#ifndef FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
-#define FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
+#ifndef FLANG_RT_REDUCTION_TEMPLATES_H_
+#define FLANG_RT_REDUCTION_TEMPLATES_H_
+#include "descriptor.h"
#include "numeric-templates.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include <algorithm>
namespace Fortran::runtime {
@@ -416,4 +416,4 @@ template <int KIND> struct Norm2Helper {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
+#endif /* FLANG_RT_REDUCTION_TEMPLATES_H_ */
diff --git a/flang/runtime/stat.h b/flang-rt/include/flang-rt/stat.h
similarity index 93%
rename from flang/runtime/stat.h
rename to flang-rt/include/flang-rt/stat.h
index 572cb6d10b489..95ae286a03b49 100644
--- a/flang/runtime/stat.h
+++ b/flang-rt/include/flang-rt/stat.h
@@ -1,4 +1,4 @@
-//===-- runtime/stat.h ------------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/stat.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.
@@ -9,8 +9,8 @@
// Defines the values returned by the runtime for STAT= specifiers
// on executable statements.
-#ifndef FORTRAN_RUNTIME_STAT_H_
-#define FORTRAN_RUNTIME_STAT_H_
+#ifndef FLANG_RT_STAT_H_
+#define FLANG_RT_STAT_H_
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/api-attrs.h"
#include "flang/Runtime/magic-numbers.h"
@@ -60,4 +60,4 @@ RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat); // returns stat
RT_API_ATTRS int ReturnError(Terminator &, int stat,
const Descriptor *errmsg = nullptr, bool hasStat = false);
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_STAT_H
+#endif /* FLANG_RT_STAT_H_ */
diff --git a/flang/runtime/terminator.h b/flang-rt/include/flang-rt/terminator.h
similarity index 95%
rename from flang/runtime/terminator.h
rename to flang-rt/include/flang-rt/terminator.h
index 609f059d6e092..800ed6f3755b7 100644
--- a/flang/runtime/terminator.h
+++ b/flang-rt/include/flang-rt/terminator.h
@@ -1,4 +1,4 @@
-//===-- runtime/terminator.h ------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/terminator.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.
@@ -8,8 +8,8 @@
// Termination of the image
-#ifndef FORTRAN_RUNTIME_TERMINATOR_H_
-#define FORTRAN_RUNTIME_TERMINATOR_H_
+#ifndef FLANG_RT_TERMINATOR_H_
+#define FLANG_RT_TERMINATOR_H_
#include "flang/Common/api-attrs.h"
#include <cstdarg>
@@ -121,4 +121,4 @@ namespace Fortran::runtime::io {
RT_API_ATTRS void FlushOutputOnCrash(const Terminator &);
}
-#endif // FORTRAN_RUNTIME_TERMINATOR_H_
+#endif /* FLANG_RT_TERMINATOR_H_ */
diff --git a/flang/runtime/tools.h b/flang-rt/include/flang-rt/tools.h
similarity index 98%
rename from flang/runtime/tools.h
rename to flang-rt/include/flang-rt/tools.h
index facbd23161057..38804a1f40991 100644
--- a/flang/runtime/tools.h
+++ b/flang-rt/include/flang-rt/tools.h
@@ -1,4 +1,4 @@
-//===-- runtime/tools.h -----------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/tools.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.
@@ -6,16 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_TOOLS_H_
-#define FORTRAN_RUNTIME_TOOLS_H_
+#ifndef FLANG_RT_TOOLS_H_
+#define FLANG_RT_TOOLS_H_
+#include "descriptor.h"
+#include "memory.h"
#include "stat.h"
#include "terminator.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/freestanding-tools.h"
-#include "flang/Runtime/memory.h"
#include <cstring>
#include <functional>
#include <map>
@@ -570,4 +570,4 @@ RT_API_ATTRS void CreatePartialReductionResult(Descriptor &result,
const char *intrinsic, TypeCode);
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TOOLS_H_
+#endif /* FLANG_RT_TOOLS_H_ */
diff --git a/flang/include/flang/Runtime/type-code.h b/flang-rt/include/flang-rt/type-code.h
similarity index 93%
rename from flang/include/flang/Runtime/type-code.h
rename to flang-rt/include/flang-rt/type-code.h
index ae854ed2145e4..1d057481261a1 100644
--- a/flang/include/flang/Runtime/type-code.h
+++ b/flang-rt/include/flang-rt/type-code.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/type-code.h -----------------------*- C++ -*-===//
+//===-- include/flang-rt/type-code.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_TYPE_CODE_H_
-#define FORTRAN_RUNTIME_TYPE_CODE_H_
+#ifndef FLANG_RT_TYPE_CODE_H_
+#define FLANG_RT_TYPE_CODE_H_
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
@@ -75,4 +75,4 @@ class TypeCode {
ISO::CFI_type_t raw_{CFI_type_other};
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TYPE_CODE_H_
+#endif /* FLANG_RT_TYPE_CODE_H_ */
diff --git a/flang/runtime/type-info.h b/flang-rt/include/flang-rt/type-info.h
similarity index 98%
rename from flang/runtime/type-info.h
rename to flang-rt/include/flang-rt/type-info.h
index 32403b1db5169..52e208c93fe25 100644
--- a/flang/runtime/type-info.h
+++ b/flang-rt/include/flang-rt/type-info.h
@@ -1,4 +1,4 @@
-//===-- runtime/type-info.h -------------------------------------*- C++ -*-===//
+//===-- include/flang-rt/type-info.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.
@@ -6,17 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_TYPE_INFO_H_
-#define FORTRAN_RUNTIME_TYPE_INFO_H_
+#ifndef FLANG_RT_TYPE_INFO_H_
+#define FLANG_RT_TYPE_INFO_H_
// A C++ perspective of the derived type description schemata in
// flang/module/__fortran_type_info.f90.
+#include "descriptor.h"
#include "terminator.h"
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/bit-population-count.h"
#include "flang/Common/optional.h"
-#include "flang/Runtime/descriptor.h"
#include <cinttypes>
#include <memory>
@@ -321,4 +321,4 @@ class DerivedType {
};
} // namespace Fortran::runtime::typeInfo
-#endif // FORTRAN_RUNTIME_TYPE_INFO_H_
+#endif /* FLANG_RT_TYPE_INFO_H_ */
diff --git a/flang/runtime/utf.h b/flang-rt/include/flang-rt/utf.h
similarity index 94%
rename from flang/runtime/utf.h
rename to flang-rt/include/flang-rt/utf.h
index 10c2d61484217..4d1e23b9ccb94 100644
--- a/flang/runtime/utf.h
+++ b/flang-rt/include/flang-rt/utf.h
@@ -1,4 +1,4 @@
-//===-- runtime/utf.h -----------------------------------------------------===//
+//===-- include/flang-rt/utf.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.
@@ -38,8 +38,8 @@
// standard maximum. However, we support extended forms up to 32 bits so that
// CHARACTER(KIND=4) can be abused to hold arbitrary 32-bit data.
-#ifndef FORTRAN_RUNTIME_UTF_H_
-#define FORTRAN_RUNTIME_UTF_H_
+#ifndef FLANG_RT_UTF_H_
+#define FLANG_RT_UTF_H_
#include "flang/Common/optional.h"
#include <cstddef>
@@ -70,4 +70,4 @@ RT_API_ATTRS Fortran::common::optional<char32_t> DecodeUTF8(const char *);
RT_API_ATTRS std::size_t EncodeUTF8(char *, char32_t);
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_UTF_H_
+#endif /* FLANG_RT_UTF_H_ */
diff --git a/flang/runtime/Float128Math/acos.cpp b/flang-rt/lib/FortranFloat128Math/acos.cpp
similarity index 87%
rename from flang/runtime/Float128Math/acos.cpp
rename to flang-rt/lib/FortranFloat128Math/acos.cpp
index d9b4950aa1e35..7f20654752754 100644
--- a/flang/runtime/Float128Math/acos.cpp
+++ b/flang-rt/lib/FortranFloat128Math/acos.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/acos.cpp -------------------------------------===//
+//===-- lib/FortranFloat128Math/acos.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/acosh.cpp b/flang-rt/lib/FortranFloat128Math/acosh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/acosh.cpp
rename to flang-rt/lib/FortranFloat128Math/acosh.cpp
index c572673ef55e6..73b64230f08c7 100644
--- a/flang/runtime/Float128Math/acosh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/acosh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/acosh.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/acosh.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/asin.cpp b/flang-rt/lib/FortranFloat128Math/asin.cpp
similarity index 87%
rename from flang/runtime/Float128Math/asin.cpp
rename to flang-rt/lib/FortranFloat128Math/asin.cpp
index 57b6ffd967360..b51ecb6b674d3 100644
--- a/flang/runtime/Float128Math/asin.cpp
+++ b/flang-rt/lib/FortranFloat128Math/asin.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/asin.cpp -------------------------------------===//
+//===-- lib/FortranFloat128Math/asin.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/asinh.cpp b/flang-rt/lib/FortranFloat128Math/asinh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/asinh.cpp
rename to flang-rt/lib/FortranFloat128Math/asinh.cpp
index 03dded722b254..2fc181d075aec 100644
--- a/flang/runtime/Float128Math/asinh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/asinh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/asinh.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/asinh.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/atan.cpp b/flang-rt/lib/FortranFloat128Math/atan.cpp
similarity index 87%
rename from flang/runtime/Float128Math/atan.cpp
rename to flang-rt/lib/FortranFloat128Math/atan.cpp
index 19c86cae8867b..ff1ec39bfdebd 100644
--- a/flang/runtime/Float128Math/atan.cpp
+++ b/flang-rt/lib/FortranFloat128Math/atan.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/atan.cpp -------------------------------------===//
+//===-- lib/FortranFloat128Math/atan.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/atan2.cpp b/flang-rt/lib/FortranFloat128Math/atan2.cpp
similarity index 88%
rename from flang/runtime/Float128Math/atan2.cpp
rename to flang-rt/lib/FortranFloat128Math/atan2.cpp
index 09d666ae14304..4e809cb547a1b 100644
--- a/flang/runtime/Float128Math/atan2.cpp
+++ b/flang-rt/lib/FortranFloat128Math/atan2.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/atan2.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/atan2.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/atanh.cpp b/flang-rt/lib/FortranFloat128Math/atanh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/atanh.cpp
rename to flang-rt/lib/FortranFloat128Math/atanh.cpp
index 442d9beafae47..d4e3e7426b16d 100644
--- a/flang/runtime/Float128Math/atanh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/atanh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/atanh.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/atanh.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/ceil.cpp b/flang-rt/lib/FortranFloat128Math/ceil.cpp
similarity index 87%
rename from flang/runtime/Float128Math/ceil.cpp
rename to flang-rt/lib/FortranFloat128Math/ceil.cpp
index 48e20b2b41577..f439f22c0565a 100644
--- a/flang/runtime/Float128Math/ceil.cpp
+++ b/flang-rt/lib/FortranFloat128Math/ceil.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/ceil.cpp -------------------------------------===//
+//===-- lib/FortranFloat128Math/ceil.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/complex-math.c b/flang-rt/lib/FortranFloat128Math/complex-math.c
similarity index 92%
rename from flang/runtime/Float128Math/complex-math.c
rename to flang-rt/lib/FortranFloat128Math/complex-math.c
index a7e32f3ef755b..fed37dfce6332 100644
--- a/flang/runtime/Float128Math/complex-math.c
+++ b/flang-rt/lib/FortranFloat128Math/complex-math.c
@@ -1,11 +1,10 @@
-/*===-- runtime/Float128Math/complex-math.c -------------------------*- C -*-===
+/*===-- lib/FortranFloat128Math/complex-math.c ----------------------*- 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
*
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
#include "complex-math.h"
diff --git a/flang/runtime/Float128Math/complex-math.h b/flang-rt/lib/FortranFloat128Math/complex-math.h
similarity index 88%
rename from flang/runtime/Float128Math/complex-math.h
rename to flang-rt/lib/FortranFloat128Math/complex-math.h
index cf5e980a39b6b..24ccc794fd144 100644
--- a/flang/runtime/Float128Math/complex-math.h
+++ b/flang-rt/lib/FortranFloat128Math/complex-math.h
@@ -1,4 +1,4 @@
-/*===-- runtime/Float128Math/complex-math.h -------------------------*- C -*-===
+/*===-- lib/FortranFloat128Math/complex-math.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.
@@ -6,8 +6,8 @@
*
*===----------------------------------------------------------------------===*/
-#ifndef FORTRAN_RUNTIME_FLOAT128MATH_COMPLEX_MATH_H_
-#define FORTRAN_RUNTIME_FLOAT128MATH_COMPLEX_MATH_H_
+#ifndef FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
+#define FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
@@ -59,4 +59,4 @@
#error "Float128Math build with glibc>=2.26 is unsupported yet"
#endif
-#endif /* FORTRAN_RUNTIME_FLOAT128MATH_COMPLEX_MATH_H_ */
+#endif /* FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_ */
diff --git a/flang/runtime/Float128Math/cos.cpp b/flang-rt/lib/FortranFloat128Math/cos.cpp
similarity index 87%
rename from flang/runtime/Float128Math/cos.cpp
rename to flang-rt/lib/FortranFloat128Math/cos.cpp
index d1b3e0e736ca3..aed337c325836 100644
--- a/flang/runtime/Float128Math/cos.cpp
+++ b/flang-rt/lib/FortranFloat128Math/cos.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/cos.cpp --------------------------------------===//
+//===-- lib/FortranFloat128Math/cos.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/cosh.cpp b/flang-rt/lib/FortranFloat128Math/cosh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/cosh.cpp
rename to flang-rt/lib/FortranFloat128Math/cosh.cpp
index 9fe5b61d8f95f..bddbff766b575 100644
--- a/flang/runtime/Float128Math/cosh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/cosh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/cosh.cpp -------------------------------------===//
+//===-- lib/FortranFloat128Math/cosh.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/erf.cpp b/flang-rt/lib/FortranFloat128Math/erf.cpp
similarity index 87%
rename from flang/runtime/Float128Math/erf.cpp
rename to flang-rt/lib/FortranFloat128Math/erf.cpp
index 2a553bd395e88..a56430040248d 100644
--- a/flang/runtime/Float128Math/erf.cpp
+++ b/flang-rt/lib/FortranFloat128Math/erf.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/erf.cpp --------------------------------------===//
+//===-- lib/FortranFloat128Math/erf.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/erfc.cpp b/flang-rt/lib/FortranFloat128Math/erfc.cpp
similarity index 87%
rename from flang/runtime/Float128Math/erfc.cpp
rename to flang-rt/lib/FortranFloat128Math/erfc.cpp
index 2435ed2786cb3..255a2a7b4edac 100644
--- a/flang/runtime/Float128Math/erfc.cpp
+++ b/flang-rt/lib/FortranFloat128Math/erfc.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/erfc.cpp -------------------------------------===//
+//===-- lib/FortranFloat128Math/erfc.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/exp.cpp b/flang-rt/lib/FortranFloat128Math/exp.cpp
similarity index 87%
rename from flang/runtime/Float128Math/exp.cpp
rename to flang-rt/lib/FortranFloat128Math/exp.cpp
index 5ca87d9dd25d2..9bc87d959cf69 100644
--- a/flang/runtime/Float128Math/exp.cpp
+++ b/flang-rt/lib/FortranFloat128Math/exp.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/exp.cpp --------------------------------------===//
+//===-- lib/FortranFloat128Math/exp.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/exponent.cpp b/flang-rt/lib/FortranFloat128Math/exponent.cpp
similarity index 90%
rename from flang/runtime/Float128Math/exponent.cpp
rename to flang-rt/lib/FortranFloat128Math/exponent.cpp
index 237cde34e8691..bf27a26a73427 100644
--- a/flang/runtime/Float128Math/exponent.cpp
+++ b/flang-rt/lib/FortranFloat128Math/exponent.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/exponent.cpp ---------------------------------===//
+//===-- lib/FortranFloat128Math/exponent.cpp --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/floor.cpp b/flang-rt/lib/FortranFloat128Math/floor.cpp
similarity index 87%
rename from flang/runtime/Float128Math/floor.cpp
rename to flang-rt/lib/FortranFloat128Math/floor.cpp
index 28f9c7b55dd51..abda5fadfd296 100644
--- a/flang/runtime/Float128Math/floor.cpp
+++ b/flang-rt/lib/FortranFloat128Math/floor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/floor.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/floor.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/fma.cpp b/flang-rt/lib/FortranFloat128Math/fma.cpp
similarity index 89%
rename from flang/runtime/Float128Math/fma.cpp
rename to flang-rt/lib/FortranFloat128Math/fma.cpp
index 87176c25dd604..2e7aabedf1e8c 100644
--- a/flang/runtime/Float128Math/fma.cpp
+++ b/flang-rt/lib/FortranFloat128Math/fma.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/fma.cpp --------------------------------------===//
+//===-- lib/FortranFloat128Math/fma.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/fraction.cpp b/flang-rt/lib/FortranFloat128Math/fraction.cpp
similarity index 87%
rename from flang/runtime/Float128Math/fraction.cpp
rename to flang-rt/lib/FortranFloat128Math/fraction.cpp
index 45ec12cd77518..bf1da6f63e5ce 100644
--- a/flang/runtime/Float128Math/fraction.cpp
+++ b/flang-rt/lib/FortranFloat128Math/fraction.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/fraction.cpp ---------------------------------===//
+//===-- lib/FortranFloat128Math/fraction.cpp --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/hypot.cpp b/flang-rt/lib/FortranFloat128Math/hypot.cpp
similarity index 88%
rename from flang/runtime/Float128Math/hypot.cpp
rename to flang-rt/lib/FortranFloat128Math/hypot.cpp
index 03049b06d3a24..910bda798c1a0 100644
--- a/flang/runtime/Float128Math/hypot.cpp
+++ b/flang-rt/lib/FortranFloat128Math/hypot.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/hypot.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/hypot.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/j0.cpp b/flang-rt/lib/FortranFloat128Math/j0.cpp
similarity index 87%
rename from flang/runtime/Float128Math/j0.cpp
rename to flang-rt/lib/FortranFloat128Math/j0.cpp
index 7207cbe1a92e7..d2fac98c3ec69 100644
--- a/flang/runtime/Float128Math/j0.cpp
+++ b/flang-rt/lib/FortranFloat128Math/j0.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/j0.cpp ---------------------------------------===//
+//===-- lib/FortranFloat128Math/j0.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/j1.cpp b/flang-rt/lib/FortranFloat128Math/j1.cpp
similarity index 87%
rename from flang/runtime/Float128Math/j1.cpp
rename to flang-rt/lib/FortranFloat128Math/j1.cpp
index 9e49bcbc32ca4..60401030124c8 100644
--- a/flang/runtime/Float128Math/j1.cpp
+++ b/flang-rt/lib/FortranFloat128Math/j1.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/j1.cpp ---------------------------------------===//
+//===-- lib/FortranFloat128Math/j1.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/jn.cpp b/flang-rt/lib/FortranFloat128Math/jn.cpp
similarity index 87%
rename from flang/runtime/Float128Math/jn.cpp
rename to flang-rt/lib/FortranFloat128Math/jn.cpp
index 37e5f428e5e26..71e11335d0830 100644
--- a/flang/runtime/Float128Math/jn.cpp
+++ b/flang-rt/lib/FortranFloat128Math/jn.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/jn.cpp ---------------------------------------===//
+//===-- lib/FortranFloat128Math/jn.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/lgamma.cpp b/flang-rt/lib/FortranFloat128Math/lgamma.cpp
similarity index 87%
rename from flang/runtime/Float128Math/lgamma.cpp
rename to flang-rt/lib/FortranFloat128Math/lgamma.cpp
index 54d0dd8083868..1ae4cc4d95d61 100644
--- a/flang/runtime/Float128Math/lgamma.cpp
+++ b/flang-rt/lib/FortranFloat128Math/lgamma.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/lgamma.cpp -----------------------------------===//
+//===-- lib/FortranFloat128Math/lgamma.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/llround.cpp b/flang-rt/lib/FortranFloat128Math/llround.cpp
similarity index 87%
rename from flang/runtime/Float128Math/llround.cpp
rename to flang-rt/lib/FortranFloat128Math/llround.cpp
index f0c53ccdf66fd..5bd4cc26dd497 100644
--- a/flang/runtime/Float128Math/llround.cpp
+++ b/flang-rt/lib/FortranFloat128Math/llround.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/llround.cpp ----------------------------------===//
+//===-- lib/FortranFloat128Math/llround.cpp ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/log.cpp b/flang-rt/lib/FortranFloat128Math/log.cpp
similarity index 87%
rename from flang/runtime/Float128Math/log.cpp
rename to flang-rt/lib/FortranFloat128Math/log.cpp
index 28fec1958f10b..414e41ae0ce29 100644
--- a/flang/runtime/Float128Math/log.cpp
+++ b/flang-rt/lib/FortranFloat128Math/log.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/log.cpp --------------------------------------===//
+//===-- lib/FortranFloat128Math/log.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/log10.cpp b/flang-rt/lib/FortranFloat128Math/log10.cpp
similarity index 87%
rename from flang/runtime/Float128Math/log10.cpp
rename to flang-rt/lib/FortranFloat128Math/log10.cpp
index f844d508f8d3b..55db1b1a2dc1f 100644
--- a/flang/runtime/Float128Math/log10.cpp
+++ b/flang-rt/lib/FortranFloat128Math/log10.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/log10.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/log10.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/lround.cpp b/flang-rt/lib/FortranFloat128Math/lround.cpp
similarity index 87%
rename from flang/runtime/Float128Math/lround.cpp
rename to flang-rt/lib/FortranFloat128Math/lround.cpp
index 8c2d3315c62a7..a0bea49243681 100644
--- a/flang/runtime/Float128Math/lround.cpp
+++ b/flang-rt/lib/FortranFloat128Math/lround.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/lround.cpp -----------------------------------===//
+//===-- lib/FortranFloat128Math/lround.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/math-entries.h b/flang-rt/lib/FortranFloat128Math/math-entries.h
similarity index 96%
rename from flang/runtime/Float128Math/math-entries.h
rename to flang-rt/lib/FortranFloat128Math/math-entries.h
index a94503fe8e67a..b9821163d94fb 100644
--- a/flang/runtime/Float128Math/math-entries.h
+++ b/flang-rt/lib/FortranFloat128Math/math-entries.h
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/math-entries.h ---------------------*- C++ -*-===//
+//===-- lib/FortranFloat128Math/math-entries.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.
@@ -6,10 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
-#define FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
-#include "terminator.h"
-#include "tools.h"
+#ifndef FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
+#define FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
+
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
#include <cfloat>
@@ -231,4 +232,4 @@ DEFINE_SIMPLE_ALIAS(Yn, ynl)
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
+#endif /* FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_ */
diff --git a/flang/runtime/Float128Math/mod-real.cpp b/flang-rt/lib/FortranFloat128Math/mod-real.cpp
similarity index 88%
rename from flang/runtime/Float128Math/mod-real.cpp
rename to flang-rt/lib/FortranFloat128Math/mod-real.cpp
index e831c2df4abc1..beb412f719c52 100644
--- a/flang/runtime/Float128Math/mod-real.cpp
+++ b/flang-rt/lib/FortranFloat128Math/mod-real.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/mod-real.cpp ---------------------------------===//
+//===-- lib/FortranFloat128Math/mod-real.cpp --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/modulo-real.cpp b/flang-rt/lib/FortranFloat128Math/modulo-real.cpp
similarity index 89%
rename from flang/runtime/Float128Math/modulo-real.cpp
rename to flang-rt/lib/FortranFloat128Math/modulo-real.cpp
index 88729da7e3987..c8160b1d27451 100644
--- a/flang/runtime/Float128Math/modulo-real.cpp
+++ b/flang-rt/lib/FortranFloat128Math/modulo-real.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/modulo-real.cpp ------------------------------===//
+//===-- lib/FortranFloat128Math/modulo-real.cpp -----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/nearbyint.cpp b/flang-rt/lib/FortranFloat128Math/nearbyint.cpp
similarity index 87%
rename from flang/runtime/Float128Math/nearbyint.cpp
rename to flang-rt/lib/FortranFloat128Math/nearbyint.cpp
index 9eecb0c5f3e2f..d572641e2b0d4 100644
--- a/flang/runtime/Float128Math/nearbyint.cpp
+++ b/flang-rt/lib/FortranFloat128Math/nearbyint.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/nearbyint.cpp --------------------------------===//
+//===-- lib/FortranFloat128Math/nearbyint.cpp -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/nearest.cpp b/flang-rt/lib/FortranFloat128Math/nearest.cpp
similarity index 88%
rename from flang/runtime/Float128Math/nearest.cpp
rename to flang-rt/lib/FortranFloat128Math/nearest.cpp
index 50f6e7ea75a60..3e32de7ea9d0a 100644
--- a/flang/runtime/Float128Math/nearest.cpp
+++ b/flang-rt/lib/FortranFloat128Math/nearest.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/nearest.cpp ----------------------------------===//
+//===-- lib/FortranFloat128Math/nearest.cpp ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/norm2.cpp b/flang-rt/lib/FortranFloat128Math/norm2.cpp
similarity index 90%
rename from flang/runtime/Float128Math/norm2.cpp
rename to flang-rt/lib/FortranFloat128Math/norm2.cpp
index 18e9c8cc8a2b9..8f6b2c87eec32 100644
--- a/flang/runtime/Float128Math/norm2.cpp
+++ b/flang-rt/lib/FortranFloat128Math/norm2.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/norm2.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/norm2.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
#include "math-entries.h"
#include "numeric-template-specs.h"
-#include "reduction-templates.h"
+#include "flang-rt/reduction-templates.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang/runtime/Float128Math/numeric-template-specs.h b/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
similarity index 82%
rename from flang/runtime/Float128Math/numeric-template-specs.h
rename to flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
index a0a77230c3e9e..fc912f75075a7 100644
--- a/flang/runtime/Float128Math/numeric-template-specs.h
+++ b/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/numeric-template-specs.h -----------*- C++ -*-===//
+//===-- lib/FortranFloat128Math/numeric-template-specs.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
-#define FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#ifndef FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#define FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
#include "math-entries.h"
-#include "numeric-templates.h"
+#include "flang-rt/numeric-templates.h"
namespace Fortran::runtime {
using F128Type = CppTypeFor<TypeCategory::Real, 16>;
@@ -52,4 +52,4 @@ template <> struct SQRTTy<F128Type> {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#endif /* FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_ */
diff --git a/flang/runtime/Float128Math/pow.cpp b/flang-rt/lib/FortranFloat128Math/pow.cpp
similarity index 88%
rename from flang/runtime/Float128Math/pow.cpp
rename to flang-rt/lib/FortranFloat128Math/pow.cpp
index 99aae04c65ecb..bbdda217c5108 100644
--- a/flang/runtime/Float128Math/pow.cpp
+++ b/flang-rt/lib/FortranFloat128Math/pow.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/pow.cpp --------------------------------------===//
+//===-- lib/FortranFloat128Math/pow.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/random.cpp b/flang-rt/lib/FortranFloat128Math/random.cpp
similarity index 84%
rename from flang/runtime/Float128Math/random.cpp
rename to flang-rt/lib/FortranFloat128Math/random.cpp
index 93c5c14cee37d..701f9429fcb6c 100644
--- a/flang/runtime/Float128Math/random.cpp
+++ b/flang-rt/lib/FortranFloat128Math/random.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/random.cpp -----------------------------------===//
+//===-- lib/FortranFloat128Math/random.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
#include "math-entries.h"
#include "numeric-template-specs.h"
-#include "random-templates.h"
+#include "flang-rt/random-templates.h"
using namespace Fortran::runtime::random;
extern "C" {
diff --git a/flang/runtime/Float128Math/remainder.cpp b/flang-rt/lib/FortranFloat128Math/remainder.cpp
similarity index 88%
rename from flang/runtime/Float128Math/remainder.cpp
rename to flang-rt/lib/FortranFloat128Math/remainder.cpp
index e5c2793dab71a..ca4165a357eda 100644
--- a/flang/runtime/Float128Math/remainder.cpp
+++ b/flang-rt/lib/FortranFloat128Math/remainder.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/remainder.cpp --------------------------------===//
+//===-- lib/FortranFloat128Math/remainder.cpp -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/round.cpp b/flang-rt/lib/FortranFloat128Math/round.cpp
similarity index 89%
rename from flang/runtime/Float128Math/round.cpp
rename to flang-rt/lib/FortranFloat128Math/round.cpp
index e79ce30536b3b..348f7ff8a6771 100644
--- a/flang/runtime/Float128Math/round.cpp
+++ b/flang-rt/lib/FortranFloat128Math/round.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/round.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/round.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/rrspacing.cpp b/flang-rt/lib/FortranFloat128Math/rrspacing.cpp
similarity index 87%
rename from flang/runtime/Float128Math/rrspacing.cpp
rename to flang-rt/lib/FortranFloat128Math/rrspacing.cpp
index 04cefc049bbee..0a87a5c572652 100644
--- a/flang/runtime/Float128Math/rrspacing.cpp
+++ b/flang-rt/lib/FortranFloat128Math/rrspacing.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/rrspacing.cpp --------------------------------===//
+//===-- lib/FortranFloat128Math/rrspacing.cpp -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/scale.cpp b/flang-rt/lib/FortranFloat128Math/scale.cpp
similarity index 90%
rename from flang/runtime/Float128Math/scale.cpp
rename to flang-rt/lib/FortranFloat128Math/scale.cpp
index 6b083afbdf4d1..a316a2a0cd706 100644
--- a/flang/runtime/Float128Math/scale.cpp
+++ b/flang-rt/lib/FortranFloat128Math/scale.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/scale.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/scale.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/set-exponent.cpp b/flang-rt/lib/FortranFloat128Math/set-exponent.cpp
similarity index 88%
rename from flang/runtime/Float128Math/set-exponent.cpp
rename to flang-rt/lib/FortranFloat128Math/set-exponent.cpp
index 63c5b325085fb..335c68f632f18 100644
--- a/flang/runtime/Float128Math/set-exponent.cpp
+++ b/flang-rt/lib/FortranFloat128Math/set-exponent.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/set-exponent.cpp -----------------------------===//
+//===-- lib/FortranFloat128Math/set-exponent.cpp ----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/sin.cpp b/flang-rt/lib/FortranFloat128Math/sin.cpp
similarity index 87%
rename from flang/runtime/Float128Math/sin.cpp
rename to flang-rt/lib/FortranFloat128Math/sin.cpp
index 99fa3e493e694..bd5f62808fc31 100644
--- a/flang/runtime/Float128Math/sin.cpp
+++ b/flang-rt/lib/FortranFloat128Math/sin.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/sin.cpp --------------------------------------===//
+//===-- lib/FortranFloat128Math/sin.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/sinh.cpp b/flang-rt/lib/FortranFloat128Math/sinh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/sinh.cpp
rename to flang-rt/lib/FortranFloat128Math/sinh.cpp
index b6cd96963612e..07f12d437ed56 100644
--- a/flang/runtime/Float128Math/sinh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/sinh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/sinh.cpp -------------------------------------===//
+//===-- lib/FortranFloat128Math/sinh.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/spacing.cpp b/flang-rt/lib/FortranFloat128Math/spacing.cpp
similarity index 87%
rename from flang/runtime/Float128Math/spacing.cpp
rename to flang-rt/lib/FortranFloat128Math/spacing.cpp
index fc6aa2c4ec2d8..b10351ab95555 100644
--- a/flang/runtime/Float128Math/spacing.cpp
+++ b/flang-rt/lib/FortranFloat128Math/spacing.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/spacing.cpp ----------------------------------===//
+//===-- lib/FortranFloat128Math/spacing.cpp ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/sqrt.cpp b/flang-rt/lib/FortranFloat128Math/sqrt.cpp
similarity index 87%
rename from flang/runtime/Float128Math/sqrt.cpp
rename to flang-rt/lib/FortranFloat128Math/sqrt.cpp
index 871c66e007984..b6fd6eabc267b 100644
--- a/flang/runtime/Float128Math/sqrt.cpp
+++ b/flang-rt/lib/FortranFloat128Math/sqrt.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/sqrt.cpp -------------------------------------===//
+//===-- lib/FortranFloat128Math/sqrt.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/tan.cpp b/flang-rt/lib/FortranFloat128Math/tan.cpp
similarity index 87%
rename from flang/runtime/Float128Math/tan.cpp
rename to flang-rt/lib/FortranFloat128Math/tan.cpp
index 2d6f448ba8955..437c0692191e8 100644
--- a/flang/runtime/Float128Math/tan.cpp
+++ b/flang-rt/lib/FortranFloat128Math/tan.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/tan.cpp --------------------------------------===//
+//===-- lib/FortranFloat128Math/tan.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/tanh.cpp b/flang-rt/lib/FortranFloat128Math/tanh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/tanh.cpp
rename to flang-rt/lib/FortranFloat128Math/tanh.cpp
index f6321f4819191..48544d4bb75f4 100644
--- a/flang/runtime/Float128Math/tanh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/tanh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/tanh.cpp -------------------------------------===//
+//===-- lib/FortranFloat128Math/tanh.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/tgamma.cpp b/flang-rt/lib/FortranFloat128Math/tgamma.cpp
similarity index 87%
rename from flang/runtime/Float128Math/tgamma.cpp
rename to flang-rt/lib/FortranFloat128Math/tgamma.cpp
index 98fd792a63330..8d7963caa61c5 100644
--- a/flang/runtime/Float128Math/tgamma.cpp
+++ b/flang-rt/lib/FortranFloat128Math/tgamma.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/tgamma.cpp -----------------------------------===//
+//===-- lib/FortranFloat128Math/tgamma.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/trunc.cpp b/flang-rt/lib/FortranFloat128Math/trunc.cpp
similarity index 89%
rename from flang/runtime/Float128Math/trunc.cpp
rename to flang-rt/lib/FortranFloat128Math/trunc.cpp
index 54fa33176813c..4a3dddeb1326c 100644
--- a/flang/runtime/Float128Math/trunc.cpp
+++ b/flang-rt/lib/FortranFloat128Math/trunc.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/trunc.cpp ------------------------------------===//
+//===-- lib/FortranFloat128Math/trunc.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/y0.cpp b/flang-rt/lib/FortranFloat128Math/y0.cpp
similarity index 87%
rename from flang/runtime/Float128Math/y0.cpp
rename to flang-rt/lib/FortranFloat128Math/y0.cpp
index 0b3059b4cfe25..c5b266b5cec03 100644
--- a/flang/runtime/Float128Math/y0.cpp
+++ b/flang-rt/lib/FortranFloat128Math/y0.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/y0.cpp ---------------------------------------===//
+//===-- lib/FortranFloat128Math/y0.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/y1.cpp b/flang-rt/lib/FortranFloat128Math/y1.cpp
similarity index 87%
rename from flang/runtime/Float128Math/y1.cpp
rename to flang-rt/lib/FortranFloat128Math/y1.cpp
index cb39d87034dc7..8b492c69e3741 100644
--- a/flang/runtime/Float128Math/y1.cpp
+++ b/flang-rt/lib/FortranFloat128Math/y1.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/y1.cpp ---------------------------------------===//
+//===-- lib/FortranFloat128Math/y1.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/Float128Math/yn.cpp b/flang-rt/lib/FortranFloat128Math/yn.cpp
similarity index 87%
rename from flang/runtime/Float128Math/yn.cpp
rename to flang-rt/lib/FortranFloat128Math/yn.cpp
index bef8f9457df2f..cb212b400f6e0 100644
--- a/flang/runtime/Float128Math/yn.cpp
+++ b/flang-rt/lib/FortranFloat128Math/yn.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/yn.cpp ---------------------------------------===//
+//===-- lib/FortranFloat128Math/yn.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/CUDA/allocatable.cpp b/flang-rt/lib/flang_rt/CUDA/allocatable.cpp
similarity index 94%
rename from flang/runtime/CUDA/allocatable.cpp
rename to flang-rt/lib/flang_rt/CUDA/allocatable.cpp
index 9be54e8906903..2281e2148d4ae 100644
--- a/flang/runtime/CUDA/allocatable.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/allocatable.cpp --------------------------------------===//
+//===-- lib/flang_rt/CUDA/allocatable.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/allocatable.h"
-#include "../assign-impl.h"
-#include "../stat.h"
-#include "../terminator.h"
+#include "flang-rt/assign-impl.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memmove-function.h"
diff --git a/flang/runtime/CUDA/allocator.cpp b/flang-rt/lib/flang_rt/CUDA/allocator.cpp
similarity index 86%
rename from flang/runtime/CUDA/allocator.cpp
rename to flang-rt/lib/flang_rt/CUDA/allocator.cpp
index 368c1124ef70a..dc1ce5920e222 100644
--- a/flang/runtime/CUDA/allocator.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/allocator.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/allocator.cpp ----------------------------------------===//
+//===-- lib/flang_rt/CUDA/allocator.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/CUDA/allocator.h"
-#include "../derived.h"
-#include "../stat.h"
-#include "../terminator.h"
-#include "../type-info.h"
+#include "flang-rt/CUDA/allocator.h"
+#include "flang-rt/allocator-registry.h"
+#include "flang-rt/derived.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/type-info.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/CUDA/common.h"
-#include "flang/Runtime/allocator-registry.h"
#include "flang/Support/Fortran.h"
#include "cuda_runtime.h"
diff --git a/flang/runtime/CUDA/descriptor.cpp b/flang-rt/lib/flang_rt/CUDA/descriptor.cpp
similarity index 90%
rename from flang/runtime/CUDA/descriptor.cpp
rename to flang-rt/lib/flang_rt/CUDA/descriptor.cpp
index 947eeb66aa3d6..9ec79ccea22c3 100644
--- a/flang/runtime/CUDA/descriptor.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/descriptor.cpp ---------------------------------------===//
+//===-- lib/flang_rt/CUDA/descriptor.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/descriptor.h"
-#include "../terminator.h"
-#include "flang/Runtime/CUDA/allocator.h"
+#include "flang-rt/CUDA/allocator.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
-#include "flang/Runtime/descriptor.h"
#include "cuda_runtime.h"
diff --git a/flang/runtime/CUDA/kernel.cpp b/flang-rt/lib/flang_rt/CUDA/kernel.cpp
similarity index 97%
rename from flang/runtime/CUDA/kernel.cpp
rename to flang-rt/lib/flang_rt/CUDA/kernel.cpp
index bdc04ccb17672..fce6e24ae0f12 100644
--- a/flang/runtime/CUDA/kernel.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/kernel.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/kernel.cpp -------------------------------------------===//
+//===-- lib/flang_rt/CUDA/kernel.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/kernel.h"
-#include "../terminator.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang/runtime/CUDA/memmove-function.cpp b/flang-rt/lib/flang_rt/CUDA/memmove-function.cpp
similarity index 91%
rename from flang/runtime/CUDA/memmove-function.cpp
rename to flang-rt/lib/flang_rt/CUDA/memmove-function.cpp
index 3ba9fa7e0f7f7..ca04e20379d03 100644
--- a/flang/runtime/CUDA/memmove-function.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/memmove-function.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/memmove-function.cpp ---------------------------------===//
+//===-- lib/flang_rt/CUDA/memmove-function.cpp ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/memmove-function.h"
-#include "../terminator.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang/runtime/CUDA/memory.cpp b/flang-rt/lib/flang_rt/CUDA/memory.cpp
similarity index 97%
rename from flang/runtime/CUDA/memory.cpp
rename to flang-rt/lib/flang_rt/CUDA/memory.cpp
index 0bbb493d2db91..3d4a74f5f9e52 100644
--- a/flang/runtime/CUDA/memory.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/memory.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/memory.cpp -------------------------------------------===//
+//===-- lib/flang_rt/CUDA/memory.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/memory.h"
-#include "../assign-impl.h"
-#include "../terminator.h"
+#include "flang-rt/assign-impl.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memmove-function.h"
diff --git a/flang/runtime/CUDA/registration.cpp b/flang-rt/lib/flang_rt/CUDA/registration.cpp
similarity index 93%
rename from flang/runtime/CUDA/registration.cpp
rename to flang-rt/lib/flang_rt/CUDA/registration.cpp
index b7b6ef389bffb..f8a7b197bed3b 100644
--- a/flang/runtime/CUDA/registration.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/registration.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/registration.cpp -------------------------------------===//
+//===-- lib/flang_rt/CUDA/registration.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/registration.h"
-#include "../terminator.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang/runtime/ISO_Fortran_binding.cpp b/flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
similarity index 98%
rename from flang/runtime/ISO_Fortran_binding.cpp
rename to flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
index 64e239f498230..d9b0bfe9aeb6b 100644
--- a/flang/runtime/ISO_Fortran_binding.cpp
+++ b/flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/ISO_Fortran_binding.cpp -----------------------------------===//
+//===-- lib/flang_rt/ISO_Fortran_binding.cpp --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,11 +10,11 @@
// as specified in section 18.5.5 of Fortran 2018.
#include "ISO_Fortran_util.h"
-#include "terminator.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/pointer.h"
-#include "flang/Runtime/type-code.h"
#include <cstdlib>
namespace Fortran::ISO {
diff --git a/flang/runtime/ISO_Fortran_util.h b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
similarity index 91%
rename from flang/runtime/ISO_Fortran_util.h
rename to flang-rt/lib/flang_rt/ISO_Fortran_util.h
index aca9aee8c5718..6128faba5bcea 100644
--- a/flang/runtime/ISO_Fortran_util.h
+++ b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
@@ -1,4 +1,4 @@
-//===-- runtime/ISO_Fortran_util.h ------------------------------*- C++ -*-===//
+//===-- lib/flang_rt/ISO_Fortran_util.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.
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_ISO_FORTRAN_UTIL_H_
-#define FORTRAN_RUNTIME_ISO_FORTRAN_UTIL_H_
+#ifndef FLANG_RT_ISO_FORTRAN_UTIL_H_
+#define FLANG_RT_ISO_FORTRAN_UTIL_H_
// Internal utils for establishing CFI_cdesc_t descriptors.
-#include "terminator.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/type-code.h"
#include <cstdlib>
namespace Fortran::ISO {
@@ -99,4 +99,4 @@ static inline RT_API_ATTRS void EstablishDescriptor(CFI_cdesc_t *descriptor,
}
}
} // namespace Fortran::ISO
-#endif // FORTRAN_RUNTIME_ISO_FORTRAN_UTIL_H_
+#endif /* FLANG_RT_ISO_FORTRAN_UTIL_H_ */
diff --git a/flang/runtime/allocatable.cpp b/flang-rt/lib/flang_rt/allocatable.cpp
similarity index 96%
rename from flang/runtime/allocatable.cpp
rename to flang-rt/lib/flang_rt/allocatable.cpp
index 686114bf86eaf..63ef99b8a72d1 100644
--- a/flang/runtime/allocatable.cpp
+++ b/flang-rt/lib/flang_rt/allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/allocatable.cpp -------------------------------------------===//
+//===-- lib/flang_rt/allocatable.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,14 +7,14 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/allocatable.h"
-#include "assign-impl.h"
-#include "derived.h"
-#include "stat.h"
-#include "terminator.h"
-#include "type-info.h"
+#include "flang-rt/assign-impl.h"
+#include "flang-rt/derived.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/type-info.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
-#include "flang/Runtime/descriptor.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang/runtime/allocator-registry.cpp b/flang-rt/lib/flang_rt/allocator-registry.cpp
similarity index 88%
rename from flang/runtime/allocator-registry.cpp
rename to flang-rt/lib/flang_rt/allocator-registry.cpp
index f5670331d6dbe..11847de68724d 100644
--- a/flang/runtime/allocator-registry.cpp
+++ b/flang-rt/lib/flang_rt/allocator-registry.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/allocator-registry.cpp ------------------------------------===//
+//===-- lib/flang_rt/allocator-registry.cpp ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/allocator-registry.h"
-#include "terminator.h"
+#include "flang-rt/allocator-registry.h"
+#include "flang-rt/terminator.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/array-constructor.cpp b/flang-rt/lib/flang_rt/array-constructor.cpp
similarity index 96%
rename from flang/runtime/array-constructor.cpp
rename to flang-rt/lib/flang_rt/array-constructor.cpp
index c6953167f5fb2..d2765c9439b75 100644
--- a/flang/runtime/array-constructor.cpp
+++ b/flang-rt/lib/flang_rt/array-constructor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/array-constructor.cpp -------------------------------------===//
+//===-- lib/flang_rt/array-constructor.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/array-constructor.h"
-#include "derived.h"
-#include "terminator.h"
-#include "tools.h"
-#include "type-info.h"
+#include "flang-rt/array-constructor.h"
+#include "flang-rt/derived.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
+#include "flang-rt/type-info.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/assign.h"
-#include "flang/Runtime/descriptor.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/assign.cpp b/flang-rt/lib/flang_rt/assign.cpp
similarity index 98%
rename from flang/runtime/assign.cpp
rename to flang-rt/lib/flang_rt/assign.cpp
index 8f0efaa376c19..0d6045eac503a 100644
--- a/flang/runtime/assign.cpp
+++ b/flang-rt/lib/flang_rt/assign.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/assign.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/assign.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/assign.h"
-#include "assign-impl.h"
-#include "derived.h"
-#include "stat.h"
-#include "terminator.h"
-#include "tools.h"
-#include "type-info.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/assign-impl.h"
+#include "flang-rt/derived.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
+#include "flang-rt/type-info.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/buffer.cpp b/flang-rt/lib/flang_rt/buffer.cpp
similarity index 89%
rename from flang/runtime/buffer.cpp
rename to flang-rt/lib/flang_rt/buffer.cpp
index 7b4869d69c2e5..e084155068bc5 100644
--- a/flang/runtime/buffer.cpp
+++ b/flang-rt/lib/flang_rt/buffer.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/buffer.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/buffer.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "buffer.h"
+#include "flang-rt/buffer.h"
#include <algorithm>
namespace Fortran::runtime::io {
diff --git a/flang/runtime/character.cpp b/flang-rt/lib/flang_rt/character.cpp
similarity index 99%
rename from flang/runtime/character.cpp
rename to flang-rt/lib/flang_rt/character.cpp
index 5049247397eb3..79d4ebdb0afbf 100644
--- a/flang/runtime/character.cpp
+++ b/flang-rt/lib/flang_rt/character.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/character.cpp ---------------------------------------------===//
+//===-- lib/flang_rt/character.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/character.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Common/bit-population-count.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include <algorithm>
#include <cstring>
diff --git a/flang/runtime/command.cpp b/flang-rt/lib/flang_rt/command.cpp
similarity index 96%
rename from flang/runtime/command.cpp
rename to flang-rt/lib/flang_rt/command.cpp
index a555e26f96a66..498ae8db17224 100644
--- a/flang/runtime/command.cpp
+++ b/flang-rt/lib/flang_rt/command.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/command.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/command.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/command.h"
-#include "environment.h"
-#include "stat.h"
-#include "terminator.h"
-#include "tools.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include <cstdlib>
#include <limits>
diff --git a/flang/runtime/complex-powi.cpp b/flang-rt/lib/flang_rt/complex-powi.cpp
similarity index 92%
rename from flang/runtime/complex-powi.cpp
rename to flang-rt/lib/flang_rt/complex-powi.cpp
index 62f73e037b76f..287bafc422057 100644
--- a/flang/runtime/complex-powi.cpp
+++ b/flang-rt/lib/flang_rt/complex-powi.cpp
@@ -1,11 +1,11 @@
-/*===-- flang/runtime/complex-powi.cpp ----------------------------*- 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
- *
- * ===-----------------------------------------------------------------------===
- */
+//===-- lib/flang_rt/complex-powi.cpp ---------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
#include "flang/Common/float128.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/entry-names.h"
diff --git a/flang/runtime/complex-reduction.c b/flang-rt/lib/flang_rt/complex-reduction.c
similarity index 97%
rename from flang/runtime/complex-reduction.c
rename to flang-rt/lib/flang_rt/complex-reduction.c
index de1ff3d683084..967f26c05e702 100644
--- a/flang/runtime/complex-reduction.c
+++ b/flang-rt/lib/flang_rt/complex-reduction.c
@@ -1,11 +1,10 @@
-/*===-- flang/runtime/complex-reduction.c ---------------------------*- C -*-===
+/*===-- lib/flang_rt/complex-reduction.c ----------------------------*- 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
*
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
#include "complex-reduction.h"
#include <float.h>
diff --git a/flang/runtime/complex-reduction.h b/flang-rt/lib/flang_rt/complex-reduction.h
similarity index 96%
rename from flang/runtime/complex-reduction.h
rename to flang-rt/lib/flang_rt/complex-reduction.h
index 5ff2a828fb3ec..2678dbf4e6472 100644
--- a/flang/runtime/complex-reduction.h
+++ b/flang-rt/lib/flang_rt/complex-reduction.h
@@ -1,19 +1,18 @@
-/*===-- flang/runtime/complex-reduction.h ---------------------------*- C -*-===
+/*===-- lib/flang_rt/complex-reduction.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
*
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
/* Wraps the C++-coded complex-valued SUM and PRODUCT reductions with
* C-coded wrapper functions returning _Complex values, to avoid problems
* with C++ build compilers that don't support C's _Complex.
*/
-#ifndef FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_
-#define FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_
+#ifndef FLANG_RT_COMPLEX_REDUCTION_H_
+#define FLANG_RT_COMPLEX_REDUCTION_H_
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
@@ -156,4 +155,4 @@ void RTNAME(ReduceComplex16DimValue)(
REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));
#endif
-#endif // FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_
+#endif /* FLANG_RT_COMPLEX_REDUCTION_H_ */
diff --git a/flang/runtime/connection.cpp b/flang-rt/lib/flang_rt/connection.cpp
similarity index 91%
rename from flang/runtime/connection.cpp
rename to flang-rt/lib/flang_rt/connection.cpp
index f24f0e832eb48..1c454b81389ac 100644
--- a/flang/runtime/connection.cpp
+++ b/flang-rt/lib/flang_rt/connection.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/connection.cpp --------------------------------------------===//
+//===-- lib/flang_rt/connection.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "connection.h"
-#include "environment.h"
-#include "io-stmt.h"
+#include "flang-rt/connection.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/io-stmt.h"
#include <algorithm>
namespace Fortran::runtime::io {
diff --git a/flang/runtime/copy.cpp b/flang-rt/lib/flang_rt/copy.cpp
similarity index 98%
rename from flang/runtime/copy.cpp
rename to flang-rt/lib/flang_rt/copy.cpp
index b20f68f019498..0ad6946d3161a 100644
--- a/flang/runtime/copy.cpp
+++ b/flang-rt/lib/flang_rt/copy.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/copy.cpp -------------------------------------------------===//
+//===-- lib/flang_rt/copy.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,10 @@
#include "copy.h"
#include "stack.h"
-#include "terminator.h"
-#include "type-info.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/type-info.h"
#include "flang/Runtime/allocatable.h"
-#include "flang/Runtime/descriptor.h"
#include <cstring>
namespace Fortran::runtime {
diff --git a/flang/runtime/copy.h b/flang-rt/lib/flang_rt/copy.h
similarity index 79%
rename from flang/runtime/copy.h
rename to flang-rt/lib/flang_rt/copy.h
index 542660530bfb6..468c2439baf61 100644
--- a/flang/runtime/copy.h
+++ b/flang-rt/lib/flang_rt/copy.h
@@ -1,4 +1,4 @@
-//===-- runtime/copy.h ------------------------------------------*- C++ -*-===//
+//===-- lib/flang_rt/copy.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.
@@ -9,10 +9,10 @@
// Utilities that copy data in a type-aware fashion, allocating & duplicating
// allocatable/automatic components of derived types along the way.
-#ifndef FORTRAN_RUNTIME_COPY_H_
-#define FORTRAN_RUNTIME_COPY_H_
+#ifndef FLANG_RT_COPY_H_
+#define FLANG_RT_COPY_H_
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
namespace Fortran::runtime {
@@ -22,4 +22,4 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
const Descriptor &from, const SubscriptValue fromAt[], Terminator &);
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_COPY_H_
+#endif /* FLANG_RT_COPY_H_ */
diff --git a/flang/runtime/derived-api.cpp b/flang-rt/lib/flang_rt/derived-api.cpp
similarity index 96%
rename from flang/runtime/derived-api.cpp
rename to flang-rt/lib/flang_rt/derived-api.cpp
index c8ffd8e3bb67c..353bc4a83ebd9 100644
--- a/flang/runtime/derived-api.cpp
+++ b/flang-rt/lib/flang_rt/derived-api.cpp
@@ -1,5 +1,4 @@
-//===-- runtime/derived-api.cpp
-//-----------------------------------------------===//
+//===-- lib/flang_rt/derived-api.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/derived-api.h"
-#include "derived.h"
-#include "terminator.h"
-#include "tools.h"
-#include "type-info.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/derived.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
+#include "flang-rt/type-info.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/derived.cpp b/flang-rt/lib/flang_rt/derived.cpp
similarity index 98%
rename from flang/runtime/derived.cpp
rename to flang-rt/lib/flang_rt/derived.cpp
index 10813c62e5da1..cace9e1074e65 100644
--- a/flang/runtime/derived.cpp
+++ b/flang-rt/lib/flang_rt/derived.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/derived.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/derived.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "derived.h"
-#include "stat.h"
-#include "terminator.h"
-#include "tools.h"
-#include "type-info.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/derived.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
+#include "flang-rt/type-info.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/descriptor-io.cpp b/flang-rt/lib/flang_rt/descriptor-io.cpp
similarity index 98%
rename from flang/runtime/descriptor-io.cpp
rename to flang-rt/lib/flang_rt/descriptor-io.cpp
index 380ad425d925f..c5cfa4d7fc597 100644
--- a/flang/runtime/descriptor-io.cpp
+++ b/flang-rt/lib/flang_rt/descriptor-io.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/descriptor-io.cpp -----------------------------------------===//
+//===-- lib/flang_rt/descriptor-io.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/descriptor-io.h b/flang-rt/lib/flang_rt/descriptor-io.h
similarity index 98%
rename from flang/runtime/descriptor-io.h
rename to flang-rt/lib/flang_rt/descriptor-io.h
index 1034958bf654a..763ebb1735752 100644
--- a/flang/runtime/descriptor-io.h
+++ b/flang-rt/lib/flang_rt/descriptor-io.h
@@ -1,4 +1,4 @@
-//===-- runtime/descriptor-io.h ---------------------------------*- C++ -*-===//
+//===-- lib/flang_rt/descriptor-io.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_DESCRIPTOR_IO_H_
-#define FORTRAN_RUNTIME_DESCRIPTOR_IO_H_
+#ifndef FLANG_RT_DESCRIPTOR_IO_H_
+#define FLANG_RT_DESCRIPTOR_IO_H_
// Implementation of I/O data list item transfers based on descriptors.
// (All I/O items come through here so that the code is exercised for test;
@@ -16,15 +16,15 @@
#include "edit-input.h"
#include "edit-output.h"
-#include "io-stmt.h"
-#include "namelist.h"
-#include "terminator.h"
-#include "type-info.h"
#include "unit.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/io-stmt.h"
+#include "flang-rt/namelist.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/type-info.h"
#include "flang/Common/optional.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
namespace Fortran::runtime::io::descr {
template <typename A>
@@ -626,4 +626,4 @@ static RT_API_ATTRS bool DescriptorIO(IoStatementState &io,
return false;
}
} // namespace Fortran::runtime::io::descr
-#endif // FORTRAN_RUNTIME_DESCRIPTOR_IO_H_
+#endif /* FLANG_RT_DESCRIPTOR_IO_H_ */
diff --git a/flang/runtime/descriptor.cpp b/flang-rt/lib/flang_rt/descriptor.cpp
similarity index 95%
rename from flang/runtime/descriptor.cpp
rename to flang-rt/lib/flang_rt/descriptor.cpp
index 32f43e89dc7a3..cdf01f12e7134 100644
--- a/flang/runtime/descriptor.cpp
+++ b/flang-rt/lib/flang_rt/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/descriptor.cpp --------------------------------------------===//
+//===-- lib/flang_rt/descriptor.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
#include "ISO_Fortran_util.h"
-#include "derived.h"
#include "memory.h"
-#include "stat.h"
-#include "terminator.h"
-#include "tools.h"
-#include "type-info.h"
-#include "flang/Runtime/allocator-registry.h"
+#include "flang-rt/allocator-registry.h"
+#include "flang-rt/derived.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
+#include "flang-rt/type-info.h"
#include <cassert>
#include <cstdlib>
#include <cstring>
@@ -141,8 +141,10 @@ RT_API_ATTRS OwningPtr<Descriptor> Descriptor::Create(
RT_API_ATTRS std::size_t Descriptor::SizeInBytes() const {
const DescriptorAddendum *addendum{Addendum()};
- return sizeof *this - sizeof(Dimension) + raw_.rank * sizeof(Dimension) +
- (addendum ? addendum->SizeInBytes() : 0);
+ std::size_t bytes{ sizeof *this - sizeof(Dimension) + raw_.rank * sizeof(Dimension) +
+ (addendum ? addendum->SizeInBytes() : 0)};
+ assert (bytes <= MaxDescriptorSizeInBytes(raw_.rank,addendum) && "Descriptor must fit compiler-allocated space");
+ return bytes;
}
RT_API_ATTRS std::size_t Descriptor::Elements() const {
diff --git a/flang/runtime/dot-product.cpp b/flang-rt/lib/flang_rt/dot-product.cpp
similarity index 98%
rename from flang/runtime/dot-product.cpp
rename to flang-rt/lib/flang_rt/dot-product.cpp
index 712497a3a50ac..ad600a4228463 100644
--- a/flang/runtime/dot-product.cpp
+++ b/flang-rt/lib/flang_rt/dot-product.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/dot-product.cpp -------------------------------------------===//
+//===-- lib/flang_rt/dot-product.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "float.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/reduction.h"
#include <cfloat>
#include <cinttypes>
diff --git a/flang/runtime/edit-input.cpp b/flang-rt/lib/flang_rt/edit-input.cpp
similarity index 99%
rename from flang/runtime/edit-input.cpp
rename to flang-rt/lib/flang_rt/edit-input.cpp
index 317f0b676bd21..7121f6e42dea6 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang-rt/lib/flang_rt/edit-input.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/edit-input.cpp --------------------------------------------===//
+//===-- lib/flang_rt/edit-input.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "edit-input.h"
-#include "namelist.h"
-#include "utf.h"
+#include "flang-rt/namelist.h"
+#include "flang-rt/utf.h"
#include "flang/Common/optional.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
diff --git a/flang/runtime/edit-input.h b/flang-rt/lib/flang_rt/edit-input.h
similarity index 89%
rename from flang/runtime/edit-input.h
rename to flang-rt/lib/flang_rt/edit-input.h
index 55a7a45578171..2d6a3f241a005 100644
--- a/flang/runtime/edit-input.h
+++ b/flang-rt/lib/flang_rt/edit-input.h
@@ -1,4 +1,4 @@
-//===-- runtime/edit-input.h ------------------------------------*- C++ -*-===//
+//===-- lib/flang_rt/edit-input.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_EDIT_INPUT_H_
-#define FORTRAN_RUNTIME_EDIT_INPUT_H_
+#ifndef FLANG_RT_EDIT_INPUT_H_
+#define FLANG_RT_EDIT_INPUT_H_
-#include "format.h"
-#include "io-stmt.h"
+#include "flang-rt/format.h"
+#include "flang-rt/io-stmt.h"
#include "flang/Decimal/decimal.h"
namespace Fortran::runtime::io {
@@ -50,4 +50,4 @@ extern template RT_API_ATTRS bool EditCharacterInput(
IoStatementState &, const DataEdit &, char32_t *, std::size_t);
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_EDIT_INPUT_H_
+#endif /* FLANG_RT_EDIT_INPUT_H_ */
diff --git a/flang/runtime/edit-output.cpp b/flang-rt/lib/flang_rt/edit-output.cpp
similarity index 99%
rename from flang/runtime/edit-output.cpp
rename to flang-rt/lib/flang_rt/edit-output.cpp
index 9db9a3d4a511b..096bd4567a42a 100644
--- a/flang/runtime/edit-output.cpp
+++ b/flang-rt/lib/flang_rt/edit-output.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/edit-output.cpp -------------------------------------------===//
+//===-- lib/flang_rt/edit-output.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "edit-output.h"
-#include "emit-encoded.h"
-#include "utf.h"
+#include "flang-rt/emit-encoded.h"
+#include "flang-rt/utf.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
#include <algorithm>
diff --git a/flang/runtime/edit-output.h b/flang-rt/lib/flang_rt/edit-output.h
similarity index 96%
rename from flang/runtime/edit-output.h
rename to flang-rt/lib/flang_rt/edit-output.h
index 42cc993f98cc1..59f5d820c4ad5 100644
--- a/flang/runtime/edit-output.h
+++ b/flang-rt/lib/flang_rt/edit-output.h
@@ -1,4 +1,4 @@
-//===-- runtime/edit-output.h -----------------------------------*- C++ -*-===//
+//===-- lib/flang_rt/edit-output.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_EDIT_OUTPUT_H_
-#define FORTRAN_RUNTIME_EDIT_OUTPUT_H_
+#ifndef FLANG_RT_EDIT_OUTPUT_H_
+#define FLANG_RT_EDIT_OUTPUT_H_
// Output data editing templates implementing the FORMAT data editing
// descriptors E, EN, ES, EX, D, F, and G for REAL data (and COMPLEX
@@ -18,8 +18,8 @@
// Drives the same fast binary-to-decimal formatting templates used
// in the f18 front-end.
-#include "format.h"
-#include "io-stmt.h"
+#include "flang-rt/format.h"
+#include "flang-rt/io-stmt.h"
#include "flang/Common/uint128.h"
#include "flang/Decimal/decimal.h"
@@ -138,4 +138,4 @@ extern template class RealOutputEditing<10>;
extern template class RealOutputEditing<16>;
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_EDIT_OUTPUT_H_
+#endif /* FLANG_RT_EDIT_OUTPUT_H_ */
diff --git a/flang/runtime/environment-default-list.h b/flang-rt/lib/flang_rt/environment-default-list.h
similarity index 70%
rename from flang/runtime/environment-default-list.h
rename to flang-rt/lib/flang_rt/environment-default-list.h
index 4da261b10b9a8..76c0955bcce6d 100644
--- a/flang/runtime/environment-default-list.h
+++ b/flang-rt/lib/flang_rt/environment-default-list.h
@@ -1,14 +1,13 @@
-/*===-- runtime/environment-default-list.h --------------------------*- C -*-===
+/*===-- lib/flang_rt/environment-default-list.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
*
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
-#ifndef FORTRAN_RUNTIME_ENVIRONMENT_DEFAULT_LIST_H_
-#define FORTRAN_RUNTIME_ENVIRONMENT_DEFAULT_LIST_H_
+#ifndef FLANG_RT_ENVIRONMENT_DEFAULT_LIST_H_
+#define FLANG_RT_ENVIRONMENT_DEFAULT_LIST_H_
/* Try to maintain C compatibility to make it easier to both define environment
* defaults in non-Fortran main programs as well as pass through the environment
@@ -28,4 +27,4 @@ struct EnvironmentDefaultList {
const struct EnvironmentDefaultItem *item;
};
-#endif /* FORTRAN_RUNTIME_ENVIRONMENT_DEFAULT_LIST_H_ */
+#endif /* FLANG_RT_ENVIRONMENT_DEFAULT_LIST_H_ */
diff --git a/flang/runtime/environment.cpp b/flang-rt/lib/flang_rt/environment.cpp
similarity index 96%
rename from flang/runtime/environment.cpp
rename to flang-rt/lib/flang_rt/environment.cpp
index 52b1d99ba536e..b8d96b933f5b6 100644
--- a/flang/runtime/environment.cpp
+++ b/flang-rt/lib/flang_rt/environment.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/environment.cpp -------------------------------------------===//
+//===-- lib/flang_rt/environment.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "environment.h"
+#include "flang-rt/environment.h"
#include "environment-default-list.h"
#include "memory.h"
-#include "tools.h"
+#include "flang-rt/tools.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
diff --git a/flang/runtime/exceptions.cpp b/flang-rt/lib/flang_rt/exceptions.cpp
similarity index 96%
rename from flang/runtime/exceptions.cpp
rename to flang-rt/lib/flang_rt/exceptions.cpp
index f541b8e844ade..c6ddc5d05ccf3 100644
--- a/flang/runtime/exceptions.cpp
+++ b/flang-rt/lib/flang_rt/exceptions.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/exceptions.cpp --------------------------------------===//
+//===-- lib/flang_rt/exceptions.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
// Runtime exception support.
#include "flang/Runtime/exceptions.h"
-#include "terminator.h"
+#include "flang-rt/terminator.h"
#include <cfenv>
#if __x86_64__
#include <xmmintrin.h>
diff --git a/flang/runtime/execute.cpp b/flang-rt/lib/flang_rt/execute.cpp
similarity index 97%
rename from flang/runtime/execute.cpp
rename to flang-rt/lib/flang_rt/execute.cpp
index c7f8f386d81f4..8d56581c12a49 100644
--- a/flang/runtime/execute.cpp
+++ b/flang-rt/lib/flang_rt/execute.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/execute.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/execute.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/execute.h"
-#include "environment.h"
-#include "stat.h"
-#include "terminator.h"
-#include "tools.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include <cstdlib>
#include <errno.h>
#include <future>
diff --git a/flang/runtime/extensions.cpp b/flang-rt/lib/flang_rt/extensions.cpp
similarity index 97%
rename from flang/runtime/extensions.cpp
rename to flang-rt/lib/flang_rt/extensions.cpp
index 50d3c72fe650d..aee71164575a2 100644
--- a/flang/runtime/extensions.cpp
+++ b/flang-rt/lib/flang_rt/extensions.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/extensions.cpp --------------------------------------------===//
+//===-- lib/flang_rt/extensions.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,10 +10,10 @@
// extensions that will eventually be implemented in Fortran.
#include "flang/Runtime/extensions.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Runtime/command.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/io-api.h"
#include <chrono>
diff --git a/flang/runtime/external-unit.cpp b/flang-rt/lib/flang_rt/external-unit.cpp
similarity index 98%
rename from flang/runtime/external-unit.cpp
rename to flang-rt/lib/flang_rt/external-unit.cpp
index d17a92622f844..4be90cbbcc4c8 100644
--- a/flang/runtime/external-unit.cpp
+++ b/flang-rt/lib/flang_rt/external-unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/external-unit.cpp -----------------------------------------===//
+//===-- lib/flang_rt/external-unit.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,11 +10,11 @@
//
//===----------------------------------------------------------------------===//
-#include "io-error.h"
-#include "lock.h"
-#include "tools.h"
#include "unit-map.h"
#include "unit.h"
+#include "flang-rt/io-error.h"
+#include "flang-rt/lock.h"
+#include "flang-rt/tools.h"
// NOTE: the header files above may define OpenMP declare target
// variables, so they have to be included unconditionally
diff --git a/flang/runtime/extrema.cpp b/flang-rt/lib/flang_rt/extrema.cpp
similarity index 99%
rename from flang/runtime/extrema.cpp
rename to flang-rt/lib/flang_rt/extrema.cpp
index 7ecdf4b91702e..8ecd7fbe91d77 100644
--- a/flang/runtime/extrema.cpp
+++ b/flang-rt/lib/flang_rt/extrema.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/extrema.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/extrema.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,7 @@
// and shapes and (for MAXLOC & MINLOC) result integer kinds. Also implements
// NORM2 using common infrastructure.
-#include "reduction-templates.h"
+#include "flang-rt/reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
diff --git a/flang/runtime/file.cpp b/flang-rt/lib/flang_rt/file.cpp
similarity index 98%
rename from flang/runtime/file.cpp
rename to flang-rt/lib/flang_rt/file.cpp
index 9e077b8cea44b..c9fcf0f97b718 100644
--- a/flang/runtime/file.cpp
+++ b/flang-rt/lib/flang_rt/file.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/file.cpp --------------------------------------------------===//
+//===-- lib/flang_rt/file.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "file.h"
-#include "tools.h"
+#include "flang-rt/file.h"
+#include "flang-rt/memory.h"
+#include "flang-rt/tools.h"
#include "flang/Runtime/magic-numbers.h"
-#include "flang/Runtime/memory.h"
#include <algorithm>
#include <cerrno>
#include <cstring>
diff --git a/flang/runtime/findloc.cpp b/flang-rt/lib/flang_rt/findloc.cpp
similarity index 99%
rename from flang/runtime/findloc.cpp
rename to flang-rt/lib/flang_rt/findloc.cpp
index b9b1d7f7ab689..ac432676f5efc 100644
--- a/flang/runtime/findloc.cpp
+++ b/flang-rt/lib/flang_rt/findloc.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/findloc.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/findloc.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
// Implements FINDLOC for all required operand types and shapes and result
// integer kinds.
-#include "reduction-templates.h"
+#include "flang-rt/reduction-templates.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
#include <cinttypes>
diff --git a/flang/runtime/format.cpp b/flang-rt/lib/flang_rt/format.cpp
similarity index 88%
rename from flang/runtime/format.cpp
rename to flang-rt/lib/flang_rt/format.cpp
index 433acce4b7373..abd01b56919a4 100644
--- a/flang/runtime/format.cpp
+++ b/flang-rt/lib/flang_rt/format.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/format.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/format.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "format-implementation.h"
+#include "flang-rt/format-implementation.h"
namespace Fortran::runtime::io {
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/flang/runtime/inquiry.cpp b/flang-rt/lib/flang_rt/inquiry.cpp
similarity index 94%
rename from flang/runtime/inquiry.cpp
rename to flang-rt/lib/flang_rt/inquiry.cpp
index 9fbcaa96fa3c4..e98d3900987dc 100644
--- a/flang/runtime/inquiry.cpp
+++ b/flang-rt/lib/flang_rt/inquiry.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/inquiry.cpp --------------------------------------===//
+//===-- lib/flang_rt/inquiry.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,9 +11,9 @@
#include "flang/Runtime/inquiry.h"
#include "copy.h"
-#include "terminator.h"
-#include "tools.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include <algorithm>
namespace Fortran::runtime {
diff --git a/flang/runtime/internal-unit.cpp b/flang-rt/lib/flang_rt/internal-unit.cpp
similarity index 97%
rename from flang/runtime/internal-unit.cpp
rename to flang-rt/lib/flang_rt/internal-unit.cpp
index f8f3877efb20e..12d702de4c598 100644
--- a/flang/runtime/internal-unit.cpp
+++ b/flang-rt/lib/flang_rt/internal-unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/internal-unit.cpp -----------------------------------------===//
+//===-- lib/flang_rt/internal-unit.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "internal-unit.h"
-#include "io-error.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/internal-unit.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/io-error.h"
#include "flang/Runtime/freestanding-tools.h"
#include <algorithm>
#include <type_traits>
diff --git a/flang/runtime/io-api-common.h b/flang-rt/lib/flang_rt/io-api-common.h
similarity index 93%
rename from flang/runtime/io-api-common.h
rename to flang-rt/lib/flang_rt/io-api-common.h
index c7b86cab73a52..ba8c7177c2811 100644
--- a/flang/runtime/io-api-common.h
+++ b/flang-rt/lib/flang_rt/io-api-common.h
@@ -1,4 +1,4 @@
-//===-- runtime/io-api-common.h ---------------------------------*- C++ -*-===//
+//===-- lib/flang_rt/io-api-common.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.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RUNTIME_IO_API_COMMON_H_
-#define FLANG_RUNTIME_IO_API_COMMON_H_
+#ifndef FLANG_RT_IO_API_COMMON_H_
+#define FLANG_RT_IO_API_COMMON_H_
-#include "io-stmt.h"
-#include "terminator.h"
#include "unit.h"
+#include "flang-rt/io-stmt.h"
+#include "flang-rt/terminator.h"
#include "flang/Common/api-attrs.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/io-api.h"
@@ -94,4 +94,4 @@ RT_API_ATTRS Cookie BeginExternalListIO(
}
} // namespace Fortran::runtime::io
-#endif // FLANG_RUNTIME_IO_API_COMMON_H_
+#endif /* FLANG_RT_IO_API_COMMON_H_ */
diff --git a/flang/runtime/io-api-minimal.cpp b/flang-rt/lib/flang_rt/io-api-minimal.cpp
similarity index 96%
rename from flang/runtime/io-api-minimal.cpp
rename to flang-rt/lib/flang_rt/io-api-minimal.cpp
index 68768427be0c2..c3234c78c10c8 100644
--- a/flang/runtime/io-api-minimal.cpp
+++ b/flang-rt/lib/flang_rt/io-api-minimal.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-api-minimal.cpp ----------------------------------------===//
+//===-- lib/flang_rt/io-api-minimal.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,12 +10,12 @@
// list-directed output (PRINT *) of intrinsic types.
#include "edit-output.h"
-#include "format.h"
#include "io-api-common.h"
-#include "io-stmt.h"
-#include "terminator.h"
-#include "tools.h"
#include "unit.h"
+#include "flang-rt/format.h"
+#include "flang-rt/io-stmt.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Runtime/io-api.h"
namespace Fortran::runtime::io {
diff --git a/flang/runtime/io-api.cpp b/flang-rt/lib/flang_rt/io-api.cpp
similarity index 99%
rename from flang/runtime/io-api.cpp
rename to flang-rt/lib/flang_rt/io-api.cpp
index 7023f61ba34de..ce1330ff323d4 100644
--- a/flang/runtime/io-api.cpp
+++ b/flang-rt/lib/flang_rt/io-api.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-api.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/io-api.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,16 +17,16 @@
#include "descriptor-io.h"
#include "edit-input.h"
#include "edit-output.h"
-#include "environment.h"
-#include "format.h"
#include "io-api-common.h"
-#include "io-stmt.h"
-#include "terminator.h"
-#include "tools.h"
#include "unit.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/format.h"
+#include "flang-rt/io-stmt.h"
+#include "flang-rt/memory.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Common/optional.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/memory.h"
#include <cstdlib>
#include <memory>
diff --git a/flang/runtime/io-error.cpp b/flang-rt/lib/flang_rt/io-error.cpp
similarity index 97%
rename from flang/runtime/io-error.cpp
rename to flang-rt/lib/flang_rt/io-error.cpp
index 37909e8e6dad2..b356642c95f85 100644
--- a/flang/runtime/io-error.cpp
+++ b/flang-rt/lib/flang_rt/io-error.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-error.cpp ----------------------------------------------===//
+//===-- lib/flang_rt/io-error.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "io-error.h"
+#include "flang-rt/io-error.h"
#include "config.h"
-#include "tools.h"
+#include "flang-rt/tools.h"
#include "flang/Runtime/magic-numbers.h"
#include <cerrno>
#include <cstdarg>
diff --git a/flang/runtime/io-stmt.cpp b/flang-rt/lib/flang_rt/io-stmt.cpp
similarity index 99%
rename from flang/runtime/io-stmt.cpp
rename to flang-rt/lib/flang_rt/io-stmt.cpp
index f24eb929ce748..a07bf70a6593e 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/flang-rt/lib/flang_rt/io-stmt.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-stmt.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/io-stmt.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#include "io-stmt.h"
-#include "connection.h"
-#include "emit-encoded.h"
-#include "format.h"
-#include "tools.h"
+#include "flang-rt/io-stmt.h"
#include "unit.h"
-#include "utf.h"
-#include "flang/Runtime/memory.h"
+#include "flang-rt/connection.h"
+#include "flang-rt/emit-encoded.h"
+#include "flang-rt/format.h"
+#include "flang-rt/memory.h"
+#include "flang-rt/tools.h"
+#include "flang-rt/utf.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
diff --git a/flang/runtime/iostat.cpp b/flang-rt/lib/flang_rt/iostat.cpp
similarity index 98%
rename from flang/runtime/iostat.cpp
rename to flang-rt/lib/flang_rt/iostat.cpp
index 39e224cb01286..ab2fc63cf7b21 100644
--- a/flang/runtime/iostat.cpp
+++ b/flang-rt/lib/flang_rt/iostat.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/iostat.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/iostat.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/main.cpp b/flang-rt/lib/flang_rt/main.cpp
similarity index 90%
rename from flang/runtime/main.cpp
rename to flang-rt/lib/flang_rt/main.cpp
index 96454989581b7..dac7268f82b16 100644
--- a/flang/runtime/main.cpp
+++ b/flang-rt/lib/flang_rt/main.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/main.cpp --------------------------------------------------===//
+//===-- lib/flang_rt/main.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/main.h"
-#include "environment.h"
-#include "terminator.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/terminator.h"
#include <cfenv>
#include <cstdio>
#include <cstdlib>
diff --git a/flang/runtime/matmul-transpose.cpp b/flang-rt/lib/flang_rt/matmul-transpose.cpp
similarity index 98%
rename from flang/runtime/matmul-transpose.cpp
rename to flang-rt/lib/flang_rt/matmul-transpose.cpp
index bafa05056bebc..307995bb8ab1e 100644
--- a/flang/runtime/matmul-transpose.cpp
+++ b/flang-rt/lib/flang_rt/matmul-transpose.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/matmul-transpose.cpp --------------------------------------===//
+//===-- lib/flang_rt/matmul-transpose.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -21,12 +21,12 @@
// to use the faster BLAS routines.
#include "flang/Runtime/matmul-transpose.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/c-or-cpp.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include <cstring>
namespace {
diff --git a/flang/runtime/matmul.cpp b/flang-rt/lib/flang_rt/matmul.cpp
similarity index 99%
rename from flang/runtime/matmul.cpp
rename to flang-rt/lib/flang_rt/matmul.cpp
index f72601073a600..c5036e24f86f4 100644
--- a/flang/runtime/matmul.cpp
+++ b/flang-rt/lib/flang_rt/matmul.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/matmul.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/matmul.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,12 +20,12 @@
// Places where BLAS routines could be called are marked as TODO items.
#include "flang/Runtime/matmul.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/c-or-cpp.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include <cstring>
namespace {
diff --git a/flang/runtime/memory.cpp b/flang-rt/lib/flang_rt/memory.cpp
similarity index 87%
rename from flang/runtime/memory.cpp
rename to flang-rt/lib/flang_rt/memory.cpp
index c7068ad6479a1..e09e45898da8e 100644
--- a/flang/runtime/memory.cpp
+++ b/flang-rt/lib/flang_rt/memory.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/memory.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/memory.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/memory.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/memory.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Runtime/freestanding-tools.h"
#include <cstdlib>
diff --git a/flang/runtime/misc-intrinsic.cpp b/flang-rt/lib/flang_rt/misc-intrinsic.cpp
similarity index 96%
rename from flang/runtime/misc-intrinsic.cpp
rename to flang-rt/lib/flang_rt/misc-intrinsic.cpp
index f7d893829fc0d..1a5bc8114e8ae 100644
--- a/flang/runtime/misc-intrinsic.cpp
+++ b/flang-rt/lib/flang_rt/misc-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/misc-intrinsic.cpp ----------------------------------------===//
+//===-- lib/flang_rt/misc-intrinsic.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/misc-intrinsic.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Common/optional.h"
-#include "flang/Runtime/descriptor.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
diff --git a/flang/runtime/namelist.cpp b/flang-rt/lib/flang_rt/namelist.cpp
similarity index 99%
rename from flang/runtime/namelist.cpp
rename to flang-rt/lib/flang_rt/namelist.cpp
index af092de70f781..4cf1cd2062ac5 100644
--- a/flang/runtime/namelist.cpp
+++ b/flang-rt/lib/flang_rt/namelist.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/namelist.cpp ----------------------------------------------===//
+//===-- lib/flang_rt/namelist.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "namelist.h"
+#include "flang-rt/namelist.h"
#include "descriptor-io.h"
-#include "emit-encoded.h"
-#include "io-stmt.h"
+#include "flang-rt/emit-encoded.h"
+#include "flang-rt/io-stmt.h"
#include "flang/Runtime/io-api.h"
#include <algorithm>
#include <cstring>
diff --git a/flang/runtime/non-tbp-dio.cpp b/flang-rt/lib/flang_rt/non-tbp-dio.cpp
similarity index 87%
rename from flang/runtime/non-tbp-dio.cpp
rename to flang-rt/lib/flang_rt/non-tbp-dio.cpp
index 9419adb7631cc..5663c2ee338d7 100644
--- a/flang/runtime/non-tbp-dio.cpp
+++ b/flang-rt/lib/flang_rt/non-tbp-dio.cpp
@@ -1,4 +1,4 @@
-//===-- flang/runtime/non-tbp-dio.cpp ---------------------------*- C++ -*-===//
+//===-- lib/flang_rt/non-tbp-dio.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "non-tbp-dio.h"
-#include "type-info.h"
+#include "flang-rt/non-tbp-dio.h"
+#include "flang-rt/type-info.h"
namespace Fortran::runtime::io {
diff --git a/flang/runtime/numeric.cpp b/flang-rt/lib/flang_rt/numeric.cpp
similarity index 99%
rename from flang/runtime/numeric.cpp
rename to flang-rt/lib/flang_rt/numeric.cpp
index 45fb56348fd44..b63c604cadcfb 100644
--- a/flang/runtime/numeric.cpp
+++ b/flang-rt/lib/flang_rt/numeric.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/numeric.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/numeric.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/numeric.h"
-#include "numeric-templates.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/numeric-templates.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Common/float128.h"
#include <cfloat>
#include <climits>
diff --git a/flang/runtime/pointer.cpp b/flang-rt/lib/flang_rt/pointer.cpp
similarity index 97%
rename from flang/runtime/pointer.cpp
rename to flang-rt/lib/flang_rt/pointer.cpp
index 2979181ddd61b..3138a54f1d122 100644
--- a/flang/runtime/pointer.cpp
+++ b/flang-rt/lib/flang_rt/pointer.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/pointer.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/pointer.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/pointer.h"
-#include "assign-impl.h"
-#include "derived.h"
-#include "environment.h"
-#include "stat.h"
-#include "terminator.h"
-#include "tools.h"
-#include "type-info.h"
+#include "flang-rt/assign-impl.h"
+#include "flang-rt/derived.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
+#include "flang-rt/type-info.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang/runtime/product.cpp b/flang-rt/lib/flang_rt/product.cpp
similarity index 98%
rename from flang/runtime/product.cpp
rename to flang-rt/lib/flang_rt/product.cpp
index 293ffd301ba2e..c7b6d23d3014e 100644
--- a/flang/runtime/product.cpp
+++ b/flang-rt/lib/flang_rt/product.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/product.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/product.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
// Implements PRODUCT for all required operand types and shapes.
-#include "reduction-templates.h"
+#include "flang-rt/reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
#include <cfloat>
diff --git a/flang/runtime/pseudo-unit.cpp b/flang-rt/lib/flang_rt/pseudo-unit.cpp
similarity index 97%
rename from flang/runtime/pseudo-unit.cpp
rename to flang-rt/lib/flang_rt/pseudo-unit.cpp
index 526afd11d916e..f4d204890581e 100644
--- a/flang/runtime/pseudo-unit.cpp
+++ b/flang-rt/lib/flang_rt/pseudo-unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/pseudo-unit.cpp -------------------------------------------===//
+//===-- lib/flang_rt/pseudo-unit.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "io-error.h"
-#include "tools.h"
#include "unit.h"
+#include "flang-rt/io-error.h"
+#include "flang-rt/tools.h"
// NOTE: the header files above may define OpenMP declare target
// variables, so they have to be included unconditionally
diff --git a/flang/runtime/ragged.cpp b/flang-rt/lib/flang_rt/ragged.cpp
similarity index 96%
rename from flang/runtime/ragged.cpp
rename to flang-rt/lib/flang_rt/ragged.cpp
index a4d9e541ba531..798b3464e7bca 100644
--- a/flang/runtime/ragged.cpp
+++ b/flang-rt/lib/flang_rt/ragged.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/ragged.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/ragged.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/ragged.h"
-#include "tools.h"
+#include "flang-rt/tools.h"
#include <cstdlib>
namespace Fortran::runtime {
diff --git a/flang/runtime/random.cpp b/flang-rt/lib/flang_rt/random.cpp
similarity index 96%
rename from flang/runtime/random.cpp
rename to flang-rt/lib/flang_rt/random.cpp
index 8f158007a5a65..76971cf3fc888 100644
--- a/flang/runtime/random.cpp
+++ b/flang-rt/lib/flang_rt/random.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/random.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/random.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,14 +10,14 @@
// RANDOM_SEED.
#include "flang/Runtime/random.h"
-#include "lock.h"
-#include "random-templates.h"
-#include "terminator.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/lock.h"
+#include "flang-rt/random-templates.h"
+#include "flang-rt/terminator.h"
#include "flang/Common/float128.h"
#include "flang/Common/leading-zero-bit-count.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include <cmath>
#include <cstdint>
#include <limits>
diff --git a/flang/runtime/reduce.cpp b/flang-rt/lib/flang_rt/reduce.cpp
similarity index 99%
rename from flang/runtime/reduce.cpp
rename to flang-rt/lib/flang_rt/reduce.cpp
index 6c42c5ef50e4f..4bb6dc10ea9da 100644
--- a/flang/runtime/reduce.cpp
+++ b/flang-rt/lib/flang_rt/reduce.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/reduce.cpp ------------------------------------------------===//
+//===-- lib/flang_rt/reduce.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,10 +9,10 @@
// REDUCE() implementation
#include "flang/Runtime/reduce.h"
-#include "reduction-templates.h"
-#include "terminator.h"
-#include "tools.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/reduction-templates.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/reduction.cpp b/flang-rt/lib/flang_rt/reduction.cpp
similarity index 99%
rename from flang/runtime/reduction.cpp
rename to flang-rt/lib/flang_rt/reduction.cpp
index a8fcde7b3a166..9ceaeffc6541a 100644
--- a/flang/runtime/reduction.cpp
+++ b/flang-rt/lib/flang_rt/reduction.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/reduction.cpp ---------------------------------------------===//
+//===-- lib/flang_rt/reduction.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,8 +14,8 @@
// NORM2, MAXLOC, MINLOC, MAXVAL, and MINVAL are in extrema.cpp.
#include "flang/Runtime/reduction.h"
-#include "reduction-templates.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/reduction-templates.h"
#include <cinttypes>
namespace Fortran::runtime {
diff --git a/flang/runtime/stack.h b/flang-rt/lib/flang_rt/stack.h
similarity index 94%
rename from flang/runtime/stack.h
rename to flang-rt/lib/flang_rt/stack.h
index b6e6edb595e9a..88cd276456fbc 100644
--- a/flang/runtime/stack.h
+++ b/flang-rt/lib/flang_rt/stack.h
@@ -1,4 +1,4 @@
-//===-- runtime/stack.h -----------------------------------------*- C++ -*-===//
+//===-- lib/flang_rt/stack.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.
@@ -10,11 +10,11 @@
// It is a list based stack with dynamic allocation/deallocation
// of the list nodes.
-#ifndef FORTRAN_RUNTIME_STACK_H
-#define FORTRAN_RUNTIME_STACK_H
+#ifndef FLANG_RT_STACK_H_
+#define FLANG_RT_STACK_H_
-#include "terminator.h"
-#include "flang/Runtime/memory.h"
+#include "flang-rt/memory.h"
+#include "flang-rt/terminator.h"
namespace Fortran::runtime {
// Storage for the Stack elements of type T.
@@ -133,4 +133,4 @@ template <typename T, unsigned N = 0> class Stack : public StackStorage<T, N> {
Terminator &terminator_;
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_STACK_H
+#endif /* FLANG_RT_STACK_H_ */
diff --git a/flang/runtime/stat.cpp b/flang-rt/lib/flang_rt/stat.cpp
similarity index 93%
rename from flang/runtime/stat.cpp
rename to flang-rt/lib/flang_rt/stat.cpp
index 525a4e36cdc77..883e85d0fbf2f 100644
--- a/flang/runtime/stat.cpp
+++ b/flang-rt/lib/flang_rt/stat.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/stat.cpp --------------------------------------------------===//
+//===-- lib/flang_rt/stat.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "stat.h"
-#include "terminator.h"
-#include "tools.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
namespace Fortran::runtime {
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/flang/runtime/stop.cpp b/flang-rt/lib/flang_rt/stop.cpp
similarity index 96%
rename from flang/runtime/stop.cpp
rename to flang-rt/lib/flang_rt/stop.cpp
index a7be8a082e026..68141383246c3 100644
--- a/flang/runtime/stop.cpp
+++ b/flang-rt/lib/flang_rt/stop.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/stop.cpp --------------------------------------------------===//
+//===-- lib/flang_rt/stop.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,11 +8,11 @@
#include "flang/Runtime/stop.h"
#include "config.h"
-#include "environment.h"
-#include "file.h"
-#include "io-error.h"
-#include "terminator.h"
#include "unit.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/file.h"
+#include "flang-rt/io-error.h"
+#include "flang-rt/terminator.h"
#include <cfenv>
#include <cstdio>
#include <cstdlib>
diff --git a/flang/runtime/sum.cpp b/flang-rt/lib/flang_rt/sum.cpp
similarity index 98%
rename from flang/runtime/sum.cpp
rename to flang-rt/lib/flang_rt/sum.cpp
index 3cb7a2b285779..fd98525b8c9b2 100644
--- a/flang/runtime/sum.cpp
+++ b/flang-rt/lib/flang_rt/sum.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/sum.cpp ---------------------------------------------------===//
+//===-- lib/flang_rt/sum.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
// cancellation on intermediate results by using "Kahan summation"
// (basically the same as manual "double-double").
-#include "reduction-templates.h"
+#include "flang-rt/reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
#include <cfloat>
diff --git a/flang/runtime/support.cpp b/flang-rt/lib/flang_rt/support.cpp
similarity index 90%
rename from flang/runtime/support.cpp
rename to flang-rt/lib/flang_rt/support.cpp
index a607120256d9d..2673176bd8185 100644
--- a/flang/runtime/support.cpp
+++ b/flang-rt/lib/flang_rt/support.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/support.cpp -----------------------------------------------===//
+//===-- lib/flang_rt/support.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,8 +8,8 @@
#include "flang/Runtime/support.h"
#include "ISO_Fortran_util.h"
-#include "type-info.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/type-info.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang/runtime/temporary-stack.cpp b/flang-rt/lib/flang_rt/temporary-stack.cpp
similarity index 97%
rename from flang/runtime/temporary-stack.cpp
rename to flang-rt/lib/flang_rt/temporary-stack.cpp
index 93340266b1b44..32ec4dacc872d 100644
--- a/flang/runtime/temporary-stack.cpp
+++ b/flang-rt/lib/flang_rt/temporary-stack.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/temporary-stack.cpp ---------------------------------------===//
+//===-- lib/flang_rt/temporary-stack.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,11 +10,11 @@
// temporaries. For use in HLFIR lowering.
#include "flang/Runtime/temporary-stack.h"
-#include "terminator.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/memory.h"
+#include "flang-rt/terminator.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/memory.h"
namespace {
diff --git a/flang/runtime/terminator.cpp b/flang-rt/lib/flang_rt/terminator.cpp
similarity index 96%
rename from flang/runtime/terminator.cpp
rename to flang-rt/lib/flang_rt/terminator.cpp
index bab9edc64fa35..0dfc08eb70370 100644
--- a/flang/runtime/terminator.cpp
+++ b/flang-rt/lib/flang_rt/terminator.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/terminate.cpp ---------------------------------------------===//
+//===-- lib/flang_rt/terminator.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "terminator.h"
+#include "flang-rt/terminator.h"
#include <cstdio>
#include <cstdlib>
diff --git a/flang/runtime/time-intrinsic.cpp b/flang-rt/lib/flang_rt/time-intrinsic.cpp
similarity index 99%
rename from flang/runtime/time-intrinsic.cpp
rename to flang-rt/lib/flang_rt/time-intrinsic.cpp
index 942604a92aaad..1929fccbd4cf3 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/flang-rt/lib/flang_rt/time-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/time-intrinsic.cpp ----------------------------------------===//
+//===-- lib/flang_rt/time-intrinsic.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,10 +9,10 @@
// Implements time-related intrinsic subroutines.
#include "flang/Runtime/time-intrinsic.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include <algorithm>
#include <cstdint>
#include <cstdio>
diff --git a/flang/runtime/tools.cpp b/flang-rt/lib/flang_rt/tools.cpp
similarity index 98%
rename from flang/runtime/tools.cpp
rename to flang-rt/lib/flang_rt/tools.cpp
index 73d6c2cf7e1d2..9b460f81ad5c2 100644
--- a/flang/runtime/tools.cpp
+++ b/flang-rt/lib/flang_rt/tools.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/tools.cpp -------------------------------------------------===//
+//===-- lib/flang_rt/tools.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "tools.h"
-#include "terminator.h"
+#include "flang-rt/tools.h"
+#include "flang-rt/terminator.h"
#include <algorithm>
#include <cstdint>
#include <cstdlib>
diff --git a/flang/runtime/transformational.cpp b/flang-rt/lib/flang_rt/transformational.cpp
similarity index 99%
rename from flang/runtime/transformational.cpp
rename to flang-rt/lib/flang_rt/transformational.cpp
index ab303bdef9b1d..7453bf18323e9 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang-rt/lib/flang_rt/transformational.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/transformational.cpp --------------------------------------===//
+//===-- lib/flang_rt/transformational.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,10 +18,10 @@
#include "flang/Runtime/transformational.h"
#include "copy.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include "flang/Common/float128.h"
-#include "flang/Runtime/descriptor.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/type-code.cpp b/flang-rt/lib/flang_rt/type-code.cpp
similarity index 98%
rename from flang/runtime/type-code.cpp
rename to flang-rt/lib/flang_rt/type-code.cpp
index d6948983bfe9f..432c7591520cb 100644
--- a/flang/runtime/type-code.cpp
+++ b/flang-rt/lib/flang_rt/type-code.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/type-code.cpp ---------------------------------------------===//
+//===-- lib/flang_rt/type-code.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/type-code.h"
+#include "flang-rt/type-code.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/type-info.cpp b/flang-rt/lib/flang_rt/type-info.cpp
similarity index 98%
rename from flang/runtime/type-info.cpp
rename to flang-rt/lib/flang_rt/type-info.cpp
index d4daa72aee6a1..e1859e4864ca1 100644
--- a/flang/runtime/type-info.cpp
+++ b/flang-rt/lib/flang_rt/type-info.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/type-info.cpp ---------------------------------------------===//
+//===-- lib/flang_rt/type-info.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "type-info.h"
-#include "terminator.h"
-#include "tools.h"
+#include "flang-rt/type-info.h"
+#include "flang-rt/terminator.h"
+#include "flang-rt/tools.h"
#include <cstdio>
namespace Fortran::runtime::typeInfo {
@@ -86,7 +86,7 @@ RT_API_ATTRS std::size_t Component::SizeInBytes(
} else if (category() == TypeCategory::Derived) {
const DerivedType *type{derivedType()};
return Descriptor::SizeInBytes(
- rank_, true, type ? type->LenParameters() : 0);
+ rank_, true, type ? type->LenParameters() : 0);
} else {
return Descriptor::SizeInBytes(rank_);
}
diff --git a/flang/runtime/unit-map.cpp b/flang-rt/lib/flang_rt/unit-map.cpp
similarity index 97%
rename from flang/runtime/unit-map.cpp
rename to flang-rt/lib/flang_rt/unit-map.cpp
index 684a9b9e20b97..0fda53ac071b2 100644
--- a/flang/runtime/unit-map.cpp
+++ b/flang-rt/lib/flang_rt/unit-map.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/unit-map.cpp ----------------------------------------------===//
+//===-- lib/flang_rt/unit-map.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/runtime/unit-map.h b/flang-rt/lib/flang_rt/unit-map.h
similarity index 92%
rename from flang/runtime/unit-map.h
rename to flang-rt/lib/flang_rt/unit-map.h
index 6f1e01bb1e64a..6f7eb692b970a 100644
--- a/flang/runtime/unit-map.h
+++ b/flang-rt/lib/flang_rt/unit-map.h
@@ -1,4 +1,4 @@
-//===-- runtime/unit-map.h --------------------------------------*- C++ -*-===//
+//===-- lib/flang_rt/unit-map.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.
@@ -9,13 +9,13 @@
// Maps Fortran unit numbers to their ExternalFileUnit instances.
// A simple hash table with forward-linked chains per bucket.
-#ifndef FORTRAN_RUNTIME_UNIT_MAP_H_
-#define FORTRAN_RUNTIME_UNIT_MAP_H_
+#ifndef FLANG_RT_UNIT_MAP_H_
+#define FLANG_RT_UNIT_MAP_H_
-#include "lock.h"
#include "unit.h"
+#include "flang-rt/lock.h"
+#include "flang-rt/memory.h"
#include "flang/Common/fast-int-set.h"
-#include "flang/Runtime/memory.h"
#include <cstdint>
#include <cstdlib>
@@ -100,4 +100,4 @@ class UnitMap {
int emergencyNewUnit_{maxNewUnits_}; // not recycled
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_UNIT_MAP_H_
+#endif /* FLANG_RT_UNIT_MAP_H_ */
diff --git a/flang/runtime/unit.cpp b/flang-rt/lib/flang_rt/unit.cpp
similarity index 99%
rename from flang/runtime/unit.cpp
rename to flang-rt/lib/flang_rt/unit.cpp
index 4aee8397d477e..f05c4b5236dd5 100644
--- a/flang/runtime/unit.cpp
+++ b/flang-rt/lib/flang_rt/unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/unit.cpp --------------------------------------------------===//
+//===-- lib/flang_rt/unit.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
#include "unit.h"
-#include "io-error.h"
-#include "lock.h"
-#include "tools.h"
+#include "flang-rt/io-error.h"
+#include "flang-rt/lock.h"
+#include "flang-rt/tools.h"
#include <limits>
#include <utility>
diff --git a/flang/runtime/unit.h b/flang-rt/lib/flang_rt/unit.h
similarity index 96%
rename from flang/runtime/unit.h
rename to flang-rt/lib/flang_rt/unit.h
index a3ea268681680..3b20c9870897a 100644
--- a/flang/runtime/unit.h
+++ b/flang-rt/lib/flang_rt/unit.h
@@ -1,4 +1,4 @@
-//===-- runtime/unit.h ------------------------------------------*- C++ -*-===//
+//===-- lib/flang_rt/unit.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.
@@ -8,21 +8,21 @@
// Fortran external I/O units
-#ifndef FORTRAN_RUNTIME_IO_UNIT_H_
-#define FORTRAN_RUNTIME_IO_UNIT_H_
-
-#include "buffer.h"
-#include "connection.h"
-#include "environment.h"
-#include "file.h"
-#include "format.h"
-#include "io-error.h"
-#include "io-stmt.h"
-#include "lock.h"
-#include "terminator.h"
+#ifndef FLANG_RT_UNIT_H_
+#define FLANG_RT_UNIT_H_
+
+#include "flang-rt/buffer.h"
+#include "flang-rt/connection.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/file.h"
+#include "flang-rt/format.h"
+#include "flang-rt/io-error.h"
+#include "flang-rt/io-stmt.h"
+#include "flang-rt/lock.h"
+#include "flang-rt/memory.h"
+#include "flang-rt/terminator.h"
#include "flang/Common/constexpr-bitset.h"
#include "flang/Common/optional.h"
-#include "flang/Runtime/memory.h"
#include <cstdlib>
#include <cstring>
#include <flang/Common/variant.h>
@@ -291,4 +291,4 @@ class ChildIo {
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_UNIT_H_
+#endif /* FLANG_RT_UNIT_H_ */
diff --git a/flang/runtime/utf.cpp b/flang-rt/lib/flang_rt/utf.cpp
similarity index 97%
rename from flang/runtime/utf.cpp
rename to flang-rt/lib/flang_rt/utf.cpp
index b09819cb2f736..dd74889c025c5 100644
--- a/flang/runtime/utf.cpp
+++ b/flang-rt/lib/flang_rt/utf.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/utf.cpp ---------------------------------------------------===//
+//===-- lib/flang_rt/utf.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "utf.h"
+#include "flang-rt/utf.h"
namespace Fortran::runtime {
diff --git a/flang/test/Driver/ctofortran.f90 b/flang-rt/test/Driver/ctofortran.f90
similarity index 100%
rename from flang/test/Driver/ctofortran.f90
rename to flang-rt/test/Driver/ctofortran.f90
diff --git a/flang/test/Driver/exec.f90 b/flang-rt/test/Driver/exec.f90
similarity index 100%
rename from flang/test/Driver/exec.f90
rename to flang-rt/test/Driver/exec.f90
diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang-rt/test/Runtime/no-cpp-dep.c
similarity index 100%
rename from flang/test/Runtime/no-cpp-dep.c
rename to flang-rt/test/Runtime/no-cpp-dep.c
diff --git a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp b/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
similarity index 98%
rename from flang/unittests/Evaluate/ISO-Fortran-binding.cpp
rename to flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
index 2884686b3f26e..d1417b715e959 100644
--- a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -1,5 +1,13 @@
+//===-- unittests/Evaluate/ISO-Fortran-binding.cpp --------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang-rt/descriptor.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
#include <type_traits>
diff --git a/flang/unittests/Evaluate/reshape.cpp b/flang-rt/unittests/Evaluate/reshape.cpp
similarity index 88%
rename from flang/unittests/Evaluate/reshape.cpp
rename to flang-rt/unittests/Evaluate/reshape.cpp
index 16cba15dcef60..a45e06ad0f69d 100644
--- a/flang/unittests/Evaluate/reshape.cpp
+++ b/flang-rt/unittests/Evaluate/reshape.cpp
@@ -1,4 +1,12 @@
-#include "flang/Runtime/descriptor.h"
+//===-- unittests/Evaluate/reshape.cpp --------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang-rt/descriptor.h"
#include "flang/Runtime/transformational.h"
#include "flang/Testing/testing.h"
#include <cinttypes>
diff --git a/flang/unittests/Runtime/AccessTest.cpp b/flang-rt/unittests/Runtime/AccessTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/AccessTest.cpp
rename to flang-rt/unittests/Runtime/AccessTest.cpp
index c2a2d7d398220..d431d0d19bd61 100644
--- a/flang/unittests/Runtime/AccessTest.cpp
+++ b/flang-rt/unittests/Runtime/AccessTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/AccessTest.cpp ----------------------------===//
+//===-- unittests/Runtime/AccessTest.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Allocatable.cpp b/flang-rt/unittests/Runtime/Allocatable.cpp
similarity index 97%
rename from flang/unittests/Runtime/Allocatable.cpp
rename to flang-rt/unittests/Runtime/Allocatable.cpp
index f15f26bfd9c57..b03003a93fe09 100644
--- a/flang/unittests/Runtime/Allocatable.cpp
+++ b/flang-rt/unittests/Runtime/Allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Allocatable.cpp--------- ---------*- C++-*-===//
+//===-- unittests/Runtime/Allocatable.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
#include "flang/Runtime/allocatable.h"
#include "gtest/gtest.h"
-#include "tools.h"
+#include "flang-rt/tools.h"
using namespace Fortran::runtime;
diff --git a/flang/unittests/Runtime/ArrayConstructor.cpp b/flang-rt/unittests/Runtime/ArrayConstructor.cpp
similarity index 97%
rename from flang/unittests/Runtime/ArrayConstructor.cpp
rename to flang-rt/unittests/Runtime/ArrayConstructor.cpp
index 53774a0eea07d..5c84cd162a293 100644
--- a/flang/unittests/Runtime/ArrayConstructor.cpp
+++ b/flang-rt/unittests/Runtime/ArrayConstructor.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/ArrayConstructor.cpp-------------*- C++ -*-===//
+//===-- unittests/Runtime/ArrayConstructor.cpp ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "tools.h"
+#include "gtest/gtest.h"
+#include "flang-rt/array-constructor.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/type-code.h"
#include "flang/Runtime/allocatable.h"
-#include "flang/Runtime/array-constructor.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/type-code.h"
#include <memory>
diff --git a/flang/unittests/Runtime/BufferTest.cpp b/flang-rt/unittests/Runtime/BufferTest.cpp
similarity index 97%
rename from flang/unittests/Runtime/BufferTest.cpp
rename to flang-rt/unittests/Runtime/BufferTest.cpp
index 0632324b25d22..7795a79593eb2 100644
--- a/flang/unittests/Runtime/BufferTest.cpp
+++ b/flang-rt/unittests/Runtime/BufferTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/BufferTest.cpp ------------------*- C++ -*-===//
+//===-- unittests/Runtime/BufferTest.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "../../runtime/buffer.h"
+#include "flang-rt/buffer.h"
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
#include <algorithm>
diff --git a/flang/unittests/Runtime/CUDA/Allocatable.cpp b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
similarity index 89%
rename from flang/unittests/Runtime/CUDA/Allocatable.cpp
rename to flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
index bdfa8f5cc3213..db6589990be18 100644
--- a/flang/unittests/Runtime/CUDA/Allocatable.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Allocatable.cpp ------------------*- C++-*-===//
+//===-- unittests/Runtime/CUDA/Allocatable.cpp ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,16 +7,16 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/allocatable.h"
+#include "cuda_runtime.h"
#include "gtest/gtest.h"
-#include "../../../runtime/terminator.h"
-#include "flang/Runtime/CUDA/allocator.h"
+#include "flang-rt/CUDA/allocator.h"
+#include "flang-rt/allocator-registry.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
-#include "flang/Runtime/allocator-registry.h"
#include "flang/Support/Fortran.h"
-#include "cuda_runtime.h"
-
using namespace Fortran::runtime;
using namespace Fortran::runtime::cuda;
diff --git a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
similarity index 91%
rename from flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
rename to flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 5ec122e4c5777..86c13d0dd290c 100644
--- a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/AllocatableCUF.cpp ---------------*- C++-*-===//
+//===-- unittests/Runtime/CUDA/AllocatorCUF.cpp -----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,16 +6,16 @@
//
//===----------------------------------------------------------------------===//
+#include "cuda_runtime.h"
#include "gtest/gtest.h"
-#include "../../../runtime/terminator.h"
-#include "flang/Runtime/CUDA/allocator.h"
+#include "flang-rt/CUDA/allocator.h"
+#include "flang-rt/allocator-registry.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
-#include "flang/Runtime/allocator-registry.h"
#include "flang/Support/Fortran.h"
-#include "cuda_runtime.h"
-
using namespace Fortran::runtime;
using namespace Fortran::runtime::cuda;
diff --git a/flang/unittests/Runtime/CUDA/Memory.cpp b/flang-rt/unittests/Runtime/CUDA/Memory.cpp
similarity index 92%
rename from flang/unittests/Runtime/CUDA/Memory.cpp
rename to flang-rt/unittests/Runtime/CUDA/Memory.cpp
index 61c9d1131ee56..32609795c0169 100644
--- a/flang/unittests/Runtime/CUDA/Memory.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Memory.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Memory.cpp -----------------------*- C++-*-===//
+//===-- unittests/Runtime/CUDA/Memory.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,18 +7,17 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/memory.h"
-#include "gtest/gtest.h"
-#include "../../../runtime/terminator.h"
+#include "cuda_runtime.h"
#include "../tools.h"
-#include "flang/Runtime/CUDA/allocator.h"
+#include "gtest/gtest.h"
+#include "flang-rt/CUDA/allocator.h"
+#include "flang-rt/allocator-registry.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
-#include "flang/Runtime/allocator-registry.h"
#include "flang/Support/Fortran.h"
-#include "cuda_runtime.h"
-
using namespace Fortran::runtime;
using namespace Fortran::runtime::cuda;
diff --git a/flang/unittests/Runtime/CharacterTest.cpp b/flang-rt/unittests/Runtime/CharacterTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/CharacterTest.cpp
rename to flang-rt/unittests/Runtime/CharacterTest.cpp
index d462c9120fd8c..696ab6b06e9e7 100644
--- a/flang/unittests/Runtime/CharacterTest.cpp
+++ b/flang-rt/unittests/Runtime/CharacterTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/CharacterTest.cpp ---------------*- C++ -*-===//
+//===-- unittests/Runtime/CharacterTest.cpp ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +11,7 @@
#include "flang/Runtime/character.h"
#include "gtest/gtest.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
#include <cstring>
#include <functional>
#include <tuple>
diff --git a/flang/unittests/Runtime/CommandTest.cpp b/flang-rt/unittests/Runtime/CommandTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/CommandTest.cpp
rename to flang-rt/unittests/Runtime/CommandTest.cpp
index ecb325330f1ad..a34c329750f39 100644
--- a/flang/unittests/Runtime/CommandTest.cpp
+++ b/flang-rt/unittests/Runtime/CommandTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/CommandTest.cpp ---------------------------===//
+//===-- unittests/Runtime/CommandTest.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
#include "flang/Runtime/command.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
#include "flang/Runtime/execute.h"
#include "flang/Runtime/extensions.h"
#include "flang/Runtime/main.h"
diff --git a/flang/unittests/Runtime/Complex.cpp b/flang-rt/unittests/Runtime/Complex.cpp
similarity index 98%
rename from flang/unittests/Runtime/Complex.cpp
rename to flang-rt/unittests/Runtime/Complex.cpp
index d714da24dc4e5..d7e5f55414fe2 100644
--- a/flang/unittests/Runtime/Complex.cpp
+++ b/flang-rt/unittests/Runtime/Complex.cpp
@@ -1,10 +1,11 @@
-//===-- flang/unittests/Runtime/Complex.cpp ---------------------*- C++ -*-===//
+//===-- unittests/Runtime/Complex.cpp ---------------------------*- 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
//
//===----------------------------------------------------------------------===//
+
#include "gmock/gmock.h"
#include "gtest/gtest-matchers.h"
#include <limits>
diff --git a/flang/unittests/Runtime/CrashHandlerFixture.cpp b/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
similarity index 92%
rename from flang/unittests/Runtime/CrashHandlerFixture.cpp
rename to flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
index 811603337e660..939cc62c433f0 100644
--- a/flang/unittests/Runtime/CrashHandlerFixture.cpp
+++ b/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
@@ -1,12 +1,13 @@
-//===-- flang/unittests/Runtime/CrashHandlerFixture.cpp ---------*- C++ -*-===//
+//===-- unittests/Runtime/CrashHandlerFixture.cpp ---------------*- 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
//
//===----------------------------------------------------------------------===//
+
#include "CrashHandlerFixture.h"
-#include "../../runtime/terminator.h"
+#include "flang-rt/terminator.h"
#include <cstdarg>
#include <cstdlib>
diff --git a/flang/unittests/Runtime/CrashHandlerFixture.h b/flang-rt/unittests/Runtime/CrashHandlerFixture.h
similarity index 70%
rename from flang/unittests/Runtime/CrashHandlerFixture.h
rename to flang-rt/unittests/Runtime/CrashHandlerFixture.h
index fe0ee0da5204e..74531d1e728f4 100644
--- a/flang/unittests/Runtime/CrashHandlerFixture.h
+++ b/flang-rt/unittests/Runtime/CrashHandlerFixture.h
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/CrashHandlerFixture.h -----------*- C++ -*-===//
+//===-- unittests/Runtime/CrashHandlerFixture.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.
@@ -10,12 +10,13 @@
/// with expected message.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_FLANG_UNITTESTS_RUNTIMEGTEST_CRASHHANDLERFIXTURE_H
-#define LLVM_FLANG_UNITTESTS_RUNTIMEGTEST_CRASHHANDLERFIXTURE_H
+
+#ifndef FLANG_RT_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_
+#define FLANG_RT_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_
#include <gtest/gtest.h>
struct CrashHandlerFixture : testing::Test {
void SetUp();
};
-#endif
+#endif /* FLANG_RT_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_ */
diff --git a/flang/unittests/Runtime/Derived.cpp b/flang-rt/unittests/Runtime/Derived.cpp
similarity index 94%
rename from flang/unittests/Runtime/Derived.cpp
rename to flang-rt/unittests/Runtime/Derived.cpp
index 019d5e8309e4a..2f45dfb80f7fd 100644
--- a/flang/unittests/Runtime/Derived.cpp
+++ b/flang-rt/unittests/Runtime/Derived.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Pointer.cpp--------- -------------*- C++-*-===//
+//===-- unittests/Runtime/Derived.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "gtest/gtest.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/tools.h"
#include "flang/Runtime/derived-api.h"
-#include "flang/Runtime/descriptor.h"
using namespace Fortran::runtime;
diff --git a/flang/unittests/Runtime/ExternalIOTest.cpp b/flang-rt/unittests/Runtime/ExternalIOTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/ExternalIOTest.cpp
rename to flang-rt/unittests/Runtime/ExternalIOTest.cpp
index b9407b5e7a591..a5481e071916d 100644
--- a/flang/unittests/Runtime/ExternalIOTest.cpp
+++ b/flang-rt/unittests/Runtime/ExternalIOTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/RuntimeGTest/ExternalIOTest.cpp ---------*- C++ -*-===//
+//===-- unittests/Runtime/ExternalIOTest.cpp --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
diff --git a/flang/unittests/Runtime/Format.cpp b/flang-rt/unittests/Runtime/Format.cpp
similarity index 96%
rename from flang/unittests/Runtime/Format.cpp
rename to flang-rt/unittests/Runtime/Format.cpp
index 01803c628de26..83650e0f999ac 100644
--- a/flang/unittests/Runtime/Format.cpp
+++ b/flang-rt/unittests/Runtime/Format.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Format.cpp ----------------------*- C++ -*-===//
+//===-- unittests/Runtime/Format.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "../runtime/connection.h"
-#include "../runtime/format-implementation.h"
-#include "../runtime/io-error.h"
+#include "flang-rt/connection.h"
+#include "flang-rt/format-implementation.h"
+#include "flang-rt/io-error.h"
#include <optional>
#include <string>
#include <tuple>
diff --git a/flang/unittests/Runtime/Inquiry.cpp b/flang-rt/unittests/Runtime/Inquiry.cpp
similarity index 98%
rename from flang/unittests/Runtime/Inquiry.cpp
rename to flang-rt/unittests/Runtime/Inquiry.cpp
index 3b523e992a317..f6097484bd481 100644
--- a/flang/unittests/Runtime/Inquiry.cpp
+++ b/flang-rt/unittests/Runtime/Inquiry.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Inquiry.cpp -------------------------------===//
+//===-- unittests/Runtime/Inquiry.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/inquiry.h"
-#include "gtest/gtest.h"
#include "tools.h"
-#include "flang/Runtime/type-code.h"
+#include "gtest/gtest.h"
+#include "flang-rt/type-code.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/flang/unittests/Runtime/ListInputTest.cpp b/flang-rt/unittests/Runtime/ListInputTest.cpp
similarity index 98%
rename from flang/unittests/Runtime/ListInputTest.cpp
rename to flang-rt/unittests/Runtime/ListInputTest.cpp
index 38c758b7ef966..0c6c59d6a325e 100644
--- a/flang/unittests/Runtime/ListInputTest.cpp
+++ b/flang-rt/unittests/Runtime/ListInputTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/ListInputTest.cpp ---------------*- C++ -*-===//
+//===-- unittests/Runtime/ListInputTest.cpp ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "../../runtime/io-error.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/io-error.h"
#include "flang/Runtime/io-api-consts.h"
using namespace Fortran::runtime;
diff --git a/flang/unittests/Runtime/LogicalFormatTest.cpp b/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
similarity index 95%
rename from flang/unittests/Runtime/LogicalFormatTest.cpp
rename to flang-rt/unittests/Runtime/LogicalFormatTest.cpp
index 26c9374be1338..07f62ee02fc66 100644
--- a/flang/unittests/Runtime/LogicalFormatTest.cpp
+++ b/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/LogicalFormatTest.cpp -----------*- C++ -*-===//
+//===-- unittests/Runtime/LogicalFormatTest.cpp -----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include <algorithm>
#include <array>
diff --git a/flang/unittests/Runtime/Matmul.cpp b/flang-rt/unittests/Runtime/Matmul.cpp
similarity index 98%
rename from flang/unittests/Runtime/Matmul.cpp
rename to flang-rt/unittests/Runtime/Matmul.cpp
index c3fed9b972df2..28bf2327da949 100644
--- a/flang/unittests/Runtime/Matmul.cpp
+++ b/flang-rt/unittests/Runtime/Matmul.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Matmul.cpp--------- -------------*- C++ -*-===//
+//===-- unittests/Runtime/Matmul.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/matmul.h"
-#include "gtest/gtest.h"
#include "tools.h"
+#include "gtest/gtest.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/type-code.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/flang/unittests/Runtime/MatmulTranspose.cpp b/flang-rt/unittests/Runtime/MatmulTranspose.cpp
similarity index 98%
rename from flang/unittests/Runtime/MatmulTranspose.cpp
rename to flang-rt/unittests/Runtime/MatmulTranspose.cpp
index c582e945dc7c9..b06afa29ce28e 100644
--- a/flang/unittests/Runtime/MatmulTranspose.cpp
+++ b/flang-rt/unittests/Runtime/MatmulTranspose.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/MatmulTranspose.cpp -------------*- C++ -*-===//
+//===-- unittests/Runtime/MatmulTranspose.cpp -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "tools.h"
+#include "gtest/gtest.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/matmul-transpose.h"
-#include "flang/Runtime/type-code.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/flang/unittests/Runtime/MiscIntrinsic.cpp b/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
similarity index 96%
rename from flang/unittests/Runtime/MiscIntrinsic.cpp
rename to flang-rt/unittests/Runtime/MiscIntrinsic.cpp
index 7e19ed250bdc0..61b05b31f45a9 100644
--- a/flang/unittests/Runtime/MiscIntrinsic.cpp
+++ b/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/MiscIntrinsic.cpp ---------------*- C++ -*-===//
+//===-- unittests/Runtime/MiscIntrinsic.cpp ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "tools.h"
-#include "flang/Runtime//misc-intrinsic.h"
+#include "gtest/gtest.h"
+#include "flang-rt/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/misc-intrinsic.h"
using namespace Fortran::runtime;
diff --git a/flang/unittests/Runtime/Namelist.cpp b/flang-rt/unittests/Runtime/Namelist.cpp
similarity index 99%
rename from flang/unittests/Runtime/Namelist.cpp
rename to flang-rt/unittests/Runtime/Namelist.cpp
index 0a28f3590b86e..d48a0273bf556 100644
--- a/flang/unittests/Runtime/Namelist.cpp
+++ b/flang-rt/unittests/Runtime/Namelist.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Namelist.cpp --------------------*- C++ -*-===//
+//===-- unittests/Runtime/Namelist.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "../../runtime/namelist.h"
+#include "flang-rt/namelist.h"
#include "CrashHandlerFixture.h"
#include "tools.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include <algorithm>
#include <cinttypes>
diff --git a/flang/unittests/Runtime/Numeric.cpp b/flang-rt/unittests/Runtime/Numeric.cpp
similarity index 99%
rename from flang/unittests/Runtime/Numeric.cpp
rename to flang-rt/unittests/Runtime/Numeric.cpp
index 29ebbc8ad7aa7..4baad3fc9ad0e 100644
--- a/flang/unittests/Runtime/Numeric.cpp
+++ b/flang-rt/unittests/Runtime/Numeric.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Numeric.cpp ---------------------*- C++ -*-===//
+//===-- unittests/Runtime/Numeric.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/NumericalFormatTest.cpp b/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/NumericalFormatTest.cpp
rename to flang-rt/unittests/Runtime/NumericalFormatTest.cpp
index 274498b8e8695..a86e6b807fc53 100644
--- a/flang/unittests/Runtime/NumericalFormatTest.cpp
+++ b/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/NumericalFormatTest.cpp ---------*- C++ -*-===//
+//===-- unittests/Runtime/NumericalFormatTest.cpp ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include <algorithm>
#include <array>
diff --git a/flang/unittests/Runtime/Pointer.cpp b/flang-rt/unittests/Runtime/Pointer.cpp
similarity index 96%
rename from flang/unittests/Runtime/Pointer.cpp
rename to flang-rt/unittests/Runtime/Pointer.cpp
index 4ce13ebc50a56..13f1922e6c5c3 100644
--- a/flang/unittests/Runtime/Pointer.cpp
+++ b/flang-rt/unittests/Runtime/Pointer.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Pointer.cpp--------- -------------*- C++-*-===//
+//===-- unittests/Runtime/Pointer.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,8 +8,8 @@
#include "flang/Runtime/pointer.h"
#include "gtest/gtest.h"
-#include "tools.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/tools.h"
using namespace Fortran::runtime;
diff --git a/flang/unittests/Runtime/Ragged.cpp b/flang-rt/unittests/Runtime/Ragged.cpp
similarity index 94%
rename from flang/unittests/Runtime/Ragged.cpp
rename to flang-rt/unittests/Runtime/Ragged.cpp
index 5049bc83405f1..feadd032f59bd 100644
--- a/flang/unittests/Runtime/Ragged.cpp
+++ b/flang-rt/unittests/Runtime/Ragged.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Ragged.cpp ----------------------*- C++ -*-===//
+//===-- unittests/Runtime/Ragged.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Random.cpp b/flang-rt/unittests/Runtime/Random.cpp
similarity index 92%
rename from flang/unittests/Runtime/Random.cpp
rename to flang-rt/unittests/Runtime/Random.cpp
index cb739b9451429..dba480cffa9c9 100644
--- a/flang/unittests/Runtime/Random.cpp
+++ b/flang-rt/unittests/Runtime/Random.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Random.cpp ----------------------*- C++ -*-===//
+//===-- unittests/Runtime/Random.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime//random.h"
+#include "flang/Runtime/random.h"
#include "gtest/gtest.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/type-code.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/type-code.h"
#include <cmath>
using namespace Fortran::runtime;
diff --git a/flang/unittests/Runtime/Reduction.cpp b/flang-rt/unittests/Runtime/Reduction.cpp
similarity index 99%
rename from flang/unittests/Runtime/Reduction.cpp
rename to flang-rt/unittests/Runtime/Reduction.cpp
index 29675399abf5c..cb84512639933 100644
--- a/flang/unittests/Runtime/Reduction.cpp
+++ b/flang-rt/unittests/Runtime/Reduction.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Reductions.cpp ----------------------------===//
+//===-- unittests/Runtime/Reduction.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,14 +7,14 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/reduction.h"
-#include "gtest/gtest.h"
#include "tools.h"
+#include "gtest/gtest.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/type-code.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/reduce.h"
-#include "flang/Runtime/type-code.h"
#include <cstdint>
#include <cstring>
#include <string>
diff --git a/flang/unittests/Runtime/RuntimeCrashTest.cpp b/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
similarity index 98%
rename from flang/unittests/Runtime/RuntimeCrashTest.cpp
rename to flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
index 72a0b290cf864..23a60d98bf6ad 100644
--- a/flang/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/CrashHandlerFixture.cpp ---------*- C++ -*-===//
+//===-- unittests/Runtime/RuntimeCrashTest.cpp ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
#include "tools.h"
-#include "../../runtime/terminator.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/io-api-consts.h"
#include "flang/Runtime/transformational.h"
#include <gtest/gtest.h>
diff --git a/flang/unittests/Runtime/Stop.cpp b/flang-rt/unittests/Runtime/Stop.cpp
similarity index 96%
rename from flang/unittests/Runtime/Stop.cpp
rename to flang-rt/unittests/Runtime/Stop.cpp
index b13602eaee5ea..102fecd1afb22 100644
--- a/flang/unittests/Runtime/Stop.cpp
+++ b/flang-rt/unittests/Runtime/Stop.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Stop.cpp ----------------------------------===//
+//===-- unittests/Runtime/Stop.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,9 +9,10 @@
/// Test runtime API for STOP statement and runtime API to kill the program.
//
//===----------------------------------------------------------------------===//
+
#include "flang/Runtime/stop.h"
#include "CrashHandlerFixture.h"
-#include "../../runtime/environment.h"
+#include "flang-rt/environment.h"
#include <cstdlib>
#include <gtest/gtest.h>
diff --git a/flang/unittests/Runtime/Support.cpp b/flang-rt/unittests/Runtime/Support.cpp
similarity index 96%
rename from flang/unittests/Runtime/Support.cpp
rename to flang-rt/unittests/Runtime/Support.cpp
index 8c8de73b5b979..0159bd74aa60c 100644
--- a/flang/unittests/Runtime/Support.cpp
+++ b/flang-rt/unittests/Runtime/Support.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Support.cpp ----------------------*- C++-*-===//
+//===-- unittests/Runtime/Support.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/support.h"
-#include "gtest/gtest.h"
#include "tools.h"
-#include "flang/Runtime/descriptor.h"
+#include "gtest/gtest.h"
+#include "flang-rt/descriptor.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/flang/unittests/Runtime/TemporaryStack.cpp b/flang-rt/unittests/Runtime/TemporaryStack.cpp
similarity index 98%
rename from flang/unittests/Runtime/TemporaryStack.cpp
rename to flang-rt/unittests/Runtime/TemporaryStack.cpp
index 4f701e09b2945..d5cb9e5bfb9da 100644
--- a/flang/unittests/Runtime/TemporaryStack.cpp
+++ b/flang-rt/unittests/Runtime/TemporaryStack.cpp
@@ -1,4 +1,4 @@
-//===--- flang/unittests/Runtime/TemporaryStack.cpp -------------*- C++ -*-===//
+//===-- unittests/Runtime/TemporaryStack.cpp --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "gtest/gtest.h"
-#include "tools.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/tools.h"
+#include "flang-rt/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/temporary-stack.h"
-#include "flang/Runtime/type-code.h"
#include <vector>
using namespace Fortran::runtime;
diff --git a/flang/unittests/Runtime/Time.cpp b/flang-rt/unittests/Runtime/Time.cpp
similarity index 98%
rename from flang/unittests/Runtime/Time.cpp
rename to flang-rt/unittests/Runtime/Time.cpp
index 9309d7b1ceffa..548c0834e34a3 100644
--- a/flang/unittests/Runtime/Time.cpp
+++ b/flang-rt/unittests/Runtime/Time.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Time.cpp ----------------------------===//
+//===-- unittests/Runtime/Time.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang/unittests/Runtime/Transformational.cpp b/flang-rt/unittests/Runtime/Transformational.cpp
similarity index 99%
rename from flang/unittests/Runtime/Transformational.cpp
rename to flang-rt/unittests/Runtime/Transformational.cpp
index 1d84b7e23779a..8805613738a60 100644
--- a/flang/unittests/Runtime/Transformational.cpp
+++ b/flang-rt/unittests/Runtime/Transformational.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/Transformational.cpp ----------------------===//
+//===-- unittests/Runtime/Transformational.cpp ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/transformational.h"
-#include "gtest/gtest.h"
#include "tools.h"
+#include "gtest/gtest.h"
+#include "flang-rt/type-code.h"
#include "flang/Common/float128.h"
-#include "flang/Runtime/type-code.h"
#include <vector>
using namespace Fortran::runtime;
diff --git a/flang/unittests/Runtime/tools.h b/flang-rt/unittests/Runtime/tools.h
similarity index 85%
rename from flang/unittests/Runtime/tools.h
rename to flang-rt/unittests/Runtime/tools.h
index 0347edace5c05..ff39d7ccb2a24 100644
--- a/flang/unittests/Runtime/tools.h
+++ b/flang-rt/unittests/Runtime/tools.h
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Runtime/tools.h -------------------------*- C++ -*-===//
+//===-- unittests/Runtime/tools.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.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
-#define FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
+#ifndef FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_
+#define FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_
#include "gtest/gtest.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/type-code.h"
#include <cstdint>
#include <cstring>
#include <vector>
@@ -54,4 +54,4 @@ static OwningPtr<Descriptor> MakeArray(const std::vector<int> &shape,
}
} // namespace Fortran::runtime
-#endif // FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
+#endif /* FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_ */
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 8a8b8bfa73b00..0044779da011d 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -23,6 +23,7 @@ if (LLVM_ENABLE_EH)
endif()
set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang-rt")
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed. \
diff --git a/flang/include/flang/Runtime/allocatable.h b/flang/include/flang/Runtime/allocatable.h
index 58061d9862095..714d85ec073c6 100644
--- a/flang/include/flang/Runtime/allocatable.h
+++ b/flang/include/flang/Runtime/allocatable.h
@@ -11,7 +11,7 @@
#ifndef FORTRAN_RUNTIME_ALLOCATABLE_H_
#define FORTRAN_RUNTIME_ALLOCATABLE_H_
-#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
namespace Fortran::runtime {
diff --git a/flang/include/flang/Runtime/descriptor-consts.h b/flang/include/flang/Runtime/descriptor-consts.h
index abcdbc4a12002..acd7bc5ddbdef 100644
--- a/flang/include/flang/Runtime/descriptor-consts.h
+++ b/flang/include/flang/Runtime/descriptor-consts.h
@@ -9,6 +9,7 @@
#ifndef FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_
#define FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_
+#include "flang/Common/Fortran-consts.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/api-attrs.h"
#include <cstddef>
@@ -29,6 +30,7 @@ class DerivedType;
namespace Fortran::runtime {
class Descriptor;
using SubscriptValue = ISO::CFI_index_t;
+using common::TypeCategory;
/// Returns size in bytes of the descriptor (not the data)
/// This must be at least as large as the largest descriptor of any target
diff --git a/flang/include/flang/Runtime/pointer.h b/flang/include/flang/Runtime/pointer.h
index 704144f08114f..67c4fe266f55c 100644
--- a/flang/include/flang/Runtime/pointer.h
+++ b/flang/include/flang/Runtime/pointer.h
@@ -12,7 +12,7 @@
#ifndef FORTRAN_RUNTIME_POINTER_H_
#define FORTRAN_RUNTIME_POINTER_H_
-#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 3e32daba52a81..2bdcfca4cba85 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -16,6 +16,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_CXX_EXTENSIONS OFF)
set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
+ set(FLANG_RT_SOURCE_DIR "${FLANG_SOURCE_DIR}/../flang-rt")
set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
@@ -57,8 +58,31 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
REAL(16) is mapped to __float128, or libm for targets where REAL(16) \
is mapped to long double, etc."
)
+
+ option(FLANG_CUF_RUNTIME
+ "Compile CUDA Fortran runtime sources" OFF)
+ if (FLANG_CUF_RUNTIME)
+ find_package(CUDAToolkit REQUIRED)
+ endif()
endif()
+# Runtime files are in Flang-RT's source dir.
+function (runtime_source_files outvar)
+ cmake_parse_arguments(ARG "" "SUBDIR" "" ${ARGN})
+
+ set(new_sources "")
+ foreach (source IN LISTS "${outvar}")
+ set(new_source "${FLANG_RT_SOURCE_DIR}/lib/flang_rt")
+ cmake_path(APPEND new_source "${ARG_SUBDIR}")
+ cmake_path(APPEND new_source "${source}")
+ list(APPEND new_sources "${new_source}")
+ endforeach ()
+ set("${outvar}" ${new_sources} PARENT_SCOPE)
+endfunction ()
+
+# Runtime includes are in Flang-RT's source dir.
+include_directories(BEFORE "${FLANG_RT_SOURCE_DIR}/include")
+
# function checks
find_package(Backtrace)
set(HAVE_BACKTRACE ${Backtrace_FOUND})
@@ -94,7 +118,7 @@ else()
set(NO_LTO_FLAGS "")
endif()
-configure_file(config.h.cmake config.h)
+configure_file("${FLANG_RT_SOURCE_DIR}/cmake/config.h.cmake.in" config.h)
# include_directories is used here instead of target_include_directories
# because add_flang_library creates multiple objects (STATIC/SHARED, OBJECT)
# with different names
@@ -236,6 +260,7 @@ set(supported_files
utf.cpp
)
+runtime_source_files(supported_files)
enable_cuda_compilation(flang_rt "${supported_files}")
enable_omp_offload_compilation("${supported_files}")
@@ -269,6 +294,9 @@ if (NOT TARGET FortranFloat128Math)
endif()
endif()
+runtime_source_files(sources)
+
+
if (NOT DEFINED MSVC)
add_flang_library(flang_rt
${sources}
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt
index 744df95267e6f..86a76658042eb 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/flang/runtime/CUDA/CMakeLists.txt
@@ -13,7 +13,7 @@ include_directories(${CUDAToolkit_INCLUDE_DIRS})
# added to the library name.
set(CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR})
-add_flang_library(${CUFRT_LIBNAME}
+set(sources
allocator.cpp
allocatable.cpp
descriptor.cpp
@@ -22,6 +22,11 @@ add_flang_library(${CUFRT_LIBNAME}
memory.cpp
registration.cpp
)
+runtime_source_files(sources SUBDIR "CUDA")
+
+add_flang_library(${CUFRT_LIBNAME}
+ ${sources}
+)
if (BUILD_SHARED_LIBS)
set(CUDA_RT_TARGET CUDA::cudart)
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt
index d65193be05ab5..2cd7e46c80407 100644
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ b/flang/runtime/Float128Math/CMakeLists.txt
@@ -17,56 +17,56 @@
include(CheckLibraryExists)
set(sources
- acos.cpp
- acosh.cpp
- asin.cpp
- asinh.cpp
- atan.cpp
- atan2.cpp
- atanh.cpp
- ceil.cpp
- complex-math.c
- cos.cpp
- cosh.cpp
- erf.cpp
- erfc.cpp
- exp.cpp
- exponent.cpp
- floor.cpp
- fma.cpp
- fraction.cpp
- hypot.cpp
- j0.cpp
- j1.cpp
- jn.cpp
- lgamma.cpp
- llround.cpp
- log.cpp
- log10.cpp
- lround.cpp
- mod-real.cpp
- modulo-real.cpp
- nearest.cpp
- nearbyint.cpp
- norm2.cpp
- pow.cpp
- random.cpp
- remainder.cpp
- round.cpp
- rrspacing.cpp
- scale.cpp
- set-exponent.cpp
- sin.cpp
- sinh.cpp
- spacing.cpp
- sqrt.cpp
- tan.cpp
- tanh.cpp
- tgamma.cpp
- trunc.cpp
- y0.cpp
- y1.cpp
- yn.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/acos.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/acosh.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/asin.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/asinh.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/atan.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/atan2.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/atanh.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/ceil.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/complex-math.c
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/cos.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/cosh.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/erf.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/erfc.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/exp.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/exponent.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/floor.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/fma.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/fraction.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/hypot.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/j0.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/j1.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/jn.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/lgamma.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/llround.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/log.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/log10.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/lround.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/mod-real.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/modulo-real.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/nearest.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/nearbyint.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/norm2.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/pow.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/random.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/remainder.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/round.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/rrspacing.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/scale.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/set-exponent.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/sin.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/sinh.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/spacing.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/sqrt.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/tan.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/tanh.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/tgamma.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/trunc.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/y0.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/y1.cpp
+ ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/yn.cpp
)
include_directories(AFTER "${CMAKE_CURRENT_SOURCE_DIR}/..")
diff --git a/flang/runtime/config.h.cmake b/flang/runtime/config.h.cmake
deleted file mode 100644
index a2271be77b8c6..0000000000000
--- a/flang/runtime/config.h.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef FORTRAN_RUNTIME_CONFIG_H
-#define FORTRAN_RUNTIME_CONFIG_H
-
-/* Define to 1 if you have the `strerror_r' function. */
-#cmakedefine01 HAVE_STRERROR_R
-
-/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you
- don't. */
-#cmakedefine01 HAVE_DECL_STRERROR_S
-
-/* Define to 1 if you have the `backtrace' function. */
-#cmakedefine HAVE_BACKTRACE ${HAVE_BACKTRACE}
-
-#define BACKTRACE_HEADER <${BACKTRACE_HEADER}>
-
-#endif
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index 7b0f85638f14e..b946d39fad54b 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -12,6 +12,8 @@ endif()
add_custom_target(FlangUnitTests)
set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests")
+include_directories("${FLANG_RT_SOURCE_DIR}/include")
+
function(add_flang_unittest_offload_properties target)
# Do not apply runtime properties if not even compiling the runtime.
if (NOT FLANG_INCLUDE_RUNTIME)
@@ -61,7 +63,13 @@ function(add_flang_nongtest_unittest test_name)
set(suffix .test)
endif()
- add_executable(${test_name}${suffix} ${test_name}.cpp)
+ # Sources for runtime tests are in Flang-RT.
+ set(test_filepath "${FLANG_RT_SOURCE_DIR}/unittests/Evaluate/${test_name}.cpp")
+ if (NOT EXISTS "${test_filepath}")
+ set(test_filepath "${test_name}.cpp")
+ endif ()
+
+ add_executable(${test_name}${suffix} "${test_filepath}")
set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Flang/Tests/Unit")
if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
diff --git a/flang/unittests/Runtime/CMakeLists.txt b/flang/unittests/Runtime/CMakeLists.txt
index a60b43d422878..2e87391402744 100644
--- a/flang/unittests/Runtime/CMakeLists.txt
+++ b/flang/unittests/Runtime/CMakeLists.txt
@@ -1,34 +1,34 @@
add_flang_unittest(FlangRuntimeTests
- AccessTest.cpp
- Allocatable.cpp
- ArrayConstructor.cpp
- BufferTest.cpp
- CharacterTest.cpp
- CommandTest.cpp
- Complex.cpp
- CrashHandlerFixture.cpp
- Derived.cpp
- ExternalIOTest.cpp
- Format.cpp
- Inquiry.cpp
- ListInputTest.cpp
- LogicalFormatTest.cpp
- Matmul.cpp
- MatmulTranspose.cpp
- MiscIntrinsic.cpp
- Namelist.cpp
- Numeric.cpp
- NumericalFormatTest.cpp
- Pointer.cpp
- Ragged.cpp
- Random.cpp
- Reduction.cpp
- RuntimeCrashTest.cpp
- Stop.cpp
- Support.cpp
- Time.cpp
- TemporaryStack.cpp
- Transformational.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/AccessTest.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Allocatable.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/ArrayConstructor.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/BufferTest.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/CharacterTest.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/CommandTest.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Complex.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/CrashHandlerFixture.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Derived.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/ExternalIOTest.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Format.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Inquiry.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/ListInputTest.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/LogicalFormatTest.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Matmul.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/MatmulTranspose.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/MiscIntrinsic.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Namelist.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Numeric.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/NumericalFormatTest.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Pointer.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Ragged.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Random.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Reduction.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/RuntimeCrashTest.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Stop.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Support.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Time.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/TemporaryStack.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/Transformational.cpp
)
target_link_libraries(FlangRuntimeTests
diff --git a/flang/unittests/Runtime/CUDA/CMakeLists.txt b/flang/unittests/Runtime/CUDA/CMakeLists.txt
index 38888e32e6ed8..762df4b460107 100644
--- a/flang/unittests/Runtime/CUDA/CMakeLists.txt
+++ b/flang/unittests/Runtime/CUDA/CMakeLists.txt
@@ -1,9 +1,9 @@
if (FLANG_CUF_RUNTIME)
add_flang_unittest(FlangCufRuntimeTests
- Allocatable.cpp
- AllocatorCUF.cpp
- Memory.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/CUDA/Allocatable.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/CUDA/AllocatorCUF.cpp
+ ${FLANG_RT_SOURCE_DIR}/unittests/Runtime/CUDA/Memory.cpp
)
if (BUILD_SHARED_LIBS)
>From f67081627ea71065635f5dd84172bcd68904f4f6 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 24 Jan 2025 16:50:07 +0100
Subject: [PATCH 07/41] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt
---
clang/lib/Driver/ToolChains/Flang.cpp | 14 +-
flang-rt/.clang-tidy | 2 +
flang-rt/CMakeLists.txt | 248 ++++++++++++++++++
flang-rt/CODE_OWNERS.TXT | 14 +
flang-rt/LICENSE.TXT | 234 +++++++++++++++++
flang-rt/README.md | 188 +++++++++++++
flang-rt/cmake/modules/AddFlangRT.cmake | 186 +++++++++++++
.../cmake/modules/AddFlangRTOffload.cmake | 101 +++++++
flang-rt/cmake/modules/GetToolchainDirs.cmake | 125 +++++++++
flang-rt/lib/CMakeLists.txt | 18 ++
.../lib/FortranFloat128Math/CMakeLists.txt | 136 ++++++++++
flang-rt/lib/Testing/CMakeLists.txt | 20 ++
flang-rt/lib/flang_rt/CMakeLists.txt | 213 +++++++++++++++
flang-rt/lib/flang_rt/CUDA/CMakeLists.txt | 33 +++
flang-rt/lib/flang_rt/io-api-minimal.cpp | 2 +-
flang-rt/test/CMakeLists.txt | 59 +++++
flang-rt/test/Driver/ctofortran.f90 | 29 +-
flang-rt/test/Driver/exec.f90 | 8 +-
flang-rt/test/NonGtestUnit/lit.cfg.py | 22 ++
flang-rt/test/NonGtestUnit/lit.site.cfg.py.in | 14 +
flang-rt/test/Runtime/no-cpp-dep.c | 5 +-
flang-rt/test/Unit/lit.cfg.py | 21 ++
flang-rt/test/Unit/lit.site.cfg.py.in | 15 ++
flang-rt/test/lit.cfg.py | 102 +++++++
flang-rt/test/lit.site.cfg.py.in | 19 ++
flang-rt/unittests/CMakeLists.txt | 111 ++++++++
flang-rt/unittests/Evaluate/CMakeLists.txt | 21 ++
flang-rt/unittests/Runtime/CMakeLists.txt | 48 ++++
.../unittests/Runtime/CUDA/CMakeLists.txt | 18 ++
flang/CMakeLists.txt | 53 ++--
flang/cmake/modules/FlangCommon.cmake | 43 +++
flang/docs/GettingStarted.md | 108 ++++----
flang/docs/ReleaseNotes.md | 8 +-
flang/module/iso_fortran_env_impl.f90 | 2 +-
flang/test/lit.cfg.py | 20 --
flang/test/lit.site.cfg.py.in | 3 -
llvm/CMakeLists.txt | 8 +-
.../modules/LLVMExternalProjectUtils.cmake | 16 +-
llvm/projects/CMakeLists.txt | 4 +-
llvm/runtimes/CMakeLists.txt | 25 +-
runtimes/CMakeLists.txt | 2 +-
41 files changed, 2169 insertions(+), 149 deletions(-)
create mode 100644 flang-rt/.clang-tidy
create mode 100644 flang-rt/CMakeLists.txt
create mode 100644 flang-rt/CODE_OWNERS.TXT
create mode 100644 flang-rt/LICENSE.TXT
create mode 100644 flang-rt/README.md
create mode 100644 flang-rt/cmake/modules/AddFlangRT.cmake
create mode 100644 flang-rt/cmake/modules/AddFlangRTOffload.cmake
create mode 100644 flang-rt/cmake/modules/GetToolchainDirs.cmake
create mode 100644 flang-rt/lib/CMakeLists.txt
create mode 100644 flang-rt/lib/FortranFloat128Math/CMakeLists.txt
create mode 100644 flang-rt/lib/Testing/CMakeLists.txt
create mode 100644 flang-rt/lib/flang_rt/CMakeLists.txt
create mode 100644 flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
create mode 100644 flang-rt/test/CMakeLists.txt
create mode 100644 flang-rt/test/NonGtestUnit/lit.cfg.py
create mode 100644 flang-rt/test/NonGtestUnit/lit.site.cfg.py.in
create mode 100644 flang-rt/test/Unit/lit.cfg.py
create mode 100644 flang-rt/test/Unit/lit.site.cfg.py.in
create mode 100644 flang-rt/test/lit.cfg.py
create mode 100644 flang-rt/test/lit.site.cfg.py.in
create mode 100644 flang-rt/unittests/CMakeLists.txt
create mode 100644 flang-rt/unittests/Evaluate/CMakeLists.txt
create mode 100644 flang-rt/unittests/Runtime/CMakeLists.txt
create mode 100644 flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
create mode 100644 flang/cmake/modules/FlangCommon.cmake
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 68a17edf8ca34..17a8a4dd8d0a8 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -342,11 +342,15 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
assert(TC.getTriple().isKnownWindowsMSVCEnvironment() &&
"can only add VS runtime library on Windows!");
- // if -fno-fortran-main has been passed, skip linking Fortran_main.a
- if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
- CmdArgs.push_back(Args.MakeArgString(
- "--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));
- }
+
+ // Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
+ // should only depend on msv(u)crt. LLVM still emits libgcc/compiler-rt
+ // functions in some cases like 128-bit integer math (__udivti3, __modti3,
+ // __fixsfti, __floattidf, ...) that msvc does not support. We are injecting a
+ // dependency to Compiler-RT's builtin library where these are implemented.
+ CmdArgs.push_back(Args.MakeArgString(
+ "--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));
+
unsigned RTOptionID = options::OPT__SLASH_MT;
if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
RTOptionID = llvm::StringSwitch<unsigned>(rtl->getValue())
diff --git a/flang-rt/.clang-tidy b/flang-rt/.clang-tidy
new file mode 100644
index 0000000000000..ee3a0ab2201bf
--- /dev/null
+++ b/flang-rt/.clang-tidy
@@ -0,0 +1,2 @@
+Checks: '-llvm-include-order,readability-braces-around-statements,-readability-identifier-naming,-clang-diagnostic-*'
+InheritParentConfig: true
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
new file mode 100644
index 0000000000000..655d0a55b4004
--- /dev/null
+++ b/flang-rt/CMakeLists.txt
@@ -0,0 +1,248 @@
+#===-- CMakeLists.txt ------------------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+#
+# Build instructions for the flang-rt library. This is file is intended to be
+# included using the LLVM_ENABLE_RUNTIMES mechanism.
+#
+#===------------------------------------------------------------------------===#
+
+if (NOT LLVM_RUNTIMES_BUILD)
+ message(FATAL_ERROR "Use this CMakeLists.txt from LLVM's runtimes build system.
+ Example:
+ cmake <llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=flang-rt
+ ")
+endif ()
+
+set(LLVM_SUBPROJECT_TITLE "Flang-RT")
+set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(FLANG_RT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang")
+
+# CMake 3.24 is the first version of CMake that directly recognizes Flang.
+# LLVM's requirement is only CMake 3.20, teach CMake 3.20-3.23 how to use Flang.
+if (CMAKE_VERSION VERSION_LESS "3.24")
+ cmake_path(GET CMAKE_Fortran_COMPILER STEM _Fortran_COMPILER_STEM)
+ if (_Fortran_COMPILER_STEM STREQUAL "flang-new" OR _Fortran_COMPILER_STEM STREQUAL "flang")
+ include(CMakeForceCompiler)
+ CMAKE_FORCE_Fortran_COMPILER("${CMAKE_Fortran_COMPILER}" "LLVMFlang")
+
+ set(CMAKE_Fortran_COMPILER_ID "LLVMFlang")
+ set(CMAKE_Fortran_COMPILER_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
+
+ set(CMAKE_Fortran_SUBMODULE_SEP "-")
+ set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
+
+ set(CMAKE_Fortran_PREPROCESS_SOURCE
+ "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
+
+ set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form")
+ set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form")
+
+ set(CMAKE_Fortran_MODDIR_FLAG "-module-dir")
+
+ set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp")
+ set(CMAKE_Fortran_POSTPROCESS_FLAG "-ffixed-line-length-72")
+
+ set(CMAKE_Fortran_COMPILE_OPTIONS_TARGET "--target=")
+
+ set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,")
+ set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",")
+ endif ()
+endif ()
+enable_language(Fortran)
+
+
+list(APPEND CMAKE_MODULE_PATH
+ "${FLANG_RT_SOURCE_DIR}/cmake/modules"
+ "${FLANG_SOURCE_DIR}/cmake/modules"
+ )
+include(AddFlangRT)
+include(GetToolchainDirs)
+include(FlangCommon)
+include(HandleCompilerRT)
+include(ExtendPath)
+
+
+############################
+# Build Mode Introspection #
+############################
+
+# Determine whether we are in the runtimes/runtimes-bins directory of a
+# bootstrap build.
+set(LLVM_TREE_AVAILABLE OFF)
+if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
+ set(LLVM_TREE_AVAILABLE ON)
+endif()
+
+# Path to LLVM development tools (FileCheck, llvm-lit, not, ...)
+set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin")
+
+# Determine build and install paths.
+# The build path is absolute, but the install dir is relative, CMake's install
+# command has to apply CMAKE_INSTALL_PREFIX itself.
+get_toolchain_library_subdir(toolchain_lib_subdir)
+if (LLVM_TREE_AVAILABLE)
+ # In a bootstrap build emit the libraries into a default search path in the
+ # build directory of the just-built compiler. This allows using the
+ # just-built compiler without specifying paths to runtime libraries.
+ #
+ # Despite Clang in the name, get_clang_resource_dir does not depend on Clang
+ # being added to the build. Flang uses the same resource dir as clang.
+ include(GetClangResourceDir)
+ get_clang_resource_dir(FLANG_RT_OUTPUT_RESOURCE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/..")
+ get_clang_resource_dir(FLANG_RT_INSTALL_RESOURCE_PATH)
+
+ extend_path(FLANG_RT_OUTPUT_RESOURCE_LIB_DIR "${FLANG_RT_OUTPUT_RESOURCE_DIR}" "${toolchain_lib_subdir}")
+else ()
+ # In a standalone runtimes build, do not write into LLVM_BINARY_DIR. It may be
+ # read-only and/or shared by multiple runtimes with different build
+ # configurations (e.g. Debug/Release). Use the runtime's own lib dir like any
+ # non-toolchain library.
+ # For the install prefix, still use the resource dir assuming that Flang will
+ # be installed there using the same prefix. This is to not have a difference
+ # between bootstrap and standalone runtimes builds.
+ set(FLANG_RT_OUTPUT_RESOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+ set(FLANG_RT_INSTALL_RESOURCE_PATH "lib${LLVM_LIBDIR_SUFFIX}/clang/${LLVM_VERSION_MAJOR}")
+
+ extend_path(FLANG_RT_OUTPUT_RESOURCE_LIB_DIR "${FLANG_RT_OUTPUT_RESOURCE_DIR}" "lib${LLVM_LIBDIR_SUFFIX}")
+endif ()
+extend_path(FLANG_RT_INSTALL_RESOURCE_LIB_PATH "${FLANG_RT_INSTALL_RESOURCE_PATH}" "${toolchain_lib_subdir}")
+cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_DIR)
+cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_PATH)
+cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_LIB_DIR)
+cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_LIB_PATH)
+
+
+#################
+# Build Options #
+#################
+
+# Important: flang-rt user options must be prefixed with "FLANG_RT_". Variables
+# with this prefix will be forwarded in bootstrap builds.
+
+option(FLANG_RT_INCLUDE_TESTS "Generate build targets for the flang-rt unit and regression-tests." "${LLVM_INCLUDE_TESTS}")
+
+
+set(FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT "" CACHE STRING "Compile Flang-RT with GPU support (CUDA or OpenMP)")
+set_property(CACHE FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT PROPERTY STRINGS
+ ""
+ CUDA
+ OpenMP
+ )
+if (NOT FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT)
+ # Support for GPUs disabled
+elseif (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
+ # Support for CUDA
+ set(FLANG_RT_LIBCUDACXX_PATH "" CACHE PATH "Path to libcu++ package installation")
+ option(FLANG_RT_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS "Do not compile global variables' definitions when producing PTX library" OFF)
+elseif (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
+ # Support for OpenMP offloading
+ set(FLANG_RT_DEVICE_ARCHITECTURES "all" CACHE STRING
+ "List of OpenMP device architectures to be used to compile the Fortran runtime (e.g. 'gfx1103;sm_90')"
+ )
+
+ if (FLANG_RT_DEVICE_ARCHITECTURES STREQUAL "all")
+ # TODO: support auto detection on the build system.
+ set(all_amdgpu_architectures
+ "gfx700;gfx701;gfx801;gfx803;gfx900;gfx902;gfx906"
+ "gfx908;gfx90a;gfx90c;gfx940;gfx1010;gfx1030"
+ "gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036"
+ "gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151"
+ "gfx1152;gfx1153")
+ set(all_nvptx_architectures
+ "sm_35;sm_37;sm_50;sm_52;sm_53;sm_60;sm_61;sm_62"
+ "sm_70;sm_72;sm_75;sm_80;sm_86;sm_89;sm_90")
+ set(all_gpu_architectures
+ "${all_amdgpu_architectures};${all_nvptx_architectures}")
+ set(FLANG_RT_DEVICE_ARCHITECTURES ${all_gpu_architectures})
+ endif()
+ list(REMOVE_DUPLICATES FLANG_RT_DEVICE_ARCHITECTURES)
+else ()
+ message(FATAL_ERROR "Invalid value '${FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT}' for FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT; must be empty, 'CUDA', or 'OpenMP'")
+endif ()
+
+
+option(FLANG_RT_ENABLE_CUF "Compile CUDA Fortran runtime sources" OFF)
+if (FLANG_RT_ENABLE_CUF)
+ find_package(CUDAToolkit REQUIRED)
+endif()
+
+
+########################
+# System Introspection #
+########################
+
+include(CheckCXXSymbolExists)
+include(CheckCXXSourceCompiles)
+check_cxx_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
+# Can't use symbol exists here as the function is overloaded in C++
+check_cxx_source_compiles(
+ "#include <string.h>
+ int main() {
+ char buf[4096];
+ return strerror_s(buf, 4096, 0);
+ }
+ "
+ HAVE_DECL_STRERROR_S)
+
+
+# Search for clang_rt.builtins library. Need in addition to msvcrt.
+if (WIN32)
+ find_compiler_rt_library(builtins FLANG_RT_BUILTINS_LIBRARY)
+endif ()
+
+
+# Check whether the compiler can undefine a macro using the "-U" flag.
+# Aternatively, we could use
+# CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU"
+# but some older versions of CMake don't define it for GCC itself.
+check_cxx_compiler_flag("-UTESTFLAG" FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
+
+
+#####################
+# Build Preparation #
+#####################
+
+if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT AND FLANG_RT_INCLUDE_TESTS)
+ # If Fortran runtime is built as CUDA library, the linking
+ # of targets that link flang-rt must be done
+ # with CUDA_RESOLVE_DEVICE_SYMBOLS.
+ # CUDA language must be enabled for CUDA_RESOLVE_DEVICE_SYMBOLS
+ # to take effect.
+ enable_language(CUDA)
+endif()
+
+
+# C++17 is required for flang-rt; user or other runtimes may override this.
+# GTest included later also requires C++17.
+set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
+set(CMAKE_CXX_STANDARD_REQUIRED YES)
+
+
+configure_file(cmake/config.h.cmake.in config.h)
+
+
+# The bootstrap build will create a phony target with the same as the top-level
+# directory ("flang-rt") and delegate it to the runtimes build dir.
+# AddFlangRT will add all non-EXCLUDE_FROM_ALL targets to it.
+add_custom_target(flang-rt)
+
+
+###################
+# Build Artifacts #
+###################
+
+add_subdirectory(lib)
+
+if (FLANG_RT_INCLUDE_TESTS)
+ add_subdirectory(unittests)
+ add_subdirectory(test)
+else ()
+ add_custom_target(check-flang-rt)
+endif()
diff --git a/flang-rt/CODE_OWNERS.TXT b/flang-rt/CODE_OWNERS.TXT
new file mode 100644
index 0000000000000..649243aa1e8fe
--- /dev/null
+++ b/flang-rt/CODE_OWNERS.TXT
@@ -0,0 +1,14 @@
+This file is a list of the people responsible for ensuring that patches for a
+particular part of Flang are reviewed, either by themself or by someone else.
+They are also the gatekeepers for their part of Flang, with the final word on
+what goes in or not.
+
+The list is sorted by surname and formatted to allow easy grepping and
+beautification by scripts. The fields are: name (N), email (E), web-address
+(W), PGP key ID and fingerprint (P), description (D), snail-mail address
+(S) and (I) IRC handle. Each entry should contain at least the (N), (E) and
+(D) fields.
+
+N: Steve Scalpone
+E: sscalpone at nvidia.com
+D: Anything not covered by others
diff --git a/flang-rt/LICENSE.TXT b/flang-rt/LICENSE.TXT
new file mode 100644
index 0000000000000..53bb2e7fbc764
--- /dev/null
+++ b/flang-rt/LICENSE.TXT
@@ -0,0 +1,234 @@
+==============================================================================
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+ `LICENSE` file at the top containing the specific license and restrictions
+ which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+ file.
diff --git a/flang-rt/README.md b/flang-rt/README.md
new file mode 100644
index 0000000000000..76993f27f8e4f
--- /dev/null
+++ b/flang-rt/README.md
@@ -0,0 +1,188 @@
+<!--===- README.md
+
+ 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
+
+-->
+
+# Fortran Runtime (Flang-RT)
+
+Flang-RT is the runtime library for code emitted by the Flang compiler
+(https://flang.llvm.org).
+
+
+## Getting Started
+
+There are two build modes for the Flang-RT. The bootstrap build, also
+called the in-tree build, and the runtime-only build, also called the
+out-of-tree build.
+Not to be confused with the terms
+[in-source and out-of-source](https://cmake.org/cmake/help/latest/manual/cmake.1.html#introduction-to-cmake-buildsystems)
+builds as defined by CMake. In an in-source build, the source directory and the
+build directory are identical, whereas with an out-of-source build the
+build artifacts are stored somewhere else, possibly in a subdirectory of the
+source directory. LLVM does not support in-source builds.
+
+
+### Requirements
+
+Requirements:
+ * [Same as LLVM](https://llvm.org/docs/GettingStarted.html#requirements).
+
+
+### Bootstrapping Runtimes Build
+
+The bootstrapping build will first build Clang and Flang, then use these
+compilers to compile Flang-RT. CMake will create a secondary build tree
+configured to use these just-built compilers. The secondary build will reuse
+the same build options (Flags, Debug/Release, ...) as the primary build.
+It will also ensure that once built, Flang-RT is found by Flang from either
+the build- or install-prefix. To enable, add `flang-rt` to
+`LLVM_ENABLE_RUNTIMES`:
+
+```bash
+cmake -S <path-to-llvm-project-source>/llvm \
+ -GNinja \
+ -DLLVM_ENABLE_PROJECTS="clang;flang" \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
+ ...
+```
+
+It is recommended to enable building OpenMP alongside Flang and Flang-RT
+as well. This will build `omp_lib.mod` required to use OpenMP from Fortran.
+Building Compiler-RT may also be required, particularly on platforms that do
+not provide all C-ABI functionality (such as Windows).
+
+```bash
+cmake -S <path-to-llvm-project-source>/llvm \
+ -GNinja \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DLLVM_ENABLE_PROJECTS="clang;flang;openmp" \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;flang-rt" \
+ ...
+```
+
+By default, the enabled runtimes will only be built for the host platform
+(`-DLLVM_RUNTIME_TARGETS=default`). To add additional targets to support
+cross-compilation via `flang --target=<target-triple>`, add more triples to
+`LLVM_RUNTIME_TARGETS`, such as
+`-DLLVM_RUNTIME_TARGETS="default;aarch64-linux-gnu"`.
+
+After configuration, build, test, and install the runtime(s) via
+
+```shell
+$ ninja flang-rt
+$ ninja check-flang-rt
+$ ninja install
+```
+
+
+### Standalone Runtimes Build
+
+Instead of building Clang and Flang from scratch, the standalone Runtime build
+uses CMake's environment introspection to find a C, C++, and Fortran compiler.
+The compiler to be used can be controlled using CMake's standard mechanisms such
+as `CMAKE_CXX_COMPILER`, `CMAKE_CXX_COMPILER`, and `CMAKE_Fortran_COMPILER`.
+`CMAKE_Fortran_COMPILER` must be `flang` built from the same Git commit as
+Flang-RT to ensure they are using the same ABI. The C and C++ compiler
+can be any compiler supporting the same ABI.
+
+In addition to the compiler, the build be able to find LLVM development tools
+such as `lit` and `FileCheck` that are not found in an LLVM's install
+directory. Use `CMAKE_BINARY_DIR` to point to directory where LLVM has
+been built. A simple build configuration might look like the following:
+
+```bash
+cmake -S <path-to-llvm-project-source>/runtimes \
+ -GNinja \
+ -DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
+ -DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir>/bin/flang \
+ -DCMAKE_Fortran_COMPILER_WORKS=yes \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
+ ...
+```
+
+The `CMAKE_Fortran_COMPILER_WORKS` parameter must be set because otherwise CMake
+will test whether the Fortran compiler can compile and link programs which will
+obviously fail without a runtime library available yet.
+
+Building Flang-RT for cross-compilation triple, the target triple can
+be selected using `LLVM_DEFAULT_TARGET_TRIPLE` AND `LLVM_RUNTIMES_TARGET`.
+Of course, Flang-RT can be built multiple times with different build
+configurations, but have to be located manually when using with the Flang
+driver using the `-L` option.
+
+After configuration, build, test, and install the runtime via
+
+```shell
+$ ninja
+$ ninja check-flang-rt
+$ ninja install
+```
+
+
+## Configuration Option Reference
+
+Flang-RT has the followign configuration options. This is in
+addition to the build options the LLVM_ENABLE_RUNTIMES mechanism and
+CMake itself provide.
+
+ * `FLANG_RT_INCLUDE_TESTS` (boolean; default: `ON`)
+
+ When `OFF`, does not add any tests and unittests. The `check-flang-rt`
+ build target will do nothing.
+
+ * `FLANG_RUNTIME_F128_MATH_LIB` (default: `""`)
+
+ Determines the implementation of `REAL(16)` math functions. If set to
+ `libquadmath`, uses `quadmath.h` and `-lquadmath` typically distributed with
+ gcc. If empty, disables `REAL(16)` support. For any other value, introspects
+ the compiler for `__float128` or 128-bit `long double` support.
+ [More details](docs/Real16MathSupport.md).
+
+ * `FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT` (values: `"CUDA"`,`"OpenMP"`, `""` default: `""`)
+
+ When set to `CUDA`, builds Flang-RT with experimental support for GPU
+ accelerators using CUDA. `CMAKE_CUDA_COMPILER` must be set if not
+ automatically detected by CMake. `nvcc` as well as `clang` are supported.
+
+ When set to `OpenMP`, builds Flang-RT with experimental support for
+ GPU accelerators using OpenMP offloading. Only Clang is supported for
+ `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`.
+
+ * `FLANG_RT_ENABLE_CUF` (bool, default: `OFF`)
+
+ Compiles the `libCufRuntime_cuda_<CUDA-version>.a/.so` library. This is
+ independent of `FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA` and only
+ requires a
+ [CUDA Toolkit installation](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html)
+ (no `CMAKE_CUDA_COMPILER`).
+
+
+### Experimental CUDA Support
+
+With `-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`, the following
+additional configuration options become available.
+
+ * `FLANG_RT_LIBCUDACXX_PATH` (path, default: `""`)
+
+ Path to libcu++ package installation.
+
+ * `FLANG_RT_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS` (boolean, default: `OFF`)
+
+ Do not compile global variables' definitions when producing PTX library.
+ Default is `OFF`, meaning global variable definitions are compiled by
+ default.
+
+
+### Experimental OpenMP Offload Support
+
+With `-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=OpenMP`, the following
+additional configuration options become available.
+
+ * `FLANG_RT_DEVICE_ARCHITECTURES` (default: `"all"`)
+
+ A list of device architectures that Flang-RT is going to support.
+ If `"all"` uses a pre-defined list of architectures. Same purpose as
+ `LIBOMPTARGET_DEVICE_ARCHITECTURES` from liboffload.
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
new file mode 100644
index 0000000000000..aa8adedf61752
--- /dev/null
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -0,0 +1,186 @@
+#===-- cmake/modules/AddFlangRT.cmake --------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+# Builds a library with common options for flang-rt.
+#
+# Usage:
+#
+# add_flangrt_library(name sources ...
+# SHARED
+# Build a dynamic (.so/.dll) library
+# STATIC
+# Build a static (.a/.lib) library
+# OBJECT
+# Create only object files without static/dynamic library
+# INSTALL_WITH_TOOLCHAIN
+# Install library into Clang's resource directory so it can be found by the
+# Flang driver during compilation, including tests
+# EXCLUDE_FROM_ALL
+# Do not build library by default; typically used for libraries needed for
+# testing only, no install
+# LINK_TO_LLVM
+# Library requires include path and linking to LLVM's Support component
+# ADDITIONAL_HEADERS
+# May specify header files for IDE generators.
+# INCLUDE_DIRECTORIES
+# Additional include_directories for all added targets
+# TARGET_PROPERTIES
+# Set target properties of all added targets
+# )
+function (add_flangrt_library name)
+ set(options STATIC SHARED OBJECT INSTALL_WITH_TOOLCHAIN EXCLUDE_FROM_ALL LINK_TO_LLVM)
+ set(multiValueArgs ADDITIONAL_HEADERS INCLUDE_DIRECTORIES TARGET_PROPERTIES)
+ cmake_parse_arguments(ARG
+ "${options}"
+ ""
+ "${multiValueArgs}"
+ ${ARGN})
+
+ if (ARG_INSTALL_WITH_TOOLCHAIN AND ARG_EXCLUDE_FROM_ALL)
+ message(SEND_ERROR "add_flangrt_library(${name} ...):
+ INSTALL_WITH_TOOLCHAIN and EXCLUDE_FROM_ALL are in conflict. When
+ installing an artifact it must have been built first in the 'all' target.
+ ")
+ endif ()
+
+ # Forward libtype to add_library
+ set(extra_args "")
+ if (ARG_SHARED)
+ list(APPEND extra_args SHARED)
+ endif ()
+ if (ARG_STATIC)
+ list(APPEND extra_args STATIC)
+ endif ()
+ if (ARG_OBJECT)
+ list(APPEND extra_args OBJECT)
+ endif ()
+ if (ARG_EXCLUDE_FROM_ALL)
+ list(APPEND extra_args EXCLUDE_FROM_ALL)
+ endif ()
+
+ # Also add header files to IDEs to list as part of the library.
+ set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
+
+ add_library(${name} ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS})
+
+ if (ARG_INSTALL_WITH_TOOLCHAIN)
+ set_target_properties(${name} PROPERTIES FOLDER "Flang-RT/Toolchain Libraries")
+ elseif (ARG_OBJECT)
+ set_target_properties(${name} PROPERTIES FOLDER "Flang-RT/Object Libraries")
+ else ()
+ set_target_properties(${name} PROPERTIES FOLDER "Flang-RT/Libraries")
+ endif ()
+
+ # Minimum required C++ version for Flang-RT, even if CMAKE_CXX_STANDARD is defined to something else.
+ target_compile_features(${name} PRIVATE cxx_std_17)
+
+ # Use compiler-specific options to disable exceptions and RTTI.
+ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
+ target_compile_options(${name} PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>
+ )
+ elseif (MSVC)
+ target_compile_options(${name} PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:/EHs-c- /GR->
+ )
+ elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
+ target_compile_options(${name} PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:-qnoeh -qnortti>
+ )
+ endif ()
+
+ # Also for CUDA source when compiling with FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA
+ if (CMAKE_CUDA_COMPILER_ID MATCHES "NVIDIA")
+ # Assuming gcc as host compiler.
+ target_compile_options(${name} PRIVATE
+ $<$<COMPILE_LANGUAGE:CUDA>:--no-exceptions -Xcompiler -fno-rtti -Xcompiler -fno-unwind-tables -Xcompiler -fno-asynchronous-unwind-tables>
+ )
+ else ()
+ # Assuming a clang-compatible CUDA compiler.
+ target_compile_options(${name} PRIVATE
+ $<$<COMPILE_LANGUAGE:CUDA>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>
+ )
+ endif ()
+
+ # Flang-RT's public headers
+ target_include_directories(${name} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
+
+ # For ISO_Fortran_binding.h to be found by the runtime itself (Accessed as #include "flang/ISO_Fortran_binding.h")
+ # User applications can use #include <ISO_Fortran_binding.h>
+ target_include_directories(${name} PRIVATE "${FLANG_SOURCE_DIR}/include")
+
+ # For Flang-RT's configured config.h to be found
+ target_include_directories(${name} PRIVATE "${FLANG_RT_BINARY_DIR}")
+
+ # Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS
+ # build, to avoid an unwanted dependency on libstdc++/libc++.so.
+ if (FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
+ target_compile_options(${name} PUBLIC -U_GLIBCXX_ASSERTIONS)
+ target_compile_options(${name} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)
+ endif ()
+
+ # Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
+ # should only depend on msvcrt/ucrt. LLVM still emits libgcc/compiler-rt
+ # functions in some cases like 128-bit integer math (__udivti3, __modti3,
+ # __fixsfti, __floattidf, ...) that msvc does not support. We are injecting a
+ # dependency to Compiler-RT's builtin library where these are implemented.
+ if (MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ if (FLANG_RT_BUILTINS_LIBRARY)
+ target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>" "$<$<COMPILE_LANGUAGE:CXX,C>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
+ endif ()
+ endif ()
+ if (MSVC AND CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
+ if (FLANG_RT_BUILTINS_LIBRARY)
+ target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "$<$<COMPILE_LANGUAGE:Fortran>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
+ else ()
+ message(WARNING "Did not find libclang_rt.builtins.lib.
+ LLVM may emit builtins that are not implemented in msvcrt/ucrt and
+ instead falls back to builtins from Compiler-RT. Linking with ${name}
+ may result in a linker error.")
+ endif ()
+ endif ()
+
+ # Non-GTest unittests depend on LLVMSupport
+ if (ARG_LINK_TO_LLVM)
+ if (LLVM_LINK_LLVM_DYLIB)
+ set(llvm_libs LLVM)
+ else()
+ llvm_map_components_to_libnames(llvm_libs Support)
+ endif()
+ target_link_libraries(${name} PUBLIC ${llvm_libs})
+ target_include_directories(${name} PUBLIC ${LLVM_INCLUDE_DIRS})
+ endif ()
+
+ if (ARG_INCLUDE_DIRECTORIES)
+ target_include_directories(${name} ${ARG_INCLUDE_DIRECTORIES})
+ endif ()
+
+ # If this is part of the toolchain, put it into the compiler's resource
+ # directory. Otherwise it is part of testing and is not installed at all.
+ # TODO: Consider multi-configuration builds (MSVC_IDE, "Ninja Multi-Config")
+ if (ARG_INSTALL_WITH_TOOLCHAIN)
+ set_target_properties(${name}
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY "${FLANG_RT_OUTPUT_RESOURCE_LIB_DIR}"
+ )
+
+ install(TARGETS ${name}
+ ARCHIVE DESTINATION "${FLANG_RT_INSTALL_RESOURCE_LIB_PATH}"
+ )
+ endif ()
+
+ if (ARG_TARGET_PROPERTIES)
+ set_target_properties(${name} PROPERTIES ${ARG_TARGET_PROPERTIES})
+ endif ()
+
+ # flang-rt should build all the Flang-RT targets that are built in an
+ # 'all' build.
+ if (NOT ARG_EXCLUDE_FROM_ALL)
+ add_dependencies(flang-rt ${name})
+ endif ()
+endfunction (add_flangrt_library)
diff --git a/flang-rt/cmake/modules/AddFlangRTOffload.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
new file mode 100644
index 0000000000000..b055646cb0604
--- /dev/null
+++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
@@ -0,0 +1,101 @@
+#===-- cmake/modules/AddFortranRTOffload.txt -------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+macro(enable_cuda_compilation name files)
+ if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
+ enable_language(CUDA)
+
+ set_target_properties(${name}
+ PROPERTIES
+ CUDA_SEPARABLE_COMPILATION ON
+ )
+
+ # Treat all supported sources as CUDA files.
+ set_source_files_properties(${files} PROPERTIES LANGUAGE CUDA)
+ set(CUDA_COMPILE_OPTIONS)
+ if ("${CMAKE_CUDA_COMPILER_ID}" MATCHES "Clang")
+ # Allow varargs.
+ set(CUDA_COMPILE_OPTIONS
+ -Xclang -fcuda-allow-variadic-functions
+ )
+ endif()
+ if ("${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA")
+ set(CUDA_COMPILE_OPTIONS
+ --expt-relaxed-constexpr
+ # Disable these warnings:
+ # 'long double' is treated as 'double' in device code
+ -Xcudafe --diag_suppress=20208
+ -Xcudafe --display_error_number
+ )
+ endif()
+ set_source_files_properties(${files} PROPERTIES COMPILE_OPTIONS
+ "${CUDA_COMPILE_OPTIONS}"
+ )
+
+ # Create a .a library consisting of CUDA PTX.
+ # This is different from a regular static library. The CUDA_PTX_COMPILATION
+ # property can only be applied to object libraries and create *.ptx files
+ # instead of *.o files. The .a will consist of those *.ptx files only.
+ add_flangrt_library(obj.${name}PTX OBJECT ${files})
+ set_property(TARGET obj.${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
+ add_flangrt_library(${name}PTX STATIC "$<TARGET_OBJECTS:obj.${name}PTX>")
+
+ # Apply configuration options
+ if (FLANG_RT_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
+ target_compile_definitions(obj.${name}PTX
+ PRIVATE FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+ )
+ endif()
+
+ # When using libcudacxx headers files, we have to use them
+ # for all files of Flang-RT.
+ if (EXISTS "${FLANG_RT_LIBCUDACXX_PATH}/include")
+ foreach (tgt IN ITEMS "${name}" "obj.${name}PTX")
+ target_include_directories(${tgt} AFTER PRIVATE "${FLANG_RT_LIBCUDACXX_PATH}/include")
+ target_compile_definitions(${tgt} PRIVATE RT_USE_LIBCUDACXX=1)
+ endforeach ()
+ endif ()
+ endif()
+endmacro()
+
+macro(enable_omp_offload_compilation name files)
+ if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
+ # OpenMP offload build only works with Clang compiler currently.
+
+ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND
+ "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+
+ string(REPLACE ";" "," compile_for_architectures
+ "${FLANG_RT_DEVICE_ARCHITECTURES}"
+ )
+
+ set(OMP_COMPILE_OPTIONS
+ -fopenmp
+ -fvisibility=hidden
+ -fopenmp-cuda-mode
+ --offload-arch=${compile_for_architectures}
+ # Force LTO for the device part.
+ -foffload-lto
+ )
+ set_source_files_properties(${files} PROPERTIES COMPILE_OPTIONS
+ "${OMP_COMPILE_OPTIONS}"
+ )
+ target_link_options(${name} PUBLIC ${OMP_COMPILE_OPTIONS})
+
+ # Enable "declare target" in the source code.
+ set_source_files_properties(${files}
+ PROPERTIES COMPILE_DEFINITIONS OMP_OFFLOAD_BUILD
+ )
+ else()
+ message(FATAL_ERROR
+ "Flang-rt build with OpenMP offload is not supported for these compilers:\n"
+ "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}\n"
+ "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
+ endif()
+ endif()
+endmacro()
diff --git a/flang-rt/cmake/modules/GetToolchainDirs.cmake b/flang-rt/cmake/modules/GetToolchainDirs.cmake
new file mode 100644
index 0000000000000..426a5e8e801f3
--- /dev/null
+++ b/flang-rt/cmake/modules/GetToolchainDirs.cmake
@@ -0,0 +1,125 @@
+#===-- cmake/modules/GetToolchainDirs.cmake --------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+
+# Determine the subdirectory relative to Clang's resource dir/sysroot where to
+# install target-specific libraries, to be found by Clang/Flang driver. This was
+# adapted from Compiler-RT's mechanism to find the path for
+# libclang_rt.builtins.a.
+#
+# Compiler-RT has two mechanisms for the path (simplified):
+#
+# * LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=1: lib/${oslibname}/libclang_rt.builtins-${arch}.a
+# * LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0: lib/${triple}/libclang_rt.builtins.a
+#
+# LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON is the newer scheme, but the old one is
+# currently still used for some platforms such as Windows. Clang looks for which
+# of the files exist before passing the path to the linker. Hence, the
+# directories have to match what Clang is looking for, which is done in
+# ToolChain::getArchSpecificLibPaths(..), ToolChain::getRuntimePath(),
+# ToolChain::getCompilerRTPath(), and ToolChain::getCompilerRT(..), not entirely
+# consistent between these functions, Compiler-RT's CMake code, and overrides
+# in different toolchains.
+#
+# For Fortran, Flang always assumes the library name libflang_rt.a without
+# architecture suffix. Hence, we always use the second scheme even as if
+# LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON, even if it actually set to OFF. It as
+# added unconditionally to the library search path by
+# ToolChain::getArchSpecificLibPaths(...).
+function (get_toolchain_library_subdir outvar)
+ if (NOT APPLE)
+ set(outval "lib")
+ else ()
+ # Required to be "darwin" for MachO toolchain.
+ get_toolchain_os_dirname(os_dirname)
+ set(outval "lib/${os_dirname}")
+ endif ()
+
+ get_toolchain_arch_dirname(arch_dirname)
+ set(outval "lib/${arch_dirname}")
+
+ set(${outvar} "${outval}" PARENT_SCOPE)
+endfunction ()
+
+
+# Corresponds to Clang's ToolChain::getOSLibName(). Adapted from Compiler-RT.
+function (get_toolchain_os_dirname outvar)
+ if (ANDROID)
+ # The CMAKE_SYSTEM_NAME for Android is "Android", but the OS is Linux and the
+ # driver will search for libraries in the "linux" directory.
+ set(outval "linux")
+ else ()
+ string(TOLOWER "${CMAKE_SYSTEM_NAME}" outval)
+ endif ()
+ set(${outvar} "${outval}" PARENT_SCOPE)
+endfunction ()
+
+
+# Corresponds to Clang's ToolChain::getRuntimePath(). Adapted from Compiler-RT.
+function (get_toolchain_arch_dirname outvar)
+ string(REPLACE "-" ";" triple_list ${LLVM_TARGET_TRIPLE})
+ list(GET triple_list 0 arch)
+
+ if("${arch}" MATCHES "^i.86$")
+ # Android uses i686, but that's remapped at a later stage.
+ set(arch "i386")
+ endif()
+
+ string(FIND ${LLVM_TARGET_TRIPLE} "-" dash_index)
+ string(SUBSTRING ${LLVM_TARGET_TRIPLE} ${dash_index} -1 triple_suffix)
+ string(SUBSTRING ${LLVM_TARGET_TRIPLE} 0 ${dash_index} triple_cpu)
+ set(arch "${triple_cpu}")
+ if("${arch}" MATCHES "^i.86$")
+ # Android uses i686, but that's remapped at a later stage.
+ set(arch "i386")
+ endif()
+
+ if(ANDROID AND ${arch} STREQUAL "i386")
+ set(target "i686${triple_suffix}")
+ elseif(${arch} STREQUAL "amd64")
+ set(target "x86_64${triple_suffix}")
+ elseif(${arch} STREQUAL "sparc64")
+ set(target "sparcv9${triple_suffix}")
+ elseif("${arch}" MATCHES "mips64|mips64el")
+ string(REGEX REPLACE "-gnu.*" "-gnuabi64" triple_suffix_gnu "${triple_suffix}")
+ string(REGEX REPLACE "mipsisa32" "mipsisa64" triple_cpu_mips "${triple_cpu}")
+ string(REGEX REPLACE "^mips$" "mips64" triple_cpu_mips "${triple_cpu_mips}")
+ string(REGEX REPLACE "^mipsel$" "mips64el" triple_cpu_mips "${triple_cpu_mips}")
+ set(target "${triple_cpu_mips}${triple_suffix_gnu}")
+ elseif("${arch}" MATCHES "mips|mipsel")
+ string(REGEX REPLACE "-gnuabi.*" "-gnu" triple_suffix_gnu "${triple_suffix}")
+ string(REGEX REPLACE "mipsisa64" "mipsisa32" triple_cpu_mips "${triple_cpu}")
+ string(REGEX REPLACE "mips64" "mips" triple_cpu_mips "${triple_cpu_mips}")
+ set(target "${triple_cpu_mips}${triple_suffix_gnu}")
+ elseif("${arch}" MATCHES "^arm")
+ # FIXME: Handle arch other than arm, armhf, armv6m
+ if (${arch} STREQUAL "armhf")
+ # If we are building for hard float but our ABI is soft float.
+ if ("${triple_suffix}" MATCHES ".*eabi$")
+ # Change "eabi" -> "eabihf"
+ set(triple_suffix "${triple_suffix}hf")
+ endif()
+ # ABI is already set in the triple, don't repeat it in the architecture.
+ set(arch "arm")
+ else ()
+ # If we are building for soft float, but the triple's ABI is hard float.
+ if ("${triple_suffix}" MATCHES ".*eabihf$")
+ # Change "eabihf" -> "eabi"
+ string(REGEX REPLACE "hf$" "" triple_suffix "${triple_suffix}")
+ endif()
+ endif()
+ set(target "${arch}${triple_suffix}")
+ elseif("${arch}" MATCHES "^amdgcn")
+ set(target "amdgcn-amd-amdhsa")
+ elseif("${arch}" MATCHES "^nvptx")
+ set(target "nvptx64-nvidia-cuda")
+ else()
+ set(target "${arch}${triple_suffix}")
+ endif()
+ set(${outvar} "${target}" PARENT_SCOPE)
+endfunction()
diff --git a/flang-rt/lib/CMakeLists.txt b/flang-rt/lib/CMakeLists.txt
new file mode 100644
index 0000000000000..8e2e0fbbbc24f
--- /dev/null
+++ b/flang-rt/lib/CMakeLists.txt
@@ -0,0 +1,18 @@
+#===-- lib/CMakeLists.txt --------------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+add_subdirectory(FortranFloat128Math)
+add_subdirectory(flang_rt)
+
+if (FLANG_RT_ENABLE_CUF)
+ add_subdirectory(flang_rt/CUDA)
+endif()
+
+if (FLANG_RT_INCLUDE_TESTS)
+ add_subdirectory(Testing)
+endif ()
diff --git a/flang-rt/lib/FortranFloat128Math/CMakeLists.txt b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
new file mode 100644
index 0000000000000..c0b2ee32248f8
--- /dev/null
+++ b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
@@ -0,0 +1,136 @@
+#===-- lib/FortranFloat128Math/CMakeLists.txt ------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+# FortranFloat128 implements IEEE-754 128-bit float math functions.
+# It is a thin wapper and it currently relies on third-party
+# libraries available for the target.
+# It is distributed as a static library only.
+# Fortran programs/libraries that end up linking any of the provided
+# will have a dependency on the third-party library that is being
+# used for building this FortranFloat128Math library.
+
+include(CheckLibraryExists)
+include(CheckIncludeFile)
+
+set(sources
+ acos.cpp
+ acosh.cpp
+ asin.cpp
+ asinh.cpp
+ atan.cpp
+ atan2.cpp
+ atanh.cpp
+ ceil.cpp
+ complex-math.c
+ cos.cpp
+ cosh.cpp
+ erf.cpp
+ erfc.cpp
+ exp.cpp
+ exponent.cpp
+ floor.cpp
+ fma.cpp
+ fraction.cpp
+ hypot.cpp
+ j0.cpp
+ j1.cpp
+ jn.cpp
+ lgamma.cpp
+ llround.cpp
+ log.cpp
+ log10.cpp
+ lround.cpp
+ mod-real.cpp
+ modulo-real.cpp
+ nearest.cpp
+ nearbyint.cpp
+ norm2.cpp
+ pow.cpp
+ random.cpp
+ remainder.cpp
+ round.cpp
+ rrspacing.cpp
+ scale.cpp
+ set-exponent.cpp
+ sin.cpp
+ sinh.cpp
+ spacing.cpp
+ sqrt.cpp
+ tan.cpp
+ tanh.cpp
+ tgamma.cpp
+ trunc.cpp
+ y0.cpp
+ y1.cpp
+ yn.cpp
+ )
+
+include_directories(AFTER "${CMAKE_CURRENT_SOURCE_DIR}/..")
+add_library(FortranFloat128MathILib INTERFACE)
+target_include_directories(FortranFloat128MathILib INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
+ )
+
+if (FLANG_RUNTIME_F128_MATH_LIB)
+ if (${FLANG_RUNTIME_F128_MATH_LIB} STREQUAL "libquadmath")
+ check_include_file(quadmath.h FOUND_QUADMATH_HEADER)
+ if(FOUND_QUADMATH_HEADER)
+ add_compile_definitions(HAS_QUADMATHLIB)
+ else()
+ message(FATAL_ERROR
+ "FLANG_RUNTIME_F128_MATH_LIB setting requires quadmath.h "
+ "to be available: ${FLANG_RUNTIME_F128_MATH_LIB}"
+ )
+ endif()
+ else()
+ message(FATAL_ERROR
+ "Unsupported third-party library for Fortran F128 math runtime: "
+ "${FLANG_RUNTIME_F128_MATH_LIB}"
+ )
+ endif()
+
+ if (WIN32)
+ # Do not create a FortranFloat128Math library under Windows, the Flang
+ # driver never links it. Instead, add the sources to flang_rt itself.
+ target_sources(FortranFloat128MathILib INTERFACE ${sources})
+ target_compile_definitions(FortranFloat128MathILib INTERFACE HAS_QUADMATHLIB)
+ else ()
+ add_flangrt_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
+ ${sources})
+ target_include_directories(FortranFloat128Math PRIVATE
+ "${FLANG_RT_SOURCE_DIR}/lib/flang_rt"
+ )
+ endif ()
+elseif (HAVE_LDBL_MANT_DIG_113)
+ # We can use 'long double' versions from libc.
+ check_library_exists(m sinl "" FOUND_LIBM)
+ if (FOUND_LIBM)
+ target_compile_definitions(FortranFloat128MathILib INTERFACE
+ HAS_LIBM
+ )
+ target_include_directories(FortranFloat128MathILib INTERFACE
+ "${FLANG_RT_SOURCE_DIR}/lib/flang_rt"
+ )
+ target_sources(FortranFloat128MathILib INTERFACE ${sources})
+ else()
+ message(FATAL_ERROR "Flang-RT cannot build without libm")
+ endif()
+else()
+ # We can use '__float128' version from libc, if it has them.
+ check_library_exists(m sinf128 "" FOUND_LIBMF128)
+ if (FOUND_LIBMF128)
+ target_compile_definitions(FortranFloat128MathILib INTERFACE
+ HAS_LIBMF128
+ )
+ target_include_directories(FortranFloat128MathILib INTERFACE
+ "${FLANG_RT_SOURCE_DIR}/lib/flang_rt"
+ )
+ # Enable this, when math-entries.h and complex-math.h is ready.
+ # target_sources(FortranFloat128MathILib INTERFACE ${sources})
+ endif()
+endif()
diff --git a/flang-rt/lib/Testing/CMakeLists.txt b/flang-rt/lib/Testing/CMakeLists.txt
new file mode 100644
index 0000000000000..19c20ad44c025
--- /dev/null
+++ b/flang-rt/lib/Testing/CMakeLists.txt
@@ -0,0 +1,20 @@
+#===-- lib/Testing/CMakeLists.txt ------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+set(public_headers "")
+file(GLOB_RECURSE public_headers
+ "${FLANG_SOURCE_DIR}/lib/Testing/*.h"
+)
+
+add_flangrt_library(NonGTestTesting EXCLUDE_FROM_ALL LINK_TO_LLVM
+ ${FLANG_SOURCE_DIR}/lib/Testing/testing.cpp
+ ${FLANG_SOURCE_DIR}/lib/Testing/fp-testing.cpp
+
+ ADDITIONAL_HEADERS
+ ${public_headers}
+ )
diff --git a/flang-rt/lib/flang_rt/CMakeLists.txt b/flang-rt/lib/flang_rt/CMakeLists.txt
new file mode 100644
index 0000000000000..4db1a1cbb874f
--- /dev/null
+++ b/flang-rt/lib/flang_rt/CMakeLists.txt
@@ -0,0 +1,213 @@
+#===-- lib/flang_rt/CMakeLists.txt -----------------------------------------===#
+#
+# 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(AddFlangRTOffload)
+# function checks
+find_package(Backtrace)
+set(HAVE_BACKTRACE ${Backtrace_FOUND})
+set(BACKTRACE_HEADER ${Backtrace_HEADER})
+
+
+# List of files that are buildable for all devices.
+set(supported_sources
+ ${FLANG_SOURCE_DIR}/lib/Decimal/binary-to-decimal.cpp
+ ${FLANG_SOURCE_DIR}/lib/Decimal/decimal-to-binary.cpp
+ ISO_Fortran_binding.cpp
+ allocator-registry.cpp
+ allocatable.cpp
+ array-constructor.cpp
+ assign.cpp
+ buffer.cpp
+ character.cpp
+ connection.cpp
+ copy.cpp
+ derived-api.cpp
+ derived.cpp
+ descriptor-io.cpp
+ descriptor.cpp
+ dot-product.cpp
+ edit-input.cpp
+ edit-output.cpp
+ environment.cpp
+ external-unit.cpp
+ extrema.cpp
+ file.cpp
+ findloc.cpp
+ format.cpp
+ inquiry.cpp
+ internal-unit.cpp
+ io-api.cpp
+ io-api-minimal.cpp
+ io-error.cpp
+ io-stmt.cpp
+ iostat.cpp
+ matmul-transpose.cpp
+ matmul.cpp
+ memory.cpp
+ misc-intrinsic.cpp
+ namelist.cpp
+ non-tbp-dio.cpp
+ numeric.cpp
+ pointer.cpp
+ product.cpp
+ pseudo-unit.cpp
+ ragged.cpp
+ stat.cpp
+ sum.cpp
+ support.cpp
+ terminator.cpp
+ tools.cpp
+ transformational.cpp
+ type-code.cpp
+ type-info.cpp
+ unit.cpp
+ unit-map.cpp
+ utf.cpp
+)
+
+# List of source not used for GPU offloading.
+set(host_sources
+ ${FLANG_SOURCE_DIR}/module/iso_fortran_env_impl.f90
+ command.cpp
+ complex-powi.cpp
+ complex-reduction.c
+ exceptions.cpp
+ execute.cpp
+ extensions.cpp
+ main.cpp
+ random.cpp
+ reduce.cpp
+ reduction.cpp
+ stop.cpp
+ temporary-stack.cpp
+ time-intrinsic.cpp
+)
+
+file(GLOB_RECURSE public_headers
+ "${FLANG_RT_SOURCE_DIR}/include/flang_rt/*.h"
+ "${FLANG_SOURCE_DIR}/include/flang/Common/*.h"
+ )
+
+file(GLOB_RECURSE private_headers
+ "${FLANG_RT_SOURCE_DIR}/lib/flang_rt/*.h"
+ "${FLANG_SOURCE_DIR}/lib/Common/*.h"
+ )
+
+
+# Import changes from sibling FortranFloat128Math
+get_target_property(f128_sources
+ FortranFloat128MathILib INTERFACE_SOURCES
+ )
+if (f128_sources)
+ # The interface may define special macros for Float128Math files,
+ # so we need to propagate them.
+ get_target_property(f128_defs
+ FortranFloat128MathILib INTERFACE_COMPILE_DEFINITIONS
+ )
+ set_property(SOURCE ${f128_sources}
+ APPEND PROPERTY COMPILE_DEFINITIONS
+ ${f128_defs}
+ )
+ get_target_property(f128_include_dirs
+ FortranFloat128MathILib INTERFACE_INCLUDE_DIRECTORIES
+ )
+ set_property(SOURCE ${f128_sources}
+ APPEND PROPERTY INCLUDE_DIRECTORIES
+ ${f128_include_dirs}
+ )
+else ()
+ set(f128_sources "")
+endif ()
+
+
+set(sources ${supported_sources} ${host_sources} ${f128_sources})
+
+if (NOT WIN32)
+ add_flangrt_library(flang_rt STATIC
+ ${sources}
+ INSTALL_WITH_TOOLCHAIN
+ ADDITIONAL_HEADERS ${public_headers} ${private_headers}
+ )
+
+ enable_cuda_compilation(flang_rt "${supported_sources}")
+ enable_omp_offload_compilation(flang_rt "${supported_sources}")
+
+ # For unittests that depend on flang_rt. Should link to the static version
+ # of the library.
+ add_library(flang_rt.static ALIAS flang_rt)
+ add_library(flang_rt.unittest ALIAS flang_rt)
+else()
+ # Target for building all versions of the runtime
+ add_custom_target(flang_rt)
+ set_target_properties(flang_rt PROPERTIES FOLDER "Flang-RT/Meta")
+
+ function (add_win_flangrt_library libtype suffix msvc_lib)
+ set(name "flang_rt.${suffix}")
+ add_flangrt_library(${name} ${libtype}
+ ${sources}
+ ${ARGN}
+ ADDITIONAL_HEADERS ${public_headers} ${private_headers}
+ )
+
+ if (msvc_lib)
+ set_target_properties(${name}
+ PROPERTIES
+ MSVC_RUNTIME_LIBRARY "${msvc_lib}"
+ )
+ endif ()
+
+ # Setting an unique Fortran_MODULE_DIRECTORY is required for each variant to
+ # write a different .mod file.
+ set_target_properties(${name}
+ PROPERTIES
+ Fortran_MODULE_DIRECTORY "module.${suffix}"
+ )
+
+ enable_cuda_compilation(${name} "${supported_sources}")
+ enable_omp_offload_compilation(${name} "${supported_sources}")
+ add_dependencies(flang_rt ${name})
+ endfunction ()
+
+ # Variants of the static flang_rt for different versions of the msvc runtime.
+ #
+ # The dynamic/dynamic_dbg variants are not DLLs themselves, only require
+ # linking to msvcrt(d).dll.
+ # FIXME: Generating actual runtime DLLs is currently not possible. There are
+ # two roadblocks:
+ #
+ # * Flang emits /DEFAULTLIB:flang_rt.dynamic.lib into
+ # iso_fortran_env_impl.f90.obj. Because that file is itself part of
+ # flang_rt.dynamic, this results in a recursive dependency when invoking
+ # the linker.
+ #
+ # * The externally-visible functions must either be annotated with
+ # __declspec(dllexport), or listed in an exports file. A possible workaround
+ # is CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS which would also export the internal
+ # C++ symbols and still requires global data symbols to be annotated
+ # manually.
+ add_win_flangrt_library(STATIC static MultiThreaded INSTALL_WITH_TOOLCHAIN)
+ add_win_flangrt_library(STATIC static_dbg MultiThreadedDebug INSTALL_WITH_TOOLCHAIN)
+ add_win_flangrt_library(STATIC dynamic MultiThreadedDLL INSTALL_WITH_TOOLCHAIN)
+ add_win_flangrt_library(STATIC dynamic_dbg MultiThreadedDebugDLL INSTALL_WITH_TOOLCHAIN)
+
+ # Unittests link against LLVMSupport which is using CMake's default runtime
+ # library selection, which is either MultiThreadedDLL or MultiThreadedDebugDLL
+ # depending on the configuration. They have to match or linking will fail.
+ if (GENERATOR_IS_MULTI_CONFIG)
+ # We cannot select an ALIAS library because it may be different
+ # per configuration. Fallback to CMake's default.
+ add_win_flangrt_library(STATIC unittest "" EXCLUDE_FROM_ALL)
+ else ()
+ string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
+ if (build_type STREQUAL "debug")
+ add_library(flang_rt.unittest ALIAS flang_rt.dynamic_dbg)
+ else ()
+ add_library(flang_rt.unittest ALIAS flang_rt.dynamic)
+ endif ()
+ endif ()
+endif()
diff --git a/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt b/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
new file mode 100644
index 0000000000000..3c741ac93d64b
--- /dev/null
+++ b/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
@@ -0,0 +1,33 @@
+#===-- lib/flang_rt/CUDA/CMakeLists.txt ------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+
+add_flangrt_library(CufRuntime STATIC
+ allocatable.cpp
+ allocator.cpp
+ descriptor.cpp
+ kernel.cpp
+ memmove-function.cpp
+ memory.cpp
+ registration.cpp
+
+ # libCufRuntime depends on a certain version of CUDA. To be able to have
+ # multiple build of this library with different CUDA version, the version is
+ # added to the library name.
+ TARGET_PROPERTIES
+ OUTPUT_NAME "CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}"
+
+ INCLUDE_DIRECTORIES
+ PRIVATE ${CUDAToolkit_INCLUDE_DIRS}
+)
+
+target_link_libraries(CufRuntime
+ PUBLIC
+ flang_rt
+ CUDA::cudart_static
+)
diff --git a/flang-rt/lib/flang_rt/io-api-minimal.cpp b/flang-rt/lib/flang_rt/io-api-minimal.cpp
index c3234c78c10c8..cd5cf6bd3e699 100644
--- a/flang-rt/lib/flang_rt/io-api-minimal.cpp
+++ b/flang-rt/lib/flang_rt/io-api-minimal.cpp
@@ -150,7 +150,7 @@ bool IODEF(OutputLogical)(Cookie cookie, bool truth) {
// Provide own definition for `std::__libcpp_verbose_abort` to avoid dependency
// on the version provided by libc++.
-void std::__libcpp_verbose_abort(char const *format, ...) {
+void std::__libcpp_verbose_abort(char const *format, ...) noexcept {
va_list list;
va_start(list, format);
std::vfprintf(stderr, format, list);
diff --git a/flang-rt/test/CMakeLists.txt b/flang-rt/test/CMakeLists.txt
new file mode 100644
index 0000000000000..5ca07b66e4f9b
--- /dev/null
+++ b/flang-rt/test/CMakeLists.txt
@@ -0,0 +1,59 @@
+#===-- test/CMakeLists.txt -------------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+# Test runner infrastructure for Flang. This configures the Flang test trees
+# for use by Lit, and delegates to LLVM's lit test handlers.
+
+llvm_canonicalize_cmake_booleans(
+ FLANG_STANDALONE_BUILD
+ LLVM_BUILD_EXAMPLES
+ LLVM_BYE_LINK_INTO_TOOLS
+ LLVM_ENABLE_PLUGINS
+)
+
+configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+ MAIN_CONFIG
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+)
+
+if (TARGET FlangRTUnitTests)
+ configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
+ MAIN_CONFIG
+ ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
+ )
+
+ configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/NonGtestUnit/lit.site.cfg.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/NonGtestUnit/lit.site.cfg.py
+ MAIN_CONFIG
+ ${CMAKE_CURRENT_SOURCE_DIR}/NonGtestUnit/lit.cfg.py
+ )
+endif ()
+
+
+add_custom_target(flang-rt-test-depends)
+set_target_properties(flang-rt-test-depends PROPERTIES FOLDER "Flang-RT/Meta")
+add_dependencies(flang-rt-test-depends
+ FlangRTUnitTests
+ flang_rt.unittest
+ flang_rt.static
+ )
+
+add_lit_testsuite(check-flang-rt "Running the Flang-RT regression tests"
+ ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS flang-rt-test-depends
+ )
+set_target_properties(check-flang-rt PROPERTIES FOLDER "Flang-RT/Meta")
+
+add_lit_testsuites(flang-rt ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS flang-rt-test-depends
+ )
diff --git a/flang-rt/test/Driver/ctofortran.f90 b/flang-rt/test/Driver/ctofortran.f90
index 10c7adaccc958..e385e7974cdc1 100644
--- a/flang-rt/test/Driver/ctofortran.f90
+++ b/flang-rt/test/Driver/ctofortran.f90
@@ -1,8 +1,10 @@
! UNSUPPORTED: system-windows
-! REQUIRES: flang-rt
+! UNSUPPORTED: offload-cuda
+
! RUN: split-file %s %t
-! RUN: chmod +x %t/runtest.sh
-! RUN: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang | FileCheck %s
+! RUN: %clang -I"%include/flang" -c %t/cfile.c -o %t/cfile.o
+! RUN: %flang -L"%libdir" %t/ffile.f90 %t/cfile.o -o %t/ctofortran
+! RUN: env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:%libdir" %t/ctofortran | FileCheck %s
!--- ffile.f90
program fmain
@@ -66,24 +68,3 @@ end subroutine foo
foo(desc);
return;
}
-!--- runtest.sh
-#!/bin/bash
-TMPDIR=$1
-FFILE=$2
-CFILE=$3
-FLANG=$4
-shift 4
-FLAGS="$*"
-BINDIR=`dirname $FLANG`
-LIBDIR=$BINDIR/../lib
-CCOMP=$BINDIR/clang
-if [ -x $CCOMP ]
-then
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBDIR
- $CCOMP $FLAGS -c $CFILE -o $TMPDIR/cfile.o
- $FLANG $FLAGS $FFILE $TMPDIR/cfile.o -o $TMPDIR/ctofortran
- $TMPDIR/ctofortran # should print "PASS"
-else
- # No clang compiler, just pass by default
- echo "PASS"
-fi
diff --git a/flang-rt/test/Driver/exec.f90 b/flang-rt/test/Driver/exec.f90
index 9ca91ee24011c..5a81a1e4c3e45 100644
--- a/flang-rt/test/Driver/exec.f90
+++ b/flang-rt/test/Driver/exec.f90
@@ -1,10 +1,10 @@
-! UNSUPPORTED: system-windows
! REQUIRES: flang-rt
+! UNSUPPORTED: offload-cuda
+
! Verify that flang can correctly build executables.
-! RUN: %flang %s -o %t
-! RUN: env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:%llvmshlibdir" %t | FileCheck %s
-! RUN: rm -f %t
+! RUN: %flang -L"%libdir" %s -o %t
+! RUN: env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:%libdir" %t | FileCheck %s
! CHECK: Hello, World!
program hello
diff --git a/flang-rt/test/NonGtestUnit/lit.cfg.py b/flang-rt/test/NonGtestUnit/lit.cfg.py
new file mode 100644
index 0000000000000..4bee709b78f43
--- /dev/null
+++ b/flang-rt/test/NonGtestUnit/lit.cfg.py
@@ -0,0 +1,22 @@
+# -*- Python -*-
+
+import os
+
+import lit.formats
+
+# name: The name of this test suite.
+config.name = "flang-rt-OldUnit"
+
+# suffixes: A list of file extensions to treat as test files.
+# On Windows, ".exe" also matches the GTests and will execited redundantly.
+config.suffixes = [".test", ".exe"]
+
+# test_source_root: The root path where unit test binaries are located.
+config.test_source_root = os.path.join(config.flangrt_binary_dir, "unittests")
+
+# test_exec_root: The root path where tests should be run.
+# lit writes a '.lit_test_times.txt' file into this directory.
+config.test_exec_root = config.flang_rt_binary_test_dir
+
+# testFormat: The test format to use to interpret tests.
+config.test_format = lit.formats.ExecutableTest()
diff --git a/flang-rt/test/NonGtestUnit/lit.site.cfg.py.in b/flang-rt/test/NonGtestUnit/lit.site.cfg.py.in
new file mode 100644
index 0000000000000..8244b5b62d3aa
--- /dev/null
+++ b/flang-rt/test/NonGtestUnit/lit.site.cfg.py.in
@@ -0,0 +1,14 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import os
+
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.flang_rt_source_dir = "@FLANG_RT_SOURCE_DIR@"
+config.flangrt_binary_dir = "@FLANG_RT_BINARY_DIR@"
+config.flang_rt_binary_test_dir = os.path.dirname(__file__)
+
+import lit.llvm
+lit.llvm.initialize(lit_config, config)
+
+# Let the main config do the real work.
+lit_config.load_config(config, os.path.join(config.flang_rt_source_dir, 'test', 'NonGtestUnit', 'lit.cfg.py'))
diff --git a/flang-rt/test/Runtime/no-cpp-dep.c b/flang-rt/test/Runtime/no-cpp-dep.c
index c03029f0f3c26..2a416bdb27ee2 100644
--- a/flang-rt/test/Runtime/no-cpp-dep.c
+++ b/flang-rt/test/Runtime/no-cpp-dep.c
@@ -3,10 +3,11 @@ This test makes sure that flang's runtime does not depend on the C++ runtime
library. It tries to link this simple file against libflang_rt.a with
a C compiler.
-REQUIRES: c-compiler, flang-rt
+UNSUPPORTED: system-windows
+UNSUPPORTED: offload-cuda
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
-RUN: %cc -std=c99 %s -I%include %libruntime -lm \
+RUN: %cc -std=c99 %s -I%include -L"%libdir" -lflang_rt -lm \
RUN: %if system-aix %{-lpthread %}
RUN: rm a.out
*/
diff --git a/flang-rt/test/Unit/lit.cfg.py b/flang-rt/test/Unit/lit.cfg.py
new file mode 100644
index 0000000000000..516bc653f413f
--- /dev/null
+++ b/flang-rt/test/Unit/lit.cfg.py
@@ -0,0 +1,21 @@
+# -*- Python -*-
+
+import os
+
+import lit.formats
+
+# name: The name of this test suite.
+config.name = "flang-rt-Unit"
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = []
+
+# test_source_root: The root path where unit test binaries are located.
+config.test_source_root = os.path.join(config.flangrt_binary_dir, "unittests")
+
+# test_exec_root: The root path where tests should be run.
+# lit writes a '.lit_test_times.txt' file into this directory.
+config.test_exec_root = config.flang_rt_binary_test_dir
+
+# testFormat: The test format to use to interpret tests.
+config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, "Tests")
diff --git a/flang-rt/test/Unit/lit.site.cfg.py.in b/flang-rt/test/Unit/lit.site.cfg.py.in
new file mode 100644
index 0000000000000..ed6dea07bcdde
--- /dev/null
+++ b/flang-rt/test/Unit/lit.site.cfg.py.in
@@ -0,0 +1,15 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import os
+
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.flang_rt_source_dir = "@FLANG_RT_SOURCE_DIR@"
+config.flangrt_binary_dir = "@FLANG_RT_BINARY_DIR@"
+config.flang_rt_binary_test_dir = os.path.dirname(__file__)
+
+import lit.llvm
+lit.llvm.initialize(lit_config, config)
+
+# Let the main config do the real work.
+lit_config.load_config(config, os.path.join(config.flang_rt_source_dir, 'test', 'Unit', 'lit.cfg.py'))
diff --git a/flang-rt/test/lit.cfg.py b/flang-rt/test/lit.cfg.py
new file mode 100644
index 0000000000000..08f3f1121c896
--- /dev/null
+++ b/flang-rt/test/lit.cfg.py
@@ -0,0 +1,102 @@
+# -*- Python -*-
+
+import shlex
+import lit.util
+
+from lit.llvm import llvm_config
+from lit.llvm.subst import ToolSubst, FindTool
+
+
+def shjoin(args, sep=" "):
+ return sep.join([shlex.quote(arg) for arg in args])
+
+
+# Configuration file for the 'lit' test runner.
+
+# name: The name of this test suite.
+config.name = "flang-rt"
+
+# testFormat: The test format to use to interpret tests.
+#
+# For now we require '&&' between commands, until they get globally killed and
+# the test runner updated.
+config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = [
+ ".c",
+ ".cpp",
+ ".f",
+ ".F",
+ ".ff",
+ ".FOR",
+ ".for",
+ ".f77",
+ ".f90",
+ ".F90",
+ ".ff90",
+ ".f95",
+ ".F95",
+ ".ff95",
+ ".fpp",
+ ".FPP",
+ ".cuf",
+ ".CUF",
+ ".f18",
+ ".F18",
+ ".f03",
+ ".F03",
+ ".f08",
+ ".F08",
+ ".ll",
+ ".fir",
+ ".mlir",
+]
+
+llvm_config.use_default_substitutions()
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# test_exec_root: The root path where tests should be run.
+# lit writes a '.lit_test_times.txt' file into this directory.
+config.test_exec_root = config.flang_rt_binary_test_dir
+
+# On MacOS, -isysroot is needed to build binaries.
+isysroot_flag = []
+if config.osx_sysroot:
+ isysroot_flag = ["-isysroot", config.osx_sysroot]
+
+tools = [
+ ToolSubst(
+ "%flang",
+ command=config.flang,
+ extra_args=isysroot_flag,
+ unresolved="fatal",
+ ),
+ ToolSubst(
+ "%clang",
+ command=FindTool("clang"),
+ extra_args=isysroot_flag,
+ unresolved="fatal",
+ ),
+ ToolSubst("%cc",
+ command=config.cc,
+ extra_args=isysroot_flag,
+ unresolved="fatal"
+ ),
+]
+llvm_config.add_tool_substitutions(tools)
+
+# Let tests find LLVM's standard tools (FileCheck, split-file, not, ...)
+llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
+
+# Include path for C headers that define Flang's Fortran ABI.
+config.substitutions.append(("%include", os.path.join(config.flang_source_dir, "include")))
+
+# Library path of libflang_rt.a (for lib search path when using non-Flang driver for linking)
+config.substitutions.append(("%libdir", config.flang_rt_output_resource_lib_dir))
+
+# For CUDA offloading, additional steps (device linking) and libraries (cudart) are needed.
+if config.flang_rt_experimental_offload_support == "CUDA":
+ config.available_features.add("offload-cuda")
diff --git a/flang-rt/test/lit.site.cfg.py.in b/flang-rt/test/lit.site.cfg.py.in
new file mode 100644
index 0000000000000..662d076b1fe24
--- /dev/null
+++ b/flang-rt/test/lit.site.cfg.py.in
@@ -0,0 +1,19 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import sys
+
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.flang_source_dir = "@FLANG_SOURCE_DIR@"
+config.flang_rt_source_dir = "@FLANG_RT_SOURCE_DIR@"
+config.flang_rt_binary_test_dir = os.path.dirname(__file__)
+config.flang_rt_output_resource_lib_dir = "@FLANG_RT_OUTPUT_RESOURCE_LIB_DIR@"
+config.flang_rt_experimental_offload_support = "@FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT@"
+config.cc = "@CMAKE_C_COMPILER@"
+config.flang = "@CMAKE_Fortran_COMPILER@"
+config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@")
+
+import lit.llvm
+lit.llvm.initialize(lit_config, config)
+
+# Let the main config do the real work.
+lit_config.load_config(config, os.path.join(config.flang_rt_source_dir, 'test', 'lit.cfg.py'))
diff --git a/flang-rt/unittests/CMakeLists.txt b/flang-rt/unittests/CMakeLists.txt
new file mode 100644
index 0000000000000..ca94805f1403b
--- /dev/null
+++ b/flang-rt/unittests/CMakeLists.txt
@@ -0,0 +1,111 @@
+#===-- unittests/CMakeLists.txt --------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+# LLVM uses a modified version of GTest that uses LLVMSupport for console
+# output. Therefore it also needs to include files from LLVM. Unfortunately,
+# LLVM/GTest doesn't add the include search path itself. Limiting the scope
+# using target_include_directories does not work because with
+# LLVM_INSTALL_GTEST=ON, as llvm_gtest is an IMPORT library.
+include_directories("${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}")
+
+# Add GTest if not already present.
+# Using a function so LLVM_SUBPROJECT_TITLE does not propagate.
+function (build_gtest)
+ set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
+ add_subdirectory("${LLVM_THIRD_PARTY_DIR}/unittest" "${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest")
+endfunction ()
+if (NOT TARGET llvm_gtest)
+ build_gtest()
+endif ()
+
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
+
+# Target that depends on all unittests
+add_custom_target(FlangRTUnitTests)
+set_target_properties(FlangRTUnitTests PROPERTIES FOLDER "Flang-RT/Meta")
+
+
+function(add_flangrt_unittest_offload_properties target)
+ # Set CUDA_RESOLVE_DEVICE_SYMBOLS.
+ if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
+ set_target_properties(${target}
+ PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON
+ )
+ endif()
+ # Enable OpenMP offload during linking. We may need to replace
+ # LINK_OPTIONS with COMPILE_OPTIONS when there are OpenMP offload
+ # unittests.
+ #
+ # FIXME: replace 'native' in --offload-arch option with the list
+ # of targets that Fortran Runtime was built for.
+ if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
+ set_target_properties(${target}
+ PROPERTIES LINK_OPTIONS
+ "-fopenmp;--offload-arch=native"
+ )
+ endif()
+endfunction()
+
+
+function(add_flangrt_unittest test_dirname)
+ cmake_parse_arguments(ARG
+ ""
+ ""
+ "LINK_LIBS"
+ ${ARGN})
+
+ add_unittest(FlangRTUnitTests ${test_dirname} ${ARG_UNPARSED_ARGUMENTS})
+
+ target_include_directories(${test_dirname} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
+ target_include_directories(${test_dirname} PRIVATE "${FLANG_SOURCE_DIR}/include")
+ target_link_libraries(${test_dirname} PRIVATE ${ARG_LINK_LIBS})
+ add_flangrt_unittest_offload_properties(${test_dirname})
+
+ # Required because LLVMSupport is compiled with this option.
+ # FIXME: According to CMake documentation, this is the default. Why is it
+ # needed? LLVM's add_unittest doesn't set it either.
+ set_target_properties(${test_dirname}
+ PROPERTIES
+ MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
+ )
+endfunction()
+
+function(add_flangrt_nongtest_unittest test_name)
+ cmake_parse_arguments(ARG
+ "SLOW_TEST"
+ ""
+ "LINK_LIBS"
+ ${ARGN})
+
+ if(ARG_SLOW_TEST)
+ set(suffix .slow)
+ else()
+ set(suffix .test)
+ endif()
+
+ add_executable(${test_name}${suffix} EXCLUDE_FROM_ALL ${ARG_UNPARSED_ARGUMENTS})
+ set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Flang-RT/Tests/Unit")
+
+ target_include_directories(${test_name}${suffix} PRIVATE
+ "${FLANG_RT_SOURCE_DIR}/include"
+ "${FLANG_SOURCE_DIR}/include"
+ )
+ target_link_libraries(${test_name}${suffix} PRIVATE NonGTestTesting ${ARG_LINK_LIBS})
+
+ if(NOT ARG_SLOW_TEST)
+ add_dependencies(FlangRTUnitTests ${test_name}${suffix})
+ endif()
+
+ add_flangrt_unittest_offload_properties(${test_name}${suffix})
+endfunction()
+
+add_subdirectory(Evaluate)
+add_subdirectory(Runtime)
diff --git a/flang-rt/unittests/Evaluate/CMakeLists.txt b/flang-rt/unittests/Evaluate/CMakeLists.txt
new file mode 100644
index 0000000000000..15b813bcb19da
--- /dev/null
+++ b/flang-rt/unittests/Evaluate/CMakeLists.txt
@@ -0,0 +1,21 @@
+#===-- unittests/Evaluate/CMakeLists.txt -----------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+add_flangrt_nongtest_unittest(reshape
+ reshape.cpp
+
+ LINK_LIBS
+ flang_rt.unittest
+)
+
+add_flangrt_nongtest_unittest(ISO-Fortran-binding
+ ISO-Fortran-binding.cpp
+
+ LINK_LIBS
+ flang_rt.unittest
+)
diff --git a/flang-rt/unittests/Runtime/CMakeLists.txt b/flang-rt/unittests/Runtime/CMakeLists.txt
new file mode 100644
index 0000000000000..32f12b14caca7
--- /dev/null
+++ b/flang-rt/unittests/Runtime/CMakeLists.txt
@@ -0,0 +1,48 @@
+#===-- unittests/Runtime/CMakeLists.txt ------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+add_flangrt_unittest(RuntimeTests
+ AccessTest.cpp
+ Allocatable.cpp
+ ArrayConstructor.cpp
+ BufferTest.cpp
+ CharacterTest.cpp
+ CommandTest.cpp
+ Complex.cpp
+ CrashHandlerFixture.cpp
+ Derived.cpp
+ ExternalIOTest.cpp
+ Format.cpp
+ Inquiry.cpp
+ ListInputTest.cpp
+ LogicalFormatTest.cpp
+ Matmul.cpp
+ MatmulTranspose.cpp
+ MiscIntrinsic.cpp
+ Namelist.cpp
+ Numeric.cpp
+ NumericalFormatTest.cpp
+ Pointer.cpp
+ Ragged.cpp
+ Random.cpp
+ Reduction.cpp
+ RuntimeCrashTest.cpp
+ Stop.cpp
+ Support.cpp
+ Time.cpp
+ TemporaryStack.cpp
+ Transformational.cpp
+
+ LINK_LIBS
+ flang_rt.unittest
+)
+target_compile_definitions(RuntimeTests PRIVATE NOT_EXE="${LLVM_TOOLS_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}")
+
+if (FLANG_RT_ENABLE_CUF)
+ add_subdirectory(CUDA)
+endif ()
diff --git a/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
new file mode 100644
index 0000000000000..37b117234208c
--- /dev/null
+++ b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
@@ -0,0 +1,18 @@
+#===-- unittests/Runtime/CUDA/CMakeLists.txt -------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+add_flangrt_unittest(FlangCufRuntimeTests
+ Allocatable.cpp
+ AllocatorCUF.cpp
+ Memory.cpp
+)
+
+target_link_libraries(FlangCufRuntimeTests
+ PRIVATE
+ CufRuntime
+)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 0044779da011d..38004c149b783 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -35,17 +35,6 @@ endif()
option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF)
-# The out of tree builds of the compiler and the Fortran runtime
-# must use the same setting of FLANG_RUNTIME_F128_MATH_LIB
-# to be composable. Failure to synchronize this setting may result
-# in linking errors or fatal failures in F128 runtime functions.
-set(FLANG_RUNTIME_F128_MATH_LIB "" CACHE STRING
- "Specifies the target library used for implementing IEEE-754 128-bit float \
- math in F18 runtime, e.g. it might be libquadmath for targets where \
- REAL(16) is mapped to __float128, or libm for targets where REAL(16) \
- is mapped to long double, etc."
- )
-
# Check for a standalone build and configure as appropriate from
# there.
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@@ -248,7 +237,25 @@ else()
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
endif()
-option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" ON)
+set(FLANG_INCLUDE_RUNTIME_default ON)
+if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
+ set(FLANG_INCLUDE_RUNTIME_default OFF)
+endif ()
+option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" FLANG_INCLUDE_RUNTIME_default)
+if (FLANG_INCLUDE_RUNTIME)
+ if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
+ message(WARNING "Building Flang-RT using LLVM_ENABLE_RUNTIMES. FLANG_INCLUDE_RUNTIME=${FLANG_INCLUDE_RUNTIME} ignored.")
+ set(FLANG_INCLUDE_RUNTIME OFF)
+ else ()
+ message(STATUS "Building flang_rt in-tree")
+ endif ()
+else ()
+ if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
+ message(STATUS "Building Flang-RT using LLVM_ENABLE_RUNTIMES.")
+ else ()
+ message(STATUS "Not building Flang-RT. For a usable Fortran toolchain, compile a standalone Flang-RT")
+ endif ()
+endif ()
set(FLANG_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
@@ -358,20 +365,6 @@ if (FLANG_REPOSITORY_STRING)
add_definitions(-DFLANG_REPOSITORY_STRING="${FLANG_REPOSITORY_STRING}")
endif()
-if (FLANG_RUNTIME_F128_MATH_LIB)
- add_compile_definitions(
- FLANG_RUNTIME_F128_MATH_LIB="${FLANG_RUNTIME_F128_MATH_LIB}"
- )
-endif()
-
-include(TestBigEndian)
-test_big_endian(IS_BIGENDIAN)
-if (IS_BIGENDIAN)
- add_compile_definitions(FLANG_BIG_ENDIAN=1)
-else ()
- add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
-endif ()
-
# Configure Flang's Version.inc file.
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/flang/Version.inc.in
@@ -469,6 +462,7 @@ if (APPLE)
endif()
include(AddFlang)
+include(FlangCommon)
if (FLANG_INCLUDE_TESTS)
add_compile_definitions(FLANG_INCLUDE_TESTS=1)
@@ -562,7 +556,12 @@ include(GetClangResourceDir)
get_clang_resource_dir(HEADER_BINARY_DIR PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. SUBDIR include)
configure_file(
${FLANG_SOURCE_DIR}/include/flang/ISO_Fortran_binding.h
- ${HEADER_BINARY_DIR}/ISO_Fortran_binding.h)
+ ${HEADER_BINARY_DIR}/ISO_Fortran_binding.h COPYONLY)
+
+# llvm-test-suite fails if it does not find the the file in this location.
+configure_file(
+ ${FLANG_SOURCE_DIR}/include/flang/ISO_Fortran_binding.h
+ ${LLVM_RUNTIME_OUTPUT_INTDIR}/../include/flang COPYONLY)
# And also install it into the install area
get_clang_resource_dir(HEADER_INSTALL_DIR SUBDIR include)
diff --git a/flang/cmake/modules/FlangCommon.cmake b/flang/cmake/modules/FlangCommon.cmake
new file mode 100644
index 0000000000000..1b8606843b224
--- /dev/null
+++ b/flang/cmake/modules/FlangCommon.cmake
@@ -0,0 +1,43 @@
+#===-- cmake/modules/FlangCommon.txt ----------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+#
+# CMake definitions shared between Flang and Flang-RT
+#
+#===------------------------------------------------------------------------===#
+
+# The out of tree builds of the compiler and the Fortran runtime
+# must use the same setting of FLANG_RUNTIME_F128_MATH_LIB
+# to be composable. Failure to synchronize this setting may result
+# in linking errors or fatal failures in F128 runtime functions.
+set(FLANG_RUNTIME_F128_MATH_LIB "" CACHE STRING
+ "Specifies the target library used for implementing IEEE-754 128-bit float \
+ math in F18 runtime, e.g. it might be libquadmath for targets where \
+ REAL(16) is mapped to __float128, or libm for targets where REAL(16) \
+ is mapped to long double, etc."
+ )
+if (FLANG_RUNTIME_F128_MATH_LIB)
+ add_compile_definitions(FLANG_RUNTIME_F128_MATH_LIB="${FLANG_RUNTIME_F128_MATH_LIB}")
+endif()
+
+# Check if 128-bit float computations can be done via long double
+check_cxx_source_compiles(
+ "#include <cfloat>
+ #if LDBL_MANT_DIG != 113
+ #error LDBL_MANT_DIG != 113
+ #endif
+ int main() { return 0; }
+ "
+ HAVE_LDBL_MANT_DIG_113)
+
+include(TestBigEndian)
+test_big_endian(IS_BIGENDIAN)
+if (IS_BIGENDIAN)
+ add_compile_definitions(FLANG_BIG_ENDIAN=1)
+else ()
+ add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
+endif ()
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index ffde50b6f481e..47ba268b3e763 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -30,7 +30,7 @@ https://llvm.org/docs/GettingStarted.html.
All of the examples below use GCC as the C/C++ compilers and ninja as the build
tool.
-### Building flang in tree
+### Building flang in tree with bootstrapped Flang-RT
Building flang in tree means building flang along with all of the projects on
which it depends. These projects include mlir, clang, flang, openmp, and
compiler-rt. Note that compiler-rt is only needed to access libraries that
@@ -82,7 +82,7 @@ cmake \
-DLLVM_TARGETS_TO_BUILD=host \
-DLLVM_LIT_ARGS=-v \
-DLLVM_ENABLE_PROJECTS="clang;mlir;flang;openmp" \
- -DLLVM_ENABLE_RUNTIMES="compiler-rt" \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;flang_rt" \
../llvm-project/llvm
ninja
@@ -101,7 +101,7 @@ the cmake command above:
To run the flang tests on this build, execute the command in the "build"
directory:
```bash
-ninja check-flang
+ninja check-flang check-flang-rt
```
To create the installed files:
@@ -111,34 +111,6 @@ ninja install
echo "latest" > $INSTALLDIR/bin/versionrc
```
-To build compiler-rt:
-```bash
-cd $ROOTDIR
-rm -rf compiler-rt
-mkdir compiler-rt
-cd compiler-rt
-CC=$INSTALLDIR/bin/clang \
-CXX=$INSTALLDIR/bin/clang++ \
-cmake \
- -G Ninja \
- ../llvm-project/compiler-rt \
- -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_INSTALL_PREFIX=$INSTALLDIR \
- -DCMAKE_CXX_STANDARD=11 \
- -DCMAKE_C_CFLAGS=-mlong-double-128 \
- -DCMAKE_CXX_CFLAGS=-mlong-double-128 \
- -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
- -DCOMPILER_RT_BUILD_ORC=OFF \
- -DCOMPILER_RT_BUILD_XRAY=OFF \
- -DCOMPILER_RT_BUILD_MEMPROF=OFF \
- -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
- -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
- -DLLVM_CONFIG_PATH=$INSTALLDIR/bin/llvm-config
-
-ninja
-ninja install
-```
-
Note that these instructions specify flang as one of the projects to build in
the in tree build. This is not strictly necessary for subsequent standalone
builds, but doing so lets you run the flang tests to verify that the source
@@ -192,31 +164,57 @@ directory:
ninja check-flang
```
-### Building flang runtime for accelerators
+To build Flang-RT (required for linking executables):
+```bash
+cd $ROOTDIR
+rm -rf flang-rt
+mkdir flang-rt
+cd flang-rt
+CC=$INSTALLDIR/bin/clang \
+CXX=$INSTALLDIR/bin/clang++ \
+cmake \
+ -G Ninja \
+ ../llvm-project/runtimes \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=$INSTALLDIR \
+ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
+ -DLLVM_BINARY_DIR=$ROOTDIR/build \
+ -DLLVM_Fortran_COMPILER=$INSTALLDIR/bin/flang \
+ -DLLVM_Fortran_COMPILER_WORKS=ON
+
+ninja
+ninja check-flang-rt
+ninja install
+```
+
+
+### Building Flang-RT for accelerators
Flang runtime can be built for accelerators in experimental mode, i.e.
complete enabling is WIP. CUDA and OpenMP target offload builds
are currently supported.
-#### Building out-of-tree
+#### Bootstrapping Build of Flang-RT
##### CUDA build
Clang with NVPTX backend and NVCC compilers are supported.
```bash
-cd llvm-project/flang
+cd llvm-project
rm -rf build_flang_runtime
mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DFLANG_EXPERIMENTAL_CUDA_RUNTIME=ON \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
+ -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CUDA_COMPILER=clang \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
- ../runtime/
-make -j flang-rt
+ ../runtimes/
+make flang-rt
```
Note that the used version of `clang` must [support](https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#cuda-support)
@@ -225,21 +223,22 @@ CUDA toolkit installations, please use `-DCUDAToolkit_ROOT=/some/path`
to specify the compatible version.
```bash
-cd llvm-project/flang
+cd llvm-project
rm -rf build_flang_runtime
mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DFLANG_EXPERIMENTAL_CUDA_RUNTIME=ON \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
+ -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CUDA_COMPILER=nvcc \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
- ../runtime/
+ ../runtimes/
-make -j flang-rt
+make flang-rt
```
Note that `nvcc` might limit support to certain
@@ -251,50 +250,59 @@ code. Note that the packaging of the libraries is different
between [Clang](https://clang.llvm.org/docs/OffloadingDesign.html#linking-target-device-code) and NVCC, so the library must be linked using
compatible compiler drivers.
-#### Building in-tree
+#### Building in-tree (bootstrap build)
One may build Flang runtime library along with building Flang itself
by providing these additional CMake variables on top of the Flang in-tree
build config:
For example:
```bash
- -DFLANG_EXPERIMENTAL_CUDA_RUNTIME=ON \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
+ -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CUDA_COMPILER=clang \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
+ ../llvm
```
Or:
```bash
- -DFLANG_EXPERIMENTAL_CUDA_RUNTIME=ON \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
+ -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_CUDA_COMPILER=nvcc \
-DCMAKE_CUDA_HOST_COMPILER=g++ \
+ ../llvm
```
-Normal `make -j check-flang` will work with such CMake configuration.
+Normal `make check-flang` will work with such CMake configuration.
+Consider building in parallel using the `-j<jobs>` flag, where `<jobs>` is a
+number low enough for all build jobs to fit into the available RAM. Using
+the number of harware threads (`nprocs`) is likely too much for most
+commodity computers.
##### OpenMP target offload build
Only Clang compiler is currently supported.
```bash
-cd llvm-project/flang
+cd llvm-project
rm -rf build_flang_runtime
mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DFLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD="host_device" \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
+ -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT="OpenMP" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
- -DFLANG_OMP_DEVICE_ARCHITECTURES="all" \
- ../runtime/
+ -DFLANG_RT_DEVICE_ARCHITECTURES=all \
+ ../runtimes/
-make -j flang-rt
+make flang-rt
```
The result of the build is a "device-only" library, i.e. the host
diff --git a/flang/docs/ReleaseNotes.md b/flang/docs/ReleaseNotes.md
index a163b4f4ed67d..2633b27f0093c 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -36,7 +36,13 @@ page](https://llvm.org/releases/).
## Build System Changes
- * FortranRuntime has been renamed to `flang_rt`.
+ * The Fortran Runtime library has been move to a new top-level directory
+ named "flang-rt". The library was also renamed from `FortranRuntime` to
+ `flang_rt`. It now supports the
+ LLVM_ENABLE_RUNTIMES mechanism to build flang-rt for multiple target
+ triples. libflang_rt.a will now be emitted into Clang's per-target
+ resource directory (next to libclang_rt.*.*) where it is also found by
+ Flang's driver.
## New Issues Found
diff --git a/flang/module/iso_fortran_env_impl.f90 b/flang/module/iso_fortran_env_impl.f90
index 5408e7de37001..3ee00acfde4d7 100644
--- a/flang/module/iso_fortran_env_impl.f90
+++ b/flang/module/iso_fortran_env_impl.f90
@@ -8,7 +8,7 @@
! This MODULE implements part of the ISO_FORTRAN_ENV module file, which
! partially requires linkable symbols for some entities defined
-! (e.g., real_kinds).
+! (e.g., real_kinds). This file is also used by Flang-RT.
module iso_fortran_env_impl
implicit none
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index 08ba586e1226d..0ba80f9a03f2e 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -166,26 +166,6 @@
if config.flang_include_runtime:
config.available_features.add("flang-rt")
-# Define some variables to help us test that the flang runtime doesn't depend on
-# the C++ runtime libraries. For this we need a C compiler. If for some reason
-# we don't have one, we can just disable the test.
-if config.flang_include_runtime and config.cc:
- libruntime = os.path.join(config.flang_lib_dir, "libflang_rt.a")
- include = os.path.join(config.flang_src_dir, "include")
-
- if (
- os.path.isfile(libruntime)
- and os.path.isdir(include)
- ):
- config.available_features.add("c-compiler")
- tools.append(
- ToolSubst(
- "%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal"
- )
- )
- tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
- tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
-
# Add all the tools and their substitutions (if applicable). Use the search paths provided for
# finding the tools.
if config.flang_standalone_build:
diff --git a/flang/test/lit.site.cfg.py.in b/flang/test/lit.site.cfg.py.in
index 697ba3fa79763..5b66e592bcfee 100644
--- a/flang/test/lit.site.cfg.py.in
+++ b/flang/test/lit.site.cfg.py.in
@@ -11,18 +11,15 @@ config.llvm_target_triple_env = "@LLVM_TARGET_TRIPLE_ENV@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
config.flang_obj_root = "@FLANG_BINARY_DIR@"
-config.flang_src_dir = "@FLANG_SOURCE_DIR@"
config.flang_tools_dir = lit_config.substitute("@FLANG_TOOLS_DIR@")
config.flang_intrinsic_modules_dir = "@FLANG_INTRINSIC_MODULES_DIR@"
config.flang_llvm_tools_dir = "@CMAKE_BINARY_DIR@/bin"
-config.flang_lib_dir = "@CMAKE_BINARY_DIR@/lib"
config.flang_test_triple = "@FLANG_TEST_TARGET_TRIPLE@"
config.flang_examples = @LLVM_BUILD_EXAMPLES@
config.python_executable = "@PYTHON_EXECUTABLE@"
config.flang_standalone_build = @FLANG_STANDALONE_BUILD@
config.has_plugins = @LLVM_ENABLE_PLUGINS@
config.linked_bye_extension = @LLVM_BYE_LINK_INTO_TOOLS@
-config.cc = "@CMAKE_C_COMPILER@"
config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@")
config.targets_to_build = "@TARGETS_TO_BUILD@"
config.default_sysroot = "@DEFAULT_SYSROOT@"
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index f14065ab03799..9a1dc824658fd 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -157,12 +157,18 @@ if ("libc" IN_LIST LLVM_ENABLE_PROJECTS)
"https://libc.llvm.org/ for building the runtimes.")
endif()
+if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
+ if (NOT "flang" IN_LIST LLVM_ENABLE_PROJECTS)
+ message(FATAL_ERROR "Flang is not enabled, but is required for the Flang-RT runtime")
+ endif ()
+endif ()
+
# Select the runtimes to build
#
# As we migrate runtimes to using the bootstrapping build, the set of default runtimes
# should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
-set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload")
+set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt")
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 55422c2a4c023..caccb62d666ce 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -38,6 +38,8 @@ endfunction()
# llvm_ExternalProject_Add(name source_dir ...
+# ENABLE_FORTRAN
+# External project requires the Flang compiler
# USE_TOOLCHAIN
# Use just-built tools (see TOOLCHAIN_TOOLS)
# EXCLUDE_FROM_ALL
@@ -65,7 +67,7 @@ endfunction()
# )
function(llvm_ExternalProject_Add name source_dir)
cmake_parse_arguments(ARG
- "USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL;ALWAYS_CLEAN"
+ "ENABLE_FORTRAN;USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL;ALWAYS_CLEAN"
"SOURCE_DIR;FOLDER"
"CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS;PASSTHROUGH_PREFIXES;STRIP_TOOL;TARGET_TRIPLE"
${ARGN})
@@ -93,6 +95,9 @@ function(llvm_ExternalProject_Add name source_dir)
if(NOT ARG_TOOLCHAIN_TOOLS)
set(ARG_TOOLCHAIN_TOOLS clang)
+ if (ARG_ENABLE_FORTRAN)
+ list(APPEND ARG_TOOLCHAIN_TOOLS flang)
+ endif ()
# AIX 64-bit XCOFF and big AR format is not yet supported in some of these tools.
if(NOT _cmake_system_name STREQUAL AIX)
list(APPEND ARG_TOOLCHAIN_TOOLS lld llvm-ar llvm-ranlib llvm-nm llvm-objdump)
@@ -143,6 +148,10 @@ function(llvm_ExternalProject_Add name source_dir)
set(CLANG_IN_TOOLCHAIN On)
endif()
+ if(flang IN_LIST TOOLCHAIN_TOOLS)
+ set(FLANG_IN_TOOLCHAIN On)
+ endif()
+
if(RUNTIME_LIBRARIES AND CLANG_IN_TOOLCHAIN)
list(APPEND TOOLCHAIN_BINS ${RUNTIME_LIBRARIES})
endif()
@@ -225,6 +234,9 @@ function(llvm_ExternalProject_Add name source_dir)
-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX})
endif()
endif()
+ if(FLANG_IN_TOOLCHAIN)
+ list(APPEND compiler_args -DCMAKE_Fortran_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/flang${CMAKE_EXECUTABLE_SUFFIX})
+ endif()
if(lld IN_LIST TOOLCHAIN_TOOLS)
if(is_msvc_target)
list(APPEND compiler_args -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link${CMAKE_EXECUTABLE_SUFFIX})
@@ -308,6 +320,7 @@ function(llvm_ExternalProject_Add name source_dir)
set(compiler_args -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
-DCMAKE_LINKER=${CMAKE_LINKER}
-DCMAKE_AR=${CMAKE_AR}
-DCMAKE_RANLIB=${CMAKE_RANLIB}
@@ -357,6 +370,7 @@ function(llvm_ExternalProject_Add name source_dir)
if(ARG_TARGET_TRIPLE)
list(APPEND compiler_args -DCMAKE_C_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
list(APPEND compiler_args -DCMAKE_CXX_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
+ list(APPEND compiler_args -DCMAKE_Fortran_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
list(APPEND compiler_args -DCMAKE_ASM_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
endif()
diff --git a/llvm/projects/CMakeLists.txt b/llvm/projects/CMakeLists.txt
index 08f2fa522420b..f254cf10806d7 100644
--- a/llvm/projects/CMakeLists.txt
+++ b/llvm/projects/CMakeLists.txt
@@ -11,7 +11,8 @@ foreach(entry ${entries})
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libunwind) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/test-suite) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/openmp) AND
- (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/cross-project-tests))
+ (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/cross-project-tests) AND
+ (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/flang-rt))
get_filename_component(entry_name "${entry}" NAME)
add_llvm_external_project(${entry_name})
endif()
@@ -37,6 +38,7 @@ if(${LLVM_BUILD_RUNTIME})
if(NOT LLVM_BUILD_EXTERNAL_COMPILER_RT)
add_llvm_external_project(compiler-rt)
endif()
+ add_llvm_external_project(flang-rt)
endif()
add_llvm_external_project(dragonegg)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 70e85c123e412..2370b41fb7f0b 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -230,7 +230,7 @@ foreach(entry ${runtimes})
endforeach()
function(runtime_default_target)
- cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS;PREFIXES" ${ARGN})
+ cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS;PREFIXES;EXTRA_ARGS" ${ARGN})
include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
set(SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE)
@@ -270,14 +270,16 @@ function(runtime_default_target)
-DLLVM_BUILD_TOOLS=${LLVM_BUILD_TOOLS}
-DCMAKE_C_COMPILER_WORKS=ON
-DCMAKE_CXX_COMPILER_WORKS=ON
+ -DCMAKE_Fortran_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
${COMMON_CMAKE_ARGS}
${RUNTIMES_CMAKE_ARGS}
${ARG_CMAKE_ARGS}
PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
LLVM_USE_LINKER
- CUDA # For runtimes that may look for the CUDA SDK (libc, offload)
+ CUDA CMAKE_CUDA # For runtimes that may look for the CUDA compiler and/or SDK (libc, offload, flang-rt)
FFI # offload uses libffi
+ FLANG_RUNTIME # Shared between Flang and Flang-RT
${ARG_PREFIXES}
EXTRA_TARGETS ${extra_targets}
${test_targets}
@@ -287,7 +289,7 @@ function(runtime_default_target)
USE_TOOLCHAIN
TARGET_TRIPLE ${LLVM_TARGET_TRIPLE}
FOLDER "Runtimes"
- ${EXTRA_ARGS})
+ ${EXTRA_ARGS} ${ARG_EXTRA_ARGS})
endfunction()
# runtime_register_target(name)
@@ -404,6 +406,7 @@ function(runtime_register_target name)
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
-DCMAKE_C_COMPILER_WORKS=ON
-DCMAKE_CXX_COMPILER_WORKS=ON
+ -DCMAKE_Fortran_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
-DLLVM_RUNTIMES_TARGET=${name}
@@ -463,10 +466,13 @@ if(build_runtimes)
# together in a single CMake invocation.
set(extra_deps "")
set(extra_cmake_args "")
+ set(extra_args "")
if(LLVM_INCLUDE_TESTS)
foreach(dep FileCheck
clang
+ clang-offload-packager
+ flang
count
lld
lli
@@ -549,19 +555,24 @@ if(build_runtimes)
if(LLVM_LIBC_FULL_BUILD)
list(APPEND extra_cmake_args "-DLLVM_LIBC_FULL_BUILD=ON")
endif()
+ if("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
+ list(APPEND extra_args ENABLE_FORTRAN)
+ endif ()
if(NOT LLVM_RUNTIME_TARGETS)
runtime_default_target(
DEPENDS ${builtins_dep} ${extra_deps}
CMAKE_ARGS ${extra_cmake_args}
- PREFIXES ${prefixes})
+ PREFIXES ${prefixes}
+ EXTRA_ARGS ${extra_args})
set(test_targets check-runtimes)
else()
if("default" IN_LIST LLVM_RUNTIME_TARGETS)
runtime_default_target(
DEPENDS ${builtins_dep} ${extra_deps}
CMAKE_ARGS ${extra_cmake_args}
- PREFIXES ${prefixes})
+ PREFIXES ${prefixes}
+ EXTRA_ARGS ${extra_args})
list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
else()
add_custom_target(runtimes)
@@ -608,7 +619,7 @@ if(build_runtimes)
runtime_register_target(${name}
DEPENDS ${builtins_dep_name} ${extra_deps}
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${extra_cmake_args}
- EXTRA_ARGS TARGET_TRIPLE ${name})
+ EXTRA_ARGS TARGET_TRIPLE ${name} ${extra_args})
endforeach()
foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
@@ -620,7 +631,7 @@ if(build_runtimes)
-DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
${extra_cmake_args}
BASE_NAME ${name}
- EXTRA_ARGS TARGET_TRIPLE ${name})
+ EXTRA_ARGS TARGET_TRIPLE ${name} ${extra_args})
endforeach()
endforeach()
endif()
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 4a6b317a03f66..7f1e2ae065d6c 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -36,7 +36,7 @@ list(INSERT CMAKE_MODULE_PATH 0
# We order libraries to mirror roughly how they are layered, except that compiler-rt can depend
# on libc++, so we put it after.
set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload")
-set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc")
+set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc;flang-rt")
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
if(LLVM_ENABLE_RUNTIMES STREQUAL "all" )
>From b05c9a033158aea459d51ff34b8ec47e72f85740 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 24 Jan 2025 16:51:27 +0100
Subject: [PATCH 08/41] [Flang-RT] Build libflang_rt.so
---
flang-rt/CMakeLists.txt | 30 ++
flang-rt/cmake/modules/AddFlangRT.cmake | 324 ++++++++++++------
.../cmake/modules/AddFlangRTOffload.cmake | 18 +-
flang-rt/lib/flang_rt/CMakeLists.txt | 9 +-
flang-rt/lib/flang_rt/CUDA/CMakeLists.txt | 26 +-
flang-rt/test/CMakeLists.txt | 2 +-
flang-rt/test/lit.cfg.py | 2 +-
7 files changed, 283 insertions(+), 128 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 655d0a55b4004..0b91b6ae7eea7 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -115,6 +115,15 @@ endif ()
extend_path(FLANG_RT_INSTALL_RESOURCE_LIB_PATH "${FLANG_RT_INSTALL_RESOURCE_PATH}" "${toolchain_lib_subdir}")
cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_DIR)
cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_PATH)
+# FIXME: For the libflang_rt.so, the toolchain resource lib dir is not a good
+# destination because it is not a ld.so default search path.
+# The machine where the executable is eventually executed may not be the
+# machine where the Flang compiler and its resource dir is installed, so
+# setting RPath by the driver is not an solution. It should belong into
+# /usr/lib/<triple>/libflang_rt.so, like e.g. libgcc_s.so.
+# But the linker as invoked by the Flang driver also requires
+# libflang_rt.so to be found when linking and the resource lib dir is
+# the only reliable location.
cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_LIB_DIR)
cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_LIB_PATH)
@@ -129,6 +138,27 @@ cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_LIB_PATH)
option(FLANG_RT_INCLUDE_TESTS "Generate build targets for the flang-rt unit and regression-tests." "${LLVM_INCLUDE_TESTS}")
+option(FLANG_RT_ENABLE_STATIC "Build Flang-RT as a static library." ON)
+if (WIN32)
+ # Windows DLL currently not implemented.
+ set(FLANG_RT_ENABLE_SHARED OFF)
+else ()
+ # TODO: Enable by default to increase test coverage, and which version of the
+ # library should be the user's choice anyway.
+ # Currently, the Flang driver adds `-L"libdir" -lflang_rt` as linker
+ # argument, which leaves the choice which library to use to the linker.
+ # Since most linkers prefer the shared library, this would constitute a
+ # breaking change unless the driver is changed.
+ option(FLANG_RT_ENABLE_SHARED "Build Flang-RT as a shared library." OFF)
+endif ()
+if (NOT FLANG_RT_ENABLE_STATIC AND NOT FLANG_RT_ENABLE_SHARED)
+ message(FATAL_ERROR "
+ Must build at least one type of library
+ (FLANG_RT_ENABLE_STATIC=ON, FLANG_RT_ENABLE_SHARED=ON, or both)
+ ")
+endif ()
+
+
set(FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT "" CACHE STRING "Compile Flang-RT with GPU support (CUDA or OpenMP)")
set_property(CACHE FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT PROPERTY STRINGS
""
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index aa8adedf61752..87ec58b2e854e 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -16,7 +16,8 @@
# STATIC
# Build a static (.a/.lib) library
# OBJECT
-# Create only object files without static/dynamic library
+# Always create an object library.
+# Without SHARED/STATIC, build only the object library.
# INSTALL_WITH_TOOLCHAIN
# Install library into Clang's resource directory so it can be found by the
# Flang driver during compilation, including tests
@@ -48,17 +49,73 @@ function (add_flangrt_library name)
")
endif ()
- # Forward libtype to add_library
- set(extra_args "")
- if (ARG_SHARED)
- list(APPEND extra_args SHARED)
+ # Internal names of libraries. If called with just single type option, use
+ # the default name for it. Name of targets must only depend on function
+ # arguments to be predictable for callers.
+ set(name_static "${name}.static")
+ set(name_shared "${name}.shared")
+ set(name_object "obj.${name}")
+ if (ARG_STATIC AND NOT ARG_SHARED)
+ set(name_static "${name}")
+ elseif (NOT ARG_STATIC AND ARG_SHARED)
+ set(name_shared "${name}")
+ elseif (NOT ARG_STATIC AND NOT ARG_SHARED AND ARG_OBJECT)
+ set(name_object "${name}")
+ elseif (NOT ARG_STATIC AND NOT ARG_SHARED AND NOT ARG_OBJECT)
+ # Only one of them will actually be built.
+ set(name_static "${name}")
+ set(name_shared "${name}")
endif ()
- if (ARG_STATIC)
- list(APPEND extra_args STATIC)
+
+ # Determine what to build. If not explicitly specified, honor
+ # BUILD_SHARED_LIBS (e.g. for unittest libraries). If can build static and
+ # shared, use ENABLE_STATIC/ENABLE_SHARED setting.
+ if (ARG_STATIC AND ARG_SHARED)
+ set(build_static ${FLANG_RT_ENABLE_STATIC})
+ set(build_shared ${FLANG_RT_ENABLE_SHARED})
+ else ()
+ set(build_static ${ARG_STATIC})
+ set(build_shared ${ARG_SHARED})
endif ()
+ if (NOT ARG_STATIC AND NOT ARG_SHARED AND NOT ARG_OBJECT)
+ if (BUILD_SHARED_LIBS)
+ set(build_shared ON)
+ else ()
+ set(build_static ON)
+ endif ()
+ endif ()
+
+ # Build an object library if building multiple libraries at once or if
+ # explicitly requested.
+ set(build_object OFF)
if (ARG_OBJECT)
- list(APPEND extra_args OBJECT)
+ set(build_object ON)
+ elseif (build_static AND build_shared)
+ set(build_object ON)
endif ()
+
+ # srctargets: targets that contain source files
+ # libtargets: static/shared if they are built
+ # alltargets: any add_library target added by this function
+ set(srctargets "")
+ set(libtargets "")
+ set(alltargets "")
+ if (build_static)
+ list(APPEND srctargets "${name_static}")
+ list(APPEND libtargets "${name_static}")
+ list(APPEND alltargets "${name_static}")
+ endif ()
+ if (build_shared)
+ list(APPEND srctargets "${name_shared}")
+ list(APPEND libtargets "${name_shared}")
+ list(APPEND alltargets "${name_shared}")
+ endif ()
+ if (build_object)
+ set(srctargets "${name_object}")
+ list(APPEND alltargets "${name_object}")
+ endif ()
+
+ set(extra_args "")
if (ARG_EXCLUDE_FROM_ALL)
list(APPEND extra_args EXCLUDE_FROM_ALL)
endif ()
@@ -66,121 +123,174 @@ function (add_flangrt_library name)
# Also add header files to IDEs to list as part of the library.
set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
- add_library(${name} ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS})
+ # Create selected library types.
+ if (build_object)
+ add_library("${name_object}" OBJECT ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS})
+ set_target_properties(${name_object} PROPERTIES
+ POSITION_INDEPENDENT_CODE ON
+ FOLDER "Flang-RT/Object Libraries"
+ )
- if (ARG_INSTALL_WITH_TOOLCHAIN)
- set_target_properties(${name} PROPERTIES FOLDER "Flang-RT/Toolchain Libraries")
- elseif (ARG_OBJECT)
- set_target_properties(${name} PROPERTIES FOLDER "Flang-RT/Object Libraries")
- else ()
- set_target_properties(${name} PROPERTIES FOLDER "Flang-RT/Libraries")
+ # Replace arguments for the libraries we are going to create.
+ set(ARG_ADDITIONAL_HEADERS "")
+ set(ARG_UNPARSED_ARGUMENTS "$<TARGET_OBJECTS:${name_object}>")
endif ()
-
- # Minimum required C++ version for Flang-RT, even if CMAKE_CXX_STANDARD is defined to something else.
- target_compile_features(${name} PRIVATE cxx_std_17)
-
- # Use compiler-specific options to disable exceptions and RTTI.
- if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
- target_compile_options(${name} PRIVATE
- $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>
- )
- elseif (MSVC)
- target_compile_options(${name} PRIVATE
- $<$<COMPILE_LANGUAGE:CXX>:/EHs-c- /GR->
- )
- elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
- target_compile_options(${name} PRIVATE
- $<$<COMPILE_LANGUAGE:CXX>:-qnoeh -qnortti>
- )
+ if (build_static)
+ add_library("${name_static}" STATIC ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS})
endif ()
-
- # Also for CUDA source when compiling with FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA
- if (CMAKE_CUDA_COMPILER_ID MATCHES "NVIDIA")
- # Assuming gcc as host compiler.
- target_compile_options(${name} PRIVATE
- $<$<COMPILE_LANGUAGE:CUDA>:--no-exceptions -Xcompiler -fno-rtti -Xcompiler -fno-unwind-tables -Xcompiler -fno-asynchronous-unwind-tables>
- )
- else ()
- # Assuming a clang-compatible CUDA compiler.
- target_compile_options(${name} PRIVATE
- $<$<COMPILE_LANGUAGE:CUDA>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>
- )
+ if (build_shared)
+ add_library("${name_shared}" SHARED ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS})
endif ()
- # Flang-RT's public headers
- target_include_directories(${name} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
+ # Provide a default target if building both and which exists in either setting.
+ if (libtargets)
+ if (BUILD_SHARED_LIBS)
+ if (build_shared)
+ set(default_target "${name_shared}")
+ else ()
+ set(default_target "${name_static}")
+ endif ()
+ else ()
+ if (build_static)
+ set(default_target "${name_static}")
+ else ()
+ set(default_target "${name_shared}")
+ endif ()
+ endif ()
+ add_library(${name}.default ALIAS "${default_target}")
+ if (NOT TARGET ${name})
+ add_library(${name} ALIAS "${default_target}")
+ endif ()
+ endif ()
- # For ISO_Fortran_binding.h to be found by the runtime itself (Accessed as #include "flang/ISO_Fortran_binding.h")
- # User applications can use #include <ISO_Fortran_binding.h>
- target_include_directories(${name} PRIVATE "${FLANG_SOURCE_DIR}/include")
+ foreach (tgtname IN LISTS libtargets)
+ if (NOT WIN32)
+ # Use same stem name for .a and .so. Common in UNIX environments.
+ # Not possible in Windows environments.
+ set_target_properties(${tgtname} PROPERTIES OUTPUT_NAME "${name}")
+ endif ()
- # For Flang-RT's configured config.h to be found
- target_include_directories(${name} PRIVATE "${FLANG_RT_BINARY_DIR}")
+ if (ARG_INSTALL_WITH_TOOLCHAIN)
+ set_target_properties(${tgtname} PROPERTIES FOLDER "Flang-RT/Toolchain Libraries")
+ else ()
+ set_target_properties(${tgtname} PROPERTIES FOLDER "Flang-RT/Libraries")
+ endif ()
+ endforeach ()
- # Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS
- # build, to avoid an unwanted dependency on libstdc++/libc++.so.
- if (FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
- target_compile_options(${name} PUBLIC -U_GLIBCXX_ASSERTIONS)
- target_compile_options(${name} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)
- endif ()
+ # Define how to compile and link the library.
+ # Some conceptionally only apply to ${srctargets} or ${libtargets}, but we
+ # apply them to ${alltargets}. In worst case, they are ignored by CMake.
+ foreach (tgtname IN LISTS alltargets)
+ # Minimum required C++ version for Flang-RT, even if CMAKE_CXX_STANDARD is defined to something else.
+ target_compile_features(${tgtname} PRIVATE cxx_std_17)
- # Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
- # should only depend on msvcrt/ucrt. LLVM still emits libgcc/compiler-rt
- # functions in some cases like 128-bit integer math (__udivti3, __modti3,
- # __fixsfti, __floattidf, ...) that msvc does not support. We are injecting a
- # dependency to Compiler-RT's builtin library where these are implemented.
- if (MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- if (FLANG_RT_BUILTINS_LIBRARY)
- target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>" "$<$<COMPILE_LANGUAGE:CXX,C>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
+ # Use compiler-specific options to disable exceptions and RTTI.
+ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
+ target_compile_options(${tgtname} PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>
+ )
+ elseif (MSVC)
+ target_compile_options(${tgtname} PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:/EHs-c- /GR->
+ )
+ elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
+ target_compile_options(${tgtname} PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:-qnoeh -qnortti>
+ )
endif ()
- endif ()
- if (MSVC AND CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
- if (FLANG_RT_BUILTINS_LIBRARY)
- target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "$<$<COMPILE_LANGUAGE:Fortran>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
+
+ # Also for CUDA source when compiling with FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA
+ if (CMAKE_CUDA_COMPILER_ID MATCHES "NVIDIA")
+ # Assuming gcc as host compiler.
+ target_compile_options(${tgtname} PRIVATE
+ $<$<COMPILE_LANGUAGE:CUDA>:--no-exceptions -Xcompiler -fno-rtti -Xcompiler -fno-unwind-tables -Xcompiler -fno-asynchronous-unwind-tables>
+ )
else ()
- message(WARNING "Did not find libclang_rt.builtins.lib.
- LLVM may emit builtins that are not implemented in msvcrt/ucrt and
- instead falls back to builtins from Compiler-RT. Linking with ${name}
- may result in a linker error.")
+ # Assuming a clang-compatible CUDA compiler.
+ target_compile_options(${tgtname} PRIVATE
+ $<$<COMPILE_LANGUAGE:CUDA>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>
+ )
endif ()
- endif ()
- # Non-GTest unittests depend on LLVMSupport
- if (ARG_LINK_TO_LLVM)
- if (LLVM_LINK_LLVM_DYLIB)
- set(llvm_libs LLVM)
- else()
- llvm_map_components_to_libnames(llvm_libs Support)
- endif()
- target_link_libraries(${name} PUBLIC ${llvm_libs})
- target_include_directories(${name} PUBLIC ${LLVM_INCLUDE_DIRS})
- endif ()
+ # Flang-RT's public headers
+ target_include_directories(${tgtname} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
- if (ARG_INCLUDE_DIRECTORIES)
- target_include_directories(${name} ${ARG_INCLUDE_DIRECTORIES})
- endif ()
+ # For ISO_Fortran_binding.h to be found by the runtime itself (Accessed as #include "flang/ISO_Fortran_binding.h")
+ # User applications can use #include <ISO_Fortran_binding.h>
+ target_include_directories(${tgtname} PRIVATE "${FLANG_SOURCE_DIR}/include")
- # If this is part of the toolchain, put it into the compiler's resource
- # directory. Otherwise it is part of testing and is not installed at all.
- # TODO: Consider multi-configuration builds (MSVC_IDE, "Ninja Multi-Config")
- if (ARG_INSTALL_WITH_TOOLCHAIN)
- set_target_properties(${name}
- PROPERTIES
- ARCHIVE_OUTPUT_DIRECTORY "${FLANG_RT_OUTPUT_RESOURCE_LIB_DIR}"
- )
+ # For Flang-RT's configured config.h to be found
+ target_include_directories(${tgtname} PRIVATE "${FLANG_RT_BINARY_DIR}")
- install(TARGETS ${name}
- ARCHIVE DESTINATION "${FLANG_RT_INSTALL_RESOURCE_LIB_PATH}"
- )
- endif ()
+ # Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS
+ # build, to avoid an unwanted dependency on libstdc++/libc++.so.
+ if (FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
+ target_compile_options(${tgtname} PUBLIC -U_GLIBCXX_ASSERTIONS)
+ target_compile_options(${tgtname} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)
+ endif ()
- if (ARG_TARGET_PROPERTIES)
- set_target_properties(${name} PROPERTIES ${ARG_TARGET_PROPERTIES})
- endif ()
+ # Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
+ # should only depend on msvcrt/ucrt. LLVM still emits libgcc/compiler-rt
+ # functions in some cases like 128-bit integer math (__udivti3, __modti3,
+ # __fixsfti, __floattidf, ...) that msvc does not support. We are injecting a
+ # dependency to Compiler-RT's builtin library where these are implemented.
+ if (MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ if (FLANG_RT_BUILTINS_LIBRARY)
+ target_compile_options(${tgtname} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>" "$<$<COMPILE_LANGUAGE:CXX,C>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
+ endif ()
+ endif ()
+ if (MSVC AND CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
+ if (FLANG_RT_BUILTINS_LIBRARY)
+ target_compile_options(${tgtname} PRIVATE "$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "$<$<COMPILE_LANGUAGE:Fortran>:--dependent-lib=${FLANG_RT_BUILTINS_LIBRARY}>")
+ else ()
+ message(WARNING "Did not find libclang_rt.builtins.lib.
+ LLVM may emit builtins that are not implemented in msvcrt/ucrt and
+ instead falls back to builtins from Compiler-RT. Linking with ${tgtname}
+ may result in a linker error.")
+ endif ()
+ endif ()
- # flang-rt should build all the Flang-RT targets that are built in an
- # 'all' build.
- if (NOT ARG_EXCLUDE_FROM_ALL)
- add_dependencies(flang-rt ${name})
- endif ()
+ # Non-GTest unittests depend on LLVMSupport
+ if (ARG_LINK_TO_LLVM)
+ if (LLVM_LINK_LLVM_DYLIB)
+ set(llvm_libs LLVM)
+ else()
+ llvm_map_components_to_libnames(llvm_libs Support)
+ endif()
+ target_link_libraries(${tgtname} PUBLIC ${llvm_libs})
+ target_include_directories(${tgtname} PUBLIC ${LLVM_INCLUDE_DIRS})
+ endif ()
+
+ if (ARG_INCLUDE_DIRECTORIES)
+ target_include_directories(${tgtname} ${ARG_INCLUDE_DIRECTORIES})
+ endif ()
+ endforeach ()
+
+ foreach (tgtname IN LISTS libtargets)
+ # If this is part of the toolchain, put it into the compiler's resource
+ # directory. Otherwise it is part of testing and is not installed at all.
+ # TODO: Consider multi-configuration builds (MSVC_IDE, "Ninja Multi-Config")
+ if (ARG_INSTALL_WITH_TOOLCHAIN)
+ set_target_properties(${tgtname}
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY "${FLANG_RT_OUTPUT_RESOURCE_LIB_DIR}"
+ LIBRARY_OUTPUT_DIRECTORY "${FLANG_RT_OUTPUT_RESOURCE_LIB_DIR}"
+ )
+
+ install(TARGETS ${tgtname}
+ ARCHIVE DESTINATION "${FLANG_RT_INSTALL_RESOURCE_LIB_PATH}"
+ LIBRARY DESTINATION "${FLANG_RT_INSTALL_RESOURCE_LIB_PATH}"
+ )
+ endif ()
+
+ if (ARG_TARGET_PROPERTIES)
+ set_target_properties(${tgtname} PROPERTIES ${ARG_TARGET_PROPERTIES})
+ endif ()
+
+ # flang-rt should build all the Flang-RT targets that are built in an
+ # 'all' build.
+ if (NOT ARG_EXCLUDE_FROM_ALL)
+ add_dependencies(flang-rt ${tgtname})
+ endif ()
+ endforeach ()
endfunction (add_flangrt_library)
diff --git a/flang-rt/cmake/modules/AddFlangRTOffload.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
index b055646cb0604..2981005d0d5ce 100644
--- a/flang-rt/cmake/modules/AddFlangRTOffload.cmake
+++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
@@ -8,9 +8,15 @@
macro(enable_cuda_compilation name files)
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
+ if (FLANG_RT_ENABLE_SHARED)
+ message(FATAL_ERROR
+ "FLANG_RT_ENABLE_SHARED is not supported for CUDA offload build of Flang-RT"
+ )
+ endif()
+
enable_language(CUDA)
- set_target_properties(${name}
+ set_target_properties(${name}.static
PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
)
@@ -55,7 +61,7 @@ macro(enable_cuda_compilation name files)
# When using libcudacxx headers files, we have to use them
# for all files of Flang-RT.
if (EXISTS "${FLANG_RT_LIBCUDACXX_PATH}/include")
- foreach (tgt IN ITEMS "${name}" "obj.${name}PTX")
+ foreach (tgt IN ITEMS "${name}.static" "obj.${name}PTX")
target_include_directories(${tgt} AFTER PRIVATE "${FLANG_RT_LIBCUDACXX_PATH}/include")
target_compile_definitions(${tgt} PRIVATE RT_USE_LIBCUDACXX=1)
endforeach ()
@@ -67,6 +73,12 @@ macro(enable_omp_offload_compilation name files)
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
# OpenMP offload build only works with Clang compiler currently.
+ if (FLANG_RT_ENABLE_SHARED)
+ message(FATAL_ERROR
+ "FLANG_RT_ENABLE_SHARED is not supported for OpenMP offload build of Flang-RT"
+ )
+ endif()
+
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND
"${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
@@ -85,7 +97,7 @@ macro(enable_omp_offload_compilation name files)
set_source_files_properties(${files} PROPERTIES COMPILE_OPTIONS
"${OMP_COMPILE_OPTIONS}"
)
- target_link_options(${name} PUBLIC ${OMP_COMPILE_OPTIONS})
+ target_link_options(${name}.static PUBLIC ${OMP_COMPILE_OPTIONS})
# Enable "declare target" in the source code.
set_source_files_properties(${files}
diff --git a/flang-rt/lib/flang_rt/CMakeLists.txt b/flang-rt/lib/flang_rt/CMakeLists.txt
index 4db1a1cbb874f..e9d7776602239 100644
--- a/flang-rt/lib/flang_rt/CMakeLists.txt
+++ b/flang-rt/lib/flang_rt/CMakeLists.txt
@@ -128,7 +128,7 @@ endif ()
set(sources ${supported_sources} ${host_sources} ${f128_sources})
if (NOT WIN32)
- add_flangrt_library(flang_rt STATIC
+ add_flangrt_library(flang_rt STATIC SHARED
${sources}
INSTALL_WITH_TOOLCHAIN
ADDITIONAL_HEADERS ${public_headers} ${private_headers}
@@ -137,10 +137,9 @@ if (NOT WIN32)
enable_cuda_compilation(flang_rt "${supported_sources}")
enable_omp_offload_compilation(flang_rt "${supported_sources}")
- # For unittests that depend on flang_rt. Should link to the static version
- # of the library.
- add_library(flang_rt.static ALIAS flang_rt)
- add_library(flang_rt.unittest ALIAS flang_rt)
+ # Select a default runtime, which is used for unit and regression tests.
+ get_target_property(default_target flang_rt.default ALIASED_TARGET)
+ add_library(flang_rt.unittest ALIAS "${default_target}")
else()
# Target for building all versions of the runtime
add_custom_target(flang_rt)
diff --git a/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt b/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
index 3c741ac93d64b..0722d9b8a2919 100644
--- a/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
+++ b/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
@@ -6,8 +6,7 @@
#
#===------------------------------------------------------------------------===#
-
-add_flangrt_library(CufRuntime STATIC
+add_flangrt_library(CufRuntime STATIC SHARED
allocatable.cpp
allocator.cpp
descriptor.cpp
@@ -16,18 +15,23 @@ add_flangrt_library(CufRuntime STATIC
memory.cpp
registration.cpp
- # libCufRuntime depends on a certain version of CUDA. To be able to have
- # multiple build of this library with different CUDA version, the version is
- # added to the library name.
TARGET_PROPERTIES
OUTPUT_NAME "CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}"
-
INCLUDE_DIRECTORIES
PRIVATE ${CUDAToolkit_INCLUDE_DIRS}
)
-target_link_libraries(CufRuntime
- PUBLIC
- flang_rt
- CUDA::cudart_static
-)
+# For the static library, link-in the static dependencies as well.
+if (TARGET CufRuntime.static)
+ target_link_libraries(CufRuntime.static PUBLIC
+ flang_rt.static
+ CUDA::cudart_static
+ )
+endif ()
+
+if (TARGET CufRuntime.shared)
+ target_link_libraries(CufRuntime.shared PUBLIC
+ flang_rt.shared
+ CUDA::cudart
+ )
+endif ()
diff --git a/flang-rt/test/CMakeLists.txt b/flang-rt/test/CMakeLists.txt
index 5ca07b66e4f9b..74f506d6f98f0 100644
--- a/flang-rt/test/CMakeLists.txt
+++ b/flang-rt/test/CMakeLists.txt
@@ -45,7 +45,7 @@ set_target_properties(flang-rt-test-depends PROPERTIES FOLDER "Flang-RT/Meta")
add_dependencies(flang-rt-test-depends
FlangRTUnitTests
flang_rt.unittest
- flang_rt.static
+ flang_rt
)
add_lit_testsuite(check-flang-rt "Running the Flang-RT regression tests"
diff --git a/flang-rt/test/lit.cfg.py b/flang-rt/test/lit.cfg.py
index 08f3f1121c896..214374ee31ec7 100644
--- a/flang-rt/test/lit.cfg.py
+++ b/flang-rt/test/lit.cfg.py
@@ -94,7 +94,7 @@ def shjoin(args, sep=" "):
# Include path for C headers that define Flang's Fortran ABI.
config.substitutions.append(("%include", os.path.join(config.flang_source_dir, "include")))
-# Library path of libflang_rt.a (for lib search path when using non-Flang driver for linking)
+# Library path of libflang_rt.a/.so (for lib search path when using non-Flang driver for linking and LD_LIBRARY_PATH)
config.substitutions.append(("%libdir", config.flang_rt_output_resource_lib_dir))
# For CUDA offloading, additional steps (device linking) and libraries (cudart) are needed.
>From 24fb7606827ba33397aad5220f423ae5daa87de5 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 27 Jan 2025 11:23:39 +0100
Subject: [PATCH 09/41] Sort files alphabetically
---
flang/lib/Support/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang/lib/Support/CMakeLists.txt b/flang/lib/Support/CMakeLists.txt
index 809266960a02d..4ee381589a208 100644
--- a/flang/lib/Support/CMakeLists.txt
+++ b/flang/lib/Support/CMakeLists.txt
@@ -43,14 +43,14 @@ if(FLANG_VENDOR)
endif()
add_flang_library(FortranSupport
+ default-kinds.cpp
Fortran.cpp
Fortran-features.cpp
- default-kinds.cpp
idioms.cpp
LangOptions.cpp
OpenMP-utils.cpp
- Version.cpp
Timing.cpp
+ Version.cpp
${version_inc}
LINK_COMPONENTS
>From f2e15355b4c7e2a302299dbac2d9119bce1a0e0f Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 27 Jan 2025 15:00:37 +0100
Subject: [PATCH 10/41] Move new file pointer.cpp
---
.../runtime => flang-rt/lib/flang_rt}/CUDA/pointer.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/pointer.cpp (93%)
diff --git a/flang/runtime/CUDA/pointer.cpp b/flang-rt/lib/flang_rt/CUDA/pointer.cpp
similarity index 93%
rename from flang/runtime/CUDA/pointer.cpp
rename to flang-rt/lib/flang_rt/CUDA/pointer.cpp
index 3252410bd8d2c..b6e8033933834 100644
--- a/flang/runtime/CUDA/pointer.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/pointer.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/pointer.cpp ------------------------------------------===//
+//===-- lib/flang_rt/CUDA/pointer.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/pointer.h"
-#include "../assign-impl.h"
-#include "../stat.h"
-#include "../terminator.h"
+#include "flang-rt/assign-impl.h"
+#include "flang-rt/descriptor.h"
+#include "flang-rt/stat.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memmove-function.h"
#include "flang/Runtime/pointer.h"
>From b02e9ad846a25cb8cd1d66a975e3fef1c9dec98a Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 28 Jan 2025 15:11:16 +0100
Subject: [PATCH 11/41] Suggest both options to build Flang-RT
---
flang/CMakeLists.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 38004c149b783..e0f32418f7f32 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -247,13 +247,13 @@ if (FLANG_INCLUDE_RUNTIME)
message(WARNING "Building Flang-RT using LLVM_ENABLE_RUNTIMES. FLANG_INCLUDE_RUNTIME=${FLANG_INCLUDE_RUNTIME} ignored.")
set(FLANG_INCLUDE_RUNTIME OFF)
else ()
- message(STATUS "Building flang_rt in-tree")
+ message(STATUS "Building Flang-RT in-tree")
endif ()
else ()
if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
- message(STATUS "Building Flang-RT using LLVM_ENABLE_RUNTIMES.")
+ message(STATUS "Building Flang-RT using LLVM_ENABLE_RUNTIMES")
else ()
- message(STATUS "Not building Flang-RT. For a usable Fortran toolchain, compile a standalone Flang-RT")
+ message(STATUS "Not building Flang-RT. For a usable Fortran toolchain, either add LLVM_ENABLE_RUNTIMES=flang-rt, or compile a standalone Flang-RT.")
endif ()
endif ()
>From b9ab00df5906d473196be6be819d9739bc7d3e63 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 29 Jan 2025 10:43:18 +0100
Subject: [PATCH 12/41] Move files back to Common
---
.../flang/Common/ISO_Fortran_binding_wrapper.h | 2 +-
flang/include/flang/Common/format.h | 2 +-
.../include/flang/{Support => Common}/indirection.h | 10 +++++-----
flang/include/flang/{Support => Common}/interval.h | 10 +++++-----
flang/include/flang/Common/optional.h | 2 +-
flang/include/flang/Common/real.h | 2 +-
.../flang/{Support => Common}/reference-counted.h | 8 ++++----
flang/include/flang/Common/reference-wrapper.h | 2 +-
flang/include/flang/{Support => Common}/reference.h | 8 ++++----
flang/include/flang/Common/restorer.h | 2 +-
.../flang/{Support => Common}/static-multimap-view.h | 8 ++++----
flang/include/flang/Common/target-rounding.h | 4 ++--
flang/include/flang/{Support => Common}/template.h | 12 ++++++------
flang/include/flang/Common/uint128.h | 2 +-
flang/include/flang/{Support => Common}/unwrap.h | 12 ++++++------
flang/include/flang/Common/visit.h | 2 +-
flang/include/flang/Evaluate/call.h | 4 ++--
flang/include/flang/Evaluate/characteristics.h | 2 +-
flang/include/flang/Evaluate/common.h | 2 +-
flang/include/flang/Evaluate/constant.h | 2 +-
flang/include/flang/Evaluate/expression.h | 4 ++--
flang/include/flang/Evaluate/formatting.h | 2 +-
flang/include/flang/Evaluate/shape.h | 2 +-
flang/include/flang/Evaluate/tools.h | 4 ++--
flang/include/flang/Evaluate/traverse.h | 2 +-
flang/include/flang/Evaluate/type.h | 2 +-
flang/include/flang/Evaluate/variable.h | 4 ++--
flang/include/flang/Lower/CallInterface.h | 2 +-
flang/include/flang/Lower/PFTBuilder.h | 4 ++--
flang/include/flang/Lower/Support/Utils.h | 2 +-
flang/include/flang/Lower/SymbolMap.h | 2 +-
.../flang/Optimizer/Builder/PPCIntrinsicCall.h | 2 +-
flang/include/flang/Parser/char-block.h | 2 +-
flang/include/flang/Parser/dump-parse-tree.h | 2 +-
flang/include/flang/Parser/message.h | 2 +-
flang/include/flang/Parser/parse-tree.h | 2 +-
flang/include/flang/Parser/provenance.h | 2 +-
flang/include/flang/Parser/source.h | 2 +-
flang/include/flang/Semantics/expression.h | 2 +-
flang/include/flang/Semantics/runtime-type-info.h | 2 +-
flang/include/flang/Semantics/scope.h | 2 +-
flang/include/flang/Semantics/symbol.h | 2 +-
flang/include/flang/Support/Fortran-features.h | 2 +-
flang/include/flang/Support/LangOptions.h | 6 +++---
flang/include/flang/Support/MathOptionsBase.h | 6 +++---
.../include/flang/{Common => Support}/OpenMP-utils.h | 8 ++++----
flang/include/flang/Support/default-kinds.h | 2 +-
flang/lib/Decimal/CMakeLists.txt | 8 ++++++++
flang/lib/Evaluate/characteristics.cpp | 2 +-
flang/lib/Evaluate/fold-implementation.h | 6 +++---
flang/lib/Evaluate/intrinsics-library.cpp | 2 +-
flang/lib/Evaluate/shape.cpp | 2 +-
flang/lib/Evaluate/target.cpp | 2 +-
flang/lib/Lower/ConvertExpr.cpp | 2 +-
flang/lib/Lower/Mangler.cpp | 2 +-
flang/lib/Lower/OpenMP/OpenMP.cpp | 2 +-
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +-
flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp | 2 +-
flang/lib/Parser/basic-parsers.h | 2 +-
flang/lib/Parser/parse-tree.cpp | 2 +-
flang/lib/Parser/unparse.cpp | 2 +-
flang/lib/Semantics/assignment.h | 2 +-
flang/lib/Semantics/check-case.cpp | 4 ++--
flang/lib/Semantics/check-coarray.cpp | 2 +-
flang/lib/Semantics/check-cuda.cpp | 2 +-
flang/lib/Semantics/check-data.h | 2 +-
flang/lib/Semantics/check-do-forall.cpp | 2 +-
flang/lib/Semantics/check-select-type.cpp | 2 +-
flang/lib/Semantics/data-to-inits.h | 2 +-
flang/lib/Semantics/pointer-assignment.cpp | 2 +-
flang/lib/Semantics/resolve-labels.cpp | 2 +-
flang/lib/Semantics/resolve-names-utils.cpp | 2 +-
flang/lib/Semantics/resolve-names.cpp | 2 +-
flang/lib/Semantics/rewrite-parse-tree.cpp | 2 +-
flang/lib/Semantics/tools.cpp | 2 +-
flang/lib/Support/OpenMP-utils.cpp | 2 +-
76 files changed, 126 insertions(+), 118 deletions(-)
rename flang/include/flang/{Support => Common}/indirection.h (95%)
rename flang/include/flang/{Support => Common}/interval.h (94%)
rename flang/include/flang/{Support => Common}/reference-counted.h (90%)
rename flang/include/flang/{Support => Common}/reference.h (91%)
rename flang/include/flang/{Support => Common}/static-multimap-view.h (91%)
rename flang/include/flang/{Support => Common}/template.h (98%)
rename flang/include/flang/{Support => Common}/unwrap.h (94%)
rename flang/include/flang/{Common => Support}/OpenMP-utils.h (92%)
diff --git a/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h b/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
index 7a8a8a9787bd0..5d9c66f47b48e 100644
--- a/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
+++ b/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -22,7 +22,7 @@
/* clang-format off */
#include <stddef.h>
-#include "flang/Common/api-attrs.h"
+#include "api-attrs.h"
#ifdef __cplusplus
namespace Fortran {
namespace ISO {
diff --git a/flang/include/flang/Common/format.h b/flang/include/flang/Common/format.h
index c5e9fb06e260f..da416506ffb5d 100644
--- a/flang/include/flang/Common/format.h
+++ b/flang/include/flang/Common/format.h
@@ -9,8 +9,8 @@
#ifndef FORTRAN_COMMON_FORMAT_H_
#define FORTRAN_COMMON_FORMAT_H_
+#include "Fortran-consts.h"
#include "enum-set.h"
-#include "flang/Common/Fortran-consts.h"
#include <cstring>
// Define a FormatValidator class template to validate a format expression
diff --git a/flang/include/flang/Support/indirection.h b/flang/include/flang/Common/indirection.h
similarity index 95%
rename from flang/include/flang/Support/indirection.h
rename to flang/include/flang/Common/indirection.h
index aeb1698516bae..7348eb0473f07 100644
--- a/flang/include/flang/Support/indirection.h
+++ b/flang/include/flang/Common/indirection.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/indirection.h ---------------------*- C++ -*-===//
+//===-- include/flang/Common/indirection.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_SUPPORT_INDIRECTION_H_
-#define FORTRAN_SUPPORT_INDIRECTION_H_
+#ifndef FORTRAN_COMMON_INDIRECTION_H_
+#define FORTRAN_COMMON_INDIRECTION_H_
// Define a smart pointer class template that is rather like
// non-nullable std::unique_ptr<>. Indirection<> is, like a C++ reference
@@ -20,7 +20,7 @@
// template class Fortran::common::Indirection<FORWARD_TYPE>;
// in one C++ source file later where a definition of the type is visible.
-#include "flang/Common/idioms.h"
+#include "idioms.h"
#include <memory>
#include <type_traits>
#include <utility>
@@ -171,4 +171,4 @@ template <typename A> class ForwardOwningPointer {
void (*deleter_)(A *){nullptr};
};
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_INDIRECTION_H_ */
+#endif // FORTRAN_COMMON_INDIRECTION_H_
diff --git a/flang/include/flang/Support/interval.h b/flang/include/flang/Common/interval.h
similarity index 94%
rename from flang/include/flang/Support/interval.h
rename to flang/include/flang/Common/interval.h
index 99c0784f006a8..c4cab0ccf1130 100644
--- a/flang/include/flang/Support/interval.h
+++ b/flang/include/flang/Common/interval.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/interval.h ------------------------*- C++ -*-===//
+//===-- include/flang/Common/interval.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.
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_SUPPORT_INTERVAL_H_
-#define FORTRAN_SUPPORT_INTERVAL_H_
+#ifndef FORTRAN_COMMON_INTERVAL_H_
+#define FORTRAN_COMMON_INTERVAL_H_
// Defines a generalized template class Interval<A> to represent
// the half-open interval [x .. x+n).
-#include "flang/Common/idioms.h"
+#include "idioms.h"
#include <algorithm>
#include <cstddef>
#include <utility>
@@ -126,4 +126,4 @@ template <typename A> class Interval {
std::size_t size_{0};
};
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_INTERVAL_H_ */
+#endif // FORTRAN_COMMON_INTERVAL_H_
diff --git a/flang/include/flang/Common/optional.h b/flang/include/flang/Common/optional.h
index c0f4278009f40..c7c81f40cc8c8 100644
--- a/flang/include/flang/Common/optional.h
+++ b/flang/include/flang/Common/optional.h
@@ -26,7 +26,7 @@
#ifndef FORTRAN_COMMON_OPTIONAL_H
#define FORTRAN_COMMON_OPTIONAL_H
-#include "flang/Common/api-attrs.h"
+#include "api-attrs.h"
#include <optional>
#include <type_traits>
diff --git a/flang/include/flang/Common/real.h b/flang/include/flang/Common/real.h
index b527deda0e3b4..b47ba46581db6 100644
--- a/flang/include/flang/Common/real.h
+++ b/flang/include/flang/Common/real.h
@@ -13,7 +13,7 @@
// The various representations are distinguished by their binary precisions
// (number of explicit significand bits and any implicit MSB in the fraction).
-#include "flang/Common/api-attrs.h"
+#include "api-attrs.h"
#include <cinttypes>
namespace Fortran::common {
diff --git a/flang/include/flang/Support/reference-counted.h b/flang/include/flang/Common/reference-counted.h
similarity index 90%
rename from flang/include/flang/Support/reference-counted.h
rename to flang/include/flang/Common/reference-counted.h
index 636613d93d80c..de91d4fb6ee8b 100644
--- a/flang/include/flang/Support/reference-counted.h
+++ b/flang/include/flang/Common/reference-counted.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/reference-counted.h ---------------*- C++ -*-===//
+//===-- include/flang/Common/reference-counted.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_SUPPORT_REFERENCE_COUNTED_H_
-#define FORTRAN_SUPPORT_REFERENCE_COUNTED_H_
+#ifndef FORTRAN_COMMON_REFERENCE_COUNTED_H_
+#define FORTRAN_COMMON_REFERENCE_COUNTED_H_
// A class template of smart pointers to objects with their own
// reference counting object lifetimes that's lighter weight
@@ -74,4 +74,4 @@ template <typename A> class CountedReference {
type *p_{nullptr};
};
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_REFERENCE_COUNTED_H_ */
+#endif // FORTRAN_COMMON_REFERENCE_COUNTED_H_
diff --git a/flang/include/flang/Common/reference-wrapper.h b/flang/include/flang/Common/reference-wrapper.h
index 2983754108f95..85b2c6d5abce3 100644
--- a/flang/include/flang/Common/reference-wrapper.h
+++ b/flang/include/flang/Common/reference-wrapper.h
@@ -25,7 +25,7 @@
#ifndef FORTRAN_COMMON_REFERENCE_WRAPPER_H
#define FORTRAN_COMMON_REFERENCE_WRAPPER_H
-#include "flang/Common/api-attrs.h"
+#include "api-attrs.h"
#include <functional>
#include <type_traits>
diff --git a/flang/include/flang/Support/reference.h b/flang/include/flang/Common/reference.h
similarity index 91%
rename from flang/include/flang/Support/reference.h
rename to flang/include/flang/Common/reference.h
index c0b0e048ae04a..0c579de44bd7f 100644
--- a/flang/include/flang/Support/reference.h
+++ b/flang/include/flang/Common/reference.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/reference.h -----------------------*- C++ -*-===//
+//===-- include/flang/Common/reference.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.
@@ -11,8 +11,8 @@
// Use Reference<A> in place of a real A& reference when assignability is
// required; safer than a bare pointer because it's guaranteed to not be null.
-#ifndef FORTRAN_SUPPORT_REFERENCE_H_
-#define FORTRAN_SUPPORT_REFERENCE_H_
+#ifndef FORTRAN_COMMON_REFERENCE_H_
+#define FORTRAN_COMMON_REFERENCE_H_
#include <type_traits>
namespace Fortran::common {
template <typename A> class Reference {
@@ -60,4 +60,4 @@ template <typename A> class Reference {
};
template <typename A> Reference(A &) -> Reference<A>;
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_REFERENCE_H_ */
+#endif
diff --git a/flang/include/flang/Common/restorer.h b/flang/include/flang/Common/restorer.h
index 0f1bc48620d37..c18c13e351c76 100644
--- a/flang/include/flang/Common/restorer.h
+++ b/flang/include/flang/Common/restorer.h
@@ -18,8 +18,8 @@
#ifndef FORTRAN_COMMON_RESTORER_H_
#define FORTRAN_COMMON_RESTORER_H_
+#include "api-attrs.h"
#include "idioms.h"
-#include "flang/Common/api-attrs.h"
namespace Fortran::common {
template <typename A> class Restorer {
public:
diff --git a/flang/include/flang/Support/static-multimap-view.h b/flang/include/flang/Common/static-multimap-view.h
similarity index 91%
rename from flang/include/flang/Support/static-multimap-view.h
rename to flang/include/flang/Common/static-multimap-view.h
index 8928fab6bfb6f..27d2ba89c8009 100644
--- a/flang/include/flang/Support/static-multimap-view.h
+++ b/flang/include/flang/Common/static-multimap-view.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/static-multimap-view.h ------------*- C++ -*-===//
+//===-- include/flang/Common/static-multimap-view.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_SUPPORT_STATIC_MULTIMAP_VIEW_H_
-#define FORTRAN_SUPPORT_STATIC_MULTIMAP_VIEW_H_
+#ifndef FORTRAN_COMMON_STATIC_MULTIMAP_VIEW_H_
+#define FORTRAN_COMMON_STATIC_MULTIMAP_VIEW_H_
#include <algorithm>
#include <utility>
@@ -59,4 +59,4 @@ template <typename V> class StaticMultimapView {
const_iterator end_{nullptr};
};
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_STATIC_MULTIMAP_VIEW_H_ */
+#endif // FORTRAN_COMMON_STATIC_MULTIMAP_VIEW_H_
diff --git a/flang/include/flang/Common/target-rounding.h b/flang/include/flang/Common/target-rounding.h
index c0c9f6c49b26a..f503b22930ed4 100644
--- a/flang/include/flang/Common/target-rounding.h
+++ b/flang/include/flang/Common/target-rounding.h
@@ -9,8 +9,8 @@
#ifndef FORTRAN_COMMON_TARGET_ROUNDING_H_
#define FORTRAN_COMMON_TARGET_ROUNDING_H_
-#include "flang/Common/Fortran-consts.h"
-#include "flang/Common/enum-set.h"
+#include "Fortran-consts.h"
+#include "enum-set.h"
namespace Fortran::common {
diff --git a/flang/include/flang/Support/template.h b/flang/include/flang/Common/template.h
similarity index 98%
rename from flang/include/flang/Support/template.h
rename to flang/include/flang/Common/template.h
index 36fa6f7072b40..6501994133759 100644
--- a/flang/include/flang/Support/template.h
+++ b/flang/include/flang/Common/template.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/template.h ------------------------*- C++ -*-===//
+//===-- include/flang/Common/template.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_SUPPORT_TEMPLATE_H_
-#define FORTRAN_SUPPORT_TEMPLATE_H_
+#ifndef FORTRAN_COMMON_TEMPLATE_H_
+#define FORTRAN_COMMON_TEMPLATE_H_
-#include "flang/Common/idioms.h"
-#include "flang/Common/variant.h"
+#include "idioms.h"
+#include "variant.h"
#include <functional>
#include <optional>
#include <tuple>
@@ -322,4 +322,4 @@ common::IfNoLvalue<typename VISITOR::Result, VISITOR> SearchTypes(
std::move(visitor), std::move(defaultResult));
}
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_TEMPLATE_H_ */
+#endif // FORTRAN_COMMON_TEMPLATE_H_
diff --git a/flang/include/flang/Common/uint128.h b/flang/include/flang/Common/uint128.h
index 821c8c3b08a52..faecb88737a0b 100644
--- a/flang/include/flang/Common/uint128.h
+++ b/flang/include/flang/Common/uint128.h
@@ -19,8 +19,8 @@
#define AVOID_NATIVE_UINT128_T 0
#endif
+#include "api-attrs.h"
#include "leading-zero-bit-count.h"
-#include "flang/Common/api-attrs.h"
#include <cstdint>
#include <type_traits>
diff --git a/flang/include/flang/Support/unwrap.h b/flang/include/flang/Common/unwrap.h
similarity index 94%
rename from flang/include/flang/Support/unwrap.h
rename to flang/include/flang/Common/unwrap.h
index e890753499d1a..84582174e4b30 100644
--- a/flang/include/flang/Support/unwrap.h
+++ b/flang/include/flang/Common/unwrap.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/unwrap.h --------------------------*- C++ -*-===//
+//===-- include/flang/Common/unwrap.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.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_SUPPORT_UNWRAP_H_
-#define FORTRAN_SUPPORT_UNWRAP_H_
+#ifndef FORTRAN_COMMON_UNWRAP_H_
+#define FORTRAN_COMMON_UNWRAP_H_
#include "indirection.h"
#include "reference-counted.h"
#include "reference.h"
-#include "flang/Common/variant.h"
-#include "flang/Common/visit.h"
+#include "variant.h"
+#include "visit.h"
#include <memory>
#include <optional>
#include <type_traits>
@@ -155,4 +155,4 @@ template <typename A, typename B> std::optional<A> UnwrapCopy(const B &x) {
}
}
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_UNWRAP_H_ */
+#endif // FORTRAN_COMMON_UNWRAP_H_
diff --git a/flang/include/flang/Common/visit.h b/flang/include/flang/Common/visit.h
index ad66297650b09..1a84102b56642 100644
--- a/flang/include/flang/Common/visit.h
+++ b/flang/include/flang/Common/visit.h
@@ -21,8 +21,8 @@
#ifndef FORTRAN_COMMON_VISIT_H_
#define FORTRAN_COMMON_VISIT_H_
+#include "api-attrs.h"
#include "variant.h"
-#include "flang/Common/api-attrs.h"
#include <type_traits>
namespace Fortran::common {
diff --git a/flang/include/flang/Evaluate/call.h b/flang/include/flang/Evaluate/call.h
index 4d8ca28cf329a..2a5929b873d74 100644
--- a/flang/include/flang/Evaluate/call.h
+++ b/flang/include/flang/Evaluate/call.h
@@ -13,11 +13,11 @@
#include "constant.h"
#include "formatting.h"
#include "type.h"
+#include "flang/Common/indirection.h"
+#include "flang/Common/reference.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/attr.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
-#include "flang/Support/reference.h"
#include <optional>
#include <vector>
diff --git a/flang/include/flang/Evaluate/characteristics.h b/flang/include/flang/Evaluate/characteristics.h
index ccd584b5ee6aa..b4e14cd299fb6 100644
--- a/flang/include/flang/Evaluate/characteristics.h
+++ b/flang/include/flang/Evaluate/characteristics.h
@@ -20,11 +20,11 @@
#include "type.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
#include <optional>
#include <string>
#include <variant>
diff --git a/flang/include/flang/Evaluate/common.h b/flang/include/flang/Evaluate/common.h
index 91d38748f5a57..993540aebca57 100644
--- a/flang/include/flang/Evaluate/common.h
+++ b/flang/include/flang/Evaluate/common.h
@@ -11,6 +11,7 @@
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/target-rounding.h"
#include "flang/Parser/char-block.h"
@@ -18,7 +19,6 @@
#include "flang/Support/Fortran-features.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/default-kinds.h"
-#include "flang/Support/indirection.h"
#include <cinttypes>
#include <map>
#include <set>
diff --git a/flang/include/flang/Evaluate/constant.h b/flang/include/flang/Evaluate/constant.h
index 63e8ed4119cdf..6fc22e3b86aa2 100644
--- a/flang/include/flang/Evaluate/constant.h
+++ b/flang/include/flang/Evaluate/constant.h
@@ -11,8 +11,8 @@
#include "formatting.h"
#include "type.h"
+#include "flang/Common/reference.h"
#include "flang/Support/default-kinds.h"
-#include "flang/Support/reference.h"
#include <map>
#include <vector>
diff --git a/flang/include/flang/Evaluate/expression.h b/flang/include/flang/Evaluate/expression.h
index ec71550d2a50c..1203fca8640a6 100644
--- a/flang/include/flang/Evaluate/expression.h
+++ b/flang/include/flang/Evaluate/expression.h
@@ -22,10 +22,10 @@
#include "type.h"
#include "variable.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/indirection.h"
+#include "flang/Common/template.h"
#include "flang/Parser/char-block.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
-#include "flang/Support/template.h"
#include <algorithm>
#include <list>
#include <tuple>
diff --git a/flang/include/flang/Evaluate/formatting.h b/flang/include/flang/Evaluate/formatting.h
index ae9351139b193..aa82f56107fdd 100644
--- a/flang/include/flang/Evaluate/formatting.h
+++ b/flang/include/flang/Evaluate/formatting.h
@@ -19,7 +19,7 @@
// This header is meant to be included by the headers that define the several
// representational class templates that need it, not by external clients.
-#include "flang/Support/indirection.h"
+#include "flang/Common/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <type_traits>
diff --git a/flang/include/flang/Evaluate/shape.h b/flang/include/flang/Evaluate/shape.h
index 18dca71379e0d..3e42ec691158b 100644
--- a/flang/include/flang/Evaluate/shape.h
+++ b/flang/include/flang/Evaluate/shape.h
@@ -15,8 +15,8 @@
#include "expression.h"
#include "traverse.h"
#include "variable.h"
+#include "flang/Common/indirection.h"
#include "flang/Evaluate/type.h"
-#include "flang/Support/indirection.h"
#include <optional>
#include <variant>
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index fbe905168d253..669efb41b0344 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -11,6 +11,8 @@
#include "traverse.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/template.h"
+#include "flang/Common/unwrap.h"
#include "flang/Evaluate/constant.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/shape.h"
@@ -19,8 +21,6 @@
#include "flang/Semantics/attr.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
-#include "flang/Support/template.h"
-#include "flang/Support/unwrap.h"
#include <array>
#include <optional>
#include <set>
diff --git a/flang/include/flang/Evaluate/traverse.h b/flang/include/flang/Evaluate/traverse.h
index 58f188a409249..dd38d64bff63f 100644
--- a/flang/include/flang/Evaluate/traverse.h
+++ b/flang/include/flang/Evaluate/traverse.h
@@ -38,9 +38,9 @@
// expression of an ASSOCIATE (or related) construct entity.
#include "expression.h"
+#include "flang/Common/indirection.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/type.h"
-#include "flang/Support/indirection.h"
#include <set>
#include <type_traits>
diff --git a/flang/include/flang/Evaluate/type.h b/flang/include/flang/Evaluate/type.h
index ab7e4723152d7..98cc9b8cbba21 100644
--- a/flang/include/flang/Evaluate/type.h
+++ b/flang/include/flang/Evaluate/type.h
@@ -24,9 +24,9 @@
#include "real.h"
#include "flang/Common/idioms.h"
#include "flang/Common/real.h"
+#include "flang/Common/template.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/template.h"
#include <cinttypes>
#include <optional>
#include <string>
diff --git a/flang/include/flang/Evaluate/variable.h b/flang/include/flang/Evaluate/variable.h
index bb4150613c81d..9b597d29813da 100644
--- a/flang/include/flang/Evaluate/variable.h
+++ b/flang/include/flang/Evaluate/variable.h
@@ -21,9 +21,9 @@
#include "static-data.h"
#include "type.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/reference.h"
+#include "flang/Common/template.h"
#include "flang/Parser/char-block.h"
-#include "flang/Support/reference.h"
-#include "flang/Support/template.h"
#include <optional>
#include <variant>
#include <vector>
diff --git a/flang/include/flang/Lower/CallInterface.h b/flang/include/flang/Lower/CallInterface.h
index c15edf62df388..72bc9dd890a94 100644
--- a/flang/include/flang/Lower/CallInterface.h
+++ b/flang/include/flang/Lower/CallInterface.h
@@ -27,8 +27,8 @@
#ifndef FORTRAN_LOWER_CALLINTERFACE_H
#define FORTRAN_LOWER_CALLINTERFACE_H
+#include "flang/Common/reference.h"
#include "flang/Evaluate/characteristics.h"
-#include "flang/Support/reference.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinOps.h"
#include <memory>
diff --git a/flang/include/flang/Lower/PFTBuilder.h b/flang/include/flang/Lower/PFTBuilder.h
index 05da17faf2dd7..42d6546b77553 100644
--- a/flang/include/flang/Lower/PFTBuilder.h
+++ b/flang/include/flang/Lower/PFTBuilder.h
@@ -17,6 +17,8 @@
#ifndef FORTRAN_LOWER_PFTBUILDER_H
#define FORTRAN_LOWER_PFTBUILDER_H
+#include "flang/Common/reference.h"
+#include "flang/Common/template.h"
#include "flang/Lower/HostAssociations.h"
#include "flang/Lower/PFTDefs.h"
#include "flang/Parser/parse-tree.h"
@@ -24,8 +26,6 @@
#include "flang/Semantics/scope.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
-#include "flang/Support/reference.h"
-#include "flang/Support/template.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h
index 08a872b228691..1cc74521e22d8 100644
--- a/flang/include/flang/Lower/Support/Utils.h
+++ b/flang/include/flang/Lower/Support/Utils.h
@@ -13,9 +13,9 @@
#ifndef FORTRAN_LOWER_SUPPORT_UTILS_H
#define FORTRAN_LOWER_SUPPORT_UTILS_H
+#include "flang/Common/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/indirection.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinAttributes.h"
diff --git a/flang/include/flang/Lower/SymbolMap.h b/flang/include/flang/Lower/SymbolMap.h
index fb64db407708a..c03f9afd40801 100644
--- a/flang/include/flang/Lower/SymbolMap.h
+++ b/flang/include/flang/Lower/SymbolMap.h
@@ -13,12 +13,12 @@
#ifndef FORTRAN_LOWER_SYMBOLMAP_H
#define FORTRAN_LOWER_SYMBOLMAP_H
+#include "flang/Common/reference.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Dialect/FortranVariableInterface.h"
#include "flang/Optimizer/Support/Matcher.h"
#include "flang/Semantics/symbol.h"
-#include "flang/Support/reference.h"
#include "mlir/IR/Value.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
diff --git a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
index 8374b18b8a17d..5ae32f70a11a7 100644
--- a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
@@ -9,8 +9,8 @@
#ifndef FORTRAN_LOWER_PPCINTRINSICCALL_H
#define FORTRAN_LOWER_PPCINTRINSICCALL_H
+#include "flang/Common/static-multimap-view.h"
#include "flang/Optimizer/Builder/IntrinsicCall.h"
-#include "flang/Support/static-multimap-view.h"
#include "mlir/Dialect/Math/IR/Math.h"
namespace fir {
diff --git a/flang/include/flang/Parser/char-block.h b/flang/include/flang/Parser/char-block.h
index 4541b31e566f9..38f4f7b82e1ea 100644
--- a/flang/include/flang/Parser/char-block.h
+++ b/flang/include/flang/Parser/char-block.h
@@ -11,7 +11,7 @@
// Describes a contiguous block of characters; does not own their storage.
-#include "flang/Support/interval.h"
+#include "flang/Common/interval.h"
#include <algorithm>
#include <cstddef>
#include <cstring>
diff --git a/flang/include/flang/Parser/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h
index 42d622c4d497b..8114cb3c7d049 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -15,8 +15,8 @@
#include "tools.h"
#include "unparse.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/indirection.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
#include <type_traits>
diff --git a/flang/include/flang/Parser/message.h b/flang/include/flang/Parser/message.h
index bfbc985b8b91a..e19b16c23b82b 100644
--- a/flang/include/flang/Parser/message.h
+++ b/flang/include/flang/Parser/message.h
@@ -16,9 +16,9 @@
#include "char-set.h"
#include "provenance.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/reference-counted.h"
#include "flang/Common/restorer.h"
#include "flang/Support/Fortran-features.h"
-#include "flang/Support/reference-counted.h"
#include <cstddef>
#include <cstring>
#include <forward_list>
diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h
index 158c27a8be2f9..69deff2a3be64 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -23,8 +23,8 @@
#include "message.h"
#include "provenance.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/indirection.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
#include "llvm/Frontend/OpenACC/ACC.h.inc"
#include "llvm/Frontend/OpenMP/OMP.h"
#include "llvm/Frontend/OpenMP/OMPConstants.h"
diff --git a/flang/include/flang/Parser/provenance.h b/flang/include/flang/Parser/provenance.h
index 7f29fb272c942..a9224b727fd05 100644
--- a/flang/include/flang/Parser/provenance.h
+++ b/flang/include/flang/Parser/provenance.h
@@ -14,7 +14,7 @@
#include "characters.h"
#include "source.h"
#include "flang/Common/idioms.h"
-#include "flang/Support/interval.h"
+#include "flang/Common/interval.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
#include <list>
diff --git a/flang/include/flang/Parser/source.h b/flang/include/flang/Parser/source.h
index a67fd66045a3d..a6efdf9546c7f 100644
--- a/flang/include/flang/Parser/source.h
+++ b/flang/include/flang/Parser/source.h
@@ -15,7 +15,7 @@
// - A Unicode byte order mark is recognized if present.
#include "characters.h"
-#include "flang/Support/reference.h"
+#include "flang/Common/reference.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
diff --git a/flang/include/flang/Semantics/expression.h b/flang/include/flang/Semantics/expression.h
index 8ea33902bd213..7b68ea728cbd5 100644
--- a/flang/include/flang/Semantics/expression.h
+++ b/flang/include/flang/Semantics/expression.h
@@ -10,6 +10,7 @@
#define FORTRAN_SEMANTICS_EXPRESSION_H_
#include "semantics.h"
+#include "flang/Common/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/characteristics.h"
@@ -23,7 +24,6 @@
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
#include <map>
#include <optional>
#include <type_traits>
diff --git a/flang/include/flang/Semantics/runtime-type-info.h b/flang/include/flang/Semantics/runtime-type-info.h
index 94c50aab69681..e90d3ae8baf1e 100644
--- a/flang/include/flang/Semantics/runtime-type-info.h
+++ b/flang/include/flang/Semantics/runtime-type-info.h
@@ -14,8 +14,8 @@
#ifndef FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
#define FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
+#include "flang/Common/reference.h"
#include "flang/Semantics/symbol.h"
-#include "flang/Support/reference.h"
#include <map>
#include <set>
#include <string>
diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index b7d115ec2bca4..b4046830522b8 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -12,10 +12,10 @@
#include "attr.h"
#include "symbol.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/reference.h"
#include "flang/Parser/message.h"
#include "flang/Parser/provenance.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/reference.h"
#include <list>
#include <map>
#include <optional>
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index dfe323acbd490..974add6cc5de3 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -11,10 +11,10 @@
#include "type.h"
#include "flang/Common/enum-set.h"
+#include "flang/Common/reference.h"
#include "flang/Common/visit.h"
#include "flang/Semantics/module-dependences.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/reference.h"
#include "llvm/ADT/DenseMapInfo.h"
#include <array>
diff --git a/flang/include/flang/Support/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
index 690329411dc50..58f84e9413676 100644
--- a/flang/include/flang/Support/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -9,9 +9,9 @@
#ifndef FORTRAN_SUPPORT_FORTRAN_FEATURES_H_
#define FORTRAN_SUPPORT_FORTRAN_FEATURES_H_
+#include "Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
-#include "flang/Support/Fortran.h"
#include <optional>
#include <vector>
diff --git a/flang/include/flang/Support/LangOptions.h b/flang/include/flang/Support/LangOptions.h
index 3c6094c9a9c87..f4f197dd87ca3 100644
--- a/flang/include/flang/Support/LangOptions.h
+++ b/flang/include/flang/Support/LangOptions.h
@@ -45,12 +45,12 @@ class LangOptionsBase {
#define LANGOPT(Name, Bits, Default) unsigned Name : Bits;
#define ENUM_LANGOPT(Name, Type, Bits, Default)
-#include "flang/Support/LangOptions.def"
+#include "LangOptions.def"
protected:
#define LANGOPT(Name, Bits, Default)
#define ENUM_LANGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "flang/Support/LangOptions.def"
+#include "LangOptions.def"
};
/// Tracks various options which control the dialect of Fortran that is
@@ -63,7 +63,7 @@ class LangOptions : public LangOptionsBase {
#define ENUM_LANGOPT(Name, Type, Bits, Default) \
Type get##Name() const { return static_cast<Type>(Name); } \
void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
-#include "flang/Support/LangOptions.def"
+#include "LangOptions.def"
/// Name of the IR file that contains the result of the OpenMP target
/// host code generation.
diff --git a/flang/include/flang/Support/MathOptionsBase.h b/flang/include/flang/Support/MathOptionsBase.h
index 072aed20da470..b4838c63d4ef8 100644
--- a/flang/include/flang/Support/MathOptionsBase.h
+++ b/flang/include/flang/Support/MathOptionsBase.h
@@ -27,16 +27,16 @@ class MathOptionsBase {
Name = static_cast<unsigned>(Value); \
return *this; \
}
-#include "flang/Support/MathOptionsBase.def"
+#include "MathOptionsBase.def"
MathOptionsBase() {
#define ENUM_MATHOPT(Name, Type, Bits, Default) set##Name(Default);
-#include "flang/Support/MathOptionsBase.def"
+#include "MathOptionsBase.def"
}
private:
#define ENUM_MATHOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "flang/Support/MathOptionsBase.def"
+#include "MathOptionsBase.def"
};
} // namespace Fortran::common
diff --git a/flang/include/flang/Common/OpenMP-utils.h b/flang/include/flang/Support/OpenMP-utils.h
similarity index 92%
rename from flang/include/flang/Common/OpenMP-utils.h
rename to flang/include/flang/Support/OpenMP-utils.h
index 827f13bc4758e..ad3da16008319 100644
--- a/flang/include/flang/Common/OpenMP-utils.h
+++ b/flang/include/flang/Support/OpenMP-utils.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/OpenMP-utils.h --------------------*- C++ -*-====//
+//===-- include/flang/Support/OpenMP-utils.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_OPENMP_UTILS_H_
-#define FORTRAN_COMMON_OPENMP_UTILS_H_
+#ifndef FORTRAN_SUPPORT_OPENMP_UTILS_H_
+#define FORTRAN_SUPPORT_OPENMP_UTILS_H_
#include "flang/Semantics/symbol.h"
@@ -73,4 +73,4 @@ mlir::Block *genEntryBlock(
mlir::OpBuilder &builder, const EntryBlockArgs &args, mlir::Region ®ion);
} // namespace Fortran::common::openmp
-#endif // FORTRAN_COMMON_OPENMP_UTILS_H_
+#endif /* FORTRAN_SUPPORT_OPENMP_UTILS_H_ */
diff --git a/flang/include/flang/Support/default-kinds.h b/flang/include/flang/Support/default-kinds.h
index 92f06e6fe2d27..5553366aa409d 100644
--- a/flang/include/flang/Support/default-kinds.h
+++ b/flang/include/flang/Support/default-kinds.h
@@ -9,7 +9,7 @@
#ifndef FORTRAN_SUPPORT_DEFAULT_KINDS_H_
#define FORTRAN_SUPPORT_DEFAULT_KINDS_H_
-#include "flang/Support/Fortran.h"
+#include "Fortran.h"
#include <cstdint>
namespace Fortran::common {
diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt
index 880b190f1c581..2fd2a429d7c22 100644
--- a/flang/lib/Decimal/CMakeLists.txt
+++ b/flang/lib/Decimal/CMakeLists.txt
@@ -1,3 +1,11 @@
+#===-- lib/Decimal/CMakeLists.txt ------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
cmake_minimum_required(VERSION 3.20.0)
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index 49d11f41ea4ca..3912d1c4b4771 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/characteristics.h"
+#include "flang/Common/indirection.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/intrinsics.h"
@@ -16,7 +17,6 @@
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <initializer_list>
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index 723bb8d97f68e..31d043f490fd8 100644
--- a/flang/lib/Evaluate/fold-implementation.h
+++ b/flang/lib/Evaluate/fold-implementation.h
@@ -12,6 +12,9 @@
#include "character.h"
#include "host.h"
#include "int-power.h"
+#include "flang/Common/indirection.h"
+#include "flang/Common/template.h"
+#include "flang/Common/unwrap.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/constant.h"
@@ -28,9 +31,6 @@
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/indirection.h"
-#include "flang/Support/template.h"
-#include "flang/Support/unwrap.h"
#include <algorithm>
#include <cmath>
#include <complex>
diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index fa2c931b21f0a..c1b270f518c0e 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -16,8 +16,8 @@
#include "host.h"
#include "flang/Common/erfc-scaled.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/static-multimap-view.h"
#include "flang/Evaluate/expression.h"
-#include "flang/Support/static-multimap-view.h"
#include <cfloat>
#include <cmath>
#include <complex>
diff --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp
index ab7c357fa78a8..58b824d9b8e64 100644
--- a/flang/lib/Evaluate/shape.cpp
+++ b/flang/lib/Evaluate/shape.cpp
@@ -8,6 +8,7 @@
#include "flang/Evaluate/shape.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/template.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/fold.h"
@@ -16,7 +17,6 @@
#include "flang/Evaluate/type.h"
#include "flang/Parser/message.h"
#include "flang/Semantics/symbol.h"
-#include "flang/Support/template.h"
#include <functional>
using namespace std::placeholders; // _1, _2, &c. for std::bind()
diff --git a/flang/lib/Evaluate/target.cpp b/flang/lib/Evaluate/target.cpp
index f87cce8b32005..94dc35ecd5900 100644
--- a/flang/lib/Evaluate/target.cpp
+++ b/flang/lib/Evaluate/target.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/target.h"
+#include "flang/Common/template.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/type.h"
-#include "flang/Support/template.h"
namespace Fortran::evaluate {
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 04df137ce566f..b33baf90582b8 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/ConvertExpr.h"
+#include "flang/Common/unwrap.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/real.h"
#include "flang/Evaluate/traverse.h"
@@ -51,7 +52,6 @@
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
#include "flang/Support/default-kinds.h"
-#include "flang/Support/unwrap.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/CommandLine.h"
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index aa40b12196520..1165417ef89a2 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/Mangler.h"
+#include "flang/Common/reference.h"
#include "flang/Lower/Support/Utils.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/reference.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 7c8d292e90f01..3789babd6c2c8 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -18,7 +18,6 @@
#include "Decomposer.h"
#include "ReductionProcessor.h"
#include "Utils.h"
-#include "flang/Common/OpenMP-utils.h"
#include "flang/Common/idioms.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/ConvertExpr.h"
@@ -35,6 +34,7 @@
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/openmp-directive-sets.h"
#include "flang/Semantics/tools.h"
+#include "flang/Support/OpenMP-utils.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Transforms/RegionUtils.h"
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 803fa8bff90dc..db9918c265164 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Optimizer/Builder/IntrinsicCall.h"
+#include "flang/Common/static-multimap-view.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/Character.h"
#include "flang/Optimizer/Builder/Complex.h"
@@ -41,7 +42,6 @@
#include "flang/Optimizer/Support/Utils.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/iostat-consts.h"
-#include "flang/Support/static-multimap-view.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
diff --git a/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp b/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
index 555601c5e92df..696e80105f80f 100644
--- a/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
+++ b/flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/OpenMP-utils.h"
+#include "flang/Support/OpenMP-utils.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
diff --git a/flang/lib/Parser/basic-parsers.h b/flang/lib/Parser/basic-parsers.h
index d739102b8464f..7e69d41debfcd 100644
--- a/flang/lib/Parser/basic-parsers.h
+++ b/flang/lib/Parser/basic-parsers.h
@@ -23,13 +23,13 @@
// template functions. See parser-combinators.txt for documentation.
#include "flang/Common/idioms.h"
+#include "flang/Common/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-state.h"
#include "flang/Parser/provenance.h"
#include "flang/Parser/user-state.h"
#include "flang/Support/Fortran-features.h"
-#include "flang/Support/indirection.h"
#include <cstring>
#include <functional>
#include <list>
diff --git a/flang/lib/Parser/parse-tree.cpp b/flang/lib/Parser/parse-tree.cpp
index 89491fd2fa2a7..a414f226058e3 100644
--- a/flang/lib/Parser/parse-tree.cpp
+++ b/flang/lib/Parser/parse-tree.cpp
@@ -8,9 +8,9 @@
#include "flang/Parser/parse-tree.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/indirection.h"
#include "flang/Parser/tools.h"
#include "flang/Parser/user-state.h"
-#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index d5d9252cf4c73..993a38749bf50 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -11,12 +11,12 @@
#include "flang/Parser/unparse.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/indirection.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cinttypes>
diff --git a/flang/lib/Semantics/assignment.h b/flang/lib/Semantics/assignment.h
index ba0c70f7d224c..95d7b3cf91b17 100644
--- a/flang/lib/Semantics/assignment.h
+++ b/flang/lib/Semantics/assignment.h
@@ -9,9 +9,9 @@
#ifndef FORTRAN_SEMANTICS_ASSIGNMENT_H_
#define FORTRAN_SEMANTICS_ASSIGNMENT_H_
+#include "flang/Common/indirection.h"
#include "flang/Evaluate/expression.h"
#include "flang/Semantics/semantics.h"
-#include "flang/Support/indirection.h"
namespace Fortran::parser {
class ContextualMessages;
diff --git a/flang/lib/Semantics/check-case.cpp b/flang/lib/Semantics/check-case.cpp
index c81d3b16ab313..5ce143c9aec91 100644
--- a/flang/lib/Semantics/check-case.cpp
+++ b/flang/lib/Semantics/check-case.cpp
@@ -8,13 +8,13 @@
#include "check-case.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/reference.h"
+#include "flang/Common/template.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/type.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/reference.h"
-#include "flang/Support/template.h"
#include <tuple>
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-coarray.cpp b/flang/lib/Semantics/check-coarray.cpp
index ac1f38801cee7..6cf61a6b923db 100644
--- a/flang/lib/Semantics/check-coarray.cpp
+++ b/flang/lib/Semantics/check-coarray.cpp
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "check-coarray.h"
+#include "flang/Common/indirection.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/indirection.h"
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index 32dcaad52e33a..c85a84ea5527f 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "check-cuda.h"
+#include "flang/Common/template.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/tools.h"
#include "flang/Evaluate/traverse.h"
@@ -16,7 +17,6 @@
#include "flang/Semantics/expression.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/template.h"
// Once labeled DO constructs have been canonicalized and their parse subtrees
// transformed into parser::DoConstructs, scan the parser::Blocks of the program
diff --git a/flang/lib/Semantics/check-data.h b/flang/lib/Semantics/check-data.h
index 6da316cccc4a7..479d32568fa66 100644
--- a/flang/lib/Semantics/check-data.h
+++ b/flang/lib/Semantics/check-data.h
@@ -10,11 +10,11 @@
#define FORTRAN_SEMANTICS_CHECK_DATA_H_
#include "data-to-inits.h"
+#include "flang/Common/interval.h"
#include "flang/Evaluate/fold-designator.h"
#include "flang/Evaluate/initial-image.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/semantics.h"
-#include "flang/Support/interval.h"
#include <list>
#include <map>
#include <vector>
diff --git a/flang/lib/Semantics/check-do-forall.cpp b/flang/lib/Semantics/check-do-forall.cpp
index ddba4c04b1ee3..84e6b6455cc61 100644
--- a/flang/lib/Semantics/check-do-forall.cpp
+++ b/flang/lib/Semantics/check-do-forall.cpp
@@ -8,6 +8,7 @@
#include "check-do-forall.h"
#include "definable.h"
+#include "flang/Common/template.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/tools.h"
@@ -21,7 +22,6 @@
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
-#include "flang/Support/template.h"
namespace Fortran::evaluate {
using ActualArgumentRef = common::Reference<const ActualArgument>;
diff --git a/flang/lib/Semantics/check-select-type.cpp b/flang/lib/Semantics/check-select-type.cpp
index b86a95492b21c..94d16a719277a 100644
--- a/flang/lib/Semantics/check-select-type.cpp
+++ b/flang/lib/Semantics/check-select-type.cpp
@@ -8,12 +8,12 @@
#include "check-select-type.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/reference.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/type.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/reference.h"
#include <optional>
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/data-to-inits.h b/flang/lib/Semantics/data-to-inits.h
index e99a02cc79db1..7486ac8113e90 100644
--- a/flang/lib/Semantics/data-to-inits.h
+++ b/flang/lib/Semantics/data-to-inits.h
@@ -9,10 +9,10 @@
#ifndef FORTRAN_SEMANTICS_DATA_TO_INITS_H_
#define FORTRAN_SEMANTICS_DATA_TO_INITS_H_
+#include "flang/Common/interval.h"
#include "flang/Evaluate/fold-designator.h"
#include "flang/Evaluate/initial-image.h"
#include "flang/Support/default-kinds.h"
-#include "flang/Support/interval.h"
#include <list>
#include <map>
diff --git a/flang/lib/Semantics/pointer-assignment.cpp b/flang/lib/Semantics/pointer-assignment.cpp
index 49684ffd5f804..7f4548c7327e3 100644
--- a/flang/lib/Semantics/pointer-assignment.cpp
+++ b/flang/lib/Semantics/pointer-assignment.cpp
@@ -10,6 +10,7 @@
#include "definable.h"
#include "flang/Common/idioms.h"
#include "flang/Common/restorer.h"
+#include "flang/Common/template.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/fold.h"
@@ -20,7 +21,6 @@
#include "flang/Semantics/expression.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/template.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <set>
diff --git a/flang/lib/Semantics/resolve-labels.cpp b/flang/lib/Semantics/resolve-labels.cpp
index 584319b8abdf6..04e4b142efedf 100644
--- a/flang/lib/Semantics/resolve-labels.cpp
+++ b/flang/lib/Semantics/resolve-labels.cpp
@@ -8,9 +8,9 @@
#include "resolve-labels.h"
#include "flang/Common/enum-set.h"
+#include "flang/Common/template.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Semantics/semantics.h"
-#include "flang/Support/template.h"
#include <cstdarg>
#include <type_traits>
diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp
index 065090ed03b6a..c91c522b7c73e 100644
--- a/flang/lib/Semantics/resolve-names-utils.cpp
+++ b/flang/lib/Semantics/resolve-names-utils.cpp
@@ -8,6 +8,7 @@
#include "resolve-names-utils.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/indirection.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/tools.h"
#include "flang/Evaluate/traverse.h"
@@ -19,7 +20,6 @@
#include "flang/Semantics/tools.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
#include <initializer_list>
#include <variant>
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index d0e0a3784f2af..d6d05a41f6917 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -13,6 +13,7 @@
#include "resolve-directives.h"
#include "resolve-names-utils.h"
#include "rewrite-parse-tree.h"
+#include "flang/Common/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/characteristics.h"
@@ -37,7 +38,6 @@
#include "flang/Semantics/type.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/default-kinds.h"
-#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <list>
#include <map>
diff --git a/flang/lib/Semantics/rewrite-parse-tree.cpp b/flang/lib/Semantics/rewrite-parse-tree.cpp
index 171c0021fba08..577558e7e33b2 100644
--- a/flang/lib/Semantics/rewrite-parse-tree.cpp
+++ b/flang/lib/Semantics/rewrite-parse-tree.cpp
@@ -8,6 +8,7 @@
#include "rewrite-parse-tree.h"
#include "rewrite-directives.h"
+#include "flang/Common/indirection.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
@@ -15,7 +16,6 @@
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
-#include "flang/Support/indirection.h"
#include <list>
namespace Fortran::semantics {
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 64e4c9d7e194d..1166ec9a58f86 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Parser/tools.h"
+#include "flang/Common/indirection.h"
#include "flang/Parser/dump-parse-tree.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
@@ -16,7 +17,6 @@
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
#include "flang/Support/Fortran.h"
-#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <set>
diff --git a/flang/lib/Support/OpenMP-utils.cpp b/flang/lib/Support/OpenMP-utils.cpp
index b3cab763aca30..178a6e38dc0f2 100644
--- a/flang/lib/Support/OpenMP-utils.cpp
+++ b/flang/lib/Support/OpenMP-utils.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/OpenMP-utils.h"
+#include "flang/Support/OpenMP-utils.h"
#include "mlir/IR/OpDefinition.h"
>From f3e9c1533d550b89c476c4f12123d5fb074e387b Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 29 Jan 2025 11:39:41 +0100
Subject: [PATCH 13/41] add missing includes
---
flang/include/flang/Common/erfc-scaled.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/flang/include/flang/Common/erfc-scaled.h b/flang/include/flang/Common/erfc-scaled.h
index a1bf3ea0f0925..88e2183c15d03 100644
--- a/flang/include/flang/Common/erfc-scaled.h
+++ b/flang/include/flang/Common/erfc-scaled.h
@@ -9,6 +9,9 @@
#ifndef FORTRAN_COMMON_ERFC_SCALED_H_
#define FORTRAN_COMMON_ERFC_SCALED_H_
+#include <cmath>
+#include <limits>
+
namespace Fortran::common {
template <typename T> inline T ErfcScaled(T arg) {
// Coefficients for approximation to erfc in the first interval.
>From 6a7bd039888c71fe037c451223fd602ccc046b09 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 29 Jan 2025 13:53:45 +0100
Subject: [PATCH 14/41] Use C++style comments for header guards
---
flang/include/flang/Runtime/random.h | 2 +-
flang/include/flang/Support/Fortran-features.h | 2 +-
flang/include/flang/Support/Fortran.h | 2 +-
flang/include/flang/Support/LangOptions.h | 2 +-
flang/include/flang/Support/MathOptionsBase.h | 2 +-
flang/include/flang/Support/OpenMP-utils.h | 2 +-
flang/include/flang/Support/Timing.h | 8 ++++----
flang/include/flang/Support/Version.h | 2 +-
flang/include/flang/Support/default-kinds.h | 2 +-
flang/lib/Support/Timing.cpp | 2 +-
10 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/flang/include/flang/Runtime/random.h b/flang/include/flang/Runtime/random.h
index bb6dcb3873f21..1f01be1aa9ffa 100644
--- a/flang/include/flang/Runtime/random.h
+++ b/flang/include/flang/Runtime/random.h
@@ -39,4 +39,4 @@ void RTNAME(RandomSeed)(const Descriptor *size, const Descriptor *put,
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_RANDOM_H_ */
+#endif // FORTRAN_RUNTIME_RANDOM_H_
diff --git a/flang/include/flang/Support/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
index 58f84e9413676..826b65e8d3c3c 100644
--- a/flang/include/flang/Support/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -125,4 +125,4 @@ class LanguageFeatureControl {
bool warnAllUsage_{false};
};
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_FORTRAN_FEATURES_H_ */
+#endif // FORTRAN_SUPPORT_FORTRAN_FEATURES_H_
diff --git a/flang/include/flang/Support/Fortran.h b/flang/include/flang/Support/Fortran.h
index 4e6bdbb67f5f3..6e6e37ba594be 100644
--- a/flang/include/flang/Support/Fortran.h
+++ b/flang/include/flang/Support/Fortran.h
@@ -109,4 +109,4 @@ inline std::string GetExternalAssemblyName(
}
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_FORTRAN_H_ */
+#endif // FORTRAN_SUPPORT_FORTRAN_H_
diff --git a/flang/include/flang/Support/LangOptions.h b/flang/include/flang/Support/LangOptions.h
index f4f197dd87ca3..fac6fb92df85a 100644
--- a/flang/include/flang/Support/LangOptions.h
+++ b/flang/include/flang/Support/LangOptions.h
@@ -77,4 +77,4 @@ class LangOptions : public LangOptionsBase {
} // end namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_LANGOPTIONS_H_ */
+#endif // FORTRAN_SUPPORT_LANGOPTIONS_H_
diff --git a/flang/include/flang/Support/MathOptionsBase.h b/flang/include/flang/Support/MathOptionsBase.h
index b4838c63d4ef8..a2bea3c598a8c 100644
--- a/flang/include/flang/Support/MathOptionsBase.h
+++ b/flang/include/flang/Support/MathOptionsBase.h
@@ -41,4 +41,4 @@ class MathOptionsBase {
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_MATHOPTIONSBASE_H_ */
+#endif // FORTRAN_SUPPORT_MATHOPTIONSBASE_H_
diff --git a/flang/include/flang/Support/OpenMP-utils.h b/flang/include/flang/Support/OpenMP-utils.h
index ad3da16008319..d8f82e1cf94f1 100644
--- a/flang/include/flang/Support/OpenMP-utils.h
+++ b/flang/include/flang/Support/OpenMP-utils.h
@@ -73,4 +73,4 @@ mlir::Block *genEntryBlock(
mlir::OpBuilder &builder, const EntryBlockArgs &args, mlir::Region ®ion);
} // namespace Fortran::common::openmp
-#endif /* FORTRAN_SUPPORT_OPENMP_UTILS_H_ */
+#endif // FORTRAN_SUPPORT_OPENMP_UTILS_H_
diff --git a/flang/include/flang/Support/Timing.h b/flang/include/flang/Support/Timing.h
index 5d66831d6c1c2..75ba2a8d85f39 100644
--- a/flang/include/flang/Support/Timing.h
+++ b/flang/include/flang/Support/Timing.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/Timing.h --------------------------*- C++ -*-===//
+//===- Timing.h - Execution time measurement facilities ---------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_SUPPORT_TIMING_H_
-#define FORTRAN_SUPPORT_TIMING_H_
+#ifndef FORTRAN_SUPPORT_TIMING_H
+#define FORTRAN_SUPPORT_TIMING_H
#include "mlir/Support/Timing.h"
@@ -24,4 +24,4 @@ std::unique_ptr<mlir::OutputStrategy> createTimingFormatterText(
} // namespace Fortran::support
-#endif /* FORTRAN_SUPPORT_TIMING_H_ */
+#endif // FORTRAN_SUPPORT_TIMING_H
diff --git a/flang/include/flang/Support/Version.h b/flang/include/flang/Support/Version.h
index 4ceb19e7f4d71..fe7f7395e1eba 100644
--- a/flang/include/flang/Support/Version.h
+++ b/flang/include/flang/Support/Version.h
@@ -53,4 +53,4 @@ std::string getFlangFullVersion();
std::string getFlangToolFullVersion(llvm::StringRef ToolName);
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_VERSION_H_ */
+#endif // FORTRAN_SUPPORT_VERSION_H_
diff --git a/flang/include/flang/Support/default-kinds.h b/flang/include/flang/Support/default-kinds.h
index 5553366aa409d..ab1422d63af30 100644
--- a/flang/include/flang/Support/default-kinds.h
+++ b/flang/include/flang/Support/default-kinds.h
@@ -58,4 +58,4 @@ class IntrinsicTypeDefaultKinds {
int defaultLogicalKind_{defaultIntegerKind_};
};
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_DEFAULT_KINDS_H_ */
+#endif // FORTRAN_SUPPORT_DEFAULT_KINDS_H_
diff --git a/flang/lib/Support/Timing.cpp b/flang/lib/Support/Timing.cpp
index 41cb2be826907..ee8309a950eec 100644
--- a/flang/lib/Support/Timing.cpp
+++ b/flang/lib/Support/Timing.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Support/Timing.cpp ----------------------------------*- C++ -*-===//
+//===- Timing.cpp - Execution time measurement facilities -----------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
>From db749b9e8d8490486cd45cf0b9e0ccf9ada77f44 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 29 Jan 2025 14:15:02 +0100
Subject: [PATCH 15/41] Use C++style comments for header guards II
---
flang/include/flang/Support/OpenMP-features.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/include/flang/Support/OpenMP-features.h b/flang/include/flang/Support/OpenMP-features.h
index 85c901e7fdb82..1dd7ea560cc96 100644
--- a/flang/include/flang/Support/OpenMP-features.h
+++ b/flang/include/flang/Support/OpenMP-features.h
@@ -49,4 +49,4 @@ void setOpenMPMacro(int version, FortranPredefinitions &predefinitions) {
}
}
} // namespace Fortran::common
-#endif /* FORTRAN_SUPPORT_OPENMP_FEATURES_H_ */
+#endif // FORTRAN_SUPPORT_OPENMP_FEATURES_H_
>From b41db9690a2dc035be9bc89c30c835d31632e5b5 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 30 Jan 2025 11:24:33 +0100
Subject: [PATCH 16/41] Post-merge fixes
---
flang-rt/lib/flang_rt/CUDA/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt b/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
index 3c741ac93d64b..428aa3059b869 100644
--- a/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
+++ b/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
@@ -11,6 +11,7 @@ add_flangrt_library(CufRuntime STATIC
allocatable.cpp
allocator.cpp
descriptor.cpp
+ init.cpp
kernel.cpp
memmove-function.cpp
memory.cpp
>From 3ce4b52dc9c4c56e1570d56a45de15e957de81d6 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 30 Jan 2025 13:33:57 +0100
Subject: [PATCH 17/41] Post-merge fixes
---
flang-rt/cmake/modules/AddFlangRTOffload.cmake | 2 +-
flang-rt/include/flang-rt/CUDA/allocator.h | 2 +-
flang-rt/include/flang-rt/allocator-registry.h | 2 +-
flang-rt/include/flang-rt/array-constructor.h | 2 +-
flang-rt/include/flang-rt/assign-impl.h | 2 +-
flang-rt/include/flang-rt/buffer.h | 2 +-
flang-rt/include/flang-rt/connection.h | 2 +-
flang-rt/include/flang-rt/derived.h | 2 +-
flang-rt/include/flang-rt/descriptor.h | 2 +-
flang-rt/include/flang-rt/emit-encoded.h | 2 +-
flang-rt/include/flang-rt/environment.h | 2 +-
flang-rt/include/flang-rt/file.h | 2 +-
flang-rt/include/flang-rt/format-implementation.h | 2 +-
flang-rt/include/flang-rt/format.h | 2 +-
flang-rt/include/flang-rt/internal-unit.h | 2 +-
flang-rt/include/flang-rt/io-error.h | 2 +-
flang-rt/include/flang-rt/io-stmt.h | 2 +-
flang-rt/include/flang-rt/lock.h | 2 +-
flang-rt/include/flang-rt/memory.h | 2 +-
flang-rt/include/flang-rt/namelist.h | 2 +-
flang-rt/include/flang-rt/non-tbp-dio.h | 2 +-
flang-rt/include/flang-rt/numeric-templates.h | 2 +-
flang-rt/include/flang-rt/random-templates.h | 2 +-
flang-rt/include/flang-rt/reduction-templates.h | 2 +-
flang-rt/include/flang-rt/stat.h | 2 +-
flang-rt/include/flang-rt/terminator.h | 2 +-
flang-rt/include/flang-rt/tools.h | 2 +-
flang-rt/include/flang-rt/type-code.h | 2 +-
flang-rt/include/flang-rt/type-info.h | 2 +-
flang-rt/include/flang-rt/utf.h | 2 +-
flang-rt/lib/FortranFloat128Math/complex-math.h | 2 +-
flang-rt/lib/FortranFloat128Math/math-entries.h | 2 +-
flang-rt/lib/FortranFloat128Math/numeric-template-specs.h | 2 +-
{flang/runtime => flang-rt/lib/flang_rt}/CUDA/init.cpp | 6 +++---
flang-rt/lib/flang_rt/ISO_Fortran_util.h | 2 +-
flang-rt/lib/flang_rt/complex-reduction.h | 2 +-
flang-rt/lib/flang_rt/copy.h | 2 +-
flang-rt/lib/flang_rt/descriptor-io.h | 2 +-
flang-rt/lib/flang_rt/edit-input.h | 2 +-
flang-rt/lib/flang_rt/edit-output.h | 2 +-
flang-rt/lib/flang_rt/io-api-common.h | 2 +-
flang-rt/lib/flang_rt/stack.h | 2 +-
flang-rt/lib/flang_rt/unit-map.h | 2 +-
flang-rt/lib/flang_rt/unit.h | 2 +-
flang-rt/unittests/Runtime/tools.h | 2 +-
45 files changed, 47 insertions(+), 47 deletions(-)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/init.cpp (82%)
diff --git a/flang-rt/cmake/modules/AddFlangRTOffload.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
index b055646cb0604..df84ed8f4c8d2 100644
--- a/flang-rt/cmake/modules/AddFlangRTOffload.cmake
+++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
@@ -1,4 +1,4 @@
-#===-- cmake/modules/AddFortranRTOffload.txt -------------------------------===#
+#===-- cmake/modules/AddFlangRTOffload.cmake -------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/include/flang-rt/CUDA/allocator.h b/flang-rt/include/flang-rt/CUDA/allocator.h
index fb09b5ff2402a..68bb0736dd5ee 100644
--- a/flang-rt/include/flang-rt/CUDA/allocator.h
+++ b/flang-rt/include/flang-rt/CUDA/allocator.h
@@ -33,4 +33,4 @@ void *CUFAllocUnified(std::size_t);
void CUFFreeUnified(void *);
} // namespace Fortran::runtime::cuda
-#endif /* FLANG_RT_CUDA_ALLOCATOR_H_ */
+#endif // FLANG_RT_CUDA_ALLOCATOR_H_
diff --git a/flang-rt/include/flang-rt/allocator-registry.h b/flang-rt/include/flang-rt/allocator-registry.h
index 1f004462ca624..ea905afc045ce 100644
--- a/flang-rt/include/flang-rt/allocator-registry.h
+++ b/flang-rt/include/flang-rt/allocator-registry.h
@@ -55,4 +55,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif /* FLANG_RT_ALLOCATOR_REGISTRY_H_ */
+#endif // FLANG_RT_ALLOCATOR_REGISTRY_H_
diff --git a/flang-rt/include/flang-rt/array-constructor.h b/flang-rt/include/flang-rt/array-constructor.h
index 7ff0779e46c6a..738050f80ef65 100644
--- a/flang-rt/include/flang-rt/array-constructor.h
+++ b/flang-rt/include/flang-rt/array-constructor.h
@@ -54,4 +54,4 @@ static_assert(alignof(Fortran::runtime::ArrayConstructorVector) <=
"MaxArrayConstructorVectorAlignInBytes");
} // namespace Fortran::runtime
-#endif /* FLANG_RT_ARRAY_CONSTRUCTOR_H_ */
+#endif // FLANG_RT_ARRAY_CONSTRUCTOR_H_
diff --git a/flang-rt/include/flang-rt/assign-impl.h b/flang-rt/include/flang-rt/assign-impl.h
index 7e2cef9df753b..2e85a451d5b52 100644
--- a/flang-rt/include/flang-rt/assign-impl.h
+++ b/flang-rt/include/flang-rt/assign-impl.h
@@ -28,4 +28,4 @@ RT_API_ATTRS void DoFromSourceAssign(Descriptor &, const Descriptor &,
#endif
} // namespace Fortran::runtime
-#endif /* FLANG_RT_ASSIGN_IMPL_H_ */
+#endif // FLANG_RT_ASSIGN_IMPL_H_
diff --git a/flang-rt/include/flang-rt/buffer.h b/flang-rt/include/flang-rt/buffer.h
index ba172448a93a5..bd2e8c47c6e30 100644
--- a/flang-rt/include/flang-rt/buffer.h
+++ b/flang-rt/include/flang-rt/buffer.h
@@ -221,4 +221,4 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
bool dirty_{false};
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_BUFFER_H_ */
+#endif // FLANG_RT_BUFFER_H_
diff --git a/flang-rt/include/flang-rt/connection.h b/flang-rt/include/flang-rt/connection.h
index 7f594deee69c6..550ddb15c7236 100644
--- a/flang-rt/include/flang-rt/connection.h
+++ b/flang-rt/include/flang-rt/connection.h
@@ -124,4 +124,4 @@ class SavedPosition {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_CONNECTION_H_ */
+#endif // FLANG_RT_CONNECTION_H_
diff --git a/flang-rt/include/flang-rt/derived.h b/flang-rt/include/flang-rt/derived.h
index 797a089e767c4..d65fb75172495 100644
--- a/flang-rt/include/flang-rt/derived.h
+++ b/flang-rt/include/flang-rt/derived.h
@@ -48,4 +48,4 @@ RT_API_ATTRS void Destroy(const Descriptor &, bool finalize,
RT_API_ATTRS bool HasDynamicComponent(const Descriptor &);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_DERIVED_H_ */
+#endif // FLANG_RT_DERIVED_H_
diff --git a/flang-rt/include/flang-rt/descriptor.h b/flang-rt/include/flang-rt/descriptor.h
index 27f80bec4ba93..f97b8443425dc 100644
--- a/flang-rt/include/flang-rt/descriptor.h
+++ b/flang-rt/include/flang-rt/descriptor.h
@@ -482,4 +482,4 @@ class alignas(Descriptor) StaticDescriptor {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_DESCRIPTOR_H_ */
+#endif // FLANG_RT_DESCRIPTOR_H_
diff --git a/flang-rt/include/flang-rt/emit-encoded.h b/flang-rt/include/flang-rt/emit-encoded.h
index f3cb7a9f790e4..279f751daff2c 100644
--- a/flang-rt/include/flang-rt/emit-encoded.h
+++ b/flang-rt/include/flang-rt/emit-encoded.h
@@ -114,4 +114,4 @@ RT_API_ATTRS bool EmitRepeated(CONTEXT &to, char ch, std::size_t n) {
}
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_EMIT_ENCODED_H_ */
+#endif // FLANG_RT_EMIT_ENCODED_H_
diff --git a/flang-rt/include/flang-rt/environment.h b/flang-rt/include/flang-rt/environment.h
index b7597ad88af62..7fa3060768502 100644
--- a/flang-rt/include/flang-rt/environment.h
+++ b/flang-rt/include/flang-rt/environment.h
@@ -67,4 +67,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif /* FLANG_RT_ENVIRONMENT_H_ */
+#endif // FLANG_RT_ENVIRONMENT_H_
diff --git a/flang-rt/include/flang-rt/file.h b/flang-rt/include/flang-rt/file.h
index ca95156e1fba4..3ab21c655a38f 100644
--- a/flang-rt/include/flang-rt/file.h
+++ b/flang-rt/include/flang-rt/file.h
@@ -113,4 +113,4 @@ RT_API_ATTRS bool MayWrite(const char *path);
RT_API_ATTRS bool MayReadAndWrite(const char *path);
RT_API_ATTRS std::int64_t SizeInBytes(const char *path);
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_FILE_H_ */
+#endif // FLANG_RT_FILE_H_
diff --git a/flang-rt/include/flang-rt/format-implementation.h b/flang-rt/include/flang-rt/format-implementation.h
index 52f265d06f9bf..6a2e1078ab350 100644
--- a/flang-rt/include/flang-rt/format-implementation.h
+++ b/flang-rt/include/flang-rt/format-implementation.h
@@ -601,4 +601,4 @@ RT_API_ATTRS void FormatControl<CONTEXT>::Finish(Context &context) {
}
}
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_FORMAT_IMPLEMENTATION_H_ */
+#endif // FLANG_RT_FORMAT_IMPLEMENTATION_H_
diff --git a/flang-rt/include/flang-rt/format.h b/flang-rt/include/flang-rt/format.h
index d81241e41877c..09e151a2e98ca 100644
--- a/flang-rt/include/flang-rt/format.h
+++ b/flang-rt/include/flang-rt/format.h
@@ -201,4 +201,4 @@ template <typename CONTEXT> class FormatControl {
Iteration stack_[maxMaxHeight];
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_FORMAT_H_ */
+#endif // FLANG_RT_FORMAT_H_
diff --git a/flang-rt/include/flang-rt/internal-unit.h b/flang-rt/include/flang-rt/internal-unit.h
index 21e64b5624196..946d69080e611 100644
--- a/flang-rt/include/flang-rt/internal-unit.h
+++ b/flang-rt/include/flang-rt/internal-unit.h
@@ -56,4 +56,4 @@ template <Direction DIR> class InternalDescriptorUnit : public ConnectionState {
extern template class InternalDescriptorUnit<Direction::Output>;
extern template class InternalDescriptorUnit<Direction::Input>;
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_INTERNAL_UNIT_H_ */
+#endif // FLANG_RT_INTERNAL_UNIT_H_
diff --git a/flang-rt/include/flang-rt/io-error.h b/flang-rt/include/flang-rt/io-error.h
index c74c08970f94a..6b5c0f9f39019 100644
--- a/flang-rt/include/flang-rt/io-error.h
+++ b/flang-rt/include/flang-rt/io-error.h
@@ -80,4 +80,4 @@ class IoErrorHandler : public Terminator {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_IO_ERROR_H_ */
+#endif // FLANG_RT_IO_ERROR_H_
diff --git a/flang-rt/include/flang-rt/io-stmt.h b/flang-rt/include/flang-rt/io-stmt.h
index 87fd93c353d76..7efab320e5e1a 100644
--- a/flang-rt/include/flang-rt/io-stmt.h
+++ b/flang-rt/include/flang-rt/io-stmt.h
@@ -791,4 +791,4 @@ class ErroneousIoStatementState : public IoStatementBase {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_IO_STMT_H_ */
+#endif // FLANG_RT_IO_STMT_H_
diff --git a/flang-rt/include/flang-rt/lock.h b/flang-rt/include/flang-rt/lock.h
index f57e97184edd5..1b09434d26f4f 100644
--- a/flang-rt/include/flang-rt/lock.h
+++ b/flang-rt/include/flang-rt/lock.h
@@ -113,4 +113,4 @@ class CriticalSection {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_LOCK_H_ */
+#endif // FLANG_RT_LOCK_H_
diff --git a/flang-rt/include/flang-rt/memory.h b/flang-rt/include/flang-rt/memory.h
index afbb1b34c1d2c..64db30baf2806 100644
--- a/flang-rt/include/flang-rt/memory.h
+++ b/flang-rt/include/flang-rt/memory.h
@@ -170,4 +170,4 @@ template <typename A> struct Allocator {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_MEMORY_H_ */
+#endif // FLANG_RT_MEMORY_H_
diff --git a/flang-rt/include/flang-rt/namelist.h b/flang-rt/include/flang-rt/namelist.h
index 5757bfb3b7109..2ae93ca9c2050 100644
--- a/flang-rt/include/flang-rt/namelist.h
+++ b/flang-rt/include/flang-rt/namelist.h
@@ -51,4 +51,4 @@ class NamelistGroup {
RT_API_ATTRS bool IsNamelistNameOrSlash(IoStatementState &);
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_NAMELIST_H_ */
+#endif // FLANG_RT_NAMELIST_H_
diff --git a/flang-rt/include/flang-rt/non-tbp-dio.h b/flang-rt/include/flang-rt/non-tbp-dio.h
index 58ed29ba7a102..1088257b72f59 100644
--- a/flang-rt/include/flang-rt/non-tbp-dio.h
+++ b/flang-rt/include/flang-rt/non-tbp-dio.h
@@ -53,4 +53,4 @@ struct NonTbpDefinedIoTable {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_NON_TBP_DIO_H_ */
+#endif // FLANG_RT_NON_TBP_DIO_H_
diff --git a/flang-rt/include/flang-rt/numeric-templates.h b/flang-rt/include/flang-rt/numeric-templates.h
index 7019151c3a207..a1475923ff3b1 100644
--- a/flang-rt/include/flang-rt/numeric-templates.h
+++ b/flang-rt/include/flang-rt/numeric-templates.h
@@ -368,4 +368,4 @@ template <typename T> inline RT_API_ATTRS T ErfcScaled(T arg) {
} // namespace Fortran::runtime
-#endif /* FLANG_RT_NUMERIC_TEMPLATES_H_ */
+#endif // FLANG_RT_NUMERIC_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/random-templates.h b/flang-rt/include/flang-rt/random-templates.h
index f320f2cd328f5..00542bd5b2553 100644
--- a/flang-rt/include/flang-rt/random-templates.h
+++ b/flang-rt/include/flang-rt/random-templates.h
@@ -108,4 +108,4 @@ inline void GenerateUnsigned(const Descriptor &harvest) {
} // namespace Fortran::runtime::random
-#endif /* FLANG_RT_RANDOM_TEMPLATES_H_ */
+#endif // FLANG_RT_RANDOM_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/reduction-templates.h b/flang-rt/include/flang-rt/reduction-templates.h
index 513b3e4478498..d6b3c24920cf9 100644
--- a/flang-rt/include/flang-rt/reduction-templates.h
+++ b/flang-rt/include/flang-rt/reduction-templates.h
@@ -416,4 +416,4 @@ template <int KIND> struct Norm2Helper {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_REDUCTION_TEMPLATES_H_ */
+#endif // FLANG_RT_REDUCTION_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/stat.h b/flang-rt/include/flang-rt/stat.h
index 95ae286a03b49..a6824f4803561 100644
--- a/flang-rt/include/flang-rt/stat.h
+++ b/flang-rt/include/flang-rt/stat.h
@@ -60,4 +60,4 @@ RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat); // returns stat
RT_API_ATTRS int ReturnError(Terminator &, int stat,
const Descriptor *errmsg = nullptr, bool hasStat = false);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_STAT_H_ */
+#endif // FLANG_RT_STAT_H_
diff --git a/flang-rt/include/flang-rt/terminator.h b/flang-rt/include/flang-rt/terminator.h
index 800ed6f3755b7..c2a4e1f64eb66 100644
--- a/flang-rt/include/flang-rt/terminator.h
+++ b/flang-rt/include/flang-rt/terminator.h
@@ -121,4 +121,4 @@ namespace Fortran::runtime::io {
RT_API_ATTRS void FlushOutputOnCrash(const Terminator &);
}
-#endif /* FLANG_RT_TERMINATOR_H_ */
+#endif // FLANG_RT_TERMINATOR_H_
diff --git a/flang-rt/include/flang-rt/tools.h b/flang-rt/include/flang-rt/tools.h
index 38804a1f40991..3503c49308e4d 100644
--- a/flang-rt/include/flang-rt/tools.h
+++ b/flang-rt/include/flang-rt/tools.h
@@ -570,4 +570,4 @@ RT_API_ATTRS void CreatePartialReductionResult(Descriptor &result,
const char *intrinsic, TypeCode);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_TOOLS_H_ */
+#endif // FLANG_RT_TOOLS_H_
diff --git a/flang-rt/include/flang-rt/type-code.h b/flang-rt/include/flang-rt/type-code.h
index 1d057481261a1..a3b79462887c1 100644
--- a/flang-rt/include/flang-rt/type-code.h
+++ b/flang-rt/include/flang-rt/type-code.h
@@ -75,4 +75,4 @@ class TypeCode {
ISO::CFI_type_t raw_{CFI_type_other};
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_TYPE_CODE_H_ */
+#endif // FLANG_RT_TYPE_CODE_H_
diff --git a/flang-rt/include/flang-rt/type-info.h b/flang-rt/include/flang-rt/type-info.h
index 52e208c93fe25..dc5cd98d7523f 100644
--- a/flang-rt/include/flang-rt/type-info.h
+++ b/flang-rt/include/flang-rt/type-info.h
@@ -321,4 +321,4 @@ class DerivedType {
};
} // namespace Fortran::runtime::typeInfo
-#endif /* FLANG_RT_TYPE_INFO_H_ */
+#endif // FLANG_RT_TYPE_INFO_H_
diff --git a/flang-rt/include/flang-rt/utf.h b/flang-rt/include/flang-rt/utf.h
index 4d1e23b9ccb94..648937ca14f16 100644
--- a/flang-rt/include/flang-rt/utf.h
+++ b/flang-rt/include/flang-rt/utf.h
@@ -70,4 +70,4 @@ RT_API_ATTRS Fortran::common::optional<char32_t> DecodeUTF8(const char *);
RT_API_ATTRS std::size_t EncodeUTF8(char *, char32_t);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_UTF_H_ */
+#endif // FLANG_RT_UTF_H_
diff --git a/flang-rt/lib/FortranFloat128Math/complex-math.h b/flang-rt/lib/FortranFloat128Math/complex-math.h
index 24ccc794fd144..d22598d52e832 100644
--- a/flang-rt/lib/FortranFloat128Math/complex-math.h
+++ b/flang-rt/lib/FortranFloat128Math/complex-math.h
@@ -59,4 +59,4 @@
#error "Float128Math build with glibc>=2.26 is unsupported yet"
#endif
-#endif /* FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_ */
+#endif // FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
diff --git a/flang-rt/lib/FortranFloat128Math/math-entries.h b/flang-rt/lib/FortranFloat128Math/math-entries.h
index b9821163d94fb..72b12a1645c7d 100644
--- a/flang-rt/lib/FortranFloat128Math/math-entries.h
+++ b/flang-rt/lib/FortranFloat128Math/math-entries.h
@@ -232,4 +232,4 @@ DEFINE_SIMPLE_ALIAS(Yn, ynl)
} // namespace Fortran::runtime
-#endif /* FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_ */
+#endif // FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
diff --git a/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h b/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
index fc912f75075a7..e618902b03adc 100644
--- a/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
+++ b/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
@@ -52,4 +52,4 @@ template <> struct SQRTTy<F128Type> {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_ */
+#endif // FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
diff --git a/flang/runtime/CUDA/init.cpp b/flang-rt/lib/flang_rt/CUDA/init.cpp
similarity index 82%
rename from flang/runtime/CUDA/init.cpp
rename to flang-rt/lib/flang_rt/CUDA/init.cpp
index 2bffce842b952..f2d47d258519e 100644
--- a/flang/runtime/CUDA/init.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/init.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/init.cpp ---------------------------------------------===//
+//===-- lib/flang_rt/CUDA/init.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/init.h"
-#include "../environment.h"
-#include "../terminator.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/ISO_Fortran_util.h b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
index 6128faba5bcea..9d4a907e1adde 100644
--- a/flang-rt/lib/flang_rt/ISO_Fortran_util.h
+++ b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
@@ -99,4 +99,4 @@ static inline RT_API_ATTRS void EstablishDescriptor(CFI_cdesc_t *descriptor,
}
}
} // namespace Fortran::ISO
-#endif /* FLANG_RT_ISO_FORTRAN_UTIL_H_ */
+#endif // FLANG_RT_ISO_FORTRAN_UTIL_H_
diff --git a/flang-rt/lib/flang_rt/complex-reduction.h b/flang-rt/lib/flang_rt/complex-reduction.h
index 2678dbf4e6472..45614ea660573 100644
--- a/flang-rt/lib/flang_rt/complex-reduction.h
+++ b/flang-rt/lib/flang_rt/complex-reduction.h
@@ -155,4 +155,4 @@ void RTNAME(ReduceComplex16DimValue)(
REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));
#endif
-#endif /* FLANG_RT_COMPLEX_REDUCTION_H_ */
+#endif // FLANG_RT_COMPLEX_REDUCTION_H_
diff --git a/flang-rt/lib/flang_rt/copy.h b/flang-rt/lib/flang_rt/copy.h
index 468c2439baf61..f4abac323196b 100644
--- a/flang-rt/lib/flang_rt/copy.h
+++ b/flang-rt/lib/flang_rt/copy.h
@@ -22,4 +22,4 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
const Descriptor &from, const SubscriptValue fromAt[], Terminator &);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_COPY_H_ */
+#endif // FLANG_RT_COPY_H_
diff --git a/flang-rt/lib/flang_rt/descriptor-io.h b/flang-rt/lib/flang_rt/descriptor-io.h
index 763ebb1735752..97bedce247d83 100644
--- a/flang-rt/lib/flang_rt/descriptor-io.h
+++ b/flang-rt/lib/flang_rt/descriptor-io.h
@@ -626,4 +626,4 @@ static RT_API_ATTRS bool DescriptorIO(IoStatementState &io,
return false;
}
} // namespace Fortran::runtime::io::descr
-#endif /* FLANG_RT_DESCRIPTOR_IO_H_ */
+#endif // FLANG_RT_DESCRIPTOR_IO_H_
diff --git a/flang-rt/lib/flang_rt/edit-input.h b/flang-rt/lib/flang_rt/edit-input.h
index 2d6a3f241a005..fdee0f0e1131e 100644
--- a/flang-rt/lib/flang_rt/edit-input.h
+++ b/flang-rt/lib/flang_rt/edit-input.h
@@ -50,4 +50,4 @@ extern template RT_API_ATTRS bool EditCharacterInput(
IoStatementState &, const DataEdit &, char32_t *, std::size_t);
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_EDIT_INPUT_H_ */
+#endif // FLANG_RT_EDIT_INPUT_H_
diff --git a/flang-rt/lib/flang_rt/edit-output.h b/flang-rt/lib/flang_rt/edit-output.h
index 59f5d820c4ad5..729f4400bd631 100644
--- a/flang-rt/lib/flang_rt/edit-output.h
+++ b/flang-rt/lib/flang_rt/edit-output.h
@@ -138,4 +138,4 @@ extern template class RealOutputEditing<10>;
extern template class RealOutputEditing<16>;
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_EDIT_OUTPUT_H_ */
+#endif // FLANG_RT_EDIT_OUTPUT_H_
diff --git a/flang-rt/lib/flang_rt/io-api-common.h b/flang-rt/lib/flang_rt/io-api-common.h
index ba8c7177c2811..5e480fdef3483 100644
--- a/flang-rt/lib/flang_rt/io-api-common.h
+++ b/flang-rt/lib/flang_rt/io-api-common.h
@@ -94,4 +94,4 @@ RT_API_ATTRS Cookie BeginExternalListIO(
}
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_IO_API_COMMON_H_ */
+#endif // FLANG_RT_IO_API_COMMON_H_
diff --git a/flang-rt/lib/flang_rt/stack.h b/flang-rt/lib/flang_rt/stack.h
index 88cd276456fbc..6f37282f00932 100644
--- a/flang-rt/lib/flang_rt/stack.h
+++ b/flang-rt/lib/flang_rt/stack.h
@@ -133,4 +133,4 @@ template <typename T, unsigned N = 0> class Stack : public StackStorage<T, N> {
Terminator &terminator_;
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_STACK_H_ */
+#endif // FLANG_RT_STACK_H_
diff --git a/flang-rt/lib/flang_rt/unit-map.h b/flang-rt/lib/flang_rt/unit-map.h
index 6f7eb692b970a..64233008b6630 100644
--- a/flang-rt/lib/flang_rt/unit-map.h
+++ b/flang-rt/lib/flang_rt/unit-map.h
@@ -100,4 +100,4 @@ class UnitMap {
int emergencyNewUnit_{maxNewUnits_}; // not recycled
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_UNIT_MAP_H_ */
+#endif // FLANG_RT_UNIT_MAP_H_
diff --git a/flang-rt/lib/flang_rt/unit.h b/flang-rt/lib/flang_rt/unit.h
index 3b20c9870897a..a5fb7fb31691f 100644
--- a/flang-rt/lib/flang_rt/unit.h
+++ b/flang-rt/lib/flang_rt/unit.h
@@ -291,4 +291,4 @@ class ChildIo {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_UNIT_H_ */
+#endif // FLANG_RT_UNIT_H_
diff --git a/flang-rt/unittests/Runtime/tools.h b/flang-rt/unittests/Runtime/tools.h
index ff39d7ccb2a24..146aae659c338 100644
--- a/flang-rt/unittests/Runtime/tools.h
+++ b/flang-rt/unittests/Runtime/tools.h
@@ -54,4 +54,4 @@ static OwningPtr<Descriptor> MakeArray(const std::vector<int> &shape,
}
} // namespace Fortran::runtime
-#endif /* FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_ */
+#endif // FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_
>From 9fce9efff9b7bbd3f1bc095f24760c77ca238f33 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 30 Jan 2025 13:33:57 +0100
Subject: [PATCH 18/41] Post-merge fixes
---
flang-rt/include/flang-rt/CUDA/allocator.h | 2 +-
flang-rt/include/flang-rt/allocator-registry.h | 2 +-
flang-rt/include/flang-rt/array-constructor.h | 2 +-
flang-rt/include/flang-rt/assign-impl.h | 2 +-
flang-rt/include/flang-rt/buffer.h | 2 +-
flang-rt/include/flang-rt/connection.h | 2 +-
flang-rt/include/flang-rt/derived.h | 2 +-
flang-rt/include/flang-rt/descriptor.h | 2 +-
flang-rt/include/flang-rt/emit-encoded.h | 2 +-
flang-rt/include/flang-rt/environment.h | 2 +-
flang-rt/include/flang-rt/file.h | 2 +-
flang-rt/include/flang-rt/format-implementation.h | 2 +-
flang-rt/include/flang-rt/format.h | 2 +-
flang-rt/include/flang-rt/internal-unit.h | 2 +-
flang-rt/include/flang-rt/io-error.h | 2 +-
flang-rt/include/flang-rt/io-stmt.h | 2 +-
flang-rt/include/flang-rt/lock.h | 2 +-
flang-rt/include/flang-rt/memory.h | 2 +-
flang-rt/include/flang-rt/namelist.h | 2 +-
flang-rt/include/flang-rt/non-tbp-dio.h | 2 +-
flang-rt/include/flang-rt/numeric-templates.h | 2 +-
flang-rt/include/flang-rt/random-templates.h | 2 +-
flang-rt/include/flang-rt/reduction-templates.h | 2 +-
flang-rt/include/flang-rt/stat.h | 2 +-
flang-rt/include/flang-rt/terminator.h | 2 +-
flang-rt/include/flang-rt/tools.h | 2 +-
flang-rt/include/flang-rt/type-code.h | 2 +-
flang-rt/include/flang-rt/type-info.h | 2 +-
flang-rt/include/flang-rt/utf.h | 2 +-
flang-rt/lib/FortranFloat128Math/complex-math.h | 2 +-
flang-rt/lib/FortranFloat128Math/math-entries.h | 2 +-
flang-rt/lib/FortranFloat128Math/numeric-template-specs.h | 2 +-
{flang/runtime => flang-rt/lib/flang_rt}/CUDA/init.cpp | 6 +++---
flang-rt/lib/flang_rt/ISO_Fortran_util.h | 2 +-
flang-rt/lib/flang_rt/complex-reduction.h | 2 +-
flang-rt/lib/flang_rt/copy.h | 2 +-
flang-rt/lib/flang_rt/descriptor-io.h | 2 +-
flang-rt/lib/flang_rt/edit-input.h | 2 +-
flang-rt/lib/flang_rt/edit-output.h | 2 +-
flang-rt/lib/flang_rt/io-api-common.h | 2 +-
flang-rt/lib/flang_rt/stack.h | 2 +-
flang-rt/lib/flang_rt/unit-map.h | 2 +-
flang-rt/lib/flang_rt/unit.h | 2 +-
flang-rt/unittests/Runtime/tools.h | 2 +-
44 files changed, 46 insertions(+), 46 deletions(-)
rename {flang/runtime => flang-rt/lib/flang_rt}/CUDA/init.cpp (82%)
diff --git a/flang-rt/include/flang-rt/CUDA/allocator.h b/flang-rt/include/flang-rt/CUDA/allocator.h
index fb09b5ff2402a..68bb0736dd5ee 100644
--- a/flang-rt/include/flang-rt/CUDA/allocator.h
+++ b/flang-rt/include/flang-rt/CUDA/allocator.h
@@ -33,4 +33,4 @@ void *CUFAllocUnified(std::size_t);
void CUFFreeUnified(void *);
} // namespace Fortran::runtime::cuda
-#endif /* FLANG_RT_CUDA_ALLOCATOR_H_ */
+#endif // FLANG_RT_CUDA_ALLOCATOR_H_
diff --git a/flang-rt/include/flang-rt/allocator-registry.h b/flang-rt/include/flang-rt/allocator-registry.h
index 1f004462ca624..ea905afc045ce 100644
--- a/flang-rt/include/flang-rt/allocator-registry.h
+++ b/flang-rt/include/flang-rt/allocator-registry.h
@@ -55,4 +55,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif /* FLANG_RT_ALLOCATOR_REGISTRY_H_ */
+#endif // FLANG_RT_ALLOCATOR_REGISTRY_H_
diff --git a/flang-rt/include/flang-rt/array-constructor.h b/flang-rt/include/flang-rt/array-constructor.h
index 7ff0779e46c6a..738050f80ef65 100644
--- a/flang-rt/include/flang-rt/array-constructor.h
+++ b/flang-rt/include/flang-rt/array-constructor.h
@@ -54,4 +54,4 @@ static_assert(alignof(Fortran::runtime::ArrayConstructorVector) <=
"MaxArrayConstructorVectorAlignInBytes");
} // namespace Fortran::runtime
-#endif /* FLANG_RT_ARRAY_CONSTRUCTOR_H_ */
+#endif // FLANG_RT_ARRAY_CONSTRUCTOR_H_
diff --git a/flang-rt/include/flang-rt/assign-impl.h b/flang-rt/include/flang-rt/assign-impl.h
index 7e2cef9df753b..2e85a451d5b52 100644
--- a/flang-rt/include/flang-rt/assign-impl.h
+++ b/flang-rt/include/flang-rt/assign-impl.h
@@ -28,4 +28,4 @@ RT_API_ATTRS void DoFromSourceAssign(Descriptor &, const Descriptor &,
#endif
} // namespace Fortran::runtime
-#endif /* FLANG_RT_ASSIGN_IMPL_H_ */
+#endif // FLANG_RT_ASSIGN_IMPL_H_
diff --git a/flang-rt/include/flang-rt/buffer.h b/flang-rt/include/flang-rt/buffer.h
index ba172448a93a5..bd2e8c47c6e30 100644
--- a/flang-rt/include/flang-rt/buffer.h
+++ b/flang-rt/include/flang-rt/buffer.h
@@ -221,4 +221,4 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
bool dirty_{false};
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_BUFFER_H_ */
+#endif // FLANG_RT_BUFFER_H_
diff --git a/flang-rt/include/flang-rt/connection.h b/flang-rt/include/flang-rt/connection.h
index 7f594deee69c6..550ddb15c7236 100644
--- a/flang-rt/include/flang-rt/connection.h
+++ b/flang-rt/include/flang-rt/connection.h
@@ -124,4 +124,4 @@ class SavedPosition {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_CONNECTION_H_ */
+#endif // FLANG_RT_CONNECTION_H_
diff --git a/flang-rt/include/flang-rt/derived.h b/flang-rt/include/flang-rt/derived.h
index 797a089e767c4..d65fb75172495 100644
--- a/flang-rt/include/flang-rt/derived.h
+++ b/flang-rt/include/flang-rt/derived.h
@@ -48,4 +48,4 @@ RT_API_ATTRS void Destroy(const Descriptor &, bool finalize,
RT_API_ATTRS bool HasDynamicComponent(const Descriptor &);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_DERIVED_H_ */
+#endif // FLANG_RT_DERIVED_H_
diff --git a/flang-rt/include/flang-rt/descriptor.h b/flang-rt/include/flang-rt/descriptor.h
index 27f80bec4ba93..f97b8443425dc 100644
--- a/flang-rt/include/flang-rt/descriptor.h
+++ b/flang-rt/include/flang-rt/descriptor.h
@@ -482,4 +482,4 @@ class alignas(Descriptor) StaticDescriptor {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_DESCRIPTOR_H_ */
+#endif // FLANG_RT_DESCRIPTOR_H_
diff --git a/flang-rt/include/flang-rt/emit-encoded.h b/flang-rt/include/flang-rt/emit-encoded.h
index f3cb7a9f790e4..279f751daff2c 100644
--- a/flang-rt/include/flang-rt/emit-encoded.h
+++ b/flang-rt/include/flang-rt/emit-encoded.h
@@ -114,4 +114,4 @@ RT_API_ATTRS bool EmitRepeated(CONTEXT &to, char ch, std::size_t n) {
}
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_EMIT_ENCODED_H_ */
+#endif // FLANG_RT_EMIT_ENCODED_H_
diff --git a/flang-rt/include/flang-rt/environment.h b/flang-rt/include/flang-rt/environment.h
index b7597ad88af62..7fa3060768502 100644
--- a/flang-rt/include/flang-rt/environment.h
+++ b/flang-rt/include/flang-rt/environment.h
@@ -67,4 +67,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif /* FLANG_RT_ENVIRONMENT_H_ */
+#endif // FLANG_RT_ENVIRONMENT_H_
diff --git a/flang-rt/include/flang-rt/file.h b/flang-rt/include/flang-rt/file.h
index ca95156e1fba4..3ab21c655a38f 100644
--- a/flang-rt/include/flang-rt/file.h
+++ b/flang-rt/include/flang-rt/file.h
@@ -113,4 +113,4 @@ RT_API_ATTRS bool MayWrite(const char *path);
RT_API_ATTRS bool MayReadAndWrite(const char *path);
RT_API_ATTRS std::int64_t SizeInBytes(const char *path);
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_FILE_H_ */
+#endif // FLANG_RT_FILE_H_
diff --git a/flang-rt/include/flang-rt/format-implementation.h b/flang-rt/include/flang-rt/format-implementation.h
index 52f265d06f9bf..6a2e1078ab350 100644
--- a/flang-rt/include/flang-rt/format-implementation.h
+++ b/flang-rt/include/flang-rt/format-implementation.h
@@ -601,4 +601,4 @@ RT_API_ATTRS void FormatControl<CONTEXT>::Finish(Context &context) {
}
}
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_FORMAT_IMPLEMENTATION_H_ */
+#endif // FLANG_RT_FORMAT_IMPLEMENTATION_H_
diff --git a/flang-rt/include/flang-rt/format.h b/flang-rt/include/flang-rt/format.h
index d81241e41877c..09e151a2e98ca 100644
--- a/flang-rt/include/flang-rt/format.h
+++ b/flang-rt/include/flang-rt/format.h
@@ -201,4 +201,4 @@ template <typename CONTEXT> class FormatControl {
Iteration stack_[maxMaxHeight];
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_FORMAT_H_ */
+#endif // FLANG_RT_FORMAT_H_
diff --git a/flang-rt/include/flang-rt/internal-unit.h b/flang-rt/include/flang-rt/internal-unit.h
index 21e64b5624196..946d69080e611 100644
--- a/flang-rt/include/flang-rt/internal-unit.h
+++ b/flang-rt/include/flang-rt/internal-unit.h
@@ -56,4 +56,4 @@ template <Direction DIR> class InternalDescriptorUnit : public ConnectionState {
extern template class InternalDescriptorUnit<Direction::Output>;
extern template class InternalDescriptorUnit<Direction::Input>;
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_INTERNAL_UNIT_H_ */
+#endif // FLANG_RT_INTERNAL_UNIT_H_
diff --git a/flang-rt/include/flang-rt/io-error.h b/flang-rt/include/flang-rt/io-error.h
index c74c08970f94a..6b5c0f9f39019 100644
--- a/flang-rt/include/flang-rt/io-error.h
+++ b/flang-rt/include/flang-rt/io-error.h
@@ -80,4 +80,4 @@ class IoErrorHandler : public Terminator {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_IO_ERROR_H_ */
+#endif // FLANG_RT_IO_ERROR_H_
diff --git a/flang-rt/include/flang-rt/io-stmt.h b/flang-rt/include/flang-rt/io-stmt.h
index 87fd93c353d76..7efab320e5e1a 100644
--- a/flang-rt/include/flang-rt/io-stmt.h
+++ b/flang-rt/include/flang-rt/io-stmt.h
@@ -791,4 +791,4 @@ class ErroneousIoStatementState : public IoStatementBase {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_IO_STMT_H_ */
+#endif // FLANG_RT_IO_STMT_H_
diff --git a/flang-rt/include/flang-rt/lock.h b/flang-rt/include/flang-rt/lock.h
index f57e97184edd5..1b09434d26f4f 100644
--- a/flang-rt/include/flang-rt/lock.h
+++ b/flang-rt/include/flang-rt/lock.h
@@ -113,4 +113,4 @@ class CriticalSection {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_LOCK_H_ */
+#endif // FLANG_RT_LOCK_H_
diff --git a/flang-rt/include/flang-rt/memory.h b/flang-rt/include/flang-rt/memory.h
index afbb1b34c1d2c..64db30baf2806 100644
--- a/flang-rt/include/flang-rt/memory.h
+++ b/flang-rt/include/flang-rt/memory.h
@@ -170,4 +170,4 @@ template <typename A> struct Allocator {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_MEMORY_H_ */
+#endif // FLANG_RT_MEMORY_H_
diff --git a/flang-rt/include/flang-rt/namelist.h b/flang-rt/include/flang-rt/namelist.h
index 5757bfb3b7109..2ae93ca9c2050 100644
--- a/flang-rt/include/flang-rt/namelist.h
+++ b/flang-rt/include/flang-rt/namelist.h
@@ -51,4 +51,4 @@ class NamelistGroup {
RT_API_ATTRS bool IsNamelistNameOrSlash(IoStatementState &);
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_NAMELIST_H_ */
+#endif // FLANG_RT_NAMELIST_H_
diff --git a/flang-rt/include/flang-rt/non-tbp-dio.h b/flang-rt/include/flang-rt/non-tbp-dio.h
index 58ed29ba7a102..1088257b72f59 100644
--- a/flang-rt/include/flang-rt/non-tbp-dio.h
+++ b/flang-rt/include/flang-rt/non-tbp-dio.h
@@ -53,4 +53,4 @@ struct NonTbpDefinedIoTable {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_NON_TBP_DIO_H_ */
+#endif // FLANG_RT_NON_TBP_DIO_H_
diff --git a/flang-rt/include/flang-rt/numeric-templates.h b/flang-rt/include/flang-rt/numeric-templates.h
index 7019151c3a207..a1475923ff3b1 100644
--- a/flang-rt/include/flang-rt/numeric-templates.h
+++ b/flang-rt/include/flang-rt/numeric-templates.h
@@ -368,4 +368,4 @@ template <typename T> inline RT_API_ATTRS T ErfcScaled(T arg) {
} // namespace Fortran::runtime
-#endif /* FLANG_RT_NUMERIC_TEMPLATES_H_ */
+#endif // FLANG_RT_NUMERIC_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/random-templates.h b/flang-rt/include/flang-rt/random-templates.h
index f320f2cd328f5..00542bd5b2553 100644
--- a/flang-rt/include/flang-rt/random-templates.h
+++ b/flang-rt/include/flang-rt/random-templates.h
@@ -108,4 +108,4 @@ inline void GenerateUnsigned(const Descriptor &harvest) {
} // namespace Fortran::runtime::random
-#endif /* FLANG_RT_RANDOM_TEMPLATES_H_ */
+#endif // FLANG_RT_RANDOM_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/reduction-templates.h b/flang-rt/include/flang-rt/reduction-templates.h
index 513b3e4478498..d6b3c24920cf9 100644
--- a/flang-rt/include/flang-rt/reduction-templates.h
+++ b/flang-rt/include/flang-rt/reduction-templates.h
@@ -416,4 +416,4 @@ template <int KIND> struct Norm2Helper {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_REDUCTION_TEMPLATES_H_ */
+#endif // FLANG_RT_REDUCTION_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/stat.h b/flang-rt/include/flang-rt/stat.h
index 95ae286a03b49..a6824f4803561 100644
--- a/flang-rt/include/flang-rt/stat.h
+++ b/flang-rt/include/flang-rt/stat.h
@@ -60,4 +60,4 @@ RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat); // returns stat
RT_API_ATTRS int ReturnError(Terminator &, int stat,
const Descriptor *errmsg = nullptr, bool hasStat = false);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_STAT_H_ */
+#endif // FLANG_RT_STAT_H_
diff --git a/flang-rt/include/flang-rt/terminator.h b/flang-rt/include/flang-rt/terminator.h
index 800ed6f3755b7..c2a4e1f64eb66 100644
--- a/flang-rt/include/flang-rt/terminator.h
+++ b/flang-rt/include/flang-rt/terminator.h
@@ -121,4 +121,4 @@ namespace Fortran::runtime::io {
RT_API_ATTRS void FlushOutputOnCrash(const Terminator &);
}
-#endif /* FLANG_RT_TERMINATOR_H_ */
+#endif // FLANG_RT_TERMINATOR_H_
diff --git a/flang-rt/include/flang-rt/tools.h b/flang-rt/include/flang-rt/tools.h
index 38804a1f40991..3503c49308e4d 100644
--- a/flang-rt/include/flang-rt/tools.h
+++ b/flang-rt/include/flang-rt/tools.h
@@ -570,4 +570,4 @@ RT_API_ATTRS void CreatePartialReductionResult(Descriptor &result,
const char *intrinsic, TypeCode);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_TOOLS_H_ */
+#endif // FLANG_RT_TOOLS_H_
diff --git a/flang-rt/include/flang-rt/type-code.h b/flang-rt/include/flang-rt/type-code.h
index 1d057481261a1..a3b79462887c1 100644
--- a/flang-rt/include/flang-rt/type-code.h
+++ b/flang-rt/include/flang-rt/type-code.h
@@ -75,4 +75,4 @@ class TypeCode {
ISO::CFI_type_t raw_{CFI_type_other};
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_TYPE_CODE_H_ */
+#endif // FLANG_RT_TYPE_CODE_H_
diff --git a/flang-rt/include/flang-rt/type-info.h b/flang-rt/include/flang-rt/type-info.h
index 52e208c93fe25..dc5cd98d7523f 100644
--- a/flang-rt/include/flang-rt/type-info.h
+++ b/flang-rt/include/flang-rt/type-info.h
@@ -321,4 +321,4 @@ class DerivedType {
};
} // namespace Fortran::runtime::typeInfo
-#endif /* FLANG_RT_TYPE_INFO_H_ */
+#endif // FLANG_RT_TYPE_INFO_H_
diff --git a/flang-rt/include/flang-rt/utf.h b/flang-rt/include/flang-rt/utf.h
index 4d1e23b9ccb94..648937ca14f16 100644
--- a/flang-rt/include/flang-rt/utf.h
+++ b/flang-rt/include/flang-rt/utf.h
@@ -70,4 +70,4 @@ RT_API_ATTRS Fortran::common::optional<char32_t> DecodeUTF8(const char *);
RT_API_ATTRS std::size_t EncodeUTF8(char *, char32_t);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_UTF_H_ */
+#endif // FLANG_RT_UTF_H_
diff --git a/flang-rt/lib/FortranFloat128Math/complex-math.h b/flang-rt/lib/FortranFloat128Math/complex-math.h
index 24ccc794fd144..d22598d52e832 100644
--- a/flang-rt/lib/FortranFloat128Math/complex-math.h
+++ b/flang-rt/lib/FortranFloat128Math/complex-math.h
@@ -59,4 +59,4 @@
#error "Float128Math build with glibc>=2.26 is unsupported yet"
#endif
-#endif /* FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_ */
+#endif // FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
diff --git a/flang-rt/lib/FortranFloat128Math/math-entries.h b/flang-rt/lib/FortranFloat128Math/math-entries.h
index b9821163d94fb..72b12a1645c7d 100644
--- a/flang-rt/lib/FortranFloat128Math/math-entries.h
+++ b/flang-rt/lib/FortranFloat128Math/math-entries.h
@@ -232,4 +232,4 @@ DEFINE_SIMPLE_ALIAS(Yn, ynl)
} // namespace Fortran::runtime
-#endif /* FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_ */
+#endif // FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
diff --git a/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h b/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
index fc912f75075a7..e618902b03adc 100644
--- a/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
+++ b/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
@@ -52,4 +52,4 @@ template <> struct SQRTTy<F128Type> {
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_ */
+#endif // FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
diff --git a/flang/runtime/CUDA/init.cpp b/flang-rt/lib/flang_rt/CUDA/init.cpp
similarity index 82%
rename from flang/runtime/CUDA/init.cpp
rename to flang-rt/lib/flang_rt/CUDA/init.cpp
index 2bffce842b952..f2d47d258519e 100644
--- a/flang/runtime/CUDA/init.cpp
+++ b/flang-rt/lib/flang_rt/CUDA/init.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/init.cpp ---------------------------------------------===//
+//===-- lib/flang_rt/CUDA/init.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/init.h"
-#include "../environment.h"
-#include "../terminator.h"
+#include "flang-rt/environment.h"
+#include "flang-rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/ISO_Fortran_util.h b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
index 6128faba5bcea..9d4a907e1adde 100644
--- a/flang-rt/lib/flang_rt/ISO_Fortran_util.h
+++ b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
@@ -99,4 +99,4 @@ static inline RT_API_ATTRS void EstablishDescriptor(CFI_cdesc_t *descriptor,
}
}
} // namespace Fortran::ISO
-#endif /* FLANG_RT_ISO_FORTRAN_UTIL_H_ */
+#endif // FLANG_RT_ISO_FORTRAN_UTIL_H_
diff --git a/flang-rt/lib/flang_rt/complex-reduction.h b/flang-rt/lib/flang_rt/complex-reduction.h
index 2678dbf4e6472..45614ea660573 100644
--- a/flang-rt/lib/flang_rt/complex-reduction.h
+++ b/flang-rt/lib/flang_rt/complex-reduction.h
@@ -155,4 +155,4 @@ void RTNAME(ReduceComplex16DimValue)(
REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));
#endif
-#endif /* FLANG_RT_COMPLEX_REDUCTION_H_ */
+#endif // FLANG_RT_COMPLEX_REDUCTION_H_
diff --git a/flang-rt/lib/flang_rt/copy.h b/flang-rt/lib/flang_rt/copy.h
index 468c2439baf61..f4abac323196b 100644
--- a/flang-rt/lib/flang_rt/copy.h
+++ b/flang-rt/lib/flang_rt/copy.h
@@ -22,4 +22,4 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
const Descriptor &from, const SubscriptValue fromAt[], Terminator &);
} // namespace Fortran::runtime
-#endif /* FLANG_RT_COPY_H_ */
+#endif // FLANG_RT_COPY_H_
diff --git a/flang-rt/lib/flang_rt/descriptor-io.h b/flang-rt/lib/flang_rt/descriptor-io.h
index 763ebb1735752..97bedce247d83 100644
--- a/flang-rt/lib/flang_rt/descriptor-io.h
+++ b/flang-rt/lib/flang_rt/descriptor-io.h
@@ -626,4 +626,4 @@ static RT_API_ATTRS bool DescriptorIO(IoStatementState &io,
return false;
}
} // namespace Fortran::runtime::io::descr
-#endif /* FLANG_RT_DESCRIPTOR_IO_H_ */
+#endif // FLANG_RT_DESCRIPTOR_IO_H_
diff --git a/flang-rt/lib/flang_rt/edit-input.h b/flang-rt/lib/flang_rt/edit-input.h
index 2d6a3f241a005..fdee0f0e1131e 100644
--- a/flang-rt/lib/flang_rt/edit-input.h
+++ b/flang-rt/lib/flang_rt/edit-input.h
@@ -50,4 +50,4 @@ extern template RT_API_ATTRS bool EditCharacterInput(
IoStatementState &, const DataEdit &, char32_t *, std::size_t);
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_EDIT_INPUT_H_ */
+#endif // FLANG_RT_EDIT_INPUT_H_
diff --git a/flang-rt/lib/flang_rt/edit-output.h b/flang-rt/lib/flang_rt/edit-output.h
index 59f5d820c4ad5..729f4400bd631 100644
--- a/flang-rt/lib/flang_rt/edit-output.h
+++ b/flang-rt/lib/flang_rt/edit-output.h
@@ -138,4 +138,4 @@ extern template class RealOutputEditing<10>;
extern template class RealOutputEditing<16>;
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_EDIT_OUTPUT_H_ */
+#endif // FLANG_RT_EDIT_OUTPUT_H_
diff --git a/flang-rt/lib/flang_rt/io-api-common.h b/flang-rt/lib/flang_rt/io-api-common.h
index ba8c7177c2811..5e480fdef3483 100644
--- a/flang-rt/lib/flang_rt/io-api-common.h
+++ b/flang-rt/lib/flang_rt/io-api-common.h
@@ -94,4 +94,4 @@ RT_API_ATTRS Cookie BeginExternalListIO(
}
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_IO_API_COMMON_H_ */
+#endif // FLANG_RT_IO_API_COMMON_H_
diff --git a/flang-rt/lib/flang_rt/stack.h b/flang-rt/lib/flang_rt/stack.h
index 88cd276456fbc..6f37282f00932 100644
--- a/flang-rt/lib/flang_rt/stack.h
+++ b/flang-rt/lib/flang_rt/stack.h
@@ -133,4 +133,4 @@ template <typename T, unsigned N = 0> class Stack : public StackStorage<T, N> {
Terminator &terminator_;
};
} // namespace Fortran::runtime
-#endif /* FLANG_RT_STACK_H_ */
+#endif // FLANG_RT_STACK_H_
diff --git a/flang-rt/lib/flang_rt/unit-map.h b/flang-rt/lib/flang_rt/unit-map.h
index 6f7eb692b970a..64233008b6630 100644
--- a/flang-rt/lib/flang_rt/unit-map.h
+++ b/flang-rt/lib/flang_rt/unit-map.h
@@ -100,4 +100,4 @@ class UnitMap {
int emergencyNewUnit_{maxNewUnits_}; // not recycled
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_UNIT_MAP_H_ */
+#endif // FLANG_RT_UNIT_MAP_H_
diff --git a/flang-rt/lib/flang_rt/unit.h b/flang-rt/lib/flang_rt/unit.h
index 3b20c9870897a..a5fb7fb31691f 100644
--- a/flang-rt/lib/flang_rt/unit.h
+++ b/flang-rt/lib/flang_rt/unit.h
@@ -291,4 +291,4 @@ class ChildIo {
};
} // namespace Fortran::runtime::io
-#endif /* FLANG_RT_UNIT_H_ */
+#endif // FLANG_RT_UNIT_H_
diff --git a/flang-rt/unittests/Runtime/tools.h b/flang-rt/unittests/Runtime/tools.h
index ff39d7ccb2a24..146aae659c338 100644
--- a/flang-rt/unittests/Runtime/tools.h
+++ b/flang-rt/unittests/Runtime/tools.h
@@ -54,4 +54,4 @@ static OwningPtr<Descriptor> MakeArray(const std::vector<int> &shape,
}
} // namespace Fortran::runtime
-#endif /* FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_ */
+#endif // FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_
>From c86aa904b55e4ff7de53691a6137233ef44bb934 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 3 Feb 2025 12:33:07 +0100
Subject: [PATCH 19/41] Rename to flang_rt.runtime, flang_rt.quadmath,
flang_rt.cuda
---
clang/lib/Driver/ToolChains/CommonArgs.cpp | 4 +-
clang/lib/Driver/ToolChains/Flang.cpp | 8 ++--
flang-rt/CMakeLists.txt | 8 +++-
flang-rt/README.md | 4 +-
flang-rt/examples/CMakeLists.txt | 9 ++++
.../ExternalHelloWorld/CMakeLists.txt | 17 ++++++++
.../ExternalHelloWorld/external-hello.cpp | 8 ++++
flang-rt/include/flang-rt/CUDA/allocator.h | 2 +-
.../{ => runtime}/allocator-registry.h | 8 ++--
.../{ => runtime}/array-constructor.h | 8 ++--
.../flang-rt/{ => runtime}/assign-impl.h | 8 ++--
.../include/flang-rt/{ => runtime}/buffer.h | 8 ++--
.../flang-rt/{ => runtime}/connection.h | 8 ++--
.../include/flang-rt/{ => runtime}/derived.h | 8 ++--
.../flang-rt/{ => runtime}/descriptor.h | 8 ++--
.../flang-rt/{ => runtime}/emit-encoded.h | 8 ++--
.../flang-rt/{ => runtime}/environment.h | 8 ++--
.../include/flang-rt/{ => runtime}/file.h | 8 ++--
.../{ => runtime}/format-implementation.h | 8 ++--
.../include/flang-rt/{ => runtime}/format.h | 8 ++--
.../flang-rt/{ => runtime}/internal-unit.h | 8 ++--
.../include/flang-rt/{ => runtime}/io-error.h | 8 ++--
.../include/flang-rt/{ => runtime}/io-stmt.h | 8 ++--
.../include/flang-rt/{ => runtime}/lock.h | 8 ++--
.../include/flang-rt/{ => runtime}/memory.h | 8 ++--
.../include/flang-rt/{ => runtime}/namelist.h | 8 ++--
.../flang-rt/{ => runtime}/non-tbp-dio.h | 8 ++--
.../{ => runtime}/numeric-templates.h | 8 ++--
.../flang-rt/{ => runtime}/random-templates.h | 8 ++--
.../{ => runtime}/reduction-templates.h | 8 ++--
.../include/flang-rt/{ => runtime}/stat.h | 8 ++--
.../flang-rt/{ => runtime}/terminator.h | 8 ++--
.../include/flang-rt/{ => runtime}/tools.h | 8 ++--
.../flang-rt/{ => runtime}/type-code.h | 8 ++--
.../flang-rt/{ => runtime}/type-info.h | 8 ++--
flang-rt/include/flang-rt/{ => runtime}/utf.h | 8 ++--
flang-rt/lib/CMakeLists.txt | 9 ++--
.../{flang_rt/CUDA => cuda}/CMakeLists.txt | 12 +++---
.../{flang_rt/CUDA => cuda}/allocatable.cpp | 10 ++---
.../lib/{flang_rt/CUDA => cuda}/allocator.cpp | 14 +++----
.../{flang_rt/CUDA => cuda}/descriptor.cpp | 8 ++--
flang-rt/lib/{flang_rt/CUDA => cuda}/init.cpp | 6 +--
.../lib/{flang_rt/CUDA => cuda}/kernel.cpp | 4 +-
.../CUDA => cuda}/memmove-function.cpp | 4 +-
.../lib/{flang_rt/CUDA => cuda}/memory.cpp | 6 +--
.../lib/{flang_rt/CUDA => cuda}/pointer.cpp | 10 ++---
.../{flang_rt/CUDA => cuda}/registration.cpp | 4 +-
.../CMakeLists.txt | 8 ++--
.../acos.cpp | 2 +-
.../acosh.cpp | 2 +-
.../asin.cpp | 2 +-
.../asinh.cpp | 2 +-
.../atan.cpp | 2 +-
.../atan2.cpp | 2 +-
.../atanh.cpp | 2 +-
.../ceil.cpp | 2 +-
.../complex-math.c | 0
.../complex-math.h | 8 ++--
.../{FortranFloat128Math => quadmath}/cos.cpp | 2 +-
.../cosh.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/erf.cpp | 2 +-
.../erfc.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/exp.cpp | 2 +-
.../exponent.cpp | 2 +-
.../floor.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/fma.cpp | 2 +-
.../fraction.cpp | 2 +-
.../hypot.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/j0.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/j1.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/jn.cpp | 2 +-
.../lgamma.cpp | 2 +-
.../llround.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/log.cpp | 2 +-
.../log10.cpp | 2 +-
.../lround.cpp | 2 +-
.../math-entries.h | 12 +++---
.../mod-real.cpp | 2 +-
.../modulo-real.cpp | 2 +-
.../nearbyint.cpp | 2 +-
.../nearest.cpp | 2 +-
.../norm2.cpp | 4 +-
.../numeric-template-specs.h | 10 ++---
.../{FortranFloat128Math => quadmath}/pow.cpp | 2 +-
.../random.cpp | 4 +-
.../remainder.cpp | 2 +-
.../round.cpp | 2 +-
.../rrspacing.cpp | 2 +-
.../scale.cpp | 2 +-
.../set-exponent.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/sin.cpp | 2 +-
.../sinh.cpp | 2 +-
.../spacing.cpp | 2 +-
.../sqrt.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/tan.cpp | 2 +-
.../tanh.cpp | 2 +-
.../tgamma.cpp | 2 +-
.../trunc.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/y0.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/y1.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/yn.cpp | 2 +-
.../lib/{flang_rt => runtime}/CMakeLists.txt | 34 +++++++--------
.../ISO_Fortran_binding.cpp | 8 ++--
.../{flang_rt => runtime}/ISO_Fortran_util.h | 14 +++----
.../lib/{flang_rt => runtime}/allocatable.cpp | 14 +++----
.../allocator-registry.cpp | 6 +--
.../array-constructor.cpp | 14 +++----
flang-rt/lib/{flang_rt => runtime}/assign.cpp | 16 ++++----
flang-rt/lib/{flang_rt => runtime}/buffer.cpp | 4 +-
.../lib/{flang_rt => runtime}/character.cpp | 8 ++--
.../lib/{flang_rt => runtime}/command.cpp | 12 +++---
.../{flang_rt => runtime}/complex-powi.cpp | 2 +-
.../{flang_rt => runtime}/complex-reduction.c | 0
.../{flang_rt => runtime}/complex-reduction.h | 8 ++--
.../lib/{flang_rt => runtime}/connection.cpp | 8 ++--
flang-rt/lib/{flang_rt => runtime}/copy.cpp | 8 ++--
flang-rt/lib/{flang_rt => runtime}/copy.h | 10 ++---
.../lib/{flang_rt => runtime}/derived-api.cpp | 12 +++---
.../lib/{flang_rt => runtime}/derived.cpp | 14 +++----
.../{flang_rt => runtime}/descriptor-io.cpp | 2 +-
.../lib/{flang_rt => runtime}/descriptor-io.h | 18 ++++----
.../lib/{flang_rt => runtime}/descriptor.cpp | 16 ++++----
.../lib/{flang_rt => runtime}/dot-product.cpp | 8 ++--
.../lib/{flang_rt => runtime}/edit-input.cpp | 6 +--
.../lib/{flang_rt => runtime}/edit-input.h | 12 +++---
.../lib/{flang_rt => runtime}/edit-output.cpp | 6 +--
.../lib/{flang_rt => runtime}/edit-output.h | 12 +++---
.../environment-default-list.h | 0
.../lib/{flang_rt => runtime}/environment.cpp | 6 +--
.../lib/{flang_rt => runtime}/exceptions.cpp | 4 +-
.../lib/{flang_rt => runtime}/execute.cpp | 12 +++---
.../lib/{flang_rt => runtime}/extensions.cpp | 8 ++--
.../{flang_rt => runtime}/external-unit.cpp | 8 ++--
.../lib/{flang_rt => runtime}/extrema.cpp | 4 +-
flang-rt/lib/{flang_rt => runtime}/file.cpp | 8 ++--
.../lib/{flang_rt => runtime}/findloc.cpp | 4 +-
flang-rt/lib/{flang_rt => runtime}/format.cpp | 4 +-
.../lib/{flang_rt => runtime}/inquiry.cpp | 8 ++--
.../{flang_rt => runtime}/internal-unit.cpp | 8 ++--
.../lib/{flang_rt => runtime}/io-api-common.h | 12 +++---
.../{flang_rt => runtime}/io-api-minimal.cpp | 10 ++---
flang-rt/lib/{flang_rt => runtime}/io-api.cpp | 16 ++++----
.../lib/{flang_rt => runtime}/io-error.cpp | 6 +--
.../lib/{flang_rt => runtime}/io-stmt.cpp | 16 ++++----
flang-rt/lib/{flang_rt => runtime}/iostat.cpp | 2 +-
flang-rt/lib/{flang_rt => runtime}/main.cpp | 6 +--
.../matmul-transpose.cpp | 8 ++--
flang-rt/lib/{flang_rt => runtime}/matmul.cpp | 8 ++--
flang-rt/lib/{flang_rt => runtime}/memory.cpp | 8 ++--
.../{flang_rt => runtime}/misc-intrinsic.cpp | 8 ++--
.../lib/{flang_rt => runtime}/namelist.cpp | 8 ++--
.../lib/{flang_rt => runtime}/non-tbp-dio.cpp | 6 +--
.../lib/{flang_rt => runtime}/numeric.cpp | 8 ++--
.../lib/{flang_rt => runtime}/pointer.cpp | 16 ++++----
.../lib/{flang_rt => runtime}/product.cpp | 4 +-
.../lib/{flang_rt => runtime}/pseudo-unit.cpp | 6 +--
flang-rt/lib/{flang_rt => runtime}/ragged.cpp | 4 +-
flang-rt/lib/{flang_rt => runtime}/random.cpp | 10 ++---
flang-rt/lib/{flang_rt => runtime}/reduce.cpp | 10 ++---
.../lib/{flang_rt => runtime}/reduction.cpp | 6 +--
flang-rt/lib/{flang_rt => runtime}/stack.h | 12 +++---
flang-rt/lib/{flang_rt => runtime}/stat.cpp | 10 ++---
flang-rt/lib/{flang_rt => runtime}/stop.cpp | 10 ++---
flang-rt/lib/{flang_rt => runtime}/sum.cpp | 4 +-
.../lib/{flang_rt => runtime}/support.cpp | 6 +--
.../{flang_rt => runtime}/temporary-stack.cpp | 8 ++--
.../lib/{flang_rt => runtime}/terminator.cpp | 4 +-
.../{flang_rt => runtime}/time-intrinsic.cpp | 8 ++--
flang-rt/lib/{flang_rt => runtime}/tools.cpp | 6 +--
.../transformational.cpp | 8 ++--
.../lib/{flang_rt => runtime}/type-code.cpp | 4 +-
.../lib/{flang_rt => runtime}/type-info.cpp | 8 ++--
.../lib/{flang_rt => runtime}/unit-map.cpp | 2 +-
flang-rt/lib/{flang_rt => runtime}/unit-map.h | 12 +++---
flang-rt/lib/{flang_rt => runtime}/unit.cpp | 8 ++--
flang-rt/lib/{flang_rt => runtime}/unit.h | 30 +++++++-------
flang-rt/lib/{flang_rt => runtime}/utf.cpp | 4 +-
flang-rt/test/CMakeLists.txt | 4 +-
flang-rt/test/lit.cfg.py | 2 +-
.../Evaluate/ISO-Fortran-binding.cpp | 2 +-
flang-rt/unittests/Evaluate/reshape.cpp | 2 +-
flang-rt/unittests/Runtime/Allocatable.cpp | 2 +-
.../unittests/Runtime/ArrayConstructor.cpp | 6 +--
flang-rt/unittests/Runtime/BufferTest.cpp | 2 +-
flang-rt/unittests/Runtime/CMakeLists.txt | 2 +-
.../unittests/Runtime/CUDA/Allocatable.cpp | 8 ++--
.../unittests/Runtime/CUDA/AllocatorCUF.cpp | 8 ++--
.../unittests/Runtime/CUDA/CMakeLists.txt | 2 +-
flang-rt/unittests/Runtime/CUDA/Memory.cpp | 6 +--
flang-rt/unittests/Runtime/CharacterTest.cpp | 2 +-
flang-rt/unittests/Runtime/CommandTest.cpp | 2 +-
.../unittests/Runtime/CrashHandlerFixture.cpp | 2 +-
flang-rt/unittests/Runtime/Derived.cpp | 4 +-
flang-rt/unittests/Runtime/ExternalIOTest.cpp | 2 +-
flang-rt/unittests/Runtime/Format.cpp | 6 +--
flang-rt/unittests/Runtime/Inquiry.cpp | 2 +-
flang-rt/unittests/Runtime/ListInputTest.cpp | 4 +-
.../unittests/Runtime/LogicalFormatTest.cpp | 2 +-
flang-rt/unittests/Runtime/Matmul.cpp | 4 +-
.../unittests/Runtime/MatmulTranspose.cpp | 4 +-
flang-rt/unittests/Runtime/MiscIntrinsic.cpp | 2 +-
flang-rt/unittests/Runtime/Namelist.cpp | 4 +-
.../unittests/Runtime/NumericalFormatTest.cpp | 2 +-
flang-rt/unittests/Runtime/Pointer.cpp | 4 +-
flang-rt/unittests/Runtime/Random.cpp | 4 +-
flang-rt/unittests/Runtime/Reduction.cpp | 4 +-
.../unittests/Runtime/RuntimeCrashTest.cpp | 2 +-
flang-rt/unittests/Runtime/Stop.cpp | 2 +-
flang-rt/unittests/Runtime/Support.cpp | 2 +-
flang-rt/unittests/Runtime/TemporaryStack.cpp | 6 +--
.../unittests/Runtime/Transformational.cpp | 2 +-
flang-rt/unittests/Runtime/tools.h | 4 +-
flang/docs/FlangDriver.md | 6 +--
flang/docs/GettingStarted.md | 10 ++---
flang/docs/OpenACC-descriptor-management.md | 2 +-
flang/docs/ReleaseNotes.md | 6 +--
flang/examples/CMakeLists.txt | 4 +-
.../ExternalHelloWorld/CMakeLists.txt | 4 +-
flang/runtime/CMakeLists.txt | 41 ++++++++++---------
flang/runtime/CUDA/CMakeLists.txt | 8 ++--
flang/test/CMakeLists.txt | 2 +-
.../test/Driver/gcc-toolchain-install-dir.f90 | 2 +-
flang/test/Driver/linker-flags.f90 | 8 ++--
.../test/Driver/msvc-dependent-lib-flags.f90 | 8 ++--
flang/test/Driver/nostdlib.f90 | 2 +-
flang/unittests/Evaluate/CMakeLists.txt | 4 +-
flang/unittests/Runtime/CMakeLists.txt | 2 +-
flang/unittests/Runtime/CUDA/CMakeLists.txt | 4 +-
lld/COFF/MinGW.cpp | 2 +-
229 files changed, 727 insertions(+), 685 deletions(-)
create mode 100644 flang-rt/examples/CMakeLists.txt
create mode 100644 flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
rename {flang => flang-rt}/examples/ExternalHelloWorld/external-hello.cpp (80%)
rename flang-rt/include/flang-rt/{ => runtime}/allocator-registry.h (87%)
rename flang-rt/include/flang-rt/{ => runtime}/array-constructor.h (90%)
rename flang-rt/include/flang-rt/{ => runtime}/assign-impl.h (85%)
rename flang-rt/include/flang-rt/{ => runtime}/buffer.h (97%)
rename flang-rt/include/flang-rt/{ => runtime}/connection.h (96%)
rename flang-rt/include/flang-rt/{ => runtime}/derived.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/descriptor.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/emit-encoded.h (94%)
rename flang-rt/include/flang-rt/{ => runtime}/environment.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/file.h (95%)
rename flang-rt/include/flang-rt/{ => runtime}/format-implementation.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/format.h (97%)
rename flang-rt/include/flang-rt/{ => runtime}/internal-unit.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/io-error.h (94%)
rename flang-rt/include/flang-rt/{ => runtime}/io-stmt.h (99%)
rename flang-rt/include/flang-rt/{ => runtime}/lock.h (94%)
rename flang-rt/include/flang-rt/{ => runtime}/memory.h (96%)
rename flang-rt/include/flang-rt/{ => runtime}/namelist.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/non-tbp-dio.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/numeric-templates.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/random-templates.h (94%)
rename flang-rt/include/flang-rt/{ => runtime}/reduction-templates.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/stat.h (93%)
rename flang-rt/include/flang-rt/{ => runtime}/terminator.h (95%)
rename flang-rt/include/flang-rt/{ => runtime}/tools.h (99%)
rename flang-rt/include/flang-rt/{ => runtime}/type-code.h (93%)
rename flang-rt/include/flang-rt/{ => runtime}/type-info.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/utf.h (94%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/CMakeLists.txt (68%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/allocatable.cpp (94%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/allocator.cpp (86%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/descriptor.cpp (90%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/init.cpp (83%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/kernel.cpp (98%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/memmove-function.cpp (91%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/memory.cpp (97%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/pointer.cpp (92%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/registration.cpp (93%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/CMakeLists.txt (94%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/acos.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/acosh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/asin.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/asinh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/atan.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/atan2.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/atanh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/ceil.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/complex-math.c (100%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/complex-math.h (88%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/cos.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/cosh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/erf.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/erfc.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/exp.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/exponent.cpp (92%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/floor.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/fma.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/fraction.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/hypot.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/j0.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/j1.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/jn.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/lgamma.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/llround.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/log.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/log10.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/lround.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/math-entries.h (96%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/mod-real.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/modulo-real.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/nearbyint.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/nearest.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/norm2.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/numeric-template-specs.h (82%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/pow.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/random.cpp (85%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/remainder.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/round.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/rrspacing.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/scale.cpp (92%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/set-exponent.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/sin.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/sinh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/spacing.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/sqrt.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/tan.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/tanh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/tgamma.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/trunc.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/y0.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/y1.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/yn.cpp (90%)
rename flang-rt/lib/{flang_rt => runtime}/CMakeLists.txt (83%)
rename flang-rt/lib/{flang_rt => runtime}/ISO_Fortran_binding.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/ISO_Fortran_util.h (90%)
rename flang-rt/lib/{flang_rt => runtime}/allocatable.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/allocator-registry.cpp (89%)
rename flang-rt/lib/{flang_rt => runtime}/array-constructor.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/assign.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/buffer.cpp (90%)
rename flang-rt/lib/{flang_rt => runtime}/character.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/command.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/complex-powi.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/complex-reduction.c (100%)
rename flang-rt/lib/{flang_rt => runtime}/complex-reduction.h (97%)
rename flang-rt/lib/{flang_rt => runtime}/connection.cpp (91%)
rename flang-rt/lib/{flang_rt => runtime}/copy.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/copy.h (78%)
rename flang-rt/lib/{flang_rt => runtime}/derived-api.cpp (95%)
rename flang-rt/lib/{flang_rt => runtime}/derived.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/descriptor-io.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/descriptor-io.h (98%)
rename flang-rt/lib/{flang_rt => runtime}/descriptor.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/dot-product.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/edit-input.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/edit-input.h (87%)
rename flang-rt/lib/{flang_rt => runtime}/edit-output.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/edit-output.h (95%)
rename flang-rt/lib/{flang_rt => runtime}/environment-default-list.h (100%)
rename flang-rt/lib/{flang_rt => runtime}/environment.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/exceptions.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/execute.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/extensions.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/external-unit.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/extrema.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/file.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/findloc.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/format.cpp (89%)
rename flang-rt/lib/{flang_rt => runtime}/inquiry.cpp (94%)
rename flang-rt/lib/{flang_rt => runtime}/internal-unit.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/io-api-common.h (92%)
rename flang-rt/lib/{flang_rt => runtime}/io-api-minimal.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/io-api.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/io-error.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/io-stmt.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/iostat.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/main.cpp (90%)
rename flang-rt/lib/{flang_rt => runtime}/matmul-transpose.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/matmul.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/memory.cpp (87%)
rename flang-rt/lib/{flang_rt => runtime}/misc-intrinsic.cpp (95%)
rename flang-rt/lib/{flang_rt => runtime}/namelist.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/non-tbp-dio.cpp (86%)
rename flang-rt/lib/{flang_rt => runtime}/numeric.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/pointer.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/product.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/pseudo-unit.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/ragged.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/random.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/reduce.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/reduction.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/stack.h (93%)
rename flang-rt/lib/{flang_rt => runtime}/stat.cpp (93%)
rename flang-rt/lib/{flang_rt => runtime}/stop.cpp (95%)
rename flang-rt/lib/{flang_rt => runtime}/sum.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/support.cpp (91%)
rename flang-rt/lib/{flang_rt => runtime}/temporary-stack.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/terminator.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/time-intrinsic.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/tools.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/transformational.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/type-code.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/type-info.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/unit-map.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/unit-map.h (92%)
rename flang-rt/lib/{flang_rt => runtime}/unit.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/unit.h (95%)
rename flang-rt/lib/{flang_rt => runtime}/utf.cpp (97%)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 361cf41544b06..dcfa80602a042 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1321,7 +1321,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
/// Add Fortran runtime libs
void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) {
- // Link flang_rt
+ // Link flang_rt.runtime
// These are handled earlier on Windows by telling the frontend driver to
// add the correct libraries to link against as dependents in the object
// file.
@@ -1337,7 +1337,7 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
if (AsNeeded)
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
}
- CmdArgs.push_back("-lflang_rt");
+ CmdArgs.push_back("-lflang_rt.runtime");
addArchSpecificRPath(TC, Args, CmdArgs);
}
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index a40b4026e3f57..f6ff58d07e822 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -367,26 +367,26 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
case options::OPT__SLASH_MT:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("--dependent-lib=libcmt");
- CmdArgs.push_back("--dependent-lib=flang_rt.static.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static.lib");
break;
case options::OPT__SLASH_MTd:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DEBUG");
CmdArgs.push_back("--dependent-lib=libcmtd");
- CmdArgs.push_back("--dependent-lib=flang_rt.static_dbg.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static_dbg.lib");
break;
case options::OPT__SLASH_MD:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrt");
- CmdArgs.push_back("--dependent-lib=flang_rt.dynamic.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic.lib");
break;
case options::OPT__SLASH_MDd:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DEBUG");
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrtd");
- CmdArgs.push_back("--dependent-lib=flang_rt.dynamic_dbg.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic_dbg.lib");
break;
}
}
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 655d0a55b4004..37f49ebc0d7bb 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -168,8 +168,8 @@ else ()
endif ()
-option(FLANG_RT_ENABLE_CUF "Compile CUDA Fortran runtime sources" OFF)
-if (FLANG_RT_ENABLE_CUF)
+option(FLANG_RT_INCLUDE_CUF "Build the CUDA Fortran runtime (libflang_rt.cuda.a)" OFF)
+if (FLANG_RT_INCLUDE_CUF)
find_package(CUDAToolkit REQUIRED)
endif()
@@ -240,6 +240,10 @@ add_custom_target(flang-rt)
add_subdirectory(lib)
+if (LLVM_INCLUDE_EXAMPLES)
+ add_subdirectory(examples)
+endif ()
+
if (FLANG_RT_INCLUDE_TESTS)
add_subdirectory(unittests)
add_subdirectory(test)
diff --git a/flang-rt/README.md b/flang-rt/README.md
index 76993f27f8e4f..aba64e2453872 100644
--- a/flang-rt/README.md
+++ b/flang-rt/README.md
@@ -151,9 +151,9 @@ CMake itself provide.
GPU accelerators using OpenMP offloading. Only Clang is supported for
`CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`.
- * `FLANG_RT_ENABLE_CUF` (bool, default: `OFF`)
+ * `FLANG_RT_INCLUDE_CUF` (bool, default: `OFF`)
- Compiles the `libCufRuntime_cuda_<CUDA-version>.a/.so` library. This is
+ Compiles the `libflang_rt.cuda_<CUDA-version>.a/.so` library. This is
independent of `FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA` and only
requires a
[CUDA Toolkit installation](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html)
diff --git a/flang-rt/examples/CMakeLists.txt b/flang-rt/examples/CMakeLists.txt
new file mode 100644
index 0000000000000..f45a95d18b641
--- /dev/null
+++ b/flang-rt/examples/CMakeLists.txt
@@ -0,0 +1,9 @@
+#===-- examples/CMakeLists.txt ---------------------------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+add_subdirectory(ExternalHelloWorld)
diff --git a/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt b/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
new file mode 100644
index 0000000000000..e9f347f18cc43
--- /dev/null
+++ b/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
@@ -0,0 +1,17 @@
+#===-- examples/ExternalHelloWorld/CMakeLists.txt --------------------------===#
+#
+# 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
+#
+#===------------------------------------------------------------------------===#
+
+# This test is not run by default as it requires input.
+add_llvm_example(external-hello-world
+ external-hello.cpp
+)
+
+target_link_libraries(external-hello-world
+ PRIVATE
+ flang_rt.runtime
+ )
diff --git a/flang/examples/ExternalHelloWorld/external-hello.cpp b/flang-rt/examples/ExternalHelloWorld/external-hello.cpp
similarity index 80%
rename from flang/examples/ExternalHelloWorld/external-hello.cpp
rename to flang-rt/examples/ExternalHelloWorld/external-hello.cpp
index 4991bf9eba999..7c8a12476295c 100644
--- a/flang/examples/ExternalHelloWorld/external-hello.cpp
+++ b/flang-rt/examples/ExternalHelloWorld/external-hello.cpp
@@ -1,3 +1,11 @@
+//===-- examples/ExternalHelloWorld/external-hello.cpp ----------*- 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
+//
+//===----------------------------------------------------------------------===//
+
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
diff --git a/flang-rt/include/flang-rt/CUDA/allocator.h b/flang-rt/include/flang-rt/CUDA/allocator.h
index 68bb0736dd5ee..5bc61cd04ee26 100644
--- a/flang-rt/include/flang-rt/CUDA/allocator.h
+++ b/flang-rt/include/flang-rt/CUDA/allocator.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/CUDA/allocator.h -----------------------*- C++ -*-===//
+//===-- include/flang-rt/cuda/allocator.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.
diff --git a/flang-rt/include/flang-rt/allocator-registry.h b/flang-rt/include/flang-rt/runtime/allocator-registry.h
similarity index 87%
rename from flang-rt/include/flang-rt/allocator-registry.h
rename to flang-rt/include/flang-rt/runtime/allocator-registry.h
index ea905afc045ce..1a59ec8b1ef5b 100644
--- a/flang-rt/include/flang-rt/allocator-registry.h
+++ b/flang-rt/include/flang-rt/runtime/allocator-registry.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/allocator-registry.h -------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/allocator-registry.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_ALLOCATOR_REGISTRY_H_
-#define FLANG_RT_ALLOCATOR_REGISTRY_H_
+#ifndef FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
+#define FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
#include "flang/Common/api-attrs.h"
#include "flang/Runtime/allocator-registry-consts.h"
@@ -55,4 +55,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif // FLANG_RT_ALLOCATOR_REGISTRY_H_
+#endif // FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
diff --git a/flang-rt/include/flang-rt/array-constructor.h b/flang-rt/include/flang-rt/runtime/array-constructor.h
similarity index 90%
rename from flang-rt/include/flang-rt/array-constructor.h
rename to flang-rt/include/flang-rt/runtime/array-constructor.h
index 738050f80ef65..9c037177161c0 100644
--- a/flang-rt/include/flang-rt/array-constructor.h
+++ b/flang-rt/include/flang-rt/runtime/array-constructor.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/array-constructor.h --------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/array-constructor.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.
@@ -9,8 +9,8 @@
// External APIs to create temporary storage for array constructors when their
// final extents or length parameters cannot be pre-computed.
-#ifndef FLANG_RT_ARRAY_CONSTRUCTOR_H_
-#define FLANG_RT_ARRAY_CONSTRUCTOR_H_
+#ifndef FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
+#define FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
#include "descriptor.h"
#include "flang/Runtime/array-constructor-consts.h"
@@ -54,4 +54,4 @@ static_assert(alignof(Fortran::runtime::ArrayConstructorVector) <=
"MaxArrayConstructorVectorAlignInBytes");
} // namespace Fortran::runtime
-#endif // FLANG_RT_ARRAY_CONSTRUCTOR_H_
+#endif // FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
diff --git a/flang-rt/include/flang-rt/assign-impl.h b/flang-rt/include/flang-rt/runtime/assign-impl.h
similarity index 85%
rename from flang-rt/include/flang-rt/assign-impl.h
rename to flang-rt/include/flang-rt/runtime/assign-impl.h
index 2e85a451d5b52..cc931f6713cd8 100644
--- a/flang-rt/include/flang-rt/assign-impl.h
+++ b/flang-rt/include/flang-rt/runtime/assign-impl.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/assign-impl.h --------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/assign-impl.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_ASSIGN_IMPL_H_
-#define FLANG_RT_ASSIGN_IMPL_H_
+#ifndef FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
+#define FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
#include "flang/Runtime/freestanding-tools.h"
@@ -28,4 +28,4 @@ RT_API_ATTRS void DoFromSourceAssign(Descriptor &, const Descriptor &,
#endif
} // namespace Fortran::runtime
-#endif // FLANG_RT_ASSIGN_IMPL_H_
+#endif // FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
diff --git a/flang-rt/include/flang-rt/buffer.h b/flang-rt/include/flang-rt/runtime/buffer.h
similarity index 97%
rename from flang-rt/include/flang-rt/buffer.h
rename to flang-rt/include/flang-rt/runtime/buffer.h
index bd2e8c47c6e30..b5a9ce9e35e91 100644
--- a/flang-rt/include/flang-rt/buffer.h
+++ b/flang-rt/include/flang-rt/runtime/buffer.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/buffer.h -------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/buffer.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.
@@ -8,8 +8,8 @@
// External file buffering
-#ifndef FLANG_RT_BUFFER_H_
-#define FLANG_RT_BUFFER_H_
+#ifndef FLANG_RT_RUNTIME_BUFFER_H_
+#define FLANG_RT_RUNTIME_BUFFER_H_
#include "io-error.h"
#include "memory.h"
@@ -221,4 +221,4 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
bool dirty_{false};
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_BUFFER_H_
+#endif // FLANG_RT_RUNTIME_BUFFER_H_
diff --git a/flang-rt/include/flang-rt/connection.h b/flang-rt/include/flang-rt/runtime/connection.h
similarity index 96%
rename from flang-rt/include/flang-rt/connection.h
rename to flang-rt/include/flang-rt/runtime/connection.h
index 550ddb15c7236..03d9658e7067b 100644
--- a/flang-rt/include/flang-rt/connection.h
+++ b/flang-rt/include/flang-rt/runtime/connection.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/connection.h ---------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/connection.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.
@@ -8,8 +8,8 @@
// Fortran I/O connection state (abstracted over internal & external units)
-#ifndef FLANG_RT_CONNECTION_H_
-#define FLANG_RT_CONNECTION_H_
+#ifndef FLANG_RT_RUNTIME_CONNECTION_H_
+#define FLANG_RT_RUNTIME_CONNECTION_H_
#include "format.h"
#include "flang/Common/optional.h"
@@ -124,4 +124,4 @@ class SavedPosition {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_CONNECTION_H_
+#endif // FLANG_RT_RUNTIME_CONNECTION_H_
diff --git a/flang-rt/include/flang-rt/derived.h b/flang-rt/include/flang-rt/runtime/derived.h
similarity index 91%
rename from flang-rt/include/flang-rt/derived.h
rename to flang-rt/include/flang-rt/runtime/derived.h
index d65fb75172495..ac6962c57168c 100644
--- a/flang-rt/include/flang-rt/derived.h
+++ b/flang-rt/include/flang-rt/runtime/derived.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/derived.h ------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/derived.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.
@@ -8,8 +8,8 @@
// Internal runtime utilities for derived type operations.
-#ifndef FLANG_RT_DERIVED_H_
-#define FLANG_RT_DERIVED_H_
+#ifndef FLANG_RT_RUNTIME_DERIVED_H_
+#define FLANG_RT_RUNTIME_DERIVED_H_
#include "flang/Common/api-attrs.h"
@@ -48,4 +48,4 @@ RT_API_ATTRS void Destroy(const Descriptor &, bool finalize,
RT_API_ATTRS bool HasDynamicComponent(const Descriptor &);
} // namespace Fortran::runtime
-#endif // FLANG_RT_DERIVED_H_
+#endif // FLANG_RT_RUNTIME_DERIVED_H_
diff --git a/flang-rt/include/flang-rt/descriptor.h b/flang-rt/include/flang-rt/runtime/descriptor.h
similarity index 98%
rename from flang-rt/include/flang-rt/descriptor.h
rename to flang-rt/include/flang-rt/runtime/descriptor.h
index f97b8443425dc..19e1a0bf6a1dd 100644
--- a/flang-rt/include/flang-rt/descriptor.h
+++ b/flang-rt/include/flang-rt/runtime/descriptor.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/descriptor.h ---------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/descriptor.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_DESCRIPTOR_H_
-#define FLANG_RT_DESCRIPTOR_H_
+#ifndef FLANG_RT_RUNTIME_DESCRIPTOR_H_
+#define FLANG_RT_RUNTIME_DESCRIPTOR_H_
// Defines data structures used during execution of a Fortran program
// to implement nontrivial dummy arguments, pointers, allocatables,
@@ -482,4 +482,4 @@ class alignas(Descriptor) StaticDescriptor {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_DESCRIPTOR_H_
+#endif // FLANG_RT_RUNTIME_DESCRIPTOR_H_
diff --git a/flang-rt/include/flang-rt/emit-encoded.h b/flang-rt/include/flang-rt/runtime/emit-encoded.h
similarity index 94%
rename from flang-rt/include/flang-rt/emit-encoded.h
rename to flang-rt/include/flang-rt/runtime/emit-encoded.h
index 279f751daff2c..d99f56b29558e 100644
--- a/flang-rt/include/flang-rt/emit-encoded.h
+++ b/flang-rt/include/flang-rt/runtime/emit-encoded.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/emit-encoded.h -------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/emit-encoded.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.
@@ -8,8 +8,8 @@
// Templates for emitting CHARACTER values with conversion
-#ifndef FLANG_RT_EMIT_ENCODED_H_
-#define FLANG_RT_EMIT_ENCODED_H_
+#ifndef FLANG_RT_RUNTIME_EMIT_ENCODED_H_
+#define FLANG_RT_RUNTIME_EMIT_ENCODED_H_
#include "connection.h"
#include "environment.h"
@@ -114,4 +114,4 @@ RT_API_ATTRS bool EmitRepeated(CONTEXT &to, char ch, std::size_t n) {
}
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_EMIT_ENCODED_H_
+#endif // FLANG_RT_RUNTIME_EMIT_ENCODED_H_
diff --git a/flang-rt/include/flang-rt/environment.h b/flang-rt/include/flang-rt/runtime/environment.h
similarity index 91%
rename from flang-rt/include/flang-rt/environment.h
rename to flang-rt/include/flang-rt/runtime/environment.h
index 7fa3060768502..142add432b5f7 100644
--- a/flang-rt/include/flang-rt/environment.h
+++ b/flang-rt/include/flang-rt/runtime/environment.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/environment.h --------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/environment.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_ENVIRONMENT_H_
-#define FLANG_RT_ENVIRONMENT_H_
+#ifndef FLANG_RT_RUNTIME_ENVIRONMENT_H_
+#define FLANG_RT_RUNTIME_ENVIRONMENT_H_
#include "flang/Common/optional.h"
#include "flang/Decimal/decimal.h"
@@ -67,4 +67,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif // FLANG_RT_ENVIRONMENT_H_
+#endif // FLANG_RT_RUNTIME_ENVIRONMENT_H_
diff --git a/flang-rt/include/flang-rt/file.h b/flang-rt/include/flang-rt/runtime/file.h
similarity index 95%
rename from flang-rt/include/flang-rt/file.h
rename to flang-rt/include/flang-rt/runtime/file.h
index 3ab21c655a38f..3bba29722b3b8 100644
--- a/flang-rt/include/flang-rt/file.h
+++ b/flang-rt/include/flang-rt/runtime/file.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/file.h ---------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/file.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.
@@ -8,8 +8,8 @@
// Raw system I/O wrappers
-#ifndef FLANG_RT_FILE_H_
-#define FLANG_RT_FILE_H_
+#ifndef FLANG_RT_RUNTIME_FILE_H_
+#define FLANG_RT_RUNTIME_FILE_H_
#include "io-error.h"
#include "memory.h"
@@ -113,4 +113,4 @@ RT_API_ATTRS bool MayWrite(const char *path);
RT_API_ATTRS bool MayReadAndWrite(const char *path);
RT_API_ATTRS std::int64_t SizeInBytes(const char *path);
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_FILE_H_
+#endif // FLANG_RT_RUNTIME_FILE_H_
diff --git a/flang-rt/include/flang-rt/format-implementation.h b/flang-rt/include/flang-rt/runtime/format-implementation.h
similarity index 98%
rename from flang-rt/include/flang-rt/format-implementation.h
rename to flang-rt/include/flang-rt/runtime/format-implementation.h
index 6a2e1078ab350..8f4eb1161dd14 100644
--- a/flang-rt/include/flang-rt/format-implementation.h
+++ b/flang-rt/include/flang-rt/runtime/format-implementation.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/format-implementation.h ----------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/format-implementation.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.
@@ -8,8 +8,8 @@
// Implements out-of-line member functions of template class FormatControl
-#ifndef FLANG_RT_FORMAT_IMPLEMENTATION_H_
-#define FLANG_RT_FORMAT_IMPLEMENTATION_H_
+#ifndef FLANG_RT_RUNTIME_FORMAT_IMPLEMENTATION_H_
+#define FLANG_RT_RUNTIME_FORMAT_IMPLEMENTATION_H_
#include "emit-encoded.h"
#include "format.h"
@@ -601,4 +601,4 @@ RT_API_ATTRS void FormatControl<CONTEXT>::Finish(Context &context) {
}
}
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_FORMAT_IMPLEMENTATION_H_
+#endif // FLANG_RT_RUNTIME_FORMAT_IMPLEMENTATION_H_
diff --git a/flang-rt/include/flang-rt/format.h b/flang-rt/include/flang-rt/runtime/format.h
similarity index 97%
rename from flang-rt/include/flang-rt/format.h
rename to flang-rt/include/flang-rt/runtime/format.h
index 09e151a2e98ca..b169d63fa4999 100644
--- a/flang-rt/include/flang-rt/format.h
+++ b/flang-rt/include/flang-rt/runtime/format.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/format.h -------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/format.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.
@@ -8,8 +8,8 @@
// FORMAT string processing
-#ifndef FLANG_RT_FORMAT_H_
-#define FLANG_RT_FORMAT_H_
+#ifndef FLANG_RT_RUNTIME_FORMAT_H_
+#define FLANG_RT_RUNTIME_FORMAT_H_
#include "environment.h"
#include "io-error.h"
@@ -201,4 +201,4 @@ template <typename CONTEXT> class FormatControl {
Iteration stack_[maxMaxHeight];
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_FORMAT_H_
+#endif // FLANG_RT_RUNTIME_FORMAT_H_
diff --git a/flang-rt/include/flang-rt/internal-unit.h b/flang-rt/include/flang-rt/runtime/internal-unit.h
similarity index 91%
rename from flang-rt/include/flang-rt/internal-unit.h
rename to flang-rt/include/flang-rt/runtime/internal-unit.h
index 946d69080e611..429d3489e0112 100644
--- a/flang-rt/include/flang-rt/internal-unit.h
+++ b/flang-rt/include/flang-rt/runtime/internal-unit.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/internal-unit.h ------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/internal-unit.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.
@@ -8,8 +8,8 @@
// Fortran internal I/O "units"
-#ifndef FLANG_RT_INTERNAL_UNIT_H_
-#define FLANG_RT_INTERNAL_UNIT_H_
+#ifndef FLANG_RT_RUNTIME_INTERNAL_UNIT_H_
+#define FLANG_RT_RUNTIME_INTERNAL_UNIT_H_
#include "connection.h"
#include "descriptor.h"
@@ -56,4 +56,4 @@ template <Direction DIR> class InternalDescriptorUnit : public ConnectionState {
extern template class InternalDescriptorUnit<Direction::Output>;
extern template class InternalDescriptorUnit<Direction::Input>;
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_INTERNAL_UNIT_H_
+#endif // FLANG_RT_RUNTIME_INTERNAL_UNIT_H_
diff --git a/flang-rt/include/flang-rt/io-error.h b/flang-rt/include/flang-rt/runtime/io-error.h
similarity index 94%
rename from flang-rt/include/flang-rt/io-error.h
rename to flang-rt/include/flang-rt/runtime/io-error.h
index 6b5c0f9f39019..1cef6a208f374 100644
--- a/flang-rt/include/flang-rt/io-error.h
+++ b/flang-rt/include/flang-rt/runtime/io-error.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/io-error.h -----------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/io-error.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.
@@ -12,8 +12,8 @@
// IOSTAT error codes are raw errno values augmented with values for
// Fortran-specific errors.
-#ifndef FLANG_RT_IO_ERROR_H_
-#define FLANG_RT_IO_ERROR_H_
+#ifndef FLANG_RT_RUNTIME_IO_ERROR_H_
+#define FLANG_RT_RUNTIME_IO_ERROR_H_
#include "memory.h"
#include "terminator.h"
@@ -80,4 +80,4 @@ class IoErrorHandler : public Terminator {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_IO_ERROR_H_
+#endif // FLANG_RT_RUNTIME_IO_ERROR_H_
diff --git a/flang-rt/include/flang-rt/io-stmt.h b/flang-rt/include/flang-rt/runtime/io-stmt.h
similarity index 99%
rename from flang-rt/include/flang-rt/io-stmt.h
rename to flang-rt/include/flang-rt/runtime/io-stmt.h
index 7efab320e5e1a..a364ddfd9b3c7 100644
--- a/flang-rt/include/flang-rt/io-stmt.h
+++ b/flang-rt/include/flang-rt/runtime/io-stmt.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/io-stmt.h ------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/io-stmt.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.
@@ -8,8 +8,8 @@
// Representations of the state of an I/O statement in progress
-#ifndef FLANG_RT_IO_STMT_H_
-#define FLANG_RT_IO_STMT_H_
+#ifndef FLANG_RT_RUNTIME_IO_STMT_H_
+#define FLANG_RT_RUNTIME_IO_STMT_H_
#include "connection.h"
#include "descriptor.h"
@@ -791,4 +791,4 @@ class ErroneousIoStatementState : public IoStatementBase {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_IO_STMT_H_
+#endif // FLANG_RT_RUNTIME_IO_STMT_H_
diff --git a/flang-rt/include/flang-rt/lock.h b/flang-rt/include/flang-rt/runtime/lock.h
similarity index 94%
rename from flang-rt/include/flang-rt/lock.h
rename to flang-rt/include/flang-rt/runtime/lock.h
index 1b09434d26f4f..7c88534245733 100644
--- a/flang-rt/include/flang-rt/lock.h
+++ b/flang-rt/include/flang-rt/runtime/lock.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/lock.h ---------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/lock.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.
@@ -8,8 +8,8 @@
// Wraps a mutex
-#ifndef FLANG_RT_LOCK_H_
-#define FLANG_RT_LOCK_H_
+#ifndef FLANG_RT_RUNTIME_LOCK_H_
+#define FLANG_RT_RUNTIME_LOCK_H_
#include "terminator.h"
#include "tools.h"
@@ -113,4 +113,4 @@ class CriticalSection {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_LOCK_H_
+#endif // FLANG_RT_RUNTIME_LOCK_H_
diff --git a/flang-rt/include/flang-rt/memory.h b/flang-rt/include/flang-rt/runtime/memory.h
similarity index 96%
rename from flang-rt/include/flang-rt/memory.h
rename to flang-rt/include/flang-rt/runtime/memory.h
index 64db30baf2806..93b477afa9814 100644
--- a/flang-rt/include/flang-rt/memory.h
+++ b/flang-rt/include/flang-rt/runtime/memory.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/memory.h -------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/memory.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.
@@ -9,8 +9,8 @@
// Thin wrapper around malloc()/free() to isolate the dependency,
// ease porting, and provide an owning pointer.
-#ifndef FLANG_RT_MEMORY_H_
-#define FLANG_RT_MEMORY_H_
+#ifndef FLANG_RT_RUNTIME_MEMORY_H_
+#define FLANG_RT_RUNTIME_MEMORY_H_
#include "flang/Common/api-attrs.h"
#include <cassert>
@@ -170,4 +170,4 @@ template <typename A> struct Allocator {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_MEMORY_H_
+#endif // FLANG_RT_RUNTIME_MEMORY_H_
diff --git a/flang-rt/include/flang-rt/namelist.h b/flang-rt/include/flang-rt/runtime/namelist.h
similarity index 91%
rename from flang-rt/include/flang-rt/namelist.h
rename to flang-rt/include/flang-rt/runtime/namelist.h
index 2ae93ca9c2050..17d7bf310cc96 100644
--- a/flang-rt/include/flang-rt/namelist.h
+++ b/flang-rt/include/flang-rt/runtime/namelist.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/namelist.h -----------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/namelist.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.
@@ -8,8 +8,8 @@
// Defines the data structure used for NAMELIST I/O
-#ifndef FLANG_RT_NAMELIST_H_
-#define FLANG_RT_NAMELIST_H_
+#ifndef FLANG_RT_RUNTIME_NAMELIST_H_
+#define FLANG_RT_RUNTIME_NAMELIST_H_
#include "non-tbp-dio.h"
#include "flang/Common/api-attrs.h"
@@ -51,4 +51,4 @@ class NamelistGroup {
RT_API_ATTRS bool IsNamelistNameOrSlash(IoStatementState &);
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_NAMELIST_H_
+#endif // FLANG_RT_RUNTIME_NAMELIST_H_
diff --git a/flang-rt/include/flang-rt/non-tbp-dio.h b/flang-rt/include/flang-rt/runtime/non-tbp-dio.h
similarity index 91%
rename from flang-rt/include/flang-rt/non-tbp-dio.h
rename to flang-rt/include/flang-rt/runtime/non-tbp-dio.h
index 1088257b72f59..2bbbfa7f97f79 100644
--- a/flang-rt/include/flang-rt/non-tbp-dio.h
+++ b/flang-rt/include/flang-rt/runtime/non-tbp-dio.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/non-tbp-dio.h --------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/non-tbp-dio.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.
@@ -19,8 +19,8 @@
// a containing scope has become inaccessible in a nested scope due
// to the use of "IMPORT, NONE" or "IMPORT, ONLY:".
-#ifndef FLANG_RT_NON_TBP_DIO_H_
-#define FLANG_RT_NON_TBP_DIO_H_
+#ifndef FLANG_RT_RUNTIME_NON_TBP_DIO_H_
+#define FLANG_RT_RUNTIME_NON_TBP_DIO_H_
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/api-attrs.h"
@@ -53,4 +53,4 @@ struct NonTbpDefinedIoTable {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_NON_TBP_DIO_H_
+#endif // FLANG_RT_RUNTIME_NON_TBP_DIO_H_
diff --git a/flang-rt/include/flang-rt/numeric-templates.h b/flang-rt/include/flang-rt/runtime/numeric-templates.h
similarity index 98%
rename from flang-rt/include/flang-rt/numeric-templates.h
rename to flang-rt/include/flang-rt/runtime/numeric-templates.h
index a1475923ff3b1..1253d56f3c0fd 100644
--- a/flang-rt/include/flang-rt/numeric-templates.h
+++ b/flang-rt/include/flang-rt/runtime/numeric-templates.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/numeric-templates.h --------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/numeric-templates.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.
@@ -15,8 +15,8 @@
// for the data type corresponding to CppTypeFor<TypeCategory::Real, 16>
// on the target.
-#ifndef FLANG_RT_NUMERIC_TEMPLATES_H_
-#define FLANG_RT_NUMERIC_TEMPLATES_H_
+#ifndef FLANG_RT_RUNTIME_NUMERIC_TEMPLATES_H_
+#define FLANG_RT_RUNTIME_NUMERIC_TEMPLATES_H_
#include "terminator.h"
#include "tools.h"
@@ -368,4 +368,4 @@ template <typename T> inline RT_API_ATTRS T ErfcScaled(T arg) {
} // namespace Fortran::runtime
-#endif // FLANG_RT_NUMERIC_TEMPLATES_H_
+#endif // FLANG_RT_RUNTIME_NUMERIC_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/random-templates.h b/flang-rt/include/flang-rt/runtime/random-templates.h
similarity index 94%
rename from flang-rt/include/flang-rt/random-templates.h
rename to flang-rt/include/flang-rt/runtime/random-templates.h
index 00542bd5b2553..895c5ad4fc8bb 100644
--- a/flang-rt/include/flang-rt/random-templates.h
+++ b/flang-rt/include/flang-rt/runtime/random-templates.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/random-templates.h ---------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/random-templates.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_RANDOM_TEMPLATES_H_
-#define FLANG_RT_RANDOM_TEMPLATES_H_
+#ifndef FLANG_RT_RUNTIME_RANDOM_TEMPLATES_H_
+#define FLANG_RT_RUNTIME_RANDOM_TEMPLATES_H_
#include "descriptor.h"
#include "lock.h"
@@ -108,4 +108,4 @@ inline void GenerateUnsigned(const Descriptor &harvest) {
} // namespace Fortran::runtime::random
-#endif // FLANG_RT_RANDOM_TEMPLATES_H_
+#endif // FLANG_RT_RUNTIME_RANDOM_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/reduction-templates.h b/flang-rt/include/flang-rt/runtime/reduction-templates.h
similarity index 98%
rename from flang-rt/include/flang-rt/reduction-templates.h
rename to flang-rt/include/flang-rt/runtime/reduction-templates.h
index d6b3c24920cf9..8c6f838b8dadf 100644
--- a/flang-rt/include/flang-rt/reduction-templates.h
+++ b/flang-rt/include/flang-rt/runtime/reduction-templates.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/reduction-templates.h ------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/reduction-templates.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.
@@ -18,8 +18,8 @@
// * Character-valued reductions (MAXVAL & MINVAL) return arbitrary
// length results, dynamically allocated in a caller-supplied descriptor
-#ifndef FLANG_RT_REDUCTION_TEMPLATES_H_
-#define FLANG_RT_REDUCTION_TEMPLATES_H_
+#ifndef FLANG_RT_RUNTIME_REDUCTION_TEMPLATES_H_
+#define FLANG_RT_RUNTIME_REDUCTION_TEMPLATES_H_
#include "descriptor.h"
#include "numeric-templates.h"
@@ -416,4 +416,4 @@ template <int KIND> struct Norm2Helper {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_REDUCTION_TEMPLATES_H_
+#endif // FLANG_RT_RUNTIME_REDUCTION_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/stat.h b/flang-rt/include/flang-rt/runtime/stat.h
similarity index 93%
rename from flang-rt/include/flang-rt/stat.h
rename to flang-rt/include/flang-rt/runtime/stat.h
index a6824f4803561..070d0bf8673fb 100644
--- a/flang-rt/include/flang-rt/stat.h
+++ b/flang-rt/include/flang-rt/runtime/stat.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/stat.h ---------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/stat.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.
@@ -9,8 +9,8 @@
// Defines the values returned by the runtime for STAT= specifiers
// on executable statements.
-#ifndef FLANG_RT_STAT_H_
-#define FLANG_RT_STAT_H_
+#ifndef FLANG_RT_RUNTIME_STAT_H_
+#define FLANG_RT_RUNTIME_STAT_H_
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/api-attrs.h"
#include "flang/Runtime/magic-numbers.h"
@@ -60,4 +60,4 @@ RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat); // returns stat
RT_API_ATTRS int ReturnError(Terminator &, int stat,
const Descriptor *errmsg = nullptr, bool hasStat = false);
} // namespace Fortran::runtime
-#endif // FLANG_RT_STAT_H_
+#endif // FLANG_RT_RUNTIME_STAT_H_
diff --git a/flang-rt/include/flang-rt/terminator.h b/flang-rt/include/flang-rt/runtime/terminator.h
similarity index 95%
rename from flang-rt/include/flang-rt/terminator.h
rename to flang-rt/include/flang-rt/runtime/terminator.h
index c2a4e1f64eb66..4815f0674c849 100644
--- a/flang-rt/include/flang-rt/terminator.h
+++ b/flang-rt/include/flang-rt/runtime/terminator.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/terminator.h ---------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/terminator.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.
@@ -8,8 +8,8 @@
// Termination of the image
-#ifndef FLANG_RT_TERMINATOR_H_
-#define FLANG_RT_TERMINATOR_H_
+#ifndef FLANG_RT_RUNTIME_TERMINATOR_H_
+#define FLANG_RT_RUNTIME_TERMINATOR_H_
#include "flang/Common/api-attrs.h"
#include <cstdarg>
@@ -121,4 +121,4 @@ namespace Fortran::runtime::io {
RT_API_ATTRS void FlushOutputOnCrash(const Terminator &);
}
-#endif // FLANG_RT_TERMINATOR_H_
+#endif // FLANG_RT_RUNTIME_TERMINATOR_H_
diff --git a/flang-rt/include/flang-rt/tools.h b/flang-rt/include/flang-rt/runtime/tools.h
similarity index 99%
rename from flang-rt/include/flang-rt/tools.h
rename to flang-rt/include/flang-rt/runtime/tools.h
index 3503c49308e4d..792aec7710a15 100644
--- a/flang-rt/include/flang-rt/tools.h
+++ b/flang-rt/include/flang-rt/runtime/tools.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/tools.h --------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/tools.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_TOOLS_H_
-#define FLANG_RT_TOOLS_H_
+#ifndef FLANG_RT_RUNTIME_TOOLS_H_
+#define FLANG_RT_RUNTIME_TOOLS_H_
#include "descriptor.h"
#include "memory.h"
@@ -570,4 +570,4 @@ RT_API_ATTRS void CreatePartialReductionResult(Descriptor &result,
const char *intrinsic, TypeCode);
} // namespace Fortran::runtime
-#endif // FLANG_RT_TOOLS_H_
+#endif // FLANG_RT_RUNTIME_TOOLS_H_
diff --git a/flang-rt/include/flang-rt/type-code.h b/flang-rt/include/flang-rt/runtime/type-code.h
similarity index 93%
rename from flang-rt/include/flang-rt/type-code.h
rename to flang-rt/include/flang-rt/runtime/type-code.h
index a3b79462887c1..9416a2816fd43 100644
--- a/flang-rt/include/flang-rt/type-code.h
+++ b/flang-rt/include/flang-rt/runtime/type-code.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/type-code.h ----------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/type-code.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_TYPE_CODE_H_
-#define FLANG_RT_TYPE_CODE_H_
+#ifndef FLANG_RT_RUNTIME_TYPE_CODE_H_
+#define FLANG_RT_RUNTIME_TYPE_CODE_H_
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
@@ -75,4 +75,4 @@ class TypeCode {
ISO::CFI_type_t raw_{CFI_type_other};
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_TYPE_CODE_H_
+#endif // FLANG_RT_RUNTIME_TYPE_CODE_H_
diff --git a/flang-rt/include/flang-rt/type-info.h b/flang-rt/include/flang-rt/runtime/type-info.h
similarity index 98%
rename from flang-rt/include/flang-rt/type-info.h
rename to flang-rt/include/flang-rt/runtime/type-info.h
index dc5cd98d7523f..9891fcecdcb25 100644
--- a/flang-rt/include/flang-rt/type-info.h
+++ b/flang-rt/include/flang-rt/runtime/type-info.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/type-info.h ----------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/type-info.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_TYPE_INFO_H_
-#define FLANG_RT_TYPE_INFO_H_
+#ifndef FLANG_RT_RUNTIME_TYPE_INFO_H_
+#define FLANG_RT_RUNTIME_TYPE_INFO_H_
// A C++ perspective of the derived type description schemata in
// flang/module/__fortran_type_info.f90.
@@ -321,4 +321,4 @@ class DerivedType {
};
} // namespace Fortran::runtime::typeInfo
-#endif // FLANG_RT_TYPE_INFO_H_
+#endif // FLANG_RT_RUNTIME_TYPE_INFO_H_
diff --git a/flang-rt/include/flang-rt/utf.h b/flang-rt/include/flang-rt/runtime/utf.h
similarity index 94%
rename from flang-rt/include/flang-rt/utf.h
rename to flang-rt/include/flang-rt/runtime/utf.h
index 648937ca14f16..b5add823124fc 100644
--- a/flang-rt/include/flang-rt/utf.h
+++ b/flang-rt/include/flang-rt/runtime/utf.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/utf.h ----------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/utf.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.
@@ -38,8 +38,8 @@
// standard maximum. However, we support extended forms up to 32 bits so that
// CHARACTER(KIND=4) can be abused to hold arbitrary 32-bit data.
-#ifndef FLANG_RT_UTF_H_
-#define FLANG_RT_UTF_H_
+#ifndef FLANG_RT_RUNTIME_UTF_H_
+#define FLANG_RT_RUNTIME_UTF_H_
#include "flang/Common/optional.h"
#include <cstddef>
@@ -70,4 +70,4 @@ RT_API_ATTRS Fortran::common::optional<char32_t> DecodeUTF8(const char *);
RT_API_ATTRS std::size_t EncodeUTF8(char *, char32_t);
} // namespace Fortran::runtime
-#endif // FLANG_RT_UTF_H_
+#endif // FLANG_RT_RUNTIME_UTF_H_
diff --git a/flang-rt/lib/CMakeLists.txt b/flang-rt/lib/CMakeLists.txt
index 8e2e0fbbbc24f..aee51dcc9fa24 100644
--- a/flang-rt/lib/CMakeLists.txt
+++ b/flang-rt/lib/CMakeLists.txt
@@ -6,11 +6,10 @@
#
#===------------------------------------------------------------------------===#
-add_subdirectory(FortranFloat128Math)
-add_subdirectory(flang_rt)
-
-if (FLANG_RT_ENABLE_CUF)
- add_subdirectory(flang_rt/CUDA)
+add_subdirectory(quadmath)
+add_subdirectory(runtime)
+if (FLANG_RT_INCLUDE_CUF)
+ add_subdirectory(cuda)
endif()
if (FLANG_RT_INCLUDE_TESTS)
diff --git a/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt b/flang-rt/lib/cuda/CMakeLists.txt
similarity index 68%
rename from flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
rename to flang-rt/lib/cuda/CMakeLists.txt
index 428aa3059b869..d5ca354c1029f 100644
--- a/flang-rt/lib/flang_rt/CUDA/CMakeLists.txt
+++ b/flang-rt/lib/cuda/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/flang_rt/CUDA/CMakeLists.txt ------------------------------------===#
+#===-- lib/cuda/CMakeLists.txt ---------------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
#===------------------------------------------------------------------------===#
-add_flangrt_library(CufRuntime STATIC
+add_flangrt_library(flang_rt.cuda STATIC
allocatable.cpp
allocator.cpp
descriptor.cpp
@@ -17,18 +17,18 @@ add_flangrt_library(CufRuntime STATIC
memory.cpp
registration.cpp
- # libCufRuntime depends on a certain version of CUDA. To be able to have
+ # libflang_rt.runtime depends on a certain version of CUDA. To be able to have
# multiple build of this library with different CUDA version, the version is
# added to the library name.
TARGET_PROPERTIES
- OUTPUT_NAME "CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}"
+ OUTPUT_NAME "flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR}"
INCLUDE_DIRECTORIES
PRIVATE ${CUDAToolkit_INCLUDE_DIRS}
)
-target_link_libraries(CufRuntime
+target_link_libraries(flang_rt.cuda
PUBLIC
- flang_rt
+ flang_rt.runtime
CUDA::cudart_static
)
diff --git a/flang-rt/lib/flang_rt/CUDA/allocatable.cpp b/flang-rt/lib/cuda/allocatable.cpp
similarity index 94%
rename from flang-rt/lib/flang_rt/CUDA/allocatable.cpp
rename to flang-rt/lib/cuda/allocatable.cpp
index 2281e2148d4ae..2f549b604fe58 100644
--- a/flang-rt/lib/flang_rt/CUDA/allocatable.cpp
+++ b/flang-rt/lib/cuda/allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/allocatable.cpp -----------------------*- C++ -*-===//
+//===-- lib/cuda/allocatable.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/allocatable.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memmove-function.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/allocator.cpp b/flang-rt/lib/cuda/allocator.cpp
similarity index 86%
rename from flang-rt/lib/flang_rt/CUDA/allocator.cpp
rename to flang-rt/lib/cuda/allocator.cpp
index dc1ce5920e222..511543f6a4863 100644
--- a/flang-rt/lib/flang_rt/CUDA/allocator.cpp
+++ b/flang-rt/lib/cuda/allocator.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/allocator.cpp -------------------------*- C++ -*-===//
+//===-- lib/cuda/allocator.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Support/Fortran.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/descriptor.cpp b/flang-rt/lib/cuda/descriptor.cpp
similarity index 90%
rename from flang-rt/lib/flang_rt/CUDA/descriptor.cpp
rename to flang-rt/lib/cuda/descriptor.cpp
index 9ec79ccea22c3..60e096acfde32 100644
--- a/flang-rt/lib/flang_rt/CUDA/descriptor.cpp
+++ b/flang-rt/lib/cuda/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/descriptor.cpp ------------------------*- C++ -*-===//
+//===-- lib/cuda/descriptor.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/descriptor.h"
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/init.cpp b/flang-rt/lib/cuda/init.cpp
similarity index 83%
rename from flang-rt/lib/flang_rt/CUDA/init.cpp
rename to flang-rt/lib/cuda/init.cpp
index f2d47d258519e..d79bffc32424d 100644
--- a/flang-rt/lib/flang_rt/CUDA/init.cpp
+++ b/flang-rt/lib/cuda/init.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/init.cpp ------------------------------*- C++ -*-===//
+//===-- lib/cuda/init.cpp ---------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/init.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/kernel.cpp b/flang-rt/lib/cuda/kernel.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/CUDA/kernel.cpp
rename to flang-rt/lib/cuda/kernel.cpp
index 7f9786319d574..75eb639817b9a 100644
--- a/flang-rt/lib/flang_rt/CUDA/kernel.cpp
+++ b/flang-rt/lib/cuda/kernel.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/kernel.cpp ----------------------------*- C++ -*-===//
+//===-- lib/cuda/kernel.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/kernel.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/memmove-function.cpp b/flang-rt/lib/cuda/memmove-function.cpp
similarity index 91%
rename from flang-rt/lib/flang_rt/CUDA/memmove-function.cpp
rename to flang-rt/lib/cuda/memmove-function.cpp
index ca04e20379d03..a7eb0cf1a3e7a 100644
--- a/flang-rt/lib/flang_rt/CUDA/memmove-function.cpp
+++ b/flang-rt/lib/cuda/memmove-function.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/memmove-function.cpp ------------------*- C++ -*-===//
+//===-- lib/cuda/memmove-function.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/memmove-function.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/memory.cpp b/flang-rt/lib/cuda/memory.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/CUDA/memory.cpp
rename to flang-rt/lib/cuda/memory.cpp
index 3d4a74f5f9e52..7ead0dd35e1d9 100644
--- a/flang-rt/lib/flang_rt/CUDA/memory.cpp
+++ b/flang-rt/lib/cuda/memory.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/memory.cpp ----------------------------*- C++ -*-===//
+//===-- lib/cuda/memory.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/memory.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memmove-function.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/pointer.cpp b/flang-rt/lib/cuda/pointer.cpp
similarity index 92%
rename from flang-rt/lib/flang_rt/CUDA/pointer.cpp
rename to flang-rt/lib/cuda/pointer.cpp
index b6e8033933834..d94e3958b9153 100644
--- a/flang-rt/lib/flang_rt/CUDA/pointer.cpp
+++ b/flang-rt/lib/cuda/pointer.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/pointer.cpp ---------------------------*- C++ -*-===//
+//===-- lib/cuda/pointer.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/pointer.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memmove-function.h"
#include "flang/Runtime/pointer.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/registration.cpp b/flang-rt/lib/cuda/registration.cpp
similarity index 93%
rename from flang-rt/lib/flang_rt/CUDA/registration.cpp
rename to flang-rt/lib/cuda/registration.cpp
index f8a7b197bed3b..60b0e491b6ffd 100644
--- a/flang-rt/lib/flang_rt/CUDA/registration.cpp
+++ b/flang-rt/lib/cuda/registration.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/registration.cpp ----------------------*- C++ -*-===//
+//===-- lib/cuda/registration.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/registration.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/FortranFloat128Math/CMakeLists.txt b/flang-rt/lib/quadmath/CMakeLists.txt
similarity index 94%
rename from flang-rt/lib/FortranFloat128Math/CMakeLists.txt
rename to flang-rt/lib/quadmath/CMakeLists.txt
index c0b2ee32248f8..2eccf23e3d166 100644
--- a/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
+++ b/flang-rt/lib/quadmath/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/FortranFloat128Math/CMakeLists.txt ------------------------------===#
+#===-- lib/quadmath/CMakeLists.txt -----------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
@@ -96,13 +96,13 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
if (WIN32)
# Do not create a FortranFloat128Math library under Windows, the Flang
- # driver never links it. Instead, add the sources to flang_rt itself.
+ # driver never links it. Instead, add the sources to flang_rt.runtime.
target_sources(FortranFloat128MathILib INTERFACE ${sources})
target_compile_definitions(FortranFloat128MathILib INTERFACE HAS_QUADMATHLIB)
else ()
- add_flangrt_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
+ add_flangrt_library(flang_rt.quadmath STATIC INSTALL_WITH_TOOLCHAIN
${sources})
- target_include_directories(FortranFloat128Math PRIVATE
+ target_include_directories(flang_rt.quadmath PRIVATE
"${FLANG_RT_SOURCE_DIR}/lib/flang_rt"
)
endif ()
diff --git a/flang-rt/lib/FortranFloat128Math/acos.cpp b/flang-rt/lib/quadmath/acos.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/acos.cpp
rename to flang-rt/lib/quadmath/acos.cpp
index 7f20654752754..d094121f0f678 100644
--- a/flang-rt/lib/FortranFloat128Math/acos.cpp
+++ b/flang-rt/lib/quadmath/acos.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/acos.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/acos.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/acosh.cpp b/flang-rt/lib/quadmath/acosh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/acosh.cpp
rename to flang-rt/lib/quadmath/acosh.cpp
index 73b64230f08c7..968aa489d15a2 100644
--- a/flang-rt/lib/FortranFloat128Math/acosh.cpp
+++ b/flang-rt/lib/quadmath/acosh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/acosh.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/acosh.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/asin.cpp b/flang-rt/lib/quadmath/asin.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/asin.cpp
rename to flang-rt/lib/quadmath/asin.cpp
index b51ecb6b674d3..c3345cd3d748a 100644
--- a/flang-rt/lib/FortranFloat128Math/asin.cpp
+++ b/flang-rt/lib/quadmath/asin.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/asin.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/asin.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/asinh.cpp b/flang-rt/lib/quadmath/asinh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/asinh.cpp
rename to flang-rt/lib/quadmath/asinh.cpp
index 2fc181d075aec..1023b678b6131 100644
--- a/flang-rt/lib/FortranFloat128Math/asinh.cpp
+++ b/flang-rt/lib/quadmath/asinh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/asinh.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/asinh.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/atan.cpp b/flang-rt/lib/quadmath/atan.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/atan.cpp
rename to flang-rt/lib/quadmath/atan.cpp
index ff1ec39bfdebd..6379df3275c03 100644
--- a/flang-rt/lib/FortranFloat128Math/atan.cpp
+++ b/flang-rt/lib/quadmath/atan.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/atan.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/atan.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/atan2.cpp b/flang-rt/lib/quadmath/atan2.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/atan2.cpp
rename to flang-rt/lib/quadmath/atan2.cpp
index 4e809cb547a1b..7527b224cb3a5 100644
--- a/flang-rt/lib/FortranFloat128Math/atan2.cpp
+++ b/flang-rt/lib/quadmath/atan2.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/atan2.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/atan2.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/atanh.cpp b/flang-rt/lib/quadmath/atanh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/atanh.cpp
rename to flang-rt/lib/quadmath/atanh.cpp
index d4e3e7426b16d..c7455fcb7ca67 100644
--- a/flang-rt/lib/FortranFloat128Math/atanh.cpp
+++ b/flang-rt/lib/quadmath/atanh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/atanh.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/atanh.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/ceil.cpp b/flang-rt/lib/quadmath/ceil.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/ceil.cpp
rename to flang-rt/lib/quadmath/ceil.cpp
index f439f22c0565a..03a98bedfdc03 100644
--- a/flang-rt/lib/FortranFloat128Math/ceil.cpp
+++ b/flang-rt/lib/quadmath/ceil.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/ceil.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/ceil.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/complex-math.c b/flang-rt/lib/quadmath/complex-math.c
similarity index 100%
rename from flang-rt/lib/FortranFloat128Math/complex-math.c
rename to flang-rt/lib/quadmath/complex-math.c
diff --git a/flang-rt/lib/FortranFloat128Math/complex-math.h b/flang-rt/lib/quadmath/complex-math.h
similarity index 88%
rename from flang-rt/lib/FortranFloat128Math/complex-math.h
rename to flang-rt/lib/quadmath/complex-math.h
index d22598d52e832..d0c53935b30c3 100644
--- a/flang-rt/lib/FortranFloat128Math/complex-math.h
+++ b/flang-rt/lib/quadmath/complex-math.h
@@ -1,4 +1,4 @@
-/*===-- lib/FortranFloat128Math/complex-math.h ----------------------*- C -*-===
+/*===-- lib/quadmath/complex-math.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.
@@ -6,8 +6,8 @@
*
*===----------------------------------------------------------------------===*/
-#ifndef FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
-#define FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
+#ifndef FLANG_RT_QUADMATH_COMPLEX_MATH_H_
+#define FLANG_RT_QUADMATH_COMPLEX_MATH_H_
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
@@ -59,4 +59,4 @@
#error "Float128Math build with glibc>=2.26 is unsupported yet"
#endif
-#endif // FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
+#endif // FLANG_RT_QUADMATH_COMPLEX_MATH_H_
diff --git a/flang-rt/lib/FortranFloat128Math/cos.cpp b/flang-rt/lib/quadmath/cos.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/cos.cpp
rename to flang-rt/lib/quadmath/cos.cpp
index aed337c325836..1116080c53d2a 100644
--- a/flang-rt/lib/FortranFloat128Math/cos.cpp
+++ b/flang-rt/lib/quadmath/cos.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/cos.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/cos.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/cosh.cpp b/flang-rt/lib/quadmath/cosh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/cosh.cpp
rename to flang-rt/lib/quadmath/cosh.cpp
index bddbff766b575..dd5978e5e5f08 100644
--- a/flang-rt/lib/FortranFloat128Math/cosh.cpp
+++ b/flang-rt/lib/quadmath/cosh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/cosh.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/cosh.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/erf.cpp b/flang-rt/lib/quadmath/erf.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/erf.cpp
rename to flang-rt/lib/quadmath/erf.cpp
index a56430040248d..0021b7900f6a1 100644
--- a/flang-rt/lib/FortranFloat128Math/erf.cpp
+++ b/flang-rt/lib/quadmath/erf.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/erf.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/erf.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/erfc.cpp b/flang-rt/lib/quadmath/erfc.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/erfc.cpp
rename to flang-rt/lib/quadmath/erfc.cpp
index 255a2a7b4edac..5b80fb475b3fc 100644
--- a/flang-rt/lib/FortranFloat128Math/erfc.cpp
+++ b/flang-rt/lib/quadmath/erfc.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/erfc.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/erfc.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/exp.cpp b/flang-rt/lib/quadmath/exp.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/exp.cpp
rename to flang-rt/lib/quadmath/exp.cpp
index 9bc87d959cf69..94e444c3b00c7 100644
--- a/flang-rt/lib/FortranFloat128Math/exp.cpp
+++ b/flang-rt/lib/quadmath/exp.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/exp.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/exp.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/exponent.cpp b/flang-rt/lib/quadmath/exponent.cpp
similarity index 92%
rename from flang-rt/lib/FortranFloat128Math/exponent.cpp
rename to flang-rt/lib/quadmath/exponent.cpp
index bf27a26a73427..0d2fa6478cca8 100644
--- a/flang-rt/lib/FortranFloat128Math/exponent.cpp
+++ b/flang-rt/lib/quadmath/exponent.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/exponent.cpp --------------------*- C++ -*-===//
+//===-- lib/quadmath/exponent.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/floor.cpp b/flang-rt/lib/quadmath/floor.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/floor.cpp
rename to flang-rt/lib/quadmath/floor.cpp
index abda5fadfd296..e5dfb33db82ce 100644
--- a/flang-rt/lib/FortranFloat128Math/floor.cpp
+++ b/flang-rt/lib/quadmath/floor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/floor.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/floor.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/fma.cpp b/flang-rt/lib/quadmath/fma.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/fma.cpp
rename to flang-rt/lib/quadmath/fma.cpp
index 2e7aabedf1e8c..910303af32339 100644
--- a/flang-rt/lib/FortranFloat128Math/fma.cpp
+++ b/flang-rt/lib/quadmath/fma.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/fma.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/fma.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/fraction.cpp b/flang-rt/lib/quadmath/fraction.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/fraction.cpp
rename to flang-rt/lib/quadmath/fraction.cpp
index bf1da6f63e5ce..a9927666a7b00 100644
--- a/flang-rt/lib/FortranFloat128Math/fraction.cpp
+++ b/flang-rt/lib/quadmath/fraction.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/fraction.cpp --------------------*- C++ -*-===//
+//===-- lib/quadmath/fraction.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/hypot.cpp b/flang-rt/lib/quadmath/hypot.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/hypot.cpp
rename to flang-rt/lib/quadmath/hypot.cpp
index 910bda798c1a0..3090d0b2aff74 100644
--- a/flang-rt/lib/FortranFloat128Math/hypot.cpp
+++ b/flang-rt/lib/quadmath/hypot.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/hypot.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/hypot.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/j0.cpp b/flang-rt/lib/quadmath/j0.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/j0.cpp
rename to flang-rt/lib/quadmath/j0.cpp
index d2fac98c3ec69..06df1c2aca452 100644
--- a/flang-rt/lib/FortranFloat128Math/j0.cpp
+++ b/flang-rt/lib/quadmath/j0.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/j0.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/j0.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/j1.cpp b/flang-rt/lib/quadmath/j1.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/j1.cpp
rename to flang-rt/lib/quadmath/j1.cpp
index 60401030124c8..d8a1f123b95e6 100644
--- a/flang-rt/lib/FortranFloat128Math/j1.cpp
+++ b/flang-rt/lib/quadmath/j1.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/j1.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/j1.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/jn.cpp b/flang-rt/lib/quadmath/jn.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/jn.cpp
rename to flang-rt/lib/quadmath/jn.cpp
index 71e11335d0830..a53e305bb8746 100644
--- a/flang-rt/lib/FortranFloat128Math/jn.cpp
+++ b/flang-rt/lib/quadmath/jn.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/jn.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/jn.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/lgamma.cpp b/flang-rt/lib/quadmath/lgamma.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/lgamma.cpp
rename to flang-rt/lib/quadmath/lgamma.cpp
index 1ae4cc4d95d61..b96dff1d0d72a 100644
--- a/flang-rt/lib/FortranFloat128Math/lgamma.cpp
+++ b/flang-rt/lib/quadmath/lgamma.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/lgamma.cpp ----------------------*- C++ -*-===//
+//===-- lib/quadmath/lgamma.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/llround.cpp b/flang-rt/lib/quadmath/llround.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/llround.cpp
rename to flang-rt/lib/quadmath/llround.cpp
index 5bd4cc26dd497..8f2913d390431 100644
--- a/flang-rt/lib/FortranFloat128Math/llround.cpp
+++ b/flang-rt/lib/quadmath/llround.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/llround.cpp ---------------------*- C++ -*-===//
+//===-- lib/quadmath/llround.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/log.cpp b/flang-rt/lib/quadmath/log.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/log.cpp
rename to flang-rt/lib/quadmath/log.cpp
index 414e41ae0ce29..0c489c922a3fc 100644
--- a/flang-rt/lib/FortranFloat128Math/log.cpp
+++ b/flang-rt/lib/quadmath/log.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/log.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/log.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/log10.cpp b/flang-rt/lib/quadmath/log10.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/log10.cpp
rename to flang-rt/lib/quadmath/log10.cpp
index 55db1b1a2dc1f..a2f222e15a147 100644
--- a/flang-rt/lib/FortranFloat128Math/log10.cpp
+++ b/flang-rt/lib/quadmath/log10.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/log10.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/log10.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/lround.cpp b/flang-rt/lib/quadmath/lround.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/lround.cpp
rename to flang-rt/lib/quadmath/lround.cpp
index a0bea49243681..539ee107a3881 100644
--- a/flang-rt/lib/FortranFloat128Math/lround.cpp
+++ b/flang-rt/lib/quadmath/lround.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/lround.cpp ----------------------*- C++ -*-===//
+//===-- lib/quadmath/lround.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/math-entries.h b/flang-rt/lib/quadmath/math-entries.h
similarity index 96%
rename from flang-rt/lib/FortranFloat128Math/math-entries.h
rename to flang-rt/lib/quadmath/math-entries.h
index 72b12a1645c7d..6e47f32cc8a43 100644
--- a/flang-rt/lib/FortranFloat128Math/math-entries.h
+++ b/flang-rt/lib/quadmath/math-entries.h
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/math-entries.h ------------------*- C++ -*-===//
+//===-- lib/quadmath/math-entries.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
-#define FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
+#ifndef FLANG_RT_QUADMATH_MATH_ENTRIES_H_
+#define FLANG_RT_QUADMATH_MATH_ENTRIES_H_
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
#include <cfloat>
@@ -232,4 +232,4 @@ DEFINE_SIMPLE_ALIAS(Yn, ynl)
} // namespace Fortran::runtime
-#endif // FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
+#endif // FLANG_RT_QUADMATH_MATH_ENTRIES_H_
diff --git a/flang-rt/lib/FortranFloat128Math/mod-real.cpp b/flang-rt/lib/quadmath/mod-real.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/mod-real.cpp
rename to flang-rt/lib/quadmath/mod-real.cpp
index beb412f719c52..0230964e3ddc2 100644
--- a/flang-rt/lib/FortranFloat128Math/mod-real.cpp
+++ b/flang-rt/lib/quadmath/mod-real.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/mod-real.cpp --------------------*- C++ -*-===//
+//===-- lib/quadmath/mod-real.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/modulo-real.cpp b/flang-rt/lib/quadmath/modulo-real.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/modulo-real.cpp
rename to flang-rt/lib/quadmath/modulo-real.cpp
index c8160b1d27451..0f28747b86985 100644
--- a/flang-rt/lib/FortranFloat128Math/modulo-real.cpp
+++ b/flang-rt/lib/quadmath/modulo-real.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/modulo-real.cpp -----------------*- C++ -*-===//
+//===-- lib/quadmath/modulo-real.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/nearbyint.cpp b/flang-rt/lib/quadmath/nearbyint.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/nearbyint.cpp
rename to flang-rt/lib/quadmath/nearbyint.cpp
index d572641e2b0d4..3811fc53d1d82 100644
--- a/flang-rt/lib/FortranFloat128Math/nearbyint.cpp
+++ b/flang-rt/lib/quadmath/nearbyint.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/nearbyint.cpp -------------------*- C++ -*-===//
+//===-- lib/quadmath/nearbyint.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/nearest.cpp b/flang-rt/lib/quadmath/nearest.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/nearest.cpp
rename to flang-rt/lib/quadmath/nearest.cpp
index 3e32de7ea9d0a..8c1969a7b596c 100644
--- a/flang-rt/lib/FortranFloat128Math/nearest.cpp
+++ b/flang-rt/lib/quadmath/nearest.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/nearest.cpp ---------------------*- C++ -*-===//
+//===-- lib/quadmath/nearest.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/norm2.cpp b/flang-rt/lib/quadmath/norm2.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/norm2.cpp
rename to flang-rt/lib/quadmath/norm2.cpp
index 8f6b2c87eec32..e98f4007737d1 100644
--- a/flang-rt/lib/FortranFloat128Math/norm2.cpp
+++ b/flang-rt/lib/quadmath/norm2.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/norm2.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/norm2.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
#include "math-entries.h"
#include "numeric-template-specs.h"
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h b/flang-rt/lib/quadmath/numeric-template-specs.h
similarity index 82%
rename from flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
rename to flang-rt/lib/quadmath/numeric-template-specs.h
index e618902b03adc..e215ad70eca14 100644
--- a/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
+++ b/flang-rt/lib/quadmath/numeric-template-specs.h
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/numeric-template-specs.h --------*- C++ -*-===//
+//===-- lib/quadmath/numeric-template-specs.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
-#define FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#ifndef FLANG_RT_QUADMATH_NUMERIC_TEMPLATE_SPECS_H_
+#define FLANG_RT_QUADMATH_NUMERIC_TEMPLATE_SPECS_H_
#include "math-entries.h"
-#include "flang-rt/numeric-templates.h"
+#include "flang-rt/runtime/numeric-templates.h"
namespace Fortran::runtime {
using F128Type = CppTypeFor<TypeCategory::Real, 16>;
@@ -52,4 +52,4 @@ template <> struct SQRTTy<F128Type> {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#endif // FLANG_RT_QUADMATH_NUMERIC_TEMPLATE_SPECS_H_
diff --git a/flang-rt/lib/FortranFloat128Math/pow.cpp b/flang-rt/lib/quadmath/pow.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/pow.cpp
rename to flang-rt/lib/quadmath/pow.cpp
index bbdda217c5108..29c0536254658 100644
--- a/flang-rt/lib/FortranFloat128Math/pow.cpp
+++ b/flang-rt/lib/quadmath/pow.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/pow.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/pow.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/random.cpp b/flang-rt/lib/quadmath/random.cpp
similarity index 85%
rename from flang-rt/lib/FortranFloat128Math/random.cpp
rename to flang-rt/lib/quadmath/random.cpp
index 701f9429fcb6c..a6d22733ebce4 100644
--- a/flang-rt/lib/FortranFloat128Math/random.cpp
+++ b/flang-rt/lib/quadmath/random.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/random.cpp ----------------------*- C++ -*-===//
+//===-- lib/quadmath/random.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
#include "math-entries.h"
#include "numeric-template-specs.h"
-#include "flang-rt/random-templates.h"
+#include "flang-rt/runtime/random-templates.h"
using namespace Fortran::runtime::random;
extern "C" {
diff --git a/flang-rt/lib/FortranFloat128Math/remainder.cpp b/flang-rt/lib/quadmath/remainder.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/remainder.cpp
rename to flang-rt/lib/quadmath/remainder.cpp
index ca4165a357eda..4b68cdd6ac9de 100644
--- a/flang-rt/lib/FortranFloat128Math/remainder.cpp
+++ b/flang-rt/lib/quadmath/remainder.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/remainder.cpp -------------------*- C++ -*-===//
+//===-- lib/quadmath/remainder.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/round.cpp b/flang-rt/lib/quadmath/round.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/round.cpp
rename to flang-rt/lib/quadmath/round.cpp
index 348f7ff8a6771..844338f5e6413 100644
--- a/flang-rt/lib/FortranFloat128Math/round.cpp
+++ b/flang-rt/lib/quadmath/round.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/round.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/round.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/rrspacing.cpp b/flang-rt/lib/quadmath/rrspacing.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/rrspacing.cpp
rename to flang-rt/lib/quadmath/rrspacing.cpp
index 0a87a5c572652..e8613f4d7d7e2 100644
--- a/flang-rt/lib/FortranFloat128Math/rrspacing.cpp
+++ b/flang-rt/lib/quadmath/rrspacing.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/rrspacing.cpp -------------------*- C++ -*-===//
+//===-- lib/quadmath/rrspacing.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/scale.cpp b/flang-rt/lib/quadmath/scale.cpp
similarity index 92%
rename from flang-rt/lib/FortranFloat128Math/scale.cpp
rename to flang-rt/lib/quadmath/scale.cpp
index a316a2a0cd706..3d919f85a4487 100644
--- a/flang-rt/lib/FortranFloat128Math/scale.cpp
+++ b/flang-rt/lib/quadmath/scale.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/scale.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/scale.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/set-exponent.cpp b/flang-rt/lib/quadmath/set-exponent.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/set-exponent.cpp
rename to flang-rt/lib/quadmath/set-exponent.cpp
index 335c68f632f18..d6b582e7c4f38 100644
--- a/flang-rt/lib/FortranFloat128Math/set-exponent.cpp
+++ b/flang-rt/lib/quadmath/set-exponent.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/set-exponent.cpp ----------------*- C++ -*-===//
+//===-- lib/quadmath/set-exponent.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/sin.cpp b/flang-rt/lib/quadmath/sin.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/sin.cpp
rename to flang-rt/lib/quadmath/sin.cpp
index bd5f62808fc31..dcff2f9ce02ca 100644
--- a/flang-rt/lib/FortranFloat128Math/sin.cpp
+++ b/flang-rt/lib/quadmath/sin.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/sin.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/sin.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/sinh.cpp b/flang-rt/lib/quadmath/sinh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/sinh.cpp
rename to flang-rt/lib/quadmath/sinh.cpp
index 07f12d437ed56..3ab7280f705a6 100644
--- a/flang-rt/lib/FortranFloat128Math/sinh.cpp
+++ b/flang-rt/lib/quadmath/sinh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/sinh.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/sinh.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/spacing.cpp b/flang-rt/lib/quadmath/spacing.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/spacing.cpp
rename to flang-rt/lib/quadmath/spacing.cpp
index b10351ab95555..1d7ecdb4852d2 100644
--- a/flang-rt/lib/FortranFloat128Math/spacing.cpp
+++ b/flang-rt/lib/quadmath/spacing.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/spacing.cpp ---------------------*- C++ -*-===//
+//===-- lib/quadmath/spacing.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/sqrt.cpp b/flang-rt/lib/quadmath/sqrt.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/sqrt.cpp
rename to flang-rt/lib/quadmath/sqrt.cpp
index b6fd6eabc267b..6e0d11a6697f0 100644
--- a/flang-rt/lib/FortranFloat128Math/sqrt.cpp
+++ b/flang-rt/lib/quadmath/sqrt.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/sqrt.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/sqrt.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/tan.cpp b/flang-rt/lib/quadmath/tan.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/tan.cpp
rename to flang-rt/lib/quadmath/tan.cpp
index 437c0692191e8..6f09b93060228 100644
--- a/flang-rt/lib/FortranFloat128Math/tan.cpp
+++ b/flang-rt/lib/quadmath/tan.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/tan.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/tan.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/tanh.cpp b/flang-rt/lib/quadmath/tanh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/tanh.cpp
rename to flang-rt/lib/quadmath/tanh.cpp
index 48544d4bb75f4..214a18d5c3778 100644
--- a/flang-rt/lib/FortranFloat128Math/tanh.cpp
+++ b/flang-rt/lib/quadmath/tanh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/tanh.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/tanh.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/tgamma.cpp b/flang-rt/lib/quadmath/tgamma.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/tgamma.cpp
rename to flang-rt/lib/quadmath/tgamma.cpp
index 8d7963caa61c5..2b05a60dcaabb 100644
--- a/flang-rt/lib/FortranFloat128Math/tgamma.cpp
+++ b/flang-rt/lib/quadmath/tgamma.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/tgamma.cpp ----------------------*- C++ -*-===//
+//===-- lib/quadmath/tgamma.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/trunc.cpp b/flang-rt/lib/quadmath/trunc.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/trunc.cpp
rename to flang-rt/lib/quadmath/trunc.cpp
index 4a3dddeb1326c..cd7c27b569fc3 100644
--- a/flang-rt/lib/FortranFloat128Math/trunc.cpp
+++ b/flang-rt/lib/quadmath/trunc.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/trunc.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/trunc.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/y0.cpp b/flang-rt/lib/quadmath/y0.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/y0.cpp
rename to flang-rt/lib/quadmath/y0.cpp
index c5b266b5cec03..9db04277660ad 100644
--- a/flang-rt/lib/FortranFloat128Math/y0.cpp
+++ b/flang-rt/lib/quadmath/y0.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/y0.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/y0.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/y1.cpp b/flang-rt/lib/quadmath/y1.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/y1.cpp
rename to flang-rt/lib/quadmath/y1.cpp
index 8b492c69e3741..92e658195f3d9 100644
--- a/flang-rt/lib/FortranFloat128Math/y1.cpp
+++ b/flang-rt/lib/quadmath/y1.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/y1.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/y1.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/yn.cpp b/flang-rt/lib/quadmath/yn.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/yn.cpp
rename to flang-rt/lib/quadmath/yn.cpp
index cb212b400f6e0..20c0bc9d5218e 100644
--- a/flang-rt/lib/FortranFloat128Math/yn.cpp
+++ b/flang-rt/lib/quadmath/yn.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/yn.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/yn.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/CMakeLists.txt b/flang-rt/lib/runtime/CMakeLists.txt
similarity index 83%
rename from flang-rt/lib/flang_rt/CMakeLists.txt
rename to flang-rt/lib/runtime/CMakeLists.txt
index 4db1a1cbb874f..1fcac510a507b 100644
--- a/flang-rt/lib/flang_rt/CMakeLists.txt
+++ b/flang-rt/lib/runtime/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/flang_rt/CMakeLists.txt -----------------------------------------===#
+#===-- lib/runtime/CMakeLists.txt ------------------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
@@ -128,26 +128,26 @@ endif ()
set(sources ${supported_sources} ${host_sources} ${f128_sources})
if (NOT WIN32)
- add_flangrt_library(flang_rt STATIC
+ add_flangrt_library(flang_rt.runtime STATIC
${sources}
INSTALL_WITH_TOOLCHAIN
ADDITIONAL_HEADERS ${public_headers} ${private_headers}
)
- enable_cuda_compilation(flang_rt "${supported_sources}")
- enable_omp_offload_compilation(flang_rt "${supported_sources}")
+ enable_cuda_compilation(flang_rt.runtime "${supported_sources}")
+ enable_omp_offload_compilation(flang_rt.runtime "${supported_sources}")
# For unittests that depend on flang_rt. Should link to the static version
# of the library.
- add_library(flang_rt.static ALIAS flang_rt)
- add_library(flang_rt.unittest ALIAS flang_rt)
+ add_library(flang_rt.runtime.static ALIAS flang_rt.runtime)
+ add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime)
else()
# Target for building all versions of the runtime
- add_custom_target(flang_rt)
- set_target_properties(flang_rt PROPERTIES FOLDER "Flang-RT/Meta")
+ add_custom_target(flang_rt.runtime)
+ set_target_properties(flang_rt.runtime PROPERTIES FOLDER "Flang-RT/Meta")
- function (add_win_flangrt_library libtype suffix msvc_lib)
- set(name "flang_rt.${suffix}")
+ function (add_win_flangrt_runtime libtype suffix msvc_lib)
+ set(name "flang_rt.runtime.${suffix}")
add_flangrt_library(${name} ${libtype}
${sources}
${ARGN}
@@ -190,10 +190,10 @@ else()
# is CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS which would also export the internal
# C++ symbols and still requires global data symbols to be annotated
# manually.
- add_win_flangrt_library(STATIC static MultiThreaded INSTALL_WITH_TOOLCHAIN)
- add_win_flangrt_library(STATIC static_dbg MultiThreadedDebug INSTALL_WITH_TOOLCHAIN)
- add_win_flangrt_library(STATIC dynamic MultiThreadedDLL INSTALL_WITH_TOOLCHAIN)
- add_win_flangrt_library(STATIC dynamic_dbg MultiThreadedDebugDLL INSTALL_WITH_TOOLCHAIN)
+ add_win_flangrt_runtime(STATIC static MultiThreaded INSTALL_WITH_TOOLCHAIN)
+ add_win_flangrt_runtime(STATIC static_dbg MultiThreadedDebug INSTALL_WITH_TOOLCHAIN)
+ add_win_flangrt_runtime(STATIC dynamic MultiThreadedDLL INSTALL_WITH_TOOLCHAIN)
+ add_win_flangrt_runtime(STATIC dynamic_dbg MultiThreadedDebugDLL INSTALL_WITH_TOOLCHAIN)
# Unittests link against LLVMSupport which is using CMake's default runtime
# library selection, which is either MultiThreadedDLL or MultiThreadedDebugDLL
@@ -201,13 +201,13 @@ else()
if (GENERATOR_IS_MULTI_CONFIG)
# We cannot select an ALIAS library because it may be different
# per configuration. Fallback to CMake's default.
- add_win_flangrt_library(STATIC unittest "" EXCLUDE_FROM_ALL)
+ add_win_flangrt_runtime(STATIC unittest "" EXCLUDE_FROM_ALL)
else ()
string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
if (build_type STREQUAL "debug")
- add_library(flang_rt.unittest ALIAS flang_rt.dynamic_dbg)
+ add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.dynamic_dbg)
else ()
- add_library(flang_rt.unittest ALIAS flang_rt.dynamic)
+ add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.dynamic)
endif ()
endif ()
endif()
diff --git a/flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp b/flang-rt/lib/runtime/ISO_Fortran_binding.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
rename to flang-rt/lib/runtime/ISO_Fortran_binding.cpp
index d9b0bfe9aeb6b..a5f8b357ae0b8 100644
--- a/flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
+++ b/flang-rt/lib/runtime/ISO_Fortran_binding.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/ISO_Fortran_binding.cpp --------------------*- C++ -*-===//
+//===-- lib/runtime/ISO_Fortran_binding.cpp ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,9 +10,9 @@
// as specified in section 18.5.5 of Fortran 2018.
#include "ISO_Fortran_util.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/pointer.h"
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/ISO_Fortran_util.h b/flang-rt/lib/runtime/ISO_Fortran_util.h
similarity index 90%
rename from flang-rt/lib/flang_rt/ISO_Fortran_util.h
rename to flang-rt/lib/runtime/ISO_Fortran_util.h
index 9d4a907e1adde..9bbc03eefc490 100644
--- a/flang-rt/lib/flang_rt/ISO_Fortran_util.h
+++ b/flang-rt/lib/runtime/ISO_Fortran_util.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/ISO_Fortran_util.h -------------------------*- C++ -*-===//
+//===-- lib/runtime/ISO_Fortran_util.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.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_ISO_FORTRAN_UTIL_H_
-#define FLANG_RT_ISO_FORTRAN_UTIL_H_
+#ifndef FLANG_RT_RUNTIME_ISO_FORTRAN_UTIL_H_
+#define FLANG_RT_RUNTIME_ISO_FORTRAN_UTIL_H_
// Internal utils for establishing CFI_cdesc_t descriptors.
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include <cstdlib>
@@ -99,4 +99,4 @@ static inline RT_API_ATTRS void EstablishDescriptor(CFI_cdesc_t *descriptor,
}
}
} // namespace Fortran::ISO
-#endif // FLANG_RT_ISO_FORTRAN_UTIL_H_
+#endif // FLANG_RT_RUNTIME_ISO_FORTRAN_UTIL_H_
diff --git a/flang-rt/lib/flang_rt/allocatable.cpp b/flang-rt/lib/runtime/allocatable.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/allocatable.cpp
rename to flang-rt/lib/runtime/allocatable.cpp
index 63ef99b8a72d1..a51816129199a 100644
--- a/flang-rt/lib/flang_rt/allocatable.cpp
+++ b/flang-rt/lib/runtime/allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/allocatable.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/allocatable.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/allocatable.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
diff --git a/flang-rt/lib/flang_rt/allocator-registry.cpp b/flang-rt/lib/runtime/allocator-registry.cpp
similarity index 89%
rename from flang-rt/lib/flang_rt/allocator-registry.cpp
rename to flang-rt/lib/runtime/allocator-registry.cpp
index 11847de68724d..f8a8daaf8e748 100644
--- a/flang-rt/lib/flang_rt/allocator-registry.cpp
+++ b/flang-rt/lib/runtime/allocator-registry.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/allocator-registry.cpp ---------------------*- C++ -*-===//
+//===-- lib/runtime/allocator-registry.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/terminator.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/array-constructor.cpp b/flang-rt/lib/runtime/array-constructor.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/array-constructor.cpp
rename to flang-rt/lib/runtime/array-constructor.cpp
index d2765c9439b75..7e267e714927f 100644
--- a/flang-rt/lib/flang_rt/array-constructor.cpp
+++ b/flang-rt/lib/runtime/array-constructor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/array-constructor.cpp ----------------------*- C++ -*-===//
+//===-- lib/runtime/array-constructor.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/array-constructor.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/array-constructor.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/assign.h"
diff --git a/flang-rt/lib/flang_rt/assign.cpp b/flang-rt/lib/runtime/assign.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/assign.cpp
rename to flang-rt/lib/runtime/assign.cpp
index 0d6045eac503a..a1f3715f278c1 100644
--- a/flang-rt/lib/flang_rt/assign.cpp
+++ b/flang-rt/lib/runtime/assign.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/assign.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/assign.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/assign.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/buffer.cpp b/flang-rt/lib/runtime/buffer.cpp
similarity index 90%
rename from flang-rt/lib/flang_rt/buffer.cpp
rename to flang-rt/lib/runtime/buffer.cpp
index e084155068bc5..4cf85e13b6d36 100644
--- a/flang-rt/lib/flang_rt/buffer.cpp
+++ b/flang-rt/lib/runtime/buffer.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/buffer.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/buffer.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/buffer.h"
+#include "flang-rt/runtime/buffer.h"
#include <algorithm>
namespace Fortran::runtime::io {
diff --git a/flang-rt/lib/flang_rt/character.cpp b/flang-rt/lib/runtime/character.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/character.cpp
rename to flang-rt/lib/runtime/character.cpp
index 79d4ebdb0afbf..10cf27c37c4d8 100644
--- a/flang-rt/lib/flang_rt/character.cpp
+++ b/flang-rt/lib/runtime/character.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/character.cpp ------------------------------*- C++ -*-===//
+//===-- lib/runtime/character.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/character.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/bit-population-count.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/character.h"
diff --git a/flang-rt/lib/flang_rt/command.cpp b/flang-rt/lib/runtime/command.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/command.cpp
rename to flang-rt/lib/runtime/command.cpp
index 498ae8db17224..8a5a61ac1ad44 100644
--- a/flang-rt/lib/flang_rt/command.cpp
+++ b/flang-rt/lib/runtime/command.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/command.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/command.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/command.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdlib>
#include <limits>
diff --git a/flang-rt/lib/flang_rt/complex-powi.cpp b/flang-rt/lib/runtime/complex-powi.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/complex-powi.cpp
rename to flang-rt/lib/runtime/complex-powi.cpp
index 287bafc422057..a561d114591cf 100644
--- a/flang-rt/lib/flang_rt/complex-powi.cpp
+++ b/flang-rt/lib/runtime/complex-powi.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/complex-powi.cpp ---------------------------*- C++ -*-===//
+//===-- lib/runtime/complex-powi.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/complex-reduction.c b/flang-rt/lib/runtime/complex-reduction.c
similarity index 100%
rename from flang-rt/lib/flang_rt/complex-reduction.c
rename to flang-rt/lib/runtime/complex-reduction.c
diff --git a/flang-rt/lib/flang_rt/complex-reduction.h b/flang-rt/lib/runtime/complex-reduction.h
similarity index 97%
rename from flang-rt/lib/flang_rt/complex-reduction.h
rename to flang-rt/lib/runtime/complex-reduction.h
index 45614ea660573..44c52fb02fa43 100644
--- a/flang-rt/lib/flang_rt/complex-reduction.h
+++ b/flang-rt/lib/runtime/complex-reduction.h
@@ -1,4 +1,4 @@
-/*===-- lib/flang_rt/complex-reduction.h ----------------------------*- C -*-===
+/*===-- lib/runtime/complex-reduction.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.
@@ -11,8 +11,8 @@
* with C++ build compilers that don't support C's _Complex.
*/
-#ifndef FLANG_RT_COMPLEX_REDUCTION_H_
-#define FLANG_RT_COMPLEX_REDUCTION_H_
+#ifndef FLANG_RT_RUNTIME_COMPLEX_REDUCTION_H_
+#define FLANG_RT_RUNTIME_COMPLEX_REDUCTION_H_
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
@@ -155,4 +155,4 @@ void RTNAME(ReduceComplex16DimValue)(
REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));
#endif
-#endif // FLANG_RT_COMPLEX_REDUCTION_H_
+#endif // FLANG_RT_RUNTIME_COMPLEX_REDUCTION_H_
diff --git a/flang-rt/lib/flang_rt/connection.cpp b/flang-rt/lib/runtime/connection.cpp
similarity index 91%
rename from flang-rt/lib/flang_rt/connection.cpp
rename to flang-rt/lib/runtime/connection.cpp
index 1c454b81389ac..2f01dbbb95920 100644
--- a/flang-rt/lib/flang_rt/connection.cpp
+++ b/flang-rt/lib/runtime/connection.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/connection.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/connection.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/connection.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/connection.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/io-stmt.h"
#include <algorithm>
namespace Fortran::runtime::io {
diff --git a/flang-rt/lib/flang_rt/copy.cpp b/flang-rt/lib/runtime/copy.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/copy.cpp
rename to flang-rt/lib/runtime/copy.cpp
index 0ad6946d3161a..5956642dd7258 100644
--- a/flang-rt/lib/flang_rt/copy.cpp
+++ b/flang-rt/lib/runtime/copy.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/copy.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/copy.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,9 +8,9 @@
#include "copy.h"
#include "stack.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Runtime/allocatable.h"
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/copy.h b/flang-rt/lib/runtime/copy.h
similarity index 78%
rename from flang-rt/lib/flang_rt/copy.h
rename to flang-rt/lib/runtime/copy.h
index f4abac323196b..836c9d4a1ef89 100644
--- a/flang-rt/lib/flang_rt/copy.h
+++ b/flang-rt/lib/runtime/copy.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/copy.h -------------------------------------*- C++ -*-===//
+//===-- lib/runtime/copy.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.
@@ -9,10 +9,10 @@
// Utilities that copy data in a type-aware fashion, allocating & duplicating
// allocatable/automatic components of derived types along the way.
-#ifndef FLANG_RT_COPY_H_
-#define FLANG_RT_COPY_H_
+#ifndef FLANG_RT_RUNTIME_COPY_H_
+#define FLANG_RT_RUNTIME_COPY_H_
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
namespace Fortran::runtime {
@@ -22,4 +22,4 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
const Descriptor &from, const SubscriptValue fromAt[], Terminator &);
} // namespace Fortran::runtime
-#endif // FLANG_RT_COPY_H_
+#endif // FLANG_RT_RUNTIME_COPY_H_
diff --git a/flang-rt/lib/flang_rt/derived-api.cpp b/flang-rt/lib/runtime/derived-api.cpp
similarity index 95%
rename from flang-rt/lib/flang_rt/derived-api.cpp
rename to flang-rt/lib/runtime/derived-api.cpp
index 353bc4a83ebd9..884fa8ee7d095 100644
--- a/flang-rt/lib/flang_rt/derived-api.cpp
+++ b/flang-rt/lib/runtime/derived-api.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/derived-api.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/derived-api.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/derived-api.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/derived.cpp b/flang-rt/lib/runtime/derived.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/derived.cpp
rename to flang-rt/lib/runtime/derived.cpp
index cace9e1074e65..87e4b29d08c28 100644
--- a/flang-rt/lib/flang_rt/derived.cpp
+++ b/flang-rt/lib/runtime/derived.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/derived.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/derived.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/descriptor-io.cpp b/flang-rt/lib/runtime/descriptor-io.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/descriptor-io.cpp
rename to flang-rt/lib/runtime/descriptor-io.cpp
index c5cfa4d7fc597..3db1455af52fe 100644
--- a/flang-rt/lib/flang_rt/descriptor-io.cpp
+++ b/flang-rt/lib/runtime/descriptor-io.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/descriptor-io.cpp --------------------------*- C++ -*-===//
+//===-- lib/runtime/descriptor-io.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/descriptor-io.h b/flang-rt/lib/runtime/descriptor-io.h
similarity index 98%
rename from flang-rt/lib/flang_rt/descriptor-io.h
rename to flang-rt/lib/runtime/descriptor-io.h
index 97bedce247d83..dd399164325cb 100644
--- a/flang-rt/lib/flang_rt/descriptor-io.h
+++ b/flang-rt/lib/runtime/descriptor-io.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/descriptor-io.h ----------------------------*- C++ -*-===//
+//===-- lib/runtime/descriptor-io.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_DESCRIPTOR_IO_H_
-#define FLANG_RT_DESCRIPTOR_IO_H_
+#ifndef FLANG_RT_RUNTIME_DESCRIPTOR_IO_H_
+#define FLANG_RT_RUNTIME_DESCRIPTOR_IO_H_
// Implementation of I/O data list item transfers based on descriptors.
// (All I/O items come through here so that the code is exercised for test;
@@ -17,11 +17,11 @@
#include "edit-input.h"
#include "edit-output.h"
#include "unit.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/namelist.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/namelist.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Common/optional.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/cpp-type.h"
@@ -626,4 +626,4 @@ static RT_API_ATTRS bool DescriptorIO(IoStatementState &io,
return false;
}
} // namespace Fortran::runtime::io::descr
-#endif // FLANG_RT_DESCRIPTOR_IO_H_
+#endif // FLANG_RT_RUNTIME_DESCRIPTOR_IO_H_
diff --git a/flang-rt/lib/flang_rt/descriptor.cpp b/flang-rt/lib/runtime/descriptor.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/descriptor.cpp
rename to flang-rt/lib/runtime/descriptor.cpp
index cdf01f12e7134..8241a34a4990c 100644
--- a/flang-rt/lib/flang_rt/descriptor.cpp
+++ b/flang-rt/lib/runtime/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/descriptor.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/descriptor.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "ISO_Fortran_util.h"
#include "memory.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
#include <cassert>
#include <cstdlib>
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/dot-product.cpp b/flang-rt/lib/runtime/dot-product.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/dot-product.cpp
rename to flang-rt/lib/runtime/dot-product.cpp
index ad600a4228463..20612f1876c15 100644
--- a/flang-rt/lib/flang_rt/dot-product.cpp
+++ b/flang-rt/lib/runtime/dot-product.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/dot-product.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/dot-product.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "float.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/reduction.h"
diff --git a/flang-rt/lib/flang_rt/edit-input.cpp b/flang-rt/lib/runtime/edit-input.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/edit-input.cpp
rename to flang-rt/lib/runtime/edit-input.cpp
index 7121f6e42dea6..99a266648f95c 100644
--- a/flang-rt/lib/flang_rt/edit-input.cpp
+++ b/flang-rt/lib/runtime/edit-input.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/edit-input.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/edit-input.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "edit-input.h"
-#include "flang-rt/namelist.h"
-#include "flang-rt/utf.h"
+#include "flang-rt/runtime/namelist.h"
+#include "flang-rt/runtime/utf.h"
#include "flang/Common/optional.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
diff --git a/flang-rt/lib/flang_rt/edit-input.h b/flang-rt/lib/runtime/edit-input.h
similarity index 87%
rename from flang-rt/lib/flang_rt/edit-input.h
rename to flang-rt/lib/runtime/edit-input.h
index fdee0f0e1131e..686cd461b3e34 100644
--- a/flang-rt/lib/flang_rt/edit-input.h
+++ b/flang-rt/lib/runtime/edit-input.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/edit-input.h -------------------------------*- C++ -*-===//
+//===-- lib/runtime/edit-input.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_EDIT_INPUT_H_
-#define FLANG_RT_EDIT_INPUT_H_
+#ifndef FLANG_RT_RUNTIME_EDIT_INPUT_H_
+#define FLANG_RT_RUNTIME_EDIT_INPUT_H_
-#include "flang-rt/format.h"
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-stmt.h"
#include "flang/Decimal/decimal.h"
namespace Fortran::runtime::io {
@@ -50,4 +50,4 @@ extern template RT_API_ATTRS bool EditCharacterInput(
IoStatementState &, const DataEdit &, char32_t *, std::size_t);
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_EDIT_INPUT_H_
+#endif // FLANG_RT_RUNTIME_EDIT_INPUT_H_
diff --git a/flang-rt/lib/flang_rt/edit-output.cpp b/flang-rt/lib/runtime/edit-output.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/edit-output.cpp
rename to flang-rt/lib/runtime/edit-output.cpp
index 096bd4567a42a..36bbc638ff5fc 100644
--- a/flang-rt/lib/flang_rt/edit-output.cpp
+++ b/flang-rt/lib/runtime/edit-output.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/edit-output.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/edit-output.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "edit-output.h"
-#include "flang-rt/emit-encoded.h"
-#include "flang-rt/utf.h"
+#include "flang-rt/runtime/emit-encoded.h"
+#include "flang-rt/runtime/utf.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
#include <algorithm>
diff --git a/flang-rt/lib/flang_rt/edit-output.h b/flang-rt/lib/runtime/edit-output.h
similarity index 95%
rename from flang-rt/lib/flang_rt/edit-output.h
rename to flang-rt/lib/runtime/edit-output.h
index 729f4400bd631..51a47405e49e4 100644
--- a/flang-rt/lib/flang_rt/edit-output.h
+++ b/flang-rt/lib/runtime/edit-output.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/edit-output.h ------------------------------*- C++ -*-===//
+//===-- lib/runtime/edit-output.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_EDIT_OUTPUT_H_
-#define FLANG_RT_EDIT_OUTPUT_H_
+#ifndef FLANG_RT_RUNTIME_EDIT_OUTPUT_H_
+#define FLANG_RT_RUNTIME_EDIT_OUTPUT_H_
// Output data editing templates implementing the FORMAT data editing
// descriptors E, EN, ES, EX, D, F, and G for REAL data (and COMPLEX
@@ -18,8 +18,8 @@
// Drives the same fast binary-to-decimal formatting templates used
// in the f18 front-end.
-#include "flang-rt/format.h"
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-stmt.h"
#include "flang/Common/uint128.h"
#include "flang/Decimal/decimal.h"
@@ -138,4 +138,4 @@ extern template class RealOutputEditing<10>;
extern template class RealOutputEditing<16>;
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_EDIT_OUTPUT_H_
+#endif // FLANG_RT_RUNTIME_EDIT_OUTPUT_H_
diff --git a/flang-rt/lib/flang_rt/environment-default-list.h b/flang-rt/lib/runtime/environment-default-list.h
similarity index 100%
rename from flang-rt/lib/flang_rt/environment-default-list.h
rename to flang-rt/lib/runtime/environment-default-list.h
diff --git a/flang-rt/lib/flang_rt/environment.cpp b/flang-rt/lib/runtime/environment.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/environment.cpp
rename to flang-rt/lib/runtime/environment.cpp
index e3727398b898f..15380ba148df5 100644
--- a/flang-rt/lib/flang_rt/environment.cpp
+++ b/flang-rt/lib/runtime/environment.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/environment.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/environment.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/environment.h"
+#include "flang-rt/runtime/environment.h"
#include "environment-default-list.h"
#include "memory.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/exceptions.cpp b/flang-rt/lib/runtime/exceptions.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/exceptions.cpp
rename to flang-rt/lib/runtime/exceptions.cpp
index f417aa8810f1c..d676a0ad53aa9 100644
--- a/flang-rt/lib/flang_rt/exceptions.cpp
+++ b/flang-rt/lib/runtime/exceptions.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/exceptions.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/exceptions.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
// Runtime exception support.
#include "flang/Runtime/exceptions.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include <cfenv>
#if defined(__aarch64__) && !defined(_WIN32)
#include <fpu_control.h>
diff --git a/flang-rt/lib/flang_rt/execute.cpp b/flang-rt/lib/runtime/execute.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/execute.cpp
rename to flang-rt/lib/runtime/execute.cpp
index 8d56581c12a49..f180da846a32c 100644
--- a/flang-rt/lib/flang_rt/execute.cpp
+++ b/flang-rt/lib/runtime/execute.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/execute.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/execute.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/execute.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdlib>
#include <errno.h>
#include <future>
diff --git a/flang-rt/lib/flang_rt/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/extensions.cpp
rename to flang-rt/lib/runtime/extensions.cpp
index ef205c5aed689..75195c33a6c21 100644
--- a/flang-rt/lib/flang_rt/extensions.cpp
+++ b/flang-rt/lib/runtime/extensions.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/extensions.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/extensions.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,9 +10,9 @@
// extensions that will eventually be implemented in Fortran.
#include "flang/Runtime/extensions.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/command.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/io-api.h"
diff --git a/flang-rt/lib/flang_rt/external-unit.cpp b/flang-rt/lib/runtime/external-unit.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/external-unit.cpp
rename to flang-rt/lib/runtime/external-unit.cpp
index 4be90cbbcc4c8..b8004d6315994 100644
--- a/flang-rt/lib/flang_rt/external-unit.cpp
+++ b/flang-rt/lib/runtime/external-unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/external-unit.cpp --------------------------*- C++ -*-===//
+//===-- lib/runtime/external-unit.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,9 +12,9 @@
#include "unit-map.h"
#include "unit.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/tools.h"
// NOTE: the header files above may define OpenMP declare target
// variables, so they have to be included unconditionally
diff --git a/flang-rt/lib/flang_rt/extrema.cpp b/flang-rt/lib/runtime/extrema.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/extrema.cpp
rename to flang-rt/lib/runtime/extrema.cpp
index 8ecd7fbe91d77..3d84daa380441 100644
--- a/flang-rt/lib/flang_rt/extrema.cpp
+++ b/flang-rt/lib/runtime/extrema.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/extrema.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/extrema.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,7 @@
// and shapes and (for MAXLOC & MINLOC) result integer kinds. Also implements
// NORM2 using common infrastructure.
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
diff --git a/flang-rt/lib/flang_rt/file.cpp b/flang-rt/lib/runtime/file.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/file.cpp
rename to flang-rt/lib/runtime/file.cpp
index c9fcf0f97b718..16e73db488727 100644
--- a/flang-rt/lib/flang_rt/file.cpp
+++ b/flang-rt/lib/runtime/file.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/file.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/file.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/file.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/file.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/magic-numbers.h"
#include <algorithm>
#include <cerrno>
diff --git a/flang-rt/lib/flang_rt/findloc.cpp b/flang-rt/lib/runtime/findloc.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/findloc.cpp
rename to flang-rt/lib/runtime/findloc.cpp
index ac432676f5efc..95986aefb86a4 100644
--- a/flang-rt/lib/flang_rt/findloc.cpp
+++ b/flang-rt/lib/runtime/findloc.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/findloc.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/findloc.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
// Implements FINDLOC for all required operand types and shapes and result
// integer kinds.
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
#include <cinttypes>
diff --git a/flang-rt/lib/flang_rt/format.cpp b/flang-rt/lib/runtime/format.cpp
similarity index 89%
rename from flang-rt/lib/flang_rt/format.cpp
rename to flang-rt/lib/runtime/format.cpp
index abd01b56919a4..ee0059f5f0729 100644
--- a/flang-rt/lib/flang_rt/format.cpp
+++ b/flang-rt/lib/runtime/format.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/format.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/format.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/format-implementation.h"
+#include "flang-rt/runtime/format-implementation.h"
namespace Fortran::runtime::io {
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/flang-rt/lib/flang_rt/inquiry.cpp b/flang-rt/lib/runtime/inquiry.cpp
similarity index 94%
rename from flang-rt/lib/flang_rt/inquiry.cpp
rename to flang-rt/lib/runtime/inquiry.cpp
index e98d3900987dc..b6a7fce7a1e78 100644
--- a/flang-rt/lib/flang_rt/inquiry.cpp
+++ b/flang-rt/lib/runtime/inquiry.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/inquiry.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/inquiry.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,9 +11,9 @@
#include "flang/Runtime/inquiry.h"
#include "copy.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include <algorithm>
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/internal-unit.cpp b/flang-rt/lib/runtime/internal-unit.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/internal-unit.cpp
rename to flang-rt/lib/runtime/internal-unit.cpp
index 12d702de4c598..e344b01e8b34e 100644
--- a/flang-rt/lib/flang_rt/internal-unit.cpp
+++ b/flang-rt/lib/runtime/internal-unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/internal-unit.cpp --------------------------*- C++ -*-===//
+//===-- lib/runtime/internal-unit.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/internal-unit.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/io-error.h"
+#include "flang-rt/runtime/internal-unit.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/io-error.h"
#include "flang/Runtime/freestanding-tools.h"
#include <algorithm>
#include <type_traits>
diff --git a/flang-rt/lib/flang_rt/io-api-common.h b/flang-rt/lib/runtime/io-api-common.h
similarity index 92%
rename from flang-rt/lib/flang_rt/io-api-common.h
rename to flang-rt/lib/runtime/io-api-common.h
index 5e480fdef3483..b91ff9ff16863 100644
--- a/flang-rt/lib/flang_rt/io-api-common.h
+++ b/flang-rt/lib/runtime/io-api-common.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-api-common.h ----------------------------*- C++ -*-===//
+//===-- lib/runtime/io-api-common.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.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_IO_API_COMMON_H_
-#define FLANG_RT_IO_API_COMMON_H_
+#ifndef FLANG_RT_RUNTIME_IO_API_COMMON_H_
+#define FLANG_RT_RUNTIME_IO_API_COMMON_H_
#include "unit.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Common/api-attrs.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/io-api.h"
@@ -94,4 +94,4 @@ RT_API_ATTRS Cookie BeginExternalListIO(
}
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_IO_API_COMMON_H_
+#endif // FLANG_RT_RUNTIME_IO_API_COMMON_H_
diff --git a/flang-rt/lib/flang_rt/io-api-minimal.cpp b/flang-rt/lib/runtime/io-api-minimal.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/io-api-minimal.cpp
rename to flang-rt/lib/runtime/io-api-minimal.cpp
index cd5cf6bd3e699..c706a3aa239a5 100644
--- a/flang-rt/lib/flang_rt/io-api-minimal.cpp
+++ b/flang-rt/lib/runtime/io-api-minimal.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-api-minimal.cpp -------------------------*- C++ -*-===//
+//===-- lib/runtime/io-api-minimal.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,10 +12,10 @@
#include "edit-output.h"
#include "io-api-common.h"
#include "unit.h"
-#include "flang-rt/format.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/io-api.h"
namespace Fortran::runtime::io {
diff --git a/flang-rt/lib/flang_rt/io-api.cpp b/flang-rt/lib/runtime/io-api.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/io-api.cpp
rename to flang-rt/lib/runtime/io-api.cpp
index c904352cba7f5..72041ae429467 100644
--- a/flang-rt/lib/flang_rt/io-api.cpp
+++ b/flang-rt/lib/runtime/io-api.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-api.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/io-api.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -19,13 +19,13 @@
#include "edit-output.h"
#include "io-api-common.h"
#include "unit.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/format.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/optional.h"
#include <cstdlib>
#include <memory>
diff --git a/flang-rt/lib/flang_rt/io-error.cpp b/flang-rt/lib/runtime/io-error.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/io-error.cpp
rename to flang-rt/lib/runtime/io-error.cpp
index b356642c95f85..b350fb66fc25b 100644
--- a/flang-rt/lib/flang_rt/io-error.cpp
+++ b/flang-rt/lib/runtime/io-error.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-error.cpp -------------------------------*- C++ -*-===//
+//===-- lib/runtime/io-error.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/io-error.h"
+#include "flang-rt/runtime/io-error.h"
#include "config.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/magic-numbers.h"
#include <cerrno>
#include <cstdarg>
diff --git a/flang-rt/lib/flang_rt/io-stmt.cpp b/flang-rt/lib/runtime/io-stmt.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/io-stmt.cpp
rename to flang-rt/lib/runtime/io-stmt.cpp
index a07bf70a6593e..b0823ffd9e703 100644
--- a/flang-rt/lib/flang_rt/io-stmt.cpp
+++ b/flang-rt/lib/runtime/io-stmt.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-stmt.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/io-stmt.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/io-stmt.h"
#include "unit.h"
-#include "flang-rt/connection.h"
-#include "flang-rt/emit-encoded.h"
-#include "flang-rt/format.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/utf.h"
+#include "flang-rt/runtime/connection.h"
+#include "flang-rt/runtime/emit-encoded.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/utf.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/iostat.cpp b/flang-rt/lib/runtime/iostat.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/iostat.cpp
rename to flang-rt/lib/runtime/iostat.cpp
index ab2fc63cf7b21..0f8bfb884e544 100644
--- a/flang-rt/lib/flang_rt/iostat.cpp
+++ b/flang-rt/lib/runtime/iostat.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/iostat.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/iostat.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/main.cpp b/flang-rt/lib/runtime/main.cpp
similarity index 90%
rename from flang-rt/lib/flang_rt/main.cpp
rename to flang-rt/lib/runtime/main.cpp
index dac7268f82b16..b3f066cda3732 100644
--- a/flang-rt/lib/flang_rt/main.cpp
+++ b/flang-rt/lib/runtime/main.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/main.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/main.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/main.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/terminator.h"
#include <cfenv>
#include <cstdio>
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/matmul-transpose.cpp b/flang-rt/lib/runtime/matmul-transpose.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/matmul-transpose.cpp
rename to flang-rt/lib/runtime/matmul-transpose.cpp
index 307995bb8ab1e..e20abbdddcd30 100644
--- a/flang-rt/lib/flang_rt/matmul-transpose.cpp
+++ b/flang-rt/lib/runtime/matmul-transpose.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/matmul-transpose.cpp -----------------------*- C++ -*-===//
+//===-- lib/runtime/matmul-transpose.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -21,9 +21,9 @@
// to use the faster BLAS routines.
#include "flang/Runtime/matmul-transpose.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/c-or-cpp.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/lib/flang_rt/matmul.cpp b/flang-rt/lib/runtime/matmul.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/matmul.cpp
rename to flang-rt/lib/runtime/matmul.cpp
index c5036e24f86f4..f14cea922d21e 100644
--- a/flang-rt/lib/flang_rt/matmul.cpp
+++ b/flang-rt/lib/runtime/matmul.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/matmul.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/matmul.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,9 +20,9 @@
// Places where BLAS routines could be called are marked as TODO items.
#include "flang/Runtime/matmul.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/c-or-cpp.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/lib/flang_rt/memory.cpp b/flang-rt/lib/runtime/memory.cpp
similarity index 87%
rename from flang-rt/lib/flang_rt/memory.cpp
rename to flang-rt/lib/runtime/memory.cpp
index e09e45898da8e..79c7e33777569 100644
--- a/flang-rt/lib/flang_rt/memory.cpp
+++ b/flang-rt/lib/runtime/memory.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/memory.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/memory.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/freestanding-tools.h"
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/misc-intrinsic.cpp b/flang-rt/lib/runtime/misc-intrinsic.cpp
similarity index 95%
rename from flang-rt/lib/flang_rt/misc-intrinsic.cpp
rename to flang-rt/lib/runtime/misc-intrinsic.cpp
index 1a5bc8114e8ae..b7335e9f6799e 100644
--- a/flang-rt/lib/flang_rt/misc-intrinsic.cpp
+++ b/flang-rt/lib/runtime/misc-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/misc-intrinsic.cpp -------------------------*- C++ -*-===//
+//===-- lib/runtime/misc-intrinsic.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/misc-intrinsic.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/optional.h"
#include <algorithm>
#include <cstdio>
diff --git a/flang-rt/lib/flang_rt/namelist.cpp b/flang-rt/lib/runtime/namelist.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/namelist.cpp
rename to flang-rt/lib/runtime/namelist.cpp
index 4cf1cd2062ac5..b0cf2180fc6d4 100644
--- a/flang-rt/lib/flang_rt/namelist.cpp
+++ b/flang-rt/lib/runtime/namelist.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/namelist.cpp -------------------------------*- C++ -*-===//
+//===-- lib/runtime/namelist.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/namelist.h"
+#include "flang-rt/runtime/namelist.h"
#include "descriptor-io.h"
-#include "flang-rt/emit-encoded.h"
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/emit-encoded.h"
+#include "flang-rt/runtime/io-stmt.h"
#include "flang/Runtime/io-api.h"
#include <algorithm>
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/non-tbp-dio.cpp b/flang-rt/lib/runtime/non-tbp-dio.cpp
similarity index 86%
rename from flang-rt/lib/flang_rt/non-tbp-dio.cpp
rename to flang-rt/lib/runtime/non-tbp-dio.cpp
index 5663c2ee338d7..72101b06e0c6e 100644
--- a/flang-rt/lib/flang_rt/non-tbp-dio.cpp
+++ b/flang-rt/lib/runtime/non-tbp-dio.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/non-tbp-dio.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/non-tbp-dio.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/non-tbp-dio.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/non-tbp-dio.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime::io {
diff --git a/flang-rt/lib/flang_rt/numeric.cpp b/flang-rt/lib/runtime/numeric.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/numeric.cpp
rename to flang-rt/lib/runtime/numeric.cpp
index b63c604cadcfb..37638765dc650 100644
--- a/flang-rt/lib/flang_rt/numeric.cpp
+++ b/flang-rt/lib/runtime/numeric.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/numeric.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/numeric.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/numeric.h"
-#include "flang-rt/numeric-templates.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/numeric-templates.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/float128.h"
#include <cfloat>
#include <climits>
diff --git a/flang-rt/lib/flang_rt/pointer.cpp b/flang-rt/lib/runtime/pointer.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/pointer.cpp
rename to flang-rt/lib/runtime/pointer.cpp
index 3138a54f1d122..93ba82e0583c0 100644
--- a/flang-rt/lib/flang_rt/pointer.cpp
+++ b/flang-rt/lib/runtime/pointer.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/pointer.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/pointer.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/pointer.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang-rt/lib/flang_rt/product.cpp b/flang-rt/lib/runtime/product.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/product.cpp
rename to flang-rt/lib/runtime/product.cpp
index c7b6d23d3014e..02fdc2bfcd576 100644
--- a/flang-rt/lib/flang_rt/product.cpp
+++ b/flang-rt/lib/runtime/product.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/product.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/product.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
// Implements PRODUCT for all required operand types and shapes.
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
#include <cfloat>
diff --git a/flang-rt/lib/flang_rt/pseudo-unit.cpp b/flang-rt/lib/runtime/pseudo-unit.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/pseudo-unit.cpp
rename to flang-rt/lib/runtime/pseudo-unit.cpp
index f4d204890581e..7e1f3bc86b294 100644
--- a/flang-rt/lib/flang_rt/pseudo-unit.cpp
+++ b/flang-rt/lib/runtime/pseudo-unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/pseudo-unit.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/pseudo-unit.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,8 +12,8 @@
//===----------------------------------------------------------------------===//
#include "unit.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/tools.h"
// NOTE: the header files above may define OpenMP declare target
// variables, so they have to be included unconditionally
diff --git a/flang-rt/lib/flang_rt/ragged.cpp b/flang-rt/lib/runtime/ragged.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/ragged.cpp
rename to flang-rt/lib/runtime/ragged.cpp
index 798b3464e7bca..dddc3ccdfd858 100644
--- a/flang-rt/lib/flang_rt/ragged.cpp
+++ b/flang-rt/lib/runtime/ragged.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/ragged.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/ragged.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/ragged.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdlib>
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/random.cpp b/flang-rt/lib/runtime/random.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/random.cpp
rename to flang-rt/lib/runtime/random.cpp
index 76971cf3fc888..dc74f2725ed51 100644
--- a/flang-rt/lib/flang_rt/random.cpp
+++ b/flang-rt/lib/runtime/random.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/random.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/random.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,10 +10,10 @@
// RANDOM_SEED.
#include "flang/Runtime/random.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/random-templates.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/random-templates.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Common/float128.h"
#include "flang/Common/leading-zero-bit-count.h"
#include "flang/Common/uint128.h"
diff --git a/flang-rt/lib/flang_rt/reduce.cpp b/flang-rt/lib/runtime/reduce.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/reduce.cpp
rename to flang-rt/lib/runtime/reduce.cpp
index 4bb6dc10ea9da..3c5e815e32d2b 100644
--- a/flang-rt/lib/flang_rt/reduce.cpp
+++ b/flang-rt/lib/runtime/reduce.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/reduce.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/reduce.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,10 +9,10 @@
// REDUCE() implementation
#include "flang/Runtime/reduce.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/reduction-templates.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/reduction-templates.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/reduction.cpp b/flang-rt/lib/runtime/reduction.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/reduction.cpp
rename to flang-rt/lib/runtime/reduction.cpp
index 9ceaeffc6541a..5e45870489479 100644
--- a/flang-rt/lib/flang_rt/reduction.cpp
+++ b/flang-rt/lib/runtime/reduction.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/reduction.cpp ------------------------------*- C++ -*-===//
+//===-- lib/runtime/reduction.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,8 +14,8 @@
// NORM2, MAXLOC, MINLOC, MAXVAL, and MINVAL are in extrema.cpp.
#include "flang/Runtime/reduction.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include <cinttypes>
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/stack.h b/flang-rt/lib/runtime/stack.h
similarity index 93%
rename from flang-rt/lib/flang_rt/stack.h
rename to flang-rt/lib/runtime/stack.h
index 6f37282f00932..38364ff541f16 100644
--- a/flang-rt/lib/flang_rt/stack.h
+++ b/flang-rt/lib/runtime/stack.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/stack.h ------------------------------------*- C++ -*-===//
+//===-- lib/runtime/stack.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.
@@ -10,11 +10,11 @@
// It is a list based stack with dynamic allocation/deallocation
// of the list nodes.
-#ifndef FLANG_RT_STACK_H_
-#define FLANG_RT_STACK_H_
+#ifndef FLANG_RT_RUNTIME_STACK_H_
+#define FLANG_RT_RUNTIME_STACK_H_
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
namespace Fortran::runtime {
// Storage for the Stack elements of type T.
@@ -133,4 +133,4 @@ template <typename T, unsigned N = 0> class Stack : public StackStorage<T, N> {
Terminator &terminator_;
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_STACK_H_
+#endif // FLANG_RT_RUNTIME_STACK_H_
diff --git a/flang-rt/lib/flang_rt/stat.cpp b/flang-rt/lib/runtime/stat.cpp
similarity index 93%
rename from flang-rt/lib/flang_rt/stat.cpp
rename to flang-rt/lib/runtime/stat.cpp
index 883e85d0fbf2f..322b7282b7024 100644
--- a/flang-rt/lib/flang_rt/stat.cpp
+++ b/flang-rt/lib/runtime/stat.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/stat.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/stat.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/stat.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
namespace Fortran::runtime {
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/flang-rt/lib/flang_rt/stop.cpp b/flang-rt/lib/runtime/stop.cpp
similarity index 95%
rename from flang-rt/lib/flang_rt/stop.cpp
rename to flang-rt/lib/runtime/stop.cpp
index 91f8e4a8f6bc1..1d70a137377aa 100644
--- a/flang-rt/lib/flang_rt/stop.cpp
+++ b/flang-rt/lib/runtime/stop.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/stop.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/stop.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,10 +9,10 @@
#include "flang/Runtime/stop.h"
#include "config.h"
#include "unit.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/file.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/file.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/terminator.h"
#include <cfenv>
#include <cstdio>
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/sum.cpp b/flang-rt/lib/runtime/sum.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/sum.cpp
rename to flang-rt/lib/runtime/sum.cpp
index fd98525b8c9b2..a76e228f18a4e 100644
--- a/flang-rt/lib/flang_rt/sum.cpp
+++ b/flang-rt/lib/runtime/sum.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/sum.cpp ------------------------------------*- C++ -*-===//
+//===-- lib/runtime/sum.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
// cancellation on intermediate results by using "Kahan summation"
// (basically the same as manual "double-double").
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
#include <cfloat>
diff --git a/flang-rt/lib/flang_rt/support.cpp b/flang-rt/lib/runtime/support.cpp
similarity index 91%
rename from flang-rt/lib/flang_rt/support.cpp
rename to flang-rt/lib/runtime/support.cpp
index 2673176bd8185..5a2b0c920aa80 100644
--- a/flang-rt/lib/flang_rt/support.cpp
+++ b/flang-rt/lib/runtime/support.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/support.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/support.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,8 +8,8 @@
#include "flang/Runtime/support.h"
#include "ISO_Fortran_util.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang-rt/lib/flang_rt/temporary-stack.cpp b/flang-rt/lib/runtime/temporary-stack.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/temporary-stack.cpp
rename to flang-rt/lib/runtime/temporary-stack.cpp
index 32ec4dacc872d..ea89d0c17bb6b 100644
--- a/flang-rt/lib/flang_rt/temporary-stack.cpp
+++ b/flang-rt/lib/runtime/temporary-stack.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/temporary-stack.cpp ------------------------*- C++ -*-===//
+//===-- lib/runtime/temporary-stack.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,9 +10,9 @@
// temporaries. For use in HLFIR lowering.
#include "flang/Runtime/temporary-stack.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
diff --git a/flang-rt/lib/flang_rt/terminator.cpp b/flang-rt/lib/runtime/terminator.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/terminator.cpp
rename to flang-rt/lib/runtime/terminator.cpp
index 0dfc08eb70370..8a57ba06b1304 100644
--- a/flang-rt/lib/flang_rt/terminator.cpp
+++ b/flang-rt/lib/runtime/terminator.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/terminator.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/terminator.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include <cstdio>
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/time-intrinsic.cpp b/flang-rt/lib/runtime/time-intrinsic.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/time-intrinsic.cpp
rename to flang-rt/lib/runtime/time-intrinsic.cpp
index 1929fccbd4cf3..69c344f5d24bc 100644
--- a/flang-rt/lib/flang_rt/time-intrinsic.cpp
+++ b/flang-rt/lib/runtime/time-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/time-intrinsic.cpp -------------------------*- C++ -*-===//
+//===-- lib/runtime/time-intrinsic.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,9 +9,9 @@
// Implements time-related intrinsic subroutines.
#include "flang/Runtime/time-intrinsic.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/cpp-type.h"
#include <algorithm>
#include <cstdint>
diff --git a/flang-rt/lib/flang_rt/tools.cpp b/flang-rt/lib/runtime/tools.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/tools.cpp
rename to flang-rt/lib/runtime/tools.cpp
index 9b460f81ad5c2..b9d9ca4fc378c 100644
--- a/flang-rt/lib/flang_rt/tools.cpp
+++ b/flang-rt/lib/runtime/tools.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/tools.cpp ----------------------------------*- C++ -*-===//
+//===-- lib/runtime/tools.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/tools.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/terminator.h"
#include <algorithm>
#include <cstdint>
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/transformational.cpp b/flang-rt/lib/runtime/transformational.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/transformational.cpp
rename to flang-rt/lib/runtime/transformational.cpp
index 7453bf18323e9..eb694a9f2c833 100644
--- a/flang-rt/lib/flang_rt/transformational.cpp
+++ b/flang-rt/lib/runtime/transformational.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/transformational.cpp -----------------------*- C++ -*-===//
+//===-- lib/runtime/transformational.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,9 +18,9 @@
#include "flang/Runtime/transformational.h"
#include "copy.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/float128.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/type-code.cpp b/flang-rt/lib/runtime/type-code.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/type-code.cpp
rename to flang-rt/lib/runtime/type-code.cpp
index 432c7591520cb..8cfec9a4ec2fb 100644
--- a/flang-rt/lib/flang_rt/type-code.cpp
+++ b/flang-rt/lib/runtime/type-code.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/type-code.cpp ------------------------------*- C++ -*-===//
+//===-- lib/runtime/type-code.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/type-code.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/type-info.cpp b/flang-rt/lib/runtime/type-info.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/type-info.cpp
rename to flang-rt/lib/runtime/type-info.cpp
index e1859e4864ca1..82182696d70c6 100644
--- a/flang-rt/lib/flang_rt/type-info.cpp
+++ b/flang-rt/lib/runtime/type-info.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/type-info.cpp ------------------------------*- C++ -*-===//
+//===-- lib/runtime/type-info.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/type-info.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/type-info.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdio>
namespace Fortran::runtime::typeInfo {
diff --git a/flang-rt/lib/flang_rt/unit-map.cpp b/flang-rt/lib/runtime/unit-map.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/unit-map.cpp
rename to flang-rt/lib/runtime/unit-map.cpp
index 0fda53ac071b2..41a03f3319d64 100644
--- a/flang-rt/lib/flang_rt/unit-map.cpp
+++ b/flang-rt/lib/runtime/unit-map.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/unit-map.cpp -------------------------------*- C++ -*-===//
+//===-- lib/runtime/unit-map.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/unit-map.h b/flang-rt/lib/runtime/unit-map.h
similarity index 92%
rename from flang-rt/lib/flang_rt/unit-map.h
rename to flang-rt/lib/runtime/unit-map.h
index 64233008b6630..fa61288a1e18d 100644
--- a/flang-rt/lib/flang_rt/unit-map.h
+++ b/flang-rt/lib/runtime/unit-map.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/unit-map.h ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/unit-map.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.
@@ -9,12 +9,12 @@
// Maps Fortran unit numbers to their ExternalFileUnit instances.
// A simple hash table with forward-linked chains per bucket.
-#ifndef FLANG_RT_UNIT_MAP_H_
-#define FLANG_RT_UNIT_MAP_H_
+#ifndef FLANG_RT_RUNTIME_UNIT_MAP_H_
+#define FLANG_RT_RUNTIME_UNIT_MAP_H_
#include "unit.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/memory.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/memory.h"
#include "flang/Common/fast-int-set.h"
#include <cstdint>
#include <cstdlib>
@@ -100,4 +100,4 @@ class UnitMap {
int emergencyNewUnit_{maxNewUnits_}; // not recycled
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_UNIT_MAP_H_
+#endif // FLANG_RT_RUNTIME_UNIT_MAP_H_
diff --git a/flang-rt/lib/flang_rt/unit.cpp b/flang-rt/lib/runtime/unit.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/unit.cpp
rename to flang-rt/lib/runtime/unit.cpp
index f05c4b5236dd5..1d4d54ae01956 100644
--- a/flang-rt/lib/flang_rt/unit.cpp
+++ b/flang-rt/lib/runtime/unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/unit.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/unit.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
#include "unit.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/tools.h"
#include <limits>
#include <utility>
diff --git a/flang-rt/lib/flang_rt/unit.h b/flang-rt/lib/runtime/unit.h
similarity index 95%
rename from flang-rt/lib/flang_rt/unit.h
rename to flang-rt/lib/runtime/unit.h
index a5fb7fb31691f..eb762a2d3b235 100644
--- a/flang-rt/lib/flang_rt/unit.h
+++ b/flang-rt/lib/runtime/unit.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/unit.h -------------------------------------*- C++ -*-===//
+//===-- lib/runtime/unit.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.
@@ -8,19 +8,19 @@
// Fortran external I/O units
-#ifndef FLANG_RT_UNIT_H_
-#define FLANG_RT_UNIT_H_
-
-#include "flang-rt/buffer.h"
-#include "flang-rt/connection.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/file.h"
-#include "flang-rt/format.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
+#ifndef FLANG_RT_RUNTIME_UNIT_H_
+#define FLANG_RT_RUNTIME_UNIT_H_
+
+#include "flang-rt/runtime/buffer.h"
+#include "flang-rt/runtime/connection.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/file.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Common/constexpr-bitset.h"
#include "flang/Common/optional.h"
#include <cstdlib>
@@ -291,4 +291,4 @@ class ChildIo {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_UNIT_H_
+#endif // FLANG_RT_RUNTIME_UNIT_H_
diff --git a/flang-rt/lib/flang_rt/utf.cpp b/flang-rt/lib/runtime/utf.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/utf.cpp
rename to flang-rt/lib/runtime/utf.cpp
index dd74889c025c5..ef9df49f24f66 100644
--- a/flang-rt/lib/flang_rt/utf.cpp
+++ b/flang-rt/lib/runtime/utf.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/utf.cpp ------------------------------------*- C++ -*-===//
+//===-- lib/runtime/utf.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/utf.h"
+#include "flang-rt/runtime/utf.h"
namespace Fortran::runtime {
diff --git a/flang-rt/test/CMakeLists.txt b/flang-rt/test/CMakeLists.txt
index 5ca07b66e4f9b..f5f7b8832d381 100644
--- a/flang-rt/test/CMakeLists.txt
+++ b/flang-rt/test/CMakeLists.txt
@@ -44,8 +44,8 @@ add_custom_target(flang-rt-test-depends)
set_target_properties(flang-rt-test-depends PROPERTIES FOLDER "Flang-RT/Meta")
add_dependencies(flang-rt-test-depends
FlangRTUnitTests
- flang_rt.unittest
- flang_rt.static
+ flang_rt.runtime
+ flang_rt.runtime.unittest
)
add_lit_testsuite(check-flang-rt "Running the Flang-RT regression tests"
diff --git a/flang-rt/test/lit.cfg.py b/flang-rt/test/lit.cfg.py
index 08f3f1121c896..909dbf6eae0ff 100644
--- a/flang-rt/test/lit.cfg.py
+++ b/flang-rt/test/lit.cfg.py
@@ -94,7 +94,7 @@ def shjoin(args, sep=" "):
# Include path for C headers that define Flang's Fortran ABI.
config.substitutions.append(("%include", os.path.join(config.flang_source_dir, "include")))
-# Library path of libflang_rt.a (for lib search path when using non-Flang driver for linking)
+# Library path of libflang_rt.runtime.a (for lib search path when using non-Flang driver for linking)
config.substitutions.append(("%libdir", config.flang_rt_output_resource_lib_dir))
# For CUDA offloading, additional steps (device linking) and libraries (cudart) are needed.
diff --git a/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp b/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
index d1417b715e959..8c0a6f29b6967 100644
--- a/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/flang-rt/unittests/Evaluate/reshape.cpp b/flang-rt/unittests/Evaluate/reshape.cpp
index a45e06ad0f69d..2abe46c0969fb 100644
--- a/flang-rt/unittests/Evaluate/reshape.cpp
+++ b/flang-rt/unittests/Evaluate/reshape.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/transformational.h"
#include "flang/Testing/testing.h"
#include <cinttypes>
diff --git a/flang-rt/unittests/Runtime/Allocatable.cpp b/flang-rt/unittests/Runtime/Allocatable.cpp
index b03003a93fe09..4702f48e0f440 100644
--- a/flang-rt/unittests/Runtime/Allocatable.cpp
+++ b/flang-rt/unittests/Runtime/Allocatable.cpp
@@ -8,7 +8,7 @@
#include "flang/Runtime/allocatable.h"
#include "gtest/gtest.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/tools.h"
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/ArrayConstructor.cpp b/flang-rt/unittests/Runtime/ArrayConstructor.cpp
index 5c84cd162a293..5f791e7f4a7c3 100644
--- a/flang-rt/unittests/Runtime/ArrayConstructor.cpp
+++ b/flang-rt/unittests/Runtime/ArrayConstructor.cpp
@@ -8,9 +8,9 @@
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/array-constructor.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/array-constructor.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/unittests/Runtime/BufferTest.cpp b/flang-rt/unittests/Runtime/BufferTest.cpp
index 7795a79593eb2..f4b9e901d6fcb 100644
--- a/flang-rt/unittests/Runtime/BufferTest.cpp
+++ b/flang-rt/unittests/Runtime/BufferTest.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/buffer.h"
+#include "flang-rt/runtime/buffer.h"
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
#include <algorithm>
diff --git a/flang-rt/unittests/Runtime/CMakeLists.txt b/flang-rt/unittests/Runtime/CMakeLists.txt
index 32f12b14caca7..d647e690c0680 100644
--- a/flang-rt/unittests/Runtime/CMakeLists.txt
+++ b/flang-rt/unittests/Runtime/CMakeLists.txt
@@ -43,6 +43,6 @@ add_flangrt_unittest(RuntimeTests
)
target_compile_definitions(RuntimeTests PRIVATE NOT_EXE="${LLVM_TOOLS_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}")
-if (FLANG_RT_ENABLE_CUF)
+if (FLANG_RT_INCLUDE_CUF)
add_subdirectory(CUDA)
endif ()
diff --git a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
index db6589990be18..90d4da849552a 100644
--- a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
@@ -9,10 +9,10 @@
#include "flang/Runtime/allocatable.h"
#include "cuda_runtime.h"
#include "gtest/gtest.h"
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Support/Fortran.h"
diff --git a/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 86c13d0dd290c..6e46a80aa8f3c 100644
--- a/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -8,10 +8,10 @@
#include "cuda_runtime.h"
#include "gtest/gtest.h"
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Support/Fortran.h"
diff --git a/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
index 37b117234208c..cd69a6f472873 100644
--- a/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
+++ b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
@@ -14,5 +14,5 @@ add_flangrt_unittest(FlangCufRuntimeTests
target_link_libraries(FlangCufRuntimeTests
PRIVATE
- CufRuntime
+ flang_rt.cuda
)
diff --git a/flang-rt/unittests/Runtime/CUDA/Memory.cpp b/flang-rt/unittests/Runtime/CUDA/Memory.cpp
index 32609795c0169..c43b165509a98 100644
--- a/flang-rt/unittests/Runtime/CUDA/Memory.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Memory.cpp
@@ -10,9 +10,9 @@
#include "cuda_runtime.h"
#include "../tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
diff --git a/flang-rt/unittests/Runtime/CharacterTest.cpp b/flang-rt/unittests/Runtime/CharacterTest.cpp
index 696ab6b06e9e7..83ec9b36d9b0c 100644
--- a/flang-rt/unittests/Runtime/CharacterTest.cpp
+++ b/flang-rt/unittests/Runtime/CharacterTest.cpp
@@ -11,7 +11,7 @@
#include "flang/Runtime/character.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include <cstring>
#include <functional>
#include <tuple>
diff --git a/flang-rt/unittests/Runtime/CommandTest.cpp b/flang-rt/unittests/Runtime/CommandTest.cpp
index a34c329750f39..72fe7629dbbb8 100644
--- a/flang-rt/unittests/Runtime/CommandTest.cpp
+++ b/flang-rt/unittests/Runtime/CommandTest.cpp
@@ -9,7 +9,7 @@
#include "flang/Runtime/command.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/execute.h"
#include "flang/Runtime/extensions.h"
#include "flang/Runtime/main.h"
diff --git a/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp b/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
index 939cc62c433f0..8213edd1f9225 100644
--- a/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
+++ b/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include <cstdarg>
#include <cstdlib>
diff --git a/flang-rt/unittests/Runtime/Derived.cpp b/flang-rt/unittests/Runtime/Derived.cpp
index 2f45dfb80f7fd..3196ba796ad19 100644
--- a/flang-rt/unittests/Runtime/Derived.cpp
+++ b/flang-rt/unittests/Runtime/Derived.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/derived-api.h"
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/ExternalIOTest.cpp b/flang-rt/unittests/Runtime/ExternalIOTest.cpp
index a5481e071916d..c83535ca82bd3 100644
--- a/flang-rt/unittests/Runtime/ExternalIOTest.cpp
+++ b/flang-rt/unittests/Runtime/ExternalIOTest.cpp
@@ -12,7 +12,7 @@
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
diff --git a/flang-rt/unittests/Runtime/Format.cpp b/flang-rt/unittests/Runtime/Format.cpp
index 83650e0f999ac..fe7403f26700b 100644
--- a/flang-rt/unittests/Runtime/Format.cpp
+++ b/flang-rt/unittests/Runtime/Format.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/connection.h"
-#include "flang-rt/format-implementation.h"
-#include "flang-rt/io-error.h"
+#include "flang-rt/runtime/connection.h"
+#include "flang-rt/runtime/format-implementation.h"
+#include "flang-rt/runtime/io-error.h"
#include <optional>
#include <string>
#include <tuple>
diff --git a/flang-rt/unittests/Runtime/Inquiry.cpp b/flang-rt/unittests/Runtime/Inquiry.cpp
index f6097484bd481..e79c037864d9c 100644
--- a/flang-rt/unittests/Runtime/Inquiry.cpp
+++ b/flang-rt/unittests/Runtime/Inquiry.cpp
@@ -9,7 +9,7 @@
#include "flang/Runtime/inquiry.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/type-code.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/flang-rt/unittests/Runtime/ListInputTest.cpp b/flang-rt/unittests/Runtime/ListInputTest.cpp
index 0c6c59d6a325e..310c41a5c3fa5 100644
--- a/flang-rt/unittests/Runtime/ListInputTest.cpp
+++ b/flang-rt/unittests/Runtime/ListInputTest.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/io-error.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/io-error.h"
#include "flang/Runtime/io-api-consts.h"
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/LogicalFormatTest.cpp b/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
index 07f62ee02fc66..bc933292181c1 100644
--- a/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
+++ b/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include <algorithm>
#include <array>
diff --git a/flang-rt/unittests/Runtime/Matmul.cpp b/flang-rt/unittests/Runtime/Matmul.cpp
index 28bf2327da949..1b716fd01fd42 100644
--- a/flang-rt/unittests/Runtime/Matmul.cpp
+++ b/flang-rt/unittests/Runtime/Matmul.cpp
@@ -9,8 +9,8 @@
#include "flang/Runtime/matmul.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/unittests/Runtime/MatmulTranspose.cpp b/flang-rt/unittests/Runtime/MatmulTranspose.cpp
index b06afa29ce28e..cc14ab755505a 100644
--- a/flang-rt/unittests/Runtime/MatmulTranspose.cpp
+++ b/flang-rt/unittests/Runtime/MatmulTranspose.cpp
@@ -8,8 +8,8 @@
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/matmul-transpose.h"
diff --git a/flang-rt/unittests/Runtime/MiscIntrinsic.cpp b/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
index 61b05b31f45a9..c6783381bfc35 100644
--- a/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
+++ b/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
@@ -8,7 +8,7 @@
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/misc-intrinsic.h"
diff --git a/flang-rt/unittests/Runtime/Namelist.cpp b/flang-rt/unittests/Runtime/Namelist.cpp
index d48a0273bf556..040dedb8cd47c 100644
--- a/flang-rt/unittests/Runtime/Namelist.cpp
+++ b/flang-rt/unittests/Runtime/Namelist.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/namelist.h"
+#include "flang-rt/runtime/namelist.h"
#include "CrashHandlerFixture.h"
#include "tools.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include <algorithm>
#include <cinttypes>
diff --git a/flang-rt/unittests/Runtime/NumericalFormatTest.cpp b/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
index a86e6b807fc53..5a8ead48dcef9 100644
--- a/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
+++ b/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include <algorithm>
#include <array>
diff --git a/flang-rt/unittests/Runtime/Pointer.cpp b/flang-rt/unittests/Runtime/Pointer.cpp
index 13f1922e6c5c3..a4645f5b6bf98 100644
--- a/flang-rt/unittests/Runtime/Pointer.cpp
+++ b/flang-rt/unittests/Runtime/Pointer.cpp
@@ -8,8 +8,8 @@
#include "flang/Runtime/pointer.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/tools.h"
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/Random.cpp b/flang-rt/unittests/Runtime/Random.cpp
index dba480cffa9c9..bf4b540e768fd 100644
--- a/flang-rt/unittests/Runtime/Random.cpp
+++ b/flang-rt/unittests/Runtime/Random.cpp
@@ -8,8 +8,8 @@
#include "flang/Runtime/random.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include <cmath>
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/Reduction.cpp b/flang-rt/unittests/Runtime/Reduction.cpp
index cb84512639933..3701a32042c58 100644
--- a/flang-rt/unittests/Runtime/Reduction.cpp
+++ b/flang-rt/unittests/Runtime/Reduction.cpp
@@ -9,8 +9,8 @@
#include "flang/Runtime/reduction.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp b/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
index 23a60d98bf6ad..e716dac2d1203 100644
--- a/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
#include "tools.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/io-api-consts.h"
#include "flang/Runtime/transformational.h"
#include <gtest/gtest.h>
diff --git a/flang-rt/unittests/Runtime/Stop.cpp b/flang-rt/unittests/Runtime/Stop.cpp
index 102fecd1afb22..5d1af20e77de7 100644
--- a/flang-rt/unittests/Runtime/Stop.cpp
+++ b/flang-rt/unittests/Runtime/Stop.cpp
@@ -12,7 +12,7 @@
#include "flang/Runtime/stop.h"
#include "CrashHandlerFixture.h"
-#include "flang-rt/environment.h"
+#include "flang-rt/runtime/environment.h"
#include <cstdlib>
#include <gtest/gtest.h>
diff --git a/flang-rt/unittests/Runtime/Support.cpp b/flang-rt/unittests/Runtime/Support.cpp
index 0159bd74aa60c..c97a6eae3a155 100644
--- a/flang-rt/unittests/Runtime/Support.cpp
+++ b/flang-rt/unittests/Runtime/Support.cpp
@@ -9,7 +9,7 @@
#include "flang/Runtime/support.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/flang-rt/unittests/Runtime/TemporaryStack.cpp b/flang-rt/unittests/Runtime/TemporaryStack.cpp
index d5cb9e5bfb9da..ff8efe123d7cc 100644
--- a/flang-rt/unittests/Runtime/TemporaryStack.cpp
+++ b/flang-rt/unittests/Runtime/TemporaryStack.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/unittests/Runtime/Transformational.cpp b/flang-rt/unittests/Runtime/Transformational.cpp
index 8805613738a60..06df96a3cc45a 100644
--- a/flang-rt/unittests/Runtime/Transformational.cpp
+++ b/flang-rt/unittests/Runtime/Transformational.cpp
@@ -9,7 +9,7 @@
#include "flang/Runtime/transformational.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/float128.h"
#include <vector>
diff --git a/flang-rt/unittests/Runtime/tools.h b/flang-rt/unittests/Runtime/tools.h
index 146aae659c338..36a4c2bd9c8b7 100644
--- a/flang-rt/unittests/Runtime/tools.h
+++ b/flang-rt/unittests/Runtime/tools.h
@@ -10,8 +10,8 @@
#define FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include <cstdint>
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index e8dc3de3577db..97744f0bee069 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -175,18 +175,18 @@ like this:
```
$ flang -v -o example example.o
-"/usr/bin/ld" [...] example.o [...] "-lflang_rt" [...]
+"/usr/bin/ld" [...] example.o [...] "-lflang_rt.runtime" [...]
```
The automatically added libraries are:
-* `flang_rt`: Provides most of the Flang runtime library.
+* `flang_rt.runtime`: Provides most of the Flang runtime library.
If the code is C/C++ based and invokes Fortran routines, one can either use Clang
or Flang as the linker driver. If Clang is used, it will automatically all
required runtime libraries needed by C++ (e.g., for STL) to the linker invocation.
In this case, one has to explicitly provide the Fortran runtime library
-`flang_rt`. An alternative is to use Flang to link.
+`flang_rt.runtime`. An alternative is to use Flang to link.
In this case, it may be required to explicitly supply C++ runtime libraries.
On Darwin, the logical root where the system libraries are located (sysroot)
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index 47ba268b3e763..0523b45966151 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -82,7 +82,7 @@ cmake \
-DLLVM_TARGETS_TO_BUILD=host \
-DLLVM_LIT_ARGS=-v \
-DLLVM_ENABLE_PROJECTS="clang;mlir;flang;openmp" \
- -DLLVM_ENABLE_RUNTIMES="compiler-rt;flang_rt" \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;flang-rt" \
../llvm-project/llvm
ninja
@@ -194,7 +194,7 @@ Flang runtime can be built for accelerators in experimental mode, i.e.
complete enabling is WIP. CUDA and OpenMP target offload builds
are currently supported.
-#### Bootstrapping Build of Flang-RT
+#### Building out-of-tree
##### CUDA build
Clang with NVPTX backend and NVCC compilers are supported.
@@ -250,7 +250,7 @@ code. Note that the packaging of the libraries is different
between [Clang](https://clang.llvm.org/docs/OffloadingDesign.html#linking-target-device-code) and NVCC, so the library must be linked using
compatible compiler drivers.
-#### Building in-tree (bootstrap build)
+#### Building in-tree (bootstrapping build)
One may build Flang runtime library along with building Flang itself
by providing these additional CMake variables on top of the Flang in-tree
build config:
@@ -281,9 +281,9 @@ Or:
Normal `make check-flang` will work with such CMake configuration.
Consider building in parallel using the `-j<jobs>` flag, where `<jobs>` is a
-number low enough for all build jobs to fit into the available RAM. Using
+number sufficiently low for all build jobs to fit into the available RAM. Using
the number of harware threads (`nprocs`) is likely too much for most
-commodity computers.
+commodity machines.
##### OpenMP target offload build
Only Clang compiler is currently supported.
diff --git a/flang/docs/OpenACC-descriptor-management.md b/flang/docs/OpenACC-descriptor-management.md
index 6c147a56894c8..008c57937e23b 100644
--- a/flang/docs/OpenACC-descriptor-management.md
+++ b/flang/docs/OpenACC-descriptor-management.md
@@ -427,7 +427,7 @@ The implementation's behavior may be described as (OpenACC 2.7.2):
All the "is-present" checks and the data actions for the auxiliary pointers must be performed atomically with regards to the present counters bookkeeping.
-The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `flang_rt` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).
+The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `flang_rt.runtime` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).
## TODOs:
diff --git a/flang/docs/ReleaseNotes.md b/flang/docs/ReleaseNotes.md
index 2633b27f0093c..689f5bf58684f 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -38,9 +38,9 @@ page](https://llvm.org/releases/).
* The Fortran Runtime library has been move to a new top-level directory
named "flang-rt". The library was also renamed from `FortranRuntime` to
- `flang_rt`. It now supports the
- LLVM_ENABLE_RUNTIMES mechanism to build flang-rt for multiple target
- triples. libflang_rt.a will now be emitted into Clang's per-target
+ `flang_rt.runtime`. It now supports the
+ LLVM_ENABLE_RUNTIMES mechanism to build Flang-RT for multiple target
+ triples. libflang_rt.runtime.a will now be emitted into Clang's per-target
resource directory (next to libclang_rt.*.*) where it is also found by
Flang's driver.
diff --git a/flang/examples/CMakeLists.txt b/flang/examples/CMakeLists.txt
index 8cc66ddbbbb0e..23c6e790791fb 100644
--- a/flang/examples/CMakeLists.txt
+++ b/flang/examples/CMakeLists.txt
@@ -1,4 +1,6 @@
-add_subdirectory(ExternalHelloWorld)
+if (FLANG_INCLUDE_RUNTIME)
+ add_subdirectory(ExternalHelloWorld)
+endif ()
add_subdirectory(PrintFlangFunctionNames)
add_subdirectory(FlangOmpReport)
add_subdirectory(FeatureList)
diff --git a/flang/examples/ExternalHelloWorld/CMakeLists.txt b/flang/examples/ExternalHelloWorld/CMakeLists.txt
index 213fc462ac2b1..dbb69475976dd 100644
--- a/flang/examples/ExternalHelloWorld/CMakeLists.txt
+++ b/flang/examples/ExternalHelloWorld/CMakeLists.txt
@@ -1,9 +1,9 @@
# This test is not run by default as it requires input.
add_llvm_example(external-hello-world
- external-hello.cpp
+ ${FLANG_RT_SOURCE_DIR}/examples/ExternalHelloWorld/external-hello.cpp
)
target_link_libraries(external-hello-world
PRIVATE
- flang_rt
+ flang_rt.runtime
)
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 2bdcfca4cba85..4e547a200a417 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -72,7 +72,7 @@ function (runtime_source_files outvar)
set(new_sources "")
foreach (source IN LISTS "${outvar}")
- set(new_source "${FLANG_RT_SOURCE_DIR}/lib/flang_rt")
+ set(new_source "${FLANG_RT_SOURCE_DIR}/lib")
cmake_path(APPEND new_source "${ARG_SUBDIR}")
cmake_path(APPEND new_source "${source}")
list(APPEND new_sources "${new_source}")
@@ -260,7 +260,7 @@ set(supported_files
utf.cpp
)
-runtime_source_files(supported_files)
+runtime_source_files(supported_files SUBDIR "runtime")
enable_cuda_compilation(flang_rt "${supported_files}")
enable_omp_offload_compilation("${supported_files}")
@@ -294,39 +294,42 @@ if (NOT TARGET FortranFloat128Math)
endif()
endif()
-runtime_source_files(sources)
+runtime_source_files(sources SUBDIR "runtime")
if (NOT DEFINED MSVC)
- add_flang_library(flang_rt
+ add_flang_library(flang_rt.runtime
${sources}
INSTALL_WITH_TOOLCHAIN
)
else()
- add_flang_library(flang_rt
+ add_flang_library(flang_rt.runtime
${sources}
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
- add_flang_library(flang_rt.static ${sources}
+ add_flang_library(flang_rt.runtime.static ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(flang_rt.static PROPERTIES FOLDER "Flang/Runtime Libraries")
+ set_target_properties(flang_rt.runtime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
- add_flang_library(flang_rt.dynamic ${sources}
+ add_flang_library(flang_rt.runtime.dynamic ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(flang_rt.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
+ set_target_properties(flang_rt.runtime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
- add_flang_library(flang_rt.static_dbg ${sources}
+ add_flang_library(flang_rt.runtime.static_dbg ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(flang_rt.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+ set_target_properties(flang_rt.runtime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
- add_flang_library(flang_rt.dynamic_dbg ${sources}
+ add_flang_library(flang_rt.runtime.dynamic_dbg ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(flang_rt.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
- add_dependencies(flang_rt flang_rt.static flang_rt.dynamic
- flang_rt.static_dbg flang_rt.dynamic_dbg)
+ set_target_properties(flang_rt.runtime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+ add_dependencies(flang_rt.runtime
+ flang_rt.runtime.static
+ flang_rt.runtime.dynamic
+ flang_rt.runtime.static_dbg
+ flang_rt.runtime.dynamic_dbg)
endif()
-set_target_properties(flang_rt PROPERTIES FOLDER "Flang/Runtime Libraries")
+set_target_properties(flang_rt.runtime PROPERTIES FOLDER "Flang/Runtime Libraries")
# If flang_rt is part of a Flang build (and not a separate build) then
# add dependency to make sure that Fortran runtime library is being built after
@@ -336,7 +339,7 @@ set_target_properties(flang_rt PROPERTIES FOLDER "Flang/Runtime Libraries")
# TODO: This is a workaround and should be updated when runtime build procedure
# is changed to a regular runtime build. See discussion in PR #95388.
if (TARGET flang AND TARGET module_files)
- add_dependencies(flang_rt flang module_files)
+ add_dependencies(flang_rt.runtime flang module_files)
endif()
if (FLANG_CUF_RUNTIME)
@@ -345,6 +348,6 @@ endif()
# Compatibility targets.
add_custom_target(flang-rt)
-add_dependencies(flang-rt flang_rt)
+add_dependencies(flang-rt flang_rt.runtime)
add_custom_target(FortranRuntime)
-add_dependencies(FortranRuntime flang_rt)
+add_dependencies(FortranRuntime flang_rt.runtime)
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt
index f202a5a5173e7..aac1f62661810 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/flang/runtime/CUDA/CMakeLists.txt
@@ -8,10 +8,10 @@
include_directories(${CUDAToolkit_INCLUDE_DIRS})
-# libCufRuntime depends on a certain version of CUDA. To be able to have
+# libflang_rt.cuda depends on a certain version of CUDA. To be able to have
# multiple build of this library with different CUDA version, the version is
# added to the library name.
-set(CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR})
+set(CUFRT_LIBNAME flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})
set(sources
allocator.cpp
@@ -24,7 +24,7 @@ set(sources
pointer.cpp
registration.cpp
)
-runtime_source_files(sources SUBDIR "CUDA")
+runtime_source_files(sources SUBDIR "cuda")
add_flang_library(${CUFRT_LIBNAME}
${sources}
@@ -38,6 +38,6 @@ endif()
target_link_libraries(${CUFRT_LIBNAME}
PRIVATE
- flang_rt
+ flang_rt.runtime
${CUDA_RT_TARGET}
)
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index e8e8099d4eaf7..3fac8717e9bd9 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -75,7 +75,7 @@ set(FLANG_TEST_DEPENDS
)
if (FLANG_INCLUDE_RUNTIME)
- list(APPEND FLANG_TEST_DEPENDS flang_rt)
+ list(APPEND FLANG_TEST_DEPENDS flang_rt.runtime)
endif ()
if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
diff --git a/flang/test/Driver/gcc-toolchain-install-dir.f90 b/flang/test/Driver/gcc-toolchain-install-dir.f90
index d9160e1971250..e195bdde6d2c9 100644
--- a/flang/test/Driver/gcc-toolchain-install-dir.f90
+++ b/flang/test/Driver/gcc-toolchain-install-dir.f90
@@ -1,5 +1,5 @@
!! Test that --gcc-toolchain and --gcc-install-dir options are working as expected.
-!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libflang_rt, etc. are not supposed to be affected.
+!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libflang_rt.runtime, etc. are not supposed to be affected.
!! PREFIX is captured twice because the driver escapes backslashes (occuring in Windows paths) in the -### output, but not on the "Selected GCC installation:" line.
! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=i386-unknown-linux-gnu --gcc-install-dir=%S/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0 | FileCheck %s --check-prefix=CHECK-I386
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index 5dc89fe45c8cc..2e9dadbfb671b 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -33,26 +33,26 @@
! SOLARIS-F128NONE-NOT: FortranFloat128Math
! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
-! UNIX-SAME: "-lflang_rt" "-lm"
+! UNIX-SAME: "-lflang_rt.runtime" "-lm"
! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
! DARWIN-SAME: "[[object_file]]"
! DARWIN-F128NONE-NOT: FortranFloat128Math
! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! DARWIN-SAME: -lflang_rt
+! DARWIN-SAME: -lflang_rt.runtime
! HAIKU-LABEL: "{{.*}}ld{{(\.exe)?}}"
! HAIKU-SAME: "[[object_file]]"
! HAIKU-F128NONE-NOT: FortranFloat128Math
! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! HAIKU-SAME: "-lflang_rt"
+! HAIKU-SAME: "-lflang_rt.runtime"
! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}"
! MINGW-SAME: "[[object_file]]"
! MINGW-F128NONE-NOT: FortranFloat128Math
! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! MINGW-SAME: -lflang_rt
+! MINGW-SAME: -lflang_rt.runtime
! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
! any .exe suffix that is added when resolving to the full path of
diff --git a/flang/test/Driver/msvc-dependent-lib-flags.f90 b/flang/test/Driver/msvc-dependent-lib-flags.f90
index dabac56d602d1..641c73912c4d1 100644
--- a/flang/test/Driver/msvc-dependent-lib-flags.f90
+++ b/flang/test/Driver/msvc-dependent-lib-flags.f90
@@ -7,21 +7,21 @@
! MSVC-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-SAME: -D_MT
! MSVC-SAME: --dependent-lib=libcmt
-! MSVC-SAME: --dependent-lib=flang_rt.static.lib
+! MSVC-SAME: --dependent-lib=flang_rt.runtime.static.lib
! MSVC-DEBUG: -fc1
! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DEBUG-SAME: -D_MT
! MSVC-DEBUG-SAME: -D_DEBUG
! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
-! MSVC-DEBUG-SAME: --dependent-lib=flang_rt.static_dbg.lib
+! MSVC-DEBUG-SAME: --dependent-lib=flang_rt.runtime.static_dbg.lib
! MSVC-DLL: -fc1
! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DLL-SAME: -D_MT
! MSVC-DLL-SAME: -D_DLL
! MSVC-DLL-SAME: --dependent-lib=msvcrt
-! MSVC-DLL-SAME: --dependent-lib=flang_rt.dynamic.lib
+! MSVC-DLL-SAME: --dependent-lib=flang_rt.runtime.dynamic.lib
! MSVC-DLL-DEBUG: -fc1
! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -29,4 +29,4 @@
! MSVC-DLL-DEBUG-SAME: -D_DEBUG
! MSVC-DLL-DEBUG-SAME: -D_DLL
! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
-! MSVC-DLL-DEBUG-SAME: --dependent-lib=flang_rt.dynamic_dbg.lib
+! MSVC-DLL-DEBUG-SAME: --dependent-lib=flang_rt.runtime.dynamic_dbg.lib
diff --git a/flang/test/Driver/nostdlib.f90 b/flang/test/Driver/nostdlib.f90
index 17ed10fa0615d..dc23be6462376 100644
--- a/flang/test/Driver/nostdlib.f90
+++ b/flang/test/Driver/nostdlib.f90
@@ -24,5 +24,5 @@
! in certain cases. But it is not clear that it is worth checking for each
! platform individually.
-! CHECK-NOT: "-lflang_rt"
+! CHECK-NOT: "-lflang_rt.runtime"
! CHECK-NOT: "-lgcc"
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 9e19b2cdfbb90..2278d61febcb1 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -60,14 +60,14 @@ if (FLANG_INCLUDE_RUNTIME)
NonGTestTesting
FortranSemantics
FortranEvaluate
- flang_rt
+ flang_rt.runtime
)
add_flang_nongtest_unittest(ISO-Fortran-binding
NonGTestTesting
FortranEvaluate
FortranSemantics
- flang_rt
+ flang_rt.runtime
)
endif ()
diff --git a/flang/unittests/Runtime/CMakeLists.txt b/flang/unittests/Runtime/CMakeLists.txt
index 2e87391402744..40afec3e113f3 100644
--- a/flang/unittests/Runtime/CMakeLists.txt
+++ b/flang/unittests/Runtime/CMakeLists.txt
@@ -33,7 +33,7 @@ add_flang_unittest(FlangRuntimeTests
target_link_libraries(FlangRuntimeTests
PRIVATE
- flang_rt
+ flang_rt.runtime
)
target_compile_definitions(FlangRuntimeTests PRIVATE NOT_EXE="$<TARGET_FILE:not>")
diff --git a/flang/unittests/Runtime/CUDA/CMakeLists.txt b/flang/unittests/Runtime/CUDA/CMakeLists.txt
index 762df4b460107..6901da3920a46 100644
--- a/flang/unittests/Runtime/CUDA/CMakeLists.txt
+++ b/flang/unittests/Runtime/CUDA/CMakeLists.txt
@@ -15,8 +15,8 @@ endif()
target_link_libraries(FlangCufRuntimeTests
PRIVATE
${CUDA_RT_TARGET}
- CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
- flang_rt
+ flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR}
+ flang_rt.runtime
)
target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index e188dfb503c1a..baaf06fa021a2 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -50,7 +50,7 @@ AutoExporter::AutoExporter(
"libclang_rt.profile-x86_64",
"libc++",
"libc++abi",
- "libflang_rt",
+ "libflang_rt.runtime",
"libunwind",
"libmsvcrt",
"libucrtbase",
>From f4729e6a2fce9b20bb259f877618099d841cf037 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 3 Feb 2025 13:03:25 +0100
Subject: [PATCH 20/41] Conditionalize runtime example
---
flang/examples/CMakeLists.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/flang/examples/CMakeLists.txt b/flang/examples/CMakeLists.txt
index 8cc66ddbbbb0e..23c6e790791fb 100644
--- a/flang/examples/CMakeLists.txt
+++ b/flang/examples/CMakeLists.txt
@@ -1,4 +1,6 @@
-add_subdirectory(ExternalHelloWorld)
+if (FLANG_INCLUDE_RUNTIME)
+ add_subdirectory(ExternalHelloWorld)
+endif ()
add_subdirectory(PrintFlangFunctionNames)
add_subdirectory(FlangOmpReport)
add_subdirectory(FeatureList)
>From 4303d5ac59c4ed62acff104501a11ee89f4a549a Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 3 Feb 2025 21:09:45 +0100
Subject: [PATCH 21/41] Rename to libflang_rt.<component>.(a|so)
---
clang/lib/Driver/ToolChains/CommonArgs.cpp | 6 +--
clang/lib/Driver/ToolChains/Flang.cpp | 22 +++++----
flang/cmake/modules/AddFlang.cmake | 2 +-
flang/docs/FlangDriver.md | 6 +--
flang/docs/GettingStarted.md | 2 +-
flang/docs/OpenACC-descriptor-management.md | 2 +-
flang/docs/Real16MathSupport.md | 4 +-
flang/docs/ReleaseNotes.md | 7 ++-
.../ExternalHelloWorld/CMakeLists.txt | 2 +-
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 4 +-
flang/runtime/CMakeLists.txt | 47 +++++++++++--------
flang/runtime/CUDA/CMakeLists.txt | 6 +--
flang/runtime/Float128Math/CMakeLists.txt | 14 +++---
flang/runtime/tools.h | 2 +-
flang/test/CMakeLists.txt | 2 +-
.../test/Driver/gcc-toolchain-install-dir.f90 | 2 +-
flang/test/Driver/linker-flags.f90 | 28 +++++------
.../test/Driver/msvc-dependent-lib-flags.f90 | 8 ++--
flang/test/Driver/nostdlib.f90 | 2 +-
flang/test/lit.cfg.py | 2 +-
flang/unittests/Evaluate/CMakeLists.txt | 4 +-
flang/unittests/Runtime/CMakeLists.txt | 2 +-
flang/unittests/Runtime/CUDA/CMakeLists.txt | 4 +-
lld/COFF/MinGW.cpp | 2 +-
24 files changed, 100 insertions(+), 82 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 361cf41544b06..a213a055956ce 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1321,7 +1321,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
/// Add Fortran runtime libs
void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) {
- // Link flang_rt
+ // Link flang_rt.runtime
// These are handled earlier on Windows by telling the frontend driver to
// add the correct libraries to link against as dependents in the object
// file.
@@ -1330,14 +1330,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
F128LibName.consume_front_insensitive("lib");
if (!F128LibName.empty()) {
bool AsNeeded = !TC.getTriple().isOSAIX();
- CmdArgs.push_back("-lFortranFloat128Math");
+ CmdArgs.push_back("-lflang_rt.quadmath");
if (AsNeeded)
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true);
CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName));
if (AsNeeded)
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
}
- CmdArgs.push_back("-lflang_rt");
+ CmdArgs.push_back("-lflang_rt.runtime");
addArchSpecificRPath(TC, Args, CmdArgs);
}
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 87111e18114f5..f6ff58d07e822 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -345,11 +345,15 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
assert(TC.getTriple().isKnownWindowsMSVCEnvironment() &&
"can only add VS runtime library on Windows!");
- // if -fno-fortran-main has been passed, skip linking Fortran_main.a
- if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
- CmdArgs.push_back(Args.MakeArgString(
- "--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));
- }
+
+ // Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
+ // should only depend on msv(u)crt. LLVM still emits libgcc/compiler-rt
+ // functions in some cases like 128-bit integer math (__udivti3, __modti3,
+ // __fixsfti, __floattidf, ...) that msvc does not support. We are injecting a
+ // dependency to Compiler-RT's builtin library where these are implemented.
+ CmdArgs.push_back(Args.MakeArgString(
+ "--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));
+
unsigned RTOptionID = options::OPT__SLASH_MT;
if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
RTOptionID = llvm::StringSwitch<unsigned>(rtl->getValue())
@@ -363,26 +367,26 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
case options::OPT__SLASH_MT:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("--dependent-lib=libcmt");
- CmdArgs.push_back("--dependent-lib=flang_rt.static.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static.lib");
break;
case options::OPT__SLASH_MTd:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DEBUG");
CmdArgs.push_back("--dependent-lib=libcmtd");
- CmdArgs.push_back("--dependent-lib=flang_rt.static_dbg.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static_dbg.lib");
break;
case options::OPT__SLASH_MD:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrt");
- CmdArgs.push_back("--dependent-lib=flang_rt.dynamic.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic.lib");
break;
case options::OPT__SLASH_MDd:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DEBUG");
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrtd");
- CmdArgs.push_back("--dependent-lib=flang_rt.dynamic_dbg.lib");
+ CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic_dbg.lib");
break;
}
}
diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake
index 1f178772067ed..c9f65eb73fef0 100644
--- a/flang/cmake/modules/AddFlang.cmake
+++ b/flang/cmake/modules/AddFlang.cmake
@@ -57,7 +57,7 @@ function(add_flang_library name)
set(LIBTYPE SHARED)
elseif(ARG_STATIC)
# If BUILD_SHARED_LIBS and ARG_STATIC are both set, llvm_add_library prioritizes STATIC.
- # This is required behavior for libFortranFloat128Math.
+ # This is required behavior for libflang_rt.quadmath.
set(LIBTYPE STATIC)
else()
# Let llvm_add_library decide, taking BUILD_SHARED_LIBS into account.
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index e8dc3de3577db..97744f0bee069 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -175,18 +175,18 @@ like this:
```
$ flang -v -o example example.o
-"/usr/bin/ld" [...] example.o [...] "-lflang_rt" [...]
+"/usr/bin/ld" [...] example.o [...] "-lflang_rt.runtime" [...]
```
The automatically added libraries are:
-* `flang_rt`: Provides most of the Flang runtime library.
+* `flang_rt.runtime`: Provides most of the Flang runtime library.
If the code is C/C++ based and invokes Fortran routines, one can either use Clang
or Flang as the linker driver. If Clang is used, it will automatically all
required runtime libraries needed by C++ (e.g., for STL) to the linker invocation.
In this case, one has to explicitly provide the Fortran runtime library
-`flang_rt`. An alternative is to use Flang to link.
+`flang_rt.runtime`. An alternative is to use Flang to link.
In this case, it may be required to explicitly supply C++ runtime libraries.
On Darwin, the logical root where the system libraries are located (sysroot)
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index ffde50b6f481e..e422a31a0b402 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -309,7 +309,7 @@ The same set of CMake variables works for Flang in-tree build.
One may provide optional CMake variables to customize the build. Available options:
* `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath`: enables build of
- `FortranFloat128Math` library that provides `REAL(16)` math APIs
+ `flang_rt.quadmath` library that provides `REAL(16)` math APIs
for intrinsics such as `SIN`, `COS`, etc. GCC `libquadmath`'s header file
`quadmath.h` must be available to the build compiler.
[More details](Real16MathSupport.md).
diff --git a/flang/docs/OpenACC-descriptor-management.md b/flang/docs/OpenACC-descriptor-management.md
index 6c147a56894c8..008c57937e23b 100644
--- a/flang/docs/OpenACC-descriptor-management.md
+++ b/flang/docs/OpenACC-descriptor-management.md
@@ -427,7 +427,7 @@ The implementation's behavior may be described as (OpenACC 2.7.2):
All the "is-present" checks and the data actions for the auxiliary pointers must be performed atomically with regards to the present counters bookkeeping.
-The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `flang_rt` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).
+The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `flang_rt.runtime` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).
## TODOs:
diff --git a/flang/docs/Real16MathSupport.md b/flang/docs/Real16MathSupport.md
index 21482c7be21af..93492c8b767c3 100644
--- a/flang/docs/Real16MathSupport.md
+++ b/flang/docs/Real16MathSupport.md
@@ -12,9 +12,9 @@ To support most `REAL(16)` (i.e. 128-bit float) math intrinsics Flang relies
on third-party libraries providing the implementation.
`-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` CMake option can be used
-to build `FortranFloat128Math` library that has unresolved references
+to build `libflang_rt.quadmath` library that has unresolved references
to GCC `libquadmath` library. A Flang driver built with this option
-will automatically link `FortranFloat128Math` and `libquadmath` libraries
+will automatically link `libflang_rt.quadmath` and `libquadmath` libraries
to any Fortran program. This implies that `libquadmath` library
has to be available in the standard library paths, so that linker
can find it. The `libquadmath` library installation into Flang project
diff --git a/flang/docs/ReleaseNotes.md b/flang/docs/ReleaseNotes.md
index a163b4f4ed67d..387d4b2e62e0f 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -36,7 +36,12 @@ page](https://llvm.org/releases/).
## Build System Changes
- * FortranRuntime has been renamed to `flang_rt`.
+ * The FortranRuntime library has been renamed to `flang_rt.runtime`.
+
+ * The FortranFloat128Math library has been renamed to `flang_rt.quadmath`.
+
+ * The CufRuntime_cuda_${version} library has been renamed to
+ `flang_rt.cuda_${version}`.
## New Issues Found
diff --git a/flang/examples/ExternalHelloWorld/CMakeLists.txt b/flang/examples/ExternalHelloWorld/CMakeLists.txt
index 213fc462ac2b1..b61948718a5e3 100644
--- a/flang/examples/ExternalHelloWorld/CMakeLists.txt
+++ b/flang/examples/ExternalHelloWorld/CMakeLists.txt
@@ -5,5 +5,5 @@ add_llvm_example(external-hello-world
target_link_libraries(external-hello-world
PRIVATE
- flang_rt
+ flang_rt.runtime
)
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index ea78103d78239..d7d1471535db8 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -808,8 +808,8 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
// Generate a call to the Fortran runtime library providing
// support for 128-bit float math.
// On 'HAS_LDBL128' targets the implementation
-// is provided by flang_rt, otherwise, it is done via
-// FortranFloat128Math library. In the latter case the compiler
+// is provided by flang_rt, otherwise, it is done via the
+// libflang_rt.quadmath library. In the latter case the compiler
// has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee
// proper linking actions in the driver.
static mlir::Value genLibF128Call(fir::FirOpBuilder &builder,
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 3e32daba52a81..1186d4b429de4 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -239,9 +239,9 @@ set(supported_files
enable_cuda_compilation(flang_rt "${supported_files}")
enable_omp_offload_compilation("${supported_files}")
-if (NOT TARGET FortranFloat128Math)
- # If FortranFloat128Math is not defined, then we are not building
- # standalone FortranFloat128Math library. Instead, include
+if (NOT TARGET flang_rt.quadmath)
+ # If flang_rt.quadmath is not defined, then we are not building
+ # standalone flang_rt.quadmath library. Instead, include
# the relevant sources into flang_rt itself.
# The information is provided via FortranFloat128MathILib
# interface library.
@@ -270,35 +270,38 @@ if (NOT TARGET FortranFloat128Math)
endif()
if (NOT DEFINED MSVC)
- add_flang_library(flang_rt
+ add_flang_library(flang_rt.runtime
${sources}
INSTALL_WITH_TOOLCHAIN
)
else()
- add_flang_library(flang_rt
+ add_flang_library(flang_rt.runtime
${sources}
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
- add_flang_library(flang_rt.static ${sources}
+ add_flang_library(flang_rt.runtime.static ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(flang_rt.static PROPERTIES FOLDER "Flang/Runtime Libraries")
+ set_target_properties(flang_rt.runtime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
- add_flang_library(flang_rt.dynamic ${sources}
+ add_flang_library(flang_rt.runtime.dynamic ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(flang_rt.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
+ set_target_properties(flang_rt.runtime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
- add_flang_library(flang_rt.static_dbg ${sources}
+ add_flang_library(flang_rt.runtime.static_dbg ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(flang_rt.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+ set_target_properties(flang_rt.runtime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
- add_flang_library(flang_rt.dynamic_dbg ${sources}
+ add_flang_library(flang_rt.runtime.dynamic_dbg ${sources}
INSTALL_WITH_TOOLCHAIN)
- set_target_properties(flang_rt.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
- add_dependencies(flang_rt flang_rt.static flang_rt.dynamic
- flang_rt.static_dbg flang_rt.dynamic_dbg)
+ set_target_properties(flang_rt.runtime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+ add_dependencies(flang_rt.runtime
+ flang_rt.runtime.static
+ flang_rt.runtime.dynamic
+ flang_rt.runtime.static_dbg
+ flang_rt.runtime.dynamic_dbg)
endif()
-set_target_properties(flang_rt PROPERTIES FOLDER "Flang/Runtime Libraries")
+set_target_properties(flang_rt.runtime PROPERTIES FOLDER "Flang/Runtime Libraries")
# If flang_rt is part of a Flang build (and not a separate build) then
# add dependency to make sure that Fortran runtime library is being built after
@@ -308,7 +311,7 @@ set_target_properties(flang_rt PROPERTIES FOLDER "Flang/Runtime Libraries")
# TODO: This is a workaround and should be updated when runtime build procedure
# is changed to a regular runtime build. See discussion in PR #95388.
if (TARGET flang AND TARGET module_files)
- add_dependencies(flang_rt flang module_files)
+ add_dependencies(flang_rt.runtime flang module_files)
endif()
if (FLANG_CUF_RUNTIME)
@@ -317,6 +320,12 @@ endif()
# Compatibility targets.
add_custom_target(flang-rt)
-add_dependencies(flang-rt flang_rt)
+add_dependencies(flang-rt flang_rt.runtime)
+if (TARGET flang_rt.quadmath)
+ add_dependencies(flang-rt flang_rt.quadmath)
+endif ()
+if (TARGET flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})
+ add_dependencies(flang-rt flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})
+endif ()
add_custom_target(FortranRuntime)
-add_dependencies(FortranRuntime flang_rt)
+add_dependencies(FortranRuntime flang_rt.runtime)
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt
index a20f77e427ce6..1fd3bf22a83cf 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/flang/runtime/CUDA/CMakeLists.txt
@@ -8,10 +8,10 @@
include_directories(${CUDAToolkit_INCLUDE_DIRS})
-# libCufRuntime depends on a certain version of CUDA. To be able to have
+# libflang_rt.cuda depends on a certain version of CUDA. To be able to have
# multiple build of this library with different CUDA version, the version is
# added to the library name.
-set(CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR})
+set(CUFRT_LIBNAME flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})
add_flang_library(${CUFRT_LIBNAME}
allocator.cpp
@@ -33,6 +33,6 @@ endif()
target_link_libraries(${CUFRT_LIBNAME}
PRIVATE
- flang_rt
+ flang_rt.runtime
${CUDA_RT_TARGET}
)
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt
index d65193be05ab5..3c382d16a21cd 100644
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ b/flang/runtime/Float128Math/CMakeLists.txt
@@ -12,7 +12,7 @@
# It is distributed as a static library only.
# Fortran programs/libraries that end up linking any of the provided
# will have a dependency on the third-party library that is being
-# used for building this FortranFloat128Math library.
+# used for building this flang_rt.quadmath library.
include(CheckLibraryExists)
@@ -93,20 +93,20 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
)
endif()
- add_flang_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
+ add_flang_library(flang_rt.quadmath STATIC INSTALL_WITH_TOOLCHAIN
${sources})
if (DEFINED MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
- add_flang_library(FortranFloat128Math.static STATIC INSTALL_WITH_TOOLCHAIN
+ add_flang_library(flang_rt.quadmath.static STATIC INSTALL_WITH_TOOLCHAIN
${sources}
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
- add_flang_library(FortranFloat128Math.static_dbg STATIC INSTALL_WITH_TOOLCHAIN
+ add_flang_library(flang_rt.quadmath.static_dbg STATIC INSTALL_WITH_TOOLCHAIN
${sources}
)
- add_dependencies(FortranFloat128Math FortranFloat128Math.static
- FortranFloat128Math.static_dbg
+ add_dependencies(flang_rt.quadmath flang_rt.quadmath.static
+ flang_rt.quadmath.static_dbg
)
endif()
elseif (HAVE_LDBL_MANT_DIG_113)
@@ -118,7 +118,7 @@ elseif (HAVE_LDBL_MANT_DIG_113)
)
target_sources(FortranFloat128MathILib INTERFACE ${sources})
else()
- message(FATAL_ERROR "flang_rt cannot build without libm")
+ message(FATAL_ERROR "flang_rt.quadmath cannot build without libm")
endif()
else()
# We can use '__float128' version from libc, if it has them.
diff --git a/flang/runtime/tools.h b/flang/runtime/tools.h
index facbd23161057..75544098d47ab 100644
--- a/flang/runtime/tools.h
+++ b/flang/runtime/tools.h
@@ -348,7 +348,7 @@ inline RT_API_ATTRS RESULT ApplyFloatingPointKind(
if constexpr (HasCppTypeFor<TypeCategory::Real, 16>) {
// If FUNC implemenation relies on FP math functions,
// then we should not be here. The compiler should have
- // generated a call to an entry in FortranFloat128Math
+ // generated a call to an entry in flang_rt.quadmath
// library.
if constexpr (!NEEDSMATH) {
return FUNC<16>{}(std::forward<A>(x)...);
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index e8e8099d4eaf7..3fac8717e9bd9 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -75,7 +75,7 @@ set(FLANG_TEST_DEPENDS
)
if (FLANG_INCLUDE_RUNTIME)
- list(APPEND FLANG_TEST_DEPENDS flang_rt)
+ list(APPEND FLANG_TEST_DEPENDS flang_rt.runtime)
endif ()
if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
diff --git a/flang/test/Driver/gcc-toolchain-install-dir.f90 b/flang/test/Driver/gcc-toolchain-install-dir.f90
index d9160e1971250..e195bdde6d2c9 100644
--- a/flang/test/Driver/gcc-toolchain-install-dir.f90
+++ b/flang/test/Driver/gcc-toolchain-install-dir.f90
@@ -1,5 +1,5 @@
!! Test that --gcc-toolchain and --gcc-install-dir options are working as expected.
-!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libflang_rt, etc. are not supposed to be affected.
+!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libflang_rt.runtime, etc. are not supposed to be affected.
!! PREFIX is captured twice because the driver escapes backslashes (occuring in Windows paths) in the -### output, but not on the "Selected GCC installation:" line.
! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=i386-unknown-linux-gnu --gcc-install-dir=%S/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0 | FileCheck %s --check-prefix=CHECK-I386
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index 5dc89fe45c8cc..0b6eff8043247 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -29,30 +29,30 @@
! executable and may find the GNU linker from MinGW or Cygwin.
! UNIX-LABEL: "{{.*}}ld{{(\.exe)?}}"
! UNIX-SAME: "[[object_file]]"
-! UNIX-F128NONE-NOT: FortranFloat128Math
-! SOLARIS-F128NONE-NOT: FortranFloat128Math
-! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
-! UNIX-SAME: "-lflang_rt" "-lm"
+! UNIX-F128NONE-NOT: libflang_rt.quadmath
+! SOLARIS-F128NONE-NOT: libflang_rt.quadmath
+! UNIX-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
+! SOLARIS-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "-z" "ignore" "-lquadmath" "-z" "record"
+! UNIX-SAME: "-lflang_rt.runtime" "-lm"
! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
! DARWIN-SAME: "[[object_file]]"
-! DARWIN-F128NONE-NOT: FortranFloat128Math
-! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! DARWIN-SAME: -lflang_rt
+! DARWIN-F128NONE-NOT: libflang_rt.quadmath
+! DARWIN-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
+! DARWIN-SAME: -lflang_rt.runtime
! HAIKU-LABEL: "{{.*}}ld{{(\.exe)?}}"
! HAIKU-SAME: "[[object_file]]"
-! HAIKU-F128NONE-NOT: FortranFloat128Math
-! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! HAIKU-SAME: "-lflang_rt"
+! HAIKU-F128NONE-NOT: libflang_rt.quadmath
+! HAIKU-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
+! HAIKU-SAME: "-lflang_rt.runtime"
! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}"
! MINGW-SAME: "[[object_file]]"
-! MINGW-F128NONE-NOT: FortranFloat128Math
-! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! MINGW-SAME: -lflang_rt
+! MINGW-F128NONE-NOT: libflang_rt.quadmath
+! MINGW-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
+! MINGW-SAME: -lflang_rt.runtime
! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
! any .exe suffix that is added when resolving to the full path of
diff --git a/flang/test/Driver/msvc-dependent-lib-flags.f90 b/flang/test/Driver/msvc-dependent-lib-flags.f90
index dabac56d602d1..641c73912c4d1 100644
--- a/flang/test/Driver/msvc-dependent-lib-flags.f90
+++ b/flang/test/Driver/msvc-dependent-lib-flags.f90
@@ -7,21 +7,21 @@
! MSVC-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-SAME: -D_MT
! MSVC-SAME: --dependent-lib=libcmt
-! MSVC-SAME: --dependent-lib=flang_rt.static.lib
+! MSVC-SAME: --dependent-lib=flang_rt.runtime.static.lib
! MSVC-DEBUG: -fc1
! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DEBUG-SAME: -D_MT
! MSVC-DEBUG-SAME: -D_DEBUG
! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
-! MSVC-DEBUG-SAME: --dependent-lib=flang_rt.static_dbg.lib
+! MSVC-DEBUG-SAME: --dependent-lib=flang_rt.runtime.static_dbg.lib
! MSVC-DLL: -fc1
! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DLL-SAME: -D_MT
! MSVC-DLL-SAME: -D_DLL
! MSVC-DLL-SAME: --dependent-lib=msvcrt
-! MSVC-DLL-SAME: --dependent-lib=flang_rt.dynamic.lib
+! MSVC-DLL-SAME: --dependent-lib=flang_rt.runtime.dynamic.lib
! MSVC-DLL-DEBUG: -fc1
! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -29,4 +29,4 @@
! MSVC-DLL-DEBUG-SAME: -D_DEBUG
! MSVC-DLL-DEBUG-SAME: -D_DLL
! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
-! MSVC-DLL-DEBUG-SAME: --dependent-lib=flang_rt.dynamic_dbg.lib
+! MSVC-DLL-DEBUG-SAME: --dependent-lib=flang_rt.runtime.dynamic_dbg.lib
diff --git a/flang/test/Driver/nostdlib.f90 b/flang/test/Driver/nostdlib.f90
index 17ed10fa0615d..dc23be6462376 100644
--- a/flang/test/Driver/nostdlib.f90
+++ b/flang/test/Driver/nostdlib.f90
@@ -24,5 +24,5 @@
! in certain cases. But it is not clear that it is worth checking for each
! platform individually.
-! CHECK-NOT: "-lflang_rt"
+! CHECK-NOT: "-lflang_rt.runtime"
! CHECK-NOT: "-lgcc"
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index 08ba586e1226d..c6266f3976f7c 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -170,7 +170,7 @@
# the C++ runtime libraries. For this we need a C compiler. If for some reason
# we don't have one, we can just disable the test.
if config.flang_include_runtime and config.cc:
- libruntime = os.path.join(config.flang_lib_dir, "libflang_rt.a")
+ libruntime = os.path.join(config.flang_lib_dir, "libflang_rt.runtime.a")
include = os.path.join(config.flang_src_dir, "include")
if (
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 9e19b2cdfbb90..2278d61febcb1 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -60,14 +60,14 @@ if (FLANG_INCLUDE_RUNTIME)
NonGTestTesting
FortranSemantics
FortranEvaluate
- flang_rt
+ flang_rt.runtime
)
add_flang_nongtest_unittest(ISO-Fortran-binding
NonGTestTesting
FortranEvaluate
FortranSemantics
- flang_rt
+ flang_rt.runtime
)
endif ()
diff --git a/flang/unittests/Runtime/CMakeLists.txt b/flang/unittests/Runtime/CMakeLists.txt
index a60b43d422878..f3743be49b015 100644
--- a/flang/unittests/Runtime/CMakeLists.txt
+++ b/flang/unittests/Runtime/CMakeLists.txt
@@ -33,7 +33,7 @@ add_flang_unittest(FlangRuntimeTests
target_link_libraries(FlangRuntimeTests
PRIVATE
- flang_rt
+ flang_rt.runtime
)
target_compile_definitions(FlangRuntimeTests PRIVATE NOT_EXE="$<TARGET_FILE:not>")
diff --git a/flang/unittests/Runtime/CUDA/CMakeLists.txt b/flang/unittests/Runtime/CUDA/CMakeLists.txt
index 38888e32e6ed8..860b2664d623b 100644
--- a/flang/unittests/Runtime/CUDA/CMakeLists.txt
+++ b/flang/unittests/Runtime/CUDA/CMakeLists.txt
@@ -15,8 +15,8 @@ endif()
target_link_libraries(FlangCufRuntimeTests
PRIVATE
${CUDA_RT_TARGET}
- CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
- flang_rt
+ flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR}
+ flang_rt.runtime
)
target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index e188dfb503c1a..baaf06fa021a2 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -50,7 +50,7 @@ AutoExporter::AutoExporter(
"libclang_rt.profile-x86_64",
"libc++",
"libc++abi",
- "libflang_rt",
+ "libflang_rt.runtime",
"libunwind",
"libmsvcrt",
"libucrtbase",
>From f97c774ef20851e15d3f1cc0d2892ff15896c7d3 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 3 Feb 2025 23:12:11 +0100
Subject: [PATCH 22/41] build fixes
---
clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +-
flang-rt/cmake/modules/AddFlangRT.cmake | 6 +-
.../cmake/modules/AddFlangRTOffload.cmake | 3 +-
.../ExternalHelloWorld/CMakeLists.txt | 2 +-
flang-rt/include/flang-rt/runtime/tools.h | 2 +-
flang-rt/lib/quadmath/CMakeLists.txt | 4 +-
flang-rt/lib/quadmath/complex-math.c | 2 +-
flang-rt/lib/quadmath/complex-math.h | 2 +-
flang-rt/lib/runtime/CMakeLists.txt | 4 +-
flang-rt/test/Runtime/no-cpp-dep.c | 4 +-
flang-rt/unittests/CMakeLists.txt | 6 -
flang-rt/unittests/Evaluate/CMakeLists.txt | 4 +-
flang-rt/unittests/Runtime/CMakeLists.txt | 2 +-
flang/cmake/modules/AddFlang.cmake | 2 +-
flang/docs/GettingStarted.md | 2 +-
flang/docs/Real16MathSupport.md | 4 +-
flang/docs/ReleaseNotes.md | 17 ++-
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 4 +-
flang/runtime/CMakeLists.txt | 15 ++-
flang/runtime/Float128Math/CMakeLists.txt | 115 +++++++++---------
flang/test/Driver/linker-flags.f90 | 20 +--
21 files changed, 113 insertions(+), 109 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index dcfa80602a042..a213a055956ce 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1330,7 +1330,7 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
F128LibName.consume_front_insensitive("lib");
if (!F128LibName.empty()) {
bool AsNeeded = !TC.getTriple().isOSAIX();
- CmdArgs.push_back("-lFortranFloat128Math");
+ CmdArgs.push_back("-lflang_rt.quadmath");
if (AsNeeded)
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true);
CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName));
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index aa8adedf61752..dc96d2b5f0a15 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -6,7 +6,7 @@
#
#===------------------------------------------------------------------------===#
-# Builds a library with common options for flang-rt.
+# Builds a library with common options for Flang-RT.
#
# Usage:
#
@@ -108,11 +108,11 @@ function (add_flangrt_library name)
endif ()
# Flang-RT's public headers
- target_include_directories(${name} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
+ target_include_directories(${name} PUBLIC "${FLANG_RT_SOURCE_DIR}/include")
# For ISO_Fortran_binding.h to be found by the runtime itself (Accessed as #include "flang/ISO_Fortran_binding.h")
# User applications can use #include <ISO_Fortran_binding.h>
- target_include_directories(${name} PRIVATE "${FLANG_SOURCE_DIR}/include")
+ target_include_directories(${name} PUBLIC "${FLANG_SOURCE_DIR}/include")
# For Flang-RT's configured config.h to be found
target_include_directories(${name} PRIVATE "${FLANG_RT_BINARY_DIR}")
diff --git a/flang-rt/cmake/modules/AddFlangRTOffload.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
index df84ed8f4c8d2..4e4bd60c63545 100644
--- a/flang-rt/cmake/modules/AddFlangRTOffload.cmake
+++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
@@ -34,8 +34,7 @@ macro(enable_cuda_compilation name files)
)
endif()
set_source_files_properties(${files} PROPERTIES COMPILE_OPTIONS
- "${CUDA_COMPILE_OPTIONS}"
- )
+ "${CUDA_COMPILE_OPTIONS}")
# Create a .a library consisting of CUDA PTX.
# This is different from a regular static library. The CUDA_PTX_COMPILATION
diff --git a/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt b/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
index e9f347f18cc43..4fd04f8f2769a 100644
--- a/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
+++ b/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
@@ -13,5 +13,5 @@ add_llvm_example(external-hello-world
target_link_libraries(external-hello-world
PRIVATE
- flang_rt.runtime
+ flang_rt.runtime
)
diff --git a/flang-rt/include/flang-rt/runtime/tools.h b/flang-rt/include/flang-rt/runtime/tools.h
index 792aec7710a15..91a026bf2ac14 100644
--- a/flang-rt/include/flang-rt/runtime/tools.h
+++ b/flang-rt/include/flang-rt/runtime/tools.h
@@ -348,7 +348,7 @@ inline RT_API_ATTRS RESULT ApplyFloatingPointKind(
if constexpr (HasCppTypeFor<TypeCategory::Real, 16>) {
// If FUNC implemenation relies on FP math functions,
// then we should not be here. The compiler should have
- // generated a call to an entry in FortranFloat128Math
+ // generated a call to an entry in the libflang_rt.quadmath
// library.
if constexpr (!NEEDSMATH) {
return FUNC<16>{}(std::forward<A>(x)...);
diff --git a/flang-rt/lib/quadmath/CMakeLists.txt b/flang-rt/lib/quadmath/CMakeLists.txt
index 2eccf23e3d166..4f113216b42c8 100644
--- a/flang-rt/lib/quadmath/CMakeLists.txt
+++ b/flang-rt/lib/quadmath/CMakeLists.txt
@@ -12,7 +12,7 @@
# It is distributed as a static library only.
# Fortran programs/libraries that end up linking any of the provided
# will have a dependency on the third-party library that is being
-# used for building this FortranFloat128Math library.
+# used for building this libflang_rt.quadmath library.
include(CheckLibraryExists)
include(CheckIncludeFile)
@@ -95,7 +95,7 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
endif()
if (WIN32)
- # Do not create a FortranFloat128Math library under Windows, the Flang
+ # Do not create a flang_rt.quadmath library under Windows, the Flang
# driver never links it. Instead, add the sources to flang_rt.runtime.
target_sources(FortranFloat128MathILib INTERFACE ${sources})
target_compile_definitions(FortranFloat128MathILib INTERFACE HAS_QUADMATHLIB)
diff --git a/flang-rt/lib/quadmath/complex-math.c b/flang-rt/lib/quadmath/complex-math.c
index fed37dfce6332..e485fd7eb5dbb 100644
--- a/flang-rt/lib/quadmath/complex-math.c
+++ b/flang-rt/lib/quadmath/complex-math.c
@@ -1,4 +1,4 @@
-/*===-- lib/FortranFloat128Math/complex-math.c ----------------------*- C -*-===
+/*===-- lib/quadmath/complex-math.c ---------------------------------*- C -*-===
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
* See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/quadmath/complex-math.h b/flang-rt/lib/quadmath/complex-math.h
index d0c53935b30c3..424ed84da4e01 100644
--- a/flang-rt/lib/quadmath/complex-math.h
+++ b/flang-rt/lib/quadmath/complex-math.h
@@ -59,4 +59,4 @@
#error "Float128Math build with glibc>=2.26 is unsupported yet"
#endif
-#endif // FLANG_RT_QUADMATH_COMPLEX_MATH_H_
+#endif /* FLANG_RT_QUADMATH_COMPLEX_MATH_H_ */
diff --git a/flang-rt/lib/runtime/CMakeLists.txt b/flang-rt/lib/runtime/CMakeLists.txt
index 1fcac510a507b..6340dee2c5c07 100644
--- a/flang-rt/lib/runtime/CMakeLists.txt
+++ b/flang-rt/lib/runtime/CMakeLists.txt
@@ -99,7 +99,7 @@ file(GLOB_RECURSE private_headers
)
-# Import changes from sibling FortranFloat128Math
+# Import changes from flang_rt.quadmath
get_target_property(f128_sources
FortranFloat128MathILib INTERFACE_SOURCES
)
@@ -170,7 +170,7 @@ else()
enable_cuda_compilation(${name} "${supported_sources}")
enable_omp_offload_compilation(${name} "${supported_sources}")
- add_dependencies(flang_rt ${name})
+ add_dependencies(flang_rt.runtime ${name})
endfunction ()
# Variants of the static flang_rt for different versions of the msvc runtime.
diff --git a/flang-rt/test/Runtime/no-cpp-dep.c b/flang-rt/test/Runtime/no-cpp-dep.c
index 2a416bdb27ee2..c98678b69aa14 100644
--- a/flang-rt/test/Runtime/no-cpp-dep.c
+++ b/flang-rt/test/Runtime/no-cpp-dep.c
@@ -1,13 +1,13 @@
/*
This test makes sure that flang's runtime does not depend on the C++ runtime
-library. It tries to link this simple file against libflang_rt.a with
+library. It tries to link this simple file against libflang_rt.runtime.a with
a C compiler.
UNSUPPORTED: system-windows
UNSUPPORTED: offload-cuda
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
-RUN: %cc -std=c99 %s -I%include -L"%libdir" -lflang_rt -lm \
+RUN: %cc -std=c99 %s -I%include -L"%libdir" -lflang_rt.runtime -lm \
RUN: %if system-aix %{-lpthread %}
RUN: rm a.out
*/
diff --git a/flang-rt/unittests/CMakeLists.txt b/flang-rt/unittests/CMakeLists.txt
index ca94805f1403b..e2a50d8b40a9d 100644
--- a/flang-rt/unittests/CMakeLists.txt
+++ b/flang-rt/unittests/CMakeLists.txt
@@ -64,8 +64,6 @@ function(add_flangrt_unittest test_dirname)
add_unittest(FlangRTUnitTests ${test_dirname} ${ARG_UNPARSED_ARGUMENTS})
- target_include_directories(${test_dirname} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
- target_include_directories(${test_dirname} PRIVATE "${FLANG_SOURCE_DIR}/include")
target_link_libraries(${test_dirname} PRIVATE ${ARG_LINK_LIBS})
add_flangrt_unittest_offload_properties(${test_dirname})
@@ -94,10 +92,6 @@ function(add_flangrt_nongtest_unittest test_name)
add_executable(${test_name}${suffix} EXCLUDE_FROM_ALL ${ARG_UNPARSED_ARGUMENTS})
set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Flang-RT/Tests/Unit")
- target_include_directories(${test_name}${suffix} PRIVATE
- "${FLANG_RT_SOURCE_DIR}/include"
- "${FLANG_SOURCE_DIR}/include"
- )
target_link_libraries(${test_name}${suffix} PRIVATE NonGTestTesting ${ARG_LINK_LIBS})
if(NOT ARG_SLOW_TEST)
diff --git a/flang-rt/unittests/Evaluate/CMakeLists.txt b/flang-rt/unittests/Evaluate/CMakeLists.txt
index 15b813bcb19da..526ec234d57da 100644
--- a/flang-rt/unittests/Evaluate/CMakeLists.txt
+++ b/flang-rt/unittests/Evaluate/CMakeLists.txt
@@ -10,12 +10,12 @@ add_flangrt_nongtest_unittest(reshape
reshape.cpp
LINK_LIBS
- flang_rt.unittest
+ flang_rt.runtime.unittest
)
add_flangrt_nongtest_unittest(ISO-Fortran-binding
ISO-Fortran-binding.cpp
LINK_LIBS
- flang_rt.unittest
+ flang_rt.runtime.unittest
)
diff --git a/flang-rt/unittests/Runtime/CMakeLists.txt b/flang-rt/unittests/Runtime/CMakeLists.txt
index d647e690c0680..61d0aba93b14b 100644
--- a/flang-rt/unittests/Runtime/CMakeLists.txt
+++ b/flang-rt/unittests/Runtime/CMakeLists.txt
@@ -39,7 +39,7 @@ add_flangrt_unittest(RuntimeTests
Transformational.cpp
LINK_LIBS
- flang_rt.unittest
+ flang_rt.runtime.unittest
)
target_compile_definitions(RuntimeTests PRIVATE NOT_EXE="${LLVM_TOOLS_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}")
diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake
index 1f178772067ed..c9f65eb73fef0 100644
--- a/flang/cmake/modules/AddFlang.cmake
+++ b/flang/cmake/modules/AddFlang.cmake
@@ -57,7 +57,7 @@ function(add_flang_library name)
set(LIBTYPE SHARED)
elseif(ARG_STATIC)
# If BUILD_SHARED_LIBS and ARG_STATIC are both set, llvm_add_library prioritizes STATIC.
- # This is required behavior for libFortranFloat128Math.
+ # This is required behavior for libflang_rt.quadmath.
set(LIBTYPE STATIC)
else()
# Let llvm_add_library decide, taking BUILD_SHARED_LIBS into account.
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index 0523b45966151..0b3b551ffbfba 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -317,7 +317,7 @@ The same set of CMake variables works for Flang in-tree build.
One may provide optional CMake variables to customize the build. Available options:
* `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath`: enables build of
- `FortranFloat128Math` library that provides `REAL(16)` math APIs
+ `flang_rt.quadmath` library that provides `REAL(16)` math APIs
for intrinsics such as `SIN`, `COS`, etc. GCC `libquadmath`'s header file
`quadmath.h` must be available to the build compiler.
[More details](Real16MathSupport.md).
diff --git a/flang/docs/Real16MathSupport.md b/flang/docs/Real16MathSupport.md
index 21482c7be21af..93492c8b767c3 100644
--- a/flang/docs/Real16MathSupport.md
+++ b/flang/docs/Real16MathSupport.md
@@ -12,9 +12,9 @@ To support most `REAL(16)` (i.e. 128-bit float) math intrinsics Flang relies
on third-party libraries providing the implementation.
`-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` CMake option can be used
-to build `FortranFloat128Math` library that has unresolved references
+to build `libflang_rt.quadmath` library that has unresolved references
to GCC `libquadmath` library. A Flang driver built with this option
-will automatically link `FortranFloat128Math` and `libquadmath` libraries
+will automatically link `libflang_rt.quadmath` and `libquadmath` libraries
to any Fortran program. This implies that `libquadmath` library
has to be available in the standard library paths, so that linker
can find it. The `libquadmath` library installation into Flang project
diff --git a/flang/docs/ReleaseNotes.md b/flang/docs/ReleaseNotes.md
index 689f5bf58684f..9396d956e2233 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -36,13 +36,18 @@ page](https://llvm.org/releases/).
## Build System Changes
+ * The FortranRuntime library has been renamed to `flang_rt.runtime`.
+
+ * The FortranFloat128Math library has been renamed to `flang_rt.quadmath`.
+
+ * The CufRuntime_cuda_${version} library has been renamed to
+ `flang_rt.cuda_${version}`.
+
* The Fortran Runtime library has been move to a new top-level directory
- named "flang-rt". The library was also renamed from `FortranRuntime` to
- `flang_rt.runtime`. It now supports the
- LLVM_ENABLE_RUNTIMES mechanism to build Flang-RT for multiple target
- triples. libflang_rt.runtime.a will now be emitted into Clang's per-target
- resource directory (next to libclang_rt.*.*) where it is also found by
- Flang's driver.
+ named "flang-rt". It now supports the LLVM_ENABLE_RUNTIMES mechanism to
+ build Flang-RT for multiple target triples. libflang_rt.runtime.{a|so} will
+ now be emitted into Clang's per-target resource directory
+ (next to libclang_rt.*.*) where it is also found by Flang's driver.
## New Issues Found
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index ea78103d78239..d7d1471535db8 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -808,8 +808,8 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
// Generate a call to the Fortran runtime library providing
// support for 128-bit float math.
// On 'HAS_LDBL128' targets the implementation
-// is provided by flang_rt, otherwise, it is done via
-// FortranFloat128Math library. In the latter case the compiler
+// is provided by flang_rt, otherwise, it is done via the
+// libflang_rt.quadmath library. In the latter case the compiler
// has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee
// proper linking actions in the driver.
static mlir::Value genLibF128Call(fir::FirOpBuilder &builder,
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 4e547a200a417..04e120cc5d37a 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -259,14 +259,14 @@ set(supported_files
unit.cpp
utf.cpp
)
-
runtime_source_files(supported_files SUBDIR "runtime")
+
enable_cuda_compilation(flang_rt "${supported_files}")
enable_omp_offload_compilation("${supported_files}")
-if (NOT TARGET FortranFloat128Math)
- # If FortranFloat128Math is not defined, then we are not building
- # standalone FortranFloat128Math library. Instead, include
+if (NOT TARGET flang_rt.quadmath)
+ # If flang_rt.quadmath is not defined, then we are not building
+ # standalone flang_rt.quadmath library. Instead, include
# the relevant sources into flang_rt itself.
# The information is provided via FortranFloat128MathILib
# interface library.
@@ -293,7 +293,6 @@ if (NOT TARGET FortranFloat128Math)
list(APPEND sources ${f128_sources})
endif()
endif()
-
runtime_source_files(sources SUBDIR "runtime")
@@ -349,5 +348,11 @@ endif()
# Compatibility targets.
add_custom_target(flang-rt)
add_dependencies(flang-rt flang_rt.runtime)
+if (TARGET flang_rt.quadmath)
+ add_dependencies(flang-rt flang_rt.quadmath)
+endif ()
+if (TARGET flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})
+ add_dependencies(flang-rt flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})
+endif ()
add_custom_target(FortranRuntime)
add_dependencies(FortranRuntime flang_rt.runtime)
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt
index 2cd7e46c80407..cdac5f893cf91 100644
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ b/flang/runtime/Float128Math/CMakeLists.txt
@@ -12,62 +12,63 @@
# It is distributed as a static library only.
# Fortran programs/libraries that end up linking any of the provided
# will have a dependency on the third-party library that is being
-# used for building this FortranFloat128Math library.
+# used for building this flang_rt.quadmath library.
include(CheckLibraryExists)
set(sources
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/acos.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/acosh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/asin.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/asinh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/atan.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/atan2.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/atanh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/ceil.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/complex-math.c
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/cos.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/cosh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/erf.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/erfc.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/exp.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/exponent.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/floor.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/fma.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/fraction.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/hypot.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/j0.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/j1.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/jn.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/lgamma.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/llround.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/log.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/log10.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/lround.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/mod-real.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/modulo-real.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/nearest.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/nearbyint.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/norm2.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/pow.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/random.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/remainder.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/round.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/rrspacing.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/scale.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/set-exponent.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/sin.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/sinh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/spacing.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/sqrt.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/tan.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/tanh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/tgamma.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/trunc.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/y0.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/y1.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/yn.cpp
+ acos.cpp
+ acosh.cpp
+ asin.cpp
+ asinh.cpp
+ atan.cpp
+ atan2.cpp
+ atanh.cpp
+ ceil.cpp
+ complex-math.c
+ cos.cpp
+ cosh.cpp
+ erf.cpp
+ erfc.cpp
+ exp.cpp
+ exponent.cpp
+ floor.cpp
+ fma.cpp
+ fraction.cpp
+ hypot.cpp
+ j0.cpp
+ j1.cpp
+ jn.cpp
+ lgamma.cpp
+ llround.cpp
+ log.cpp
+ log10.cpp
+ lround.cpp
+ mod-real.cpp
+ modulo-real.cpp
+ nearest.cpp
+ nearbyint.cpp
+ norm2.cpp
+ pow.cpp
+ random.cpp
+ remainder.cpp
+ round.cpp
+ rrspacing.cpp
+ scale.cpp
+ set-exponent.cpp
+ sin.cpp
+ sinh.cpp
+ spacing.cpp
+ sqrt.cpp
+ tan.cpp
+ tanh.cpp
+ tgamma.cpp
+ trunc.cpp
+ y0.cpp
+ y1.cpp
+ yn.cpp
)
+runtime_source_files(sources SUBDIR "quadmath")
include_directories(AFTER "${CMAKE_CURRENT_SOURCE_DIR}/..")
add_library(FortranFloat128MathILib INTERFACE)
@@ -93,20 +94,20 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
)
endif()
- add_flang_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
+ add_flang_library(flang_rt.quadmath STATIC INSTALL_WITH_TOOLCHAIN
${sources})
if (DEFINED MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
- add_flang_library(FortranFloat128Math.static STATIC INSTALL_WITH_TOOLCHAIN
+ add_flang_library(flang_rt.quadmath.static STATIC INSTALL_WITH_TOOLCHAIN
${sources}
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
- add_flang_library(FortranFloat128Math.static_dbg STATIC INSTALL_WITH_TOOLCHAIN
+ add_flang_library(flang_rt.quadmath.static_dbg STATIC INSTALL_WITH_TOOLCHAIN
${sources}
)
- add_dependencies(FortranFloat128Math FortranFloat128Math.static
- FortranFloat128Math.static_dbg
+ add_dependencies(flang_rt.quadmath flang_rt.quadmath.static
+ flang_rt.quadmath.static_dbg
)
endif()
elseif (HAVE_LDBL_MANT_DIG_113)
@@ -118,7 +119,7 @@ elseif (HAVE_LDBL_MANT_DIG_113)
)
target_sources(FortranFloat128MathILib INTERFACE ${sources})
else()
- message(FATAL_ERROR "flang_rt cannot build without libm")
+ message(FATAL_ERROR "flang_rt.quadmath cannot build without libm")
endif()
else()
# We can use '__float128' version from libc, if it has them.
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index 2e9dadbfb671b..0b6eff8043247 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -29,29 +29,29 @@
! executable and may find the GNU linker from MinGW or Cygwin.
! UNIX-LABEL: "{{.*}}ld{{(\.exe)?}}"
! UNIX-SAME: "[[object_file]]"
-! UNIX-F128NONE-NOT: FortranFloat128Math
-! SOLARIS-F128NONE-NOT: FortranFloat128Math
-! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
+! UNIX-F128NONE-NOT: libflang_rt.quadmath
+! SOLARIS-F128NONE-NOT: libflang_rt.quadmath
+! UNIX-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
+! SOLARIS-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "-z" "ignore" "-lquadmath" "-z" "record"
! UNIX-SAME: "-lflang_rt.runtime" "-lm"
! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
! DARWIN-SAME: "[[object_file]]"
-! DARWIN-F128NONE-NOT: FortranFloat128Math
-! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
+! DARWIN-F128NONE-NOT: libflang_rt.quadmath
+! DARWIN-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
! DARWIN-SAME: -lflang_rt.runtime
! HAIKU-LABEL: "{{.*}}ld{{(\.exe)?}}"
! HAIKU-SAME: "[[object_file]]"
-! HAIKU-F128NONE-NOT: FortranFloat128Math
-! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
+! HAIKU-F128NONE-NOT: libflang_rt.quadmath
+! HAIKU-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
! HAIKU-SAME: "-lflang_rt.runtime"
! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}"
! MINGW-SAME: "[[object_file]]"
-! MINGW-F128NONE-NOT: FortranFloat128Math
-! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
+! MINGW-F128NONE-NOT: libflang_rt.quadmath
+! MINGW-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
! MINGW-SAME: -lflang_rt.runtime
! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
>From 8fae56556fd8dd69b39af96098b16bd8fd9626e1 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 3 Feb 2025 23:33:40 +0100
Subject: [PATCH 23/41] forgotten change
---
flang/test/Runtime/no-cpp-dep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang/test/Runtime/no-cpp-dep.c
index c03029f0f3c26..4fcf8f9d478d8 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/flang/test/Runtime/no-cpp-dep.c
@@ -1,6 +1,6 @@
/*
This test makes sure that flang's runtime does not depend on the C++ runtime
-library. It tries to link this simple file against libflang_rt.a with
+library. It tries to link this simple file against libflang_rt.runtime.a with
a C compiler.
REQUIRES: c-compiler, flang-rt
>From 8e8b33897eebd68fb5f4d7819eea25b573006120 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 3 Feb 2025 23:42:46 +0100
Subject: [PATCH 24/41] Rename to flang_rt.runtime, flang_rt.quadmath,
flang_rt.cuda
---
.../ExternalHelloWorld/external-hello.cpp | 8 ++
.../flang-rt/{CUDA => cuda}/allocator.h | 2 +-
.../{ => runtime}/allocator-registry.h | 8 +-
.../{ => runtime}/array-constructor.h | 8 +-
.../flang-rt/{ => runtime}/assign-impl.h | 8 +-
.../include/flang-rt/{ => runtime}/buffer.h | 8 +-
.../flang-rt/{ => runtime}/connection.h | 8 +-
.../include/flang-rt/{ => runtime}/derived.h | 8 +-
.../flang-rt/{ => runtime}/descriptor.h | 8 +-
.../flang-rt/{ => runtime}/emit-encoded.h | 8 +-
.../flang-rt/{ => runtime}/environment.h | 8 +-
.../include/flang-rt/{ => runtime}/file.h | 8 +-
.../{ => runtime}/format-implementation.h | 8 +-
.../include/flang-rt/{ => runtime}/format.h | 8 +-
.../flang-rt/{ => runtime}/internal-unit.h | 8 +-
.../include/flang-rt/{ => runtime}/io-error.h | 8 +-
.../include/flang-rt/{ => runtime}/io-stmt.h | 8 +-
.../include/flang-rt/{ => runtime}/lock.h | 8 +-
.../include/flang-rt/{ => runtime}/memory.h | 8 +-
.../include/flang-rt/{ => runtime}/namelist.h | 8 +-
.../flang-rt/{ => runtime}/non-tbp-dio.h | 8 +-
.../{ => runtime}/numeric-templates.h | 8 +-
.../flang-rt/{ => runtime}/random-templates.h | 8 +-
.../{ => runtime}/reduction-templates.h | 8 +-
.../include/flang-rt/{ => runtime}/stat.h | 8 +-
.../flang-rt/{ => runtime}/terminator.h | 8 +-
.../include/flang-rt/{ => runtime}/tools.h | 10 +-
.../flang-rt/{ => runtime}/type-code.h | 8 +-
.../flang-rt/{ => runtime}/type-info.h | 8 +-
flang-rt/include/flang-rt/{ => runtime}/utf.h | 8 +-
.../{flang_rt/CUDA => cuda}/allocatable.cpp | 10 +-
.../lib/{flang_rt/CUDA => cuda}/allocator.cpp | 14 +--
.../{flang_rt/CUDA => cuda}/descriptor.cpp | 8 +-
flang-rt/lib/{flang_rt/CUDA => cuda}/init.cpp | 6 +-
.../lib/{flang_rt/CUDA => cuda}/kernel.cpp | 4 +-
.../CUDA => cuda}/memmove-function.cpp | 4 +-
.../lib/{flang_rt/CUDA => cuda}/memory.cpp | 6 +-
.../lib/{flang_rt/CUDA => cuda}/pointer.cpp | 10 +-
.../{flang_rt/CUDA => cuda}/registration.cpp | 4 +-
.../acos.cpp | 2 +-
.../acosh.cpp | 2 +-
.../asin.cpp | 2 +-
.../asinh.cpp | 2 +-
.../atan.cpp | 2 +-
.../atan2.cpp | 2 +-
.../atanh.cpp | 2 +-
.../ceil.cpp | 2 +-
.../complex-math.c | 2 +-
.../complex-math.h | 8 +-
.../{FortranFloat128Math => quadmath}/cos.cpp | 2 +-
.../cosh.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/erf.cpp | 2 +-
.../erfc.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/exp.cpp | 2 +-
.../exponent.cpp | 2 +-
.../floor.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/fma.cpp | 2 +-
.../fraction.cpp | 2 +-
.../hypot.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/j0.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/j1.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/jn.cpp | 2 +-
.../lgamma.cpp | 2 +-
.../llround.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/log.cpp | 2 +-
.../log10.cpp | 2 +-
.../lround.cpp | 2 +-
.../math-entries.h | 12 +--
.../mod-real.cpp | 2 +-
.../modulo-real.cpp | 2 +-
.../nearbyint.cpp | 2 +-
.../nearest.cpp | 2 +-
.../norm2.cpp | 4 +-
.../numeric-template-specs.h | 10 +-
.../{FortranFloat128Math => quadmath}/pow.cpp | 2 +-
.../random.cpp | 4 +-
.../remainder.cpp | 2 +-
.../round.cpp | 2 +-
.../rrspacing.cpp | 2 +-
.../scale.cpp | 2 +-
.../set-exponent.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/sin.cpp | 2 +-
.../sinh.cpp | 2 +-
.../spacing.cpp | 2 +-
.../sqrt.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/tan.cpp | 2 +-
.../tanh.cpp | 2 +-
.../tgamma.cpp | 2 +-
.../trunc.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/y0.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/y1.cpp | 2 +-
.../{FortranFloat128Math => quadmath}/yn.cpp | 2 +-
.../ISO_Fortran_binding.cpp | 8 +-
.../{flang_rt => runtime}/ISO_Fortran_util.h | 14 +--
.../lib/{flang_rt => runtime}/allocatable.cpp | 14 +--
.../allocator-registry.cpp | 6 +-
.../array-constructor.cpp | 14 +--
flang-rt/lib/{flang_rt => runtime}/assign.cpp | 16 +--
flang-rt/lib/{flang_rt => runtime}/buffer.cpp | 4 +-
.../lib/{flang_rt => runtime}/character.cpp | 8 +-
.../lib/{flang_rt => runtime}/command.cpp | 12 +--
.../{flang_rt => runtime}/complex-powi.cpp | 2 +-
.../{flang_rt => runtime}/complex-reduction.c | 0
.../{flang_rt => runtime}/complex-reduction.h | 8 +-
.../lib/{flang_rt => runtime}/connection.cpp | 8 +-
flang-rt/lib/{flang_rt => runtime}/copy.cpp | 8 +-
flang-rt/lib/{flang_rt => runtime}/copy.h | 10 +-
.../lib/{flang_rt => runtime}/derived-api.cpp | 12 +--
.../lib/{flang_rt => runtime}/derived.cpp | 14 +--
.../{flang_rt => runtime}/descriptor-io.cpp | 2 +-
.../lib/{flang_rt => runtime}/descriptor-io.h | 18 ++--
.../lib/{flang_rt => runtime}/descriptor.cpp | 16 +--
.../lib/{flang_rt => runtime}/dot-product.cpp | 8 +-
.../lib/{flang_rt => runtime}/edit-input.cpp | 6 +-
.../lib/{flang_rt => runtime}/edit-input.h | 12 +--
.../lib/{flang_rt => runtime}/edit-output.cpp | 6 +-
.../lib/{flang_rt => runtime}/edit-output.h | 12 +--
.../environment-default-list.h | 0
.../lib/{flang_rt => runtime}/environment.cpp | 6 +-
.../lib/{flang_rt => runtime}/exceptions.cpp | 4 +-
.../lib/{flang_rt => runtime}/execute.cpp | 12 +--
.../lib/{flang_rt => runtime}/extensions.cpp | 8 +-
.../{flang_rt => runtime}/external-unit.cpp | 8 +-
.../lib/{flang_rt => runtime}/extrema.cpp | 4 +-
flang-rt/lib/{flang_rt => runtime}/file.cpp | 8 +-
.../lib/{flang_rt => runtime}/findloc.cpp | 4 +-
flang-rt/lib/{flang_rt => runtime}/format.cpp | 4 +-
.../lib/{flang_rt => runtime}/inquiry.cpp | 8 +-
.../{flang_rt => runtime}/internal-unit.cpp | 8 +-
.../lib/{flang_rt => runtime}/io-api-common.h | 12 +--
.../{flang_rt => runtime}/io-api-minimal.cpp | 12 +--
flang-rt/lib/{flang_rt => runtime}/io-api.cpp | 16 +--
.../lib/{flang_rt => runtime}/io-error.cpp | 6 +-
.../lib/{flang_rt => runtime}/io-stmt.cpp | 16 +--
flang-rt/lib/{flang_rt => runtime}/iostat.cpp | 2 +-
flang-rt/lib/{flang_rt => runtime}/main.cpp | 6 +-
.../matmul-transpose.cpp | 8 +-
flang-rt/lib/{flang_rt => runtime}/matmul.cpp | 8 +-
flang-rt/lib/{flang_rt => runtime}/memory.cpp | 8 +-
.../{flang_rt => runtime}/misc-intrinsic.cpp | 8 +-
.../lib/{flang_rt => runtime}/namelist.cpp | 8 +-
.../lib/{flang_rt => runtime}/non-tbp-dio.cpp | 6 +-
.../lib/{flang_rt => runtime}/numeric.cpp | 8 +-
.../lib/{flang_rt => runtime}/pointer.cpp | 16 +--
.../lib/{flang_rt => runtime}/product.cpp | 4 +-
.../lib/{flang_rt => runtime}/pseudo-unit.cpp | 6 +-
flang-rt/lib/{flang_rt => runtime}/ragged.cpp | 4 +-
flang-rt/lib/{flang_rt => runtime}/random.cpp | 10 +-
flang-rt/lib/{flang_rt => runtime}/reduce.cpp | 10 +-
.../lib/{flang_rt => runtime}/reduction.cpp | 6 +-
flang-rt/lib/{flang_rt => runtime}/stack.h | 12 +--
flang-rt/lib/{flang_rt => runtime}/stat.cpp | 10 +-
flang-rt/lib/{flang_rt => runtime}/stop.cpp | 10 +-
flang-rt/lib/{flang_rt => runtime}/sum.cpp | 4 +-
.../lib/{flang_rt => runtime}/support.cpp | 6 +-
.../{flang_rt => runtime}/temporary-stack.cpp | 8 +-
.../lib/{flang_rt => runtime}/terminator.cpp | 4 +-
.../{flang_rt => runtime}/time-intrinsic.cpp | 8 +-
flang-rt/lib/{flang_rt => runtime}/tools.cpp | 6 +-
.../transformational.cpp | 8 +-
.../lib/{flang_rt => runtime}/type-code.cpp | 4 +-
.../lib/{flang_rt => runtime}/type-info.cpp | 8 +-
.../lib/{flang_rt => runtime}/unit-map.cpp | 2 +-
flang-rt/lib/{flang_rt => runtime}/unit-map.h | 12 +--
flang-rt/lib/{flang_rt => runtime}/unit.cpp | 8 +-
flang-rt/lib/{flang_rt => runtime}/unit.h | 30 +++---
flang-rt/lib/{flang_rt => runtime}/utf.cpp | 4 +-
flang-rt/test/Runtime/no-cpp-dep.c | 2 +-
.../Evaluate/ISO-Fortran-binding.cpp | 2 +-
flang-rt/unittests/Evaluate/reshape.cpp | 2 +-
flang-rt/unittests/Runtime/Allocatable.cpp | 2 +-
.../unittests/Runtime/ArrayConstructor.cpp | 6 +-
flang-rt/unittests/Runtime/BufferTest.cpp | 2 +-
.../unittests/Runtime/CUDA/Allocatable.cpp | 8 +-
.../unittests/Runtime/CUDA/AllocatorCUF.cpp | 8 +-
flang-rt/unittests/Runtime/CUDA/Memory.cpp | 6 +-
flang-rt/unittests/Runtime/CharacterTest.cpp | 2 +-
flang-rt/unittests/Runtime/CommandTest.cpp | 2 +-
.../unittests/Runtime/CrashHandlerFixture.cpp | 2 +-
flang-rt/unittests/Runtime/Derived.cpp | 4 +-
flang-rt/unittests/Runtime/ExternalIOTest.cpp | 2 +-
flang-rt/unittests/Runtime/Format.cpp | 6 +-
flang-rt/unittests/Runtime/Inquiry.cpp | 2 +-
flang-rt/unittests/Runtime/ListInputTest.cpp | 4 +-
.../unittests/Runtime/LogicalFormatTest.cpp | 2 +-
flang-rt/unittests/Runtime/Matmul.cpp | 4 +-
.../unittests/Runtime/MatmulTranspose.cpp | 4 +-
flang-rt/unittests/Runtime/MiscIntrinsic.cpp | 2 +-
flang-rt/unittests/Runtime/Namelist.cpp | 4 +-
.../unittests/Runtime/NumericalFormatTest.cpp | 2 +-
flang-rt/unittests/Runtime/Pointer.cpp | 4 +-
flang-rt/unittests/Runtime/Random.cpp | 4 +-
flang-rt/unittests/Runtime/Reduction.cpp | 4 +-
.../unittests/Runtime/RuntimeCrashTest.cpp | 2 +-
flang-rt/unittests/Runtime/Stop.cpp | 2 +-
flang-rt/unittests/Runtime/Support.cpp | 2 +-
flang-rt/unittests/Runtime/TemporaryStack.cpp | 6 +-
.../unittests/Runtime/Transformational.cpp | 2 +-
flang-rt/unittests/Runtime/tools.h | 4 +-
.../ExternalHelloWorld/CMakeLists.txt | 2 +-
flang/runtime/CMakeLists.txt | 7 +-
flang/runtime/CUDA/CMakeLists.txt | 2 +-
flang/runtime/Float128Math/CMakeLists.txt | 101 +++++++++---------
203 files changed, 651 insertions(+), 643 deletions(-)
rename {flang => flang-rt}/examples/ExternalHelloWorld/external-hello.cpp (80%)
rename flang-rt/include/flang-rt/{CUDA => cuda}/allocator.h (93%)
rename flang-rt/include/flang-rt/{ => runtime}/allocator-registry.h (87%)
rename flang-rt/include/flang-rt/{ => runtime}/array-constructor.h (90%)
rename flang-rt/include/flang-rt/{ => runtime}/assign-impl.h (85%)
rename flang-rt/include/flang-rt/{ => runtime}/buffer.h (97%)
rename flang-rt/include/flang-rt/{ => runtime}/connection.h (96%)
rename flang-rt/include/flang-rt/{ => runtime}/derived.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/descriptor.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/emit-encoded.h (94%)
rename flang-rt/include/flang-rt/{ => runtime}/environment.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/file.h (95%)
rename flang-rt/include/flang-rt/{ => runtime}/format-implementation.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/format.h (97%)
rename flang-rt/include/flang-rt/{ => runtime}/internal-unit.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/io-error.h (94%)
rename flang-rt/include/flang-rt/{ => runtime}/io-stmt.h (99%)
rename flang-rt/include/flang-rt/{ => runtime}/lock.h (94%)
rename flang-rt/include/flang-rt/{ => runtime}/memory.h (96%)
rename flang-rt/include/flang-rt/{ => runtime}/namelist.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/non-tbp-dio.h (91%)
rename flang-rt/include/flang-rt/{ => runtime}/numeric-templates.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/random-templates.h (94%)
rename flang-rt/include/flang-rt/{ => runtime}/reduction-templates.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/stat.h (93%)
rename flang-rt/include/flang-rt/{ => runtime}/terminator.h (95%)
rename flang-rt/include/flang-rt/{ => runtime}/tools.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/type-code.h (93%)
rename flang-rt/include/flang-rt/{ => runtime}/type-info.h (98%)
rename flang-rt/include/flang-rt/{ => runtime}/utf.h (94%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/allocatable.cpp (94%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/allocator.cpp (86%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/descriptor.cpp (90%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/init.cpp (83%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/kernel.cpp (98%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/memmove-function.cpp (91%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/memory.cpp (97%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/pointer.cpp (92%)
rename flang-rt/lib/{flang_rt/CUDA => cuda}/registration.cpp (93%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/acos.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/acosh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/asin.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/asinh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/atan.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/atan2.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/atanh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/ceil.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/complex-math.c (96%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/complex-math.h (88%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/cos.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/cosh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/erf.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/erfc.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/exp.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/exponent.cpp (92%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/floor.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/fma.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/fraction.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/hypot.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/j0.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/j1.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/jn.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/lgamma.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/llround.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/log.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/log10.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/lround.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/math-entries.h (96%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/mod-real.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/modulo-real.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/nearbyint.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/nearest.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/norm2.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/numeric-template-specs.h (82%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/pow.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/random.cpp (85%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/remainder.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/round.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/rrspacing.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/scale.cpp (92%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/set-exponent.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/sin.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/sinh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/spacing.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/sqrt.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/tan.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/tanh.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/tgamma.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/trunc.cpp (91%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/y0.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/y1.cpp (90%)
rename flang-rt/lib/{FortranFloat128Math => quadmath}/yn.cpp (90%)
rename flang-rt/lib/{flang_rt => runtime}/ISO_Fortran_binding.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/ISO_Fortran_util.h (90%)
rename flang-rt/lib/{flang_rt => runtime}/allocatable.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/allocator-registry.cpp (89%)
rename flang-rt/lib/{flang_rt => runtime}/array-constructor.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/assign.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/buffer.cpp (90%)
rename flang-rt/lib/{flang_rt => runtime}/character.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/command.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/complex-powi.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/complex-reduction.c (100%)
rename flang-rt/lib/{flang_rt => runtime}/complex-reduction.h (97%)
rename flang-rt/lib/{flang_rt => runtime}/connection.cpp (91%)
rename flang-rt/lib/{flang_rt => runtime}/copy.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/copy.h (78%)
rename flang-rt/lib/{flang_rt => runtime}/derived-api.cpp (95%)
rename flang-rt/lib/{flang_rt => runtime}/derived.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/descriptor-io.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/descriptor-io.h (98%)
rename flang-rt/lib/{flang_rt => runtime}/descriptor.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/dot-product.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/edit-input.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/edit-input.h (87%)
rename flang-rt/lib/{flang_rt => runtime}/edit-output.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/edit-output.h (95%)
rename flang-rt/lib/{flang_rt => runtime}/environment-default-list.h (100%)
rename flang-rt/lib/{flang_rt => runtime}/environment.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/exceptions.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/execute.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/extensions.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/external-unit.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/extrema.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/file.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/findloc.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/format.cpp (89%)
rename flang-rt/lib/{flang_rt => runtime}/inquiry.cpp (94%)
rename flang-rt/lib/{flang_rt => runtime}/internal-unit.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/io-api-common.h (92%)
rename flang-rt/lib/{flang_rt => runtime}/io-api-minimal.cpp (94%)
rename flang-rt/lib/{flang_rt => runtime}/io-api.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/io-error.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/io-stmt.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/iostat.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/main.cpp (90%)
rename flang-rt/lib/{flang_rt => runtime}/matmul-transpose.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/matmul.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/memory.cpp (87%)
rename flang-rt/lib/{flang_rt => runtime}/misc-intrinsic.cpp (95%)
rename flang-rt/lib/{flang_rt => runtime}/namelist.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/non-tbp-dio.cpp (86%)
rename flang-rt/lib/{flang_rt => runtime}/numeric.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/pointer.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/product.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/pseudo-unit.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/ragged.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/random.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/reduce.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/reduction.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/stack.h (93%)
rename flang-rt/lib/{flang_rt => runtime}/stat.cpp (93%)
rename flang-rt/lib/{flang_rt => runtime}/stop.cpp (95%)
rename flang-rt/lib/{flang_rt => runtime}/sum.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/support.cpp (91%)
rename flang-rt/lib/{flang_rt => runtime}/temporary-stack.cpp (97%)
rename flang-rt/lib/{flang_rt => runtime}/terminator.cpp (96%)
rename flang-rt/lib/{flang_rt => runtime}/time-intrinsic.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/tools.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/transformational.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/type-code.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/type-info.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/unit-map.cpp (98%)
rename flang-rt/lib/{flang_rt => runtime}/unit-map.h (92%)
rename flang-rt/lib/{flang_rt => runtime}/unit.cpp (99%)
rename flang-rt/lib/{flang_rt => runtime}/unit.h (95%)
rename flang-rt/lib/{flang_rt => runtime}/utf.cpp (97%)
diff --git a/flang/examples/ExternalHelloWorld/external-hello.cpp b/flang-rt/examples/ExternalHelloWorld/external-hello.cpp
similarity index 80%
rename from flang/examples/ExternalHelloWorld/external-hello.cpp
rename to flang-rt/examples/ExternalHelloWorld/external-hello.cpp
index 4991bf9eba999..7c8a12476295c 100644
--- a/flang/examples/ExternalHelloWorld/external-hello.cpp
+++ b/flang-rt/examples/ExternalHelloWorld/external-hello.cpp
@@ -1,3 +1,11 @@
+//===-- examples/ExternalHelloWorld/external-hello.cpp ----------*- 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
+//
+//===----------------------------------------------------------------------===//
+
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
diff --git a/flang-rt/include/flang-rt/CUDA/allocator.h b/flang-rt/include/flang-rt/cuda/allocator.h
similarity index 93%
rename from flang-rt/include/flang-rt/CUDA/allocator.h
rename to flang-rt/include/flang-rt/cuda/allocator.h
index 68bb0736dd5ee..5bc61cd04ee26 100644
--- a/flang-rt/include/flang-rt/CUDA/allocator.h
+++ b/flang-rt/include/flang-rt/cuda/allocator.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/CUDA/allocator.h -----------------------*- C++ -*-===//
+//===-- include/flang-rt/cuda/allocator.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.
diff --git a/flang-rt/include/flang-rt/allocator-registry.h b/flang-rt/include/flang-rt/runtime/allocator-registry.h
similarity index 87%
rename from flang-rt/include/flang-rt/allocator-registry.h
rename to flang-rt/include/flang-rt/runtime/allocator-registry.h
index ea905afc045ce..1a59ec8b1ef5b 100644
--- a/flang-rt/include/flang-rt/allocator-registry.h
+++ b/flang-rt/include/flang-rt/runtime/allocator-registry.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/allocator-registry.h -------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/allocator-registry.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_ALLOCATOR_REGISTRY_H_
-#define FLANG_RT_ALLOCATOR_REGISTRY_H_
+#ifndef FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
+#define FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
#include "flang/Common/api-attrs.h"
#include "flang/Runtime/allocator-registry-consts.h"
@@ -55,4 +55,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif // FLANG_RT_ALLOCATOR_REGISTRY_H_
+#endif // FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
diff --git a/flang-rt/include/flang-rt/array-constructor.h b/flang-rt/include/flang-rt/runtime/array-constructor.h
similarity index 90%
rename from flang-rt/include/flang-rt/array-constructor.h
rename to flang-rt/include/flang-rt/runtime/array-constructor.h
index 738050f80ef65..9c037177161c0 100644
--- a/flang-rt/include/flang-rt/array-constructor.h
+++ b/flang-rt/include/flang-rt/runtime/array-constructor.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/array-constructor.h --------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/array-constructor.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.
@@ -9,8 +9,8 @@
// External APIs to create temporary storage for array constructors when their
// final extents or length parameters cannot be pre-computed.
-#ifndef FLANG_RT_ARRAY_CONSTRUCTOR_H_
-#define FLANG_RT_ARRAY_CONSTRUCTOR_H_
+#ifndef FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
+#define FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
#include "descriptor.h"
#include "flang/Runtime/array-constructor-consts.h"
@@ -54,4 +54,4 @@ static_assert(alignof(Fortran::runtime::ArrayConstructorVector) <=
"MaxArrayConstructorVectorAlignInBytes");
} // namespace Fortran::runtime
-#endif // FLANG_RT_ARRAY_CONSTRUCTOR_H_
+#endif // FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
diff --git a/flang-rt/include/flang-rt/assign-impl.h b/flang-rt/include/flang-rt/runtime/assign-impl.h
similarity index 85%
rename from flang-rt/include/flang-rt/assign-impl.h
rename to flang-rt/include/flang-rt/runtime/assign-impl.h
index 2e85a451d5b52..cc931f6713cd8 100644
--- a/flang-rt/include/flang-rt/assign-impl.h
+++ b/flang-rt/include/flang-rt/runtime/assign-impl.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/assign-impl.h --------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/assign-impl.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_ASSIGN_IMPL_H_
-#define FLANG_RT_ASSIGN_IMPL_H_
+#ifndef FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
+#define FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
#include "flang/Runtime/freestanding-tools.h"
@@ -28,4 +28,4 @@ RT_API_ATTRS void DoFromSourceAssign(Descriptor &, const Descriptor &,
#endif
} // namespace Fortran::runtime
-#endif // FLANG_RT_ASSIGN_IMPL_H_
+#endif // FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
diff --git a/flang-rt/include/flang-rt/buffer.h b/flang-rt/include/flang-rt/runtime/buffer.h
similarity index 97%
rename from flang-rt/include/flang-rt/buffer.h
rename to flang-rt/include/flang-rt/runtime/buffer.h
index bd2e8c47c6e30..b5a9ce9e35e91 100644
--- a/flang-rt/include/flang-rt/buffer.h
+++ b/flang-rt/include/flang-rt/runtime/buffer.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/buffer.h -------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/buffer.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.
@@ -8,8 +8,8 @@
// External file buffering
-#ifndef FLANG_RT_BUFFER_H_
-#define FLANG_RT_BUFFER_H_
+#ifndef FLANG_RT_RUNTIME_BUFFER_H_
+#define FLANG_RT_RUNTIME_BUFFER_H_
#include "io-error.h"
#include "memory.h"
@@ -221,4 +221,4 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
bool dirty_{false};
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_BUFFER_H_
+#endif // FLANG_RT_RUNTIME_BUFFER_H_
diff --git a/flang-rt/include/flang-rt/connection.h b/flang-rt/include/flang-rt/runtime/connection.h
similarity index 96%
rename from flang-rt/include/flang-rt/connection.h
rename to flang-rt/include/flang-rt/runtime/connection.h
index 550ddb15c7236..03d9658e7067b 100644
--- a/flang-rt/include/flang-rt/connection.h
+++ b/flang-rt/include/flang-rt/runtime/connection.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/connection.h ---------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/connection.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.
@@ -8,8 +8,8 @@
// Fortran I/O connection state (abstracted over internal & external units)
-#ifndef FLANG_RT_CONNECTION_H_
-#define FLANG_RT_CONNECTION_H_
+#ifndef FLANG_RT_RUNTIME_CONNECTION_H_
+#define FLANG_RT_RUNTIME_CONNECTION_H_
#include "format.h"
#include "flang/Common/optional.h"
@@ -124,4 +124,4 @@ class SavedPosition {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_CONNECTION_H_
+#endif // FLANG_RT_RUNTIME_CONNECTION_H_
diff --git a/flang-rt/include/flang-rt/derived.h b/flang-rt/include/flang-rt/runtime/derived.h
similarity index 91%
rename from flang-rt/include/flang-rt/derived.h
rename to flang-rt/include/flang-rt/runtime/derived.h
index d65fb75172495..ac6962c57168c 100644
--- a/flang-rt/include/flang-rt/derived.h
+++ b/flang-rt/include/flang-rt/runtime/derived.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/derived.h ------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/derived.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.
@@ -8,8 +8,8 @@
// Internal runtime utilities for derived type operations.
-#ifndef FLANG_RT_DERIVED_H_
-#define FLANG_RT_DERIVED_H_
+#ifndef FLANG_RT_RUNTIME_DERIVED_H_
+#define FLANG_RT_RUNTIME_DERIVED_H_
#include "flang/Common/api-attrs.h"
@@ -48,4 +48,4 @@ RT_API_ATTRS void Destroy(const Descriptor &, bool finalize,
RT_API_ATTRS bool HasDynamicComponent(const Descriptor &);
} // namespace Fortran::runtime
-#endif // FLANG_RT_DERIVED_H_
+#endif // FLANG_RT_RUNTIME_DERIVED_H_
diff --git a/flang-rt/include/flang-rt/descriptor.h b/flang-rt/include/flang-rt/runtime/descriptor.h
similarity index 98%
rename from flang-rt/include/flang-rt/descriptor.h
rename to flang-rt/include/flang-rt/runtime/descriptor.h
index f97b8443425dc..19e1a0bf6a1dd 100644
--- a/flang-rt/include/flang-rt/descriptor.h
+++ b/flang-rt/include/flang-rt/runtime/descriptor.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/descriptor.h ---------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/descriptor.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_DESCRIPTOR_H_
-#define FLANG_RT_DESCRIPTOR_H_
+#ifndef FLANG_RT_RUNTIME_DESCRIPTOR_H_
+#define FLANG_RT_RUNTIME_DESCRIPTOR_H_
// Defines data structures used during execution of a Fortran program
// to implement nontrivial dummy arguments, pointers, allocatables,
@@ -482,4 +482,4 @@ class alignas(Descriptor) StaticDescriptor {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_DESCRIPTOR_H_
+#endif // FLANG_RT_RUNTIME_DESCRIPTOR_H_
diff --git a/flang-rt/include/flang-rt/emit-encoded.h b/flang-rt/include/flang-rt/runtime/emit-encoded.h
similarity index 94%
rename from flang-rt/include/flang-rt/emit-encoded.h
rename to flang-rt/include/flang-rt/runtime/emit-encoded.h
index 279f751daff2c..d99f56b29558e 100644
--- a/flang-rt/include/flang-rt/emit-encoded.h
+++ b/flang-rt/include/flang-rt/runtime/emit-encoded.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/emit-encoded.h -------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/emit-encoded.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.
@@ -8,8 +8,8 @@
// Templates for emitting CHARACTER values with conversion
-#ifndef FLANG_RT_EMIT_ENCODED_H_
-#define FLANG_RT_EMIT_ENCODED_H_
+#ifndef FLANG_RT_RUNTIME_EMIT_ENCODED_H_
+#define FLANG_RT_RUNTIME_EMIT_ENCODED_H_
#include "connection.h"
#include "environment.h"
@@ -114,4 +114,4 @@ RT_API_ATTRS bool EmitRepeated(CONTEXT &to, char ch, std::size_t n) {
}
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_EMIT_ENCODED_H_
+#endif // FLANG_RT_RUNTIME_EMIT_ENCODED_H_
diff --git a/flang-rt/include/flang-rt/environment.h b/flang-rt/include/flang-rt/runtime/environment.h
similarity index 91%
rename from flang-rt/include/flang-rt/environment.h
rename to flang-rt/include/flang-rt/runtime/environment.h
index 7fa3060768502..142add432b5f7 100644
--- a/flang-rt/include/flang-rt/environment.h
+++ b/flang-rt/include/flang-rt/runtime/environment.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/environment.h --------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/environment.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_ENVIRONMENT_H_
-#define FLANG_RT_ENVIRONMENT_H_
+#ifndef FLANG_RT_RUNTIME_ENVIRONMENT_H_
+#define FLANG_RT_RUNTIME_ENVIRONMENT_H_
#include "flang/Common/optional.h"
#include "flang/Decimal/decimal.h"
@@ -67,4 +67,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif // FLANG_RT_ENVIRONMENT_H_
+#endif // FLANG_RT_RUNTIME_ENVIRONMENT_H_
diff --git a/flang-rt/include/flang-rt/file.h b/flang-rt/include/flang-rt/runtime/file.h
similarity index 95%
rename from flang-rt/include/flang-rt/file.h
rename to flang-rt/include/flang-rt/runtime/file.h
index 3ab21c655a38f..3bba29722b3b8 100644
--- a/flang-rt/include/flang-rt/file.h
+++ b/flang-rt/include/flang-rt/runtime/file.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/file.h ---------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/file.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.
@@ -8,8 +8,8 @@
// Raw system I/O wrappers
-#ifndef FLANG_RT_FILE_H_
-#define FLANG_RT_FILE_H_
+#ifndef FLANG_RT_RUNTIME_FILE_H_
+#define FLANG_RT_RUNTIME_FILE_H_
#include "io-error.h"
#include "memory.h"
@@ -113,4 +113,4 @@ RT_API_ATTRS bool MayWrite(const char *path);
RT_API_ATTRS bool MayReadAndWrite(const char *path);
RT_API_ATTRS std::int64_t SizeInBytes(const char *path);
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_FILE_H_
+#endif // FLANG_RT_RUNTIME_FILE_H_
diff --git a/flang-rt/include/flang-rt/format-implementation.h b/flang-rt/include/flang-rt/runtime/format-implementation.h
similarity index 98%
rename from flang-rt/include/flang-rt/format-implementation.h
rename to flang-rt/include/flang-rt/runtime/format-implementation.h
index 6a2e1078ab350..8f4eb1161dd14 100644
--- a/flang-rt/include/flang-rt/format-implementation.h
+++ b/flang-rt/include/flang-rt/runtime/format-implementation.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/format-implementation.h ----------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/format-implementation.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.
@@ -8,8 +8,8 @@
// Implements out-of-line member functions of template class FormatControl
-#ifndef FLANG_RT_FORMAT_IMPLEMENTATION_H_
-#define FLANG_RT_FORMAT_IMPLEMENTATION_H_
+#ifndef FLANG_RT_RUNTIME_FORMAT_IMPLEMENTATION_H_
+#define FLANG_RT_RUNTIME_FORMAT_IMPLEMENTATION_H_
#include "emit-encoded.h"
#include "format.h"
@@ -601,4 +601,4 @@ RT_API_ATTRS void FormatControl<CONTEXT>::Finish(Context &context) {
}
}
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_FORMAT_IMPLEMENTATION_H_
+#endif // FLANG_RT_RUNTIME_FORMAT_IMPLEMENTATION_H_
diff --git a/flang-rt/include/flang-rt/format.h b/flang-rt/include/flang-rt/runtime/format.h
similarity index 97%
rename from flang-rt/include/flang-rt/format.h
rename to flang-rt/include/flang-rt/runtime/format.h
index 09e151a2e98ca..b169d63fa4999 100644
--- a/flang-rt/include/flang-rt/format.h
+++ b/flang-rt/include/flang-rt/runtime/format.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/format.h -------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/format.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.
@@ -8,8 +8,8 @@
// FORMAT string processing
-#ifndef FLANG_RT_FORMAT_H_
-#define FLANG_RT_FORMAT_H_
+#ifndef FLANG_RT_RUNTIME_FORMAT_H_
+#define FLANG_RT_RUNTIME_FORMAT_H_
#include "environment.h"
#include "io-error.h"
@@ -201,4 +201,4 @@ template <typename CONTEXT> class FormatControl {
Iteration stack_[maxMaxHeight];
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_FORMAT_H_
+#endif // FLANG_RT_RUNTIME_FORMAT_H_
diff --git a/flang-rt/include/flang-rt/internal-unit.h b/flang-rt/include/flang-rt/runtime/internal-unit.h
similarity index 91%
rename from flang-rt/include/flang-rt/internal-unit.h
rename to flang-rt/include/flang-rt/runtime/internal-unit.h
index 946d69080e611..429d3489e0112 100644
--- a/flang-rt/include/flang-rt/internal-unit.h
+++ b/flang-rt/include/flang-rt/runtime/internal-unit.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/internal-unit.h ------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/internal-unit.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.
@@ -8,8 +8,8 @@
// Fortran internal I/O "units"
-#ifndef FLANG_RT_INTERNAL_UNIT_H_
-#define FLANG_RT_INTERNAL_UNIT_H_
+#ifndef FLANG_RT_RUNTIME_INTERNAL_UNIT_H_
+#define FLANG_RT_RUNTIME_INTERNAL_UNIT_H_
#include "connection.h"
#include "descriptor.h"
@@ -56,4 +56,4 @@ template <Direction DIR> class InternalDescriptorUnit : public ConnectionState {
extern template class InternalDescriptorUnit<Direction::Output>;
extern template class InternalDescriptorUnit<Direction::Input>;
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_INTERNAL_UNIT_H_
+#endif // FLANG_RT_RUNTIME_INTERNAL_UNIT_H_
diff --git a/flang-rt/include/flang-rt/io-error.h b/flang-rt/include/flang-rt/runtime/io-error.h
similarity index 94%
rename from flang-rt/include/flang-rt/io-error.h
rename to flang-rt/include/flang-rt/runtime/io-error.h
index 6b5c0f9f39019..1cef6a208f374 100644
--- a/flang-rt/include/flang-rt/io-error.h
+++ b/flang-rt/include/flang-rt/runtime/io-error.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/io-error.h -----------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/io-error.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.
@@ -12,8 +12,8 @@
// IOSTAT error codes are raw errno values augmented with values for
// Fortran-specific errors.
-#ifndef FLANG_RT_IO_ERROR_H_
-#define FLANG_RT_IO_ERROR_H_
+#ifndef FLANG_RT_RUNTIME_IO_ERROR_H_
+#define FLANG_RT_RUNTIME_IO_ERROR_H_
#include "memory.h"
#include "terminator.h"
@@ -80,4 +80,4 @@ class IoErrorHandler : public Terminator {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_IO_ERROR_H_
+#endif // FLANG_RT_RUNTIME_IO_ERROR_H_
diff --git a/flang-rt/include/flang-rt/io-stmt.h b/flang-rt/include/flang-rt/runtime/io-stmt.h
similarity index 99%
rename from flang-rt/include/flang-rt/io-stmt.h
rename to flang-rt/include/flang-rt/runtime/io-stmt.h
index 7efab320e5e1a..a364ddfd9b3c7 100644
--- a/flang-rt/include/flang-rt/io-stmt.h
+++ b/flang-rt/include/flang-rt/runtime/io-stmt.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/io-stmt.h ------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/io-stmt.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.
@@ -8,8 +8,8 @@
// Representations of the state of an I/O statement in progress
-#ifndef FLANG_RT_IO_STMT_H_
-#define FLANG_RT_IO_STMT_H_
+#ifndef FLANG_RT_RUNTIME_IO_STMT_H_
+#define FLANG_RT_RUNTIME_IO_STMT_H_
#include "connection.h"
#include "descriptor.h"
@@ -791,4 +791,4 @@ class ErroneousIoStatementState : public IoStatementBase {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_IO_STMT_H_
+#endif // FLANG_RT_RUNTIME_IO_STMT_H_
diff --git a/flang-rt/include/flang-rt/lock.h b/flang-rt/include/flang-rt/runtime/lock.h
similarity index 94%
rename from flang-rt/include/flang-rt/lock.h
rename to flang-rt/include/flang-rt/runtime/lock.h
index 1b09434d26f4f..7c88534245733 100644
--- a/flang-rt/include/flang-rt/lock.h
+++ b/flang-rt/include/flang-rt/runtime/lock.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/lock.h ---------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/lock.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.
@@ -8,8 +8,8 @@
// Wraps a mutex
-#ifndef FLANG_RT_LOCK_H_
-#define FLANG_RT_LOCK_H_
+#ifndef FLANG_RT_RUNTIME_LOCK_H_
+#define FLANG_RT_RUNTIME_LOCK_H_
#include "terminator.h"
#include "tools.h"
@@ -113,4 +113,4 @@ class CriticalSection {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_LOCK_H_
+#endif // FLANG_RT_RUNTIME_LOCK_H_
diff --git a/flang-rt/include/flang-rt/memory.h b/flang-rt/include/flang-rt/runtime/memory.h
similarity index 96%
rename from flang-rt/include/flang-rt/memory.h
rename to flang-rt/include/flang-rt/runtime/memory.h
index 64db30baf2806..93b477afa9814 100644
--- a/flang-rt/include/flang-rt/memory.h
+++ b/flang-rt/include/flang-rt/runtime/memory.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/memory.h -------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/memory.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.
@@ -9,8 +9,8 @@
// Thin wrapper around malloc()/free() to isolate the dependency,
// ease porting, and provide an owning pointer.
-#ifndef FLANG_RT_MEMORY_H_
-#define FLANG_RT_MEMORY_H_
+#ifndef FLANG_RT_RUNTIME_MEMORY_H_
+#define FLANG_RT_RUNTIME_MEMORY_H_
#include "flang/Common/api-attrs.h"
#include <cassert>
@@ -170,4 +170,4 @@ template <typename A> struct Allocator {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_MEMORY_H_
+#endif // FLANG_RT_RUNTIME_MEMORY_H_
diff --git a/flang-rt/include/flang-rt/namelist.h b/flang-rt/include/flang-rt/runtime/namelist.h
similarity index 91%
rename from flang-rt/include/flang-rt/namelist.h
rename to flang-rt/include/flang-rt/runtime/namelist.h
index 2ae93ca9c2050..17d7bf310cc96 100644
--- a/flang-rt/include/flang-rt/namelist.h
+++ b/flang-rt/include/flang-rt/runtime/namelist.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/namelist.h -----------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/namelist.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.
@@ -8,8 +8,8 @@
// Defines the data structure used for NAMELIST I/O
-#ifndef FLANG_RT_NAMELIST_H_
-#define FLANG_RT_NAMELIST_H_
+#ifndef FLANG_RT_RUNTIME_NAMELIST_H_
+#define FLANG_RT_RUNTIME_NAMELIST_H_
#include "non-tbp-dio.h"
#include "flang/Common/api-attrs.h"
@@ -51,4 +51,4 @@ class NamelistGroup {
RT_API_ATTRS bool IsNamelistNameOrSlash(IoStatementState &);
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_NAMELIST_H_
+#endif // FLANG_RT_RUNTIME_NAMELIST_H_
diff --git a/flang-rt/include/flang-rt/non-tbp-dio.h b/flang-rt/include/flang-rt/runtime/non-tbp-dio.h
similarity index 91%
rename from flang-rt/include/flang-rt/non-tbp-dio.h
rename to flang-rt/include/flang-rt/runtime/non-tbp-dio.h
index 1088257b72f59..2bbbfa7f97f79 100644
--- a/flang-rt/include/flang-rt/non-tbp-dio.h
+++ b/flang-rt/include/flang-rt/runtime/non-tbp-dio.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/non-tbp-dio.h --------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/non-tbp-dio.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.
@@ -19,8 +19,8 @@
// a containing scope has become inaccessible in a nested scope due
// to the use of "IMPORT, NONE" or "IMPORT, ONLY:".
-#ifndef FLANG_RT_NON_TBP_DIO_H_
-#define FLANG_RT_NON_TBP_DIO_H_
+#ifndef FLANG_RT_RUNTIME_NON_TBP_DIO_H_
+#define FLANG_RT_RUNTIME_NON_TBP_DIO_H_
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/api-attrs.h"
@@ -53,4 +53,4 @@ struct NonTbpDefinedIoTable {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_NON_TBP_DIO_H_
+#endif // FLANG_RT_RUNTIME_NON_TBP_DIO_H_
diff --git a/flang-rt/include/flang-rt/numeric-templates.h b/flang-rt/include/flang-rt/runtime/numeric-templates.h
similarity index 98%
rename from flang-rt/include/flang-rt/numeric-templates.h
rename to flang-rt/include/flang-rt/runtime/numeric-templates.h
index a1475923ff3b1..1253d56f3c0fd 100644
--- a/flang-rt/include/flang-rt/numeric-templates.h
+++ b/flang-rt/include/flang-rt/runtime/numeric-templates.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/numeric-templates.h --------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/numeric-templates.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.
@@ -15,8 +15,8 @@
// for the data type corresponding to CppTypeFor<TypeCategory::Real, 16>
// on the target.
-#ifndef FLANG_RT_NUMERIC_TEMPLATES_H_
-#define FLANG_RT_NUMERIC_TEMPLATES_H_
+#ifndef FLANG_RT_RUNTIME_NUMERIC_TEMPLATES_H_
+#define FLANG_RT_RUNTIME_NUMERIC_TEMPLATES_H_
#include "terminator.h"
#include "tools.h"
@@ -368,4 +368,4 @@ template <typename T> inline RT_API_ATTRS T ErfcScaled(T arg) {
} // namespace Fortran::runtime
-#endif // FLANG_RT_NUMERIC_TEMPLATES_H_
+#endif // FLANG_RT_RUNTIME_NUMERIC_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/random-templates.h b/flang-rt/include/flang-rt/runtime/random-templates.h
similarity index 94%
rename from flang-rt/include/flang-rt/random-templates.h
rename to flang-rt/include/flang-rt/runtime/random-templates.h
index 00542bd5b2553..895c5ad4fc8bb 100644
--- a/flang-rt/include/flang-rt/random-templates.h
+++ b/flang-rt/include/flang-rt/runtime/random-templates.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/random-templates.h ---------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/random-templates.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_RANDOM_TEMPLATES_H_
-#define FLANG_RT_RANDOM_TEMPLATES_H_
+#ifndef FLANG_RT_RUNTIME_RANDOM_TEMPLATES_H_
+#define FLANG_RT_RUNTIME_RANDOM_TEMPLATES_H_
#include "descriptor.h"
#include "lock.h"
@@ -108,4 +108,4 @@ inline void GenerateUnsigned(const Descriptor &harvest) {
} // namespace Fortran::runtime::random
-#endif // FLANG_RT_RANDOM_TEMPLATES_H_
+#endif // FLANG_RT_RUNTIME_RANDOM_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/reduction-templates.h b/flang-rt/include/flang-rt/runtime/reduction-templates.h
similarity index 98%
rename from flang-rt/include/flang-rt/reduction-templates.h
rename to flang-rt/include/flang-rt/runtime/reduction-templates.h
index d6b3c24920cf9..8c6f838b8dadf 100644
--- a/flang-rt/include/flang-rt/reduction-templates.h
+++ b/flang-rt/include/flang-rt/runtime/reduction-templates.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/reduction-templates.h ------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/reduction-templates.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.
@@ -18,8 +18,8 @@
// * Character-valued reductions (MAXVAL & MINVAL) return arbitrary
// length results, dynamically allocated in a caller-supplied descriptor
-#ifndef FLANG_RT_REDUCTION_TEMPLATES_H_
-#define FLANG_RT_REDUCTION_TEMPLATES_H_
+#ifndef FLANG_RT_RUNTIME_REDUCTION_TEMPLATES_H_
+#define FLANG_RT_RUNTIME_REDUCTION_TEMPLATES_H_
#include "descriptor.h"
#include "numeric-templates.h"
@@ -416,4 +416,4 @@ template <int KIND> struct Norm2Helper {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_REDUCTION_TEMPLATES_H_
+#endif // FLANG_RT_RUNTIME_REDUCTION_TEMPLATES_H_
diff --git a/flang-rt/include/flang-rt/stat.h b/flang-rt/include/flang-rt/runtime/stat.h
similarity index 93%
rename from flang-rt/include/flang-rt/stat.h
rename to flang-rt/include/flang-rt/runtime/stat.h
index a6824f4803561..070d0bf8673fb 100644
--- a/flang-rt/include/flang-rt/stat.h
+++ b/flang-rt/include/flang-rt/runtime/stat.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/stat.h ---------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/stat.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.
@@ -9,8 +9,8 @@
// Defines the values returned by the runtime for STAT= specifiers
// on executable statements.
-#ifndef FLANG_RT_STAT_H_
-#define FLANG_RT_STAT_H_
+#ifndef FLANG_RT_RUNTIME_STAT_H_
+#define FLANG_RT_RUNTIME_STAT_H_
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/api-attrs.h"
#include "flang/Runtime/magic-numbers.h"
@@ -60,4 +60,4 @@ RT_API_ATTRS int ToErrmsg(const Descriptor *errmsg, int stat); // returns stat
RT_API_ATTRS int ReturnError(Terminator &, int stat,
const Descriptor *errmsg = nullptr, bool hasStat = false);
} // namespace Fortran::runtime
-#endif // FLANG_RT_STAT_H_
+#endif // FLANG_RT_RUNTIME_STAT_H_
diff --git a/flang-rt/include/flang-rt/terminator.h b/flang-rt/include/flang-rt/runtime/terminator.h
similarity index 95%
rename from flang-rt/include/flang-rt/terminator.h
rename to flang-rt/include/flang-rt/runtime/terminator.h
index c2a4e1f64eb66..4815f0674c849 100644
--- a/flang-rt/include/flang-rt/terminator.h
+++ b/flang-rt/include/flang-rt/runtime/terminator.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/terminator.h ---------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/terminator.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.
@@ -8,8 +8,8 @@
// Termination of the image
-#ifndef FLANG_RT_TERMINATOR_H_
-#define FLANG_RT_TERMINATOR_H_
+#ifndef FLANG_RT_RUNTIME_TERMINATOR_H_
+#define FLANG_RT_RUNTIME_TERMINATOR_H_
#include "flang/Common/api-attrs.h"
#include <cstdarg>
@@ -121,4 +121,4 @@ namespace Fortran::runtime::io {
RT_API_ATTRS void FlushOutputOnCrash(const Terminator &);
}
-#endif // FLANG_RT_TERMINATOR_H_
+#endif // FLANG_RT_RUNTIME_TERMINATOR_H_
diff --git a/flang-rt/include/flang-rt/tools.h b/flang-rt/include/flang-rt/runtime/tools.h
similarity index 98%
rename from flang-rt/include/flang-rt/tools.h
rename to flang-rt/include/flang-rt/runtime/tools.h
index 6bb31cbcc9b93..91a026bf2ac14 100644
--- a/flang-rt/include/flang-rt/tools.h
+++ b/flang-rt/include/flang-rt/runtime/tools.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/tools.h --------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/tools.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_TOOLS_H_
-#define FLANG_RT_TOOLS_H_
+#ifndef FLANG_RT_RUNTIME_TOOLS_H_
+#define FLANG_RT_RUNTIME_TOOLS_H_
#include "descriptor.h"
#include "memory.h"
@@ -348,7 +348,7 @@ inline RT_API_ATTRS RESULT ApplyFloatingPointKind(
if constexpr (HasCppTypeFor<TypeCategory::Real, 16>) {
// If FUNC implemenation relies on FP math functions,
// then we should not be here. The compiler should have
- // generated a call to an entry in flang_rt.quadmath
+ // generated a call to an entry in the libflang_rt.quadmath
// library.
if constexpr (!NEEDSMATH) {
return FUNC<16>{}(std::forward<A>(x)...);
@@ -570,4 +570,4 @@ RT_API_ATTRS void CreatePartialReductionResult(Descriptor &result,
const char *intrinsic, TypeCode);
} // namespace Fortran::runtime
-#endif // FLANG_RT_TOOLS_H_
+#endif // FLANG_RT_RUNTIME_TOOLS_H_
diff --git a/flang-rt/include/flang-rt/type-code.h b/flang-rt/include/flang-rt/runtime/type-code.h
similarity index 93%
rename from flang-rt/include/flang-rt/type-code.h
rename to flang-rt/include/flang-rt/runtime/type-code.h
index a3b79462887c1..9416a2816fd43 100644
--- a/flang-rt/include/flang-rt/type-code.h
+++ b/flang-rt/include/flang-rt/runtime/type-code.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/type-code.h ----------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/type-code.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_TYPE_CODE_H_
-#define FLANG_RT_TYPE_CODE_H_
+#ifndef FLANG_RT_RUNTIME_TYPE_CODE_H_
+#define FLANG_RT_RUNTIME_TYPE_CODE_H_
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
@@ -75,4 +75,4 @@ class TypeCode {
ISO::CFI_type_t raw_{CFI_type_other};
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_TYPE_CODE_H_
+#endif // FLANG_RT_RUNTIME_TYPE_CODE_H_
diff --git a/flang-rt/include/flang-rt/type-info.h b/flang-rt/include/flang-rt/runtime/type-info.h
similarity index 98%
rename from flang-rt/include/flang-rt/type-info.h
rename to flang-rt/include/flang-rt/runtime/type-info.h
index dc5cd98d7523f..9891fcecdcb25 100644
--- a/flang-rt/include/flang-rt/type-info.h
+++ b/flang-rt/include/flang-rt/runtime/type-info.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/type-info.h ----------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/type-info.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_TYPE_INFO_H_
-#define FLANG_RT_TYPE_INFO_H_
+#ifndef FLANG_RT_RUNTIME_TYPE_INFO_H_
+#define FLANG_RT_RUNTIME_TYPE_INFO_H_
// A C++ perspective of the derived type description schemata in
// flang/module/__fortran_type_info.f90.
@@ -321,4 +321,4 @@ class DerivedType {
};
} // namespace Fortran::runtime::typeInfo
-#endif // FLANG_RT_TYPE_INFO_H_
+#endif // FLANG_RT_RUNTIME_TYPE_INFO_H_
diff --git a/flang-rt/include/flang-rt/utf.h b/flang-rt/include/flang-rt/runtime/utf.h
similarity index 94%
rename from flang-rt/include/flang-rt/utf.h
rename to flang-rt/include/flang-rt/runtime/utf.h
index 648937ca14f16..b5add823124fc 100644
--- a/flang-rt/include/flang-rt/utf.h
+++ b/flang-rt/include/flang-rt/runtime/utf.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/utf.h ----------------------------------*- C++ -*-===//
+//===-- include/flang-rt/runtime/utf.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.
@@ -38,8 +38,8 @@
// standard maximum. However, we support extended forms up to 32 bits so that
// CHARACTER(KIND=4) can be abused to hold arbitrary 32-bit data.
-#ifndef FLANG_RT_UTF_H_
-#define FLANG_RT_UTF_H_
+#ifndef FLANG_RT_RUNTIME_UTF_H_
+#define FLANG_RT_RUNTIME_UTF_H_
#include "flang/Common/optional.h"
#include <cstddef>
@@ -70,4 +70,4 @@ RT_API_ATTRS Fortran::common::optional<char32_t> DecodeUTF8(const char *);
RT_API_ATTRS std::size_t EncodeUTF8(char *, char32_t);
} // namespace Fortran::runtime
-#endif // FLANG_RT_UTF_H_
+#endif // FLANG_RT_RUNTIME_UTF_H_
diff --git a/flang-rt/lib/flang_rt/CUDA/allocatable.cpp b/flang-rt/lib/cuda/allocatable.cpp
similarity index 94%
rename from flang-rt/lib/flang_rt/CUDA/allocatable.cpp
rename to flang-rt/lib/cuda/allocatable.cpp
index 2281e2148d4ae..2f549b604fe58 100644
--- a/flang-rt/lib/flang_rt/CUDA/allocatable.cpp
+++ b/flang-rt/lib/cuda/allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/allocatable.cpp -----------------------*- C++ -*-===//
+//===-- lib/cuda/allocatable.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/allocatable.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memmove-function.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/allocator.cpp b/flang-rt/lib/cuda/allocator.cpp
similarity index 86%
rename from flang-rt/lib/flang_rt/CUDA/allocator.cpp
rename to flang-rt/lib/cuda/allocator.cpp
index dc1ce5920e222..511543f6a4863 100644
--- a/flang-rt/lib/flang_rt/CUDA/allocator.cpp
+++ b/flang-rt/lib/cuda/allocator.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/allocator.cpp -------------------------*- C++ -*-===//
+//===-- lib/cuda/allocator.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Support/Fortran.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/descriptor.cpp b/flang-rt/lib/cuda/descriptor.cpp
similarity index 90%
rename from flang-rt/lib/flang_rt/CUDA/descriptor.cpp
rename to flang-rt/lib/cuda/descriptor.cpp
index 9ec79ccea22c3..60e096acfde32 100644
--- a/flang-rt/lib/flang_rt/CUDA/descriptor.cpp
+++ b/flang-rt/lib/cuda/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/descriptor.cpp ------------------------*- C++ -*-===//
+//===-- lib/cuda/descriptor.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/descriptor.h"
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/init.cpp b/flang-rt/lib/cuda/init.cpp
similarity index 83%
rename from flang-rt/lib/flang_rt/CUDA/init.cpp
rename to flang-rt/lib/cuda/init.cpp
index f2d47d258519e..d79bffc32424d 100644
--- a/flang-rt/lib/flang_rt/CUDA/init.cpp
+++ b/flang-rt/lib/cuda/init.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/init.cpp ------------------------------*- C++ -*-===//
+//===-- lib/cuda/init.cpp ---------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/init.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/kernel.cpp b/flang-rt/lib/cuda/kernel.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/CUDA/kernel.cpp
rename to flang-rt/lib/cuda/kernel.cpp
index 7f9786319d574..75eb639817b9a 100644
--- a/flang-rt/lib/flang_rt/CUDA/kernel.cpp
+++ b/flang-rt/lib/cuda/kernel.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/kernel.cpp ----------------------------*- C++ -*-===//
+//===-- lib/cuda/kernel.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/kernel.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/memmove-function.cpp b/flang-rt/lib/cuda/memmove-function.cpp
similarity index 91%
rename from flang-rt/lib/flang_rt/CUDA/memmove-function.cpp
rename to flang-rt/lib/cuda/memmove-function.cpp
index ca04e20379d03..a7eb0cf1a3e7a 100644
--- a/flang-rt/lib/flang_rt/CUDA/memmove-function.cpp
+++ b/flang-rt/lib/cuda/memmove-function.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/memmove-function.cpp ------------------*- C++ -*-===//
+//===-- lib/cuda/memmove-function.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/memmove-function.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/memory.cpp b/flang-rt/lib/cuda/memory.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/CUDA/memory.cpp
rename to flang-rt/lib/cuda/memory.cpp
index 3d4a74f5f9e52..7ead0dd35e1d9 100644
--- a/flang-rt/lib/flang_rt/CUDA/memory.cpp
+++ b/flang-rt/lib/cuda/memory.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/memory.cpp ----------------------------*- C++ -*-===//
+//===-- lib/cuda/memory.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/memory.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memmove-function.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/pointer.cpp b/flang-rt/lib/cuda/pointer.cpp
similarity index 92%
rename from flang-rt/lib/flang_rt/CUDA/pointer.cpp
rename to flang-rt/lib/cuda/pointer.cpp
index b6e8033933834..d94e3958b9153 100644
--- a/flang-rt/lib/flang_rt/CUDA/pointer.cpp
+++ b/flang-rt/lib/cuda/pointer.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/pointer.cpp ---------------------------*- C++ -*-===//
+//===-- lib/cuda/pointer.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/pointer.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/memmove-function.h"
#include "flang/Runtime/pointer.h"
diff --git a/flang-rt/lib/flang_rt/CUDA/registration.cpp b/flang-rt/lib/cuda/registration.cpp
similarity index 93%
rename from flang-rt/lib/flang_rt/CUDA/registration.cpp
rename to flang-rt/lib/cuda/registration.cpp
index f8a7b197bed3b..60b0e491b6ffd 100644
--- a/flang-rt/lib/flang_rt/CUDA/registration.cpp
+++ b/flang-rt/lib/cuda/registration.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/CUDA/registration.cpp ----------------------*- C++ -*-===//
+//===-- lib/cuda/registration.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/registration.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/lib/FortranFloat128Math/acos.cpp b/flang-rt/lib/quadmath/acos.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/acos.cpp
rename to flang-rt/lib/quadmath/acos.cpp
index 7f20654752754..d094121f0f678 100644
--- a/flang-rt/lib/FortranFloat128Math/acos.cpp
+++ b/flang-rt/lib/quadmath/acos.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/acos.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/acos.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/acosh.cpp b/flang-rt/lib/quadmath/acosh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/acosh.cpp
rename to flang-rt/lib/quadmath/acosh.cpp
index 73b64230f08c7..968aa489d15a2 100644
--- a/flang-rt/lib/FortranFloat128Math/acosh.cpp
+++ b/flang-rt/lib/quadmath/acosh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/acosh.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/acosh.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/asin.cpp b/flang-rt/lib/quadmath/asin.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/asin.cpp
rename to flang-rt/lib/quadmath/asin.cpp
index b51ecb6b674d3..c3345cd3d748a 100644
--- a/flang-rt/lib/FortranFloat128Math/asin.cpp
+++ b/flang-rt/lib/quadmath/asin.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/asin.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/asin.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/asinh.cpp b/flang-rt/lib/quadmath/asinh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/asinh.cpp
rename to flang-rt/lib/quadmath/asinh.cpp
index 2fc181d075aec..1023b678b6131 100644
--- a/flang-rt/lib/FortranFloat128Math/asinh.cpp
+++ b/flang-rt/lib/quadmath/asinh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/asinh.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/asinh.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/atan.cpp b/flang-rt/lib/quadmath/atan.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/atan.cpp
rename to flang-rt/lib/quadmath/atan.cpp
index ff1ec39bfdebd..6379df3275c03 100644
--- a/flang-rt/lib/FortranFloat128Math/atan.cpp
+++ b/flang-rt/lib/quadmath/atan.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/atan.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/atan.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/atan2.cpp b/flang-rt/lib/quadmath/atan2.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/atan2.cpp
rename to flang-rt/lib/quadmath/atan2.cpp
index 4e809cb547a1b..7527b224cb3a5 100644
--- a/flang-rt/lib/FortranFloat128Math/atan2.cpp
+++ b/flang-rt/lib/quadmath/atan2.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/atan2.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/atan2.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/atanh.cpp b/flang-rt/lib/quadmath/atanh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/atanh.cpp
rename to flang-rt/lib/quadmath/atanh.cpp
index d4e3e7426b16d..c7455fcb7ca67 100644
--- a/flang-rt/lib/FortranFloat128Math/atanh.cpp
+++ b/flang-rt/lib/quadmath/atanh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/atanh.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/atanh.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/ceil.cpp b/flang-rt/lib/quadmath/ceil.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/ceil.cpp
rename to flang-rt/lib/quadmath/ceil.cpp
index f439f22c0565a..03a98bedfdc03 100644
--- a/flang-rt/lib/FortranFloat128Math/ceil.cpp
+++ b/flang-rt/lib/quadmath/ceil.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/ceil.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/ceil.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/complex-math.c b/flang-rt/lib/quadmath/complex-math.c
similarity index 96%
rename from flang-rt/lib/FortranFloat128Math/complex-math.c
rename to flang-rt/lib/quadmath/complex-math.c
index fed37dfce6332..e485fd7eb5dbb 100644
--- a/flang-rt/lib/FortranFloat128Math/complex-math.c
+++ b/flang-rt/lib/quadmath/complex-math.c
@@ -1,4 +1,4 @@
-/*===-- lib/FortranFloat128Math/complex-math.c ----------------------*- C -*-===
+/*===-- lib/quadmath/complex-math.c ---------------------------------*- C -*-===
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
* See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/complex-math.h b/flang-rt/lib/quadmath/complex-math.h
similarity index 88%
rename from flang-rt/lib/FortranFloat128Math/complex-math.h
rename to flang-rt/lib/quadmath/complex-math.h
index d22598d52e832..424ed84da4e01 100644
--- a/flang-rt/lib/FortranFloat128Math/complex-math.h
+++ b/flang-rt/lib/quadmath/complex-math.h
@@ -1,4 +1,4 @@
-/*===-- lib/FortranFloat128Math/complex-math.h ----------------------*- C -*-===
+/*===-- lib/quadmath/complex-math.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.
@@ -6,8 +6,8 @@
*
*===----------------------------------------------------------------------===*/
-#ifndef FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
-#define FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
+#ifndef FLANG_RT_QUADMATH_COMPLEX_MATH_H_
+#define FLANG_RT_QUADMATH_COMPLEX_MATH_H_
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
@@ -59,4 +59,4 @@
#error "Float128Math build with glibc>=2.26 is unsupported yet"
#endif
-#endif // FLANG_RT_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
+#endif /* FLANG_RT_QUADMATH_COMPLEX_MATH_H_ */
diff --git a/flang-rt/lib/FortranFloat128Math/cos.cpp b/flang-rt/lib/quadmath/cos.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/cos.cpp
rename to flang-rt/lib/quadmath/cos.cpp
index aed337c325836..1116080c53d2a 100644
--- a/flang-rt/lib/FortranFloat128Math/cos.cpp
+++ b/flang-rt/lib/quadmath/cos.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/cos.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/cos.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/cosh.cpp b/flang-rt/lib/quadmath/cosh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/cosh.cpp
rename to flang-rt/lib/quadmath/cosh.cpp
index bddbff766b575..dd5978e5e5f08 100644
--- a/flang-rt/lib/FortranFloat128Math/cosh.cpp
+++ b/flang-rt/lib/quadmath/cosh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/cosh.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/cosh.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/erf.cpp b/flang-rt/lib/quadmath/erf.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/erf.cpp
rename to flang-rt/lib/quadmath/erf.cpp
index a56430040248d..0021b7900f6a1 100644
--- a/flang-rt/lib/FortranFloat128Math/erf.cpp
+++ b/flang-rt/lib/quadmath/erf.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/erf.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/erf.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/erfc.cpp b/flang-rt/lib/quadmath/erfc.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/erfc.cpp
rename to flang-rt/lib/quadmath/erfc.cpp
index 255a2a7b4edac..5b80fb475b3fc 100644
--- a/flang-rt/lib/FortranFloat128Math/erfc.cpp
+++ b/flang-rt/lib/quadmath/erfc.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/erfc.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/erfc.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/exp.cpp b/flang-rt/lib/quadmath/exp.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/exp.cpp
rename to flang-rt/lib/quadmath/exp.cpp
index 9bc87d959cf69..94e444c3b00c7 100644
--- a/flang-rt/lib/FortranFloat128Math/exp.cpp
+++ b/flang-rt/lib/quadmath/exp.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/exp.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/exp.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/exponent.cpp b/flang-rt/lib/quadmath/exponent.cpp
similarity index 92%
rename from flang-rt/lib/FortranFloat128Math/exponent.cpp
rename to flang-rt/lib/quadmath/exponent.cpp
index bf27a26a73427..0d2fa6478cca8 100644
--- a/flang-rt/lib/FortranFloat128Math/exponent.cpp
+++ b/flang-rt/lib/quadmath/exponent.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/exponent.cpp --------------------*- C++ -*-===//
+//===-- lib/quadmath/exponent.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/floor.cpp b/flang-rt/lib/quadmath/floor.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/floor.cpp
rename to flang-rt/lib/quadmath/floor.cpp
index abda5fadfd296..e5dfb33db82ce 100644
--- a/flang-rt/lib/FortranFloat128Math/floor.cpp
+++ b/flang-rt/lib/quadmath/floor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/floor.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/floor.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/fma.cpp b/flang-rt/lib/quadmath/fma.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/fma.cpp
rename to flang-rt/lib/quadmath/fma.cpp
index 2e7aabedf1e8c..910303af32339 100644
--- a/flang-rt/lib/FortranFloat128Math/fma.cpp
+++ b/flang-rt/lib/quadmath/fma.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/fma.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/fma.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/fraction.cpp b/flang-rt/lib/quadmath/fraction.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/fraction.cpp
rename to flang-rt/lib/quadmath/fraction.cpp
index bf1da6f63e5ce..a9927666a7b00 100644
--- a/flang-rt/lib/FortranFloat128Math/fraction.cpp
+++ b/flang-rt/lib/quadmath/fraction.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/fraction.cpp --------------------*- C++ -*-===//
+//===-- lib/quadmath/fraction.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/hypot.cpp b/flang-rt/lib/quadmath/hypot.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/hypot.cpp
rename to flang-rt/lib/quadmath/hypot.cpp
index 910bda798c1a0..3090d0b2aff74 100644
--- a/flang-rt/lib/FortranFloat128Math/hypot.cpp
+++ b/flang-rt/lib/quadmath/hypot.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/hypot.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/hypot.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/j0.cpp b/flang-rt/lib/quadmath/j0.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/j0.cpp
rename to flang-rt/lib/quadmath/j0.cpp
index d2fac98c3ec69..06df1c2aca452 100644
--- a/flang-rt/lib/FortranFloat128Math/j0.cpp
+++ b/flang-rt/lib/quadmath/j0.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/j0.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/j0.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/j1.cpp b/flang-rt/lib/quadmath/j1.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/j1.cpp
rename to flang-rt/lib/quadmath/j1.cpp
index 60401030124c8..d8a1f123b95e6 100644
--- a/flang-rt/lib/FortranFloat128Math/j1.cpp
+++ b/flang-rt/lib/quadmath/j1.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/j1.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/j1.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/jn.cpp b/flang-rt/lib/quadmath/jn.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/jn.cpp
rename to flang-rt/lib/quadmath/jn.cpp
index 71e11335d0830..a53e305bb8746 100644
--- a/flang-rt/lib/FortranFloat128Math/jn.cpp
+++ b/flang-rt/lib/quadmath/jn.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/jn.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/jn.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/lgamma.cpp b/flang-rt/lib/quadmath/lgamma.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/lgamma.cpp
rename to flang-rt/lib/quadmath/lgamma.cpp
index 1ae4cc4d95d61..b96dff1d0d72a 100644
--- a/flang-rt/lib/FortranFloat128Math/lgamma.cpp
+++ b/flang-rt/lib/quadmath/lgamma.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/lgamma.cpp ----------------------*- C++ -*-===//
+//===-- lib/quadmath/lgamma.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/llround.cpp b/flang-rt/lib/quadmath/llround.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/llround.cpp
rename to flang-rt/lib/quadmath/llround.cpp
index 5bd4cc26dd497..8f2913d390431 100644
--- a/flang-rt/lib/FortranFloat128Math/llround.cpp
+++ b/flang-rt/lib/quadmath/llround.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/llround.cpp ---------------------*- C++ -*-===//
+//===-- lib/quadmath/llround.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/log.cpp b/flang-rt/lib/quadmath/log.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/log.cpp
rename to flang-rt/lib/quadmath/log.cpp
index 414e41ae0ce29..0c489c922a3fc 100644
--- a/flang-rt/lib/FortranFloat128Math/log.cpp
+++ b/flang-rt/lib/quadmath/log.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/log.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/log.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/log10.cpp b/flang-rt/lib/quadmath/log10.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/log10.cpp
rename to flang-rt/lib/quadmath/log10.cpp
index 55db1b1a2dc1f..a2f222e15a147 100644
--- a/flang-rt/lib/FortranFloat128Math/log10.cpp
+++ b/flang-rt/lib/quadmath/log10.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/log10.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/log10.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/lround.cpp b/flang-rt/lib/quadmath/lround.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/lround.cpp
rename to flang-rt/lib/quadmath/lround.cpp
index a0bea49243681..539ee107a3881 100644
--- a/flang-rt/lib/FortranFloat128Math/lround.cpp
+++ b/flang-rt/lib/quadmath/lround.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/lround.cpp ----------------------*- C++ -*-===//
+//===-- lib/quadmath/lround.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/math-entries.h b/flang-rt/lib/quadmath/math-entries.h
similarity index 96%
rename from flang-rt/lib/FortranFloat128Math/math-entries.h
rename to flang-rt/lib/quadmath/math-entries.h
index 72b12a1645c7d..6e47f32cc8a43 100644
--- a/flang-rt/lib/FortranFloat128Math/math-entries.h
+++ b/flang-rt/lib/quadmath/math-entries.h
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/math-entries.h ------------------*- C++ -*-===//
+//===-- lib/quadmath/math-entries.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
-#define FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
+#ifndef FLANG_RT_QUADMATH_MATH_ENTRIES_H_
+#define FLANG_RT_QUADMATH_MATH_ENTRIES_H_
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
#include <cfloat>
@@ -232,4 +232,4 @@ DEFINE_SIMPLE_ALIAS(Yn, ynl)
} // namespace Fortran::runtime
-#endif // FLANG_RT_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
+#endif // FLANG_RT_QUADMATH_MATH_ENTRIES_H_
diff --git a/flang-rt/lib/FortranFloat128Math/mod-real.cpp b/flang-rt/lib/quadmath/mod-real.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/mod-real.cpp
rename to flang-rt/lib/quadmath/mod-real.cpp
index beb412f719c52..0230964e3ddc2 100644
--- a/flang-rt/lib/FortranFloat128Math/mod-real.cpp
+++ b/flang-rt/lib/quadmath/mod-real.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/mod-real.cpp --------------------*- C++ -*-===//
+//===-- lib/quadmath/mod-real.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/modulo-real.cpp b/flang-rt/lib/quadmath/modulo-real.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/modulo-real.cpp
rename to flang-rt/lib/quadmath/modulo-real.cpp
index c8160b1d27451..0f28747b86985 100644
--- a/flang-rt/lib/FortranFloat128Math/modulo-real.cpp
+++ b/flang-rt/lib/quadmath/modulo-real.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/modulo-real.cpp -----------------*- C++ -*-===//
+//===-- lib/quadmath/modulo-real.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/nearbyint.cpp b/flang-rt/lib/quadmath/nearbyint.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/nearbyint.cpp
rename to flang-rt/lib/quadmath/nearbyint.cpp
index d572641e2b0d4..3811fc53d1d82 100644
--- a/flang-rt/lib/FortranFloat128Math/nearbyint.cpp
+++ b/flang-rt/lib/quadmath/nearbyint.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/nearbyint.cpp -------------------*- C++ -*-===//
+//===-- lib/quadmath/nearbyint.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/nearest.cpp b/flang-rt/lib/quadmath/nearest.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/nearest.cpp
rename to flang-rt/lib/quadmath/nearest.cpp
index 3e32de7ea9d0a..8c1969a7b596c 100644
--- a/flang-rt/lib/FortranFloat128Math/nearest.cpp
+++ b/flang-rt/lib/quadmath/nearest.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/nearest.cpp ---------------------*- C++ -*-===//
+//===-- lib/quadmath/nearest.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/norm2.cpp b/flang-rt/lib/quadmath/norm2.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/norm2.cpp
rename to flang-rt/lib/quadmath/norm2.cpp
index 8f6b2c87eec32..e98f4007737d1 100644
--- a/flang-rt/lib/FortranFloat128Math/norm2.cpp
+++ b/flang-rt/lib/quadmath/norm2.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/norm2.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/norm2.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
#include "math-entries.h"
#include "numeric-template-specs.h"
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h b/flang-rt/lib/quadmath/numeric-template-specs.h
similarity index 82%
rename from flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
rename to flang-rt/lib/quadmath/numeric-template-specs.h
index e618902b03adc..e215ad70eca14 100644
--- a/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
+++ b/flang-rt/lib/quadmath/numeric-template-specs.h
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/numeric-template-specs.h --------*- C++ -*-===//
+//===-- lib/quadmath/numeric-template-specs.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
-#define FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#ifndef FLANG_RT_QUADMATH_NUMERIC_TEMPLATE_SPECS_H_
+#define FLANG_RT_QUADMATH_NUMERIC_TEMPLATE_SPECS_H_
#include "math-entries.h"
-#include "flang-rt/numeric-templates.h"
+#include "flang-rt/runtime/numeric-templates.h"
namespace Fortran::runtime {
using F128Type = CppTypeFor<TypeCategory::Real, 16>;
@@ -52,4 +52,4 @@ template <> struct SQRTTy<F128Type> {
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#endif // FLANG_RT_QUADMATH_NUMERIC_TEMPLATE_SPECS_H_
diff --git a/flang-rt/lib/FortranFloat128Math/pow.cpp b/flang-rt/lib/quadmath/pow.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/pow.cpp
rename to flang-rt/lib/quadmath/pow.cpp
index bbdda217c5108..29c0536254658 100644
--- a/flang-rt/lib/FortranFloat128Math/pow.cpp
+++ b/flang-rt/lib/quadmath/pow.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/pow.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/pow.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/random.cpp b/flang-rt/lib/quadmath/random.cpp
similarity index 85%
rename from flang-rt/lib/FortranFloat128Math/random.cpp
rename to flang-rt/lib/quadmath/random.cpp
index 701f9429fcb6c..a6d22733ebce4 100644
--- a/flang-rt/lib/FortranFloat128Math/random.cpp
+++ b/flang-rt/lib/quadmath/random.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/random.cpp ----------------------*- C++ -*-===//
+//===-- lib/quadmath/random.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
#include "math-entries.h"
#include "numeric-template-specs.h"
-#include "flang-rt/random-templates.h"
+#include "flang-rt/runtime/random-templates.h"
using namespace Fortran::runtime::random;
extern "C" {
diff --git a/flang-rt/lib/FortranFloat128Math/remainder.cpp b/flang-rt/lib/quadmath/remainder.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/remainder.cpp
rename to flang-rt/lib/quadmath/remainder.cpp
index ca4165a357eda..4b68cdd6ac9de 100644
--- a/flang-rt/lib/FortranFloat128Math/remainder.cpp
+++ b/flang-rt/lib/quadmath/remainder.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/remainder.cpp -------------------*- C++ -*-===//
+//===-- lib/quadmath/remainder.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/round.cpp b/flang-rt/lib/quadmath/round.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/round.cpp
rename to flang-rt/lib/quadmath/round.cpp
index 348f7ff8a6771..844338f5e6413 100644
--- a/flang-rt/lib/FortranFloat128Math/round.cpp
+++ b/flang-rt/lib/quadmath/round.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/round.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/round.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/rrspacing.cpp b/flang-rt/lib/quadmath/rrspacing.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/rrspacing.cpp
rename to flang-rt/lib/quadmath/rrspacing.cpp
index 0a87a5c572652..e8613f4d7d7e2 100644
--- a/flang-rt/lib/FortranFloat128Math/rrspacing.cpp
+++ b/flang-rt/lib/quadmath/rrspacing.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/rrspacing.cpp -------------------*- C++ -*-===//
+//===-- lib/quadmath/rrspacing.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/scale.cpp b/flang-rt/lib/quadmath/scale.cpp
similarity index 92%
rename from flang-rt/lib/FortranFloat128Math/scale.cpp
rename to flang-rt/lib/quadmath/scale.cpp
index a316a2a0cd706..3d919f85a4487 100644
--- a/flang-rt/lib/FortranFloat128Math/scale.cpp
+++ b/flang-rt/lib/quadmath/scale.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/scale.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/scale.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/set-exponent.cpp b/flang-rt/lib/quadmath/set-exponent.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/set-exponent.cpp
rename to flang-rt/lib/quadmath/set-exponent.cpp
index 335c68f632f18..d6b582e7c4f38 100644
--- a/flang-rt/lib/FortranFloat128Math/set-exponent.cpp
+++ b/flang-rt/lib/quadmath/set-exponent.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/set-exponent.cpp ----------------*- C++ -*-===//
+//===-- lib/quadmath/set-exponent.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/sin.cpp b/flang-rt/lib/quadmath/sin.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/sin.cpp
rename to flang-rt/lib/quadmath/sin.cpp
index bd5f62808fc31..dcff2f9ce02ca 100644
--- a/flang-rt/lib/FortranFloat128Math/sin.cpp
+++ b/flang-rt/lib/quadmath/sin.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/sin.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/sin.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/sinh.cpp b/flang-rt/lib/quadmath/sinh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/sinh.cpp
rename to flang-rt/lib/quadmath/sinh.cpp
index 07f12d437ed56..3ab7280f705a6 100644
--- a/flang-rt/lib/FortranFloat128Math/sinh.cpp
+++ b/flang-rt/lib/quadmath/sinh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/sinh.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/sinh.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/spacing.cpp b/flang-rt/lib/quadmath/spacing.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/spacing.cpp
rename to flang-rt/lib/quadmath/spacing.cpp
index b10351ab95555..1d7ecdb4852d2 100644
--- a/flang-rt/lib/FortranFloat128Math/spacing.cpp
+++ b/flang-rt/lib/quadmath/spacing.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/spacing.cpp ---------------------*- C++ -*-===//
+//===-- lib/quadmath/spacing.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/sqrt.cpp b/flang-rt/lib/quadmath/sqrt.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/sqrt.cpp
rename to flang-rt/lib/quadmath/sqrt.cpp
index b6fd6eabc267b..6e0d11a6697f0 100644
--- a/flang-rt/lib/FortranFloat128Math/sqrt.cpp
+++ b/flang-rt/lib/quadmath/sqrt.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/sqrt.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/sqrt.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/tan.cpp b/flang-rt/lib/quadmath/tan.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/tan.cpp
rename to flang-rt/lib/quadmath/tan.cpp
index 437c0692191e8..6f09b93060228 100644
--- a/flang-rt/lib/FortranFloat128Math/tan.cpp
+++ b/flang-rt/lib/quadmath/tan.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/tan.cpp -------------------------*- C++ -*-===//
+//===-- lib/quadmath/tan.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/tanh.cpp b/flang-rt/lib/quadmath/tanh.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/tanh.cpp
rename to flang-rt/lib/quadmath/tanh.cpp
index 48544d4bb75f4..214a18d5c3778 100644
--- a/flang-rt/lib/FortranFloat128Math/tanh.cpp
+++ b/flang-rt/lib/quadmath/tanh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/tanh.cpp ------------------------*- C++ -*-===//
+//===-- lib/quadmath/tanh.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/tgamma.cpp b/flang-rt/lib/quadmath/tgamma.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/tgamma.cpp
rename to flang-rt/lib/quadmath/tgamma.cpp
index 8d7963caa61c5..2b05a60dcaabb 100644
--- a/flang-rt/lib/FortranFloat128Math/tgamma.cpp
+++ b/flang-rt/lib/quadmath/tgamma.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/tgamma.cpp ----------------------*- C++ -*-===//
+//===-- lib/quadmath/tgamma.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/trunc.cpp b/flang-rt/lib/quadmath/trunc.cpp
similarity index 91%
rename from flang-rt/lib/FortranFloat128Math/trunc.cpp
rename to flang-rt/lib/quadmath/trunc.cpp
index 4a3dddeb1326c..cd7c27b569fc3 100644
--- a/flang-rt/lib/FortranFloat128Math/trunc.cpp
+++ b/flang-rt/lib/quadmath/trunc.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/trunc.cpp -----------------------*- C++ -*-===//
+//===-- lib/quadmath/trunc.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/y0.cpp b/flang-rt/lib/quadmath/y0.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/y0.cpp
rename to flang-rt/lib/quadmath/y0.cpp
index c5b266b5cec03..9db04277660ad 100644
--- a/flang-rt/lib/FortranFloat128Math/y0.cpp
+++ b/flang-rt/lib/quadmath/y0.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/y0.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/y0.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/y1.cpp b/flang-rt/lib/quadmath/y1.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/y1.cpp
rename to flang-rt/lib/quadmath/y1.cpp
index 8b492c69e3741..92e658195f3d9 100644
--- a/flang-rt/lib/FortranFloat128Math/y1.cpp
+++ b/flang-rt/lib/quadmath/y1.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/y1.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/y1.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/FortranFloat128Math/yn.cpp b/flang-rt/lib/quadmath/yn.cpp
similarity index 90%
rename from flang-rt/lib/FortranFloat128Math/yn.cpp
rename to flang-rt/lib/quadmath/yn.cpp
index cb212b400f6e0..20c0bc9d5218e 100644
--- a/flang-rt/lib/FortranFloat128Math/yn.cpp
+++ b/flang-rt/lib/quadmath/yn.cpp
@@ -1,4 +1,4 @@
-//===-- lib/FortranFloat128Math/yn.cpp --------------------------*- C++ -*-===//
+//===-- lib/quadmath/yn.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp b/flang-rt/lib/runtime/ISO_Fortran_binding.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
rename to flang-rt/lib/runtime/ISO_Fortran_binding.cpp
index d9b0bfe9aeb6b..a5f8b357ae0b8 100644
--- a/flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
+++ b/flang-rt/lib/runtime/ISO_Fortran_binding.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/ISO_Fortran_binding.cpp --------------------*- C++ -*-===//
+//===-- lib/runtime/ISO_Fortran_binding.cpp ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,9 +10,9 @@
// as specified in section 18.5.5 of Fortran 2018.
#include "ISO_Fortran_util.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/pointer.h"
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/ISO_Fortran_util.h b/flang-rt/lib/runtime/ISO_Fortran_util.h
similarity index 90%
rename from flang-rt/lib/flang_rt/ISO_Fortran_util.h
rename to flang-rt/lib/runtime/ISO_Fortran_util.h
index 9d4a907e1adde..9bbc03eefc490 100644
--- a/flang-rt/lib/flang_rt/ISO_Fortran_util.h
+++ b/flang-rt/lib/runtime/ISO_Fortran_util.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/ISO_Fortran_util.h -------------------------*- C++ -*-===//
+//===-- lib/runtime/ISO_Fortran_util.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.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_ISO_FORTRAN_UTIL_H_
-#define FLANG_RT_ISO_FORTRAN_UTIL_H_
+#ifndef FLANG_RT_RUNTIME_ISO_FORTRAN_UTIL_H_
+#define FLANG_RT_RUNTIME_ISO_FORTRAN_UTIL_H_
// Internal utils for establishing CFI_cdesc_t descriptors.
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include <cstdlib>
@@ -99,4 +99,4 @@ static inline RT_API_ATTRS void EstablishDescriptor(CFI_cdesc_t *descriptor,
}
}
} // namespace Fortran::ISO
-#endif // FLANG_RT_ISO_FORTRAN_UTIL_H_
+#endif // FLANG_RT_RUNTIME_ISO_FORTRAN_UTIL_H_
diff --git a/flang-rt/lib/flang_rt/allocatable.cpp b/flang-rt/lib/runtime/allocatable.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/allocatable.cpp
rename to flang-rt/lib/runtime/allocatable.cpp
index 63ef99b8a72d1..a51816129199a 100644
--- a/flang-rt/lib/flang_rt/allocatable.cpp
+++ b/flang-rt/lib/runtime/allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/allocatable.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/allocatable.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/allocatable.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
diff --git a/flang-rt/lib/flang_rt/allocator-registry.cpp b/flang-rt/lib/runtime/allocator-registry.cpp
similarity index 89%
rename from flang-rt/lib/flang_rt/allocator-registry.cpp
rename to flang-rt/lib/runtime/allocator-registry.cpp
index 11847de68724d..f8a8daaf8e748 100644
--- a/flang-rt/lib/flang_rt/allocator-registry.cpp
+++ b/flang-rt/lib/runtime/allocator-registry.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/allocator-registry.cpp ---------------------*- C++ -*-===//
+//===-- lib/runtime/allocator-registry.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/terminator.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/array-constructor.cpp b/flang-rt/lib/runtime/array-constructor.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/array-constructor.cpp
rename to flang-rt/lib/runtime/array-constructor.cpp
index d2765c9439b75..7e267e714927f 100644
--- a/flang-rt/lib/flang_rt/array-constructor.cpp
+++ b/flang-rt/lib/runtime/array-constructor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/array-constructor.cpp ----------------------*- C++ -*-===//
+//===-- lib/runtime/array-constructor.cpp -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/array-constructor.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/array-constructor.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/assign.h"
diff --git a/flang-rt/lib/flang_rt/assign.cpp b/flang-rt/lib/runtime/assign.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/assign.cpp
rename to flang-rt/lib/runtime/assign.cpp
index 0d6045eac503a..a1f3715f278c1 100644
--- a/flang-rt/lib/flang_rt/assign.cpp
+++ b/flang-rt/lib/runtime/assign.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/assign.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/assign.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/assign.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/buffer.cpp b/flang-rt/lib/runtime/buffer.cpp
similarity index 90%
rename from flang-rt/lib/flang_rt/buffer.cpp
rename to flang-rt/lib/runtime/buffer.cpp
index e084155068bc5..4cf85e13b6d36 100644
--- a/flang-rt/lib/flang_rt/buffer.cpp
+++ b/flang-rt/lib/runtime/buffer.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/buffer.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/buffer.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/buffer.h"
+#include "flang-rt/runtime/buffer.h"
#include <algorithm>
namespace Fortran::runtime::io {
diff --git a/flang-rt/lib/flang_rt/character.cpp b/flang-rt/lib/runtime/character.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/character.cpp
rename to flang-rt/lib/runtime/character.cpp
index 79d4ebdb0afbf..10cf27c37c4d8 100644
--- a/flang-rt/lib/flang_rt/character.cpp
+++ b/flang-rt/lib/runtime/character.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/character.cpp ------------------------------*- C++ -*-===//
+//===-- lib/runtime/character.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/character.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/bit-population-count.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/character.h"
diff --git a/flang-rt/lib/flang_rt/command.cpp b/flang-rt/lib/runtime/command.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/command.cpp
rename to flang-rt/lib/runtime/command.cpp
index 498ae8db17224..8a5a61ac1ad44 100644
--- a/flang-rt/lib/flang_rt/command.cpp
+++ b/flang-rt/lib/runtime/command.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/command.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/command.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/command.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdlib>
#include <limits>
diff --git a/flang-rt/lib/flang_rt/complex-powi.cpp b/flang-rt/lib/runtime/complex-powi.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/complex-powi.cpp
rename to flang-rt/lib/runtime/complex-powi.cpp
index 287bafc422057..a561d114591cf 100644
--- a/flang-rt/lib/flang_rt/complex-powi.cpp
+++ b/flang-rt/lib/runtime/complex-powi.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/complex-powi.cpp ---------------------------*- C++ -*-===//
+//===-- lib/runtime/complex-powi.cpp ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/complex-reduction.c b/flang-rt/lib/runtime/complex-reduction.c
similarity index 100%
rename from flang-rt/lib/flang_rt/complex-reduction.c
rename to flang-rt/lib/runtime/complex-reduction.c
diff --git a/flang-rt/lib/flang_rt/complex-reduction.h b/flang-rt/lib/runtime/complex-reduction.h
similarity index 97%
rename from flang-rt/lib/flang_rt/complex-reduction.h
rename to flang-rt/lib/runtime/complex-reduction.h
index 45614ea660573..44c52fb02fa43 100644
--- a/flang-rt/lib/flang_rt/complex-reduction.h
+++ b/flang-rt/lib/runtime/complex-reduction.h
@@ -1,4 +1,4 @@
-/*===-- lib/flang_rt/complex-reduction.h ----------------------------*- C -*-===
+/*===-- lib/runtime/complex-reduction.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.
@@ -11,8 +11,8 @@
* with C++ build compilers that don't support C's _Complex.
*/
-#ifndef FLANG_RT_COMPLEX_REDUCTION_H_
-#define FLANG_RT_COMPLEX_REDUCTION_H_
+#ifndef FLANG_RT_RUNTIME_COMPLEX_REDUCTION_H_
+#define FLANG_RT_RUNTIME_COMPLEX_REDUCTION_H_
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
@@ -155,4 +155,4 @@ void RTNAME(ReduceComplex16DimValue)(
REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));
#endif
-#endif // FLANG_RT_COMPLEX_REDUCTION_H_
+#endif // FLANG_RT_RUNTIME_COMPLEX_REDUCTION_H_
diff --git a/flang-rt/lib/flang_rt/connection.cpp b/flang-rt/lib/runtime/connection.cpp
similarity index 91%
rename from flang-rt/lib/flang_rt/connection.cpp
rename to flang-rt/lib/runtime/connection.cpp
index 1c454b81389ac..2f01dbbb95920 100644
--- a/flang-rt/lib/flang_rt/connection.cpp
+++ b/flang-rt/lib/runtime/connection.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/connection.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/connection.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/connection.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/connection.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/io-stmt.h"
#include <algorithm>
namespace Fortran::runtime::io {
diff --git a/flang-rt/lib/flang_rt/copy.cpp b/flang-rt/lib/runtime/copy.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/copy.cpp
rename to flang-rt/lib/runtime/copy.cpp
index 0ad6946d3161a..5956642dd7258 100644
--- a/flang-rt/lib/flang_rt/copy.cpp
+++ b/flang-rt/lib/runtime/copy.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/copy.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/copy.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,9 +8,9 @@
#include "copy.h"
#include "stack.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Runtime/allocatable.h"
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/copy.h b/flang-rt/lib/runtime/copy.h
similarity index 78%
rename from flang-rt/lib/flang_rt/copy.h
rename to flang-rt/lib/runtime/copy.h
index f4abac323196b..836c9d4a1ef89 100644
--- a/flang-rt/lib/flang_rt/copy.h
+++ b/flang-rt/lib/runtime/copy.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/copy.h -------------------------------------*- C++ -*-===//
+//===-- lib/runtime/copy.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.
@@ -9,10 +9,10 @@
// Utilities that copy data in a type-aware fashion, allocating & duplicating
// allocatable/automatic components of derived types along the way.
-#ifndef FLANG_RT_COPY_H_
-#define FLANG_RT_COPY_H_
+#ifndef FLANG_RT_RUNTIME_COPY_H_
+#define FLANG_RT_RUNTIME_COPY_H_
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
namespace Fortran::runtime {
@@ -22,4 +22,4 @@ RT_API_ATTRS void CopyElement(const Descriptor &to, const SubscriptValue toAt[],
const Descriptor &from, const SubscriptValue fromAt[], Terminator &);
} // namespace Fortran::runtime
-#endif // FLANG_RT_COPY_H_
+#endif // FLANG_RT_RUNTIME_COPY_H_
diff --git a/flang-rt/lib/flang_rt/derived-api.cpp b/flang-rt/lib/runtime/derived-api.cpp
similarity index 95%
rename from flang-rt/lib/flang_rt/derived-api.cpp
rename to flang-rt/lib/runtime/derived-api.cpp
index 353bc4a83ebd9..884fa8ee7d095 100644
--- a/flang-rt/lib/flang_rt/derived-api.cpp
+++ b/flang-rt/lib/runtime/derived-api.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/derived-api.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/derived-api.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/derived-api.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/derived.cpp b/flang-rt/lib/runtime/derived.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/derived.cpp
rename to flang-rt/lib/runtime/derived.cpp
index cace9e1074e65..87e4b29d08c28 100644
--- a/flang-rt/lib/flang_rt/derived.cpp
+++ b/flang-rt/lib/runtime/derived.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/derived.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/derived.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/derived.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/descriptor-io.cpp b/flang-rt/lib/runtime/descriptor-io.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/descriptor-io.cpp
rename to flang-rt/lib/runtime/descriptor-io.cpp
index c5cfa4d7fc597..3db1455af52fe 100644
--- a/flang-rt/lib/flang_rt/descriptor-io.cpp
+++ b/flang-rt/lib/runtime/descriptor-io.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/descriptor-io.cpp --------------------------*- C++ -*-===//
+//===-- lib/runtime/descriptor-io.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/descriptor-io.h b/flang-rt/lib/runtime/descriptor-io.h
similarity index 98%
rename from flang-rt/lib/flang_rt/descriptor-io.h
rename to flang-rt/lib/runtime/descriptor-io.h
index 97bedce247d83..dd399164325cb 100644
--- a/flang-rt/lib/flang_rt/descriptor-io.h
+++ b/flang-rt/lib/runtime/descriptor-io.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/descriptor-io.h ----------------------------*- C++ -*-===//
+//===-- lib/runtime/descriptor-io.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_DESCRIPTOR_IO_H_
-#define FLANG_RT_DESCRIPTOR_IO_H_
+#ifndef FLANG_RT_RUNTIME_DESCRIPTOR_IO_H_
+#define FLANG_RT_RUNTIME_DESCRIPTOR_IO_H_
// Implementation of I/O data list item transfers based on descriptors.
// (All I/O items come through here so that the code is exercised for test;
@@ -17,11 +17,11 @@
#include "edit-input.h"
#include "edit-output.h"
#include "unit.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/namelist.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/namelist.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/type-info.h"
#include "flang/Common/optional.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/cpp-type.h"
@@ -626,4 +626,4 @@ static RT_API_ATTRS bool DescriptorIO(IoStatementState &io,
return false;
}
} // namespace Fortran::runtime::io::descr
-#endif // FLANG_RT_DESCRIPTOR_IO_H_
+#endif // FLANG_RT_RUNTIME_DESCRIPTOR_IO_H_
diff --git a/flang-rt/lib/flang_rt/descriptor.cpp b/flang-rt/lib/runtime/descriptor.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/descriptor.cpp
rename to flang-rt/lib/runtime/descriptor.cpp
index cdf01f12e7134..8241a34a4990c 100644
--- a/flang-rt/lib/flang_rt/descriptor.cpp
+++ b/flang-rt/lib/runtime/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/descriptor.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/descriptor.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "ISO_Fortran_util.h"
#include "memory.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
#include <cassert>
#include <cstdlib>
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/dot-product.cpp b/flang-rt/lib/runtime/dot-product.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/dot-product.cpp
rename to flang-rt/lib/runtime/dot-product.cpp
index ad600a4228463..20612f1876c15 100644
--- a/flang-rt/lib/flang_rt/dot-product.cpp
+++ b/flang-rt/lib/runtime/dot-product.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/dot-product.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/dot-product.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "float.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/reduction.h"
diff --git a/flang-rt/lib/flang_rt/edit-input.cpp b/flang-rt/lib/runtime/edit-input.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/edit-input.cpp
rename to flang-rt/lib/runtime/edit-input.cpp
index 7121f6e42dea6..99a266648f95c 100644
--- a/flang-rt/lib/flang_rt/edit-input.cpp
+++ b/flang-rt/lib/runtime/edit-input.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/edit-input.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/edit-input.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "edit-input.h"
-#include "flang-rt/namelist.h"
-#include "flang-rt/utf.h"
+#include "flang-rt/runtime/namelist.h"
+#include "flang-rt/runtime/utf.h"
#include "flang/Common/optional.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
diff --git a/flang-rt/lib/flang_rt/edit-input.h b/flang-rt/lib/runtime/edit-input.h
similarity index 87%
rename from flang-rt/lib/flang_rt/edit-input.h
rename to flang-rt/lib/runtime/edit-input.h
index fdee0f0e1131e..686cd461b3e34 100644
--- a/flang-rt/lib/flang_rt/edit-input.h
+++ b/flang-rt/lib/runtime/edit-input.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/edit-input.h -------------------------------*- C++ -*-===//
+//===-- lib/runtime/edit-input.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.
@@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_EDIT_INPUT_H_
-#define FLANG_RT_EDIT_INPUT_H_
+#ifndef FLANG_RT_RUNTIME_EDIT_INPUT_H_
+#define FLANG_RT_RUNTIME_EDIT_INPUT_H_
-#include "flang-rt/format.h"
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-stmt.h"
#include "flang/Decimal/decimal.h"
namespace Fortran::runtime::io {
@@ -50,4 +50,4 @@ extern template RT_API_ATTRS bool EditCharacterInput(
IoStatementState &, const DataEdit &, char32_t *, std::size_t);
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_EDIT_INPUT_H_
+#endif // FLANG_RT_RUNTIME_EDIT_INPUT_H_
diff --git a/flang-rt/lib/flang_rt/edit-output.cpp b/flang-rt/lib/runtime/edit-output.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/edit-output.cpp
rename to flang-rt/lib/runtime/edit-output.cpp
index 096bd4567a42a..36bbc638ff5fc 100644
--- a/flang-rt/lib/flang_rt/edit-output.cpp
+++ b/flang-rt/lib/runtime/edit-output.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/edit-output.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/edit-output.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "edit-output.h"
-#include "flang-rt/emit-encoded.h"
-#include "flang-rt/utf.h"
+#include "flang-rt/runtime/emit-encoded.h"
+#include "flang-rt/runtime/utf.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
#include <algorithm>
diff --git a/flang-rt/lib/flang_rt/edit-output.h b/flang-rt/lib/runtime/edit-output.h
similarity index 95%
rename from flang-rt/lib/flang_rt/edit-output.h
rename to flang-rt/lib/runtime/edit-output.h
index 729f4400bd631..51a47405e49e4 100644
--- a/flang-rt/lib/flang_rt/edit-output.h
+++ b/flang-rt/lib/runtime/edit-output.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/edit-output.h ------------------------------*- C++ -*-===//
+//===-- lib/runtime/edit-output.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.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_EDIT_OUTPUT_H_
-#define FLANG_RT_EDIT_OUTPUT_H_
+#ifndef FLANG_RT_RUNTIME_EDIT_OUTPUT_H_
+#define FLANG_RT_RUNTIME_EDIT_OUTPUT_H_
// Output data editing templates implementing the FORMAT data editing
// descriptors E, EN, ES, EX, D, F, and G for REAL data (and COMPLEX
@@ -18,8 +18,8 @@
// Drives the same fast binary-to-decimal formatting templates used
// in the f18 front-end.
-#include "flang-rt/format.h"
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-stmt.h"
#include "flang/Common/uint128.h"
#include "flang/Decimal/decimal.h"
@@ -138,4 +138,4 @@ extern template class RealOutputEditing<10>;
extern template class RealOutputEditing<16>;
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_EDIT_OUTPUT_H_
+#endif // FLANG_RT_RUNTIME_EDIT_OUTPUT_H_
diff --git a/flang-rt/lib/flang_rt/environment-default-list.h b/flang-rt/lib/runtime/environment-default-list.h
similarity index 100%
rename from flang-rt/lib/flang_rt/environment-default-list.h
rename to flang-rt/lib/runtime/environment-default-list.h
diff --git a/flang-rt/lib/flang_rt/environment.cpp b/flang-rt/lib/runtime/environment.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/environment.cpp
rename to flang-rt/lib/runtime/environment.cpp
index e3727398b898f..15380ba148df5 100644
--- a/flang-rt/lib/flang_rt/environment.cpp
+++ b/flang-rt/lib/runtime/environment.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/environment.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/environment.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/environment.h"
+#include "flang-rt/runtime/environment.h"
#include "environment-default-list.h"
#include "memory.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/exceptions.cpp b/flang-rt/lib/runtime/exceptions.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/exceptions.cpp
rename to flang-rt/lib/runtime/exceptions.cpp
index f417aa8810f1c..d676a0ad53aa9 100644
--- a/flang-rt/lib/flang_rt/exceptions.cpp
+++ b/flang-rt/lib/runtime/exceptions.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/exceptions.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/exceptions.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
// Runtime exception support.
#include "flang/Runtime/exceptions.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include <cfenv>
#if defined(__aarch64__) && !defined(_WIN32)
#include <fpu_control.h>
diff --git a/flang-rt/lib/flang_rt/execute.cpp b/flang-rt/lib/runtime/execute.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/execute.cpp
rename to flang-rt/lib/runtime/execute.cpp
index 8d56581c12a49..f180da846a32c 100644
--- a/flang-rt/lib/flang_rt/execute.cpp
+++ b/flang-rt/lib/runtime/execute.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/execute.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/execute.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/execute.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdlib>
#include <errno.h>
#include <future>
diff --git a/flang-rt/lib/flang_rt/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/extensions.cpp
rename to flang-rt/lib/runtime/extensions.cpp
index ef205c5aed689..75195c33a6c21 100644
--- a/flang-rt/lib/flang_rt/extensions.cpp
+++ b/flang-rt/lib/runtime/extensions.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/extensions.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/extensions.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,9 +10,9 @@
// extensions that will eventually be implemented in Fortran.
#include "flang/Runtime/extensions.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/command.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/io-api.h"
diff --git a/flang-rt/lib/flang_rt/external-unit.cpp b/flang-rt/lib/runtime/external-unit.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/external-unit.cpp
rename to flang-rt/lib/runtime/external-unit.cpp
index 4be90cbbcc4c8..b8004d6315994 100644
--- a/flang-rt/lib/flang_rt/external-unit.cpp
+++ b/flang-rt/lib/runtime/external-unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/external-unit.cpp --------------------------*- C++ -*-===//
+//===-- lib/runtime/external-unit.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,9 +12,9 @@
#include "unit-map.h"
#include "unit.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/tools.h"
// NOTE: the header files above may define OpenMP declare target
// variables, so they have to be included unconditionally
diff --git a/flang-rt/lib/flang_rt/extrema.cpp b/flang-rt/lib/runtime/extrema.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/extrema.cpp
rename to flang-rt/lib/runtime/extrema.cpp
index 8ecd7fbe91d77..3d84daa380441 100644
--- a/flang-rt/lib/flang_rt/extrema.cpp
+++ b/flang-rt/lib/runtime/extrema.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/extrema.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/extrema.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,7 @@
// and shapes and (for MAXLOC & MINLOC) result integer kinds. Also implements
// NORM2 using common infrastructure.
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
diff --git a/flang-rt/lib/flang_rt/file.cpp b/flang-rt/lib/runtime/file.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/file.cpp
rename to flang-rt/lib/runtime/file.cpp
index c9fcf0f97b718..16e73db488727 100644
--- a/flang-rt/lib/flang_rt/file.cpp
+++ b/flang-rt/lib/runtime/file.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/file.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/file.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/file.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/file.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/magic-numbers.h"
#include <algorithm>
#include <cerrno>
diff --git a/flang-rt/lib/flang_rt/findloc.cpp b/flang-rt/lib/runtime/findloc.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/findloc.cpp
rename to flang-rt/lib/runtime/findloc.cpp
index ac432676f5efc..95986aefb86a4 100644
--- a/flang-rt/lib/flang_rt/findloc.cpp
+++ b/flang-rt/lib/runtime/findloc.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/findloc.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/findloc.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,7 @@
// Implements FINDLOC for all required operand types and shapes and result
// integer kinds.
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
#include <cinttypes>
diff --git a/flang-rt/lib/flang_rt/format.cpp b/flang-rt/lib/runtime/format.cpp
similarity index 89%
rename from flang-rt/lib/flang_rt/format.cpp
rename to flang-rt/lib/runtime/format.cpp
index abd01b56919a4..ee0059f5f0729 100644
--- a/flang-rt/lib/flang_rt/format.cpp
+++ b/flang-rt/lib/runtime/format.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/format.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/format.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/format-implementation.h"
+#include "flang-rt/runtime/format-implementation.h"
namespace Fortran::runtime::io {
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/flang-rt/lib/flang_rt/inquiry.cpp b/flang-rt/lib/runtime/inquiry.cpp
similarity index 94%
rename from flang-rt/lib/flang_rt/inquiry.cpp
rename to flang-rt/lib/runtime/inquiry.cpp
index e98d3900987dc..b6a7fce7a1e78 100644
--- a/flang-rt/lib/flang_rt/inquiry.cpp
+++ b/flang-rt/lib/runtime/inquiry.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/inquiry.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/inquiry.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,9 +11,9 @@
#include "flang/Runtime/inquiry.h"
#include "copy.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include <algorithm>
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/internal-unit.cpp b/flang-rt/lib/runtime/internal-unit.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/internal-unit.cpp
rename to flang-rt/lib/runtime/internal-unit.cpp
index 12d702de4c598..e344b01e8b34e 100644
--- a/flang-rt/lib/flang_rt/internal-unit.cpp
+++ b/flang-rt/lib/runtime/internal-unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/internal-unit.cpp --------------------------*- C++ -*-===//
+//===-- lib/runtime/internal-unit.cpp ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/internal-unit.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/io-error.h"
+#include "flang-rt/runtime/internal-unit.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/io-error.h"
#include "flang/Runtime/freestanding-tools.h"
#include <algorithm>
#include <type_traits>
diff --git a/flang-rt/lib/flang_rt/io-api-common.h b/flang-rt/lib/runtime/io-api-common.h
similarity index 92%
rename from flang-rt/lib/flang_rt/io-api-common.h
rename to flang-rt/lib/runtime/io-api-common.h
index 5e480fdef3483..b91ff9ff16863 100644
--- a/flang-rt/lib/flang_rt/io-api-common.h
+++ b/flang-rt/lib/runtime/io-api-common.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-api-common.h ----------------------------*- C++ -*-===//
+//===-- lib/runtime/io-api-common.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.
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_IO_API_COMMON_H_
-#define FLANG_RT_IO_API_COMMON_H_
+#ifndef FLANG_RT_RUNTIME_IO_API_COMMON_H_
+#define FLANG_RT_RUNTIME_IO_API_COMMON_H_
#include "unit.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Common/api-attrs.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/io-api.h"
@@ -94,4 +94,4 @@ RT_API_ATTRS Cookie BeginExternalListIO(
}
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_IO_API_COMMON_H_
+#endif // FLANG_RT_RUNTIME_IO_API_COMMON_H_
diff --git a/flang-rt/lib/flang_rt/io-api-minimal.cpp b/flang-rt/lib/runtime/io-api-minimal.cpp
similarity index 94%
rename from flang-rt/lib/flang_rt/io-api-minimal.cpp
rename to flang-rt/lib/runtime/io-api-minimal.cpp
index c3234c78c10c8..c706a3aa239a5 100644
--- a/flang-rt/lib/flang_rt/io-api-minimal.cpp
+++ b/flang-rt/lib/runtime/io-api-minimal.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-api-minimal.cpp -------------------------*- C++ -*-===//
+//===-- lib/runtime/io-api-minimal.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,10 +12,10 @@
#include "edit-output.h"
#include "io-api-common.h"
#include "unit.h"
-#include "flang-rt/format.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/io-api.h"
namespace Fortran::runtime::io {
@@ -150,7 +150,7 @@ bool IODEF(OutputLogical)(Cookie cookie, bool truth) {
// Provide own definition for `std::__libcpp_verbose_abort` to avoid dependency
// on the version provided by libc++.
-void std::__libcpp_verbose_abort(char const *format, ...) {
+void std::__libcpp_verbose_abort(char const *format, ...) noexcept {
va_list list;
va_start(list, format);
std::vfprintf(stderr, format, list);
diff --git a/flang-rt/lib/flang_rt/io-api.cpp b/flang-rt/lib/runtime/io-api.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/io-api.cpp
rename to flang-rt/lib/runtime/io-api.cpp
index c904352cba7f5..72041ae429467 100644
--- a/flang-rt/lib/flang_rt/io-api.cpp
+++ b/flang-rt/lib/runtime/io-api.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-api.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/io-api.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -19,13 +19,13 @@
#include "edit-output.h"
#include "io-api-common.h"
#include "unit.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/format.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/optional.h"
#include <cstdlib>
#include <memory>
diff --git a/flang-rt/lib/flang_rt/io-error.cpp b/flang-rt/lib/runtime/io-error.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/io-error.cpp
rename to flang-rt/lib/runtime/io-error.cpp
index b356642c95f85..b350fb66fc25b 100644
--- a/flang-rt/lib/flang_rt/io-error.cpp
+++ b/flang-rt/lib/runtime/io-error.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-error.cpp -------------------------------*- C++ -*-===//
+//===-- lib/runtime/io-error.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/io-error.h"
+#include "flang-rt/runtime/io-error.h"
#include "config.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/magic-numbers.h"
#include <cerrno>
#include <cstdarg>
diff --git a/flang-rt/lib/flang_rt/io-stmt.cpp b/flang-rt/lib/runtime/io-stmt.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/io-stmt.cpp
rename to flang-rt/lib/runtime/io-stmt.cpp
index a07bf70a6593e..b0823ffd9e703 100644
--- a/flang-rt/lib/flang_rt/io-stmt.cpp
+++ b/flang-rt/lib/runtime/io-stmt.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/io-stmt.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/io-stmt.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/io-stmt.h"
#include "unit.h"
-#include "flang-rt/connection.h"
-#include "flang-rt/emit-encoded.h"
-#include "flang-rt/format.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/utf.h"
+#include "flang-rt/runtime/connection.h"
+#include "flang-rt/runtime/emit-encoded.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/utf.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/iostat.cpp b/flang-rt/lib/runtime/iostat.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/iostat.cpp
rename to flang-rt/lib/runtime/iostat.cpp
index ab2fc63cf7b21..0f8bfb884e544 100644
--- a/flang-rt/lib/flang_rt/iostat.cpp
+++ b/flang-rt/lib/runtime/iostat.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/iostat.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/iostat.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/main.cpp b/flang-rt/lib/runtime/main.cpp
similarity index 90%
rename from flang-rt/lib/flang_rt/main.cpp
rename to flang-rt/lib/runtime/main.cpp
index dac7268f82b16..b3f066cda3732 100644
--- a/flang-rt/lib/flang_rt/main.cpp
+++ b/flang-rt/lib/runtime/main.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/main.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/main.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/main.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/terminator.h"
#include <cfenv>
#include <cstdio>
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/matmul-transpose.cpp b/flang-rt/lib/runtime/matmul-transpose.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/matmul-transpose.cpp
rename to flang-rt/lib/runtime/matmul-transpose.cpp
index 307995bb8ab1e..e20abbdddcd30 100644
--- a/flang-rt/lib/flang_rt/matmul-transpose.cpp
+++ b/flang-rt/lib/runtime/matmul-transpose.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/matmul-transpose.cpp -----------------------*- C++ -*-===//
+//===-- lib/runtime/matmul-transpose.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -21,9 +21,9 @@
// to use the faster BLAS routines.
#include "flang/Runtime/matmul-transpose.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/c-or-cpp.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/lib/flang_rt/matmul.cpp b/flang-rt/lib/runtime/matmul.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/matmul.cpp
rename to flang-rt/lib/runtime/matmul.cpp
index c5036e24f86f4..f14cea922d21e 100644
--- a/flang-rt/lib/flang_rt/matmul.cpp
+++ b/flang-rt/lib/runtime/matmul.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/matmul.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/matmul.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,9 +20,9 @@
// Places where BLAS routines could be called are marked as TODO items.
#include "flang/Runtime/matmul.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/c-or-cpp.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/lib/flang_rt/memory.cpp b/flang-rt/lib/runtime/memory.cpp
similarity index 87%
rename from flang-rt/lib/flang_rt/memory.cpp
rename to flang-rt/lib/runtime/memory.cpp
index e09e45898da8e..79c7e33777569 100644
--- a/flang-rt/lib/flang_rt/memory.cpp
+++ b/flang-rt/lib/runtime/memory.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/memory.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/memory.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/freestanding-tools.h"
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/misc-intrinsic.cpp b/flang-rt/lib/runtime/misc-intrinsic.cpp
similarity index 95%
rename from flang-rt/lib/flang_rt/misc-intrinsic.cpp
rename to flang-rt/lib/runtime/misc-intrinsic.cpp
index 1a5bc8114e8ae..b7335e9f6799e 100644
--- a/flang-rt/lib/flang_rt/misc-intrinsic.cpp
+++ b/flang-rt/lib/runtime/misc-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/misc-intrinsic.cpp -------------------------*- C++ -*-===//
+//===-- lib/runtime/misc-intrinsic.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/misc-intrinsic.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/optional.h"
#include <algorithm>
#include <cstdio>
diff --git a/flang-rt/lib/flang_rt/namelist.cpp b/flang-rt/lib/runtime/namelist.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/namelist.cpp
rename to flang-rt/lib/runtime/namelist.cpp
index 4cf1cd2062ac5..b0cf2180fc6d4 100644
--- a/flang-rt/lib/flang_rt/namelist.cpp
+++ b/flang-rt/lib/runtime/namelist.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/namelist.cpp -------------------------------*- C++ -*-===//
+//===-- lib/runtime/namelist.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/namelist.h"
+#include "flang-rt/runtime/namelist.h"
#include "descriptor-io.h"
-#include "flang-rt/emit-encoded.h"
-#include "flang-rt/io-stmt.h"
+#include "flang-rt/runtime/emit-encoded.h"
+#include "flang-rt/runtime/io-stmt.h"
#include "flang/Runtime/io-api.h"
#include <algorithm>
#include <cstring>
diff --git a/flang-rt/lib/flang_rt/non-tbp-dio.cpp b/flang-rt/lib/runtime/non-tbp-dio.cpp
similarity index 86%
rename from flang-rt/lib/flang_rt/non-tbp-dio.cpp
rename to flang-rt/lib/runtime/non-tbp-dio.cpp
index 5663c2ee338d7..72101b06e0c6e 100644
--- a/flang-rt/lib/flang_rt/non-tbp-dio.cpp
+++ b/flang-rt/lib/runtime/non-tbp-dio.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/non-tbp-dio.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/non-tbp-dio.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/non-tbp-dio.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/non-tbp-dio.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime::io {
diff --git a/flang-rt/lib/flang_rt/numeric.cpp b/flang-rt/lib/runtime/numeric.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/numeric.cpp
rename to flang-rt/lib/runtime/numeric.cpp
index b63c604cadcfb..37638765dc650 100644
--- a/flang-rt/lib/flang_rt/numeric.cpp
+++ b/flang-rt/lib/runtime/numeric.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/numeric.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/numeric.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/numeric.h"
-#include "flang-rt/numeric-templates.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/numeric-templates.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/float128.h"
#include <cfloat>
#include <climits>
diff --git a/flang-rt/lib/flang_rt/pointer.cpp b/flang-rt/lib/runtime/pointer.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/pointer.cpp
rename to flang-rt/lib/runtime/pointer.cpp
index 3138a54f1d122..93ba82e0583c0 100644
--- a/flang-rt/lib/flang_rt/pointer.cpp
+++ b/flang-rt/lib/runtime/pointer.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/pointer.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/pointer.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/pointer.h"
-#include "flang-rt/assign-impl.h"
-#include "flang-rt/derived.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/stat.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/assign-impl.h"
+#include "flang-rt/runtime/derived.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang-rt/lib/flang_rt/product.cpp b/flang-rt/lib/runtime/product.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/product.cpp
rename to flang-rt/lib/runtime/product.cpp
index c7b6d23d3014e..02fdc2bfcd576 100644
--- a/flang-rt/lib/flang_rt/product.cpp
+++ b/flang-rt/lib/runtime/product.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/product.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/product.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,7 @@
// Implements PRODUCT for all required operand types and shapes.
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
#include <cfloat>
diff --git a/flang-rt/lib/flang_rt/pseudo-unit.cpp b/flang-rt/lib/runtime/pseudo-unit.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/pseudo-unit.cpp
rename to flang-rt/lib/runtime/pseudo-unit.cpp
index f4d204890581e..7e1f3bc86b294 100644
--- a/flang-rt/lib/flang_rt/pseudo-unit.cpp
+++ b/flang-rt/lib/runtime/pseudo-unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/pseudo-unit.cpp ----------------------------*- C++ -*-===//
+//===-- lib/runtime/pseudo-unit.cpp -----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,8 +12,8 @@
//===----------------------------------------------------------------------===//
#include "unit.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/tools.h"
// NOTE: the header files above may define OpenMP declare target
// variables, so they have to be included unconditionally
diff --git a/flang-rt/lib/flang_rt/ragged.cpp b/flang-rt/lib/runtime/ragged.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/ragged.cpp
rename to flang-rt/lib/runtime/ragged.cpp
index 798b3464e7bca..dddc3ccdfd858 100644
--- a/flang-rt/lib/flang_rt/ragged.cpp
+++ b/flang-rt/lib/runtime/ragged.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/ragged.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/ragged.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/ragged.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdlib>
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/random.cpp b/flang-rt/lib/runtime/random.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/random.cpp
rename to flang-rt/lib/runtime/random.cpp
index 76971cf3fc888..dc74f2725ed51 100644
--- a/flang-rt/lib/flang_rt/random.cpp
+++ b/flang-rt/lib/runtime/random.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/random.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/random.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,10 +10,10 @@
// RANDOM_SEED.
#include "flang/Runtime/random.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/random-templates.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/random-templates.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Common/float128.h"
#include "flang/Common/leading-zero-bit-count.h"
#include "flang/Common/uint128.h"
diff --git a/flang-rt/lib/flang_rt/reduce.cpp b/flang-rt/lib/runtime/reduce.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/reduce.cpp
rename to flang-rt/lib/runtime/reduce.cpp
index 4bb6dc10ea9da..3c5e815e32d2b 100644
--- a/flang-rt/lib/flang_rt/reduce.cpp
+++ b/flang-rt/lib/runtime/reduce.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/reduce.cpp ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/reduce.cpp ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,10 +9,10 @@
// REDUCE() implementation
#include "flang/Runtime/reduce.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/reduction-templates.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/reduction-templates.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/reduction.cpp b/flang-rt/lib/runtime/reduction.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/reduction.cpp
rename to flang-rt/lib/runtime/reduction.cpp
index 9ceaeffc6541a..5e45870489479 100644
--- a/flang-rt/lib/flang_rt/reduction.cpp
+++ b/flang-rt/lib/runtime/reduction.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/reduction.cpp ------------------------------*- C++ -*-===//
+//===-- lib/runtime/reduction.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,8 +14,8 @@
// NORM2, MAXLOC, MINLOC, MAXVAL, and MINVAL are in extrema.cpp.
#include "flang/Runtime/reduction.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include <cinttypes>
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/stack.h b/flang-rt/lib/runtime/stack.h
similarity index 93%
rename from flang-rt/lib/flang_rt/stack.h
rename to flang-rt/lib/runtime/stack.h
index 6f37282f00932..38364ff541f16 100644
--- a/flang-rt/lib/flang_rt/stack.h
+++ b/flang-rt/lib/runtime/stack.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/stack.h ------------------------------------*- C++ -*-===//
+//===-- lib/runtime/stack.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.
@@ -10,11 +10,11 @@
// It is a list based stack with dynamic allocation/deallocation
// of the list nodes.
-#ifndef FLANG_RT_STACK_H_
-#define FLANG_RT_STACK_H_
+#ifndef FLANG_RT_RUNTIME_STACK_H_
+#define FLANG_RT_RUNTIME_STACK_H_
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
namespace Fortran::runtime {
// Storage for the Stack elements of type T.
@@ -133,4 +133,4 @@ template <typename T, unsigned N = 0> class Stack : public StackStorage<T, N> {
Terminator &terminator_;
};
} // namespace Fortran::runtime
-#endif // FLANG_RT_STACK_H_
+#endif // FLANG_RT_RUNTIME_STACK_H_
diff --git a/flang-rt/lib/flang_rt/stat.cpp b/flang-rt/lib/runtime/stat.cpp
similarity index 93%
rename from flang-rt/lib/flang_rt/stat.cpp
rename to flang-rt/lib/runtime/stat.cpp
index 883e85d0fbf2f..322b7282b7024 100644
--- a/flang-rt/lib/flang_rt/stat.cpp
+++ b/flang-rt/lib/runtime/stat.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/stat.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/stat.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/stat.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/stat.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
namespace Fortran::runtime {
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/flang-rt/lib/flang_rt/stop.cpp b/flang-rt/lib/runtime/stop.cpp
similarity index 95%
rename from flang-rt/lib/flang_rt/stop.cpp
rename to flang-rt/lib/runtime/stop.cpp
index 91f8e4a8f6bc1..1d70a137377aa 100644
--- a/flang-rt/lib/flang_rt/stop.cpp
+++ b/flang-rt/lib/runtime/stop.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/stop.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/stop.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,10 +9,10 @@
#include "flang/Runtime/stop.h"
#include "config.h"
#include "unit.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/file.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/file.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/terminator.h"
#include <cfenv>
#include <cstdio>
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/sum.cpp b/flang-rt/lib/runtime/sum.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/sum.cpp
rename to flang-rt/lib/runtime/sum.cpp
index fd98525b8c9b2..a76e228f18a4e 100644
--- a/flang-rt/lib/flang_rt/sum.cpp
+++ b/flang-rt/lib/runtime/sum.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/sum.cpp ------------------------------------*- C++ -*-===//
+//===-- lib/runtime/sum.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,7 @@
// cancellation on intermediate results by using "Kahan summation"
// (basically the same as manual "double-double").
-#include "flang-rt/reduction-templates.h"
+#include "flang-rt/runtime/reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
#include <cfloat>
diff --git a/flang-rt/lib/flang_rt/support.cpp b/flang-rt/lib/runtime/support.cpp
similarity index 91%
rename from flang-rt/lib/flang_rt/support.cpp
rename to flang-rt/lib/runtime/support.cpp
index 2673176bd8185..5a2b0c920aa80 100644
--- a/flang-rt/lib/flang_rt/support.cpp
+++ b/flang-rt/lib/runtime/support.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/support.cpp --------------------------------*- C++ -*-===//
+//===-- lib/runtime/support.cpp ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,8 +8,8 @@
#include "flang/Runtime/support.h"
#include "ISO_Fortran_util.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-info.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-info.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/flang-rt/lib/flang_rt/temporary-stack.cpp b/flang-rt/lib/runtime/temporary-stack.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/temporary-stack.cpp
rename to flang-rt/lib/runtime/temporary-stack.cpp
index 32ec4dacc872d..ea89d0c17bb6b 100644
--- a/flang-rt/lib/flang_rt/temporary-stack.cpp
+++ b/flang-rt/lib/runtime/temporary-stack.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/temporary-stack.cpp ------------------------*- C++ -*-===//
+//===-- lib/runtime/temporary-stack.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,9 +10,9 @@
// temporaries. For use in HLFIR lowering.
#include "flang/Runtime/temporary-stack.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
diff --git a/flang-rt/lib/flang_rt/terminator.cpp b/flang-rt/lib/runtime/terminator.cpp
similarity index 96%
rename from flang-rt/lib/flang_rt/terminator.cpp
rename to flang-rt/lib/runtime/terminator.cpp
index 0dfc08eb70370..8a57ba06b1304 100644
--- a/flang-rt/lib/flang_rt/terminator.cpp
+++ b/flang-rt/lib/runtime/terminator.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/terminator.cpp -----------------------------*- C++ -*-===//
+//===-- lib/runtime/terminator.cpp ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include <cstdio>
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/time-intrinsic.cpp b/flang-rt/lib/runtime/time-intrinsic.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/time-intrinsic.cpp
rename to flang-rt/lib/runtime/time-intrinsic.cpp
index 1929fccbd4cf3..69c344f5d24bc 100644
--- a/flang-rt/lib/flang_rt/time-intrinsic.cpp
+++ b/flang-rt/lib/runtime/time-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/time-intrinsic.cpp -------------------------*- C++ -*-===//
+//===-- lib/runtime/time-intrinsic.cpp --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,9 +9,9 @@
// Implements time-related intrinsic subroutines.
#include "flang/Runtime/time-intrinsic.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/cpp-type.h"
#include <algorithm>
#include <cstdint>
diff --git a/flang-rt/lib/flang_rt/tools.cpp b/flang-rt/lib/runtime/tools.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/tools.cpp
rename to flang-rt/lib/runtime/tools.cpp
index 9b460f81ad5c2..b9d9ca4fc378c 100644
--- a/flang-rt/lib/flang_rt/tools.cpp
+++ b/flang-rt/lib/runtime/tools.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/tools.cpp ----------------------------------*- C++ -*-===//
+//===-- lib/runtime/tools.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/tools.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/terminator.h"
#include <algorithm>
#include <cstdint>
#include <cstdlib>
diff --git a/flang-rt/lib/flang_rt/transformational.cpp b/flang-rt/lib/runtime/transformational.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/transformational.cpp
rename to flang-rt/lib/runtime/transformational.cpp
index 7453bf18323e9..eb694a9f2c833 100644
--- a/flang-rt/lib/flang_rt/transformational.cpp
+++ b/flang-rt/lib/runtime/transformational.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/transformational.cpp -----------------------*- C++ -*-===//
+//===-- lib/runtime/transformational.cpp ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,9 +18,9 @@
#include "flang/Runtime/transformational.h"
#include "copy.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Common/float128.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/type-code.cpp b/flang-rt/lib/runtime/type-code.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/type-code.cpp
rename to flang-rt/lib/runtime/type-code.cpp
index 432c7591520cb..8cfec9a4ec2fb 100644
--- a/flang-rt/lib/flang_rt/type-code.cpp
+++ b/flang-rt/lib/runtime/type-code.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/type-code.cpp ------------------------------*- C++ -*-===//
+//===-- lib/runtime/type-code.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/type-code.h"
namespace Fortran::runtime {
diff --git a/flang-rt/lib/flang_rt/type-info.cpp b/flang-rt/lib/runtime/type-info.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/type-info.cpp
rename to flang-rt/lib/runtime/type-info.cpp
index e1859e4864ca1..82182696d70c6 100644
--- a/flang-rt/lib/flang_rt/type-info.cpp
+++ b/flang-rt/lib/runtime/type-info.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/type-info.cpp ------------------------------*- C++ -*-===//
+//===-- lib/runtime/type-info.cpp -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/type-info.h"
-#include "flang-rt/terminator.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/type-info.h"
+#include "flang-rt/runtime/terminator.h"
+#include "flang-rt/runtime/tools.h"
#include <cstdio>
namespace Fortran::runtime::typeInfo {
diff --git a/flang-rt/lib/flang_rt/unit-map.cpp b/flang-rt/lib/runtime/unit-map.cpp
similarity index 98%
rename from flang-rt/lib/flang_rt/unit-map.cpp
rename to flang-rt/lib/runtime/unit-map.cpp
index 0fda53ac071b2..41a03f3319d64 100644
--- a/flang-rt/lib/flang_rt/unit-map.cpp
+++ b/flang-rt/lib/runtime/unit-map.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/unit-map.cpp -------------------------------*- C++ -*-===//
+//===-- lib/runtime/unit-map.cpp --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/flang-rt/lib/flang_rt/unit-map.h b/flang-rt/lib/runtime/unit-map.h
similarity index 92%
rename from flang-rt/lib/flang_rt/unit-map.h
rename to flang-rt/lib/runtime/unit-map.h
index 64233008b6630..fa61288a1e18d 100644
--- a/flang-rt/lib/flang_rt/unit-map.h
+++ b/flang-rt/lib/runtime/unit-map.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/unit-map.h ---------------------------------*- C++ -*-===//
+//===-- lib/runtime/unit-map.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.
@@ -9,12 +9,12 @@
// Maps Fortran unit numbers to their ExternalFileUnit instances.
// A simple hash table with forward-linked chains per bucket.
-#ifndef FLANG_RT_UNIT_MAP_H_
-#define FLANG_RT_UNIT_MAP_H_
+#ifndef FLANG_RT_RUNTIME_UNIT_MAP_H_
+#define FLANG_RT_RUNTIME_UNIT_MAP_H_
#include "unit.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/memory.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/memory.h"
#include "flang/Common/fast-int-set.h"
#include <cstdint>
#include <cstdlib>
@@ -100,4 +100,4 @@ class UnitMap {
int emergencyNewUnit_{maxNewUnits_}; // not recycled
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_UNIT_MAP_H_
+#endif // FLANG_RT_RUNTIME_UNIT_MAP_H_
diff --git a/flang-rt/lib/flang_rt/unit.cpp b/flang-rt/lib/runtime/unit.cpp
similarity index 99%
rename from flang-rt/lib/flang_rt/unit.cpp
rename to flang-rt/lib/runtime/unit.cpp
index f05c4b5236dd5..1d4d54ae01956 100644
--- a/flang-rt/lib/flang_rt/unit.cpp
+++ b/flang-rt/lib/runtime/unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/unit.cpp -----------------------------------*- C++ -*-===//
+//===-- lib/runtime/unit.cpp ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
#include "unit.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/tools.h"
#include <limits>
#include <utility>
diff --git a/flang-rt/lib/flang_rt/unit.h b/flang-rt/lib/runtime/unit.h
similarity index 95%
rename from flang-rt/lib/flang_rt/unit.h
rename to flang-rt/lib/runtime/unit.h
index a5fb7fb31691f..eb762a2d3b235 100644
--- a/flang-rt/lib/flang_rt/unit.h
+++ b/flang-rt/lib/runtime/unit.h
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/unit.h -------------------------------------*- C++ -*-===//
+//===-- lib/runtime/unit.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.
@@ -8,19 +8,19 @@
// Fortran external I/O units
-#ifndef FLANG_RT_UNIT_H_
-#define FLANG_RT_UNIT_H_
-
-#include "flang-rt/buffer.h"
-#include "flang-rt/connection.h"
-#include "flang-rt/environment.h"
-#include "flang-rt/file.h"
-#include "flang-rt/format.h"
-#include "flang-rt/io-error.h"
-#include "flang-rt/io-stmt.h"
-#include "flang-rt/lock.h"
-#include "flang-rt/memory.h"
-#include "flang-rt/terminator.h"
+#ifndef FLANG_RT_RUNTIME_UNIT_H_
+#define FLANG_RT_RUNTIME_UNIT_H_
+
+#include "flang-rt/runtime/buffer.h"
+#include "flang-rt/runtime/connection.h"
+#include "flang-rt/runtime/environment.h"
+#include "flang-rt/runtime/file.h"
+#include "flang-rt/runtime/format.h"
+#include "flang-rt/runtime/io-error.h"
+#include "flang-rt/runtime/io-stmt.h"
+#include "flang-rt/runtime/lock.h"
+#include "flang-rt/runtime/memory.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Common/constexpr-bitset.h"
#include "flang/Common/optional.h"
#include <cstdlib>
@@ -291,4 +291,4 @@ class ChildIo {
};
} // namespace Fortran::runtime::io
-#endif // FLANG_RT_UNIT_H_
+#endif // FLANG_RT_RUNTIME_UNIT_H_
diff --git a/flang-rt/lib/flang_rt/utf.cpp b/flang-rt/lib/runtime/utf.cpp
similarity index 97%
rename from flang-rt/lib/flang_rt/utf.cpp
rename to flang-rt/lib/runtime/utf.cpp
index dd74889c025c5..ef9df49f24f66 100644
--- a/flang-rt/lib/flang_rt/utf.cpp
+++ b/flang-rt/lib/runtime/utf.cpp
@@ -1,4 +1,4 @@
-//===-- lib/flang_rt/utf.cpp ------------------------------------*- C++ -*-===//
+//===-- lib/runtime/utf.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/utf.h"
+#include "flang-rt/runtime/utf.h"
namespace Fortran::runtime {
diff --git a/flang-rt/test/Runtime/no-cpp-dep.c b/flang-rt/test/Runtime/no-cpp-dep.c
index c03029f0f3c26..4fcf8f9d478d8 100644
--- a/flang-rt/test/Runtime/no-cpp-dep.c
+++ b/flang-rt/test/Runtime/no-cpp-dep.c
@@ -1,6 +1,6 @@
/*
This test makes sure that flang's runtime does not depend on the C++ runtime
-library. It tries to link this simple file against libflang_rt.a with
+library. It tries to link this simple file against libflang_rt.runtime.a with
a C compiler.
REQUIRES: c-compiler, flang-rt
diff --git a/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp b/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
index d1417b715e959..8c0a6f29b6967 100644
--- a/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/flang-rt/unittests/Evaluate/reshape.cpp b/flang-rt/unittests/Evaluate/reshape.cpp
index a45e06ad0f69d..2abe46c0969fb 100644
--- a/flang-rt/unittests/Evaluate/reshape.cpp
+++ b/flang-rt/unittests/Evaluate/reshape.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/transformational.h"
#include "flang/Testing/testing.h"
#include <cinttypes>
diff --git a/flang-rt/unittests/Runtime/Allocatable.cpp b/flang-rt/unittests/Runtime/Allocatable.cpp
index b03003a93fe09..4702f48e0f440 100644
--- a/flang-rt/unittests/Runtime/Allocatable.cpp
+++ b/flang-rt/unittests/Runtime/Allocatable.cpp
@@ -8,7 +8,7 @@
#include "flang/Runtime/allocatable.h"
#include "gtest/gtest.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/tools.h"
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/ArrayConstructor.cpp b/flang-rt/unittests/Runtime/ArrayConstructor.cpp
index 5c84cd162a293..5f791e7f4a7c3 100644
--- a/flang-rt/unittests/Runtime/ArrayConstructor.cpp
+++ b/flang-rt/unittests/Runtime/ArrayConstructor.cpp
@@ -8,9 +8,9 @@
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/array-constructor.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/array-constructor.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/unittests/Runtime/BufferTest.cpp b/flang-rt/unittests/Runtime/BufferTest.cpp
index 7795a79593eb2..f4b9e901d6fcb 100644
--- a/flang-rt/unittests/Runtime/BufferTest.cpp
+++ b/flang-rt/unittests/Runtime/BufferTest.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/buffer.h"
+#include "flang-rt/runtime/buffer.h"
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
#include <algorithm>
diff --git a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
index db6589990be18..90d4da849552a 100644
--- a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
@@ -9,10 +9,10 @@
#include "flang/Runtime/allocatable.h"
#include "cuda_runtime.h"
#include "gtest/gtest.h"
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Support/Fortran.h"
diff --git a/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 86c13d0dd290c..6e46a80aa8f3c 100644
--- a/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -8,10 +8,10 @@
#include "cuda_runtime.h"
#include "gtest/gtest.h"
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Support/Fortran.h"
diff --git a/flang-rt/unittests/Runtime/CUDA/Memory.cpp b/flang-rt/unittests/Runtime/CUDA/Memory.cpp
index 32609795c0169..c43b165509a98 100644
--- a/flang-rt/unittests/Runtime/CUDA/Memory.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Memory.cpp
@@ -10,9 +10,9 @@
#include "cuda_runtime.h"
#include "../tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/CUDA/allocator.h"
-#include "flang-rt/allocator-registry.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/cuda/allocator.h"
+#include "flang-rt/runtime/allocator-registry.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
diff --git a/flang-rt/unittests/Runtime/CharacterTest.cpp b/flang-rt/unittests/Runtime/CharacterTest.cpp
index 696ab6b06e9e7..83ec9b36d9b0c 100644
--- a/flang-rt/unittests/Runtime/CharacterTest.cpp
+++ b/flang-rt/unittests/Runtime/CharacterTest.cpp
@@ -11,7 +11,7 @@
#include "flang/Runtime/character.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include <cstring>
#include <functional>
#include <tuple>
diff --git a/flang-rt/unittests/Runtime/CommandTest.cpp b/flang-rt/unittests/Runtime/CommandTest.cpp
index a34c329750f39..72fe7629dbbb8 100644
--- a/flang-rt/unittests/Runtime/CommandTest.cpp
+++ b/flang-rt/unittests/Runtime/CommandTest.cpp
@@ -9,7 +9,7 @@
#include "flang/Runtime/command.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/execute.h"
#include "flang/Runtime/extensions.h"
#include "flang/Runtime/main.h"
diff --git a/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp b/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
index 939cc62c433f0..8213edd1f9225 100644
--- a/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
+++ b/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include <cstdarg>
#include <cstdlib>
diff --git a/flang-rt/unittests/Runtime/Derived.cpp b/flang-rt/unittests/Runtime/Derived.cpp
index 2f45dfb80f7fd..3196ba796ad19 100644
--- a/flang-rt/unittests/Runtime/Derived.cpp
+++ b/flang-rt/unittests/Runtime/Derived.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/tools.h"
#include "flang/Runtime/derived-api.h"
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/ExternalIOTest.cpp b/flang-rt/unittests/Runtime/ExternalIOTest.cpp
index a5481e071916d..c83535ca82bd3 100644
--- a/flang-rt/unittests/Runtime/ExternalIOTest.cpp
+++ b/flang-rt/unittests/Runtime/ExternalIOTest.cpp
@@ -12,7 +12,7 @@
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
diff --git a/flang-rt/unittests/Runtime/Format.cpp b/flang-rt/unittests/Runtime/Format.cpp
index 83650e0f999ac..fe7403f26700b 100644
--- a/flang-rt/unittests/Runtime/Format.cpp
+++ b/flang-rt/unittests/Runtime/Format.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/connection.h"
-#include "flang-rt/format-implementation.h"
-#include "flang-rt/io-error.h"
+#include "flang-rt/runtime/connection.h"
+#include "flang-rt/runtime/format-implementation.h"
+#include "flang-rt/runtime/io-error.h"
#include <optional>
#include <string>
#include <tuple>
diff --git a/flang-rt/unittests/Runtime/Inquiry.cpp b/flang-rt/unittests/Runtime/Inquiry.cpp
index f6097484bd481..e79c037864d9c 100644
--- a/flang-rt/unittests/Runtime/Inquiry.cpp
+++ b/flang-rt/unittests/Runtime/Inquiry.cpp
@@ -9,7 +9,7 @@
#include "flang/Runtime/inquiry.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/type-code.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/flang-rt/unittests/Runtime/ListInputTest.cpp b/flang-rt/unittests/Runtime/ListInputTest.cpp
index 0c6c59d6a325e..310c41a5c3fa5 100644
--- a/flang-rt/unittests/Runtime/ListInputTest.cpp
+++ b/flang-rt/unittests/Runtime/ListInputTest.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/io-error.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/io-error.h"
#include "flang/Runtime/io-api-consts.h"
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/LogicalFormatTest.cpp b/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
index 07f62ee02fc66..bc933292181c1 100644
--- a/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
+++ b/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include <algorithm>
#include <array>
diff --git a/flang-rt/unittests/Runtime/Matmul.cpp b/flang-rt/unittests/Runtime/Matmul.cpp
index 28bf2327da949..1b716fd01fd42 100644
--- a/flang-rt/unittests/Runtime/Matmul.cpp
+++ b/flang-rt/unittests/Runtime/Matmul.cpp
@@ -9,8 +9,8 @@
#include "flang/Runtime/matmul.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/unittests/Runtime/MatmulTranspose.cpp b/flang-rt/unittests/Runtime/MatmulTranspose.cpp
index b06afa29ce28e..cc14ab755505a 100644
--- a/flang-rt/unittests/Runtime/MatmulTranspose.cpp
+++ b/flang-rt/unittests/Runtime/MatmulTranspose.cpp
@@ -8,8 +8,8 @@
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/matmul-transpose.h"
diff --git a/flang-rt/unittests/Runtime/MiscIntrinsic.cpp b/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
index 61b05b31f45a9..c6783381bfc35 100644
--- a/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
+++ b/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
@@ -8,7 +8,7 @@
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/misc-intrinsic.h"
diff --git a/flang-rt/unittests/Runtime/Namelist.cpp b/flang-rt/unittests/Runtime/Namelist.cpp
index d48a0273bf556..040dedb8cd47c 100644
--- a/flang-rt/unittests/Runtime/Namelist.cpp
+++ b/flang-rt/unittests/Runtime/Namelist.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/namelist.h"
+#include "flang-rt/runtime/namelist.h"
#include "CrashHandlerFixture.h"
#include "tools.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include <algorithm>
#include <cinttypes>
diff --git a/flang-rt/unittests/Runtime/NumericalFormatTest.cpp b/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
index a86e6b807fc53..5a8ead48dcef9 100644
--- a/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
+++ b/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
#include "flang/Runtime/io-api-consts.h"
#include <algorithm>
#include <array>
diff --git a/flang-rt/unittests/Runtime/Pointer.cpp b/flang-rt/unittests/Runtime/Pointer.cpp
index 13f1922e6c5c3..a4645f5b6bf98 100644
--- a/flang-rt/unittests/Runtime/Pointer.cpp
+++ b/flang-rt/unittests/Runtime/Pointer.cpp
@@ -8,8 +8,8 @@
#include "flang/Runtime/pointer.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/tools.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/tools.h"
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/Random.cpp b/flang-rt/unittests/Runtime/Random.cpp
index dba480cffa9c9..bf4b540e768fd 100644
--- a/flang-rt/unittests/Runtime/Random.cpp
+++ b/flang-rt/unittests/Runtime/Random.cpp
@@ -8,8 +8,8 @@
#include "flang/Runtime/random.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include <cmath>
using namespace Fortran::runtime;
diff --git a/flang-rt/unittests/Runtime/Reduction.cpp b/flang-rt/unittests/Runtime/Reduction.cpp
index cb84512639933..3701a32042c58 100644
--- a/flang-rt/unittests/Runtime/Reduction.cpp
+++ b/flang-rt/unittests/Runtime/Reduction.cpp
@@ -9,8 +9,8 @@
#include "flang/Runtime/reduction.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp b/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
index 23a60d98bf6ad..e716dac2d1203 100644
--- a/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
#include "tools.h"
-#include "flang-rt/terminator.h"
+#include "flang-rt/runtime/terminator.h"
#include "flang/Runtime/io-api-consts.h"
#include "flang/Runtime/transformational.h"
#include <gtest/gtest.h>
diff --git a/flang-rt/unittests/Runtime/Stop.cpp b/flang-rt/unittests/Runtime/Stop.cpp
index 102fecd1afb22..5d1af20e77de7 100644
--- a/flang-rt/unittests/Runtime/Stop.cpp
+++ b/flang-rt/unittests/Runtime/Stop.cpp
@@ -12,7 +12,7 @@
#include "flang/Runtime/stop.h"
#include "CrashHandlerFixture.h"
-#include "flang-rt/environment.h"
+#include "flang-rt/runtime/environment.h"
#include <cstdlib>
#include <gtest/gtest.h>
diff --git a/flang-rt/unittests/Runtime/Support.cpp b/flang-rt/unittests/Runtime/Support.cpp
index 0159bd74aa60c..c97a6eae3a155 100644
--- a/flang-rt/unittests/Runtime/Support.cpp
+++ b/flang-rt/unittests/Runtime/Support.cpp
@@ -9,7 +9,7 @@
#include "flang/Runtime/support.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
+#include "flang-rt/runtime/descriptor.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/flang-rt/unittests/Runtime/TemporaryStack.cpp b/flang-rt/unittests/Runtime/TemporaryStack.cpp
index d5cb9e5bfb9da..ff8efe123d7cc 100644
--- a/flang-rt/unittests/Runtime/TemporaryStack.cpp
+++ b/flang-rt/unittests/Runtime/TemporaryStack.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/tools.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/tools.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang-rt/unittests/Runtime/Transformational.cpp b/flang-rt/unittests/Runtime/Transformational.cpp
index 8805613738a60..06df96a3cc45a 100644
--- a/flang-rt/unittests/Runtime/Transformational.cpp
+++ b/flang-rt/unittests/Runtime/Transformational.cpp
@@ -9,7 +9,7 @@
#include "flang/Runtime/transformational.h"
#include "tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Common/float128.h"
#include <vector>
diff --git a/flang-rt/unittests/Runtime/tools.h b/flang-rt/unittests/Runtime/tools.h
index 146aae659c338..36a4c2bd9c8b7 100644
--- a/flang-rt/unittests/Runtime/tools.h
+++ b/flang-rt/unittests/Runtime/tools.h
@@ -10,8 +10,8 @@
#define FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_
#include "gtest/gtest.h"
-#include "flang-rt/descriptor.h"
-#include "flang-rt/type-code.h"
+#include "flang-rt/runtime/descriptor.h"
+#include "flang-rt/runtime/type-code.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include <cstdint>
diff --git a/flang/examples/ExternalHelloWorld/CMakeLists.txt b/flang/examples/ExternalHelloWorld/CMakeLists.txt
index b61948718a5e3..dbb69475976dd 100644
--- a/flang/examples/ExternalHelloWorld/CMakeLists.txt
+++ b/flang/examples/ExternalHelloWorld/CMakeLists.txt
@@ -1,6 +1,6 @@
# This test is not run by default as it requires input.
add_llvm_example(external-hello-world
- external-hello.cpp
+ ${FLANG_RT_SOURCE_DIR}/examples/ExternalHelloWorld/external-hello.cpp
)
target_link_libraries(external-hello-world
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 315947b962d22..04e120cc5d37a 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -72,7 +72,7 @@ function (runtime_source_files outvar)
set(new_sources "")
foreach (source IN LISTS "${outvar}")
- set(new_source "${FLANG_RT_SOURCE_DIR}/lib/flang_rt")
+ set(new_source "${FLANG_RT_SOURCE_DIR}/lib")
cmake_path(APPEND new_source "${ARG_SUBDIR}")
cmake_path(APPEND new_source "${source}")
list(APPEND new_sources "${new_source}")
@@ -259,8 +259,8 @@ set(supported_files
unit.cpp
utf.cpp
)
+runtime_source_files(supported_files SUBDIR "runtime")
-runtime_source_files(supported_files)
enable_cuda_compilation(flang_rt "${supported_files}")
enable_omp_offload_compilation("${supported_files}")
@@ -293,8 +293,7 @@ if (NOT TARGET flang_rt.quadmath)
list(APPEND sources ${f128_sources})
endif()
endif()
-
-runtime_source_files(sources)
+runtime_source_files(sources SUBDIR "runtime")
if (NOT DEFINED MSVC)
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt
index 945cf60f00faa..aac1f62661810 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/flang/runtime/CUDA/CMakeLists.txt
@@ -24,7 +24,7 @@ set(sources
pointer.cpp
registration.cpp
)
-runtime_source_files(sources SUBDIR "CUDA")
+runtime_source_files(sources SUBDIR "cuda")
add_flang_library(${CUFRT_LIBNAME}
${sources}
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt
index a2266cf93237e..cdac5f893cf91 100644
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ b/flang/runtime/Float128Math/CMakeLists.txt
@@ -17,57 +17,58 @@
include(CheckLibraryExists)
set(sources
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/acos.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/acosh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/asin.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/asinh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/atan.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/atan2.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/atanh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/ceil.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/complex-math.c
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/cos.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/cosh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/erf.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/erfc.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/exp.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/exponent.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/floor.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/fma.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/fraction.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/hypot.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/j0.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/j1.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/jn.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/lgamma.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/llround.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/log.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/log10.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/lround.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/mod-real.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/modulo-real.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/nearest.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/nearbyint.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/norm2.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/pow.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/random.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/remainder.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/round.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/rrspacing.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/scale.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/set-exponent.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/sin.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/sinh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/spacing.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/sqrt.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/tan.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/tanh.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/tgamma.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/trunc.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/y0.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/y1.cpp
- ${FLANG_RT_SOURCE_DIR}/lib/FortranFloat128Math/yn.cpp
+ acos.cpp
+ acosh.cpp
+ asin.cpp
+ asinh.cpp
+ atan.cpp
+ atan2.cpp
+ atanh.cpp
+ ceil.cpp
+ complex-math.c
+ cos.cpp
+ cosh.cpp
+ erf.cpp
+ erfc.cpp
+ exp.cpp
+ exponent.cpp
+ floor.cpp
+ fma.cpp
+ fraction.cpp
+ hypot.cpp
+ j0.cpp
+ j1.cpp
+ jn.cpp
+ lgamma.cpp
+ llround.cpp
+ log.cpp
+ log10.cpp
+ lround.cpp
+ mod-real.cpp
+ modulo-real.cpp
+ nearest.cpp
+ nearbyint.cpp
+ norm2.cpp
+ pow.cpp
+ random.cpp
+ remainder.cpp
+ round.cpp
+ rrspacing.cpp
+ scale.cpp
+ set-exponent.cpp
+ sin.cpp
+ sinh.cpp
+ spacing.cpp
+ sqrt.cpp
+ tan.cpp
+ tanh.cpp
+ tgamma.cpp
+ trunc.cpp
+ y0.cpp
+ y1.cpp
+ yn.cpp
)
+runtime_source_files(sources SUBDIR "quadmath")
include_directories(AFTER "${CMAKE_CURRENT_SOURCE_DIR}/..")
add_library(FortranFloat128MathILib INTERFACE)
>From 0282bd6d23585b435cdbec1b37fd99c136ee795b Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 3 Feb 2025 23:47:53 +0100
Subject: [PATCH 25/41] Avoid change noise
---
flang/module/iso_fortran_env_impl.f90 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/module/iso_fortran_env_impl.f90 b/flang/module/iso_fortran_env_impl.f90
index 3ee00acfde4d7..5408e7de37001 100644
--- a/flang/module/iso_fortran_env_impl.f90
+++ b/flang/module/iso_fortran_env_impl.f90
@@ -8,7 +8,7 @@
! This MODULE implements part of the ISO_FORTRAN_ENV module file, which
! partially requires linkable symbols for some entities defined
-! (e.g., real_kinds). This file is also used by Flang-RT.
+! (e.g., real_kinds).
module iso_fortran_env_impl
implicit none
>From 919fda04cf0d46a4d9f1d5c5b8a7709aaeb7e334 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 4 Feb 2025 00:07:48 +0100
Subject: [PATCH 26/41] Post-merge fixes
---
flang-rt/cmake/modules/AddFlangRT.cmake | 10 ++++++++--
flang-rt/examples/ExternalHelloWorld/CMakeLists.txt | 2 +-
flang-rt/lib/cuda/CMakeLists.txt | 6 +++---
flang-rt/unittests/Runtime/CUDA/CMakeLists.txt | 2 +-
4 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index eee4aa61bee6c..e4acb8eea5790 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -142,8 +142,8 @@ function (add_flangrt_library name)
add_library("${name_shared}" SHARED ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS})
endif ()
- # Provide a default target if building both and which exists in either setting.
if (libtargets)
+ # Provide a default alias which exists in either setting.
if (BUILD_SHARED_LIBS)
if (build_shared)
set(default_target "${name_shared}")
@@ -158,8 +158,14 @@ function (add_flangrt_library name)
endif ()
endif ()
add_library(${name}.default ALIAS "${default_target}")
+
+ # Provide a build target that builds any enabled library.
+ # Not intended for target_link_libraries. Either use the ${name}.static,
+ # ${name}.shared variants, or ${name}.default to let BUILD_SHARED_LIBS
+ # decide.
if (NOT TARGET ${name})
- add_library(${name} ALIAS "${default_target}")
+ add_custom_target(${name})
+ add_dependencies(${name} ${libtargets})
endif ()
endif ()
diff --git a/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt b/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
index 4fd04f8f2769a..ccc39242745d9 100644
--- a/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
+++ b/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
@@ -13,5 +13,5 @@ add_llvm_example(external-hello-world
target_link_libraries(external-hello-world
PRIVATE
- flang_rt.runtime
+ flang_rt.runtime.default
)
diff --git a/flang-rt/lib/cuda/CMakeLists.txt b/flang-rt/lib/cuda/CMakeLists.txt
index 8623689f9ca0d..fc9a95bc49dc5 100644
--- a/flang-rt/lib/cuda/CMakeLists.txt
+++ b/flang-rt/lib/cuda/CMakeLists.txt
@@ -27,7 +27,7 @@ add_flangrt_library(flang_rt.cuda STATIC SHARED
# For the static library, link-in the static dependencies as well.
if (TARGET flang_rt.cuda.static)
- target_link_libraries(flang.cuda.static PUBLIC
+ target_link_libraries(flang_rt.cuda.static PUBLIC
flang_rt.runtime.static
CUDA::cudart_static
)
@@ -35,8 +35,8 @@ endif ()
# For the shared library, use the shared versions of the dependencies.
if (TARGET flang_rt.cuda.shared)
- target_link_libraries(CufRuntime.shared PUBLIC
- flang_rt.shared
+ target_link_libraries(flang_rt.cuda.shared PUBLIC
+ flang_rt.runtime.shared
CUDA::cudart
)
endif ()
diff --git a/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
index cd69a6f472873..2faacfda92a84 100644
--- a/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
+++ b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
@@ -14,5 +14,5 @@ add_flangrt_unittest(FlangCufRuntimeTests
target_link_libraries(FlangCufRuntimeTests
PRIVATE
- flang_rt.cuda
+ flang_rt.cuda.default
)
>From d0cf50915755f0200b5c0169eea1b5ee41642aa0 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 4 Feb 2025 02:57:48 +0100
Subject: [PATCH 27/41] Post-merge fixes
---
flang-rt/CMakeLists.txt | 6 ++++++
flang-rt/cmake/config.h.cmake.in | 5 +++++
flang-rt/cmake/modules/AddFlangRT.cmake | 10 ++++++++--
flang-rt/lib/runtime/CMakeLists.txt | 4 +++-
4 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 37f49ebc0d7bb..8060ed84eb840 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -205,6 +205,12 @@ endif ()
check_cxx_compiler_flag("-UTESTFLAG" FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
+# function checks
+find_package(Backtrace)
+set(HAVE_BACKTRACE ${Backtrace_FOUND})
+set(BACKTRACE_HEADER ${Backtrace_HEADER})
+
+
#####################
# Build Preparation #
#####################
diff --git a/flang-rt/cmake/config.h.cmake.in b/flang-rt/cmake/config.h.cmake.in
index 8a4668b90addd..84c234d86bae6 100644
--- a/flang-rt/cmake/config.h.cmake.in
+++ b/flang-rt/cmake/config.h.cmake.in
@@ -16,4 +16,9 @@
don't. */
#cmakedefine01 HAVE_DECL_STRERROR_S
+/* Define to 1 if you have the `backtrace' function. */
+#cmakedefine HAVE_BACKTRACE ${HAVE_BACKTRACE}
+
+#define BACKTRACE_HEADER <${BACKTRACE_HEADER}>
+
#endif
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index dc96d2b5f0a15..d78dacb0f6d53 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -28,13 +28,15 @@
# ADDITIONAL_HEADERS
# May specify header files for IDE generators.
# INCLUDE_DIRECTORIES
-# Additional include_directories for all added targets
+# Additional target_include_directories for all added targets
+# LINK_LIBRARIES
+# Additional target_link_libraries for all added targets
# TARGET_PROPERTIES
# Set target properties of all added targets
# )
function (add_flangrt_library name)
set(options STATIC SHARED OBJECT INSTALL_WITH_TOOLCHAIN EXCLUDE_FROM_ALL LINK_TO_LLVM)
- set(multiValueArgs ADDITIONAL_HEADERS INCLUDE_DIRECTORIES TARGET_PROPERTIES)
+ set(multiValueArgs ADDITIONAL_HEADERS INCLUDE_DIRECTORIES LINK_LIBRARIES TARGET_PROPERTIES)
cmake_parse_arguments(ARG
"${options}"
""
@@ -160,6 +162,10 @@ function (add_flangrt_library name)
target_include_directories(${name} ${ARG_INCLUDE_DIRECTORIES})
endif ()
+ if (ARG_LINK_LIBRARIES)
+ target_link_libraries(${name} PUBLIC ${ARG_LINK_LIBRARIES})
+ endif ()
+
# If this is part of the toolchain, put it into the compiler's resource
# directory. Otherwise it is part of testing and is not installed at all.
# TODO: Consider multi-configuration builds (MSVC_IDE, "Ninja Multi-Config")
diff --git a/flang-rt/lib/runtime/CMakeLists.txt b/flang-rt/lib/runtime/CMakeLists.txt
index 6340dee2c5c07..0afcbf2783533 100644
--- a/flang-rt/lib/runtime/CMakeLists.txt
+++ b/flang-rt/lib/runtime/CMakeLists.txt
@@ -124,12 +124,13 @@ else ()
set(f128_sources "")
endif ()
-
set(sources ${supported_sources} ${host_sources} ${f128_sources})
+
if (NOT WIN32)
add_flangrt_library(flang_rt.runtime STATIC
${sources}
+ LINK_LIBRARIES ${Backtrace_LIBRARY}
INSTALL_WITH_TOOLCHAIN
ADDITIONAL_HEADERS ${public_headers} ${private_headers}
)
@@ -151,6 +152,7 @@ else()
add_flangrt_library(${name} ${libtype}
${sources}
${ARGN}
+ LINK_LIBRARIES ${Backtrace_LIBRARY}
ADDITIONAL_HEADERS ${public_headers} ${private_headers}
)
>From b286a88b23b0ac977222c8b7d7289f8c9f292eb5 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 6 Feb 2025 10:58:03 +0100
Subject: [PATCH 28/41] clang-format includes
---
flang/include/flang/Common/ISO_Fortran_binding_wrapper.h | 2 +-
flang/include/flang/Frontend/CompilerInvocation.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h b/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
index 5d9c66f47b48e..890522953efe0 100644
--- a/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
+++ b/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -1,4 +1,4 @@
-/*===-- include/flang/Common/ISO_Fortran_binding_wrapper.h ----------*- C -*-===
+/*===-- include/flang/Common/ISO_Fortran_binding_wrapper.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.
diff --git a/flang/include/flang/Frontend/CompilerInvocation.h b/flang/include/flang/Frontend/CompilerInvocation.h
index b3b7297f6f7f1..9e6724be33033 100644
--- a/flang/include/flang/Frontend/CompilerInvocation.h
+++ b/flang/include/flang/Frontend/CompilerInvocation.h
@@ -20,8 +20,8 @@
#include "flang/Lower/LoweringOptions.h"
#include "flang/Parser/parsing.h"
#include "flang/Semantics/semantics.h"
-#include "mlir/Support/Timing.h"
#include "flang/Support/LangOptions.h"
+#include "mlir/Support/Timing.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "llvm/Option/ArgList.h"
>From 778f51608331ac1267353b1c1225357f5e7a9106 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 6 Feb 2025 19:02:37 +0100
Subject: [PATCH 29/41] Adapt BSD test
---
flang/test/Driver/linker-flags.f90 | 1 -
1 file changed, 1 deletion(-)
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index 4b4b6d52f1327..16bd4c3ba8371 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -41,7 +41,6 @@
! BSD-F128NONE-NOT: FortranFloat128Math
! BSD-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
! BSD-SAME: -lFortranRuntime
-! BSD-SAME: -lFortranDecimal
! BSD-SAME: -lexecinfo
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
>From 8ce70e56d8f3bf838503d619b1a4dafa8df29a71 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 6 Feb 2025 19:06:58 +0100
Subject: [PATCH 30/41] Adapt BSD test for rename
---
flang/test/Driver/linker-flags.f90 | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index 2c6c3beef4783..4e62a8c32d360 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -29,8 +29,8 @@
! executable and may find the GNU linker from MinGW or Cygwin.
! UNIX-LABEL: "{{.*}}ld{{(\.exe)?}}"
! UNIX-SAME: "[[object_file]]"
-! UNIX-F128NONE-NOT: libflang_rt.quadmath
-! SOLARIS-F128NONE-NOT: libflang_rt.quadmath
+! UNIX-F128NONE-NOT: lang_rt.quadmath
+! SOLARIS-F128NONE-NOT: flang_rt.quadmath
! UNIX-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
! SOLARIS-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "-z" "ignore" "-lquadmath" "-z" "record"
! UNIX-SAME: "-lflang_rt.runtime" "-lm"
@@ -38,9 +38,9 @@
! BSD-LABEL: "{{.*}}ld{{(\.exe)?}}"
! BSD-SAME: "[[object_file]]"
-! BSD-F128NONE-NOT: FortranFloat128Math
-! BSD-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! BSD-SAME: -lFortranRuntime
+! BSD-F128NONE-NOT: flang_rt.quadmath
+! BSD-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed"
+! BSD-SAME: -lflang_rt.runtime
! BSD-SAME: -lexecinfo
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
>From f258e0e71651b63847aed875a46db116a5265b78 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 6 Feb 2025 19:43:34 +0100
Subject: [PATCH 31/41] Use C++ header guards III
---
flang/include/flang/Testing/fp-testing.h | 2 +-
flang/include/flang/Testing/testing.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang/include/flang/Testing/fp-testing.h b/flang/include/flang/Testing/fp-testing.h
index e223d2ef7d1b8..c65766b8b47e8 100644
--- a/flang/include/flang/Testing/fp-testing.h
+++ b/flang/include/flang/Testing/fp-testing.h
@@ -32,4 +32,4 @@ class ScopedHostFloatingPointEnvironment {
#endif
};
-#endif /* FORTRAN_TESTING_FP_TESTING_H_ */
+#endif // FORTRAN_TESTING_FP_TESTING_H_
diff --git a/flang/include/flang/Testing/testing.h b/flang/include/flang/Testing/testing.h
index 404650c9a89f2..03b589924518d 100644
--- a/flang/include/flang/Testing/testing.h
+++ b/flang/include/flang/Testing/testing.h
@@ -41,4 +41,4 @@ FailureDetailPrinter Match(const char *file, int line, const std::string &want,
FailureDetailPrinter Compare(const char *file, int line, const char *xs,
const char *rel, const char *ys, std::uint64_t x, std::uint64_t y);
} // namespace testing
-#endif /* FORTRAN_TESTING_TESTING_H_ */
+#endif // FORTRAN_TESTING_TESTING_H_
>From e3098d3f1699ada527a61f38049a6fd5d55789da Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 7 Feb 2025 13:00:39 +0100
Subject: [PATCH 32/41] [Flang] Optionally do not compile the runtime in-tree
Introduce the CMake switch FLANG_INCLUDE_RUNTIME. When set to off, do not add build instructions for the runtime.
This is required for Flang-RT (#110217) and the current runtime CMake code to co-exist. When using `LLVM_ENABLE_RUNTIME=flang-rt`, the in-tree build instructions are in conflict and must be disabled.
---
flang/CMakeLists.txt | 6 +++++-
flang/examples/CMakeLists.txt | 4 +++-
flang/test/CMakeLists.txt | 6 +++++-
flang/test/Driver/ctofortran.f90 | 1 +
flang/test/Driver/exec.f90 | 1 +
flang/test/Runtime/no-cpp-dep.c | 2 +-
flang/test/lit.cfg.py | 5 ++++-
flang/test/lit.site.cfg.py.in | 2 ++
flang/tools/f18/CMakeLists.txt | 2 +-
flang/unittests/CMakeLists.txt | 11 +++++++++-
flang/unittests/Evaluate/CMakeLists.txt | 27 +++++++++++++------------
11 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 2e27bc2279ac4..e6de8df5cef15 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -247,6 +247,8 @@ else()
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
endif()
+option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" ON)
+
set(FLANG_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
mark_as_advanced(FLANG_TOOLS_INSTALL_DIR)
@@ -487,7 +489,9 @@ if (FLANG_BUILD_TOOLS)
add_subdirectory(tools)
endif()
-add_subdirectory(runtime)
+if (FLANG_INCLUDE_RUNTIME)
+ add_subdirectory(runtime)
+endif ()
if (LLVM_INCLUDE_EXAMPLES)
add_subdirectory(examples)
diff --git a/flang/examples/CMakeLists.txt b/flang/examples/CMakeLists.txt
index 8cc66ddbbbb0e..23c6e790791fb 100644
--- a/flang/examples/CMakeLists.txt
+++ b/flang/examples/CMakeLists.txt
@@ -1,4 +1,6 @@
-add_subdirectory(ExternalHelloWorld)
+if (FLANG_INCLUDE_RUNTIME)
+ add_subdirectory(ExternalHelloWorld)
+endif ()
add_subdirectory(PrintFlangFunctionNames)
add_subdirectory(FlangOmpReport)
add_subdirectory(FeatureList)
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index cab214c2ef4c8..e398e0786147a 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -71,9 +71,13 @@ set(FLANG_TEST_DEPENDS
llvm-objdump
llvm-readobj
split-file
- FortranRuntime
FortranDecimal
)
+
+if (FLANG_INCLUDE_RUNTIME)
+ list(APPEND FLANG_TEST_DEPENDS FortranRuntime)
+endif ()
+
if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
list(APPEND FLANG_TEST_DEPENDS Bye)
endif()
diff --git a/flang/test/Driver/ctofortran.f90 b/flang/test/Driver/ctofortran.f90
index 78eac32133b18..10c7adaccc958 100644
--- a/flang/test/Driver/ctofortran.f90
+++ b/flang/test/Driver/ctofortran.f90
@@ -1,4 +1,5 @@
! UNSUPPORTED: system-windows
+! REQUIRES: flang-rt
! RUN: split-file %s %t
! RUN: chmod +x %t/runtest.sh
! RUN: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang | FileCheck %s
diff --git a/flang/test/Driver/exec.f90 b/flang/test/Driver/exec.f90
index fd174005ddf62..9ca91ee24011c 100644
--- a/flang/test/Driver/exec.f90
+++ b/flang/test/Driver/exec.f90
@@ -1,4 +1,5 @@
! UNSUPPORTED: system-windows
+! REQUIRES: flang-rt
! Verify that flang can correctly build executables.
! RUN: %flang %s -o %t
diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang/test/Runtime/no-cpp-dep.c
index b1a5fa004014c..7303ce63fdec4 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/flang/test/Runtime/no-cpp-dep.c
@@ -3,7 +3,7 @@ This test makes sure that flang's runtime does not depend on the C++ runtime
library. It tries to link this simple file against libFortranRuntime.a with
a C compiler.
-REQUIRES: c-compiler
+REQUIRES: c-compiler, flang-rt
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
RUN: %cc -std=c99 %s -I%include %libruntime -lm \
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index c452b6d231c89..f4580afc8c47b 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -163,10 +163,13 @@
ToolSubst("%not_todo_abort_cmd", command=FindTool("not"), unresolved="fatal")
)
+if config.flang_include_runtime:
+ config.available_features.add("flang-rt")
+
# Define some variables to help us test that the flang runtime doesn't depend on
# the C++ runtime libraries. For this we need a C compiler. If for some reason
# we don't have one, we can just disable the test.
-if config.cc:
+if config.flang_include_runtime and config.cc:
libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
include = os.path.join(config.flang_src_dir, "include")
diff --git a/flang/test/lit.site.cfg.py.in b/flang/test/lit.site.cfg.py.in
index d1a0ac763cf8a..697ba3fa79763 100644
--- a/flang/test/lit.site.cfg.py.in
+++ b/flang/test/lit.site.cfg.py.in
@@ -1,6 +1,7 @@
@LIT_SITE_CFG_IN_HEADER@
import sys
+import lit.util
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
config.llvm_shlib_dir = lit_config.substitute(path(r"@SHLIBDIR@"))
@@ -32,6 +33,7 @@ else:
config.openmp_module_dir = None
config.flang_runtime_f128_math_lib = "@FLANG_RUNTIME_F128_MATH_LIB@"
config.have_ldbl_mant_dig_113 = "@HAVE_LDBL_MANT_DIG_113@"
+config.flang_include_runtime = lit.util.pythonize_bool("@FLANG_INCLUDE_RUNTIME@")
import lit.llvm
lit.llvm.initialize(lit_config, config)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index cc2bc5b8eb5ce..85ba2c74cdeb5 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -109,7 +109,7 @@ if (NOT CMAKE_CROSSCOMPILING)
set(compile_with "-fsyntax-only")
set(object_output "")
set(include_in_link FALSE)
- if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION)
+ if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION AND FLANG_INCLUDE_RUNTIME)
set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}")
set(compile_with -c -o ${object_output})
set(include_in_link TRUE)
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index 945067fed4f82..ecb7d68d8f729 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -1,3 +1,5 @@
+include(AddFlangOffloadRuntime)
+
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
# If Fortran runtime is built as CUDA library, the linking
# of targets that link FortranRuntime must be done
@@ -11,6 +13,11 @@ add_custom_target(FlangUnitTests)
set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests")
function(add_flang_unittest_offload_properties target)
+ # Do not apply runtime properties if not even compiling the runtime.
+ if (NOT FLANG_INCLUDE_RUNTIME)
+ return ()
+ endif ()
+
# Set CUDA_RESOLVE_DEVICE_SYMBOLS.
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
set_target_properties(${target}
@@ -75,5 +82,7 @@ add_subdirectory(Optimizer)
add_subdirectory(Common)
add_subdirectory(Decimal)
add_subdirectory(Evaluate)
-add_subdirectory(Runtime)
+if (FLANG_INCLUDE_RUNTIME)
+ add_subdirectory(Runtime)
+endif ()
add_subdirectory(Frontend)
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 8111ecd72cfc7..1c3fac29cd298 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -33,7 +33,6 @@ add_flang_nongtest_unittest(intrinsics
FortranDecimal
FortranSemantics
FortranParser
- FortranRuntime
)
add_flang_nongtest_unittest(logical
@@ -56,19 +55,21 @@ add_flang_nongtest_unittest(real
)
llvm_update_compile_flags(real.test)
-add_flang_nongtest_unittest(reshape
- NonGTestTesting
- FortranSemantics
- FortranEvaluate
- FortranRuntime
-)
+if (FLANG_INCLUDE_RUNTIME)
+ add_flang_nongtest_unittest(reshape
+ NonGTestTesting
+ FortranSemantics
+ FortranEvaluate
+ FortranRuntime
+ )
-add_flang_nongtest_unittest(ISO-Fortran-binding
- NonGTestTesting
- FortranEvaluate
- FortranSemantics
- FortranRuntime
-)
+ add_flang_nongtest_unittest(ISO-Fortran-binding
+ NonGTestTesting
+ FortranEvaluate
+ FortranSemantics
+ FortranRuntime
+ )
+endif ()
add_flang_nongtest_unittest(folding
FortranSupport
>From 6b4621029a667e0b3cbfbefd28e09282f7e023fd Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Sat, 8 Feb 2025 17:24:45 +0100
Subject: [PATCH 33/41] Specifically refer to flang_rt.runtime in comments
---
flang/CMakeLists.txt | 2 +-
flang/runtime/CMakeLists.txt | 2 +-
flang/tools/f18/CMakeLists.txt | 8 ++++----
flang/unittests/CMakeLists.txt | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 7c598e02bd09b..c6271f1856eb9 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -301,7 +301,7 @@ set(FLANG_DEFAULT_LINKER "" CACHE STRING
"Default linker to use (linker name or absolute path, empty for platform default)")
set(FLANG_DEFAULT_RTLIB "" CACHE STRING
- "Default Fortran runtime library to use (\"libflang_rt\"), leave empty for platform default.")
+ "Default Fortran runtime library to use (\"libflang_rt.runtime\"), leave empty for platform default.")
if (NOT(FLANG_DEFAULT_RTLIB STREQUAL ""))
message(WARNING "Resetting Flang's default runtime library to use platform default.")
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 65c6b0d374013..7cc720e2df9af 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -247,7 +247,7 @@ enable_omp_offload_compilation("${supported_files}")
if (NOT TARGET flang_rt.quadmath)
# If flang_rt.quadmath is not defined, then we are not building
# standalone flang_rt.quadmath library. Instead, include
- # the relevant sources into flang_rt itself.
+ # the relevant sources into flang_rt.runtime itself.
# The information is provided via FortranFloat128MathILib
# interface library.
get_target_property(f128_sources
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index a849e95df31c1..5b5f23b5dc73c 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
)
# Define the list of Fortran module files that need to be compiled
-# to produce an object file for inclusion into the flang_rt
+# to produce an object file for inclusion into the flang_rt.runtime
# library.
set(MODULES_WITH_IMPLEMENTATION
"iso_fortran_env_impl"
@@ -105,7 +105,7 @@ if (NOT CMAKE_CROSSCOMPILING)
endif()
# Some modules have an implementation part that needs to be added to the
- # flang_rt library.
+ # flang_rt.runtime library.
set(compile_with "-fsyntax-only")
set(object_output "")
set(include_in_link FALSE)
@@ -127,14 +127,14 @@ if (NOT CMAKE_CROSSCOMPILING)
install(FILES ${base}.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
# If a module has been compiled into an object file, add the file to
- # the link line for the flang_rt library.
+ # the link line for the flang_rt.runtime library.
if(include_in_link)
list(APPEND module_objects ${object_output})
endif()
endforeach()
# Set a CACHE variable that is visible to the CMakeLists.txt in runtime/, so that
- # the compiled Fortran modules can be added to the link line of the flang_rt
+ # the compiled Fortran modules can be added to the link line of the flang_rt.runtime
# library.
set(FORTRAN_MODULE_OBJECTS ${module_objects} CACHE INTERNAL "" FORCE)
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index 7b0f85638f14e..c54ceb3332abf 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -2,7 +2,7 @@ include(AddFlangOffloadRuntime)
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
# If Fortran runtime is built as CUDA library, the linking
- # of targets that link flang_rt must be done
+ # of targets that link flang_rt.runtime must be done
# with CUDA_RESOLVE_DEVICE_SYMBOLS.
# CUDA language must be enabled for CUDA_RESOLVE_DEVICE_SYMBOLS
# to take effect.
>From 19fe1a344b376880fc980f8397bb6292a58a585e Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 10 Feb 2025 20:23:05 +0100
Subject: [PATCH 34/41] Disable LTO
Apply https://reviews.llvm.org/D140016 to LLVM_ENABLE_RUNTIMES=flang-rt
---
flang-rt/CMakeLists.txt | 3 +++
flang-rt/cmake/modules/AddFlangRT.cmake | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 8060ed84eb840..df35e24ec28a7 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -204,6 +204,9 @@ endif ()
# but some older versions of CMake don't define it for GCC itself.
check_cxx_compiler_flag("-UTESTFLAG" FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
+# Check whether -fno-lto is supported.
+check_cxx_compiler_flag(-fno-lto FLANG_RT_HAS_FNO_LTO_FLAG)
+
# function checks
find_package(Backtrace)
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index d78dacb0f6d53..630aeb3c65005 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -126,6 +126,13 @@ function (add_flangrt_library name)
target_compile_options(${name} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)
endif ()
+ # When building the flang runtime if LTO is enabled the archive file
+ # contains LLVM IR rather than object code. Currently flang is not
+ # LTO aware so cannot link this file to compiled Fortran code.
+ if (FLANG_RT_HAS_FNO_LTO_FLAG)
+ target_compile_options(${name} PRIVATE -fno-lto)
+ endif ()
+
# Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
# should only depend on msvcrt/ucrt. LLVM still emits libgcc/compiler-rt
# functions in some cases like 128-bit integer math (__udivti3, __modti3,
>From 8b91f2f2ca59653c140a6aeed84a57ca4566c898 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 10 Feb 2025 20:44:30 +0100
Subject: [PATCH 35/41] Undo move of CUDA/allocator.h
---
flang-rt/lib/cuda/allocator.cpp | 2 +-
flang-rt/lib/cuda/descriptor.cpp | 2 +-
flang-rt/unittests/Runtime/CUDA/Allocatable.cpp | 2 +-
flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp | 2 +-
flang-rt/unittests/Runtime/CUDA/Memory.cpp | 2 +-
.../include/flang/Runtime/CUDA}/allocator.h | 10 +++++-----
6 files changed, 10 insertions(+), 10 deletions(-)
rename {flang-rt/include/flang-rt/cuda => flang/include/flang/Runtime/CUDA}/allocator.h (78%)
diff --git a/flang-rt/lib/cuda/allocator.cpp b/flang-rt/lib/cuda/allocator.cpp
index 511543f6a4863..4199bf04b33f0 100644
--- a/flang-rt/lib/cuda/allocator.cpp
+++ b/flang-rt/lib/cuda/allocator.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang-rt/cuda/allocator.h"
+#include "flang/Runtime/CUDA/allocator.h"
#include "flang-rt/runtime/allocator-registry.h"
#include "flang-rt/runtime/derived.h"
#include "flang-rt/runtime/stat.h"
diff --git a/flang-rt/lib/cuda/descriptor.cpp b/flang-rt/lib/cuda/descriptor.cpp
index 60e096acfde32..d44ab2e45d2a8 100644
--- a/flang-rt/lib/cuda/descriptor.cpp
+++ b/flang-rt/lib/cuda/descriptor.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/descriptor.h"
-#include "flang-rt/cuda/allocator.h"
#include "flang-rt/runtime/descriptor.h"
#include "flang-rt/runtime/terminator.h"
+#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
index 90d4da849552a..3f759a69c0388 100644
--- a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
@@ -9,10 +9,10 @@
#include "flang/Runtime/allocatable.h"
#include "cuda_runtime.h"
#include "gtest/gtest.h"
-#include "flang-rt/cuda/allocator.h"
#include "flang-rt/runtime/allocator-registry.h"
#include "flang-rt/runtime/descriptor.h"
#include "flang-rt/runtime/terminator.h"
+#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Support/Fortran.h"
diff --git a/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 6e46a80aa8f3c..9bda3270fe8a1 100644
--- a/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -8,10 +8,10 @@
#include "cuda_runtime.h"
#include "gtest/gtest.h"
-#include "flang-rt/cuda/allocator.h"
#include "flang-rt/runtime/allocator-registry.h"
#include "flang-rt/runtime/descriptor.h"
#include "flang-rt/runtime/terminator.h"
+#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Support/Fortran.h"
diff --git a/flang-rt/unittests/Runtime/CUDA/Memory.cpp b/flang-rt/unittests/Runtime/CUDA/Memory.cpp
index c43b165509a98..37ae59ec238c8 100644
--- a/flang-rt/unittests/Runtime/CUDA/Memory.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Memory.cpp
@@ -10,9 +10,9 @@
#include "cuda_runtime.h"
#include "../tools.h"
#include "gtest/gtest.h"
-#include "flang-rt/cuda/allocator.h"
#include "flang-rt/runtime/allocator-registry.h"
#include "flang-rt/runtime/terminator.h"
+#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
diff --git a/flang-rt/include/flang-rt/cuda/allocator.h b/flang/include/flang/Runtime/CUDA/allocator.h
similarity index 78%
rename from flang-rt/include/flang-rt/cuda/allocator.h
rename to flang/include/flang/Runtime/CUDA/allocator.h
index 5bc61cd04ee26..4fb4c94c5e9b0 100644
--- a/flang-rt/include/flang-rt/cuda/allocator.h
+++ b/flang/include/flang/Runtime/CUDA/allocator.h
@@ -1,4 +1,4 @@
-//===-- include/flang-rt/cuda/allocator.h -----------------------*- C++ -*-===//
+//===-- include/flang/Runtime/CUDA/allocator.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.
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RT_CUDA_ALLOCATOR_H_
-#define FLANG_RT_CUDA_ALLOCATOR_H_
+#ifndef FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
+#define FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
-#include "flang/Runtime/CUDA/common.h"
+#include "common.h"
#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
@@ -33,4 +33,4 @@ void *CUFAllocUnified(std::size_t);
void CUFFreeUnified(void *);
} // namespace Fortran::runtime::cuda
-#endif // FLANG_RT_CUDA_ALLOCATOR_H_
+#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
>From c7f809879e57c3c03e434773a86093d7f96bf39f Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 11 Feb 2025 10:38:10 +0100
Subject: [PATCH 36/41] Apply darker formatting
---
flang-rt/test/lit.cfg.py | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/flang-rt/test/lit.cfg.py b/flang-rt/test/lit.cfg.py
index 909dbf6eae0ff..652da31e6438f 100644
--- a/flang-rt/test/lit.cfg.py
+++ b/flang-rt/test/lit.cfg.py
@@ -80,11 +80,7 @@ def shjoin(args, sep=" "):
extra_args=isysroot_flag,
unresolved="fatal",
),
- ToolSubst("%cc",
- command=config.cc,
- extra_args=isysroot_flag,
- unresolved="fatal"
- ),
+ ToolSubst("%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal"),
]
llvm_config.add_tool_substitutions(tools)
@@ -92,7 +88,9 @@ def shjoin(args, sep=" "):
llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
# Include path for C headers that define Flang's Fortran ABI.
-config.substitutions.append(("%include", os.path.join(config.flang_source_dir, "include")))
+config.substitutions.append(
+ ("%include", os.path.join(config.flang_source_dir, "include"))
+)
# Library path of libflang_rt.runtime.a (for lib search path when using non-Flang driver for linking)
config.substitutions.append(("%libdir", config.flang_rt_output_resource_lib_dir))
>From 276020f433b49f91ab4eb373a001626ba5365ecf Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 13 Feb 2025 13:33:27 +0100
Subject: [PATCH 37/41] Fix setting option default
---
flang/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index ec8c2d6ffbbf5..4dda492b43119 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -242,7 +242,7 @@ set(FLANG_INCLUDE_RUNTIME_default ON)
if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
set(FLANG_INCLUDE_RUNTIME_default OFF)
endif ()
-option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" FLANG_INCLUDE_RUNTIME_default)
+option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" ${FLANG_INCLUDE_RUNTIME_default})
if (FLANG_INCLUDE_RUNTIME)
if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
message(WARNING "Building Flang-RT using LLVM_ENABLE_RUNTIMES. FLANG_INCLUDE_RUNTIME=${FLANG_INCLUDE_RUNTIME} ignored.")
>From 179682717ad315f230a009a4713071f0dd94d5f8 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 13 Feb 2025 19:49:24 +0100
Subject: [PATCH 38/41] Undo llvm-test-suite workaround
---
flang/CMakeLists.txt | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 4dda492b43119..ec9d05c6432d8 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -557,12 +557,7 @@ include(GetClangResourceDir)
get_clang_resource_dir(HEADER_BINARY_DIR PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. SUBDIR include)
configure_file(
${FLANG_SOURCE_DIR}/include/flang/ISO_Fortran_binding.h
- ${HEADER_BINARY_DIR}/ISO_Fortran_binding.h COPYONLY)
-
-# llvm-test-suite fails if it does not find the the file in this location.
-configure_file(
- ${FLANG_SOURCE_DIR}/include/flang/ISO_Fortran_binding.h
- ${LLVM_RUNTIME_OUTPUT_INTDIR}/../include/flang COPYONLY)
+ ${HEADER_BINARY_DIR}/ISO_Fortran_binding.h)
# And also install it into the install area
get_clang_resource_dir(HEADER_INSTALL_DIR SUBDIR include)
>From 1ee1300dbf2577bd225cf7d3e9492f914d377d73 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 13 Feb 2025 23:36:50 +0100
Subject: [PATCH 39/41] Post-merge fixes
---
flang-rt/unittests/Runtime/Pointer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang-rt/unittests/Runtime/Pointer.cpp b/flang-rt/unittests/Runtime/Pointer.cpp
index b2515c9f981cd..6e8861d374889 100644
--- a/flang-rt/unittests/Runtime/Pointer.cpp
+++ b/flang-rt/unittests/Runtime/Pointer.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/pointer.h"
+#include "tools.h"
#include "gtest/gtest.h"
#include "flang-rt/runtime/descriptor.h"
-#include "flang-rt/runtime/tools.h"
using namespace Fortran::runtime;
>From c7d6b01333533c4b3a37ce8ae0a7e8af0afa489b Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 14 Feb 2025 00:55:04 +0100
Subject: [PATCH 40/41] Re-apply llvm-test-suite workaround
It actually is needed to run llvm-test-suite from a bootstrap
build clang/flang.
---
flang/CMakeLists.txt | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index ec9d05c6432d8..0e0df37d63994 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -557,7 +557,13 @@ include(GetClangResourceDir)
get_clang_resource_dir(HEADER_BINARY_DIR PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. SUBDIR include)
configure_file(
${FLANG_SOURCE_DIR}/include/flang/ISO_Fortran_binding.h
- ${HEADER_BINARY_DIR}/ISO_Fortran_binding.h)
+ ${HEADER_BINARY_DIR}/ISO_Fortran_binding.h COPYONLY)
+
+# llvm-test-suite explicitly searches for this header file
+# (`ISO_FORTRAN_C_HEADER`), cannot hide it in Clang's resource dir.
+configure_file(
+ ${FLANG_SOURCE_DIR}/include/flang/ISO_Fortran_binding.h
+ ${LLVM_RUNTIME_OUTPUT_INTDIR}/../include/flang/ISO_Fortran_binding.h COPYONLY)
# And also install it into the install area
get_clang_resource_dir(HEADER_INSTALL_DIR SUBDIR include)
>From 2f214660a5e6fe52f78d65e10744ff95e0f734e5 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 13 Feb 2025 23:36:50 +0100
Subject: [PATCH 41/41] Post-merge fixes
---
flang-rt/unittests/Runtime/Pointer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang-rt/unittests/Runtime/Pointer.cpp b/flang-rt/unittests/Runtime/Pointer.cpp
index b2515c9f981cd..6e8861d374889 100644
--- a/flang-rt/unittests/Runtime/Pointer.cpp
+++ b/flang-rt/unittests/Runtime/Pointer.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/pointer.h"
+#include "tools.h"
#include "gtest/gtest.h"
#include "flang-rt/runtime/descriptor.h"
-#include "flang-rt/runtime/tools.h"
using namespace Fortran::runtime;
More information about the llvm-commits
mailing list