[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)
Michael Kruse via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Dec 9 07:41:55 PST 2024
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/110217
>From f89c561fe1d11ead1172e576479ceff5b84fb8f7 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 27 Sep 2024 09:18:49 +0200
Subject: [PATCH 01/58] [Flang] LLVM_ENABLE_RUNTIMES=FortranRuntime
Extract Flang's runtime library to use the LLVM_ENABLE_RUNTIME
mechanism.
---
FortranRuntime/.clang-format | 21 +
FortranRuntime/CMakeLists.txt | 184 ++++++++
FortranRuntime/CODE_OWNERS.TXT | 14 +
FortranRuntime/LICENSE.TXT | 234 +++++++++++
FortranRuntime/README.md | 20 +
.../cmake/config.h.cmake.in | 0
.../cmake/modules/AddFortranRuntime.cmake | 109 +++++
.../include/flang/Common/Fortran-consts.h | 50 +++
.../flang/Common}/ISO_Fortran_binding.h | 5 +-
.../Common}/ISO_Fortran_binding_wrapper.h | 7 +-
.../include/flang/Common/api-attrs.h | 5 +-
.../flang/Common}/binary-floating-point.h | 2 +-
.../flang/Common/bit-population-count.h | 0
.../include/flang/Common/constexpr-bitset.h | 0
.../include/flang/Common}/decimal.h | 5 +-
.../include/flang/Common/enum-class.h | 0
.../include/flang/Common/enum-set.h | 0
.../include/flang/Common/fast-int-set.h | 2 +-
.../include/flang/Common/float128.h | 2 +-
.../include/flang/Common/format.h | 2 +-
.../include/flang/Common/idioms.h | 0
.../flang/Common/leading-zero-bit-count.h | 0
.../include/flang/Common/optional.h | 0
.../include/flang/Common/real.h | 0
.../include/flang/Common/reference-wrapper.h | 0
.../include/flang/Common/restorer.h | 0
.../include/flang/Common/target-rounding.h | 40 ++
.../include/flang/Common/uint128.h | 0
.../include/flang/Common/variant.h | 0
.../include/flang/Common/visit.h | 0
.../include/flang/Common/windows-include.h | 0
.../include/flang/Runtime/CUDA/allocator.h | 0
.../include/flang/Runtime/CUDA/descriptor.h | 0
.../include/flang/Runtime/allocatable.h | 0
.../flang/Runtime/allocator-registry.h | 2 +-
.../include/flang/Runtime/array-constructor.h | 0
.../include/flang/Runtime/assign.h | 0
.../include/flang/Runtime/c-or-cpp.h | 0
.../include/flang/Runtime/character.h | 0
.../include/flang/Runtime/command.h | 0
.../include/flang/Runtime/cpp-type.h | 2 +-
.../include/flang/Runtime/derived-api.h | 0
.../include/flang/Runtime/descriptor.h | 2 +-
.../include/flang/Runtime/entry-names.h | 5 +-
.../include/flang/Runtime/exceptions.h | 2 +-
.../include/flang/Runtime/execute.h | 2 +-
.../include/flang/Runtime/extensions.h | 0
.../flang/Runtime/freestanding-tools.h | 0
.../include/flang/Runtime/inquiry.h | 2 +-
.../include/flang/Runtime/io-api.h | 0
.../include/flang/Runtime/iostat.h | 0
.../include/flang/Runtime/magic-numbers.h | 6 +-
.../include/flang/Runtime/main.h | 0
.../flang/Runtime/matmul-instances.inc | 0
.../include/flang/Runtime/matmul-transpose.h | 0
.../include/flang/Runtime/matmul.h | 0
.../include/flang/Runtime/memory.h | 0
.../include/flang/Runtime/misc-intrinsic.h | 0
.../include/flang/Runtime/numeric.h | 0
.../include/flang/Runtime/pointer.h | 0
.../include/flang/Runtime/ragged.h | 2 +-
.../include/flang/Runtime/random.h | 0
.../include/flang/Runtime/reduce.h | 0
.../include/flang/Runtime/reduction.h | 0
.../include/flang/Runtime/stop.h | 0
.../include/flang/Runtime/support.h | 2 +-
.../include/flang/Runtime/temporary-stack.h | 0
.../include/flang/Runtime/time-intrinsic.h | 0
.../include/flang/Runtime/transformational.h | 0
.../include/flang/Runtime/type-code.h | 4 +-
.../include/flang/Testing}/fp-testing.h | 14 +-
.../include/flang/Testing}/testing.h | 8 +
FortranRuntime/lib/CMakeLists.txt | 12 +
.../lib/Common}/big-radix-floating-point.h | 6 +-
.../lib/Common}/binary-to-decimal.cpp | 4 +-
.../lib/Common}/decimal-to-binary.cpp | 6 +-
FortranRuntime/lib/Runtime/CMakeLists.txt | 242 +++++++++++
.../lib/Runtime}/CUDA/CMakeLists.txt | 2 +-
.../lib/Runtime}/CUDA/allocator.cpp | 4 +-
.../lib/Runtime}/CUDA/descriptor.cpp | 2 +-
.../lib/Runtime}/Float128Math/CMakeLists.txt | 2 +-
.../lib/Runtime}/Float128Math/acos.cpp | 2 +-
.../lib/Runtime}/Float128Math/acosh.cpp | 2 +-
.../lib/Runtime}/Float128Math/asin.cpp | 2 +-
.../lib/Runtime}/Float128Math/asinh.cpp | 2 +-
.../lib/Runtime}/Float128Math/atan.cpp | 2 +-
.../lib/Runtime}/Float128Math/atan2.cpp | 2 +-
.../lib/Runtime}/Float128Math/atanh.cpp | 2 +-
.../lib/Runtime}/Float128Math/ceil.cpp | 2 +-
.../lib/Runtime}/Float128Math/complex-math.c | 5 +-
.../lib/Runtime}/Float128Math/complex-math.h | 2 +-
.../lib/Runtime}/Float128Math/cos.cpp | 2 +-
.../lib/Runtime}/Float128Math/cosh.cpp | 2 +-
.../lib/Runtime}/Float128Math/erf.cpp | 2 +-
.../lib/Runtime}/Float128Math/erfc.cpp | 2 +-
.../lib/Runtime}/Float128Math/exp.cpp | 2 +-
.../lib/Runtime}/Float128Math/exponent.cpp | 2 +-
.../lib/Runtime}/Float128Math/floor.cpp | 2 +-
.../lib/Runtime}/Float128Math/fma.cpp | 2 +-
.../lib/Runtime}/Float128Math/fraction.cpp | 2 +-
.../lib/Runtime}/Float128Math/hypot.cpp | 2 +-
.../lib/Runtime}/Float128Math/j0.cpp | 2 +-
.../lib/Runtime}/Float128Math/j1.cpp | 2 +-
.../lib/Runtime}/Float128Math/jn.cpp | 2 +-
.../lib/Runtime}/Float128Math/lgamma.cpp | 2 +-
.../lib/Runtime}/Float128Math/llround.cpp | 2 +-
.../lib/Runtime}/Float128Math/log.cpp | 2 +-
.../lib/Runtime}/Float128Math/log10.cpp | 2 +-
.../lib/Runtime}/Float128Math/lround.cpp | 2 +-
.../lib/Runtime}/Float128Math/math-entries.h | 2 +-
.../lib/Runtime}/Float128Math/mod-real.cpp | 2 +-
.../lib/Runtime}/Float128Math/modulo-real.cpp | 2 +-
.../lib/Runtime}/Float128Math/nearest.cpp | 2 +-
.../lib/Runtime}/Float128Math/norm2.cpp | 2 +-
.../Float128Math/numeric-template-specs.h | 2 +-
.../lib/Runtime}/Float128Math/pow.cpp | 2 +-
.../lib/Runtime}/Float128Math/random.cpp | 2 +-
.../lib/Runtime}/Float128Math/round.cpp | 2 +-
.../lib/Runtime}/Float128Math/rrspacing.cpp | 2 +-
.../lib/Runtime}/Float128Math/scale.cpp | 2 +-
.../Runtime}/Float128Math/set-exponent.cpp | 2 +-
.../lib/Runtime}/Float128Math/sin.cpp | 2 +-
.../lib/Runtime}/Float128Math/sinh.cpp | 2 +-
.../lib/Runtime}/Float128Math/spacing.cpp | 2 +-
.../lib/Runtime}/Float128Math/sqrt.cpp | 2 +-
.../lib/Runtime}/Float128Math/tan.cpp | 2 +-
.../lib/Runtime}/Float128Math/tanh.cpp | 2 +-
.../lib/Runtime}/Float128Math/tgamma.cpp | 2 +-
.../lib/Runtime}/Float128Math/trunc.cpp | 2 +-
.../lib/Runtime}/Float128Math/y0.cpp | 2 +-
.../lib/Runtime}/Float128Math/y1.cpp | 2 +-
.../lib/Runtime}/Float128Math/yn.cpp | 2 +-
.../lib/Runtime}/ISO_Fortran_binding.cpp | 4 +-
.../lib/Runtime}/ISO_Fortran_util.h | 4 +-
.../lib/Runtime}/allocatable.cpp | 4 +-
.../lib/Runtime}/allocator-registry.cpp | 2 +-
.../lib/Runtime}/array-constructor.cpp | 2 +-
.../lib/Runtime}/assign-impl.h | 2 +-
.../lib/Runtime}/assign.cpp | 2 +-
.../lib/Runtime}/buffer.cpp | 2 +-
.../lib/Runtime}/buffer.h | 2 +-
.../lib/Runtime}/character.cpp | 2 +-
.../lib/Runtime}/command.cpp | 2 +-
.../lib/Runtime}/complex-powi.cpp | 15 +-
.../lib/Runtime}/complex-reduction.c | 5 +-
.../lib/Runtime}/complex-reduction.h | 5 +-
.../lib/Runtime}/connection.cpp | 2 +-
.../lib/Runtime}/connection.h | 2 +-
.../lib/Runtime}/copy.cpp | 2 +-
.../lib/Runtime}/copy.h | 2 +-
.../lib/Runtime}/derived-api.cpp | 3 +-
.../lib/Runtime}/derived.cpp | 2 +-
.../lib/Runtime}/derived.h | 2 +-
.../lib/Runtime}/descriptor-io.cpp | 2 +-
.../lib/Runtime}/descriptor-io.h | 2 +-
.../lib/Runtime}/descriptor.cpp | 2 +-
.../lib/Runtime}/dot-product.cpp | 2 +-
.../lib/Runtime}/edit-input.cpp | 2 +-
.../lib/Runtime}/edit-input.h | 4 +-
.../lib/Runtime}/edit-output.cpp | 2 +-
.../lib/Runtime}/edit-output.h | 4 +-
.../lib/Runtime}/emit-encoded.h | 2 +-
.../lib/Runtime}/environment-default-list.h | 5 +-
.../lib/Runtime}/environment.cpp | 2 +-
.../lib/Runtime}/environment.h | 4 +-
.../lib/Runtime}/exceptions.cpp | 2 +-
.../lib/Runtime}/execute.cpp | 2 +-
.../lib/Runtime}/extensions.cpp | 2 +-
.../lib/Runtime}/external-unit.cpp | 2 +-
.../lib/Runtime}/extrema.cpp | 2 +-
.../lib/Runtime}/file.cpp | 2 +-
.../lib/Runtime}/file.h | 2 +-
.../lib/Runtime}/findloc.cpp | 2 +-
.../lib/Runtime}/format-implementation.h | 4 +-
.../lib/Runtime}/format.cpp | 2 +-
.../lib/Runtime}/format.h | 6 +-
.../lib/Runtime}/inquiry.cpp | 2 +-
.../lib/Runtime}/internal-unit.cpp | 2 +-
.../lib/Runtime}/internal-unit.h | 2 +-
.../lib/Runtime}/io-api-common.h | 2 +-
.../lib/Runtime}/io-api-minimal.cpp | 2 +-
.../lib/Runtime}/io-api.cpp | 2 +-
.../lib/Runtime}/io-error.cpp | 2 +-
.../lib/Runtime}/io-error.h | 2 +-
.../lib/Runtime}/io-stmt.cpp | 2 +-
.../lib/Runtime}/io-stmt.h | 2 +-
.../lib/Runtime}/iostat.cpp | 2 +-
.../lib/Runtime}/iso_fortran_env_impl.f90 | 2 +-
.../lib/Runtime}/lock.h | 2 +-
.../lib/Runtime}/main.cpp | 2 +-
.../lib/Runtime}/matmul-transpose.cpp | 2 +-
.../lib/Runtime}/matmul.cpp | 2 +-
.../lib/Runtime}/memory.cpp | 2 +-
.../lib/Runtime}/misc-intrinsic.cpp | 2 +-
.../lib/Runtime}/namelist.cpp | 2 +-
.../lib/Runtime}/namelist.h | 2 +-
.../lib/Runtime}/non-tbp-dio.cpp | 2 +-
.../lib/Runtime}/non-tbp-dio.h | 5 +-
.../lib/Runtime}/numeric-templates.h | 2 +-
.../lib/Runtime}/numeric.cpp | 2 +-
.../lib/Runtime}/pointer.cpp | 2 +-
.../lib/Runtime}/product.cpp | 2 +-
.../lib/Runtime}/pseudo-unit.cpp | 2 +-
.../lib/Runtime}/ragged.cpp | 2 +-
.../lib/Runtime}/random-templates.h | 2 +-
.../lib/Runtime}/random.cpp | 2 +-
.../lib/Runtime}/reduce.cpp | 2 +-
.../lib/Runtime}/reduction-templates.h | 2 +-
.../lib/Runtime}/reduction.cpp | 2 +-
.../lib/Runtime}/stack.h | 2 +-
.../lib/Runtime}/stat.cpp | 2 +-
.../lib/Runtime}/stat.h | 4 +-
.../lib/Runtime}/stop.cpp | 2 +-
.../lib/Runtime}/sum.cpp | 2 +-
.../lib/Runtime}/support.cpp | 2 +-
.../lib/Runtime}/temporary-stack.cpp | 4 +-
.../lib/Runtime}/terminator.cpp | 2 +-
.../lib/Runtime}/terminator.h | 2 +-
.../lib/Runtime}/time-intrinsic.cpp | 2 +-
.../lib/Runtime}/tools.cpp | 2 +-
.../lib/Runtime}/tools.h | 2 +-
.../lib/Runtime}/transformational.cpp | 2 +-
.../lib/Runtime}/type-code.cpp | 3 +-
.../lib/Runtime}/type-info.cpp | 2 +-
.../lib/Runtime}/type-info.h | 4 +-
.../lib/Runtime}/unit-map.cpp | 2 +-
.../lib/Runtime}/unit-map.h | 2 +-
.../lib/Runtime}/unit.cpp | 2 +-
.../lib/Runtime}/unit.h | 2 +-
.../lib/Runtime}/utf.cpp | 2 +-
.../lib/Runtime}/utf.h | 2 +-
FortranRuntime/lib/Testing/CMakeLists.txt | 19 +
.../lib/Testing}/fp-testing.cpp | 12 +-
.../lib/Testing}/testing.cpp | 10 +-
.../module/.clang-format | 0
FortranRuntime/module/CMakeLists.txt | 63 +++
.../module/__cuda_builtins.f90 | 0
.../module/__fortran_builtins.f90 | 0
.../module/__fortran_ieee_exceptions.f90 | 0
.../module/__fortran_type_info.f90 | 0
.../module/__ppc_intrinsics.f90 | 0
.../module/__ppc_types.f90 | 0
.../module/cudadevice.f90 | 2 +-
.../module/ieee_arithmetic.f90 | 0
.../module/ieee_exceptions.f90 | 0
.../module/ieee_features.f90 | 0
.../module/iso_c_binding.f90 | 0
.../module/iso_fortran_env.f90 | 0
{flang => FortranRuntime}/module/mma.f90 | 43 +-
FortranRuntime/test/CMakeLists.txt | 70 ++++
FortranRuntime/test/NonGtestUnit/lit.cfg.py | 21 +
.../test/NonGtestUnit/lit.site.cfg.py.in | 13 +
.../test/Runtime/no-cpp-dep.c | 12 +-
FortranRuntime/test/Unit/lit.cfg.py | 21 +
FortranRuntime/test/Unit/lit.site.cfg.py.in | 14 +
FortranRuntime/test/lit.cfg.py | 78 ++++
FortranRuntime/test/lit.site.cfg.py.in | 17 +
FortranRuntime/unittests/CMakeLists.txt | 62 +++
.../unittests/Common/CMakeLists.txt | 13 +
.../unittests/Common/FastIntSetTest.cpp | 2 +-
.../unittests/Decimal/CMakeLists.txt | 20 +
.../unittests/Decimal/quick-sanity-test.cpp | 10 +-
.../unittests/Decimal/thorough-test.cpp | 10 +-
.../unittests/Evaluate/CMakeLists.txt | 19 +
.../Evaluate/ISO-Fortran-binding.cpp | 12 +-
.../unittests/Evaluate/reshape.cpp | 10 +-
.../unittests/Runtime/AccessTest.cpp | 2 +-
.../unittests/Runtime/Allocatable.cpp | 2 +-
.../unittests/Runtime/ArrayConstructor.cpp | 2 +-
.../unittests/Runtime/BufferTest.cpp | 4 +-
.../unittests/Runtime/CMakeLists.txt | 19 +-
.../unittests/Runtime/CUDA/AllocatorCUF.cpp | 4 +-
.../unittests/Runtime/CharacterTest.cpp | 2 +-
.../unittests/Runtime/CommandTest.cpp | 2 +-
.../unittests/Runtime/Complex.cpp | 4 +-
.../unittests/Runtime/CrashHandlerFixture.cpp | 4 +-
.../unittests/Runtime/CrashHandlerFixture.h | 2 +-
.../unittests/Runtime/Derived.cpp | 2 +-
.../unittests/Runtime/ExternalIOTest.cpp | 2 +-
.../unittests/Runtime/Format.cpp | 8 +-
.../unittests/Runtime/Inquiry.cpp | 2 +-
.../unittests/Runtime/ListInputTest.cpp | 4 +-
.../unittests/Runtime/LogicalFormatTest.cpp | 2 +-
.../unittests/Runtime/Matmul.cpp | 2 +-
.../unittests/Runtime/MatmulTranspose.cpp | 2 +-
.../unittests/Runtime/MiscIntrinsic.cpp | 2 +-
.../unittests/Runtime/Namelist.cpp | 4 +-
.../unittests/Runtime/Numeric.cpp | 2 +-
.../unittests/Runtime/NumericalFormatTest.cpp | 2 +-
.../unittests/Runtime/Pointer.cpp | 2 +-
.../unittests/Runtime/Ragged.cpp | 2 +-
.../unittests/Runtime/Random.cpp | 2 +-
.../unittests/Runtime/Reduction.cpp | 2 +-
.../unittests/Runtime/RuntimeCrashTest.cpp | 4 +-
.../unittests/Runtime/Stop.cpp | 4 +-
.../unittests/Runtime/Support.cpp | 2 +-
.../unittests/Runtime/TemporaryStack.cpp | 4 +-
.../unittests/Runtime/Time.cpp | 2 +-
.../unittests/Runtime/Transformational.cpp | 2 +-
.../unittests/Runtime/tools.h | 2 +-
clang/lib/Driver/ToolChains/CommonArgs.cpp | 3 +-
clang/lib/Driver/ToolChains/Flang.cpp | 4 -
flang/CMakeLists.txt | 45 +-
flang/docs/FlangDriver.md | 5 +-
flang/include/flang/Evaluate/call.h | 6 +-
.../include/flang/Evaluate/characteristics.h | 6 +-
flang/include/flang/Evaluate/common.h | 18 +-
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 | 17 +-
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 +-
.../include/flang/Frontend/FrontendOptions.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 +-
.../flang/Optimizer/Builder/IntrinsicCall.h | 1 +
.../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 | 2 +-
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 +-
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 | 2 +-
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 | 4 +-
.../flang/{Common => Support}/Fortran.h | 38 +-
.../{Common => Support}/MathOptionsBase.def | 0
.../{Common => Support}/MathOptionsBase.h | 8 +-
.../{Common => Support}/OpenMP-features.h | 2 +-
.../flang/{Common => Support}/Version.h | 2 +-
.../flang/{Common => Support}/default-kinds.h | 4 +-
.../flang/{Common => Support}/indirection.h | 4 +-
.../flang/{Common => Support}/interval.h | 4 +-
.../{Common => Support}/reference-counted.h | 2 +-
.../flang/{Common => Support}/reference.h | 2 +-
.../static-multimap-view.h | 2 +-
.../flang/{Common => Support}/template.h | 4 +-
.../flang/{Common => Support}/unwrap.h | 6 +-
flang/include/flang/Tools/CrossToolHelpers.h | 2 +-
flang/lib/CMakeLists.txt | 5 +-
flang/lib/Common/CMakeLists.txt | 60 +--
flang/lib/Decimal/CMakeLists.txt | 86 ----
flang/lib/Evaluate/CMakeLists.txt | 3 +-
flang/lib/Evaluate/call.cpp | 2 +-
flang/lib/Evaluate/characteristics.cpp | 2 +-
flang/lib/Evaluate/common.cpp | 4 +
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/real.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 | 21 +-
flang/lib/Optimizer/CodeGen/TypeConverter.cpp | 2 +-
flang/lib/Optimizer/Dialect/FIRType.cpp | 2 +-
.../lib/Optimizer/Transforms/AddDebugInfo.cpp | 2 +-
.../Transforms/AssumedRankOpConversion.cpp | 2 +-
flang/lib/Optimizer/Transforms/CMakeLists.txt | 1 +
.../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 | 56 +++
.../{Common => Support}/Fortran-features.cpp | 6 +-
flang/lib/{Common => Support}/Fortran.cpp | 6 +-
flang/lib/{Common => Support}/Version.cpp | 4 +-
flang/lib/Support/big-radix-floating-point.h | 396 ++++++++++++++++++
.../lib/{Common => Support}/default-kinds.cpp | 4 +-
flang/lib/{Common => Support}/idioms.cpp | 2 +-
flang/runtime/CMakeLists.txt | 314 --------------
flang/test/CMakeLists.txt | 4 +-
flang/test/Driver/linker-flags.f90 | 6 +-
.../test/Driver/msvc-dependent-lib-flags.f90 | 4 -
flang/test/lib/CMakeLists.txt | 1 +
flang/test/lit.cfg.py | 23 -
flang/test/lit.site.cfg.py.in | 1 -
flang/tools/CMakeLists.txt | 1 -
flang/tools/bbc/CMakeLists.txt | 1 +
flang/tools/bbc/bbc.cpp | 8 +-
flang/tools/f18-parse-demo/CMakeLists.txt | 2 +
flang/tools/f18-parse-demo/f18-parse-demo.cpp | 4 +-
flang/tools/f18/CMakeLists.txt | 173 --------
flang/tools/f18/dump.cpp | 42 --
flang/tools/fir-opt/CMakeLists.txt | 2 +
flang/tools/flang-driver/CMakeLists.txt | 3 +
flang/tools/tco/CMakeLists.txt | 2 +
flang/unittests/CMakeLists.txt | 37 --
flang/unittests/Common/CMakeLists.txt | 3 -
flang/unittests/Decimal/CMakeLists.txt | 10 -
flang/unittests/Evaluate/CMakeLists.txt | 24 +-
.../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/uint128.cpp | 2 +-
flang/unittests/Runtime/CUDA/CMakeLists.txt | 15 -
lld/COFF/MinGW.cpp | 6 +-
llvm/CMakeLists.txt | 2 +-
.../modules/LLVMExternalProjectUtils.cmake | 16 +-
llvm/projects/CMakeLists.txt | 5 +-
llvm/runtimes/CMakeLists.txt | 32 +-
runtimes/CMakeLists.txt | 3 +-
469 files changed, 2512 insertions(+), 1388 deletions(-)
create mode 100644 FortranRuntime/.clang-format
create mode 100644 FortranRuntime/CMakeLists.txt
create mode 100644 FortranRuntime/CODE_OWNERS.TXT
create mode 100644 FortranRuntime/LICENSE.TXT
create mode 100644 FortranRuntime/README.md
rename flang/runtime/config.h.cmake => FortranRuntime/cmake/config.h.cmake.in (100%)
create mode 100644 FortranRuntime/cmake/modules/AddFortranRuntime.cmake
create mode 100644 FortranRuntime/include/flang/Common/Fortran-consts.h
rename {flang/include/flang => FortranRuntime/include/flang/Common}/ISO_Fortran_binding.h (97%)
rename {flang/include/flang => FortranRuntime/include/flang/Common}/ISO_Fortran_binding_wrapper.h (85%)
rename {flang => FortranRuntime}/include/flang/Common/api-attrs.h (99%)
rename {flang/include/flang/Decimal => FortranRuntime/include/flang/Common}/binary-floating-point.h (99%)
rename {flang => FortranRuntime}/include/flang/Common/bit-population-count.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/constexpr-bitset.h (100%)
rename {flang/include/flang/Decimal => FortranRuntime/include/flang/Common}/decimal.h (97%)
rename {flang => FortranRuntime}/include/flang/Common/enum-class.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/enum-set.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/fast-int-set.h (99%)
rename {flang => FortranRuntime}/include/flang/Common/float128.h (96%)
rename {flang => FortranRuntime}/include/flang/Common/format.h (99%)
rename {flang => FortranRuntime}/include/flang/Common/idioms.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/leading-zero-bit-count.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/optional.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/real.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/reference-wrapper.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/restorer.h (100%)
create mode 100644 FortranRuntime/include/flang/Common/target-rounding.h
rename {flang => FortranRuntime}/include/flang/Common/uint128.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/variant.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/visit.h (100%)
rename {flang => FortranRuntime}/include/flang/Common/windows-include.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/CUDA/allocator.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/CUDA/descriptor.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/allocatable.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/allocator-registry.h (96%)
rename {flang => FortranRuntime}/include/flang/Runtime/array-constructor.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/assign.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/c-or-cpp.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/character.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/command.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/cpp-type.h (98%)
rename {flang => FortranRuntime}/include/flang/Runtime/derived-api.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/descriptor.h (99%)
rename {flang => FortranRuntime}/include/flang/Runtime/entry-names.h (97%)
rename {flang => FortranRuntime}/include/flang/Runtime/exceptions.h (91%)
rename {flang => FortranRuntime}/include/flang/Runtime/execute.h (93%)
rename {flang => FortranRuntime}/include/flang/Runtime/extensions.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/freestanding-tools.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/inquiry.h (94%)
rename {flang => FortranRuntime}/include/flang/Runtime/io-api.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/iostat.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/magic-numbers.h (98%)
rename {flang => FortranRuntime}/include/flang/Runtime/main.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/matmul-instances.inc (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/matmul-transpose.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/matmul.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/memory.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/misc-intrinsic.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/numeric.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/pointer.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/ragged.h (97%)
rename {flang => FortranRuntime}/include/flang/Runtime/random.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/reduce.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/reduction.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/stop.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/support.h (96%)
rename {flang => FortranRuntime}/include/flang/Runtime/temporary-stack.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/time-intrinsic.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/transformational.h (100%)
rename {flang => FortranRuntime}/include/flang/Runtime/type-code.h (96%)
rename {flang/unittests/Evaluate => FortranRuntime/include/flang/Testing}/fp-testing.h (56%)
rename {flang/unittests/Evaluate => FortranRuntime/include/flang/Testing}/testing.h (80%)
create mode 100644 FortranRuntime/lib/CMakeLists.txt
rename {flang/lib/Decimal => FortranRuntime/lib/Common}/big-radix-floating-point.h (98%)
rename {flang/lib/Decimal => FortranRuntime/lib/Common}/binary-to-decimal.cpp (99%)
rename {flang/lib/Decimal => FortranRuntime/lib/Common}/decimal-to-binary.cpp (99%)
create mode 100644 FortranRuntime/lib/Runtime/CMakeLists.txt
rename {flang/runtime => FortranRuntime/lib/Runtime}/CUDA/CMakeLists.txt (93%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/CUDA/allocator.cpp (94%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/CUDA/descriptor.cpp (91%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/CMakeLists.txt (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/acos.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/acosh.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/asin.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/asinh.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/atan.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/atan2.cpp (88%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/atanh.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/ceil.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/complex-math.c (92%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/complex-math.h (96%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/cos.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/cosh.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/erf.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/erfc.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/exp.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/exponent.cpp (90%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/floor.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/fma.cpp (89%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/fraction.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/hypot.cpp (88%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/j0.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/j1.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/jn.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/lgamma.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/llround.cpp (88%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/log.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/log10.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/lround.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/math-entries.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/mod-real.cpp (89%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/modulo-real.cpp (89%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/nearest.cpp (89%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/norm2.cpp (93%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/numeric-template-specs.h (96%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/pow.cpp (88%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/random.cpp (89%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/round.cpp (89%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/rrspacing.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/scale.cpp (90%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/set-exponent.cpp (88%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/sin.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/sinh.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/spacing.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/sqrt.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/tan.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/tanh.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/tgamma.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/trunc.cpp (89%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/y0.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/y1.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/Float128Math/yn.cpp (87%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/ISO_Fortran_binding.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/ISO_Fortran_util.h (96%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/allocatable.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/allocator-registry.cpp (94%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/array-constructor.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/assign-impl.h (93%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/assign.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/buffer.cpp (92%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/buffer.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/character.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/command.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/complex-powi.cpp (91%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/complex-reduction.c (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/complex-reduction.h (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/connection.cpp (96%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/connection.h (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/copy.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/copy.h (93%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/derived-api.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/derived.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/derived.h (94%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/descriptor-io.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/descriptor-io.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/descriptor.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/dot-product.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-input.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-input.h (95%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-output.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/edit-output.h (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/emit-encoded.h (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/environment-default-list.h (85%)
mode change 100755 => 100644
rename {flang/runtime => FortranRuntime/lib/Runtime}/environment.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/environment.h (95%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/exceptions.cpp (96%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/execute.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/extensions.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/external-unit.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/extrema.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/file.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/file.h (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/findloc.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/format-implementation.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/format.cpp (92%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/format.h (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/inquiry.cpp (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/internal-unit.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/internal-unit.h (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/io-api-common.h (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/io-api-minimal.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/io-api.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/io-error.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/io-error.h (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/io-stmt.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/io-stmt.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/iostat.cpp (98%)
rename {flang/module => FortranRuntime/lib/Runtime}/iso_fortran_env_impl.f90 (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/lock.h (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/main.cpp (94%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/matmul-transpose.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/matmul.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/memory.cpp (93%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/misc-intrinsic.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/namelist.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/namelist.h (96%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/non-tbp-dio.cpp (93%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/non-tbp-dio.h (93%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/numeric-templates.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/numeric.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/pointer.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/product.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/pseudo-unit.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/ragged.cpp (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/random-templates.h (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/random.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/reduce.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/reduction-templates.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/reduction.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/stack.h (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/stat.cpp (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/stat.h (95%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/stop.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/sum.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/support.cpp (94%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/temporary-stack.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/terminator.cpp (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/terminator.h (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/time-intrinsic.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/tools.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/tools.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/transformational.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/type-code.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/type-info.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/type-info.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/unit-map.cpp (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/unit-map.h (97%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/unit.cpp (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/unit.h (99%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/utf.cpp (98%)
rename {flang/runtime => FortranRuntime/lib/Runtime}/utf.h (97%)
create mode 100644 FortranRuntime/lib/Testing/CMakeLists.txt
rename {flang/unittests/Evaluate => FortranRuntime/lib/Testing}/fp-testing.cpp (86%)
rename {flang/unittests/Evaluate => FortranRuntime/lib/Testing}/testing.cpp (88%)
rename {flang => FortranRuntime}/module/.clang-format (100%)
create mode 100644 FortranRuntime/module/CMakeLists.txt
rename {flang => FortranRuntime}/module/__cuda_builtins.f90 (100%)
rename {flang => FortranRuntime}/module/__fortran_builtins.f90 (100%)
rename {flang => FortranRuntime}/module/__fortran_ieee_exceptions.f90 (100%)
rename {flang => FortranRuntime}/module/__fortran_type_info.f90 (100%)
rename {flang => FortranRuntime}/module/__ppc_intrinsics.f90 (100%)
rename {flang => FortranRuntime}/module/__ppc_types.f90 (100%)
rename {flang => FortranRuntime}/module/cudadevice.f90 (96%)
rename {flang => FortranRuntime}/module/ieee_arithmetic.f90 (100%)
rename {flang => FortranRuntime}/module/ieee_exceptions.f90 (100%)
rename {flang => FortranRuntime}/module/ieee_features.f90 (100%)
rename {flang => FortranRuntime}/module/iso_c_binding.f90 (100%)
rename {flang => FortranRuntime}/module/iso_fortran_env.f90 (100%)
rename {flang => FortranRuntime}/module/mma.f90 (98%)
create mode 100644 FortranRuntime/test/CMakeLists.txt
create mode 100644 FortranRuntime/test/NonGtestUnit/lit.cfg.py
create mode 100644 FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in
rename {flang => FortranRuntime}/test/Runtime/no-cpp-dep.c (75%)
create mode 100644 FortranRuntime/test/Unit/lit.cfg.py
create mode 100644 FortranRuntime/test/Unit/lit.site.cfg.py.in
create mode 100644 FortranRuntime/test/lit.cfg.py
create mode 100644 FortranRuntime/test/lit.site.cfg.py.in
create mode 100644 FortranRuntime/unittests/CMakeLists.txt
create mode 100644 FortranRuntime/unittests/Common/CMakeLists.txt
rename {flang => FortranRuntime}/unittests/Common/FastIntSetTest.cpp (97%)
create mode 100644 FortranRuntime/unittests/Decimal/CMakeLists.txt
rename {flang => FortranRuntime}/unittests/Decimal/quick-sanity-test.cpp (91%)
rename {flang => FortranRuntime}/unittests/Decimal/thorough-test.cpp (85%)
create mode 100644 FortranRuntime/unittests/Evaluate/CMakeLists.txt
rename {flang => FortranRuntime}/unittests/Evaluate/ISO-Fortran-binding.cpp (98%)
rename {flang => FortranRuntime}/unittests/Evaluate/reshape.cpp (88%)
rename {flang => FortranRuntime}/unittests/Runtime/AccessTest.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/Allocatable.cpp (98%)
rename {flang => FortranRuntime}/unittests/Runtime/ArrayConstructor.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/BufferTest.cpp (97%)
rename {flang => FortranRuntime}/unittests/Runtime/CMakeLists.txt (54%)
rename {flang => FortranRuntime}/unittests/Runtime/CUDA/AllocatorCUF.cpp (95%)
rename {flang => FortranRuntime}/unittests/Runtime/CharacterTest.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/CommandTest.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/Complex.cpp (98%)
rename {flang => FortranRuntime}/unittests/Runtime/CrashHandlerFixture.cpp (92%)
rename {flang => FortranRuntime}/unittests/Runtime/CrashHandlerFixture.h (91%)
rename {flang => FortranRuntime}/unittests/Runtime/Derived.cpp (96%)
rename {flang => FortranRuntime}/unittests/Runtime/ExternalIOTest.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/Format.cpp (96%)
rename {flang => FortranRuntime}/unittests/Runtime/Inquiry.cpp (98%)
rename {flang => FortranRuntime}/unittests/Runtime/ListInputTest.cpp (98%)
rename {flang => FortranRuntime}/unittests/Runtime/LogicalFormatTest.cpp (96%)
rename {flang => FortranRuntime}/unittests/Runtime/Matmul.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/MatmulTranspose.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/MiscIntrinsic.cpp (98%)
rename {flang => FortranRuntime}/unittests/Runtime/Namelist.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/Numeric.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/NumericalFormatTest.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/Pointer.cpp (98%)
rename {flang => FortranRuntime}/unittests/Runtime/Ragged.cpp (94%)
rename {flang => FortranRuntime}/unittests/Runtime/Random.cpp (97%)
rename {flang => FortranRuntime}/unittests/Runtime/Reduction.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/RuntimeCrashTest.cpp (98%)
rename {flang => FortranRuntime}/unittests/Runtime/Stop.cpp (96%)
rename {flang => FortranRuntime}/unittests/Runtime/Support.cpp (97%)
rename {flang => FortranRuntime}/unittests/Runtime/TemporaryStack.cpp (98%)
rename {flang => FortranRuntime}/unittests/Runtime/Time.cpp (98%)
rename {flang => FortranRuntime}/unittests/Runtime/Transformational.cpp (99%)
rename {flang => FortranRuntime}/unittests/Runtime/tools.h (96%)
rename flang/include/flang/{Common => Support}/Fortran-features.h (98%)
rename flang/include/flang/{Common => Support}/Fortran.h (73%)
rename flang/include/flang/{Common => Support}/MathOptionsBase.def (100%)
rename flang/include/flang/{Common => Support}/MathOptionsBase.h (86%)
rename flang/include/flang/{Common => Support}/OpenMP-features.h (94%)
rename flang/include/flang/{Common => Support}/Version.h (95%)
rename flang/include/flang/{Common => Support}/default-kinds.h (96%)
rename flang/include/flang/{Common => Support}/indirection.h (98%)
rename flang/include/flang/{Common => Support}/interval.h (97%)
rename flang/include/flang/{Common => Support}/reference-counted.h (96%)
rename flang/include/flang/{Common => Support}/reference.h (97%)
rename flang/include/flang/{Common => Support}/static-multimap-view.h (97%)
rename flang/include/flang/{Common => Support}/template.h (99%)
rename flang/include/flang/{Common => Support}/unwrap.h (97%)
delete mode 100644 flang/lib/Decimal/CMakeLists.txt
create mode 100644 flang/lib/Support/CMakeLists.txt
rename flang/lib/{Common => Support}/Fortran-features.cpp (91%)
rename flang/lib/{Common => Support}/Fortran.cpp (96%)
rename flang/lib/{Common => Support}/Version.cpp (95%)
create mode 100644 flang/lib/Support/big-radix-floating-point.h
rename flang/lib/{Common => Support}/default-kinds.cpp (94%)
rename flang/lib/{Common => Support}/idioms.cpp (89%)
delete mode 100644 flang/runtime/CMakeLists.txt
delete mode 100644 flang/tools/f18/CMakeLists.txt
delete mode 100644 flang/tools/f18/dump.cpp
delete mode 100644 flang/unittests/Common/CMakeLists.txt
delete mode 100644 flang/unittests/Decimal/CMakeLists.txt
delete mode 100644 flang/unittests/Runtime/CUDA/CMakeLists.txt
diff --git a/FortranRuntime/.clang-format b/FortranRuntime/.clang-format
new file mode 100644
index 00000000000000..c1dfe06fdf5782
--- /dev/null
+++ b/FortranRuntime/.clang-format
@@ -0,0 +1,21 @@
+---
+# 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: 4
+ - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
+ Priority: 3
+ - Regex: '^"(flang|\.\.)/'
+ Priority: 2
+ - Regex: '.*'
+ Priority: 1
+...
+
+# vim:set filetype=yaml:
diff --git a/FortranRuntime/CMakeLists.txt b/FortranRuntime/CMakeLists.txt
new file mode 100644
index 00000000000000..765e1445fc1a18
--- /dev/null
+++ b/FortranRuntime/CMakeLists.txt
@@ -0,0 +1,184 @@
+#===-- 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 FortranRuntime library and Fortran modules required
+# by programs compiled by Flang. This is file is intended to be included using
+# the LLVM_ENABLE_RUNTIMES mechanism.
+#
+#===------------------------------------------------------------------------===#
+
+set(LLVM_SUBPROJECT_TITLE "Fortran Runtime")
+set(FORTRANRUNTIME_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(FORTRANRUNTIME_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+
+list(APPEND CMAKE_MODULE_PATH
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+ )
+include(AddFortranRuntime)
+
+
+
+############################
+# Build Mode Introspection #
+############################
+
+# Setting these variables from an LLVM build is sufficient that FortranRuntime can
+# construct the output paths, so it can behave as if it were in-tree here.
+set(LLVM_TREE_AVAILABLE OFF)
+if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
+ # This is a bootstap build
+ set(LLVM_TREE_AVAILABLE ON)
+endif()
+
+if (LLVM_TREE_AVAILABLE)
+ # Despite Clang in the name, get_clang_resource_dir does not depend on Clang being added to the build
+ # flang-new uses the same resource dir as clang.
+ include(GetClangResourceDir)
+ get_clang_resource_dir(FORTRANRUNTIME_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
+ get_clang_resource_dir(FORTRANRUNTIME_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the install prefix itself
+
+ # FIXME: If compiling multiple triples, include dirs overwrite each other
+ get_clang_resource_dir(FORTRANRUNTIME_BUILD_INCLUDE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "include")
+ get_clang_resource_dir(FORTRANRUNTIME_INSTALL_INCLUDE_DIR SUBDIR "include")
+else ()
+ set(FORTRANRUNTIME_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
+ set(FORTRANRUNTIME_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
+
+ set(FORTRANRUNTIME_BUILD_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+ set(FORTRANRUNTIME_INSTALL_INCLUDE_DIR "include")
+endif ()
+
+
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+ set(FORTRANRUNTIME_BUILD_LIB_DIR "${FORTRANRUNTIME_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+ set(FORTRANRUNTIME_INSTALL_LIB_DIR "${FORTRANRUNTIME_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+endif()
+
+
+
+
+#################
+# Build Options #
+#################
+
+option(FORTRANRUNTIME_INCLUDE_TESTS
+ "Generate build targets for the FortranRuntime unit tests."
+ ${LLVM_INCLUDE_TESTS})
+
+# 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(FORTRARUNTIME_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()
+
+option(FLANG_EXPERIMENTAL_CUDA_RUNTIME "Compile Fortran runtime as CUDA sources (experimental)" OFF)
+if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
+ message(FATAL_ERROOR "FLANG_EXPERIMENTAL_CUDA_RUNTIME currently not supported")
+endif()
+
+
+
+
+########################
+# System Introspection #
+########################
+
+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(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)
+
+# 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)
+
+# 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)
+
+
+#####################
+# Build Preparation #
+#####################
+
+enable_language(Fortran)
+
+# C++17 required for FortranRuntime, 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)
+
+# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
+# to avoid an unwanted dependency on libstdc++/libc++.so.
+add_definitions(-U_GLIBCXX_ASSERTIONS)
+add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
+
+
+configure_file(cmake/config.h.cmake.in config.h)
+
+configure_file(
+ "${FORTRANRUNTIME_SOURCE_DIR}/include/flang/Common/ISO_Fortran_binding.h"
+ "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/ISO_Fortran_binding.h"
+)
+install(
+ FILES "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/ISO_Fortran_binding.h"
+ DESTINATION "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}"
+)
+
+
+
+###################
+# Build Artifacts #
+###################
+
+add_subdirectory(lib)
+add_subdirectory(module)
+
+if (FORTRANRUNTIME_INCLUDE_TESTS)
+ add_subdirectory(unittests)
+ add_subdirectory(test)
+endif()
+
diff --git a/FortranRuntime/CODE_OWNERS.TXT b/FortranRuntime/CODE_OWNERS.TXT
new file mode 100644
index 00000000000000..649243aa1e8fec
--- /dev/null
+++ b/FortranRuntime/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/FortranRuntime/LICENSE.TXT b/FortranRuntime/LICENSE.TXT
new file mode 100644
index 00000000000000..53bb2e7fbc7643
--- /dev/null
+++ b/FortranRuntime/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/FortranRuntime/README.md b/FortranRuntime/README.md
new file mode 100644
index 00000000000000..6fd4b3359f7888
--- /dev/null
+++ b/FortranRuntime/README.md
@@ -0,0 +1,20 @@
+# Fortran Runtime
+
+Fortran Runtime is the runtime library for code emitted by the Flang
+compiler (https://flang.llvm.org).
+
+## Getting Started
+
+### Bootstrap Build
+
+```sh
+cmake -S <path-to-llvm-project>/llvm -DLLVM_ENABLE_PROJECTS=flang -DLLVM_ENABLE_RUNTIMES=FortranRuntime
+```
+
+### Runtime-only build
+
+```sh
+cmake -S <path-to-llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=FortranRuntime -DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir-or-installprefix>/bin/flang-new
+```
+
+
diff --git a/flang/runtime/config.h.cmake b/FortranRuntime/cmake/config.h.cmake.in
similarity index 100%
rename from flang/runtime/config.h.cmake
rename to FortranRuntime/cmake/config.h.cmake.in
diff --git a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
new file mode 100644
index 00000000000000..a4fc95495610cc
--- /dev/null
+++ b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
@@ -0,0 +1,109 @@
+#===-- cmake/modules/AddFortranRuntime.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 option for FortranRuntime.
+#
+# Usage:
+#
+# add_fortranruntime_library(name sources ...
+# SHARED
+# Build a dynamic (.so/.dll) library
+# STATIC
+# Build a static (.a/.lib) library
+# OBJECT
+# Create only object- and Fortran module 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.
+# )
+function (add_fortranruntime_library name)
+ set(options STATIC SHARED OBJECT INSTALL_WITH_TOOLCHAIN EXCLUDE_FROM_ALL LINK_TO_LLVM)
+ set(multiValueArgs ADDITIONAL_HEADERS)
+ cmake_parse_arguments(ARG
+ "${options}"
+ ""
+ "${multiValueArgs}"
+ ${ARGN})
+
+ # 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)
+
+ # 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 (EXCLUDE_FROM_ALL)
+ list(APPEND extra_args EXCLUDE_FROM_ALL)
+ endif ()
+
+ add_library(${name} ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS} )
+ if (ARG_INSTALL_WITH_TOOLCHAIN)
+ set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Toolchain Libraries")
+ elseif (ARG_OBJECT)
+ set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Object Libraries")
+ else ()
+ set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Libraries")
+ endif ()
+
+ target_compile_features(${name} PRIVATE cxx_std_17)
+ 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->)
+ endif()
+
+ target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_BINARY_DIR}") # For configured config.h for be found
+ target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+
+set_target_properties(${name}
+ PROPERTIES
+ Fortran_MODULE_DIRECTORY "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/flang"
+)
+
+ 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} PRIVATE ${LLVM_INCLUDE_DIRS})
+ 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
+ if (INSTALL_WITH_TOOLCHAIN)
+ set_target_properties(${name}
+ PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
+ ARCHIVE_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
+ RUNTIME_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
+ )
+
+ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+ install(TARGETS ${name}
+ LIBRARY DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
+ ARCHIVE DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
+ RUNTIME DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
+ )
+ endif ()
+ endif ()
+endfunction (add_fortranruntime_library)
diff --git a/FortranRuntime/include/flang/Common/Fortran-consts.h b/FortranRuntime/include/flang/Common/Fortran-consts.h
new file mode 100644
index 00000000000000..3156c6c50c3b9a
--- /dev/null
+++ b/FortranRuntime/include/flang/Common/Fortran-consts.h
@@ -0,0 +1,50 @@
+//===-- include/flang/Common/Fortran-consts.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_COMMON_FORTRAN_CONSTS_H_
+#define FORTRAN_COMMON_FORTRAN_CONSTS_H_
+
+// Fortran language concepts that are used in many phases are defined
+// once here to avoid redundancy and needless translation.
+
+#include "flang/Common/enum-class.h"
+#include <cstdint>
+
+namespace Fortran::common {
+
+// Fortran has five kinds of intrinsic data types, plus the derived types.
+ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
+ENUM_CLASS(VectorElementCategory, Integer, Unsigned, Real)
+
+
+ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
+ Print, Read, Rewind, Wait, Write)
+
+// Defined I/O variants
+ENUM_CLASS(
+ DefinedIo, ReadFormatted, ReadUnformatted, WriteFormatted, WriteUnformatted)
+
+// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
+static constexpr int maxRank{15};
+
+
+// Floating-point rounding modes; these are packed into a byte to save
+// room in the runtime's format processing context structure. These
+// enumerators are defined with the corresponding values returned from
+// llvm.get.rounding.
+enum class RoundingMode : std::uint8_t {
+ ToZero, // ROUND=ZERO, RZ - truncation
+ TiesToEven, // ROUND=NEAREST, RN - default IEEE rounding
+ Up, // ROUND=UP, RU
+ Down, // ROUND=DOWN, RD
+ TiesAwayFromZero, // ROUND=COMPATIBLE, RC - ties round away from zero
+};
+
+
+} // namespace Fortran::common
+#endif // FORTRAN_COMMON_FORTRAN_CONSTS_H_
diff --git a/flang/include/flang/ISO_Fortran_binding.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
similarity index 97%
rename from flang/include/flang/ISO_Fortran_binding.h
rename to FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
index 89a10ce69a2ba2..21247103bcc552 100644
--- a/flang/include/flang/ISO_Fortran_binding.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
@@ -1,11 +1,10 @@
-/*===-- include/flang/ISO_Fortran_binding.h -----------------------*- C++ -*-===
+/*===-- include/flang/Common/ISO_Fortran_binding.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 CFI_ISO_FORTRAN_BINDING_H_
#define CFI_ISO_FORTRAN_BINDING_H_
diff --git a/flang/include/flang/ISO_Fortran_binding_wrapper.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
similarity index 85%
rename from flang/include/flang/ISO_Fortran_binding_wrapper.h
rename to FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
index 37289bdbabd03c..ee02f6f129732e 100644
--- a/flang/include/flang/ISO_Fortran_binding_wrapper.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -1,11 +1,10 @@
-/*===-- 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_
@@ -23,7 +22,7 @@
/* clang-format off */
#include <stddef.h>
-#include "Common/api-attrs.h"
+#include "flang/Common/api-attrs.h"
#ifdef __cplusplus
namespace Fortran {
namespace ISO {
diff --git a/flang/include/flang/Common/api-attrs.h b/FortranRuntime/include/flang/Common/api-attrs.h
similarity index 99%
rename from flang/include/flang/Common/api-attrs.h
rename to FortranRuntime/include/flang/Common/api-attrs.h
index d73e60996bc81f..b56a3c8a047af6 100644
--- a/flang/include/flang/Common/api-attrs.h
+++ b/FortranRuntime/include/flang/Common/api-attrs.h
@@ -1,11 +1,10 @@
-/*===-- include/flang/Common/api-attrs.h ---------------------------*- C -*-=//
+/*===-- include/flang/Common/api-attrs.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
*
- *===------------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
/*
* The file defines a set macros that can be used to apply
diff --git a/flang/include/flang/Decimal/binary-floating-point.h b/FortranRuntime/include/flang/Common/binary-floating-point.h
similarity index 99%
rename from flang/include/flang/Decimal/binary-floating-point.h
rename to FortranRuntime/include/flang/Common/binary-floating-point.h
index 1e0cde97d98e61..1409b94192740c 100644
--- a/flang/include/flang/Decimal/binary-floating-point.h
+++ b/FortranRuntime/include/flang/Common/binary-floating-point.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Decimal/binary-floating-point.h -----------*- C++ -*-===//
+//===-- include/flang/Common/binary-floating-point.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/Common/bit-population-count.h b/FortranRuntime/include/flang/Common/bit-population-count.h
similarity index 100%
rename from flang/include/flang/Common/bit-population-count.h
rename to FortranRuntime/include/flang/Common/bit-population-count.h
diff --git a/flang/include/flang/Common/constexpr-bitset.h b/FortranRuntime/include/flang/Common/constexpr-bitset.h
similarity index 100%
rename from flang/include/flang/Common/constexpr-bitset.h
rename to FortranRuntime/include/flang/Common/constexpr-bitset.h
diff --git a/flang/include/flang/Decimal/decimal.h b/FortranRuntime/include/flang/Common/decimal.h
similarity index 97%
rename from flang/include/flang/Decimal/decimal.h
rename to FortranRuntime/include/flang/Common/decimal.h
index 443163d058e28b..2a75b98c112225 100644
--- a/flang/include/flang/Decimal/decimal.h
+++ b/FortranRuntime/include/flang/Common/decimal.h
@@ -1,11 +1,10 @@
-/*===-- include/flang/Decimal/decimal.h ---------------------------*- C++ -*-===
+/*===-- include/flang/Common/decimal.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
*
- * ===-----------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
/* C and C++ API for binary-to/from-decimal conversion package. */
diff --git a/flang/include/flang/Common/enum-class.h b/FortranRuntime/include/flang/Common/enum-class.h
similarity index 100%
rename from flang/include/flang/Common/enum-class.h
rename to FortranRuntime/include/flang/Common/enum-class.h
diff --git a/flang/include/flang/Common/enum-set.h b/FortranRuntime/include/flang/Common/enum-set.h
similarity index 100%
rename from flang/include/flang/Common/enum-set.h
rename to FortranRuntime/include/flang/Common/enum-set.h
diff --git a/flang/include/flang/Common/fast-int-set.h b/FortranRuntime/include/flang/Common/fast-int-set.h
similarity index 99%
rename from flang/include/flang/Common/fast-int-set.h
rename to FortranRuntime/include/flang/Common/fast-int-set.h
index d1c9c756a44a65..48209a773c4cd1 100644
--- a/flang/include/flang/Common/fast-int-set.h
+++ b/FortranRuntime/include/flang/Common/fast-int-set.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/fast-int-set.h --------------------*- C++ -*-===//
+//===-- include/flang/Common/fast-int-set.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/Common/float128.h b/FortranRuntime/include/flang/Common/float128.h
similarity index 96%
rename from flang/include/flang/Common/float128.h
rename to FortranRuntime/include/flang/Common/float128.h
index 2e76bc0a162e61..a7036bf679e5ae 100644
--- a/flang/include/flang/Common/float128.h
+++ b/FortranRuntime/include/flang/Common/float128.h
@@ -1,4 +1,4 @@
-/*===-- flang/Common/float128.h ----------------------------------*- C -*-===
+/*===-- include/flang/Common/float128.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/Common/format.h b/FortranRuntime/include/flang/Common/format.h
similarity index 99%
rename from flang/include/flang/Common/format.h
rename to FortranRuntime/include/flang/Common/format.h
index 2374ff6983cf41..138e84b72b733d 100644
--- a/flang/include/flang/Common/format.h
+++ b/FortranRuntime/include/flang/Common/format.h
@@ -10,7 +10,7 @@
#define FORTRAN_COMMON_FORMAT_H_
#include "enum-set.h"
-#include "flang/Common/Fortran.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/Common/idioms.h b/FortranRuntime/include/flang/Common/idioms.h
similarity index 100%
rename from flang/include/flang/Common/idioms.h
rename to FortranRuntime/include/flang/Common/idioms.h
diff --git a/flang/include/flang/Common/leading-zero-bit-count.h b/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
similarity index 100%
rename from flang/include/flang/Common/leading-zero-bit-count.h
rename to FortranRuntime/include/flang/Common/leading-zero-bit-count.h
diff --git a/flang/include/flang/Common/optional.h b/FortranRuntime/include/flang/Common/optional.h
similarity index 100%
rename from flang/include/flang/Common/optional.h
rename to FortranRuntime/include/flang/Common/optional.h
diff --git a/flang/include/flang/Common/real.h b/FortranRuntime/include/flang/Common/real.h
similarity index 100%
rename from flang/include/flang/Common/real.h
rename to FortranRuntime/include/flang/Common/real.h
diff --git a/flang/include/flang/Common/reference-wrapper.h b/FortranRuntime/include/flang/Common/reference-wrapper.h
similarity index 100%
rename from flang/include/flang/Common/reference-wrapper.h
rename to FortranRuntime/include/flang/Common/reference-wrapper.h
diff --git a/flang/include/flang/Common/restorer.h b/FortranRuntime/include/flang/Common/restorer.h
similarity index 100%
rename from flang/include/flang/Common/restorer.h
rename to FortranRuntime/include/flang/Common/restorer.h
diff --git a/FortranRuntime/include/flang/Common/target-rounding.h b/FortranRuntime/include/flang/Common/target-rounding.h
new file mode 100644
index 00000000000000..970d8fb61fbd1b
--- /dev/null
+++ b/FortranRuntime/include/flang/Common/target-rounding.h
@@ -0,0 +1,40 @@
+//===-- include/flang/Common/target-rounding.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_COMMON_TARGET_ROUNDING_H_
+#define FORTRAN_COMMON_TARGET_ROUNDING_H_
+
+
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Common/enum-set.h"
+
+
+namespace Fortran::common {
+
+// Floating-point rounding control
+struct Rounding {
+ common::RoundingMode mode{common::RoundingMode::TiesToEven};
+ // When set, emulate status flag behavior peculiar to x86
+ // (viz., fail to set the Underflow flag when an inexact product of a
+ // multiplication is rounded up to a normal number from a subnormal
+ // in some rounding modes)
+#if __x86_64__ || __riscv || __loongarch__
+ bool x86CompatibleBehavior{true};
+#else
+ bool x86CompatibleBehavior{false};
+#endif
+};
+
+
+// These are ordered like the bits in a common fenv.h header file.
+ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
+ Inexact)
+using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;
+
+}
+#endif // FORTRAN_COMMON_TARGET_ROUNDING_H_
diff --git a/flang/include/flang/Common/uint128.h b/FortranRuntime/include/flang/Common/uint128.h
similarity index 100%
rename from flang/include/flang/Common/uint128.h
rename to FortranRuntime/include/flang/Common/uint128.h
diff --git a/flang/include/flang/Common/variant.h b/FortranRuntime/include/flang/Common/variant.h
similarity index 100%
rename from flang/include/flang/Common/variant.h
rename to FortranRuntime/include/flang/Common/variant.h
diff --git a/flang/include/flang/Common/visit.h b/FortranRuntime/include/flang/Common/visit.h
similarity index 100%
rename from flang/include/flang/Common/visit.h
rename to FortranRuntime/include/flang/Common/visit.h
diff --git a/flang/include/flang/Common/windows-include.h b/FortranRuntime/include/flang/Common/windows-include.h
similarity index 100%
rename from flang/include/flang/Common/windows-include.h
rename to FortranRuntime/include/flang/Common/windows-include.h
diff --git a/flang/include/flang/Runtime/CUDA/allocator.h b/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
similarity index 100%
rename from flang/include/flang/Runtime/CUDA/allocator.h
rename to FortranRuntime/include/flang/Runtime/CUDA/allocator.h
diff --git a/flang/include/flang/Runtime/CUDA/descriptor.h b/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
similarity index 100%
rename from flang/include/flang/Runtime/CUDA/descriptor.h
rename to FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
diff --git a/flang/include/flang/Runtime/allocatable.h b/FortranRuntime/include/flang/Runtime/allocatable.h
similarity index 100%
rename from flang/include/flang/Runtime/allocatable.h
rename to FortranRuntime/include/flang/Runtime/allocatable.h
diff --git a/flang/include/flang/Runtime/allocator-registry.h b/FortranRuntime/include/flang/Runtime/allocator-registry.h
similarity index 96%
rename from flang/include/flang/Runtime/allocator-registry.h
rename to FortranRuntime/include/flang/Runtime/allocator-registry.h
index acfada506fafc6..411cc68f58ec33 100644
--- a/flang/include/flang/Runtime/allocator-registry.h
+++ b/FortranRuntime/include/flang/Runtime/allocator-registry.h
@@ -1,4 +1,4 @@
-//===-- runtime/allocator-registry.h ----------------------------*- C++ -*-===//
+//===-- include/flang/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.
diff --git a/flang/include/flang/Runtime/array-constructor.h b/FortranRuntime/include/flang/Runtime/array-constructor.h
similarity index 100%
rename from flang/include/flang/Runtime/array-constructor.h
rename to FortranRuntime/include/flang/Runtime/array-constructor.h
diff --git a/flang/include/flang/Runtime/assign.h b/FortranRuntime/include/flang/Runtime/assign.h
similarity index 100%
rename from flang/include/flang/Runtime/assign.h
rename to FortranRuntime/include/flang/Runtime/assign.h
diff --git a/flang/include/flang/Runtime/c-or-cpp.h b/FortranRuntime/include/flang/Runtime/c-or-cpp.h
similarity index 100%
rename from flang/include/flang/Runtime/c-or-cpp.h
rename to FortranRuntime/include/flang/Runtime/c-or-cpp.h
diff --git a/flang/include/flang/Runtime/character.h b/FortranRuntime/include/flang/Runtime/character.h
similarity index 100%
rename from flang/include/flang/Runtime/character.h
rename to FortranRuntime/include/flang/Runtime/character.h
diff --git a/flang/include/flang/Runtime/command.h b/FortranRuntime/include/flang/Runtime/command.h
similarity index 100%
rename from flang/include/flang/Runtime/command.h
rename to FortranRuntime/include/flang/Runtime/command.h
diff --git a/flang/include/flang/Runtime/cpp-type.h b/FortranRuntime/include/flang/Runtime/cpp-type.h
similarity index 98%
rename from flang/include/flang/Runtime/cpp-type.h
rename to FortranRuntime/include/flang/Runtime/cpp-type.h
index fe21dd544cf7d8..27b43de7d0f0f6 100644
--- a/flang/include/flang/Runtime/cpp-type.h
+++ b/FortranRuntime/include/flang/Runtime/cpp-type.h
@@ -11,7 +11,7 @@
#ifndef FORTRAN_RUNTIME_CPP_TYPE_H_
#define FORTRAN_RUNTIME_CPP_TYPE_H_
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
#include "flang/Common/float128.h"
#include "flang/Common/uint128.h"
#include <complex>
diff --git a/flang/include/flang/Runtime/derived-api.h b/FortranRuntime/include/flang/Runtime/derived-api.h
similarity index 100%
rename from flang/include/flang/Runtime/derived-api.h
rename to FortranRuntime/include/flang/Runtime/derived-api.h
diff --git a/flang/include/flang/Runtime/descriptor.h b/FortranRuntime/include/flang/Runtime/descriptor.h
similarity index 99%
rename from flang/include/flang/Runtime/descriptor.h
rename to FortranRuntime/include/flang/Runtime/descriptor.h
index 030d0c1031fbaa..2fe5b11200cf6d 100644
--- a/flang/include/flang/Runtime/descriptor.h
+++ b/FortranRuntime/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/memory.h"
#include "flang/Runtime/type-code.h"
#include <algorithm>
diff --git a/flang/include/flang/Runtime/entry-names.h b/FortranRuntime/include/flang/Runtime/entry-names.h
similarity index 97%
rename from flang/include/flang/Runtime/entry-names.h
rename to FortranRuntime/include/flang/Runtime/entry-names.h
index 68582b92b54941..52de2496d9421d 100644
--- a/flang/include/flang/Runtime/entry-names.h
+++ b/FortranRuntime/include/flang/Runtime/entry-names.h
@@ -1,11 +1,10 @@
-/*===-- include/flang/Runtime/entry-names.h -------------------------*- C -*-=//
+/*===-- include/flang/Runtime/entry-names.h -------------------------*- C -*-===
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
* See https://llvm.org/LICENSE.txt for license information.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*
- *===------------------------------------------------------------------------===
- */
+ *===----------------------------------------------------------------------===*/
/* Defines the macro RTNAME(n) which decorates the external name of a runtime
* library function or object with extra characters so that it
diff --git a/flang/include/flang/Runtime/exceptions.h b/FortranRuntime/include/flang/Runtime/exceptions.h
similarity index 91%
rename from flang/include/flang/Runtime/exceptions.h
rename to FortranRuntime/include/flang/Runtime/exceptions.h
index 1ab22da103a50f..1fb74e14e54d30 100644
--- a/flang/include/flang/Runtime/exceptions.h
+++ b/FortranRuntime/include/flang/Runtime/exceptions.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/exceptions.h ----------------*- C++ -*-===//
+//===-- include/flang/Runtime/exceptions.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/Runtime/execute.h b/FortranRuntime/include/flang/Runtime/execute.h
similarity index 93%
rename from flang/include/flang/Runtime/execute.h
rename to FortranRuntime/include/flang/Runtime/execute.h
index ca137b9d1823c4..ba3e950ca92941 100644
--- a/flang/include/flang/Runtime/execute.h
+++ b/FortranRuntime/include/flang/Runtime/execute.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/command.h -------------------------*- C++ -*-===//
+//===-- include/flang/Runtime/execute.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/Runtime/extensions.h b/FortranRuntime/include/flang/Runtime/extensions.h
similarity index 100%
rename from flang/include/flang/Runtime/extensions.h
rename to FortranRuntime/include/flang/Runtime/extensions.h
diff --git a/flang/include/flang/Runtime/freestanding-tools.h b/FortranRuntime/include/flang/Runtime/freestanding-tools.h
similarity index 100%
rename from flang/include/flang/Runtime/freestanding-tools.h
rename to FortranRuntime/include/flang/Runtime/freestanding-tools.h
diff --git a/flang/include/flang/Runtime/inquiry.h b/FortranRuntime/include/flang/Runtime/inquiry.h
similarity index 94%
rename from flang/include/flang/Runtime/inquiry.h
rename to FortranRuntime/include/flang/Runtime/inquiry.h
index c7a7487f1a1b18..36ef929ed5b2f1 100644
--- a/flang/include/flang/Runtime/inquiry.h
+++ b/FortranRuntime/include/flang/Runtime/inquiry.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/inquiry.h ----------------*- C++ -*-===//
+//===-- include/flang/Runtime/inquiry.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/Runtime/io-api.h b/FortranRuntime/include/flang/Runtime/io-api.h
similarity index 100%
rename from flang/include/flang/Runtime/io-api.h
rename to FortranRuntime/include/flang/Runtime/io-api.h
diff --git a/flang/include/flang/Runtime/iostat.h b/FortranRuntime/include/flang/Runtime/iostat.h
similarity index 100%
rename from flang/include/flang/Runtime/iostat.h
rename to FortranRuntime/include/flang/Runtime/iostat.h
diff --git a/flang/include/flang/Runtime/magic-numbers.h b/FortranRuntime/include/flang/Runtime/magic-numbers.h
similarity index 98%
rename from flang/include/flang/Runtime/magic-numbers.h
rename to FortranRuntime/include/flang/Runtime/magic-numbers.h
index bab0e9ae05299a..931df690766219 100644
--- a/flang/include/flang/Runtime/magic-numbers.h
+++ b/FortranRuntime/include/flang/Runtime/magic-numbers.h
@@ -1,10 +1,10 @@
-#if 0 /*===-- include/flang/Runtime/magic-numbers.h -----------------------===*/
-/*
+#if 0 /*===-- include/flang/Runtime/magic-numbers.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
*
- *===----------------------------------------------------------------------===*/
+/*===----------------------------------------------------------------------===*/
#endif
#if 0
This header can be included into both Fortran and C.
diff --git a/flang/include/flang/Runtime/main.h b/FortranRuntime/include/flang/Runtime/main.h
similarity index 100%
rename from flang/include/flang/Runtime/main.h
rename to FortranRuntime/include/flang/Runtime/main.h
diff --git a/flang/include/flang/Runtime/matmul-instances.inc b/FortranRuntime/include/flang/Runtime/matmul-instances.inc
similarity index 100%
rename from flang/include/flang/Runtime/matmul-instances.inc
rename to FortranRuntime/include/flang/Runtime/matmul-instances.inc
diff --git a/flang/include/flang/Runtime/matmul-transpose.h b/FortranRuntime/include/flang/Runtime/matmul-transpose.h
similarity index 100%
rename from flang/include/flang/Runtime/matmul-transpose.h
rename to FortranRuntime/include/flang/Runtime/matmul-transpose.h
diff --git a/flang/include/flang/Runtime/matmul.h b/FortranRuntime/include/flang/Runtime/matmul.h
similarity index 100%
rename from flang/include/flang/Runtime/matmul.h
rename to FortranRuntime/include/flang/Runtime/matmul.h
diff --git a/flang/include/flang/Runtime/memory.h b/FortranRuntime/include/flang/Runtime/memory.h
similarity index 100%
rename from flang/include/flang/Runtime/memory.h
rename to FortranRuntime/include/flang/Runtime/memory.h
diff --git a/flang/include/flang/Runtime/misc-intrinsic.h b/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
similarity index 100%
rename from flang/include/flang/Runtime/misc-intrinsic.h
rename to FortranRuntime/include/flang/Runtime/misc-intrinsic.h
diff --git a/flang/include/flang/Runtime/numeric.h b/FortranRuntime/include/flang/Runtime/numeric.h
similarity index 100%
rename from flang/include/flang/Runtime/numeric.h
rename to FortranRuntime/include/flang/Runtime/numeric.h
diff --git a/flang/include/flang/Runtime/pointer.h b/FortranRuntime/include/flang/Runtime/pointer.h
similarity index 100%
rename from flang/include/flang/Runtime/pointer.h
rename to FortranRuntime/include/flang/Runtime/pointer.h
diff --git a/flang/include/flang/Runtime/ragged.h b/FortranRuntime/include/flang/Runtime/ragged.h
similarity index 97%
rename from flang/include/flang/Runtime/ragged.h
rename to FortranRuntime/include/flang/Runtime/ragged.h
index f52a619c55b43e..ff157ea16f081e 100644
--- a/flang/include/flang/Runtime/ragged.h
+++ b/FortranRuntime/include/flang/Runtime/ragged.h
@@ -1,4 +1,4 @@
-//===-- Runtime/ragged.h ----------------------------------------*- C++ -*-===//
+//===-- include/flang/Runtime/ragged.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/Runtime/random.h b/FortranRuntime/include/flang/Runtime/random.h
similarity index 100%
rename from flang/include/flang/Runtime/random.h
rename to FortranRuntime/include/flang/Runtime/random.h
diff --git a/flang/include/flang/Runtime/reduce.h b/FortranRuntime/include/flang/Runtime/reduce.h
similarity index 100%
rename from flang/include/flang/Runtime/reduce.h
rename to FortranRuntime/include/flang/Runtime/reduce.h
diff --git a/flang/include/flang/Runtime/reduction.h b/FortranRuntime/include/flang/Runtime/reduction.h
similarity index 100%
rename from flang/include/flang/Runtime/reduction.h
rename to FortranRuntime/include/flang/Runtime/reduction.h
diff --git a/flang/include/flang/Runtime/stop.h b/FortranRuntime/include/flang/Runtime/stop.h
similarity index 100%
rename from flang/include/flang/Runtime/stop.h
rename to FortranRuntime/include/flang/Runtime/stop.h
diff --git a/flang/include/flang/Runtime/support.h b/FortranRuntime/include/flang/Runtime/support.h
similarity index 96%
rename from flang/include/flang/Runtime/support.h
rename to FortranRuntime/include/flang/Runtime/support.h
index ba9c2598bb0ddd..4a6d4357e87103 100644
--- a/flang/include/flang/Runtime/support.h
+++ b/FortranRuntime/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/temporary-stack.h b/FortranRuntime/include/flang/Runtime/temporary-stack.h
similarity index 100%
rename from flang/include/flang/Runtime/temporary-stack.h
rename to FortranRuntime/include/flang/Runtime/temporary-stack.h
diff --git a/flang/include/flang/Runtime/time-intrinsic.h b/FortranRuntime/include/flang/Runtime/time-intrinsic.h
similarity index 100%
rename from flang/include/flang/Runtime/time-intrinsic.h
rename to FortranRuntime/include/flang/Runtime/time-intrinsic.h
diff --git a/flang/include/flang/Runtime/transformational.h b/FortranRuntime/include/flang/Runtime/transformational.h
similarity index 100%
rename from flang/include/flang/Runtime/transformational.h
rename to FortranRuntime/include/flang/Runtime/transformational.h
diff --git a/flang/include/flang/Runtime/type-code.h b/FortranRuntime/include/flang/Runtime/type-code.h
similarity index 96%
rename from flang/include/flang/Runtime/type-code.h
rename to FortranRuntime/include/flang/Runtime/type-code.h
index 8e7314e0af1efc..3c1b03dfaa1140 100644
--- a/flang/include/flang/Runtime/type-code.h
+++ b/FortranRuntime/include/flang/Runtime/type-code.h
@@ -9,9 +9,9 @@
#ifndef FORTRAN_RUNTIME_TYPE_CODE_H_
#define FORTRAN_RUNTIME_TYPE_CODE_H_
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
#include "flang/Common/optional.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include <utility>
namespace Fortran::runtime {
diff --git a/flang/unittests/Evaluate/fp-testing.h b/FortranRuntime/include/flang/Testing/fp-testing.h
similarity index 56%
rename from flang/unittests/Evaluate/fp-testing.h
rename to FortranRuntime/include/flang/Testing/fp-testing.h
index 22dfa2d7d80c60..16c6017e8529d5 100644
--- a/flang/unittests/Evaluate/fp-testing.h
+++ b/FortranRuntime/include/flang/Testing/fp-testing.h
@@ -1,12 +1,20 @@
+//===-- 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_TEST_EVALUATE_FP_TESTING_H_
#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
-#include "flang/Evaluate/target.h"
+#include "flang/Common/target-rounding.h"
#include <fenv.h>
using Fortran::common::RoundingMode;
-using Fortran::evaluate::RealFlags;
-using Fortran::evaluate::Rounding;
+using Fortran::common::RealFlags;
+using Fortran::common::Rounding;
class ScopedHostFloatingPointEnvironment {
public:
diff --git a/flang/unittests/Evaluate/testing.h b/FortranRuntime/include/flang/Testing/testing.h
similarity index 80%
rename from flang/unittests/Evaluate/testing.h
rename to FortranRuntime/include/flang/Testing/testing.h
index 422e2853c05bc6..d763109d62d373 100644
--- a/flang/unittests/Evaluate/testing.h
+++ b/FortranRuntime/include/flang/Testing/testing.h
@@ -1,3 +1,11 @@
+//===-- 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_EVALUATE_TESTING_H_
#define FORTRAN_EVALUATE_TESTING_H_
diff --git a/FortranRuntime/lib/CMakeLists.txt b/FortranRuntime/lib/CMakeLists.txt
new file mode 100644
index 00000000000000..8c4382078a8e70
--- /dev/null
+++ b/FortranRuntime/lib/CMakeLists.txt
@@ -0,0 +1,12 @@
+#===-- 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(Runtime)
+if (FORTRANRUNTIME_INCLUDE_TESTS)
+ add_subdirectory(Testing)
+endif ()
diff --git a/flang/lib/Decimal/big-radix-floating-point.h b/FortranRuntime/lib/Common/big-radix-floating-point.h
similarity index 98%
rename from flang/lib/Decimal/big-radix-floating-point.h
rename to FortranRuntime/lib/Common/big-radix-floating-point.h
index f9afebf5b3d703..7b8fb03710a3d4 100644
--- a/flang/lib/Decimal/big-radix-floating-point.h
+++ b/FortranRuntime/lib/Common/big-radix-floating-point.h
@@ -1,4 +1,4 @@
-//===-- lib/Decimal/big-radix-floating-point.h ------------------*- C++ -*-===//
+//===-- lib/Common/big-radix-floating-point.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.
@@ -24,8 +24,8 @@
#include "flang/Common/bit-population-count.h"
#include "flang/Common/leading-zero-bit-count.h"
#include "flang/Common/uint128.h"
-#include "flang/Decimal/binary-floating-point.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/binary-floating-point.h"
+#include "flang/Common/decimal.h"
#include <cinttypes>
#include <limits>
#include <type_traits>
diff --git a/flang/lib/Decimal/binary-to-decimal.cpp b/FortranRuntime/lib/Common/binary-to-decimal.cpp
similarity index 99%
rename from flang/lib/Decimal/binary-to-decimal.cpp
rename to FortranRuntime/lib/Common/binary-to-decimal.cpp
index b64865e95df24d..fb2caefdae8fa1 100644
--- a/flang/lib/Decimal/binary-to-decimal.cpp
+++ b/FortranRuntime/lib/Common/binary-to-decimal.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Decimal/binary-to-decimal.cpp ---------------------------------===//
+//===-- lib/Common/binary-to-decimal.cpp ------------------------*- 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 "big-radix-floating-point.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
#include <cassert>
#include <cfloat>
#include <string>
diff --git a/flang/lib/Decimal/decimal-to-binary.cpp b/FortranRuntime/lib/Common/decimal-to-binary.cpp
similarity index 99%
rename from flang/lib/Decimal/decimal-to-binary.cpp
rename to FortranRuntime/lib/Common/decimal-to-binary.cpp
index 94c51774237399..0ef24d3bcfecfc 100644
--- a/flang/lib/Decimal/decimal-to-binary.cpp
+++ b/FortranRuntime/lib/Common/decimal-to-binary.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Decimal/decimal-to-binary.cpp ---------------------------------===//
+//===-- lib/Common/decimal-to-binary.cpp ------------------------*- 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 @@
#include "big-radix-floating-point.h"
#include "flang/Common/bit-population-count.h"
#include "flang/Common/leading-zero-bit-count.h"
-#include "flang/Decimal/binary-floating-point.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/binary-floating-point.h"
+#include "flang/Common/decimal.h"
#include "flang/Runtime/freestanding-tools.h"
#include <cinttypes>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
new file mode 100644
index 00000000000000..3402dd5fe6af8f
--- /dev/null
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -0,0 +1,242 @@
+#===-- 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.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===------------------------------------------------------------------------===#
+
+add_subdirectory(Float128Math)
+
+set(sources
+ ISO_Fortran_binding.cpp
+ allocator-registry.cpp
+ allocatable.cpp
+ array-constructor.cpp
+ assign.cpp
+ buffer.cpp
+ character.cpp
+ command.cpp
+ complex-powi.cpp
+ complex-reduction.c
+ 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
+ exceptions.cpp
+ execute.cpp
+ extensions.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
+ iso_fortran_env_impl.f90
+ iostat.cpp
+ main.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
+ random.cpp
+ reduce.cpp
+ reduction.cpp
+ stat.cpp
+ stop.cpp
+ sum.cpp
+ support.cpp
+ temporary-stack.cpp
+ terminator.cpp
+ time-intrinsic.cpp
+ tools.cpp
+ transformational.cpp
+ type-code.cpp
+ type-info.cpp
+ unit-map.cpp
+ unit.cpp
+ utf.cpp
+ ../Common/binary-to-decimal.cpp
+ ../Common/decimal-to-binary.cpp
+)
+
+# List of files that are buildable for all devices.
+set(supported_files
+ ISO_Fortran_binding.cpp
+ allocatable.cpp
+ allocator-registry.cpp
+ array-constructor.cpp
+ assign.cpp
+ buffer.cpp
+ character.cpp
+ connection.cpp
+ copy.cpp
+ derived-api.cpp
+ derived.cpp
+ descriptor.cpp
+ descriptor-io.cpp
+ dot-product.cpp
+ edit-input.cpp
+ edit-output.cpp
+ environment.cpp
+ extrema.cpp
+ external-unit.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
+ utf.cpp
+ )
+
+
+ set(public_headers "")
+ file(GLOB_RECURSE public_headers
+ "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Runtime/*.h"
+ "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Common/*.h"
+ )
+
+
+ set(private_headers "")
+ file(GLOB_RECURSE private_headers
+ "${FLANGRUNTIME_SOURCE_DIR}/lib/Runtime/*.h"
+ "${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
+ )
+
+
+
+
+
+
+
+
+
+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}
+ )
+ list(APPEND sources ${f128_sources})
+endif()
+
+
+
+
+
+
+
+
+
+
+
+
+if (NOT DEFINED WIN32)
+ add_fortranruntime_library(FortranRuntime STATIC
+ ${sources}
+ INSTALL_WITH_TOOLCHAIN
+ ADDITIONAL_HEADERS ${public_headers} ${private_headers}
+ )
+
+ # For unittests that link to FortranRuntime. Should link to the static version of the library.
+ add_library(FortranRuntime.static ALIAS FortranRuntime)
+else()
+ # ${sources} also contains Fortran files. CMake write the generated Fortran files into the same directory (lib/Runtime/iso_fortran_env_impl.mod), so we need to compile it only once and add the object files to different runtime version.
+ add_fortranruntime_library(FortranRuntime.obj OBJECT
+ ${sources}
+
+ ADDITIONAL_HEADERS ${public_headers} ${private_headers}
+ )
+
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
+ add_fortranruntime_library(FortranRuntime.static STATIC $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
+ )
+
+
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
+ add_fortranruntime_library(FortranRuntime.dynamic SHARED $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
+ )
+
+
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
+ add_fortranruntime_library(FortranRuntime.static_dbg STATIC $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
+ )
+
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
+ add_fortranruntime_library(FortranRuntime.dynamic_dbg SHARED $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
+ )
+ target_link_libraries(FortranRuntime.dynamic_dbg PRIVATE FortranRuntime.obj)
+
+ # Target for building all versions of the runtime
+ add_custom_target(FortranRuntime)
+ set_target_properties(FortranRuntime PROPERTIES FOLDER "Fortran Runtime/Meta")
+ add_dependencies(FortranRuntime FortranRuntime.static FortranRuntime.dynamic
+ FortranRuntime.static_dbg FortranRuntime.dynamic_dbg)
+
+ if (MSVC)
+ # The Fortran files compiled with flang-new assumes libcall functions such as `__udivti3`
+ # Add LLVM_ENABLE_RUNTIMES=compiler-rt for it to be available during the runtimes build
+ # FIXME: Can embed linker command --dependent-lib into object files as already done with FortranRuntime.<mode>.lib
+ if (NOT TARGET clang_rt.builtins-x86_64)
+ message(WARNING
+ "compiler-rt needed when compiling with msvc\n"
+ "Flang/LLVM will emit code that calls into libgcc/compiler-rt, but using the MSVC linker will only link Microsoft's CRT automatically\n"
+ "Add compiler-rt to LLVM_ENABLE_RUNTIMES to fix"
+ )
+ endif ()
+ target_link_libraries(FortranRuntime.static PUBLIC clang_rt.builtins-x86_64)
+ target_link_libraries(FortranRuntime.dynamic PUBLIC clang_rt.builtins-x86_64)
+ target_link_libraries(FortranRuntime.static_dbg PUBLIC clang_rt.builtins-x86_64)
+ target_link_libraries(FortranRuntime.dynamic_dbg PUBLIC clang_rt.builtins-x86_64)
+ endif ()
+endif()
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
similarity index 93%
rename from flang/runtime/CUDA/CMakeLists.txt
rename to FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
index 81055b2737c0f1..f75b854d1eb3ba 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- runtime/CUDA/CMakeLists.txt -----------------------------------------===#
+#===-- lib/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.
diff --git a/flang/runtime/CUDA/allocator.cpp b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
similarity index 94%
rename from flang/runtime/CUDA/allocator.cpp
rename to FortranRuntime/lib/Runtime/CUDA/allocator.cpp
index d4a473d58e86cd..379f52b45057a0 100644
--- a/flang/runtime/CUDA/allocator.cpp
+++ b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/allocator.cpp ----------------------------------------===//
+//===-- lib/Runtime/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.
@@ -11,7 +11,7 @@
#include "../stat.h"
#include "../terminator.h"
#include "../type-info.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/allocator-registry.h"
diff --git a/flang/runtime/CUDA/descriptor.cpp b/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
similarity index 91%
rename from flang/runtime/CUDA/descriptor.cpp
rename to FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
index 1031b1e601b646..9664fea4ebc78a 100644
--- a/flang/runtime/CUDA/descriptor.cpp
+++ b/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/CUDA/descriptor.cpp ---------------------------------------===//
+//===-- lib/Runtime/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.
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
similarity index 98%
rename from flang/runtime/Float128Math/CMakeLists.txt
rename to FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
index a5f5bec1e7e4b8..1ff158c401855f 100644
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- runtime/Float128Math/CMakeLists.txt ---------------------------------===#
+#===-- lib/Runtime/Float128Math/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.
diff --git a/flang/runtime/Float128Math/acos.cpp b/FortranRuntime/lib/Runtime/Float128Math/acos.cpp
similarity index 87%
rename from flang/runtime/Float128Math/acos.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/acos.cpp
index 14ff6944856844..7b15e4a0bfd3ae 100644
--- a/flang/runtime/Float128Math/acos.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/acos.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/acos.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/acosh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/acosh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/acosh.cpp
index 9d70804e44a470..c873259b4545b8 100644
--- a/flang/runtime/Float128Math/acosh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/acosh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/acosh.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/asin.cpp
similarity index 87%
rename from flang/runtime/Float128Math/asin.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/asin.cpp
index 6781b23f0363db..8866d51430197a 100644
--- a/flang/runtime/Float128Math/asin.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/asin.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/asin.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/asinh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/asinh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/asinh.cpp
index 1310bc61c1de0f..288193001ce1da 100644
--- a/flang/runtime/Float128Math/asinh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/asinh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/asinh.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/atan.cpp
similarity index 87%
rename from flang/runtime/Float128Math/atan.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/atan.cpp
index f01382df90c0ee..390c080b4d501b 100644
--- a/flang/runtime/Float128Math/atan.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/atan.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/atan.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/atan2.cpp
similarity index 88%
rename from flang/runtime/Float128Math/atan2.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/atan2.cpp
index dd646b0452b115..3c206b75704431 100644
--- a/flang/runtime/Float128Math/atan2.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/atan2.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/atan2.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/atanh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/atanh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/atanh.cpp
index 5fc5ba5debc81a..77ceb188f04e42 100644
--- a/flang/runtime/Float128Math/atanh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/atanh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/atanh.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/ceil.cpp
similarity index 87%
rename from flang/runtime/Float128Math/ceil.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/ceil.cpp
index ed4d164a62bedc..46bc253bd0922d 100644
--- a/flang/runtime/Float128Math/ceil.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/ceil.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/ceil.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/complex-math.c
similarity index 92%
rename from flang/runtime/Float128Math/complex-math.c
rename to FortranRuntime/lib/Runtime/Float128Math/complex-math.c
index d0180c63a0d7bf..f34ef7da76e599 100644
--- a/flang/runtime/Float128Math/complex-math.c
+++ b/FortranRuntime/lib/Runtime/Float128Math/complex-math.c
@@ -1,11 +1,10 @@
-/*===-- runtime/Float128Math/complex-math.c -------------------------*- C -*-===
+/*===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/complex-math.h
similarity index 96%
rename from flang/runtime/Float128Math/complex-math.h
rename to FortranRuntime/lib/Runtime/Float128Math/complex-math.h
index 81dd53a175d1aa..6f5c7954bab035 100644
--- a/flang/runtime/Float128Math/complex-math.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/complex-math.h
@@ -1,4 +1,4 @@
-/*===-- runtime/Float128Math/complex-math.h -------------------------*- C -*-===
+/*===-- lib/Runtime/Float128Math/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.
diff --git a/flang/runtime/Float128Math/cos.cpp b/FortranRuntime/lib/Runtime/Float128Math/cos.cpp
similarity index 87%
rename from flang/runtime/Float128Math/cos.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/cos.cpp
index b93c92f275f791..8ce47151e2914b 100644
--- a/flang/runtime/Float128Math/cos.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/cos.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/cos.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/cosh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/cosh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/cosh.cpp
index a3662a826dcb1c..f1ec45bcfb479d 100644
--- a/flang/runtime/Float128Math/cosh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/cosh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/cosh.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/erf.cpp
similarity index 87%
rename from flang/runtime/Float128Math/erf.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/erf.cpp
index 631f71c76effe7..010088467794d1 100644
--- a/flang/runtime/Float128Math/erf.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/erf.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/erf.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/erfc.cpp
similarity index 87%
rename from flang/runtime/Float128Math/erfc.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/erfc.cpp
index ea3cd646d8c4ba..b226f8d2dc378b 100644
--- a/flang/runtime/Float128Math/erfc.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/erfc.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/erfc.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/exp.cpp
similarity index 87%
rename from flang/runtime/Float128Math/exp.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/exp.cpp
index b1161b0f29294c..e22f9df3579e96 100644
--- a/flang/runtime/Float128Math/exp.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/exp.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/exp.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/exponent.cpp
similarity index 90%
rename from flang/runtime/Float128Math/exponent.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/exponent.cpp
index 1be1dd0d0ac8b8..f07bf30bd1096f 100644
--- a/flang/runtime/Float128Math/exponent.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/exponent.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/exponent.cpp ---------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/floor.cpp
similarity index 87%
rename from flang/runtime/Float128Math/floor.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/floor.cpp
index 78a94984cac8a3..8744e6e2fec63c 100644
--- a/flang/runtime/Float128Math/floor.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/floor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/floor.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/fma.cpp
similarity index 89%
rename from flang/runtime/Float128Math/fma.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/fma.cpp
index ec67e8e6fba22b..198fec5d4bc356 100644
--- a/flang/runtime/Float128Math/fma.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/fma.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/fma.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/fraction.cpp
similarity index 87%
rename from flang/runtime/Float128Math/fraction.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/fraction.cpp
index 8c9889b7f6871e..d4749bf3eb7e0e 100644
--- a/flang/runtime/Float128Math/fraction.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/fraction.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/fraction.cpp ---------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/hypot.cpp
similarity index 88%
rename from flang/runtime/Float128Math/hypot.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/hypot.cpp
index b4fa1d66bcfa6a..6542bf505060df 100644
--- a/flang/runtime/Float128Math/hypot.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/hypot.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/hypot.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/j0.cpp
similarity index 87%
rename from flang/runtime/Float128Math/j0.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/j0.cpp
index 9390a7eeb3c605..27e4338cdfc2b0 100644
--- a/flang/runtime/Float128Math/j0.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/j0.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/j0.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/j1.cpp
similarity index 87%
rename from flang/runtime/Float128Math/j1.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/j1.cpp
index c54927123388c6..d3f897827f9f67 100644
--- a/flang/runtime/Float128Math/j1.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/j1.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/j1.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/jn.cpp
similarity index 87%
rename from flang/runtime/Float128Math/jn.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/jn.cpp
index 15afd83400c320..681bb5b1ff3ad5 100644
--- a/flang/runtime/Float128Math/jn.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/jn.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/jn.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/lgamma.cpp
similarity index 87%
rename from flang/runtime/Float128Math/lgamma.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/lgamma.cpp
index ac31c89a912b32..0426db2e3b98d3 100644
--- a/flang/runtime/Float128Math/lgamma.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/lgamma.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/lgamma.cpp -----------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/llround.cpp
similarity index 88%
rename from flang/runtime/Float128Math/llround.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/llround.cpp
index b77281c507fe7c..4c9026cce00283 100644
--- a/flang/runtime/Float128Math/llround.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/llround.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/llround.cpp ----------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/log.cpp
similarity index 87%
rename from flang/runtime/Float128Math/log.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/log.cpp
index 38e6b581fd849c..a5a431ae5ffbbb 100644
--- a/flang/runtime/Float128Math/log.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/log.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/log.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/log10.cpp
similarity index 87%
rename from flang/runtime/Float128Math/log10.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/log10.cpp
index 3c89c0e707774f..9a83f57b6c736d 100644
--- a/flang/runtime/Float128Math/log10.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/log10.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/log10.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/lround.cpp
similarity index 87%
rename from flang/runtime/Float128Math/lround.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/lround.cpp
index ce7a228038a1d3..65546881157948 100644
--- a/flang/runtime/Float128Math/lround.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/lround.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/lround.cpp -----------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
similarity index 99%
rename from flang/runtime/Float128Math/math-entries.h
rename to FortranRuntime/lib/Runtime/Float128Math/math-entries.h
index 13fdab26470038..798efdfb1e120c 100644
--- a/flang/runtime/Float128Math/math-entries.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/math-entries.h ---------------------*- C++ -*-===//
+//===-- lib/Runtime/Float128Math/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.
diff --git a/flang/runtime/Float128Math/mod-real.cpp b/FortranRuntime/lib/Runtime/Float128Math/mod-real.cpp
similarity index 89%
rename from flang/runtime/Float128Math/mod-real.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/mod-real.cpp
index 42e6ce76e2fa1b..e3b96d39e76ae6 100644
--- a/flang/runtime/Float128Math/mod-real.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/mod-real.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/mod-real.cpp ---------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/modulo-real.cpp
similarity index 89%
rename from flang/runtime/Float128Math/modulo-real.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/modulo-real.cpp
index 13000aba8c8323..8edf59e9f59dd4 100644
--- a/flang/runtime/Float128Math/modulo-real.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/modulo-real.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/modulo-real.cpp ------------------------------===//
+//===-- lib/Runtime/Float128Math/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/nearest.cpp b/FortranRuntime/lib/Runtime/Float128Math/nearest.cpp
similarity index 89%
rename from flang/runtime/Float128Math/nearest.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/nearest.cpp
index 148ac4ef839160..8b9f142d79ff93 100644
--- a/flang/runtime/Float128Math/nearest.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/nearest.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/nearest.cpp ----------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/norm2.cpp
similarity index 93%
rename from flang/runtime/Float128Math/norm2.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/norm2.cpp
index 15c482f7f007ce..a0c26e40de0064 100644
--- a/flang/runtime/Float128Math/norm2.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/norm2.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/norm2.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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.
diff --git a/flang/runtime/Float128Math/numeric-template-specs.h b/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
similarity index 96%
rename from flang/runtime/Float128Math/numeric-template-specs.h
rename to FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
index a0a77230c3e9eb..ca9696e18f6a92 100644
--- a/flang/runtime/Float128Math/numeric-template-specs.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/numeric-template-specs.h -----------*- C++ -*-===//
+//===-- lib/Runtime/Float128Math/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.
diff --git a/flang/runtime/Float128Math/pow.cpp b/FortranRuntime/lib/Runtime/Float128Math/pow.cpp
similarity index 88%
rename from flang/runtime/Float128Math/pow.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/pow.cpp
index 7a48828ee3e765..c11978ca068f23 100644
--- a/flang/runtime/Float128Math/pow.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/pow.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/pow.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/random.cpp
similarity index 89%
rename from flang/runtime/Float128Math/random.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/random.cpp
index cda962b416144e..a9dc3c7a82b673 100644
--- a/flang/runtime/Float128Math/random.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/random.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/random.cpp -----------------------------------===//
+//===-- lib/Runtime/Float128Math/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.
diff --git a/flang/runtime/Float128Math/round.cpp b/FortranRuntime/lib/Runtime/Float128Math/round.cpp
similarity index 89%
rename from flang/runtime/Float128Math/round.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/round.cpp
index 6420c1bc9cd25d..5a9366b3af4785 100644
--- a/flang/runtime/Float128Math/round.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/round.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/round.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/rrspacing.cpp
similarity index 87%
rename from flang/runtime/Float128Math/rrspacing.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/rrspacing.cpp
index feddac418eec39..2c501b3512c215 100644
--- a/flang/runtime/Float128Math/rrspacing.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/rrspacing.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/rrspacing.cpp --------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/scale.cpp
similarity index 90%
rename from flang/runtime/Float128Math/scale.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/scale.cpp
index 0be958bd9f2a72..859c955b8114e0 100644
--- a/flang/runtime/Float128Math/scale.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/scale.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/scale.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/set-exponent.cpp
similarity index 88%
rename from flang/runtime/Float128Math/set-exponent.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/set-exponent.cpp
index 99c34af7962b9a..52258182871a14 100644
--- a/flang/runtime/Float128Math/set-exponent.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/set-exponent.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/set-exponent.cpp -----------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/sin.cpp
similarity index 87%
rename from flang/runtime/Float128Math/sin.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/sin.cpp
index 8ebc3f9881586e..99aa4095c8cf1a 100644
--- a/flang/runtime/Float128Math/sin.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/sin.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/sin.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/sinh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/sinh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/sinh.cpp
index aa716a3e51ef5a..a7dfe36737de43 100644
--- a/flang/runtime/Float128Math/sinh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/sinh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/sinh.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/spacing.cpp
similarity index 87%
rename from flang/runtime/Float128Math/spacing.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/spacing.cpp
index a86c0b30e567ab..66a01851965840 100644
--- a/flang/runtime/Float128Math/spacing.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/spacing.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/spacing.cpp ----------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/sqrt.cpp
similarity index 87%
rename from flang/runtime/Float128Math/sqrt.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/sqrt.cpp
index 83165a4c623191..cbc1e503d50fd9 100644
--- a/flang/runtime/Float128Math/sqrt.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/sqrt.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/sqrt.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/tan.cpp
similarity index 87%
rename from flang/runtime/Float128Math/tan.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/tan.cpp
index 8f4b723ca977bd..dbe4627f585f14 100644
--- a/flang/runtime/Float128Math/tan.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/tan.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/tan.cpp --------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/tanh.cpp
similarity index 87%
rename from flang/runtime/Float128Math/tanh.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/tanh.cpp
index b43a89520b6797..37e40966ced722 100644
--- a/flang/runtime/Float128Math/tanh.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/tanh.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/tanh.cpp -------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/tgamma.cpp
similarity index 87%
rename from flang/runtime/Float128Math/tgamma.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/tgamma.cpp
index 93f97800bdc966..07a019c6d9971f 100644
--- a/flang/runtime/Float128Math/tgamma.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/tgamma.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/tgamma.cpp -----------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/trunc.cpp
similarity index 89%
rename from flang/runtime/Float128Math/trunc.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/trunc.cpp
index ca15a739c030e8..9f38bdc18e73c4 100644
--- a/flang/runtime/Float128Math/trunc.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/trunc.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/trunc.cpp ------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/y0.cpp
similarity index 87%
rename from flang/runtime/Float128Math/y0.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/y0.cpp
index d6f39aac1053a8..6eaa3396e7ea07 100644
--- a/flang/runtime/Float128Math/y0.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/y0.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/y0.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/y1.cpp
similarity index 87%
rename from flang/runtime/Float128Math/y1.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/y1.cpp
index 477d36a9ea3c66..c9f48ea0e26546 100644
--- a/flang/runtime/Float128Math/y1.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/y1.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/y1.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/FortranRuntime/lib/Runtime/Float128Math/yn.cpp
similarity index 87%
rename from flang/runtime/Float128Math/yn.cpp
rename to FortranRuntime/lib/Runtime/Float128Math/yn.cpp
index 3a040cc8858970..6bc5f4996a88d5 100644
--- a/flang/runtime/Float128Math/yn.cpp
+++ b/FortranRuntime/lib/Runtime/Float128Math/yn.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/Float128Math/yn.cpp ---------------------------------------===//
+//===-- lib/Runtime/Float128Math/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/ISO_Fortran_binding.cpp b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
similarity index 98%
rename from flang/runtime/ISO_Fortran_binding.cpp
rename to FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
index fe22026f31f55f..d2fab4bbc30b4d 100644
--- a/flang/runtime/ISO_Fortran_binding.cpp
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/ISO_Fortran_binding.cpp -----------------------------------===//
+//===-- 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.
@@ -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/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
similarity index 96%
rename from flang/runtime/ISO_Fortran_util.h
rename to FortranRuntime/lib/Runtime/ISO_Fortran_util.h
index dd0eeef80bb896..c45e8fc7a8d253 100644
--- a/flang/runtime/ISO_Fortran_util.h
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
@@ -1,4 +1,4 @@
-//===-- runtime/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.
@@ -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/FortranRuntime/lib/Runtime/allocatable.cpp
similarity index 98%
rename from flang/runtime/allocatable.cpp
rename to FortranRuntime/lib/Runtime/allocatable.cpp
index 5e065f47636a89..e3b43a5f813935 100644
--- a/flang/runtime/allocatable.cpp
+++ b/FortranRuntime/lib/Runtime/allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/allocatable.cpp -------------------------------------------===//
+//===-- 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.
@@ -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/allocator-registry.cpp b/FortranRuntime/lib/Runtime/allocator-registry.cpp
similarity index 94%
rename from flang/runtime/allocator-registry.cpp
rename to FortranRuntime/lib/Runtime/allocator-registry.cpp
index f5670331d6dbe2..68fb8b80680558 100644
--- a/flang/runtime/allocator-registry.cpp
+++ b/FortranRuntime/lib/Runtime/allocator-registry.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/allocator-registry.cpp ------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/array-constructor.cpp b/FortranRuntime/lib/Runtime/array-constructor.cpp
similarity index 99%
rename from flang/runtime/array-constructor.cpp
rename to FortranRuntime/lib/Runtime/array-constructor.cpp
index 72e08feff7fd10..287d054887abf0 100644
--- a/flang/runtime/array-constructor.cpp
+++ b/FortranRuntime/lib/Runtime/array-constructor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/array-constructor.cpp -------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/assign-impl.h b/FortranRuntime/lib/Runtime/assign-impl.h
similarity index 93%
rename from flang/runtime/assign-impl.h
rename to FortranRuntime/lib/Runtime/assign-impl.h
index f07a501d1d1263..6bc8ef78c38a90 100644
--- a/flang/runtime/assign-impl.h
+++ b/FortranRuntime/lib/Runtime/assign-impl.h
@@ -1,4 +1,4 @@
-//===-- runtime/assign-impl.h -----------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/assign.cpp b/FortranRuntime/lib/Runtime/assign.cpp
similarity index 99%
rename from flang/runtime/assign.cpp
rename to FortranRuntime/lib/Runtime/assign.cpp
index d558ada51cd21a..7c5eb135d4cfdf 100644
--- a/flang/runtime/assign.cpp
+++ b/FortranRuntime/lib/Runtime/assign.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/assign.cpp ------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/buffer.cpp b/FortranRuntime/lib/Runtime/buffer.cpp
similarity index 92%
rename from flang/runtime/buffer.cpp
rename to FortranRuntime/lib/Runtime/buffer.cpp
index 7b4869d69c2e51..ce78fe34503c46 100644
--- a/flang/runtime/buffer.cpp
+++ b/FortranRuntime/lib/Runtime/buffer.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/buffer.cpp ------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/buffer.h b/FortranRuntime/lib/Runtime/buffer.h
similarity index 99%
rename from flang/runtime/buffer.h
rename to FortranRuntime/lib/Runtime/buffer.h
index 41a1abb1b2d907..24e43734552e99 100644
--- a/flang/runtime/buffer.h
+++ b/FortranRuntime/lib/Runtime/buffer.h
@@ -1,4 +1,4 @@
-//===-- runtime/buffer.h ----------------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/character.cpp b/FortranRuntime/lib/Runtime/character.cpp
similarity index 99%
rename from flang/runtime/character.cpp
rename to FortranRuntime/lib/Runtime/character.cpp
index 5049247397eb3c..73d3d93c5015f6 100644
--- a/flang/runtime/character.cpp
+++ b/FortranRuntime/lib/Runtime/character.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/character.cpp ---------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/command.cpp b/FortranRuntime/lib/Runtime/command.cpp
similarity index 98%
rename from flang/runtime/command.cpp
rename to FortranRuntime/lib/Runtime/command.cpp
index a555e26f96a66c..50a084714e69a4 100644
--- a/flang/runtime/command.cpp
+++ b/FortranRuntime/lib/Runtime/command.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/command.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/complex-powi.cpp b/FortranRuntime/lib/Runtime/complex-powi.cpp
similarity index 91%
rename from flang/runtime/complex-powi.cpp
rename to FortranRuntime/lib/Runtime/complex-powi.cpp
index 77031e40242791..2eacf56386b193 100644
--- a/flang/runtime/complex-powi.cpp
+++ b/FortranRuntime/lib/Runtime/complex-powi.cpp
@@ -1,11 +1,10 @@
-/*===-- 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/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
+//
+//===----------------------------------------------------------------------===//
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
#include <cstdint>
diff --git a/flang/runtime/complex-reduction.c b/FortranRuntime/lib/Runtime/complex-reduction.c
similarity index 97%
rename from flang/runtime/complex-reduction.c
rename to FortranRuntime/lib/Runtime/complex-reduction.c
index 37ce3fa410016b..138174e9122b1c 100644
--- a/flang/runtime/complex-reduction.c
+++ b/FortranRuntime/lib/Runtime/complex-reduction.c
@@ -1,11 +1,10 @@
-/*===-- flang/runtime/complex-reduction.c ---------------------------*- C -*-===
+/*===-- lib/Runtime/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/FortranRuntime/lib/Runtime/complex-reduction.h
similarity index 97%
rename from flang/runtime/complex-reduction.h
rename to FortranRuntime/lib/Runtime/complex-reduction.h
index b0f19622fdb1a5..1ca5b9a33c4640 100644
--- a/flang/runtime/complex-reduction.h
+++ b/FortranRuntime/lib/Runtime/complex-reduction.h
@@ -1,11 +1,10 @@
-/*===-- flang/runtime/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.
* 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
diff --git a/flang/runtime/connection.cpp b/FortranRuntime/lib/Runtime/connection.cpp
similarity index 96%
rename from flang/runtime/connection.cpp
rename to FortranRuntime/lib/Runtime/connection.cpp
index f24f0e832eb484..f9e91f1f193ba0 100644
--- a/flang/runtime/connection.cpp
+++ b/FortranRuntime/lib/Runtime/connection.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/connection.cpp --------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/connection.h b/FortranRuntime/lib/Runtime/connection.h
similarity index 98%
rename from flang/runtime/connection.h
rename to FortranRuntime/lib/Runtime/connection.h
index 6f1ea90a160e5e..f74e94ff6fb4a3 100644
--- a/flang/runtime/connection.h
+++ b/FortranRuntime/lib/Runtime/connection.h
@@ -1,4 +1,4 @@
-//===-- runtime/connection.h ------------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/copy.cpp b/FortranRuntime/lib/Runtime/copy.cpp
similarity index 99%
rename from flang/runtime/copy.cpp
rename to FortranRuntime/lib/Runtime/copy.cpp
index b20f68f019498b..72a86e3b80a7d5 100644
--- a/flang/runtime/copy.cpp
+++ b/FortranRuntime/lib/Runtime/copy.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/copy.cpp -------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/copy.h b/FortranRuntime/lib/Runtime/copy.h
similarity index 93%
rename from flang/runtime/copy.h
rename to FortranRuntime/lib/Runtime/copy.h
index 542660530bfb65..6d37b075e74504 100644
--- a/flang/runtime/copy.h
+++ b/FortranRuntime/lib/Runtime/copy.h
@@ -1,4 +1,4 @@
-//===-- runtime/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.
diff --git a/flang/runtime/derived-api.cpp b/FortranRuntime/lib/Runtime/derived-api.cpp
similarity index 98%
rename from flang/runtime/derived-api.cpp
rename to FortranRuntime/lib/Runtime/derived-api.cpp
index eca784be208d10..0bcdd45ddbbaec 100644
--- a/flang/runtime/derived-api.cpp
+++ b/FortranRuntime/lib/Runtime/derived-api.cpp
@@ -1,5 +1,4 @@
-//===-- runtime/derived-api.cpp
-//-----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/derived.cpp b/FortranRuntime/lib/Runtime/derived.cpp
similarity index 99%
rename from flang/runtime/derived.cpp
rename to FortranRuntime/lib/Runtime/derived.cpp
index 659f54fa344bb0..04d765211db63b 100644
--- a/flang/runtime/derived.cpp
+++ b/FortranRuntime/lib/Runtime/derived.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/derived.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/derived.h b/FortranRuntime/lib/Runtime/derived.h
similarity index 94%
rename from flang/runtime/derived.h
rename to FortranRuntime/lib/Runtime/derived.h
index b4863df8db417c..27c04c7cc56969 100644
--- a/flang/runtime/derived.h
+++ b/FortranRuntime/lib/Runtime/derived.h
@@ -1,4 +1,4 @@
-//===-- runtime/derived.h -------------------------------------------------===//
+//===-- lib/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.
diff --git a/flang/runtime/descriptor-io.cpp b/FortranRuntime/lib/Runtime/descriptor-io.cpp
similarity index 98%
rename from flang/runtime/descriptor-io.cpp
rename to FortranRuntime/lib/Runtime/descriptor-io.cpp
index 380ad425d925f0..896fad16a67e8a 100644
--- a/flang/runtime/descriptor-io.cpp
+++ b/FortranRuntime/lib/Runtime/descriptor-io.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/descriptor-io.cpp -----------------------------------------===//
+//===-- 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/runtime/descriptor-io.h b/FortranRuntime/lib/Runtime/descriptor-io.h
similarity index 99%
rename from flang/runtime/descriptor-io.h
rename to FortranRuntime/lib/Runtime/descriptor-io.h
index ff5f683c6da52f..58cb091f852596 100644
--- a/flang/runtime/descriptor-io.h
+++ b/FortranRuntime/lib/Runtime/descriptor-io.h
@@ -1,4 +1,4 @@
-//===-- runtime/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.
diff --git a/flang/runtime/descriptor.cpp b/FortranRuntime/lib/Runtime/descriptor.cpp
similarity index 99%
rename from flang/runtime/descriptor.cpp
rename to FortranRuntime/lib/Runtime/descriptor.cpp
index 32f43e89dc7a36..f064fe3dcc32e9 100644
--- a/flang/runtime/descriptor.cpp
+++ b/FortranRuntime/lib/Runtime/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/descriptor.cpp --------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/dot-product.cpp b/FortranRuntime/lib/Runtime/dot-product.cpp
similarity index 99%
rename from flang/runtime/dot-product.cpp
rename to FortranRuntime/lib/Runtime/dot-product.cpp
index 977698269bcb46..9eb22790e38a69 100644
--- a/flang/runtime/dot-product.cpp
+++ b/FortranRuntime/lib/Runtime/dot-product.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/dot-product.cpp -------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/edit-input.cpp b/FortranRuntime/lib/Runtime/edit-input.cpp
similarity index 99%
rename from flang/runtime/edit-input.cpp
rename to FortranRuntime/lib/Runtime/edit-input.cpp
index 2cee35e23f31a3..6ebb0e7aca4ade 100644
--- a/flang/runtime/edit-input.cpp
+++ b/FortranRuntime/lib/Runtime/edit-input.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/edit-input.cpp --------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/edit-input.h b/FortranRuntime/lib/Runtime/edit-input.h
similarity index 95%
rename from flang/runtime/edit-input.h
rename to FortranRuntime/lib/Runtime/edit-input.h
index a90180b8ee2ebd..96dc3f561c22a7 100644
--- a/flang/runtime/edit-input.h
+++ b/FortranRuntime/lib/Runtime/edit-input.h
@@ -1,4 +1,4 @@
-//===-- runtime/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.
@@ -11,7 +11,7 @@
#include "format.h"
#include "io-stmt.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
namespace Fortran::runtime::io {
diff --git a/flang/runtime/edit-output.cpp b/FortranRuntime/lib/Runtime/edit-output.cpp
similarity index 99%
rename from flang/runtime/edit-output.cpp
rename to FortranRuntime/lib/Runtime/edit-output.cpp
index 9d60732258bfbc..ccaf8085f016fd 100644
--- a/flang/runtime/edit-output.cpp
+++ b/FortranRuntime/lib/Runtime/edit-output.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/edit-output.cpp -------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/edit-output.h b/FortranRuntime/lib/Runtime/edit-output.h
similarity index 98%
rename from flang/runtime/edit-output.h
rename to FortranRuntime/lib/Runtime/edit-output.h
index 365bc2e2a4d10b..7f303020a83a84 100644
--- a/flang/runtime/edit-output.h
+++ b/FortranRuntime/lib/Runtime/edit-output.h
@@ -1,4 +1,4 @@
-//===-- runtime/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.
@@ -21,7 +21,7 @@
#include "format.h"
#include "io-stmt.h"
#include "flang/Common/uint128.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
namespace Fortran::runtime::io {
diff --git a/flang/runtime/emit-encoded.h b/FortranRuntime/lib/Runtime/emit-encoded.h
similarity index 98%
rename from flang/runtime/emit-encoded.h
rename to FortranRuntime/lib/Runtime/emit-encoded.h
index 4b5e3900788357..f07fcced488435 100644
--- a/flang/runtime/emit-encoded.h
+++ b/FortranRuntime/lib/Runtime/emit-encoded.h
@@ -1,4 +1,4 @@
-//===-- runtime/emit-encoded.h ----------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/environment-default-list.h b/FortranRuntime/lib/Runtime/environment-default-list.h
old mode 100755
new mode 100644
similarity index 85%
rename from flang/runtime/environment-default-list.h
rename to FortranRuntime/lib/Runtime/environment-default-list.h
index 4da261b10b9a84..6b7542516e7134
--- a/flang/runtime/environment-default-list.h
+++ b/FortranRuntime/lib/Runtime/environment-default-list.h
@@ -1,11 +1,10 @@
-/*===-- runtime/environment-default-list.h --------------------------*- C -*-===
+/*===-- lib/Runtime/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_
diff --git a/flang/runtime/environment.cpp b/FortranRuntime/lib/Runtime/environment.cpp
similarity index 98%
rename from flang/runtime/environment.cpp
rename to FortranRuntime/lib/Runtime/environment.cpp
index 52b1d99ba536ed..272914877988a5 100644
--- a/flang/runtime/environment.cpp
+++ b/FortranRuntime/lib/Runtime/environment.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/environment.cpp -------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/environment.h b/FortranRuntime/lib/Runtime/environment.h
similarity index 95%
rename from flang/runtime/environment.h
rename to FortranRuntime/lib/Runtime/environment.h
index b8b9f10e4e57f5..71526d2b85d74c 100644
--- a/flang/runtime/environment.h
+++ b/FortranRuntime/lib/Runtime/environment.h
@@ -1,4 +1,4 @@
-//===-- runtime/environment.h -----------------------------------*- C++ -*-===//
+//===-- lib/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.
@@ -10,7 +10,7 @@
#define FORTRAN_RUNTIME_ENVIRONMENT_H_
#include "flang/Common/optional.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
struct EnvironmentDefaultList;
diff --git a/flang/runtime/exceptions.cpp b/FortranRuntime/lib/Runtime/exceptions.cpp
similarity index 96%
rename from flang/runtime/exceptions.cpp
rename to FortranRuntime/lib/Runtime/exceptions.cpp
index 8239c556bcea97..7739130ae2346a 100644
--- a/flang/runtime/exceptions.cpp
+++ b/FortranRuntime/lib/Runtime/exceptions.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/exceptions.cpp --------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/execute.cpp b/FortranRuntime/lib/Runtime/execute.cpp
similarity index 99%
rename from flang/runtime/execute.cpp
rename to FortranRuntime/lib/Runtime/execute.cpp
index c7f8f386d81f4f..77aac164242612 100644
--- a/flang/runtime/execute.cpp
+++ b/FortranRuntime/lib/Runtime/execute.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/execute.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/extensions.cpp b/FortranRuntime/lib/Runtime/extensions.cpp
similarity index 98%
rename from flang/runtime/extensions.cpp
rename to FortranRuntime/lib/Runtime/extensions.cpp
index be3833db88b07a..e75fa75893a82b 100644
--- a/flang/runtime/extensions.cpp
+++ b/FortranRuntime/lib/Runtime/extensions.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/extensions.cpp --------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/external-unit.cpp b/FortranRuntime/lib/Runtime/external-unit.cpp
similarity index 99%
rename from flang/runtime/external-unit.cpp
rename to FortranRuntime/lib/Runtime/external-unit.cpp
index d17a92622f8448..f5fa2c31dafc4e 100644
--- a/flang/runtime/external-unit.cpp
+++ b/FortranRuntime/lib/Runtime/external-unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/external-unit.cpp -----------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/extrema.cpp b/FortranRuntime/lib/Runtime/extrema.cpp
similarity index 99%
rename from flang/runtime/extrema.cpp
rename to FortranRuntime/lib/Runtime/extrema.cpp
index d6e9633372f524..be9da63d7bd6b8 100644
--- a/flang/runtime/extrema.cpp
+++ b/FortranRuntime/lib/Runtime/extrema.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/extrema.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/file.cpp b/FortranRuntime/lib/Runtime/file.cpp
similarity index 99%
rename from flang/runtime/file.cpp
rename to FortranRuntime/lib/Runtime/file.cpp
index ec772903242b80..44e3850cdfcb13 100644
--- a/flang/runtime/file.cpp
+++ b/FortranRuntime/lib/Runtime/file.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/file.cpp --------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/file.h b/FortranRuntime/lib/Runtime/file.h
similarity index 98%
rename from flang/runtime/file.h
rename to FortranRuntime/lib/Runtime/file.h
index c06acbb9904cc1..6890cb62d66652 100644
--- a/flang/runtime/file.h
+++ b/FortranRuntime/lib/Runtime/file.h
@@ -1,4 +1,4 @@
-//===-- runtime/file.h ------------------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/findloc.cpp b/FortranRuntime/lib/Runtime/findloc.cpp
similarity index 99%
rename from flang/runtime/findloc.cpp
rename to FortranRuntime/lib/Runtime/findloc.cpp
index 674a21ae50b853..da5fe0c0a0a467 100644
--- a/flang/runtime/findloc.cpp
+++ b/FortranRuntime/lib/Runtime/findloc.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/findloc.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/format-implementation.h b/FortranRuntime/lib/Runtime/format-implementation.h
similarity index 99%
rename from flang/runtime/format-implementation.h
rename to FortranRuntime/lib/Runtime/format-implementation.h
index 46204ca927c135..2ed6006c3b2fa0 100644
--- a/flang/runtime/format-implementation.h
+++ b/FortranRuntime/lib/Runtime/format-implementation.h
@@ -1,4 +1,4 @@
-//===-- runtime/format-implementation.h -------------------------*- C++ -*-===//
+//===-- lib/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.
@@ -16,7 +16,7 @@
#include "io-stmt.h"
#include "memory.h"
#include "flang/Common/format.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
#include "flang/Runtime/main.h"
#include <algorithm>
#include <cstring>
diff --git a/flang/runtime/format.cpp b/FortranRuntime/lib/Runtime/format.cpp
similarity index 92%
rename from flang/runtime/format.cpp
rename to FortranRuntime/lib/Runtime/format.cpp
index 433acce4b73739..73a61f785c23b8 100644
--- a/flang/runtime/format.cpp
+++ b/FortranRuntime/lib/Runtime/format.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/format.cpp ------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/format.h b/FortranRuntime/lib/Runtime/format.h
similarity index 98%
rename from flang/runtime/format.h
rename to FortranRuntime/lib/Runtime/format.h
index 5329f2482d3e46..b9c6979d1c2c98 100644
--- a/flang/runtime/format.h
+++ b/FortranRuntime/lib/Runtime/format.h
@@ -1,4 +1,4 @@
-//===-- runtime/format.h ----------------------------------------*- C++ -*-===//
+//===-- lib/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.
@@ -13,9 +13,9 @@
#include "environment.h"
#include "io-error.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
#include "flang/Common/optional.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
#include "flang/Runtime/freestanding-tools.h"
#include <cinttypes>
diff --git a/flang/runtime/inquiry.cpp b/FortranRuntime/lib/Runtime/inquiry.cpp
similarity index 97%
rename from flang/runtime/inquiry.cpp
rename to FortranRuntime/lib/Runtime/inquiry.cpp
index 9fbcaa96fa3c43..9a5ef0cea210db 100644
--- a/flang/runtime/inquiry.cpp
+++ b/FortranRuntime/lib/Runtime/inquiry.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/inquiry.cpp --------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/internal-unit.cpp b/FortranRuntime/lib/Runtime/internal-unit.cpp
similarity index 98%
rename from flang/runtime/internal-unit.cpp
rename to FortranRuntime/lib/Runtime/internal-unit.cpp
index f28700ee015815..95d371a49ac187 100644
--- a/flang/runtime/internal-unit.cpp
+++ b/FortranRuntime/lib/Runtime/internal-unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/internal-unit.cpp -----------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/internal-unit.h b/FortranRuntime/lib/Runtime/internal-unit.h
similarity index 97%
rename from flang/runtime/internal-unit.h
rename to FortranRuntime/lib/Runtime/internal-unit.h
index a0ee6353eeda3b..444bc9ab515994 100644
--- a/flang/runtime/internal-unit.h
+++ b/FortranRuntime/lib/Runtime/internal-unit.h
@@ -1,4 +1,4 @@
-//===-- runtime/internal-unit.h ---------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/io-api-common.h b/FortranRuntime/lib/Runtime/io-api-common.h
similarity index 98%
rename from flang/runtime/io-api-common.h
rename to FortranRuntime/lib/Runtime/io-api-common.h
index c7b86cab73a525..9b4c3405b0991e 100644
--- a/flang/runtime/io-api-common.h
+++ b/FortranRuntime/lib/Runtime/io-api-common.h
@@ -1,4 +1,4 @@
-//===-- runtime/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.
diff --git a/flang/runtime/io-api-minimal.cpp b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
similarity index 98%
rename from flang/runtime/io-api-minimal.cpp
rename to FortranRuntime/lib/Runtime/io-api-minimal.cpp
index ad76fe3de0324c..6bc262cae78458 100644
--- a/flang/runtime/io-api-minimal.cpp
+++ b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-api-minimal.cpp ----------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/io-api.cpp b/FortranRuntime/lib/Runtime/io-api.cpp
similarity index 99%
rename from flang/runtime/io-api.cpp
rename to FortranRuntime/lib/Runtime/io-api.cpp
index e3c6b9e5ca8959..f4a396d4c49a45 100644
--- a/flang/runtime/io-api.cpp
+++ b/FortranRuntime/lib/Runtime/io-api.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-api.cpp ------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/io-error.cpp b/FortranRuntime/lib/Runtime/io-error.cpp
similarity index 98%
rename from flang/runtime/io-error.cpp
rename to FortranRuntime/lib/Runtime/io-error.cpp
index 7a90966f81047f..053667462058de 100644
--- a/flang/runtime/io-error.cpp
+++ b/FortranRuntime/lib/Runtime/io-error.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-error.cpp ----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/io-error.h b/FortranRuntime/lib/Runtime/io-error.h
similarity index 97%
rename from flang/runtime/io-error.h
rename to FortranRuntime/lib/Runtime/io-error.h
index 426573e2faf00c..b03e07567a0607 100644
--- a/flang/runtime/io-error.h
+++ b/FortranRuntime/lib/Runtime/io-error.h
@@ -1,4 +1,4 @@
-//===-- runtime/io-error.h --------------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/io-stmt.cpp b/FortranRuntime/lib/Runtime/io-stmt.cpp
similarity index 99%
rename from flang/runtime/io-stmt.cpp
rename to FortranRuntime/lib/Runtime/io-stmt.cpp
index 265bd0dc9d9499..80c96710eb49ca 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/FortranRuntime/lib/Runtime/io-stmt.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/io-stmt.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/io-stmt.h b/FortranRuntime/lib/Runtime/io-stmt.h
similarity index 99%
rename from flang/runtime/io-stmt.h
rename to FortranRuntime/lib/Runtime/io-stmt.h
index 2e0ca46078ecdc..e90e64c8fd1ff3 100644
--- a/flang/runtime/io-stmt.h
+++ b/FortranRuntime/lib/Runtime/io-stmt.h
@@ -1,4 +1,4 @@
-//===-- runtime/io-stmt.h ---------------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/iostat.cpp b/FortranRuntime/lib/Runtime/iostat.cpp
similarity index 98%
rename from flang/runtime/iostat.cpp
rename to FortranRuntime/lib/Runtime/iostat.cpp
index 39e224cb01286b..f23567be4910da 100644
--- a/flang/runtime/iostat.cpp
+++ b/FortranRuntime/lib/Runtime/iostat.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/iostat.cpp ------------------------------------------------===//
+//===-- 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/module/iso_fortran_env_impl.f90 b/FortranRuntime/lib/Runtime/iso_fortran_env_impl.f90
similarity index 98%
rename from flang/module/iso_fortran_env_impl.f90
rename to FortranRuntime/lib/Runtime/iso_fortran_env_impl.f90
index 4de54dda7bab1c..1a4da69266c55b 100644
--- a/flang/module/iso_fortran_env_impl.f90
+++ b/FortranRuntime/lib/Runtime/iso_fortran_env_impl.f90
@@ -1,4 +1,4 @@
-!===-- module/iso_fortran_env_impl.f90 --=--------------------------------===!
+!===-- lib/Runtime/iso_fortran_env_impl.f90 --------------------------------===!
!
! 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/lock.h b/FortranRuntime/lib/Runtime/lock.h
similarity index 97%
rename from flang/runtime/lock.h
rename to FortranRuntime/lib/Runtime/lock.h
index 46ca28703a45b4..75c1adb12a8c62 100644
--- a/flang/runtime/lock.h
+++ b/FortranRuntime/lib/Runtime/lock.h
@@ -1,4 +1,4 @@
-//===-- runtime/lock.h ------------------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/main.cpp b/FortranRuntime/lib/Runtime/main.cpp
similarity index 94%
rename from flang/runtime/main.cpp
rename to FortranRuntime/lib/Runtime/main.cpp
index 96454989581b71..3fe985e524548d 100644
--- a/flang/runtime/main.cpp
+++ b/FortranRuntime/lib/Runtime/main.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/main.cpp --------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/matmul-transpose.cpp b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
similarity index 99%
rename from flang/runtime/matmul-transpose.cpp
rename to FortranRuntime/lib/Runtime/matmul-transpose.cpp
index 283472650a1c69..d493333dfa9877 100644
--- a/flang/runtime/matmul-transpose.cpp
+++ b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/matmul-transpose.cpp --------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/matmul.cpp b/FortranRuntime/lib/Runtime/matmul.cpp
similarity index 99%
rename from flang/runtime/matmul.cpp
rename to FortranRuntime/lib/Runtime/matmul.cpp
index 252557e2f9e7ad..124369e72886c5 100644
--- a/flang/runtime/matmul.cpp
+++ b/FortranRuntime/lib/Runtime/matmul.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/matmul.cpp ------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/memory.cpp b/FortranRuntime/lib/Runtime/memory.cpp
similarity index 93%
rename from flang/runtime/memory.cpp
rename to FortranRuntime/lib/Runtime/memory.cpp
index c7068ad6479a12..4a811107ca220a 100644
--- a/flang/runtime/memory.cpp
+++ b/FortranRuntime/lib/Runtime/memory.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/memory.cpp ------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/misc-intrinsic.cpp b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
similarity index 98%
rename from flang/runtime/misc-intrinsic.cpp
rename to FortranRuntime/lib/Runtime/misc-intrinsic.cpp
index f7d893829fc0d3..b942d762e76ab3 100644
--- a/flang/runtime/misc-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/misc-intrinsic.cpp ----------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/namelist.cpp b/FortranRuntime/lib/Runtime/namelist.cpp
similarity index 99%
rename from flang/runtime/namelist.cpp
rename to FortranRuntime/lib/Runtime/namelist.cpp
index af092de70f7819..e6229d56577568 100644
--- a/flang/runtime/namelist.cpp
+++ b/FortranRuntime/lib/Runtime/namelist.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/namelist.cpp ----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/namelist.h b/FortranRuntime/lib/Runtime/namelist.h
similarity index 96%
rename from flang/runtime/namelist.h
rename to FortranRuntime/lib/Runtime/namelist.h
index 25216a75e9367d..4694b3104a9c75 100644
--- a/flang/runtime/namelist.h
+++ b/FortranRuntime/lib/Runtime/namelist.h
@@ -1,4 +1,4 @@
-//===-- runtime/namelist.h --------------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/non-tbp-dio.cpp b/FortranRuntime/lib/Runtime/non-tbp-dio.cpp
similarity index 93%
rename from flang/runtime/non-tbp-dio.cpp
rename to FortranRuntime/lib/Runtime/non-tbp-dio.cpp
index 9419adb7631cc9..9fa04397bc9610 100644
--- a/flang/runtime/non-tbp-dio.cpp
+++ b/FortranRuntime/lib/Runtime/non-tbp-dio.cpp
@@ -1,4 +1,4 @@
-//===-- flang/runtime/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.
diff --git a/flang/runtime/non-tbp-dio.h b/FortranRuntime/lib/Runtime/non-tbp-dio.h
similarity index 93%
rename from flang/runtime/non-tbp-dio.h
rename to FortranRuntime/lib/Runtime/non-tbp-dio.h
index 05038a264ed992..0a45c96a3f2e25 100644
--- a/flang/runtime/non-tbp-dio.h
+++ b/FortranRuntime/lib/Runtime/non-tbp-dio.h
@@ -1,4 +1,4 @@
-//===-- flang/runtime/non-tbp-dio.h -----------------------------*- C++ -*-===//
+//===-- lib/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.
@@ -22,7 +22,8 @@
#ifndef FORTRAN_RUNTIME_NON_TBP_DIO_H_
#define FORTRAN_RUNTIME_NON_TBP_DIO_H_
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Common/api-attrs.h"
#include <cstddef>
namespace Fortran::runtime::typeInfo {
diff --git a/flang/runtime/numeric-templates.h b/FortranRuntime/lib/Runtime/numeric-templates.h
similarity index 99%
rename from flang/runtime/numeric-templates.h
rename to FortranRuntime/lib/Runtime/numeric-templates.h
index 1b43498a6bfd12..640c6d17c4b580 100644
--- a/flang/runtime/numeric-templates.h
+++ b/FortranRuntime/lib/Runtime/numeric-templates.h
@@ -1,4 +1,4 @@
-//===-- runtime/numeric-templates.h -----------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/numeric.cpp b/FortranRuntime/lib/Runtime/numeric.cpp
similarity index 99%
rename from flang/runtime/numeric.cpp
rename to FortranRuntime/lib/Runtime/numeric.cpp
index 9a8ddc6615564d..b0f68a7fc81d29 100644
--- a/flang/runtime/numeric.cpp
+++ b/FortranRuntime/lib/Runtime/numeric.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/numeric.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/pointer.cpp b/FortranRuntime/lib/Runtime/pointer.cpp
similarity index 99%
rename from flang/runtime/pointer.cpp
rename to FortranRuntime/lib/Runtime/pointer.cpp
index 2979181ddd61bd..fba9e639fa37a8 100644
--- a/flang/runtime/pointer.cpp
+++ b/FortranRuntime/lib/Runtime/pointer.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/pointer.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/product.cpp b/FortranRuntime/lib/Runtime/product.cpp
similarity index 98%
rename from flang/runtime/product.cpp
rename to FortranRuntime/lib/Runtime/product.cpp
index 7fc0fcd3b107de..e4a6e81bd0c508 100644
--- a/flang/runtime/product.cpp
+++ b/FortranRuntime/lib/Runtime/product.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/product.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/pseudo-unit.cpp b/FortranRuntime/lib/Runtime/pseudo-unit.cpp
similarity index 98%
rename from flang/runtime/pseudo-unit.cpp
rename to FortranRuntime/lib/Runtime/pseudo-unit.cpp
index 526afd11d916e9..62c6b1df5071c7 100644
--- a/flang/runtime/pseudo-unit.cpp
+++ b/FortranRuntime/lib/Runtime/pseudo-unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/pseudo-unit.cpp -------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/ragged.cpp b/FortranRuntime/lib/Runtime/ragged.cpp
similarity index 97%
rename from flang/runtime/ragged.cpp
rename to FortranRuntime/lib/Runtime/ragged.cpp
index a4d9e541ba5311..681a800e29dca7 100644
--- a/flang/runtime/ragged.cpp
+++ b/FortranRuntime/lib/Runtime/ragged.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/ragged.cpp ------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/random-templates.h b/FortranRuntime/lib/Runtime/random-templates.h
similarity index 97%
rename from flang/runtime/random-templates.h
rename to FortranRuntime/lib/Runtime/random-templates.h
index f34422f6f5d9ac..4faca63ba34b9d 100644
--- a/flang/runtime/random-templates.h
+++ b/FortranRuntime/lib/Runtime/random-templates.h
@@ -1,4 +1,4 @@
-//===-- runtime/random-templates.h ------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/random.cpp b/FortranRuntime/lib/Runtime/random.cpp
similarity index 98%
rename from flang/runtime/random.cpp
rename to FortranRuntime/lib/Runtime/random.cpp
index 69de9b8c96fb5d..343b0a389fcaf6 100644
--- a/flang/runtime/random.cpp
+++ b/FortranRuntime/lib/Runtime/random.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/random.cpp ------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/reduce.cpp b/FortranRuntime/lib/Runtime/reduce.cpp
similarity index 99%
rename from flang/runtime/reduce.cpp
rename to FortranRuntime/lib/Runtime/reduce.cpp
index 2f4bb6ea159cf4..c3e7ef74363431 100644
--- a/flang/runtime/reduce.cpp
+++ b/FortranRuntime/lib/Runtime/reduce.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/reduce.cpp ------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/reduction-templates.h b/FortranRuntime/lib/Runtime/reduction-templates.h
similarity index 99%
rename from flang/runtime/reduction-templates.h
rename to FortranRuntime/lib/Runtime/reduction-templates.h
index a51404c9637620..ba193a9f0e3b9d 100644
--- a/flang/runtime/reduction-templates.h
+++ b/FortranRuntime/lib/Runtime/reduction-templates.h
@@ -1,4 +1,4 @@
-//===-- runtime/reduction-templates.h ---------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/reduction.cpp b/FortranRuntime/lib/Runtime/reduction.cpp
similarity index 99%
rename from flang/runtime/reduction.cpp
rename to FortranRuntime/lib/Runtime/reduction.cpp
index 074a270cb50838..0de7dd07b17a5b 100644
--- a/flang/runtime/reduction.cpp
+++ b/FortranRuntime/lib/Runtime/reduction.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/reduction.cpp ---------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/stack.h b/FortranRuntime/lib/Runtime/stack.h
similarity index 98%
rename from flang/runtime/stack.h
rename to FortranRuntime/lib/Runtime/stack.h
index b6e6edb595e9ad..974ccb9d30b0eb 100644
--- a/flang/runtime/stack.h
+++ b/FortranRuntime/lib/Runtime/stack.h
@@ -1,4 +1,4 @@
-//===-- runtime/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.
diff --git a/flang/runtime/stat.cpp b/FortranRuntime/lib/Runtime/stat.cpp
similarity index 97%
rename from flang/runtime/stat.cpp
rename to FortranRuntime/lib/Runtime/stat.cpp
index 525a4e36cdc773..d483f75998a746 100644
--- a/flang/runtime/stat.cpp
+++ b/FortranRuntime/lib/Runtime/stat.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/stat.cpp --------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/stat.h b/FortranRuntime/lib/Runtime/stat.h
similarity index 95%
rename from flang/runtime/stat.h
rename to FortranRuntime/lib/Runtime/stat.h
index 71faeb027d9085..9f56d88f588a1e 100644
--- a/flang/runtime/stat.h
+++ b/FortranRuntime/lib/Runtime/stat.h
@@ -1,4 +1,4 @@
-//===-- runtime/stat.h ------------------------------------------*- C++ -*-===//
+//===-- lib/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.
@@ -12,7 +12,7 @@
#ifndef FORTRAN_RUNTIME_STAT_H_
#define FORTRAN_RUNTIME_STAT_H_
#include "flang/Common/api-attrs.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/magic-numbers.h"
namespace Fortran::runtime {
diff --git a/flang/runtime/stop.cpp b/FortranRuntime/lib/Runtime/stop.cpp
similarity index 98%
rename from flang/runtime/stop.cpp
rename to FortranRuntime/lib/Runtime/stop.cpp
index cfb36b40840200..8465a53168e551 100644
--- a/flang/runtime/stop.cpp
+++ b/FortranRuntime/lib/Runtime/stop.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/stop.cpp --------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/sum.cpp b/FortranRuntime/lib/Runtime/sum.cpp
similarity index 98%
rename from flang/runtime/sum.cpp
rename to FortranRuntime/lib/Runtime/sum.cpp
index 63d8c9029a0ef5..64982b9fd53690 100644
--- a/flang/runtime/sum.cpp
+++ b/FortranRuntime/lib/Runtime/sum.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/sum.cpp ---------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/support.cpp b/FortranRuntime/lib/Runtime/support.cpp
similarity index 94%
rename from flang/runtime/support.cpp
rename to FortranRuntime/lib/Runtime/support.cpp
index a607120256d9d9..1dffa99191bae1 100644
--- a/flang/runtime/support.cpp
+++ b/FortranRuntime/lib/Runtime/support.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/support.cpp -----------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/temporary-stack.cpp b/FortranRuntime/lib/Runtime/temporary-stack.cpp
similarity index 98%
rename from flang/runtime/temporary-stack.cpp
rename to FortranRuntime/lib/Runtime/temporary-stack.cpp
index 667b10e04dbd29..12fa18586b7421 100644
--- a/flang/runtime/temporary-stack.cpp
+++ b/FortranRuntime/lib/Runtime/temporary-stack.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/temporary-stack.cpp ---------------------------------------===//
+//===-- 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.
@@ -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/runtime/terminator.cpp b/FortranRuntime/lib/Runtime/terminator.cpp
similarity index 97%
rename from flang/runtime/terminator.cpp
rename to FortranRuntime/lib/Runtime/terminator.cpp
index bab9edc64fa35b..4146e28235511f 100644
--- a/flang/runtime/terminator.cpp
+++ b/FortranRuntime/lib/Runtime/terminator.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/terminate.cpp ---------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/terminator.h b/FortranRuntime/lib/Runtime/terminator.h
similarity index 98%
rename from flang/runtime/terminator.h
rename to FortranRuntime/lib/Runtime/terminator.h
index 609f059d6e0921..02b3a4c4f066f8 100644
--- a/flang/runtime/terminator.h
+++ b/FortranRuntime/lib/Runtime/terminator.h
@@ -1,4 +1,4 @@
-//===-- runtime/terminator.h ------------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/time-intrinsic.cpp b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
similarity index 99%
rename from flang/runtime/time-intrinsic.cpp
rename to FortranRuntime/lib/Runtime/time-intrinsic.cpp
index e6f6e81c7b50cc..05f7e4f80f18b6 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/time-intrinsic.cpp ----------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/tools.cpp b/FortranRuntime/lib/Runtime/tools.cpp
similarity index 99%
rename from flang/runtime/tools.cpp
rename to FortranRuntime/lib/Runtime/tools.cpp
index 73d6c2cf7e1d2b..d5c113a31fc501 100644
--- a/flang/runtime/tools.cpp
+++ b/FortranRuntime/lib/Runtime/tools.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/tools.cpp -------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/tools.h b/FortranRuntime/lib/Runtime/tools.h
similarity index 99%
rename from flang/runtime/tools.h
rename to FortranRuntime/lib/Runtime/tools.h
index dc12e5c4533e2e..b57c7996135913 100644
--- a/flang/runtime/tools.h
+++ b/FortranRuntime/lib/Runtime/tools.h
@@ -1,4 +1,4 @@
-//===-- runtime/tools.h -----------------------------------------*- C++ -*-===//
+//===-- lib/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.
diff --git a/flang/runtime/transformational.cpp b/FortranRuntime/lib/Runtime/transformational.cpp
similarity index 99%
rename from flang/runtime/transformational.cpp
rename to FortranRuntime/lib/Runtime/transformational.cpp
index b6b204be4418c9..8c244fc296f3b9 100644
--- a/flang/runtime/transformational.cpp
+++ b/FortranRuntime/lib/Runtime/transformational.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/transformational.cpp --------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/type-code.cpp b/FortranRuntime/lib/Runtime/type-code.cpp
similarity index 98%
rename from flang/runtime/type-code.cpp
rename to FortranRuntime/lib/Runtime/type-code.cpp
index cb1b944433aae5..2709ca1be75a53 100644
--- a/flang/runtime/type-code.cpp
+++ b/FortranRuntime/lib/Runtime/type-code.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/type-code.cpp ---------------------------------------------===//
+//===-- 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.
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/type-code.h"
+#include <cstdint>
namespace Fortran::runtime {
diff --git a/flang/runtime/type-info.cpp b/FortranRuntime/lib/Runtime/type-info.cpp
similarity index 99%
rename from flang/runtime/type-info.cpp
rename to FortranRuntime/lib/Runtime/type-info.cpp
index cb18c5669b5ffc..24fc9c33d92819 100644
--- a/flang/runtime/type-info.cpp
+++ b/FortranRuntime/lib/Runtime/type-info.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/type-info.cpp ---------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/type-info.h b/FortranRuntime/lib/Runtime/type-info.h
similarity index 99%
rename from flang/runtime/type-info.h
rename to FortranRuntime/lib/Runtime/type-info.h
index c3f3595e32ef28..28e7c4696613b3 100644
--- a/flang/runtime/type-info.h
+++ b/FortranRuntime/lib/Runtime/type-info.h
@@ -1,4 +1,4 @@
-//===-- runtime/type-info.h -------------------------------------*- C++ -*-===//
+//===-- lib/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.
@@ -13,7 +13,7 @@
// flang/module/__fortran_type_info.f90.
#include "terminator.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
#include "flang/Common/bit-population-count.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/descriptor.h"
diff --git a/flang/runtime/unit-map.cpp b/FortranRuntime/lib/Runtime/unit-map.cpp
similarity index 97%
rename from flang/runtime/unit-map.cpp
rename to FortranRuntime/lib/Runtime/unit-map.cpp
index 684a9b9e20b97a..93958be8df7ea5 100644
--- a/flang/runtime/unit-map.cpp
+++ b/FortranRuntime/lib/Runtime/unit-map.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/unit-map.cpp ----------------------------------------------===//
+//===-- 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/runtime/unit-map.h b/FortranRuntime/lib/Runtime/unit-map.h
similarity index 97%
rename from flang/runtime/unit-map.h
rename to FortranRuntime/lib/Runtime/unit-map.h
index 6f1e01bb1e64ac..f9f0d34d4f0193 100644
--- a/flang/runtime/unit-map.h
+++ b/FortranRuntime/lib/Runtime/unit-map.h
@@ -1,4 +1,4 @@
-//===-- runtime/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.
diff --git a/flang/runtime/unit.cpp b/FortranRuntime/lib/Runtime/unit.cpp
similarity index 99%
rename from flang/runtime/unit.cpp
rename to FortranRuntime/lib/Runtime/unit.cpp
index 4aee8397d477e7..496679ee8ce5f4 100644
--- a/flang/runtime/unit.cpp
+++ b/FortranRuntime/lib/Runtime/unit.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/unit.cpp --------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/unit.h b/FortranRuntime/lib/Runtime/unit.h
similarity index 99%
rename from flang/runtime/unit.h
rename to FortranRuntime/lib/Runtime/unit.h
index a3ea2686816803..608f3a28ef687d 100644
--- a/flang/runtime/unit.h
+++ b/FortranRuntime/lib/Runtime/unit.h
@@ -1,4 +1,4 @@
-//===-- runtime/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.
diff --git a/flang/runtime/utf.cpp b/FortranRuntime/lib/Runtime/utf.cpp
similarity index 98%
rename from flang/runtime/utf.cpp
rename to FortranRuntime/lib/Runtime/utf.cpp
index b09819cb2f736b..635451153d39a6 100644
--- a/flang/runtime/utf.cpp
+++ b/FortranRuntime/lib/Runtime/utf.cpp
@@ -1,4 +1,4 @@
-//===-- runtime/utf.cpp ---------------------------------------------------===//
+//===-- 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.
diff --git a/flang/runtime/utf.h b/FortranRuntime/lib/Runtime/utf.h
similarity index 97%
rename from flang/runtime/utf.h
rename to FortranRuntime/lib/Runtime/utf.h
index 10c2d61484217a..5ba40437ea0c95 100644
--- a/flang/runtime/utf.h
+++ b/FortranRuntime/lib/Runtime/utf.h
@@ -1,4 +1,4 @@
-//===-- runtime/utf.h -----------------------------------------------------===//
+//===-- lib/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.
diff --git a/FortranRuntime/lib/Testing/CMakeLists.txt b/FortranRuntime/lib/Testing/CMakeLists.txt
new file mode 100644
index 00000000000000..75b38662c2a0fa
--- /dev/null
+++ b/FortranRuntime/lib/Testing/CMakeLists.txt
@@ -0,0 +1,19 @@
+#===-- 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
+ "${FLANGRUNTIME_SOURCE_DIR}/lib/Testing/*.h"
+)
+
+add_fortranruntime_library(NonGTestTesting EXCLUDE_FROM_ALL LINK_TO_LLVM
+ testing.cpp
+ fp-testing.cpp
+ ADDITIONAL_HEADERS
+ ${public_headers}
+)
diff --git a/flang/unittests/Evaluate/fp-testing.cpp b/FortranRuntime/lib/Testing/fp-testing.cpp
similarity index 86%
rename from flang/unittests/Evaluate/fp-testing.cpp
rename to FortranRuntime/lib/Testing/fp-testing.cpp
index 94d8d5086d000b..8541b1406334d3 100644
--- a/flang/unittests/Evaluate/fp-testing.cpp
+++ b/FortranRuntime/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>
@@ -8,7 +16,7 @@
#endif
using Fortran::common::RoundingMode;
-using Fortran::evaluate::RealFlag;
+using Fortran::common::RealFlag;
ScopedHostFloatingPointEnvironment::ScopedHostFloatingPointEnvironment(
#if __x86_64__
diff --git a/flang/unittests/Evaluate/testing.cpp b/FortranRuntime/lib/Testing/testing.cpp
similarity index 88%
rename from flang/unittests/Evaluate/testing.cpp
rename to FortranRuntime/lib/Testing/testing.cpp
index b2f73bf1b265a7..37f9d88f4886b4 100644
--- a/flang/unittests/Evaluate/testing.cpp
+++ b/FortranRuntime/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/module/.clang-format b/FortranRuntime/module/.clang-format
similarity index 100%
rename from flang/module/.clang-format
rename to FortranRuntime/module/.clang-format
diff --git a/FortranRuntime/module/CMakeLists.txt b/FortranRuntime/module/CMakeLists.txt
new file mode 100644
index 00000000000000..9841cbd586b2df
--- /dev/null
+++ b/FortranRuntime/module/CMakeLists.txt
@@ -0,0 +1,63 @@
+#===-- module/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(module_sources
+ "__cuda_builtins.f90"
+ "__fortran_builtins.f90"
+ "__fortran_ieee_exceptions.f90"
+ "__fortran_type_info.f90"
+ # "cudadevice.f90" # TODO: -fc1 -xcuda
+ "ieee_arithmetic.f90"
+ "ieee_exceptions.f90"
+ "ieee_features.f90"
+ "iso_c_binding.f90"
+ "iso_fortran_env.f90"
+)
+
+set_source_files_properties(
+ "iso_fortran_env.f90"
+ PROPERTIES
+ COMPILE_FLAGS "-mmlir -ignore-module-only-builtins"
+)
+
+set_source_files_properties(
+ "__fortran_builtins.f90"
+ PROPERTIES
+ COMPILE_FLAGS "-mmlir -ignore-missing-type-desc"
+)
+
+# Requires PowerPC vector instructions
+if (LLVM_TARGET_TRIPLE MATCHES "(ppc|powerpc)(32|64)?(le|be)?\-.*")
+ list(APPEND module_sources
+ "__ppc_types.f90"
+ "__ppc_intrinsics.f90"
+ "mma.f90"
+ )
+endif ()
+
+add_fortranruntime_library(module_files OBJECT
+ ${module_sources}
+)
+
+# Usually, CMake will ignore dependencies from Fortran intrinsic modules. Since this is building those intrinsic modules themselves, tell CMake to not prune such dependencies.
+set_target_properties(module_files
+ PROPERTIES
+ Fortran_BUILDING_INSTRINSIC_MODULES ON
+)
+
+# The usual technique to install files in CMake is
+#
+# install(TARGET <targetname> <artifacttype> ...)
+#
+# However, there is no <artifacttype> for Fortran modules. We have to derive the module file path individually.
+set(module_files "")
+foreach (f90file IN LISTS module_sources)
+ get_filename_component(base "${f90file}" NAME_WE )
+ list(APPEND module_files "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/flang/${base}.mod")
+endforeach ()
+install(FILES ${module_files} DESTINATION "${FORTRANRUNTIME_INSTALL_INCLUDE_DIR}/flang")
diff --git a/flang/module/__cuda_builtins.f90 b/FortranRuntime/module/__cuda_builtins.f90
similarity index 100%
rename from flang/module/__cuda_builtins.f90
rename to FortranRuntime/module/__cuda_builtins.f90
diff --git a/flang/module/__fortran_builtins.f90 b/FortranRuntime/module/__fortran_builtins.f90
similarity index 100%
rename from flang/module/__fortran_builtins.f90
rename to FortranRuntime/module/__fortran_builtins.f90
diff --git a/flang/module/__fortran_ieee_exceptions.f90 b/FortranRuntime/module/__fortran_ieee_exceptions.f90
similarity index 100%
rename from flang/module/__fortran_ieee_exceptions.f90
rename to FortranRuntime/module/__fortran_ieee_exceptions.f90
diff --git a/flang/module/__fortran_type_info.f90 b/FortranRuntime/module/__fortran_type_info.f90
similarity index 100%
rename from flang/module/__fortran_type_info.f90
rename to FortranRuntime/module/__fortran_type_info.f90
diff --git a/flang/module/__ppc_intrinsics.f90 b/FortranRuntime/module/__ppc_intrinsics.f90
similarity index 100%
rename from flang/module/__ppc_intrinsics.f90
rename to FortranRuntime/module/__ppc_intrinsics.f90
diff --git a/flang/module/__ppc_types.f90 b/FortranRuntime/module/__ppc_types.f90
similarity index 100%
rename from flang/module/__ppc_types.f90
rename to FortranRuntime/module/__ppc_types.f90
diff --git a/flang/module/cudadevice.f90 b/FortranRuntime/module/cudadevice.f90
similarity index 96%
rename from flang/module/cudadevice.f90
rename to FortranRuntime/module/cudadevice.f90
index 0224ecfdde7c60..dd487f6ed1ffee 100644
--- a/flang/module/cudadevice.f90
+++ b/FortranRuntime/module/cudadevice.f90
@@ -1,4 +1,4 @@
-!===-- module/cudedevice.f90 -----------------------------------------------===!
+!===-- module/cudadevice.f90 -----------------------------------------------===!
!
! 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/module/ieee_arithmetic.f90 b/FortranRuntime/module/ieee_arithmetic.f90
similarity index 100%
rename from flang/module/ieee_arithmetic.f90
rename to FortranRuntime/module/ieee_arithmetic.f90
diff --git a/flang/module/ieee_exceptions.f90 b/FortranRuntime/module/ieee_exceptions.f90
similarity index 100%
rename from flang/module/ieee_exceptions.f90
rename to FortranRuntime/module/ieee_exceptions.f90
diff --git a/flang/module/ieee_features.f90 b/FortranRuntime/module/ieee_features.f90
similarity index 100%
rename from flang/module/ieee_features.f90
rename to FortranRuntime/module/ieee_features.f90
diff --git a/flang/module/iso_c_binding.f90 b/FortranRuntime/module/iso_c_binding.f90
similarity index 100%
rename from flang/module/iso_c_binding.f90
rename to FortranRuntime/module/iso_c_binding.f90
diff --git a/flang/module/iso_fortran_env.f90 b/FortranRuntime/module/iso_fortran_env.f90
similarity index 100%
rename from flang/module/iso_fortran_env.f90
rename to FortranRuntime/module/iso_fortran_env.f90
diff --git a/flang/module/mma.f90 b/FortranRuntime/module/mma.f90
similarity index 98%
rename from flang/module/mma.f90
rename to FortranRuntime/module/mma.f90
index 4c41822e000a3d..14aab69035a334 100644
--- a/flang/module/mma.f90
+++ b/FortranRuntime/module/mma.f90
@@ -55,9 +55,18 @@ pure __vector_pair function func_vpi0vp(arg1, arg2); \
!dir$ ignore_tkr(r) arg2; \
end function;
- FUNC_VPI0VI(1) FUNC_VPI0VI(2) FUNC_VPI0VI(4) FUNC_VPI0VI(8)
- FUNC_VPI0VU(1) FUNC_VPI0VU(2) FUNC_VPI0VU(4) FUNC_VPI0VU(8)
- FUNC_VPI0VR(4) FUNC_VPI0VR(8)
+! FIXME: Potential Flang bug: combining multiple of those on a single line breaks after preprocessing as an explicit step as done by CMake
+! Line counting is also wrong
+ FUNC_VPI0VI(1)
+ FUNC_VPI0VI(2)
+ FUNC_VPI0VI(4)
+ FUNC_VPI0VI(8)
+ FUNC_VPI0VU(1)
+ FUNC_VPI0VU(2)
+ FUNC_VPI0VU(4)
+ FUNC_VPI0VU(8)
+ FUNC_VPI0VR(4)
+ FUNC_VPI0VR(8)
FUNC_VPI0VP
#undef FUNC_VPI0VP
@@ -144,14 +153,26 @@ elemental subroutine sub_vpvr##VKIND##vr##VKIND(pair, arg1, arg2); \
vector(real(VKIND)), intent(in) :: arg1, arg2; \
end subroutine ;
- ELEM_SUB_VPVIVI(1) ELEM_SUB_VPVIVI(2)
- ELEM_SUB_VPVIVI(4) ELEM_SUB_VPVIVI(8)
- ELEM_SUB_VPVUVU(1) ELEM_SUB_VPVUVU(2)
- ELEM_SUB_VPVUVU(4) ELEM_SUB_VPVUVU(8)
- ELEM_SUB_VPVRVR(4) ELEM_SUB_VPVRVR(8)
- SUB_VPI0VI(1) SUB_VPI0VI(2) SUB_VPI0VI(4) SUB_VPI0VI(8)
- SUB_VPI0VU(1) SUB_VPI0VU(2) SUB_VPI0VU(4) SUB_VPI0VU(8)
- SUB_VPI0VR(4) SUB_VPI0VR(8)
+ ELEM_SUB_VPVIVI(1)
+ ELEM_SUB_VPVIVI(2)
+ ELEM_SUB_VPVIVI(4)
+ ELEM_SUB_VPVIVI(8)
+ ELEM_SUB_VPVUVU(1)
+ ELEM_SUB_VPVUVU(2)
+ ELEM_SUB_VPVUVU(4)
+ ELEM_SUB_VPVUVU(8)
+ ELEM_SUB_VPVRVR(4)
+ ELEM_SUB_VPVRVR(8)
+ SUB_VPI0VI(1)
+ SUB_VPI0VI(2)
+ SUB_VPI0VI(4)
+ SUB_VPI0VI(8)
+ SUB_VPI0VU(1)
+ SUB_VPI0VU(2)
+ SUB_VPI0VU(4)
+ SUB_VPI0VU(8)
+ SUB_VPI0VR(4)
+ SUB_VPI0VR(8)
#undef ELEM_SUB_VPVIVI
#undef ELEM_SUB_VPVUVU
diff --git a/FortranRuntime/test/CMakeLists.txt b/FortranRuntime/test/CMakeLists.txt
new file mode 100644
index 00000000000000..1f822859089f3d
--- /dev/null
+++ b/FortranRuntime/test/CMakeLists.txt
@@ -0,0 +1,70 @@
+#===-- 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
+)
+
+set(FLANG_TOOLS_DIR ${FLANG_BINARY_DIR}/bin)
+
+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 FortranRuntimeUnitTests)
+ 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 ()
+
+set(FORTRANRUNTIME_TEST_DEPENDS "")
+if (FORTRANRUNTIME_INCLUDE_TESTS)
+ if (TARGET FortranRuntimeUnitTests)
+ list(APPEND FORTRANRUNTIME_TEST_DEPENDS FortranRuntimeUnitTests)
+ endif()
+endif()
+
+add_custom_target(FortranRuntime-test-depends)
+set_target_properties(FortranRuntime-test-depends PROPERTIES FOLDER "Fortran Runtime/Meta")
+
+add_lit_testsuite(check-FortranRuntime "Running the Flang regression tests"
+ ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${FORTRANRUNTIME_TEST_DEPENDS}
+)
+set_target_properties(check-FortranRuntime PROPERTIES FOLDER "Fortran Runtime/Meta")
+
+
+add_lit_testsuites(FORTRANRUNTIME ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${FORTRANRUNTIME_TEST_DEPENDS})
+
+# To modify the default target triple for flang tests.
+if (DEFINED FLANG_TEST_TARGET_TRIPLE)
+ if (NOT DEFINED LLVM_TARGET_TRIPLE_ENV OR LLVM_TARGET_TRIPLE_ENV STREQUAL "")
+ message(FATAL_ERROR "LLVM_TARGET_TRIPLE_ENV must also be defined in order "
+ "to use FLANG_TEST_TARGET_TRIPLE.")
+ endif()
+endif()
diff --git a/FortranRuntime/test/NonGtestUnit/lit.cfg.py b/FortranRuntime/test/NonGtestUnit/lit.cfg.py
new file mode 100644
index 00000000000000..cd78ca76de503f
--- /dev/null
+++ b/FortranRuntime/test/NonGtestUnit/lit.cfg.py
@@ -0,0 +1,21 @@
+# -*- Python -*-
+
+import os
+
+import lit.formats
+
+# name: The name of this test suite.
+config.name = "FortranRuntime-OldUnit"
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = [".test"]
+
+# test_source_root: The root path where unit test binaries are located.
+config.test_source_root = os.path.join(config.fortranruntime_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.fortranruntime_binary_test_dir
+
+# testFormat: The test format to use to interpret tests.
+config.test_format = lit.formats.ExecutableTest()
diff --git a/FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in b/FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in
new file mode 100644
index 00000000000000..3d1780a5d600a9
--- /dev/null
+++ b/FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in
@@ -0,0 +1,13 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import os
+
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.fortranruntime_binary_dir = "@FORTRANRUNTIME_BINARY_DIR@"
+config.fortranruntime_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, "@FORTRANRUNTIME_SOURCE_DIR@/test/NonGtestUnit/lit.cfg.py")
diff --git a/flang/test/Runtime/no-cpp-dep.c b/FortranRuntime/test/Runtime/no-cpp-dep.c
similarity index 75%
rename from flang/test/Runtime/no-cpp-dep.c
rename to FortranRuntime/test/Runtime/no-cpp-dep.c
index 606a5d189f7199..f6760b75a148ff 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/FortranRuntime/test/Runtime/no-cpp-dep.c
@@ -3,16 +3,18 @@ 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
+UNSUPPORTED: system-windows
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
*/
#include "flang/Runtime/entry-names.h"
#include <stdint.h>
+#include <stdbool.h>
+#include <stddef.h>
/*
Manually add declarations for the runtime functions that we want to make sure
@@ -29,7 +31,9 @@ void RTNAME(ProgramStart)(
int32_t RTNAME(ArgumentCount)();
int32_t RTNAME(GetCommandArgument)(int32_t, const struct Descriptor *,
const struct Descriptor *, const struct Descriptor *);
-int32_t RTNAME(GetEnvVariable)();
+int32_t RTNAME(GetEnvVariable)(const struct Descriptor *,
+ const struct Descriptor *, const struct Descriptor *, bool ,
+ const struct Descriptor *, const char *, int );
int64_t RTNAME(SystemClockCount)(int kind);
int main() {
@@ -37,7 +41,7 @@ int main() {
RTNAME(ProgramStart)(0, 0, 0, 0);
int32_t c = RTNAME(ArgumentCount)();
int32_t v = RTNAME(GetCommandArgument)(0, 0, 0, 0);
- int32_t e = RTNAME(GetEnvVariable)("FOO", 0, 0);
+ int32_t e = RTNAME(GetEnvVariable)(NULL, NULL, NULL, false, NULL, "FOO", 0);
int64_t t = RTNAME(SystemClockCount)(8);
return x + c + v + e;
}
diff --git a/FortranRuntime/test/Unit/lit.cfg.py b/FortranRuntime/test/Unit/lit.cfg.py
new file mode 100644
index 00000000000000..888fb3981916c8
--- /dev/null
+++ b/FortranRuntime/test/Unit/lit.cfg.py
@@ -0,0 +1,21 @@
+# -*- Python -*-
+
+import os
+
+import lit.formats
+
+# name: The name of this test suite.
+config.name = "FortranRuntime-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.fortranruntime_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.fortranruntime_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/FortranRuntime/test/Unit/lit.site.cfg.py.in b/FortranRuntime/test/Unit/lit.site.cfg.py.in
new file mode 100644
index 00000000000000..fa993aa897faca
--- /dev/null
+++ b/FortranRuntime/test/Unit/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.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.fortranruntime_binary_dir = "@FORTRANRUNTIME_BINARY_DIR@"
+config.fortranruntime_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, "@FORTRANRUNTIME_SOURCE_DIR@/test/Unit/lit.cfg.py")
diff --git a/FortranRuntime/test/lit.cfg.py b/FortranRuntime/test/lit.cfg.py
new file mode 100644
index 00000000000000..dd5124b8de4095
--- /dev/null
+++ b/FortranRuntime/test/lit.cfg.py
@@ -0,0 +1,78 @@
+# -*- Python -*-
+
+import lit.util
+
+from lit.llvm import llvm_config
+from lit.llvm.subst import ToolSubst
+
+# Configuration file for the 'lit' test runner.
+
+# name: The name of this test suite.
+config.name = "FortranRuntime"
+
+# 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.fortranruntime_binary_test_dir
+
+# On MacOS, -isysroot is needed to build binaries.
+isysroot_flag = []
+if config.osx_sysroot:
+ isysroot_flag = ["-isysroot", config.osx_sysroot]
+
+# 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.
+libruntime = os.path.join(config.fortranruntime_build_lib_dir, "libFortranRuntime.a")
+include = os.path.join(config.fortranruntime_source_dir, "include")
+tools = []
+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"))
+
+llvm_config.add_tool_substitutions(tools)
+
diff --git a/FortranRuntime/test/lit.site.cfg.py.in b/FortranRuntime/test/lit.site.cfg.py.in
new file mode 100644
index 00000000000000..d860d297ebd7c3
--- /dev/null
+++ b/FortranRuntime/test/lit.site.cfg.py.in
@@ -0,0 +1,17 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import sys
+
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.build_lib_dir = "@FORTRANRUNTIME_BUILD_LIB_DIR@"
+config.fortranruntime_source_dir = "@FORTRANRUNTIME_SOURCE_DIR@"
+config.fortranruntime_binary_test_dir = os.path.dirname(__file__)
+config.fortranruntime_build_lib_dir = "@FORTRANRUNTIME_BUILD_LIB_DIR@"
+config.cc = "@CMAKE_C_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, "@FORTRANRUNTIME_SOURCE_DIR@/test/lit.cfg.py")
diff --git a/FortranRuntime/unittests/CMakeLists.txt b/FortranRuntime/unittests/CMakeLists.txt
new file mode 100644
index 00000000000000..d1aed058aad142
--- /dev/null
+++ b/FortranRuntime/unittests/CMakeLists.txt
@@ -0,0 +1,62 @@
+#===-- 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
+#
+#===------------------------------------------------------------------------===#
+
+function (build_gtest)
+ include_directories("${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}")
+ set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
+ add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
+endfunction ()
+
+# Add GTest if not already present
+if (NOT TARGET llvm_gtest)
+ build_gtest()
+endif ()
+
+# Target that depends on all unittests
+add_custom_target(FortranRuntimeUnitTests)
+set_target_properties(FortranRuntimeUnitTests PROPERTIES FOLDER "Fortran Runtime/Tests")
+
+function(add_fortranruntime_unittest test_dirname)
+ cmake_parse_arguments(ARG
+ ""
+ ""
+ "LINK_LIBS"
+ ${ARGN})
+
+ add_unittest(FortranRuntimeUnitTests ${test_dirname} ${ARG_UNPARSED_ARGUMENTS})
+ target_include_directories(${test_dirname} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+ target_link_libraries(${test_dirname} PRIVATE ${ARG_LINK_LIBS})
+endfunction()
+
+function(add_fortranruntime_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} ${ARG_UNPARSED_ARGUMENTS})
+ target_link_libraries(${test_name}${suffix} PRIVATE NonGTestTesting ${ARG_LINK_LIBS})
+ target_include_directories(${test_name}${suffix} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+ set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Fortran Runtime/Tests/Unit")
+
+ if(NOT ARG_SLOW_TEST)
+ add_dependencies(FortranRuntimeUnitTests ${test_name}${suffix})
+ endif()
+endfunction()
+
+add_subdirectory(Common)
+add_subdirectory(Decimal)
+add_subdirectory(Evaluate)
+add_subdirectory(Runtime)
diff --git a/FortranRuntime/unittests/Common/CMakeLists.txt b/FortranRuntime/unittests/Common/CMakeLists.txt
new file mode 100644
index 00000000000000..f107036f19ed8d
--- /dev/null
+++ b/FortranRuntime/unittests/Common/CMakeLists.txt
@@ -0,0 +1,13 @@
+#===-- unittests/Common/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_fortranruntime_unittest(FlangCommonTests
+ FastIntSetTest.cpp
+ LINK_LIBS
+ FortranRuntime.static
+)
diff --git a/flang/unittests/Common/FastIntSetTest.cpp b/FortranRuntime/unittests/Common/FastIntSetTest.cpp
similarity index 97%
rename from flang/unittests/Common/FastIntSetTest.cpp
rename to FortranRuntime/unittests/Common/FastIntSetTest.cpp
index bd1b953fa16631..f19359f4097ab8 100644
--- a/flang/unittests/Common/FastIntSetTest.cpp
+++ b/FortranRuntime/unittests/Common/FastIntSetTest.cpp
@@ -1,4 +1,4 @@
-//===-- flang/unittests/Common/FastIntSetTest.cpp ---------------*- C++ -*-===//
+//===-- unittests/Common/FastIntSetTest.cpp ---------------------*- 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/FortranRuntime/unittests/Decimal/CMakeLists.txt b/FortranRuntime/unittests/Decimal/CMakeLists.txt
new file mode 100644
index 00000000000000..3d96da45c94148
--- /dev/null
+++ b/FortranRuntime/unittests/Decimal/CMakeLists.txt
@@ -0,0 +1,20 @@
+#===-- unittests/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_fortranruntime_nongtest_unittest(quick-sanity-test
+quick-sanity-test.cpp
+LINK_LIBS
+ FortranRuntime.static
+)
+
+# This test is not run by default as it takes a long time to execute.
+add_fortranruntime_nongtest_unittest(thorough-test SLOW_TEST
+thorough-test.cpp
+LINK_LIBS
+ FortranRuntime.static
+)
diff --git a/flang/unittests/Decimal/quick-sanity-test.cpp b/FortranRuntime/unittests/Decimal/quick-sanity-test.cpp
similarity index 91%
rename from flang/unittests/Decimal/quick-sanity-test.cpp
rename to FortranRuntime/unittests/Decimal/quick-sanity-test.cpp
index dafb075307ab6a..0e8ff0ce48b3c6 100644
--- a/flang/unittests/Decimal/quick-sanity-test.cpp
+++ b/FortranRuntime/unittests/Decimal/quick-sanity-test.cpp
@@ -1,4 +1,12 @@
-#include "flang/Decimal/decimal.h"
+//===-- unittests/Decimal/quick-sanity-test.cpp -----------------*- 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/decimal.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
#include <cstdio>
diff --git a/flang/unittests/Decimal/thorough-test.cpp b/FortranRuntime/unittests/Decimal/thorough-test.cpp
similarity index 85%
rename from flang/unittests/Decimal/thorough-test.cpp
rename to FortranRuntime/unittests/Decimal/thorough-test.cpp
index 46951f33eb8fee..0648b61d7c1cda 100644
--- a/flang/unittests/Decimal/thorough-test.cpp
+++ b/FortranRuntime/unittests/Decimal/thorough-test.cpp
@@ -1,4 +1,12 @@
-#include "flang/Decimal/decimal.h"
+//===-- unittests/Decimal/thorough-test.cpp ---------------------*- 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/decimal.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
#include <cstdio>
diff --git a/FortranRuntime/unittests/Evaluate/CMakeLists.txt b/FortranRuntime/unittests/Evaluate/CMakeLists.txt
new file mode 100644
index 00000000000000..e6501f13a74e6b
--- /dev/null
+++ b/FortranRuntime/unittests/Evaluate/CMakeLists.txt
@@ -0,0 +1,19 @@
+#===-- 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_fortranruntime_nongtest_unittest(reshape
+reshape.cpp
+LINK_LIBS
+ FortranRuntime.static
+)
+
+add_fortranruntime_nongtest_unittest(ISO-Fortran-binding
+ISO-Fortran-binding.cpp
+LINK_LIBS
+ FortranRuntime.static
+)
diff --git a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
similarity index 98%
rename from flang/unittests/Evaluate/ISO-Fortran-binding.cpp
rename to FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
index 3c98363f900466..97d23ca90e5022 100644
--- a/flang/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -1,5 +1,13 @@
-#include "testing.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
+//===-- 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/Testing/testing.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/Evaluate/reshape.cpp b/FortranRuntime/unittests/Evaluate/reshape.cpp
similarity index 88%
rename from flang/unittests/Evaluate/reshape.cpp
rename to FortranRuntime/unittests/Evaluate/reshape.cpp
index 5d138cd3d88d98..82caebe081fcd2 100644
--- a/flang/unittests/Evaluate/reshape.cpp
+++ b/FortranRuntime/unittests/Evaluate/reshape.cpp
@@ -1,4 +1,12 @@
-#include "testing.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/Testing/testing.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/transformational.h"
#include <cinttypes>
diff --git a/flang/unittests/Runtime/AccessTest.cpp b/FortranRuntime/unittests/Runtime/AccessTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/AccessTest.cpp
rename to FortranRuntime/unittests/Runtime/AccessTest.cpp
index 66f19f78c7cfb6..e72386cc9ac247 100644
--- a/flang/unittests/Runtime/AccessTest.cpp
+++ b/FortranRuntime/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/FortranRuntime/unittests/Runtime/Allocatable.cpp
similarity index 98%
rename from flang/unittests/Runtime/Allocatable.cpp
rename to FortranRuntime/unittests/Runtime/Allocatable.cpp
index f15f26bfd9c575..8e10dc408ceae8 100644
--- a/flang/unittests/Runtime/Allocatable.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/ArrayConstructor.cpp b/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
similarity index 99%
rename from flang/unittests/Runtime/ArrayConstructor.cpp
rename to FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
index 9d78da79623613..8c7fce3e4fb5f7 100644
--- a/flang/unittests/Runtime/ArrayConstructor.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/BufferTest.cpp b/FortranRuntime/unittests/Runtime/BufferTest.cpp
similarity index 97%
rename from flang/unittests/Runtime/BufferTest.cpp
rename to FortranRuntime/unittests/Runtime/BufferTest.cpp
index 0632324b25d22e..9a7dd86d0c1dc6 100644
--- a/flang/unittests/Runtime/BufferTest.cpp
+++ b/FortranRuntime/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 "../../lib/Runtime/buffer.h"
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
#include <algorithm>
diff --git a/flang/unittests/Runtime/CMakeLists.txt b/FortranRuntime/unittests/Runtime/CMakeLists.txt
similarity index 54%
rename from flang/unittests/Runtime/CMakeLists.txt
rename to FortranRuntime/unittests/Runtime/CMakeLists.txt
index 2c3f8c1a9e9ac8..1e966987c272a0 100644
--- a/flang/unittests/Runtime/CMakeLists.txt
+++ b/FortranRuntime/unittests/Runtime/CMakeLists.txt
@@ -1,4 +1,12 @@
-add_flang_unittest(FlangRuntimeTests
+#===-- 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_fortranruntime_unittest(FlangRuntimeTests
AccessTest.cpp
Allocatable.cpp
ArrayConstructor.cpp
@@ -29,11 +37,6 @@ add_flang_unittest(FlangRuntimeTests
Time.cpp
TemporaryStack.cpp
Transformational.cpp
+LINK_LIBS
+ FortranRuntime.static
)
-
-target_link_libraries(FlangRuntimeTests
- PRIVATE
- FortranRuntime
-)
-
-add_subdirectory(CUDA)
diff --git a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
similarity index 95%
rename from flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
rename to FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
index b51ff0ac006cc6..5bafb484236340 100644
--- a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/FortranRuntime/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.
@@ -8,7 +8,7 @@
#include "gtest/gtest.h"
#include "../../../runtime/terminator.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
diff --git a/flang/unittests/Runtime/CharacterTest.cpp b/FortranRuntime/unittests/Runtime/CharacterTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/CharacterTest.cpp
rename to FortranRuntime/unittests/Runtime/CharacterTest.cpp
index e54fd8a5075f64..710c1ca0eee817 100644
--- a/flang/unittests/Runtime/CharacterTest.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/CommandTest.cpp b/FortranRuntime/unittests/Runtime/CommandTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/CommandTest.cpp
rename to FortranRuntime/unittests/Runtime/CommandTest.cpp
index b0c43ba01d8f33..03a31ceab8030b 100644
--- a/flang/unittests/Runtime/CommandTest.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/Complex.cpp b/FortranRuntime/unittests/Runtime/Complex.cpp
similarity index 98%
rename from flang/unittests/Runtime/Complex.cpp
rename to FortranRuntime/unittests/Runtime/Complex.cpp
index 46f3ad2f2712b2..daa4b5c7960842 100644
--- a/flang/unittests/Runtime/Complex.cpp
+++ b/FortranRuntime/unittests/Runtime/Complex.cpp
@@ -1,4 +1,4 @@
-//===-- 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.
@@ -13,7 +13,7 @@
#pragma clang diagnostic ignored "-Wc99-extensions"
#endif
-#include "flang/Common/Fortran.h"
+#include "flang/Common/Fortran-consts.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/entry-names.h"
diff --git a/flang/unittests/Runtime/CrashHandlerFixture.cpp b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.cpp
similarity index 92%
rename from flang/unittests/Runtime/CrashHandlerFixture.cpp
rename to FortranRuntime/unittests/Runtime/CrashHandlerFixture.cpp
index 811603337e6608..5e0b746c7e974a 100644
--- a/flang/unittests/Runtime/CrashHandlerFixture.cpp
+++ b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.cpp
@@ -1,4 +1,4 @@
-//===-- 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.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "../../runtime/terminator.h"
+#include "../../lib/Runtime/terminator.h"
#include <cstdarg>
#include <cstdlib>
diff --git a/flang/unittests/Runtime/CrashHandlerFixture.h b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
similarity index 91%
rename from flang/unittests/Runtime/CrashHandlerFixture.h
rename to FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
index fe0ee0da5204e4..af6d8e4cc7d525 100644
--- a/flang/unittests/Runtime/CrashHandlerFixture.h
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/Derived.cpp b/FortranRuntime/unittests/Runtime/Derived.cpp
similarity index 96%
rename from flang/unittests/Runtime/Derived.cpp
rename to FortranRuntime/unittests/Runtime/Derived.cpp
index 019d5e8309e4a0..8d5471e3e0bcf3 100644
--- a/flang/unittests/Runtime/Derived.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/ExternalIOTest.cpp b/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/ExternalIOTest.cpp
rename to FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
index 13327964e12a48..23c1e9992c101e 100644
--- a/flang/unittests/Runtime/ExternalIOTest.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/Format.cpp b/FortranRuntime/unittests/Runtime/Format.cpp
similarity index 96%
rename from flang/unittests/Runtime/Format.cpp
rename to FortranRuntime/unittests/Runtime/Format.cpp
index 01803c628de26a..f1447608917f2d 100644
--- a/flang/unittests/Runtime/Format.cpp
+++ b/FortranRuntime/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 "../../lib/Runtime/connection.h"
+#include "../../lib/Runtime/format-implementation.h"
+#include "../../lib/Runtime/io-error.h"
#include <optional>
#include <string>
#include <tuple>
diff --git a/flang/unittests/Runtime/Inquiry.cpp b/FortranRuntime/unittests/Runtime/Inquiry.cpp
similarity index 98%
rename from flang/unittests/Runtime/Inquiry.cpp
rename to FortranRuntime/unittests/Runtime/Inquiry.cpp
index 3b523e992a3179..39303b7c809002 100644
--- a/flang/unittests/Runtime/Inquiry.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/ListInputTest.cpp b/FortranRuntime/unittests/Runtime/ListInputTest.cpp
similarity index 98%
rename from flang/unittests/Runtime/ListInputTest.cpp
rename to FortranRuntime/unittests/Runtime/ListInputTest.cpp
index a4eba5283add68..472838c25841c9 100644
--- a/flang/unittests/Runtime/ListInputTest.cpp
+++ b/FortranRuntime/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,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "../../runtime/io-error.h"
+#include "../../lib/Runtime/io-error.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"
diff --git a/flang/unittests/Runtime/LogicalFormatTest.cpp b/FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
similarity index 96%
rename from flang/unittests/Runtime/LogicalFormatTest.cpp
rename to FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
index a2c19d1e1ca948..928fddec50c874 100644
--- a/flang/unittests/Runtime/LogicalFormatTest.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/Matmul.cpp b/FortranRuntime/unittests/Runtime/Matmul.cpp
similarity index 99%
rename from flang/unittests/Runtime/Matmul.cpp
rename to FortranRuntime/unittests/Runtime/Matmul.cpp
index c3fed9b972df2a..a37b618d3ab11a 100644
--- a/flang/unittests/Runtime/Matmul.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/MatmulTranspose.cpp b/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
similarity index 99%
rename from flang/unittests/Runtime/MatmulTranspose.cpp
rename to FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
index c582e945dc7c93..3483d1896e8bf6 100644
--- a/flang/unittests/Runtime/MatmulTranspose.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/MiscIntrinsic.cpp b/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
similarity index 98%
rename from flang/unittests/Runtime/MiscIntrinsic.cpp
rename to FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
index 7e19ed250bdc05..5672440c0e1b95 100644
--- a/flang/unittests/Runtime/MiscIntrinsic.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/Namelist.cpp b/FortranRuntime/unittests/Runtime/Namelist.cpp
similarity index 99%
rename from flang/unittests/Runtime/Namelist.cpp
rename to FortranRuntime/unittests/Runtime/Namelist.cpp
index 9037fa15a97cb3..729f9ffa5c7c10 100644
--- a/flang/unittests/Runtime/Namelist.cpp
+++ b/FortranRuntime/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,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "../../runtime/namelist.h"
+#include "../../lib/Runtime/namelist.h"
#include "CrashHandlerFixture.h"
#include "tools.h"
#include "flang/Runtime/descriptor.h"
diff --git a/flang/unittests/Runtime/Numeric.cpp b/FortranRuntime/unittests/Runtime/Numeric.cpp
similarity index 99%
rename from flang/unittests/Runtime/Numeric.cpp
rename to FortranRuntime/unittests/Runtime/Numeric.cpp
index 799756aab3839a..d15919b972bca7 100644
--- a/flang/unittests/Runtime/Numeric.cpp
+++ b/FortranRuntime/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/FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
similarity index 99%
rename from flang/unittests/Runtime/NumericalFormatTest.cpp
rename to FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
index f0055153203508..8a1dd6de1449b9 100644
--- a/flang/unittests/Runtime/NumericalFormatTest.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/Pointer.cpp b/FortranRuntime/unittests/Runtime/Pointer.cpp
similarity index 98%
rename from flang/unittests/Runtime/Pointer.cpp
rename to FortranRuntime/unittests/Runtime/Pointer.cpp
index 4ce13ebc50a565..aa8545cdf951d1 100644
--- a/flang/unittests/Runtime/Pointer.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/Ragged.cpp b/FortranRuntime/unittests/Runtime/Ragged.cpp
similarity index 94%
rename from flang/unittests/Runtime/Ragged.cpp
rename to FortranRuntime/unittests/Runtime/Ragged.cpp
index 5049bc83405f17..feadd032f59bd4 100644
--- a/flang/unittests/Runtime/Ragged.cpp
+++ b/FortranRuntime/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/FortranRuntime/unittests/Runtime/Random.cpp
similarity index 97%
rename from flang/unittests/Runtime/Random.cpp
rename to FortranRuntime/unittests/Runtime/Random.cpp
index cb739b94514290..c2300a478832ab 100644
--- a/flang/unittests/Runtime/Random.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/Reduction.cpp b/FortranRuntime/unittests/Runtime/Reduction.cpp
similarity index 99%
rename from flang/unittests/Runtime/Reduction.cpp
rename to FortranRuntime/unittests/Runtime/Reduction.cpp
index 25eb5fd760eadb..e8b5ac878871fd 100644
--- a/flang/unittests/Runtime/Reduction.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/RuntimeCrashTest.cpp b/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
similarity index 98%
rename from flang/unittests/Runtime/RuntimeCrashTest.cpp
rename to FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
index a649051fdca0c5..7ce1ee796d739b 100644
--- a/flang/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/FortranRuntime/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 "../../lib/Runtime/terminator.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/transformational.h"
#include <gtest/gtest.h>
diff --git a/flang/unittests/Runtime/Stop.cpp b/FortranRuntime/unittests/Runtime/Stop.cpp
similarity index 96%
rename from flang/unittests/Runtime/Stop.cpp
rename to FortranRuntime/unittests/Runtime/Stop.cpp
index b13602eaee5ea6..c12ec097068438 100644
--- a/flang/unittests/Runtime/Stop.cpp
+++ b/FortranRuntime/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.
@@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/stop.h"
#include "CrashHandlerFixture.h"
-#include "../../runtime/environment.h"
+#include "../../lib/Runtime/environment.h"
#include <cstdlib>
#include <gtest/gtest.h>
diff --git a/flang/unittests/Runtime/Support.cpp b/FortranRuntime/unittests/Runtime/Support.cpp
similarity index 97%
rename from flang/unittests/Runtime/Support.cpp
rename to FortranRuntime/unittests/Runtime/Support.cpp
index 9d1a417fdbf426..b7aa39ef5523ba 100644
--- a/flang/unittests/Runtime/Support.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/TemporaryStack.cpp b/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
similarity index 98%
rename from flang/unittests/Runtime/TemporaryStack.cpp
rename to FortranRuntime/unittests/Runtime/TemporaryStack.cpp
index 0a9344969ca6ba..495c693b0493ef 100644
--- a/flang/unittests/Runtime/TemporaryStack.cpp
+++ b/FortranRuntime/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.
@@ -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"
diff --git a/flang/unittests/Runtime/Time.cpp b/FortranRuntime/unittests/Runtime/Time.cpp
similarity index 98%
rename from flang/unittests/Runtime/Time.cpp
rename to FortranRuntime/unittests/Runtime/Time.cpp
index 9309d7b1ceffa0..548c0834e34a36 100644
--- a/flang/unittests/Runtime/Time.cpp
+++ b/FortranRuntime/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/FortranRuntime/unittests/Runtime/Transformational.cpp
similarity index 99%
rename from flang/unittests/Runtime/Transformational.cpp
rename to FortranRuntime/unittests/Runtime/Transformational.cpp
index 5836e70c740f9a..2dcab5a2aa8974 100644
--- a/flang/unittests/Runtime/Transformational.cpp
+++ b/FortranRuntime/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.
diff --git a/flang/unittests/Runtime/tools.h b/FortranRuntime/unittests/Runtime/tools.h
similarity index 96%
rename from flang/unittests/Runtime/tools.h
rename to FortranRuntime/unittests/Runtime/tools.h
index 0347edace5c05c..a8e2096a90572e 100644
--- a/flang/unittests/Runtime/tools.h
+++ b/FortranRuntime/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.
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index f58b816a9709dd..5e4057116a97cb 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1291,7 +1291,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.
@@ -1308,7 +1308,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");
}
}
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 6ce79d27e98c48..3619a8f4b81f08 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -309,21 +309,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");
@@ -331,7 +328,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/CMakeLists.txt b/flang/CMakeLists.txt
index 971e5d5c93f231..00e570798bb412 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(FORTRANRUNTIME_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../FortranRuntime")
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed. \
@@ -34,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)
@@ -170,7 +160,6 @@ if (FLANG_STANDALONE_BUILD)
link_directories("${LLVM_LIBRARY_DIR}")
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
@@ -249,7 +238,6 @@ include_directories(SYSTEM ${CLANG_INCLUDE_DIR})
# tco tool and FIR lib output directories
if(FLANG_STANDALONE_BUILD)
- set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
endif()
# Always build tco tool
@@ -257,7 +245,8 @@ set(LLVM_BUILD_TOOLS ON)
include_directories(BEFORE
${FLANG_BINARY_DIR}/include
- ${FLANG_SOURCE_DIR}/include)
+ ${FLANG_SOURCE_DIR}/include
+ ${FORTRANRUNTIME_SOURCE_DIR}/include)
# Add Flang-centric modules to cmake path.
list(INSERT CMAKE_MODULE_PATH 0
@@ -335,12 +324,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)
@@ -462,14 +445,6 @@ if (FLANG_BUILD_TOOLS)
add_subdirectory(tools)
endif()
-option(FLANG_CUF_RUNTIME
- "Compile CUDA Fortran runtime sources" OFF)
-if (FLANG_CUF_RUNTIME)
- find_package(CUDAToolkit REQUIRED)
-endif()
-
-add_subdirectory(runtime)
-
if (LLVM_INCLUDE_EXAMPLES)
add_subdirectory(examples)
endif()
@@ -532,17 +507,3 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
)
endif()
-# Put ISO_Fortran_binding.h into the include files of the build area now
-# so that we can run tests before installing
-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)
-
-# And also install it into the install area
-get_clang_resource_dir(HEADER_INSTALL_DIR SUBDIR include)
-install(
- FILES include/flang/ISO_Fortran_binding.h
- DESTINATION ${HEADER_INSTALL_DIR} )
-
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index e1c11062125028..98611ee338e706 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -179,19 +179,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.
+`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/include/flang/Evaluate/call.h b/flang/include/flang/Evaluate/call.h
index 7531d8a81e808d..8137185da61442 100644
--- a/flang/include/flang/Evaluate/call.h
+++ b/flang/include/flang/Evaluate/call.h
@@ -13,9 +13,9 @@
#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/Support/Fortran.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/reference.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/attr.h"
#include <optional>
diff --git a/flang/include/flang/Evaluate/characteristics.h b/flang/include/flang/Evaluate/characteristics.h
index 11533a7259b055..8f1e6876d88d58 100644
--- a/flang/include/flang/Evaluate/characteristics.h
+++ b/flang/include/flang/Evaluate/characteristics.h
@@ -18,11 +18,11 @@
#include "shape.h"
#include "tools.h"
#include "type.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/symbol.h"
#include <optional>
diff --git a/flang/include/flang/Evaluate/common.h b/flang/include/flang/Evaluate/common.h
index d493e5fe044173..69f09a930dc604 100644
--- a/flang/include/flang/Evaluate/common.h
+++ b/flang/include/flang/Evaluate/common.h
@@ -9,15 +9,17 @@
#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/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
+#include "flang/Common/Fortran-consts.h"
#include "flang/Common/restorer.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
+#include "flang/Common/target-rounding.h"
#include <cinttypes>
#include <map>
#include <set>
@@ -33,6 +35,9 @@ class TargetCharacteristics;
using common::ConstantSubscript;
using common::RelationalOperator;
+using common::RoundingMode;
+using common::RealFlags;
+using common::RealFlag;
// Integers are always ordered; reals may not be.
ENUM_CLASS(Ordering, Less, Equal, Greater)
@@ -128,11 +133,6 @@ static constexpr bool Satisfies(RelationalOperator op, Relation relation) {
return false; // silence g++ warning
}
-// These are ordered like the bits in a common fenv.h header file.
-ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
- Inexact)
-using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;
-
template <typename A> struct ValueWithRealFlags {
A AccumulateFlags(RealFlags &f) {
f |= flags;
diff --git a/flang/include/flang/Evaluate/constant.h b/flang/include/flang/Evaluate/constant.h
index d9866a08889f35..a171b10026409c 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 2a40193e32306b..a582a2ea1a6989 100644
--- a/flang/include/flang/Evaluate/expression.h
+++ b/flang/include/flang/Evaluate/expression.h
@@ -21,10 +21,10 @@
#include "formatting.h"
#include "type.h"
#include "variable.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
-#include "flang/Common/template.h"
+#include "flang/Support/indirection.h"
+#include "flang/Support/template.h"
#include "flang/Parser/char-block.h"
#include <algorithm>
#include <list>
diff --git a/flang/include/flang/Evaluate/formatting.h b/flang/include/flang/Evaluate/formatting.h
index aa82f56107fdd3..ae9351139b1933 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 15afb772ae767b..17f555445f6f79 100644
--- a/flang/include/flang/Evaluate/intrinsics.h
+++ b/flang/include/flang/Evaluate/intrinsics.h
@@ -12,7 +12,7 @@
#include "call.h"
#include "characteristics.h"
#include "type.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
#include <memory>
diff --git a/flang/include/flang/Evaluate/shape.h b/flang/include/flang/Evaluate/shape.h
index e33044c0d34e56..f3eeea7984bba7 100644
--- a/flang/include/flang/Evaluate/shape.h
+++ b/flang/include/flang/Evaluate/shape.h
@@ -15,7 +15,7 @@
#include "expression.h"
#include "traverse.h"
#include "variable.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Evaluate/type.h"
#include <optional>
#include <variant>
diff --git a/flang/include/flang/Evaluate/target.h b/flang/include/flang/Evaluate/target.h
index d076fcbf083078..8f52b29bec6654 100644
--- a/flang/include/flang/Evaluate/target.h
+++ b/flang/include/flang/Evaluate/target.h
@@ -12,27 +12,16 @@
#ifndef FORTRAN_EVALUATE_TARGET_H_
#define FORTRAN_EVALUATE_TARGET_H_
-#include "flang/Common/Fortran.h"
+#include "flang/Support/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 <cstdint>
namespace Fortran::evaluate {
-// Floating-point rounding control
-struct Rounding {
- common::RoundingMode mode{common::RoundingMode::TiesToEven};
- // When set, emulate status flag behavior peculiar to x86
- // (viz., fail to set the Underflow flag when an inexact product of a
- // multiplication is rounded up to a normal number from a subnormal
- // in some rounding modes)
-#if __x86_64__ || __riscv || __loongarch__
- bool x86CompatibleBehavior{true};
-#else
- bool x86CompatibleBehavior{false};
-#endif
-};
+using common::Rounding;
ENUM_CLASS(IeeeFeature, Denormal, Divide, Flags, Halting, Inf, Io, NaN,
Rounding, Sqrt, Standard, Subnormal, UnderflowControl)
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index a0487e399d936c..29d19bff44c79c 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -11,8 +11,8 @@
#include "traverse.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/template.h"
-#include "flang/Common/unwrap.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
#include "flang/Evaluate/constant.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/shape.h"
diff --git a/flang/include/flang/Evaluate/traverse.h b/flang/include/flang/Evaluate/traverse.h
index 7f4a67d97e64e7..e04888f395c013 100644
--- a/flang/include/flang/Evaluate/traverse.h
+++ b/flang/include/flang/Evaluate/traverse.h
@@ -38,7 +38,7 @@
// expression of an ASSOCIATE (or related) construct entity.
#include "expression.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/type.h"
#include <set>
diff --git a/flang/include/flang/Evaluate/type.h b/flang/include/flang/Evaluate/type.h
index bd8887dbce4e82..b68a5790c810fd 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/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/real.h"
-#include "flang/Common/template.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 9565826dbfaea4..8d0da5b24277cd 100644
--- a/flang/include/flang/Evaluate/variable.h
+++ b/flang/include/flang/Evaluate/variable.h
@@ -21,8 +21,8 @@
#include "static-data.h"
#include "type.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
-#include "flang/Common/template.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
#include "flang/Parser/char-block.h"
#include <optional>
#include <variant>
diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h
index 82ca99672ec610..b69ffe83de1707 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_FRONTEND_FRONTENDOPTIONS_H
#define FORTRAN_FRONTEND_FRONTENDOPTIONS_H
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Lower/EnvironmentDefault.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/unparse.h"
diff --git a/flang/include/flang/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index daded9091780e2..56646c196a7de5 100644
--- a/flang/include/flang/Lower/AbstractConverter.h
+++ b/flang/include/flang/Lower/AbstractConverter.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_LOWER_ABSTRACTCONVERTER_H
#define FORTRAN_LOWER_ABSTRACTCONVERTER_H
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Lower/LoweringOptions.h"
#include "flang/Lower/PFTDefs.h"
#include "flang/Optimizer/Builder/BoxValue.h"
diff --git a/flang/include/flang/Lower/Bridge.h b/flang/include/flang/Lower/Bridge.h
index 4379ed512cdf0a..0c2c7abc324952 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_LOWER_BRIDGE_H
#define FORTRAN_LOWER_BRIDGE_H
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Lower/AbstractConverter.h"
#include "flang/Lower/EnvironmentDefault.h"
#include "flang/Lower/LoweringOptions.h"
diff --git a/flang/include/flang/Lower/CallInterface.h b/flang/include/flang/Lower/CallInterface.h
index 9a688330e8bd2d..df01eafe679d7d 100644
--- a/flang/include/flang/Lower/CallInterface.h
+++ b/flang/include/flang/Lower/CallInterface.h
@@ -27,7 +27,7 @@
#ifndef FORTRAN_LOWER_CALLINTERFACE_H
#define FORTRAN_LOWER_CALLINTERFACE_H
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
#include "flang/Evaluate/characteristics.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinOps.h"
diff --git a/flang/include/flang/Lower/ConvertType.h b/flang/include/flang/Lower/ConvertType.h
index 7a3f92649a4e4a..b889d2bb279de2 100644
--- a/flang/include/flang/Lower/ConvertType.h
+++ b/flang/include/flang/Lower/ConvertType.h
@@ -21,7 +21,7 @@
#ifndef FORTRAN_LOWER_CONVERT_TYPE_H
#define FORTRAN_LOWER_CONVERT_TYPE_H
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Evaluate/type.h"
#include "mlir/IR/BuiltinTypes.h"
diff --git a/flang/include/flang/Lower/LoweringOptions.h b/flang/include/flang/Lower/LoweringOptions.h
index 8105ccd7ef6b15..171510393b8168 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 7f1b93c564b4c4..7ee61e630581fe 100644
--- a/flang/include/flang/Lower/PFTBuilder.h
+++ b/flang/include/flang/Lower/PFTBuilder.h
@@ -17,8 +17,8 @@
#ifndef FORTRAN_LOWER_PFTBUILDER_H
#define FORTRAN_LOWER_PFTBUILDER_H
-#include "flang/Common/reference.h"
-#include "flang/Common/template.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
#include "flang/Lower/HostAssociations.h"
#include "flang/Lower/PFTDefs.h"
#include "flang/Parser/parse-tree.h"
diff --git a/flang/include/flang/Lower/Support/Utils.h b/flang/include/flang/Lower/Support/Utils.h
index 1cc74521e22d88..a09cfb16f7805a 100644
--- a/flang/include/flang/Lower/Support/Utils.h
+++ b/flang/include/flang/Lower/Support/Utils.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_LOWER_SUPPORT_UTILS_H
#define FORTRAN_LOWER_SUPPORT_UTILS_H
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/tools.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
diff --git a/flang/include/flang/Lower/SymbolMap.h b/flang/include/flang/Lower/SymbolMap.h
index c03f9afd40801c..7bba02e41a3bdf 100644
--- a/flang/include/flang/Lower/SymbolMap.h
+++ b/flang/include/flang/Lower/SymbolMap.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_LOWER_SYMBOLMAP_H
#define FORTRAN_LOWER_SYMBOLMAP_H
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Dialect/FortranVariableInterface.h"
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index f7151f26f09cb3..90279417b5c939 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -16,7 +16,7 @@
#ifndef FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
#define FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
-#include "flang/Common/MathOptionsBase.h"
+#include "flang/Support/MathOptionsBase.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
#include "flang/Optimizer/Dialect/FIRType.h"
diff --git a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
index 78bb82b17d4050..3fc4201bd16c6c 100644
--- a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
@@ -397,6 +397,7 @@ struct IntrinsicLibrary {
fir::ExtendedValue genUbound(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
fir::ExtendedValue genUnpack(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
fir::ExtendedValue genVerify(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
+ fir::ExtendedValue genNumericStorageSize(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
/// Implement all conversion functions like DBLE, the first argument is
/// the value to convert. There may be an additional KIND arguments that
diff --git a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
index a7c4c075d818ee..26cf34188eb568 100644
--- a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
@@ -9,7 +9,7 @@
#ifndef FORTRAN_LOWER_PPCINTRINSICCALL_H
#define FORTRAN_LOWER_PPCINTRINSICCALL_H
-#include "flang/Common/static-multimap-view.h"
+#include "flang/Support/static-multimap-view.h"
#include "flang/Optimizer/Builder/IntrinsicCall.h"
#include "mlir/Dialect/Math/IR/Math.h"
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index a103861f1510b8..104e363e689857 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -17,7 +17,7 @@
#ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H
#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/uint128.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
diff --git a/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h b/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
index ff0cf29e8073e6..31d1416846d0c9 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.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 f32e39b543e3f7..85615a4d69157d 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 308c82118d5020..ec21d672287e62 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 02bec4164fca08..631322b34c49e5 100644
--- a/flang/include/flang/Optimizer/Support/Utils.h
+++ b/flang/include/flang/Optimizer/Support/Utils.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
#define FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"
diff --git a/flang/include/flang/Parser/char-block.h b/flang/include/flang/Parser/char-block.h
index 38f4f7b82e1eae..4541b31e566f95 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 37c3370b48a085..f98ac17b6ecba7 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/Support/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.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 668559aeec9478..70746bf551f2d7 100644
--- a/flang/include/flang/Parser/message.h
+++ b/flang/include/flang/Parser/message.h
@@ -16,7 +16,7 @@
#include "char-set.h"
#include "provenance.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference-counted.h"
+#include "flang/Support/reference-counted.h"
#include "flang/Common/restorer.h"
#include <cstddef>
#include <cstring>
diff --git a/flang/include/flang/Parser/parse-state.h b/flang/include/flang/Parser/parse-state.h
index 76cbb3470dc08d..20d339aeeccccf 100644
--- a/flang/include/flang/Parser/parse-state.h
+++ b/flang/include/flang/Parser/parse-state.h
@@ -16,7 +16,7 @@
// and recovery during parsing!
#include "user-state.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Common/idioms.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/message.h"
diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h
index 548fcc81984b2a..a6d19dd6435966 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/Support/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "llvm/Frontend/OpenACC/ACC.h.inc"
#include "llvm/Frontend/OpenMP/OMPConstants.h"
#include <cinttypes>
diff --git a/flang/include/flang/Parser/parsing.h b/flang/include/flang/Parser/parsing.h
index 4d329c189cb80e..b0de98737f536e 100644
--- a/flang/include/flang/Parser/parsing.h
+++ b/flang/include/flang/Parser/parsing.h
@@ -14,7 +14,7 @@
#include "message.h"
#include "parse-tree.h"
#include "provenance.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Parser/preprocessor.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
diff --git a/flang/include/flang/Parser/provenance.h b/flang/include/flang/Parser/provenance.h
index a9224b727fd054..7f29fb272c9421 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 a6efdf9546c7f3..a67fd66045a3de 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 61745a833c715c..fff651208e0e52 100644
--- a/flang/include/flang/Parser/user-state.h
+++ b/flang/include/flang/Parser/user-state.h
@@ -14,7 +14,7 @@
// parse tree construction so as to avoid any need for representing
// state in static data.
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Common/idioms.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/parse-tree.h"
diff --git a/flang/include/flang/Semantics/expression.h b/flang/include/flang/Semantics/expression.h
index c90c8c4b3cc70f..77e26ffb834dd9 100644
--- a/flang/include/flang/Semantics/expression.h
+++ b/flang/include/flang/Semantics/expression.h
@@ -10,8 +10,8 @@
#define FORTRAN_SEMANTICS_EXPRESSION_H_
#include "semantics.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/characteristics.h"
diff --git a/flang/include/flang/Semantics/runtime-type-info.h b/flang/include/flang/Semantics/runtime-type-info.h
index e90d3ae8baf1eb..3f9f776797d782 100644
--- a/flang/include/flang/Semantics/runtime-type-info.h
+++ b/flang/include/flang/Semantics/runtime-type-info.h
@@ -14,7 +14,7 @@
#ifndef FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
#define FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
#include "flang/Semantics/symbol.h"
#include <map>
#include <set>
diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index e73a507e9b3f5b..8b416dcffb5245 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -11,9 +11,9 @@
#include "attr.h"
#include "symbol.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
#include "flang/Parser/message.h"
#include "flang/Parser/provenance.h"
#include <list>
diff --git a/flang/include/flang/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h
index e73f9d2e85d589..899d4afa016bff 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -11,7 +11,7 @@
#include "scope.h"
#include "symbol.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index b4db6689a94271..29587be2c7d77d 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -10,9 +10,9 @@
#define FORTRAN_SEMANTICS_SYMBOL_H_
#include "type.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/enum-set.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
#include "flang/Common/visit.h"
#include "flang/Semantics/module-dependences.h"
#include "llvm/ADT/DenseMapInfo.h"
diff --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index 15c02ecc0058cc..9be7ebff9b5bb6 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -12,7 +12,7 @@
// Simple predicates and look-up functions that are best defined
// canonically for use in semantic checking.
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/shape.h"
diff --git a/flang/include/flang/Semantics/type.h b/flang/include/flang/Semantics/type.h
index e2d47d38f927f7..fd31bc805e2de6 100644
--- a/flang/include/flang/Semantics/type.h
+++ b/flang/include/flang/Semantics/type.h
@@ -9,7 +9,7 @@
#ifndef FORTRAN_SEMANTICS_TYPE_H_
#define FORTRAN_SEMANTICS_TYPE_H_
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/char-block.h"
diff --git a/flang/include/flang/Common/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
similarity index 98%
rename from flang/include/flang/Common/Fortran-features.h
rename to flang/include/flang/Support/Fortran-features.h
index 86c6e02b0f2ffd..f0bfc9232ea9e9 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.
@@ -9,7 +9,7 @@
#ifndef FORTRAN_COMMON_FORTRAN_FEATURES_H_
#define FORTRAN_COMMON_FORTRAN_FEATURES_H_
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
#include <vector>
diff --git a/flang/include/flang/Common/Fortran.h b/flang/include/flang/Support/Fortran.h
similarity index 73%
rename from flang/include/flang/Common/Fortran.h
rename to flang/include/flang/Support/Fortran.h
index 5b2ed43a8f99c0..6dbfb51f19dd8e 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.
@@ -9,21 +9,20 @@
#ifndef FORTRAN_COMMON_FORTRAN_H_
#define FORTRAN_COMMON_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>
+
namespace Fortran::common {
-class LanguageFeatureControl;
+ class LanguageFeatureControl;
+
-// Fortran has five kinds of intrinsic data types, plus the derived types.
-ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
-ENUM_CLASS(VectorElementCategory, Integer, Unsigned, Real)
constexpr bool IsNumericTypeCategory(TypeCategory category) {
return category == TypeCategory::Integer || category == TypeCategory::Real ||
@@ -47,8 +46,6 @@ const char *AsFortran(RelationalOperator);
ENUM_CLASS(Intent, Default, In, Out, InOut)
-ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
- Print, Read, Rewind, Wait, Write)
// Union of specifiers for all I/O statements.
ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
@@ -61,28 +58,14 @@ ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
Dispose, // nonstandard
)
-// Defined I/O variants
-ENUM_CLASS(
- DefinedIo, ReadFormatted, ReadUnformatted, WriteFormatted, WriteUnformatted)
+
const char *AsFortran(DefinedIo);
-// Floating-point rounding modes; these are packed into a byte to save
-// room in the runtime's format processing context structure. These
-// enumerators are defined with the corresponding values returned from
-// llvm.get.rounding.
-enum class RoundingMode : std::uint8_t {
- ToZero, // ROUND=ZERO, RZ - truncation
- TiesToEven, // ROUND=NEAREST, RN - default IEEE rounding
- Up, // ROUND=UP, RU
- Down, // ROUND=DOWN, RD
- TiesAwayFromZero, // ROUND=COMPATIBLE, RC - ties round away from zero
-};
// Fortran label. Must be in [1..99999].
using Label = std::uint64_t;
-// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
-static constexpr int maxRank{15};
+
// CUDA subprogram attribute combinations
ENUM_CLASS(CUDASubprogramAttrs, Host, Device, HostDevice, Global, Grid_Global)
@@ -129,6 +112,5 @@ inline std::string GetExternalAssemblyName(
std::string symbolName, bool underscoring) {
return underscoring ? std::move(symbolName) + "_" : std::move(symbolName);
}
-
} // namespace Fortran::common
#endif // FORTRAN_COMMON_FORTRAN_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 86%
rename from flang/include/flang/Common/MathOptionsBase.h
rename to flang/include/flang/Support/MathOptionsBase.h
index 7f8ebdbee19878..a739ba3e066599 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.
@@ -27,16 +27,16 @@ 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
diff --git a/flang/include/flang/Common/OpenMP-features.h b/flang/include/flang/Support/OpenMP-features.h
similarity index 94%
rename from flang/include/flang/Common/OpenMP-features.h
rename to flang/include/flang/Support/OpenMP-features.h
index 480c8b4c1013fe..fb73d4191d1c1a 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.
diff --git a/flang/include/flang/Common/Version.h b/flang/include/flang/Support/Version.h
similarity index 95%
rename from flang/include/flang/Common/Version.h
rename to flang/include/flang/Support/Version.h
index 3257d4a4f64593..643ddd2e27f69a 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.
diff --git a/flang/include/flang/Common/default-kinds.h b/flang/include/flang/Support/default-kinds.h
similarity index 96%
rename from flang/include/flang/Common/default-kinds.h
rename to flang/include/flang/Support/default-kinds.h
index 6c66b98e98a05b..e78a08dfae6cc3 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.
@@ -9,7 +9,7 @@
#ifndef FORTRAN_COMMON_DEFAULT_KINDS_H_
#define FORTRAN_COMMON_DEFAULT_KINDS_H_
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include <cstdint>
namespace Fortran::common {
diff --git a/flang/include/flang/Common/indirection.h b/flang/include/flang/Support/indirection.h
similarity index 98%
rename from flang/include/flang/Common/indirection.h
rename to flang/include/flang/Support/indirection.h
index 7348eb0473f072..1221a659323503 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.
@@ -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>
diff --git a/flang/include/flang/Common/interval.h b/flang/include/flang/Support/interval.h
similarity index 97%
rename from flang/include/flang/Common/interval.h
rename to flang/include/flang/Support/interval.h
index c4cab0ccf1130b..2918cc54de3926 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.
@@ -12,7 +12,7 @@
// 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>
diff --git a/flang/include/flang/Common/reference-counted.h b/flang/include/flang/Support/reference-counted.h
similarity index 96%
rename from flang/include/flang/Common/reference-counted.h
rename to flang/include/flang/Support/reference-counted.h
index de91d4fb6ee8b7..d7a065c59d5a0f 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.
diff --git a/flang/include/flang/Common/reference.h b/flang/include/flang/Support/reference.h
similarity index 97%
rename from flang/include/flang/Common/reference.h
rename to flang/include/flang/Support/reference.h
index 0c579de44bd7fa..cb367ae231376d 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.
diff --git a/flang/include/flang/Common/static-multimap-view.h b/flang/include/flang/Support/static-multimap-view.h
similarity index 97%
rename from flang/include/flang/Common/static-multimap-view.h
rename to flang/include/flang/Support/static-multimap-view.h
index 27d2ba89c8009c..71da272a26de2f 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.
diff --git a/flang/include/flang/Common/template.h b/flang/include/flang/Support/template.h
similarity index 99%
rename from flang/include/flang/Common/template.h
rename to flang/include/flang/Support/template.h
index 51d09fb42ce368..e15de9c2d0cea8 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.
@@ -9,7 +9,7 @@
#ifndef FORTRAN_COMMON_TEMPLATE_H_
#define FORTRAN_COMMON_TEMPLATE_H_
-#include "variant.h"
+#include "flang/Common/variant.h"
#include "flang/Common/idioms.h"
#include <functional>
#include <optional>
diff --git a/flang/include/flang/Common/unwrap.h b/flang/include/flang/Support/unwrap.h
similarity index 97%
rename from flang/include/flang/Common/unwrap.h
rename to flang/include/flang/Support/unwrap.h
index 84582174e4b300..d8fa553dedda3f 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.
@@ -12,8 +12,8 @@
#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>
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h
index 75fd783af237d0..bc105f471aa003 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
#define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
-#include "flang/Common/MathOptionsBase.h"
+#include "flang/Support/MathOptionsBase.h"
#include "flang/Frontend/CodeGenOptions.h"
#include "flang/Frontend/LangOptions.h"
#include <cstdint>
diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index f41d4df1f07e3c..d29da136ea3eda 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -1,6 +1,9 @@
+
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../FortranRuntime/include")
+
add_subdirectory(Common)
+add_subdirectory(Support)
add_subdirectory(Evaluate)
-add_subdirectory(Decimal)
add_subdirectory(Lower)
add_subdirectory(Parser)
add_subdirectory(Semantics)
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index c6f818ad27cd19..b62aeb2c08b779 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -1,48 +1,12 @@
-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
- Version.cpp
- ${version_inc}
-
- LINK_COMPONENTS
- Support
-)
+#===-- FortranRuntime/lib/Common/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(FortranCommon
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/binary-to-decimal.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/decimal-to-binary.cpp"
+)
diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt
deleted file mode 100644
index 880b190f1c5815..00000000000000
--- a/flang/lib/Decimal/CMakeLists.txt
+++ /dev/null
@@ -1,86 +0,0 @@
-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
- 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/lib/Evaluate/CMakeLists.txt b/flang/lib/Evaluate/CMakeLists.txt
index b38f450d746ea7..5f2e345b7bfb56 100644
--- a/flang/lib/Evaluate/CMakeLists.txt
+++ b/flang/lib/Evaluate/CMakeLists.txt
@@ -60,9 +60,8 @@ add_flang_library(FortranEvaluate
variable.cpp
LINK_LIBS
- FortranCommon
- FortranDecimal
FortranParser
+ FortranSupport
${LIBPGMATH}
${QUADMATHLIB}
diff --git a/flang/lib/Evaluate/call.cpp b/flang/lib/Evaluate/call.cpp
index c5b50e806d2497..1cb8eb89f41687 100644
--- a/flang/lib/Evaluate/call.cpp
+++ b/flang/lib/Evaluate/call.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/call.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/check-expression.h"
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index 70e24d6e82eb8e..091f2e2b553e86 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/characteristics.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/intrinsics.h"
diff --git a/flang/lib/Evaluate/common.cpp b/flang/lib/Evaluate/common.cpp
index c633bff57b1ecd..7741bec650575d 100644
--- a/flang/lib/Evaluate/common.cpp
+++ b/flang/lib/Evaluate/common.cpp
@@ -9,10 +9,14 @@
#include "flang/Evaluate/common.h"
#include "flang/Common/idioms.h"
+
using namespace Fortran::parser::literals;
+
+
namespace Fortran::evaluate {
+
void RealFlagWarnings(
FoldingContext &context, const RealFlags &flags, const char *operation) {
if (context.languageFeatures().ShouldWarn(
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index 1b14a305b87f4f..c8452cdd6a0caa 100644
--- a/flang/lib/Evaluate/fold-implementation.h
+++ b/flang/lib/Evaluate/fold-implementation.h
@@ -12,9 +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/Support/indirection.h"
+#include "flang/Support/template.h"
+#include "flang/Support/unwrap.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/constant.h"
diff --git a/flang/lib/Evaluate/formatting.cpp b/flang/lib/Evaluate/formatting.cpp
index 0870d56549f74d..db5d005d97c8c9 100644
--- a/flang/lib/Evaluate/formatting.cpp
+++ b/flang/lib/Evaluate/formatting.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/formatting.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/constant.h"
#include "flang/Evaluate/expression.h"
diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index ed28d8130808fa..440ddaaf9689c8 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -14,7 +14,7 @@
#include "flang/Evaluate/intrinsics-library.h"
#include "fold-implementation.h"
#include "host.h"
-#include "flang/Common/static-multimap-view.h"
+#include "flang/Support/static-multimap-view.h"
#include "flang/Evaluate/expression.h"
#include <cfloat>
#include <cmath>
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 166dae93178c51..343bd2c9f22be2 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/intrinsics.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/check-expression.h"
diff --git a/flang/lib/Evaluate/real.cpp b/flang/lib/Evaluate/real.cpp
index 642490646dcaf3..9d465e5f35d6ae 100644
--- a/flang/lib/Evaluate/real.cpp
+++ b/flang/lib/Evaluate/real.cpp
@@ -9,7 +9,7 @@
#include "flang/Evaluate/real.h"
#include "int-power.h"
#include "flang/Common/idioms.h"
-#include "flang/Decimal/decimal.h"
+#include "flang/Common/decimal.h"
#include "flang/Parser/characters.h"
#include "llvm/Support/raw_ostream.h"
#include <limits>
diff --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp
index c62d0cb0ff29dd..7b78d8c7b9734f 100644
--- a/flang/lib/Evaluate/shape.cpp
+++ b/flang/lib/Evaluate/shape.cpp
@@ -8,7 +8,7 @@
#include "flang/Evaluate/shape.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/fold.h"
diff --git a/flang/lib/Evaluate/target.cpp b/flang/lib/Evaluate/target.cpp
index 1e2cf6b0d298d4..d0722c31e3c3f7 100644
--- a/flang/lib/Evaluate/target.cpp
+++ b/flang/lib/Evaluate/target.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/target.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/type.h"
diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index ecdcc73d61ec1f..9b20b6a92cca0f 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -28,7 +28,7 @@ add_flang_library(flangFrontend
FortranParser
FortranSemantics
FortranEvaluate
- FortranCommon
+ FortranSupport
FortranLower
FIRDialect
FIRDialectSupport
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index d37430e0e5773e..a0653576852101 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/CompilerInstance.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/TextDiagnosticPrinter.h"
#include "flang/Parser/parsing.h"
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 90c327546198b5..5fe6ccbc44a894 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -11,9 +11,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/CompilerInvocation.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/OpenMP-features.h"
-#include "flang/Common/Version.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
#include "flang/Frontend/CodeGenOptions.h"
#include "flang/Frontend/PreprocessorOptions.h"
#include "flang/Frontend/TargetOptions.h"
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index cda82bcb7ecc71..7d51c20514387a 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/FrontendActions.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Frontend/CompilerInstance.h"
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/FrontendOptions.h"
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 79e5a04463e00b..6924717cb467ac 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -12,7 +12,7 @@
#include "flang/Lower/Bridge.h"
#include "DirectivesCommon.h"
-#include "flang/Common/Version.h"
+#include "flang/Support/Version.h"
#include "flang/Lower/Allocatable.h"
#include "flang/Lower/CallInterface.h"
#include "flang/Lower/Coarray.h"
diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt
index ba6622d8504a4f..cb37857ab1de0b 100644
--- a/flang/lib/Lower/CMakeLists.txt
+++ b/flang/lib/Lower/CMakeLists.txt
@@ -56,7 +56,7 @@ add_flang_library(FortranLower
HLFIRDialect
${dialect_libs}
${extension_libs}
- FortranCommon
+ FortranSupport
FortranParser
FortranEvaluate
FortranSemantics
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index c0ef96adc20c3e..153845699dae3d 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/CallInterface.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Evaluate/fold.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/Mangler.h"
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 62a7615e1af13c..4d2ac95ea784b5 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -11,8 +11,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/ConvertExpr.h"
-#include "flang/Common/default-kinds.h"
-#include "flang/Common/unwrap.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/unwrap.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/real.h"
#include "flang/Evaluate/traverse.h"
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index a66dae8851a866..565f9c6cbc5892 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/Mangler.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
#include "flang/Lower/Support/Utils.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/FIRType.h"
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index dc0dc47bda9a9d..5f1a25b1af23e9 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -14,7 +14,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Optimizer/Builder/IntrinsicCall.h"
-#include "flang/Common/static-multimap-view.h"
+#include "flang/Support/static-multimap-view.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/Character.h"
#include "flang/Optimizer/Builder/Complex.h"
@@ -68,6 +68,11 @@
/// a call is generated for it. LLVM intrinsics are handled as a math
/// runtime library here.
+static llvm::cl::opt<bool> ignoreModuleOnlyBuiltins(
+ "ignore-module-only-builtins",
+ llvm::cl::desc("ignore failures from __builtin_numeric_storage_size when compiling FortranRuntime"),
+ llvm::cl::init(false), llvm::cl::Hidden);
+
namespace fir {
fir::ExtendedValue getAbsentIntrinsicArgument() { return fir::UnboxedValue{}; }
@@ -502,6 +507,7 @@ static constexpr IntrinsicHandler handlers[]{
/*isElemental=*/false},
{"not", &I::genNot},
{"null", &I::genNull, {{{"mold", asInquired}}}, /*isElemental=*/false},
+ {"numeric_storage_size", &I::genNumericStorageSize},
{"pack",
&I::genPack,
{{{"array", asBox},
@@ -7218,6 +7224,19 @@ IntrinsicLibrary::genVerify(mlir::Type resultType,
return readAndAddCleanUp(resultMutableBox, resultType, "VERIFY");
}
+
+ fir::ExtendedValue IntrinsicLibrary:: genNumericStorageSize(mlir::Type resultType, llvm::ArrayRef<fir::ExtendedValue> args) {
+ assert(args.empty() );
+
+ if (!ignoreModuleOnlyBuiltins) {
+ fir::emitFatalError(loc, "__builtin_numeric_storage_size is for internal use only. Use NUMERIC_STORAGE_SIZE from ISO_FORTRAN_ENV module instead.");
+ return {};
+ }
+
+ return builder.createIntegerConstant(loc, resultType , 32 );
+ }
+
+
/// Process calls to Minloc, Maxloc intrinsic functions
template <typename FN, typename FD>
fir::ExtendedValue
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
index 1043494b6fb48a..c632e42ef72c29 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
@@ -13,7 +13,7 @@
#define DEBUG_TYPE "flang-type-conversion"
#include "flang/Optimizer/CodeGen/TypeConverter.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/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"
diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index c1debf28d00332..08d75c46faee4b 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/Transforms/AddDebugInfo.cpp b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index 46e70d7ef9180a..f41633629bb3e2 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "DebugTypeGenerator.h"
-#include "flang/Common/Version.h"
+#include "flang/Support/Version.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/CodeGen/CGOps.h"
diff --git a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
index 2c9c73e8a5394d..ca6eacfd0e7200 100644
--- a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Lower/BuiltinModules.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Runtime/Support.h"
diff --git a/flang/lib/Optimizer/Transforms/CMakeLists.txt b/flang/lib/Optimizer/Transforms/CMakeLists.txt
index b32f2ef86fca44..35794300dbc6aa 100644
--- a/flang/lib/Optimizer/Transforms/CMakeLists.txt
+++ b/flang/lib/Optimizer/Transforms/CMakeLists.txt
@@ -44,6 +44,7 @@ add_flang_library(FIRTransforms
FIRDialectSupport
FIRSupport
FortranCommon
+ FortranSupport
HLFIRDialect
MLIRAffineUtils
MLIRFuncDialect
diff --git a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
index c22c74d3f78af7..d3c44a75e4cffb 100644
--- a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
#include "flang/Optimizer/CodeGen/TypeConverter.h"
#include "flang/Optimizer/Dialect/CUF/CUFOps.h"
diff --git a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
index 648628fd1c9af0..1915abe2f91e0e 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
diff --git a/flang/lib/Optimizer/Transforms/LoopVersioning.cpp b/flang/lib/Optimizer/Transforms/LoopVersioning.cpp
index 51dc48f0fcb129..f6bd2aeb17bc20 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 c61179a7460e32..c56dfa1cdfb524 100644
--- a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
+++ b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
@@ -22,7 +22,7 @@
/// and small in size.
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/LowLevelIntrinsics.h"
diff --git a/flang/lib/Optimizer/Transforms/StackReclaim.cpp b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
index 8a60a9e64f704b..629ba587adf3ca 100644
--- a/flang/lib/Optimizer/Transforms/StackReclaim.cpp
+++ b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Transforms/Passes.h"
diff --git a/flang/lib/Optimizer/Transforms/VScaleAttr.cpp b/flang/lib/Optimizer/Transforms/VScaleAttr.cpp
index d311167c58b4d6..54a2456e77366c 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 600a2f67df4431..b2cd3cbbe35ffc 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 515b5993d67376..6575c7d01de346 100644
--- a/flang/lib/Parser/basic-parsers.h
+++ b/flang/lib/Parser/basic-parsers.h
@@ -22,9 +22,9 @@
// 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/Support/Fortran-features.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-state.h"
diff --git a/flang/lib/Parser/parse-tree.cpp b/flang/lib/Parser/parse-tree.cpp
index 7f0899aaa14294..3b90a57c602945 100644
--- a/flang/lib/Parser/parse-tree.cpp
+++ b/flang/lib/Parser/parse-tree.cpp
@@ -8,7 +8,7 @@
#include "flang/Parser/parse-tree.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Parser/tools.h"
#include "flang/Parser/user-state.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/flang/lib/Parser/prescan.h b/flang/lib/Parser/prescan.h
index 9d4f7c0c302a1a..0ea614d1df3bd9 100644
--- a/flang/lib/Parser/prescan.h
+++ b/flang/lib/Parser/prescan.h
@@ -16,7 +16,7 @@
// fixed form character literals on truncated card images, file
// inclusion, and driving the Fortran source preprocessor.
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/message.h"
#include "flang/Parser/provenance.h"
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 2511a5dda9d095..7b0385c63cd8a1 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -10,9 +10,9 @@
// traversal templates in parse-tree-visitor.h.
#include "flang/Parser/unparse.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Semantics/CMakeLists.txt b/flang/lib/Semantics/CMakeLists.txt
index 41406ecf50e004..4203648a50ef71 100644
--- a/flang/lib/Semantics/CMakeLists.txt
+++ b/flang/lib/Semantics/CMakeLists.txt
@@ -52,7 +52,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 95d7b3cf91b17a..275625d3ed6522 100644
--- a/flang/lib/Semantics/assignment.h
+++ b/flang/lib/Semantics/assignment.h
@@ -9,7 +9,7 @@
#ifndef FORTRAN_SEMANTICS_ASSIGNMENT_H_
#define FORTRAN_SEMANTICS_ASSIGNMENT_H_
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Evaluate/expression.h"
#include "flang/Semantics/semantics.h"
diff --git a/flang/lib/Semantics/check-case.cpp b/flang/lib/Semantics/check-case.cpp
index d296460127e12c..0e38b24f1b319d 100644
--- a/flang/lib/Semantics/check-case.cpp
+++ b/flang/lib/Semantics/check-case.cpp
@@ -8,8 +8,8 @@
#include "check-case.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
-#include "flang/Common/template.h"
+#include "flang/Support/reference.h"
+#include "flang/Support/template.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/type.h"
#include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Semantics/check-coarray.cpp b/flang/lib/Semantics/check-coarray.cpp
index 6cf61a6b923db3..d34c70e60d966b 100644
--- a/flang/lib/Semantics/check-coarray.cpp
+++ b/flang/lib/Semantics/check-coarray.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "check-coarray.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index d8bd435bf09f38..738a471f4d01f5 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "check-cuda.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/tools.h"
#include "flang/Evaluate/traverse.h"
diff --git a/flang/lib/Semantics/check-data.h b/flang/lib/Semantics/check-data.h
index 479d32568fa66a..5cdf46a5ffb1c9 100644
--- a/flang/lib/Semantics/check-data.h
+++ b/flang/lib/Semantics/check-data.h
@@ -10,7 +10,7 @@
#define FORTRAN_SEMANTICS_CHECK_DATA_H_
#include "data-to-inits.h"
-#include "flang/Common/interval.h"
+#include "flang/Support/interval.h"
#include "flang/Evaluate/fold-designator.h"
#include "flang/Evaluate/initial-image.h"
#include "flang/Semantics/expression.h"
diff --git a/flang/lib/Semantics/check-do-forall.cpp b/flang/lib/Semantics/check-do-forall.cpp
index d798244ff1ef2d..42e1c07fc45c3e 100644
--- a/flang/lib/Semantics/check-do-forall.cpp
+++ b/flang/lib/Semantics/check-do-forall.cpp
@@ -8,7 +8,7 @@
#include "check-do-forall.h"
#include "definable.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/tools.h"
diff --git a/flang/lib/Semantics/check-return.cpp b/flang/lib/Semantics/check-return.cpp
index ec2600bac3c68e..6a03467a27a759 100644
--- a/flang/lib/Semantics/check-return.cpp
+++ b/flang/lib/Semantics/check-return.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "check-return.h"
-#include "flang/Common/Fortran-features.h"
+#include "flang/Support/Fortran-features.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
diff --git a/flang/lib/Semantics/check-select-rank.cpp b/flang/lib/Semantics/check-select-rank.cpp
index 2e602d307013c1..722226465b6642 100644
--- a/flang/lib/Semantics/check-select-rank.cpp
+++ b/flang/lib/Semantics/check-select-rank.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "check-select-rank.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Parser/message.h"
#include "flang/Parser/tools.h"
diff --git a/flang/lib/Semantics/check-select-type.cpp b/flang/lib/Semantics/check-select-type.cpp
index 94d16a719277af..da41410bd24612 100644
--- a/flang/lib/Semantics/check-select-type.cpp
+++ b/flang/lib/Semantics/check-select-type.cpp
@@ -8,7 +8,7 @@
#include "check-select-type.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/reference.h"
+#include "flang/Support/reference.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/type.h"
#include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Semantics/check-stop.cpp b/flang/lib/Semantics/check-stop.cpp
index 43535b07f029e9..dab076424bd8e6 100644
--- a/flang/lib/Semantics/check-stop.cpp
+++ b/flang/lib/Semantics/check-stop.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "check-stop.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
diff --git a/flang/lib/Semantics/data-to-inits.h b/flang/lib/Semantics/data-to-inits.h
index d8cc4601de26fa..df4d552760eda6 100644
--- a/flang/lib/Semantics/data-to-inits.h
+++ b/flang/lib/Semantics/data-to-inits.h
@@ -9,8 +9,8 @@
#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/Support/default-kinds.h"
+#include "flang/Support/interval.h"
#include "flang/Evaluate/fold-designator.h"
#include "flang/Evaluate/initial-image.h"
#include <list>
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 072ebe172f45a9..a4be06515e4c87 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -11,7 +11,7 @@
#include "pointer-assignment.h"
#include "resolve-names-utils.h"
#include "resolve-names.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/fold.h"
diff --git a/flang/lib/Semantics/pointer-assignment.cpp b/flang/lib/Semantics/pointer-assignment.cpp
index 4948fce77a2502..abd3c5f461cb7e 100644
--- a/flang/lib/Semantics/pointer-assignment.cpp
+++ b/flang/lib/Semantics/pointer-assignment.cpp
@@ -10,7 +10,7 @@
#include "definable.h"
#include "flang/Common/idioms.h"
#include "flang/Common/restorer.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/fold.h"
diff --git a/flang/lib/Semantics/resolve-labels.cpp b/flang/lib/Semantics/resolve-labels.cpp
index e5e96ec6327e2b..84d2e51d438bfe 100644
--- a/flang/lib/Semantics/resolve-labels.cpp
+++ b/flang/lib/Semantics/resolve-labels.cpp
@@ -8,7 +8,7 @@
#include "resolve-labels.h"
#include "flang/Common/enum-set.h"
-#include "flang/Common/template.h"
+#include "flang/Support/template.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Semantics/semantics.h"
#include <cstdarg>
diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp
index 39392257938d66..bc5f458f403cf2 100644
--- a/flang/lib/Semantics/resolve-names-utils.cpp
+++ b/flang/lib/Semantics/resolve-names-utils.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "resolve-names-utils.h"
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/tools.h"
#include "flang/Evaluate/traverse.h"
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index d8f601212d8d01..920cefa084e05c 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -14,9 +14,9 @@
#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/Support/Fortran.h"
+#include "flang/Support/default-kinds.h"
+#include "flang/Support/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/characteristics.h"
diff --git a/flang/lib/Semantics/rewrite-parse-tree.cpp b/flang/lib/Semantics/rewrite-parse-tree.cpp
index b4fb72ce213017..46641f5bd3c363 100644
--- a/flang/lib/Semantics/rewrite-parse-tree.cpp
+++ b/flang/lib/Semantics/rewrite-parse-tree.cpp
@@ -8,7 +8,7 @@
#include "rewrite-parse-tree.h"
#include "rewrite-directives.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/indirection.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp
index 8592d1e5d6217e..c39c8ac5a7b111 100644
--- a/flang/lib/Semantics/semantics.cpp
+++ b/flang/lib/Semantics/semantics.cpp
@@ -37,7 +37,7 @@
#include "resolve-labels.h"
#include "resolve-names.h"
#include "rewrite-parse-tree.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/tools.h"
#include "flang/Semantics/expression.h"
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 8d16ab71008766..2aa0476b8fa07a 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Parser/tools.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Common/indirection.h"
+#include "flang/Support/Fortran.h"
+#include "flang/Support/indirection.h"
#include "flang/Parser/dump-parse-tree.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
diff --git a/flang/lib/Support/CMakeLists.txt b/flang/lib/Support/CMakeLists.txt
new file mode 100644
index 00000000000000..674ed0f196c89e
--- /dev/null
+++ b/flang/lib/Support/CMakeLists.txt
@@ -0,0 +1,56 @@
+#===-- 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
+ Version.cpp
+ ${version_inc}
+
+ LINK_COMPONENTS
+ Support
+)
diff --git a/flang/lib/Common/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
similarity index 91%
rename from flang/lib/Common/Fortran-features.cpp
rename to flang/lib/Support/Fortran-features.cpp
index 25a948818e6560..e49735218ab967 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,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/Fortran.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.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 c014b1263a67f0..21eafe385015b5 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/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 d67255f353dfd7..8ee4908f28f621 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/Support/big-radix-floating-point.h b/flang/lib/Support/big-radix-floating-point.h
new file mode 100644
index 00000000000000..4c3d8f8b30832a
--- /dev/null
+++ b/flang/lib/Support/big-radix-floating-point.h
@@ -0,0 +1,396 @@
+//===-- lib/Support/big-radix-floating-point.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_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
+#define FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
+
+// This is a helper class for use in floating-point conversions between
+// binary and decimal representations. It holds a multiple-precision
+// integer value using digits of a radix that is a large even power of ten
+// (10,000,000,000,000,000 by default, 10**16). These digits are accompanied
+// by a signed exponent that denotes multiplication by a power of ten.
+// The effective radix point is to the right of the digits (i.e., they do
+// not represent a fraction).
+//
+// The operations supported by this class are limited to those required
+// for conversions between binary and decimal representations; it is not
+// a general-purpose facility.
+
+#include "flang/Common/bit-population-count.h"
+#include "flang/Common/leading-zero-bit-count.h"
+#include "flang/Common/uint128.h"
+#include "flang/Support/binary-floating-point.h"
+#include "flang/Common/decimal.h"
+#include <cinttypes>
+#include <limits>
+#include <type_traits>
+
+// Some environments, viz. glibc 2.17, allow the macro HUGE
+// to leak out of <math.h>.
+#undef HUGE
+
+namespace Fortran::decimal {
+
+static constexpr std::uint64_t TenToThe(int power) {
+ return power <= 0 ? 1 : 10 * TenToThe(power - 1);
+}
+
+// 10**(LOG10RADIX + 3) must be < 2**wordbits, and LOG10RADIX must be
+// even, so that pairs of decimal digits do not straddle Digits.
+// So LOG10RADIX must be 16 or 6.
+template <int PREC, int LOG10RADIX = 16> class BigRadixFloatingPointNumber {
+public:
+ using Real = BinaryFloatingPointNumber<PREC>;
+ static constexpr int log10Radix{LOG10RADIX};
+
+private:
+ static constexpr std::uint64_t uint64Radix{TenToThe(log10Radix)};
+ static constexpr int minDigitBits{
+ 64 - common::LeadingZeroBitCount(uint64Radix)};
+ using Digit = common::HostUnsignedIntType<minDigitBits>;
+ static constexpr Digit radix{uint64Radix};
+ static_assert(radix < std::numeric_limits<Digit>::max() / 1000,
+ "radix is somehow too big");
+ static_assert(radix > std::numeric_limits<Digit>::max() / 10000,
+ "radix is somehow too small");
+
+ // The base-2 logarithm of the least significant bit that can arise
+ // in a subnormal IEEE floating-point number.
+ static constexpr int minLog2AnyBit{
+ -Real::exponentBias - Real::binaryPrecision};
+
+ // The number of Digits needed to represent the smallest subnormal.
+ static constexpr int maxDigits{3 - minLog2AnyBit / log10Radix};
+
+public:
+ explicit RT_API_ATTRS BigRadixFloatingPointNumber(
+ enum FortranRounding rounding = RoundNearest)
+ : rounding_{rounding} {}
+
+ // Converts a binary floating point value.
+ explicit RT_API_ATTRS BigRadixFloatingPointNumber(
+ Real, enum FortranRounding = RoundNearest);
+
+ RT_API_ATTRS BigRadixFloatingPointNumber &SetToZero() {
+ isNegative_ = false;
+ digits_ = 0;
+ exponent_ = 0;
+ return *this;
+ }
+
+ RT_API_ATTRS bool IsInteger() const { return exponent_ >= 0; }
+
+ // Converts decimal floating-point to binary.
+ RT_API_ATTRS ConversionToBinaryResult<PREC> ConvertToBinary();
+
+ // Parses and converts to binary. Handles leading spaces,
+ // "NaN", & optionally-signed "Inf". Does not skip internal
+ // spaces.
+ // The argument is a reference to a pointer that is left
+ // pointing to the first character that wasn't parsed.
+ RT_API_ATTRS ConversionToBinaryResult<PREC> ConvertToBinary(
+ const char *&, const char *end = nullptr);
+
+ // Formats a decimal floating-point number to a user buffer.
+ // May emit "NaN" or "Inf", or an possibly-signed integer.
+ // No decimal point is written, but if it were, it would be
+ // after the last digit; the effective decimal exponent is
+ // returned as part of the result structure so that it can be
+ // formatted by the client.
+ RT_API_ATTRS ConversionToDecimalResult ConvertToDecimal(
+ char *, std::size_t, enum DecimalConversionFlags, int digits) const;
+
+ // Discard decimal digits not needed to distinguish this value
+ // from the decimal encodings of two others (viz., the nearest binary
+ // floating-point numbers immediately below and above this one).
+ // The last decimal digit may not be uniquely determined in all
+ // cases, and will be the mean value when that is so (e.g., if
+ // last decimal digit values 6-8 would all work, it'll be a 7).
+ // This minimization necessarily assumes that the value will be
+ // emitted and read back into the same (or less precise) format
+ // with default rounding to the nearest value.
+ RT_API_ATTRS void Minimize(
+ BigRadixFloatingPointNumber &&less, BigRadixFloatingPointNumber &&more);
+
+ template <typename STREAM> STREAM &Dump(STREAM &) const;
+
+private:
+ RT_API_ATTRS BigRadixFloatingPointNumber(
+ const BigRadixFloatingPointNumber &that)
+ : digits_{that.digits_}, exponent_{that.exponent_},
+ isNegative_{that.isNegative_}, rounding_{that.rounding_} {
+ for (int j{0}; j < digits_; ++j) {
+ digit_[j] = that.digit_[j];
+ }
+ }
+
+ RT_API_ATTRS bool IsZero() const {
+ // Don't assume normalization.
+ for (int j{0}; j < digits_; ++j) {
+ if (digit_[j] != 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // Predicate: true when 10*value would cause a carry.
+ // (When this happens during decimal-to-binary conversion,
+ // there are more digits in the input string than can be
+ // represented precisely.)
+ RT_API_ATTRS bool IsFull() const {
+ return digits_ == digitLimit_ && digit_[digits_ - 1] >= radix / 10;
+ }
+
+ // Sets *this to an unsigned integer value.
+ // Returns any remainder.
+ template <typename UINT> RT_API_ATTRS UINT SetTo(UINT n) {
+ static_assert(
+ std::is_same_v<UINT, common::uint128_t> || std::is_unsigned_v<UINT>);
+ SetToZero();
+ while (n != 0) {
+ auto q{n / 10u};
+ if (n != q * 10) {
+ break;
+ }
+ ++exponent_;
+ n = q;
+ }
+ if constexpr (sizeof n < sizeof(Digit)) {
+ if (n != 0) {
+ digit_[digits_++] = n;
+ }
+ return 0;
+ } else {
+ while (n != 0 && digits_ < digitLimit_) {
+ auto q{n / radix};
+ digit_[digits_++] = static_cast<Digit>(n - q * radix);
+ n = q;
+ }
+ return n;
+ }
+ }
+
+ RT_API_ATTRS int RemoveLeastOrderZeroDigits() {
+ int remove{0};
+ if (digits_ > 0 && digit_[0] == 0) {
+ while (remove < digits_ && digit_[remove] == 0) {
+ ++remove;
+ }
+ if (remove >= digits_) {
+ digits_ = 0;
+ } else if (remove > 0) {
+#if defined __GNUC__ && __GNUC__ < 8
+ // (&& j + remove < maxDigits) was added to avoid GCC < 8 build failure
+ // on -Werror=array-bounds. This can be removed if -Werror is disable.
+ for (int j{0}; j + remove < digits_ && (j + remove < maxDigits); ++j) {
+#else
+ for (int j{0}; j + remove < digits_; ++j) {
+#endif
+ digit_[j] = digit_[j + remove];
+ }
+ digits_ -= remove;
+ }
+ }
+ return remove;
+ }
+
+ RT_API_ATTRS void RemoveLeadingZeroDigits() {
+ while (digits_ > 0 && digit_[digits_ - 1] == 0) {
+ --digits_;
+ }
+ }
+
+ RT_API_ATTRS void Normalize() {
+ RemoveLeadingZeroDigits();
+ exponent_ += RemoveLeastOrderZeroDigits() * log10Radix;
+ }
+
+ // This limited divisibility test only works for even divisors of the radix,
+ // which is fine since it's only ever used with 2 and 5.
+ template <int N> RT_API_ATTRS bool IsDivisibleBy() const {
+ static_assert(N > 1 && radix % N == 0, "bad modulus");
+ return digits_ == 0 || (digit_[0] % N) == 0;
+ }
+
+ template <unsigned DIVISOR> RT_API_ATTRS int DivideBy() {
+ Digit remainder{0};
+ for (int j{digits_ - 1}; j >= 0; --j) {
+ Digit q{digit_[j] / DIVISOR};
+ Digit nrem{digit_[j] - DIVISOR * q};
+ digit_[j] = q + (radix / DIVISOR) * remainder;
+ remainder = nrem;
+ }
+ return remainder;
+ }
+
+ RT_API_ATTRS void DivideByPowerOfTwo(int twoPow) { // twoPow <= log10Radix
+ Digit remainder{0};
+ auto mask{(Digit{1} << twoPow) - 1};
+ auto coeff{radix >> twoPow};
+ for (int j{digits_ - 1}; j >= 0; --j) {
+ auto nrem{digit_[j] & mask};
+ digit_[j] = (digit_[j] >> twoPow) + coeff * remainder;
+ remainder = nrem;
+ }
+ }
+
+ // Returns true on overflow
+ RT_API_ATTRS bool DivideByPowerOfTwoInPlace(int twoPow) {
+ if (digits_ > 0) {
+ while (twoPow > 0) {
+ int chunk{twoPow > log10Radix ? log10Radix : twoPow};
+ if ((digit_[0] & ((Digit{1} << chunk) - 1)) == 0) {
+ DivideByPowerOfTwo(chunk);
+ twoPow -= chunk;
+ continue;
+ }
+ twoPow -= chunk;
+ if (digit_[digits_ - 1] >> chunk != 0) {
+ if (digits_ == digitLimit_) {
+ return true; // overflow
+ }
+ digit_[digits_++] = 0;
+ }
+ auto remainder{digit_[digits_ - 1]};
+ exponent_ -= log10Radix;
+ auto coeff{radix >> chunk}; // precise; radix is (5*2)**log10Radix
+ auto mask{(Digit{1} << chunk) - 1};
+ for (int j{digits_ - 1}; j >= 1; --j) {
+ digit_[j] = (digit_[j - 1] >> chunk) + coeff * remainder;
+ remainder = digit_[j - 1] & mask;
+ }
+ digit_[0] = coeff * remainder;
+ }
+ }
+ return false; // no overflow
+ }
+
+ RT_API_ATTRS int AddCarry(int position = 0, int carry = 1) {
+ for (; position < digits_; ++position) {
+ Digit v{digit_[position] + carry};
+ if (v < radix) {
+ digit_[position] = v;
+ return 0;
+ }
+ digit_[position] = v - radix;
+ carry = 1;
+ }
+ if (digits_ < digitLimit_) {
+ digit_[digits_++] = carry;
+ return 0;
+ }
+ Normalize();
+ if (digits_ < digitLimit_) {
+ digit_[digits_++] = carry;
+ return 0;
+ }
+ return carry;
+ }
+
+ RT_API_ATTRS void Decrement() {
+ for (int j{0}; digit_[j]-- == 0; ++j) {
+ digit_[j] = radix - 1;
+ }
+ }
+
+ template <int N> RT_API_ATTRS int MultiplyByHelper(int carry = 0) {
+ for (int j{0}; j < digits_; ++j) {
+ auto v{N * digit_[j] + carry};
+ carry = v / radix;
+ digit_[j] = v - carry * radix; // i.e., v % radix
+ }
+ return carry;
+ }
+
+ template <int N> RT_API_ATTRS int MultiplyBy(int carry = 0) {
+ if (int newCarry{MultiplyByHelper<N>(carry)}) {
+ return AddCarry(digits_, newCarry);
+ } else {
+ return 0;
+ }
+ }
+
+ template <int N> RT_API_ATTRS int MultiplyWithoutNormalization() {
+ if (int carry{MultiplyByHelper<N>(0)}) {
+ if (digits_ < digitLimit_) {
+ digit_[digits_++] = carry;
+ return 0;
+ } else {
+ return carry;
+ }
+ } else {
+ return 0;
+ }
+ }
+
+ RT_API_ATTRS void LoseLeastSignificantDigit(); // with rounding
+
+ RT_API_ATTRS void PushCarry(int carry) {
+ if (digits_ == maxDigits && RemoveLeastOrderZeroDigits() == 0) {
+ LoseLeastSignificantDigit();
+ digit_[digits_ - 1] += carry;
+ } else {
+ digit_[digits_++] = carry;
+ }
+ }
+
+ // Adds another number and then divides by two.
+ // Assumes same exponent and sign.
+ // Returns true when the result has effectively been rounded down.
+ RT_API_ATTRS bool Mean(const BigRadixFloatingPointNumber &);
+
+ // Parses a floating-point number; leaves the pointer reference
+ // argument pointing at the next character after what was recognized.
+ // The "end" argument can be left null if the caller is sure that the
+ // string is properly terminated with an addressable character that
+ // can't be in a valid floating-point character.
+ RT_API_ATTRS bool ParseNumber(const char *&, bool &inexact, const char *end);
+
+ using Raw = typename Real::RawType;
+ constexpr RT_API_ATTRS Raw SignBit() const {
+ return Raw{isNegative_} << (Real::bits - 1);
+ }
+ constexpr RT_API_ATTRS Raw Infinity() const {
+ Raw result{static_cast<Raw>(Real::maxExponent)};
+ result <<= Real::significandBits;
+ result |= SignBit();
+ if constexpr (Real::bits == 80) { // x87
+ result |= Raw{1} << 63;
+ }
+ return result;
+ }
+ constexpr RT_API_ATTRS Raw NaN(bool isQuiet = true) {
+ Raw result{Real::maxExponent};
+ result <<= Real::significandBits;
+ result |= SignBit();
+ if constexpr (Real::bits == 80) { // x87
+ result |= Raw{isQuiet ? 3u : 2u} << 62;
+ } else {
+ Raw quiet{isQuiet ? Raw{2} : Raw{1}};
+ quiet <<= Real::significandBits - 2;
+ result |= quiet;
+ }
+ return result;
+ }
+ constexpr RT_API_ATTRS Raw HUGE() const {
+ Raw result{static_cast<Raw>(Real::maxExponent)};
+ result <<= Real::significandBits;
+ result |= SignBit();
+ return result - 1; // decrement exponent, set all significand bits
+ }
+
+ Digit digit_[maxDigits]; // in little-endian order: digit_[0] is LSD
+ int digits_{0}; // # of elements in digit_[] array; zero when zero
+ int digitLimit_{maxDigits}; // precision clamp
+ int exponent_{0}; // signed power of ten
+ bool isNegative_{false};
+ enum FortranRounding rounding_ { RoundNearest };
+};
+} // namespace Fortran::decimal
+#endif
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 0c708fcd605094..612adceb9d996b 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 536a5c2e5479df..906a4c1bcd9b0a 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/CMakeLists.txt b/flang/runtime/CMakeLists.txt
deleted file mode 100644
index 4537b2d059d65b..00000000000000
--- a/flang/runtime/CMakeLists.txt
+++ /dev/null
@@ -1,314 +0,0 @@
-#===-- 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
-#
-#===------------------------------------------------------------------------===#
-
-if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
- cmake_minimum_required(VERSION 3.20.0)
-
- project(FlangRuntime 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)
-
- # 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."
- )
-endif()
-
-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)
-
-# 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)
-
-check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
-if (FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
- set(NO_LTO_FLAGS "-fno-lto")
-else()
- set(NO_LTO_FLAGS "")
-endif()
-
-configure_file(config.h.cmake 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
-include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR})
-
-append(${NO_LTO_FLAGS} CMAKE_C_FLAGS)
-append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS)
-
-# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
-# to avoid an unwanted dependency on libstdc++/libc++.so.
-add_definitions(-U_GLIBCXX_ASSERTIONS)
-add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
-
-add_subdirectory(Float128Math)
-
-set(sources
- ISO_Fortran_binding.cpp
- allocator-registry.cpp
- allocatable.cpp
- array-constructor.cpp
- assign.cpp
- buffer.cpp
- character.cpp
- command.cpp
- complex-powi.cpp
- complex-reduction.c
- 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
- exceptions.cpp
- execute.cpp
- extensions.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
- main.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
- random.cpp
- reduce.cpp
- reduction.cpp
- stat.cpp
- stop.cpp
- sum.cpp
- support.cpp
- temporary-stack.cpp
- terminator.cpp
- time-intrinsic.cpp
- tools.cpp
- transformational.cpp
- type-code.cpp
- type-info.cpp
- unit-map.cpp
- unit.cpp
- utf.cpp
- ${FORTRAN_MODULE_OBJECTS}
-)
-
-include(AddFlangOffloadRuntime)
-
-# List of files that are buildable for all devices.
-set(supported_files
- ISO_Fortran_binding.cpp
- allocatable.cpp
- allocator-registry.cpp
- array-constructor.cpp
- assign.cpp
- buffer.cpp
- character.cpp
- connection.cpp
- copy.cpp
- derived-api.cpp
- derived.cpp
- descriptor.cpp
- descriptor-io.cpp
- dot-product.cpp
- edit-input.cpp
- edit-output.cpp
- environment.cpp
- extrema.cpp
- external-unit.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
- utf.cpp
- )
-
-enable_cuda_compilation(FortranRuntime "${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 information is provided via FortranFloat128MathILib
- # interface library.
- 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}
- )
- list(APPEND sources ${f128_sources})
- endif()
-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
- FortranRuntime.static_dbg FortranRuntime.dynamic_dbg)
-endif()
-set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries")
-
-# If FortranRuntime 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-new' target is built.
-#
-# 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-new AND TARGET module_files)
- add_dependencies(FortranRuntime flang-new module_files)
-endif()
-
-if (FLANG_CUF_RUNTIME)
- add_subdirectory(CUDA)
-endif()
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index a18a5c6519eda4..60261ea352780a 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -63,7 +63,7 @@ set(FLANG_TEST_DEPENDS
FileCheck
count
not
- module_files
+# module_files
fir-opt
tco
bbc
@@ -71,8 +71,6 @@ set(FLANG_TEST_DEPENDS
llvm-objdump
llvm-readobj
split-file
- FortranRuntime
- FortranDecimal
)
if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
list(APPEND FLANG_TEST_DEPENDS Bye)
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index ac9500d7c45cec..fdeb95e4dd97c6 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 765917f07d8e72..befe61fdadcd14 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/lib/CMakeLists.txt b/flang/test/lib/CMakeLists.txt
index fc6ef10fab1f5a..687b107844c651 100644
--- a/flang/test/lib/CMakeLists.txt
+++ b/flang/test/lib/CMakeLists.txt
@@ -1 +1,2 @@
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
add_subdirectory(Analysis)
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index 4acbc0606d1977..48b03e34798792 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -163,29 +163,6 @@
ToolSubst("%not_todo_abort_cmd", command=FindTool("not"), unresolved="fatal")
)
-# 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:
- 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")
- tools.append(
- ToolSubst(
- "%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal"
- )
- )
- 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
# 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 d1a0ac763cf8a0..65864302fb7aec 100644
--- a/flang/test/lit.site.cfg.py.in
+++ b/flang/test/lit.site.cfg.py.in
@@ -21,7 +21,6 @@ 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/flang/tools/CMakeLists.txt b/flang/tools/CMakeLists.txt
index 337545ae0d4d7a..c9f00c8cc6dbd6 100644
--- a/flang/tools/CMakeLists.txt
+++ b/flang/tools/CMakeLists.txt
@@ -7,7 +7,6 @@
#===------------------------------------------------------------------------===#
add_subdirectory(bbc)
-add_subdirectory(f18)
add_subdirectory(flang-driver)
add_subdirectory(tco)
add_subdirectory(f18-parse-demo)
diff --git a/flang/tools/bbc/CMakeLists.txt b/flang/tools/bbc/CMakeLists.txt
index 69316d4dc61de3..68e4b59fd6eec5 100644
--- a/flang/tools/bbc/CMakeLists.txt
+++ b/flang/tools/bbc/CMakeLists.txt
@@ -6,6 +6,7 @@ AllTargetsInfos
TargetParser
)
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
add_flang_tool(bbc bbc.cpp
DEPENDS
FIROptCodeGenPassIncGen
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index dcff4503f16571..e9ec6b7116e0aa 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -14,10 +14,10 @@
///
//===----------------------------------------------------------------------===//
-#include "flang/Common/Fortran-features.h"
-#include "flang/Common/OpenMP-features.h"
-#include "flang/Common/Version.h"
-#include "flang/Common/default-kinds.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/OpenMP-features.h"
+#include "flang/Support/Version.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Frontend/TargetOptions.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/PFTBuilder.h"
diff --git a/flang/tools/f18-parse-demo/CMakeLists.txt b/flang/tools/f18-parse-demo/CMakeLists.txt
index df1f1d24a55e51..34f1bf048ad849 100644
--- a/flang/tools/f18-parse-demo/CMakeLists.txt
+++ b/flang/tools/f18-parse-demo/CMakeLists.txt
@@ -1,3 +1,5 @@
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
+
set(LLVM_LINK_COMPONENTS
FrontendOpenACC
FrontendOpenMP
diff --git a/flang/tools/f18-parse-demo/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
index 3025dbd4dca4ab..691b6cebec9b51 100644
--- a/flang/tools/f18-parse-demo/f18-parse-demo.cpp
+++ b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
@@ -21,8 +21,8 @@
// 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/Support/Fortran-features.h"
+#include "flang/Support/default-kinds.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/dump-parse-tree.h"
#include "flang/Parser/message.h"
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
deleted file mode 100644
index 9d7b8633958cb7..00000000000000
--- a/flang/tools/f18/CMakeLists.txt
+++ /dev/null
@@ -1,173 +0,0 @@
-set(LLVM_LINK_COMPONENTS
- FrontendOpenACC
- FrontendOpenMP
- Support
- )
-
-# Define the list of Fortran module files that need to be compiled
-# to produce an object file for inclusion into the FortranRuntime
-# library.
-set(MODULES_WITH_IMPLEMENTATION
- "iso_fortran_env_impl"
-)
-
-# Define the list of Fortran module files for which it is
-# sufficient to generate the module file via -fsyntax-only.
-set(MODULES_WITHOUT_IMPLEMENTATION
- "__fortran_builtins"
- "__fortran_ieee_exceptions"
- "__fortran_type_info"
- "__ppc_types"
- "__ppc_intrinsics"
- "mma"
- "__cuda_builtins"
- "cudadevice"
- "ieee_arithmetic"
- "ieee_exceptions"
- "ieee_features"
- "iso_c_binding"
- "iso_fortran_env"
-)
-
-set(MODULES ${MODULES_WITH_IMPLEMENTATION} ${MODULES_WITHOUT_IMPLEMENTATION})
-
-# 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)
-
-# Figure out whether we can support REAL(KIND=16)
-if (FLANG_RUNTIME_F128_MATH_LIB)
- set(FLANG_SUPPORT_R16 "1")
-elseif (HAVE_LDBL_MANT_DIG_113)
- set(FLANG_SUPPORT_R16 "1")
-else()
- set(FLANG_SUPPORT_R16 "0")
-endif()
-
-# Init variable to hold extra object files coming from the Fortran modules;
-# these module files will be contributed from the CMakeLists in flang/tools/f18.
-set(module_objects "")
-
-# Create module files directly from the top-level module source directory.
-# If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
-# cross compiled, and thus can't be executed on the build system and thus
-# can't be used for generating module files.
-if (NOT CMAKE_CROSSCOMPILING)
- foreach(filename ${MODULES})
- set(depends "")
- set(opts "")
- if(${filename} STREQUAL "__fortran_builtins" OR
- ${filename} STREQUAL "__ppc_types")
- elseif(${filename} STREQUAL "__ppc_intrinsics" OR
- ${filename} STREQUAL "mma")
- set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__ppc_types.mod)
- elseif(${filename} STREQUAL "cudadevice")
- set(opts -fc1 -xcuda)
- set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__cuda_builtins.mod)
- else()
- set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
- if(${filename} STREQUAL "iso_fortran_env")
- set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/iso_fortran_env_impl.mod)
- endif()
- if(${filename} STREQUAL "ieee_arithmetic" OR
- ${filename} STREQUAL "ieee_exceptions")
- set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_ieee_exceptions.mod)
- endif()
- endif()
- if(NOT ${filename} STREQUAL "__fortran_type_info" AND NOT ${filename} STREQUAL "__fortran_builtins")
- set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_type_info.mod)
- endif()
-
- # The module contains PPC vector types that needs the PPC target.
- if(${filename} STREQUAL "__ppc_intrinsics" OR
- ${filename} STREQUAL "mma")
- if (PowerPC IN_LIST LLVM_TARGETS_TO_BUILD)
- set(opts "--target=ppc64le")
- else()
- # Do not compile PPC module if the target is not available.
- continue()
- endif()
- endif()
-
- set(decls "")
- if (FLANG_SUPPORT_R16)
- set(decls "-DFLANG_SUPPORT_R16")
- endif()
-
- # Some modules have an implementation part that needs to be added to the
- # FortranRuntime library.
- set(compile_with "-fsyntax-only")
- set(object_output "")
- set(include_in_link FALSE)
- if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION)
- set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}")
- set(compile_with -c -o ${object_output})
- set(include_in_link TRUE)
- endif()
-
- set(base ${FLANG_INTRINSIC_MODULES_DIR}/${filename})
- # TODO: We may need to flag this with conditional, in case Flang is built w/o OpenMP support
- add_custom_command(OUTPUT ${base}.mod ${object_output}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
- COMMAND flang-new ${opts} ${decls} -cpp ${compile_with} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
- ${FLANG_SOURCE_DIR}/module/${filename}.f90
- DEPENDS flang-new ${FLANG_SOURCE_DIR}/module/${filename}.f90 ${FLANG_SOURCE_DIR}/module/__fortran_builtins.f90 ${depends}
- )
- list(APPEND MODULE_FILES ${base}.mod)
- 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.
- 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
- # library.
- set(FORTRAN_MODULE_OBJECTS ${module_objects} CACHE INTERNAL "" FORCE)
-
- # Special case for omp_lib.mod, because its source comes from openmp/runtime/src/include.
- # It also produces two module files: omp_lib.mod and omp_lib_kinds.mod. Compile these
- # files only if OpenMP support has been configured.
- if (LLVM_TOOL_OPENMP_BUILD)
- message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.mod")
- set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
- add_custom_command(OUTPUT ${base}.mod ${base}_kinds.mod
- COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
- COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
- ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90
- DEPENDS flang-new ${FLANG_INTRINSIC_MODULES_DIR}/iso_c_binding.mod ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90 ${depends}
- )
- add_custom_command(OUTPUT ${base}.f18.mod
- DEPENDS ${base}.mod
- COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
- add_custom_command(OUTPUT ${base}_kinds.f18.mod
- DEPENDS ${base}.mod
- COMMAND ${CMAKE_COMMAND} -E copy ${base}_kinds.mod ${base}_kinds.f18.mod)
- list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod)
- install(FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
- else()
- message(STATUS "Not building omp_lib.mod, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
- endif()
-endif()
-
-add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
-set_target_properties(module_files PROPERTIES FOLDER "Flang/Resources")
-
-# TODO Move this to a more suitable location
-# Copy the generated omp_lib.h header file, if OpenMP support has been configured.
-if (LLVM_TOOL_OPENMP_BUILD)
- message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.h")
- file(COPY ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
- install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
-else()
- message(STATUS "Not copying omp_lib.h, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
-endif()
diff --git a/flang/tools/f18/dump.cpp b/flang/tools/f18/dump.cpp
deleted file mode 100644
index f11b5aedf4c6af..00000000000000
--- a/flang/tools/f18/dump.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-//===-- tools/f18/dump.cpp ------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// This file defines Dump routines available for calling from the debugger.
-// Each is based on operator<< for that type. There are overloadings for
-// reference and pointer, and for dumping to a provided raw_ostream or errs().
-
-#ifdef DEBUGF18
-
-#include "llvm/Support/raw_ostream.h"
-
-#define DEFINE_DUMP(ns, name) \
- namespace ns { \
- class name; \
- llvm::raw_ostream &operator<<(llvm::raw_ostream &, const name &); \
- } \
- void Dump(llvm::raw_ostream &os, const ns::name &x) { os << x << '\n'; } \
- void Dump(llvm::raw_ostream &os, const ns::name *x) { \
- if (x == nullptr) \
- os << "null\n"; \
- else \
- Dump(os, *x); \
- } \
- void Dump(const ns::name &x) { Dump(llvm::errs(), x); } \
- void Dump(const ns::name *x) { Dump(llvm::errs(), *x); }
-
-namespace Fortran {
-DEFINE_DUMP(parser, Name)
-DEFINE_DUMP(parser, CharBlock)
-DEFINE_DUMP(semantics, Symbol)
-DEFINE_DUMP(semantics, Scope)
-DEFINE_DUMP(semantics, IntrinsicTypeSpec)
-DEFINE_DUMP(semantics, DerivedTypeSpec)
-DEFINE_DUMP(semantics, DeclTypeSpec)
-} // namespace Fortran
-
-#endif
diff --git a/flang/tools/fir-opt/CMakeLists.txt b/flang/tools/fir-opt/CMakeLists.txt
index 4c6dbf7d9c8c37..3723ac5d7b37d2 100644
--- a/flang/tools/fir-opt/CMakeLists.txt
+++ b/flang/tools/fir-opt/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
add_flang_tool(fir-opt fir-opt.cpp)
llvm_update_compile_flags(fir-opt)
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
@@ -19,6 +20,7 @@ target_link_libraries(fir-opt PRIVATE
FIRCodeGen
HLFIRDialect
HLFIRTransforms
+ FortranCommon # FIXME: Dependency of something else
FlangOpenMPTransforms
FIRAnalysis
${test_libs}
diff --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt
index 9f33cdfe3fa90f..a2ad672b9d48c9 100644
--- a/flang/tools/flang-driver/CMakeLists.txt
+++ b/flang/tools/flang-driver/CMakeLists.txt
@@ -1,6 +1,9 @@
# Infrastructure to build flang driver entry point. Flang driver depends on
# LLVM libraries.
+message("include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include)")
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
+
# Set your project compile flags.
link_directories(${LLVM_LIBRARY_DIR})
diff --git a/flang/tools/tco/CMakeLists.txt b/flang/tools/tco/CMakeLists.txt
index 698a398547c773..f308fb6acbe98b 100644
--- a/flang/tools/tco/CMakeLists.txt
+++ b/flang/tools/tco/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
Passes
)
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
add_flang_tool(tco tco.cpp)
llvm_update_compile_flags(tco)
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
@@ -17,6 +18,7 @@ target_link_libraries(tco PRIVATE
FIRBuilder
HLFIRDialect
HLFIRTransforms
+ FortranCommon
FlangOpenMPTransforms
${dialect_libs}
${extension_libs}
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index 945067fed4f82d..f9953bd434d44e 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -1,40 +1,8 @@
-if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
- # If Fortran runtime is built as CUDA library, the linking
- # of targets that link FortranRuntime 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()
-
add_custom_target(FlangUnitTests)
set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests")
-function(add_flang_unittest_offload_properties target)
- # Set CUDA_RESOLVE_DEVICE_SYMBOLS.
- if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
- 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.
- # Common code must be moved from flang/runtime/CMakeLists.txt.
- if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "off")
- set_target_properties(${target}
- PROPERTIES LINK_OPTIONS
- "-fopenmp;--offload-arch=native"
- )
- endif()
-endfunction()
-
function(add_flang_unittest test_dirname)
add_unittest(FlangUnitTests ${test_dirname} ${ARGN})
- add_flang_unittest_offload_properties(${test_dirname})
endfunction()
if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
@@ -67,13 +35,8 @@ function(add_flang_nongtest_unittest test_name)
if(NOT ARG_SLOW_TEST)
add_dependencies(FlangUnitTests ${test_name}${suffix})
endif()
-
- add_flang_unittest_offload_properties(${test_name}${suffix})
endfunction()
add_subdirectory(Optimizer)
-add_subdirectory(Common)
-add_subdirectory(Decimal)
add_subdirectory(Evaluate)
-add_subdirectory(Runtime)
add_subdirectory(Frontend)
diff --git a/flang/unittests/Common/CMakeLists.txt b/flang/unittests/Common/CMakeLists.txt
deleted file mode 100644
index bda02ed29a5efa..00000000000000
--- a/flang/unittests/Common/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-add_flang_unittest(FlangCommonTests
- FastIntSetTest.cpp
-)
diff --git a/flang/unittests/Decimal/CMakeLists.txt b/flang/unittests/Decimal/CMakeLists.txt
deleted file mode 100644
index d301a9d3628c56..00000000000000
--- a/flang/unittests/Decimal/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-add_flang_nongtest_unittest(quick-sanity-test
- FortranDecimal
-)
-
-# This test is not run by default as it takes a long time to execute.
-add_flang_nongtest_unittest(thorough-test
- SLOW_TEST
- FortranDecimal
-)
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 52eb385f4763fb..a7f763d7b17d85 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -1,7 +1,7 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_library(FortranEvaluateTesting
- testing.cpp
- fp-testing.cpp
+ ${FORTRANRUNTIME_SOURCE_DIR}/lib/Testing/testing.cpp
+ ${FORTRANRUNTIME_SOURCE_DIR}/lib/Testing/fp-testing.cpp
)
set_target_properties(FortranEvaluateTesting PROPERTIES FOLDER "Flang/Tests")
if (LLVM_LINK_LLVM_DYLIB)
@@ -40,13 +40,12 @@ add_flang_nongtest_unittest(integer
)
add_flang_nongtest_unittest(intrinsics
+ FortranSupport
FortranCommon
FortranEvaluateTesting
FortranEvaluate
- FortranDecimal
FortranSemantics
FortranParser
- FortranRuntime
)
add_flang_nongtest_unittest(logical
@@ -64,25 +63,12 @@ set(LLVM_REQUIRES_RTTI ON)
add_flang_nongtest_unittest(real
FortranEvaluateTesting
FortranEvaluate
- FortranDecimal
+ FortranCommon
+ FortranSupport
FortranSemantics
)
llvm_update_compile_flags(real.test)
-add_flang_nongtest_unittest(reshape
- FortranEvaluateTesting
- FortranSemantics
- FortranEvaluate
- FortranRuntime
-)
-
-add_flang_nongtest_unittest(ISO-Fortran-binding
- FortranEvaluateTesting
- FortranEvaluate
- FortranSemantics
- FortranRuntime
-)
-
add_flang_nongtest_unittest(folding
FortranCommon
FortranEvaluateTesting
diff --git a/flang/unittests/Evaluate/bit-population-count.cpp b/flang/unittests/Evaluate/bit-population-count.cpp
index 24e721c14f94a7..0c9529a92e5724 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 f03a6bc2a4e23c..6349997bafee48 100644
--- a/flang/unittests/Evaluate/expression.cpp
+++ b/flang/unittests/Evaluate/expression.cpp
@@ -1,5 +1,5 @@
#include "flang/Evaluate/expression.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
diff --git a/flang/unittests/Evaluate/folding.cpp b/flang/unittests/Evaluate/folding.cpp
index 4e8ff9754e4ccb..35df702ff20ea6 100644
--- a/flang/unittests/Evaluate/folding.cpp
+++ b/flang/unittests/Evaluate/folding.cpp
@@ -1,4 +1,4 @@
-#include "testing.h"
+#include "flang/Testing/testing.h"
#include "../../lib/Evaluate/host.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/expression.h"
diff --git a/flang/unittests/Evaluate/integer.cpp b/flang/unittests/Evaluate/integer.cpp
index 3eabb2434cce60..5ab22cc6443a7b 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 86c471d2c62950..0baf01a4cb1b7e 100644
--- a/flang/unittests/Evaluate/intrinsics.cpp
+++ b/flang/unittests/Evaluate/intrinsics.cpp
@@ -1,5 +1,5 @@
#include "flang/Evaluate/intrinsics.h"
-#include "testing.h"
+#include "flang/Testing/testing.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/target.h"
diff --git a/flang/unittests/Evaluate/leading-zero-bit-count.cpp b/flang/unittests/Evaluate/leading-zero-bit-count.cpp
index 968946b69f27ea..25e2664e76df04 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 d79aff84487123..ee568371eab86c 100644
--- a/flang/unittests/Evaluate/logical.cpp
+++ b/flang/unittests/Evaluate/logical.cpp
@@ -1,4 +1,4 @@
-#include "testing.h"
+#include "flang/Testing/testing.h"
#include "flang/Evaluate/type.h"
#include <cstdio>
diff --git a/flang/unittests/Evaluate/real.cpp b/flang/unittests/Evaluate/real.cpp
index ccbaf81f054cb5..ab1a178df22312 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -1,5 +1,5 @@
-#include "fp-testing.h"
-#include "testing.h"
+#include "flang/Testing/fp-testing.h"
+#include "flang/Testing/testing.h"
#include "flang/Evaluate/type.h"
#include "llvm/Support/raw_ostream.h"
#include <cmath>
diff --git a/flang/unittests/Evaluate/uint128.cpp b/flang/unittests/Evaluate/uint128.cpp
index f05c1c96a7e8b0..0b749abe1c080a 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>
diff --git a/flang/unittests/Runtime/CUDA/CMakeLists.txt b/flang/unittests/Runtime/CUDA/CMakeLists.txt
deleted file mode 100644
index ed0caece3d15db..00000000000000
--- a/flang/unittests/Runtime/CUDA/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-if (FLANG_CUF_RUNTIME)
-
-add_flang_unittest(FlangCufRuntimeTests
- AllocatorCUF.cpp
-)
-
-target_link_libraries(FlangCufRuntimeTests
- PRIVATE
- CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
- FortranRuntime
-)
-
-target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
-
-endif()
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index 29c01da9e28f6d..e4e6a3bb52410f 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -51,7 +51,11 @@ AutoExporter::AutoExporter(
"libc++",
"libc++abi",
"libFortranRuntime",
- "libFortranDecimal",
+ "libFortranFloat128Math",
+ "libFortranRuntime.static",
+ "libFortranRuntime.dynamic",
+ "libFortranRuntime.static_dbg",
+ "libFortranRuntime.dynamic_dbg",
"libunwind",
"libmsvcrt",
"libucrtbase",
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index c637febce1c1fe..70f6f50ee5e11a 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -149,7 +149,7 @@ endif()
# 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;FortranRuntime")
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 f7e1165bc4b947..f49ce19b3f845c 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -34,6 +34,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
@@ -61,7 +63,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})
@@ -89,6 +91,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-new)
+ 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)
@@ -139,6 +144,10 @@ function(llvm_ExternalProject_Add name source_dir)
set(CLANG_IN_TOOLCHAIN On)
endif()
+ if(flang-new IN_LIST TOOLCHAIN_TOOLS)
+ set(FLANG_IN_TOOLCHAIN On)
+ endif()
+
if(RUNTIME_LIBRARIES AND CLANG_IN_TOOLCHAIN)
list(APPEND TOOLCHAIN_BINS ${RUNTIME_LIBRARIES})
endif()
@@ -221,6 +230,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-new${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})
@@ -304,6 +316,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}
@@ -353,6 +366,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 08f2fa522420b0..fab28c9df6d384 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}/FortranRuntime))
get_filename_component(entry_name "${entry}" NAME)
add_llvm_external_project(${entry_name})
endif()
@@ -37,6 +38,8 @@ if(${LLVM_BUILD_RUNTIME})
if(NOT LLVM_BUILD_EXTERNAL_COMPILER_RT)
add_llvm_external_project(compiler-rt)
endif()
+
+ add_llvm_external_project(FortranRuntime)
endif()
add_llvm_external_project(dragonegg)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 187c44fb9d04d2..e4389b120f49df 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -96,6 +96,7 @@ function(builtin_default_target compiler_rt_path)
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
-DLLVM_CMAKE_DIR=${CMAKE_BINARY_DIR}
-DCMAKE_C_COMPILER_WORKS=ON
+ -DCMAKE_Fortran_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
${COMMON_CMAKE_ARGS}
${BUILTINS_CMAKE_ARGS}
@@ -136,6 +137,7 @@ function(builtin_register_target compiler_rt_path name)
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
-DLLVM_CMAKE_DIR=${CMAKE_BINARY_DIR}
-DCMAKE_C_COMPILER_WORKS=ON
+ -DCMAKE_Fortran_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
${COMMON_CMAKE_ARGS}
@@ -261,6 +263,7 @@ function(runtime_default_target)
llvm_ExternalProject_Add(runtimes
${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
DEPENDS ${ARG_DEPENDS}
+ ${enable_fortran}
# Builtins were built separately above
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
@@ -270,6 +273,7 @@ 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}
@@ -396,6 +400,7 @@ function(runtime_register_target name)
llvm_ExternalProject_Add(runtimes-${name}
${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
DEPENDS ${ARG_DEPENDS}
+ ${enable_fortran}
# Builtins were built separately above
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
@@ -403,6 +408,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}
@@ -462,10 +468,12 @@ if(build_runtimes)
# together in a single CMake invocation.
set(extra_deps "")
set(extra_cmake_args "")
+ set(enable_fortran "")
if(LLVM_INCLUDE_TESTS)
foreach(dep FileCheck
clang
+ flang-new
count
lld
lli
@@ -502,18 +510,17 @@ if(build_runtimes)
list(APPEND extra_cmake_args "-DCMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}")
endif()
+ # FIXME: Go away
if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
- if (${LLVM_TOOL_FLANG_BUILD})
- message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
- set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
- set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
- # TODO: This is a workaround until flang becomes a first-class project
- # in llvm/CMakeList.txt. Until then, this line ensures that flang-new is
- # built before "openmp" is built as a runtime project. Besides "flang-new"
- # to build the compiler, we also need to add "module_files" to make sure
- # that all .mod files are also properly build.
- list(APPEND extra_deps "flang-new" "module_files")
- endif()
+ #if (LLVM_TOOL_FLANG_BUILD AND "FortranRuntime" IN_LIST LLVM_ENABLE_PROJECTS)
+ # message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
+ # set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new${CMAKE_EXECUTABLE_SUFFIX}")
+ # #TODO: set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
+ # list(APPEND extra_deps "flang-new")
+ #endif()
+ if (LLVM_TOOL_FLANG_BUILD AND "FortranRuntime" IN_LIST LLVM_ENABLE_PROJECTS)
+ set(enable_fortran ENABLE_FORTRAN)
+ endif ()
foreach(dep opt llvm-link llvm-extract clang clang-offload-packager)
if(TARGET ${dep})
list(APPEND extra_deps ${dep})
@@ -563,6 +570,9 @@ if(build_runtimes)
if(LLVM_LIBC_FULL_BUILD)
list(APPEND extra_cmake_args "-DLLVM_LIBC_FULL_BUILD=ON")
endif()
+ if("FortranRuntime" IN_LIST LLVM_ENABLE_RUNTIMES)
+ set(enable_fortran ENABLE_FORTRAN)
+ endif ()
if(NOT LLVM_RUNTIME_TARGETS)
runtime_default_target(
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 830165c799c2ab..d77b4da6e00e34 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -23,7 +23,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_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload;FortranRuntime")
set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc")
set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
"Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
@@ -49,6 +49,7 @@ function(runtime_register_component name)
set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
endfunction()
+message("LLVM_BINARY_DIR: ${LLVM_BINARY_DIR}")
find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
>From 7c697c49dc220449676a6f641a7624106d1df709 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 27 Sep 2024 18:58:16 +0200
Subject: [PATCH 02/58] Cleanup + reduce patch size
---
.../include/flang/Common/Fortran-consts.h | 8 +-
.../flang/Common/ISO_Fortran_binding.h | 8 +-
.../Common/ISO_Fortran_binding_wrapper.h | 8 +-
.../include/flang/Common/api-attrs.h | 6 +-
.../flang/Common/binary-floating-point.h | 6 +-
.../flang/Common/bit-population-count.h | 2 +-
.../include/flang/Common/constexpr-bitset.h | 2 +-
FortranRuntime/include/flang/Common/decimal.h | 6 +-
.../include/flang/Common/enum-class.h | 2 +-
.../include/flang/Common/enum-set.h | 2 +-
.../include/flang/Common/fast-int-set.h | 2 +-
FortranRuntime/include/flang/Common/format.h | 2 +-
FortranRuntime/include/flang/Common/idioms.h | 2 +-
.../flang/Common/leading-zero-bit-count.h | 2 +-
.../include/flang/Common/optional.h | 6 +-
FortranRuntime/include/flang/Common/real.h | 2 +-
.../include/flang/Common/reference-wrapper.h | 6 +-
.../include/flang/Common/restorer.h | 4 +-
.../include/flang/Common/target-rounding.h | 7 +-
FortranRuntime/include/flang/Common/uint128.h | 4 +-
FortranRuntime/include/flang/Common/variant.h | 6 +-
FortranRuntime/include/flang/Common/visit.h | 4 +-
.../include/flang/Common/windows-include.h | 2 +-
.../include/flang/Runtime/CUDA/allocator.h | 2 +-
.../include/flang/Runtime/CUDA/descriptor.h | 2 +-
.../include/flang/Runtime/allocatable.h | 2 +-
.../flang/Runtime/allocator-registry.h | 6 +-
.../include/flang/Runtime/array-constructor.h | 6 +-
FortranRuntime/include/flang/Runtime/assign.h | 2 +-
.../include/flang/Runtime/c-or-cpp.h | 2 +-
.../include/flang/Runtime/character.h | 2 +-
.../include/flang/Runtime/command.h | 2 +-
.../include/flang/Runtime/cpp-type.h | 2 +-
.../include/flang/Runtime/derived-api.h | 2 +-
.../include/flang/Runtime/descriptor.h | 2 +-
.../include/flang/Runtime/entry-names.h | 6 +-
.../include/flang/Runtime/exceptions.h | 2 +-
.../include/flang/Runtime/execute.h | 2 +-
.../include/flang/Runtime/extensions.h | 2 +-
.../flang/Runtime/freestanding-tools.h | 2 +-
.../include/flang/Runtime/inquiry.h | 2 +-
FortranRuntime/include/flang/Runtime/io-api.h | 2 +-
FortranRuntime/include/flang/Runtime/iostat.h | 2 +-
FortranRuntime/include/flang/Runtime/main.h | 2 +-
.../include/flang/Runtime/matmul-transpose.h | 2 +-
FortranRuntime/include/flang/Runtime/matmul.h | 2 +-
FortranRuntime/include/flang/Runtime/memory.h | 2 +-
.../include/flang/Runtime/misc-intrinsic.h | 2 +-
.../include/flang/Runtime/numeric.h | 2 +-
.../include/flang/Runtime/pointer.h | 2 +-
FortranRuntime/include/flang/Runtime/ragged.h | 2 +-
FortranRuntime/include/flang/Runtime/random.h | 5 +
FortranRuntime/include/flang/Runtime/reduce.h | 2 +-
.../include/flang/Runtime/reduction.h | 2 +-
FortranRuntime/include/flang/Runtime/stop.h | 2 +-
.../include/flang/Runtime/support.h | 2 +-
.../include/flang/Runtime/temporary-stack.h | 2 +-
.../include/flang/Runtime/time-intrinsic.h | 2 +-
.../include/flang/Runtime/transformational.h | 2 +-
.../include/flang/Runtime/type-code.h | 4 +-
.../include/flang/Testing/fp-testing.h | 8 +-
.../include/flang/Testing/testing.h | 6 +-
.../lib/Common/big-radix-floating-point.h | 10 +-
.../lib/Common/decimal-to-binary.cpp | 4 +-
FortranRuntime/lib/Runtime/CMakeLists.txt | 20 -
.../lib/Runtime/CUDA/CMakeLists.txt | 2 +-
FortranRuntime/lib/Runtime/CUDA/allocator.cpp | 2 +-
.../lib/Runtime/Float128Math/CMakeLists.txt | 2 +-
.../lib/Runtime/Float128Math/math-entries.h | 6 +-
.../Float128Math/numeric-template-specs.h | 2 +-
.../lib/Runtime/ISO_Fortran_binding.cpp | 2 +-
FortranRuntime/lib/Runtime/ISO_Fortran_util.h | 4 +-
FortranRuntime/lib/Runtime/allocatable.cpp | 6 +-
.../lib/Runtime/array-constructor.cpp | 6 +-
FortranRuntime/lib/Runtime/assign-impl.h | 2 +-
FortranRuntime/lib/Runtime/assign.cpp | 2 +-
FortranRuntime/lib/Runtime/buffer.h | 4 +-
FortranRuntime/lib/Runtime/character.cpp | 4 +-
FortranRuntime/lib/Runtime/command.cpp | 2 +-
.../lib/Runtime/complex-reduction.h | 2 +-
FortranRuntime/lib/Runtime/connection.h | 8 +-
FortranRuntime/lib/Runtime/copy.cpp | 4 +-
FortranRuntime/lib/Runtime/copy.h | 2 +-
FortranRuntime/lib/Runtime/derived-api.cpp | 2 +-
FortranRuntime/lib/Runtime/derived.cpp | 2 +-
FortranRuntime/lib/Runtime/derived.h | 2 +-
FortranRuntime/lib/Runtime/descriptor-io.h | 10 +-
FortranRuntime/lib/Runtime/descriptor.cpp | 2 +-
FortranRuntime/lib/Runtime/dot-product.cpp | 6 +-
FortranRuntime/lib/Runtime/edit-input.cpp | 4 +-
FortranRuntime/lib/Runtime/edit-input.h | 4 +-
FortranRuntime/lib/Runtime/edit-output.cpp | 2 +-
FortranRuntime/lib/Runtime/edit-output.h | 6 +-
FortranRuntime/lib/Runtime/emit-encoded.h | 2 +-
FortranRuntime/lib/Runtime/environment.h | 4 +-
FortranRuntime/lib/Runtime/execute.cpp | 2 +-
FortranRuntime/lib/Runtime/extensions.cpp | 4 +-
FortranRuntime/lib/Runtime/extrema.cpp | 2 +-
FortranRuntime/lib/Runtime/file.cpp | 2 +-
FortranRuntime/lib/Runtime/file.h | 4 +-
FortranRuntime/lib/Runtime/findloc.cpp | 2 +-
.../lib/Runtime/format-implementation.h | 8 +-
FortranRuntime/lib/Runtime/format.h | 6 +-
FortranRuntime/lib/Runtime/inquiry.cpp | 2 +-
FortranRuntime/lib/Runtime/internal-unit.cpp | 2 +-
FortranRuntime/lib/Runtime/internal-unit.h | 6 +-
FortranRuntime/lib/Runtime/io-api-common.h | 12 +-
FortranRuntime/lib/Runtime/io-api-minimal.cpp | 2 +-
FortranRuntime/lib/Runtime/io-api.cpp | 6 +-
FortranRuntime/lib/Runtime/io-error.cpp | 2 +-
FortranRuntime/lib/Runtime/io-error.h | 4 +-
FortranRuntime/lib/Runtime/io-stmt.cpp | 2 +-
FortranRuntime/lib/Runtime/io-stmt.h | 8 +-
FortranRuntime/lib/Runtime/lock.h | 2 +-
.../lib/Runtime/matmul-transpose.cpp | 4 +-
FortranRuntime/lib/Runtime/matmul.cpp | 4 +-
FortranRuntime/lib/Runtime/memory.cpp | 2 +-
FortranRuntime/lib/Runtime/misc-intrinsic.cpp | 4 +-
FortranRuntime/lib/Runtime/namelist.cpp | 2 +-
FortranRuntime/lib/Runtime/namelist.h | 4 +-
FortranRuntime/lib/Runtime/non-tbp-dio.h | 2 +-
.../lib/Runtime/numeric-templates.h | 6 +-
FortranRuntime/lib/Runtime/numeric.cpp | 2 +-
FortranRuntime/lib/Runtime/product.cpp | 2 +-
FortranRuntime/lib/Runtime/random-templates.h | 6 +-
FortranRuntime/lib/Runtime/random.cpp | 6 +-
FortranRuntime/lib/Runtime/reduce.cpp | 2 +-
.../lib/Runtime/reduction-templates.h | 6 +-
FortranRuntime/lib/Runtime/reduction.cpp | 2 +-
FortranRuntime/lib/Runtime/stack.h | 8 +-
FortranRuntime/lib/Runtime/stat.cpp | 2 +-
FortranRuntime/lib/Runtime/stat.h | 4 +-
FortranRuntime/lib/Runtime/sum.cpp | 2 +-
FortranRuntime/lib/Runtime/support.cpp | 2 +-
.../lib/Runtime/temporary-stack.cpp | 2 +-
FortranRuntime/lib/Runtime/terminator.h | 2 +-
FortranRuntime/lib/Runtime/time-intrinsic.cpp | 4 +-
FortranRuntime/lib/Runtime/tools.h | 6 +-
.../lib/Runtime/transformational.cpp | 4 +-
FortranRuntime/lib/Runtime/type-info.h | 4 +-
FortranRuntime/lib/Runtime/unit-map.h | 6 +-
FortranRuntime/lib/Runtime/unit.h | 12 +-
FortranRuntime/lib/Runtime/utf.h | 2 +-
FortranRuntime/lib/Testing/fp-testing.cpp | 8 -
.../unittests/Common/FastIntSetTest.cpp | 2 +-
.../Evaluate/ISO-Fortran-binding.cpp | 2 +-
FortranRuntime/unittests/Evaluate/reshape.cpp | 2 +-
.../unittests/Runtime/AccessTest.cpp | 2 +-
.../unittests/Runtime/Allocatable.cpp | 2 +-
.../unittests/Runtime/ArrayConstructor.cpp | 4 +-
.../unittests/Runtime/CUDA/AllocatorCUF.cpp | 4 +-
.../unittests/Runtime/CharacterTest.cpp | 2 +-
.../unittests/Runtime/CommandTest.cpp | 4 +-
FortranRuntime/unittests/Runtime/Complex.cpp | 2 +-
.../unittests/Runtime/CrashHandlerFixture.h | 6 +-
FortranRuntime/unittests/Runtime/Derived.cpp | 4 +-
.../unittests/Runtime/ExternalIOTest.cpp | 2 +-
FortranRuntime/unittests/Runtime/Inquiry.cpp | 4 +-
.../unittests/Runtime/ListInputTest.cpp | 2 +-
FortranRuntime/unittests/Runtime/Matmul.cpp | 4 +-
.../unittests/Runtime/MatmulTranspose.cpp | 4 +-
.../unittests/Runtime/MiscIntrinsic.cpp | 4 +-
FortranRuntime/unittests/Runtime/Namelist.cpp | 2 +-
FortranRuntime/unittests/Runtime/Numeric.cpp | 2 +-
FortranRuntime/unittests/Runtime/Pointer.cpp | 4 +-
FortranRuntime/unittests/Runtime/Random.cpp | 2 +-
.../unittests/Runtime/Reduction.cpp | 4 +-
.../unittests/Runtime/RuntimeCrashTest.cpp | 4 +-
FortranRuntime/unittests/Runtime/Stop.cpp | 2 +-
FortranRuntime/unittests/Runtime/Support.cpp | 4 +-
.../unittests/Runtime/TemporaryStack.cpp | 4 +-
FortranRuntime/unittests/Runtime/Time.cpp | 2 +-
.../unittests/Runtime/Transformational.cpp | 4 +-
FortranRuntime/unittests/Runtime/tools.h | 4 +-
flang/CMakeLists.txt | 2 +
flang/include/flang/Evaluate/call.h | 4 +-
.../include/flang/Evaluate/characteristics.h | 6 +-
flang/include/flang/Evaluate/common.h | 16 +-
flang/include/flang/Evaluate/expression.h | 4 +-
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 | 4 +-
flang/include/flang/Evaluate/variable.h | 2 +-
.../include/flang/Frontend/FrontendOptions.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/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/include/flang/Optimizer/Support/Utils.h | 2 +-
flang/include/flang/Parser/dump-parse-tree.h | 2 +-
flang/include/flang/Parser/message.h | 2 +-
flang/include/flang/Parser/parse-state.h | 2 +-
flang/include/flang/Parser/parse-tree.h | 2 +-
flang/include/flang/Parser/parsing.h | 2 +-
flang/include/flang/Parser/user-state.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 | 2 +-
flang/include/flang/Semantics/symbol.h | 4 +-
flang/include/flang/Semantics/tools.h | 2 +-
flang/include/flang/Semantics/type.h | 2 +-
.../include/flang/Support/Fortran-features.h | 2 +-
flang/include/flang/Support/Fortran.h | 16 +-
flang/include/flang/Support/template.h | 2 +-
flang/include/flang/Tools/CrossToolHelpers.h | 2 +-
flang/lib/Common/CMakeLists.txt | 8 -
flang/lib/Evaluate/call.cpp | 2 +-
flang/lib/Evaluate/characteristics.cpp | 2 +-
flang/lib/Evaluate/common.cpp | 1 -
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/real.cpp | 2 +-
flang/lib/Evaluate/shape.cpp | 2 +-
flang/lib/Evaluate/target.cpp | 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/CallInterface.cpp | 2 +-
flang/lib/Lower/ConvertExpr.cpp | 4 +-
flang/lib/Lower/Mangler.cpp | 2 +-
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 8 +-
flang/lib/Optimizer/CodeGen/TypeConverter.cpp | 2 +-
.../lib/Optimizer/Transforms/AddDebugInfo.cpp | 2 +-
.../Transforms/AssumedRankOpConversion.cpp | 2 +-
.../Optimizer/Transforms/CufOpConversion.cpp | 2 +-
.../Transforms/ExternalNameConversion.cpp | 2 +-
.../Transforms/SimplifyIntrinsics.cpp | 2 +-
.../lib/Optimizer/Transforms/StackReclaim.cpp | 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/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/Fortran-features.cpp | 2 +-
flang/lib/Support/big-radix-floating-point.h | 396 ------------------
flang/test/CMakeLists.txt | 1 -
flang/tools/bbc/bbc.cpp | 8 +-
flang/tools/f18-parse-demo/f18-parse-demo.cpp | 4 +-
flang/unittests/Evaluate/expression.cpp | 2 +-
flang/unittests/Evaluate/folding.cpp | 2 +-
flang/unittests/Evaluate/intrinsics.cpp | 2 +-
flang/unittests/Evaluate/logical.cpp | 2 +-
flang/unittests/Evaluate/real.cpp | 2 +-
lld/COFF/MinGW.cpp | 1 -
llvm/projects/CMakeLists.txt | 1 -
llvm/runtimes/CMakeLists.txt | 7 -
runtimes/CMakeLists.txt | 1 -
278 files changed, 441 insertions(+), 897 deletions(-)
delete mode 100644 flang/lib/Support/big-radix-floating-point.h
diff --git a/FortranRuntime/include/flang/Common/Fortran-consts.h b/FortranRuntime/include/flang/Common/Fortran-consts.h
index 3156c6c50c3b9a..eedcdae335c400 100644
--- a/FortranRuntime/include/flang/Common/Fortran-consts.h
+++ b/FortranRuntime/include/flang/Common/Fortran-consts.h
@@ -9,9 +9,6 @@
#ifndef FORTRAN_COMMON_FORTRAN_CONSTS_H_
#define FORTRAN_COMMON_FORTRAN_CONSTS_H_
-// Fortran language concepts that are used in many phases are defined
-// once here to avoid redundancy and needless translation.
-
#include "flang/Common/enum-class.h"
#include <cstdint>
@@ -21,7 +18,6 @@ namespace Fortran::common {
ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
ENUM_CLASS(VectorElementCategory, Integer, Unsigned, Real)
-
ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
Print, Read, Rewind, Wait, Write)
@@ -32,7 +28,6 @@ ENUM_CLASS(
// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
static constexpr int maxRank{15};
-
// Floating-point rounding modes; these are packed into a byte to save
// room in the runtime's format processing context structure. These
// enumerators are defined with the corresponding values returned from
@@ -45,6 +40,5 @@ enum class RoundingMode : std::uint8_t {
TiesAwayFromZero, // ROUND=COMPATIBLE, RC - ties round away from zero
};
-
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORTRAN_CONSTS_H_
+#endif /* FORTRAN_COMMON_FORTRAN_CONSTS_H_ */
diff --git a/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
index 21247103bcc552..516355c01ec7d0 100644
--- a/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
@@ -6,14 +6,14 @@
*
*===----------------------------------------------------------------------===*/
-#ifndef CFI_ISO_FORTRAN_BINDING_H_
-#define CFI_ISO_FORTRAN_BINDING_H_
+#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_
+#define FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_
/* When this header is included into the compiler and runtime implementations,
* 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
@@ -206,4 +206,4 @@ RT_API_ATTRS int CFI_setpointer(
} // extern "C"
#endif
-#endif /* CFI_ISO_FORTRAN_BINDING_H_ */
+#endif /* FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_ */
diff --git a/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
index ee02f6f129732e..d1bc9be34859a4 100644
--- a/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -6,8 +6,8 @@
*
*===----------------------------------------------------------------------===*/
-#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
@@ -22,7 +22,7 @@
/* clang-format off */
#include <stddef.h>
-#include "flang/Common/api-attrs.h"
+#include "flang/Common/api-attrs.h"
#ifdef __cplusplus
namespace Fortran {
namespace ISO {
@@ -35,4 +35,4 @@ namespace ISO {
#endif /* __cplusplus */
/* clang-format on */
-#endif /* FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_ */
+#endif /* FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_ */
diff --git a/FortranRuntime/include/flang/Common/api-attrs.h b/FortranRuntime/include/flang/Common/api-attrs.h
index b56a3c8a047af6..9a3001fb255c11 100644
--- a/FortranRuntime/include/flang/Common/api-attrs.h
+++ b/FortranRuntime/include/flang/Common/api-attrs.h
@@ -12,8 +12,8 @@
* declared/defined/used in Flang runtime library.
*/
-#ifndef FORTRAN_RUNTIME_API_ATTRS_H_
-#define FORTRAN_RUNTIME_API_ATTRS_H_
+#ifndef FORTRAN_COMMON_API_ATTRS_H_
+#define FORTRAN_COMMON_API_ATTRS_H_
/*
* RT_EXT_API_GROUP_BEGIN/END pair is placed around definitions
@@ -177,4 +177,4 @@
#define RT_DEVICE_NOINLINE_HOST_INLINE inline
#endif
-#endif /* !FORTRAN_RUNTIME_API_ATTRS_H_ */
+#endif /* FORTRAN_COMMON_API_ATTRS_H_ */
diff --git a/FortranRuntime/include/flang/Common/binary-floating-point.h b/FortranRuntime/include/flang/Common/binary-floating-point.h
index 1409b94192740c..705acc31bdfb21 100644
--- a/FortranRuntime/include/flang/Common/binary-floating-point.h
+++ b/FortranRuntime/include/flang/Common/binary-floating-point.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_DECIMAL_BINARY_FLOATING_POINT_H_
-#define FORTRAN_DECIMAL_BINARY_FLOATING_POINT_H_
+#ifndef FORTRAN_COMMON_BINARY_FLOATING_POINT_H_
+#define FORTRAN_COMMON_BINARY_FLOATING_POINT_H_
// Access and manipulate the fields of an IEEE-754 binary
// floating-point value via a generalized template.
@@ -208,4 +208,4 @@ template <int BINARY_PRECISION> class BinaryFloatingPointNumber {
RawType raw_{0};
};
} // namespace Fortran::decimal
-#endif
+#endif /* FORTRAN_COMMON_BINARY_FLOATING_POINT_H_ */
diff --git a/FortranRuntime/include/flang/Common/bit-population-count.h b/FortranRuntime/include/flang/Common/bit-population-count.h
index e1aeb78f9a3765..59ade914d14d85 100644
--- a/FortranRuntime/include/flang/Common/bit-population-count.h
+++ b/FortranRuntime/include/flang/Common/bit-population-count.h
@@ -93,4 +93,4 @@ template <typename INT> inline constexpr int TrailingZeroBitCount(INT x) {
}
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_BIT_POPULATION_COUNT_H_
+#endif /* FORTRAN_COMMON_BIT_POPULATION_COUNT_H_ */
diff --git a/FortranRuntime/include/flang/Common/constexpr-bitset.h b/FortranRuntime/include/flang/Common/constexpr-bitset.h
index 1aafb6eff84c61..093b247b5f4eff 100644
--- a/FortranRuntime/include/flang/Common/constexpr-bitset.h
+++ b/FortranRuntime/include/flang/Common/constexpr-bitset.h
@@ -144,4 +144,4 @@ template <int BITS> class BitSet {
Word bits_{0};
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_CONSTEXPR_BITSET_H_
+#endif /* FORTRAN_COMMON_CONSTEXPR_BITSET_H_ */
diff --git a/FortranRuntime/include/flang/Common/decimal.h b/FortranRuntime/include/flang/Common/decimal.h
index 2a75b98c112225..c086f97129f6a5 100644
--- a/FortranRuntime/include/flang/Common/decimal.h
+++ b/FortranRuntime/include/flang/Common/decimal.h
@@ -8,8 +8,8 @@
/* C and C++ API for binary-to/from-decimal conversion package. */
-#ifndef FORTRAN_DECIMAL_DECIMAL_H_
-#define FORTRAN_DECIMAL_DECIMAL_H_
+#ifndef FORTRAN_COMMON_DECIMAL_H_
+#define FORTRAN_COMMON_DECIMAL_H_
#include "flang/Common/api-attrs.h"
#include <stddef.h>
@@ -136,4 +136,4 @@ RT_API_ATTRS enum NS(ConversionResultFlags) ConvertDecimalToLongDouble(
#ifdef __cplusplus
} // extern "C"
#endif
-#endif
+#endif /* FORTRAN_COMMON_DECIMAL_H_ */
diff --git a/FortranRuntime/include/flang/Common/enum-class.h b/FortranRuntime/include/flang/Common/enum-class.h
index 41575d45091a8d..787648ffec48e8 100644
--- a/FortranRuntime/include/flang/Common/enum-class.h
+++ b/FortranRuntime/include/flang/Common/enum-class.h
@@ -69,4 +69,4 @@ constexpr std::array<std::string_view, ITEMS> EnumNames(const char *p) {
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_ENUM_CLASS_H_
+#endif /* FORTRAN_COMMON_ENUM_CLASS_H_ */
diff --git a/FortranRuntime/include/flang/Common/enum-set.h b/FortranRuntime/include/flang/Common/enum-set.h
index 5290b76debee88..6100fc5e2e31c5 100644
--- a/FortranRuntime/include/flang/Common/enum-set.h
+++ b/FortranRuntime/include/flang/Common/enum-set.h
@@ -228,4 +228,4 @@ struct std::hash<Fortran::common::EnumSet<ENUM, values>> {
return std::hash(x.bitset());
}
};
-#endif // FORTRAN_COMMON_ENUM_SET_H_
+#endif /* FORTRAN_COMMON_ENUM_SET_H_ */
diff --git a/FortranRuntime/include/flang/Common/fast-int-set.h b/FortranRuntime/include/flang/Common/fast-int-set.h
index 48209a773c4cd1..323ee4dc7e94d9 100644
--- a/FortranRuntime/include/flang/Common/fast-int-set.h
+++ b/FortranRuntime/include/flang/Common/fast-int-set.h
@@ -103,4 +103,4 @@ template <int N> class FastIntSet {
bool isFullyInitialized_{false}; // memory was cleared
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_FAST_INT_SET_H_
+#endif /* FORTRAN_COMMON_FAST_INT_SET_H_ */
diff --git a/FortranRuntime/include/flang/Common/format.h b/FortranRuntime/include/flang/Common/format.h
index 138e84b72b733d..6f4dfc8d2376b7 100644
--- a/FortranRuntime/include/flang/Common/format.h
+++ b/FortranRuntime/include/flang/Common/format.h
@@ -901,4 +901,4 @@ template <typename CHAR> bool FormatValidator<CHAR>::Check() {
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORMAT_H_
+#endif /* FORTRAN_COMMON_FORMAT_H_ */
diff --git a/FortranRuntime/include/flang/Common/idioms.h b/FortranRuntime/include/flang/Common/idioms.h
index 99f383ec75b999..1ae0c0b35112e9 100644
--- a/FortranRuntime/include/flang/Common/idioms.h
+++ b/FortranRuntime/include/flang/Common/idioms.h
@@ -150,4 +150,4 @@ template <typename A, typename... B>
using IfNoLvalue = std::enable_if_t<(... && !std::is_lvalue_reference_v<B>), A>;
template <typename... RVREF> using NoLvalue = IfNoLvalue<void, RVREF...>;
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_IDIOMS_H_
+#endif /* FORTRAN_COMMON_IDIOMS_H_ */
diff --git a/FortranRuntime/include/flang/Common/leading-zero-bit-count.h b/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
index a296e0b446917f..e788bfa9bcfd08 100644
--- a/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
+++ b/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
@@ -93,4 +93,4 @@ template <typename A> inline constexpr int BitsNeededFor(A x) {
return 8 * sizeof x - LeadingZeroBitCount(x);
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_LEADING_ZERO_BIT_COUNT_H_
+#endif /* FORTRAN_COMMON_LEADING_ZERO_BIT_COUNT_H_ */
diff --git a/FortranRuntime/include/flang/Common/optional.h b/FortranRuntime/include/flang/Common/optional.h
index c0f4278009f40a..c3db3b1329a2fd 100644
--- a/FortranRuntime/include/flang/Common/optional.h
+++ b/FortranRuntime/include/flang/Common/optional.h
@@ -23,8 +23,8 @@
// * cuda:: namespace need to be forced for all std:: references.
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_OPTIONAL_H
-#define FORTRAN_COMMON_OPTIONAL_H
+#ifndef FORTRAN_COMMON_OPTIONAL_H_
+#define FORTRAN_COMMON_OPTIONAL_H_
#include "flang/Common/api-attrs.h"
#include <optional>
@@ -240,4 +240,4 @@ using std::optional;
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_OPTIONAL_H
+#endif /* FORTRAN_COMMON_OPTIONAL_H_ */
diff --git a/FortranRuntime/include/flang/Common/real.h b/FortranRuntime/include/flang/Common/real.h
index b527deda0e3b4f..dc9a2404731e70 100644
--- a/FortranRuntime/include/flang/Common/real.h
+++ b/FortranRuntime/include/flang/Common/real.h
@@ -141,4 +141,4 @@ class RealCharacteristics {
};
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_REAL_H_
+#endif /* FORTRAN_COMMON_REAL_H_ */
diff --git a/FortranRuntime/include/flang/Common/reference-wrapper.h b/FortranRuntime/include/flang/Common/reference-wrapper.h
index 2983754108f95a..6822fb335f398c 100644
--- a/FortranRuntime/include/flang/Common/reference-wrapper.h
+++ b/FortranRuntime/include/flang/Common/reference-wrapper.h
@@ -22,8 +22,8 @@
//
// clang-format on
-#ifndef FORTRAN_COMMON_REFERENCE_WRAPPER_H
-#define FORTRAN_COMMON_REFERENCE_WRAPPER_H
+#ifndef FORTRAN_COMMON_REFERENCE_WRAPPER_H_
+#define FORTRAN_COMMON_REFERENCE_WRAPPER_H_
#include "flang/Common/api-attrs.h"
#include <functional>
@@ -111,4 +111,4 @@ using std::reference_wrapper;
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_REFERENCE_WRAPPER_H
+#endif /* FORTRAN_COMMON_REFERENCE_WRAPPER_H_ */
diff --git a/FortranRuntime/include/flang/Common/restorer.h b/FortranRuntime/include/flang/Common/restorer.h
index 0f1bc48620d37e..a5c5ebe7344a1b 100644
--- a/FortranRuntime/include/flang/Common/restorer.h
+++ b/FortranRuntime/include/flang/Common/restorer.h
@@ -18,8 +18,8 @@
#ifndef FORTRAN_COMMON_RESTORER_H_
#define FORTRAN_COMMON_RESTORER_H_
-#include "idioms.h"
#include "flang/Common/api-attrs.h"
+#include "idioms.h"
namespace Fortran::common {
template <typename A> class Restorer {
public:
@@ -53,4 +53,4 @@ RT_API_ATTRS common::IfNoLvalue<Restorer<A>, B> ScopedSet(
return Restorer<A>{to, std::move(original)};
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_RESTORER_H_
+#endif /* FORTRAN_COMMON_RESTORER_H_ */
diff --git a/FortranRuntime/include/flang/Common/target-rounding.h b/FortranRuntime/include/flang/Common/target-rounding.h
index 970d8fb61fbd1b..c0c9f6c49b26a2 100644
--- a/FortranRuntime/include/flang/Common/target-rounding.h
+++ b/FortranRuntime/include/flang/Common/target-rounding.h
@@ -9,11 +9,9 @@
#ifndef FORTRAN_COMMON_TARGET_ROUNDING_H_
#define FORTRAN_COMMON_TARGET_ROUNDING_H_
-
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/enum-set.h"
-
namespace Fortran::common {
// Floating-point rounding control
@@ -30,11 +28,10 @@ struct Rounding {
#endif
};
-
// These are ordered like the bits in a common fenv.h header file.
ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
Inexact)
using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;
-}
-#endif // FORTRAN_COMMON_TARGET_ROUNDING_H_
+} // namespace Fortran::common
+#endif /* FORTRAN_COMMON_TARGET_ROUNDING_H_ */
diff --git a/FortranRuntime/include/flang/Common/uint128.h b/FortranRuntime/include/flang/Common/uint128.h
index 821c8c3b08a52f..1b2ee6a2c14b87 100644
--- a/FortranRuntime/include/flang/Common/uint128.h
+++ b/FortranRuntime/include/flang/Common/uint128.h
@@ -19,8 +19,8 @@
#define AVOID_NATIVE_UINT128_T 0
#endif
-#include "leading-zero-bit-count.h"
#include "flang/Common/api-attrs.h"
+#include "leading-zero-bit-count.h"
#include <cstdint>
#include <type_traits>
@@ -303,4 +303,4 @@ template <int BITS>
using HostSignedIntType = typename HostSignedIntTypeHelper<BITS>::type;
} // namespace Fortran::common
-#endif
+#endif /* FORTRAN_COMMON_UINT128_H_ */
diff --git a/FortranRuntime/include/flang/Common/variant.h b/FortranRuntime/include/flang/Common/variant.h
index 1af85876afac00..ff9b1aed4eba91 100644
--- a/FortranRuntime/include/flang/Common/variant.h
+++ b/FortranRuntime/include/flang/Common/variant.h
@@ -11,8 +11,8 @@
// and the related names become available, though, they may correspond
// to alternative definitions (e.g. from cuda::std namespace).
-#ifndef FORTRAN_COMMON_VARIANT_H
-#define FORTRAN_COMMON_VARIANT_H
+#ifndef FORTRAN_COMMON_VARIANT_H_
+#define FORTRAN_COMMON_VARIANT_H_
#if RT_USE_LIBCUDACXX
#include <cuda/std/variant>
@@ -27,4 +27,4 @@ using cuda::std::visit;
#include <variant>
#endif // !RT_USE_LIBCUDACXX
-#endif // FORTRAN_COMMON_VARIANT_H
+#endif /* FORTRAN_COMMON_VARIANT_H_ */
diff --git a/FortranRuntime/include/flang/Common/visit.h b/FortranRuntime/include/flang/Common/visit.h
index ad66297650b093..8030ac9be173c3 100644
--- a/FortranRuntime/include/flang/Common/visit.h
+++ b/FortranRuntime/include/flang/Common/visit.h
@@ -21,8 +21,8 @@
#ifndef FORTRAN_COMMON_VISIT_H_
#define FORTRAN_COMMON_VISIT_H_
-#include "variant.h"
#include "flang/Common/api-attrs.h"
+#include "variant.h"
#include <type_traits>
namespace Fortran::common {
@@ -100,4 +100,4 @@ using Fortran::common::log2visit::visit;
#endif
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_VISIT_H_
+#endif /* FORTRAN_COMMON_VISIT_H_ */
diff --git a/FortranRuntime/include/flang/Common/windows-include.h b/FortranRuntime/include/flang/Common/windows-include.h
index 75ef4974251ff9..bee79d4fceb3ba 100644
--- a/FortranRuntime/include/flang/Common/windows-include.h
+++ b/FortranRuntime/include/flang/Common/windows-include.h
@@ -22,4 +22,4 @@
#endif // _WIN32
-#endif // FORTRAN_COMMON_WINDOWS_INCLUDE_H_
+#endif /* FORTRAN_COMMON_WINDOWS_INCLUDE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/CUDA/allocator.h b/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
index 4527c9f18fa054..48185e8f34eaf6 100644
--- a/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
+++ b/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
@@ -43,4 +43,4 @@ void *CUFAllocUnified(std::size_t);
void CUFFreeUnified(void *);
} // namespace Fortran::runtime::cuda
-#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
+#endif /* FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h b/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
index d593989420420f..68ad0987d9aecd 100644
--- a/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
+++ b/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
@@ -27,4 +27,4 @@ void RTDECL(CUFFreeDesciptor)(
} // extern "C"
} // namespace Fortran::runtime::cuda
-#endif // FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_
+#endif /* FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/allocatable.h b/FortranRuntime/include/flang/Runtime/allocatable.h
index 58061d9862095e..d7f3910074a760 100644
--- a/FortranRuntime/include/flang/Runtime/allocatable.h
+++ b/FortranRuntime/include/flang/Runtime/allocatable.h
@@ -129,4 +129,4 @@ void RTDECL(AllocatableDeallocateNoFinal)(
Descriptor &, const char *sourceFile = nullptr, int sourceLine = 0);
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ALLOCATABLE_H_
+#endif /* FORTRAN_RUNTIME_ALLOCATABLE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/allocator-registry.h b/FortranRuntime/include/flang/Runtime/allocator-registry.h
index 411cc68f58ec33..4e7d9bcedfb375 100644
--- a/FortranRuntime/include/flang/Runtime/allocator-registry.h
+++ b/FortranRuntime/include/flang/Runtime/allocator-registry.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_ALLOCATOR_H_
-#define FORTRAN_RUNTIME_ALLOCATOR_H_
+#ifndef FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
+#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
#include "flang/Common/api-attrs.h"
#include <cstdlib>
@@ -62,4 +62,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ALLOCATOR_H_
+#endif /* FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/array-constructor.h b/FortranRuntime/include/flang/Runtime/array-constructor.h
index 46fc0418c7991e..82367756f5dc79 100644
--- a/FortranRuntime/include/flang/Runtime/array-constructor.h
+++ b/FortranRuntime/include/flang/Runtime/array-constructor.h
@@ -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 FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
-#define FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
+#ifndef FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
+#define FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/entry-names.h"
@@ -115,4 +115,4 @@ void RTDECL(PushArrayConstructorSimpleScalar)(
ArrayConstructorVector &vector, void *from);
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
+#endif /* FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/assign.h b/FortranRuntime/include/flang/Runtime/assign.h
index a1cc9eaf4355f6..55d15a5c046868 100644
--- a/FortranRuntime/include/flang/Runtime/assign.h
+++ b/FortranRuntime/include/flang/Runtime/assign.h
@@ -58,4 +58,4 @@ void RTDECL(AssignPolymorphic)(Descriptor &to, const Descriptor &from,
const char *sourceFile = nullptr, int sourceLine = 0);
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ASSIGN_H_
+#endif /* FORTRAN_RUNTIME_ASSIGN_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/c-or-cpp.h b/FortranRuntime/include/flang/Runtime/c-or-cpp.h
index 8bac523907750c..3c0c0be643cbc3 100644
--- a/FortranRuntime/include/flang/Runtime/c-or-cpp.h
+++ b/FortranRuntime/include/flang/Runtime/c-or-cpp.h
@@ -28,4 +28,4 @@
#define NORETURN IF_CPLUSPLUS([[noreturn]])
#define NO_ARGUMENTS IF_NOT_CPLUSPLUS(void)
-#endif // FORTRAN_RUNTIME_C_OR_CPP_H_
+#endif /* FORTRAN_RUNTIME_C_OR_CPP_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/character.h b/FortranRuntime/include/flang/Runtime/character.h
index dd47686fe858fd..a842c30cd8120c 100644
--- a/FortranRuntime/include/flang/Runtime/character.h
+++ b/FortranRuntime/include/flang/Runtime/character.h
@@ -129,4 +129,4 @@ void RTDECL(Verify)(Descriptor &result, const Descriptor &string,
const char *sourceFile = nullptr, int sourceLine = 0);
}
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_CHARACTER_H_
+#endif /* FORTRAN_RUNTIME_CHARACTER_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/command.h b/FortranRuntime/include/flang/Runtime/command.h
index 7ab3f6442dcf92..2bbdfca7631163 100644
--- a/FortranRuntime/include/flang/Runtime/command.h
+++ b/FortranRuntime/include/flang/Runtime/command.h
@@ -62,4 +62,4 @@ std::int32_t RTNAME(GetCwd)(
}
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_COMMAND_H_
+#endif /* FORTRAN_RUNTIME_COMMAND_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/cpp-type.h b/FortranRuntime/include/flang/Runtime/cpp-type.h
index 27b43de7d0f0f6..7de1ea4f45f224 100644
--- a/FortranRuntime/include/flang/Runtime/cpp-type.h
+++ b/FortranRuntime/include/flang/Runtime/cpp-type.h
@@ -110,4 +110,4 @@ template <> struct CppTypeForHelper<TypeCategory::Logical, 1> {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_CPP_TYPE_H_
+#endif /* FORTRAN_RUNTIME_CPP_TYPE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/derived-api.h b/FortranRuntime/include/flang/Runtime/derived-api.h
index 79aa7d82de8819..ca1681e974051c 100644
--- a/FortranRuntime/include/flang/Runtime/derived-api.h
+++ b/FortranRuntime/include/flang/Runtime/derived-api.h
@@ -63,4 +63,4 @@ bool RTDECL(ExtendsTypeOf)(const Descriptor &, const Descriptor &);
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_DERIVED_API_H_
+#endif /* FORTRAN_RUNTIME_DERIVED_API_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/descriptor.h b/FortranRuntime/include/flang/Runtime/descriptor.h
index 2fe5b11200cf6d..867f4d4ee29ac0 100644
--- a/FortranRuntime/include/flang/Runtime/descriptor.h
+++ b/FortranRuntime/include/flang/Runtime/descriptor.h
@@ -492,4 +492,4 @@ class alignas(Descriptor) StaticDescriptor {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_DESCRIPTOR_H_
+#endif /* FORTRAN_RUNTIME_DESCRIPTOR_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/entry-names.h b/FortranRuntime/include/flang/Runtime/entry-names.h
index 52de2496d9421d..25134771bf9185 100644
--- a/FortranRuntime/include/flang/Runtime/entry-names.h
+++ b/FortranRuntime/include/flang/Runtime/entry-names.h
@@ -15,8 +15,8 @@
* The value of REVISION should not be changed until/unless the API to the
* runtime library must change in some way that breaks backward compatibility.
*/
-#ifndef FORTRAN_RUNTIME_ENTRY_NAMES_H
-#define FORTRAN_RUNTIME_ENTRY_NAMES_H
+#ifndef FORTRAN_RUNTIME_ENTRY_NAMES_H_
+#define FORTRAN_RUNTIME_ENTRY_NAMES_H_
#include "flang/Common/api-attrs.h"
@@ -40,4 +40,4 @@
#define RTNAME_STRING(name) RTNAME_STRINGIFY(RTNAME(name))
#endif
-#endif /* !FORTRAN_RUNTIME_ENTRY_NAMES_H */
+#endif /* FORTRAN_RUNTIME_ENTRY_NAMES_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/exceptions.h b/FortranRuntime/include/flang/Runtime/exceptions.h
index 1fb74e14e54d30..f2c67325b34d92 100644
--- a/FortranRuntime/include/flang/Runtime/exceptions.h
+++ b/FortranRuntime/include/flang/Runtime/exceptions.h
@@ -26,4 +26,4 @@ std::uint32_t RTNAME(MapException)(std::uint32_t excepts);
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_EXCEPTIONS_H_
+#endif /* FORTRAN_RUNTIME_EXCEPTIONS_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/execute.h b/FortranRuntime/include/flang/Runtime/execute.h
index ba3e950ca92941..d1958a82594ffd 100644
--- a/FortranRuntime/include/flang/Runtime/execute.h
+++ b/FortranRuntime/include/flang/Runtime/execute.h
@@ -26,4 +26,4 @@ void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait = true,
}
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_EXECUTE_H_
+#endif /* FORTRAN_RUNTIME_EXECUTE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/extensions.h b/FortranRuntime/include/flang/Runtime/extensions.h
index fef651f3b2eedb..f46ccdd7d9528d 100644
--- a/FortranRuntime/include/flang/Runtime/extensions.h
+++ b/FortranRuntime/include/flang/Runtime/extensions.h
@@ -52,4 +52,4 @@ std::int64_t FORTRAN_PROCEDURE_NAME(access)(const char *name,
#endif
} // extern "C"
-#endif // FORTRAN_RUNTIME_EXTENSIONS_H_
+#endif /* FORTRAN_RUNTIME_EXTENSIONS_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/freestanding-tools.h b/FortranRuntime/include/flang/Runtime/freestanding-tools.h
index e94cb0a6c938cd..8aeef54ba0af3d 100644
--- a/FortranRuntime/include/flang/Runtime/freestanding-tools.h
+++ b/FortranRuntime/include/flang/Runtime/freestanding-tools.h
@@ -215,4 +215,4 @@ using std::toupper;
#endif // !STD_TOUPPER_UNSUPPORTED
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_FREESTANDING_TOOLS_H_
+#endif /* FORTRAN_RUNTIME_FREESTANDING_TOOLS_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/inquiry.h b/FortranRuntime/include/flang/Runtime/inquiry.h
index 36ef929ed5b2f1..83b07cf2f31a47 100644
--- a/FortranRuntime/include/flang/Runtime/inquiry.h
+++ b/FortranRuntime/include/flang/Runtime/inquiry.h
@@ -40,4 +40,4 @@ void RTDECL(Ubound)(void *result, const Descriptor &array, int kind,
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_INQUIRY_H_
+#endif /* FORTRAN_RUNTIME_INQUIRY_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/io-api.h b/FortranRuntime/include/flang/Runtime/io-api.h
index 328afc715a3f1e..367146a4925c53 100644
--- a/FortranRuntime/include/flang/Runtime/io-api.h
+++ b/FortranRuntime/include/flang/Runtime/io-api.h
@@ -369,4 +369,4 @@ enum Iostat IODECL(EndIoStatement)(Cookie);
} // extern "C"
} // namespace Fortran::runtime::io
-#endif
+#endif /* FORTRAN_RUNTIME_IO_API_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/iostat.h b/FortranRuntime/include/flang/Runtime/iostat.h
index 6ce7c82b424eb7..a5a2a560f05f8d 100644
--- a/FortranRuntime/include/flang/Runtime/iostat.h
+++ b/FortranRuntime/include/flang/Runtime/iostat.h
@@ -92,4 +92,4 @@ enum Iostat {
RT_API_ATTRS const char *IostatErrorString(int);
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IOSTAT_H_
+#endif /* FORTRAN_RUNTIME_IOSTAT_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/main.h b/FortranRuntime/include/flang/Runtime/main.h
index 88232ea64fa6ab..98fcf1250d0ad6 100644
--- a/FortranRuntime/include/flang/Runtime/main.h
+++ b/FortranRuntime/include/flang/Runtime/main.h
@@ -20,4 +20,4 @@ void RTNAME(ProgramStart)(
void RTNAME(ByteswapOption)(void); // -byteswapio
FORTRAN_EXTERN_C_END
-#endif // FORTRAN_RUNTIME_MAIN_H_
+#endif /* FORTRAN_RUNTIME_MAIN_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/matmul-transpose.h b/FortranRuntime/include/flang/Runtime/matmul-transpose.h
index 2d79ca10e08958..077277fae2da86 100644
--- a/FortranRuntime/include/flang/Runtime/matmul-transpose.h
+++ b/FortranRuntime/include/flang/Runtime/matmul-transpose.h
@@ -46,4 +46,4 @@ void RTDECL(MatmulTransposeDirect)(const Descriptor &, const Descriptor &,
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_MATMUL_TRANSPOSE_H_
+#endif /* FORTRAN_RUNTIME_MATMUL_TRANSPOSE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/matmul.h b/FortranRuntime/include/flang/Runtime/matmul.h
index a72d4a06ee4594..cd375ac43d77f2 100644
--- a/FortranRuntime/include/flang/Runtime/matmul.h
+++ b/FortranRuntime/include/flang/Runtime/matmul.h
@@ -45,4 +45,4 @@ void RTDECL(MatmulDirect)(const Descriptor &, const Descriptor &,
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_MATMUL_H_
+#endif /* FORTRAN_RUNTIME_MATMUL_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/memory.h b/FortranRuntime/include/flang/Runtime/memory.h
index 98412a989f890b..84af4d7189c074 100644
--- a/FortranRuntime/include/flang/Runtime/memory.h
+++ b/FortranRuntime/include/flang/Runtime/memory.h
@@ -170,4 +170,4 @@ template <typename A> struct Allocator {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_MEMORY_H_
+#endif /* FORTRAN_RUNTIME_MEMORY_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/misc-intrinsic.h b/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
index 3fb3aaed49c0fb..1d4163c2e1e751 100644
--- a/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
+++ b/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
@@ -28,4 +28,4 @@ void RTDECL(TransferSize)(Descriptor &result, const Descriptor &source,
std::int64_t size);
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_MISC_INTRINSIC_H_
+#endif /* FORTRAN_RUNTIME_MISC_INTRINSIC_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/numeric.h b/FortranRuntime/include/flang/Runtime/numeric.h
index 84a5a7cd7a361c..5fbab2e069b739 100644
--- a/FortranRuntime/include/flang/Runtime/numeric.h
+++ b/FortranRuntime/include/flang/Runtime/numeric.h
@@ -455,4 +455,4 @@ CppTypeFor<TypeCategory::Real, 16> RTDECL(FPow16k)(
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_NUMERIC_H_
+#endif /* FORTRAN_RUNTIME_NUMERIC_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/pointer.h b/FortranRuntime/include/flang/Runtime/pointer.h
index 704144f08114f2..b7322ad92bd583 100644
--- a/FortranRuntime/include/flang/Runtime/pointer.h
+++ b/FortranRuntime/include/flang/Runtime/pointer.h
@@ -122,4 +122,4 @@ RT_API_ATTRS bool ValidatePointerPayload(const ISO::CFI_cdesc_t &);
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_POINTER_H_
+#endif /* FORTRAN_RUNTIME_POINTER_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/ragged.h b/FortranRuntime/include/flang/Runtime/ragged.h
index ff157ea16f081e..8574bc1fa110c8 100644
--- a/FortranRuntime/include/flang/Runtime/ragged.h
+++ b/FortranRuntime/include/flang/Runtime/ragged.h
@@ -57,4 +57,4 @@ void RTDECL(RaggedArrayDeallocate)(void *raggedArrayHeader);
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_RAGGED_H_
+#endif /* FORTRAN_RUNTIME_RAGGED_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/random.h b/FortranRuntime/include/flang/Runtime/random.h
index 269297dff47dba..bb6dcb3873f21d 100644
--- a/FortranRuntime/include/flang/Runtime/random.h
+++ b/FortranRuntime/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/FortranRuntime/include/flang/Runtime/reduce.h b/FortranRuntime/include/flang/Runtime/reduce.h
index 60f54c393b4bbd..ae2828f04bf7c0 100644
--- a/FortranRuntime/include/flang/Runtime/reduce.h
+++ b/FortranRuntime/include/flang/Runtime/reduce.h
@@ -435,4 +435,4 @@ void RTDECL(ReduceDerivedTypeDim)(Descriptor &result, const Descriptor &array,
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_REDUCE_H_
+#endif /* FORTRAN_RUNTIME_REDUCE_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/reduction.h b/FortranRuntime/include/flang/Runtime/reduction.h
index 97986c12e8a10e..e00593fbc9f75e 100644
--- a/FortranRuntime/include/flang/Runtime/reduction.h
+++ b/FortranRuntime/include/flang/Runtime/reduction.h
@@ -444,4 +444,4 @@ bool RTDECL(DotProductLogical)(const Descriptor &, const Descriptor &,
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_REDUCTION_H_
+#endif /* FORTRAN_RUNTIME_REDUCTION_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/stop.h b/FortranRuntime/include/flang/Runtime/stop.h
index f7c4ffe7403e8e..9ba41343c6f964 100644
--- a/FortranRuntime/include/flang/Runtime/stop.h
+++ b/FortranRuntime/include/flang/Runtime/stop.h
@@ -37,4 +37,4 @@ NORETURN void RTNAME(ReportFatalUserError)(
FORTRAN_EXTERN_C_END
-#endif // FORTRAN_RUNTIME_STOP_H_
+#endif /* FORTRAN_RUNTIME_STOP_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/support.h b/FortranRuntime/include/flang/Runtime/support.h
index 4a6d4357e87103..9c9b067a18f2e4 100644
--- a/FortranRuntime/include/flang/Runtime/support.h
+++ b/FortranRuntime/include/flang/Runtime/support.h
@@ -47,4 +47,4 @@ void RTDECL(CopyAndUpdateDescriptor)(Descriptor &to, const Descriptor &from,
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_SUPPORT_H_
+#endif /* FORTRAN_RUNTIME_SUPPORT_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/temporary-stack.h b/FortranRuntime/include/flang/Runtime/temporary-stack.h
index 3c1a4ea11a4352..f83fab7b0ac811 100644
--- a/FortranRuntime/include/flang/Runtime/temporary-stack.h
+++ b/FortranRuntime/include/flang/Runtime/temporary-stack.h
@@ -64,4 +64,4 @@ void RTNAME(DestroyDescriptorStack)(void *opaquePtr);
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TEMPORARY_STACK_H_
+#endif /* FORTRAN_RUNTIME_TEMPORARY_STACK_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/time-intrinsic.h b/FortranRuntime/include/flang/Runtime/time-intrinsic.h
index 80490a17e45597..0e63fc6a4647a4 100644
--- a/FortranRuntime/include/flang/Runtime/time-intrinsic.h
+++ b/FortranRuntime/include/flang/Runtime/time-intrinsic.h
@@ -48,4 +48,4 @@ void RTNAME(Etime)(const Descriptor *values, const Descriptor *time,
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TIME_INTRINSIC_H_
+#endif /* FORTRAN_RUNTIME_TIME_INTRINSIC_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/transformational.h b/FortranRuntime/include/flang/Runtime/transformational.h
index a39b872f376a69..266dd9d7aebc24 100644
--- a/FortranRuntime/include/flang/Runtime/transformational.h
+++ b/FortranRuntime/include/flang/Runtime/transformational.h
@@ -154,4 +154,4 @@ void RTDECL(Unpack)(Descriptor &result, const Descriptor &vector,
} // extern "C"
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
+#endif /* FORTRAN_RUNTIME_TRANSFORMATIONAL_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/type-code.h b/FortranRuntime/include/flang/Runtime/type-code.h
index 3c1b03dfaa1140..ec359f25dbdd12 100644
--- a/FortranRuntime/include/flang/Runtime/type-code.h
+++ b/FortranRuntime/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/optional.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/optional.h"
#include <utility>
namespace Fortran::runtime {
@@ -75,4 +75,4 @@ class TypeCode {
ISO::CFI_type_t raw_{CFI_type_other};
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TYPE_CODE_H_
+#endif /* FORTRAN_RUNTIME_TYPE_CODE_H_ */
diff --git a/FortranRuntime/include/flang/Testing/fp-testing.h b/FortranRuntime/include/flang/Testing/fp-testing.h
index 16c6017e8529d5..e223d2ef7d1b8b 100644
--- a/FortranRuntime/include/flang/Testing/fp-testing.h
+++ b/FortranRuntime/include/flang/Testing/fp-testing.h
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_
-#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
+#ifndef FORTRAN_TESTING_FP_TESTING_H_
+#define FORTRAN_TESTING_FP_TESTING_H_
#include "flang/Common/target-rounding.h"
#include <fenv.h>
-using Fortran::common::RoundingMode;
using Fortran::common::RealFlags;
using Fortran::common::Rounding;
+using Fortran::common::RoundingMode;
class ScopedHostFloatingPointEnvironment {
public:
@@ -32,4 +32,4 @@ class ScopedHostFloatingPointEnvironment {
#endif
};
-#endif // FORTRAN_TEST_EVALUATE_FP_TESTING_H_
+#endif /* FORTRAN_TESTING_FP_TESTING_H_ */
diff --git a/FortranRuntime/include/flang/Testing/testing.h b/FortranRuntime/include/flang/Testing/testing.h
index d763109d62d373..404650c9a89f2c 100644
--- a/FortranRuntime/include/flang/Testing/testing.h
+++ b/FortranRuntime/include/flang/Testing/testing.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_EVALUATE_TESTING_H_
-#define FORTRAN_EVALUATE_TESTING_H_
+#ifndef FORTRAN_TESTING_TESTING_H_
+#define FORTRAN_TESTING_TESTING_H_
#include <cinttypes>
#include <string>
@@ -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_EVALUATE_TESTING_H_
+#endif /* FORTRAN_TESTING_TESTING_H_ */
diff --git a/FortranRuntime/lib/Common/big-radix-floating-point.h b/FortranRuntime/lib/Common/big-radix-floating-point.h
index 7b8fb03710a3d4..6d247f3796eea5 100644
--- a/FortranRuntime/lib/Common/big-radix-floating-point.h
+++ b/FortranRuntime/lib/Common/big-radix-floating-point.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
-#define FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
+#ifndef FORTRAN_COMMON_BIG_RADIX_FLOATING_POINT_H_
+#define FORTRAN_COMMON_BIG_RADIX_FLOATING_POINT_H_
// This is a helper class for use in floating-point conversions between
// binary and decimal representations. It holds a multiple-precision
@@ -21,11 +21,11 @@
// for conversions between binary and decimal representations; it is not
// a general-purpose facility.
+#include "flang/Common/binary-floating-point.h"
#include "flang/Common/bit-population-count.h"
+#include "flang/Common/decimal.h"
#include "flang/Common/leading-zero-bit-count.h"
#include "flang/Common/uint128.h"
-#include "flang/Common/binary-floating-point.h"
-#include "flang/Common/decimal.h"
#include <cinttypes>
#include <limits>
#include <type_traits>
@@ -393,4 +393,4 @@ template <int PREC, int LOG10RADIX = 16> class BigRadixFloatingPointNumber {
enum FortranRounding rounding_ { RoundNearest };
};
} // namespace Fortran::decimal
-#endif
+#endif /* FORTRAN_COMMON_BIG_RADIX_FLOATING_POINT_H_ */
diff --git a/FortranRuntime/lib/Common/decimal-to-binary.cpp b/FortranRuntime/lib/Common/decimal-to-binary.cpp
index 0ef24d3bcfecfc..cbf1664e9c240d 100644
--- a/FortranRuntime/lib/Common/decimal-to-binary.cpp
+++ b/FortranRuntime/lib/Common/decimal-to-binary.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "big-radix-floating-point.h"
-#include "flang/Common/bit-population-count.h"
-#include "flang/Common/leading-zero-bit-count.h"
#include "flang/Common/binary-floating-point.h"
+#include "flang/Common/bit-population-count.h"
#include "flang/Common/decimal.h"
+#include "flang/Common/leading-zero-bit-count.h"
#include "flang/Runtime/freestanding-tools.h"
#include <cinttypes>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index 3402dd5fe6af8f..9ccbc9ea78b0fc 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -139,21 +139,12 @@ set(supported_files
"${FLANGRUNTIME_SOURCE_DIR}/include/flang/Common/*.h"
)
-
set(private_headers "")
file(GLOB_RECURSE private_headers
"${FLANGRUNTIME_SOURCE_DIR}/lib/Runtime/*.h"
"${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
)
-
-
-
-
-
-
-
-
get_target_property(f128_sources
FortranFloat128MathILib INTERFACE_SOURCES
)
@@ -170,17 +161,6 @@ if (f128_sources)
list(APPEND sources ${f128_sources})
endif()
-
-
-
-
-
-
-
-
-
-
-
if (NOT DEFINED WIN32)
add_fortranruntime_library(FortranRuntime STATIC
${sources}
diff --git a/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
index f75b854d1eb3ba..81055b2737c0f1 100644
--- a/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/Runtime/CUDA/CMakeLists.txt -------------------------------------===#
+#===-- 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.
diff --git a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
index 379f52b45057a0..2efd6bf0a95249 100644
--- a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
+++ b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
@@ -11,9 +11,9 @@
#include "../stat.h"
#include "../terminator.h"
#include "../type-info.h"
-#include "flang/Support/Fortran.h"
#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/allocator-registry.h"
+#include "flang/Support/Fortran.h"
#include "cuda_runtime.h"
diff --git a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
index 1ff158c401855f..a5f5bec1e7e4b8 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/Runtime/Float128Math/CMakeLists.txt -----------------------------===#
+#===-- runtime/Float128Math/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.
diff --git a/FortranRuntime/lib/Runtime/Float128Math/math-entries.h b/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
index 798efdfb1e120c..cb1e0130602260 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
@@ -8,10 +8,10 @@
#ifndef FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
#define FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
-#include "terminator.h"
-#include "tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
+#include "terminator.h"
+#include "tools.h"
#include <cfloat>
#include <cmath>
#include <type_traits>
@@ -222,4 +222,4 @@ DEFINE_SIMPLE_ALIAS(Yn, ynl)
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
+#endif /* FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_ */
diff --git a/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h b/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
index ca9696e18f6a92..2a843df2d1d861 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
@@ -52,4 +52,4 @@ template <> struct SQRTTy<F128Type> {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#endif /* FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_ */
diff --git a/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
index d2fab4bbc30b4d..9711b2bcf49757 100644
--- a/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
@@ -10,11 +10,11 @@
// as specified in section 18.5.5 of Fortran 2018.
#include "ISO_Fortran_util.h"
-#include "terminator.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 "terminator.h"
#include <cstdlib>
namespace Fortran::ISO {
diff --git a/FortranRuntime/lib/Runtime/ISO_Fortran_util.h b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
index c45e8fc7a8d253..7ab280733028af 100644
--- a/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
@@ -11,10 +11,10 @@
// Internal utils for establishing CFI_cdesc_t descriptors.
-#include "terminator.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/type-code.h"
+#include "terminator.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 /* FORTRAN_RUNTIME_ISO_FORTRAN_UTIL_H_ */
diff --git a/FortranRuntime/lib/Runtime/allocatable.cpp b/FortranRuntime/lib/Runtime/allocatable.cpp
index e3b43a5f813935..8b6c1a4c1477eb 100644
--- a/FortranRuntime/lib/Runtime/allocatable.cpp
+++ b/FortranRuntime/lib/Runtime/allocatable.cpp
@@ -9,12 +9,12 @@
#include "flang/Runtime/allocatable.h"
#include "assign-impl.h"
#include "derived.h"
-#include "stat.h"
-#include "terminator.h"
-#include "type-info.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
#include "flang/Runtime/descriptor.h"
+#include "stat.h"
+#include "terminator.h"
+#include "type-info.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/FortranRuntime/lib/Runtime/array-constructor.cpp b/FortranRuntime/lib/Runtime/array-constructor.cpp
index 287d054887abf0..db57d4fc4c3f68 100644
--- a/FortranRuntime/lib/Runtime/array-constructor.cpp
+++ b/FortranRuntime/lib/Runtime/array-constructor.cpp
@@ -8,12 +8,12 @@
#include "flang/Runtime/array-constructor.h"
#include "derived.h"
-#include "terminator.h"
-#include "tools.h"
-#include "type-info.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/assign.h"
#include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
+#include "type-info.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/assign-impl.h b/FortranRuntime/lib/Runtime/assign-impl.h
index 6bc8ef78c38a90..d5538fab18b6b5 100644
--- a/FortranRuntime/lib/Runtime/assign-impl.h
+++ b/FortranRuntime/lib/Runtime/assign-impl.h
@@ -21,4 +21,4 @@ RT_API_ATTRS void DoFromSourceAssign(
Descriptor &, const Descriptor &, Terminator &);
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ASSIGN_IMPL_H_
+#endif /* FORTRAN_RUNTIME_ASSIGN_IMPL_H_ */
diff --git a/FortranRuntime/lib/Runtime/assign.cpp b/FortranRuntime/lib/Runtime/assign.cpp
index 7c5eb135d4cfdf..cc38e55e3a9e1e 100644
--- a/FortranRuntime/lib/Runtime/assign.cpp
+++ b/FortranRuntime/lib/Runtime/assign.cpp
@@ -9,11 +9,11 @@
#include "flang/Runtime/assign.h"
#include "assign-impl.h"
#include "derived.h"
+#include "flang/Runtime/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
#include "type-info.h"
-#include "flang/Runtime/descriptor.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/buffer.h b/FortranRuntime/lib/Runtime/buffer.h
index 24e43734552e99..dd3c19fa14392f 100644
--- a/FortranRuntime/lib/Runtime/buffer.h
+++ b/FortranRuntime/lib/Runtime/buffer.h
@@ -11,9 +11,9 @@
#ifndef FORTRAN_RUNTIME_BUFFER_H_
#define FORTRAN_RUNTIME_BUFFER_H_
-#include "io-error.h"
#include "flang/Runtime/freestanding-tools.h"
#include "flang/Runtime/memory.h"
+#include "io-error.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 /* FORTRAN_RUNTIME_BUFFER_H_ */
diff --git a/FortranRuntime/lib/Runtime/character.cpp b/FortranRuntime/lib/Runtime/character.cpp
index 73d3d93c5015f6..32fc010c6c04dd 100644
--- a/FortranRuntime/lib/Runtime/character.cpp
+++ b/FortranRuntime/lib/Runtime/character.cpp
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/character.h"
-#include "terminator.h"
-#include "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 "terminator.h"
+#include "tools.h"
#include <algorithm>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/command.cpp b/FortranRuntime/lib/Runtime/command.cpp
index 50a084714e69a4..dc57758d4f7955 100644
--- a/FortranRuntime/lib/Runtime/command.cpp
+++ b/FortranRuntime/lib/Runtime/command.cpp
@@ -8,10 +8,10 @@
#include "flang/Runtime/command.h"
#include "environment.h"
+#include "flang/Runtime/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
-#include "flang/Runtime/descriptor.h"
#include <cstdlib>
#include <limits>
diff --git a/FortranRuntime/lib/Runtime/complex-reduction.h b/FortranRuntime/lib/Runtime/complex-reduction.h
index 1ca5b9a33c4640..e8e287215b7d97 100644
--- a/FortranRuntime/lib/Runtime/complex-reduction.h
+++ b/FortranRuntime/lib/Runtime/complex-reduction.h
@@ -155,4 +155,4 @@ void RTNAME(ReduceComplex16DimValue)(
REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));
#endif
-#endif // FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_
+#endif /* FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_ */
diff --git a/FortranRuntime/lib/Runtime/connection.h b/FortranRuntime/lib/Runtime/connection.h
index f74e94ff6fb4a3..92a3a9c3860a3e 100644
--- a/FortranRuntime/lib/Runtime/connection.h
+++ b/FortranRuntime/lib/Runtime/connection.h
@@ -8,11 +8,11 @@
// Fortran I/O connection state (abstracted over internal & external units)
-#ifndef FORTRAN_RUNTIME_IO_CONNECTION_H_
-#define FORTRAN_RUNTIME_IO_CONNECTION_H_
+#ifndef FORTRAN_RUNTIME_CONNECTION_H_
+#define FORTRAN_RUNTIME_CONNECTION_H_
-#include "format.h"
#include "flang/Common/optional.h"
+#include "format.h"
#include <cinttypes>
namespace Fortran::runtime::io {
@@ -124,4 +124,4 @@ class SavedPosition {
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_CONNECTION_H_
+#endif /* FORTRAN_RUNTIME_CONNECTION_H_ */
diff --git a/FortranRuntime/lib/Runtime/copy.cpp b/FortranRuntime/lib/Runtime/copy.cpp
index 72a86e3b80a7d5..39c7da45172a43 100644
--- a/FortranRuntime/lib/Runtime/copy.cpp
+++ b/FortranRuntime/lib/Runtime/copy.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "copy.h"
+#include "flang/Runtime/allocatable.h"
+#include "flang/Runtime/descriptor.h"
#include "stack.h"
#include "terminator.h"
#include "type-info.h"
-#include "flang/Runtime/allocatable.h"
-#include "flang/Runtime/descriptor.h"
#include <cstring>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/copy.h b/FortranRuntime/lib/Runtime/copy.h
index 6d37b075e74504..f2c5b41718b71c 100644
--- a/FortranRuntime/lib/Runtime/copy.h
+++ b/FortranRuntime/lib/Runtime/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 // FORTRAN_RUNTIME_COPY_H_
+#endif /* FORTRAN_RUNTIME_COPY_H_ */
diff --git a/FortranRuntime/lib/Runtime/derived-api.cpp b/FortranRuntime/lib/Runtime/derived-api.cpp
index 0bcdd45ddbbaec..4b68cdbbed7b2c 100644
--- a/FortranRuntime/lib/Runtime/derived-api.cpp
+++ b/FortranRuntime/lib/Runtime/derived-api.cpp
@@ -8,10 +8,10 @@
#include "flang/Runtime/derived-api.h"
#include "derived.h"
+#include "flang/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "type-info.h"
-#include "flang/Runtime/descriptor.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/derived.cpp b/FortranRuntime/lib/Runtime/derived.cpp
index 04d765211db63b..52bf54d62c8599 100644
--- a/FortranRuntime/lib/Runtime/derived.cpp
+++ b/FortranRuntime/lib/Runtime/derived.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "derived.h"
+#include "flang/Runtime/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
#include "type-info.h"
-#include "flang/Runtime/descriptor.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/derived.h b/FortranRuntime/lib/Runtime/derived.h
index 27c04c7cc56969..e03e657f01cee9 100644
--- a/FortranRuntime/lib/Runtime/derived.h
+++ b/FortranRuntime/lib/Runtime/derived.h
@@ -40,4 +40,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 /* FORTRAN_RUNTIME_DERIVED_H_ */
diff --git a/FortranRuntime/lib/Runtime/descriptor-io.h b/FortranRuntime/lib/Runtime/descriptor-io.h
index 58cb091f852596..2ccad0cea70a29 100644
--- a/FortranRuntime/lib/Runtime/descriptor-io.h
+++ b/FortranRuntime/lib/Runtime/descriptor-io.h
@@ -16,15 +16,15 @@
#include "edit-input.h"
#include "edit-output.h"
+#include "flang/Common/optional.h"
+#include "flang/Common/uint128.h"
+#include "flang/Runtime/cpp-type.h"
+#include "flang/Runtime/descriptor.h"
#include "io-stmt.h"
#include "namelist.h"
#include "terminator.h"
#include "type-info.h"
#include "unit.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>
@@ -608,4 +608,4 @@ static RT_API_ATTRS bool DescriptorIO(IoStatementState &io,
return false;
}
} // namespace Fortran::runtime::io::descr
-#endif // FORTRAN_RUNTIME_DESCRIPTOR_IO_H_
+#endif /* FORTRAN_RUNTIME_DESCRIPTOR_IO_H_ */
diff --git a/FortranRuntime/lib/Runtime/descriptor.cpp b/FortranRuntime/lib/Runtime/descriptor.cpp
index f064fe3dcc32e9..6756134b06e7b1 100644
--- a/FortranRuntime/lib/Runtime/descriptor.cpp
+++ b/FortranRuntime/lib/Runtime/descriptor.cpp
@@ -9,12 +9,12 @@
#include "flang/Runtime/descriptor.h"
#include "ISO_Fortran_util.h"
#include "derived.h"
+#include "flang/Runtime/allocator-registry.h"
#include "memory.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
#include "type-info.h"
-#include "flang/Runtime/allocator-registry.h"
#include <cassert>
#include <cstdlib>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/dot-product.cpp b/FortranRuntime/lib/Runtime/dot-product.cpp
index 9eb22790e38a69..ab1cfa58ef3d02 100644
--- a/FortranRuntime/lib/Runtime/dot-product.cpp
+++ b/FortranRuntime/lib/Runtime/dot-product.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "float.h"
-#include "terminator.h"
-#include "tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/reduction.h"
+#include "float.h"
+#include "terminator.h"
+#include "tools.h"
#include <cfloat>
#include <cinttypes>
diff --git a/FortranRuntime/lib/Runtime/edit-input.cpp b/FortranRuntime/lib/Runtime/edit-input.cpp
index 6ebb0e7aca4ade..eaa9d0d7e641e7 100644
--- a/FortranRuntime/lib/Runtime/edit-input.cpp
+++ b/FortranRuntime/lib/Runtime/edit-input.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "edit-input.h"
-#include "namelist.h"
-#include "utf.h"
#include "flang/Common/optional.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/freestanding-tools.h"
+#include "namelist.h"
+#include "utf.h"
#include <algorithm>
#include <cfenv>
diff --git a/FortranRuntime/lib/Runtime/edit-input.h b/FortranRuntime/lib/Runtime/edit-input.h
index 96dc3f561c22a7..2eda81a6d4e11d 100644
--- a/FortranRuntime/lib/Runtime/edit-input.h
+++ b/FortranRuntime/lib/Runtime/edit-input.h
@@ -9,9 +9,9 @@
#ifndef FORTRAN_RUNTIME_EDIT_INPUT_H_
#define FORTRAN_RUNTIME_EDIT_INPUT_H_
+#include "flang/Common/decimal.h"
#include "format.h"
#include "io-stmt.h"
-#include "flang/Common/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 /* FORTRAN_RUNTIME_EDIT_INPUT_H_ */
diff --git a/FortranRuntime/lib/Runtime/edit-output.cpp b/FortranRuntime/lib/Runtime/edit-output.cpp
index ccaf8085f016fd..1fab7db6d3b187 100644
--- a/FortranRuntime/lib/Runtime/edit-output.cpp
+++ b/FortranRuntime/lib/Runtime/edit-output.cpp
@@ -8,9 +8,9 @@
#include "edit-output.h"
#include "emit-encoded.h"
-#include "utf.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
+#include "utf.h"
#include <algorithm>
namespace Fortran::runtime::io {
diff --git a/FortranRuntime/lib/Runtime/edit-output.h b/FortranRuntime/lib/Runtime/edit-output.h
index 7f303020a83a84..cb25b68a35f05b 100644
--- a/FortranRuntime/lib/Runtime/edit-output.h
+++ b/FortranRuntime/lib/Runtime/edit-output.h
@@ -18,10 +18,10 @@
// Drives the same fast binary-to-decimal formatting templates used
// in the f18 front-end.
+#include "flang/Common/decimal.h"
+#include "flang/Common/uint128.h"
#include "format.h"
#include "io-stmt.h"
-#include "flang/Common/uint128.h"
-#include "flang/Common/decimal.h"
namespace Fortran::runtime::io {
@@ -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 /* FORTRAN_RUNTIME_EDIT_OUTPUT_H_ */
diff --git a/FortranRuntime/lib/Runtime/emit-encoded.h b/FortranRuntime/lib/Runtime/emit-encoded.h
index f07fcced488435..11163a41720795 100644
--- a/FortranRuntime/lib/Runtime/emit-encoded.h
+++ b/FortranRuntime/lib/Runtime/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 // FORTRAN_RUNTIME_EMIT_ENCODED_H_
+#endif /* FORTRAN_RUNTIME_EMIT_ENCODED_H_ */
diff --git a/FortranRuntime/lib/Runtime/environment.h b/FortranRuntime/lib/Runtime/environment.h
index 71526d2b85d74c..7d10b3a2b934bf 100644
--- a/FortranRuntime/lib/Runtime/environment.h
+++ b/FortranRuntime/lib/Runtime/environment.h
@@ -9,8 +9,8 @@
#ifndef FORTRAN_RUNTIME_ENVIRONMENT_H_
#define FORTRAN_RUNTIME_ENVIRONMENT_H_
-#include "flang/Common/optional.h"
#include "flang/Common/decimal.h"
+#include "flang/Common/optional.h"
struct EnvironmentDefaultList;
@@ -64,4 +64,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_ENVIRONMENT_H_
+#endif /* FORTRAN_RUNTIME_ENVIRONMENT_H_ */
diff --git a/FortranRuntime/lib/Runtime/execute.cpp b/FortranRuntime/lib/Runtime/execute.cpp
index 77aac164242612..54f28d052873b4 100644
--- a/FortranRuntime/lib/Runtime/execute.cpp
+++ b/FortranRuntime/lib/Runtime/execute.cpp
@@ -8,10 +8,10 @@
#include "flang/Runtime/execute.h"
#include "environment.h"
+#include "flang/Runtime/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
-#include "flang/Runtime/descriptor.h"
#include <cstdlib>
#include <errno.h>
#include <future>
diff --git a/FortranRuntime/lib/Runtime/extensions.cpp b/FortranRuntime/lib/Runtime/extensions.cpp
index e75fa75893a82b..94bfa3059e6b45 100644
--- a/FortranRuntime/lib/Runtime/extensions.cpp
+++ b/FortranRuntime/lib/Runtime/extensions.cpp
@@ -10,12 +10,12 @@
// extensions that will eventually be implemented in Fortran.
#include "flang/Runtime/extensions.h"
-#include "terminator.h"
-#include "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 "terminator.h"
+#include "tools.h"
#include <chrono>
#include <cstring>
#include <ctime>
diff --git a/FortranRuntime/lib/Runtime/extrema.cpp b/FortranRuntime/lib/Runtime/extrema.cpp
index be9da63d7bd6b8..0809cb1d5f2ae2 100644
--- a/FortranRuntime/lib/Runtime/extrema.cpp
+++ b/FortranRuntime/lib/Runtime/extrema.cpp
@@ -10,10 +10,10 @@
// and shapes and (for MAXLOC & MINLOC) result integer kinds. Also implements
// NORM2 using common infrastructure.
-#include "reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
+#include "reduction-templates.h"
#include <algorithm>
#include <cfloat>
#include <cinttypes>
diff --git a/FortranRuntime/lib/Runtime/file.cpp b/FortranRuntime/lib/Runtime/file.cpp
index 44e3850cdfcb13..b82f1c63e397f9 100644
--- a/FortranRuntime/lib/Runtime/file.cpp
+++ b/FortranRuntime/lib/Runtime/file.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "file.h"
-#include "tools.h"
#include "flang/Runtime/magic-numbers.h"
#include "flang/Runtime/memory.h"
+#include "tools.h"
#include <algorithm>
#include <cerrno>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/file.h b/FortranRuntime/lib/Runtime/file.h
index 6890cb62d66652..66d62756634b24 100644
--- a/FortranRuntime/lib/Runtime/file.h
+++ b/FortranRuntime/lib/Runtime/file.h
@@ -11,9 +11,9 @@
#ifndef FORTRAN_RUNTIME_FILE_H_
#define FORTRAN_RUNTIME_FILE_H_
-#include "io-error.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/memory.h"
+#include "io-error.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 /* FORTRAN_RUNTIME_FILE_H_ */
diff --git a/FortranRuntime/lib/Runtime/findloc.cpp b/FortranRuntime/lib/Runtime/findloc.cpp
index da5fe0c0a0a467..47c51fbcef4939 100644
--- a/FortranRuntime/lib/Runtime/findloc.cpp
+++ b/FortranRuntime/lib/Runtime/findloc.cpp
@@ -9,9 +9,9 @@
// Implements FINDLOC for all required operand types and shapes and result
// integer kinds.
-#include "reduction-templates.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
+#include "reduction-templates.h"
#include <cinttypes>
#include <complex>
diff --git a/FortranRuntime/lib/Runtime/format-implementation.h b/FortranRuntime/lib/Runtime/format-implementation.h
index 2ed6006c3b2fa0..8d0d0f3376eafc 100644
--- a/FortranRuntime/lib/Runtime/format-implementation.h
+++ b/FortranRuntime/lib/Runtime/format-implementation.h
@@ -12,12 +12,12 @@
#define FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
#include "emit-encoded.h"
+#include "flang/Common/decimal.h"
+#include "flang/Common/format.h"
+#include "flang/Runtime/main.h"
#include "format.h"
#include "io-stmt.h"
#include "memory.h"
-#include "flang/Common/format.h"
-#include "flang/Common/decimal.h"
-#include "flang/Runtime/main.h"
#include <algorithm>
#include <cstring>
#include <limits>
@@ -601,4 +601,4 @@ RT_API_ATTRS void FormatControl<CONTEXT>::Finish(Context &context) {
}
}
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
+#endif /* FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_ */
diff --git a/FortranRuntime/lib/Runtime/format.h b/FortranRuntime/lib/Runtime/format.h
index b9c6979d1c2c98..3e0807ee452a7e 100644
--- a/FortranRuntime/lib/Runtime/format.h
+++ b/FortranRuntime/lib/Runtime/format.h
@@ -12,11 +12,11 @@
#define FORTRAN_RUNTIME_FORMAT_H_
#include "environment.h"
-#include "io-error.h"
#include "flang/Common/Fortran-consts.h"
-#include "flang/Common/optional.h"
#include "flang/Common/decimal.h"
+#include "flang/Common/optional.h"
#include "flang/Runtime/freestanding-tools.h"
+#include "io-error.h"
#include <cinttypes>
namespace Fortran::runtime {
@@ -201,4 +201,4 @@ template <typename CONTEXT> class FormatControl {
Iteration stack_[maxMaxHeight];
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_FORMAT_H_
+#endif /* FORTRAN_RUNTIME_FORMAT_H_ */
diff --git a/FortranRuntime/lib/Runtime/inquiry.cpp b/FortranRuntime/lib/Runtime/inquiry.cpp
index 9a5ef0cea210db..172b46037d6c4b 100644
--- a/FortranRuntime/lib/Runtime/inquiry.cpp
+++ b/FortranRuntime/lib/Runtime/inquiry.cpp
@@ -11,9 +11,9 @@
#include "flang/Runtime/inquiry.h"
#include "copy.h"
+#include "flang/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
-#include "flang/Runtime/descriptor.h"
#include <algorithm>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/internal-unit.cpp b/FortranRuntime/lib/Runtime/internal-unit.cpp
index 95d371a49ac187..81b937ba63d4b8 100644
--- a/FortranRuntime/lib/Runtime/internal-unit.cpp
+++ b/FortranRuntime/lib/Runtime/internal-unit.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "internal-unit.h"
-#include "io-error.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/freestanding-tools.h"
+#include "io-error.h"
#include <algorithm>
#include <type_traits>
diff --git a/FortranRuntime/lib/Runtime/internal-unit.h b/FortranRuntime/lib/Runtime/internal-unit.h
index 444bc9ab515994..c4107696810f2b 100644
--- a/FortranRuntime/lib/Runtime/internal-unit.h
+++ b/FortranRuntime/lib/Runtime/internal-unit.h
@@ -8,8 +8,8 @@
// Fortran internal I/O "units"
-#ifndef FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
-#define FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
+#ifndef FORTRAN_RUNTIME_INTERNAL_UNIT_H_
+#define FORTRAN_RUNTIME_INTERNAL_UNIT_H_
#include "connection.h"
#include "flang/Runtime/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 // FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
+#endif /* FORTRAN_RUNTIME_INTERNAL_UNIT_H_ */
diff --git a/FortranRuntime/lib/Runtime/io-api-common.h b/FortranRuntime/lib/Runtime/io-api-common.h
index 9b4c3405b0991e..427666723501a2 100644
--- a/FortranRuntime/lib/Runtime/io-api-common.h
+++ b/FortranRuntime/lib/Runtime/io-api-common.h
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANG_RUNTIME_IO_API_COMMON_H_
-#define FLANG_RUNTIME_IO_API_COMMON_H_
+#ifndef FORTRAN_RUNTIME_IO_API_COMMON_H_
+#define FORTRAN_RUNTIME_IO_API_COMMON_H_
-#include "io-stmt.h"
-#include "terminator.h"
-#include "unit.h"
#include "flang/Common/api-attrs.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/io-api.h"
+#include "io-stmt.h"
+#include "terminator.h"
+#include "unit.h"
namespace Fortran::runtime::io {
@@ -94,4 +94,4 @@ RT_API_ATTRS Cookie BeginExternalListIO(
}
} // namespace Fortran::runtime::io
-#endif // FLANG_RUNTIME_IO_API_COMMON_H_
+#endif /* FORTRAN_RUNTIME_IO_API_COMMON_H_ */
diff --git a/FortranRuntime/lib/Runtime/io-api-minimal.cpp b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
index 6bc262cae78458..683694bd63c068 100644
--- a/FortranRuntime/lib/Runtime/io-api-minimal.cpp
+++ b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
@@ -10,13 +10,13 @@
// list-directed output (PRINT *) of intrinsic types.
#include "edit-output.h"
+#include "flang/Runtime/io-api.h"
#include "format.h"
#include "io-api-common.h"
#include "io-stmt.h"
#include "terminator.h"
#include "tools.h"
#include "unit.h"
-#include "flang/Runtime/io-api.h"
namespace Fortran::runtime::io {
RT_EXT_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/io-api.cpp b/FortranRuntime/lib/Runtime/io-api.cpp
index f4a396d4c49a45..102ea26b359111 100644
--- a/FortranRuntime/lib/Runtime/io-api.cpp
+++ b/FortranRuntime/lib/Runtime/io-api.cpp
@@ -18,15 +18,15 @@
#include "edit-input.h"
#include "edit-output.h"
#include "environment.h"
+#include "flang/Common/optional.h"
+#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/memory.h"
#include "format.h"
#include "io-api-common.h"
#include "io-stmt.h"
#include "terminator.h"
#include "tools.h"
#include "unit.h"
-#include "flang/Common/optional.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/memory.h"
#include <cstdlib>
#include <memory>
diff --git a/FortranRuntime/lib/Runtime/io-error.cpp b/FortranRuntime/lib/Runtime/io-error.cpp
index 053667462058de..b14a30354d2347 100644
--- a/FortranRuntime/lib/Runtime/io-error.cpp
+++ b/FortranRuntime/lib/Runtime/io-error.cpp
@@ -8,8 +8,8 @@
#include "io-error.h"
#include "config.h"
-#include "tools.h"
#include "flang/Runtime/magic-numbers.h"
+#include "tools.h"
#include <cerrno>
#include <cstdarg>
#include <cstdio>
diff --git a/FortranRuntime/lib/Runtime/io-error.h b/FortranRuntime/lib/Runtime/io-error.h
index b03e07567a0607..7388a2134ed0d3 100644
--- a/FortranRuntime/lib/Runtime/io-error.h
+++ b/FortranRuntime/lib/Runtime/io-error.h
@@ -15,9 +15,9 @@
#ifndef FORTRAN_RUNTIME_IO_ERROR_H_
#define FORTRAN_RUNTIME_IO_ERROR_H_
-#include "terminator.h"
#include "flang/Runtime/iostat.h"
#include "flang/Runtime/memory.h"
+#include "terminator.h"
#include <cinttypes>
namespace Fortran::runtime::io {
@@ -78,4 +78,4 @@ class IoErrorHandler : public Terminator {
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_ERROR_H_
+#endif /* FORTRAN_RUNTIME_IO_ERROR_H_ */
diff --git a/FortranRuntime/lib/Runtime/io-stmt.cpp b/FortranRuntime/lib/Runtime/io-stmt.cpp
index 80c96710eb49ca..5be5d98ace0d8a 100644
--- a/FortranRuntime/lib/Runtime/io-stmt.cpp
+++ b/FortranRuntime/lib/Runtime/io-stmt.cpp
@@ -9,11 +9,11 @@
#include "io-stmt.h"
#include "connection.h"
#include "emit-encoded.h"
+#include "flang/Runtime/memory.h"
#include "format.h"
#include "tools.h"
#include "unit.h"
#include "utf.h"
-#include "flang/Runtime/memory.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/io-stmt.h b/FortranRuntime/lib/Runtime/io-stmt.h
index e90e64c8fd1ff3..79a8b28c8aa19f 100644
--- a/FortranRuntime/lib/Runtime/io-stmt.h
+++ b/FortranRuntime/lib/Runtime/io-stmt.h
@@ -13,14 +13,14 @@
#include "connection.h"
#include "file.h"
-#include "format.h"
-#include "internal-unit.h"
-#include "io-error.h"
#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 "format.h"
+#include "internal-unit.h"
+#include "io-error.h"
#include <flang/Common/variant.h>
#include <functional>
#include <type_traits>
@@ -789,4 +789,4 @@ class ErroneousIoStatementState : public IoStatementBase {
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_IO_STMT_H_
+#endif /* FORTRAN_RUNTIME_IO_STMT_H_ */
diff --git a/FortranRuntime/lib/Runtime/lock.h b/FortranRuntime/lib/Runtime/lock.h
index 75c1adb12a8c62..69ff6403736dae 100644
--- a/FortranRuntime/lib/Runtime/lock.h
+++ b/FortranRuntime/lib/Runtime/lock.h
@@ -113,4 +113,4 @@ class CriticalSection {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_LOCK_H_
+#endif /* FORTRAN_RUNTIME_LOCK_H_ */
diff --git a/FortranRuntime/lib/Runtime/matmul-transpose.cpp b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
index d493333dfa9877..3b4b487daa335e 100644
--- a/FortranRuntime/lib/Runtime/matmul-transpose.cpp
+++ b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
@@ -21,12 +21,12 @@
// to use the faster BLAS routines.
#include "flang/Runtime/matmul-transpose.h"
-#include "terminator.h"
-#include "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 "terminator.h"
+#include "tools.h"
#include <cstring>
namespace {
diff --git a/FortranRuntime/lib/Runtime/matmul.cpp b/FortranRuntime/lib/Runtime/matmul.cpp
index 124369e72886c5..62674316bc6a57 100644
--- a/FortranRuntime/lib/Runtime/matmul.cpp
+++ b/FortranRuntime/lib/Runtime/matmul.cpp
@@ -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/Common/optional.h"
#include "flang/Runtime/c-or-cpp.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
#include <cstring>
namespace {
diff --git a/FortranRuntime/lib/Runtime/memory.cpp b/FortranRuntime/lib/Runtime/memory.cpp
index 4a811107ca220a..bf2c4cd4a35470 100644
--- a/FortranRuntime/lib/Runtime/memory.cpp
+++ b/FortranRuntime/lib/Runtime/memory.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/memory.h"
+#include "flang/Runtime/freestanding-tools.h"
#include "terminator.h"
#include "tools.h"
-#include "flang/Runtime/freestanding-tools.h"
#include <cstdlib>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/misc-intrinsic.cpp b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
index b942d762e76ab3..a0f41e4e3f156c 100644
--- a/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/misc-intrinsic.h"
-#include "terminator.h"
-#include "tools.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/namelist.cpp b/FortranRuntime/lib/Runtime/namelist.cpp
index e6229d56577568..1c8942fc375c43 100644
--- a/FortranRuntime/lib/Runtime/namelist.cpp
+++ b/FortranRuntime/lib/Runtime/namelist.cpp
@@ -9,8 +9,8 @@
#include "namelist.h"
#include "descriptor-io.h"
#include "emit-encoded.h"
-#include "io-stmt.h"
#include "flang/Runtime/io-api.h"
+#include "io-stmt.h"
#include <algorithm>
#include <cstring>
#include <limits>
diff --git a/FortranRuntime/lib/Runtime/namelist.h b/FortranRuntime/lib/Runtime/namelist.h
index 4694b3104a9c75..2c4d331ae05e85 100644
--- a/FortranRuntime/lib/Runtime/namelist.h
+++ b/FortranRuntime/lib/Runtime/namelist.h
@@ -11,8 +11,8 @@
#ifndef FORTRAN_RUNTIME_NAMELIST_H_
#define FORTRAN_RUNTIME_NAMELIST_H_
-#include "non-tbp-dio.h"
#include "flang/Common/api-attrs.h"
+#include "non-tbp-dio.h"
#include <cstddef>
@@ -51,4 +51,4 @@ class NamelistGroup {
RT_API_ATTRS bool IsNamelistNameOrSlash(IoStatementState &);
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_NAMELIST_H_
+#endif /* FORTRAN_RUNTIME_NAMELIST_H_ */
diff --git a/FortranRuntime/lib/Runtime/non-tbp-dio.h b/FortranRuntime/lib/Runtime/non-tbp-dio.h
index 0a45c96a3f2e25..426d5a92fd37d4 100644
--- a/FortranRuntime/lib/Runtime/non-tbp-dio.h
+++ b/FortranRuntime/lib/Runtime/non-tbp-dio.h
@@ -53,4 +53,4 @@ struct NonTbpDefinedIoTable {
};
} // namespace Fortran::runtime::io
-#endif // FORTRAN_RUNTIME_NON_TBP_DIO_H_
+#endif /* FORTRAN_RUNTIME_NON_TBP_DIO_H_ */
diff --git a/FortranRuntime/lib/Runtime/numeric-templates.h b/FortranRuntime/lib/Runtime/numeric-templates.h
index 640c6d17c4b580..f0045e8ee36e20 100644
--- a/FortranRuntime/lib/Runtime/numeric-templates.h
+++ b/FortranRuntime/lib/Runtime/numeric-templates.h
@@ -18,10 +18,10 @@
#ifndef FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
#define FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
-#include "terminator.h"
-#include "tools.h"
#include "flang/Common/api-attrs.h"
#include "flang/Common/float128.h"
+#include "terminator.h"
+#include "tools.h"
#include <cstdint>
#include <limits>
@@ -465,4 +465,4 @@ template <typename T> inline RT_API_ATTRS T ErfcScaled(T arg) {
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
+#endif /* FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_ */
diff --git a/FortranRuntime/lib/Runtime/numeric.cpp b/FortranRuntime/lib/Runtime/numeric.cpp
index b0f68a7fc81d29..a3fcfeaa9ee266 100644
--- a/FortranRuntime/lib/Runtime/numeric.cpp
+++ b/FortranRuntime/lib/Runtime/numeric.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/numeric.h"
+#include "flang/Common/float128.h"
#include "numeric-templates.h"
#include "terminator.h"
#include "tools.h"
-#include "flang/Common/float128.h"
#include <cfloat>
#include <climits>
#include <cmath>
diff --git a/FortranRuntime/lib/Runtime/product.cpp b/FortranRuntime/lib/Runtime/product.cpp
index e4a6e81bd0c508..8c11bf4144919e 100644
--- a/FortranRuntime/lib/Runtime/product.cpp
+++ b/FortranRuntime/lib/Runtime/product.cpp
@@ -8,9 +8,9 @@
// Implements PRODUCT for all required operand types and shapes.
-#include "reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
+#include "reduction-templates.h"
#include <cfloat>
#include <cinttypes>
#include <complex>
diff --git a/FortranRuntime/lib/Runtime/random-templates.h b/FortranRuntime/lib/Runtime/random-templates.h
index 4faca63ba34b9d..801484225bc211 100644
--- a/FortranRuntime/lib/Runtime/random-templates.h
+++ b/FortranRuntime/lib/Runtime/random-templates.h
@@ -9,10 +9,10 @@
#ifndef FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
#define FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
-#include "lock.h"
-#include "numeric-templates.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/descriptor.h"
+#include "lock.h"
+#include "numeric-templates.h"
#include <algorithm>
#include <random>
@@ -85,4 +85,4 @@ inline void Generate(const Descriptor &harvest) {
} // namespace Fortran::runtime::random
-#endif // FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
+#endif /* FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_ */
diff --git a/FortranRuntime/lib/Runtime/random.cpp b/FortranRuntime/lib/Runtime/random.cpp
index 343b0a389fcaf6..8e1561960d48be 100644
--- a/FortranRuntime/lib/Runtime/random.cpp
+++ b/FortranRuntime/lib/Runtime/random.cpp
@@ -10,14 +10,14 @@
// RANDOM_SEED.
#include "flang/Runtime/random.h"
-#include "lock.h"
-#include "random-templates.h"
-#include "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 "lock.h"
+#include "random-templates.h"
+#include "terminator.h"
#include <cmath>
#include <cstdint>
#include <limits>
diff --git a/FortranRuntime/lib/Runtime/reduce.cpp b/FortranRuntime/lib/Runtime/reduce.cpp
index c3e7ef74363431..4d33c2a714e5af 100644
--- a/FortranRuntime/lib/Runtime/reduce.cpp
+++ b/FortranRuntime/lib/Runtime/reduce.cpp
@@ -9,10 +9,10 @@
// REDUCE() implementation
#include "flang/Runtime/reduce.h"
+#include "flang/Runtime/descriptor.h"
#include "reduction-templates.h"
#include "terminator.h"
#include "tools.h"
-#include "flang/Runtime/descriptor.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/reduction-templates.h b/FortranRuntime/lib/Runtime/reduction-templates.h
index ba193a9f0e3b9d..30ae641ba7b3ac 100644
--- a/FortranRuntime/lib/Runtime/reduction-templates.h
+++ b/FortranRuntime/lib/Runtime/reduction-templates.h
@@ -21,11 +21,11 @@
#ifndef FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
#define FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
+#include "flang/Runtime/cpp-type.h"
+#include "flang/Runtime/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 {
@@ -412,4 +412,4 @@ template <int KIND> struct Norm2Helper {
};
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
+#endif /* FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_ */
diff --git a/FortranRuntime/lib/Runtime/reduction.cpp b/FortranRuntime/lib/Runtime/reduction.cpp
index 0de7dd07b17a5b..f4e1f2aa6818d5 100644
--- a/FortranRuntime/lib/Runtime/reduction.cpp
+++ b/FortranRuntime/lib/Runtime/reduction.cpp
@@ -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 "reduction-templates.h"
#include <cinttypes>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/stack.h b/FortranRuntime/lib/Runtime/stack.h
index 974ccb9d30b0eb..dc5b6101d3da0f 100644
--- a/FortranRuntime/lib/Runtime/stack.h
+++ b/FortranRuntime/lib/Runtime/stack.h
@@ -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 FORTRAN_RUNTIME_STACK_H_
+#define FORTRAN_RUNTIME_STACK_H_
-#include "terminator.h"
#include "flang/Runtime/memory.h"
+#include "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 /* FORTRAN_RUNTIME_STACK_H_ */
diff --git a/FortranRuntime/lib/Runtime/stat.cpp b/FortranRuntime/lib/Runtime/stat.cpp
index d483f75998a746..01ae922e080865 100644
--- a/FortranRuntime/lib/Runtime/stat.cpp
+++ b/FortranRuntime/lib/Runtime/stat.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "stat.h"
+#include "flang/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
-#include "flang/Runtime/descriptor.h"
namespace Fortran::runtime {
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/stat.h b/FortranRuntime/lib/Runtime/stat.h
index 9f56d88f588a1e..eccd69024d726b 100644
--- a/FortranRuntime/lib/Runtime/stat.h
+++ b/FortranRuntime/lib/Runtime/stat.h
@@ -11,8 +11,8 @@
#ifndef FORTRAN_RUNTIME_STAT_H_
#define FORTRAN_RUNTIME_STAT_H_
-#include "flang/Common/api-attrs.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/api-attrs.h"
#include "flang/Runtime/magic-numbers.h"
namespace Fortran::runtime {
@@ -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 /* FORTRAN_RUNTIME_STAT_H_ */
diff --git a/FortranRuntime/lib/Runtime/sum.cpp b/FortranRuntime/lib/Runtime/sum.cpp
index 64982b9fd53690..e33b77e20f0f11 100644
--- a/FortranRuntime/lib/Runtime/sum.cpp
+++ b/FortranRuntime/lib/Runtime/sum.cpp
@@ -12,9 +12,9 @@
// cancellation on intermediate results by using "Kahan summation"
// (basically the same as manual "double-double").
-#include "reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
+#include "reduction-templates.h"
#include <cfloat>
#include <cinttypes>
#include <complex>
diff --git a/FortranRuntime/lib/Runtime/support.cpp b/FortranRuntime/lib/Runtime/support.cpp
index 1dffa99191bae1..0a39ff24b0cafc 100644
--- a/FortranRuntime/lib/Runtime/support.cpp
+++ b/FortranRuntime/lib/Runtime/support.cpp
@@ -8,8 +8,8 @@
#include "flang/Runtime/support.h"
#include "ISO_Fortran_util.h"
-#include "type-info.h"
#include "flang/Runtime/descriptor.h"
+#include "type-info.h"
namespace Fortran::runtime {
extern "C" {
diff --git a/FortranRuntime/lib/Runtime/temporary-stack.cpp b/FortranRuntime/lib/Runtime/temporary-stack.cpp
index 12fa18586b7421..f944dfb7aa1471 100644
--- a/FortranRuntime/lib/Runtime/temporary-stack.cpp
+++ b/FortranRuntime/lib/Runtime/temporary-stack.cpp
@@ -10,11 +10,11 @@
// temporaries. For use in HLFIR lowering.
#include "flang/Runtime/temporary-stack.h"
-#include "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"
+#include "terminator.h"
namespace {
diff --git a/FortranRuntime/lib/Runtime/terminator.h b/FortranRuntime/lib/Runtime/terminator.h
index 02b3a4c4f066f8..f475658b0eab3d 100644
--- a/FortranRuntime/lib/Runtime/terminator.h
+++ b/FortranRuntime/lib/Runtime/terminator.h
@@ -121,4 +121,4 @@ namespace Fortran::runtime::io {
RT_API_ATTRS void FlushOutputOnCrash(const Terminator &);
}
-#endif // FORTRAN_RUNTIME_TERMINATOR_H_
+#endif /* FORTRAN_RUNTIME_TERMINATOR_H_ */
diff --git a/FortranRuntime/lib/Runtime/time-intrinsic.cpp b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
index 05f7e4f80f18b6..4b362c90c52f25 100644
--- a/FortranRuntime/lib/Runtime/time-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
@@ -9,10 +9,10 @@
// Implements time-related intrinsic subroutines.
#include "flang/Runtime/time-intrinsic.h"
-#include "terminator.h"
-#include "tools.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
#include <algorithm>
#include <cstdint>
#include <cstdio>
diff --git a/FortranRuntime/lib/Runtime/tools.h b/FortranRuntime/lib/Runtime/tools.h
index b57c7996135913..4058767ca283a9 100644
--- a/FortranRuntime/lib/Runtime/tools.h
+++ b/FortranRuntime/lib/Runtime/tools.h
@@ -9,13 +9,13 @@
#ifndef FORTRAN_RUNTIME_TOOLS_H_
#define FORTRAN_RUNTIME_TOOLS_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 "stat.h"
+#include "terminator.h"
#include <cstring>
#include <functional>
#include <map>
@@ -535,4 +535,4 @@ RT_API_ATTRS void CreatePartialReductionResult(Descriptor &result,
const char *intrinsic, TypeCode);
} // namespace Fortran::runtime
-#endif // FORTRAN_RUNTIME_TOOLS_H_
+#endif /* FORTRAN_RUNTIME_TOOLS_H_ */
diff --git a/FortranRuntime/lib/Runtime/transformational.cpp b/FortranRuntime/lib/Runtime/transformational.cpp
index 8c244fc296f3b9..66dc5bd4939bae 100644
--- a/FortranRuntime/lib/Runtime/transformational.cpp
+++ b/FortranRuntime/lib/Runtime/transformational.cpp
@@ -18,10 +18,10 @@
#include "flang/Runtime/transformational.h"
#include "copy.h"
-#include "terminator.h"
-#include "tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/descriptor.h"
+#include "terminator.h"
+#include "tools.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/type-info.h b/FortranRuntime/lib/Runtime/type-info.h
index 28e7c4696613b3..ff3523bcb2b8eb 100644
--- a/FortranRuntime/lib/Runtime/type-info.h
+++ b/FortranRuntime/lib/Runtime/type-info.h
@@ -12,11 +12,11 @@
// A C++ perspective of the derived type description schemata in
// flang/module/__fortran_type_info.f90.
-#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 "terminator.h"
#include <cinttypes>
#include <memory>
@@ -321,4 +321,4 @@ class DerivedType {
};
} // namespace Fortran::runtime::typeInfo
-#endif // FORTRAN_RUNTIME_TYPE_INFO_H_
+#endif /* FORTRAN_RUNTIME_TYPE_INFO_H_ */
diff --git a/FortranRuntime/lib/Runtime/unit-map.h b/FortranRuntime/lib/Runtime/unit-map.h
index f9f0d34d4f0193..4e61246f9a2d86 100644
--- a/FortranRuntime/lib/Runtime/unit-map.h
+++ b/FortranRuntime/lib/Runtime/unit-map.h
@@ -12,10 +12,10 @@
#ifndef FORTRAN_RUNTIME_UNIT_MAP_H_
#define FORTRAN_RUNTIME_UNIT_MAP_H_
-#include "lock.h"
-#include "unit.h"
#include "flang/Common/fast-int-set.h"
#include "flang/Runtime/memory.h"
+#include "lock.h"
+#include "unit.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 /* FORTRAN_RUNTIME_UNIT_MAP_H_ */
diff --git a/FortranRuntime/lib/Runtime/unit.h b/FortranRuntime/lib/Runtime/unit.h
index 608f3a28ef687d..993fbf2977cebf 100644
--- a/FortranRuntime/lib/Runtime/unit.h
+++ b/FortranRuntime/lib/Runtime/unit.h
@@ -8,21 +8,21 @@
// Fortran external I/O units
-#ifndef FORTRAN_RUNTIME_IO_UNIT_H_
-#define FORTRAN_RUNTIME_IO_UNIT_H_
+#ifndef FORTRAN_RUNTIME_UNIT_H_
+#define FORTRAN_RUNTIME_UNIT_H_
#include "buffer.h"
#include "connection.h"
#include "environment.h"
#include "file.h"
+#include "flang/Common/constexpr-bitset.h"
+#include "flang/Common/optional.h"
+#include "flang/Runtime/memory.h"
#include "format.h"
#include "io-error.h"
#include "io-stmt.h"
#include "lock.h"
#include "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 /* FORTRAN_RUNTIME_UNIT_H_ */
diff --git a/FortranRuntime/lib/Runtime/utf.h b/FortranRuntime/lib/Runtime/utf.h
index 5ba40437ea0c95..35c03fd4cdded5 100644
--- a/FortranRuntime/lib/Runtime/utf.h
+++ b/FortranRuntime/lib/Runtime/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 // FORTRAN_RUNTIME_UTF_H_
+#endif /* FORTRAN_RUNTIME_UTF_H_ */
diff --git a/FortranRuntime/lib/Testing/fp-testing.cpp b/FortranRuntime/lib/Testing/fp-testing.cpp
index 8541b1406334d3..3301d2d8efb15f 100644
--- a/FortranRuntime/lib/Testing/fp-testing.cpp
+++ b/FortranRuntime/lib/Testing/fp-testing.cpp
@@ -1,11 +1,3 @@
-//===-- 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>
diff --git a/FortranRuntime/unittests/Common/FastIntSetTest.cpp b/FortranRuntime/unittests/Common/FastIntSetTest.cpp
index f19359f4097ab8..a36a334e370eb9 100644
--- a/FortranRuntime/unittests/Common/FastIntSetTest.cpp
+++ b/FortranRuntime/unittests/Common/FastIntSetTest.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "flang/Common/fast-int-set.h"
+#include "gtest/gtest.h"
#include <optional>
TEST(FastIntSetTests, Sanity) {
diff --git a/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
index 97d23ca90e5022..d2546e0c22d2d6 100644
--- a/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Testing/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/FortranRuntime/unittests/Evaluate/reshape.cpp b/FortranRuntime/unittests/Evaluate/reshape.cpp
index 82caebe081fcd2..a93afd2a3c90cd 100644
--- a/FortranRuntime/unittests/Evaluate/reshape.cpp
+++ b/FortranRuntime/unittests/Evaluate/reshape.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Testing/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/FortranRuntime/unittests/Runtime/AccessTest.cpp b/FortranRuntime/unittests/Runtime/AccessTest.cpp
index e72386cc9ac247..3e9feaf945b66d 100644
--- a/FortranRuntime/unittests/Runtime/AccessTest.cpp
+++ b/FortranRuntime/unittests/Runtime/AccessTest.cpp
@@ -10,9 +10,9 @@
#ifndef _WIN32
#include "CrashHandlerFixture.h"
-#include "gtest/gtest.h"
#include "flang/Runtime/extensions.h"
#include "llvm/ADT/Twine.h"
+#include "gtest/gtest.h"
#include <fcntl.h>
#include <sys/stat.h>
diff --git a/FortranRuntime/unittests/Runtime/Allocatable.cpp b/FortranRuntime/unittests/Runtime/Allocatable.cpp
index 8e10dc408ceae8..c01f85598d21ed 100644
--- a/FortranRuntime/unittests/Runtime/Allocatable.cpp
+++ b/FortranRuntime/unittests/Runtime/Allocatable.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/allocatable.h"
-#include "gtest/gtest.h"
#include "tools.h"
+#include "gtest/gtest.h"
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp b/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
index 8c7fce3e4fb5f7..9011da304b6bc3 100644
--- a/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
+++ b/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
-#include "tools.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 "tools.h"
+#include "gtest/gtest.h"
#include <memory>
diff --git a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 5bafb484236340..d2c1600af8c631 100644
--- a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "../../../runtime/terminator.h"
-#include "flang/Support/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 "gtest/gtest.h"
#include "cuda_runtime.h"
diff --git a/FortranRuntime/unittests/Runtime/CharacterTest.cpp b/FortranRuntime/unittests/Runtime/CharacterTest.cpp
index 710c1ca0eee817..8829f5e43265b0 100644
--- a/FortranRuntime/unittests/Runtime/CharacterTest.cpp
+++ b/FortranRuntime/unittests/Runtime/CharacterTest.cpp
@@ -10,8 +10,8 @@
// in Fortran.
#include "flang/Runtime/character.h"
-#include "gtest/gtest.h"
#include "flang/Runtime/descriptor.h"
+#include "gtest/gtest.h"
#include <cstring>
#include <functional>
#include <tuple>
diff --git a/FortranRuntime/unittests/Runtime/CommandTest.cpp b/FortranRuntime/unittests/Runtime/CommandTest.cpp
index 03a31ceab8030b..aa79ce381ba8d0 100644
--- a/FortranRuntime/unittests/Runtime/CommandTest.cpp
+++ b/FortranRuntime/unittests/Runtime/CommandTest.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/command.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/execute.h"
#include "flang/Runtime/extensions.h"
#include "flang/Runtime/main.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
#include <cstddef>
#include <cstdlib>
diff --git a/FortranRuntime/unittests/Runtime/Complex.cpp b/FortranRuntime/unittests/Runtime/Complex.cpp
index daa4b5c7960842..d714da24dc4e58 100644
--- a/FortranRuntime/unittests/Runtime/Complex.cpp
+++ b/FortranRuntime/unittests/Runtime/Complex.cpp
@@ -1,4 +1,4 @@
-//===-- unittests/Runtime/Complex.cpp ---------------------------*- C++ -*-===//
+//===-- flang/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.
diff --git a/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
index af6d8e4cc7d525..46805775af0b39 100644
--- a/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
+++ b/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
@@ -10,12 +10,12 @@
/// with expected message.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_FLANG_UNITTESTS_RUNTIMEGTEST_CRASHHANDLERFIXTURE_H
-#define LLVM_FLANG_UNITTESTS_RUNTIMEGTEST_CRASHHANDLERFIXTURE_H
+#ifndef FORTRAN_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_
+#define FORTRAN_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_
#include <gtest/gtest.h>
struct CrashHandlerFixture : testing::Test {
void SetUp();
};
-#endif
+#endif /* FORTRAN_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_ */
diff --git a/FortranRuntime/unittests/Runtime/Derived.cpp b/FortranRuntime/unittests/Runtime/Derived.cpp
index 8d5471e3e0bcf3..11b732fe10b790 100644
--- a/FortranRuntime/unittests/Runtime/Derived.cpp
+++ b/FortranRuntime/unittests/Runtime/Derived.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
-#include "tools.h"
#include "flang/Runtime/derived-api.h"
#include "flang/Runtime/descriptor.h"
+#include "tools.h"
+#include "gtest/gtest.h"
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp b/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
index 23c1e9992c101e..00c2fd76ce0c04 100644
--- a/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
+++ b/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
@@ -11,12 +11,12 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "gtest/gtest.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
#include <cstring>
#include <string_view>
diff --git a/FortranRuntime/unittests/Runtime/Inquiry.cpp b/FortranRuntime/unittests/Runtime/Inquiry.cpp
index 39303b7c809002..204a97a1088ac0 100644
--- a/FortranRuntime/unittests/Runtime/Inquiry.cpp
+++ b/FortranRuntime/unittests/Runtime/Inquiry.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/inquiry.h"
-#include "gtest/gtest.h"
-#include "tools.h"
#include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/ListInputTest.cpp b/FortranRuntime/unittests/Runtime/ListInputTest.cpp
index 472838c25841c9..4c30d6ed750141 100644
--- a/FortranRuntime/unittests/Runtime/ListInputTest.cpp
+++ b/FortranRuntime/unittests/Runtime/ListInputTest.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "CrashHandlerFixture.h"
#include "../../lib/Runtime/io-error.h"
+#include "CrashHandlerFixture.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"
diff --git a/FortranRuntime/unittests/Runtime/Matmul.cpp b/FortranRuntime/unittests/Runtime/Matmul.cpp
index a37b618d3ab11a..cfa5d18cc36d33 100644
--- a/FortranRuntime/unittests/Runtime/Matmul.cpp
+++ b/FortranRuntime/unittests/Runtime/Matmul.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/matmul.h"
-#include "gtest/gtest.h"
-#include "tools.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp b/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
index 3483d1896e8bf6..146c2283fb1aca 100644
--- a/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
+++ b/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
-#include "tools.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"
+#include "tools.h"
+#include "gtest/gtest.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp b/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
index 5672440c0e1b95..08229b5e48f0dd 100644
--- a/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
+++ b/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
-#include "tools.h"
#include "flang/Runtime//misc-intrinsic.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
+#include "tools.h"
+#include "gtest/gtest.h"
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Namelist.cpp b/FortranRuntime/unittests/Runtime/Namelist.cpp
index 729f9ffa5c7c10..7b834dec49c3c4 100644
--- a/FortranRuntime/unittests/Runtime/Namelist.cpp
+++ b/FortranRuntime/unittests/Runtime/Namelist.cpp
@@ -8,9 +8,9 @@
#include "../../lib/Runtime/namelist.h"
#include "CrashHandlerFixture.h"
-#include "tools.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"
+#include "tools.h"
#include <algorithm>
#include <cinttypes>
#include <complex>
diff --git a/FortranRuntime/unittests/Runtime/Numeric.cpp b/FortranRuntime/unittests/Runtime/Numeric.cpp
index d15919b972bca7..fb595ae262c324 100644
--- a/FortranRuntime/unittests/Runtime/Numeric.cpp
+++ b/FortranRuntime/unittests/Runtime/Numeric.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/numeric.h"
-#include "gtest/gtest.h"
#include "flang/Common/float128.h"
+#include "gtest/gtest.h"
#include <cmath>
#include <limits>
diff --git a/FortranRuntime/unittests/Runtime/Pointer.cpp b/FortranRuntime/unittests/Runtime/Pointer.cpp
index aa8545cdf951d1..a05bd70a64bb9f 100644
--- a/FortranRuntime/unittests/Runtime/Pointer.cpp
+++ b/FortranRuntime/unittests/Runtime/Pointer.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/pointer.h"
-#include "gtest/gtest.h"
-#include "tools.h"
#include "flang/Runtime/descriptor.h"
+#include "tools.h"
+#include "gtest/gtest.h"
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Random.cpp b/FortranRuntime/unittests/Runtime/Random.cpp
index c2300a478832ab..4e4b59cbcf40e7 100644
--- a/FortranRuntime/unittests/Runtime/Random.cpp
+++ b/FortranRuntime/unittests/Runtime/Random.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime//random.h"
-#include "gtest/gtest.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/type-code.h"
+#include "gtest/gtest.h"
#include <cmath>
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Reduction.cpp b/FortranRuntime/unittests/Runtime/Reduction.cpp
index e8b5ac878871fd..c35f6e2fa6a41b 100644
--- a/FortranRuntime/unittests/Runtime/Reduction.cpp
+++ b/FortranRuntime/unittests/Runtime/Reduction.cpp
@@ -7,14 +7,14 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/reduction.h"
-#include "gtest/gtest.h"
-#include "tools.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 "tools.h"
+#include "gtest/gtest.h"
#include <cstdint>
#include <cstring>
#include <string>
diff --git a/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp b/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
index 7ce1ee796d739b..61580a8d46792f 100644
--- a/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
@@ -10,11 +10,11 @@
/// runtime components and ensure the test fixture handles crashes as we expect.
//
//===----------------------------------------------------------------------===//
-#include "CrashHandlerFixture.h"
-#include "tools.h"
#include "../../lib/Runtime/terminator.h"
+#include "CrashHandlerFixture.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/transformational.h"
+#include "tools.h"
#include <gtest/gtest.h>
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Stop.cpp b/FortranRuntime/unittests/Runtime/Stop.cpp
index c12ec097068438..5fd8deaad21d6b 100644
--- a/FortranRuntime/unittests/Runtime/Stop.cpp
+++ b/FortranRuntime/unittests/Runtime/Stop.cpp
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#include "flang/Runtime/stop.h"
-#include "CrashHandlerFixture.h"
#include "../../lib/Runtime/environment.h"
+#include "CrashHandlerFixture.h"
#include <cstdlib>
#include <gtest/gtest.h>
diff --git a/FortranRuntime/unittests/Runtime/Support.cpp b/FortranRuntime/unittests/Runtime/Support.cpp
index b7aa39ef5523ba..38c0d6efaf9db7 100644
--- a/FortranRuntime/unittests/Runtime/Support.cpp
+++ b/FortranRuntime/unittests/Runtime/Support.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/support.h"
-#include "gtest/gtest.h"
-#include "tools.h"
#include "flang/Runtime/descriptor.h"
+#include "tools.h"
+#include "gtest/gtest.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/TemporaryStack.cpp b/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
index 495c693b0493ef..63d99416ea64cb 100644
--- a/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
+++ b/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
-#include "tools.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 "tools.h"
+#include "gtest/gtest.h"
#include <vector>
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Time.cpp b/FortranRuntime/unittests/Runtime/Time.cpp
index 548c0834e34a36..6fd00d669a9575 100644
--- a/FortranRuntime/unittests/Runtime/Time.cpp
+++ b/FortranRuntime/unittests/Runtime/Time.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "flang/Runtime/time-intrinsic.h"
+#include "gtest/gtest.h"
#include <algorithm>
#include <cctype>
#include <cerrno>
diff --git a/FortranRuntime/unittests/Runtime/Transformational.cpp b/FortranRuntime/unittests/Runtime/Transformational.cpp
index 2dcab5a2aa8974..b5a4e0e8e9588b 100644
--- a/FortranRuntime/unittests/Runtime/Transformational.cpp
+++ b/FortranRuntime/unittests/Runtime/Transformational.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/transformational.h"
-#include "gtest/gtest.h"
-#include "tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/type-code.h"
+#include "tools.h"
+#include "gtest/gtest.h"
#include <vector>
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/tools.h b/FortranRuntime/unittests/Runtime/tools.h
index a8e2096a90572e..702103d225ab72 100644
--- a/FortranRuntime/unittests/Runtime/tools.h
+++ b/FortranRuntime/unittests/Runtime/tools.h
@@ -9,11 +9,11 @@
#ifndef FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
#define FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
-#include "gtest/gtest.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/type-code.h"
+#include "gtest/gtest.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 /* FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_ */
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 00e570798bb412..47517c5e7ab82f 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -160,6 +160,7 @@ if (FLANG_STANDALONE_BUILD)
link_directories("${LLVM_LIBRARY_DIR}")
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
@@ -238,6 +239,7 @@ include_directories(SYSTEM ${CLANG_INCLUDE_DIR})
# tco tool and FIR lib output directories
if(FLANG_STANDALONE_BUILD)
+ set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
endif()
# Always build tco tool
diff --git a/flang/include/flang/Evaluate/call.h b/flang/include/flang/Evaluate/call.h
index 8137185da61442..080f78c4e80fc0 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/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 "flang/Parser/char-block.h"
-#include "flang/Semantics/attr.h"
#include <optional>
#include <vector>
diff --git a/flang/include/flang/Evaluate/characteristics.h b/flang/include/flang/Evaluate/characteristics.h
index 8f1e6876d88d58..e40155fb287b62 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/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
-#include "flang/Support/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 69f09a930dc604..91d38748f5a575 100644
--- a/flang/include/flang/Evaluate/common.h
+++ b/flang/include/flang/Evaluate/common.h
@@ -9,17 +9,16 @@
#ifndef FORTRAN_EVALUATE_COMMON_H_
#define FORTRAN_EVALUATE_COMMON_H_
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
-#include "flang/Support/default-kinds.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
-#include "flang/Support/indirection.h"
-#include "flang/Common/Fortran-consts.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/Common/target-rounding.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>
@@ -34,10 +33,9 @@ class IntrinsicProcTable;
class TargetCharacteristics;
using common::ConstantSubscript;
-using common::RelationalOperator;
-using common::RoundingMode;
-using common::RealFlags;
using common::RealFlag;
+using common::RealFlags;
+using common::RelationalOperator;
// Integers are always ordered; reals may not be.
ENUM_CLASS(Ordering, Less, Equal, Greater)
diff --git a/flang/include/flang/Evaluate/expression.h b/flang/include/flang/Evaluate/expression.h
index a582a2ea1a6989..20e8725f91d5e5 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/Support/Fortran.h"
#include "flang/Common/idioms.h"
+#include "flang/Parser/char-block.h"
+#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include "flang/Support/template.h"
-#include "flang/Parser/char-block.h"
#include <algorithm>
#include <list>
#include <tuple>
diff --git a/flang/include/flang/Evaluate/intrinsics.h b/flang/include/flang/Evaluate/intrinsics.h
index 17f555445f6f79..dbe1ba7fe7ec1b 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/Support/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 f3eeea7984bba7..8e8d89ffd8d108 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/Support/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 8f52b29bec6654..11ac41a5deb69f 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/Support/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 29d19bff44c79c..9e1c25a3529380 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/Support/template.h"
-#include "flang/Support/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 e04888f395c013..508d4ca76b30f6 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/Support/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 b68a5790c810fd..93311e3d2e5ae0 100644
--- a/flang/include/flang/Evaluate/type.h
+++ b/flang/include/flang/Evaluate/type.h
@@ -22,10 +22,10 @@
#include "integer.h"
#include "logical.h"
#include "real.h"
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/real.h"
+#include "flang/Support/Fortran-features.h"
+#include "flang/Support/Fortran.h"
#include "flang/Support/template.h"
#include <cinttypes>
#include <optional>
diff --git a/flang/include/flang/Evaluate/variable.h b/flang/include/flang/Evaluate/variable.h
index 8d0da5b24277cd..161625b6887189 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/Parser/char-block.h"
#include "flang/Support/reference.h"
#include "flang/Support/template.h"
-#include "flang/Parser/char-block.h"
#include <optional>
#include <variant>
#include <vector>
diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h
index b69ffe83de1707..c436eb4cbac6f3 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/Support/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/Lower/AbstractConverter.h b/flang/include/flang/Lower/AbstractConverter.h
index 56646c196a7de5..6c8d77db2202b5 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/Support/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 0c2c7abc324952..f07207c5026ebd 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -13,13 +13,13 @@
#ifndef FORTRAN_LOWER_BRIDGE_H
#define FORTRAN_LOWER_BRIDGE_H
-#include "flang/Support/Fortran.h"
#include "flang/Lower/AbstractConverter.h"
#include "flang/Lower/EnvironmentDefault.h"
#include "flang/Lower/LoweringOptions.h"
#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 <set>
diff --git a/flang/include/flang/Lower/CallInterface.h b/flang/include/flang/Lower/CallInterface.h
index df01eafe679d7d..b16ad7a91afd0a 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/Support/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 b889d2bb279de2..179a6825840464 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/Support/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/PFTBuilder.h b/flang/include/flang/Lower/PFTBuilder.h
index 7ee61e630581fe..b2e0d776a228b1 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/Support/reference.h"
-#include "flang/Support/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 a09cfb16f7805a..08a872b228691d 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/Support/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 7bba02e41a3bdf..fb64db407708ad 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/Support/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 90279417b5c939..14c1d5033fab40 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/Support/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 26cf34188eb568..2a3e85988184b4 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/Support/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 104e363e689857..e9fb177d311c01 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/Support/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/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h
index 631322b34c49e5..88d38cb7574813 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/Support/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/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h
index f98ac17b6ecba7..30ea08806430a9 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -14,8 +14,8 @@
#include "parse-tree.h"
#include "tools.h"
#include "unparse.h"
-#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
diff --git a/flang/include/flang/Parser/message.h b/flang/include/flang/Parser/message.h
index 70746bf551f2d7..c3d4a78c2c0023 100644
--- a/flang/include/flang/Parser/message.h
+++ b/flang/include/flang/Parser/message.h
@@ -16,8 +16,8 @@
#include "char-set.h"
#include "provenance.h"
#include "flang/Common/idioms.h"
-#include "flang/Support/reference-counted.h"
#include "flang/Common/restorer.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 20d339aeeccccf..36d70b81b79236 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/Support/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 a6d19dd6435966..de869f8200a261 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -22,8 +22,8 @@
#include "format-specification.h"
#include "message.h"
#include "provenance.h"
-#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include "llvm/Frontend/OpenACC/ACC.h.inc"
#include "llvm/Frontend/OpenMP/OMPConstants.h"
diff --git a/flang/include/flang/Parser/parsing.h b/flang/include/flang/Parser/parsing.h
index b0de98737f536e..0e608cb220d2c5 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/Support/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/user-state.h b/flang/include/flang/Parser/user-state.h
index fff651208e0e52..129f9fb8fee058 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/Support/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/Semantics/expression.h b/flang/include/flang/Semantics/expression.h
index 77e26ffb834dd9..194cb746ff8a84 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/Support/Fortran.h"
-#include "flang/Support/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 3f9f776797d782..94c50aab696816 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/Support/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 8b416dcffb5245..72e8bab71b6c70 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/Support/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Support/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 899d4afa016bff..abce30f725d972 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -11,12 +11,12 @@
#include "scope.h"
#include "symbol.h"
-#include "flang/Support/Fortran-features.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
#include "flang/Parser/message.h"
#include "flang/Semantics/module-dependences.h"
+#include "flang/Support/Fortran-features.h"
#include <iosfwd>
#include <set>
#include <string>
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 29587be2c7d77d..d207cfe7d7421a 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/Support/Fortran.h"
#include "flang/Common/enum-set.h"
-#include "flang/Support/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 9be7ebff9b5bb6..e31de6e958a8c4 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/Support/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 fd31bc805e2de6..210ea7a129376d 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/Support/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/Support/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
index f0bfc9232ea9e9..718ce680afeeab 100644
--- a/flang/include/flang/Support/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -9,9 +9,9 @@
#ifndef FORTRAN_COMMON_FORTRAN_FEATURES_H_
#define FORTRAN_COMMON_FORTRAN_FEATURES_H_
-#include "flang/Support/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
#include <vector>
namespace Fortran::common {
diff --git a/flang/include/flang/Support/Fortran.h b/flang/include/flang/Support/Fortran.h
index 6dbfb51f19dd8e..343a0b30d2ba9c 100644
--- a/flang/include/flang/Support/Fortran.h
+++ b/flang/include/flang/Support/Fortran.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Support/Fortran.h -------------------------*- C++ -*-===//
+//===-- include/flang/Common/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.
@@ -9,7 +9,8 @@
#ifndef FORTRAN_COMMON_FORTRAN_H_
#define FORTRAN_COMMON_FORTRAN_H_
-
+// Fortran language concepts that are used in many phases are defined
+// once here to avoid redundancy and needless translation.
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/enum-set.h"
@@ -18,11 +19,8 @@
#include <optional>
#include <string>
-
namespace Fortran::common {
- class LanguageFeatureControl;
-
-
+class LanguageFeatureControl;
constexpr bool IsNumericTypeCategory(TypeCategory category) {
return category == TypeCategory::Integer || category == TypeCategory::Real ||
@@ -46,7 +44,6 @@ const char *AsFortran(RelationalOperator);
ENUM_CLASS(Intent, Default, In, Out, InOut)
-
// Union of specifiers for all I/O statements.
ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
Delim, Direct, Encoding, End, Eor, Err, Exist, File, Fmt, Form, Formatted,
@@ -58,15 +55,11 @@ ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
Dispose, // nonstandard
)
-
const char *AsFortran(DefinedIo);
-
// Fortran label. Must be in [1..99999].
using Label = std::uint64_t;
-
-
// CUDA subprogram attribute combinations
ENUM_CLASS(CUDASubprogramAttrs, Host, Device, HostDevice, Global, Grid_Global)
@@ -112,5 +105,6 @@ inline std::string GetExternalAssemblyName(
std::string symbolName, bool underscoring) {
return underscoring ? std::move(symbolName) + "_" : std::move(symbolName);
}
+
} // namespace Fortran::common
#endif // FORTRAN_COMMON_FORTRAN_H_
diff --git a/flang/include/flang/Support/template.h b/flang/include/flang/Support/template.h
index e15de9c2d0cea8..58c9b0a5628e8a 100644
--- a/flang/include/flang/Support/template.h
+++ b/flang/include/flang/Support/template.h
@@ -9,8 +9,8 @@
#ifndef FORTRAN_COMMON_TEMPLATE_H_
#define FORTRAN_COMMON_TEMPLATE_H_
-#include "flang/Common/variant.h"
#include "flang/Common/idioms.h"
+#include "flang/Common/variant.h"
#include <functional>
#include <optional>
#include <tuple>
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h
index bc105f471aa003..168c3aefe0cd41 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/Support/MathOptionsBase.h"
#include "flang/Frontend/CodeGenOptions.h"
#include "flang/Frontend/LangOptions.h"
+#include "flang/Support/MathOptionsBase.h"
#include <cstdint>
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index b62aeb2c08b779..73af3bdd589162 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -1,11 +1,3 @@
-#===-- FortranRuntime/lib/Common/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(FortranCommon
"${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/binary-to-decimal.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/decimal-to-binary.cpp"
diff --git a/flang/lib/Evaluate/call.cpp b/flang/lib/Evaluate/call.cpp
index 1cb8eb89f41687..f77df92a7597ab 100644
--- a/flang/lib/Evaluate/call.cpp
+++ b/flang/lib/Evaluate/call.cpp
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/call.h"
-#include "flang/Support/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 091f2e2b553e86..ffa3ec721cbd63 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/characteristics.h"
-#include "flang/Support/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/common.cpp b/flang/lib/Evaluate/common.cpp
index 7741bec650575d..ed040b0728c4db 100644
--- a/flang/lib/Evaluate/common.cpp
+++ b/flang/lib/Evaluate/common.cpp
@@ -9,7 +9,6 @@
#include "flang/Evaluate/common.h"
#include "flang/Common/idioms.h"
-
using namespace Fortran::parser::literals;
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index c8452cdd6a0caa..86cbd971aebcb5 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/Support/indirection.h"
-#include "flang/Support/template.h"
-#include "flang/Support/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 db5d005d97c8c9..a53fa019984b43 100644
--- a/flang/lib/Evaluate/formatting.cpp
+++ b/flang/lib/Evaluate/formatting.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/formatting.h"
-#include "flang/Support/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 440ddaaf9689c8..4f1eff492afae5 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -14,8 +14,8 @@
#include "flang/Evaluate/intrinsics-library.h"
#include "fold-implementation.h"
#include "host.h"
-#include "flang/Support/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 343bd2c9f22be2..bcad2d831cb784 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/intrinsics.h"
-#include "flang/Support/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/real.cpp b/flang/lib/Evaluate/real.cpp
index 9d465e5f35d6ae..01d2e14cbf933e 100644
--- a/flang/lib/Evaluate/real.cpp
+++ b/flang/lib/Evaluate/real.cpp
@@ -8,8 +8,8 @@
#include "flang/Evaluate/real.h"
#include "int-power.h"
-#include "flang/Common/idioms.h"
#include "flang/Common/decimal.h"
+#include "flang/Common/idioms.h"
#include "flang/Parser/characters.h"
#include "llvm/Support/raw_ostream.h"
#include <limits>
diff --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp
index 7b78d8c7b9734f..d77dd312eba97a 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/Support/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 d0722c31e3c3f7..79d260af6d50b9 100644
--- a/flang/lib/Evaluate/target.cpp
+++ b/flang/lib/Evaluate/target.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Evaluate/target.h"
-#include "flang/Support/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/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index a0653576852101..d86d6e678a4ed9 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -11,12 +11,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/CompilerInstance.h"
-#include "flang/Support/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 "clang/Basic/DiagnosticFrontend.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/MC/TargetRegistry.h"
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 5fe6ccbc44a894..5416234ca3e9e6 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -11,13 +11,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/CompilerInvocation.h"
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/OpenMP-features.h"
-#include "flang/Support/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 7d51c20514387a..dced7f296e7904 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/FrontendActions.h"
-#include "flang/Support/default-kinds.h"
#include "flang/Frontend/CompilerInstance.h"
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/FrontendOptions.h"
@@ -33,6 +32,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 6924717cb467ac..c903c2169e4dcd 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -12,7 +12,6 @@
#include "flang/Lower/Bridge.h"
#include "DirectivesCommon.h"
-#include "flang/Support/Version.h"
#include "flang/Lower/Allocatable.h"
#include "flang/Lower/CallInterface.h"
#include "flang/Lower/Coarray.h"
@@ -59,6 +58,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/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index 153845699dae3d..9334ce009eae5e 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/CallInterface.h"
-#include "flang/Support/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 4d2ac95ea784b5..b85043f78884f0 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -11,8 +11,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/ConvertExpr.h"
-#include "flang/Support/default-kinds.h"
-#include "flang/Support/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 565f9c6cbc5892..4ff170c19d922a 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Lower/Mangler.h"
-#include "flang/Support/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 5f1a25b1af23e9..460923bbccc27a 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/Support/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.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"
@@ -507,7 +507,7 @@ static constexpr IntrinsicHandler handlers[]{
/*isElemental=*/false},
{"not", &I::genNot},
{"null", &I::genNull, {{{"mold", asInquired}}}, /*isElemental=*/false},
- {"numeric_storage_size", &I::genNumericStorageSize},
+ {"numeric_storage_size", &I::genNumericStorageSize},
{"pack",
&I::genPack,
{{{"array", asBox},
@@ -7224,8 +7224,7 @@ IntrinsicLibrary::genVerify(mlir::Type resultType,
return readAndAddCleanUp(resultMutableBox, resultType, "VERIFY");
}
-
- fir::ExtendedValue IntrinsicLibrary:: genNumericStorageSize(mlir::Type resultType, llvm::ArrayRef<fir::ExtendedValue> args) {
+fir::ExtendedValue IntrinsicLibrary:: genNumericStorageSize(mlir::Type resultType, llvm::ArrayRef<fir::ExtendedValue> args) {
assert(args.empty() );
if (!ignoreModuleOnlyBuiltins) {
@@ -7236,7 +7235,6 @@ IntrinsicLibrary::genVerify(mlir::Type resultType,
return builder.createIntegerConstant(loc, resultType , 32 );
}
-
/// Process calls to Minloc, Maxloc intrinsic functions
template <typename FN, typename FD>
fir::ExtendedValue
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
index c632e42ef72c29..45354e0fe79666 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/Support/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/Transforms/AddDebugInfo.cpp b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index f41633629bb3e2..f84dd6bf6c06c5 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//
#include "DebugTypeGenerator.h"
-#include "flang/Support/Version.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/CodeGen/CGOps.h"
@@ -22,6 +21,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 ca6eacfd0e7200..9fccbd24a74982 100644
--- a/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Support/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/CufOpConversion.cpp b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
index d3c44a75e4cffb..d7d321c6b9af3f 100644
--- a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Support/Fortran.h"
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
#include "flang/Optimizer/CodeGen/TypeConverter.h"
#include "flang/Optimizer/Dialect/CUF/CUFOps.h"
@@ -16,6 +15,7 @@
#include "flang/Optimizer/Support/DataLayout.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
+#include "flang/Support/Fortran.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
diff --git a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
index 1915abe2f91e0e..3e4f46297357f9 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Support/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/IR/Attributes.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Pass/Pass.h"
diff --git a/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp b/flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
index c56dfa1cdfb524..3f5178710689cb 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/Support/Fortran.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/LowLevelIntrinsics.h"
@@ -34,6 +33,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 629ba587adf3ca..eb088c30e94f20 100644
--- a/flang/lib/Optimizer/Transforms/StackReclaim.cpp
+++ b/flang/lib/Optimizer/Transforms/StackReclaim.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Support/Fortran.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/Parser/basic-parsers.h b/flang/lib/Parser/basic-parsers.h
index 6575c7d01de346..be0f4fc44374ca 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/Support/Fortran-features.h"
#include "flang/Common/idioms.h"
-#include "flang/Support/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 3b90a57c602945..0793383efefb5f 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/Support/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 0ea614d1df3bd9..f9d920a6621aa5 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/Support/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 7b0385c63cd8a1..4a044514916030 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/Support/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Support/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 275625d3ed6522..ba0c70f7d224cb 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/Support/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 0e38b24f1b319d..6d38bbee1eb2cb 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/Support/reference.h"
-#include "flang/Support/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 d34c70e60d966b..ac1f38801cee72 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/Support/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 738a471f4d01f5..b89b46868d2e58 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/Support/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 5cdf46a5ffb1c9..6da316cccc4a7b 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/Support/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 42e1c07fc45c3e..26530e798c9f4c 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/Support/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 6a03467a27a759..c7b91a2725c942 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/Support/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 722226465b6642..b227bbaaef4ba4 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/Support/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 da41410bd24612..b86a95492b21c1 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/Support/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 dab076424bd8e6..aabd52098e63bb 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/Support/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 df4d552760eda6..e99a02cc79db15 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/Support/default-kinds.h"
-#include "flang/Support/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 a4be06515e4c87..2a8ed892c800eb 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/Support/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 abd3c5f461cb7e..d8fcedf24bdb9e 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/Support/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 84d2e51d438bfe..e988ba8e331963 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/Support/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 bc5f458f403cf2..3aa48e92d423db 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/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
-#include "flang/Support/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 920cefa084e05c..ebcb864549e48e 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -14,9 +14,6 @@
#include "resolve-directives.h"
#include "resolve-names-utils.h"
#include "rewrite-parse-tree.h"
-#include "flang/Support/Fortran.h"
-#include "flang/Support/default-kinds.h"
-#include "flang/Support/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/characteristics.h"
@@ -37,6 +34,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 46641f5bd3c363..7f4efe67d7ec9f 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/Support/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 c39c8ac5a7b111..aa897f3011f51d 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/Support/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 2aa0476b8fa07a..3f5cf3cebbea9b 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//
#include "flang/Parser/tools.h"
-#include "flang/Support/Fortran.h"
-#include "flang/Support/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/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
index e49735218ab967..868d18caa13c64 100644
--- a/flang/lib/Support/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Support/Fortran-features.h"
-#include "flang/Support/Fortran.h"
#include "flang/Common/idioms.h"
+#include "flang/Support/Fortran.h"
namespace Fortran::common {
diff --git a/flang/lib/Support/big-radix-floating-point.h b/flang/lib/Support/big-radix-floating-point.h
deleted file mode 100644
index 4c3d8f8b30832a..00000000000000
--- a/flang/lib/Support/big-radix-floating-point.h
+++ /dev/null
@@ -1,396 +0,0 @@
-//===-- lib/Support/big-radix-floating-point.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_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
-#define FORTRAN_DECIMAL_BIG_RADIX_FLOATING_POINT_H_
-
-// This is a helper class for use in floating-point conversions between
-// binary and decimal representations. It holds a multiple-precision
-// integer value using digits of a radix that is a large even power of ten
-// (10,000,000,000,000,000 by default, 10**16). These digits are accompanied
-// by a signed exponent that denotes multiplication by a power of ten.
-// The effective radix point is to the right of the digits (i.e., they do
-// not represent a fraction).
-//
-// The operations supported by this class are limited to those required
-// for conversions between binary and decimal representations; it is not
-// a general-purpose facility.
-
-#include "flang/Common/bit-population-count.h"
-#include "flang/Common/leading-zero-bit-count.h"
-#include "flang/Common/uint128.h"
-#include "flang/Support/binary-floating-point.h"
-#include "flang/Common/decimal.h"
-#include <cinttypes>
-#include <limits>
-#include <type_traits>
-
-// Some environments, viz. glibc 2.17, allow the macro HUGE
-// to leak out of <math.h>.
-#undef HUGE
-
-namespace Fortran::decimal {
-
-static constexpr std::uint64_t TenToThe(int power) {
- return power <= 0 ? 1 : 10 * TenToThe(power - 1);
-}
-
-// 10**(LOG10RADIX + 3) must be < 2**wordbits, and LOG10RADIX must be
-// even, so that pairs of decimal digits do not straddle Digits.
-// So LOG10RADIX must be 16 or 6.
-template <int PREC, int LOG10RADIX = 16> class BigRadixFloatingPointNumber {
-public:
- using Real = BinaryFloatingPointNumber<PREC>;
- static constexpr int log10Radix{LOG10RADIX};
-
-private:
- static constexpr std::uint64_t uint64Radix{TenToThe(log10Radix)};
- static constexpr int minDigitBits{
- 64 - common::LeadingZeroBitCount(uint64Radix)};
- using Digit = common::HostUnsignedIntType<minDigitBits>;
- static constexpr Digit radix{uint64Radix};
- static_assert(radix < std::numeric_limits<Digit>::max() / 1000,
- "radix is somehow too big");
- static_assert(radix > std::numeric_limits<Digit>::max() / 10000,
- "radix is somehow too small");
-
- // The base-2 logarithm of the least significant bit that can arise
- // in a subnormal IEEE floating-point number.
- static constexpr int minLog2AnyBit{
- -Real::exponentBias - Real::binaryPrecision};
-
- // The number of Digits needed to represent the smallest subnormal.
- static constexpr int maxDigits{3 - minLog2AnyBit / log10Radix};
-
-public:
- explicit RT_API_ATTRS BigRadixFloatingPointNumber(
- enum FortranRounding rounding = RoundNearest)
- : rounding_{rounding} {}
-
- // Converts a binary floating point value.
- explicit RT_API_ATTRS BigRadixFloatingPointNumber(
- Real, enum FortranRounding = RoundNearest);
-
- RT_API_ATTRS BigRadixFloatingPointNumber &SetToZero() {
- isNegative_ = false;
- digits_ = 0;
- exponent_ = 0;
- return *this;
- }
-
- RT_API_ATTRS bool IsInteger() const { return exponent_ >= 0; }
-
- // Converts decimal floating-point to binary.
- RT_API_ATTRS ConversionToBinaryResult<PREC> ConvertToBinary();
-
- // Parses and converts to binary. Handles leading spaces,
- // "NaN", & optionally-signed "Inf". Does not skip internal
- // spaces.
- // The argument is a reference to a pointer that is left
- // pointing to the first character that wasn't parsed.
- RT_API_ATTRS ConversionToBinaryResult<PREC> ConvertToBinary(
- const char *&, const char *end = nullptr);
-
- // Formats a decimal floating-point number to a user buffer.
- // May emit "NaN" or "Inf", or an possibly-signed integer.
- // No decimal point is written, but if it were, it would be
- // after the last digit; the effective decimal exponent is
- // returned as part of the result structure so that it can be
- // formatted by the client.
- RT_API_ATTRS ConversionToDecimalResult ConvertToDecimal(
- char *, std::size_t, enum DecimalConversionFlags, int digits) const;
-
- // Discard decimal digits not needed to distinguish this value
- // from the decimal encodings of two others (viz., the nearest binary
- // floating-point numbers immediately below and above this one).
- // The last decimal digit may not be uniquely determined in all
- // cases, and will be the mean value when that is so (e.g., if
- // last decimal digit values 6-8 would all work, it'll be a 7).
- // This minimization necessarily assumes that the value will be
- // emitted and read back into the same (or less precise) format
- // with default rounding to the nearest value.
- RT_API_ATTRS void Minimize(
- BigRadixFloatingPointNumber &&less, BigRadixFloatingPointNumber &&more);
-
- template <typename STREAM> STREAM &Dump(STREAM &) const;
-
-private:
- RT_API_ATTRS BigRadixFloatingPointNumber(
- const BigRadixFloatingPointNumber &that)
- : digits_{that.digits_}, exponent_{that.exponent_},
- isNegative_{that.isNegative_}, rounding_{that.rounding_} {
- for (int j{0}; j < digits_; ++j) {
- digit_[j] = that.digit_[j];
- }
- }
-
- RT_API_ATTRS bool IsZero() const {
- // Don't assume normalization.
- for (int j{0}; j < digits_; ++j) {
- if (digit_[j] != 0) {
- return false;
- }
- }
- return true;
- }
-
- // Predicate: true when 10*value would cause a carry.
- // (When this happens during decimal-to-binary conversion,
- // there are more digits in the input string than can be
- // represented precisely.)
- RT_API_ATTRS bool IsFull() const {
- return digits_ == digitLimit_ && digit_[digits_ - 1] >= radix / 10;
- }
-
- // Sets *this to an unsigned integer value.
- // Returns any remainder.
- template <typename UINT> RT_API_ATTRS UINT SetTo(UINT n) {
- static_assert(
- std::is_same_v<UINT, common::uint128_t> || std::is_unsigned_v<UINT>);
- SetToZero();
- while (n != 0) {
- auto q{n / 10u};
- if (n != q * 10) {
- break;
- }
- ++exponent_;
- n = q;
- }
- if constexpr (sizeof n < sizeof(Digit)) {
- if (n != 0) {
- digit_[digits_++] = n;
- }
- return 0;
- } else {
- while (n != 0 && digits_ < digitLimit_) {
- auto q{n / radix};
- digit_[digits_++] = static_cast<Digit>(n - q * radix);
- n = q;
- }
- return n;
- }
- }
-
- RT_API_ATTRS int RemoveLeastOrderZeroDigits() {
- int remove{0};
- if (digits_ > 0 && digit_[0] == 0) {
- while (remove < digits_ && digit_[remove] == 0) {
- ++remove;
- }
- if (remove >= digits_) {
- digits_ = 0;
- } else if (remove > 0) {
-#if defined __GNUC__ && __GNUC__ < 8
- // (&& j + remove < maxDigits) was added to avoid GCC < 8 build failure
- // on -Werror=array-bounds. This can be removed if -Werror is disable.
- for (int j{0}; j + remove < digits_ && (j + remove < maxDigits); ++j) {
-#else
- for (int j{0}; j + remove < digits_; ++j) {
-#endif
- digit_[j] = digit_[j + remove];
- }
- digits_ -= remove;
- }
- }
- return remove;
- }
-
- RT_API_ATTRS void RemoveLeadingZeroDigits() {
- while (digits_ > 0 && digit_[digits_ - 1] == 0) {
- --digits_;
- }
- }
-
- RT_API_ATTRS void Normalize() {
- RemoveLeadingZeroDigits();
- exponent_ += RemoveLeastOrderZeroDigits() * log10Radix;
- }
-
- // This limited divisibility test only works for even divisors of the radix,
- // which is fine since it's only ever used with 2 and 5.
- template <int N> RT_API_ATTRS bool IsDivisibleBy() const {
- static_assert(N > 1 && radix % N == 0, "bad modulus");
- return digits_ == 0 || (digit_[0] % N) == 0;
- }
-
- template <unsigned DIVISOR> RT_API_ATTRS int DivideBy() {
- Digit remainder{0};
- for (int j{digits_ - 1}; j >= 0; --j) {
- Digit q{digit_[j] / DIVISOR};
- Digit nrem{digit_[j] - DIVISOR * q};
- digit_[j] = q + (radix / DIVISOR) * remainder;
- remainder = nrem;
- }
- return remainder;
- }
-
- RT_API_ATTRS void DivideByPowerOfTwo(int twoPow) { // twoPow <= log10Radix
- Digit remainder{0};
- auto mask{(Digit{1} << twoPow) - 1};
- auto coeff{radix >> twoPow};
- for (int j{digits_ - 1}; j >= 0; --j) {
- auto nrem{digit_[j] & mask};
- digit_[j] = (digit_[j] >> twoPow) + coeff * remainder;
- remainder = nrem;
- }
- }
-
- // Returns true on overflow
- RT_API_ATTRS bool DivideByPowerOfTwoInPlace(int twoPow) {
- if (digits_ > 0) {
- while (twoPow > 0) {
- int chunk{twoPow > log10Radix ? log10Radix : twoPow};
- if ((digit_[0] & ((Digit{1} << chunk) - 1)) == 0) {
- DivideByPowerOfTwo(chunk);
- twoPow -= chunk;
- continue;
- }
- twoPow -= chunk;
- if (digit_[digits_ - 1] >> chunk != 0) {
- if (digits_ == digitLimit_) {
- return true; // overflow
- }
- digit_[digits_++] = 0;
- }
- auto remainder{digit_[digits_ - 1]};
- exponent_ -= log10Radix;
- auto coeff{radix >> chunk}; // precise; radix is (5*2)**log10Radix
- auto mask{(Digit{1} << chunk) - 1};
- for (int j{digits_ - 1}; j >= 1; --j) {
- digit_[j] = (digit_[j - 1] >> chunk) + coeff * remainder;
- remainder = digit_[j - 1] & mask;
- }
- digit_[0] = coeff * remainder;
- }
- }
- return false; // no overflow
- }
-
- RT_API_ATTRS int AddCarry(int position = 0, int carry = 1) {
- for (; position < digits_; ++position) {
- Digit v{digit_[position] + carry};
- if (v < radix) {
- digit_[position] = v;
- return 0;
- }
- digit_[position] = v - radix;
- carry = 1;
- }
- if (digits_ < digitLimit_) {
- digit_[digits_++] = carry;
- return 0;
- }
- Normalize();
- if (digits_ < digitLimit_) {
- digit_[digits_++] = carry;
- return 0;
- }
- return carry;
- }
-
- RT_API_ATTRS void Decrement() {
- for (int j{0}; digit_[j]-- == 0; ++j) {
- digit_[j] = radix - 1;
- }
- }
-
- template <int N> RT_API_ATTRS int MultiplyByHelper(int carry = 0) {
- for (int j{0}; j < digits_; ++j) {
- auto v{N * digit_[j] + carry};
- carry = v / radix;
- digit_[j] = v - carry * radix; // i.e., v % radix
- }
- return carry;
- }
-
- template <int N> RT_API_ATTRS int MultiplyBy(int carry = 0) {
- if (int newCarry{MultiplyByHelper<N>(carry)}) {
- return AddCarry(digits_, newCarry);
- } else {
- return 0;
- }
- }
-
- template <int N> RT_API_ATTRS int MultiplyWithoutNormalization() {
- if (int carry{MultiplyByHelper<N>(0)}) {
- if (digits_ < digitLimit_) {
- digit_[digits_++] = carry;
- return 0;
- } else {
- return carry;
- }
- } else {
- return 0;
- }
- }
-
- RT_API_ATTRS void LoseLeastSignificantDigit(); // with rounding
-
- RT_API_ATTRS void PushCarry(int carry) {
- if (digits_ == maxDigits && RemoveLeastOrderZeroDigits() == 0) {
- LoseLeastSignificantDigit();
- digit_[digits_ - 1] += carry;
- } else {
- digit_[digits_++] = carry;
- }
- }
-
- // Adds another number and then divides by two.
- // Assumes same exponent and sign.
- // Returns true when the result has effectively been rounded down.
- RT_API_ATTRS bool Mean(const BigRadixFloatingPointNumber &);
-
- // Parses a floating-point number; leaves the pointer reference
- // argument pointing at the next character after what was recognized.
- // The "end" argument can be left null if the caller is sure that the
- // string is properly terminated with an addressable character that
- // can't be in a valid floating-point character.
- RT_API_ATTRS bool ParseNumber(const char *&, bool &inexact, const char *end);
-
- using Raw = typename Real::RawType;
- constexpr RT_API_ATTRS Raw SignBit() const {
- return Raw{isNegative_} << (Real::bits - 1);
- }
- constexpr RT_API_ATTRS Raw Infinity() const {
- Raw result{static_cast<Raw>(Real::maxExponent)};
- result <<= Real::significandBits;
- result |= SignBit();
- if constexpr (Real::bits == 80) { // x87
- result |= Raw{1} << 63;
- }
- return result;
- }
- constexpr RT_API_ATTRS Raw NaN(bool isQuiet = true) {
- Raw result{Real::maxExponent};
- result <<= Real::significandBits;
- result |= SignBit();
- if constexpr (Real::bits == 80) { // x87
- result |= Raw{isQuiet ? 3u : 2u} << 62;
- } else {
- Raw quiet{isQuiet ? Raw{2} : Raw{1}};
- quiet <<= Real::significandBits - 2;
- result |= quiet;
- }
- return result;
- }
- constexpr RT_API_ATTRS Raw HUGE() const {
- Raw result{static_cast<Raw>(Real::maxExponent)};
- result <<= Real::significandBits;
- result |= SignBit();
- return result - 1; // decrement exponent, set all significand bits
- }
-
- Digit digit_[maxDigits]; // in little-endian order: digit_[0] is LSD
- int digits_{0}; // # of elements in digit_[] array; zero when zero
- int digitLimit_{maxDigits}; // precision clamp
- int exponent_{0}; // signed power of ten
- bool isNegative_{false};
- enum FortranRounding rounding_ { RoundNearest };
-};
-} // namespace Fortran::decimal
-#endif
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index 60261ea352780a..03fa79979470ee 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -63,7 +63,6 @@ set(FLANG_TEST_DEPENDS
FileCheck
count
not
-# module_files
fir-opt
tco
bbc
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index e9ec6b7116e0aa..917e052ef35fa1 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -14,10 +14,6 @@
///
//===----------------------------------------------------------------------===//
-#include "flang/Support/Fortran-features.h"
-#include "flang/Support/OpenMP-features.h"
-#include "flang/Support/Version.h"
-#include "flang/Support/default-kinds.h"
#include "flang/Frontend/TargetOptions.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/PFTBuilder.h"
@@ -40,6 +36,10 @@
#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/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/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp
index 691b6cebec9b51..a50c88dc840643 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/Support/Fortran-features.h"
-#include "flang/Support/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/unittests/Evaluate/expression.cpp b/flang/unittests/Evaluate/expression.cpp
index 6349997bafee48..d575f36def287e 100644
--- a/flang/unittests/Evaluate/expression.cpp
+++ b/flang/unittests/Evaluate/expression.cpp
@@ -1,10 +1,10 @@
#include "flang/Evaluate/expression.h"
-#include "flang/Testing/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 35df702ff20ea6..832e55d44316da 100644
--- a/flang/unittests/Evaluate/folding.cpp
+++ b/flang/unittests/Evaluate/folding.cpp
@@ -1,4 +1,3 @@
-#include "flang/Testing/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/intrinsics.cpp b/flang/unittests/Evaluate/intrinsics.cpp
index 0baf01a4cb1b7e..cca2f8c30247e0 100644
--- a/flang/unittests/Evaluate/intrinsics.cpp
+++ b/flang/unittests/Evaluate/intrinsics.cpp
@@ -1,10 +1,10 @@
#include "flang/Evaluate/intrinsics.h"
-#include "flang/Testing/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/logical.cpp b/flang/unittests/Evaluate/logical.cpp
index ee568371eab86c..ba7d0d8d0c0e3a 100644
--- a/flang/unittests/Evaluate/logical.cpp
+++ b/flang/unittests/Evaluate/logical.cpp
@@ -1,5 +1,5 @@
-#include "flang/Testing/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 ab1a178df22312..23406fc6909aea 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -1,6 +1,6 @@
+#include "flang/Evaluate/type.h"
#include "flang/Testing/fp-testing.h"
#include "flang/Testing/testing.h"
-#include "flang/Evaluate/type.h"
#include "llvm/Support/raw_ostream.h"
#include <cmath>
#include <cstdio>
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index e4e6a3bb52410f..74d1ae0615fa6a 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -51,7 +51,6 @@ AutoExporter::AutoExporter(
"libc++",
"libc++abi",
"libFortranRuntime",
- "libFortranFloat128Math",
"libFortranRuntime.static",
"libFortranRuntime.dynamic",
"libFortranRuntime.static_dbg",
diff --git a/llvm/projects/CMakeLists.txt b/llvm/projects/CMakeLists.txt
index fab28c9df6d384..d8808bc79f0129 100644
--- a/llvm/projects/CMakeLists.txt
+++ b/llvm/projects/CMakeLists.txt
@@ -38,7 +38,6 @@ if(${LLVM_BUILD_RUNTIME})
if(NOT LLVM_BUILD_EXTERNAL_COMPILER_RT)
add_llvm_external_project(compiler-rt)
endif()
-
add_llvm_external_project(FortranRuntime)
endif()
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index e4389b120f49df..5da91169058724 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -510,14 +510,7 @@ if(build_runtimes)
list(APPEND extra_cmake_args "-DCMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}")
endif()
- # FIXME: Go away
if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
- #if (LLVM_TOOL_FLANG_BUILD AND "FortranRuntime" IN_LIST LLVM_ENABLE_PROJECTS)
- # message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
- # set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new${CMAKE_EXECUTABLE_SUFFIX}")
- # #TODO: set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
- # list(APPEND extra_deps "flang-new")
- #endif()
if (LLVM_TOOL_FLANG_BUILD AND "FortranRuntime" IN_LIST LLVM_ENABLE_PROJECTS)
set(enable_fortran ENABLE_FORTRAN)
endif ()
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index d77b4da6e00e34..2a7798fd60af42 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -49,7 +49,6 @@ function(runtime_register_component name)
set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
endfunction()
-message("LLVM_BINARY_DIR: ${LLVM_BINARY_DIR}")
find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
>From c7bc5e9785751bba5784b2ec93702b8e5005974d Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 30 Sep 2024 15:06:18 +0200
Subject: [PATCH 03/58] Move target-independent modules back to Flang
Move modules back to flang
Fix check-flang
Build fixes and cleanup
Test fix
Solve mscrt lib choice
clang_rt.builtins workaround via CMAake
clang_rt.builtins workaround via Clang
Revert "clang_rt.builtins workaround via Clang"
This reverts commit 2678d0c9a0ca86cfada9351d3328119388a35609.
Fix search for libclang_rt.builtins
move magic-numbers.h to common files
---
FortranRuntime/CMakeLists.txt | 52 +++---
.../cmake/modules/AddFortranRuntime.cmake | 43 +++--
.../Common/ISO_Fortran_binding_wrapper.h | 2 +-
.../flang/{Runtime => Common}/magic-numbers.h | 0
FortranRuntime/include/flang/Runtime/io-api.h | 2 +-
FortranRuntime/include/flang/Runtime/iostat.h | 2 +-
FortranRuntime/lib/Runtime/CMakeLists.txt | 153 ++++++-----------
FortranRuntime/lib/Runtime/file.cpp | 2 +-
FortranRuntime/lib/Runtime/io-error.cpp | 2 +-
FortranRuntime/lib/Runtime/stat.h | 2 +-
FortranRuntime/module/CMakeLists.txt | 63 -------
FortranRuntime/test/CMakeLists.txt | 13 +-
.../test/Driver/ctofortran.f90 | 3 +-
.../test/Driver/exec.f90 | 2 +-
FortranRuntime/test/NonGtestUnit/lit.cfg.py | 3 +-
FortranRuntime/test/lit.cfg.py | 16 +-
FortranRuntime/unittests/CMakeLists.txt | 11 +-
.../unittests/Common/CMakeLists.txt | 2 +-
.../unittests/Decimal/CMakeLists.txt | 4 +-
.../unittests/Evaluate/CMakeLists.txt | 4 +-
.../unittests/Runtime/CMakeLists.txt | 2 +-
clang/lib/Driver/ToolChains/Flang.cpp | 6 +-
flang/CMakeLists.txt | 14 ++
.../include/flang}/ISO_Fortran_binding.h | 11 +-
flang/lib/CMakeLists.txt | 3 -
flang/lib/Evaluate/fold-logical.cpp | 2 +-
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 17 --
.../module/.clang-format | 0
.../module/__cuda_builtins.f90 | 0
.../module/__fortran_builtins.f90 | 2 +-
.../module/__fortran_ieee_exceptions.f90 | 2 +-
.../module/__fortran_type_info.f90 | 0
.../module/__ppc_intrinsics.f90 | 0
.../module/__ppc_types.f90 | 0
.../module/cudadevice.f90 | 2 +-
.../module/ieee_arithmetic.f90 | 2 +-
.../module/ieee_exceptions.f90 | 0
.../module/ieee_features.f90 | 0
.../module/iso_c_binding.f90 | 0
.../module/iso_fortran_env.f90 | 2 +-
{FortranRuntime => flang}/module/mma.f90 | 43 ++---
flang/test/CMakeLists.txt | 1 +
.../test/Driver/msvc-dependent-lib-flags.f90 | 4 -
flang/tools/CMakeLists.txt | 1 +
flang/tools/bbc/CMakeLists.txt | 1 -
flang/tools/f18-parse-demo/CMakeLists.txt | 2 -
flang/tools/f18/CMakeLists.txt | 161 ++++++++++++++++++
flang/tools/f18/dump.cpp | 42 +++++
flang/tools/fir-opt/CMakeLists.txt | 2 -
flang/tools/flang-driver/CMakeLists.txt | 3 -
flang/tools/tco/CMakeLists.txt | 2 -
51 files changed, 387 insertions(+), 321 deletions(-)
rename FortranRuntime/include/flang/{Runtime => Common}/magic-numbers.h (100%)
delete mode 100644 FortranRuntime/module/CMakeLists.txt
rename {flang => FortranRuntime}/test/Driver/ctofortran.f90 (99%)
rename {flang => FortranRuntime}/test/Driver/exec.f90 (89%)
rename {FortranRuntime/include/flang/Common => flang/include/flang}/ISO_Fortran_binding.h (95%)
rename {FortranRuntime => flang}/module/.clang-format (100%)
rename {FortranRuntime => flang}/module/__cuda_builtins.f90 (100%)
rename {FortranRuntime => flang}/module/__fortran_builtins.f90 (99%)
rename {FortranRuntime => flang}/module/__fortran_ieee_exceptions.f90 (98%)
rename {FortranRuntime => flang}/module/__fortran_type_info.f90 (100%)
rename {FortranRuntime => flang}/module/__ppc_intrinsics.f90 (100%)
rename {FortranRuntime => flang}/module/__ppc_types.f90 (100%)
rename {FortranRuntime => flang}/module/cudadevice.f90 (96%)
rename {FortranRuntime => flang}/module/ieee_arithmetic.f90 (99%)
rename {FortranRuntime => flang}/module/ieee_exceptions.f90 (100%)
rename {FortranRuntime => flang}/module/ieee_features.f90 (100%)
rename {FortranRuntime => flang}/module/iso_c_binding.f90 (100%)
rename {FortranRuntime => flang}/module/iso_fortran_env.f90 (98%)
rename {FortranRuntime => flang}/module/mma.f90 (98%)
create mode 100644 flang/tools/f18/CMakeLists.txt
create mode 100644 flang/tools/f18/dump.cpp
diff --git a/FortranRuntime/CMakeLists.txt b/FortranRuntime/CMakeLists.txt
index 765e1445fc1a18..5c20b496dea821 100644
--- a/FortranRuntime/CMakeLists.txt
+++ b/FortranRuntime/CMakeLists.txt
@@ -15,6 +15,9 @@
set(LLVM_SUBPROJECT_TITLE "Fortran Runtime")
set(FORTRANRUNTIME_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(FORTRANRUNTIME_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang")
+
+enable_language(Fortran)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
@@ -22,7 +25,6 @@ list(APPEND CMAKE_MODULE_PATH
include(AddFortranRuntime)
-
############################
# Build Mode Introspection #
############################
@@ -38,28 +40,21 @@ endif()
if (LLVM_TREE_AVAILABLE)
# Despite Clang in the name, get_clang_resource_dir does not depend on Clang being added to the build
# flang-new uses the same resource dir as clang.
- include(GetClangResourceDir)
+ include(GetClangResourceDir)
get_clang_resource_dir(FORTRANRUNTIME_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
get_clang_resource_dir(FORTRANRUNTIME_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the install prefix itself
-
- # FIXME: If compiling multiple triples, include dirs overwrite each other
- get_clang_resource_dir(FORTRANRUNTIME_BUILD_INCLUDE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "include")
- get_clang_resource_dir(FORTRANRUNTIME_INSTALL_INCLUDE_DIR SUBDIR "include")
else ()
set(FORTRANRUNTIME_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
set(FORTRANRUNTIME_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
-
- set(FORTRANRUNTIME_BUILD_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
- set(FORTRANRUNTIME_INSTALL_INCLUDE_DIR "include")
endif ()
-
-if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+if (DEFINED WIN32)
+ set(FORTRANRUNTIME_BUILD_LIB_DIR "${FORTRANRUNTIME_BUILD_LIB_DIR}/windows")
+ set(FORTRANRUNTIME_INSTALL_LIB_DIR "${FORTRANRUNTIME_INSTALL_LIB_DIR}/windows")
+elseif (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
set(FORTRANRUNTIME_BUILD_LIB_DIR "${FORTRANRUNTIME_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
set(FORTRANRUNTIME_INSTALL_LIB_DIR "${FORTRANRUNTIME_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
-endif()
-
-
+endif ()
#################
@@ -139,16 +134,26 @@ check_cxx_source_compiles(
"
HAVE_LDBL_MANT_DIG_113)
+# Search for clang_rt.builtins
+execute_process(
+ COMMAND "${CMAKE_CXX_COMPILER}" "-print-libgcc-file-name" "-rtlib=compiler-rt"
+ RESULT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE
+ OUTPUT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT
+ )
+if (NOT CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE AND CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT)
+ string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FORTRANRUNTIME_LIBCALL)
+else ()
+ set(FORTRANRUNTIME_LIBCALL "")
+endif ()
+
#####################
# Build Preparation #
#####################
-enable_language(Fortran)
-
# C++17 required for FortranRuntime, 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 17 CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
@@ -156,29 +161,16 @@ set(CMAKE_CXX_STANDARD_REQUIRED YES)
add_definitions(-U_GLIBCXX_ASSERTIONS)
add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
-
configure_file(cmake/config.h.cmake.in config.h)
-configure_file(
- "${FORTRANRUNTIME_SOURCE_DIR}/include/flang/Common/ISO_Fortran_binding.h"
- "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/ISO_Fortran_binding.h"
-)
-install(
- FILES "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/ISO_Fortran_binding.h"
- DESTINATION "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}"
-)
-
-
###################
# Build Artifacts #
###################
add_subdirectory(lib)
-add_subdirectory(module)
if (FORTRANRUNTIME_INCLUDE_TESTS)
add_subdirectory(unittests)
add_subdirectory(test)
endif()
-
diff --git a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
index a4fc95495610cc..e4dff982e6deea 100644
--- a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
+++ b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
@@ -53,7 +53,8 @@ function (add_fortranruntime_library name)
list(APPEND extra_args EXCLUDE_FROM_ALL)
endif ()
- add_library(${name} ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS} )
+ add_library(${name} ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS})
+
if (ARG_INSTALL_WITH_TOOLCHAIN)
set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Toolchain Libraries")
elseif (ARG_OBJECT)
@@ -63,20 +64,28 @@ function (add_fortranruntime_library name)
endif ()
target_compile_features(${name} PRIVATE cxx_std_17)
- 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->)
- endif()
+ 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->)
+ endif ()
- target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_BINARY_DIR}") # For configured config.h for be found
+ # FortranRuntime's public headers
target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
-set_target_properties(${name}
- PROPERTIES
- Fortran_MODULE_DIRECTORY "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/flang"
-)
+ # For ISO_Fortran_binding.h to be found (Accessed as #include "flang/ISO_Fortran_binding.h")
+ target_include_directories(${name} PRIVATE "${FLANG_SOURCE_DIR}/include")
+
+ # For configured config.h for be found
+ target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_BINARY_DIR}")
+ # Clang/Flang, targeting the MSVC ABI, including clang-cl, should only depends on msv(u)crt. LLVM still emits libgcc/compiler-rt functions for 128-bit integer math (__udivti3, __modti3, __fixsfti, __floattidf, ...) that msvc does not support.
+ # We are injecting a dependency to Compiler-RT where these are implemented.
+ if (MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") AND FORTRANRUNTIME_LIBCALL)
+ target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "--dependent-lib=${FORTRANRUNTIME_LIBCALL}")
+ endif ()
+
+ # Non-GTest unittests depend on LLVMSupport
if (ARG_LINK_TO_LLVM)
if (LLVM_LINK_LLVM_DYLIB)
set(llvm_libs LLVM)
@@ -84,26 +93,24 @@ set_target_properties(${name}
llvm_map_components_to_libnames(llvm_libs Support)
endif()
target_link_libraries(${name} PUBLIC ${llvm_libs})
- target_include_directories(${name} PRIVATE ${LLVM_INCLUDE_DIRS})
+ target_include_directories(${name} PRIVATE ${LLVM_INCLUDE_DIRS})
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
- if (INSTALL_WITH_TOOLCHAIN)
+ if (ARG_INSTALL_WITH_TOOLCHAIN)
set_target_properties(${name}
- PROPERTIES
+ PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
- )
+ )
- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
- install(TARGETS ${name}
+ install(TARGETS ${name}
LIBRARY DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
ARCHIVE DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
RUNTIME DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
)
- endif ()
endif ()
endfunction (add_fortranruntime_library)
diff --git a/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
index d1bc9be34859a4..2c0fdc123c8759 100644
--- a/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
+++ b/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
@@ -28,7 +28,7 @@ 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
diff --git a/FortranRuntime/include/flang/Runtime/magic-numbers.h b/FortranRuntime/include/flang/Common/magic-numbers.h
similarity index 100%
rename from FortranRuntime/include/flang/Runtime/magic-numbers.h
rename to FortranRuntime/include/flang/Common/magic-numbers.h
diff --git a/FortranRuntime/include/flang/Runtime/io-api.h b/FortranRuntime/include/flang/Runtime/io-api.h
index 367146a4925c53..93971a2282cd00 100644
--- a/FortranRuntime/include/flang/Runtime/io-api.h
+++ b/FortranRuntime/include/flang/Runtime/io-api.h
@@ -14,7 +14,7 @@
#include "flang/Common/uint128.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/iostat.h"
-#include "flang/Runtime/magic-numbers.h"
+#include "flang/Common/magic-numbers.h"
#include <cinttypes>
#include <cstddef>
diff --git a/FortranRuntime/include/flang/Runtime/iostat.h b/FortranRuntime/include/flang/Runtime/iostat.h
index a5a2a560f05f8d..9a52990045ee13 100644
--- a/FortranRuntime/include/flang/Runtime/iostat.h
+++ b/FortranRuntime/include/flang/Runtime/iostat.h
@@ -12,7 +12,7 @@
#ifndef FORTRAN_RUNTIME_IOSTAT_H_
#define FORTRAN_RUNTIME_IOSTAT_H_
#include "flang/Common/api-attrs.h"
-#include "flang/Runtime/magic-numbers.h"
+#include "flang/Common/magic-numbers.h"
namespace Fortran::runtime::io {
// The value of IOSTAT= is zero when no error, end-of-record,
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index 9ccbc9ea78b0fc..5a0cc2ff14383a 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -9,6 +9,8 @@
add_subdirectory(Float128Math)
set(sources
+ ../Common/binary-to-decimal.cpp
+ ../Common/decimal-to-binary.cpp
ISO_Fortran_binding.cpp
allocator-registry.cpp
allocatable.cpp
@@ -74,76 +76,19 @@ set(sources
unit-map.cpp
unit.cpp
utf.cpp
- ../Common/binary-to-decimal.cpp
- ../Common/decimal-to-binary.cpp
)
-# List of files that are buildable for all devices.
-set(supported_files
- ISO_Fortran_binding.cpp
- allocatable.cpp
- allocator-registry.cpp
- array-constructor.cpp
- assign.cpp
- buffer.cpp
- character.cpp
- connection.cpp
- copy.cpp
- derived-api.cpp
- derived.cpp
- descriptor.cpp
- descriptor-io.cpp
- dot-product.cpp
- edit-input.cpp
- edit-output.cpp
- environment.cpp
- extrema.cpp
- external-unit.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
- utf.cpp
+set(public_headers "")
+file(GLOB_RECURSE public_headers
+ "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Runtime/*.h"
+ "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Common/*.h"
)
-
- set(public_headers "")
- file(GLOB_RECURSE public_headers
- "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Runtime/*.h"
- "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Common/*.h"
- )
-
- set(private_headers "")
- file(GLOB_RECURSE private_headers
- "${FLANGRUNTIME_SOURCE_DIR}/lib/Runtime/*.h"
- "${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
- )
+set(private_headers "")
+file(GLOB_RECURSE private_headers
+ "${FLANGRUNTIME_SOURCE_DIR}/lib/Runtime/*.h"
+ "${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
+ )
get_target_property(f128_sources
FortranFloat128MathILib INTERFACE_SOURCES
@@ -170,53 +115,59 @@ if (NOT DEFINED WIN32)
# For unittests that link to FortranRuntime. Should link to the static version of the library.
add_library(FortranRuntime.static ALIAS FortranRuntime)
+ add_library(FortranRuntime.unittest ALIAS FortranRuntime)
else()
- # ${sources} also contains Fortran files. CMake write the generated Fortran files into the same directory (lib/Runtime/iso_fortran_env_impl.mod), so we need to compile it only once and add the object files to different runtime version.
- add_fortranruntime_library(FortranRuntime.obj OBJECT
- ${sources}
-
- ADDITIONAL_HEADERS ${public_headers} ${private_headers}
- )
+ function (add_win_fortranruntime_library libtype suffix msvc_lib)
+ set(name "FortranRuntime.${suffix}")
+ add_fortranruntime_library(${name} ${libtype}
+ ${sources}
+ ${ARGN}
+ INSTALL_WITH_TOOLCHAIN
+ ADDITIONAL_HEADERS ${public_headers} ${private_headers}
+ )
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
- add_fortranruntime_library(FortranRuntime.static STATIC $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
- )
+ # Setting an unique Fortran_MODULE_DIRECTORY is required for each variant to write a different .mod file.
+ set_target_properties(${name}
+ PROPERTIES
+ MSVC_RUNTIME_LIBRARY ${msvc_lib}
+ Fortran_MODULE_DIRECTORY "module.${suffix}"
+ )
+ endfunction ()
-
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
- add_fortranruntime_library(FortranRuntime.dynamic SHARED $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
- )
+ add_win_fortranruntime_library(STATIC static MultiThreaded)
+ add_win_fortranruntime_library(STATIC static_dbg MultiThreadedDebug)
-
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
- add_fortranruntime_library(FortranRuntime.static_dbg STATIC $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
- )
+ # unittests link against LLVMSupport which is compiled with /MD
+ add_win_fortranruntime_library(STATIC unittest MultiThreadedDLL EXCLUDE_FROM_ALL)
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
- add_fortranruntime_library(FortranRuntime.dynamic_dbg SHARED $<TARGET_OBJECTS:FortranRuntime.obj> INSTALL_WITH_TOOLCHAIN #${sources}
- )
- target_link_libraries(FortranRuntime.dynamic_dbg PRIVATE FortranRuntime.obj)
+ # FIXME: Before DLL versions of the runtime can be used, exported definitions must be annotated with __declspec(dllexport).
+ add_win_fortranruntime_library(SHARED dynamic MultiThreadedDLL)
+ add_win_fortranruntime_library(SHARED dynamic_dbg MultiThreadedDebugDLL)
# Target for building all versions of the runtime
add_custom_target(FortranRuntime)
set_target_properties(FortranRuntime PROPERTIES FOLDER "Fortran Runtime/Meta")
- add_dependencies(FortranRuntime FortranRuntime.static FortranRuntime.dynamic
- FortranRuntime.static_dbg FortranRuntime.dynamic_dbg)
+ add_dependencies(FortranRuntime
+ FortranRuntime.static
+ FortranRuntime.static_dbg
+ FortranRuntime.dynamic
+ FortranRuntime.dynamic_dbg
+ )
if (MSVC)
- # The Fortran files compiled with flang-new assumes libcall functions such as `__udivti3`
+ # The Fortran files compiled with flang-new generate libcall functions such as `__udivti3`
# Add LLVM_ENABLE_RUNTIMES=compiler-rt for it to be available during the runtimes build
# FIXME: Can embed linker command --dependent-lib into object files as already done with FortranRuntime.<mode>.lib
- if (NOT TARGET clang_rt.builtins-x86_64)
- message(WARNING
- "compiler-rt needed when compiling with msvc\n"
- "Flang/LLVM will emit code that calls into libgcc/compiler-rt, but using the MSVC linker will only link Microsoft's CRT automatically\n"
- "Add compiler-rt to LLVM_ENABLE_RUNTIMES to fix"
- )
- endif ()
- target_link_libraries(FortranRuntime.static PUBLIC clang_rt.builtins-x86_64)
- target_link_libraries(FortranRuntime.dynamic PUBLIC clang_rt.builtins-x86_64)
- target_link_libraries(FortranRuntime.static_dbg PUBLIC clang_rt.builtins-x86_64)
- target_link_libraries(FortranRuntime.dynamic_dbg PUBLIC clang_rt.builtins-x86_64)
+ #if (NOT TARGET clang_rt.builtins-x86_64)
+ # message(WARNING
+ # "compiler-rt needed when compiling with msvc\n"
+ # "Flang/LLVM will emit code that calls into libgcc/compiler-rt, but using the MSVC linker will only link Microsoft's CRT automatically\n"
+ # "Add compiler-rt to LLVM_ENABLE_RUNTIMES to fix"
+ # )
+ #endif ()
+ #target_link_libraries(FortranRuntime.static PUBLIC clang_rt.builtins-x86_64)
+ #target_link_libraries(FortranRuntime.static_dbg PUBLIC clang_rt.builtins-x86_64)
+ #target_link_libraries(FortranRuntime.dynamic PUBLIC clang_rt.builtins-x86_64)
+ #target_link_libraries(FortranRuntime.dynamic_dbg PUBLIC clang_rt.builtins-x86_64)
endif ()
endif()
diff --git a/FortranRuntime/lib/Runtime/file.cpp b/FortranRuntime/lib/Runtime/file.cpp
index b82f1c63e397f9..9988ced2b5c18c 100644
--- a/FortranRuntime/lib/Runtime/file.cpp
+++ b/FortranRuntime/lib/Runtime/file.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "file.h"
-#include "flang/Runtime/magic-numbers.h"
+#include "flang/Common/magic-numbers.h"
#include "flang/Runtime/memory.h"
#include "tools.h"
#include <algorithm>
diff --git a/FortranRuntime/lib/Runtime/io-error.cpp b/FortranRuntime/lib/Runtime/io-error.cpp
index b14a30354d2347..30fabe5ba077fe 100644
--- a/FortranRuntime/lib/Runtime/io-error.cpp
+++ b/FortranRuntime/lib/Runtime/io-error.cpp
@@ -8,7 +8,7 @@
#include "io-error.h"
#include "config.h"
-#include "flang/Runtime/magic-numbers.h"
+#include "flang/Common/magic-numbers.h"
#include "tools.h"
#include <cerrno>
#include <cstdarg>
diff --git a/FortranRuntime/lib/Runtime/stat.h b/FortranRuntime/lib/Runtime/stat.h
index eccd69024d726b..a679f9da16dd46 100644
--- a/FortranRuntime/lib/Runtime/stat.h
+++ b/FortranRuntime/lib/Runtime/stat.h
@@ -13,7 +13,7 @@
#define FORTRAN_RUNTIME_STAT_H_
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/api-attrs.h"
-#include "flang/Runtime/magic-numbers.h"
+#include "flang/Common/magic-numbers.h"
namespace Fortran::runtime {
class Descriptor;
diff --git a/FortranRuntime/module/CMakeLists.txt b/FortranRuntime/module/CMakeLists.txt
deleted file mode 100644
index 9841cbd586b2df..00000000000000
--- a/FortranRuntime/module/CMakeLists.txt
+++ /dev/null
@@ -1,63 +0,0 @@
-#===-- module/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(module_sources
- "__cuda_builtins.f90"
- "__fortran_builtins.f90"
- "__fortran_ieee_exceptions.f90"
- "__fortran_type_info.f90"
- # "cudadevice.f90" # TODO: -fc1 -xcuda
- "ieee_arithmetic.f90"
- "ieee_exceptions.f90"
- "ieee_features.f90"
- "iso_c_binding.f90"
- "iso_fortran_env.f90"
-)
-
-set_source_files_properties(
- "iso_fortran_env.f90"
- PROPERTIES
- COMPILE_FLAGS "-mmlir -ignore-module-only-builtins"
-)
-
-set_source_files_properties(
- "__fortran_builtins.f90"
- PROPERTIES
- COMPILE_FLAGS "-mmlir -ignore-missing-type-desc"
-)
-
-# Requires PowerPC vector instructions
-if (LLVM_TARGET_TRIPLE MATCHES "(ppc|powerpc)(32|64)?(le|be)?\-.*")
- list(APPEND module_sources
- "__ppc_types.f90"
- "__ppc_intrinsics.f90"
- "mma.f90"
- )
-endif ()
-
-add_fortranruntime_library(module_files OBJECT
- ${module_sources}
-)
-
-# Usually, CMake will ignore dependencies from Fortran intrinsic modules. Since this is building those intrinsic modules themselves, tell CMake to not prune such dependencies.
-set_target_properties(module_files
- PROPERTIES
- Fortran_BUILDING_INSTRINSIC_MODULES ON
-)
-
-# The usual technique to install files in CMake is
-#
-# install(TARGET <targetname> <artifacttype> ...)
-#
-# However, there is no <artifacttype> for Fortran modules. We have to derive the module file path individually.
-set(module_files "")
-foreach (f90file IN LISTS module_sources)
- get_filename_component(base "${f90file}" NAME_WE )
- list(APPEND module_files "${FORTRANRUNTIME_BUILD_INCLUDE_DIR}/flang/${base}.mod")
-endforeach ()
-install(FILES ${module_files} DESTINATION "${FORTRANRUNTIME_INSTALL_INCLUDE_DIR}/flang")
diff --git a/FortranRuntime/test/CMakeLists.txt b/FortranRuntime/test/CMakeLists.txt
index 1f822859089f3d..c10c487d48c410 100644
--- a/FortranRuntime/test/CMakeLists.txt
+++ b/FortranRuntime/test/CMakeLists.txt
@@ -41,17 +41,16 @@ if (TARGET FortranRuntimeUnitTests)
)
endif ()
-set(FORTRANRUNTIME_TEST_DEPENDS "")
-if (FORTRANRUNTIME_INCLUDE_TESTS)
- if (TARGET FortranRuntimeUnitTests)
- list(APPEND FORTRANRUNTIME_TEST_DEPENDS FortranRuntimeUnitTests)
- endif()
-endif()
+set(FORTRANRUNTIME_TEST_DEPENDS
+ FortranRuntimeUnitTests
+ FortranRuntime.static
+ )
add_custom_target(FortranRuntime-test-depends)
set_target_properties(FortranRuntime-test-depends PROPERTIES FOLDER "Fortran Runtime/Meta")
+add_dependencies(FortranRuntime-test-depends ${FORTRANRUNTIME_TEST_DEPENDS})
-add_lit_testsuite(check-FortranRuntime "Running the Flang regression tests"
+add_lit_testsuite(check-FortranRuntime "Running the FortranRuntime regression tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${FORTRANRUNTIME_TEST_DEPENDS}
)
diff --git a/flang/test/Driver/ctofortran.f90 b/FortranRuntime/test/Driver/ctofortran.f90
similarity index 99%
rename from flang/test/Driver/ctofortran.f90
rename to FortranRuntime/test/Driver/ctofortran.f90
index 78eac32133b18e..a9cbf166bfe46c 100644
--- a/flang/test/Driver/ctofortran.f90
+++ b/FortranRuntime/test/Driver/ctofortran.f90
@@ -1,8 +1,9 @@
-! UNSUPPORTED: system-windows
! 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
+! UNSUPPORTED: system-windows
+
!--- ffile.f90
program fmain
interface
diff --git a/flang/test/Driver/exec.f90 b/FortranRuntime/test/Driver/exec.f90
similarity index 89%
rename from flang/test/Driver/exec.f90
rename to FortranRuntime/test/Driver/exec.f90
index fd174005ddf62a..07b42492b34d30 100644
--- a/flang/test/Driver/exec.f90
+++ b/FortranRuntime/test/Driver/exec.f90
@@ -1,4 +1,4 @@
-! UNSUPPORTED: system-windows
+! UNSUPPORTED? system-windows
! Verify that flang can correctly build executables.
! RUN: %flang %s -o %t
diff --git a/FortranRuntime/test/NonGtestUnit/lit.cfg.py b/FortranRuntime/test/NonGtestUnit/lit.cfg.py
index cd78ca76de503f..f807f2825a1bc7 100644
--- a/FortranRuntime/test/NonGtestUnit/lit.cfg.py
+++ b/FortranRuntime/test/NonGtestUnit/lit.cfg.py
@@ -8,7 +8,8 @@
config.name = "FortranRuntime-OldUnit"
# suffixes: A list of file extensions to treat as test files.
-config.suffixes = [".test"]
+# 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.fortranruntime_binary_dir, "unittests")
diff --git a/FortranRuntime/test/lit.cfg.py b/FortranRuntime/test/lit.cfg.py
index dd5124b8de4095..8aa1c6ab20e6ea 100644
--- a/FortranRuntime/test/lit.cfg.py
+++ b/FortranRuntime/test/lit.cfg.py
@@ -3,7 +3,7 @@
import lit.util
from lit.llvm import llvm_config
-from lit.llvm.subst import ToolSubst
+from lit.llvm.subst import ToolSubst, FindTool
# Configuration file for the 'lit' test runner.
@@ -61,11 +61,19 @@
if config.osx_sysroot:
isysroot_flag = ["-isysroot", config.osx_sysroot]
+tools = [
+ ToolSubst(
+ "%flang",
+ command=FindTool("flang-new"),
+ extra_args=isysroot_flag,
+ unresolved="fatal",
+ )
+ ]
+
# 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.
libruntime = os.path.join(config.fortranruntime_build_lib_dir, "libFortranRuntime.a")
include = os.path.join(config.fortranruntime_source_dir, "include")
-tools = []
tools.append(
ToolSubst(
"%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal"
@@ -74,5 +82,7 @@
tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
-llvm_config.add_tool_substitutions(tools)
+# Lwt tests find LLVM's standard tools (FileCheck, split-file, not, ...)
+llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
+llvm_config.add_tool_substitutions(tools)
diff --git a/FortranRuntime/unittests/CMakeLists.txt b/FortranRuntime/unittests/CMakeLists.txt
index d1aed058aad142..89e1c909d0f98e 100644
--- a/FortranRuntime/unittests/CMakeLists.txt
+++ b/FortranRuntime/unittests/CMakeLists.txt
@@ -21,6 +21,9 @@ endif ()
add_custom_target(FortranRuntimeUnitTests)
set_target_properties(FortranRuntimeUnitTests PROPERTIES FOLDER "Fortran Runtime/Tests")
+# Required because LLVMSupport is compiled with this option (by default).
+set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
+
function(add_fortranruntime_unittest test_dirname)
cmake_parse_arguments(ARG
""
@@ -29,7 +32,9 @@ function(add_fortranruntime_unittest test_dirname)
${ARGN})
add_unittest(FortranRuntimeUnitTests ${test_dirname} ${ARG_UNPARSED_ARGUMENTS})
+
target_include_directories(${test_dirname} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+ target_include_directories(${test_dirname} PRIVATE "${FLANG_SOURCE_DIR}/include")
target_link_libraries(${test_dirname} PRIVATE ${ARG_LINK_LIBS})
endfunction()
@@ -47,10 +52,12 @@ function(add_fortranruntime_nongtest_unittest test_name)
endif()
add_executable(${test_name}${suffix} ${ARG_UNPARSED_ARGUMENTS})
- target_link_libraries(${test_name}${suffix} PRIVATE NonGTestTesting ${ARG_LINK_LIBS})
- target_include_directories(${test_name}${suffix} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Fortran Runtime/Tests/Unit")
+ target_include_directories(${test_name}${suffix} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+ target_include_directories(${test_name}${suffix} PRIVATE "${FLANG_SOURCE_DIR}/include")
+ target_link_libraries(${test_name}${suffix} PRIVATE NonGTestTesting ${ARG_LINK_LIBS})
+
if(NOT ARG_SLOW_TEST)
add_dependencies(FortranRuntimeUnitTests ${test_name}${suffix})
endif()
diff --git a/FortranRuntime/unittests/Common/CMakeLists.txt b/FortranRuntime/unittests/Common/CMakeLists.txt
index f107036f19ed8d..5b3aebaf5f654a 100644
--- a/FortranRuntime/unittests/Common/CMakeLists.txt
+++ b/FortranRuntime/unittests/Common/CMakeLists.txt
@@ -9,5 +9,5 @@
add_fortranruntime_unittest(FlangCommonTests
FastIntSetTest.cpp
LINK_LIBS
- FortranRuntime.static
+ FortranRuntime.unittest
)
diff --git a/FortranRuntime/unittests/Decimal/CMakeLists.txt b/FortranRuntime/unittests/Decimal/CMakeLists.txt
index 3d96da45c94148..033773049680f6 100644
--- a/FortranRuntime/unittests/Decimal/CMakeLists.txt
+++ b/FortranRuntime/unittests/Decimal/CMakeLists.txt
@@ -9,12 +9,12 @@
add_fortranruntime_nongtest_unittest(quick-sanity-test
quick-sanity-test.cpp
LINK_LIBS
- FortranRuntime.static
+ FortranRuntime.unittest
)
# This test is not run by default as it takes a long time to execute.
add_fortranruntime_nongtest_unittest(thorough-test SLOW_TEST
thorough-test.cpp
LINK_LIBS
- FortranRuntime.static
+ FortranRuntime.unittest
)
diff --git a/FortranRuntime/unittests/Evaluate/CMakeLists.txt b/FortranRuntime/unittests/Evaluate/CMakeLists.txt
index e6501f13a74e6b..567832a2f15bcb 100644
--- a/FortranRuntime/unittests/Evaluate/CMakeLists.txt
+++ b/FortranRuntime/unittests/Evaluate/CMakeLists.txt
@@ -9,11 +9,11 @@
add_fortranruntime_nongtest_unittest(reshape
reshape.cpp
LINK_LIBS
- FortranRuntime.static
+ FortranRuntime.unittest
)
add_fortranruntime_nongtest_unittest(ISO-Fortran-binding
ISO-Fortran-binding.cpp
LINK_LIBS
- FortranRuntime.static
+ FortranRuntime.unittest
)
diff --git a/FortranRuntime/unittests/Runtime/CMakeLists.txt b/FortranRuntime/unittests/Runtime/CMakeLists.txt
index 1e966987c272a0..b4c0d7f86c1878 100644
--- a/FortranRuntime/unittests/Runtime/CMakeLists.txt
+++ b/FortranRuntime/unittests/Runtime/CMakeLists.txt
@@ -38,5 +38,5 @@ add_fortranruntime_unittest(FlangRuntimeTests
TemporaryStack.cpp
Transformational.cpp
LINK_LIBS
- FortranRuntime.static
+ FortranRuntime.unittest
)
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 3619a8f4b81f08..aff656d74daa2f 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -290,11 +290,7 @@ 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")));
- }
+
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/CMakeLists.txt b/flang/CMakeLists.txt
index 47517c5e7ab82f..827ed11e55001c 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -509,3 +509,17 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
)
endif()
+# Put ISO_Fortran_binding.h into the include files of the build area now
+# so that we can run tests before installing
+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)
+
+# And also install it into the install area
+get_clang_resource_dir(HEADER_INSTALL_DIR SUBDIR include)
+install(
+ FILES include/flang/ISO_Fortran_binding.h
+ DESTINATION ${HEADER_INSTALL_DIR} )
+
diff --git a/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h b/flang/include/flang/ISO_Fortran_binding.h
similarity index 95%
rename from FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
rename to flang/include/flang/ISO_Fortran_binding.h
index 516355c01ec7d0..3361db27aa4517 100644
--- a/FortranRuntime/include/flang/Common/ISO_Fortran_binding.h
+++ b/flang/include/flang/ISO_Fortran_binding.h
@@ -1,13 +1,14 @@
-/*===-- include/flang/Common/ISO_Fortran_binding.h ------------------*- C -*-===
+/*===-- include/flang/ISO_Fortran_binding.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_COMMON_ISO_FORTRAN_BINDING_H_
-#define FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_
+#ifndef CFI_ISO_FORTRAN_BINDING_H_
+#define CFI_ISO_FORTRAN_BINDING_H_
/* When this header is included into the compiler and runtime implementations,
* it does so by means of a wrapper header that establishes namespaces and
@@ -206,4 +207,4 @@ RT_API_ATTRS int CFI_setpointer(
} // extern "C"
#endif
-#endif /* FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_ */
+#endif /* CFI_ISO_FORTRAN_BINDING_H_ */
diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index d29da136ea3eda..0ab7d1c888df96 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -1,6 +1,3 @@
-
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../FortranRuntime/include")
-
add_subdirectory(Common)
add_subdirectory(Support)
add_subdirectory(Evaluate)
diff --git a/flang/lib/Evaluate/fold-logical.cpp b/flang/lib/Evaluate/fold-logical.cpp
index ee6655f8387177..3c0b85cc3480b2 100644
--- a/flang/lib/Evaluate/fold-logical.cpp
+++ b/flang/lib/Evaluate/fold-logical.cpp
@@ -10,7 +10,7 @@
#include "fold-matmul.h"
#include "fold-reduction.h"
#include "flang/Evaluate/check-expression.h"
-#include "flang/Runtime/magic-numbers.h"
+#include "flang/Common/magic-numbers.h"
namespace Fortran::evaluate {
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 460923bbccc27a..b98ab3e6999655 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -68,11 +68,6 @@
/// a call is generated for it. LLVM intrinsics are handled as a math
/// runtime library here.
-static llvm::cl::opt<bool> ignoreModuleOnlyBuiltins(
- "ignore-module-only-builtins",
- llvm::cl::desc("ignore failures from __builtin_numeric_storage_size when compiling FortranRuntime"),
- llvm::cl::init(false), llvm::cl::Hidden);
-
namespace fir {
fir::ExtendedValue getAbsentIntrinsicArgument() { return fir::UnboxedValue{}; }
@@ -507,7 +502,6 @@ static constexpr IntrinsicHandler handlers[]{
/*isElemental=*/false},
{"not", &I::genNot},
{"null", &I::genNull, {{{"mold", asInquired}}}, /*isElemental=*/false},
- {"numeric_storage_size", &I::genNumericStorageSize},
{"pack",
&I::genPack,
{{{"array", asBox},
@@ -7224,17 +7218,6 @@ IntrinsicLibrary::genVerify(mlir::Type resultType,
return readAndAddCleanUp(resultMutableBox, resultType, "VERIFY");
}
-fir::ExtendedValue IntrinsicLibrary:: genNumericStorageSize(mlir::Type resultType, llvm::ArrayRef<fir::ExtendedValue> args) {
- assert(args.empty() );
-
- if (!ignoreModuleOnlyBuiltins) {
- fir::emitFatalError(loc, "__builtin_numeric_storage_size is for internal use only. Use NUMERIC_STORAGE_SIZE from ISO_FORTRAN_ENV module instead.");
- return {};
- }
-
- return builder.createIntegerConstant(loc, resultType , 32 );
- }
-
/// Process calls to Minloc, Maxloc intrinsic functions
template <typename FN, typename FD>
fir::ExtendedValue
diff --git a/FortranRuntime/module/.clang-format b/flang/module/.clang-format
similarity index 100%
rename from FortranRuntime/module/.clang-format
rename to flang/module/.clang-format
diff --git a/FortranRuntime/module/__cuda_builtins.f90 b/flang/module/__cuda_builtins.f90
similarity index 100%
rename from FortranRuntime/module/__cuda_builtins.f90
rename to flang/module/__cuda_builtins.f90
diff --git a/FortranRuntime/module/__fortran_builtins.f90 b/flang/module/__fortran_builtins.f90
similarity index 99%
rename from FortranRuntime/module/__fortran_builtins.f90
rename to flang/module/__fortran_builtins.f90
index d1d4a639e70d72..fe91305c836ff4 100644
--- a/FortranRuntime/module/__fortran_builtins.f90
+++ b/flang/module/__fortran_builtins.f90
@@ -6,7 +6,7 @@
!
!===------------------------------------------------------------------------===!
-#include '../include/flang/Runtime/magic-numbers.h'
+#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'
! These naming shenanigans prevent names from Fortran intrinsic modules
! from being usable on INTRINSIC statements, and force the program
diff --git a/FortranRuntime/module/__fortran_ieee_exceptions.f90 b/flang/module/__fortran_ieee_exceptions.f90
similarity index 98%
rename from FortranRuntime/module/__fortran_ieee_exceptions.f90
rename to flang/module/__fortran_ieee_exceptions.f90
index 6691012eda238a..56f79a473b556a 100644
--- a/FortranRuntime/module/__fortran_ieee_exceptions.f90
+++ b/flang/module/__fortran_ieee_exceptions.f90
@@ -11,7 +11,7 @@
! here under another name so that IEEE_ARITHMETIC can USE it and export its
! declarations without clashing with a non-intrinsic module in a program.
-#include '../include/flang/Runtime/magic-numbers.h'
+#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'
module __fortran_ieee_exceptions
use __fortran_builtins, only: &
diff --git a/FortranRuntime/module/__fortran_type_info.f90 b/flang/module/__fortran_type_info.f90
similarity index 100%
rename from FortranRuntime/module/__fortran_type_info.f90
rename to flang/module/__fortran_type_info.f90
diff --git a/FortranRuntime/module/__ppc_intrinsics.f90 b/flang/module/__ppc_intrinsics.f90
similarity index 100%
rename from FortranRuntime/module/__ppc_intrinsics.f90
rename to flang/module/__ppc_intrinsics.f90
diff --git a/FortranRuntime/module/__ppc_types.f90 b/flang/module/__ppc_types.f90
similarity index 100%
rename from FortranRuntime/module/__ppc_types.f90
rename to flang/module/__ppc_types.f90
diff --git a/FortranRuntime/module/cudadevice.f90 b/flang/module/cudadevice.f90
similarity index 96%
rename from FortranRuntime/module/cudadevice.f90
rename to flang/module/cudadevice.f90
index dd487f6ed1ffee..0224ecfdde7c60 100644
--- a/FortranRuntime/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -1,4 +1,4 @@
-!===-- module/cudadevice.f90 -----------------------------------------------===!
+!===-- module/cudedevice.f90 -----------------------------------------------===!
!
! 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/FortranRuntime/module/ieee_arithmetic.f90 b/flang/module/ieee_arithmetic.f90
similarity index 99%
rename from FortranRuntime/module/ieee_arithmetic.f90
rename to flang/module/ieee_arithmetic.f90
index 7eaa7db55af9f8..667374d0660806 100644
--- a/FortranRuntime/module/ieee_arithmetic.f90
+++ b/flang/module/ieee_arithmetic.f90
@@ -8,7 +8,7 @@
! Fortran 2018 Clause 17
-#include '../include/flang/Runtime/magic-numbers.h'
+#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'
module ieee_arithmetic
! F18 Clause 17.1p1:
diff --git a/FortranRuntime/module/ieee_exceptions.f90 b/flang/module/ieee_exceptions.f90
similarity index 100%
rename from FortranRuntime/module/ieee_exceptions.f90
rename to flang/module/ieee_exceptions.f90
diff --git a/FortranRuntime/module/ieee_features.f90 b/flang/module/ieee_features.f90
similarity index 100%
rename from FortranRuntime/module/ieee_features.f90
rename to flang/module/ieee_features.f90
diff --git a/FortranRuntime/module/iso_c_binding.f90 b/flang/module/iso_c_binding.f90
similarity index 100%
rename from FortranRuntime/module/iso_c_binding.f90
rename to flang/module/iso_c_binding.f90
diff --git a/FortranRuntime/module/iso_fortran_env.f90 b/flang/module/iso_fortran_env.f90
similarity index 98%
rename from FortranRuntime/module/iso_fortran_env.f90
rename to flang/module/iso_fortran_env.f90
index 4e575b422c2a04..d1f956b6b86408 100644
--- a/FortranRuntime/module/iso_fortran_env.f90
+++ b/flang/module/iso_fortran_env.f90
@@ -8,7 +8,7 @@
! See Fortran 2023, subclause 16.10.2
-#include '../include/flang/Runtime/magic-numbers.h'
+#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'
module iso_fortran_env
diff --git a/FortranRuntime/module/mma.f90 b/flang/module/mma.f90
similarity index 98%
rename from FortranRuntime/module/mma.f90
rename to flang/module/mma.f90
index 14aab69035a334..4c41822e000a3d 100644
--- a/FortranRuntime/module/mma.f90
+++ b/flang/module/mma.f90
@@ -55,18 +55,9 @@ pure __vector_pair function func_vpi0vp(arg1, arg2); \
!dir$ ignore_tkr(r) arg2; \
end function;
-! FIXME: Potential Flang bug: combining multiple of those on a single line breaks after preprocessing as an explicit step as done by CMake
-! Line counting is also wrong
- FUNC_VPI0VI(1)
- FUNC_VPI0VI(2)
- FUNC_VPI0VI(4)
- FUNC_VPI0VI(8)
- FUNC_VPI0VU(1)
- FUNC_VPI0VU(2)
- FUNC_VPI0VU(4)
- FUNC_VPI0VU(8)
- FUNC_VPI0VR(4)
- FUNC_VPI0VR(8)
+ FUNC_VPI0VI(1) FUNC_VPI0VI(2) FUNC_VPI0VI(4) FUNC_VPI0VI(8)
+ FUNC_VPI0VU(1) FUNC_VPI0VU(2) FUNC_VPI0VU(4) FUNC_VPI0VU(8)
+ FUNC_VPI0VR(4) FUNC_VPI0VR(8)
FUNC_VPI0VP
#undef FUNC_VPI0VP
@@ -153,26 +144,14 @@ elemental subroutine sub_vpvr##VKIND##vr##VKIND(pair, arg1, arg2); \
vector(real(VKIND)), intent(in) :: arg1, arg2; \
end subroutine ;
- ELEM_SUB_VPVIVI(1)
- ELEM_SUB_VPVIVI(2)
- ELEM_SUB_VPVIVI(4)
- ELEM_SUB_VPVIVI(8)
- ELEM_SUB_VPVUVU(1)
- ELEM_SUB_VPVUVU(2)
- ELEM_SUB_VPVUVU(4)
- ELEM_SUB_VPVUVU(8)
- ELEM_SUB_VPVRVR(4)
- ELEM_SUB_VPVRVR(8)
- SUB_VPI0VI(1)
- SUB_VPI0VI(2)
- SUB_VPI0VI(4)
- SUB_VPI0VI(8)
- SUB_VPI0VU(1)
- SUB_VPI0VU(2)
- SUB_VPI0VU(4)
- SUB_VPI0VU(8)
- SUB_VPI0VR(4)
- SUB_VPI0VR(8)
+ ELEM_SUB_VPVIVI(1) ELEM_SUB_VPVIVI(2)
+ ELEM_SUB_VPVIVI(4) ELEM_SUB_VPVIVI(8)
+ ELEM_SUB_VPVUVU(1) ELEM_SUB_VPVUVU(2)
+ ELEM_SUB_VPVUVU(4) ELEM_SUB_VPVUVU(8)
+ ELEM_SUB_VPVRVR(4) ELEM_SUB_VPVRVR(8)
+ SUB_VPI0VI(1) SUB_VPI0VI(2) SUB_VPI0VI(4) SUB_VPI0VI(8)
+ SUB_VPI0VU(1) SUB_VPI0VU(2) SUB_VPI0VU(4) SUB_VPI0VU(8)
+ SUB_VPI0VR(4) SUB_VPI0VR(8)
#undef ELEM_SUB_VPVIVI
#undef ELEM_SUB_VPVUVU
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index 03fa79979470ee..c121fda70d16f0 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -63,6 +63,7 @@ set(FLANG_TEST_DEPENDS
FileCheck
count
not
+ module_files
fir-opt
tco
bbc
diff --git a/flang/test/Driver/msvc-dependent-lib-flags.f90 b/flang/test/Driver/msvc-dependent-lib-flags.f90
index befe61fdadcd14..e7fa63548fa840 100644
--- a/flang/test/Driver/msvc-dependent-lib-flags.f90
+++ b/flang/test/Driver/msvc-dependent-lib-flags.f90
@@ -4,27 +4,23 @@
! RUN: %flang -### --target=aarch64-windows-msvc -resource-dir=%S/Inputs/resource_dir -fms-runtime-lib=dll_dbg %S/Inputs/hello.f90 -v 2>&1 | FileCheck %s --check-prefixes=MSVC-DLL-DEBUG
! MSVC: -fc1
-! 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-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-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-DEBUG: -fc1
-! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
! MSVC-DLL-DEBUG-SAME: -D_MT
! MSVC-DLL-DEBUG-SAME: -D_DEBUG
! MSVC-DLL-DEBUG-SAME: -D_DLL
diff --git a/flang/tools/CMakeLists.txt b/flang/tools/CMakeLists.txt
index c9f00c8cc6dbd6..337545ae0d4d7a 100644
--- a/flang/tools/CMakeLists.txt
+++ b/flang/tools/CMakeLists.txt
@@ -7,6 +7,7 @@
#===------------------------------------------------------------------------===#
add_subdirectory(bbc)
+add_subdirectory(f18)
add_subdirectory(flang-driver)
add_subdirectory(tco)
add_subdirectory(f18-parse-demo)
diff --git a/flang/tools/bbc/CMakeLists.txt b/flang/tools/bbc/CMakeLists.txt
index 68e4b59fd6eec5..69316d4dc61de3 100644
--- a/flang/tools/bbc/CMakeLists.txt
+++ b/flang/tools/bbc/CMakeLists.txt
@@ -6,7 +6,6 @@ AllTargetsInfos
TargetParser
)
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
add_flang_tool(bbc bbc.cpp
DEPENDS
FIROptCodeGenPassIncGen
diff --git a/flang/tools/f18-parse-demo/CMakeLists.txt b/flang/tools/f18-parse-demo/CMakeLists.txt
index 34f1bf048ad849..df1f1d24a55e51 100644
--- a/flang/tools/f18-parse-demo/CMakeLists.txt
+++ b/flang/tools/f18-parse-demo/CMakeLists.txt
@@ -1,5 +1,3 @@
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
-
set(LLVM_LINK_COMPONENTS
FrontendOpenACC
FrontendOpenMP
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
new file mode 100644
index 00000000000000..5f749a433f05cd
--- /dev/null
+++ b/flang/tools/f18/CMakeLists.txt
@@ -0,0 +1,161 @@
+set(LLVM_LINK_COMPONENTS
+ FrontendOpenACC
+ FrontendOpenMP
+ Support
+ )
+
+# Define the list of Fortran module files for which it is
+# sufficient to generate the module file via -fsyntax-only.
+set(MODULES_WITHOUT_IMPLEMENTATION
+ "__fortran_builtins"
+ "__fortran_ieee_exceptions"
+ "__fortran_type_info"
+ "__ppc_types"
+ "__ppc_intrinsics"
+ "mma"
+ "__cuda_builtins"
+ "cudadevice"
+ "ieee_arithmetic"
+ "ieee_exceptions"
+ "ieee_features"
+ "iso_c_binding"
+ "iso_fortran_env"
+ "iso_fortran_env_impl"
+)
+
+set(MODULES ${MODULES_WITHOUT_IMPLEMENTATION})
+
+# 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)
+
+# Figure out whether we can support REAL(KIND=16)
+if (FLANG_RUNTIME_F128_MATH_LIB)
+ set(FLANG_SUPPORT_R16 "1")
+elseif (HAVE_LDBL_MANT_DIG_113)
+ set(FLANG_SUPPORT_R16 "1")
+else()
+ set(FLANG_SUPPORT_R16 "0")
+endif()
+
+# Init variable to hold extra object files coming from the Fortran modules;
+# these module files will be contributed from the CMakeLists in flang/tools/f18.
+set(module_objects "")
+
+# Create module files directly from the top-level module source directory.
+# If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
+# cross compiled, and thus can't be executed on the build system and thus
+# can't be used for generating module files.
+if (NOT CMAKE_CROSSCOMPILING)
+ foreach(filename ${MODULES})
+ set(depends "")
+ set(opts "")
+ set(sourcepath "${FLANG_SOURCE_DIR}/module/${filename}.f90")
+ set(modpath "${FLANG_INTRINSIC_MODULES_DIR}/${filename}.mod")
+ if(${filename} STREQUAL "__fortran_builtins" OR
+ ${filename} STREQUAL "__ppc_types")
+ elseif(${filename} STREQUAL "__ppc_intrinsics" OR
+ ${filename} STREQUAL "mma")
+ set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__ppc_types.mod)
+ elseif(${filename} STREQUAL "cudadevice")
+ set(opts -fc1 -xcuda)
+ set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__cuda_builtins.mod)
+ else()
+ set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
+ if(${filename} STREQUAL "iso_fortran_env_impl")
+ set(sourcepath "${FLANG_SOURCE_DIR}/../FortranRuntime/lib/Runtime/${filename}.f90")
+ endif()
+ if(${filename} STREQUAL "iso_fortran_env")
+ set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/iso_fortran_env_impl.mod)
+ endif()
+ if(${filename} STREQUAL "ieee_arithmetic" OR
+ ${filename} STREQUAL "ieee_exceptions")
+ set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_ieee_exceptions.mod)
+ endif()
+ endif()
+ if(NOT ${filename} STREQUAL "__fortran_type_info" AND NOT ${filename} STREQUAL "__fortran_builtins")
+ set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_type_info.mod)
+ endif()
+
+ # The module contains PPC vector types that needs the PPC target.
+ if(${filename} STREQUAL "__ppc_intrinsics" OR
+ ${filename} STREQUAL "mma")
+ if (PowerPC IN_LIST LLVM_TARGETS_TO_BUILD)
+ set(opts "--target=ppc64le")
+ else()
+ # Do not compile PPC module if the target is not available.
+ continue()
+ endif()
+ endif()
+
+ set(decls "")
+ if (FLANG_SUPPORT_R16)
+ set(decls "-DFLANG_SUPPORT_R16")
+ endif()
+
+ # Some modules have an implementation part that needs to be added to the
+ # FortranRuntime library.
+ set(compile_with "-fsyntax-only")
+ set(object_output "")
+ set(include_in_link FALSE)
+
+ # TODO: We may need to flag this with conditional, in case Flang is built w/o OpenMP support
+ add_custom_command(OUTPUT ${modpath} ${object_output}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
+ COMMAND flang-new ${opts} ${decls} -cpp ${compile_with} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
+ ${sourcepath}
+ DEPENDS flang-new ${sourcepath} ${FLANG_SOURCE_DIR}/module/__fortran_builtins.f90 ${depends}
+ )
+ list(APPEND MODULE_FILES "${modpath}")
+ install(FILES "${modpath}" 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.
+ if(include_in_link)
+ list(APPEND module_objects ${object_output})
+ endif()
+ endforeach()
+
+ # Special case for omp_lib.mod, because its source comes from openmp/runtime/src/include.
+ # It also produces two module files: omp_lib.mod and omp_lib_kinds.mod. Compile these
+ # files only if OpenMP support has been configured.
+ if (LLVM_TOOL_OPENMP_BUILD)
+ message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.mod")
+ set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
+ add_custom_command(OUTPUT ${base}.mod ${base}_kinds.mod
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
+ COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
+ ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90
+ DEPENDS flang-new ${FLANG_INTRINSIC_MODULES_DIR}/iso_c_binding.mod ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90 ${depends}
+ )
+ add_custom_command(OUTPUT ${base}.f18.mod
+ DEPENDS ${base}.mod
+ COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
+ add_custom_command(OUTPUT ${base}_kinds.f18.mod
+ DEPENDS ${base}.mod
+ COMMAND ${CMAKE_COMMAND} -E copy ${base}_kinds.mod ${base}_kinds.f18.mod)
+ list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod)
+ install(FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
+ else()
+ message(STATUS "Not building omp_lib.mod, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
+ endif()
+endif()
+
+add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
+set_target_properties(module_files PROPERTIES FOLDER "Flang/Resources")
+
+# TODO Move this to a more suitable location
+# Copy the generated omp_lib.h header file, if OpenMP support has been configured.
+if (LLVM_TOOL_OPENMP_BUILD)
+ message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.h")
+ file(COPY ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
+ install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
+else()
+ message(STATUS "Not copying omp_lib.h, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
+endif()
diff --git a/flang/tools/f18/dump.cpp b/flang/tools/f18/dump.cpp
new file mode 100644
index 00000000000000..f11b5aedf4c6af
--- /dev/null
+++ b/flang/tools/f18/dump.cpp
@@ -0,0 +1,42 @@
+//===-- tools/f18/dump.cpp ------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// This file defines Dump routines available for calling from the debugger.
+// Each is based on operator<< for that type. There are overloadings for
+// reference and pointer, and for dumping to a provided raw_ostream or errs().
+
+#ifdef DEBUGF18
+
+#include "llvm/Support/raw_ostream.h"
+
+#define DEFINE_DUMP(ns, name) \
+ namespace ns { \
+ class name; \
+ llvm::raw_ostream &operator<<(llvm::raw_ostream &, const name &); \
+ } \
+ void Dump(llvm::raw_ostream &os, const ns::name &x) { os << x << '\n'; } \
+ void Dump(llvm::raw_ostream &os, const ns::name *x) { \
+ if (x == nullptr) \
+ os << "null\n"; \
+ else \
+ Dump(os, *x); \
+ } \
+ void Dump(const ns::name &x) { Dump(llvm::errs(), x); } \
+ void Dump(const ns::name *x) { Dump(llvm::errs(), *x); }
+
+namespace Fortran {
+DEFINE_DUMP(parser, Name)
+DEFINE_DUMP(parser, CharBlock)
+DEFINE_DUMP(semantics, Symbol)
+DEFINE_DUMP(semantics, Scope)
+DEFINE_DUMP(semantics, IntrinsicTypeSpec)
+DEFINE_DUMP(semantics, DerivedTypeSpec)
+DEFINE_DUMP(semantics, DeclTypeSpec)
+} // namespace Fortran
+
+#endif
diff --git a/flang/tools/fir-opt/CMakeLists.txt b/flang/tools/fir-opt/CMakeLists.txt
index 3723ac5d7b37d2..4c6dbf7d9c8c37 100644
--- a/flang/tools/fir-opt/CMakeLists.txt
+++ b/flang/tools/fir-opt/CMakeLists.txt
@@ -1,4 +1,3 @@
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
add_flang_tool(fir-opt fir-opt.cpp)
llvm_update_compile_flags(fir-opt)
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
@@ -20,7 +19,6 @@ target_link_libraries(fir-opt PRIVATE
FIRCodeGen
HLFIRDialect
HLFIRTransforms
- FortranCommon # FIXME: Dependency of something else
FlangOpenMPTransforms
FIRAnalysis
${test_libs}
diff --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt
index a2ad672b9d48c9..9f33cdfe3fa90f 100644
--- a/flang/tools/flang-driver/CMakeLists.txt
+++ b/flang/tools/flang-driver/CMakeLists.txt
@@ -1,9 +1,6 @@
# Infrastructure to build flang driver entry point. Flang driver depends on
# LLVM libraries.
-message("include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include)")
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
-
# Set your project compile flags.
link_directories(${LLVM_LIBRARY_DIR})
diff --git a/flang/tools/tco/CMakeLists.txt b/flang/tools/tco/CMakeLists.txt
index f308fb6acbe98b..698a398547c773 100644
--- a/flang/tools/tco/CMakeLists.txt
+++ b/flang/tools/tco/CMakeLists.txt
@@ -2,7 +2,6 @@ set(LLVM_LINK_COMPONENTS
Passes
)
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
add_flang_tool(tco tco.cpp)
llvm_update_compile_flags(tco)
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
@@ -18,7 +17,6 @@ target_link_libraries(tco PRIVATE
FIRBuilder
HLFIRDialect
HLFIRTransforms
- FortranCommon
FlangOpenMPTransforms
${dialect_libs}
${extension_libs}
>From 6307e77e75a4081fee75ff295d0fae70a255df6e Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 1 Oct 2024 17:26:34 +0200
Subject: [PATCH 04/58] python-format
---
FortranRuntime/test/lit.cfg.py | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/FortranRuntime/test/lit.cfg.py b/FortranRuntime/test/lit.cfg.py
index 8aa1c6ab20e6ea..a9f47f142bb884 100644
--- a/FortranRuntime/test/lit.cfg.py
+++ b/FortranRuntime/test/lit.cfg.py
@@ -52,7 +52,7 @@
# 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.
+# 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.fortranruntime_binary_test_dir
@@ -62,23 +62,21 @@
isysroot_flag = ["-isysroot", config.osx_sysroot]
tools = [
- ToolSubst(
+ ToolSubst(
"%flang",
command=FindTool("flang-new"),
extra_args=isysroot_flag,
unresolved="fatal",
- )
- ]
+ )
+]
# 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.
libruntime = os.path.join(config.fortranruntime_build_lib_dir, "libFortranRuntime.a")
include = os.path.join(config.fortranruntime_source_dir, "include")
tools.append(
- ToolSubst(
- "%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal"
- )
- )
+ 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"))
>From 20fc7c5798c825580c485921dc037b75d22a9270 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 1 Oct 2024 23:00:29 +0200
Subject: [PATCH 05/58] Add .clang-tidy
---
FortranRuntime/.clang-tidy | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 FortranRuntime/.clang-tidy
diff --git a/FortranRuntime/.clang-tidy b/FortranRuntime/.clang-tidy
new file mode 100644
index 00000000000000..ee3a0ab2201bf3
--- /dev/null
+++ b/FortranRuntime/.clang-tidy
@@ -0,0 +1,2 @@
+Checks: '-llvm-include-order,readability-braces-around-statements,-readability-identifier-naming,-clang-diagnostic-*'
+InheritParentConfig: true
>From 871c6900569bb92a652a447b1b481b7627cc50d4 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 2 Oct 2024 12:24:01 +0200
Subject: [PATCH 06/58] Common CMake code
---
FortranRuntime/CMakeLists.txt | 52 +------------------
.../cmake/modules/AddFortranRuntime.cmake | 9 +++-
.../cmake/modules/FlangCommon.cmake | 31 +++++++++++
FortranRuntime/lib/Runtime/CMakeLists.txt | 17 ------
flang/CMakeLists.txt | 10 +---
5 files changed, 41 insertions(+), 78 deletions(-)
create mode 100644 FortranRuntime/cmake/modules/FlangCommon.cmake
diff --git a/FortranRuntime/CMakeLists.txt b/FortranRuntime/CMakeLists.txt
index 5c20b496dea821..bda76dd87c0d7a 100644
--- a/FortranRuntime/CMakeLists.txt
+++ b/FortranRuntime/CMakeLists.txt
@@ -23,6 +23,7 @@ list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
)
include(AddFortranRuntime)
+include(FlangCommon)
############################
@@ -65,42 +66,16 @@ option(FORTRANRUNTIME_INCLUDE_TESTS
"Generate build targets for the FortranRuntime unit tests."
${LLVM_INCLUDE_TESTS})
-# 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(FORTRARUNTIME_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()
-
option(FLANG_EXPERIMENTAL_CUDA_RUNTIME "Compile Fortran runtime as CUDA sources (experimental)" OFF)
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
message(FATAL_ERROOR "FLANG_EXPERIMENTAL_CUDA_RUNTIME currently not supported")
endif()
-
-
########################
# System Introspection #
########################
-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(CheckCXXSymbolExists)
include(CheckCXXSourceCompiles)
check_cxx_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
@@ -114,26 +89,6 @@ check_cxx_source_compiles(
"
HAVE_DECL_STRERROR_S)
-# 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)
-
-# 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)
-
# Search for clang_rt.builtins
execute_process(
COMMAND "${CMAKE_CXX_COMPILER}" "-print-libgcc-file-name" "-rtlib=compiler-rt"
@@ -156,11 +111,6 @@ endif ()
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
-# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
-# to avoid an unwanted dependency on libstdc++/libc++.so.
-add_definitions(-U_GLIBCXX_ASSERTIONS)
-add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
-
configure_file(cmake/config.h.cmake.in config.h)
diff --git a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
index e4dff982e6deea..5410cb769754b5 100644
--- a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
+++ b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
@@ -65,9 +65,9 @@ function (add_fortranruntime_library name)
target_compile_features(${name} PRIVATE cxx_std_17)
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>)
+ 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->)
+ target_compile_options(${name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/EHs-c- /GR->)
endif ()
# FortranRuntime's public headers
@@ -79,6 +79,11 @@ function (add_fortranruntime_library name)
# For configured config.h for be found
target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_BINARY_DIR}")
+ # Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
+ # to avoid an unwanted dependency on libstdc++/libc++.so.
+ target_compile_definitions(${name} PRIVATE -U_GLIBCXX_ASSERTIONS)
+ target_compile_definitions(${name} PRIVATE -U_LIBCPP_ENABLE_ASSERTIONS)
+
# Clang/Flang, targeting the MSVC ABI, including clang-cl, should only depends on msv(u)crt. LLVM still emits libgcc/compiler-rt functions for 128-bit integer math (__udivti3, __modti3, __fixsfti, __floattidf, ...) that msvc does not support.
# We are injecting a dependency to Compiler-RT where these are implemented.
if (MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") AND FORTRANRUNTIME_LIBCALL)
diff --git a/FortranRuntime/cmake/modules/FlangCommon.cmake b/FortranRuntime/cmake/modules/FlangCommon.cmake
new file mode 100644
index 00000000000000..34c91048f47887
--- /dev/null
+++ b/FortranRuntime/cmake/modules/FlangCommon.cmake
@@ -0,0 +1,31 @@
+# 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/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index 5a0cc2ff14383a..1938ed6e21f54a 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -153,21 +153,4 @@ else()
FortranRuntime.dynamic
FortranRuntime.dynamic_dbg
)
-
- if (MSVC)
- # The Fortran files compiled with flang-new generate libcall functions such as `__udivti3`
- # Add LLVM_ENABLE_RUNTIMES=compiler-rt for it to be available during the runtimes build
- # FIXME: Can embed linker command --dependent-lib into object files as already done with FortranRuntime.<mode>.lib
- #if (NOT TARGET clang_rt.builtins-x86_64)
- # message(WARNING
- # "compiler-rt needed when compiling with msvc\n"
- # "Flang/LLVM will emit code that calls into libgcc/compiler-rt, but using the MSVC linker will only link Microsoft's CRT automatically\n"
- # "Add compiler-rt to LLVM_ENABLE_RUNTIMES to fix"
- # )
- #endif ()
- #target_link_libraries(FortranRuntime.static PUBLIC clang_rt.builtins-x86_64)
- #target_link_libraries(FortranRuntime.static_dbg PUBLIC clang_rt.builtins-x86_64)
- #target_link_libraries(FortranRuntime.dynamic PUBLIC clang_rt.builtins-x86_64)
- #target_link_libraries(FortranRuntime.dynamic_dbg PUBLIC clang_rt.builtins-x86_64)
- endif ()
endif()
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 827ed11e55001c..ac189de2386b16 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -253,6 +253,7 @@ include_directories(BEFORE
# Add Flang-centric modules to cmake path.
list(INSERT CMAKE_MODULE_PATH 0
"${FLANG_SOURCE_DIR}/cmake/modules"
+ "${FORTRANRUNTIME_SOURCE_DIR}/cmake/modules"
"${LLVM_COMMON_CMAKE_UTILS}/Modules"
)
include(AddFlang)
@@ -326,14 +327,6 @@ if (FLANG_REPOSITORY_STRING)
add_definitions(-DFLANG_REPOSITORY_STRING="${FLANG_REPOSITORY_STRING}")
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
@@ -432,6 +425,7 @@ endif()
include(CMakeParseArguments)
include(AddFlang)
+include(FlangCommon)
if (FLANG_INCLUDE_TESTS)
add_compile_definitions(FLANG_INCLUDE_TESTS=1)
>From c42127f2eb26ee4a7cff9cf02628834b3cb2ebae Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 3 Oct 2024 20:11:32 +0200
Subject: [PATCH 07/58] Float128Math support
---
FortranRuntime/CMakeLists.txt | 7 +++++
.../cmake/modules/AddFortranRuntime.cmake | 5 ----
FortranRuntime/lib/Runtime/CMakeLists.txt | 5 ++++
.../lib/Runtime/Float128Math/CMakeLists.txt | 29 +++++++------------
4 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/FortranRuntime/CMakeLists.txt b/FortranRuntime/CMakeLists.txt
index bda76dd87c0d7a..a68bd5bd00b758 100644
--- a/FortranRuntime/CMakeLists.txt
+++ b/FortranRuntime/CMakeLists.txt
@@ -89,11 +89,13 @@ check_cxx_source_compiles(
"
HAVE_DECL_STRERROR_S)
+
# Search for clang_rt.builtins
execute_process(
COMMAND "${CMAKE_CXX_COMPILER}" "-print-libgcc-file-name" "-rtlib=compiler-rt"
RESULT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE
OUTPUT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT
+ ERROR_QUIET
)
if (NOT CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE AND CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT)
string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FORTRANRUNTIME_LIBCALL)
@@ -111,6 +113,11 @@ endif ()
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
+# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
+# to avoid an unwanted dependency on libstdc++/libc++.so.
+add_definitions(-U_GLIBCXX_ASSERTIONS)
+add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
+
configure_file(cmake/config.h.cmake.in config.h)
diff --git a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
index 5410cb769754b5..316923ca632c20 100644
--- a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
+++ b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
@@ -79,11 +79,6 @@ function (add_fortranruntime_library name)
# For configured config.h for be found
target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_BINARY_DIR}")
- # Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
- # to avoid an unwanted dependency on libstdc++/libc++.so.
- target_compile_definitions(${name} PRIVATE -U_GLIBCXX_ASSERTIONS)
- target_compile_definitions(${name} PRIVATE -U_LIBCPP_ENABLE_ASSERTIONS)
-
# Clang/Flang, targeting the MSVC ABI, including clang-cl, should only depends on msv(u)crt. LLVM still emits libgcc/compiler-rt functions for 128-bit integer math (__udivti3, __modti3, __fixsfti, __floattidf, ...) that msvc does not support.
# We are injecting a dependency to Compiler-RT where these are implemented.
if (MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") AND FORTRANRUNTIME_LIBCALL)
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index 1938ed6e21f54a..87d34054172201 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -90,6 +90,9 @@ file(GLOB_RECURSE private_headers
"${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
)
+
+
+
get_target_property(f128_sources
FortranFloat128MathILib INTERFACE_SOURCES
)
@@ -106,6 +109,8 @@ if (f128_sources)
list(APPEND sources ${f128_sources})
endif()
+
+
if (NOT DEFINED WIN32)
add_fortranruntime_library(FortranRuntime STATIC
${sources}
diff --git a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
index 1ff158c401855f..a55d39e88cd404 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/Runtime/Float128Math/CMakeLists.txt -----------------------------===#
+#===-- runtime/Float128Math/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.
@@ -15,6 +15,7 @@
# used for building this FortranFloat128Math library.
include(CheckLibraryExists)
+include(CheckIncludeFile)
set(sources
acos.cpp
@@ -87,23 +88,15 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
"${FLANG_RUNTIME_F128_MATH_LIB}"
)
endif()
-
- add_flang_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
- ${sources})
-
- if (DEFINED MSVC)
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
- add_flang_library(FortranFloat128Math.static STATIC INSTALL_WITH_TOOLCHAIN
- ${sources}
- )
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
- add_flang_library(FortranFloat128Math.static_dbg STATIC INSTALL_WITH_TOOLCHAIN
- ${sources}
- )
- add_dependencies(FortranFloat128Math FortranFloat128Math.static
- FortranFloat128Math.static_dbg
- )
- endif()
+
+ if (WIN32)
+ # Do not create a FortranFloat128Math library under Windows, the Flang driver never links it. Instead, add the sources to the main FortranRuntime.lib.
+ target_sources(FortranFloat128MathILib INTERFACE ${sources})
+ target_compile_definitions(FortranFloat128MathILib INTERFACE HAS_QUADMATHLIB)
+ else ()
+ add_fortranruntime_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
+ ${sources})
+ endif ()
elseif (HAVE_LDBL_MANT_DIG_113)
# We can use 'long double' versions from libc.
check_library_exists(m sinl "" FOUND_LIBM)
>From 0867eb3b9447b9b8139be293eb15436a4b60c064 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 4 Oct 2024 13:52:28 +0200
Subject: [PATCH 08/58] Update test for windows
---
FortranRuntime/test/Driver/exec.f90 | 1 -
1 file changed, 1 deletion(-)
diff --git a/FortranRuntime/test/Driver/exec.f90 b/FortranRuntime/test/Driver/exec.f90
index 07b42492b34d30..372f6d8a8d7bfd 100644
--- a/FortranRuntime/test/Driver/exec.f90
+++ b/FortranRuntime/test/Driver/exec.f90
@@ -1,4 +1,3 @@
-! UNSUPPORTED? system-windows
! Verify that flang can correctly build executables.
! RUN: %flang %s -o %t
>From 5c2ae6b26b6f4751c9532f68ea64cff4b60b5228 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 7 Oct 2024 12:57:03 +0200
Subject: [PATCH 09/58] Re-add offloading support
---
FortranRuntime/CMakeLists.txt | 60 +++++++++++++------
.../modules/AddFlangOffloadRuntime.cmake | 55 ++++++-----------
FortranRuntime/lib/Runtime/CMakeLists.txt | 6 +-
.../lib/Runtime/CUDA/CMakeLists.txt | 5 +-
FortranRuntime/lib/Runtime/CUDA/allocator.cpp | 2 +-
FortranRuntime/unittests/CMakeLists.txt | 45 ++++++++++++--
flang/docs/GettingStarted.md | 12 ++--
7 files changed, 113 insertions(+), 72 deletions(-)
rename {flang => FortranRuntime}/cmake/modules/AddFlangOffloadRuntime.cmake (61%)
diff --git a/FortranRuntime/CMakeLists.txt b/FortranRuntime/CMakeLists.txt
index a68bd5bd00b758..fe5610f0c20816 100644
--- a/FortranRuntime/CMakeLists.txt
+++ b/FortranRuntime/CMakeLists.txt
@@ -62,13 +62,27 @@ endif ()
# Build Options #
#################
-option(FORTRANRUNTIME_INCLUDE_TESTS
- "Generate build targets for the FortranRuntime unit tests."
- ${LLVM_INCLUDE_TESTS})
+option(FORTRANRUNTIME_INCLUDE_TESTS "Generate build targets for the FortranRuntime unit and regression-tests." "${LLVM_INCLUDE_TESTS}")
+
+set(FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT "" CACHE STRING "Compile FortranRuntime with GPU support (CUDA or OpenMP)")
+set_property(CACHE FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT PROPERTY STRINGS
+ ""
+ CUDA
+ OpenMP)
+if (NOT FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT)
+elseif (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
+ set(FORTRANRUNTIME_LIBCUDACXX_PATH "" CACHE PATH "Path to libcu++ package installation")
+ option(FORTRANRUNTIME_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS "Do not compile global variables' definitions when producing PTX library" OFF)
+elseif (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
+set(FORTRANRUNTIME_DEVICE_ARCHITECTURES "all" CACHE STRING
+ "List of OpenMP device architectures to be used to compile the Fortran runtime (e.g. 'gfx1103;sm_90')")
+else ()
+ message(FATAL_ERROR "Invalid value '${FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT}' for FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT; must be empty, 'CUDA', or 'OpenMP'")
+endif ()
-option(FLANG_EXPERIMENTAL_CUDA_RUNTIME "Compile Fortran runtime as CUDA sources (experimental)" OFF)
-if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
- message(FATAL_ERROOR "FLANG_EXPERIMENTAL_CUDA_RUNTIME currently not supported")
+option(FORTRANRUNTIME_ENABLE_CUF "Compile CUDA Fortran runtime sources" OFF)
+if (FORTRANRUNTIME_ENABLE_CUF)
+ find_package(CUDAToolkit REQUIRED)
endif()
@@ -90,17 +104,19 @@ check_cxx_source_compiles(
HAVE_DECL_STRERROR_S)
-# Search for clang_rt.builtins
-execute_process(
- COMMAND "${CMAKE_CXX_COMPILER}" "-print-libgcc-file-name" "-rtlib=compiler-rt"
- RESULT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE
- OUTPUT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT
- ERROR_QUIET
- )
-if (NOT CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE AND CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT)
- string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FORTRANRUNTIME_LIBCALL)
-else ()
- set(FORTRANRUNTIME_LIBCALL "")
+# Search for clang_rt.builtins library.
+if (WIN32)
+ execute_process(
+ COMMAND "${CMAKE_CXX_COMPILER}" "-print-libgcc-file-name" "-rtlib=compiler-rt"
+ RESULT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE
+ OUTPUT_VARIABLE CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT
+ ERROR_QUIET
+ )
+ if (NOT CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE AND CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT)
+ string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FORTRANRUNTIME_LIBCALL)
+ else ()
+ set(FORTRANRUNTIME_LIBCALL "")
+ endif ()
endif ()
@@ -108,6 +124,16 @@ endif ()
# Build Preparation #
#####################
+if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT AND FORTRANRUNTIME_INCLUDE_TESTS)
+ # If Fortran runtime is built as CUDA library, the linking
+ # of targets that link FortranRuntime 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 required for FortranRuntime, 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")
diff --git a/flang/cmake/modules/AddFlangOffloadRuntime.cmake b/FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake
similarity index 61%
rename from flang/cmake/modules/AddFlangOffloadRuntime.cmake
rename to FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake
index 6407be5d038b81..ae6fcabbed9b92 100644
--- a/flang/cmake/modules/AddFlangOffloadRuntime.cmake
+++ b/FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake
@@ -1,21 +1,15 @@
-option(FLANG_EXPERIMENTAL_CUDA_RUNTIME
- "Compile Fortran runtime as CUDA sources (experimental)" OFF
- )
-option(FLANG_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS
- "Do not compile global variables' definitions when producing PTX library" OFF
- )
-set(FLANG_LIBCUDACXX_PATH "" CACHE PATH "Path to libcu++ package installation")
-set(FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD "off" CACHE STRING
- "Compile Fortran runtime as OpenMP target offload sources (experimental). Valid options are 'off', 'host_device', 'nohost'")
-set(FLANG_OMP_DEVICE_ARCHITECTURES "all" CACHE STRING
- "List of OpenMP device architectures to be used to compile the Fortran runtime (e.g. 'gfx1103;sm_90')")
+
+
+
+
+
macro(enable_cuda_compilation name files)
- if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
+ if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
if (BUILD_SHARED_LIBS)
message(FATAL_ERROR
"BUILD_SHARED_LIBS is not supported for CUDA build of Fortran runtime"
@@ -50,17 +44,17 @@ macro(enable_cuda_compilation name files)
"${CUDA_COMPILE_OPTIONS}"
)
- if (EXISTS "${FLANG_LIBCUDACXX_PATH}/include")
+ if (EXISTS "${FORTRANRUNTIME_LIBCUDACXX_PATH}/include")
# When using libcudacxx headers files, we have to use them
# for all files of F18 runtime.
- include_directories(AFTER ${FLANG_LIBCUDACXX_PATH}/include)
+ include_directories(AFTER ${FORTRANRUNTIME_LIBCUDACXX_PATH}/include)
add_compile_definitions(RT_USE_LIBCUDACXX=1)
endif()
# Add an OBJECT library consisting of CUDA PTX.
llvm_add_library(${name}PTX OBJECT PARTIAL_SOURCES_INTENDED ${files})
set_property(TARGET obj.${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
- if (FLANG_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
+ if (FORTRANRUNTIME_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
target_compile_definitions(obj.${name}PTX
PRIVATE FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
)
@@ -69,24 +63,9 @@ macro(enable_cuda_compilation name files)
endmacro()
macro(enable_omp_offload_compilation files)
- if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "off")
- # 'host_device' build only works with Clang compiler currently.
- # The build is done with the CMAKE_C/CXX_COMPILER, i.e. it does not use
- # the in-tree built Clang. We may have a mode that would use the in-tree
- # built Clang.
- #
- # 'nohost' is supposed to produce an LLVM Bitcode library,
- # and it has to be done with a C/C++ compiler producing LLVM Bitcode
- # compatible with the LLVM toolchain version distributed with the Flang
- # compiler.
- # In general, the in-tree built Clang should be used for 'nohost' build.
- # Note that 'nohost' build does not produce the host version of Flang
- # runtime library, so there will be two separate distributable objects.
- # 'nohost' build is a TODO.
-
- if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "host_device")
- message(FATAL_ERROR "Unsupported OpenMP offload build of Flang runtime")
- endif()
+ if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
+ # OpenMP offload build only works with Clang compiler currently.
+
if (BUILD_SHARED_LIBS)
message(FATAL_ERROR
"BUILD_SHARED_LIBS is not supported for OpenMP offload build of Fortran runtime"
@@ -111,13 +90,13 @@ macro(enable_omp_offload_compilation files)
"${all_amdgpu_architectures};${all_nvptx_architectures}"
)
# TODO: support auto detection on the build system.
- if (FLANG_OMP_DEVICE_ARCHITECTURES STREQUAL "all")
- set(FLANG_OMP_DEVICE_ARCHITECTURES ${all_gpu_architectures})
+ if (FORTRANRUNTIME_DEVICE_ARCHITECTURES STREQUAL "all")
+ set(FORTRANRUNTIME_DEVICE_ARCHITECTURES ${all_gpu_architectures})
endif()
- list(REMOVE_DUPLICATES FLANG_OMP_DEVICE_ARCHITECTURES)
+ list(REMOVE_DUPLICATES FORTRANRUNTIME_DEVICE_ARCHITECTURES)
string(REPLACE ";" "," compile_for_architectures
- "${FLANG_OMP_DEVICE_ARCHITECTURES}"
+ "${FORTRANRUNTIME_DEVICE_ARCHITECTURES}"
)
set(OMP_COMPILE_OPTIONS
@@ -138,7 +117,7 @@ macro(enable_omp_offload_compilation files)
)
else()
message(FATAL_ERROR
- "Flang runtime build is not supported for these compilers:\n"
+ "FortranRuntime 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()
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index 87d34054172201..cc0161c05c57fa 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -111,7 +111,7 @@ endif()
-if (NOT DEFINED WIN32)
+if (NOT WIN32)
add_fortranruntime_library(FortranRuntime STATIC
${sources}
INSTALL_WITH_TOOLCHAIN
@@ -159,3 +159,7 @@ else()
FortranRuntime.dynamic_dbg
)
endif()
+
+if (FORTRANRUNTIME_ENABLE_CUF)
+ add_subdirectory(CUDA)
+endif()
diff --git a/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
index f75b854d1eb3ba..78b98652d60813 100644
--- a/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
@@ -6,17 +6,16 @@
#
#===------------------------------------------------------------------------===#
-include_directories(${CUDAToolkit_INCLUDE_DIRS})
-
# 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.
set(CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR})
-add_flang_library(${CUFRT_LIBNAME}
+add_fortranruntime_library(${CUFRT_LIBNAME}
allocator.cpp
descriptor.cpp
)
+target_include_directories(${CUFRT_LIBNAME} PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
if (BUILD_SHARED_LIBS)
set(CUDA_RT_TARGET CUDA::cudart)
diff --git a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
index 2efd6bf0a95249..6401faede9fdf5 100644
--- a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
+++ b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
@@ -11,7 +11,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/allocator-registry.h"
#include "flang/Support/Fortran.h"
diff --git a/FortranRuntime/unittests/CMakeLists.txt b/FortranRuntime/unittests/CMakeLists.txt
index 89e1c909d0f98e..d9533d853df6d7 100644
--- a/FortranRuntime/unittests/CMakeLists.txt
+++ b/FortranRuntime/unittests/CMakeLists.txt
@@ -6,24 +6,55 @@
#
#===------------------------------------------------------------------------===#
+# Add GTest if not already present.
+# Using a function so include_directories/LLVM_SUBPROJECT_TITLE does not propagate
function (build_gtest)
include_directories("${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}")
set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
- add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
+ add_subdirectory("${LLVM_THIRD_PARTY_DIR}/unittest" "${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest")
endfunction ()
-
-# Add GTest if not already present
if (NOT TARGET llvm_gtest)
build_gtest()
endif ()
-# Target that depends on all unittests
-add_custom_target(FortranRuntimeUnitTests)
-set_target_properties(FortranRuntimeUnitTests PROPERTIES FOLDER "Fortran Runtime/Tests")
+
# Required because LLVMSupport is compiled with this option (by default).
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
+
+# Target that depends on all unittests
+add_custom_target(FortranRuntimeUnitTests)
+set_target_properties(FortranRuntimeUnitTests PROPERTIES FOLDER "Fortran Runtime/Meta")
+
+
+function(add_flang_unittest_offload_properties target)
+ # Set CUDA_RESOLVE_DEVICE_SYMBOLS.
+ if (FORTRANRUNTIME_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 (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
+ set_target_properties(${target}
+ PROPERTIES LINK_OPTIONS
+ "-fopenmp;--offload-arch=native"
+ )
+ endif()
+endfunction()
+
+
function(add_fortranruntime_unittest test_dirname)
cmake_parse_arguments(ARG
""
@@ -36,6 +67,7 @@ function(add_fortranruntime_unittest test_dirname)
target_include_directories(${test_dirname} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
target_include_directories(${test_dirname} PRIVATE "${FLANG_SOURCE_DIR}/include")
target_link_libraries(${test_dirname} PRIVATE ${ARG_LINK_LIBS})
+ add_flang_unittest_offload_properties(${test_dirname})
endfunction()
function(add_fortranruntime_nongtest_unittest test_name)
@@ -61,6 +93,7 @@ function(add_fortranruntime_nongtest_unittest test_name)
if(NOT ARG_SLOW_TEST)
add_dependencies(FortranRuntimeUnitTests ${test_name}${suffix})
endif()
+ add_flang_unittest_offload_properties(${test_name}${suffix})
endfunction()
add_subdirectory(Common)
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index 1c85a6754b155b..e93f051c88d33e 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -209,7 +209,7 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DFLANG_EXPERIMENTAL_CUDA_RUNTIME=ON \
+ -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
@@ -231,7 +231,7 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DFLANG_EXPERIMENTAL_CUDA_RUNTIME=ON \
+ -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
@@ -258,7 +258,7 @@ build config:
For example:
```bash
- -DFLANG_EXPERIMENTAL_CUDA_RUNTIME=ON \
+ -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
@@ -268,7 +268,7 @@ For example:
Or:
```bash
- -DFLANG_EXPERIMENTAL_CUDA_RUNTIME=ON \
+ -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
@@ -288,10 +288,10 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DFLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD="host_device" \
+ -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT="OpenMP" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
- -DFLANG_OMP_DEVICE_ARCHITECTURES="all" \
+ -DFORTRANRUNTIME_DEVICE_ARCHITECTURES="all" \
../runtime/
make -j FortranRuntime
>From f6d9f371a968eefb5152ca47bceb51649dca92a9 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 7 Oct 2024 15:55:34 +0200
Subject: [PATCH 10/58] Add documentation
---
FortranRuntime/README.md | 134 +++++++++++++++++++++++++++++++++--
flang/docs/GettingStarted.md | 21 +++---
llvm/runtimes/CMakeLists.txt | 1 +
3 files changed, 142 insertions(+), 14 deletions(-)
diff --git a/FortranRuntime/README.md b/FortranRuntime/README.md
index 6fd4b3359f7888..6018276f6d4c5a 100644
--- a/FortranRuntime/README.md
+++ b/FortranRuntime/README.md
@@ -1,20 +1,142 @@
+<!--===- 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
Fortran Runtime is the runtime library for code emitted by the Flang
compiler (https://flang.llvm.org).
+
## Getting Started
-### Bootstrap Build
+There are two build modes for the FortranRuntime. 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
-```sh
-cmake -S <path-to-llvm-project>/llvm -DLLVM_ENABLE_PROJECTS=flang -DLLVM_ENABLE_RUNTIMES=FortranRuntime
+Requirements:
+ * [Same as LLVM](https://llvm.org/docs/GettingStarted.html#requirements).
+ * While for LLVM C++14 suffices, Flang and FortranRuntime require a C++17-capable C++ compiler.
+
+
+### Bootstrap/In-Tree Build
+
+The bootstrap build will first build Clang and Flang, then use these compilers to compile the FortranRuntime.
+CMake will create a secondary build tree in configured with 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, the FortranRuntime is found by Flang from either the build- or install-prefix. To enable, add `FortranRuntime` to `LLVM_ENABLE_RUNTIMES`:
+
+```bash
+cmake -S <path-to-llvm-project>/llvm \
+ -DNinja \
+ -DLLVM_ENABLE_PROJECTS=flang \
+ -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
+ ...
```
-### Runtime-only build
+It is recommended to enable building OpenMP alongside Flang and FortranRuntime 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).
-```sh
-cmake -S <path-to-llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=FortranRuntime -DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir-or-installprefix>/bin/flang-new
+```bash
+cmake -S <path-to-llvm-project>/llvm \
+ -DNinja \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DLLVM_ENABLE_PROJECTS="flang;openmp" \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;FortranRuntime" \
+ ...
```
+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-new --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 via
+
+```shell
+$ ninja FortranRuntime
+$ ninja check-FortranRuntime
+$ ninja install-FortranRuntime
+```
+
+
+### Runtime-only/Out-of-Tree Build
+
+Instead of building Clang and Flang from scratch, the Runtime-only 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-new` built from the same Git commit as FortranRuntime 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 maight look like the following:
+
+```bash
+cmake -S <path-to-llvm-project>/runtimes \
+ -GNinja \
+ -DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
+ -DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir>/bin/flang-new \
+ -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
+ ...
+```
+
+uilding the FortranRuntime for cross-compilation triple, the target triple can be selected using `LLVM_DEFAULT_TARGET_TRIPLE` AND `LLVM_RUNTIMES_TARGET`. Of course, FortranRuntime 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.
+
+A more complete build configuration could be the following:
+
+```bash
+cmake -S <path-to-llvm-project>/runtimes \
+ -GNinja \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX="${HOME}/local" \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;FortranRuntime" \
+ -DCMAKE_C_COMPILER=gcc \
+ -DCMAKE_CXX_COMPILER=g++ \
+ -DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
+ -DLLVM_DIR=<path-to-llvm-builddir>/lib/cmake/llvm \
+ -DClang_DIR=<path-to-llvm-builddir>/lib/cmake/clang \
+ -DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir-or-installprefix>/bin/flang-new \
+ -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-linux-gnu \
+ -DLLVM_RUNTIMES_TARGET=x86_64-linux-gnu \
+ ...
+```
+
+## Configuration Option Reference
+
+The FortranRuntime has the followign configuration options. This is in addition to the build options the LLVM_ENABLE_RUNTIMES mechanism and CMake itself provide.
+
+ * `FORTRANRUNTIME_INCLUDE_TESTS` (boolean; default: `ON`)
+
+ When `OFF`, does not add any tests, unittests, and omits the `check-FortranRuntime` build target.
+
+ * `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](Real16MathSupport.md).
+
+ * `FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT` (values: `"CUDA"`,`"OpenMP"`, `""` default: `""`)
+
+ When set to `CUDA`, builds a FortranRuntime with 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 a FortranRuntime with support for GPU accelerators using OpenMP offloading. Only Clang is supported for `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`.
+
+ * `FORTRANRUNTIME_ENABLE_CUF` (bool, default: `OFF`)
+
+ Compiles the `libCufRuntime_cuda_<CUDA-version>.a/.so` library. This is independent of `FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA` and only requires a [CUDA Toolkit installation](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html) found (not `CMAKE_CUDA_COMPILER`).
+
+
+### CUDA Support
+
+With `-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`, the following additional configuration options become available.
+
+ * `FORTRANRUNTIME_LIBCUDACXX_PATH` (path, default: `""`)
+
+ Path to libcu++ package installation.
+
+ * `FORTRANRUNTIME_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.
+
+
+### OpenMP Offload Support
+
+With `-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=OpenMP`, the following additional configuration options become available.
+
+ * `FORTRANRUNTIME_DEVICE_ARCHITECTURES` (default: `"all"`)
+ A list of device architectures that the FortranRuntime is supporting. If `"all"` uses a pre-defined list of architectures. Same purpose as `LIBOMPTARGET_DEVICE_ARCHITECTURES` from liboffload.
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index e93f051c88d33e..4a6275a3b57730 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -30,10 +30,10 @@ 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 (bootstrap build)
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
+which it depends. These projects include mlir, clang, flang, openmp,
+compiler-rt, and FortranRuntime. Note that compiler-rt is only needed to access libraries that
support 16 bit floating point numbers. It's not needed to run the automated
tests. You can use several different C++ compilers for most of the build,
includig GNU and clang. But building compiler-rt requres using the clang
@@ -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;FortranRuntime" \
../llvm-project/llvm
ninja
@@ -209,13 +209,14 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
+ -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
-DFORTRANRUNTIME_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/
+ ../runtimes/
make -j FortranRuntime
```
@@ -231,13 +232,14 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
+ -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
-DFORTRANRUNTIME_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 FortranRuntime
```
@@ -251,13 +253,14 @@ 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
+ -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
@@ -268,6 +271,7 @@ For example:
Or:
```bash
+ -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=gcc \
@@ -288,11 +292,12 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
+ -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT="OpenMP" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DFORTRANRUNTIME_DEVICE_ARCHITECTURES="all" \
- ../runtime/
+ ../runtimes/
make -j FortranRuntime
```
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 5da91169058724..4ee7c390f8ecd3 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -281,6 +281,7 @@ function(runtime_default_target)
PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
LLVM_USE_LINKER
CUDA # For runtimes that may look for the CUDA SDK (libc, offload)
+ FLANG_RUNTIME # Shared between Flang and FortranRuntime
${ARG_PREFIXES}
EXTRA_TARGETS ${extra_targets}
${test_targets}
>From 2e23147c9cc8a5e7d832d164663ef2bb8e2eb88e Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 7 Oct 2024 16:13:15 +0200
Subject: [PATCH 11/58] clang-format
---
FortranRuntime/test/Runtime/no-cpp-dep.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/FortranRuntime/test/Runtime/no-cpp-dep.c b/FortranRuntime/test/Runtime/no-cpp-dep.c
index f6760b75a148ff..971e7141678893 100644
--- a/FortranRuntime/test/Runtime/no-cpp-dep.c
+++ b/FortranRuntime/test/Runtime/no-cpp-dep.c
@@ -12,9 +12,9 @@ RUN: rm a.out
*/
#include "flang/Runtime/entry-names.h"
-#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
+#include <stdint.h>
/*
Manually add declarations for the runtime functions that we want to make sure
@@ -32,8 +32,8 @@ int32_t RTNAME(ArgumentCount)();
int32_t RTNAME(GetCommandArgument)(int32_t, const struct Descriptor *,
const struct Descriptor *, const struct Descriptor *);
int32_t RTNAME(GetEnvVariable)(const struct Descriptor *,
- const struct Descriptor *, const struct Descriptor *, bool ,
- const struct Descriptor *, const char *, int );
+ const struct Descriptor *, const struct Descriptor *, bool,
+ const struct Descriptor *, const char *, int);
int64_t RTNAME(SystemClockCount)(int kind);
int main() {
>From b293bdfaf632b8cde85739e9313a7eb7338c346e Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 7 Oct 2024 16:13:44 +0200
Subject: [PATCH 12/58] Undo avoiding C23-incompatibility warning
---
FortranRuntime/test/Runtime/no-cpp-dep.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/FortranRuntime/test/Runtime/no-cpp-dep.c b/FortranRuntime/test/Runtime/no-cpp-dep.c
index 971e7141678893..f68f2b2cf3b475 100644
--- a/FortranRuntime/test/Runtime/no-cpp-dep.c
+++ b/FortranRuntime/test/Runtime/no-cpp-dep.c
@@ -31,9 +31,7 @@ void RTNAME(ProgramStart)(
int32_t RTNAME(ArgumentCount)();
int32_t RTNAME(GetCommandArgument)(int32_t, const struct Descriptor *,
const struct Descriptor *, const struct Descriptor *);
-int32_t RTNAME(GetEnvVariable)(const struct Descriptor *,
- const struct Descriptor *, const struct Descriptor *, bool,
- const struct Descriptor *, const char *, int);
+int32_t RTNAME(GetEnvVariable)();
int64_t RTNAME(SystemClockCount)(int kind);
int main() {
@@ -41,7 +39,7 @@ int main() {
RTNAME(ProgramStart)(0, 0, 0, 0);
int32_t c = RTNAME(ArgumentCount)();
int32_t v = RTNAME(GetCommandArgument)(0, 0, 0, 0);
- int32_t e = RTNAME(GetEnvVariable)(NULL, NULL, NULL, false, NULL, "FOO", 0);
+ int32_t e = RTNAME(GetEnvVariable)("FOO", 0, 0);
int64_t t = RTNAME(SystemClockCount)(8);
return x + c + v + e;
}
>From 981dbcc0b57a62299e488b0516245aa24ef4b35d Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 7 Oct 2024 22:45:54 +0200
Subject: [PATCH 13/58] Formatting and release notes update
---
FortranRuntime/CMakeLists.txt | 2 +
FortranRuntime/README.md | 103 +++++++++++++-----
FortranRuntime/cmake/config.h.cmake.in | 8 ++
.../modules/AddFlangOffloadRuntime.cmake | 16 ++-
.../cmake/modules/AddFortranRuntime.cmake | 36 +++---
.../cmake/modules/FlangCommon.cmake | 12 ++
FortranRuntime/lib/CMakeLists.txt | 1 +
FortranRuntime/lib/Runtime/CMakeLists.txt | 14 +--
.../lib/Runtime/Float128Math/CMakeLists.txt | 6 +-
FortranRuntime/lib/Testing/CMakeLists.txt | 1 +
FortranRuntime/test/Driver/ctofortran.f90 | 3 +-
FortranRuntime/unittests/CMakeLists.txt | 1 -
flang/docs/GettingStarted.md | 19 ++--
flang/docs/ReleaseNotes.md | 7 ++
flang/lib/CMakeLists.txt | 2 +-
flang/lib/Common/CMakeLists.txt | 12 +-
flang/lib/Evaluate/CMakeLists.txt | 2 +-
flang/lib/Optimizer/Transforms/CMakeLists.txt | 1 -
flang/test/lib/CMakeLists.txt | 1 -
flang/tools/f18/CMakeLists.txt | 6 +-
flang/unittests/Evaluate/CMakeLists.txt | 3 +-
21 files changed, 176 insertions(+), 80 deletions(-)
diff --git a/FortranRuntime/CMakeLists.txt b/FortranRuntime/CMakeLists.txt
index fe5610f0c20816..e65cab7060cb02 100644
--- a/FortranRuntime/CMakeLists.txt
+++ b/FortranRuntime/CMakeLists.txt
@@ -156,4 +156,6 @@ add_subdirectory(lib)
if (FORTRANRUNTIME_INCLUDE_TESTS)
add_subdirectory(unittests)
add_subdirectory(test)
+else ()
+ add_custom_target(check-FortranRuntime)
endif()
diff --git a/FortranRuntime/README.md b/FortranRuntime/README.md
index 6018276f6d4c5a..cb578507f8c96e 100644
--- a/FortranRuntime/README.md
+++ b/FortranRuntime/README.md
@@ -8,27 +8,40 @@
# Fortran Runtime
-Fortran Runtime is the runtime library for code emitted by the Flang
-compiler (https://flang.llvm.org).
+Fortran Runtime is the runtime library for code emitted by the Flang compiler
+(https://flang.llvm.org).
## Getting Started
-There are two build modes for the FortranRuntime. 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.
+There are two build modes for the FortranRuntime. 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).
- * While for LLVM C++14 suffices, Flang and FortranRuntime require a C++17-capable C++ compiler.
+ * While for LLVM C++14 suffices, Flang and FortranRuntime require a
+ C++17-capable C++ compiler.
### Bootstrap/In-Tree Build
-The bootstrap build will first build Clang and Flang, then use these compilers to compile the FortranRuntime.
-CMake will create a secondary build tree in configured with 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, the FortranRuntime is found by Flang from either the build- or install-prefix. To enable, add `FortranRuntime` to `LLVM_ENABLE_RUNTIMES`:
+The bootstrap build will first build Clang and Flang, then use these compilers
+to compile the FortranRuntime. CMake will create a secondary build tree in
+configured with 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, the FortranRuntime is found by Flang from either
+the build- or install-prefix. To enable, add `FortranRuntime` to
+`LLVM_ENABLE_RUNTIMES`:
```bash
cmake -S <path-to-llvm-project>/llvm \
@@ -38,7 +51,10 @@ cmake -S <path-to-llvm-project>/llvm \
...
```
-It is recommended to enable building OpenMP alongside Flang and FortranRuntime 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).
+It is recommended to enable building OpenMP alongside Flang and FortranRuntime
+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>/llvm \
@@ -49,23 +65,35 @@ cmake -S <path-to-llvm-project>/llvm \
...
```
-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-new --target=<target-triple>`, add more triples to `LLVM_RUNTIME_TARGETS`, such as `-DLLVM_RUNTIME_TARGETS="default;aarch64-linux-gnu"`.
+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-new --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 via
+After configuration, build, test, and install the runtime(s) via
```shell
$ ninja FortranRuntime
$ ninja check-FortranRuntime
-$ ninja install-FortranRuntime
+$ ninja install
```
### Runtime-only/Out-of-Tree Build
-Instead of building Clang and Flang from scratch, the Runtime-only 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-new` built from the same Git commit as FortranRuntime to ensure they are using the same ABI. The C and C++ compiler can be any compiler supporting the same ABI.
+Instead of building Clang and Flang from scratch, the Runtime-only 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-new` built from the same Git commit as
+FortranRuntime 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 maight look like the following:
+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>/runtimes \
@@ -76,7 +104,11 @@ cmake -S <path-to-llvm-project>/runtimes \
...
```
-uilding the FortranRuntime for cross-compilation triple, the target triple can be selected using `LLVM_DEFAULT_TARGET_TRIPLE` AND `LLVM_RUNTIMES_TARGET`. Of course, FortranRuntime 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.
+Building the FortranRuntime for cross-compilation triple, the target triple can
+be selected using `LLVM_DEFAULT_TARGET_TRIPLE` AND `LLVM_RUNTIMES_TARGET`.
+Of course, FortranRuntime 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.
A more complete build configuration could be the following:
@@ -99,30 +131,46 @@ cmake -S <path-to-llvm-project>/runtimes
## Configuration Option Reference
-The FortranRuntime has the followign configuration options. This is in addition to the build options the LLVM_ENABLE_RUNTIMES mechanism and CMake itself provide.
+The FortranRuntime has the followign configuration options. This is in
+addition to the build options the LLVM_ENABLE_RUNTIMES mechanism and
+CMake itself provide.
* `FORTRANRUNTIME_INCLUDE_TESTS` (boolean; default: `ON`)
- When `OFF`, does not add any tests, unittests, and omits the `check-FortranRuntime` build target.
+ When `OFF`, does not add any tests and unittests. The `check-FortranRuntime`
+ 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](Real16MathSupport.md).
+ 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).
* `FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT` (values: `"CUDA"`,`"OpenMP"`, `""` default: `""`)
- When set to `CUDA`, builds a FortranRuntime with 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 `CUDA`, builds a FortranRuntime 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 a FortranRuntime with support for GPU accelerators using OpenMP offloading. Only Clang is supported for `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`.
+ When set to `OpenMP`, builds a FortranRuntime with experimental support for
+ GPU accelerators using OpenMP offloading. Only Clang is supported for
+ `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`.
* `FORTRANRUNTIME_ENABLE_CUF` (bool, default: `OFF`)
- Compiles the `libCufRuntime_cuda_<CUDA-version>.a/.so` library. This is independent of `FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA` and only requires a [CUDA Toolkit installation](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html) found (not `CMAKE_CUDA_COMPILER`).
+ Compiles the `libCufRuntime_cuda_<CUDA-version>.a/.so` library. This is
+ independent of `FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA` and only
+ requires a
+ [CUDA Toolkit installation](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html)
+ (no `CMAKE_CUDA_COMPILER`).
### CUDA Support
-With `-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`, the following additional configuration options become available.
+With `-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`, the following
+additional configuration options become available.
* `FORTRANRUNTIME_LIBCUDACXX_PATH` (path, default: `""`)
@@ -130,13 +178,18 @@ With `-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`, the following additio
* `FORTRANRUNTIME_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.
+ Do not compile global variables' definitions when producing PTX library.
+ Default is `OFF`, meaning global variable definitions are compiled by
+ default.
### OpenMP Offload Support
-With `-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=OpenMP`, the following additional configuration options become available.
+With `-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=OpenMP`, the following
+additional configuration options become available.
* `FORTRANRUNTIME_DEVICE_ARCHITECTURES` (default: `"all"`)
- A list of device architectures that the FortranRuntime is supporting. If `"all"` uses a pre-defined list of architectures. Same purpose as `LIBOMPTARGET_DEVICE_ARCHITECTURES` from liboffload.
+ A list of device architectures that the FortranRuntime is supporting.
+ If `"all"` uses a pre-defined list of architectures. Same purpose as
+ `LIBOMPTARGET_DEVICE_ARCHITECTURES` from liboffload.
diff --git a/FortranRuntime/cmake/config.h.cmake.in b/FortranRuntime/cmake/config.h.cmake.in
index 0a1d1394b9bc49..4fa31c7e89ad7b 100644
--- a/FortranRuntime/cmake/config.h.cmake.in
+++ b/FortranRuntime/cmake/config.h.cmake.in
@@ -1,3 +1,11 @@
+//===-- cmake/config.h.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
diff --git a/FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake b/FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake
index ae6fcabbed9b92..8cfd02267dfdca 100644
--- a/FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake
+++ b/FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake
@@ -1,12 +1,10 @@
-
-
-
-
-
-
-
-
-
+#===-- cmake/modules/AddFlangOffloadRuntime.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 (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
diff --git a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
index 316923ca632c20..841459e4dbd105 100644
--- a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
+++ b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
@@ -6,7 +6,7 @@
#
#===------------------------------------------------------------------------===#
-# Builds a library with common option for FortranRuntime.
+# Builds a library with common options for FortranRuntime.
#
# Usage:
#
@@ -16,11 +16,13 @@
# STATIC
# Build a static (.a/.lib) library
# OBJECT
-# Create only object- and Fortran module files without static/dynamic library
+# 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
+# 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
+# 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
@@ -65,22 +67,30 @@ function (add_fortranruntime_library name)
target_compile_features(${name} PRIVATE cxx_std_17)
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>)
+ 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->)
+ target_compile_options(${name} PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:/EHs-c- /GR->
+ )
endif ()
# FortranRuntime's public headers
target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
- # For ISO_Fortran_binding.h to be found (Accessed as #include "flang/ISO_Fortran_binding.h")
+ # 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 configured config.h for be found
+ # For FortranRuntime's configured config.h to be found
target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_BINARY_DIR}")
- # Clang/Flang, targeting the MSVC ABI, including clang-cl, should only depends on msv(u)crt. LLVM still emits libgcc/compiler-rt functions for 128-bit integer math (__udivti3, __modti3, __fixsfti, __floattidf, ...) that msvc does not support.
- # We are injecting a dependency to Compiler-RT where these are implemented.
+ # Clang/Flang, targeting the MSVC ABI, including clang-cl, should only depends
+ # on msv(u)crt. LLVM still emits libgcc/compiler-rt functions for 128-bit
+ # integer math (__udivti3, __modti3, __fixsfti, __floattidf, ...) that msvc
+ # does not support. We are injecting a dependency to Compiler-RT where these
+ # are implemented.
if (MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") AND FORTRANRUNTIME_LIBCALL)
target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "--dependent-lib=${FORTRANRUNTIME_LIBCALL}")
endif ()
@@ -96,9 +106,9 @@ function (add_fortranruntime_library name)
target_include_directories(${name} PRIVATE ${LLVM_INCLUDE_DIRS})
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
+ # 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
diff --git a/FortranRuntime/cmake/modules/FlangCommon.cmake b/FortranRuntime/cmake/modules/FlangCommon.cmake
index 34c91048f47887..d7194ad4d7ef56 100644
--- a/FortranRuntime/cmake/modules/FlangCommon.cmake
+++ b/FortranRuntime/cmake/modules/FlangCommon.cmake
@@ -1,3 +1,15 @@
+#===-- 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 betwween Flang and FortranRuntime
+#
+#===------------------------------------------------------------------------===#
+
# 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
diff --git a/FortranRuntime/lib/CMakeLists.txt b/FortranRuntime/lib/CMakeLists.txt
index 8c4382078a8e70..74c78b3fa3a493 100644
--- a/FortranRuntime/lib/CMakeLists.txt
+++ b/FortranRuntime/lib/CMakeLists.txt
@@ -10,3 +10,4 @@ add_subdirectory(Runtime)
if (FORTRANRUNTIME_INCLUDE_TESTS)
add_subdirectory(Testing)
endif ()
+
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index cc0161c05c57fa..b62556ff4b4e66 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -90,9 +90,6 @@ file(GLOB_RECURSE private_headers
"${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
)
-
-
-
get_target_property(f128_sources
FortranFloat128MathILib INTERFACE_SOURCES
)
@@ -109,8 +106,6 @@ if (f128_sources)
list(APPEND sources ${f128_sources})
endif()
-
-
if (NOT WIN32)
add_fortranruntime_library(FortranRuntime STATIC
${sources}
@@ -118,7 +113,8 @@ if (NOT WIN32)
ADDITIONAL_HEADERS ${public_headers} ${private_headers}
)
- # For unittests that link to FortranRuntime. Should link to the static version of the library.
+ # For unittests that link to FortranRuntime. Should link to the static version
+ # of the library.
add_library(FortranRuntime.static ALIAS FortranRuntime)
add_library(FortranRuntime.unittest ALIAS FortranRuntime)
else()
@@ -131,7 +127,8 @@ else()
ADDITIONAL_HEADERS ${public_headers} ${private_headers}
)
- # Setting an unique Fortran_MODULE_DIRECTORY is required for each variant to write a different .mod file.
+ # Setting an unique Fortran_MODULE_DIRECTORY is required for each variant to
+ # write a different .mod file.
set_target_properties(${name}
PROPERTIES
MSVC_RUNTIME_LIBRARY ${msvc_lib}
@@ -145,7 +142,8 @@ else()
# unittests link against LLVMSupport which is compiled with /MD
add_win_fortranruntime_library(STATIC unittest MultiThreadedDLL EXCLUDE_FROM_ALL)
- # FIXME: Before DLL versions of the runtime can be used, exported definitions must be annotated with __declspec(dllexport).
+ # FIXME: Before DLL versions of the runtime can be used, exported definitions
+ # must be annotated with __declspec(dllexport).
add_win_fortranruntime_library(SHARED dynamic MultiThreadedDLL)
add_win_fortranruntime_library(SHARED dynamic_dbg MultiThreadedDebugDLL)
diff --git a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
index a55d39e88cd404..ed65da0a5ac71c 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
@@ -88,9 +88,11 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
"${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 the main FortranRuntime.lib.
+ # Do not create a FortranFloat128Math library under Windows, the Flang
+ # driver never links it. Instead, add the sources to the main
+ # FortranRuntime.lib.
target_sources(FortranFloat128MathILib INTERFACE ${sources})
target_compile_definitions(FortranFloat128MathILib INTERFACE HAS_QUADMATHLIB)
else ()
diff --git a/FortranRuntime/lib/Testing/CMakeLists.txt b/FortranRuntime/lib/Testing/CMakeLists.txt
index 75b38662c2a0fa..d5caada3fb68e8 100644
--- a/FortranRuntime/lib/Testing/CMakeLists.txt
+++ b/FortranRuntime/lib/Testing/CMakeLists.txt
@@ -17,3 +17,4 @@ add_fortranruntime_library(NonGTestTesting EXCLUDE_FROM_ALL LINK_TO_LLVM
ADDITIONAL_HEADERS
${public_headers}
)
+
diff --git a/FortranRuntime/test/Driver/ctofortran.f90 b/FortranRuntime/test/Driver/ctofortran.f90
index a9cbf166bfe46c..78eac32133b18e 100644
--- a/FortranRuntime/test/Driver/ctofortran.f90
+++ b/FortranRuntime/test/Driver/ctofortran.f90
@@ -1,9 +1,8 @@
+! UNSUPPORTED: system-windows
! 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
-! UNSUPPORTED: system-windows
-
!--- ffile.f90
program fmain
interface
diff --git a/FortranRuntime/unittests/CMakeLists.txt b/FortranRuntime/unittests/CMakeLists.txt
index d9533d853df6d7..3733588b82624f 100644
--- a/FortranRuntime/unittests/CMakeLists.txt
+++ b/FortranRuntime/unittests/CMakeLists.txt
@@ -39,7 +39,6 @@ function(add_flang_unittest_offload_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.
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index 4a6275a3b57730..eb9049ad607570 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -197,13 +197,13 @@ 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
+#### Building out-of-tree (Runtime-only build)
##### 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
@@ -217,7 +217,7 @@ cmake \
-DCMAKE_CUDA_COMPILER=clang \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
../runtimes/
-make -j FortranRuntime
+make -j`nprocs` FortranRuntime
```
Note that the used version of `clang` must [support](https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#cuda-support)
@@ -226,7 +226,7 @@ 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
@@ -241,7 +241,7 @@ cmake \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
../runtimes/
-make -j FortranRuntime
+make -j`nprocs` FortranRuntime
```
Note that `nvcc` might limit support to certain
@@ -267,6 +267,7 @@ For example:
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CUDA_COMPILER=clang \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
+ ../llvm
```
Or:
@@ -278,15 +279,17 @@ Or:
-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 -j`nprocs` check-flang` will work with such CMake configuration.
+Consider a lower value instead of `nprocs` appropriate to the available RAM.
##### 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
@@ -299,7 +302,7 @@ cmake \
-DFORTRANRUNTIME_DEVICE_ARCHITECTURES="all" \
../runtimes/
-make -j FortranRuntime
+make -j`nprocs` FortranRuntime
```
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 f0c956281915f4..80ebbb5481ba50 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -36,6 +36,13 @@ page](https://llvm.org/releases/).
## Build System Changes
+ * The Fortran Runtime library (libFortranRuntime) has been move to a new
+ top-level directory named "FortranRuntime". It now supports the
+ LLVM_ENABLE_RUNTIMES mechanism to build libFortranRuntime for multiple target
+ triples. libFortranRuntime.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/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index 0ab7d1c888df96..a7cdb4819d7252 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -1,9 +1,9 @@
add_subdirectory(Common)
-add_subdirectory(Support)
add_subdirectory(Evaluate)
add_subdirectory(Lower)
add_subdirectory(Parser)
add_subdirectory(Semantics)
+add_subdirectory(Support)
add_subdirectory(Frontend)
add_subdirectory(FrontendTool)
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index 73af3bdd589162..f7fdc74a32ec8c 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -1,4 +1,12 @@
+#===-- lib/Common/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(FortranCommon
- "${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/binary-to-decimal.cpp"
- "${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/lib/Common/decimal-to-binary.cpp"
+ "${FORTRANRUNTIME_SOURCE_DIR}/lib/Common/binary-to-decimal.cpp"
+ "${FORTRANRUNTIME_SOURCE_DIR}/lib/Common/decimal-to-binary.cpp"
)
diff --git a/flang/lib/Evaluate/CMakeLists.txt b/flang/lib/Evaluate/CMakeLists.txt
index 5f2e345b7bfb56..2847020adcc3ec 100644
--- a/flang/lib/Evaluate/CMakeLists.txt
+++ b/flang/lib/Evaluate/CMakeLists.txt
@@ -60,8 +60,8 @@ add_flang_library(FortranEvaluate
variable.cpp
LINK_LIBS
- FortranParser
FortranSupport
+ FortranParser
${LIBPGMATH}
${QUADMATHLIB}
diff --git a/flang/lib/Optimizer/Transforms/CMakeLists.txt b/flang/lib/Optimizer/Transforms/CMakeLists.txt
index 35794300dbc6aa..49baf063efe8a3 100644
--- a/flang/lib/Optimizer/Transforms/CMakeLists.txt
+++ b/flang/lib/Optimizer/Transforms/CMakeLists.txt
@@ -43,7 +43,6 @@ add_flang_library(FIRTransforms
FIRDialect
FIRDialectSupport
FIRSupport
- FortranCommon
FortranSupport
HLFIRDialect
MLIRAffineUtils
diff --git a/flang/test/lib/CMakeLists.txt b/flang/test/lib/CMakeLists.txt
index 687b107844c651..fc6ef10fab1f5a 100644
--- a/flang/test/lib/CMakeLists.txt
+++ b/flang/test/lib/CMakeLists.txt
@@ -1,2 +1 @@
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../../FortranRuntime/include")
add_subdirectory(Analysis)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 5f749a433f05cd..401c7cc2bdef79 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -6,7 +6,7 @@ set(LLVM_LINK_COMPONENTS
# Define the list of Fortran module files for which it is
# sufficient to generate the module file via -fsyntax-only.
-set(MODULES_WITHOUT_IMPLEMENTATION
+set(MODULES
"__fortran_builtins"
"__fortran_ieee_exceptions"
"__fortran_type_info"
@@ -23,8 +23,6 @@ set(MODULES_WITHOUT_IMPLEMENTATION
"iso_fortran_env_impl"
)
-set(MODULES ${MODULES_WITHOUT_IMPLEMENTATION})
-
# Check if 128-bit float computations can be done via long double.
check_cxx_source_compiles(
"#include <cfloat>
@@ -69,7 +67,7 @@ if (NOT CMAKE_CROSSCOMPILING)
else()
set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
if(${filename} STREQUAL "iso_fortran_env_impl")
- set(sourcepath "${FLANG_SOURCE_DIR}/../FortranRuntime/lib/Runtime/${filename}.f90")
+ set(sourcepath "${FORTRANRUNTIME_SOURCE_DIR}/lib/Runtime/${filename}.f90")
endif()
if(${filename} STREQUAL "iso_fortran_env")
set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/iso_fortran_env_impl.mod)
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index a7f763d7b17d85..324195348d045b 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -40,11 +40,11 @@ add_flang_nongtest_unittest(integer
)
add_flang_nongtest_unittest(intrinsics
- FortranSupport
FortranCommon
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
+ FortranSupport
FortranParser
)
@@ -63,7 +63,6 @@ set(LLVM_REQUIRES_RTTI ON)
add_flang_nongtest_unittest(real
FortranEvaluateTesting
FortranEvaluate
- FortranCommon
FortranSupport
FortranSemantics
)
>From 8ba5c8b182bec2b66b82c9a745f07ddc2c1bec59 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 8 Oct 2024 23:08:07 +0200
Subject: [PATCH 14/58] Compile fix after too aggressive cleanup
---
FortranRuntime/cmake/modules/AddFortranRuntime.cmake | 2 +-
FortranRuntime/lib/Runtime/CMakeLists.txt | 5 +++++
FortranRuntime/unittests/CMakeLists.txt | 3 +--
flang/lib/Evaluate/CMakeLists.txt | 1 +
4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
index 841459e4dbd105..e9563c6e3a60b9 100644
--- a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
+++ b/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
@@ -68,7 +68,7 @@ function (add_fortranruntime_library name)
target_compile_features(${name} PRIVATE cxx_std_17)
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
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables>
)
elseif (MSVC)
target_compile_options(${name} PRIVATE
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index b62556ff4b4e66..2465c9a9ed9bb8 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -90,6 +90,11 @@ file(GLOB_RECURSE private_headers
"${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
)
+include(AddFlangOffloadRuntime)
+
+enable_cuda_compilation(FortranRuntime "${supported_files}")
+enable_omp_offload_compilation("${supported_files}")
+
get_target_property(f128_sources
FortranFloat128MathILib INTERFACE_SOURCES
)
diff --git a/FortranRuntime/unittests/CMakeLists.txt b/FortranRuntime/unittests/CMakeLists.txt
index 3733588b82624f..b57a0e1292590b 100644
--- a/FortranRuntime/unittests/CMakeLists.txt
+++ b/FortranRuntime/unittests/CMakeLists.txt
@@ -17,8 +17,6 @@ if (NOT TARGET llvm_gtest)
build_gtest()
endif ()
-
-
# Required because LLVMSupport is compiled with this option (by default).
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
@@ -92,6 +90,7 @@ function(add_fortranruntime_nongtest_unittest test_name)
if(NOT ARG_SLOW_TEST)
add_dependencies(FortranRuntimeUnitTests ${test_name}${suffix})
endif()
+
add_flang_unittest_offload_properties(${test_name}${suffix})
endfunction()
diff --git a/flang/lib/Evaluate/CMakeLists.txt b/flang/lib/Evaluate/CMakeLists.txt
index 2847020adcc3ec..1408f382255a8b 100644
--- a/flang/lib/Evaluate/CMakeLists.txt
+++ b/flang/lib/Evaluate/CMakeLists.txt
@@ -60,6 +60,7 @@ add_flang_library(FortranEvaluate
variable.cpp
LINK_LIBS
+ FortranCommon
FortranSupport
FortranParser
${LIBPGMATH}
>From 54b516786bd725e5b409d7ee6a4f55fe09a1baa9 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 9 Oct 2024 09:48:46 +0200
Subject: [PATCH 15/58] CUDA/OpenMP build fix
---
...e.cmake => AddFortranOffloadRuntime.cmake} | 10 ++--
.../include/flang/Common/fast-int-set.h | 6 +-
FortranRuntime/lib/Runtime/CMakeLists.txt | 59 +++++++++++--------
.../lib/Runtime/allocator-registry.cpp | 4 +-
FortranRuntime/lib/Runtime/environment.cpp | 4 +-
FortranRuntime/lib/Runtime/unit.cpp | 4 +-
FortranRuntime/lib/Runtime/utf.cpp | 4 +-
FortranRuntime/test/Runtime/no-cpp-dep.c | 3 +
FortranRuntime/unittests/CMakeLists.txt | 6 +-
.../unittests/Runtime/CMakeLists.txt | 4 ++
.../unittests/Runtime/CUDA/AllocatorCUF.cpp | 2 +-
.../unittests/Runtime/CUDA/CMakeLists.txt | 19 ++++++
llvm/runtimes/CMakeLists.txt | 1 +
13 files changed, 82 insertions(+), 44 deletions(-)
rename FortranRuntime/cmake/modules/{AddFlangOffloadRuntime.cmake => AddFortranOffloadRuntime.cmake} (93%)
create mode 100644 FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt
diff --git a/FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake b/FortranRuntime/cmake/modules/AddFortranOffloadRuntime.cmake
similarity index 93%
rename from FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake
rename to FortranRuntime/cmake/modules/AddFortranOffloadRuntime.cmake
index 8cfd02267dfdca..d60a26ce0f8a86 100644
--- a/FortranRuntime/cmake/modules/AddFlangOffloadRuntime.cmake
+++ b/FortranRuntime/cmake/modules/AddFortranOffloadRuntime.cmake
@@ -1,4 +1,4 @@
-#===-- cmake/modules/AddFlangOffloadRuntime.txt ----------------------------===#
+#===-- cmake/modules/AddFortranOffloadRuntime.txt --------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
@@ -50,11 +50,11 @@ macro(enable_cuda_compilation name files)
endif()
# Add an OBJECT library consisting of CUDA PTX.
- llvm_add_library(${name}PTX OBJECT PARTIAL_SOURCES_INTENDED ${files})
- set_property(TARGET obj.${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
+ add_fortranruntime_library(${name}PTX OBJECT ${files})
+ set_property(TARGET ${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
if (FORTRANRUNTIME_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
- target_compile_definitions(obj.${name}PTX
- PRIVATE FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+ target_compile_definitions(${name}PTX
+ PRIVATE FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
)
endif()
endif()
diff --git a/FortranRuntime/include/flang/Common/fast-int-set.h b/FortranRuntime/include/flang/Common/fast-int-set.h
index 323ee4dc7e94d9..fe3f1632060b50 100644
--- a/FortranRuntime/include/flang/Common/fast-int-set.h
+++ b/FortranRuntime/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 "flang/Common/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/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index 2465c9a9ed9bb8..678edde7947eb6 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -6,9 +6,10 @@
#
#===------------------------------------------------------------------------===#
-add_subdirectory(Float128Math)
+include(AddFortranOffloadRuntime)
-set(sources
+# List of files that are buildable for all devices.
+set(supported_sources
../Common/binary-to-decimal.cpp
../Common/decimal-to-binary.cpp
ISO_Fortran_binding.cpp
@@ -18,9 +19,6 @@ set(sources
assign.cpp
buffer.cpp
character.cpp
- command.cpp
- complex-powi.cpp
- complex-reduction.c
connection.cpp
copy.cpp
derived-api.cpp
@@ -31,9 +29,6 @@ set(sources
edit-input.cpp
edit-output.cpp
environment.cpp
- exceptions.cpp
- execute.cpp
- extensions.cpp
external-unit.cpp
extrema.cpp
file.cpp
@@ -45,9 +40,7 @@ set(sources
io-api-minimal.cpp
io-error.cpp
io-stmt.cpp
- iso_fortran_env_impl.f90
iostat.cpp
- main.cpp
matmul-transpose.cpp
matmul.cpp
memory.cpp
@@ -59,41 +52,49 @@ set(sources
product.cpp
pseudo-unit.cpp
ragged.cpp
- random.cpp
- reduce.cpp
- reduction.cpp
stat.cpp
- stop.cpp
sum.cpp
support.cpp
- temporary-stack.cpp
terminator.cpp
- time-intrinsic.cpp
tools.cpp
transformational.cpp
type-code.cpp
type-info.cpp
- unit-map.cpp
unit.cpp
+ unit-map.cpp
utf.cpp
)
-set(public_headers "")
+# List of source not used for GPU offloading.
+set(host_sources
+ command.cpp
+ complex-powi.cpp
+ complex-reduction.c
+ exceptions.cpp
+ execute.cpp
+ extensions.cpp
+ iso_fortran_env_impl.f90
+ main.cpp
+ random.cpp
+ reduce.cpp
+ reduction.cpp
+ stop.cpp
+ temporary-stack.cpp
+ time-intrinsic.cpp
+)
+
file(GLOB_RECURSE public_headers
"${FLANGRUNTIME_SOURCE_DIR}/include/flang/Runtime/*.h"
"${FLANGRUNTIME_SOURCE_DIR}/include/flang/Common/*.h"
)
-set(private_headers "")
file(GLOB_RECURSE private_headers
"${FLANGRUNTIME_SOURCE_DIR}/lib/Runtime/*.h"
"${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
)
-include(AddFlangOffloadRuntime)
-enable_cuda_compilation(FortranRuntime "${supported_files}")
-enable_omp_offload_compilation("${supported_files}")
+add_subdirectory(Float128Math)
get_target_property(f128_sources
FortranFloat128MathILib INTERFACE_SOURCES
@@ -108,8 +109,12 @@ if (f128_sources)
APPEND PROPERTY COMPILE_DEFINITIONS
${f128_defs}
)
- list(APPEND sources ${f128_sources})
-endif()
+else ()
+ set(f128_sources "")
+endif ()
+
+
+set(sources ${supported_sources} ${host_sources} ${f128_sources})
if (NOT WIN32)
add_fortranruntime_library(FortranRuntime STATIC
@@ -118,6 +123,9 @@ if (NOT WIN32)
ADDITIONAL_HEADERS ${public_headers} ${private_headers}
)
+ enable_cuda_compilation(FortranRuntime "${supported_sources}")
+ enable_omp_offload_compilation("${supported_sources}")
+
# For unittests that link to FortranRuntime. Should link to the static version
# of the library.
add_library(FortranRuntime.static ALIAS FortranRuntime)
@@ -139,6 +147,9 @@ else()
MSVC_RUNTIME_LIBRARY ${msvc_lib}
Fortran_MODULE_DIRECTORY "module.${suffix}"
)
+
+ enable_cuda_compilation(FortranRuntime "${supported_sources}")
+ enable_omp_offload_compilation("${supported_sources}")
endfunction ()
add_win_fortranruntime_library(STATIC static MultiThreaded)
diff --git a/FortranRuntime/lib/Runtime/allocator-registry.cpp b/FortranRuntime/lib/Runtime/allocator-registry.cpp
index 68fb8b80680558..edd3685e83a820 100644
--- a/FortranRuntime/lib/Runtime/allocator-registry.cpp
+++ b/FortranRuntime/lib/Runtime/allocator-registry.cpp
@@ -11,11 +11,11 @@
namespace Fortran::runtime {
-#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS AllocatorRegistry allocatorRegistry;
RT_OFFLOAD_VAR_GROUP_END
-#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
RT_API_ATTRS void AllocatorRegistry::Register(int pos, Allocator_t allocator) {
diff --git a/FortranRuntime/lib/Runtime/environment.cpp b/FortranRuntime/lib/Runtime/environment.cpp
index 272914877988a5..9cbb198dd9141c 100644
--- a/FortranRuntime/lib/Runtime/environment.cpp
+++ b/FortranRuntime/lib/Runtime/environment.cpp
@@ -23,11 +23,11 @@ extern char **environ;
namespace Fortran::runtime {
-#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS ExecutionEnvironment executionEnvironment;
RT_OFFLOAD_VAR_GROUP_END
-#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
static void SetEnvironmentDefaults(const EnvironmentDefaultList *envDefaults) {
if (!envDefaults) {
diff --git a/FortranRuntime/lib/Runtime/unit.cpp b/FortranRuntime/lib/Runtime/unit.cpp
index 496679ee8ce5f4..f6e4dc2a7befd4 100644
--- a/FortranRuntime/lib/Runtime/unit.cpp
+++ b/FortranRuntime/lib/Runtime/unit.cpp
@@ -19,13 +19,13 @@
namespace Fortran::runtime::io {
-#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS ExternalFileUnit *defaultInput{nullptr}; // unit 5
RT_VAR_ATTRS ExternalFileUnit *defaultOutput{nullptr}; // unit 6
RT_VAR_ATTRS ExternalFileUnit *errorOutput{nullptr}; // unit 0 extension
RT_OFFLOAD_VAR_GROUP_END
-#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/utf.cpp b/FortranRuntime/lib/Runtime/utf.cpp
index 635451153d39a6..d2839f9cf3793a 100644
--- a/FortranRuntime/lib/Runtime/utf.cpp
+++ b/FortranRuntime/lib/Runtime/utf.cpp
@@ -10,7 +10,7 @@
namespace Fortran::runtime {
-#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
// clang-format off
RT_OFFLOAD_VAR_GROUP_BEGIN
const RT_CONST_VAR_ATTRS std::uint8_t UTF8FirstByteTable[256]{
@@ -41,7 +41,7 @@ const RT_CONST_VAR_ATTRS std::uint8_t UTF8FirstByteTable[256]{
};
RT_OFFLOAD_VAR_GROUP_END
// clang-format on
-#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/test/Runtime/no-cpp-dep.c b/FortranRuntime/test/Runtime/no-cpp-dep.c
index f68f2b2cf3b475..2cc5669a60d3a2 100644
--- a/FortranRuntime/test/Runtime/no-cpp-dep.c
+++ b/FortranRuntime/test/Runtime/no-cpp-dep.c
@@ -5,6 +5,9 @@ a C compiler.
UNSUPPORTED: system-windows
+FIXME: This currently fails with CUDA-enabled FortranRuntime because it needs
+ to link libcuda_rt.
+
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
RUN: %cc -std=c99 %s -I%include %libruntime -lm \
RUN: %if system-aix %{-lpthread %}
diff --git a/FortranRuntime/unittests/CMakeLists.txt b/FortranRuntime/unittests/CMakeLists.txt
index b57a0e1292590b..1bb788651a8d33 100644
--- a/FortranRuntime/unittests/CMakeLists.txt
+++ b/FortranRuntime/unittests/CMakeLists.txt
@@ -30,7 +30,7 @@ add_custom_target(FortranRuntimeUnitTests)
set_target_properties(FortranRuntimeUnitTests PROPERTIES FOLDER "Fortran Runtime/Meta")
-function(add_flang_unittest_offload_properties target)
+function(add_fortranruntime_unittest_offload_properties target)
# Set CUDA_RESOLVE_DEVICE_SYMBOLS.
if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
set_target_properties(${target}
@@ -64,7 +64,7 @@ function(add_fortranruntime_unittest test_dirname)
target_include_directories(${test_dirname} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
target_include_directories(${test_dirname} PRIVATE "${FLANG_SOURCE_DIR}/include")
target_link_libraries(${test_dirname} PRIVATE ${ARG_LINK_LIBS})
- add_flang_unittest_offload_properties(${test_dirname})
+ add_fortranruntime_unittest_offload_properties(${test_dirname})
endfunction()
function(add_fortranruntime_nongtest_unittest test_name)
@@ -91,7 +91,7 @@ function(add_fortranruntime_nongtest_unittest test_name)
add_dependencies(FortranRuntimeUnitTests ${test_name}${suffix})
endif()
- add_flang_unittest_offload_properties(${test_name}${suffix})
+ add_fortranruntime_unittest_offload_properties(${test_name}${suffix})
endfunction()
add_subdirectory(Common)
diff --git a/FortranRuntime/unittests/Runtime/CMakeLists.txt b/FortranRuntime/unittests/Runtime/CMakeLists.txt
index b4c0d7f86c1878..e4439dcc8b3c7e 100644
--- a/FortranRuntime/unittests/Runtime/CMakeLists.txt
+++ b/FortranRuntime/unittests/Runtime/CMakeLists.txt
@@ -40,3 +40,7 @@ add_fortranruntime_unittest(FlangRuntimeTests
LINK_LIBS
FortranRuntime.unittest
)
+
+if (FORTRANRUNTIME_ENABLE_CUF)
+ add_subdirectory(CUDA)
+endif ()
diff --git a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
index d2c1600af8c631..bb1ea411cb7760 100644
--- a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "../../../runtime/terminator.h"
+#include "../../../lib/Runtime/terminator.h"
#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
diff --git a/FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt b/FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt
new file mode 100644
index 00000000000000..04321e65d733ad
--- /dev/null
+++ b/FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt
@@ -0,0 +1,19 @@
+#===-- 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_fortranruntime_unittest(FlangCufRuntimeTests
+ AllocatorCUF.cpp
+)
+
+target_link_libraries(FlangCufRuntimeTests
+ PRIVATE
+ CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
+ FortranRuntime
+)
+
+target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 4ee7c390f8ecd3..d589a809578035 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -474,6 +474,7 @@ if(build_runtimes)
if(LLVM_INCLUDE_TESTS)
foreach(dep FileCheck
clang
+ clang-offload-packager
flang-new
count
lld
>From 9f37b91f7843f2808e9e53df02d2cfa15a6355c4 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 9 Oct 2024 11:12:53 +0200
Subject: [PATCH 16/58] Do not compile former libDecimal for devices
---
FortranRuntime/lib/Runtime/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index 678edde7947eb6..1b8944d7641fab 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -10,8 +10,6 @@ include(AddFortranOffloadRuntime)
# List of files that are buildable for all devices.
set(supported_sources
- ../Common/binary-to-decimal.cpp
- ../Common/decimal-to-binary.cpp
ISO_Fortran_binding.cpp
allocator-registry.cpp
allocatable.cpp
@@ -67,6 +65,8 @@ set(supported_sources
# List of source not used for GPU offloading.
set(host_sources
+ ../Common/binary-to-decimal.cpp
+ ../Common/decimal-to-binary.cpp
command.cpp
complex-powi.cpp
complex-reduction.c
>From 7123f2cc4d0d70e8e90871323b7901ad7380cc8c Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 11 Oct 2024 00:29:35 +0200
Subject: [PATCH 17/58] Undo leftover change of moving module_files to
FortranRuntime
---
llvm/runtimes/CMakeLists.txt | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index d589a809578035..80f1cf5d6b6ea6 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -513,9 +513,17 @@ if(build_runtimes)
endif()
if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
- if (LLVM_TOOL_FLANG_BUILD AND "FortranRuntime" IN_LIST LLVM_ENABLE_PROJECTS)
- set(enable_fortran ENABLE_FORTRAN)
- endif ()
+ if (${LLVM_TOOL_FLANG_BUILD})
+ message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
+ set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
+ set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
+ # TODO: This is a workaround until flang becomes a first-class project
+ # in llvm/CMakeList.txt. Until then, this line ensures that flang-new is
+ # built before "openmp" is built as a runtime project. Besides "flang-new"
+ # to build the compiler, we also need to add "module_files" to make sure
+ # that all .mod files are also properly build.
+ list(APPEND extra_deps "flang-new" "module_files")
+ endif()
foreach(dep opt llvm-link llvm-extract clang clang-offload-packager)
if(TARGET ${dep})
list(APPEND extra_deps ${dep})
>From cc21ca919551164acb87553f35ec76a00b095605 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 15 Oct 2024 14:24:49 +0200
Subject: [PATCH 18/58] Merge 'keep common files in flang/'
---
FortranRuntime/cmake/config.h.cmake.in | 14 +--
.../Runtime/allocator-registry.h | 11 +-
.../Runtime/array-constructor.h | 48 +++++++
.../Runtime/descriptor.h | 22 +---
.../FortranRuntime/Runtime/io-api-funcs.h | 39 ++++++
.../FortranRuntime/Runtime/iostat-funcs.h | 23 ++++
.../Runtime/memory.h | 2 +-
.../Runtime/type-code.h | 2 +-
.../include/flang/Runtime/array-constructor.h | 118 ------------------
FortranRuntime/lib/Runtime/CMakeLists.txt | 4 +-
FortranRuntime/lib/Runtime/CUDA/allocator.cpp | 6 +-
.../lib/Runtime/CUDA/descriptor.cpp | 4 +-
.../lib/Runtime/Float128Math/math-entries.h | 4 +-
.../lib/Runtime/ISO_Fortran_binding.cpp | 6 +-
FortranRuntime/lib/Runtime/ISO_Fortran_util.h | 6 +-
FortranRuntime/lib/Runtime/allocatable.cpp | 10 +-
.../lib/Runtime/allocator-registry.cpp | 6 +-
.../lib/Runtime/array-constructor.cpp | 8 +-
FortranRuntime/lib/Runtime/assign.cpp | 2 +-
FortranRuntime/lib/Runtime/buffer.h | 4 +-
FortranRuntime/lib/Runtime/character.cpp | 6 +-
FortranRuntime/lib/Runtime/command.cpp | 2 +-
FortranRuntime/lib/Runtime/connection.h | 2 +-
FortranRuntime/lib/Runtime/copy.cpp | 4 +-
FortranRuntime/lib/Runtime/copy.h | 2 +-
FortranRuntime/lib/Runtime/derived-api.cpp | 2 +-
FortranRuntime/lib/Runtime/derived.cpp | 2 +-
FortranRuntime/lib/Runtime/descriptor-io.h | 8 +-
FortranRuntime/lib/Runtime/descriptor.cpp | 10 +-
FortranRuntime/lib/Runtime/dot-product.cpp | 8 +-
FortranRuntime/lib/Runtime/edit-input.cpp | 4 +-
FortranRuntime/lib/Runtime/edit-input.h | 2 +-
FortranRuntime/lib/Runtime/edit-output.cpp | 2 +-
FortranRuntime/lib/Runtime/edit-output.h | 4 +-
FortranRuntime/lib/Runtime/environment.cpp | 4 +-
FortranRuntime/lib/Runtime/execute.cpp | 2 +-
FortranRuntime/lib/Runtime/extensions.cpp | 8 +-
FortranRuntime/lib/Runtime/extrema.cpp | 2 +-
FortranRuntime/lib/Runtime/file.cpp | 4 +-
FortranRuntime/lib/Runtime/file.h | 4 +-
FortranRuntime/lib/Runtime/findloc.cpp | 2 +-
.../lib/Runtime/format-implementation.h | 6 +-
FortranRuntime/lib/Runtime/format.h | 2 +-
FortranRuntime/lib/Runtime/inquiry.cpp | 2 +-
FortranRuntime/lib/Runtime/internal-unit.cpp | 6 +-
FortranRuntime/lib/Runtime/internal-unit.h | 2 +-
FortranRuntime/lib/Runtime/io-api-common.h | 6 +-
FortranRuntime/lib/Runtime/io-api-minimal.cpp | 2 +-
FortranRuntime/lib/Runtime/io-api.cpp | 8 +-
FortranRuntime/lib/Runtime/io-error.cpp | 2 +-
FortranRuntime/lib/Runtime/io-error.h | 4 +-
FortranRuntime/lib/Runtime/io-stmt.cpp | 2 +-
FortranRuntime/lib/Runtime/io-stmt.h | 10 +-
FortranRuntime/lib/Runtime/iostat.cpp | 2 +-
.../lib/Runtime/matmul-transpose.cpp | 6 +-
FortranRuntime/lib/Runtime/matmul.cpp | 6 +-
FortranRuntime/lib/Runtime/memory.cpp | 4 +-
FortranRuntime/lib/Runtime/misc-intrinsic.cpp | 4 +-
FortranRuntime/lib/Runtime/namelist.cpp | 2 +-
FortranRuntime/lib/Runtime/namelist.h | 2 +-
.../lib/Runtime/numeric-templates.h | 4 +-
FortranRuntime/lib/Runtime/numeric.cpp | 2 +-
FortranRuntime/lib/Runtime/product.cpp | 2 +-
FortranRuntime/lib/Runtime/random-templates.h | 4 +-
FortranRuntime/lib/Runtime/random.cpp | 8 +-
FortranRuntime/lib/Runtime/reduce.cpp | 2 +-
.../lib/Runtime/reduction-templates.h | 4 +-
FortranRuntime/lib/Runtime/reduction.cpp | 2 +-
FortranRuntime/lib/Runtime/stack.h | 2 +-
FortranRuntime/lib/Runtime/stat.cpp | 2 +-
FortranRuntime/lib/Runtime/stat.h | 2 +-
FortranRuntime/lib/Runtime/sum.cpp | 2 +-
FortranRuntime/lib/Runtime/support.cpp | 2 +-
.../lib/Runtime/temporary-stack.cpp | 6 +-
FortranRuntime/lib/Runtime/time-intrinsic.cpp | 4 +-
FortranRuntime/lib/Runtime/tools.h | 8 +-
.../lib/Runtime/transformational.cpp | 4 +-
FortranRuntime/lib/Runtime/type-code.cpp | 2 +-
FortranRuntime/lib/Runtime/type-info.cpp | 10 +-
FortranRuntime/lib/Runtime/type-info.h | 4 +-
FortranRuntime/lib/Runtime/unit-map.h | 4 +-
FortranRuntime/lib/Runtime/unit.cpp | 4 +-
FortranRuntime/lib/Runtime/unit.h | 6 +-
FortranRuntime/lib/Runtime/utf.cpp | 4 +-
FortranRuntime/lib/Testing/CMakeLists.txt | 7 +-
FortranRuntime/test/lit.cfg.py | 2 +-
FortranRuntime/test/lit.site.cfg.py.in | 1 +
FortranRuntime/unittests/CMakeLists.txt | 2 -
.../unittests/Evaluate/CMakeLists.txt | 4 +-
.../Evaluate/ISO-Fortran-binding.cpp | 5 +-
FortranRuntime/unittests/Evaluate/reshape.cpp | 2 +-
.../unittests/Runtime/AccessTest.cpp | 2 +-
.../unittests/Runtime/Allocatable.cpp | 2 +-
.../unittests/Runtime/ArrayConstructor.cpp | 10 +-
.../unittests/Runtime/CUDA/AllocatorCUF.cpp | 12 +-
.../unittests/Runtime/CharacterTest.cpp | 2 +-
.../unittests/Runtime/CommandTest.cpp | 6 +-
FortranRuntime/unittests/Runtime/Derived.cpp | 6 +-
.../unittests/Runtime/ExternalIOTest.cpp | 6 +-
FortranRuntime/unittests/Runtime/Inquiry.cpp | 4 +-
.../unittests/Runtime/ListInputTest.cpp | 6 +-
.../unittests/Runtime/LogicalFormatTest.cpp | 4 +-
FortranRuntime/unittests/Runtime/Matmul.cpp | 8 +-
.../unittests/Runtime/MatmulTranspose.cpp | 8 +-
.../unittests/Runtime/MiscIntrinsic.cpp | 8 +-
FortranRuntime/unittests/Runtime/Namelist.cpp | 4 +-
FortranRuntime/unittests/Runtime/Numeric.cpp | 2 +-
.../unittests/Runtime/NumericalFormatTest.cpp | 4 +-
FortranRuntime/unittests/Runtime/Pointer.cpp | 4 +-
FortranRuntime/unittests/Runtime/Random.cpp | 6 +-
.../unittests/Runtime/Reduction.cpp | 8 +-
.../unittests/Runtime/RuntimeCrashTest.cpp | 4 +-
FortranRuntime/unittests/Runtime/Stop.cpp | 2 +-
FortranRuntime/unittests/Runtime/Support.cpp | 4 +-
.../unittests/Runtime/TemporaryStack.cpp | 8 +-
FortranRuntime/unittests/Runtime/Time.cpp | 2 +-
.../unittests/Runtime/Transformational.cpp | 6 +-
FortranRuntime/unittests/Runtime/tools.h | 6 +-
.../include/flang/Common/Fortran-consts.h | 0
.../Common/ISO_Fortran_binding_wrapper.h | 2 +-
flang/include/flang/Common/README.md | 25 ++++
.../include/flang/Common/api-attrs.h | 11 +-
.../flang/Common/binary-floating-point.h | 0
.../flang/Common/bit-population-count.h | 2 +-
.../include/flang/Common/constexpr-bitset.h | 2 +-
.../include/flang/Common/decimal.h | 0
.../include/flang/Common/enum-class.h | 2 +-
.../include/flang/Common/enum-set.h | 2 +-
.../include/flang/Common/fast-int-set.h | 10 +-
.../include/flang/Common/float128.h | 2 +-
.../include/flang/Common/format.h | 2 +-
.../include/flang/Common/idioms.h | 2 +-
.../flang/Common/leading-zero-bit-count.h | 2 +-
.../include/flang/Common/optional.h | 6 +-
.../include/flang/Common/real.h | 2 +-
.../include/flang/Common/reference-wrapper.h | 6 +-
.../include/flang/Common/restorer.h | 4 +-
.../include/flang/Common/target-rounding.h | 0
.../include/flang/Common/uint128.h | 4 +-
.../include/flang/Common/variant.h | 6 +-
.../include/flang/Common/visit.h | 4 +-
.../include/flang/Common/windows-include.h | 2 +-
flang/include/flang/ISO_Fortran_binding.h | 2 +-
flang/include/flang/Lower/Allocatable.h | 2 +-
.../flang/Optimizer/Builder/IntrinsicCall.h | 1 -
.../flang/Optimizer/Builder/MutableBox.h | 2 +-
.../flang/Optimizer/CodeGen/DescriptorModel.h | 2 +-
.../include/flang/Runtime/CUDA/allocator.h | 4 +-
.../include/flang/Runtime/CUDA/descriptor.h | 4 +-
flang/include/flang/Runtime/README.md | 27 ++++
.../include/flang/Runtime/allocatable.h | 7 +-
.../flang/Runtime/allocator-registry-consts.h | 20 +++
.../flang/Runtime/array-constructor-consts.h | 54 ++++++++
.../include/flang/Runtime/assign.h | 2 +-
.../include/flang/Runtime/c-or-cpp.h | 2 +-
.../include/flang/Runtime/character.h | 2 +-
.../include/flang/Runtime/command.h | 2 +-
.../include/flang/Runtime/cpp-type.h | 2 +-
.../include/flang/Runtime/derived-api.h | 2 +-
.../include/flang/Runtime/descriptor-consts.h | 73 +++++++++++
.../include/flang/Runtime/entry-names.h | 11 +-
.../include/flang/Runtime/exceptions.h | 4 +-
.../include/flang/Runtime/execute.h | 4 +-
.../include/flang/Runtime/extensions.h | 2 +-
.../flang/Runtime/freestanding-tools.h | 2 +-
.../include/flang/Runtime/inquiry.h | 4 +-
.../include/flang/Runtime/io-api.h | 7 +-
.../include/flang/Runtime/iostat.h | 6 +-
.../include/flang/Runtime}/magic-numbers.h | 6 +-
.../include/flang/Runtime/main.h | 2 +-
.../flang/Runtime/matmul-instances.inc | 0
.../include/flang/Runtime/matmul-transpose.h | 2 +-
.../include/flang/Runtime/matmul.h | 2 +-
.../include/flang/Runtime/misc-intrinsic.h | 2 +-
.../include/flang/Runtime/numeric.h | 2 +-
.../include/flang/Runtime/pointer.h | 6 +-
.../include/flang/Runtime/ragged.h | 4 +-
.../include/flang/Runtime/random.h | 0
.../include/flang/Runtime/reduce.h | 2 +-
.../include/flang/Runtime/reduction.h | 2 +-
.../include/flang/Runtime/stop.h | 2 +-
.../include/flang/Runtime/support.h | 2 +-
.../include/flang/Runtime/temporary-stack.h | 2 +-
.../include/flang/Runtime/time-intrinsic.h | 2 +-
.../include/flang/Runtime/transformational.h | 2 +-
.../include/flang/Support/Fortran-features.h | 6 +-
flang/include/flang/Support/Fortran.h | 8 +-
flang/include/flang/Support/MathOptionsBase.h | 6 +-
flang/include/flang/Support/Version.h | 6 +-
flang/include/flang/Support/default-kinds.h | 6 +-
flang/include/flang/Support/indirection.h | 6 +-
flang/include/flang/Support/interval.h | 6 +-
flang/include/flang/Support/template.h | 6 +-
flang/include/flang/Support/unwrap.h | 6 +-
flang/include/flang/Testing/README.md | 25 ++++
.../include/flang/Testing/fp-testing.h | 0
.../include/flang/Testing/testing.h | 0
flang/lib/Common/CMakeLists.txt | 6 +-
flang/lib/Common/README.md | 25 ++++
.../lib/Common/big-radix-floating-point.h | 0
.../lib/Common/binary-to-decimal.cpp | 0
.../lib/Common/decimal-to-binary.cpp | 0
flang/lib/Evaluate/fold-logical.cpp | 2 +-
flang/lib/Lower/ConvertVariable.cpp | 2 +-
.../Builder/Runtime/ArrayConstructor.cpp | 6 +-
flang/lib/Optimizer/CodeGen/CodeGen.cpp | 18 ++-
flang/lib/Semantics/compute-offsets.cpp | 8 +-
flang/lib/Testing/CMakeLists.txt | 20 +++
flang/lib/Testing/README.md | 25 ++++
.../lib/Testing/fp-testing.cpp | 0
.../lib/Testing/testing.cpp | 0
flang/module/__fortran_builtins.f90 | 2 +-
flang/module/__fortran_ieee_exceptions.f90 | 2 +-
flang/module/ieee_arithmetic.f90 | 2 +-
flang/module/iso_fortran_env.f90 | 2 +-
.../unittests/Common/CMakeLists.txt | 0
.../unittests/Common/FastIntSetTest.cpp | 4 +-
.../unittests/Decimal/CMakeLists.txt | 0
.../unittests/Decimal/quick-sanity-test.cpp | 8 --
.../unittests/Decimal/thorough-test.cpp | 8 --
flang/unittests/Evaluate/CMakeLists.txt | 4 +-
.../Builder/Runtime/AllocatableTest.cpp | 2 +-
222 files changed, 823 insertions(+), 554 deletions(-)
rename FortranRuntime/include/{flang => FortranRuntime}/Runtime/allocator-registry.h (82%)
create mode 100644 FortranRuntime/include/FortranRuntime/Runtime/array-constructor.h
rename FortranRuntime/include/{flang => FortranRuntime}/Runtime/descriptor.h (96%)
create mode 100644 FortranRuntime/include/FortranRuntime/Runtime/io-api-funcs.h
create mode 100644 FortranRuntime/include/FortranRuntime/Runtime/iostat-funcs.h
rename FortranRuntime/include/{flang => FortranRuntime}/Runtime/memory.h (98%)
rename FortranRuntime/include/{flang => FortranRuntime}/Runtime/type-code.h (97%)
delete mode 100644 FortranRuntime/include/flang/Runtime/array-constructor.h
rename {FortranRuntime => flang}/include/flang/Common/Fortran-consts.h (100%)
rename {FortranRuntime => flang}/include/flang/Common/ISO_Fortran_binding_wrapper.h (97%)
create mode 100644 flang/include/flang/Common/README.md
rename {FortranRuntime => flang}/include/flang/Common/api-attrs.h (97%)
rename {FortranRuntime => flang}/include/flang/Common/binary-floating-point.h (100%)
rename {FortranRuntime => flang}/include/flang/Common/bit-population-count.h (98%)
rename {FortranRuntime => flang}/include/flang/Common/constexpr-bitset.h (98%)
rename {FortranRuntime => flang}/include/flang/Common/decimal.h (100%)
rename {FortranRuntime => flang}/include/flang/Common/enum-class.h (98%)
rename {FortranRuntime => flang}/include/flang/Common/enum-set.h (99%)
rename {FortranRuntime => flang}/include/flang/Common/fast-int-set.h (95%)
rename {FortranRuntime => flang}/include/flang/Common/float128.h (96%)
rename {FortranRuntime => flang}/include/flang/Common/format.h (99%)
rename {FortranRuntime => flang}/include/flang/Common/idioms.h (99%)
rename {FortranRuntime => flang}/include/flang/Common/leading-zero-bit-count.h (98%)
rename {FortranRuntime => flang}/include/flang/Common/optional.h (98%)
rename {FortranRuntime => flang}/include/flang/Common/real.h (99%)
rename {FortranRuntime => flang}/include/flang/Common/reference-wrapper.h (96%)
rename {FortranRuntime => flang}/include/flang/Common/restorer.h (97%)
rename {FortranRuntime => flang}/include/flang/Common/target-rounding.h (100%)
rename {FortranRuntime => flang}/include/flang/Common/uint128.h (99%)
rename {FortranRuntime => flang}/include/flang/Common/variant.h (89%)
rename {FortranRuntime => flang}/include/flang/Common/visit.h (98%)
rename {FortranRuntime => flang}/include/flang/Common/windows-include.h (93%)
rename {FortranRuntime => flang}/include/flang/Runtime/CUDA/allocator.h (93%)
rename {FortranRuntime => flang}/include/flang/Runtime/CUDA/descriptor.h (91%)
create mode 100644 flang/include/flang/Runtime/README.md
rename {FortranRuntime => flang}/include/flang/Runtime/allocatable.h (97%)
create mode 100644 flang/include/flang/Runtime/allocator-registry-consts.h
create mode 100644 flang/include/flang/Runtime/array-constructor-consts.h
rename {FortranRuntime => flang}/include/flang/Runtime/assign.h (98%)
rename {FortranRuntime => flang}/include/flang/Runtime/c-or-cpp.h (95%)
rename {FortranRuntime => flang}/include/flang/Runtime/character.h (99%)
rename {FortranRuntime => flang}/include/flang/Runtime/command.h (98%)
rename {FortranRuntime => flang}/include/flang/Runtime/cpp-type.h (98%)
rename {FortranRuntime => flang}/include/flang/Runtime/derived-api.h (98%)
create mode 100644 flang/include/flang/Runtime/descriptor-consts.h
rename {FortranRuntime => flang}/include/flang/Runtime/entry-names.h (89%)
rename {FortranRuntime => flang}/include/flang/Runtime/exceptions.h (86%)
rename {FortranRuntime => flang}/include/flang/Runtime/execute.h (89%)
rename {FortranRuntime => flang}/include/flang/Runtime/extensions.h (97%)
rename {FortranRuntime => flang}/include/flang/Runtime/freestanding-tools.h (99%)
rename {FortranRuntime => flang}/include/flang/Runtime/inquiry.h (91%)
rename {FortranRuntime => flang}/include/flang/Runtime/io-api.h (98%)
rename {FortranRuntime => flang}/include/flang/Runtime/iostat.h (96%)
rename {FortranRuntime/include/flang/Common => flang/include/flang/Runtime}/magic-numbers.h (98%)
rename {FortranRuntime => flang}/include/flang/Runtime/main.h (95%)
rename {FortranRuntime => flang}/include/flang/Runtime/matmul-instances.inc (100%)
rename {FortranRuntime => flang}/include/flang/Runtime/matmul-transpose.h (97%)
rename {FortranRuntime => flang}/include/flang/Runtime/matmul.h (97%)
rename {FortranRuntime => flang}/include/flang/Runtime/misc-intrinsic.h (95%)
rename {FortranRuntime => flang}/include/flang/Runtime/numeric.h (99%)
rename {FortranRuntime => flang}/include/flang/Runtime/pointer.h (97%)
rename {FortranRuntime => flang}/include/flang/Runtime/ragged.h (96%)
rename {FortranRuntime => flang}/include/flang/Runtime/random.h (100%)
rename {FortranRuntime => flang}/include/flang/Runtime/reduce.h (99%)
rename {FortranRuntime => flang}/include/flang/Runtime/reduction.h (99%)
rename {FortranRuntime => flang}/include/flang/Runtime/stop.h (97%)
rename {FortranRuntime => flang}/include/flang/Runtime/support.h (97%)
rename {FortranRuntime => flang}/include/flang/Runtime/temporary-stack.h (98%)
rename {FortranRuntime => flang}/include/flang/Runtime/time-intrinsic.h (97%)
rename {FortranRuntime => flang}/include/flang/Runtime/transformational.h (99%)
create mode 100644 flang/include/flang/Testing/README.md
rename {FortranRuntime => flang}/include/flang/Testing/fp-testing.h (100%)
rename {FortranRuntime => flang}/include/flang/Testing/testing.h (100%)
create mode 100644 flang/lib/Common/README.md
rename {FortranRuntime => flang}/lib/Common/big-radix-floating-point.h (100%)
rename {FortranRuntime => flang}/lib/Common/binary-to-decimal.cpp (100%)
rename {FortranRuntime => flang}/lib/Common/decimal-to-binary.cpp (100%)
create mode 100644 flang/lib/Testing/CMakeLists.txt
create mode 100644 flang/lib/Testing/README.md
rename {FortranRuntime => flang}/lib/Testing/fp-testing.cpp (100%)
rename {FortranRuntime => flang}/lib/Testing/testing.cpp (100%)
rename {FortranRuntime => flang}/unittests/Common/CMakeLists.txt (100%)
rename {FortranRuntime => flang}/unittests/Common/FastIntSetTest.cpp (97%)
rename {FortranRuntime => flang}/unittests/Decimal/CMakeLists.txt (100%)
rename {FortranRuntime => flang}/unittests/Decimal/quick-sanity-test.cpp (92%)
rename {FortranRuntime => flang}/unittests/Decimal/thorough-test.cpp (86%)
diff --git a/FortranRuntime/cmake/config.h.cmake.in b/FortranRuntime/cmake/config.h.cmake.in
index 4fa31c7e89ad7b..8a4668b90addda 100644
--- a/FortranRuntime/cmake/config.h.cmake.in
+++ b/FortranRuntime/cmake/config.h.cmake.in
@@ -1,10 +1,10 @@
-//===-- cmake/config.h.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
-//
-//===----------------------------------------------------------------------===//
+/*===-- 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
diff --git a/FortranRuntime/include/flang/Runtime/allocator-registry.h b/FortranRuntime/include/FortranRuntime/Runtime/allocator-registry.h
similarity index 82%
rename from FortranRuntime/include/flang/Runtime/allocator-registry.h
rename to FortranRuntime/include/FortranRuntime/Runtime/allocator-registry.h
index 4e7d9bcedfb375..30a583b88c083e 100644
--- a/FortranRuntime/include/flang/Runtime/allocator-registry.h
+++ b/FortranRuntime/include/FortranRuntime/Runtime/allocator-registry.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/allocator-registry.h --------------*- C++ -*-===//
+//===-- include/FortranRuntime/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.
@@ -10,17 +10,10 @@
#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
#include "flang/Common/api-attrs.h"
+#include "flang/Runtime/allocator-registry-consts.h"
#include <cstdlib>
#include <vector>
-static constexpr unsigned kDefaultAllocator = 0;
-
-// Allocator used for CUF
-static constexpr unsigned kPinnedAllocatorPos = 1;
-static constexpr unsigned kDeviceAllocatorPos = 2;
-static constexpr unsigned kManagedAllocatorPos = 3;
-static constexpr unsigned kUnifiedAllocatorPos = 4;
-
#define MAX_ALLOCATOR 7 // 3 bits are reserved in the descriptor.
namespace Fortran::runtime {
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/array-constructor.h b/FortranRuntime/include/FortranRuntime/Runtime/array-constructor.h
new file mode 100644
index 00000000000000..314d5e56599cd3
--- /dev/null
+++ b/FortranRuntime/include/FortranRuntime/Runtime/array-constructor.h
@@ -0,0 +1,48 @@
+//===-- include/FortranRuntime/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.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// External APIs to create temporary storage for array constructors when their
+// final extents or length parameters cannot be pre-computed.
+
+#ifndef FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
+#define FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
+
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang/Runtime/array-constructor-consts.h"
+#include "flang/Runtime/entry-names.h"
+#include <cstdint>
+
+namespace Fortran::runtime {
+
+// Runtime data structure to hold information about the storage of
+// an array constructor being constructed.
+struct ArrayConstructorVector {
+ RT_API_ATTRS ArrayConstructorVector(class Descriptor &to,
+ SubscriptValue nextValuePosition, SubscriptValue actualAllocationSize,
+ const char *sourceFile, int sourceLine, bool useValueLengthParameters)
+ : to{to}, nextValuePosition{nextValuePosition},
+ actualAllocationSize{actualAllocationSize}, sourceFile{sourceFile},
+ sourceLine{sourceLine},
+ useValueLengthParameters_{useValueLengthParameters} {}
+
+ RT_API_ATTRS bool useValueLengthParameters() const {
+ return useValueLengthParameters_;
+ }
+
+ class Descriptor &to;
+ SubscriptValue nextValuePosition;
+ SubscriptValue actualAllocationSize;
+ const char *sourceFile;
+ int sourceLine;
+
+private:
+ unsigned char useValueLengthParameters_ : 1;
+};
+
+} // namespace Fortran::runtime
+#endif /* FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/descriptor.h b/FortranRuntime/include/FortranRuntime/Runtime/descriptor.h
similarity index 96%
rename from FortranRuntime/include/flang/Runtime/descriptor.h
rename to FortranRuntime/include/FortranRuntime/Runtime/descriptor.h
index 867f4d4ee29ac0..f79ad6b9637a4a 100644
--- a/FortranRuntime/include/flang/Runtime/descriptor.h
+++ b/FortranRuntime/include/FortranRuntime/Runtime/descriptor.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/descriptor.h ----------------------*- C++ -*-===//
+//===-- include/FortranRuntime/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.
@@ -18,9 +18,10 @@
// User C code is welcome to depend on that ISO_Fortran_binding.h file,
// but should never reference this internal header.
+#include "FortranRuntime/Runtime/memory.h"
+#include "FortranRuntime/Runtime/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
-#include "flang/Runtime/memory.h"
-#include "flang/Runtime/type-code.h"
+#include "flang/Runtime/descriptor-consts.h"
#include <algorithm>
#include <cassert>
#include <cinttypes>
@@ -28,14 +29,8 @@
#include <cstdio>
#include <cstring>
-namespace Fortran::runtime::typeInfo {
-using TypeParameterValue = std::int64_t;
-class DerivedType;
-} // namespace Fortran::runtime::typeInfo
-
namespace Fortran::runtime {
-using SubscriptValue = ISO::CFI_index_t;
class Terminator;
RT_VAR_GROUP_BEGIN
@@ -420,13 +415,6 @@ class Descriptor {
void Dump(FILE * = stdout) const;
-// Value of the addendum presence flag.
-#define _CFI_ADDENDUM_FLAG 1
-// Number of bits needed to be shifted when manipulating the allocator index.
-#define _CFI_ALLOCATOR_IDX_SHIFT 1
-// Allocator index mask.
-#define _CFI_ALLOCATOR_IDX_MASK 0b00001110
-
RT_API_ATTRS inline bool HasAddendum() const {
return raw_.extra & _CFI_ADDENDUM_FLAG;
}
@@ -464,6 +452,8 @@ class alignas(Descriptor) StaticDescriptor {
static constexpr bool hasAddendum{ADDENDUM || MAX_LEN_PARMS > 0};
static constexpr std::size_t byteSize{
Descriptor::SizeInBytes(maxRank, hasAddendum, maxLengthTypeParameters)};
+ static_assert(byteSize <=
+ MaxDescriptorSizeInBytes(maxRank, hasAddendum, maxLengthTypeParameters));
RT_OFFLOAD_VAR_GROUP_END
RT_API_ATTRS Descriptor &descriptor() {
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/io-api-funcs.h b/FortranRuntime/include/FortranRuntime/Runtime/io-api-funcs.h
new file mode 100644
index 00000000000000..516fe25784656c
--- /dev/null
+++ b/FortranRuntime/include/FortranRuntime/Runtime/io-api-funcs.h
@@ -0,0 +1,39 @@
+//===-- include/FortranRuntime/Runtime/io-api-funcs.h -----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Defines API between compiled code and I/O runtime library.
+
+#ifndef FORTRAN_RUNTIME_IO_API_FUNCS_H_
+#define FORTRAN_RUNTIME_IO_API_FUNCS_H_
+
+#include "flang/Common/uint128.h"
+#include "flang/Runtime/entry-names.h"
+#include "flang/Runtime/io-api.h"
+#include "flang/Runtime/iostat.h"
+#include "flang/Runtime/magic-numbers.h"
+#include <cinttypes>
+#include <cstddef>
+
+namespace Fortran::runtime {
+class Descriptor;
+} // namespace Fortran::runtime
+
+namespace Fortran::runtime::io {
+
+struct NonTbpDefinedIoTable;
+class NamelistGroup;
+class IoStatementState;
+using Cookie = IoStatementState *;
+using ExternalUnit = int;
+using AsynchronousId = int;
+
+RT_API_ATTRS const char *InquiryKeywordHashDecode(
+ char *buffer, std::size_t, InquiryKeywordHash);
+
+} // namespace Fortran::runtime::io
+#endif /* FORTRAN_RUNTIME_IO_API_FUNCS_H_ */
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/iostat-funcs.h b/FortranRuntime/include/FortranRuntime/Runtime/iostat-funcs.h
new file mode 100644
index 00000000000000..10906afb01673c
--- /dev/null
+++ b/FortranRuntime/include/FortranRuntime/Runtime/iostat-funcs.h
@@ -0,0 +1,23 @@
+//===-- include/FortranRuntime/Runtime/iostat-funcs.h -----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Defines the values returned by the runtime for IOSTAT= specifiers
+// on I/O statements.
+
+#ifndef FORTRAN_RUNTIME_IOSTAT_FUNCS_H_
+#define FORTRAN_RUNTIME_IOSTAT_FUNCS_H_
+
+#include "flang/Common/api-attrs.h"
+#include "flang/Runtime/iostat.h"
+
+namespace Fortran::runtime::io {
+
+RT_API_ATTRS const char *IostatErrorString(int);
+
+} // namespace Fortran::runtime::io
+#endif /* FORTRAN_RUNTIME_IOSTAT_FUNCS_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/memory.h b/FortranRuntime/include/FortranRuntime/Runtime/memory.h
similarity index 98%
rename from FortranRuntime/include/flang/Runtime/memory.h
rename to FortranRuntime/include/FortranRuntime/Runtime/memory.h
index 84af4d7189c074..3e7fd2d9ea3e3b 100644
--- a/FortranRuntime/include/flang/Runtime/memory.h
+++ b/FortranRuntime/include/FortranRuntime/Runtime/memory.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/memory.h --------------------------*- C++ -*-===//
+//===-- include/FortranRuntime/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.
diff --git a/FortranRuntime/include/flang/Runtime/type-code.h b/FortranRuntime/include/FortranRuntime/Runtime/type-code.h
similarity index 97%
rename from FortranRuntime/include/flang/Runtime/type-code.h
rename to FortranRuntime/include/FortranRuntime/Runtime/type-code.h
index ec359f25dbdd12..92ff593410c12c 100644
--- a/FortranRuntime/include/flang/Runtime/type-code.h
+++ b/FortranRuntime/include/FortranRuntime/Runtime/type-code.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/type-code.h -----------------------*- C++ -*-===//
+//===-- include/FortranRuntime/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.
diff --git a/FortranRuntime/include/flang/Runtime/array-constructor.h b/FortranRuntime/include/flang/Runtime/array-constructor.h
deleted file mode 100644
index 82367756f5dc79..00000000000000
--- a/FortranRuntime/include/flang/Runtime/array-constructor.h
+++ /dev/null
@@ -1,118 +0,0 @@
-//===-- include/flang/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.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// External APIs to create temporary storage for array constructors when their
-// final extents or length parameters cannot be pre-computed.
-
-#ifndef FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
-#define FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
-
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/entry-names.h"
-#include <cstdint>
-
-namespace Fortran::runtime {
-
-// Runtime data structure to hold information about the storage of
-// an array constructor being constructed.
-struct ArrayConstructorVector {
- RT_API_ATTRS ArrayConstructorVector(class Descriptor &to,
- SubscriptValue nextValuePosition, SubscriptValue actualAllocationSize,
- const char *sourceFile, int sourceLine, bool useValueLengthParameters)
- : to{to}, nextValuePosition{nextValuePosition},
- actualAllocationSize{actualAllocationSize}, sourceFile{sourceFile},
- sourceLine{sourceLine},
- useValueLengthParameters_{useValueLengthParameters} {}
-
- RT_API_ATTRS bool useValueLengthParameters() const {
- return useValueLengthParameters_;
- }
-
- class Descriptor &to;
- SubscriptValue nextValuePosition;
- SubscriptValue actualAllocationSize;
- const char *sourceFile;
- int sourceLine;
-
-private:
- unsigned char useValueLengthParameters_ : 1;
-};
-
-// This file defines an API to "push" an evaluated array constructor value
-// "from" into some storage "to" of an array constructor. It can be seen as a
-// form of std::vector::push_back() implementation for Fortran array
-// constructors. In the APIs and ArrayConstructorVector struct above:
-//
-// - "to" is a ranked-1 descriptor whose declared type is already set to the
-// array constructor derived type. It may be already allocated, even before the
-// first call to this API, or it may be unallocated. "to" extent is increased
-// every time a "from" is pushed past its current extent. At this end of the
-// API calls, its extent is the extent of the array constructor. If "to" is
-// unallocated and its extent is not null, it is assumed this is the final array
-// constructor extent value, and the first allocation already "reserves" storage
-// space accordingly to avoid reallocations.
-// - "from" is a scalar or array descriptor for the evaluated array
-// constructor value that must be copied into the storage of "to" at
-// "nextValuePosition".
-// - "useValueLengthParameters" must be set to true if the array constructor
-// has length parameters and no type spec. If it is true and "to" is
-// unallocated, "to" will take the length parameters of "from". If it is true
-// and "to" is an allocated character array constructor, it will be checked
-// that "from" length matches the one from "to". When it is false, the
-// character length must already be set in "to" before the first call to this
-// API and "from" character lengths are allowed to mismatch from "to".
-// - "nextValuePosition" is the zero based sequence position of "from" in the
-// array constructor. It is updated after this call by the number of "from"
-// elements. It should be set to zero by the caller of this API before the first
-// call.
-// - "actualAllocationSize" is the current allocation size of "to" storage. It
-// may be bigger than "to" extent for reallocation optimization purposes, but
-// should never be smaller, unless this is the first call and "to" is
-// unallocated. It is updated by the runtime after each successful allocation or
-// reallocation. It should be set to "to" extent if "to" is allocated before the
-// first call of this API, and can be left undefined otherwise.
-//
-// Note that this API can be used with "to" being a variable (that can be
-// discontiguous). This can be done when the variable is the left hand side of
-// an assignment from an array constructor as long as:
-// - none of the ac-value overlaps with the variable,
-// - this is an intrinsic assignment that is not a whole allocatable
-// assignment, *and* for a type that has no components requiring user defined
-// assignments,
-// - the variable is properly finalized before using this API if its need to,
-// - "useValueLengthParameters" should be set to false in this case, even if
-// the array constructor has no type-spec, since the variable may have a
-// different character length than the array constructor values.
-
-extern "C" {
-// API to initialize an ArrayConstructorVector before any values are pushed to
-// it. Inlined code is only expected to allocate the "ArrayConstructorVector"
-// class instance storage with sufficient size (using
-// "2*sizeof(ArrayConstructorVector)" on the host should be safe regardless of
-// the target the runtime is compiled for). This avoids the need for the runtime
-// to maintain a state, or to use dynamic allocation for it. "vectorClassSize"
-// is used to validate that lowering allocated enough space for it.
-void RTDECL(InitArrayConstructorVector)(ArrayConstructorVector &vector,
- Descriptor &to, bool useValueLengthParameters, int vectorClassSize,
- const char *sourceFile = nullptr, int sourceLine = 0);
-
-// Generic API to push any kind of entity into the array constructor (any
-// Fortran type and any rank).
-void RTDECL(PushArrayConstructorValue)(
- ArrayConstructorVector &vector, const Descriptor &from);
-
-// API to push scalar array constructor value of:
-// - a numerical or logical type,
-// - or a derived type that has no length parameters, and no allocatable
-// component (that would require deep copies).
-// It requires no descriptor for the value that is passed via its base address.
-void RTDECL(PushArrayConstructorSimpleScalar)(
- ArrayConstructorVector &vector, void *from);
-} // extern "C"
-} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_ */
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/FortranRuntime/lib/Runtime/CMakeLists.txt
index 1b8944d7641fab..1db5520d5eaedf 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/FortranRuntime/lib/Runtime/CMakeLists.txt
@@ -65,8 +65,8 @@ set(supported_sources
# List of source not used for GPU offloading.
set(host_sources
- ../Common/binary-to-decimal.cpp
- ../Common/decimal-to-binary.cpp
+ ${FLANG_SOURCE_DIR}/lib/Common/binary-to-decimal.cpp
+ ${FLANG_SOURCE_DIR}/lib/Common/decimal-to-binary.cpp
command.cpp
complex-powi.cpp
complex-reduction.c
diff --git a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
index 6401faede9fdf5..c9d62f6ea8f3bf 100644
--- a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
+++ b/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/CUDA/allocator.h"
+#include "FortranRuntime/Runtime/CUDA/allocator.h"
+#include "FortranRuntime/Runtime/allocator-registry.h"
#include "../derived.h"
#include "../stat.h"
#include "../terminator.h"
#include "../type-info.h"
-#include "flang/Common/ISO_Fortran_binding_wrapper.h"
-#include "flang/Runtime/allocator-registry.h"
+#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Support/Fortran.h"
#include "cuda_runtime.h"
diff --git a/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp b/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
index 9664fea4ebc78a..94b5feca4ce4dc 100644
--- a/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
+++ b/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/CUDA/descriptor.h"
-#include "flang/Runtime/CUDA/allocator.h"
+#include "FortranRuntime/Runtime/CUDA/descriptor.h"
+#include "FortranRuntime/Runtime/CUDA/allocator.h"
namespace Fortran::runtime::cuda {
extern "C" {
diff --git a/FortranRuntime/lib/Runtime/Float128Math/math-entries.h b/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
index cb1e0130602260..1449000820f00e 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
+++ b/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
@@ -8,10 +8,10 @@
#ifndef FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
#define FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
-#include "flang/Common/float128.h"
-#include "flang/Runtime/entry-names.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Common/float128.h"
+#include "flang/Runtime/entry-names.h"
#include <cfloat>
#include <cmath>
#include <type_traits>
diff --git a/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
index 9711b2bcf49757..997226b08e96a6 100644
--- a/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
@@ -9,12 +9,12 @@
// Implements the required interoperability API from ISO_Fortran_binding.h
// as specified in section 18.5.5 of Fortran 2018.
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/type-code.h"
#include "ISO_Fortran_util.h"
+#include "terminator.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 "terminator.h"
#include <cstdlib>
namespace Fortran::ISO {
diff --git a/FortranRuntime/lib/Runtime/ISO_Fortran_util.h b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
index 7ab280733028af..e418266dddccc7 100644
--- a/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
+++ b/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
@@ -11,10 +11,10 @@
// Internal utils for establishing CFI_cdesc_t descriptors.
-#include "flang/Common/ISO_Fortran_binding_wrapper.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/type-code.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/type-code.h"
#include "terminator.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include <cstdlib>
namespace Fortran::ISO {
diff --git a/FortranRuntime/lib/Runtime/allocatable.cpp b/FortranRuntime/lib/Runtime/allocatable.cpp
index 8b6c1a4c1477eb..4a3b89f4879c12 100644
--- a/FortranRuntime/lib/Runtime/allocatable.cpp
+++ b/FortranRuntime/lib/Runtime/allocatable.cpp
@@ -7,14 +7,18 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/allocatable.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "assign-impl.h"
#include "derived.h"
-#include "flang/Common/ISO_Fortran_binding_wrapper.h"
-#include "flang/Runtime/assign.h"
-#include "flang/Runtime/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "type-info.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
+#include "flang/Runtime/assign.h"
+
+using Fortran::common::TypeCategory;
+
+
namespace Fortran::runtime {
extern "C" {
diff --git a/FortranRuntime/lib/Runtime/allocator-registry.cpp b/FortranRuntime/lib/Runtime/allocator-registry.cpp
index edd3685e83a820..17883e5c54870d 100644
--- a/FortranRuntime/lib/Runtime/allocator-registry.cpp
+++ b/FortranRuntime/lib/Runtime/allocator-registry.cpp
@@ -6,16 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/allocator-registry.h"
+#include "FortranRuntime/Runtime/allocator-registry.h"
#include "terminator.h"
namespace Fortran::runtime {
-#ifndef FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS AllocatorRegistry allocatorRegistry;
RT_OFFLOAD_VAR_GROUP_END
-#endif // FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
RT_API_ATTRS void AllocatorRegistry::Register(int pos, Allocator_t allocator) {
diff --git a/FortranRuntime/lib/Runtime/array-constructor.cpp b/FortranRuntime/lib/Runtime/array-constructor.cpp
index db57d4fc4c3f68..002dfba2c066f5 100644
--- a/FortranRuntime/lib/Runtime/array-constructor.cpp
+++ b/FortranRuntime/lib/Runtime/array-constructor.cpp
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/array-constructor.h"
+#include "FortranRuntime/Runtime/array-constructor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "derived.h"
-#include "flang/Runtime/allocatable.h"
-#include "flang/Runtime/assign.h"
-#include "flang/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "type-info.h"
+#include "flang/Runtime/allocatable.h"
+#include "flang/Runtime/assign.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/assign.cpp b/FortranRuntime/lib/Runtime/assign.cpp
index cc38e55e3a9e1e..3a1486ace928a2 100644
--- a/FortranRuntime/lib/Runtime/assign.cpp
+++ b/FortranRuntime/lib/Runtime/assign.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/assign.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "assign-impl.h"
#include "derived.h"
-#include "flang/Runtime/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/buffer.h b/FortranRuntime/lib/Runtime/buffer.h
index dd3c19fa14392f..52df0f10813c25 100644
--- a/FortranRuntime/lib/Runtime/buffer.h
+++ b/FortranRuntime/lib/Runtime/buffer.h
@@ -11,9 +11,9 @@
#ifndef FORTRAN_RUNTIME_BUFFER_H_
#define FORTRAN_RUNTIME_BUFFER_H_
-#include "flang/Runtime/freestanding-tools.h"
-#include "flang/Runtime/memory.h"
+#include "FortranRuntime/Runtime/memory.h"
#include "io-error.h"
+#include "flang/Runtime/freestanding-tools.h"
#include <algorithm>
#include <cinttypes>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/character.cpp b/FortranRuntime/lib/Runtime/character.cpp
index 32fc010c6c04dd..1f3edd6e80392e 100644
--- a/FortranRuntime/lib/Runtime/character.cpp
+++ b/FortranRuntime/lib/Runtime/character.cpp
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/character.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "terminator.h"
+#include "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 "terminator.h"
-#include "tools.h"
#include <algorithm>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/command.cpp b/FortranRuntime/lib/Runtime/command.cpp
index dc57758d4f7955..64b2e62461dd58 100644
--- a/FortranRuntime/lib/Runtime/command.cpp
+++ b/FortranRuntime/lib/Runtime/command.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/command.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "environment.h"
-#include "flang/Runtime/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/connection.h b/FortranRuntime/lib/Runtime/connection.h
index 92a3a9c3860a3e..e078bfb9f0f7e7 100644
--- a/FortranRuntime/lib/Runtime/connection.h
+++ b/FortranRuntime/lib/Runtime/connection.h
@@ -11,8 +11,8 @@
#ifndef FORTRAN_RUNTIME_CONNECTION_H_
#define FORTRAN_RUNTIME_CONNECTION_H_
-#include "flang/Common/optional.h"
#include "format.h"
+#include "flang/Common/optional.h"
#include <cinttypes>
namespace Fortran::runtime::io {
diff --git a/FortranRuntime/lib/Runtime/copy.cpp b/FortranRuntime/lib/Runtime/copy.cpp
index 39c7da45172a43..1049b925f68e5c 100644
--- a/FortranRuntime/lib/Runtime/copy.cpp
+++ b/FortranRuntime/lib/Runtime/copy.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "copy.h"
-#include "flang/Runtime/allocatable.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "stack.h"
#include "terminator.h"
#include "type-info.h"
+#include "flang/Runtime/allocatable.h"
#include <cstring>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/copy.h b/FortranRuntime/lib/Runtime/copy.h
index f2c5b41718b71c..3d179d0bec91a7 100644
--- a/FortranRuntime/lib/Runtime/copy.h
+++ b/FortranRuntime/lib/Runtime/copy.h
@@ -12,7 +12,7 @@
#ifndef FORTRAN_RUNTIME_COPY_H_
#define FORTRAN_RUNTIME_COPY_H_
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/derived-api.cpp b/FortranRuntime/lib/Runtime/derived-api.cpp
index 4b68cdbbed7b2c..176fc0849f25cf 100644
--- a/FortranRuntime/lib/Runtime/derived-api.cpp
+++ b/FortranRuntime/lib/Runtime/derived-api.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/derived-api.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "derived.h"
-#include "flang/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "type-info.h"
diff --git a/FortranRuntime/lib/Runtime/derived.cpp b/FortranRuntime/lib/Runtime/derived.cpp
index 52bf54d62c8599..cb2dca24bb4758 100644
--- a/FortranRuntime/lib/Runtime/derived.cpp
+++ b/FortranRuntime/lib/Runtime/derived.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "derived.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/descriptor-io.h b/FortranRuntime/lib/Runtime/descriptor-io.h
index 2ccad0cea70a29..30d1bd48457728 100644
--- a/FortranRuntime/lib/Runtime/descriptor-io.h
+++ b/FortranRuntime/lib/Runtime/descriptor-io.h
@@ -14,17 +14,17 @@
// some scalar I/O data transfer APIs could be changed to bypass their use
// of descriptors in the future for better efficiency.)
+#include "FortranRuntime/Runtime/descriptor.h"
#include "edit-input.h"
#include "edit-output.h"
-#include "flang/Common/optional.h"
-#include "flang/Common/uint128.h"
-#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
#include "io-stmt.h"
#include "namelist.h"
#include "terminator.h"
#include "type-info.h"
#include "unit.h"
+#include "flang/Common/optional.h"
+#include "flang/Common/uint128.h"
+#include "flang/Runtime/cpp-type.h"
namespace Fortran::runtime::io::descr {
template <typename A>
diff --git a/FortranRuntime/lib/Runtime/descriptor.cpp b/FortranRuntime/lib/Runtime/descriptor.cpp
index 6756134b06e7b1..96fd48eb6687a9 100644
--- a/FortranRuntime/lib/Runtime/descriptor.cpp
+++ b/FortranRuntime/lib/Runtime/descriptor.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/allocator-registry.h"
#include "ISO_Fortran_util.h"
#include "derived.h"
-#include "flang/Runtime/allocator-registry.h"
#include "memory.h"
#include "stat.h"
#include "terminator.h"
@@ -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/FortranRuntime/lib/Runtime/dot-product.cpp b/FortranRuntime/lib/Runtime/dot-product.cpp
index ab1cfa58ef3d02..2992cbb1f39ad6 100644
--- a/FortranRuntime/lib/Runtime/dot-product.cpp
+++ b/FortranRuntime/lib/Runtime/dot-product.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Common/float128.h"
-#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/reduction.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "float.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Common/float128.h"
+#include "flang/Runtime/cpp-type.h"
+#include "flang/Runtime/reduction.h"
#include <cfloat>
#include <cinttypes>
diff --git a/FortranRuntime/lib/Runtime/edit-input.cpp b/FortranRuntime/lib/Runtime/edit-input.cpp
index eaa9d0d7e641e7..6ebb0e7aca4ade 100644
--- a/FortranRuntime/lib/Runtime/edit-input.cpp
+++ b/FortranRuntime/lib/Runtime/edit-input.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "edit-input.h"
+#include "namelist.h"
+#include "utf.h"
#include "flang/Common/optional.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/freestanding-tools.h"
-#include "namelist.h"
-#include "utf.h"
#include <algorithm>
#include <cfenv>
diff --git a/FortranRuntime/lib/Runtime/edit-input.h b/FortranRuntime/lib/Runtime/edit-input.h
index 2eda81a6d4e11d..f88f6daa47be79 100644
--- a/FortranRuntime/lib/Runtime/edit-input.h
+++ b/FortranRuntime/lib/Runtime/edit-input.h
@@ -9,9 +9,9 @@
#ifndef FORTRAN_RUNTIME_EDIT_INPUT_H_
#define FORTRAN_RUNTIME_EDIT_INPUT_H_
-#include "flang/Common/decimal.h"
#include "format.h"
#include "io-stmt.h"
+#include "flang/Common/decimal.h"
namespace Fortran::runtime::io {
diff --git a/FortranRuntime/lib/Runtime/edit-output.cpp b/FortranRuntime/lib/Runtime/edit-output.cpp
index 1fab7db6d3b187..ccaf8085f016fd 100644
--- a/FortranRuntime/lib/Runtime/edit-output.cpp
+++ b/FortranRuntime/lib/Runtime/edit-output.cpp
@@ -8,9 +8,9 @@
#include "edit-output.h"
#include "emit-encoded.h"
+#include "utf.h"
#include "flang/Common/real.h"
#include "flang/Common/uint128.h"
-#include "utf.h"
#include <algorithm>
namespace Fortran::runtime::io {
diff --git a/FortranRuntime/lib/Runtime/edit-output.h b/FortranRuntime/lib/Runtime/edit-output.h
index cb25b68a35f05b..7e6c6cdedde3ac 100644
--- a/FortranRuntime/lib/Runtime/edit-output.h
+++ b/FortranRuntime/lib/Runtime/edit-output.h
@@ -18,10 +18,10 @@
// Drives the same fast binary-to-decimal formatting templates used
// in the f18 front-end.
-#include "flang/Common/decimal.h"
-#include "flang/Common/uint128.h"
#include "format.h"
#include "io-stmt.h"
+#include "flang/Common/decimal.h"
+#include "flang/Common/uint128.h"
namespace Fortran::runtime::io {
diff --git a/FortranRuntime/lib/Runtime/environment.cpp b/FortranRuntime/lib/Runtime/environment.cpp
index 9cbb198dd9141c..272914877988a5 100644
--- a/FortranRuntime/lib/Runtime/environment.cpp
+++ b/FortranRuntime/lib/Runtime/environment.cpp
@@ -23,11 +23,11 @@ extern char **environ;
namespace Fortran::runtime {
-#ifndef FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS ExecutionEnvironment executionEnvironment;
RT_OFFLOAD_VAR_GROUP_END
-#endif // FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
static void SetEnvironmentDefaults(const EnvironmentDefaultList *envDefaults) {
if (!envDefaults) {
diff --git a/FortranRuntime/lib/Runtime/execute.cpp b/FortranRuntime/lib/Runtime/execute.cpp
index 54f28d052873b4..b333c61c8a59f4 100644
--- a/FortranRuntime/lib/Runtime/execute.cpp
+++ b/FortranRuntime/lib/Runtime/execute.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/execute.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "environment.h"
-#include "flang/Runtime/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/extensions.cpp b/FortranRuntime/lib/Runtime/extensions.cpp
index 94bfa3059e6b45..bb25fe6ee9d886 100644
--- a/FortranRuntime/lib/Runtime/extensions.cpp
+++ b/FortranRuntime/lib/Runtime/extensions.cpp
@@ -10,12 +10,12 @@
// extensions that will eventually be implemented in Fortran.
#include "flang/Runtime/extensions.h"
-#include "flang/Runtime/command.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/entry-names.h"
-#include "flang/Runtime/io-api.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Runtime/command.h"
+#include "flang/Runtime/entry-names.h"
#include <chrono>
#include <cstring>
#include <ctime>
diff --git a/FortranRuntime/lib/Runtime/extrema.cpp b/FortranRuntime/lib/Runtime/extrema.cpp
index 0809cb1d5f2ae2..be9da63d7bd6b8 100644
--- a/FortranRuntime/lib/Runtime/extrema.cpp
+++ b/FortranRuntime/lib/Runtime/extrema.cpp
@@ -10,10 +10,10 @@
// and shapes and (for MAXLOC & MINLOC) result integer kinds. Also implements
// NORM2 using common infrastructure.
+#include "reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
-#include "reduction-templates.h"
#include <algorithm>
#include <cfloat>
#include <cinttypes>
diff --git a/FortranRuntime/lib/Runtime/file.cpp b/FortranRuntime/lib/Runtime/file.cpp
index 80829d844881e8..de52dafd12df9a 100644
--- a/FortranRuntime/lib/Runtime/file.cpp
+++ b/FortranRuntime/lib/Runtime/file.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "file.h"
+#include "FortranRuntime/Runtime/memory.h"
#include "tools.h"
-#include "flang/Common/magic-numbers.h"
-#include "flang/Runtime/memory.h"
+#include "flang/Runtime/magic-numbers.h"
#include <algorithm>
#include <cerrno>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/file.h b/FortranRuntime/lib/Runtime/file.h
index 66d62756634b24..60ddf2a2741610 100644
--- a/FortranRuntime/lib/Runtime/file.h
+++ b/FortranRuntime/lib/Runtime/file.h
@@ -11,9 +11,9 @@
#ifndef FORTRAN_RUNTIME_FILE_H_
#define FORTRAN_RUNTIME_FILE_H_
-#include "flang/Common/optional.h"
-#include "flang/Runtime/memory.h"
+#include "FortranRuntime/Runtime/memory.h"
#include "io-error.h"
+#include "flang/Common/optional.h"
#include <cinttypes>
namespace Fortran::runtime::io {
diff --git a/FortranRuntime/lib/Runtime/findloc.cpp b/FortranRuntime/lib/Runtime/findloc.cpp
index 47c51fbcef4939..da5fe0c0a0a467 100644
--- a/FortranRuntime/lib/Runtime/findloc.cpp
+++ b/FortranRuntime/lib/Runtime/findloc.cpp
@@ -9,9 +9,9 @@
// Implements FINDLOC for all required operand types and shapes and result
// integer kinds.
+#include "reduction-templates.h"
#include "flang/Runtime/character.h"
#include "flang/Runtime/reduction.h"
-#include "reduction-templates.h"
#include <cinttypes>
#include <complex>
diff --git a/FortranRuntime/lib/Runtime/format-implementation.h b/FortranRuntime/lib/Runtime/format-implementation.h
index 8d0d0f3376eafc..f17f0a2cb4bfd9 100644
--- a/FortranRuntime/lib/Runtime/format-implementation.h
+++ b/FortranRuntime/lib/Runtime/format-implementation.h
@@ -12,12 +12,12 @@
#define FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
#include "emit-encoded.h"
-#include "flang/Common/decimal.h"
-#include "flang/Common/format.h"
-#include "flang/Runtime/main.h"
#include "format.h"
#include "io-stmt.h"
#include "memory.h"
+#include "flang/Common/decimal.h"
+#include "flang/Common/format.h"
+#include "flang/Runtime/main.h"
#include <algorithm>
#include <cstring>
#include <limits>
diff --git a/FortranRuntime/lib/Runtime/format.h b/FortranRuntime/lib/Runtime/format.h
index 3e0807ee452a7e..098a251a04d568 100644
--- a/FortranRuntime/lib/Runtime/format.h
+++ b/FortranRuntime/lib/Runtime/format.h
@@ -12,11 +12,11 @@
#define FORTRAN_RUNTIME_FORMAT_H_
#include "environment.h"
+#include "io-error.h"
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/decimal.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/freestanding-tools.h"
-#include "io-error.h"
#include <cinttypes>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/inquiry.cpp b/FortranRuntime/lib/Runtime/inquiry.cpp
index 172b46037d6c4b..c24492754b4f43 100644
--- a/FortranRuntime/lib/Runtime/inquiry.cpp
+++ b/FortranRuntime/lib/Runtime/inquiry.cpp
@@ -10,8 +10,8 @@
// inquire about shape information of arrays -- LBOUND and SIZE.
#include "flang/Runtime/inquiry.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "copy.h"
-#include "flang/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include <algorithm>
diff --git a/FortranRuntime/lib/Runtime/internal-unit.cpp b/FortranRuntime/lib/Runtime/internal-unit.cpp
index 81b937ba63d4b8..4494de9dddc1a1 100644
--- a/FortranRuntime/lib/Runtime/internal-unit.cpp
+++ b/FortranRuntime/lib/Runtime/internal-unit.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "internal-unit.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/freestanding-tools.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "io-error.h"
+#include "flang/Runtime/freestanding-tools.h"
#include <algorithm>
#include <type_traits>
@@ -36,6 +36,8 @@ RT_API_ATTRS InternalDescriptorUnit<DIR>::InternalDescriptorUnit(
Descriptor &d{descriptor()};
RUNTIME_CHECK(
terminator, that.SizeInBytes() <= d.SizeInBytes(maxRank, true, 0));
+ RUNTIME_CHECK(terminator,
+ that.SizeInBytes() <= MaxDescriptorSizeInBytes(maxRank, true, 0));
new (&d) Descriptor{that};
d.Check();
internalIoCharKind = thatType->second;
diff --git a/FortranRuntime/lib/Runtime/internal-unit.h b/FortranRuntime/lib/Runtime/internal-unit.h
index c4107696810f2b..7579016f14646d 100644
--- a/FortranRuntime/lib/Runtime/internal-unit.h
+++ b/FortranRuntime/lib/Runtime/internal-unit.h
@@ -11,8 +11,8 @@
#ifndef FORTRAN_RUNTIME_INTERNAL_UNIT_H_
#define FORTRAN_RUNTIME_INTERNAL_UNIT_H_
+#include "FortranRuntime/Runtime/descriptor.h"
#include "connection.h"
-#include "flang/Runtime/descriptor.h"
#include <cinttypes>
#include <type_traits>
diff --git a/FortranRuntime/lib/Runtime/io-api-common.h b/FortranRuntime/lib/Runtime/io-api-common.h
index 427666723501a2..fed1d11d6ce6a6 100644
--- a/FortranRuntime/lib/Runtime/io-api-common.h
+++ b/FortranRuntime/lib/Runtime/io-api-common.h
@@ -9,12 +9,12 @@
#ifndef FORTRAN_RUNTIME_IO_API_COMMON_H_
#define FORTRAN_RUNTIME_IO_API_COMMON_H_
-#include "flang/Common/api-attrs.h"
-#include "flang/Common/optional.h"
-#include "flang/Runtime/io-api.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
#include "io-stmt.h"
#include "terminator.h"
#include "unit.h"
+#include "flang/Common/api-attrs.h"
+#include "flang/Common/optional.h"
namespace Fortran::runtime::io {
diff --git a/FortranRuntime/lib/Runtime/io-api-minimal.cpp b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
index 683694bd63c068..8cde2333804572 100644
--- a/FortranRuntime/lib/Runtime/io-api-minimal.cpp
+++ b/FortranRuntime/lib/Runtime/io-api-minimal.cpp
@@ -9,8 +9,8 @@
// Implements the subset of the I/O statement API needed for basic
// list-directed output (PRINT *) of intrinsic types.
+#include "FortranRuntime/Runtime/io-api-funcs.h"
#include "edit-output.h"
-#include "flang/Runtime/io-api.h"
#include "format.h"
#include "io-api-common.h"
#include "io-stmt.h"
diff --git a/FortranRuntime/lib/Runtime/io-api.cpp b/FortranRuntime/lib/Runtime/io-api.cpp
index 102ea26b359111..fa95d68a004b51 100644
--- a/FortranRuntime/lib/Runtime/io-api.cpp
+++ b/FortranRuntime/lib/Runtime/io-api.cpp
@@ -13,20 +13,20 @@
// OutputReal{32,64}, OutputComplex{32,64}, OutputAscii, & EndIoStatement()
// are in runtime/io-api-minimal.cpp.
-#include "flang/Runtime/io-api.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
+#include "FortranRuntime/Runtime/memory.h"
#include "descriptor-io.h"
#include "edit-input.h"
#include "edit-output.h"
#include "environment.h"
-#include "flang/Common/optional.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/memory.h"
#include "format.h"
#include "io-api-common.h"
#include "io-stmt.h"
#include "terminator.h"
#include "tools.h"
#include "unit.h"
+#include "flang/Common/optional.h"
#include <cstdlib>
#include <memory>
diff --git a/FortranRuntime/lib/Runtime/io-error.cpp b/FortranRuntime/lib/Runtime/io-error.cpp
index 400b211c1c418e..053667462058de 100644
--- a/FortranRuntime/lib/Runtime/io-error.cpp
+++ b/FortranRuntime/lib/Runtime/io-error.cpp
@@ -9,7 +9,7 @@
#include "io-error.h"
#include "config.h"
#include "tools.h"
-#include "flang/Common/magic-numbers.h"
+#include "flang/Runtime/magic-numbers.h"
#include <cerrno>
#include <cstdarg>
#include <cstdio>
diff --git a/FortranRuntime/lib/Runtime/io-error.h b/FortranRuntime/lib/Runtime/io-error.h
index 7388a2134ed0d3..e2018cc2ea0ab1 100644
--- a/FortranRuntime/lib/Runtime/io-error.h
+++ b/FortranRuntime/lib/Runtime/io-error.h
@@ -15,8 +15,8 @@
#ifndef FORTRAN_RUNTIME_IO_ERROR_H_
#define FORTRAN_RUNTIME_IO_ERROR_H_
-#include "flang/Runtime/iostat.h"
-#include "flang/Runtime/memory.h"
+#include "FortranRuntime/Runtime/iostat-funcs.h"
+#include "FortranRuntime/Runtime/memory.h"
#include "terminator.h"
#include <cinttypes>
diff --git a/FortranRuntime/lib/Runtime/io-stmt.cpp b/FortranRuntime/lib/Runtime/io-stmt.cpp
index 5be5d98ace0d8a..fe02e221671665 100644
--- a/FortranRuntime/lib/Runtime/io-stmt.cpp
+++ b/FortranRuntime/lib/Runtime/io-stmt.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "io-stmt.h"
+#include "FortranRuntime/Runtime/memory.h"
#include "connection.h"
#include "emit-encoded.h"
-#include "flang/Runtime/memory.h"
#include "format.h"
#include "tools.h"
#include "unit.h"
diff --git a/FortranRuntime/lib/Runtime/io-stmt.h b/FortranRuntime/lib/Runtime/io-stmt.h
index 79a8b28c8aa19f..21746ff1966218 100644
--- a/FortranRuntime/lib/Runtime/io-stmt.h
+++ b/FortranRuntime/lib/Runtime/io-stmt.h
@@ -11,16 +11,16 @@
#ifndef FORTRAN_RUNTIME_IO_STMT_H_
#define FORTRAN_RUNTIME_IO_STMT_H_
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
#include "connection.h"
#include "file.h"
-#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 "format.h"
#include "internal-unit.h"
#include "io-error.h"
+#include "flang/Common/optional.h"
+#include "flang/Common/reference-wrapper.h"
+#include "flang/Common/visit.h"
#include <flang/Common/variant.h>
#include <functional>
#include <type_traits>
diff --git a/FortranRuntime/lib/Runtime/iostat.cpp b/FortranRuntime/lib/Runtime/iostat.cpp
index f23567be4910da..8d769a09252fd6 100644
--- a/FortranRuntime/lib/Runtime/iostat.cpp
+++ b/FortranRuntime/lib/Runtime/iostat.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/iostat.h"
+#include "FortranRuntime/Runtime/iostat-funcs.h"
namespace Fortran::runtime::io {
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/matmul-transpose.cpp b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
index 3b4b487daa335e..ec5388e3fca793 100644
--- a/FortranRuntime/lib/Runtime/matmul-transpose.cpp
+++ b/FortranRuntime/lib/Runtime/matmul-transpose.cpp
@@ -21,12 +21,12 @@
// to use the faster BLAS routines.
#include "flang/Runtime/matmul-transpose.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "terminator.h"
+#include "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 "terminator.h"
-#include "tools.h"
#include <cstring>
namespace {
diff --git a/FortranRuntime/lib/Runtime/matmul.cpp b/FortranRuntime/lib/Runtime/matmul.cpp
index 62674316bc6a57..01be7f7c75bc45 100644
--- a/FortranRuntime/lib/Runtime/matmul.cpp
+++ b/FortranRuntime/lib/Runtime/matmul.cpp
@@ -20,12 +20,12 @@
// Places where BLAS routines could be called are marked as TODO items.
#include "flang/Runtime/matmul.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "terminator.h"
+#include "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 "terminator.h"
-#include "tools.h"
#include <cstring>
namespace {
diff --git a/FortranRuntime/lib/Runtime/memory.cpp b/FortranRuntime/lib/Runtime/memory.cpp
index bf2c4cd4a35470..a4cebf7edc6c64 100644
--- a/FortranRuntime/lib/Runtime/memory.cpp
+++ b/FortranRuntime/lib/Runtime/memory.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/memory.h"
-#include "flang/Runtime/freestanding-tools.h"
+#include "FortranRuntime/Runtime/memory.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Runtime/freestanding-tools.h"
#include <cstdlib>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/misc-intrinsic.cpp b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
index a0f41e4e3f156c..91a3b136e009a5 100644
--- a/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/misc-intrinsic.h"
-#include "flang/Common/optional.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Common/optional.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/namelist.cpp b/FortranRuntime/lib/Runtime/namelist.cpp
index 1c8942fc375c43..46036549bcd316 100644
--- a/FortranRuntime/lib/Runtime/namelist.cpp
+++ b/FortranRuntime/lib/Runtime/namelist.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "namelist.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
#include "descriptor-io.h"
#include "emit-encoded.h"
-#include "flang/Runtime/io-api.h"
#include "io-stmt.h"
#include <algorithm>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/namelist.h b/FortranRuntime/lib/Runtime/namelist.h
index 2c4d331ae05e85..04432f8a08cb97 100644
--- a/FortranRuntime/lib/Runtime/namelist.h
+++ b/FortranRuntime/lib/Runtime/namelist.h
@@ -11,8 +11,8 @@
#ifndef FORTRAN_RUNTIME_NAMELIST_H_
#define FORTRAN_RUNTIME_NAMELIST_H_
-#include "flang/Common/api-attrs.h"
#include "non-tbp-dio.h"
+#include "flang/Common/api-attrs.h"
#include <cstddef>
diff --git a/FortranRuntime/lib/Runtime/numeric-templates.h b/FortranRuntime/lib/Runtime/numeric-templates.h
index f0045e8ee36e20..159b8b0b9579ad 100644
--- a/FortranRuntime/lib/Runtime/numeric-templates.h
+++ b/FortranRuntime/lib/Runtime/numeric-templates.h
@@ -18,10 +18,10 @@
#ifndef FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
#define FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_
-#include "flang/Common/api-attrs.h"
-#include "flang/Common/float128.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Common/api-attrs.h"
+#include "flang/Common/float128.h"
#include <cstdint>
#include <limits>
diff --git a/FortranRuntime/lib/Runtime/numeric.cpp b/FortranRuntime/lib/Runtime/numeric.cpp
index a3fcfeaa9ee266..b0f68a7fc81d29 100644
--- a/FortranRuntime/lib/Runtime/numeric.cpp
+++ b/FortranRuntime/lib/Runtime/numeric.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/numeric.h"
-#include "flang/Common/float128.h"
#include "numeric-templates.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Common/float128.h"
#include <cfloat>
#include <climits>
#include <cmath>
diff --git a/FortranRuntime/lib/Runtime/product.cpp b/FortranRuntime/lib/Runtime/product.cpp
index 8c11bf4144919e..e4a6e81bd0c508 100644
--- a/FortranRuntime/lib/Runtime/product.cpp
+++ b/FortranRuntime/lib/Runtime/product.cpp
@@ -8,9 +8,9 @@
// Implements PRODUCT for all required operand types and shapes.
+#include "reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
-#include "reduction-templates.h"
#include <cfloat>
#include <cinttypes>
#include <complex>
diff --git a/FortranRuntime/lib/Runtime/random-templates.h b/FortranRuntime/lib/Runtime/random-templates.h
index 801484225bc211..9faa9c7cfa7002 100644
--- a/FortranRuntime/lib/Runtime/random-templates.h
+++ b/FortranRuntime/lib/Runtime/random-templates.h
@@ -9,10 +9,10 @@
#ifndef FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
#define FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
-#include "flang/Common/optional.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "lock.h"
#include "numeric-templates.h"
+#include "flang/Common/optional.h"
#include <algorithm>
#include <random>
diff --git a/FortranRuntime/lib/Runtime/random.cpp b/FortranRuntime/lib/Runtime/random.cpp
index 8e1561960d48be..911b59b508eb4f 100644
--- a/FortranRuntime/lib/Runtime/random.cpp
+++ b/FortranRuntime/lib/Runtime/random.cpp
@@ -10,14 +10,14 @@
// RANDOM_SEED.
#include "flang/Runtime/random.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "lock.h"
+#include "random-templates.h"
+#include "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 "lock.h"
-#include "random-templates.h"
-#include "terminator.h"
#include <cmath>
#include <cstdint>
#include <limits>
diff --git a/FortranRuntime/lib/Runtime/reduce.cpp b/FortranRuntime/lib/Runtime/reduce.cpp
index 4d33c2a714e5af..a020ffef6fe6a5 100644
--- a/FortranRuntime/lib/Runtime/reduce.cpp
+++ b/FortranRuntime/lib/Runtime/reduce.cpp
@@ -9,7 +9,7 @@
// REDUCE() implementation
#include "flang/Runtime/reduce.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "reduction-templates.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/reduction-templates.h b/FortranRuntime/lib/Runtime/reduction-templates.h
index 30ae641ba7b3ac..714584ec613ba3 100644
--- a/FortranRuntime/lib/Runtime/reduction-templates.h
+++ b/FortranRuntime/lib/Runtime/reduction-templates.h
@@ -21,11 +21,11 @@
#ifndef FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
#define FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_
-#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "numeric-templates.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Runtime/cpp-type.h"
#include <algorithm>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/reduction.cpp b/FortranRuntime/lib/Runtime/reduction.cpp
index f4e1f2aa6818d5..21930fee07ead7 100644
--- a/FortranRuntime/lib/Runtime/reduction.cpp
+++ b/FortranRuntime/lib/Runtime/reduction.cpp
@@ -14,7 +14,7 @@
// NORM2, MAXLOC, MINLOC, MAXVAL, and MINVAL are in extrema.cpp.
#include "flang/Runtime/reduction.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "reduction-templates.h"
#include <cinttypes>
diff --git a/FortranRuntime/lib/Runtime/stack.h b/FortranRuntime/lib/Runtime/stack.h
index dc5b6101d3da0f..36e2d0a103a887 100644
--- a/FortranRuntime/lib/Runtime/stack.h
+++ b/FortranRuntime/lib/Runtime/stack.h
@@ -13,7 +13,7 @@
#ifndef FORTRAN_RUNTIME_STACK_H_
#define FORTRAN_RUNTIME_STACK_H_
-#include "flang/Runtime/memory.h"
+#include "FortranRuntime/Runtime/memory.h"
#include "terminator.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/stat.cpp b/FortranRuntime/lib/Runtime/stat.cpp
index 01ae922e080865..1af6c43102518b 100644
--- a/FortranRuntime/lib/Runtime/stat.cpp
+++ b/FortranRuntime/lib/Runtime/stat.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "stat.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/stat.h b/FortranRuntime/lib/Runtime/stat.h
index a679f9da16dd46..eccd69024d726b 100644
--- a/FortranRuntime/lib/Runtime/stat.h
+++ b/FortranRuntime/lib/Runtime/stat.h
@@ -13,7 +13,7 @@
#define FORTRAN_RUNTIME_STAT_H_
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/api-attrs.h"
-#include "flang/Common/magic-numbers.h"
+#include "flang/Runtime/magic-numbers.h"
namespace Fortran::runtime {
class Descriptor;
diff --git a/FortranRuntime/lib/Runtime/sum.cpp b/FortranRuntime/lib/Runtime/sum.cpp
index e33b77e20f0f11..64982b9fd53690 100644
--- a/FortranRuntime/lib/Runtime/sum.cpp
+++ b/FortranRuntime/lib/Runtime/sum.cpp
@@ -12,9 +12,9 @@
// cancellation on intermediate results by using "Kahan summation"
// (basically the same as manual "double-double").
+#include "reduction-templates.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/reduction.h"
-#include "reduction-templates.h"
#include <cfloat>
#include <cinttypes>
#include <complex>
diff --git a/FortranRuntime/lib/Runtime/support.cpp b/FortranRuntime/lib/Runtime/support.cpp
index 0a39ff24b0cafc..798d502ba248e2 100644
--- a/FortranRuntime/lib/Runtime/support.cpp
+++ b/FortranRuntime/lib/Runtime/support.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/support.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "ISO_Fortran_util.h"
-#include "flang/Runtime/descriptor.h"
#include "type-info.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/temporary-stack.cpp b/FortranRuntime/lib/Runtime/temporary-stack.cpp
index f944dfb7aa1471..d8ff08e51cc211 100644
--- a/FortranRuntime/lib/Runtime/temporary-stack.cpp
+++ b/FortranRuntime/lib/Runtime/temporary-stack.cpp
@@ -10,11 +10,11 @@
// temporaries. For use in HLFIR lowering.
#include "flang/Runtime/temporary-stack.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/memory.h"
+#include "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"
-#include "terminator.h"
namespace {
diff --git a/FortranRuntime/lib/Runtime/time-intrinsic.cpp b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
index 4b362c90c52f25..15c42077c0afd5 100644
--- a/FortranRuntime/lib/Runtime/time-intrinsic.cpp
+++ b/FortranRuntime/lib/Runtime/time-intrinsic.cpp
@@ -9,10 +9,10 @@
// Implements time-related intrinsic subroutines.
#include "flang/Runtime/time-intrinsic.h"
-#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Runtime/cpp-type.h"
#include <algorithm>
#include <cstdint>
#include <cstdio>
diff --git a/FortranRuntime/lib/Runtime/tools.h b/FortranRuntime/lib/Runtime/tools.h
index 4058767ca283a9..332ffac77f2595 100644
--- a/FortranRuntime/lib/Runtime/tools.h
+++ b/FortranRuntime/lib/Runtime/tools.h
@@ -9,13 +9,13 @@
#ifndef FORTRAN_RUNTIME_TOOLS_H_
#define FORTRAN_RUNTIME_TOOLS_H_
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/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 "stat.h"
-#include "terminator.h"
#include <cstring>
#include <functional>
#include <map>
diff --git a/FortranRuntime/lib/Runtime/transformational.cpp b/FortranRuntime/lib/Runtime/transformational.cpp
index 66dc5bd4939bae..28dd02a28036de 100644
--- a/FortranRuntime/lib/Runtime/transformational.cpp
+++ b/FortranRuntime/lib/Runtime/transformational.cpp
@@ -17,11 +17,11 @@
// of the standard but it more likely to conform with its intent.
#include "flang/Runtime/transformational.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "copy.h"
-#include "flang/Common/float128.h"
-#include "flang/Runtime/descriptor.h"
#include "terminator.h"
#include "tools.h"
+#include "flang/Common/float128.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/type-code.cpp b/FortranRuntime/lib/Runtime/type-code.cpp
index 2709ca1be75a53..16f5497bc7a709 100644
--- a/FortranRuntime/lib/Runtime/type-code.cpp
+++ b/FortranRuntime/lib/Runtime/type-code.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/type-code.h"
+#include "FortranRuntime/Runtime/type-code.h"
#include <cstdint>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/type-info.cpp b/FortranRuntime/lib/Runtime/type-info.cpp
index 24fc9c33d92819..19e9211fc063f4 100644
--- a/FortranRuntime/lib/Runtime/type-info.cpp
+++ b/FortranRuntime/lib/Runtime/type-info.cpp
@@ -84,10 +84,14 @@ RT_API_ATTRS std::size_t Component::SizeInBytes(
return GetElementByteSize(instance) * GetElements(instance);
} else if (category() == TypeCategory::Derived) {
const DerivedType *type{derivedType()};
- return Descriptor::SizeInBytes(
- rank_, true, type ? type->LenParameters() : 0);
+ auto bytes {Descriptor::SizeInBytes(
+ rank_, true, type ? type->LenParameters() : 0)};
+ assert(bytes <= MaxDescriptorSizeInBytes( rank_, true, type ? type->LenParameters() : 0));
+ return bytes;
} else {
- return Descriptor::SizeInBytes(rank_);
+ auto bytes{ Descriptor::SizeInBytes(rank_)};
+ assert(bytes <= MaxDescriptorSizeInBytes( rank_));
+ return bytes;
}
}
diff --git a/FortranRuntime/lib/Runtime/type-info.h b/FortranRuntime/lib/Runtime/type-info.h
index ff3523bcb2b8eb..150942547c2ee8 100644
--- a/FortranRuntime/lib/Runtime/type-info.h
+++ b/FortranRuntime/lib/Runtime/type-info.h
@@ -12,11 +12,11 @@
// A C++ perspective of the derived type description schemata in
// flang/module/__fortran_type_info.f90.
+#include "FortranRuntime/Runtime/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 "terminator.h"
#include <cinttypes>
#include <memory>
diff --git a/FortranRuntime/lib/Runtime/unit-map.h b/FortranRuntime/lib/Runtime/unit-map.h
index 4e61246f9a2d86..f37e2df7f3b15a 100644
--- a/FortranRuntime/lib/Runtime/unit-map.h
+++ b/FortranRuntime/lib/Runtime/unit-map.h
@@ -12,10 +12,10 @@
#ifndef FORTRAN_RUNTIME_UNIT_MAP_H_
#define FORTRAN_RUNTIME_UNIT_MAP_H_
-#include "flang/Common/fast-int-set.h"
-#include "flang/Runtime/memory.h"
+#include "FortranRuntime/Runtime/memory.h"
#include "lock.h"
#include "unit.h"
+#include "flang/Common/fast-int-set.h"
#include <cstdint>
#include <cstdlib>
diff --git a/FortranRuntime/lib/Runtime/unit.cpp b/FortranRuntime/lib/Runtime/unit.cpp
index f6e4dc2a7befd4..496679ee8ce5f4 100644
--- a/FortranRuntime/lib/Runtime/unit.cpp
+++ b/FortranRuntime/lib/Runtime/unit.cpp
@@ -19,13 +19,13 @@
namespace Fortran::runtime::io {
-#ifndef FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS ExternalFileUnit *defaultInput{nullptr}; // unit 5
RT_VAR_ATTRS ExternalFileUnit *defaultOutput{nullptr}; // unit 6
RT_VAR_ATTRS ExternalFileUnit *errorOutput{nullptr}; // unit 0 extension
RT_OFFLOAD_VAR_GROUP_END
-#endif // FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/unit.h b/FortranRuntime/lib/Runtime/unit.h
index 993fbf2977cebf..4a7444aedbe5b6 100644
--- a/FortranRuntime/lib/Runtime/unit.h
+++ b/FortranRuntime/lib/Runtime/unit.h
@@ -11,18 +11,18 @@
#ifndef FORTRAN_RUNTIME_UNIT_H_
#define FORTRAN_RUNTIME_UNIT_H_
+#include "FortranRuntime/Runtime/memory.h"
#include "buffer.h"
#include "connection.h"
#include "environment.h"
#include "file.h"
-#include "flang/Common/constexpr-bitset.h"
-#include "flang/Common/optional.h"
-#include "flang/Runtime/memory.h"
#include "format.h"
#include "io-error.h"
#include "io-stmt.h"
#include "lock.h"
#include "terminator.h"
+#include "flang/Common/constexpr-bitset.h"
+#include "flang/Common/optional.h"
#include <cstdlib>
#include <cstring>
#include <flang/Common/variant.h>
diff --git a/FortranRuntime/lib/Runtime/utf.cpp b/FortranRuntime/lib/Runtime/utf.cpp
index d2839f9cf3793a..635451153d39a6 100644
--- a/FortranRuntime/lib/Runtime/utf.cpp
+++ b/FortranRuntime/lib/Runtime/utf.cpp
@@ -10,7 +10,7 @@
namespace Fortran::runtime {
-#ifndef FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
// clang-format off
RT_OFFLOAD_VAR_GROUP_BEGIN
const RT_CONST_VAR_ATTRS std::uint8_t UTF8FirstByteTable[256]{
@@ -41,7 +41,7 @@ const RT_CONST_VAR_ATTRS std::uint8_t UTF8FirstByteTable[256]{
};
RT_OFFLOAD_VAR_GROUP_END
// clang-format on
-#endif // FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Testing/CMakeLists.txt b/FortranRuntime/lib/Testing/CMakeLists.txt
index d5caada3fb68e8..41ad0d7314dd37 100644
--- a/FortranRuntime/lib/Testing/CMakeLists.txt
+++ b/FortranRuntime/lib/Testing/CMakeLists.txt
@@ -8,13 +8,12 @@
set(public_headers "")
file(GLOB_RECURSE public_headers
- "${FLANGRUNTIME_SOURCE_DIR}/lib/Testing/*.h"
+ "${FLANG_SOURCE_DIR}/lib/Testing/*.h"
)
add_fortranruntime_library(NonGTestTesting EXCLUDE_FROM_ALL LINK_TO_LLVM
- testing.cpp
- fp-testing.cpp
+ ${FLANG_SOURCE_DIR}/lib/Testing/testing.cpp
+ ${FLANG_SOURCE_DIR}/lib/Testing/fp-testing.cpp
ADDITIONAL_HEADERS
${public_headers}
)
-
diff --git a/FortranRuntime/test/lit.cfg.py b/FortranRuntime/test/lit.cfg.py
index a9f47f142bb884..1b9041111b72e8 100644
--- a/FortranRuntime/test/lit.cfg.py
+++ b/FortranRuntime/test/lit.cfg.py
@@ -73,7 +73,7 @@
# 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.
libruntime = os.path.join(config.fortranruntime_build_lib_dir, "libFortranRuntime.a")
-include = os.path.join(config.fortranruntime_source_dir, "include")
+include = os.path.join(config.flang_source_dir, "include")
tools.append(
ToolSubst("%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal")
)
diff --git a/FortranRuntime/test/lit.site.cfg.py.in b/FortranRuntime/test/lit.site.cfg.py.in
index d860d297ebd7c3..a21fc128086eae 100644
--- a/FortranRuntime/test/lit.site.cfg.py.in
+++ b/FortranRuntime/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@ import sys
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.build_lib_dir = "@FORTRANRUNTIME_BUILD_LIB_DIR@"
+config.flang_source_dir = "@FLANG_SOURCE_DIR@"
config.fortranruntime_source_dir = "@FORTRANRUNTIME_SOURCE_DIR@"
config.fortranruntime_binary_test_dir = os.path.dirname(__file__)
config.fortranruntime_build_lib_dir = "@FORTRANRUNTIME_BUILD_LIB_DIR@"
diff --git a/FortranRuntime/unittests/CMakeLists.txt b/FortranRuntime/unittests/CMakeLists.txt
index 1bb788651a8d33..592f2ef7ce42ab 100644
--- a/FortranRuntime/unittests/CMakeLists.txt
+++ b/FortranRuntime/unittests/CMakeLists.txt
@@ -94,7 +94,5 @@ function(add_fortranruntime_nongtest_unittest test_name)
add_fortranruntime_unittest_offload_properties(${test_name}${suffix})
endfunction()
-add_subdirectory(Common)
-add_subdirectory(Decimal)
add_subdirectory(Evaluate)
add_subdirectory(Runtime)
diff --git a/FortranRuntime/unittests/Evaluate/CMakeLists.txt b/FortranRuntime/unittests/Evaluate/CMakeLists.txt
index 567832a2f15bcb..fd3a5755dd1227 100644
--- a/FortranRuntime/unittests/Evaluate/CMakeLists.txt
+++ b/FortranRuntime/unittests/Evaluate/CMakeLists.txt
@@ -7,13 +7,13 @@
#===------------------------------------------------------------------------===#
add_fortranruntime_nongtest_unittest(reshape
-reshape.cpp
+ reshape.cpp
LINK_LIBS
FortranRuntime.unittest
)
add_fortranruntime_nongtest_unittest(ISO-Fortran-binding
-ISO-Fortran-binding.cpp
+ ISO-Fortran-binding.cpp
LINK_LIBS
FortranRuntime.unittest
)
diff --git a/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
index d2546e0c22d2d6..b68dfbcbd5b335 100644
--- a/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include "FortranRuntime/Runtime/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>
@@ -28,6 +28,9 @@ template <int rank> class Test_CFI_CDESC_T {
MATCH(false, std::is_const<type>::value);
MATCH(false, std::is_volatile<type>::value);
// suitable in size
+ MATCH(true,
+ Descriptor::SizeInBytes(rank_, false) <=
+ MaxDescriptorSizeInBytes(rank_, false));
if (rank > 0) {
MATCH(sizeof(dvStorage_), Descriptor::SizeInBytes(rank_, false));
} else { // C++ implementation over-allocates for rank=0 by 24bytes.
diff --git a/FortranRuntime/unittests/Evaluate/reshape.cpp b/FortranRuntime/unittests/Evaluate/reshape.cpp
index a93afd2a3c90cd..0233ab37e25c6e 100644
--- a/FortranRuntime/unittests/Evaluate/reshape.cpp
+++ b/FortranRuntime/unittests/Evaluate/reshape.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "flang/Runtime/transformational.h"
#include "flang/Testing/testing.h"
#include <cinttypes>
diff --git a/FortranRuntime/unittests/Runtime/AccessTest.cpp b/FortranRuntime/unittests/Runtime/AccessTest.cpp
index 3e9feaf945b66d..e72386cc9ac247 100644
--- a/FortranRuntime/unittests/Runtime/AccessTest.cpp
+++ b/FortranRuntime/unittests/Runtime/AccessTest.cpp
@@ -10,9 +10,9 @@
#ifndef _WIN32
#include "CrashHandlerFixture.h"
+#include "gtest/gtest.h"
#include "flang/Runtime/extensions.h"
#include "llvm/ADT/Twine.h"
-#include "gtest/gtest.h"
#include <fcntl.h>
#include <sys/stat.h>
diff --git a/FortranRuntime/unittests/Runtime/Allocatable.cpp b/FortranRuntime/unittests/Runtime/Allocatable.cpp
index c01f85598d21ed..8e10dc408ceae8 100644
--- a/FortranRuntime/unittests/Runtime/Allocatable.cpp
+++ b/FortranRuntime/unittests/Runtime/Allocatable.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/allocatable.h"
-#include "tools.h"
#include "gtest/gtest.h"
+#include "tools.h"
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp b/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
index 9011da304b6bc3..9d9a4ddae8689f 100644
--- a/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
+++ b/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
+#include "FortranRuntime/Runtime/array-constructor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/type-code.h"
+#include "gtest/gtest.h"
+#include "tools.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 "tools.h"
-#include "gtest/gtest.h"
#include <memory>
diff --git a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
index bb1ea411cb7760..d2a2e5a11abf80 100644
--- a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "../../../lib/Runtime/terminator.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 "FortranRuntime/Runtime/CUDA/allocator.h"
+#include "FortranRuntime/Runtime/CUDA/descriptor.h"
+#include "FortranRuntime/Runtime/allocatable.h"
+#include "FortranRuntime/Runtime/allocator-registry.h"
#include "gtest/gtest.h"
+#include "../../../runtime/terminator.h"
+#include "flang/Support/Fortran.h"
#include "cuda_runtime.h"
diff --git a/FortranRuntime/unittests/Runtime/CharacterTest.cpp b/FortranRuntime/unittests/Runtime/CharacterTest.cpp
index 8829f5e43265b0..610061e2122cd5 100644
--- a/FortranRuntime/unittests/Runtime/CharacterTest.cpp
+++ b/FortranRuntime/unittests/Runtime/CharacterTest.cpp
@@ -10,7 +10,7 @@
// in Fortran.
#include "flang/Runtime/character.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "gtest/gtest.h"
#include <cstring>
#include <functional>
diff --git a/FortranRuntime/unittests/Runtime/CommandTest.cpp b/FortranRuntime/unittests/Runtime/CommandTest.cpp
index aa79ce381ba8d0..a7d68508c5abca 100644
--- a/FortranRuntime/unittests/Runtime/CommandTest.cpp
+++ b/FortranRuntime/unittests/Runtime/CommandTest.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/command.h"
-#include "flang/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
#include "flang/Runtime/execute.h"
#include "flang/Runtime/extensions.h"
#include "flang/Runtime/main.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
#include <cstddef>
#include <cstdlib>
diff --git a/FortranRuntime/unittests/Runtime/Derived.cpp b/FortranRuntime/unittests/Runtime/Derived.cpp
index 11b732fe10b790..22361352fdf5d9 100644
--- a/FortranRuntime/unittests/Runtime/Derived.cpp
+++ b/FortranRuntime/unittests/Runtime/Derived.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/derived-api.h"
-#include "flang/Runtime/descriptor.h"
-#include "tools.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "gtest/gtest.h"
+#include "tools.h"
+#include "flang/Runtime/derived-api.h"
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp b/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
index 00c2fd76ce0c04..7ff4aa3c14bdc5 100644
--- a/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
+++ b/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
@@ -11,12 +11,12 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/io-api.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
+#include "gtest/gtest.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
#include "llvm/Support/raw_ostream.h"
-#include "gtest/gtest.h"
#include <cstring>
#include <string_view>
diff --git a/FortranRuntime/unittests/Runtime/Inquiry.cpp b/FortranRuntime/unittests/Runtime/Inquiry.cpp
index 204a97a1088ac0..3e5f0037177f1c 100644
--- a/FortranRuntime/unittests/Runtime/Inquiry.cpp
+++ b/FortranRuntime/unittests/Runtime/Inquiry.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/inquiry.h"
-#include "flang/Runtime/type-code.h"
-#include "tools.h"
+#include "FortranRuntime/Runtime/type-code.h"
#include "gtest/gtest.h"
+#include "tools.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/ListInputTest.cpp b/FortranRuntime/unittests/Runtime/ListInputTest.cpp
index 4c30d6ed750141..e0fe4dfeac3949 100644
--- a/FortranRuntime/unittests/Runtime/ListInputTest.cpp
+++ b/FortranRuntime/unittests/Runtime/ListInputTest.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "../../lib/Runtime/io-error.h"
#include "CrashHandlerFixture.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/io-api.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
+#include "../../lib/Runtime/io-error.h"
using namespace Fortran::runtime;
using namespace Fortran::runtime::io;
diff --git a/FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp b/FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
index 928fddec50c874..9fa0c2f4260edb 100644
--- a/FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
+++ b/FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/io-api.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
#include <algorithm>
#include <array>
#include <cstring>
diff --git a/FortranRuntime/unittests/Runtime/Matmul.cpp b/FortranRuntime/unittests/Runtime/Matmul.cpp
index cfa5d18cc36d33..6eb4012e785ff1 100644
--- a/FortranRuntime/unittests/Runtime/Matmul.cpp
+++ b/FortranRuntime/unittests/Runtime/Matmul.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/matmul.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/type-code.h"
+#include "gtest/gtest.h"
+#include "tools.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/type-code.h"
-#include "tools.h"
-#include "gtest/gtest.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp b/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
index 146c2283fb1aca..199062f820c303 100644
--- a/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
+++ b/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/type-code.h"
+#include "gtest/gtest.h"
+#include "tools.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"
-#include "tools.h"
-#include "gtest/gtest.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp b/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
index 08229b5e48f0dd..1033dda9d636f7 100644
--- a/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
+++ b/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime//misc-intrinsic.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "gtest/gtest.h"
+#include "tools.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
-#include "tools.h"
-#include "gtest/gtest.h"
+#include "flang/Runtime/misc-intrinsic.h"
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Namelist.cpp b/FortranRuntime/unittests/Runtime/Namelist.cpp
index 7b834dec49c3c4..544ab85234fd65 100644
--- a/FortranRuntime/unittests/Runtime/Namelist.cpp
+++ b/FortranRuntime/unittests/Runtime/Namelist.cpp
@@ -8,8 +8,8 @@
#include "../../lib/Runtime/namelist.h"
#include "CrashHandlerFixture.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/io-api.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
#include "tools.h"
#include <algorithm>
#include <cinttypes>
diff --git a/FortranRuntime/unittests/Runtime/Numeric.cpp b/FortranRuntime/unittests/Runtime/Numeric.cpp
index fb595ae262c324..d15919b972bca7 100644
--- a/FortranRuntime/unittests/Runtime/Numeric.cpp
+++ b/FortranRuntime/unittests/Runtime/Numeric.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/numeric.h"
-#include "flang/Common/float128.h"
#include "gtest/gtest.h"
+#include "flang/Common/float128.h"
#include <cmath>
#include <limits>
diff --git a/FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp b/FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
index 8a1dd6de1449b9..c588c739686bed 100644
--- a/FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
+++ b/FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/io-api.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/io-api-funcs.h"
#include <algorithm>
#include <array>
#include <cstring>
diff --git a/FortranRuntime/unittests/Runtime/Pointer.cpp b/FortranRuntime/unittests/Runtime/Pointer.cpp
index a05bd70a64bb9f..733cd42232875f 100644
--- a/FortranRuntime/unittests/Runtime/Pointer.cpp
+++ b/FortranRuntime/unittests/Runtime/Pointer.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/pointer.h"
-#include "flang/Runtime/descriptor.h"
-#include "tools.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "gtest/gtest.h"
+#include "tools.h"
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Random.cpp b/FortranRuntime/unittests/Runtime/Random.cpp
index 4e4b59cbcf40e7..81497a682660a8 100644
--- a/FortranRuntime/unittests/Runtime/Random.cpp
+++ b/FortranRuntime/unittests/Runtime/Random.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime//random.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/type-code.h"
+#include "flang/Runtime/random.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/type-code.h"
#include "gtest/gtest.h"
#include <cmath>
diff --git a/FortranRuntime/unittests/Runtime/Reduction.cpp b/FortranRuntime/unittests/Runtime/Reduction.cpp
index c35f6e2fa6a41b..a382f4b7a71770 100644
--- a/FortranRuntime/unittests/Runtime/Reduction.cpp
+++ b/FortranRuntime/unittests/Runtime/Reduction.cpp
@@ -7,14 +7,14 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/reduction.h"
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/type-code.h"
+#include "gtest/gtest.h"
+#include "tools.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 "tools.h"
-#include "gtest/gtest.h"
#include <cstdint>
#include <cstring>
#include <string>
diff --git a/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp b/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
index 61580a8d46792f..7ce1ee796d739b 100644
--- a/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
@@ -10,11 +10,11 @@
/// runtime components and ensure the test fixture handles crashes as we expect.
//
//===----------------------------------------------------------------------===//
-#include "../../lib/Runtime/terminator.h"
#include "CrashHandlerFixture.h"
+#include "tools.h"
+#include "../../lib/Runtime/terminator.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/transformational.h"
-#include "tools.h"
#include <gtest/gtest.h>
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Stop.cpp b/FortranRuntime/unittests/Runtime/Stop.cpp
index 5fd8deaad21d6b..c12ec097068438 100644
--- a/FortranRuntime/unittests/Runtime/Stop.cpp
+++ b/FortranRuntime/unittests/Runtime/Stop.cpp
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#include "flang/Runtime/stop.h"
-#include "../../lib/Runtime/environment.h"
#include "CrashHandlerFixture.h"
+#include "../../lib/Runtime/environment.h"
#include <cstdlib>
#include <gtest/gtest.h>
diff --git a/FortranRuntime/unittests/Runtime/Support.cpp b/FortranRuntime/unittests/Runtime/Support.cpp
index 38c0d6efaf9db7..05328e6baa411c 100644
--- a/FortranRuntime/unittests/Runtime/Support.cpp
+++ b/FortranRuntime/unittests/Runtime/Support.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/support.h"
-#include "flang/Runtime/descriptor.h"
-#include "tools.h"
+#include "FortranRuntime/Runtime/descriptor.h"
#include "gtest/gtest.h"
+#include "tools.h"
using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
diff --git a/FortranRuntime/unittests/Runtime/TemporaryStack.cpp b/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
index 63d99416ea64cb..b0b1041f0f09e7 100644
--- a/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
+++ b/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/type-code.h"
+#include "gtest/gtest.h"
+#include "tools.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 "tools.h"
-#include "gtest/gtest.h"
#include <vector>
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/Time.cpp b/FortranRuntime/unittests/Runtime/Time.cpp
index 6fd00d669a9575..548c0834e34a36 100644
--- a/FortranRuntime/unittests/Runtime/Time.cpp
+++ b/FortranRuntime/unittests/Runtime/Time.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/time-intrinsic.h"
#include "gtest/gtest.h"
+#include "flang/Runtime/time-intrinsic.h"
#include <algorithm>
#include <cctype>
#include <cerrno>
diff --git a/FortranRuntime/unittests/Runtime/Transformational.cpp b/FortranRuntime/unittests/Runtime/Transformational.cpp
index b5a4e0e8e9588b..6b8903750d0aec 100644
--- a/FortranRuntime/unittests/Runtime/Transformational.cpp
+++ b/FortranRuntime/unittests/Runtime/Transformational.cpp
@@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/transformational.h"
-#include "flang/Common/float128.h"
-#include "flang/Runtime/type-code.h"
-#include "tools.h"
+#include "FortranRuntime/Runtime/type-code.h"
#include "gtest/gtest.h"
+#include "tools.h"
+#include "flang/Common/float128.h"
#include <vector>
using namespace Fortran::runtime;
diff --git a/FortranRuntime/unittests/Runtime/tools.h b/FortranRuntime/unittests/Runtime/tools.h
index 702103d225ab72..8000d83fc0c394 100644
--- a/FortranRuntime/unittests/Runtime/tools.h
+++ b/FortranRuntime/unittests/Runtime/tools.h
@@ -9,11 +9,11 @@
#ifndef FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
#define FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
+#include "FortranRuntime/Runtime/descriptor.h"
+#include "FortranRuntime/Runtime/type-code.h"
+#include "gtest/gtest.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
-#include "flang/Runtime/descriptor.h"
-#include "flang/Runtime/type-code.h"
-#include "gtest/gtest.h"
#include <cstdint>
#include <cstring>
#include <vector>
diff --git a/FortranRuntime/include/flang/Common/Fortran-consts.h b/flang/include/flang/Common/Fortran-consts.h
similarity index 100%
rename from FortranRuntime/include/flang/Common/Fortran-consts.h
rename to flang/include/flang/Common/Fortran-consts.h
diff --git a/FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h b/flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
similarity index 97%
rename from FortranRuntime/include/flang/Common/ISO_Fortran_binding_wrapper.h
rename to flang/include/flang/Common/ISO_Fortran_binding_wrapper.h
index 2c0fdc123c8759..ccfc360dfc820c 100644
--- a/FortranRuntime/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 "flang/Common/api-attrs.h"
#ifdef __cplusplus
namespace Fortran {
namespace ISO {
diff --git a/flang/include/flang/Common/README.md b/flang/include/flang/Common/README.md
new file mode 100644
index 00000000000000..a722732fb76407
--- /dev/null
+++ b/flang/include/flang/Common/README.md
@@ -0,0 +1,25 @@
+Files in this directory are used by Flang (the compiler) and FortranRuntime
+(the runtime library for Flang-compiled programs). They must be compatible by
+both. For definitions used only by Flang, consider
+`flang/{lib,include/flang}/Support` instead. For definitions used only by
+FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+
+The requirements for common code include:
+
+ * No dependence to LLVM, including LLVMSupport.
+
+ * No link-dependence to the C++ runtime. This means that e.g. `std::string`
+ cannot be used.
+
+ * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used
+ instead.
+
+ * Preprocessor macros from `config.h` and CMake
+ `(target/add)_compile_definitions` must be defined by both build scripts.
+ See `flang/cmake/modules/FlangCommon.cmake`.
+
+ * Some header files are included from `.c` files.
+ `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C.
+
+ * Global declarations may need to be annotated using definitions from
+ `api-attrs.h`.
diff --git a/FortranRuntime/include/flang/Common/api-attrs.h b/flang/include/flang/Common/api-attrs.h
similarity index 97%
rename from FortranRuntime/include/flang/Common/api-attrs.h
rename to flang/include/flang/Common/api-attrs.h
index 9a3001fb255c11..d73e60996bc81f 100644
--- a/FortranRuntime/include/flang/Common/api-attrs.h
+++ b/flang/include/flang/Common/api-attrs.h
@@ -1,10 +1,11 @@
-/*===-- include/flang/Common/api-attrs.h ----------------------------*- C -*-===
+/*===-- include/flang/Common/api-attrs.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
*
- *===----------------------------------------------------------------------===*/
+ *===------------------------------------------------------------------------===
+ */
/*
* The file defines a set macros that can be used to apply
@@ -12,8 +13,8 @@
* declared/defined/used in Flang runtime library.
*/
-#ifndef FORTRAN_COMMON_API_ATTRS_H_
-#define FORTRAN_COMMON_API_ATTRS_H_
+#ifndef FORTRAN_RUNTIME_API_ATTRS_H_
+#define FORTRAN_RUNTIME_API_ATTRS_H_
/*
* RT_EXT_API_GROUP_BEGIN/END pair is placed around definitions
@@ -177,4 +178,4 @@
#define RT_DEVICE_NOINLINE_HOST_INLINE inline
#endif
-#endif /* FORTRAN_COMMON_API_ATTRS_H_ */
+#endif /* !FORTRAN_RUNTIME_API_ATTRS_H_ */
diff --git a/FortranRuntime/include/flang/Common/binary-floating-point.h b/flang/include/flang/Common/binary-floating-point.h
similarity index 100%
rename from FortranRuntime/include/flang/Common/binary-floating-point.h
rename to flang/include/flang/Common/binary-floating-point.h
diff --git a/FortranRuntime/include/flang/Common/bit-population-count.h b/flang/include/flang/Common/bit-population-count.h
similarity index 98%
rename from FortranRuntime/include/flang/Common/bit-population-count.h
rename to flang/include/flang/Common/bit-population-count.h
index 59ade914d14d85..e1aeb78f9a3765 100644
--- a/FortranRuntime/include/flang/Common/bit-population-count.h
+++ b/flang/include/flang/Common/bit-population-count.h
@@ -93,4 +93,4 @@ template <typename INT> inline constexpr int TrailingZeroBitCount(INT x) {
}
}
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_BIT_POPULATION_COUNT_H_ */
+#endif // FORTRAN_COMMON_BIT_POPULATION_COUNT_H_
diff --git a/FortranRuntime/include/flang/Common/constexpr-bitset.h b/flang/include/flang/Common/constexpr-bitset.h
similarity index 98%
rename from FortranRuntime/include/flang/Common/constexpr-bitset.h
rename to flang/include/flang/Common/constexpr-bitset.h
index 093b247b5f4eff..1aafb6eff84c61 100644
--- a/FortranRuntime/include/flang/Common/constexpr-bitset.h
+++ b/flang/include/flang/Common/constexpr-bitset.h
@@ -144,4 +144,4 @@ template <int BITS> class BitSet {
Word bits_{0};
};
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_CONSTEXPR_BITSET_H_ */
+#endif // FORTRAN_COMMON_CONSTEXPR_BITSET_H_
diff --git a/FortranRuntime/include/flang/Common/decimal.h b/flang/include/flang/Common/decimal.h
similarity index 100%
rename from FortranRuntime/include/flang/Common/decimal.h
rename to flang/include/flang/Common/decimal.h
diff --git a/FortranRuntime/include/flang/Common/enum-class.h b/flang/include/flang/Common/enum-class.h
similarity index 98%
rename from FortranRuntime/include/flang/Common/enum-class.h
rename to flang/include/flang/Common/enum-class.h
index 787648ffec48e8..41575d45091a8d 100644
--- a/FortranRuntime/include/flang/Common/enum-class.h
+++ b/flang/include/flang/Common/enum-class.h
@@ -69,4 +69,4 @@ constexpr std::array<std::string_view, ITEMS> EnumNames(const char *p) {
}
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_ENUM_CLASS_H_ */
+#endif // FORTRAN_COMMON_ENUM_CLASS_H_
diff --git a/FortranRuntime/include/flang/Common/enum-set.h b/flang/include/flang/Common/enum-set.h
similarity index 99%
rename from FortranRuntime/include/flang/Common/enum-set.h
rename to flang/include/flang/Common/enum-set.h
index 6100fc5e2e31c5..5290b76debee88 100644
--- a/FortranRuntime/include/flang/Common/enum-set.h
+++ b/flang/include/flang/Common/enum-set.h
@@ -228,4 +228,4 @@ struct std::hash<Fortran::common::EnumSet<ENUM, values>> {
return std::hash(x.bitset());
}
};
-#endif /* FORTRAN_COMMON_ENUM_SET_H_ */
+#endif // FORTRAN_COMMON_ENUM_SET_H_
diff --git a/FortranRuntime/include/flang/Common/fast-int-set.h b/flang/include/flang/Common/fast-int-set.h
similarity index 95%
rename from FortranRuntime/include/flang/Common/fast-int-set.h
rename to flang/include/flang/Common/fast-int-set.h
index fe3f1632060b50..d1c9c756a44a65 100644
--- a/FortranRuntime/include/flang/Common/fast-int-set.h
+++ b/flang/include/flang/Common/fast-int-set.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Common/fast-int-set.h ---------------------*- C++ -*-===//
+//===-- include/flang/Common/fast-int-set.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.
@@ -24,7 +24,7 @@
#ifndef FORTRAN_COMMON_FAST_INT_SET_H_
#define FORTRAN_COMMON_FAST_INT_SET_H_
-#include "flang/Common/optional.h"
+#include <optional>
namespace Fortran::common {
@@ -83,9 +83,9 @@ template <int N> class FastIntSet {
}
}
- optional<int> PopValue() {
+ std::optional<int> PopValue() {
if (IsEmpty()) {
- return nullopt;
+ return std::nullopt;
} else {
return value_[--size_];
}
@@ -103,4 +103,4 @@ template <int N> class FastIntSet {
bool isFullyInitialized_{false}; // memory was cleared
};
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_FAST_INT_SET_H_ */
+#endif // FORTRAN_COMMON_FAST_INT_SET_H_
diff --git a/FortranRuntime/include/flang/Common/float128.h b/flang/include/flang/Common/float128.h
similarity index 96%
rename from FortranRuntime/include/flang/Common/float128.h
rename to flang/include/flang/Common/float128.h
index a7036bf679e5ae..2e76bc0a162e61 100644
--- a/FortranRuntime/include/flang/Common/float128.h
+++ b/flang/include/flang/Common/float128.h
@@ -1,4 +1,4 @@
-/*===-- include/flang/Common/float128.h -----------------------------*- C -*-===
+/*===-- flang/Common/float128.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/FortranRuntime/include/flang/Common/format.h b/flang/include/flang/Common/format.h
similarity index 99%
rename from FortranRuntime/include/flang/Common/format.h
rename to flang/include/flang/Common/format.h
index 6f4dfc8d2376b7..138e84b72b733d 100644
--- a/FortranRuntime/include/flang/Common/format.h
+++ b/flang/include/flang/Common/format.h
@@ -901,4 +901,4 @@ template <typename CHAR> bool FormatValidator<CHAR>::Check() {
}
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_FORMAT_H_ */
+#endif // FORTRAN_COMMON_FORMAT_H_
diff --git a/FortranRuntime/include/flang/Common/idioms.h b/flang/include/flang/Common/idioms.h
similarity index 99%
rename from FortranRuntime/include/flang/Common/idioms.h
rename to flang/include/flang/Common/idioms.h
index 1ae0c0b35112e9..99f383ec75b999 100644
--- a/FortranRuntime/include/flang/Common/idioms.h
+++ b/flang/include/flang/Common/idioms.h
@@ -150,4 +150,4 @@ template <typename A, typename... B>
using IfNoLvalue = std::enable_if_t<(... && !std::is_lvalue_reference_v<B>), A>;
template <typename... RVREF> using NoLvalue = IfNoLvalue<void, RVREF...>;
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_IDIOMS_H_ */
+#endif // FORTRAN_COMMON_IDIOMS_H_
diff --git a/FortranRuntime/include/flang/Common/leading-zero-bit-count.h b/flang/include/flang/Common/leading-zero-bit-count.h
similarity index 98%
rename from FortranRuntime/include/flang/Common/leading-zero-bit-count.h
rename to flang/include/flang/Common/leading-zero-bit-count.h
index e788bfa9bcfd08..a296e0b446917f 100644
--- a/FortranRuntime/include/flang/Common/leading-zero-bit-count.h
+++ b/flang/include/flang/Common/leading-zero-bit-count.h
@@ -93,4 +93,4 @@ template <typename A> inline constexpr int BitsNeededFor(A x) {
return 8 * sizeof x - LeadingZeroBitCount(x);
}
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_LEADING_ZERO_BIT_COUNT_H_ */
+#endif // FORTRAN_COMMON_LEADING_ZERO_BIT_COUNT_H_
diff --git a/FortranRuntime/include/flang/Common/optional.h b/flang/include/flang/Common/optional.h
similarity index 98%
rename from FortranRuntime/include/flang/Common/optional.h
rename to flang/include/flang/Common/optional.h
index c3db3b1329a2fd..c0f4278009f40a 100644
--- a/FortranRuntime/include/flang/Common/optional.h
+++ b/flang/include/flang/Common/optional.h
@@ -23,8 +23,8 @@
// * cuda:: namespace need to be forced for all std:: references.
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_OPTIONAL_H_
-#define FORTRAN_COMMON_OPTIONAL_H_
+#ifndef FORTRAN_COMMON_OPTIONAL_H
+#define FORTRAN_COMMON_OPTIONAL_H
#include "flang/Common/api-attrs.h"
#include <optional>
@@ -240,4 +240,4 @@ using std::optional;
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_OPTIONAL_H_ */
+#endif // FORTRAN_COMMON_OPTIONAL_H
diff --git a/FortranRuntime/include/flang/Common/real.h b/flang/include/flang/Common/real.h
similarity index 99%
rename from FortranRuntime/include/flang/Common/real.h
rename to flang/include/flang/Common/real.h
index dc9a2404731e70..b527deda0e3b4f 100644
--- a/FortranRuntime/include/flang/Common/real.h
+++ b/flang/include/flang/Common/real.h
@@ -141,4 +141,4 @@ class RealCharacteristics {
};
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_REAL_H_ */
+#endif // FORTRAN_COMMON_REAL_H_
diff --git a/FortranRuntime/include/flang/Common/reference-wrapper.h b/flang/include/flang/Common/reference-wrapper.h
similarity index 96%
rename from FortranRuntime/include/flang/Common/reference-wrapper.h
rename to flang/include/flang/Common/reference-wrapper.h
index 6822fb335f398c..2983754108f95a 100644
--- a/FortranRuntime/include/flang/Common/reference-wrapper.h
+++ b/flang/include/flang/Common/reference-wrapper.h
@@ -22,8 +22,8 @@
//
// clang-format on
-#ifndef FORTRAN_COMMON_REFERENCE_WRAPPER_H_
-#define FORTRAN_COMMON_REFERENCE_WRAPPER_H_
+#ifndef FORTRAN_COMMON_REFERENCE_WRAPPER_H
+#define FORTRAN_COMMON_REFERENCE_WRAPPER_H
#include "flang/Common/api-attrs.h"
#include <functional>
@@ -111,4 +111,4 @@ using std::reference_wrapper;
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_REFERENCE_WRAPPER_H_ */
+#endif // FORTRAN_COMMON_REFERENCE_WRAPPER_H
diff --git a/FortranRuntime/include/flang/Common/restorer.h b/flang/include/flang/Common/restorer.h
similarity index 97%
rename from FortranRuntime/include/flang/Common/restorer.h
rename to flang/include/flang/Common/restorer.h
index a5c5ebe7344a1b..0f1bc48620d37e 100644
--- a/FortranRuntime/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 "flang/Common/api-attrs.h"
#include "idioms.h"
+#include "flang/Common/api-attrs.h"
namespace Fortran::common {
template <typename A> class Restorer {
public:
@@ -53,4 +53,4 @@ RT_API_ATTRS common::IfNoLvalue<Restorer<A>, B> ScopedSet(
return Restorer<A>{to, std::move(original)};
}
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_RESTORER_H_ */
+#endif // FORTRAN_COMMON_RESTORER_H_
diff --git a/FortranRuntime/include/flang/Common/target-rounding.h b/flang/include/flang/Common/target-rounding.h
similarity index 100%
rename from FortranRuntime/include/flang/Common/target-rounding.h
rename to flang/include/flang/Common/target-rounding.h
diff --git a/FortranRuntime/include/flang/Common/uint128.h b/flang/include/flang/Common/uint128.h
similarity index 99%
rename from FortranRuntime/include/flang/Common/uint128.h
rename to flang/include/flang/Common/uint128.h
index 1b2ee6a2c14b87..821c8c3b08a52f 100644
--- a/FortranRuntime/include/flang/Common/uint128.h
+++ b/flang/include/flang/Common/uint128.h
@@ -19,8 +19,8 @@
#define AVOID_NATIVE_UINT128_T 0
#endif
-#include "flang/Common/api-attrs.h"
#include "leading-zero-bit-count.h"
+#include "flang/Common/api-attrs.h"
#include <cstdint>
#include <type_traits>
@@ -303,4 +303,4 @@ template <int BITS>
using HostSignedIntType = typename HostSignedIntTypeHelper<BITS>::type;
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_UINT128_H_ */
+#endif
diff --git a/FortranRuntime/include/flang/Common/variant.h b/flang/include/flang/Common/variant.h
similarity index 89%
rename from FortranRuntime/include/flang/Common/variant.h
rename to flang/include/flang/Common/variant.h
index ff9b1aed4eba91..1af85876afac00 100644
--- a/FortranRuntime/include/flang/Common/variant.h
+++ b/flang/include/flang/Common/variant.h
@@ -11,8 +11,8 @@
// and the related names become available, though, they may correspond
// to alternative definitions (e.g. from cuda::std namespace).
-#ifndef FORTRAN_COMMON_VARIANT_H_
-#define FORTRAN_COMMON_VARIANT_H_
+#ifndef FORTRAN_COMMON_VARIANT_H
+#define FORTRAN_COMMON_VARIANT_H
#if RT_USE_LIBCUDACXX
#include <cuda/std/variant>
@@ -27,4 +27,4 @@ using cuda::std::visit;
#include <variant>
#endif // !RT_USE_LIBCUDACXX
-#endif /* FORTRAN_COMMON_VARIANT_H_ */
+#endif // FORTRAN_COMMON_VARIANT_H
diff --git a/FortranRuntime/include/flang/Common/visit.h b/flang/include/flang/Common/visit.h
similarity index 98%
rename from FortranRuntime/include/flang/Common/visit.h
rename to flang/include/flang/Common/visit.h
index 8030ac9be173c3..ad66297650b093 100644
--- a/FortranRuntime/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 "flang/Common/api-attrs.h"
#include "variant.h"
+#include "flang/Common/api-attrs.h"
#include <type_traits>
namespace Fortran::common {
@@ -100,4 +100,4 @@ using Fortran::common::log2visit::visit;
#endif
} // namespace Fortran::common
-#endif /* FORTRAN_COMMON_VISIT_H_ */
+#endif // FORTRAN_COMMON_VISIT_H_
diff --git a/FortranRuntime/include/flang/Common/windows-include.h b/flang/include/flang/Common/windows-include.h
similarity index 93%
rename from FortranRuntime/include/flang/Common/windows-include.h
rename to flang/include/flang/Common/windows-include.h
index bee79d4fceb3ba..75ef4974251ff9 100644
--- a/FortranRuntime/include/flang/Common/windows-include.h
+++ b/flang/include/flang/Common/windows-include.h
@@ -22,4 +22,4 @@
#endif // _WIN32
-#endif /* FORTRAN_COMMON_WINDOWS_INCLUDE_H_ */
+#endif // FORTRAN_COMMON_WINDOWS_INCLUDE_H_
diff --git a/flang/include/flang/ISO_Fortran_binding.h b/flang/include/flang/ISO_Fortran_binding.h
index 3361db27aa4517..89a10ce69a2ba2 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_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
+#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
#include <stddef.h>
#define FORTRAN_ISO_NAMESPACE_
#endif
diff --git a/flang/include/flang/Lower/Allocatable.h b/flang/include/flang/Lower/Allocatable.h
index 1209b157ed1f41..0e89af94af40f6 100644
--- a/flang/include/flang/Lower/Allocatable.h
+++ b/flang/include/flang/Lower/Allocatable.h
@@ -15,7 +15,7 @@
#include "flang/Lower/AbstractConverter.h"
#include "flang/Optimizer/Builder/MutableBox.h"
-#include "flang/Runtime/allocator-registry.h"
+#include "flang/Runtime/allocator-registry-consts.h"
#include "llvm/ADT/StringRef.h"
namespace mlir {
diff --git a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
index 3fc4201bd16c6c..78bb82b17d4050 100644
--- a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
@@ -397,7 +397,6 @@ struct IntrinsicLibrary {
fir::ExtendedValue genUbound(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
fir::ExtendedValue genUnpack(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
fir::ExtendedValue genVerify(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
- fir::ExtendedValue genNumericStorageSize(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
/// Implement all conversion functions like DBLE, the first argument is
/// the value to convert. There may be an additional KIND arguments that
diff --git a/flang/include/flang/Optimizer/Builder/MutableBox.h b/flang/include/flang/Optimizer/Builder/MutableBox.h
index fea7c7204837b4..39657ddaf6e03a 100644
--- a/flang/include/flang/Optimizer/Builder/MutableBox.h
+++ b/flang/include/flang/Optimizer/Builder/MutableBox.h
@@ -14,7 +14,7 @@
#define FORTRAN_OPTIMIZER_BUILDER_MUTABLEBOX_H
#include "flang/Optimizer/Builder/BoxValue.h"
-#include "flang/Runtime/allocator-registry.h"
+#include "flang/Runtime/allocator-registry-consts.h"
#include "llvm/ADT/StringRef.h"
namespace mlir {
diff --git a/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h b/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
index 31d1416846d0c9..b9a8a670d07938 100644
--- a/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
+++ b/flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
@@ -23,7 +23,7 @@
#define OPTIMIZER_DESCRIPTOR_MODEL_H
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/descriptor-consts.h"
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "llvm/Support/ErrorHandling.h"
diff --git a/FortranRuntime/include/flang/Runtime/CUDA/allocator.h b/flang/include/flang/Runtime/CUDA/allocator.h
similarity index 93%
rename from FortranRuntime/include/flang/Runtime/CUDA/allocator.h
rename to flang/include/flang/Runtime/CUDA/allocator.h
index 48185e8f34eaf6..cc88896b1f0bd6 100644
--- a/FortranRuntime/include/flang/Runtime/CUDA/allocator.h
+++ b/flang/include/flang/Runtime/CUDA/allocator.h
@@ -9,7 +9,7 @@
#ifndef FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
#define FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
-#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
#define CUDA_REPORT_IF_ERROR(expr) \
@@ -43,4 +43,4 @@ void *CUFAllocUnified(std::size_t);
void CUFFreeUnified(void *);
} // namespace Fortran::runtime::cuda
-#endif /* FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_ */
+#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
diff --git a/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h b/flang/include/flang/Runtime/CUDA/descriptor.h
similarity index 91%
rename from FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
rename to flang/include/flang/Runtime/CUDA/descriptor.h
index 68ad0987d9aecd..501a834f43bd42 100644
--- a/FortranRuntime/include/flang/Runtime/CUDA/descriptor.h
+++ b/flang/include/flang/Runtime/CUDA/descriptor.h
@@ -9,7 +9,7 @@
#ifndef FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_
#define FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_
-#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
#include <cstddef>
@@ -27,4 +27,4 @@ void RTDECL(CUFFreeDesciptor)(
} // extern "C"
} // namespace Fortran::runtime::cuda
-#endif /* FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_ */
+#endif // FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_
diff --git a/flang/include/flang/Runtime/README.md b/flang/include/flang/Runtime/README.md
new file mode 100644
index 00000000000000..a13a7e23162e98
--- /dev/null
+++ b/flang/include/flang/Runtime/README.md
@@ -0,0 +1,27 @@
+Files in this directory are used by Flang (the compiler) and FortranRuntime
+(the runtime library for Flang-compiled programs). They must be compatible by
+both. For definitions used only by Flang, consider
+`flang/{lib,include/flang}/Support` instead. For definitions used only by
+FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+
+The requirements for common code include:
+
+ * No dependence to LLVM, including LLVMSupport.
+
+ * No link-dependence to the C++ runtime. This means that e.g. `std::string`
+ cannot be used.
+
+ * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used
+ instead.
+
+ * Preprocessor macros from `config.h` and CMake
+ `(target/add)_compile_definitions` must be defined by both build scripts.
+ See `flang/cmake/modules/FlangCommon.cmake`.
+
+ * Some header files are included from `.c` files.
+ `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C.
+
+ * Global declarations may need to be annotated using definitions from
+ `api-attrs.h`.
+
+ * The `Runtime` component is header-only.
diff --git a/FortranRuntime/include/flang/Runtime/allocatable.h b/flang/include/flang/Runtime/allocatable.h
similarity index 97%
rename from FortranRuntime/include/flang/Runtime/allocatable.h
rename to flang/include/flang/Runtime/allocatable.h
index d7f3910074a760..480e987ed5ec6b 100644
--- a/FortranRuntime/include/flang/Runtime/allocatable.h
+++ b/flang/include/flang/Runtime/allocatable.h
@@ -11,10 +11,13 @@
#ifndef FORTRAN_RUNTIME_ALLOCATABLE_H_
#define FORTRAN_RUNTIME_ALLOCATABLE_H_
-#include "flang/Runtime/descriptor.h"
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
namespace Fortran::runtime {
+using SubscriptValue = ISO::CFI_index_t;
+using common::TypeCategory;
extern "C" {
@@ -129,4 +132,4 @@ void RTDECL(AllocatableDeallocateNoFinal)(
Descriptor &, const char *sourceFile = nullptr, int sourceLine = 0);
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_ALLOCATABLE_H_ */
+#endif // FORTRAN_RUNTIME_ALLOCATABLE_H_
diff --git a/flang/include/flang/Runtime/allocator-registry-consts.h b/flang/include/flang/Runtime/allocator-registry-consts.h
new file mode 100644
index 00000000000000..70735c2fc7a71c
--- /dev/null
+++ b/flang/include/flang/Runtime/allocator-registry-consts.h
@@ -0,0 +1,20 @@
+//===-- include/flang/Runtime/allocator-registry-consts.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_ALLOCATOR_REGISTRY_CONSTS_H_
+#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_
+
+static constexpr unsigned kDefaultAllocator = 0;
+
+// Allocator used for CUF
+static constexpr unsigned kPinnedAllocatorPos = 1;
+static constexpr unsigned kDeviceAllocatorPos = 2;
+static constexpr unsigned kManagedAllocatorPos = 3;
+static constexpr unsigned kUnifiedAllocatorPos = 4;
+
+#endif /* FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_ */
diff --git a/flang/include/flang/Runtime/array-constructor-consts.h b/flang/include/flang/Runtime/array-constructor-consts.h
new file mode 100644
index 00000000000000..da058874e50487
--- /dev/null
+++ b/flang/include/flang/Runtime/array-constructor-consts.h
@@ -0,0 +1,54 @@
+//===-- include/flang/Runtime/array-constructor-consts.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
+//
+//===----------------------------------------------------------------------===//
+
+// External APIs to create temporary storage for array constructors when their
+// final extents or length parameters cannot be pre-computed.
+
+#ifndef FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_CONSTS_H_
+#define FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_CONSTS_H_
+
+#include "flang/Runtime/descriptor-consts.h"
+#include "flang/Runtime/entry-names.h"
+#include <cstdint>
+
+namespace Fortran::runtime {
+struct ArrayConstructorVector;
+
+// Max sizeof(ArrayConstructorVector) and sizeof(ArrayConstructorVector) for any
+// target.
+// TODO: Use target-specific size/alignment instead of overapproximation.
+constexpr std::size_t MaxArrayConstructorVectorSizeInBytes = 2 * 40;
+constexpr std::size_t MaxArrayConstructorVectorAlignInBytes = 8;
+
+extern "C" {
+// API to initialize an ArrayConstructorVector before any values are pushed to
+// it. Inlined code is only expected to allocate the "ArrayConstructorVector"
+// class instance storage with sufficient size (using
+// "2*sizeof(ArrayConstructorVector)" on the host should be safe regardless of
+// the target the runtime is compiled for). This avoids the need for the runtime
+// to maintain a state, or to use dynamic allocation for it. "vectorClassSize"
+// is used to validate that lowering allocated enough space for it.
+void RTDECL(InitArrayConstructorVector)(ArrayConstructorVector &vector,
+ Descriptor &to, bool useValueLengthParameters, int vectorClassSize,
+ const char *sourceFile = nullptr, int sourceLine = 0);
+
+// Generic API to push any kind of entity into the array constructor (any
+// Fortran type and any rank).
+void RTDECL(PushArrayConstructorValue)(
+ ArrayConstructorVector &vector, const Descriptor &from);
+
+// API to push scalar array constructor value of:
+// - a numerical or logical type,
+// - or a derived type that has no length parameters, and no allocatable
+// component (that would require deep copies).
+// It requires no descriptor for the value that is passed via its base address.
+void RTDECL(PushArrayConstructorSimpleScalar)(
+ ArrayConstructorVector &vector, void *from);
+} // extern "C"
+} // namespace Fortran::runtime
+#endif /* FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_CONSTS_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/assign.h b/flang/include/flang/Runtime/assign.h
similarity index 98%
rename from FortranRuntime/include/flang/Runtime/assign.h
rename to flang/include/flang/Runtime/assign.h
index 55d15a5c046868..a1cc9eaf4355f6 100644
--- a/FortranRuntime/include/flang/Runtime/assign.h
+++ b/flang/include/flang/Runtime/assign.h
@@ -58,4 +58,4 @@ void RTDECL(AssignPolymorphic)(Descriptor &to, const Descriptor &from,
const char *sourceFile = nullptr, int sourceLine = 0);
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_ASSIGN_H_ */
+#endif // FORTRAN_RUNTIME_ASSIGN_H_
diff --git a/FortranRuntime/include/flang/Runtime/c-or-cpp.h b/flang/include/flang/Runtime/c-or-cpp.h
similarity index 95%
rename from FortranRuntime/include/flang/Runtime/c-or-cpp.h
rename to flang/include/flang/Runtime/c-or-cpp.h
index 3c0c0be643cbc3..8bac523907750c 100644
--- a/FortranRuntime/include/flang/Runtime/c-or-cpp.h
+++ b/flang/include/flang/Runtime/c-or-cpp.h
@@ -28,4 +28,4 @@
#define NORETURN IF_CPLUSPLUS([[noreturn]])
#define NO_ARGUMENTS IF_NOT_CPLUSPLUS(void)
-#endif /* FORTRAN_RUNTIME_C_OR_CPP_H_ */
+#endif // FORTRAN_RUNTIME_C_OR_CPP_H_
diff --git a/FortranRuntime/include/flang/Runtime/character.h b/flang/include/flang/Runtime/character.h
similarity index 99%
rename from FortranRuntime/include/flang/Runtime/character.h
rename to flang/include/flang/Runtime/character.h
index a842c30cd8120c..dd47686fe858fd 100644
--- a/FortranRuntime/include/flang/Runtime/character.h
+++ b/flang/include/flang/Runtime/character.h
@@ -129,4 +129,4 @@ void RTDECL(Verify)(Descriptor &result, const Descriptor &string,
const char *sourceFile = nullptr, int sourceLine = 0);
}
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_CHARACTER_H_ */
+#endif // FORTRAN_RUNTIME_CHARACTER_H_
diff --git a/FortranRuntime/include/flang/Runtime/command.h b/flang/include/flang/Runtime/command.h
similarity index 98%
rename from FortranRuntime/include/flang/Runtime/command.h
rename to flang/include/flang/Runtime/command.h
index 2bbdfca7631163..7ab3f6442dcf92 100644
--- a/FortranRuntime/include/flang/Runtime/command.h
+++ b/flang/include/flang/Runtime/command.h
@@ -62,4 +62,4 @@ std::int32_t RTNAME(GetCwd)(
}
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_COMMAND_H_ */
+#endif // FORTRAN_RUNTIME_COMMAND_H_
diff --git a/FortranRuntime/include/flang/Runtime/cpp-type.h b/flang/include/flang/Runtime/cpp-type.h
similarity index 98%
rename from FortranRuntime/include/flang/Runtime/cpp-type.h
rename to flang/include/flang/Runtime/cpp-type.h
index 7de1ea4f45f224..27b43de7d0f0f6 100644
--- a/FortranRuntime/include/flang/Runtime/cpp-type.h
+++ b/flang/include/flang/Runtime/cpp-type.h
@@ -110,4 +110,4 @@ template <> struct CppTypeForHelper<TypeCategory::Logical, 1> {
};
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_CPP_TYPE_H_ */
+#endif // FORTRAN_RUNTIME_CPP_TYPE_H_
diff --git a/FortranRuntime/include/flang/Runtime/derived-api.h b/flang/include/flang/Runtime/derived-api.h
similarity index 98%
rename from FortranRuntime/include/flang/Runtime/derived-api.h
rename to flang/include/flang/Runtime/derived-api.h
index ca1681e974051c..79aa7d82de8819 100644
--- a/FortranRuntime/include/flang/Runtime/derived-api.h
+++ b/flang/include/flang/Runtime/derived-api.h
@@ -63,4 +63,4 @@ bool RTDECL(ExtendsTypeOf)(const Descriptor &, const Descriptor &);
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_DERIVED_API_H_ */
+#endif // FORTRAN_RUNTIME_DERIVED_API_H_
diff --git a/flang/include/flang/Runtime/descriptor-consts.h b/flang/include/flang/Runtime/descriptor-consts.h
new file mode 100644
index 00000000000000..aa5e2e4ee8b45f
--- /dev/null
+++ b/flang/include/flang/Runtime/descriptor-consts.h
@@ -0,0 +1,73 @@
+//===-- include/flang/Runtime/descriptor-consts.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_DESCRIPTOR_CONSTS_H_
+#define FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_
+
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
+#include "flang/Common/api-attrs.h"
+#include <cstddef>
+#include <cstdint>
+
+// Value of the addendum presence flag.
+#define _CFI_ADDENDUM_FLAG 1
+// Number of bits needed to be shifted when manipulating the allocator index.
+#define _CFI_ALLOCATOR_IDX_SHIFT 1
+// Allocator index mask.
+#define _CFI_ALLOCATOR_IDX_MASK 0b00001110
+
+namespace Fortran::runtime::typeInfo {
+using TypeParameterValue = std::int64_t;
+class DerivedType;
+} // namespace Fortran::runtime::typeInfo
+
+namespace Fortran::runtime {
+class Descriptor;
+using SubscriptValue = ISO::CFI_index_t;
+
+/// Returns size in bytes of the descriptor (not the data)
+/// This must be at least as large as the largest descriptor of any target
+/// triple.
+static constexpr RT_API_ATTRS std::size_t MaxDescriptorSizeInBytes(
+ int rank, bool addendum = false, int lengthTypeParameters = 0) {
+ // Layout:
+ //
+ // fortran::runtime::Descriptor {
+ // ISO::CFI_cdesc_t {
+ // void *base_addr; (pointer -> up to 8 bytes)
+ // size_t elem_len; (up to 8 bytes)
+ // int version; (up to 4 bytes)
+ // CFI_rank_t rank; (unsigned char -> 1 byte)
+ // CFI_type_t type; (signed char -> 1 byte)
+ // CFI_attribute_t attribute; (unsigned char -> 1 byte)
+ // unsigned char extra; (1 byte)
+ // }
+ // }
+ // fortran::runtime::Dimension[rank] {
+ // ISO::CFI_dim_t {
+ // CFI_index_t lower_bound; (ptrdiff_t -> up to 8 bytes)
+ // CFI_index_t extent; (ptrdiff_t -> up to 8 bytes)
+ // CFI_index_t sm; (ptrdiff_t -> up to 8 bytes)
+ // }
+ // }
+ // fortran::runtime::DescriptorAddendum {
+ // const typeInfo::DerivedType *derivedType_; (pointer -> up to 8
+ // bytes) typeInfo::TypeParameterValue len_[lenParameters]; (int64_t -> 8
+ // bytes)
+ // }
+ std::size_t bytes{24u + rank * 24u};
+ if (addendum || lengthTypeParameters > 0) {
+ if (lengthTypeParameters < 1)
+ lengthTypeParameters = 1;
+ bytes += 8u + static_cast<std::size_t>(lengthTypeParameters) * 8u;
+ }
+ return bytes;
+}
+
+} // namespace Fortran::runtime
+#endif /* FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_ */
diff --git a/FortranRuntime/include/flang/Runtime/entry-names.h b/flang/include/flang/Runtime/entry-names.h
similarity index 89%
rename from FortranRuntime/include/flang/Runtime/entry-names.h
rename to flang/include/flang/Runtime/entry-names.h
index 25134771bf9185..68582b92b54941 100644
--- a/FortranRuntime/include/flang/Runtime/entry-names.h
+++ b/flang/include/flang/Runtime/entry-names.h
@@ -1,10 +1,11 @@
-/*===-- include/flang/Runtime/entry-names.h -------------------------*- C -*-===
+/*===-- include/flang/Runtime/entry-names.h -------------------------*- C -*-=//
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
* See https://llvm.org/LICENSE.txt for license information.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*
- *===----------------------------------------------------------------------===*/
+ *===------------------------------------------------------------------------===
+ */
/* Defines the macro RTNAME(n) which decorates the external name of a runtime
* library function or object with extra characters so that it
@@ -15,8 +16,8 @@
* The value of REVISION should not be changed until/unless the API to the
* runtime library must change in some way that breaks backward compatibility.
*/
-#ifndef FORTRAN_RUNTIME_ENTRY_NAMES_H_
-#define FORTRAN_RUNTIME_ENTRY_NAMES_H_
+#ifndef FORTRAN_RUNTIME_ENTRY_NAMES_H
+#define FORTRAN_RUNTIME_ENTRY_NAMES_H
#include "flang/Common/api-attrs.h"
@@ -40,4 +41,4 @@
#define RTNAME_STRING(name) RTNAME_STRINGIFY(RTNAME(name))
#endif
-#endif /* FORTRAN_RUNTIME_ENTRY_NAMES_H_ */
+#endif /* !FORTRAN_RUNTIME_ENTRY_NAMES_H */
diff --git a/FortranRuntime/include/flang/Runtime/exceptions.h b/flang/include/flang/Runtime/exceptions.h
similarity index 86%
rename from FortranRuntime/include/flang/Runtime/exceptions.h
rename to flang/include/flang/Runtime/exceptions.h
index f2c67325b34d92..1ab22da103a50f 100644
--- a/FortranRuntime/include/flang/Runtime/exceptions.h
+++ b/flang/include/flang/Runtime/exceptions.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/exceptions.h ----------------------*- C++ -*-===//
+//===-- include/flang/Runtime/exceptions.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.
@@ -26,4 +26,4 @@ std::uint32_t RTNAME(MapException)(std::uint32_t excepts);
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_EXCEPTIONS_H_ */
+#endif // FORTRAN_RUNTIME_EXCEPTIONS_H_
diff --git a/FortranRuntime/include/flang/Runtime/execute.h b/flang/include/flang/Runtime/execute.h
similarity index 89%
rename from FortranRuntime/include/flang/Runtime/execute.h
rename to flang/include/flang/Runtime/execute.h
index d1958a82594ffd..ca137b9d1823c4 100644
--- a/FortranRuntime/include/flang/Runtime/execute.h
+++ b/flang/include/flang/Runtime/execute.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/execute.h -------------------------*- C++ -*-===//
+//===-- include/flang/Runtime/command.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.
@@ -26,4 +26,4 @@ void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait = true,
}
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_EXECUTE_H_ */
+#endif // FORTRAN_RUNTIME_EXECUTE_H_
diff --git a/FortranRuntime/include/flang/Runtime/extensions.h b/flang/include/flang/Runtime/extensions.h
similarity index 97%
rename from FortranRuntime/include/flang/Runtime/extensions.h
rename to flang/include/flang/Runtime/extensions.h
index f46ccdd7d9528d..fef651f3b2eedb 100644
--- a/FortranRuntime/include/flang/Runtime/extensions.h
+++ b/flang/include/flang/Runtime/extensions.h
@@ -52,4 +52,4 @@ std::int64_t FORTRAN_PROCEDURE_NAME(access)(const char *name,
#endif
} // extern "C"
-#endif /* FORTRAN_RUNTIME_EXTENSIONS_H_ */
+#endif // FORTRAN_RUNTIME_EXTENSIONS_H_
diff --git a/FortranRuntime/include/flang/Runtime/freestanding-tools.h b/flang/include/flang/Runtime/freestanding-tools.h
similarity index 99%
rename from FortranRuntime/include/flang/Runtime/freestanding-tools.h
rename to flang/include/flang/Runtime/freestanding-tools.h
index 8aeef54ba0af3d..e94cb0a6c938cd 100644
--- a/FortranRuntime/include/flang/Runtime/freestanding-tools.h
+++ b/flang/include/flang/Runtime/freestanding-tools.h
@@ -215,4 +215,4 @@ using std::toupper;
#endif // !STD_TOUPPER_UNSUPPORTED
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_FREESTANDING_TOOLS_H_ */
+#endif // FORTRAN_RUNTIME_FREESTANDING_TOOLS_H_
diff --git a/FortranRuntime/include/flang/Runtime/inquiry.h b/flang/include/flang/Runtime/inquiry.h
similarity index 91%
rename from FortranRuntime/include/flang/Runtime/inquiry.h
rename to flang/include/flang/Runtime/inquiry.h
index 83b07cf2f31a47..c7a7487f1a1b18 100644
--- a/FortranRuntime/include/flang/Runtime/inquiry.h
+++ b/flang/include/flang/Runtime/inquiry.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/inquiry.h -------------------------*- C++ -*-===//
+//===-- include/flang/Runtime/inquiry.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.
@@ -40,4 +40,4 @@ void RTDECL(Ubound)(void *result, const Descriptor &array, int kind,
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_INQUIRY_H_ */
+#endif // FORTRAN_RUNTIME_INQUIRY_H_
diff --git a/FortranRuntime/include/flang/Runtime/io-api.h b/flang/include/flang/Runtime/io-api.h
similarity index 98%
rename from FortranRuntime/include/flang/Runtime/io-api.h
rename to flang/include/flang/Runtime/io-api.h
index be948061c241a0..e588b46dc4b3a1 100644
--- a/FortranRuntime/include/flang/Runtime/io-api.h
+++ b/flang/include/flang/Runtime/io-api.h
@@ -11,10 +11,10 @@
#ifndef FORTRAN_RUNTIME_IO_API_H_
#define FORTRAN_RUNTIME_IO_API_H_
-#include "flang/Common/magic-numbers.h"
#include "flang/Common/uint128.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/iostat.h"
+#include "flang/Runtime/magic-numbers.h"
#include <cinttypes>
#include <cstddef>
@@ -51,9 +51,6 @@ constexpr InquiryKeywordHash HashInquiryKeyword(const char *p) {
return hash;
}
-RT_API_ATTRS const char *InquiryKeywordHashDecode(
- char *buffer, std::size_t, InquiryKeywordHash);
-
extern "C" {
#define IONAME(name) RTNAME(io##name)
@@ -369,4 +366,4 @@ enum Iostat IODECL(EndIoStatement)(Cookie);
} // extern "C"
} // namespace Fortran::runtime::io
-#endif /* FORTRAN_RUNTIME_IO_API_H_ */
+#endif
diff --git a/FortranRuntime/include/flang/Runtime/iostat.h b/flang/include/flang/Runtime/iostat.h
similarity index 96%
rename from FortranRuntime/include/flang/Runtime/iostat.h
rename to flang/include/flang/Runtime/iostat.h
index 9a52990045ee13..0565718f6c103d 100644
--- a/FortranRuntime/include/flang/Runtime/iostat.h
+++ b/flang/include/flang/Runtime/iostat.h
@@ -12,7 +12,7 @@
#ifndef FORTRAN_RUNTIME_IOSTAT_H_
#define FORTRAN_RUNTIME_IOSTAT_H_
#include "flang/Common/api-attrs.h"
-#include "flang/Common/magic-numbers.h"
+#include "flang/Runtime/magic-numbers.h"
namespace Fortran::runtime::io {
// The value of IOSTAT= is zero when no error, end-of-record,
@@ -89,7 +89,5 @@ enum Iostat {
IostatNonExternalDefinedUnformattedIo,
};
-RT_API_ATTRS const char *IostatErrorString(int);
-
} // namespace Fortran::runtime::io
-#endif /* FORTRAN_RUNTIME_IOSTAT_H_ */
+#endif // FORTRAN_RUNTIME_IOSTAT_H_
diff --git a/FortranRuntime/include/flang/Common/magic-numbers.h b/flang/include/flang/Runtime/magic-numbers.h
similarity index 98%
rename from FortranRuntime/include/flang/Common/magic-numbers.h
rename to flang/include/flang/Runtime/magic-numbers.h
index 931df690766219..bab0e9ae05299a 100644
--- a/FortranRuntime/include/flang/Common/magic-numbers.h
+++ b/flang/include/flang/Runtime/magic-numbers.h
@@ -1,10 +1,10 @@
-#if 0 /*===-- include/flang/Runtime/magic-numbers.h ---------------*- C -*-===*/
- *
+#if 0 /*===-- include/flang/Runtime/magic-numbers.h -----------------------===*/
+/*
* 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
*
-/*===----------------------------------------------------------------------===*/
+ *===----------------------------------------------------------------------===*/
#endif
#if 0
This header can be included into both Fortran and C.
diff --git a/FortranRuntime/include/flang/Runtime/main.h b/flang/include/flang/Runtime/main.h
similarity index 95%
rename from FortranRuntime/include/flang/Runtime/main.h
rename to flang/include/flang/Runtime/main.h
index 98fcf1250d0ad6..88232ea64fa6ab 100644
--- a/FortranRuntime/include/flang/Runtime/main.h
+++ b/flang/include/flang/Runtime/main.h
@@ -20,4 +20,4 @@ void RTNAME(ProgramStart)(
void RTNAME(ByteswapOption)(void); // -byteswapio
FORTRAN_EXTERN_C_END
-#endif /* FORTRAN_RUNTIME_MAIN_H_ */
+#endif // FORTRAN_RUNTIME_MAIN_H_
diff --git a/FortranRuntime/include/flang/Runtime/matmul-instances.inc b/flang/include/flang/Runtime/matmul-instances.inc
similarity index 100%
rename from FortranRuntime/include/flang/Runtime/matmul-instances.inc
rename to flang/include/flang/Runtime/matmul-instances.inc
diff --git a/FortranRuntime/include/flang/Runtime/matmul-transpose.h b/flang/include/flang/Runtime/matmul-transpose.h
similarity index 97%
rename from FortranRuntime/include/flang/Runtime/matmul-transpose.h
rename to flang/include/flang/Runtime/matmul-transpose.h
index 077277fae2da86..2d79ca10e08958 100644
--- a/FortranRuntime/include/flang/Runtime/matmul-transpose.h
+++ b/flang/include/flang/Runtime/matmul-transpose.h
@@ -46,4 +46,4 @@ void RTDECL(MatmulTransposeDirect)(const Descriptor &, const Descriptor &,
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_MATMUL_TRANSPOSE_H_ */
+#endif // FORTRAN_RUNTIME_MATMUL_TRANSPOSE_H_
diff --git a/FortranRuntime/include/flang/Runtime/matmul.h b/flang/include/flang/Runtime/matmul.h
similarity index 97%
rename from FortranRuntime/include/flang/Runtime/matmul.h
rename to flang/include/flang/Runtime/matmul.h
index cd375ac43d77f2..a72d4a06ee4594 100644
--- a/FortranRuntime/include/flang/Runtime/matmul.h
+++ b/flang/include/flang/Runtime/matmul.h
@@ -45,4 +45,4 @@ void RTDECL(MatmulDirect)(const Descriptor &, const Descriptor &,
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_MATMUL_H_ */
+#endif // FORTRAN_RUNTIME_MATMUL_H_
diff --git a/FortranRuntime/include/flang/Runtime/misc-intrinsic.h b/flang/include/flang/Runtime/misc-intrinsic.h
similarity index 95%
rename from FortranRuntime/include/flang/Runtime/misc-intrinsic.h
rename to flang/include/flang/Runtime/misc-intrinsic.h
index 1d4163c2e1e751..3fb3aaed49c0fb 100644
--- a/FortranRuntime/include/flang/Runtime/misc-intrinsic.h
+++ b/flang/include/flang/Runtime/misc-intrinsic.h
@@ -28,4 +28,4 @@ void RTDECL(TransferSize)(Descriptor &result, const Descriptor &source,
std::int64_t size);
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_MISC_INTRINSIC_H_ */
+#endif // FORTRAN_RUNTIME_MISC_INTRINSIC_H_
diff --git a/FortranRuntime/include/flang/Runtime/numeric.h b/flang/include/flang/Runtime/numeric.h
similarity index 99%
rename from FortranRuntime/include/flang/Runtime/numeric.h
rename to flang/include/flang/Runtime/numeric.h
index 5fbab2e069b739..84a5a7cd7a361c 100644
--- a/FortranRuntime/include/flang/Runtime/numeric.h
+++ b/flang/include/flang/Runtime/numeric.h
@@ -455,4 +455,4 @@ CppTypeFor<TypeCategory::Real, 16> RTDECL(FPow16k)(
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_NUMERIC_H_ */
+#endif // FORTRAN_RUNTIME_NUMERIC_H_
diff --git a/FortranRuntime/include/flang/Runtime/pointer.h b/flang/include/flang/Runtime/pointer.h
similarity index 97%
rename from FortranRuntime/include/flang/Runtime/pointer.h
rename to flang/include/flang/Runtime/pointer.h
index b7322ad92bd583..c6d29db7218376 100644
--- a/FortranRuntime/include/flang/Runtime/pointer.h
+++ b/flang/include/flang/Runtime/pointer.h
@@ -12,10 +12,14 @@
#ifndef FORTRAN_RUNTIME_POINTER_H_
#define FORTRAN_RUNTIME_POINTER_H_
-#include "flang/Runtime/descriptor.h"
+#include "flang/Common/Fortran-consts.h"
+#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
namespace Fortran::runtime {
+using SubscriptValue = ISO::CFI_index_t;
+using common::TypeCategory;
+
extern "C" {
// Data pointer initialization for NULLIFY(), "p=>NULL()`, & for ALLOCATE().
diff --git a/FortranRuntime/include/flang/Runtime/ragged.h b/flang/include/flang/Runtime/ragged.h
similarity index 96%
rename from FortranRuntime/include/flang/Runtime/ragged.h
rename to flang/include/flang/Runtime/ragged.h
index 8574bc1fa110c8..f52a619c55b43e 100644
--- a/FortranRuntime/include/flang/Runtime/ragged.h
+++ b/flang/include/flang/Runtime/ragged.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/ragged.h --------------------------*- C++ -*-===//
+//===-- Runtime/ragged.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.
@@ -57,4 +57,4 @@ void RTDECL(RaggedArrayDeallocate)(void *raggedArrayHeader);
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_RAGGED_H_ */
+#endif // FORTRAN_RUNTIME_RAGGED_H_
diff --git a/FortranRuntime/include/flang/Runtime/random.h b/flang/include/flang/Runtime/random.h
similarity index 100%
rename from FortranRuntime/include/flang/Runtime/random.h
rename to flang/include/flang/Runtime/random.h
diff --git a/FortranRuntime/include/flang/Runtime/reduce.h b/flang/include/flang/Runtime/reduce.h
similarity index 99%
rename from FortranRuntime/include/flang/Runtime/reduce.h
rename to flang/include/flang/Runtime/reduce.h
index ae2828f04bf7c0..60f54c393b4bbd 100644
--- a/FortranRuntime/include/flang/Runtime/reduce.h
+++ b/flang/include/flang/Runtime/reduce.h
@@ -435,4 +435,4 @@ void RTDECL(ReduceDerivedTypeDim)(Descriptor &result, const Descriptor &array,
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_REDUCE_H_ */
+#endif // FORTRAN_RUNTIME_REDUCE_H_
diff --git a/FortranRuntime/include/flang/Runtime/reduction.h b/flang/include/flang/Runtime/reduction.h
similarity index 99%
rename from FortranRuntime/include/flang/Runtime/reduction.h
rename to flang/include/flang/Runtime/reduction.h
index e00593fbc9f75e..97986c12e8a10e 100644
--- a/FortranRuntime/include/flang/Runtime/reduction.h
+++ b/flang/include/flang/Runtime/reduction.h
@@ -444,4 +444,4 @@ bool RTDECL(DotProductLogical)(const Descriptor &, const Descriptor &,
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_REDUCTION_H_ */
+#endif // FORTRAN_RUNTIME_REDUCTION_H_
diff --git a/FortranRuntime/include/flang/Runtime/stop.h b/flang/include/flang/Runtime/stop.h
similarity index 97%
rename from FortranRuntime/include/flang/Runtime/stop.h
rename to flang/include/flang/Runtime/stop.h
index 9ba41343c6f964..f7c4ffe7403e8e 100644
--- a/FortranRuntime/include/flang/Runtime/stop.h
+++ b/flang/include/flang/Runtime/stop.h
@@ -37,4 +37,4 @@ NORETURN void RTNAME(ReportFatalUserError)(
FORTRAN_EXTERN_C_END
-#endif /* FORTRAN_RUNTIME_STOP_H_ */
+#endif // FORTRAN_RUNTIME_STOP_H_
diff --git a/FortranRuntime/include/flang/Runtime/support.h b/flang/include/flang/Runtime/support.h
similarity index 97%
rename from FortranRuntime/include/flang/Runtime/support.h
rename to flang/include/flang/Runtime/support.h
index 9c9b067a18f2e4..4a6d4357e87103 100644
--- a/FortranRuntime/include/flang/Runtime/support.h
+++ b/flang/include/flang/Runtime/support.h
@@ -47,4 +47,4 @@ void RTDECL(CopyAndUpdateDescriptor)(Descriptor &to, const Descriptor &from,
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_SUPPORT_H_ */
+#endif // FORTRAN_RUNTIME_SUPPORT_H_
diff --git a/FortranRuntime/include/flang/Runtime/temporary-stack.h b/flang/include/flang/Runtime/temporary-stack.h
similarity index 98%
rename from FortranRuntime/include/flang/Runtime/temporary-stack.h
rename to flang/include/flang/Runtime/temporary-stack.h
index f83fab7b0ac811..3c1a4ea11a4352 100644
--- a/FortranRuntime/include/flang/Runtime/temporary-stack.h
+++ b/flang/include/flang/Runtime/temporary-stack.h
@@ -64,4 +64,4 @@ void RTNAME(DestroyDescriptorStack)(void *opaquePtr);
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_TEMPORARY_STACK_H_ */
+#endif // FORTRAN_RUNTIME_TEMPORARY_STACK_H_
diff --git a/FortranRuntime/include/flang/Runtime/time-intrinsic.h b/flang/include/flang/Runtime/time-intrinsic.h
similarity index 97%
rename from FortranRuntime/include/flang/Runtime/time-intrinsic.h
rename to flang/include/flang/Runtime/time-intrinsic.h
index 0e63fc6a4647a4..80490a17e45597 100644
--- a/FortranRuntime/include/flang/Runtime/time-intrinsic.h
+++ b/flang/include/flang/Runtime/time-intrinsic.h
@@ -48,4 +48,4 @@ void RTNAME(Etime)(const Descriptor *values, const Descriptor *time,
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_TIME_INTRINSIC_H_ */
+#endif // FORTRAN_RUNTIME_TIME_INTRINSIC_H_
diff --git a/FortranRuntime/include/flang/Runtime/transformational.h b/flang/include/flang/Runtime/transformational.h
similarity index 99%
rename from FortranRuntime/include/flang/Runtime/transformational.h
rename to flang/include/flang/Runtime/transformational.h
index 266dd9d7aebc24..a39b872f376a69 100644
--- a/FortranRuntime/include/flang/Runtime/transformational.h
+++ b/flang/include/flang/Runtime/transformational.h
@@ -154,4 +154,4 @@ void RTDECL(Unpack)(Descriptor &result, const Descriptor &vector,
} // extern "C"
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_TRANSFORMATIONAL_H_ */
+#endif // FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
diff --git a/flang/include/flang/Support/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
index 718ce680afeeab..1423d2c83d22cc 100644
--- a/flang/include/flang/Support/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#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/enum-set.h"
#include "flang/Common/idioms.h"
@@ -191,4 +191,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/Support/Fortran.h b/flang/include/flang/Support/Fortran.h
index 343a0b30d2ba9c..7a9b0d56d6b2ac 100644
--- a/flang/include/flang/Support/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,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#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.
@@ -107,4 +107,4 @@ inline std::string GetExternalAssemblyName(
}
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_FORTRAN_H_
+#endif /* FORTRAN_SUPPORT_FORTRAN_H_ */
diff --git a/flang/include/flang/Support/MathOptionsBase.h b/flang/include/flang/Support/MathOptionsBase.h
index a739ba3e066599..072aed20da4708 100644
--- a/flang/include/flang/Support/MathOptionsBase.h
+++ b/flang/include/flang/Support/MathOptionsBase.h
@@ -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 {
@@ -41,4 +41,4 @@ class MathOptionsBase {
} // namespace Fortran::common
-#endif // FORTRAN_COMMON_MATHOPTIONSBASE_H
+#endif /* FORTRAN_SUPPORT_MATHOPTIONSBASE_H_ */
diff --git a/flang/include/flang/Support/Version.h b/flang/include/flang/Support/Version.h
index 643ddd2e27f69a..4ceb19e7f4d714 100644
--- a/flang/include/flang/Support/Version.h
+++ b/flang/include/flang/Support/Version.h
@@ -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/Support/default-kinds.h b/flang/include/flang/Support/default-kinds.h
index e78a08dfae6cc3..92f06e6fe2d272 100644
--- a/flang/include/flang/Support/default-kinds.h
+++ b/flang/include/flang/Support/default-kinds.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#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/Support/Fortran.h"
#include <cstdint>
@@ -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/Support/indirection.h b/flang/include/flang/Support/indirection.h
index 1221a659323503..aeb1698516bae9 100644
--- a/flang/include/flang/Support/indirection.h
+++ b/flang/include/flang/Support/indirection.h
@@ -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
@@ -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/Support/interval.h b/flang/include/flang/Support/interval.h
index 2918cc54de3926..99c0784f006a80 100644
--- a/flang/include/flang/Support/interval.h
+++ b/flang/include/flang/Support/interval.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#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).
@@ -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/Support/template.h b/flang/include/flang/Support/template.h
index 58c9b0a5628e8a..36fa6f7072b40c 100644
--- a/flang/include/flang/Support/template.h
+++ b/flang/include/flang/Support/template.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_COMMON_TEMPLATE_H_
-#define FORTRAN_COMMON_TEMPLATE_H_
+#ifndef FORTRAN_SUPPORT_TEMPLATE_H_
+#define FORTRAN_SUPPORT_TEMPLATE_H_
#include "flang/Common/idioms.h"
#include "flang/Common/variant.h"
@@ -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/Support/unwrap.h b/flang/include/flang/Support/unwrap.h
index d8fa553dedda3f..e890753499d1a1 100644
--- a/flang/include/flang/Support/unwrap.h
+++ b/flang/include/flang/Support/unwrap.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#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"
@@ -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/Testing/README.md b/flang/include/flang/Testing/README.md
new file mode 100644
index 00000000000000..a722732fb76407
--- /dev/null
+++ b/flang/include/flang/Testing/README.md
@@ -0,0 +1,25 @@
+Files in this directory are used by Flang (the compiler) and FortranRuntime
+(the runtime library for Flang-compiled programs). They must be compatible by
+both. For definitions used only by Flang, consider
+`flang/{lib,include/flang}/Support` instead. For definitions used only by
+FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+
+The requirements for common code include:
+
+ * No dependence to LLVM, including LLVMSupport.
+
+ * No link-dependence to the C++ runtime. This means that e.g. `std::string`
+ cannot be used.
+
+ * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used
+ instead.
+
+ * Preprocessor macros from `config.h` and CMake
+ `(target/add)_compile_definitions` must be defined by both build scripts.
+ See `flang/cmake/modules/FlangCommon.cmake`.
+
+ * Some header files are included from `.c` files.
+ `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C.
+
+ * Global declarations may need to be annotated using definitions from
+ `api-attrs.h`.
diff --git a/FortranRuntime/include/flang/Testing/fp-testing.h b/flang/include/flang/Testing/fp-testing.h
similarity index 100%
rename from FortranRuntime/include/flang/Testing/fp-testing.h
rename to flang/include/flang/Testing/fp-testing.h
diff --git a/FortranRuntime/include/flang/Testing/testing.h b/flang/include/flang/Testing/testing.h
similarity index 100%
rename from FortranRuntime/include/flang/Testing/testing.h
rename to flang/include/flang/Testing/testing.h
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index f7fdc74a32ec8c..8039bd8a51ee82 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -6,7 +6,7 @@
#
#===------------------------------------------------------------------------===#
-add_flang_library(FortranCommon
- "${FORTRANRUNTIME_SOURCE_DIR}/lib/Common/binary-to-decimal.cpp"
- "${FORTRANRUNTIME_SOURCE_DIR}/lib/Common/decimal-to-binary.cpp"
+add_flang_library(FortranCommon
+ binary-to-decimal.cpp
+ decimal-to-binary.cpp
)
diff --git a/flang/lib/Common/README.md b/flang/lib/Common/README.md
new file mode 100644
index 00000000000000..a722732fb76407
--- /dev/null
+++ b/flang/lib/Common/README.md
@@ -0,0 +1,25 @@
+Files in this directory are used by Flang (the compiler) and FortranRuntime
+(the runtime library for Flang-compiled programs). They must be compatible by
+both. For definitions used only by Flang, consider
+`flang/{lib,include/flang}/Support` instead. For definitions used only by
+FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+
+The requirements for common code include:
+
+ * No dependence to LLVM, including LLVMSupport.
+
+ * No link-dependence to the C++ runtime. This means that e.g. `std::string`
+ cannot be used.
+
+ * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used
+ instead.
+
+ * Preprocessor macros from `config.h` and CMake
+ `(target/add)_compile_definitions` must be defined by both build scripts.
+ See `flang/cmake/modules/FlangCommon.cmake`.
+
+ * Some header files are included from `.c` files.
+ `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C.
+
+ * Global declarations may need to be annotated using definitions from
+ `api-attrs.h`.
diff --git a/FortranRuntime/lib/Common/big-radix-floating-point.h b/flang/lib/Common/big-radix-floating-point.h
similarity index 100%
rename from FortranRuntime/lib/Common/big-radix-floating-point.h
rename to flang/lib/Common/big-radix-floating-point.h
diff --git a/FortranRuntime/lib/Common/binary-to-decimal.cpp b/flang/lib/Common/binary-to-decimal.cpp
similarity index 100%
rename from FortranRuntime/lib/Common/binary-to-decimal.cpp
rename to flang/lib/Common/binary-to-decimal.cpp
diff --git a/FortranRuntime/lib/Common/decimal-to-binary.cpp b/flang/lib/Common/decimal-to-binary.cpp
similarity index 100%
rename from FortranRuntime/lib/Common/decimal-to-binary.cpp
rename to flang/lib/Common/decimal-to-binary.cpp
diff --git a/flang/lib/Evaluate/fold-logical.cpp b/flang/lib/Evaluate/fold-logical.cpp
index a7e1aad38f3586..ee6655f8387177 100644
--- a/flang/lib/Evaluate/fold-logical.cpp
+++ b/flang/lib/Evaluate/fold-logical.cpp
@@ -9,8 +9,8 @@
#include "fold-implementation.h"
#include "fold-matmul.h"
#include "fold-reduction.h"
-#include "flang/Common/magic-numbers.h"
#include "flang/Evaluate/check-expression.h"
+#include "flang/Runtime/magic-numbers.h"
namespace Fortran::evaluate {
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index f76d44f5479d32..82bedca7bd41dd 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -39,7 +39,7 @@
#include "flang/Optimizer/Support/FatalError.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Optimizer/Support/Utils.h"
-#include "flang/Runtime/allocator-registry.h"
+#include "flang/Runtime/allocator-registry-consts.h"
#include "flang/Semantics/runtime-type-info.h"
#include "flang/Semantics/tools.h"
#include "llvm/Support/CommandLine.h"
diff --git a/flang/lib/Optimizer/Builder/Runtime/ArrayConstructor.cpp b/flang/lib/Optimizer/Builder/Runtime/ArrayConstructor.cpp
index c786bef5cb1c4c..b7c6dc5fb2bf6c 100644
--- a/flang/lib/Optimizer/Builder/Runtime/ArrayConstructor.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/ArrayConstructor.cpp
@@ -9,7 +9,7 @@
#include "flang/Optimizer/Builder/Runtime/ArrayConstructor.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
-#include "flang/Runtime/array-constructor.h"
+#include "flang/Runtime/array-constructor-consts.h"
using namespace Fortran::runtime;
@@ -29,8 +29,8 @@ mlir::Value fir::runtime::genInitArrayConstructorVector(
// the target. The "cookieSize" argument is used to validate this wild
// assumption until runtime interfaces are improved.
std::size_t arrayVectorStructBitSize =
- 2 * sizeof(Fortran::runtime::ArrayConstructorVector) * 8;
- std::size_t alignLike = alignof(Fortran::runtime::ArrayConstructorVector) * 8;
+ MaxArrayConstructorVectorSizeInBytes * 8;
+ std::size_t alignLike = MaxArrayConstructorVectorAlignInBytes * 8;
fir::SequenceType::Extent numElem =
(arrayVectorStructBitSize + alignLike - 1) / alignLike;
mlir::Type intType = builder.getIntegerType(alignLike);
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 88293bcf36a780..eed389380f7cca 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -23,8 +23,8 @@
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Optimizer/Support/TypeCode.h"
#include "flang/Optimizer/Support/Utils.h"
-#include "flang/Runtime/allocator-registry.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/allocator-registry-consts.h"
+#include "flang/Runtime/descriptor-consts.h"
#include "flang/Semantics/runtime-type-info.h"
#include "mlir/Conversion/ArithCommon/AttrToLLVMConverter.h"
#include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"
@@ -1273,16 +1273,12 @@ struct EmboxCommonConversion : public fir::FIROpConversion<OP> {
insertField(rewriter, loc, descriptor, {kExtraPosInBox}, extraField);
} else {
// Compute the value of the extra field based on allocator_idx and
- // addendum present using a Descriptor object.
- Fortran::runtime::StaticDescriptor staticDescriptor;
- Fortran::runtime::Descriptor &desc{staticDescriptor.descriptor()};
- desc.raw().extra = 0;
- desc.SetAllocIdx(allocatorIdx);
+ // addendum present.
+ unsigned extra = allocatorIdx << _CFI_ALLOCATOR_IDX_SHIFT;
if (hasAddendum)
- desc.SetHasAddendum();
- descriptor =
- insertField(rewriter, loc, descriptor, {kExtraPosInBox},
- this->genI32Constant(loc, rewriter, desc.raw().extra));
+ extra |= _CFI_ADDENDUM_FLAG;
+ descriptor = insertField(rewriter, loc, descriptor, {kExtraPosInBox},
+ this->genI32Constant(loc, rewriter, extra));
}
if (hasAddendum) {
diff --git a/flang/lib/Semantics/compute-offsets.cpp b/flang/lib/Semantics/compute-offsets.cpp
index b5a58ddca0ecdd..c5774ed30de748 100644
--- a/flang/lib/Semantics/compute-offsets.cpp
+++ b/flang/lib/Semantics/compute-offsets.cpp
@@ -11,7 +11,7 @@
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/shape.h"
#include "flang/Evaluate/type.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/descriptor-consts.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
@@ -341,8 +341,12 @@ auto ComputeOffsetsHelper::GetSizeAndAlignment(
const auto *derived{evaluate::GetDerivedTypeSpec(dyType)};
int lenParams{derived ? CountLenParameters(*derived) : 0};
bool needAddendum{derived || (dyType && dyType->IsUnlimitedPolymorphic())};
- std::size_t size{runtime::Descriptor::SizeInBytes(
+
+ // FIXME: Get descriptor size from targetCharacteristics instead
+ // overapproximation
+ std::size_t size{runtime::MaxDescriptorSizeInBytes(
symbol.Rank(), needAddendum, lenParams)};
+
return {size, targetCharacteristics.descriptorAlignment()};
}
if (IsProcedurePointer(symbol)) {
diff --git a/flang/lib/Testing/CMakeLists.txt b/flang/lib/Testing/CMakeLists.txt
new file mode 100644
index 00000000000000..d5caada3fb68e8
--- /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
+#
+#===------------------------------------------------------------------------===#
+
+set(public_headers "")
+file(GLOB_RECURSE public_headers
+ "${FLANGRUNTIME_SOURCE_DIR}/lib/Testing/*.h"
+)
+
+add_fortranruntime_library(NonGTestTesting EXCLUDE_FROM_ALL LINK_TO_LLVM
+ testing.cpp
+ fp-testing.cpp
+ ADDITIONAL_HEADERS
+ ${public_headers}
+)
+
diff --git a/flang/lib/Testing/README.md b/flang/lib/Testing/README.md
new file mode 100644
index 00000000000000..a722732fb76407
--- /dev/null
+++ b/flang/lib/Testing/README.md
@@ -0,0 +1,25 @@
+Files in this directory are used by Flang (the compiler) and FortranRuntime
+(the runtime library for Flang-compiled programs). They must be compatible by
+both. For definitions used only by Flang, consider
+`flang/{lib,include/flang}/Support` instead. For definitions used only by
+FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+
+The requirements for common code include:
+
+ * No dependence to LLVM, including LLVMSupport.
+
+ * No link-dependence to the C++ runtime. This means that e.g. `std::string`
+ cannot be used.
+
+ * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used
+ instead.
+
+ * Preprocessor macros from `config.h` and CMake
+ `(target/add)_compile_definitions` must be defined by both build scripts.
+ See `flang/cmake/modules/FlangCommon.cmake`.
+
+ * Some header files are included from `.c` files.
+ `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C.
+
+ * Global declarations may need to be annotated using definitions from
+ `api-attrs.h`.
diff --git a/FortranRuntime/lib/Testing/fp-testing.cpp b/flang/lib/Testing/fp-testing.cpp
similarity index 100%
rename from FortranRuntime/lib/Testing/fp-testing.cpp
rename to flang/lib/Testing/fp-testing.cpp
diff --git a/FortranRuntime/lib/Testing/testing.cpp b/flang/lib/Testing/testing.cpp
similarity index 100%
rename from FortranRuntime/lib/Testing/testing.cpp
rename to flang/lib/Testing/testing.cpp
diff --git a/flang/module/__fortran_builtins.f90 b/flang/module/__fortran_builtins.f90
index fe91305c836ff4..d1d4a639e70d72 100644
--- a/flang/module/__fortran_builtins.f90
+++ b/flang/module/__fortran_builtins.f90
@@ -6,7 +6,7 @@
!
!===------------------------------------------------------------------------===!
-#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'
+#include '../include/flang/Runtime/magic-numbers.h'
! These naming shenanigans prevent names from Fortran intrinsic modules
! from being usable on INTRINSIC statements, and force the program
diff --git a/flang/module/__fortran_ieee_exceptions.f90 b/flang/module/__fortran_ieee_exceptions.f90
index 56f79a473b556a..6691012eda238a 100644
--- a/flang/module/__fortran_ieee_exceptions.f90
+++ b/flang/module/__fortran_ieee_exceptions.f90
@@ -11,7 +11,7 @@
! here under another name so that IEEE_ARITHMETIC can USE it and export its
! declarations without clashing with a non-intrinsic module in a program.
-#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'
+#include '../include/flang/Runtime/magic-numbers.h'
module __fortran_ieee_exceptions
use __fortran_builtins, only: &
diff --git a/flang/module/ieee_arithmetic.f90 b/flang/module/ieee_arithmetic.f90
index 667374d0660806..7eaa7db55af9f8 100644
--- a/flang/module/ieee_arithmetic.f90
+++ b/flang/module/ieee_arithmetic.f90
@@ -8,7 +8,7 @@
! Fortran 2018 Clause 17
-#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'
+#include '../include/flang/Runtime/magic-numbers.h'
module ieee_arithmetic
! F18 Clause 17.1p1:
diff --git a/flang/module/iso_fortran_env.f90 b/flang/module/iso_fortran_env.f90
index d1f956b6b86408..4e575b422c2a04 100644
--- a/flang/module/iso_fortran_env.f90
+++ b/flang/module/iso_fortran_env.f90
@@ -8,7 +8,7 @@
! See Fortran 2023, subclause 16.10.2
-#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'
+#include '../include/flang/Runtime/magic-numbers.h'
module iso_fortran_env
diff --git a/FortranRuntime/unittests/Common/CMakeLists.txt b/flang/unittests/Common/CMakeLists.txt
similarity index 100%
rename from FortranRuntime/unittests/Common/CMakeLists.txt
rename to flang/unittests/Common/CMakeLists.txt
diff --git a/FortranRuntime/unittests/Common/FastIntSetTest.cpp b/flang/unittests/Common/FastIntSetTest.cpp
similarity index 97%
rename from FortranRuntime/unittests/Common/FastIntSetTest.cpp
rename to flang/unittests/Common/FastIntSetTest.cpp
index a36a334e370eb9..bd1b953fa16631 100644
--- a/FortranRuntime/unittests/Common/FastIntSetTest.cpp
+++ b/flang/unittests/Common/FastIntSetTest.cpp
@@ -1,4 +1,4 @@
-//===-- unittests/Common/FastIntSetTest.cpp ---------------------*- C++ -*-===//
+//===-- flang/unittests/Common/FastIntSetTest.cpp ---------------*- 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/fast-int-set.h"
#include "gtest/gtest.h"
+#include "flang/Common/fast-int-set.h"
#include <optional>
TEST(FastIntSetTests, Sanity) {
diff --git a/FortranRuntime/unittests/Decimal/CMakeLists.txt b/flang/unittests/Decimal/CMakeLists.txt
similarity index 100%
rename from FortranRuntime/unittests/Decimal/CMakeLists.txt
rename to flang/unittests/Decimal/CMakeLists.txt
diff --git a/FortranRuntime/unittests/Decimal/quick-sanity-test.cpp b/flang/unittests/Decimal/quick-sanity-test.cpp
similarity index 92%
rename from FortranRuntime/unittests/Decimal/quick-sanity-test.cpp
rename to flang/unittests/Decimal/quick-sanity-test.cpp
index 0e8ff0ce48b3c6..c36c73b817e1f9 100644
--- a/FortranRuntime/unittests/Decimal/quick-sanity-test.cpp
+++ b/flang/unittests/Decimal/quick-sanity-test.cpp
@@ -1,11 +1,3 @@
-//===-- unittests/Decimal/quick-sanity-test.cpp -----------------*- 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/decimal.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
diff --git a/FortranRuntime/unittests/Decimal/thorough-test.cpp b/flang/unittests/Decimal/thorough-test.cpp
similarity index 86%
rename from FortranRuntime/unittests/Decimal/thorough-test.cpp
rename to flang/unittests/Decimal/thorough-test.cpp
index 0648b61d7c1cda..0f7a2d4b33e764 100644
--- a/FortranRuntime/unittests/Decimal/thorough-test.cpp
+++ b/flang/unittests/Decimal/thorough-test.cpp
@@ -1,11 +1,3 @@
-//===-- unittests/Decimal/thorough-test.cpp ---------------------*- 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/decimal.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 324195348d045b..0cb0fc4dd52531 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -1,7 +1,7 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_library(FortranEvaluateTesting
- ${FORTRANRUNTIME_SOURCE_DIR}/lib/Testing/testing.cpp
- ${FORTRANRUNTIME_SOURCE_DIR}/lib/Testing/fp-testing.cpp
+ ${FLANG_SOURCE_DIR}/lib/Testing/testing.cpp
+ ${FLANG_SOURCE_DIR}/lib/Testing/fp-testing.cpp
)
set_target_properties(FortranEvaluateTesting PROPERTIES FOLDER "Flang/Tests")
if (LLVM_LINK_LLVM_DYLIB)
diff --git a/flang/unittests/Optimizer/Builder/Runtime/AllocatableTest.cpp b/flang/unittests/Optimizer/Builder/Runtime/AllocatableTest.cpp
index 1db43cacc90f07..f618e72d7b7f3c 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/AllocatableTest.cpp
+++ b/flang/unittests/Optimizer/Builder/Runtime/AllocatableTest.cpp
@@ -9,7 +9,7 @@
#include "flang/Optimizer/Builder/Runtime/Allocatable.h"
#include "RuntimeCallTestBase.h"
#include "gtest/gtest.h"
-#include "flang/Runtime/descriptor.h"
+#include "flang/Runtime/descriptor-consts.h"
using namespace Fortran::runtime;
>From 83910a4f7e9035152a3a8ed5cf3cc72a7335df36 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 16 Oct 2024 12:08:47 +0200
Subject: [PATCH 19/58] FortranRuntime -> flang-rt
---
.../test/NonGtestUnit/lit.site.cfg.py.in | 13 ---
FortranRuntime/test/Unit/lit.site.cfg.py.in | 14 ---
FortranRuntime/test/lit.site.cfg.py.in | 18 ----
clang/lib/Driver/ToolChains/CommonArgs.cpp | 4 +-
clang/lib/Driver/ToolChains/Flang.cpp | 8 +-
{FortranRuntime => flang-rt}/.clang-format | 0
{FortranRuntime => flang-rt}/.clang-tidy | 0
{FortranRuntime => flang-rt}/CMakeLists.txt | 82 +++++++++---------
{FortranRuntime => flang-rt}/CODE_OWNERS.TXT | 0
{FortranRuntime => flang-rt}/LICENSE.TXT | 0
{FortranRuntime => flang-rt}/README.md | 62 ++++++-------
.../cmake/config.h.cmake.in | 0
.../cmake/modules/AddFlangRT.cmake | 44 +++++-----
.../cmake/modules/AddFlangRTOffload.cmake | 24 +++---
.../include/flang-rt/CufRuntime}/allocator.h | 8 +-
.../flang-rt/flang_rt}/allocator-registry.h | 8 +-
.../flang-rt/flang_rt}/array-constructor.h | 10 +--
.../include/flang-rt/flang_rt}/descriptor.h | 12 +--
.../include/flang-rt/flang_rt}/io-api-funcs.h | 8 +-
.../include/flang-rt/flang_rt}/iostat-funcs.h | 8 +-
.../include/flang-rt/flang_rt}/memory.h | 8 +-
.../include/flang-rt/flang_rt}/type-code.h | 8 +-
.../lib/CMakeLists.txt | 10 ++-
.../lib/CufRuntime}/CMakeLists.txt | 6 +-
.../lib/CufRuntime}/allocator.cpp | 18 ++--
.../lib/CufRuntime}/descriptor.cpp | 6 +-
.../lib/FortranFloat128Math}/CMakeLists.txt | 9 +-
.../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 | 2 +-
.../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 | 8 +-
.../lib/FortranFloat128Math}/mod-real.cpp | 2 +-
.../lib/FortranFloat128Math}/modulo-real.cpp | 2 +-
.../lib/FortranFloat128Math}/nearest.cpp | 2 +-
.../lib/FortranFloat128Math}/norm2.cpp | 2 +-
.../numeric-template-specs.h | 8 +-
.../lib/FortranFloat128Math}/pow.cpp | 2 +-
.../lib/FortranFloat128Math}/random.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/Testing/CMakeLists.txt | 2 +-
.../lib/flang_rt}/CMakeLists.txt | 63 +++++++-------
.../lib/flang_rt}/ISO_Fortran_binding.cpp | 6 +-
.../lib/flang_rt}/ISO_Fortran_util.h | 12 +--
.../lib/flang_rt}/allocatable.cpp | 4 +-
.../lib/flang_rt}/allocator-registry.cpp | 8 +-
.../lib/flang_rt}/array-constructor.cpp | 6 +-
.../lib/flang_rt}/assign-impl.h | 0
.../lib/flang_rt}/assign.cpp | 4 +-
.../lib/flang_rt}/buffer.cpp | 2 +-
.../lib/flang_rt}/buffer.h | 10 +--
.../lib/flang_rt}/character.cpp | 4 +-
.../lib/flang_rt}/command.cpp | 4 +-
.../lib/flang_rt}/complex-powi.cpp | 2 +-
.../lib/flang_rt}/complex-reduction.c | 2 +-
.../lib/flang_rt}/complex-reduction.h | 8 +-
.../lib/flang_rt}/connection.cpp | 2 +-
.../lib/flang_rt}/connection.h | 8 +-
.../lib/flang_rt}/copy.cpp | 4 +-
.../Runtime => flang-rt/lib/flang_rt}/copy.h | 10 +--
.../lib/flang_rt}/derived-api.cpp | 4 +-
.../lib/flang_rt}/derived.cpp | 4 +-
.../lib/flang_rt}/derived.h | 8 +-
.../lib/flang_rt}/descriptor-io.cpp | 2 +-
.../lib/flang_rt}/descriptor-io.h | 10 +--
.../lib/flang_rt}/descriptor.cpp | 6 +-
.../lib/flang_rt}/dot-product.cpp | 4 +-
.../lib/flang_rt}/edit-input.cpp | 2 +-
.../lib/flang_rt}/edit-input.h | 8 +-
.../lib/flang_rt}/edit-output.cpp | 2 +-
.../lib/flang_rt}/edit-output.h | 8 +-
.../lib/flang_rt}/emit-encoded.h | 8 +-
.../lib/flang_rt}/environment-default-list.h | 0
.../lib/flang_rt}/environment.cpp | 6 +-
.../lib/flang_rt}/environment.h | 8 +-
.../lib/flang_rt}/exceptions.cpp | 2 +-
.../lib/flang_rt}/execute.cpp | 4 +-
.../lib/flang_rt}/extensions.cpp | 6 +-
.../lib/flang_rt}/external-unit.cpp | 2 +-
.../lib/flang_rt}/extrema.cpp | 2 +-
.../lib/flang_rt}/file.cpp | 4 +-
.../Runtime => flang-rt/lib/flang_rt}/file.h | 10 +--
.../lib/flang_rt}/findloc.cpp | 2 +-
.../lib/flang_rt}/format-implementation.h | 8 +-
.../lib/flang_rt}/format.cpp | 2 +-
.../lib/flang_rt}/format.h | 8 +-
.../lib/flang_rt}/inquiry.cpp | 4 +-
.../lib/flang_rt}/internal-unit.cpp | 4 +-
.../lib/flang_rt}/internal-unit.h | 10 +--
.../lib/flang_rt}/io-api-common.h | 10 +--
.../lib/flang_rt}/io-api-minimal.cpp | 4 +-
.../lib/flang_rt}/io-api.cpp | 8 +-
.../lib/flang_rt}/io-error.cpp | 2 +-
.../lib/flang_rt}/io-error.h | 12 +--
.../lib/flang_rt}/io-stmt.cpp | 4 +-
.../lib/flang_rt}/io-stmt.h | 12 +--
.../lib/flang_rt}/iostat.cpp | 4 +-
.../Runtime => flang-rt/lib/flang_rt}/lock.h | 8 +-
.../lib/flang_rt}/main.cpp | 2 +-
.../lib/flang_rt}/matmul-transpose.cpp | 4 +-
.../lib/flang_rt}/matmul.cpp | 4 +-
.../lib/flang_rt}/memory.cpp | 4 +-
.../lib/flang_rt}/misc-intrinsic.cpp | 4 +-
.../lib/flang_rt}/namelist.cpp | 4 +-
.../lib/flang_rt}/namelist.h | 8 +-
.../lib/flang_rt}/non-tbp-dio.cpp | 2 +-
.../lib/flang_rt}/non-tbp-dio.h | 8 +-
.../lib/flang_rt}/numeric-templates.h | 8 +-
.../lib/flang_rt}/numeric.cpp | 2 +-
.../lib/flang_rt}/pointer.cpp | 2 +-
.../lib/flang_rt}/product.cpp | 2 +-
.../lib/flang_rt}/pseudo-unit.cpp | 2 +-
.../lib/flang_rt}/ragged.cpp | 2 +-
.../lib/flang_rt}/random-templates.h | 10 +--
.../lib/flang_rt}/random.cpp | 4 +-
.../lib/flang_rt}/reduce.cpp | 4 +-
.../lib/flang_rt}/reduction-templates.h | 10 +--
.../lib/flang_rt}/reduction.cpp | 4 +-
.../Runtime => flang-rt/lib/flang_rt}/stack.h | 10 +--
.../lib/flang_rt}/stat.cpp | 4 +-
.../Runtime => flang-rt/lib/flang_rt}/stat.h | 8 +-
.../lib/flang_rt}/stop.cpp | 2 +-
.../Runtime => flang-rt/lib/flang_rt}/sum.cpp | 2 +-
.../lib/flang_rt}/support.cpp | 4 +-
.../lib/flang_rt}/temporary-stack.cpp | 6 +-
.../lib/flang_rt}/terminator.cpp | 2 +-
.../lib/flang_rt}/terminator.h | 8 +-
.../lib/flang_rt}/time-intrinsic.cpp | 6 +-
.../lib/flang_rt}/tools.cpp | 2 +-
.../Runtime => flang-rt/lib/flang_rt}/tools.h | 12 +--
.../lib/flang_rt}/transformational.cpp | 4 +-
.../lib/flang_rt}/type-code.cpp | 4 +-
.../lib/flang_rt}/type-info.cpp | 2 +-
.../lib/flang_rt}/type-info.h | 10 +--
.../lib/flang_rt}/unit-map.cpp | 2 +-
.../lib/flang_rt}/unit-map.h | 10 +--
.../lib/flang_rt}/unit.cpp | 6 +-
.../Runtime => flang-rt/lib/flang_rt}/unit.h | 10 +--
.../Runtime => flang-rt/lib/flang_rt}/utf.cpp | 6 +-
.../Runtime => flang-rt/lib/flang_rt}/utf.h | 8 +-
.../test/CMakeLists.txt | 32 +++----
.../test/Driver/ctofortran.f90 | 0
.../test/Driver/exec.f90 | 0
.../test/NonGtestUnit/lit.cfg.py | 6 +-
flang-rt/test/NonGtestUnit/lit.site.cfg.py.in | 14 +++
.../test/Runtime/no-cpp-dep.c | 6 +-
.../test/Unit/lit.cfg.py | 6 +-
flang-rt/test/Unit/lit.site.cfg.py.in | 15 ++++
{FortranRuntime => flang-rt}/test/lit.cfg.py | 8 +-
flang-rt/test/lit.site.cfg.py.in | 17 ++++
.../unittests/CMakeLists.txt | 26 +++---
.../unittests/Evaluate/CMakeLists.txt | 8 +-
.../Evaluate/ISO-Fortran-binding.cpp | 2 +-
.../unittests/Evaluate/reshape.cpp | 2 +-
.../unittests/Runtime/AccessTest.cpp | 0
.../unittests/Runtime/Allocatable.cpp | 0
.../unittests/Runtime/ArrayConstructor.cpp | 6 +-
.../unittests/Runtime/BufferTest.cpp | 2 +-
.../unittests/Runtime/CMakeLists.txt | 6 +-
.../unittests/Runtime/CUDA/AllocatorCUF.cpp | 14 +--
.../unittests/Runtime/CUDA/CMakeLists.txt | 4 +-
.../unittests/Runtime/CharacterTest.cpp | 2 +-
.../unittests/Runtime/CommandTest.cpp | 2 +-
.../unittests/Runtime/Complex.cpp | 0
.../unittests/Runtime/CrashHandlerFixture.cpp | 2 +-
.../unittests/Runtime/CrashHandlerFixture.h | 0
.../unittests/Runtime/Derived.cpp | 2 +-
.../unittests/Runtime/ExternalIOTest.cpp | 4 +-
.../unittests/Runtime/Format.cpp | 6 +-
.../unittests/Runtime/Inquiry.cpp | 2 +-
.../unittests/Runtime/ListInputTest.cpp | 6 +-
.../unittests/Runtime/LogicalFormatTest.cpp | 4 +-
.../unittests/Runtime/Matmul.cpp | 4 +-
.../unittests/Runtime/MatmulTranspose.cpp | 4 +-
.../unittests/Runtime/MiscIntrinsic.cpp | 2 +-
.../unittests/Runtime/Namelist.cpp | 6 +-
.../unittests/Runtime/Numeric.cpp | 0
.../unittests/Runtime/NumericalFormatTest.cpp | 4 +-
.../unittests/Runtime/Pointer.cpp | 2 +-
.../unittests/Runtime/Ragged.cpp | 0
.../unittests/Runtime/Random.cpp | 4 +-
.../unittests/Runtime/Reduction.cpp | 4 +-
.../unittests/Runtime/RuntimeCrashTest.cpp | 2 +-
.../unittests/Runtime/Stop.cpp | 2 +-
.../unittests/Runtime/Support.cpp | 2 +-
.../unittests/Runtime/TemporaryStack.cpp | 4 +-
.../unittests/Runtime/Time.cpp | 0
.../unittests/Runtime/Transformational.cpp | 2 +-
.../unittests/Runtime/tools.h | 4 +-
flang/CMakeLists.txt | 7 +-
.../cmake/modules/FlangCommon.cmake | 86 +++++++++----------
flang/docs/FlangDriver.md | 8 +-
flang/docs/GettingStarted.md | 34 ++++----
flang/docs/OpenACC-descriptor-management.md | 2 +-
flang/docs/ReleaseNotes.md | 13 +--
.../ExternalHelloWorld/CMakeLists.txt | 2 +-
flang/include/flang/Common/README.md | 6 +-
flang/include/flang/ISO_Fortran_binding.h | 16 +++-
flang/include/flang/Runtime/README.md | 4 +-
flang/include/flang/Testing/README.md | 6 +-
flang/lib/Common/README.md | 6 +-
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +-
.../Optimizer/Transforms/CufOpConversion.cpp | 2 +-
flang/lib/Testing/CMakeLists.txt | 20 -----
flang/lib/Testing/README.md | 6 +-
.../module}/iso_fortran_env_impl.f90 | 4 +-
.../test/Driver/gcc-toolchain-install-dir.f90 | 2 +-
flang/test/Driver/linker-flags.f90 | 8 +-
.../test/Driver/msvc-dependent-lib-flags.f90 | 8 +-
flang/tools/f18/CMakeLists.txt | 24 ++----
flang/unittests/Common/CMakeLists.txt | 4 +-
flang/unittests/Decimal/CMakeLists.txt | 8 +-
lld/COFF/MinGW.cpp | 10 +--
llvm/CMakeLists.txt | 2 +-
llvm/projects/CMakeLists.txt | 4 +-
llvm/runtimes/CMakeLists.txt | 6 +-
runtimes/CMakeLists.txt | 4 +-
255 files changed, 815 insertions(+), 838 deletions(-)
delete mode 100644 FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in
delete mode 100644 FortranRuntime/test/Unit/lit.site.cfg.py.in
delete mode 100644 FortranRuntime/test/lit.site.cfg.py.in
rename {FortranRuntime => flang-rt}/.clang-format (100%)
rename {FortranRuntime => flang-rt}/.clang-tidy (100%)
rename {FortranRuntime => flang-rt}/CMakeLists.txt (54%)
rename {FortranRuntime => flang-rt}/CODE_OWNERS.TXT (100%)
rename {FortranRuntime => flang-rt}/LICENSE.TXT (100%)
rename {FortranRuntime => flang-rt}/README.md (76%)
rename {FortranRuntime => flang-rt}/cmake/config.h.cmake.in (100%)
rename FortranRuntime/cmake/modules/AddFortranRuntime.cmake => flang-rt/cmake/modules/AddFlangRT.cmake (72%)
rename FortranRuntime/cmake/modules/AddFortranOffloadRuntime.cmake => flang-rt/cmake/modules/AddFlangRTOffload.cmake (82%)
rename {flang/include/flang/Runtime/CUDA => flang-rt/include/flang-rt/CufRuntime}/allocator.h (85%)
rename {FortranRuntime/include/FortranRuntime/Runtime => flang-rt/include/flang-rt/flang_rt}/allocator-registry.h (87%)
rename {FortranRuntime/include/FortranRuntime/Runtime => flang-rt/include/flang-rt/flang_rt}/array-constructor.h (85%)
rename {FortranRuntime/include/FortranRuntime/Runtime => flang-rt/include/flang-rt/flang_rt}/descriptor.h (98%)
rename {FortranRuntime/include/FortranRuntime/Runtime => flang-rt/include/flang-rt/flang_rt}/io-api-funcs.h (84%)
rename {FortranRuntime/include/FortranRuntime/Runtime => flang-rt/include/flang-rt/flang_rt}/iostat-funcs.h (75%)
rename {FortranRuntime/include/FortranRuntime/Runtime => flang-rt/include/flang-rt/flang_rt}/memory.h (96%)
rename {FortranRuntime/include/FortranRuntime/Runtime => flang-rt/include/flang-rt/flang_rt}/type-code.h (93%)
rename {FortranRuntime => flang-rt}/lib/CMakeLists.txt (71%)
rename {FortranRuntime/lib/Runtime/CUDA => flang-rt/lib/CufRuntime}/CMakeLists.txt (87%)
rename {FortranRuntime/lib/Runtime/CUDA => flang-rt/lib/CufRuntime}/allocator.cpp (81%)
rename {FortranRuntime/lib/Runtime/CUDA => flang-rt/lib/CufRuntime}/descriptor.cpp (82%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/CMakeLists.txt (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/acos.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/acosh.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/asin.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/asinh.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/atan.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/atan2.cpp (91%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/atanh.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/ceil.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/complex-math.c (96%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/complex-math.h (88%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/cos.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/cosh.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/erf.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/erfc.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/exp.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/exponent.cpp (92%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/floor.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/fma.cpp (91%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/fraction.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/hypot.cpp (91%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/j0.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/j1.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/jn.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/lgamma.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/llround.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/log.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/log10.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/lround.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/math-entries.h (97%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/mod-real.cpp (91%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/modulo-real.cpp (91%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/nearest.cpp (91%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/norm2.cpp (94%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/numeric-template-specs.h (84%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/pow.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/random.cpp (91%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/round.cpp (92%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/rrspacing.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/scale.cpp (92%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/set-exponent.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/sin.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/sinh.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/spacing.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/sqrt.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/tan.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/tanh.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/tgamma.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/trunc.cpp (91%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/y0.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/y1.cpp (90%)
rename {FortranRuntime/lib/Runtime/Float128Math => flang-rt/lib/FortranFloat128Math}/yn.cpp (90%)
rename {FortranRuntime => flang-rt}/lib/Testing/CMakeLists.txt (89%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/CMakeLists.txt (66%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/ISO_Fortran_binding.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/ISO_Fortran_util.h (91%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/allocatable.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/allocator-registry.cpp (85%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/array-constructor.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/assign-impl.h (100%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/assign.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/buffer.cpp (93%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/buffer.h (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/character.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/command.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/complex-powi.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/complex-reduction.c (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/complex-reduction.h (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/connection.cpp (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/connection.h (96%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/copy.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/copy.h (78%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/derived-api.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/derived.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/derived.h (88%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/descriptor-io.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/descriptor-io.h (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/descriptor.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/dot-product.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/edit-input.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/edit-input.h (90%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/edit-output.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/edit-output.h (96%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/emit-encoded.h (94%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/environment-default-list.h (100%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/environment.cpp (96%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/environment.h (91%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/exceptions.cpp (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/execute.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/extensions.cpp (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/external-unit.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/extrema.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/file.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/file.h (94%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/findloc.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/format-implementation.h (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/format.cpp (93%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/format.h (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/inquiry.cpp (96%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/internal-unit.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/internal-unit.h (89%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/io-api-common.h (92%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/io-api-minimal.cpp (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/io-api.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/io-error.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/io-error.h (90%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/io-stmt.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/io-stmt.h (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/iostat.cpp (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/lock.h (94%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/main.cpp (95%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/matmul-transpose.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/matmul.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/memory.cpp (92%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/misc-intrinsic.cpp (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/namelist.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/namelist.h (91%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/non-tbp-dio.cpp (93%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/non-tbp-dio.h (91%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/numeric-templates.h (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/numeric.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/pointer.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/product.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/pseudo-unit.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/ragged.cpp (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/random-templates.h (91%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/random.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/reduce.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/reduction-templates.h (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/reduction.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/stack.h (94%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/stat.cpp (96%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/stat.h (93%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/stop.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/sum.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/support.cpp (93%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/temporary-stack.cpp (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/terminator.cpp (97%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/terminator.h (95%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/time-intrinsic.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/tools.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/tools.h (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/transformational.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/type-code.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/type-info.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/type-info.h (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/unit-map.cpp (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/unit-map.h (93%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/unit.cpp (99%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/unit.h (98%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/utf.cpp (96%)
rename {FortranRuntime/lib/Runtime => flang-rt/lib/flang_rt}/utf.h (94%)
rename {FortranRuntime => flang-rt}/test/CMakeLists.txt (57%)
rename {FortranRuntime => flang-rt}/test/Driver/ctofortran.f90 (100%)
rename {FortranRuntime => flang-rt}/test/Driver/exec.f90 (100%)
rename {FortranRuntime => flang-rt}/test/NonGtestUnit/lit.cfg.py (75%)
create mode 100644 flang-rt/test/NonGtestUnit/lit.site.cfg.py.in
rename {FortranRuntime => flang-rt}/test/Runtime/no-cpp-dep.c (87%)
rename {FortranRuntime => flang-rt}/test/Unit/lit.cfg.py (73%)
create mode 100644 flang-rt/test/Unit/lit.site.cfg.py.in
rename {FortranRuntime => flang-rt}/test/lit.cfg.py (89%)
create mode 100644 flang-rt/test/lit.site.cfg.py.in
rename {FortranRuntime => flang-rt}/unittests/CMakeLists.txt (72%)
rename {FortranRuntime => flang-rt}/unittests/Evaluate/CMakeLists.txt (73%)
rename {FortranRuntime => flang-rt}/unittests/Evaluate/ISO-Fortran-binding.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Evaluate/reshape.cpp (98%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/AccessTest.cpp (100%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Allocatable.cpp (100%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/ArrayConstructor.cpp (97%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/BufferTest.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/CMakeLists.txt (90%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/CUDA/AllocatorCUF.cpp (90%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/CUDA/CMakeLists.txt (89%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/CharacterTest.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/CommandTest.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Complex.cpp (100%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/CrashHandlerFixture.cpp (96%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/CrashHandlerFixture.h (100%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Derived.cpp (98%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/ExternalIOTest.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Format.cpp (97%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Inquiry.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/ListInputTest.cpp (98%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/LogicalFormatTest.cpp (95%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Matmul.cpp (98%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/MatmulTranspose.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/MiscIntrinsic.cpp (98%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Namelist.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Numeric.cpp (100%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/NumericalFormatTest.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Pointer.cpp (98%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Ragged.cpp (100%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Random.cpp (95%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Reduction.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/RuntimeCrashTest.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Stop.cpp (98%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Support.cpp (98%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/TemporaryStack.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Time.cpp (100%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/Transformational.cpp (99%)
rename {FortranRuntime => flang-rt}/unittests/Runtime/tools.h (95%)
rename {FortranRuntime => flang}/cmake/modules/FlangCommon.cmake (93%)
delete mode 100644 flang/lib/Testing/CMakeLists.txt
rename {FortranRuntime/lib/Runtime => flang/module}/iso_fortran_env_impl.f90 (97%)
diff --git a/FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in b/FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in
deleted file mode 100644
index 3d1780a5d600a9..00000000000000
--- a/FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in
+++ /dev/null
@@ -1,13 +0,0 @@
- at LIT_SITE_CFG_IN_HEADER@
-
-import os
-
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.fortranruntime_binary_dir = "@FORTRANRUNTIME_BINARY_DIR@"
-config.fortranruntime_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, "@FORTRANRUNTIME_SOURCE_DIR@/test/NonGtestUnit/lit.cfg.py")
diff --git a/FortranRuntime/test/Unit/lit.site.cfg.py.in b/FortranRuntime/test/Unit/lit.site.cfg.py.in
deleted file mode 100644
index fa993aa897faca..00000000000000
--- a/FortranRuntime/test/Unit/lit.site.cfg.py.in
+++ /dev/null
@@ -1,14 +0,0 @@
- at LIT_SITE_CFG_IN_HEADER@
-
-import os
-
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_build_mode = "@LLVM_BUILD_MODE@"
-config.fortranruntime_binary_dir = "@FORTRANRUNTIME_BINARY_DIR@"
-config.fortranruntime_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, "@FORTRANRUNTIME_SOURCE_DIR@/test/Unit/lit.cfg.py")
diff --git a/FortranRuntime/test/lit.site.cfg.py.in b/FortranRuntime/test/lit.site.cfg.py.in
deleted file mode 100644
index a21fc128086eae..00000000000000
--- a/FortranRuntime/test/lit.site.cfg.py.in
+++ /dev/null
@@ -1,18 +0,0 @@
- at LIT_SITE_CFG_IN_HEADER@
-
-import sys
-
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.build_lib_dir = "@FORTRANRUNTIME_BUILD_LIB_DIR@"
-config.flang_source_dir = "@FLANG_SOURCE_DIR@"
-config.fortranruntime_source_dir = "@FORTRANRUNTIME_SOURCE_DIR@"
-config.fortranruntime_binary_test_dir = os.path.dirname(__file__)
-config.fortranruntime_build_lib_dir = "@FORTRANRUNTIME_BUILD_LIB_DIR@"
-config.cc = "@CMAKE_C_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, "@FORTRANRUNTIME_SOURCE_DIR@/test/lit.cfg.py")
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 5e4057116a97cb..ed2539cb4e3c5e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1291,7 +1291,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.
@@ -1307,7 +1307,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");
}
}
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index aff656d74daa2f..072d57e8a7ff46 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -304,26 +304,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/FortranRuntime/.clang-format b/flang-rt/.clang-format
similarity index 100%
rename from FortranRuntime/.clang-format
rename to flang-rt/.clang-format
diff --git a/FortranRuntime/.clang-tidy b/flang-rt/.clang-tidy
similarity index 100%
rename from FortranRuntime/.clang-tidy
rename to flang-rt/.clang-tidy
diff --git a/FortranRuntime/CMakeLists.txt b/flang-rt/CMakeLists.txt
similarity index 54%
rename from FortranRuntime/CMakeLists.txt
rename to flang-rt/CMakeLists.txt
index e65cab7060cb02..bd83a51482f4af 100644
--- a/FortranRuntime/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -6,23 +6,23 @@
#
#===------------------------------------------------------------------------===#
#
-# Build instructions for the FortranRuntime library and Fortran modules required
-# by programs compiled by Flang. This is file is intended to be included using
-# the LLVM_ENABLE_RUNTIMES mechanism.
+# Build instructions for the flang-rt library. This is file is intended to be
+# included using the LLVM_ENABLE_RUNTIMES mechanism.
#
#===------------------------------------------------------------------------===#
set(LLVM_SUBPROJECT_TITLE "Fortran Runtime")
-set(FORTRANRUNTIME_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
-set(FORTRANRUNTIME_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+set(FLANGRT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(FLANGRT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang")
enable_language(Fortran)
list(APPEND CMAKE_MODULE_PATH
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+ "${FLANGRT_SOURCE_DIR}/cmake/modules"
+ "${FLANG_SOURCE_DIR}/cmake/modules"
)
-include(AddFortranRuntime)
+include(AddFlangRT)
include(FlangCommon)
@@ -30,7 +30,7 @@ include(FlangCommon)
# Build Mode Introspection #
############################
-# Setting these variables from an LLVM build is sufficient that FortranRuntime can
+# Setting these variables from an LLVM build is sufficient that flang-rt can
# construct the output paths, so it can behave as if it were in-tree here.
set(LLVM_TREE_AVAILABLE OFF)
if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
@@ -42,19 +42,19 @@ if (LLVM_TREE_AVAILABLE)
# Despite Clang in the name, get_clang_resource_dir does not depend on Clang being added to the build
# flang-new uses the same resource dir as clang.
include(GetClangResourceDir)
- get_clang_resource_dir(FORTRANRUNTIME_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
- get_clang_resource_dir(FORTRANRUNTIME_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the install prefix itself
+ get_clang_resource_dir(FLANGRT_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
+ get_clang_resource_dir(FLANGRT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the install prefix itself
else ()
- set(FORTRANRUNTIME_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
- set(FORTRANRUNTIME_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
+ set(FLANGRT_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
+ set(FLANGRT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
endif ()
if (DEFINED WIN32)
- set(FORTRANRUNTIME_BUILD_LIB_DIR "${FORTRANRUNTIME_BUILD_LIB_DIR}/windows")
- set(FORTRANRUNTIME_INSTALL_LIB_DIR "${FORTRANRUNTIME_INSTALL_LIB_DIR}/windows")
+ set(FLANGRT_BUILD_LIB_DIR "${FLANGRT_BUILD_LIB_DIR}/windows")
+ set(FLANGRT_INSTALL_LIB_DIR "${FLANGRT_INSTALL_LIB_DIR}/windows")
elseif (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
- set(FORTRANRUNTIME_BUILD_LIB_DIR "${FORTRANRUNTIME_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
- set(FORTRANRUNTIME_INSTALL_LIB_DIR "${FORTRANRUNTIME_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+ set(FLANGRT_BUILD_LIB_DIR "${FLANGRT_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+ set(FLANGRT_INSTALL_LIB_DIR "${FLANGRT_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
endif ()
@@ -62,26 +62,30 @@ endif ()
# Build Options #
#################
-option(FORTRANRUNTIME_INCLUDE_TESTS "Generate build targets for the FortranRuntime unit and regression-tests." "${LLVM_INCLUDE_TESTS}")
-
-set(FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT "" CACHE STRING "Compile FortranRuntime with GPU support (CUDA or OpenMP)")
-set_property(CACHE FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT PROPERTY STRINGS
- ""
- CUDA
- OpenMP)
-if (NOT FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT)
-elseif (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
- set(FORTRANRUNTIME_LIBCUDACXX_PATH "" CACHE PATH "Path to libcu++ package installation")
- option(FORTRANRUNTIME_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS "Do not compile global variables' definitions when producing PTX library" OFF)
-elseif (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
-set(FORTRANRUNTIME_DEVICE_ARCHITECTURES "all" CACHE STRING
+# 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)
+elseif (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "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")
+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')")
else ()
- message(FATAL_ERROR "Invalid value '${FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT}' for FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT; must be empty, 'CUDA', or 'OpenMP'")
+ message(FATAL_ERROR "Invalid value '${FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT}' for FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT; must be empty, 'CUDA', or 'OpenMP'")
endif ()
-option(FORTRANRUNTIME_ENABLE_CUF "Compile CUDA Fortran runtime sources" OFF)
-if (FORTRANRUNTIME_ENABLE_CUF)
+option(FLANG_RT_ENABLE_CUF "Compile CUDA Fortran runtime sources" OFF)
+if (FLANG_RT_ENABLE_CUF)
find_package(CUDAToolkit REQUIRED)
endif()
@@ -113,9 +117,9 @@ if (WIN32)
ERROR_QUIET
)
if (NOT CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE AND CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT)
- string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FORTRANRUNTIME_LIBCALL)
+ string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FLANGRT_LIBCALL)
else ()
- set(FORTRANRUNTIME_LIBCALL "")
+ set(FLANGRT_LIBCALL "")
endif ()
endif ()
@@ -124,9 +128,9 @@ endif ()
# Build Preparation #
#####################
-if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT AND FORTRANRUNTIME_INCLUDE_TESTS)
+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 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.
@@ -134,7 +138,7 @@ if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT AND FORTRANRUNTIME_INCLUDE_TESTS
endif()
-# C++17 required for FortranRuntime, user or other runtimes may override this.
+# 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)
@@ -153,9 +157,9 @@ configure_file(cmake/config.h.cmake.in config.h)
add_subdirectory(lib)
-if (FORTRANRUNTIME_INCLUDE_TESTS)
+if (FLANG_RT_INCLUDE_TESTS)
add_subdirectory(unittests)
add_subdirectory(test)
else ()
- add_custom_target(check-FortranRuntime)
+ add_custom_target(check-flang-rt)
endif()
diff --git a/FortranRuntime/CODE_OWNERS.TXT b/flang-rt/CODE_OWNERS.TXT
similarity index 100%
rename from FortranRuntime/CODE_OWNERS.TXT
rename to flang-rt/CODE_OWNERS.TXT
diff --git a/FortranRuntime/LICENSE.TXT b/flang-rt/LICENSE.TXT
similarity index 100%
rename from FortranRuntime/LICENSE.TXT
rename to flang-rt/LICENSE.TXT
diff --git a/FortranRuntime/README.md b/flang-rt/README.md
similarity index 76%
rename from FortranRuntime/README.md
rename to flang-rt/README.md
index cb578507f8c96e..01836f9d8f714d 100644
--- a/FortranRuntime/README.md
+++ b/flang-rt/README.md
@@ -6,15 +6,15 @@
-->
-# Fortran Runtime
+# Fortran Runtime (flang-rt)
-Fortran Runtime is the runtime library for code emitted by the Flang compiler
+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 FortranRuntime. The bootstrap build, also
+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
@@ -29,29 +29,29 @@ source directory. LLVM does not support in-source builds.
Requirements:
* [Same as LLVM](https://llvm.org/docs/GettingStarted.html#requirements).
- * While for LLVM C++14 suffices, Flang and FortranRuntime require a
+ * While for LLVM C++14 suffices, Flang and flang-rt require a
C++17-capable C++ compiler.
### Bootstrap/In-Tree Build
The bootstrap build will first build Clang and Flang, then use these compilers
-to compile the FortranRuntime. CMake will create a secondary build tree in
+to compile flang-rt. CMake will create a secondary build tree in
configured with 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, the FortranRuntime is found by Flang from either
-the build- or install-prefix. To enable, add `FortranRuntime` to
+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>/llvm \
-DNinja \
-DLLVM_ENABLE_PROJECTS=flang \
- -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
...
```
-It is recommended to enable building OpenMP alongside Flang and FortranRuntime
+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).
@@ -61,7 +61,7 @@ cmake -S <path-to-llvm-project>/llvm \
-DNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="flang;openmp" \
- -DLLVM_ENABLE_RUNTIMES="compiler-rt;FortranRuntime" \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;flang-rt" \
...
```
@@ -74,8 +74,8 @@ cross-compilation via `flang-new --target=<target-triple>`, add more triples to
After configuration, build, test, and install the runtime(s) via
```shell
-$ ninja FortranRuntime
-$ ninja check-FortranRuntime
+$ ninja flang-rt
+$ ninja check-flang-rt
$ ninja install
```
@@ -87,7 +87,7 @@ 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-new` built from the same Git commit as
-FortranRuntime to ensure they are using the same ABI. The C and C++ compiler
+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
@@ -100,13 +100,13 @@ cmake -S <path-to-llvm-project>/runtimes \
-GNinja \
-DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
-DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir>/bin/flang-new \
- -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
...
```
-Building the FortranRuntime for cross-compilation triple, the target triple can
+Building flang-rt for cross-compilation triple, the target triple can
be selected using `LLVM_DEFAULT_TARGET_TRIPLE` AND `LLVM_RUNTIMES_TARGET`.
-Of course, FortranRuntime can be built multiple times with different build
+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.
@@ -117,7 +117,7 @@ cmake -S <path-to-llvm-project>/runtimes
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${HOME}/local" \
- -DLLVM_ENABLE_RUNTIMES="compiler-rt;FortranRuntime" \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;flang-rt" \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
@@ -131,13 +131,13 @@ cmake -S <path-to-llvm-project>/runtimes
## Configuration Option Reference
-The FortranRuntime has the followign configuration options. This is in
+Flang-rt has the followign configuration options. This is in
addition to the build options the LLVM_ENABLE_RUNTIMES mechanism and
CMake itself provide.
- * `FORTRANRUNTIME_INCLUDE_TESTS` (boolean; default: `ON`)
+ * `FLANG_RT_INCLUDE_TESTS` (boolean; default: `ON`)
- When `OFF`, does not add any tests and unittests. The `check-FortranRuntime`
+ When `OFF`, does not add any tests and unittests. The `check-flang-rt`
build target will do nothing.
* `FLANG_RUNTIME_F128_MATH_LIB` (default: `""`)
@@ -148,20 +148,20 @@ CMake itself provide.
the compiler for `__float128` or 128-bit `long double` support.
[More details](docs/Real16MathSupport.md).
- * `FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT` (values: `"CUDA"`,`"OpenMP"`, `""` default: `""`)
+ * `FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT` (values: `"CUDA"`,`"OpenMP"`, `""` default: `""`)
- When set to `CUDA`, builds a FortranRuntime with experimental support for GPU
+ 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 a FortranRuntime with experimental support for
+ 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`.
- * `FORTRANRUNTIME_ENABLE_CUF` (bool, default: `OFF`)
+ * `FLANG_RT_ENABLE_CUF` (bool, default: `OFF`)
Compiles the `libCufRuntime_cuda_<CUDA-version>.a/.so` library. This is
- independent of `FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA` and only
+ 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`).
@@ -169,14 +169,14 @@ CMake itself provide.
### CUDA Support
-With `-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`, the following
+With `-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`, the following
additional configuration options become available.
- * `FORTRANRUNTIME_LIBCUDACXX_PATH` (path, default: `""`)
+ * `FLANG_RT_LIBCUDACXX_PATH` (path, default: `""`)
Path to libcu++ package installation.
- * `FORTRANRUNTIME_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS` (boolean, default: `OFF`)
+ * `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
@@ -185,11 +185,11 @@ additional configuration options become available.
### OpenMP Offload Support
-With `-DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=OpenMP`, the following
+With `-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=OpenMP`, the following
additional configuration options become available.
- * `FORTRANRUNTIME_DEVICE_ARCHITECTURES` (default: `"all"`)
+ * `FLANG_RT_DEVICE_ARCHITECTURES` (default: `"all"`)
- A list of device architectures that the FortranRuntime is supporting.
+ A list of device architectures that flang-rt is supporting.
If `"all"` uses a pre-defined list of architectures. Same purpose as
`LIBOMPTARGET_DEVICE_ARCHITECTURES` from liboffload.
diff --git a/FortranRuntime/cmake/config.h.cmake.in b/flang-rt/cmake/config.h.cmake.in
similarity index 100%
rename from FortranRuntime/cmake/config.h.cmake.in
rename to flang-rt/cmake/config.h.cmake.in
diff --git a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
similarity index 72%
rename from FortranRuntime/cmake/modules/AddFortranRuntime.cmake
rename to flang-rt/cmake/modules/AddFlangRT.cmake
index e9563c6e3a60b9..797eeddae32142 100644
--- a/FortranRuntime/cmake/modules/AddFortranRuntime.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -1,4 +1,4 @@
-#===-- cmake/modules/AddFortranRuntime.cmake -------------------------------===#
+#===-- 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.
@@ -6,11 +6,11 @@
#
#===------------------------------------------------------------------------===#
-# Builds a library with common options for FortranRuntime.
+# Builds a library with common options for flang-rt.
#
# Usage:
#
-# add_fortranruntime_library(name sources ...
+# add_flangrt_library(name sources ...
# SHARED
# Build a dynamic (.so/.dll) library
# STATIC
@@ -28,7 +28,7 @@
# ADDITIONAL_HEADERS
# May specify header files for IDE generators.
# )
-function (add_fortranruntime_library name)
+function (add_flangrt_library name)
set(options STATIC SHARED OBJECT INSTALL_WITH_TOOLCHAIN EXCLUDE_FROM_ALL LINK_TO_LLVM)
set(multiValueArgs ADDITIONAL_HEADERS)
cmake_parse_arguments(ARG
@@ -76,23 +76,23 @@ function (add_fortranruntime_library name)
)
endif ()
- # FortranRuntime's public headers
- target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+ # Flang-rt's public headers
+ target_include_directories(${name} PRIVATE "${FLANGRT_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 FortranRuntime's configured config.h to be found
- target_include_directories(${name} PRIVATE "${FORTRANRUNTIME_BINARY_DIR}")
+ # For flang-rt's configured config.h to be found
+ target_include_directories(${name} PRIVATE "${FLANGRT_BINARY_DIR}")
- # Clang/Flang, targeting the MSVC ABI, including clang-cl, should only depends
- # on msv(u)crt. LLVM still emits libgcc/compiler-rt functions for 128-bit
- # integer math (__udivti3, __modti3, __fixsfti, __floattidf, ...) that msvc
- # does not support. We are injecting a dependency to Compiler-RT where these
- # are implemented.
- if (MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") AND FORTRANRUNTIME_LIBCALL)
- target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "--dependent-lib=${FORTRANRUNTIME_LIBCALL}")
+ # 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 for 128-bit integer math (__udivti3, __modti3, __fixsfti,
+ # __floattidf, ...) that msvc does not support. We are injecting a dependency
+ # to Compiler-RT where these are implemented.
+ if (MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") AND FLANGRT_LIBCALL)
+ target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "--dependent-lib=${FLANGRT_LIBCALL}")
endif ()
# Non-GTest unittests depend on LLVMSupport
@@ -112,15 +112,15 @@ function (add_fortranruntime_library name)
if (ARG_INSTALL_WITH_TOOLCHAIN)
set_target_properties(${name}
PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
- ARCHIVE_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
- RUNTIME_OUTPUT_DIRECTORY "${FORTRANRUNTIME_BUILD_LIB_DIR}"
+ LIBRARY_OUTPUT_DIRECTORY "${FLANGRT_BUILD_LIB_DIR}"
+ ARCHIVE_OUTPUT_DIRECTORY "${FLANGRT_BUILD_LIB_DIR}"
+ RUNTIME_OUTPUT_DIRECTORY "${FLANGRT_BUILD_LIB_DIR}"
)
install(TARGETS ${name}
- LIBRARY DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
- ARCHIVE DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
- RUNTIME DESTINATION "${FORTRANRUNTIME_INSTALL_LIB_DIR}"
+ LIBRARY DESTINATION "${FLANGRT_INSTALL_LIB_DIR}"
+ ARCHIVE DESTINATION "${FLANGRT_INSTALL_LIB_DIR}"
+ RUNTIME DESTINATION "${FLANGRT_INSTALL_LIB_DIR}"
)
endif ()
-endfunction (add_fortranruntime_library)
+endfunction (add_flangrt_library)
diff --git a/FortranRuntime/cmake/modules/AddFortranOffloadRuntime.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
similarity index 82%
rename from FortranRuntime/cmake/modules/AddFortranOffloadRuntime.cmake
rename to flang-rt/cmake/modules/AddFlangRTOffload.cmake
index d60a26ce0f8a86..a6b94602b0456f 100644
--- a/FortranRuntime/cmake/modules/AddFortranOffloadRuntime.cmake
+++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
@@ -7,7 +7,7 @@
#===------------------------------------------------------------------------===#
macro(enable_cuda_compilation name files)
- if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
+ if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
if (BUILD_SHARED_LIBS)
message(FATAL_ERROR
"BUILD_SHARED_LIBS is not supported for CUDA build of Fortran runtime"
@@ -42,26 +42,26 @@ macro(enable_cuda_compilation name files)
"${CUDA_COMPILE_OPTIONS}"
)
- if (EXISTS "${FORTRANRUNTIME_LIBCUDACXX_PATH}/include")
+ if (EXISTS "${FLANG_RT_LIBCUDACXX_PATH}/include")
# When using libcudacxx headers files, we have to use them
# for all files of F18 runtime.
- include_directories(AFTER ${FORTRANRUNTIME_LIBCUDACXX_PATH}/include)
+ include_directories(AFTER ${FLANG_RT_LIBCUDACXX_PATH}/include)
add_compile_definitions(RT_USE_LIBCUDACXX=1)
endif()
# Add an OBJECT library consisting of CUDA PTX.
- add_fortranruntime_library(${name}PTX OBJECT ${files})
+ add_flangrt_library(${name}PTX OBJECT ${files})
set_property(TARGET ${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
- if (FORTRANRUNTIME_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
+ if (FLANG_RT_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
target_compile_definitions(${name}PTX
- PRIVATE FORTRANRUNTIME_NO_GLOBAL_VAR_DEFS
+ PRIVATE FLANGRT_NO_GLOBAL_VAR_DEFS
)
endif()
endif()
endmacro()
macro(enable_omp_offload_compilation files)
- if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
+ if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
# OpenMP offload build only works with Clang compiler currently.
if (BUILD_SHARED_LIBS)
@@ -88,13 +88,13 @@ macro(enable_omp_offload_compilation files)
"${all_amdgpu_architectures};${all_nvptx_architectures}"
)
# TODO: support auto detection on the build system.
- if (FORTRANRUNTIME_DEVICE_ARCHITECTURES STREQUAL "all")
- set(FORTRANRUNTIME_DEVICE_ARCHITECTURES ${all_gpu_architectures})
+ if (FLANG_RT_DEVICE_ARCHITECTURES STREQUAL "all")
+ set(FLANG_RT_DEVICE_ARCHITECTURES ${all_gpu_architectures})
endif()
- list(REMOVE_DUPLICATES FORTRANRUNTIME_DEVICE_ARCHITECTURES)
+ list(REMOVE_DUPLICATES FLANG_RT_DEVICE_ARCHITECTURES)
string(REPLACE ";" "," compile_for_architectures
- "${FORTRANRUNTIME_DEVICE_ARCHITECTURES}"
+ "${FLANG_RT_DEVICE_ARCHITECTURES}"
)
set(OMP_COMPILE_OPTIONS
@@ -115,7 +115,7 @@ macro(enable_omp_offload_compilation files)
)
else()
message(FATAL_ERROR
- "FortranRuntime build with OpenMP offload is not supported for these compilers:\n"
+ "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()
diff --git a/flang/include/flang/Runtime/CUDA/allocator.h b/flang-rt/include/flang-rt/CufRuntime/allocator.h
similarity index 85%
rename from flang/include/flang/Runtime/CUDA/allocator.h
rename to flang-rt/include/flang-rt/CufRuntime/allocator.h
index cc88896b1f0bd6..63406e0de6d2fa 100644
--- a/flang/include/flang/Runtime/CUDA/allocator.h
+++ b/flang-rt/include/flang-rt/CufRuntime/allocator.h
@@ -1,4 +1,4 @@
-//===-- include/flang/Runtime/CUDA/allocator.h ------------------*- C++ -*-===//
+//===-- include/flang-rt/CufRuntime/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,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
-#define FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
+#ifndef FORTRAN_CUFRUNTIME_ALLOCATOR_H_
+#define FORTRAN_CUFRUNTIME_ALLOCATOR_H_
#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
@@ -43,4 +43,4 @@ void *CUFAllocUnified(std::size_t);
void CUFFreeUnified(void *);
} // namespace Fortran::runtime::cuda
-#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
+#endif /* FORTRAN_CUFRUNTIME_ALLOCATOR_H_ */
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/allocator-registry.h b/flang-rt/include/flang-rt/flang_rt/allocator-registry.h
similarity index 87%
rename from FortranRuntime/include/FortranRuntime/Runtime/allocator-registry.h
rename to flang-rt/include/flang-rt/flang_rt/allocator-registry.h
index 30a583b88c083e..ecad61ab4043d7 100644
--- a/FortranRuntime/include/FortranRuntime/Runtime/allocator-registry.h
+++ b/flang-rt/include/flang-rt/flang_rt/allocator-registry.h
@@ -1,4 +1,4 @@
-//===-- include/FortranRuntime/Runtime/allocator-registry.h -----*- C++ -*-===//
+//===-- include/flang-rt/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 FORTRAN_FLANG_RT_ALLOCATOR_REGISTRY_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_ALLOCATOR_REGISTRY_H_ */
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/array-constructor.h b/flang-rt/include/flang-rt/flang_rt/array-constructor.h
similarity index 85%
rename from FortranRuntime/include/FortranRuntime/Runtime/array-constructor.h
rename to flang-rt/include/flang-rt/flang_rt/array-constructor.h
index 314d5e56599cd3..e8fffc762b6fbe 100644
--- a/FortranRuntime/include/FortranRuntime/Runtime/array-constructor.h
+++ b/flang-rt/include/flang-rt/flang_rt/array-constructor.h
@@ -1,4 +1,4 @@
-//===-- include/FortranRuntime/Runtime/array-constructor.h ------*- C++ -*-===//
+//===-- include/flang-rt/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,10 +9,10 @@
// External APIs to create temporary storage for array constructors when their
// final extents or length parameters cannot be pre-computed.
-#ifndef FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
-#define FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
+#ifndef FORTRAN_FLANG_RT_ARRAY_CONSTRUCTOR_H_
+#define FORTRAN_FLANG_RT_ARRAY_CONSTRUCTOR_H_
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "flang/Runtime/array-constructor-consts.h"
#include "flang/Runtime/entry-names.h"
#include <cstdint>
@@ -45,4 +45,4 @@ struct ArrayConstructorVector {
};
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_ */
+#endif /* FORTRAN_FLANG_RT_ARRAY_CONSTRUCTOR_H_ */
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/descriptor.h b/flang-rt/include/flang-rt/flang_rt/descriptor.h
similarity index 98%
rename from FortranRuntime/include/FortranRuntime/Runtime/descriptor.h
rename to flang-rt/include/flang-rt/flang_rt/descriptor.h
index f79ad6b9637a4a..fea5b55c1922ce 100644
--- a/FortranRuntime/include/FortranRuntime/Runtime/descriptor.h
+++ b/flang-rt/include/flang-rt/flang_rt/descriptor.h
@@ -1,4 +1,4 @@
-//===-- include/FortranRuntime/Runtime/descriptor.h -------------*- C++ -*-===//
+//===-- include/flang-rt/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 FORTRAN_FLANG_RT_DESCRIPTOR_H_
+#define FORTRAN_FLANG_RT_DESCRIPTOR_H_
// Defines data structures used during execution of a Fortran program
// to implement nontrivial dummy arguments, pointers, allocatables,
@@ -18,8 +18,8 @@
// User C code is welcome to depend on that ISO_Fortran_binding.h file,
// but should never reference this internal header.
-#include "FortranRuntime/Runtime/memory.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/memory.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor-consts.h"
#include <algorithm>
@@ -482,4 +482,4 @@ class alignas(Descriptor) StaticDescriptor {
};
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_DESCRIPTOR_H_ */
+#endif /* FORTRAN_FLANG_RT_DESCRIPTOR_H_ */
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/io-api-funcs.h b/flang-rt/include/flang-rt/flang_rt/io-api-funcs.h
similarity index 84%
rename from FortranRuntime/include/FortranRuntime/Runtime/io-api-funcs.h
rename to flang-rt/include/flang-rt/flang_rt/io-api-funcs.h
index 516fe25784656c..00cb49ad015437 100644
--- a/FortranRuntime/include/FortranRuntime/Runtime/io-api-funcs.h
+++ b/flang-rt/include/flang-rt/flang_rt/io-api-funcs.h
@@ -1,4 +1,4 @@
-//===-- include/FortranRuntime/Runtime/io-api-funcs.h -----------*- C++ -*-===//
+//===-- include/flang-rt/flang_rt/io-api-funcs.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 API between compiled code and I/O runtime library.
-#ifndef FORTRAN_RUNTIME_IO_API_FUNCS_H_
-#define FORTRAN_RUNTIME_IO_API_FUNCS_H_
+#ifndef FORTRAN_FLANG_RT_IO_API_FUNCS_H_
+#define FORTRAN_FLANG_RT_IO_API_FUNCS_H_
#include "flang/Common/uint128.h"
#include "flang/Runtime/entry-names.h"
@@ -36,4 +36,4 @@ RT_API_ATTRS const char *InquiryKeywordHashDecode(
char *buffer, std::size_t, InquiryKeywordHash);
} // namespace Fortran::runtime::io
-#endif /* FORTRAN_RUNTIME_IO_API_FUNCS_H_ */
+#endif /* FORTRAN_FLANG_RT_IO_API_FUNCS_H_ */
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/iostat-funcs.h b/flang-rt/include/flang-rt/flang_rt/iostat-funcs.h
similarity index 75%
rename from FortranRuntime/include/FortranRuntime/Runtime/iostat-funcs.h
rename to flang-rt/include/flang-rt/flang_rt/iostat-funcs.h
index 10906afb01673c..dd24d41fbaad10 100644
--- a/FortranRuntime/include/FortranRuntime/Runtime/iostat-funcs.h
+++ b/flang-rt/include/flang-rt/flang_rt/iostat-funcs.h
@@ -1,4 +1,4 @@
-//===-- include/FortranRuntime/Runtime/iostat-funcs.h -----------*- C++ -*-===//
+//===-- include/flang-rt/flang_rt/iostat-funcs.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 IOSTAT= specifiers
// on I/O statements.
-#ifndef FORTRAN_RUNTIME_IOSTAT_FUNCS_H_
-#define FORTRAN_RUNTIME_IOSTAT_FUNCS_H_
+#ifndef FORTRAN_FLANG_RT_IOSTAT_FUNCS_H_
+#define FORTRAN_FLANG_RT_IOSTAT_FUNCS_H_
#include "flang/Common/api-attrs.h"
#include "flang/Runtime/iostat.h"
@@ -20,4 +20,4 @@ namespace Fortran::runtime::io {
RT_API_ATTRS const char *IostatErrorString(int);
} // namespace Fortran::runtime::io
-#endif /* FORTRAN_RUNTIME_IOSTAT_FUNCS_H_ */
+#endif /* FORTRAN_FLANG_RT_IOSTAT_FUNCS_H_ */
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/memory.h b/flang-rt/include/flang-rt/flang_rt/memory.h
similarity index 96%
rename from FortranRuntime/include/FortranRuntime/Runtime/memory.h
rename to flang-rt/include/flang-rt/flang_rt/memory.h
index 3e7fd2d9ea3e3b..b97f6525d60036 100644
--- a/FortranRuntime/include/FortranRuntime/Runtime/memory.h
+++ b/flang-rt/include/flang-rt/flang_rt/memory.h
@@ -1,4 +1,4 @@
-//===-- include/FortranRuntime/Runtime/memory.h -----------------*- C++ -*-===//
+//===-- include/flang-rt/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 FORTRAN_FLANG_RT_MEMORY_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_MEMORY_H_ */
diff --git a/FortranRuntime/include/FortranRuntime/Runtime/type-code.h b/flang-rt/include/flang-rt/flang_rt/type-code.h
similarity index 93%
rename from FortranRuntime/include/FortranRuntime/Runtime/type-code.h
rename to flang-rt/include/flang-rt/flang_rt/type-code.h
index 92ff593410c12c..7c694a13431b13 100644
--- a/FortranRuntime/include/FortranRuntime/Runtime/type-code.h
+++ b/flang-rt/include/flang-rt/flang_rt/type-code.h
@@ -1,4 +1,4 @@
-//===-- include/FortranRuntime/Runtime/type-code.h --------------*- C++ -*-===//
+//===-- include/flang-rt/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 FORTRAN_FLANG_RT_TYPE_CODE_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_TYPE_CODE_H_ */
diff --git a/FortranRuntime/lib/CMakeLists.txt b/flang-rt/lib/CMakeLists.txt
similarity index 71%
rename from FortranRuntime/lib/CMakeLists.txt
rename to flang-rt/lib/CMakeLists.txt
index 74c78b3fa3a493..f0422f5e0a58b4 100644
--- a/FortranRuntime/lib/CMakeLists.txt
+++ b/flang-rt/lib/CMakeLists.txt
@@ -6,8 +6,12 @@
#
#===------------------------------------------------------------------------===#
-add_subdirectory(Runtime)
-if (FORTRANRUNTIME_INCLUDE_TESTS)
+add_subdirectory(FortranFloat128Math)
+add_subdirectory(flang_rt)
+if (FLANG_RT_ENABLE_CUF)
+ add_subdirectory(CufRuntime)
+endif()
+
+if (FLANG_RT_INCLUDE_TESTS)
add_subdirectory(Testing)
endif ()
-
diff --git a/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt b/flang-rt/lib/CufRuntime/CMakeLists.txt
similarity index 87%
rename from FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
rename to flang-rt/lib/CufRuntime/CMakeLists.txt
index 78b98652d60813..1eb80d9ca1d497 100644
--- a/FortranRuntime/lib/Runtime/CUDA/CMakeLists.txt
+++ b/flang-rt/lib/CufRuntime/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/Runtime/CUDA/CMakeLists.txt -------------------------------------===#
+#===-- lib/CufRuntime/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.
@@ -11,7 +11,7 @@
# added to the library name.
set(CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR})
-add_fortranruntime_library(${CUFRT_LIBNAME}
+add_flangrt_library(${CUFRT_LIBNAME}
allocator.cpp
descriptor.cpp
)
@@ -25,6 +25,6 @@ endif()
target_link_libraries(${CUFRT_LIBNAME}
PRIVATE
- FortranRuntime
+ flang_rt
${CUDA_RT_TARGET}
)
diff --git a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp b/flang-rt/lib/CufRuntime/allocator.cpp
similarity index 81%
rename from FortranRuntime/lib/Runtime/CUDA/allocator.cpp
rename to flang-rt/lib/CufRuntime/allocator.cpp
index c9d62f6ea8f3bf..8c16fb77f2ac46 100644
--- a/FortranRuntime/lib/Runtime/CUDA/allocator.cpp
+++ b/flang-rt/lib/CufRuntime/allocator.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/CUDA/allocator.cpp --------------------------*- C++ -*-===//
+//===-- lib/CufRuntime/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 "FortranRuntime/Runtime/CUDA/allocator.h"
-#include "FortranRuntime/Runtime/allocator-registry.h"
-#include "../derived.h"
-#include "../stat.h"
-#include "../terminator.h"
-#include "../type-info.h"
-#include "flang/ISO_Fortran_binding_wrapper.h"
-#include "flang/Support/Fortran.h"
+#include "flang-rt/CufRuntime/allocator.h"
+#include "flang-rt/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/Fortran-consts.h"
+#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "cuda_runtime.h"
diff --git a/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp b/flang-rt/lib/CufRuntime/descriptor.cpp
similarity index 82%
rename from FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
rename to flang-rt/lib/CufRuntime/descriptor.cpp
index 94b5feca4ce4dc..b034fc76b67d4d 100644
--- a/FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
+++ b/flang-rt/lib/CufRuntime/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/CUDA/descriptor.cpp -------------------------*- C++ -*-===//
+//===-- lib/CufRuntime/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,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/CUDA/descriptor.h"
-#include "FortranRuntime/Runtime/CUDA/allocator.h"
+#include "flang/Runtime/CUDA/descriptor.h"
+#include "flang-rt/CufRuntime/allocator.h"
namespace Fortran::runtime::cuda {
extern "C" {
diff --git a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
rename to flang-rt/lib/FortranFloat128Math/CMakeLists.txt
index ed65da0a5ac71c..b12dfee64af8f6 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/CMakeLists.txt
+++ b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- runtime/Float128Math/CMakeLists.txt ---------------------------------===#
+#===-- 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.
@@ -91,12 +91,11 @@ 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 the main
- # FortranRuntime.lib.
+ # driver never links it. Instead, add the sources to the flang_rt itself.
target_sources(FortranFloat128MathILib INTERFACE ${sources})
target_compile_definitions(FortranFloat128MathILib INTERFACE HAS_QUADMATHLIB)
else ()
- add_fortranruntime_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
+ add_flangrt_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
${sources})
endif ()
elseif (HAVE_LDBL_MANT_DIG_113)
@@ -108,7 +107,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/FortranRuntime/lib/Runtime/Float128Math/acos.cpp b/flang-rt/lib/FortranFloat128Math/acos.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/acos.cpp
rename to flang-rt/lib/FortranFloat128Math/acos.cpp
index 7b15e4a0bfd3ae..e204c6c871f3fa 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/acos.cpp
+++ b/flang-rt/lib/FortranFloat128Math/acos.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/acos.cpp -----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/acosh.cpp b/flang-rt/lib/FortranFloat128Math/acosh.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/acosh.cpp
rename to flang-rt/lib/FortranFloat128Math/acosh.cpp
index c873259b4545b8..90ff7886e6909d 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/acosh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/acosh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/acosh.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/asin.cpp b/flang-rt/lib/FortranFloat128Math/asin.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/asin.cpp
rename to flang-rt/lib/FortranFloat128Math/asin.cpp
index 8866d51430197a..18368044d72b0f 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/asin.cpp
+++ b/flang-rt/lib/FortranFloat128Math/asin.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/asin.cpp -----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/asinh.cpp b/flang-rt/lib/FortranFloat128Math/asinh.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/asinh.cpp
rename to flang-rt/lib/FortranFloat128Math/asinh.cpp
index 288193001ce1da..2c1f040cfc3872 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/asinh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/asinh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/asinh.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/atan.cpp b/flang-rt/lib/FortranFloat128Math/atan.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/atan.cpp
rename to flang-rt/lib/FortranFloat128Math/atan.cpp
index 390c080b4d501b..8bd9a2626caf83 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/atan.cpp
+++ b/flang-rt/lib/FortranFloat128Math/atan.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/atan.cpp -----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/atan2.cpp b/flang-rt/lib/FortranFloat128Math/atan2.cpp
similarity index 91%
rename from FortranRuntime/lib/Runtime/Float128Math/atan2.cpp
rename to flang-rt/lib/FortranFloat128Math/atan2.cpp
index 3c206b75704431..4994be699a0b67 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/atan2.cpp
+++ b/flang-rt/lib/FortranFloat128Math/atan2.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/atan2.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/atanh.cpp b/flang-rt/lib/FortranFloat128Math/atanh.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/atanh.cpp
rename to flang-rt/lib/FortranFloat128Math/atanh.cpp
index 77ceb188f04e42..f5ace35ac51caa 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/atanh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/atanh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/atanh.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/ceil.cpp b/flang-rt/lib/FortranFloat128Math/ceil.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/ceil.cpp
rename to flang-rt/lib/FortranFloat128Math/ceil.cpp
index 46bc253bd0922d..834da9396c071d 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/ceil.cpp
+++ b/flang-rt/lib/FortranFloat128Math/ceil.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/ceil.cpp -----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/complex-math.c b/flang-rt/lib/FortranFloat128Math/complex-math.c
similarity index 96%
rename from FortranRuntime/lib/Runtime/Float128Math/complex-math.c
rename to flang-rt/lib/FortranFloat128Math/complex-math.c
index f34ef7da76e599..493ffe942f7e31 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/complex-math.c
+++ b/flang-rt/lib/FortranFloat128Math/complex-math.c
@@ -1,4 +1,4 @@
-/*===-- lib/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.
diff --git a/FortranRuntime/lib/Runtime/Float128Math/complex-math.h b/flang-rt/lib/FortranFloat128Math/complex-math.h
similarity index 88%
rename from FortranRuntime/lib/Runtime/Float128Math/complex-math.h
rename to flang-rt/lib/FortranFloat128Math/complex-math.h
index 6f5c7954bab035..bb67523e1bddcc 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/complex-math.h
+++ b/flang-rt/lib/FortranFloat128Math/complex-math.h
@@ -1,4 +1,4 @@
-/*===-- lib/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 FORTRAN_FORTRANFLOAT128MATH_COMPLEX_MATH_H_
+#define FORTRAN_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 /* FORTRAN_FORTRANFLOAT128MATH_COMPLEX_MATH_H_ */
diff --git a/FortranRuntime/lib/Runtime/Float128Math/cos.cpp b/flang-rt/lib/FortranFloat128Math/cos.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/cos.cpp
rename to flang-rt/lib/FortranFloat128Math/cos.cpp
index 8ce47151e2914b..2651982666118b 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/cos.cpp
+++ b/flang-rt/lib/FortranFloat128Math/cos.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/cos.cpp ------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/cosh.cpp b/flang-rt/lib/FortranFloat128Math/cosh.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/cosh.cpp
rename to flang-rt/lib/FortranFloat128Math/cosh.cpp
index f1ec45bcfb479d..dda01e5abef66d 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/cosh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/cosh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/cosh.cpp -----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/erf.cpp b/flang-rt/lib/FortranFloat128Math/erf.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/erf.cpp
rename to flang-rt/lib/FortranFloat128Math/erf.cpp
index 010088467794d1..f5e713d93cac61 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/erf.cpp
+++ b/flang-rt/lib/FortranFloat128Math/erf.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/erf.cpp ------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/erfc.cpp b/flang-rt/lib/FortranFloat128Math/erfc.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/erfc.cpp
rename to flang-rt/lib/FortranFloat128Math/erfc.cpp
index b226f8d2dc378b..3f8b78ba0e64f9 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/erfc.cpp
+++ b/flang-rt/lib/FortranFloat128Math/erfc.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/erfc.cpp -----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/exp.cpp b/flang-rt/lib/FortranFloat128Math/exp.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/exp.cpp
rename to flang-rt/lib/FortranFloat128Math/exp.cpp
index e22f9df3579e96..0b694b159f3621 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/exp.cpp
+++ b/flang-rt/lib/FortranFloat128Math/exp.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/exp.cpp ------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/exponent.cpp b/flang-rt/lib/FortranFloat128Math/exponent.cpp
similarity index 92%
rename from FortranRuntime/lib/Runtime/Float128Math/exponent.cpp
rename to flang-rt/lib/FortranFloat128Math/exponent.cpp
index f07bf30bd1096f..a9c1b867e7ea37 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/exponent.cpp
+++ b/flang-rt/lib/FortranFloat128Math/exponent.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/exponent.cpp -------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/floor.cpp b/flang-rt/lib/FortranFloat128Math/floor.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/floor.cpp
rename to flang-rt/lib/FortranFloat128Math/floor.cpp
index 8744e6e2fec63c..27cfed2f1f9599 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/floor.cpp
+++ b/flang-rt/lib/FortranFloat128Math/floor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/floor.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/fma.cpp b/flang-rt/lib/FortranFloat128Math/fma.cpp
similarity index 91%
rename from FortranRuntime/lib/Runtime/Float128Math/fma.cpp
rename to flang-rt/lib/FortranFloat128Math/fma.cpp
index 198fec5d4bc356..a9ac1581002cec 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/fma.cpp
+++ b/flang-rt/lib/FortranFloat128Math/fma.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/fma.cpp ------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/fraction.cpp b/flang-rt/lib/FortranFloat128Math/fraction.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/fraction.cpp
rename to flang-rt/lib/FortranFloat128Math/fraction.cpp
index d4749bf3eb7e0e..39c59a25812abb 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/fraction.cpp
+++ b/flang-rt/lib/FortranFloat128Math/fraction.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/fraction.cpp -------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/hypot.cpp b/flang-rt/lib/FortranFloat128Math/hypot.cpp
similarity index 91%
rename from FortranRuntime/lib/Runtime/Float128Math/hypot.cpp
rename to flang-rt/lib/FortranFloat128Math/hypot.cpp
index 6542bf505060df..c130e204f9951e 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/hypot.cpp
+++ b/flang-rt/lib/FortranFloat128Math/hypot.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/hypot.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/j0.cpp b/flang-rt/lib/FortranFloat128Math/j0.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/j0.cpp
rename to flang-rt/lib/FortranFloat128Math/j0.cpp
index 27e4338cdfc2b0..d6454b56c8a86b 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/j0.cpp
+++ b/flang-rt/lib/FortranFloat128Math/j0.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/j0.cpp -------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/j1.cpp b/flang-rt/lib/FortranFloat128Math/j1.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/j1.cpp
rename to flang-rt/lib/FortranFloat128Math/j1.cpp
index d3f897827f9f67..2b7283aea0fe46 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/j1.cpp
+++ b/flang-rt/lib/FortranFloat128Math/j1.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/j1.cpp -------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/jn.cpp b/flang-rt/lib/FortranFloat128Math/jn.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/jn.cpp
rename to flang-rt/lib/FortranFloat128Math/jn.cpp
index 681bb5b1ff3ad5..cdc9af9b3dd6a5 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/jn.cpp
+++ b/flang-rt/lib/FortranFloat128Math/jn.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/jn.cpp -------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/lgamma.cpp b/flang-rt/lib/FortranFloat128Math/lgamma.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/lgamma.cpp
rename to flang-rt/lib/FortranFloat128Math/lgamma.cpp
index 0426db2e3b98d3..cecf9e90ad29ba 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/lgamma.cpp
+++ b/flang-rt/lib/FortranFloat128Math/lgamma.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/lgamma.cpp ---------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/llround.cpp b/flang-rt/lib/FortranFloat128Math/llround.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/llround.cpp
rename to flang-rt/lib/FortranFloat128Math/llround.cpp
index 4c9026cce00283..7853ac10f53e88 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/llround.cpp
+++ b/flang-rt/lib/FortranFloat128Math/llround.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/llround.cpp --------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/log.cpp b/flang-rt/lib/FortranFloat128Math/log.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/log.cpp
rename to flang-rt/lib/FortranFloat128Math/log.cpp
index a5a431ae5ffbbb..d705eaf441c31f 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/log.cpp
+++ b/flang-rt/lib/FortranFloat128Math/log.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/log.cpp ------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/log10.cpp b/flang-rt/lib/FortranFloat128Math/log10.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/log10.cpp
rename to flang-rt/lib/FortranFloat128Math/log10.cpp
index 9a83f57b6c736d..af61f8762371b9 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/log10.cpp
+++ b/flang-rt/lib/FortranFloat128Math/log10.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/log10.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/lround.cpp b/flang-rt/lib/FortranFloat128Math/lround.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/lround.cpp
rename to flang-rt/lib/FortranFloat128Math/lround.cpp
index 65546881157948..24278f1040e9e3 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/lround.cpp
+++ b/flang-rt/lib/FortranFloat128Math/lround.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/lround.cpp ---------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/math-entries.h b/flang-rt/lib/FortranFloat128Math/math-entries.h
similarity index 97%
rename from FortranRuntime/lib/Runtime/Float128Math/math-entries.h
rename to flang-rt/lib/FortranFloat128Math/math-entries.h
index 1449000820f00e..9b13c10836f877 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/math-entries.h
+++ b/flang-rt/lib/FortranFloat128Math/math-entries.h
@@ -1,4 +1,4 @@
-//===-- lib/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,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
-#define FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
+#ifndef FORTRAN_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
+#define FORTRAN_FORTRANFLOAT128MATH_MATH_ENTRIES_H_
#include "terminator.h"
#include "tools.h"
#include "flang/Common/float128.h"
@@ -222,4 +222,4 @@ DEFINE_SIMPLE_ALIAS(Yn, ynl)
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_ */
+#endif /* FORTRAN_FORTRANFLOAT128MATH_MATH_ENTRIES_H_ */
diff --git a/FortranRuntime/lib/Runtime/Float128Math/mod-real.cpp b/flang-rt/lib/FortranFloat128Math/mod-real.cpp
similarity index 91%
rename from FortranRuntime/lib/Runtime/Float128Math/mod-real.cpp
rename to flang-rt/lib/FortranFloat128Math/mod-real.cpp
index e3b96d39e76ae6..b3c2b715b21995 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/mod-real.cpp
+++ b/flang-rt/lib/FortranFloat128Math/mod-real.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/mod-real.cpp -------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/modulo-real.cpp b/flang-rt/lib/FortranFloat128Math/modulo-real.cpp
similarity index 91%
rename from FortranRuntime/lib/Runtime/Float128Math/modulo-real.cpp
rename to flang-rt/lib/FortranFloat128Math/modulo-real.cpp
index 8edf59e9f59dd4..f5e3cf8a259a73 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/modulo-real.cpp
+++ b/flang-rt/lib/FortranFloat128Math/modulo-real.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/modulo-real.cpp ----------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/nearest.cpp b/flang-rt/lib/FortranFloat128Math/nearest.cpp
similarity index 91%
rename from FortranRuntime/lib/Runtime/Float128Math/nearest.cpp
rename to flang-rt/lib/FortranFloat128Math/nearest.cpp
index 8b9f142d79ff93..eb34c2ddb6ab48 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/nearest.cpp
+++ b/flang-rt/lib/FortranFloat128Math/nearest.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/nearest.cpp --------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/norm2.cpp b/flang-rt/lib/FortranFloat128Math/norm2.cpp
similarity index 94%
rename from FortranRuntime/lib/Runtime/Float128Math/norm2.cpp
rename to flang-rt/lib/FortranFloat128Math/norm2.cpp
index a0c26e40de0064..d000fde1bb0bea 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/norm2.cpp
+++ b/flang-rt/lib/FortranFloat128Math/norm2.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/norm2.cpp ----------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h b/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
similarity index 84%
rename from FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
rename to flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
index 2a843df2d1d861..f34ee5f4e3a8de 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/numeric-template-specs.h
+++ b/flang-rt/lib/FortranFloat128Math/numeric-template-specs.h
@@ -1,4 +1,4 @@
-//===-- lib/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,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
-#define FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#ifndef FORTRAN_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
+#define FORTRAN_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_
#include "math-entries.h"
#include "numeric-templates.h"
@@ -52,4 +52,4 @@ template <> struct SQRTTy<F128Type> {
};
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_FLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_ */
+#endif /* FORTRAN_FORTRANFLOAT128MATH_NUMERIC_TEMPLATE_SPECS_H_ */
diff --git a/FortranRuntime/lib/Runtime/Float128Math/pow.cpp b/flang-rt/lib/FortranFloat128Math/pow.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/pow.cpp
rename to flang-rt/lib/FortranFloat128Math/pow.cpp
index c11978ca068f23..f5deb00a556f48 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/pow.cpp
+++ b/flang-rt/lib/FortranFloat128Math/pow.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/pow.cpp ------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/random.cpp b/flang-rt/lib/FortranFloat128Math/random.cpp
similarity index 91%
rename from FortranRuntime/lib/Runtime/Float128Math/random.cpp
rename to flang-rt/lib/FortranFloat128Math/random.cpp
index a9dc3c7a82b673..3a01c2c88b1d66 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/random.cpp
+++ b/flang-rt/lib/FortranFloat128Math/random.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/random.cpp ---------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/Float128Math/round.cpp b/flang-rt/lib/FortranFloat128Math/round.cpp
similarity index 92%
rename from FortranRuntime/lib/Runtime/Float128Math/round.cpp
rename to flang-rt/lib/FortranFloat128Math/round.cpp
index 5a9366b3af4785..3453f4ea8a1a26 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/round.cpp
+++ b/flang-rt/lib/FortranFloat128Math/round.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/round.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/rrspacing.cpp b/flang-rt/lib/FortranFloat128Math/rrspacing.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/rrspacing.cpp
rename to flang-rt/lib/FortranFloat128Math/rrspacing.cpp
index 2c501b3512c215..0809815027f859 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/rrspacing.cpp
+++ b/flang-rt/lib/FortranFloat128Math/rrspacing.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/rrspacing.cpp ------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/scale.cpp b/flang-rt/lib/FortranFloat128Math/scale.cpp
similarity index 92%
rename from FortranRuntime/lib/Runtime/Float128Math/scale.cpp
rename to flang-rt/lib/FortranFloat128Math/scale.cpp
index 859c955b8114e0..37528330bfb115 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/scale.cpp
+++ b/flang-rt/lib/FortranFloat128Math/scale.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/scale.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/set-exponent.cpp b/flang-rt/lib/FortranFloat128Math/set-exponent.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/set-exponent.cpp
rename to flang-rt/lib/FortranFloat128Math/set-exponent.cpp
index 52258182871a14..52f8f08f7003ef 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/set-exponent.cpp
+++ b/flang-rt/lib/FortranFloat128Math/set-exponent.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/set-exponent.cpp ---------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/sin.cpp b/flang-rt/lib/FortranFloat128Math/sin.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/sin.cpp
rename to flang-rt/lib/FortranFloat128Math/sin.cpp
index 99aa4095c8cf1a..1a24e7c57ba469 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/sin.cpp
+++ b/flang-rt/lib/FortranFloat128Math/sin.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/sin.cpp ------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/sinh.cpp b/flang-rt/lib/FortranFloat128Math/sinh.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/sinh.cpp
rename to flang-rt/lib/FortranFloat128Math/sinh.cpp
index a7dfe36737de43..7a4127cee970cd 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/sinh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/sinh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/sinh.cpp -----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/spacing.cpp b/flang-rt/lib/FortranFloat128Math/spacing.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/spacing.cpp
rename to flang-rt/lib/FortranFloat128Math/spacing.cpp
index 66a01851965840..d3ed077d5412dc 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/spacing.cpp
+++ b/flang-rt/lib/FortranFloat128Math/spacing.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/spacing.cpp --------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/sqrt.cpp b/flang-rt/lib/FortranFloat128Math/sqrt.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/sqrt.cpp
rename to flang-rt/lib/FortranFloat128Math/sqrt.cpp
index cbc1e503d50fd9..a9f5246f35388f 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/sqrt.cpp
+++ b/flang-rt/lib/FortranFloat128Math/sqrt.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/sqrt.cpp -----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/tan.cpp b/flang-rt/lib/FortranFloat128Math/tan.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/tan.cpp
rename to flang-rt/lib/FortranFloat128Math/tan.cpp
index dbe4627f585f14..dc386c5be6ab74 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/tan.cpp
+++ b/flang-rt/lib/FortranFloat128Math/tan.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/tan.cpp ------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/tanh.cpp b/flang-rt/lib/FortranFloat128Math/tanh.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/tanh.cpp
rename to flang-rt/lib/FortranFloat128Math/tanh.cpp
index 37e40966ced722..5f8af3f1cd8d77 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/tanh.cpp
+++ b/flang-rt/lib/FortranFloat128Math/tanh.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/tanh.cpp -----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/tgamma.cpp b/flang-rt/lib/FortranFloat128Math/tgamma.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/tgamma.cpp
rename to flang-rt/lib/FortranFloat128Math/tgamma.cpp
index 07a019c6d9971f..b1a42cdc5d0f41 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/tgamma.cpp
+++ b/flang-rt/lib/FortranFloat128Math/tgamma.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/tgamma.cpp ---------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/trunc.cpp b/flang-rt/lib/FortranFloat128Math/trunc.cpp
similarity index 91%
rename from FortranRuntime/lib/Runtime/Float128Math/trunc.cpp
rename to flang-rt/lib/FortranFloat128Math/trunc.cpp
index 9f38bdc18e73c4..455204ece3b2f6 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/trunc.cpp
+++ b/flang-rt/lib/FortranFloat128Math/trunc.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/trunc.cpp ----------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/y0.cpp b/flang-rt/lib/FortranFloat128Math/y0.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/y0.cpp
rename to flang-rt/lib/FortranFloat128Math/y0.cpp
index 6eaa3396e7ea07..58bd71105efea6 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/y0.cpp
+++ b/flang-rt/lib/FortranFloat128Math/y0.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/y0.cpp -------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/y1.cpp b/flang-rt/lib/FortranFloat128Math/y1.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/y1.cpp
rename to flang-rt/lib/FortranFloat128Math/y1.cpp
index c9f48ea0e26546..5d7b48e276b6f9 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/y1.cpp
+++ b/flang-rt/lib/FortranFloat128Math/y1.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/y1.cpp -------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/Float128Math/yn.cpp b/flang-rt/lib/FortranFloat128Math/yn.cpp
similarity index 90%
rename from FortranRuntime/lib/Runtime/Float128Math/yn.cpp
rename to flang-rt/lib/FortranFloat128Math/yn.cpp
index 6bc5f4996a88d5..9f19861931d84c 100644
--- a/FortranRuntime/lib/Runtime/Float128Math/yn.cpp
+++ b/flang-rt/lib/FortranFloat128Math/yn.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/Float128Math/yn.cpp -------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Testing/CMakeLists.txt b/flang-rt/lib/Testing/CMakeLists.txt
similarity index 89%
rename from FortranRuntime/lib/Testing/CMakeLists.txt
rename to flang-rt/lib/Testing/CMakeLists.txt
index 41ad0d7314dd37..bdfca0ee9d3f23 100644
--- a/FortranRuntime/lib/Testing/CMakeLists.txt
+++ b/flang-rt/lib/Testing/CMakeLists.txt
@@ -11,7 +11,7 @@ file(GLOB_RECURSE public_headers
"${FLANG_SOURCE_DIR}/lib/Testing/*.h"
)
-add_fortranruntime_library(NonGTestTesting EXCLUDE_FROM_ALL LINK_TO_LLVM
+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
diff --git a/FortranRuntime/lib/Runtime/CMakeLists.txt b/flang-rt/lib/flang_rt/CMakeLists.txt
similarity index 66%
rename from FortranRuntime/lib/Runtime/CMakeLists.txt
rename to flang-rt/lib/flang_rt/CMakeLists.txt
index 1db5520d5eaedf..860152c39c7204 100644
--- a/FortranRuntime/lib/Runtime/CMakeLists.txt
+++ b/flang-rt/lib/flang_rt/CMakeLists.txt
@@ -1,4 +1,4 @@
-#===-- lib/Runtime/CMakeLists.txt ------------------------------------------===#
+#===-- 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.
@@ -6,7 +6,7 @@
#
#===------------------------------------------------------------------------===#
-include(AddFortranOffloadRuntime)
+include(AddFlangRTOffload)
# List of files that are buildable for all devices.
set(supported_sources
@@ -73,7 +73,7 @@ set(host_sources
exceptions.cpp
execute.cpp
extensions.cpp
- iso_fortran_env_impl.f90
+ ${FLANG_SOURCE_DIR}/module/iso_fortran_env_impl.f90
main.cpp
random.cpp
reduce.cpp
@@ -84,18 +84,17 @@ set(host_sources
)
file(GLOB_RECURSE public_headers
- "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Runtime/*.h"
- "${FLANGRUNTIME_SOURCE_DIR}/include/flang/Common/*.h"
+ "${FLANGRT_SOURCE_DIR}/include/flang/Runtime/*.h"
+ "${FLANGRT_SOURCE_DIR}/include/flang/Common/*.h"
)
file(GLOB_RECURSE private_headers
- "${FLANGRUNTIME_SOURCE_DIR}/lib/Runtime/*.h"
- "${FLANGRUNTIME_SOURCE_DIR}/lib/Common/*.h"
+ "${FLANGRT_SOURCE_DIR}/lib/Runtime/*.h"
+ "${FLANGRT_SOURCE_DIR}/lib/Common/*.h"
)
-add_subdirectory(Float128Math)
-
+# Import changes from sibling FortranFloat128Math
get_target_property(f128_sources
FortranFloat128MathILib INTERFACE_SOURCES
)
@@ -117,23 +116,23 @@ endif ()
set(sources ${supported_sources} ${host_sources} ${f128_sources})
if (NOT WIN32)
- add_fortranruntime_library(FortranRuntime STATIC
+ add_flangrt_library(flang_rt STATIC
${sources}
INSTALL_WITH_TOOLCHAIN
ADDITIONAL_HEADERS ${public_headers} ${private_headers}
)
- enable_cuda_compilation(FortranRuntime "${supported_sources}")
+ enable_cuda_compilation(flang_rt "${supported_sources}")
enable_omp_offload_compilation("${supported_sources}")
- # For unittests that link to FortranRuntime. Should link to the static version
+ # For unittests that depend on flang_rt. Should link to the static version
# of the library.
- add_library(FortranRuntime.static ALIAS FortranRuntime)
- add_library(FortranRuntime.unittest ALIAS FortranRuntime)
+ add_library(flang_rt.static ALIAS flang_rt)
+ add_library(flang_rt.unittest ALIAS flang_rt)
else()
- function (add_win_fortranruntime_library libtype suffix msvc_lib)
- set(name "FortranRuntime.${suffix}")
- add_fortranruntime_library(${name} ${libtype}
+ function (add_win_flangrt_library libtype suffix msvc_lib)
+ set(name "flang_rt.${suffix}")
+ add_flangrt_library(${name} ${libtype}
${sources}
${ARGN}
INSTALL_WITH_TOOLCHAIN
@@ -148,32 +147,28 @@ else()
Fortran_MODULE_DIRECTORY "module.${suffix}"
)
- enable_cuda_compilation(FortranRuntime "${supported_sources}")
+ enable_cuda_compilation(${name} "${supported_sources}")
enable_omp_offload_compilation("${supported_sources}")
endfunction ()
- add_win_fortranruntime_library(STATIC static MultiThreaded)
- add_win_fortranruntime_library(STATIC static_dbg MultiThreadedDebug)
+ add_win_flangrt_library(STATIC static MultiThreaded)
+ add_win_flangrt_library(STATIC static_dbg MultiThreadedDebug)
# unittests link against LLVMSupport which is compiled with /MD
- add_win_fortranruntime_library(STATIC unittest MultiThreadedDLL EXCLUDE_FROM_ALL)
+ add_win_flangrt_library(STATIC unittest MultiThreadedDLL EXCLUDE_FROM_ALL)
# FIXME: Before DLL versions of the runtime can be used, exported definitions
# must be annotated with __declspec(dllexport).
- add_win_fortranruntime_library(SHARED dynamic MultiThreadedDLL)
- add_win_fortranruntime_library(SHARED dynamic_dbg MultiThreadedDebugDLL)
+ add_win_flangrt_library(SHARED dynamic MultiThreadedDLL)
+ add_win_flangrt_library(SHARED dynamic_dbg MultiThreadedDebugDLL)
# Target for building all versions of the runtime
- add_custom_target(FortranRuntime)
- set_target_properties(FortranRuntime PROPERTIES FOLDER "Fortran Runtime/Meta")
- add_dependencies(FortranRuntime
- FortranRuntime.static
- FortranRuntime.static_dbg
- FortranRuntime.dynamic
- FortranRuntime.dynamic_dbg
+ add_custom_target(flang_rt)
+ set_target_properties(flang_rt PROPERTIES FOLDER "Fortran Runtime/Meta")
+ add_dependencies(flang_rt
+ flang_rt.static
+ flang_rt.static_dbg
+ flang_rt.dynamic
+ flang_rt.dynamic_dbg
)
endif()
-
-if (FORTRANRUNTIME_ENABLE_CUF)
- add_subdirectory(CUDA)
-endif()
diff --git a/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp b/flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
rename to flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
index 997226b08e96a6..37bc1b9dfe426b 100644
--- a/FortranRuntime/lib/Runtime/ISO_Fortran_binding.cpp
+++ b/flang-rt/lib/flang_rt/ISO_Fortran_binding.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/ISO_Fortran_binding.cpp ---------------------*- C++ -*-===//
+//===-- 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.
@@ -9,9 +9,9 @@
// Implements the required interoperability API from ISO_Fortran_binding.h
// as specified in section 18.5.5 of Fortran 2018.
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/type-code.h"
#include "ISO_Fortran_util.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "terminator.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/pointer.h"
diff --git a/FortranRuntime/lib/Runtime/ISO_Fortran_util.h b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
similarity index 91%
rename from FortranRuntime/lib/Runtime/ISO_Fortran_util.h
rename to flang-rt/lib/flang_rt/ISO_Fortran_util.h
index e418266dddccc7..a7bb1d21679063 100644
--- a/FortranRuntime/lib/Runtime/ISO_Fortran_util.h
+++ b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
@@ -1,4 +1,4 @@
-//===-- lib/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,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_ISO_FORTRAN_UTIL_H_
-#define FORTRAN_RUNTIME_ISO_FORTRAN_UTIL_H_
+#ifndef FORTRAN_FLANG_RT_ISO_FORTRAN_UTIL_H_
+#define FORTRAN_FLANG_RT_ISO_FORTRAN_UTIL_H_
// Internal utils for establishing CFI_cdesc_t descriptors.
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "terminator.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 /* FORTRAN_RUNTIME_ISO_FORTRAN_UTIL_H_ */
+#endif /* FORTRAN_FLANG_RT_ISO_FORTRAN_UTIL_H_ */
diff --git a/FortranRuntime/lib/Runtime/allocatable.cpp b/flang-rt/lib/flang_rt/allocatable.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/allocatable.cpp
rename to flang-rt/lib/flang_rt/allocatable.cpp
index 4a3b89f4879c12..b9be74f8cb6f1b 100644
--- a/FortranRuntime/lib/Runtime/allocatable.cpp
+++ b/flang-rt/lib/flang_rt/allocatable.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/allocatable.cpp -----------------------------*- C++ -*-===//
+//===-- 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,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/allocatable.h"
-#include "FortranRuntime/Runtime/descriptor.h"
#include "assign-impl.h"
#include "derived.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "type-info.h"
diff --git a/FortranRuntime/lib/Runtime/allocator-registry.cpp b/flang-rt/lib/flang_rt/allocator-registry.cpp
similarity index 85%
rename from FortranRuntime/lib/Runtime/allocator-registry.cpp
rename to flang-rt/lib/flang_rt/allocator-registry.cpp
index 17883e5c54870d..a0e6fd8eadc856 100644
--- a/FortranRuntime/lib/Runtime/allocator-registry.cpp
+++ b/flang-rt/lib/flang_rt/allocator-registry.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/allocator-registry.cpp ----------------------*- C++ -*-===//
+//===-- 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,16 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/allocator-registry.h"
+#include "flang-rt/flang_rt/allocator-registry.h"
#include "terminator.h"
namespace Fortran::runtime {
-#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FLANGRT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS AllocatorRegistry allocatorRegistry;
RT_OFFLOAD_VAR_GROUP_END
-#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FLANGRT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
RT_API_ATTRS void AllocatorRegistry::Register(int pos, Allocator_t allocator) {
diff --git a/FortranRuntime/lib/Runtime/array-constructor.cpp b/flang-rt/lib/flang_rt/array-constructor.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/array-constructor.cpp
rename to flang-rt/lib/flang_rt/array-constructor.cpp
index 002dfba2c066f5..daaa1e3b04a3b6 100644
--- a/FortranRuntime/lib/Runtime/array-constructor.cpp
+++ b/flang-rt/lib/flang_rt/array-constructor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/array-constructor.cpp -----------------------*- C++ -*-===//
+//===-- 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,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/array-constructor.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/array-constructor.h"
#include "derived.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "type-info.h"
diff --git a/FortranRuntime/lib/Runtime/assign-impl.h b/flang-rt/lib/flang_rt/assign-impl.h
similarity index 100%
rename from FortranRuntime/lib/Runtime/assign-impl.h
rename to flang-rt/lib/flang_rt/assign-impl.h
diff --git a/FortranRuntime/lib/Runtime/assign.cpp b/flang-rt/lib/flang_rt/assign.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/assign.cpp
rename to flang-rt/lib/flang_rt/assign.cpp
index 3a1486ace928a2..4916fc48888189 100644
--- a/FortranRuntime/lib/Runtime/assign.cpp
+++ b/flang-rt/lib/flang_rt/assign.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/assign.cpp ----------------------------------*- C++ -*-===//
+//===-- 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,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/assign.h"
-#include "FortranRuntime/Runtime/descriptor.h"
#include "assign-impl.h"
#include "derived.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/buffer.cpp b/flang-rt/lib/flang_rt/buffer.cpp
similarity index 93%
rename from FortranRuntime/lib/Runtime/buffer.cpp
rename to flang-rt/lib/flang_rt/buffer.cpp
index ce78fe34503c46..9913cdf2e7ec40 100644
--- a/FortranRuntime/lib/Runtime/buffer.cpp
+++ b/flang-rt/lib/flang_rt/buffer.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/buffer.cpp ----------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/buffer.h b/flang-rt/lib/flang_rt/buffer.h
similarity index 97%
rename from FortranRuntime/lib/Runtime/buffer.h
rename to flang-rt/lib/flang_rt/buffer.h
index 52df0f10813c25..eb9b0712819a6c 100644
--- a/FortranRuntime/lib/Runtime/buffer.h
+++ b/flang-rt/lib/flang_rt/buffer.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/buffer.h ------------------------------------*- C++ -*-===//
+//===-- lib/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,10 +8,10 @@
// External file buffering
-#ifndef FORTRAN_RUNTIME_BUFFER_H_
-#define FORTRAN_RUNTIME_BUFFER_H_
+#ifndef FORTRAN_FLANG_RT_BUFFER_H_
+#define FORTRAN_FLANG_RT_BUFFER_H_
-#include "FortranRuntime/Runtime/memory.h"
+#include "flang-rt/flang_rt/memory.h"
#include "io-error.h"
#include "flang/Runtime/freestanding-tools.h"
#include <algorithm>
@@ -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 /* FORTRAN_FLANG_RT_BUFFER_H_ */
diff --git a/FortranRuntime/lib/Runtime/character.cpp b/flang-rt/lib/flang_rt/character.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/character.cpp
rename to flang-rt/lib/flang_rt/character.cpp
index 1f3edd6e80392e..aeb26098c399c8 100644
--- a/FortranRuntime/lib/Runtime/character.cpp
+++ b/flang-rt/lib/flang_rt/character.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/character.cpp -------------------------------*- C++ -*-===//
+//===-- 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,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/character.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Common/bit-population-count.h"
diff --git a/FortranRuntime/lib/Runtime/command.cpp b/flang-rt/lib/flang_rt/command.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/command.cpp
rename to flang-rt/lib/flang_rt/command.cpp
index 64b2e62461dd58..5c7497518f3da3 100644
--- a/FortranRuntime/lib/Runtime/command.cpp
+++ b/flang-rt/lib/flang_rt/command.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/command.cpp ---------------------------------*- C++ -*-===//
+//===-- 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,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/command.h"
-#include "FortranRuntime/Runtime/descriptor.h"
#include "environment.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/complex-powi.cpp b/flang-rt/lib/flang_rt/complex-powi.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/complex-powi.cpp
rename to flang-rt/lib/flang_rt/complex-powi.cpp
index 2eacf56386b193..90013c117aea41 100644
--- a/FortranRuntime/lib/Runtime/complex-powi.cpp
+++ b/flang-rt/lib/flang_rt/complex-powi.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/complex-powi.cpp ----------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/complex-reduction.c b/flang-rt/lib/flang_rt/complex-reduction.c
similarity index 98%
rename from FortranRuntime/lib/Runtime/complex-reduction.c
rename to flang-rt/lib/flang_rt/complex-reduction.c
index 138174e9122b1c..23f1edb58b2d4e 100644
--- a/FortranRuntime/lib/Runtime/complex-reduction.c
+++ b/flang-rt/lib/flang_rt/complex-reduction.c
@@ -1,4 +1,4 @@
-/*===-- lib/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.
diff --git a/FortranRuntime/lib/Runtime/complex-reduction.h b/flang-rt/lib/flang_rt/complex-reduction.h
similarity index 97%
rename from FortranRuntime/lib/Runtime/complex-reduction.h
rename to flang-rt/lib/flang_rt/complex-reduction.h
index e8e287215b7d97..b386b25cd0fff8 100644
--- a/FortranRuntime/lib/Runtime/complex-reduction.h
+++ b/flang-rt/lib/flang_rt/complex-reduction.h
@@ -1,4 +1,4 @@
-/*===-- lib/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.
@@ -11,8 +11,8 @@
* with C++ build compilers that don't support C's _Complex.
*/
-#ifndef FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_
-#define FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_
+#ifndef FORTRAN_FLANG_RT_COMPLEX_REDUCTION_H_
+#define FORTRAN_FLANG_RT_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 /* FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_ */
+#endif /* FORTRAN_FLANG_RT_COMPLEX_REDUCTION_H_ */
diff --git a/FortranRuntime/lib/Runtime/connection.cpp b/flang-rt/lib/flang_rt/connection.cpp
similarity index 97%
rename from FortranRuntime/lib/Runtime/connection.cpp
rename to flang-rt/lib/flang_rt/connection.cpp
index f9e91f1f193ba0..d623190f22f6f9 100644
--- a/FortranRuntime/lib/Runtime/connection.cpp
+++ b/flang-rt/lib/flang_rt/connection.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/connection.cpp ------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/connection.h b/flang-rt/lib/flang_rt/connection.h
similarity index 96%
rename from FortranRuntime/lib/Runtime/connection.h
rename to flang-rt/lib/flang_rt/connection.h
index e078bfb9f0f7e7..f8b9b3f9debcda 100644
--- a/FortranRuntime/lib/Runtime/connection.h
+++ b/flang-rt/lib/flang_rt/connection.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/connection.h --------------------------------*- C++ -*-===//
+//===-- lib/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_CONNECTION_H_
-#define FORTRAN_RUNTIME_CONNECTION_H_
+#ifndef FORTRAN_FLANG_RT_CONNECTION_H_
+#define FORTRAN_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_CONNECTION_H_ */
+#endif /* FORTRAN_FLANG_RT_CONNECTION_H_ */
diff --git a/FortranRuntime/lib/Runtime/copy.cpp b/flang-rt/lib/flang_rt/copy.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/copy.cpp
rename to flang-rt/lib/flang_rt/copy.cpp
index 1049b925f68e5c..fc5c0af6b95851 100644
--- a/FortranRuntime/lib/Runtime/copy.cpp
+++ b/flang-rt/lib/flang_rt/copy.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/copy.cpp ------------------------------------*- C++ -*-===//
+//===-- 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.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "copy.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "stack.h"
#include "terminator.h"
#include "type-info.h"
diff --git a/FortranRuntime/lib/Runtime/copy.h b/flang-rt/lib/flang_rt/copy.h
similarity index 78%
rename from FortranRuntime/lib/Runtime/copy.h
rename to flang-rt/lib/flang_rt/copy.h
index 3d179d0bec91a7..8f27c3a90b7847 100644
--- a/FortranRuntime/lib/Runtime/copy.h
+++ b/flang-rt/lib/flang_rt/copy.h
@@ -1,4 +1,4 @@
-//===-- lib/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 FORTRAN_FLANG_RT_COPY_H_
+#define FORTRAN_FLANG_RT_COPY_H_
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/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 /* FORTRAN_FLANG_RT_COPY_H_ */
diff --git a/FortranRuntime/lib/Runtime/derived-api.cpp b/flang-rt/lib/flang_rt/derived-api.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/derived-api.cpp
rename to flang-rt/lib/flang_rt/derived-api.cpp
index 176fc0849f25cf..faf24508981bae 100644
--- a/FortranRuntime/lib/Runtime/derived-api.cpp
+++ b/flang-rt/lib/flang_rt/derived-api.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/derived-api.cpp -----------------------------*- C++ -*-===//
+//===-- 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.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/derived-api.h"
-#include "FortranRuntime/Runtime/descriptor.h"
#include "derived.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "type-info.h"
diff --git a/FortranRuntime/lib/Runtime/derived.cpp b/flang-rt/lib/flang_rt/derived.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/derived.cpp
rename to flang-rt/lib/flang_rt/derived.cpp
index cb2dca24bb4758..9b17a0d437375c 100644
--- a/FortranRuntime/lib/Runtime/derived.cpp
+++ b/flang-rt/lib/flang_rt/derived.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/derived.cpp ---------------------------------*- C++ -*-===//
+//===-- 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.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "derived.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/derived.h b/flang-rt/lib/flang_rt/derived.h
similarity index 88%
rename from FortranRuntime/lib/Runtime/derived.h
rename to flang-rt/lib/flang_rt/derived.h
index e03e657f01cee9..3d6563f39c0663 100644
--- a/FortranRuntime/lib/Runtime/derived.h
+++ b/flang-rt/lib/flang_rt/derived.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/derived.h -----------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_DERIVED_H_
+#define FORTRAN_FLANG_RT_DERIVED_H_
#include "flang/Common/api-attrs.h"
@@ -40,4 +40,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 /* FORTRAN_FLANG_RT_DERIVED_H_ */
diff --git a/FortranRuntime/lib/Runtime/descriptor-io.cpp b/flang-rt/lib/flang_rt/descriptor-io.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/descriptor-io.cpp
rename to flang-rt/lib/flang_rt/descriptor-io.cpp
index 896fad16a67e8a..c5cfa4d7fc5972 100644
--- a/FortranRuntime/lib/Runtime/descriptor-io.cpp
+++ b/flang-rt/lib/flang_rt/descriptor-io.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/descriptor-io.cpp ---------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/descriptor-io.h b/flang-rt/lib/flang_rt/descriptor-io.h
similarity index 98%
rename from FortranRuntime/lib/Runtime/descriptor-io.h
rename to flang-rt/lib/flang_rt/descriptor-io.h
index 30d1bd48457728..2e48b4a0353e2a 100644
--- a/FortranRuntime/lib/Runtime/descriptor-io.h
+++ b/flang-rt/lib/flang_rt/descriptor-io.h
@@ -1,4 +1,4 @@
-//===-- lib/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,17 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_DESCRIPTOR_IO_H_
-#define FORTRAN_RUNTIME_DESCRIPTOR_IO_H_
+#ifndef FORTRAN_FLANG_RT_DESCRIPTOR_IO_H_
+#define FORTRAN_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;
// some scalar I/O data transfer APIs could be changed to bypass their use
// of descriptors in the future for better efficiency.)
-#include "FortranRuntime/Runtime/descriptor.h"
#include "edit-input.h"
#include "edit-output.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "io-stmt.h"
#include "namelist.h"
#include "terminator.h"
@@ -608,4 +608,4 @@ static RT_API_ATTRS bool DescriptorIO(IoStatementState &io,
return false;
}
} // namespace Fortran::runtime::io::descr
-#endif /* FORTRAN_RUNTIME_DESCRIPTOR_IO_H_ */
+#endif /* FORTRAN_FLANG_RT_DESCRIPTOR_IO_H_ */
diff --git a/FortranRuntime/lib/Runtime/descriptor.cpp b/flang-rt/lib/flang_rt/descriptor.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/descriptor.cpp
rename to flang-rt/lib/flang_rt/descriptor.cpp
index 96fd48eb6687a9..77536e760ad1cd 100644
--- a/FortranRuntime/lib/Runtime/descriptor.cpp
+++ b/flang-rt/lib/flang_rt/descriptor.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/descriptor.cpp ------------------------------*- C++ -*-===//
+//===-- 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,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/allocator-registry.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "ISO_Fortran_util.h"
#include "derived.h"
+#include "flang-rt/flang_rt/allocator-registry.h"
#include "memory.h"
#include "stat.h"
#include "terminator.h"
diff --git a/FortranRuntime/lib/Runtime/dot-product.cpp b/flang-rt/lib/flang_rt/dot-product.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/dot-product.cpp
rename to flang-rt/lib/flang_rt/dot-product.cpp
index 2992cbb1f39ad6..01e15ad331d7c4 100644
--- a/FortranRuntime/lib/Runtime/dot-product.cpp
+++ b/flang-rt/lib/flang_rt/dot-product.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/dot-product.cpp -----------------------------*- C++ -*-===//
+//===-- 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.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "float.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/edit-input.cpp b/flang-rt/lib/flang_rt/edit-input.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/edit-input.cpp
rename to flang-rt/lib/flang_rt/edit-input.cpp
index 6ebb0e7aca4ade..9e3f102cf86684 100644
--- a/FortranRuntime/lib/Runtime/edit-input.cpp
+++ b/flang-rt/lib/flang_rt/edit-input.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/edit-input.cpp ------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/edit-input.h b/flang-rt/lib/flang_rt/edit-input.h
similarity index 90%
rename from FortranRuntime/lib/Runtime/edit-input.h
rename to flang-rt/lib/flang_rt/edit-input.h
index f88f6daa47be79..59f601afa306a3 100644
--- a/FortranRuntime/lib/Runtime/edit-input.h
+++ b/flang-rt/lib/flang_rt/edit-input.h
@@ -1,4 +1,4 @@
-//===-- lib/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,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_EDIT_INPUT_H_
-#define FORTRAN_RUNTIME_EDIT_INPUT_H_
+#ifndef FORTRAN_FLANG_RT_EDIT_INPUT_H_
+#define FORTRAN_FLANG_RT_EDIT_INPUT_H_
#include "format.h"
#include "io-stmt.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 /* FORTRAN_RUNTIME_EDIT_INPUT_H_ */
+#endif /* FORTRAN_FLANG_RT_EDIT_INPUT_H_ */
diff --git a/FortranRuntime/lib/Runtime/edit-output.cpp b/flang-rt/lib/flang_rt/edit-output.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/edit-output.cpp
rename to flang-rt/lib/flang_rt/edit-output.cpp
index ccaf8085f016fd..2e353f1ad80a21 100644
--- a/FortranRuntime/lib/Runtime/edit-output.cpp
+++ b/flang-rt/lib/flang_rt/edit-output.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/edit-output.cpp -----------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/edit-output.h b/flang-rt/lib/flang_rt/edit-output.h
similarity index 96%
rename from FortranRuntime/lib/Runtime/edit-output.h
rename to flang-rt/lib/flang_rt/edit-output.h
index 7e6c6cdedde3ac..325658b4a25dc6 100644
--- a/FortranRuntime/lib/Runtime/edit-output.h
+++ b/flang-rt/lib/flang_rt/edit-output.h
@@ -1,4 +1,4 @@
-//===-- lib/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 FORTRAN_FLANG_RT_EDIT_OUTPUT_H_
+#define FORTRAN_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
@@ -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 /* FORTRAN_FLANG_RT_EDIT_OUTPUT_H_ */
diff --git a/FortranRuntime/lib/Runtime/emit-encoded.h b/flang-rt/lib/flang_rt/emit-encoded.h
similarity index 94%
rename from FortranRuntime/lib/Runtime/emit-encoded.h
rename to flang-rt/lib/flang_rt/emit-encoded.h
index 11163a41720795..87216e5808a286 100644
--- a/FortranRuntime/lib/Runtime/emit-encoded.h
+++ b/flang-rt/lib/flang_rt/emit-encoded.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/emit-encoded.h ------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_EMIT_ENCODED_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_EMIT_ENCODED_H_ */
diff --git a/FortranRuntime/lib/Runtime/environment-default-list.h b/flang-rt/lib/flang_rt/environment-default-list.h
similarity index 100%
rename from FortranRuntime/lib/Runtime/environment-default-list.h
rename to flang-rt/lib/flang_rt/environment-default-list.h
diff --git a/FortranRuntime/lib/Runtime/environment.cpp b/flang-rt/lib/flang_rt/environment.cpp
similarity index 96%
rename from FortranRuntime/lib/Runtime/environment.cpp
rename to flang-rt/lib/flang_rt/environment.cpp
index 272914877988a5..a9447815efeeaf 100644
--- a/FortranRuntime/lib/Runtime/environment.cpp
+++ b/flang-rt/lib/flang_rt/environment.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/environment.cpp -----------------------------*- C++ -*-===//
+//===-- 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.
@@ -23,11 +23,11 @@ extern char **environ;
namespace Fortran::runtime {
-#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FLANGRT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS ExecutionEnvironment executionEnvironment;
RT_OFFLOAD_VAR_GROUP_END
-#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FLANGRT_NO_GLOBAL_VAR_DEFS
static void SetEnvironmentDefaults(const EnvironmentDefaultList *envDefaults) {
if (!envDefaults) {
diff --git a/FortranRuntime/lib/Runtime/environment.h b/flang-rt/lib/flang_rt/environment.h
similarity index 91%
rename from FortranRuntime/lib/Runtime/environment.h
rename to flang-rt/lib/flang_rt/environment.h
index 7d10b3a2b934bf..125c9b39528b94 100644
--- a/FortranRuntime/lib/Runtime/environment.h
+++ b/flang-rt/lib/flang_rt/environment.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/environment.h -------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_ENVIRONMENT_H_
+#define FORTRAN_FLANG_RT_ENVIRONMENT_H_
#include "flang/Common/decimal.h"
#include "flang/Common/optional.h"
@@ -64,4 +64,4 @@ RT_OFFLOAD_VAR_GROUP_END
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_ENVIRONMENT_H_ */
+#endif /* FORTRAN_FLANG_RT_ENVIRONMENT_H_ */
diff --git a/FortranRuntime/lib/Runtime/exceptions.cpp b/flang-rt/lib/flang_rt/exceptions.cpp
similarity index 97%
rename from FortranRuntime/lib/Runtime/exceptions.cpp
rename to flang-rt/lib/flang_rt/exceptions.cpp
index 7739130ae2346a..9ad5fe6849b076 100644
--- a/FortranRuntime/lib/Runtime/exceptions.cpp
+++ b/flang-rt/lib/flang_rt/exceptions.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/exceptions.cpp ------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/execute.cpp b/flang-rt/lib/flang_rt/execute.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/execute.cpp
rename to flang-rt/lib/flang_rt/execute.cpp
index b333c61c8a59f4..d3d42a49737fed 100644
--- a/FortranRuntime/lib/Runtime/execute.cpp
+++ b/flang-rt/lib/flang_rt/execute.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/execute.cpp ---------------------------------*- C++ -*-===//
+//===-- 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,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/execute.h"
-#include "FortranRuntime/Runtime/descriptor.h"
#include "environment.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "stat.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/extensions.cpp b/flang-rt/lib/flang_rt/extensions.cpp
similarity index 97%
rename from FortranRuntime/lib/Runtime/extensions.cpp
rename to flang-rt/lib/flang_rt/extensions.cpp
index bb25fe6ee9d886..4cd9791cd0e5cb 100644
--- a/FortranRuntime/lib/Runtime/extensions.cpp
+++ b/flang-rt/lib/flang_rt/extensions.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/extensions.cpp ------------------------------*- C++ -*-===//
+//===-- 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,8 +10,8 @@
// extensions that will eventually be implemented in Fortran.
#include "flang/Runtime/extensions.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/io-api-funcs.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Runtime/command.h"
diff --git a/FortranRuntime/lib/Runtime/external-unit.cpp b/flang-rt/lib/flang_rt/external-unit.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/external-unit.cpp
rename to flang-rt/lib/flang_rt/external-unit.cpp
index f5fa2c31dafc4e..1942cc1ff4daec 100644
--- a/FortranRuntime/lib/Runtime/external-unit.cpp
+++ b/flang-rt/lib/flang_rt/external-unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/external-unit.cpp ---------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/extrema.cpp b/flang-rt/lib/flang_rt/extrema.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/extrema.cpp
rename to flang-rt/lib/flang_rt/extrema.cpp
index be9da63d7bd6b8..7a230afc4190c6 100644
--- a/FortranRuntime/lib/Runtime/extrema.cpp
+++ b/flang-rt/lib/flang_rt/extrema.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/extrema.cpp ---------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/file.cpp b/flang-rt/lib/flang_rt/file.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/file.cpp
rename to flang-rt/lib/flang_rt/file.cpp
index de52dafd12df9a..d98c8afeca3514 100644
--- a/FortranRuntime/lib/Runtime/file.cpp
+++ b/flang-rt/lib/flang_rt/file.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/file.cpp ------------------------------------*- C++ -*-===//
+//===-- 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.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "file.h"
-#include "FortranRuntime/Runtime/memory.h"
+#include "flang-rt/flang_rt/memory.h"
#include "tools.h"
#include "flang/Runtime/magic-numbers.h"
#include <algorithm>
diff --git a/FortranRuntime/lib/Runtime/file.h b/flang-rt/lib/flang_rt/file.h
similarity index 94%
rename from FortranRuntime/lib/Runtime/file.h
rename to flang-rt/lib/flang_rt/file.h
index 60ddf2a2741610..b4068e3dce0d14 100644
--- a/FortranRuntime/lib/Runtime/file.h
+++ b/flang-rt/lib/flang_rt/file.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/file.h --------------------------------------*- C++ -*-===//
+//===-- lib/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,10 +8,10 @@
// Raw system I/O wrappers
-#ifndef FORTRAN_RUNTIME_FILE_H_
-#define FORTRAN_RUNTIME_FILE_H_
+#ifndef FORTRAN_FLANG_RT_FILE_H_
+#define FORTRAN_FLANG_RT_FILE_H_
-#include "FortranRuntime/Runtime/memory.h"
+#include "flang-rt/flang_rt/memory.h"
#include "io-error.h"
#include "flang/Common/optional.h"
#include <cinttypes>
@@ -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 /* FORTRAN_FLANG_RT_FILE_H_ */
diff --git a/FortranRuntime/lib/Runtime/findloc.cpp b/flang-rt/lib/flang_rt/findloc.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/findloc.cpp
rename to flang-rt/lib/flang_rt/findloc.cpp
index da5fe0c0a0a467..8ee4c7c6cf7800 100644
--- a/FortranRuntime/lib/Runtime/findloc.cpp
+++ b/flang-rt/lib/flang_rt/findloc.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/findloc.cpp ---------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/format-implementation.h b/flang-rt/lib/flang_rt/format-implementation.h
similarity index 98%
rename from FortranRuntime/lib/Runtime/format-implementation.h
rename to flang-rt/lib/flang_rt/format-implementation.h
index f17f0a2cb4bfd9..9b7ad6f2ce1fc6 100644
--- a/FortranRuntime/lib/Runtime/format-implementation.h
+++ b/flang-rt/lib/flang_rt/format-implementation.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/format-implementation.h ---------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_FORMAT_IMPLEMENTATION_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_FORMAT_IMPLEMENTATION_H_ */
diff --git a/FortranRuntime/lib/Runtime/format.cpp b/flang-rt/lib/flang_rt/format.cpp
similarity index 93%
rename from FortranRuntime/lib/Runtime/format.cpp
rename to flang-rt/lib/flang_rt/format.cpp
index 73a61f785c23b8..aedf04b8a40a1b 100644
--- a/FortranRuntime/lib/Runtime/format.cpp
+++ b/flang-rt/lib/flang_rt/format.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/format.cpp ----------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/format.h b/flang-rt/lib/flang_rt/format.h
similarity index 97%
rename from FortranRuntime/lib/Runtime/format.h
rename to flang-rt/lib/flang_rt/format.h
index 098a251a04d568..b41eec9564baaa 100644
--- a/FortranRuntime/lib/Runtime/format.h
+++ b/flang-rt/lib/flang_rt/format.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/format.h ------------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_FORMAT_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_FORMAT_H_ */
diff --git a/FortranRuntime/lib/Runtime/inquiry.cpp b/flang-rt/lib/flang_rt/inquiry.cpp
similarity index 96%
rename from FortranRuntime/lib/Runtime/inquiry.cpp
rename to flang-rt/lib/flang_rt/inquiry.cpp
index c24492754b4f43..b29ab4ee3c6663 100644
--- a/FortranRuntime/lib/Runtime/inquiry.cpp
+++ b/flang-rt/lib/flang_rt/inquiry.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/inquiry.cpp ---------------------------------*- C++ -*-===//
+//===-- 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.
@@ -10,8 +10,8 @@
// inquire about shape information of arrays -- LBOUND and SIZE.
#include "flang/Runtime/inquiry.h"
-#include "FortranRuntime/Runtime/descriptor.h"
#include "copy.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include <algorithm>
diff --git a/FortranRuntime/lib/Runtime/internal-unit.cpp b/flang-rt/lib/flang_rt/internal-unit.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/internal-unit.cpp
rename to flang-rt/lib/flang_rt/internal-unit.cpp
index 4494de9dddc1a1..7775ded1e86d57 100644
--- a/FortranRuntime/lib/Runtime/internal-unit.cpp
+++ b/flang-rt/lib/flang_rt/internal-unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/internal-unit.cpp ---------------------------*- C++ -*-===//
+//===-- 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.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "internal-unit.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "io-error.h"
#include "flang/Runtime/freestanding-tools.h"
#include <algorithm>
diff --git a/FortranRuntime/lib/Runtime/internal-unit.h b/flang-rt/lib/flang_rt/internal-unit.h
similarity index 89%
rename from FortranRuntime/lib/Runtime/internal-unit.h
rename to flang-rt/lib/flang_rt/internal-unit.h
index 7579016f14646d..2f7d0220b84b37 100644
--- a/FortranRuntime/lib/Runtime/internal-unit.h
+++ b/flang-rt/lib/flang_rt/internal-unit.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/internal-unit.h -----------------------------*- C++ -*-===//
+//===-- lib/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_INTERNAL_UNIT_H_
-#define FORTRAN_RUNTIME_INTERNAL_UNIT_H_
+#ifndef FORTRAN_FLANG_RT_INTERNAL_UNIT_H_
+#define FORTRAN_FLANG_RT_INTERNAL_UNIT_H_
-#include "FortranRuntime/Runtime/descriptor.h"
#include "connection.h"
+#include "flang-rt/flang_rt/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_INTERNAL_UNIT_H_ */
+#endif /* FORTRAN_FLANG_RT_INTERNAL_UNIT_H_ */
diff --git a/FortranRuntime/lib/Runtime/io-api-common.h b/flang-rt/lib/flang_rt/io-api-common.h
similarity index 92%
rename from FortranRuntime/lib/Runtime/io-api-common.h
rename to flang-rt/lib/flang_rt/io-api-common.h
index fed1d11d6ce6a6..5ff1b57c73cda6 100644
--- a/FortranRuntime/lib/Runtime/io-api-common.h
+++ b/flang-rt/lib/flang_rt/io-api-common.h
@@ -1,4 +1,4 @@
-//===-- lib/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,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_IO_API_COMMON_H_
-#define FORTRAN_RUNTIME_IO_API_COMMON_H_
+#ifndef FORTRAN_FLANG_RT_IO_API_COMMON_H_
+#define FORTRAN_FLANG_RT_IO_API_COMMON_H_
-#include "FortranRuntime/Runtime/io-api-funcs.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
#include "io-stmt.h"
#include "terminator.h"
#include "unit.h"
@@ -94,4 +94,4 @@ RT_API_ATTRS Cookie BeginExternalListIO(
}
} // namespace Fortran::runtime::io
-#endif /* FORTRAN_RUNTIME_IO_API_COMMON_H_ */
+#endif /* FORTRAN_FLANG_RT_IO_API_COMMON_H_ */
diff --git a/FortranRuntime/lib/Runtime/io-api-minimal.cpp b/flang-rt/lib/flang_rt/io-api-minimal.cpp
similarity index 97%
rename from FortranRuntime/lib/Runtime/io-api-minimal.cpp
rename to flang-rt/lib/flang_rt/io-api-minimal.cpp
index 8cde2333804572..92524430650126 100644
--- a/FortranRuntime/lib/Runtime/io-api-minimal.cpp
+++ b/flang-rt/lib/flang_rt/io-api-minimal.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/io-api-minimal.cpp --------------------------*- C++ -*-===//
+//===-- 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.
@@ -9,8 +9,8 @@
// Implements the subset of the I/O statement API needed for basic
// list-directed output (PRINT *) of intrinsic types.
-#include "FortranRuntime/Runtime/io-api-funcs.h"
#include "edit-output.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
#include "format.h"
#include "io-api-common.h"
#include "io-stmt.h"
diff --git a/FortranRuntime/lib/Runtime/io-api.cpp b/flang-rt/lib/flang_rt/io-api.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/io-api.cpp
rename to flang-rt/lib/flang_rt/io-api.cpp
index fa95d68a004b51..0de1e24f71dac5 100644
--- a/FortranRuntime/lib/Runtime/io-api.cpp
+++ b/flang-rt/lib/flang_rt/io-api.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/io-api.cpp ----------------------------------*- C++ -*-===//
+//===-- 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.
@@ -13,13 +13,13 @@
// OutputReal{32,64}, OutputComplex{32,64}, OutputAscii, & EndIoStatement()
// are in runtime/io-api-minimal.cpp.
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/io-api-funcs.h"
-#include "FortranRuntime/Runtime/memory.h"
#include "descriptor-io.h"
#include "edit-input.h"
#include "edit-output.h"
#include "environment.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
+#include "flang-rt/flang_rt/memory.h"
#include "format.h"
#include "io-api-common.h"
#include "io-stmt.h"
diff --git a/FortranRuntime/lib/Runtime/io-error.cpp b/flang-rt/lib/flang_rt/io-error.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/io-error.cpp
rename to flang-rt/lib/flang_rt/io-error.cpp
index 053667462058de..215c839d98cc35 100644
--- a/FortranRuntime/lib/Runtime/io-error.cpp
+++ b/flang-rt/lib/flang_rt/io-error.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/io-error.cpp --------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/io-error.h b/flang-rt/lib/flang_rt/io-error.h
similarity index 90%
rename from FortranRuntime/lib/Runtime/io-error.h
rename to flang-rt/lib/flang_rt/io-error.h
index e2018cc2ea0ab1..7798d0830a1323 100644
--- a/FortranRuntime/lib/Runtime/io-error.h
+++ b/flang-rt/lib/flang_rt/io-error.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/io-error.h ----------------------------------*- C++ -*-===//
+//===-- lib/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,11 +12,11 @@
// 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 FORTRAN_FLANG_RT_IO_ERROR_H_
+#define FORTRAN_FLANG_RT_IO_ERROR_H_
-#include "FortranRuntime/Runtime/iostat-funcs.h"
-#include "FortranRuntime/Runtime/memory.h"
+#include "flang-rt/flang_rt/iostat-funcs.h"
+#include "flang-rt/flang_rt/memory.h"
#include "terminator.h"
#include <cinttypes>
@@ -78,4 +78,4 @@ class IoErrorHandler : public Terminator {
};
} // namespace Fortran::runtime::io
-#endif /* FORTRAN_RUNTIME_IO_ERROR_H_ */
+#endif /* FORTRAN_FLANG_RT_IO_ERROR_H_ */
diff --git a/FortranRuntime/lib/Runtime/io-stmt.cpp b/flang-rt/lib/flang_rt/io-stmt.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/io-stmt.cpp
rename to flang-rt/lib/flang_rt/io-stmt.cpp
index fe02e221671665..7c243a8c934a7a 100644
--- a/FortranRuntime/lib/Runtime/io-stmt.cpp
+++ b/flang-rt/lib/flang_rt/io-stmt.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/io-stmt.cpp ---------------------------------*- C++ -*-===//
+//===-- 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.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "io-stmt.h"
-#include "FortranRuntime/Runtime/memory.h"
#include "connection.h"
#include "emit-encoded.h"
+#include "flang-rt/flang_rt/memory.h"
#include "format.h"
#include "tools.h"
#include "unit.h"
diff --git a/FortranRuntime/lib/Runtime/io-stmt.h b/flang-rt/lib/flang_rt/io-stmt.h
similarity index 99%
rename from FortranRuntime/lib/Runtime/io-stmt.h
rename to flang-rt/lib/flang_rt/io-stmt.h
index 21746ff1966218..78bc42502be687 100644
--- a/FortranRuntime/lib/Runtime/io-stmt.h
+++ b/flang-rt/lib/flang_rt/io-stmt.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/io-stmt.h -----------------------------------*- C++ -*-===//
+//===-- lib/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,13 +8,13 @@
// Representations of the state of an I/O statement in progress
-#ifndef FORTRAN_RUNTIME_IO_STMT_H_
-#define FORTRAN_RUNTIME_IO_STMT_H_
+#ifndef FORTRAN_FLANG_RT_IO_STMT_H_
+#define FORTRAN_FLANG_RT_IO_STMT_H_
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/io-api-funcs.h"
#include "connection.h"
#include "file.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
#include "format.h"
#include "internal-unit.h"
#include "io-error.h"
@@ -789,4 +789,4 @@ class ErroneousIoStatementState : public IoStatementBase {
};
} // namespace Fortran::runtime::io
-#endif /* FORTRAN_RUNTIME_IO_STMT_H_ */
+#endif /* FORTRAN_FLANG_RT_IO_STMT_H_ */
diff --git a/FortranRuntime/lib/Runtime/iostat.cpp b/flang-rt/lib/flang_rt/iostat.cpp
similarity index 97%
rename from FortranRuntime/lib/Runtime/iostat.cpp
rename to flang-rt/lib/flang_rt/iostat.cpp
index 8d769a09252fd6..39f4474dcf7229 100644
--- a/FortranRuntime/lib/Runtime/iostat.cpp
+++ b/flang-rt/lib/flang_rt/iostat.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/iostat.cpp ----------------------------------*- C++ -*-===//
+//===-- 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.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/iostat-funcs.h"
+#include "flang-rt/flang_rt/iostat-funcs.h"
namespace Fortran::runtime::io {
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/lock.h b/flang-rt/lib/flang_rt/lock.h
similarity index 94%
rename from FortranRuntime/lib/Runtime/lock.h
rename to flang-rt/lib/flang_rt/lock.h
index 69ff6403736dae..955059a711c47d 100644
--- a/FortranRuntime/lib/Runtime/lock.h
+++ b/flang-rt/lib/flang_rt/lock.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/lock.h --------------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_LOCK_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_LOCK_H_ */
diff --git a/FortranRuntime/lib/Runtime/main.cpp b/flang-rt/lib/flang_rt/main.cpp
similarity index 95%
rename from FortranRuntime/lib/Runtime/main.cpp
rename to flang-rt/lib/flang_rt/main.cpp
index 3fe985e524548d..71ed7f8319f60f 100644
--- a/FortranRuntime/lib/Runtime/main.cpp
+++ b/flang-rt/lib/flang_rt/main.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/main.cpp ------------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/matmul-transpose.cpp b/flang-rt/lib/flang_rt/matmul-transpose.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/matmul-transpose.cpp
rename to flang-rt/lib/flang_rt/matmul-transpose.cpp
index ec5388e3fca793..2c7c4a89117f04 100644
--- a/FortranRuntime/lib/Runtime/matmul-transpose.cpp
+++ b/flang-rt/lib/flang_rt/matmul-transpose.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/matmul-transpose.cpp ------------------------*- C++ -*-===//
+//===-- 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,7 +21,7 @@
// to use the faster BLAS routines.
#include "flang/Runtime/matmul-transpose.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Common/optional.h"
diff --git a/FortranRuntime/lib/Runtime/matmul.cpp b/flang-rt/lib/flang_rt/matmul.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/matmul.cpp
rename to flang-rt/lib/flang_rt/matmul.cpp
index 01be7f7c75bc45..8157911f34fd38 100644
--- a/FortranRuntime/lib/Runtime/matmul.cpp
+++ b/flang-rt/lib/flang_rt/matmul.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/matmul.cpp ----------------------------------*- C++ -*-===//
+//===-- 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,7 +20,7 @@
// Places where BLAS routines could be called are marked as TODO items.
#include "flang/Runtime/matmul.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Common/optional.h"
diff --git a/FortranRuntime/lib/Runtime/memory.cpp b/flang-rt/lib/flang_rt/memory.cpp
similarity index 92%
rename from FortranRuntime/lib/Runtime/memory.cpp
rename to flang-rt/lib/flang_rt/memory.cpp
index a4cebf7edc6c64..66aa5be0cddc60 100644
--- a/FortranRuntime/lib/Runtime/memory.cpp
+++ b/flang-rt/lib/flang_rt/memory.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/memory.cpp ----------------------------------*- C++ -*-===//
+//===-- 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,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/memory.h"
+#include "flang-rt/flang_rt/memory.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Runtime/freestanding-tools.h"
diff --git a/FortranRuntime/lib/Runtime/misc-intrinsic.cpp b/flang-rt/lib/flang_rt/misc-intrinsic.cpp
similarity index 97%
rename from FortranRuntime/lib/Runtime/misc-intrinsic.cpp
rename to flang-rt/lib/flang_rt/misc-intrinsic.cpp
index 91a3b136e009a5..00098c5b4e20b0 100644
--- a/FortranRuntime/lib/Runtime/misc-intrinsic.cpp
+++ b/flang-rt/lib/flang_rt/misc-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/misc-intrinsic.cpp --------------------------*- C++ -*-===//
+//===-- 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,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/misc-intrinsic.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Common/optional.h"
diff --git a/FortranRuntime/lib/Runtime/namelist.cpp b/flang-rt/lib/flang_rt/namelist.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/namelist.cpp
rename to flang-rt/lib/flang_rt/namelist.cpp
index 46036549bcd316..92dbd33b7f9609 100644
--- a/FortranRuntime/lib/Runtime/namelist.cpp
+++ b/flang-rt/lib/flang_rt/namelist.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/namelist.cpp --------------------------------*- C++ -*-===//
+//===-- 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.
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "namelist.h"
-#include "FortranRuntime/Runtime/io-api-funcs.h"
#include "descriptor-io.h"
#include "emit-encoded.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
#include "io-stmt.h"
#include <algorithm>
#include <cstring>
diff --git a/FortranRuntime/lib/Runtime/namelist.h b/flang-rt/lib/flang_rt/namelist.h
similarity index 91%
rename from FortranRuntime/lib/Runtime/namelist.h
rename to flang-rt/lib/flang_rt/namelist.h
index 04432f8a08cb97..519ec5dd2ddbc5 100644
--- a/FortranRuntime/lib/Runtime/namelist.h
+++ b/flang-rt/lib/flang_rt/namelist.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/namelist.h ----------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_NAMELIST_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_NAMELIST_H_ */
diff --git a/FortranRuntime/lib/Runtime/non-tbp-dio.cpp b/flang-rt/lib/flang_rt/non-tbp-dio.cpp
similarity index 93%
rename from FortranRuntime/lib/Runtime/non-tbp-dio.cpp
rename to flang-rt/lib/flang_rt/non-tbp-dio.cpp
index 9fa04397bc9610..3aade68cbb6d3e 100644
--- a/FortranRuntime/lib/Runtime/non-tbp-dio.cpp
+++ b/flang-rt/lib/flang_rt/non-tbp-dio.cpp
@@ -1,4 +1,4 @@
-//===-- lib/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.
diff --git a/FortranRuntime/lib/Runtime/non-tbp-dio.h b/flang-rt/lib/flang_rt/non-tbp-dio.h
similarity index 91%
rename from FortranRuntime/lib/Runtime/non-tbp-dio.h
rename to flang-rt/lib/flang_rt/non-tbp-dio.h
index 426d5a92fd37d4..dfc96603a8eb1c 100644
--- a/FortranRuntime/lib/Runtime/non-tbp-dio.h
+++ b/flang-rt/lib/flang_rt/non-tbp-dio.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/non-tbp-dio.h -------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_NON_TBP_DIO_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_NON_TBP_DIO_H_ */
diff --git a/FortranRuntime/lib/Runtime/numeric-templates.h b/flang-rt/lib/flang_rt/numeric-templates.h
similarity index 98%
rename from FortranRuntime/lib/Runtime/numeric-templates.h
rename to flang-rt/lib/flang_rt/numeric-templates.h
index 159b8b0b9579ad..0471b89f9153ad 100644
--- a/FortranRuntime/lib/Runtime/numeric-templates.h
+++ b/flang-rt/lib/flang_rt/numeric-templates.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/numeric-templates.h -------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_NUMERIC_TEMPLATES_H_
+#define FORTRAN_FLANG_RT_NUMERIC_TEMPLATES_H_
#include "terminator.h"
#include "tools.h"
@@ -465,4 +465,4 @@ template <typename T> inline RT_API_ATTRS T ErfcScaled(T arg) {
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_NUMERIC_TEMPLATES_H_ */
+#endif /* FORTRAN_FLANG_RT_NUMERIC_TEMPLATES_H_ */
diff --git a/FortranRuntime/lib/Runtime/numeric.cpp b/flang-rt/lib/flang_rt/numeric.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/numeric.cpp
rename to flang-rt/lib/flang_rt/numeric.cpp
index b0f68a7fc81d29..4c2c0394ede188 100644
--- a/FortranRuntime/lib/Runtime/numeric.cpp
+++ b/flang-rt/lib/flang_rt/numeric.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/numeric.cpp ---------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/pointer.cpp b/flang-rt/lib/flang_rt/pointer.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/pointer.cpp
rename to flang-rt/lib/flang_rt/pointer.cpp
index fba9e639fa37a8..7479cd780709fa 100644
--- a/FortranRuntime/lib/Runtime/pointer.cpp
+++ b/flang-rt/lib/flang_rt/pointer.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/pointer.cpp ---------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/product.cpp b/flang-rt/lib/flang_rt/product.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/product.cpp
rename to flang-rt/lib/flang_rt/product.cpp
index e4a6e81bd0c508..cd0c4e9440ceb3 100644
--- a/FortranRuntime/lib/Runtime/product.cpp
+++ b/flang-rt/lib/flang_rt/product.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/product.cpp ---------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/pseudo-unit.cpp b/flang-rt/lib/flang_rt/pseudo-unit.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/pseudo-unit.cpp
rename to flang-rt/lib/flang_rt/pseudo-unit.cpp
index 62c6b1df5071c7..9ce39ca9307c9c 100644
--- a/FortranRuntime/lib/Runtime/pseudo-unit.cpp
+++ b/flang-rt/lib/flang_rt/pseudo-unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/pseudo-unit.cpp -----------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/ragged.cpp b/flang-rt/lib/flang_rt/ragged.cpp
similarity index 97%
rename from FortranRuntime/lib/Runtime/ragged.cpp
rename to flang-rt/lib/flang_rt/ragged.cpp
index 681a800e29dca7..df6469e9c5ba27 100644
--- a/FortranRuntime/lib/Runtime/ragged.cpp
+++ b/flang-rt/lib/flang_rt/ragged.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/ragged.cpp ----------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/random-templates.h b/flang-rt/lib/flang_rt/random-templates.h
similarity index 91%
rename from FortranRuntime/lib/Runtime/random-templates.h
rename to flang-rt/lib/flang_rt/random-templates.h
index 9faa9c7cfa7002..475c972a823226 100644
--- a/FortranRuntime/lib/Runtime/random-templates.h
+++ b/flang-rt/lib/flang_rt/random-templates.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/random-templates.h --------------------------*- C++ -*-===//
+//===-- lib/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,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
-#define FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_
+#ifndef FORTRAN_FLANG_RT_RANDOM_TEMPLATES_H_
+#define FORTRAN_FLANG_RT_RANDOM_TEMPLATES_H_
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "lock.h"
#include "numeric-templates.h"
#include "flang/Common/optional.h"
@@ -85,4 +85,4 @@ inline void Generate(const Descriptor &harvest) {
} // namespace Fortran::runtime::random
-#endif /* FORTRAN_RUNTIME_RANDOM_TEMPLATES_H_ */
+#endif /* FORTRAN_FLANG_RT_RANDOM_TEMPLATES_H_ */
diff --git a/FortranRuntime/lib/Runtime/random.cpp b/flang-rt/lib/flang_rt/random.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/random.cpp
rename to flang-rt/lib/flang_rt/random.cpp
index 911b59b508eb4f..9922ae87b084a8 100644
--- a/FortranRuntime/lib/Runtime/random.cpp
+++ b/flang-rt/lib/flang_rt/random.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/random.cpp ----------------------------------*- C++ -*-===//
+//===-- 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,7 +10,7 @@
// RANDOM_SEED.
#include "flang/Runtime/random.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "lock.h"
#include "random-templates.h"
#include "terminator.h"
diff --git a/FortranRuntime/lib/Runtime/reduce.cpp b/flang-rt/lib/flang_rt/reduce.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/reduce.cpp
rename to flang-rt/lib/flang_rt/reduce.cpp
index a020ffef6fe6a5..6997d4c63065b9 100644
--- a/FortranRuntime/lib/Runtime/reduce.cpp
+++ b/flang-rt/lib/flang_rt/reduce.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/reduce.cpp ----------------------------------*- C++ -*-===//
+//===-- 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,7 +9,7 @@
// REDUCE() implementation
#include "flang/Runtime/reduce.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "reduction-templates.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/reduction-templates.h b/flang-rt/lib/flang_rt/reduction-templates.h
similarity index 98%
rename from FortranRuntime/lib/Runtime/reduction-templates.h
rename to flang-rt/lib/flang_rt/reduction-templates.h
index 714584ec613ba3..774b6f3c99850f 100644
--- a/FortranRuntime/lib/Runtime/reduction-templates.h
+++ b/flang-rt/lib/flang_rt/reduction-templates.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/reduction-templates.h -----------------------*- C++ -*-===//
+//===-- lib/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,10 +18,10 @@
// * 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 FORTRAN_FLANG_RT_REDUCTION_TEMPLATES_H_
+#define FORTRAN_FLANG_RT_REDUCTION_TEMPLATES_H_
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "numeric-templates.h"
#include "terminator.h"
#include "tools.h"
@@ -412,4 +412,4 @@ template <int KIND> struct Norm2Helper {
};
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_REDUCTION_TEMPLATES_H_ */
+#endif /* FORTRAN_FLANG_RT_REDUCTION_TEMPLATES_H_ */
diff --git a/FortranRuntime/lib/Runtime/reduction.cpp b/flang-rt/lib/flang_rt/reduction.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/reduction.cpp
rename to flang-rt/lib/flang_rt/reduction.cpp
index 21930fee07ead7..f9d5f442e8928f 100644
--- a/FortranRuntime/lib/Runtime/reduction.cpp
+++ b/flang-rt/lib/flang_rt/reduction.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/reduction.cpp -------------------------------*- C++ -*-===//
+//===-- 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,7 +14,7 @@
// NORM2, MAXLOC, MINLOC, MAXVAL, and MINVAL are in extrema.cpp.
#include "flang/Runtime/reduction.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "reduction-templates.h"
#include <cinttypes>
diff --git a/FortranRuntime/lib/Runtime/stack.h b/flang-rt/lib/flang_rt/stack.h
similarity index 94%
rename from FortranRuntime/lib/Runtime/stack.h
rename to flang-rt/lib/flang_rt/stack.h
index 36e2d0a103a887..4c1ab4e85ed71f 100644
--- a/FortranRuntime/lib/Runtime/stack.h
+++ b/flang-rt/lib/flang_rt/stack.h
@@ -1,4 +1,4 @@
-//===-- lib/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,10 +10,10 @@
// 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 FORTRAN_FLANG_RT_STACK_H_
+#define FORTRAN_FLANG_RT_STACK_H_
-#include "FortranRuntime/Runtime/memory.h"
+#include "flang-rt/flang_rt/memory.h"
#include "terminator.h"
namespace Fortran::runtime {
@@ -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 /* FORTRAN_FLANG_RT_STACK_H_ */
diff --git a/FortranRuntime/lib/Runtime/stat.cpp b/flang-rt/lib/flang_rt/stat.cpp
similarity index 96%
rename from FortranRuntime/lib/Runtime/stat.cpp
rename to flang-rt/lib/flang_rt/stat.cpp
index 1af6c43102518b..77eefe3d1ac518 100644
--- a/FortranRuntime/lib/Runtime/stat.cpp
+++ b/flang-rt/lib/flang_rt/stat.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/stat.cpp ------------------------------------*- C++ -*-===//
+//===-- 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.
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "stat.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
diff --git a/FortranRuntime/lib/Runtime/stat.h b/flang-rt/lib/flang_rt/stat.h
similarity index 93%
rename from FortranRuntime/lib/Runtime/stat.h
rename to flang-rt/lib/flang_rt/stat.h
index eccd69024d726b..dbab381001d7d8 100644
--- a/FortranRuntime/lib/Runtime/stat.h
+++ b/flang-rt/lib/flang_rt/stat.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/stat.h --------------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_STAT_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_STAT_H_ */
diff --git a/FortranRuntime/lib/Runtime/stop.cpp b/flang-rt/lib/flang_rt/stop.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/stop.cpp
rename to flang-rt/lib/flang_rt/stop.cpp
index 8465a53168e551..ea50d1ba4747ff 100644
--- a/FortranRuntime/lib/Runtime/stop.cpp
+++ b/flang-rt/lib/flang_rt/stop.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/stop.cpp ------------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/sum.cpp b/flang-rt/lib/flang_rt/sum.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/sum.cpp
rename to flang-rt/lib/flang_rt/sum.cpp
index 64982b9fd53690..3c225efe8a2788 100644
--- a/FortranRuntime/lib/Runtime/sum.cpp
+++ b/flang-rt/lib/flang_rt/sum.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/sum.cpp -------------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/support.cpp b/flang-rt/lib/flang_rt/support.cpp
similarity index 93%
rename from FortranRuntime/lib/Runtime/support.cpp
rename to flang-rt/lib/flang_rt/support.cpp
index 798d502ba248e2..436ae6f87ae692 100644
--- a/FortranRuntime/lib/Runtime/support.cpp
+++ b/flang-rt/lib/flang_rt/support.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/support.cpp ---------------------------------*- C++ -*-===//
+//===-- 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.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/support.h"
-#include "FortranRuntime/Runtime/descriptor.h"
#include "ISO_Fortran_util.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "type-info.h"
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/temporary-stack.cpp b/flang-rt/lib/flang_rt/temporary-stack.cpp
similarity index 97%
rename from FortranRuntime/lib/Runtime/temporary-stack.cpp
rename to flang-rt/lib/flang_rt/temporary-stack.cpp
index d8ff08e51cc211..f566e6d8a086ff 100644
--- a/FortranRuntime/lib/Runtime/temporary-stack.cpp
+++ b/flang-rt/lib/flang_rt/temporary-stack.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/temporary-stack.cpp -------------------------*- C++ -*-===//
+//===-- 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,8 +10,8 @@
// temporaries. For use in HLFIR lowering.
#include "flang/Runtime/temporary-stack.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/memory.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/memory.h"
#include "terminator.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/assign.h"
diff --git a/FortranRuntime/lib/Runtime/terminator.cpp b/flang-rt/lib/flang_rt/terminator.cpp
similarity index 97%
rename from FortranRuntime/lib/Runtime/terminator.cpp
rename to flang-rt/lib/flang_rt/terminator.cpp
index 4146e28235511f..2e8d895a9025a6 100644
--- a/FortranRuntime/lib/Runtime/terminator.cpp
+++ b/flang-rt/lib/flang_rt/terminator.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/terminator.cpp ------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/terminator.h b/flang-rt/lib/flang_rt/terminator.h
similarity index 95%
rename from FortranRuntime/lib/Runtime/terminator.h
rename to flang-rt/lib/flang_rt/terminator.h
index f475658b0eab3d..61c6452a282d12 100644
--- a/FortranRuntime/lib/Runtime/terminator.h
+++ b/flang-rt/lib/flang_rt/terminator.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/terminator.h --------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_TERMINATOR_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_TERMINATOR_H_ */
diff --git a/FortranRuntime/lib/Runtime/time-intrinsic.cpp b/flang-rt/lib/flang_rt/time-intrinsic.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/time-intrinsic.cpp
rename to flang-rt/lib/flang_rt/time-intrinsic.cpp
index 15c42077c0afd5..6e2befbc30e9fa 100644
--- a/FortranRuntime/lib/Runtime/time-intrinsic.cpp
+++ b/flang-rt/lib/flang_rt/time-intrinsic.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/time-intrinsic.cpp --------------------------*- C++ -*-===//
+//===-- 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,7 +9,7 @@
// Implements time-related intrinsic subroutines.
#include "flang/Runtime/time-intrinsic.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Runtime/cpp-type.h"
@@ -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/FortranRuntime/lib/Runtime/tools.cpp b/flang-rt/lib/flang_rt/tools.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/tools.cpp
rename to flang-rt/lib/flang_rt/tools.cpp
index d5c113a31fc501..228b781b207ddd 100644
--- a/FortranRuntime/lib/Runtime/tools.cpp
+++ b/flang-rt/lib/flang_rt/tools.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/tools.cpp -----------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/tools.h b/flang-rt/lib/flang_rt/tools.h
similarity index 98%
rename from FortranRuntime/lib/Runtime/tools.h
rename to flang-rt/lib/flang_rt/tools.h
index 332ffac77f2595..9880d0e93f5a82 100644
--- a/FortranRuntime/lib/Runtime/tools.h
+++ b/flang-rt/lib/flang_rt/tools.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/tools.h -------------------------------------*- C++ -*-===//
+//===-- lib/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,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_TOOLS_H_
-#define FORTRAN_RUNTIME_TOOLS_H_
+#ifndef FORTRAN_FLANG_RT_TOOLS_H_
+#define FORTRAN_FLANG_RT_TOOLS_H_
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/memory.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/memory.h"
#include "stat.h"
#include "terminator.h"
#include "flang/Common/optional.h"
@@ -535,4 +535,4 @@ RT_API_ATTRS void CreatePartialReductionResult(Descriptor &result,
const char *intrinsic, TypeCode);
} // namespace Fortran::runtime
-#endif /* FORTRAN_RUNTIME_TOOLS_H_ */
+#endif /* FORTRAN_FLANG_RT_TOOLS_H_ */
diff --git a/FortranRuntime/lib/Runtime/transformational.cpp b/flang-rt/lib/flang_rt/transformational.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/transformational.cpp
rename to flang-rt/lib/flang_rt/transformational.cpp
index 28dd02a28036de..f21c63fbfd7a1b 100644
--- a/FortranRuntime/lib/Runtime/transformational.cpp
+++ b/flang-rt/lib/flang_rt/transformational.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/transformational.cpp ------------------------*- C++ -*-===//
+//===-- 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.
@@ -17,8 +17,8 @@
// of the standard but it more likely to conform with its intent.
#include "flang/Runtime/transformational.h"
-#include "FortranRuntime/Runtime/descriptor.h"
#include "copy.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Common/float128.h"
diff --git a/FortranRuntime/lib/Runtime/type-code.cpp b/flang-rt/lib/flang_rt/type-code.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/type-code.cpp
rename to flang-rt/lib/flang_rt/type-code.cpp
index 16f5497bc7a709..96fabf7ec7698f 100644
--- a/FortranRuntime/lib/Runtime/type-code.cpp
+++ b/flang-rt/lib/flang_rt/type-code.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/type-code.cpp -------------------------------*- C++ -*-===//
+//===-- 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 "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/type-code.h"
#include <cstdint>
namespace Fortran::runtime {
diff --git a/FortranRuntime/lib/Runtime/type-info.cpp b/flang-rt/lib/flang_rt/type-info.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/type-info.cpp
rename to flang-rt/lib/flang_rt/type-info.cpp
index 19e9211fc063f4..031721833ddebc 100644
--- a/FortranRuntime/lib/Runtime/type-info.cpp
+++ b/flang-rt/lib/flang_rt/type-info.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/type-info.cpp -------------------------------*- C++ -*-===//
+//===-- 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.
diff --git a/FortranRuntime/lib/Runtime/type-info.h b/flang-rt/lib/flang_rt/type-info.h
similarity index 98%
rename from FortranRuntime/lib/Runtime/type-info.h
rename to flang-rt/lib/flang_rt/type-info.h
index 150942547c2ee8..3b0b193d63379c 100644
--- a/FortranRuntime/lib/Runtime/type-info.h
+++ b/flang-rt/lib/flang_rt/type-info.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/type-info.h ---------------------------------*- C++ -*-===//
+//===-- lib/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,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FORTRAN_RUNTIME_TYPE_INFO_H_
-#define FORTRAN_RUNTIME_TYPE_INFO_H_
+#ifndef FORTRAN_FLANG_RT_TYPE_INFO_H_
+#define FORTRAN_FLANG_RT_TYPE_INFO_H_
// A C++ perspective of the derived type description schemata in
// flang/module/__fortran_type_info.f90.
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "terminator.h"
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/bit-population-count.h"
@@ -321,4 +321,4 @@ class DerivedType {
};
} // namespace Fortran::runtime::typeInfo
-#endif /* FORTRAN_RUNTIME_TYPE_INFO_H_ */
+#endif /* FORTRAN_FLANG_RT_TYPE_INFO_H_ */
diff --git a/FortranRuntime/lib/Runtime/unit-map.cpp b/flang-rt/lib/flang_rt/unit-map.cpp
similarity index 98%
rename from FortranRuntime/lib/Runtime/unit-map.cpp
rename to flang-rt/lib/flang_rt/unit-map.cpp
index 93958be8df7ea5..0fda53ac071b27 100644
--- a/FortranRuntime/lib/Runtime/unit-map.cpp
+++ b/flang-rt/lib/flang_rt/unit-map.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/unit-map.cpp --------------------------------*- C++ -*-===//
+//===-- 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/FortranRuntime/lib/Runtime/unit-map.h b/flang-rt/lib/flang_rt/unit-map.h
similarity index 93%
rename from FortranRuntime/lib/Runtime/unit-map.h
rename to flang-rt/lib/flang_rt/unit-map.h
index f37e2df7f3b15a..7215a5677f006b 100644
--- a/FortranRuntime/lib/Runtime/unit-map.h
+++ b/flang-rt/lib/flang_rt/unit-map.h
@@ -1,4 +1,4 @@
-//===-- lib/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,10 +9,10 @@
// 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 FORTRAN_FLANG_RT_UNIT_MAP_H_
+#define FORTRAN_FLANG_RT_UNIT_MAP_H_
-#include "FortranRuntime/Runtime/memory.h"
+#include "flang-rt/flang_rt/memory.h"
#include "lock.h"
#include "unit.h"
#include "flang/Common/fast-int-set.h"
@@ -100,4 +100,4 @@ class UnitMap {
int emergencyNewUnit_{maxNewUnits_}; // not recycled
};
} // namespace Fortran::runtime::io
-#endif /* FORTRAN_RUNTIME_UNIT_MAP_H_ */
+#endif /* FORTRAN_FLANG_RT_UNIT_MAP_H_ */
diff --git a/FortranRuntime/lib/Runtime/unit.cpp b/flang-rt/lib/flang_rt/unit.cpp
similarity index 99%
rename from FortranRuntime/lib/Runtime/unit.cpp
rename to flang-rt/lib/flang_rt/unit.cpp
index 496679ee8ce5f4..b5a4282faf22e5 100644
--- a/FortranRuntime/lib/Runtime/unit.cpp
+++ b/flang-rt/lib/flang_rt/unit.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/unit.cpp ------------------------------------*- C++ -*-===//
+//===-- 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.
@@ -19,13 +19,13 @@
namespace Fortran::runtime::io {
-#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FLANGRT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS ExternalFileUnit *defaultInput{nullptr}; // unit 5
RT_VAR_ATTRS ExternalFileUnit *defaultOutput{nullptr}; // unit 6
RT_VAR_ATTRS ExternalFileUnit *errorOutput{nullptr}; // unit 0 extension
RT_OFFLOAD_VAR_GROUP_END
-#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FLANGRT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/unit.h b/flang-rt/lib/flang_rt/unit.h
similarity index 98%
rename from FortranRuntime/lib/Runtime/unit.h
rename to flang-rt/lib/flang_rt/unit.h
index 4a7444aedbe5b6..077a34833734ac 100644
--- a/FortranRuntime/lib/Runtime/unit.h
+++ b/flang-rt/lib/flang_rt/unit.h
@@ -1,4 +1,4 @@
-//===-- lib/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,14 +8,14 @@
// Fortran external I/O units
-#ifndef FORTRAN_RUNTIME_UNIT_H_
-#define FORTRAN_RUNTIME_UNIT_H_
+#ifndef FORTRAN_FLANG_RT_UNIT_H_
+#define FORTRAN_FLANG_RT_UNIT_H_
-#include "FortranRuntime/Runtime/memory.h"
#include "buffer.h"
#include "connection.h"
#include "environment.h"
#include "file.h"
+#include "flang-rt/flang_rt/memory.h"
#include "format.h"
#include "io-error.h"
#include "io-stmt.h"
@@ -291,4 +291,4 @@ class ChildIo {
};
} // namespace Fortran::runtime::io
-#endif /* FORTRAN_RUNTIME_UNIT_H_ */
+#endif /* FORTRAN_FLANG_RT_UNIT_H_ */
diff --git a/FortranRuntime/lib/Runtime/utf.cpp b/flang-rt/lib/flang_rt/utf.cpp
similarity index 96%
rename from FortranRuntime/lib/Runtime/utf.cpp
rename to flang-rt/lib/flang_rt/utf.cpp
index 635451153d39a6..860db5f2367d38 100644
--- a/FortranRuntime/lib/Runtime/utf.cpp
+++ b/flang-rt/lib/flang_rt/utf.cpp
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/utf.cpp -------------------------------------*- C++ -*-===//
+//===-- 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.
@@ -10,7 +10,7 @@
namespace Fortran::runtime {
-#ifndef FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#ifndef FLANGRT_NO_GLOBAL_VAR_DEFS
// clang-format off
RT_OFFLOAD_VAR_GROUP_BEGIN
const RT_CONST_VAR_ATTRS std::uint8_t UTF8FirstByteTable[256]{
@@ -41,7 +41,7 @@ const RT_CONST_VAR_ATTRS std::uint8_t UTF8FirstByteTable[256]{
};
RT_OFFLOAD_VAR_GROUP_END
// clang-format on
-#endif // FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+#endif // FLANGRT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/FortranRuntime/lib/Runtime/utf.h b/flang-rt/lib/flang_rt/utf.h
similarity index 94%
rename from FortranRuntime/lib/Runtime/utf.h
rename to flang-rt/lib/flang_rt/utf.h
index 35c03fd4cdded5..71dc7b05a77513 100644
--- a/FortranRuntime/lib/Runtime/utf.h
+++ b/flang-rt/lib/flang_rt/utf.h
@@ -1,4 +1,4 @@
-//===-- lib/Runtime/utf.h ---------------------------------------*- C++ -*-===//
+//===-- lib/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 FORTRAN_FLANG_RT_UTF_H_
+#define FORTRAN_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 /* FORTRAN_FLANG_RT_UTF_H_ */
diff --git a/FortranRuntime/test/CMakeLists.txt b/flang-rt/test/CMakeLists.txt
similarity index 57%
rename from FortranRuntime/test/CMakeLists.txt
rename to flang-rt/test/CMakeLists.txt
index c10c487d48c410..be42717b2834f3 100644
--- a/FortranRuntime/test/CMakeLists.txt
+++ b/flang-rt/test/CMakeLists.txt
@@ -25,7 +25,7 @@ configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)
-if (TARGET FortranRuntimeUnitTests)
+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
@@ -41,29 +41,21 @@ if (TARGET FortranRuntimeUnitTests)
)
endif ()
-set(FORTRANRUNTIME_TEST_DEPENDS
- FortranRuntimeUnitTests
- FortranRuntime.static
+set(FLANGRT_TEST_DEPENDS
+ FlangRTUnitTests
+ flang_rt.unittest
)
-add_custom_target(FortranRuntime-test-depends)
-set_target_properties(FortranRuntime-test-depends PROPERTIES FOLDER "Fortran Runtime/Meta")
-add_dependencies(FortranRuntime-test-depends ${FORTRANRUNTIME_TEST_DEPENDS})
+add_custom_target(flang-rt-test-depends)
+set_target_properties(flang-rt-test-depends PROPERTIES FOLDER "Fortran Runtime/Meta")
+add_dependencies(flang-rt-test-depends ${FLANGRT_TEST_DEPENDS})
-add_lit_testsuite(check-FortranRuntime "Running the FortranRuntime regression tests"
+add_lit_testsuite(check-flang-rt "Running the flang-rt regression tests"
${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS ${FORTRANRUNTIME_TEST_DEPENDS}
+ DEPENDS ${FLANGRT_TEST_DEPENDS}
)
-set_target_properties(check-FortranRuntime PROPERTIES FOLDER "Fortran Runtime/Meta")
+set_target_properties(check-flang-rt PROPERTIES FOLDER "Fortran Runtime/Meta")
-add_lit_testsuites(FORTRANRUNTIME ${CMAKE_CURRENT_SOURCE_DIR}
- DEPENDS ${FORTRANRUNTIME_TEST_DEPENDS})
-
-# To modify the default target triple for flang tests.
-if (DEFINED FLANG_TEST_TARGET_TRIPLE)
- if (NOT DEFINED LLVM_TARGET_TRIPLE_ENV OR LLVM_TARGET_TRIPLE_ENV STREQUAL "")
- message(FATAL_ERROR "LLVM_TARGET_TRIPLE_ENV must also be defined in order "
- "to use FLANG_TEST_TARGET_TRIPLE.")
- endif()
-endif()
+add_lit_testsuites(flang-rt ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${FLANGRT_TEST_DEPENDS})
diff --git a/FortranRuntime/test/Driver/ctofortran.f90 b/flang-rt/test/Driver/ctofortran.f90
similarity index 100%
rename from FortranRuntime/test/Driver/ctofortran.f90
rename to flang-rt/test/Driver/ctofortran.f90
diff --git a/FortranRuntime/test/Driver/exec.f90 b/flang-rt/test/Driver/exec.f90
similarity index 100%
rename from FortranRuntime/test/Driver/exec.f90
rename to flang-rt/test/Driver/exec.f90
diff --git a/FortranRuntime/test/NonGtestUnit/lit.cfg.py b/flang-rt/test/NonGtestUnit/lit.cfg.py
similarity index 75%
rename from FortranRuntime/test/NonGtestUnit/lit.cfg.py
rename to flang-rt/test/NonGtestUnit/lit.cfg.py
index f807f2825a1bc7..20e28b0d3b55fd 100644
--- a/FortranRuntime/test/NonGtestUnit/lit.cfg.py
+++ b/flang-rt/test/NonGtestUnit/lit.cfg.py
@@ -5,18 +5,18 @@
import lit.formats
# name: The name of this test suite.
-config.name = "FortranRuntime-OldUnit"
+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.fortranruntime_binary_dir, "unittests")
+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.fortranruntime_binary_test_dir
+config.test_exec_root = config.flangrt_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 00000000000000..9dc4d2d5a1513f
--- /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.flangrt_source_dir = "@FLANGRT_SOURCE_DIR@"
+config.flangrt_binary_dir = "@FLANGRT_BINARY_DIR@"
+config.flangrt_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.flangrt_source_dir, 'test', 'NonGtestUnit', 'lit.cfg.py'))
diff --git a/FortranRuntime/test/Runtime/no-cpp-dep.c b/flang-rt/test/Runtime/no-cpp-dep.c
similarity index 87%
rename from FortranRuntime/test/Runtime/no-cpp-dep.c
rename to flang-rt/test/Runtime/no-cpp-dep.c
index 2cc5669a60d3a2..510816a07967ab 100644
--- a/FortranRuntime/test/Runtime/no-cpp-dep.c
+++ b/flang-rt/test/Runtime/no-cpp-dep.c
@@ -1,12 +1,12 @@
/*
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.
UNSUPPORTED: system-windows
-FIXME: This currently fails with CUDA-enabled FortranRuntime because it needs
- to link libcuda_rt.
+FIXME: This currently fails with CUDA-enabled flang-rt because it needs
+ to link libcudart.
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
RUN: %cc -std=c99 %s -I%include %libruntime -lm \
diff --git a/FortranRuntime/test/Unit/lit.cfg.py b/flang-rt/test/Unit/lit.cfg.py
similarity index 73%
rename from FortranRuntime/test/Unit/lit.cfg.py
rename to flang-rt/test/Unit/lit.cfg.py
index 888fb3981916c8..e46a78584c0425 100644
--- a/FortranRuntime/test/Unit/lit.cfg.py
+++ b/flang-rt/test/Unit/lit.cfg.py
@@ -5,17 +5,17 @@
import lit.formats
# name: The name of this test suite.
-config.name = "FortranRuntime-Unit"
+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.fortranruntime_binary_dir, "unittests")
+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.fortranruntime_binary_test_dir
+config.test_exec_root = config.flangrt_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 00000000000000..f6ed1e758d9374
--- /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.flangrt_source_dir = "@FLANGRT_SOURCE_DIR@"
+config.flangrt_binary_dir = "@FLANGRT_BINARY_DIR@"
+config.flangrt_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.flangrt_source_dir, 'test', 'Unit', 'lit.cfg.py'))
diff --git a/FortranRuntime/test/lit.cfg.py b/flang-rt/test/lit.cfg.py
similarity index 89%
rename from FortranRuntime/test/lit.cfg.py
rename to flang-rt/test/lit.cfg.py
index 1b9041111b72e8..1c3a08b3ae75b7 100644
--- a/FortranRuntime/test/lit.cfg.py
+++ b/flang-rt/test/lit.cfg.py
@@ -8,7 +8,7 @@
# Configuration file for the 'lit' test runner.
# name: The name of this test suite.
-config.name = "FortranRuntime"
+config.name = "flang-rt"
# testFormat: The test format to use to interpret tests.
#
@@ -54,7 +54,7 @@
# 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.fortranruntime_binary_test_dir
+config.test_exec_root = config.flangrt_binary_test_dir
# On MacOS, -isysroot is needed to build binaries.
isysroot_flag = []
@@ -72,7 +72,7 @@
# 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.
-libruntime = os.path.join(config.fortranruntime_build_lib_dir, "libFortranRuntime.a")
+libruntime = os.path.join(config.flangrt_build_lib_dir, "libflang_rt.a")
include = os.path.join(config.flang_source_dir, "include")
tools.append(
ToolSubst("%cc", command=config.cc, extra_args=isysroot_flag, unresolved="fatal")
@@ -80,7 +80,7 @@
tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
-# Lwt tests find LLVM's standard tools (FileCheck, split-file, not, ...)
+# Let tests find LLVM's standard tools (FileCheck, split-file, not, ...)
llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
llvm_config.add_tool_substitutions(tools)
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 00000000000000..630f7dfcd508c7
--- /dev/null
+++ b/flang-rt/test/lit.site.cfg.py.in
@@ -0,0 +1,17 @@
+ at LIT_SITE_CFG_IN_HEADER@
+
+import sys
+
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.flang_source_dir = "@FLANG_SOURCE_DIR@"
+config.flangrt_source_dir = "@FLANGRT_SOURCE_DIR@"
+config.flangrt_binary_test_dir = os.path.dirname(__file__)
+config.flangrt_build_lib_dir = "@FLANGRT_BUILD_LIB_DIR@"
+config.cc = "@CMAKE_C_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.flangrt_source_dir, 'test', 'lit.cfg.py'))
diff --git a/FortranRuntime/unittests/CMakeLists.txt b/flang-rt/unittests/CMakeLists.txt
similarity index 72%
rename from FortranRuntime/unittests/CMakeLists.txt
rename to flang-rt/unittests/CMakeLists.txt
index 592f2ef7ce42ab..d6ed84c9f72bf0 100644
--- a/FortranRuntime/unittests/CMakeLists.txt
+++ b/flang-rt/unittests/CMakeLists.txt
@@ -26,13 +26,13 @@ endif()
# Target that depends on all unittests
-add_custom_target(FortranRuntimeUnitTests)
-set_target_properties(FortranRuntimeUnitTests PROPERTIES FOLDER "Fortran Runtime/Meta")
+add_custom_target(FlangRTUnitTests)
+set_target_properties(FlangRTUnitTests PROPERTIES FOLDER "Fortran Runtime/Meta")
-function(add_fortranruntime_unittest_offload_properties target)
+function(add_flangrt_unittest_offload_properties target)
# Set CUDA_RESOLVE_DEVICE_SYMBOLS.
- if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
+ if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
set_target_properties(${target}
PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON
)
@@ -43,7 +43,7 @@ function(add_fortranruntime_unittest_offload_properties target)
#
# FIXME: replace 'native' in --offload-arch option with the list
# of targets that Fortran Runtime was built for.
- if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
+ if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
set_target_properties(${target}
PROPERTIES LINK_OPTIONS
"-fopenmp;--offload-arch=native"
@@ -52,22 +52,22 @@ function(add_fortranruntime_unittest_offload_properties target)
endfunction()
-function(add_fortranruntime_unittest test_dirname)
+function(add_flangrt_unittest test_dirname)
cmake_parse_arguments(ARG
""
""
"LINK_LIBS"
${ARGN})
- add_unittest(FortranRuntimeUnitTests ${test_dirname} ${ARG_UNPARSED_ARGUMENTS})
+ add_unittest(FlangRTUnitTests ${test_dirname} ${ARG_UNPARSED_ARGUMENTS})
- target_include_directories(${test_dirname} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+ target_include_directories(${test_dirname} PRIVATE "${FLANGRT_SOURCE_DIR}/include")
target_include_directories(${test_dirname} PRIVATE "${FLANG_SOURCE_DIR}/include")
target_link_libraries(${test_dirname} PRIVATE ${ARG_LINK_LIBS})
- add_fortranruntime_unittest_offload_properties(${test_dirname})
+ add_flangrt_unittest_offload_properties(${test_dirname})
endfunction()
-function(add_fortranruntime_nongtest_unittest test_name)
+function(add_flangrt_nongtest_unittest test_name)
cmake_parse_arguments(ARG
"SLOW_TEST"
""
@@ -83,15 +83,15 @@ function(add_fortranruntime_nongtest_unittest test_name)
add_executable(${test_name}${suffix} ${ARG_UNPARSED_ARGUMENTS})
set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Fortran Runtime/Tests/Unit")
- target_include_directories(${test_name}${suffix} PRIVATE "${FORTRANRUNTIME_SOURCE_DIR}/include")
+ target_include_directories(${test_name}${suffix} PRIVATE "${FLANGRT_SOURCE_DIR}/include")
target_include_directories(${test_name}${suffix} PRIVATE "${FLANG_SOURCE_DIR}/include")
target_link_libraries(${test_name}${suffix} PRIVATE NonGTestTesting ${ARG_LINK_LIBS})
if(NOT ARG_SLOW_TEST)
- add_dependencies(FortranRuntimeUnitTests ${test_name}${suffix})
+ add_dependencies(FlangRTUnitTests ${test_name}${suffix})
endif()
- add_fortranruntime_unittest_offload_properties(${test_name}${suffix})
+ add_flangrt_unittest_offload_properties(${test_name}${suffix})
endfunction()
add_subdirectory(Evaluate)
diff --git a/FortranRuntime/unittests/Evaluate/CMakeLists.txt b/flang-rt/unittests/Evaluate/CMakeLists.txt
similarity index 73%
rename from FortranRuntime/unittests/Evaluate/CMakeLists.txt
rename to flang-rt/unittests/Evaluate/CMakeLists.txt
index fd3a5755dd1227..dd4b729f698cf6 100644
--- a/FortranRuntime/unittests/Evaluate/CMakeLists.txt
+++ b/flang-rt/unittests/Evaluate/CMakeLists.txt
@@ -6,14 +6,14 @@
#
#===------------------------------------------------------------------------===#
-add_fortranruntime_nongtest_unittest(reshape
+add_flangrt_nongtest_unittest(reshape
reshape.cpp
LINK_LIBS
- FortranRuntime.unittest
+ flang_rt.unittest
)
-add_fortranruntime_nongtest_unittest(ISO-Fortran-binding
+add_flangrt_nongtest_unittest(ISO-Fortran-binding
ISO-Fortran-binding.cpp
LINK_LIBS
- FortranRuntime.unittest
+ flang_rt.unittest
)
diff --git a/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp b/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
similarity index 99%
rename from FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
rename to flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
index b68dfbcbd5b335..03cc59291787aa 100644
--- a/FortranRuntime/unittests/Evaluate/ISO-Fortran-binding.cpp
+++ b/flang-rt/unittests/Evaluate/ISO-Fortran-binding.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/FortranRuntime/unittests/Evaluate/reshape.cpp b/flang-rt/unittests/Evaluate/reshape.cpp
similarity index 98%
rename from FortranRuntime/unittests/Evaluate/reshape.cpp
rename to flang-rt/unittests/Evaluate/reshape.cpp
index 0233ab37e25c6e..c9ead4fe744f91 100644
--- a/FortranRuntime/unittests/Evaluate/reshape.cpp
+++ b/flang-rt/unittests/Evaluate/reshape.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "flang/Runtime/transformational.h"
#include "flang/Testing/testing.h"
#include <cinttypes>
diff --git a/FortranRuntime/unittests/Runtime/AccessTest.cpp b/flang-rt/unittests/Runtime/AccessTest.cpp
similarity index 100%
rename from FortranRuntime/unittests/Runtime/AccessTest.cpp
rename to flang-rt/unittests/Runtime/AccessTest.cpp
diff --git a/FortranRuntime/unittests/Runtime/Allocatable.cpp b/flang-rt/unittests/Runtime/Allocatable.cpp
similarity index 100%
rename from FortranRuntime/unittests/Runtime/Allocatable.cpp
rename to flang-rt/unittests/Runtime/Allocatable.cpp
diff --git a/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp b/flang-rt/unittests/Runtime/ArrayConstructor.cpp
similarity index 97%
rename from FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
rename to flang-rt/unittests/Runtime/ArrayConstructor.cpp
index 9d9a4ddae8689f..c52ce8e4ea54fd 100644
--- a/FortranRuntime/unittests/Runtime/ArrayConstructor.cpp
+++ b/flang-rt/unittests/Runtime/ArrayConstructor.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/array-constructor.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/array-constructor.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/allocatable.h"
diff --git a/FortranRuntime/unittests/Runtime/BufferTest.cpp b/flang-rt/unittests/Runtime/BufferTest.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/BufferTest.cpp
rename to flang-rt/unittests/Runtime/BufferTest.cpp
index 9a7dd86d0c1dc6..41c660e638e712 100644
--- a/FortranRuntime/unittests/Runtime/BufferTest.cpp
+++ b/flang-rt/unittests/Runtime/BufferTest.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "../../lib/Runtime/buffer.h"
+#include "../../lib/flang_rt/buffer.h"
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
#include <algorithm>
diff --git a/FortranRuntime/unittests/Runtime/CMakeLists.txt b/flang-rt/unittests/Runtime/CMakeLists.txt
similarity index 90%
rename from FortranRuntime/unittests/Runtime/CMakeLists.txt
rename to flang-rt/unittests/Runtime/CMakeLists.txt
index e4439dcc8b3c7e..ce15fe5ef74f96 100644
--- a/FortranRuntime/unittests/Runtime/CMakeLists.txt
+++ b/flang-rt/unittests/Runtime/CMakeLists.txt
@@ -6,7 +6,7 @@
#
#===------------------------------------------------------------------------===#
-add_fortranruntime_unittest(FlangRuntimeTests
+add_flangrt_unittest(RuntimeTests
AccessTest.cpp
Allocatable.cpp
ArrayConstructor.cpp
@@ -38,9 +38,9 @@ add_fortranruntime_unittest(FlangRuntimeTests
TemporaryStack.cpp
Transformational.cpp
LINK_LIBS
- FortranRuntime.unittest
+ flang_rt.unittest
)
-if (FORTRANRUNTIME_ENABLE_CUF)
+if (FLANG_RT_ENABLE_CUF)
add_subdirectory(CUDA)
endif ()
diff --git a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
similarity index 90%
rename from FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
rename to flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
index d2a2e5a11abf80..46461a863c0696 100644
--- a/FortranRuntime/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -6,16 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/CUDA/allocator.h"
-#include "FortranRuntime/Runtime/CUDA/descriptor.h"
-#include "FortranRuntime/Runtime/allocatable.h"
-#include "FortranRuntime/Runtime/allocator-registry.h"
+#include "cuda_runtime.h"
+#include "flang-rt/flang_rt/allocator-registry.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "gtest/gtest.h"
-#include "../../../runtime/terminator.h"
+#include "../../../lib/flang_rt/terminator.h"
+#include "flang-rt/CufRuntime/allocator.h"
+#include "flang/Runtime/CUDA/descriptor.h"
+#include "flang/Runtime/allocatable.h"
#include "flang/Support/Fortran.h"
-#include "cuda_runtime.h"
-
using namespace Fortran::runtime;
using namespace Fortran::runtime::cuda;
diff --git a/FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
similarity index 89%
rename from FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt
rename to flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
index 04321e65d733ad..829ae9250f345e 100644
--- a/FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt
+++ b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
@@ -6,14 +6,14 @@
#
#===------------------------------------------------------------------------===#
-add_fortranruntime_unittest(FlangCufRuntimeTests
+add_flangrt_unittest(FlangCufRuntimeTests
AllocatorCUF.cpp
)
target_link_libraries(FlangCufRuntimeTests
PRIVATE
CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
- FortranRuntime
+ flang_rt
)
target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
diff --git a/FortranRuntime/unittests/Runtime/CharacterTest.cpp b/flang-rt/unittests/Runtime/CharacterTest.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/CharacterTest.cpp
rename to flang-rt/unittests/Runtime/CharacterTest.cpp
index 610061e2122cd5..3a4b5706e53849 100644
--- a/FortranRuntime/unittests/Runtime/CharacterTest.cpp
+++ b/flang-rt/unittests/Runtime/CharacterTest.cpp
@@ -10,7 +10,7 @@
// in Fortran.
#include "flang/Runtime/character.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "gtest/gtest.h"
#include <cstring>
#include <functional>
diff --git a/FortranRuntime/unittests/Runtime/CommandTest.cpp b/flang-rt/unittests/Runtime/CommandTest.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/CommandTest.cpp
rename to flang-rt/unittests/Runtime/CommandTest.cpp
index a7d68508c5abca..15b2ed2e42bba1 100644
--- a/FortranRuntime/unittests/Runtime/CommandTest.cpp
+++ b/flang-rt/unittests/Runtime/CommandTest.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/command.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "flang/Runtime/execute.h"
diff --git a/FortranRuntime/unittests/Runtime/Complex.cpp b/flang-rt/unittests/Runtime/Complex.cpp
similarity index 100%
rename from FortranRuntime/unittests/Runtime/Complex.cpp
rename to flang-rt/unittests/Runtime/Complex.cpp
diff --git a/FortranRuntime/unittests/Runtime/CrashHandlerFixture.cpp b/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
similarity index 96%
rename from FortranRuntime/unittests/Runtime/CrashHandlerFixture.cpp
rename to flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
index 5e0b746c7e974a..3959b0d4b78809 100644
--- a/FortranRuntime/unittests/Runtime/CrashHandlerFixture.cpp
+++ b/flang-rt/unittests/Runtime/CrashHandlerFixture.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "../../lib/Runtime/terminator.h"
+#include "../../lib/flang_rt/terminator.h"
#include <cstdarg>
#include <cstdlib>
diff --git a/FortranRuntime/unittests/Runtime/CrashHandlerFixture.h b/flang-rt/unittests/Runtime/CrashHandlerFixture.h
similarity index 100%
rename from FortranRuntime/unittests/Runtime/CrashHandlerFixture.h
rename to flang-rt/unittests/Runtime/CrashHandlerFixture.h
diff --git a/FortranRuntime/unittests/Runtime/Derived.cpp b/flang-rt/unittests/Runtime/Derived.cpp
similarity index 98%
rename from FortranRuntime/unittests/Runtime/Derived.cpp
rename to flang-rt/unittests/Runtime/Derived.cpp
index 22361352fdf5d9..055174a3b5a907 100644
--- a/FortranRuntime/unittests/Runtime/Derived.cpp
+++ b/flang-rt/unittests/Runtime/Derived.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/derived-api.h"
diff --git a/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp b/flang-rt/unittests/Runtime/ExternalIOTest.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
rename to flang-rt/unittests/Runtime/ExternalIOTest.cpp
index 7ff4aa3c14bdc5..a93ee97da8f5f7 100644
--- a/FortranRuntime/unittests/Runtime/ExternalIOTest.cpp
+++ b/flang-rt/unittests/Runtime/ExternalIOTest.cpp
@@ -11,8 +11,8 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/io-api-funcs.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
#include "gtest/gtest.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
diff --git a/FortranRuntime/unittests/Runtime/Format.cpp b/flang-rt/unittests/Runtime/Format.cpp
similarity index 97%
rename from FortranRuntime/unittests/Runtime/Format.cpp
rename to flang-rt/unittests/Runtime/Format.cpp
index f1447608917f2d..3012806a8eacc1 100644
--- a/FortranRuntime/unittests/Runtime/Format.cpp
+++ b/flang-rt/unittests/Runtime/Format.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "../../lib/Runtime/connection.h"
-#include "../../lib/Runtime/format-implementation.h"
-#include "../../lib/Runtime/io-error.h"
+#include "../../lib/flang_rt/connection.h"
+#include "../../lib/flang_rt/format-implementation.h"
+#include "../../lib/flang_rt/io-error.h"
#include <optional>
#include <string>
#include <tuple>
diff --git a/FortranRuntime/unittests/Runtime/Inquiry.cpp b/flang-rt/unittests/Runtime/Inquiry.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/Inquiry.cpp
rename to flang-rt/unittests/Runtime/Inquiry.cpp
index 3e5f0037177f1c..0bda07aaef295c 100644
--- a/FortranRuntime/unittests/Runtime/Inquiry.cpp
+++ b/flang-rt/unittests/Runtime/Inquiry.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/inquiry.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "gtest/gtest.h"
#include "tools.h"
diff --git a/FortranRuntime/unittests/Runtime/ListInputTest.cpp b/flang-rt/unittests/Runtime/ListInputTest.cpp
similarity index 98%
rename from FortranRuntime/unittests/Runtime/ListInputTest.cpp
rename to flang-rt/unittests/Runtime/ListInputTest.cpp
index e0fe4dfeac3949..7e04ab834eb247 100644
--- a/FortranRuntime/unittests/Runtime/ListInputTest.cpp
+++ b/flang-rt/unittests/Runtime/ListInputTest.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/io-api-funcs.h"
-#include "../../lib/Runtime/io-error.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
+#include "../../lib/flang_rt/io-error.h"
using namespace Fortran::runtime;
using namespace Fortran::runtime::io;
diff --git a/FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp b/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
similarity index 95%
rename from FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
rename to flang-rt/unittests/Runtime/LogicalFormatTest.cpp
index 9fa0c2f4260edb..b5a9e2d317841f 100644
--- a/FortranRuntime/unittests/Runtime/LogicalFormatTest.cpp
+++ b/flang-rt/unittests/Runtime/LogicalFormatTest.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/io-api-funcs.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
#include <algorithm>
#include <array>
#include <cstring>
diff --git a/FortranRuntime/unittests/Runtime/Matmul.cpp b/flang-rt/unittests/Runtime/Matmul.cpp
similarity index 98%
rename from FortranRuntime/unittests/Runtime/Matmul.cpp
rename to flang-rt/unittests/Runtime/Matmul.cpp
index 6eb4012e785ff1..e833b3861badac 100644
--- a/FortranRuntime/unittests/Runtime/Matmul.cpp
+++ b/flang-rt/unittests/Runtime/Matmul.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/matmul.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/allocatable.h"
diff --git a/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp b/flang-rt/unittests/Runtime/MatmulTranspose.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
rename to flang-rt/unittests/Runtime/MatmulTranspose.cpp
index 199062f820c303..560f62935e35bc 100644
--- a/FortranRuntime/unittests/Runtime/MatmulTranspose.cpp
+++ b/flang-rt/unittests/Runtime/MatmulTranspose.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/allocatable.h"
diff --git a/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp b/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
similarity index 98%
rename from FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
rename to flang-rt/unittests/Runtime/MiscIntrinsic.cpp
index 1033dda9d636f7..ca3a3e4fd3b839 100644
--- a/FortranRuntime/unittests/Runtime/MiscIntrinsic.cpp
+++ b/flang-rt/unittests/Runtime/MiscIntrinsic.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/allocatable.h"
diff --git a/FortranRuntime/unittests/Runtime/Namelist.cpp b/flang-rt/unittests/Runtime/Namelist.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/Namelist.cpp
rename to flang-rt/unittests/Runtime/Namelist.cpp
index 544ab85234fd65..d30625f23bfc1c 100644
--- a/FortranRuntime/unittests/Runtime/Namelist.cpp
+++ b/flang-rt/unittests/Runtime/Namelist.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "../../lib/Runtime/namelist.h"
+#include "../../lib/flang_rt/namelist.h"
#include "CrashHandlerFixture.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/io-api-funcs.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
#include "tools.h"
#include <algorithm>
#include <cinttypes>
diff --git a/FortranRuntime/unittests/Runtime/Numeric.cpp b/flang-rt/unittests/Runtime/Numeric.cpp
similarity index 100%
rename from FortranRuntime/unittests/Runtime/Numeric.cpp
rename to flang-rt/unittests/Runtime/Numeric.cpp
diff --git a/FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp b/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
rename to flang-rt/unittests/Runtime/NumericalFormatTest.cpp
index c588c739686bed..6c11bb0d4a49d6 100644
--- a/FortranRuntime/unittests/Runtime/NumericalFormatTest.cpp
+++ b/flang-rt/unittests/Runtime/NumericalFormatTest.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/io-api-funcs.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/io-api-funcs.h"
#include <algorithm>
#include <array>
#include <cstring>
diff --git a/FortranRuntime/unittests/Runtime/Pointer.cpp b/flang-rt/unittests/Runtime/Pointer.cpp
similarity index 98%
rename from FortranRuntime/unittests/Runtime/Pointer.cpp
rename to flang-rt/unittests/Runtime/Pointer.cpp
index 733cd42232875f..c787ed9e71eee9 100644
--- a/FortranRuntime/unittests/Runtime/Pointer.cpp
+++ b/flang-rt/unittests/Runtime/Pointer.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/pointer.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "gtest/gtest.h"
#include "tools.h"
diff --git a/FortranRuntime/unittests/Runtime/Ragged.cpp b/flang-rt/unittests/Runtime/Ragged.cpp
similarity index 100%
rename from FortranRuntime/unittests/Runtime/Ragged.cpp
rename to flang-rt/unittests/Runtime/Ragged.cpp
diff --git a/FortranRuntime/unittests/Runtime/Random.cpp b/flang-rt/unittests/Runtime/Random.cpp
similarity index 95%
rename from FortranRuntime/unittests/Runtime/Random.cpp
rename to flang-rt/unittests/Runtime/Random.cpp
index 81497a682660a8..bd4fcfd5e87975 100644
--- a/FortranRuntime/unittests/Runtime/Random.cpp
+++ b/flang-rt/unittests/Runtime/Random.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/random.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "gtest/gtest.h"
#include <cmath>
diff --git a/FortranRuntime/unittests/Runtime/Reduction.cpp b/flang-rt/unittests/Runtime/Reduction.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/Reduction.cpp
rename to flang-rt/unittests/Runtime/Reduction.cpp
index a382f4b7a71770..0f3789b017c6f6 100644
--- a/FortranRuntime/unittests/Runtime/Reduction.cpp
+++ b/flang-rt/unittests/Runtime/Reduction.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/reduction.h"
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Common/float128.h"
diff --git a/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp b/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
rename to flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
index 7ce1ee796d739b..f1ea6c897d515e 100644
--- a/FortranRuntime/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/flang-rt/unittests/Runtime/RuntimeCrashTest.cpp
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
#include "tools.h"
-#include "../../lib/Runtime/terminator.h"
+#include "../../lib/flang_rt/terminator.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/transformational.h"
#include <gtest/gtest.h>
diff --git a/FortranRuntime/unittests/Runtime/Stop.cpp b/flang-rt/unittests/Runtime/Stop.cpp
similarity index 98%
rename from FortranRuntime/unittests/Runtime/Stop.cpp
rename to flang-rt/unittests/Runtime/Stop.cpp
index c12ec097068438..9aaabc2e6c6384 100644
--- a/FortranRuntime/unittests/Runtime/Stop.cpp
+++ b/flang-rt/unittests/Runtime/Stop.cpp
@@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/stop.h"
#include "CrashHandlerFixture.h"
-#include "../../lib/Runtime/environment.h"
+#include "../../lib/flang_rt/environment.h"
#include <cstdlib>
#include <gtest/gtest.h>
diff --git a/FortranRuntime/unittests/Runtime/Support.cpp b/flang-rt/unittests/Runtime/Support.cpp
similarity index 98%
rename from FortranRuntime/unittests/Runtime/Support.cpp
rename to flang-rt/unittests/Runtime/Support.cpp
index 05328e6baa411c..d37369df025f45 100644
--- a/FortranRuntime/unittests/Runtime/Support.cpp
+++ b/flang-rt/unittests/Runtime/Support.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/support.h"
-#include "FortranRuntime/Runtime/descriptor.h"
+#include "flang-rt/flang_rt/descriptor.h"
#include "gtest/gtest.h"
#include "tools.h"
diff --git a/FortranRuntime/unittests/Runtime/TemporaryStack.cpp b/flang-rt/unittests/Runtime/TemporaryStack.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/TemporaryStack.cpp
rename to flang-rt/unittests/Runtime/TemporaryStack.cpp
index b0b1041f0f09e7..8a9f2dfe6d22f1 100644
--- a/FortranRuntime/unittests/Runtime/TemporaryStack.cpp
+++ b/flang-rt/unittests/Runtime/TemporaryStack.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
diff --git a/FortranRuntime/unittests/Runtime/Time.cpp b/flang-rt/unittests/Runtime/Time.cpp
similarity index 100%
rename from FortranRuntime/unittests/Runtime/Time.cpp
rename to flang-rt/unittests/Runtime/Time.cpp
diff --git a/FortranRuntime/unittests/Runtime/Transformational.cpp b/flang-rt/unittests/Runtime/Transformational.cpp
similarity index 99%
rename from FortranRuntime/unittests/Runtime/Transformational.cpp
rename to flang-rt/unittests/Runtime/Transformational.cpp
index 6b8903750d0aec..e8981e9b122eb7 100644
--- a/FortranRuntime/unittests/Runtime/Transformational.cpp
+++ b/flang-rt/unittests/Runtime/Transformational.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/transformational.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Common/float128.h"
diff --git a/FortranRuntime/unittests/Runtime/tools.h b/flang-rt/unittests/Runtime/tools.h
similarity index 95%
rename from FortranRuntime/unittests/Runtime/tools.h
rename to flang-rt/unittests/Runtime/tools.h
index 8000d83fc0c394..7edeff7f7eb579 100644
--- a/FortranRuntime/unittests/Runtime/tools.h
+++ b/flang-rt/unittests/Runtime/tools.h
@@ -9,8 +9,8 @@
#ifndef FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
#define FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
-#include "FortranRuntime/Runtime/descriptor.h"
-#include "FortranRuntime/Runtime/type-code.h"
+#include "flang-rt/flang_rt/descriptor.h"
+#include "flang-rt/flang_rt/type-code.h"
#include "gtest/gtest.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index ac189de2386b16..34c5661c963a80 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -23,7 +23,6 @@ if (LLVM_ENABLE_EH)
endif()
set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-set(FORTRANRUNTIME_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../FortranRuntime")
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed. \
@@ -247,13 +246,11 @@ set(LLVM_BUILD_TOOLS ON)
include_directories(BEFORE
${FLANG_BINARY_DIR}/include
- ${FLANG_SOURCE_DIR}/include
- ${FORTRANRUNTIME_SOURCE_DIR}/include)
+ ${FLANG_SOURCE_DIR}/include)
# Add Flang-centric modules to cmake path.
list(INSERT CMAKE_MODULE_PATH 0
"${FLANG_SOURCE_DIR}/cmake/modules"
- "${FORTRANRUNTIME_SOURCE_DIR}/cmake/modules"
"${LLVM_COMMON_CMAKE_UTILS}/Modules"
)
include(AddFlang)
@@ -271,7 +268,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/FortranRuntime/cmake/modules/FlangCommon.cmake b/flang/cmake/modules/FlangCommon.cmake
similarity index 93%
rename from FortranRuntime/cmake/modules/FlangCommon.cmake
rename to flang/cmake/modules/FlangCommon.cmake
index d7194ad4d7ef56..1b8606843b2240 100644
--- a/FortranRuntime/cmake/modules/FlangCommon.cmake
+++ b/flang/cmake/modules/FlangCommon.cmake
@@ -1,43 +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 betwween Flang and FortranRuntime
-#
-#===------------------------------------------------------------------------===#
-
-# 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 ()
+#===-- 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/FlangDriver.md b/flang/docs/FlangDriver.md
index 98611ee338e706..5165ac6c323ac2 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -179,18 +179,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 libraries
-`FortranRuntime`. An alternative is to use Flang to link.
+In this case, one has to explicitly provide the Fortran runtime library
+`flang_ty`. 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 eb9049ad607570..9061a00c2de250 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -32,8 +32,8 @@ tool.
### Building flang in tree (bootstrap build)
Building flang in tree means building flang along with all of the projects on
-which it depends. These projects include mlir, clang, flang, openmp,
-compiler-rt, and FortranRuntime. Note that compiler-rt is only needed to access libraries that
+which it depends. These projects include mlir, clang, flang, openmp, and
+compiler-rt. Note that compiler-rt is only needed to access libraries that
support 16 bit floating point numbers. It's not needed to run the automated
tests. You can use several different C++ compilers for most of the build,
includig GNU and clang. But building compiler-rt requres using the clang
@@ -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;FortranRuntime" \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;flang_rt" \
../llvm-project/llvm
ninja
@@ -209,15 +209,15 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
- -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
+ -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++ \
../runtimes/
-make -j`nprocs` FortranRuntime
+make -j`nprocs` 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)
@@ -232,8 +232,8 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
- -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
+ -DLLVM_ENABLE_RUNTIMES=flang_rt \
+ -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
@@ -241,7 +241,7 @@ cmake \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
../runtimes/
-make -j`nprocs` FortranRuntime
+make -j`nprocs` flang_rt
```
Note that `nvcc` might limit support to certain
@@ -260,8 +260,8 @@ build config:
For example:
```bash
- -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
- -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
+ -DLLVM_ENABLE_RUNTIMES=flang_rt \
+ -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
@@ -272,8 +272,8 @@ For example:
Or:
```bash
- -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
- -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
+ -DLLVM_ENABLE_RUNTIMES=flang_rt \
+ -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
@@ -295,14 +295,14 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DLLVM_ENABLE_RUNTIMES=FortranRuntime \
- -DFORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT="OpenMP" \
+ -DLLVM_ENABLE_RUNTIMES=flang_rt \
+ -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT="OpenMP" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
- -DFORTRANRUNTIME_DEVICE_ARCHITECTURES="all" \
+ -DFLANG_RT_DEVICE_ARCHITECTURES="all" \
../runtimes/
-make -j`nprocs` FortranRuntime
+make -j`nprocs` 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 0b5103000d8e7c..215643086fb7d1 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 80ebbb5481ba50..347f470452b247 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -36,12 +36,13 @@ page](https://llvm.org/releases/).
## Build System Changes
- * The Fortran Runtime library (libFortranRuntime) has been move to a new
- top-level directory named "FortranRuntime". It now supports the
- LLVM_ENABLE_RUNTIMES mechanism to build libFortranRuntime for multiple target
- triples. libFortranRuntime.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.
+ * The Fortran Runtime library has been move to a new top-level directory
+ named "flang-rt". The library was also renamed from `libFortranRuntime.a` to
+ `libflang_rt.a`. 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/examples/ExternalHelloWorld/CMakeLists.txt b/flang/examples/ExternalHelloWorld/CMakeLists.txt
index 042d4b6238ba45..213fc462ac2b1a 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/include/flang/Common/README.md b/flang/include/flang/Common/README.md
index a722732fb76407..5203465f7f2fa9 100644
--- a/flang/include/flang/Common/README.md
+++ b/flang/include/flang/Common/README.md
@@ -1,8 +1,8 @@
-Files in this directory are used by Flang (the compiler) and FortranRuntime
+Files in this directory are used by Flang (the compiler) and flang-rt
(the runtime library for Flang-compiled programs). They must be compatible by
both. For definitions used only by Flang, consider
`flang/{lib,include/flang}/Support` instead. For definitions used only by
-FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+the runtime, consider `flang-rt/{lib,include/flang-rt}/flang_rt`.
The requirements for common code include:
@@ -23,3 +23,5 @@ The requirements for common code include:
* Global declarations may need to be annotated using definitions from
`api-attrs.h`.
+
+ * The `Runtime` component is header-only.
diff --git a/flang/include/flang/ISO_Fortran_binding.h b/flang/include/flang/ISO_Fortran_binding.h
index 89a10ce69a2ba2..b211bcd98af868 100644
--- a/flang/include/flang/ISO_Fortran_binding.h
+++ b/flang/include/flang/ISO_Fortran_binding.h
@@ -1,3 +1,11 @@
+//===-- include/flang/ISO_Fortran_binding.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
+//
+//===----------------------------------------------------------------------===//
+
/*===-- include/flang/ISO_Fortran_binding.h -----------------------*- C++ -*-===
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -7,14 +15,14 @@
* ===-----------------------------------------------------------------------===
*/
-#ifndef CFI_ISO_FORTRAN_BINDING_H_
-#define CFI_ISO_FORTRAN_BINDING_H_
+#ifndef FORTRAN_ISO_FORTRAN_BINDING_H_
+#define FORTRAN_ISO_FORTRAN_BINDING_H_
/* When this header is included into the compiler and runtime implementations,
* 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
@@ -207,4 +215,4 @@ RT_API_ATTRS int CFI_setpointer(
} // extern "C"
#endif
-#endif /* CFI_ISO_FORTRAN_BINDING_H_ */
+#endif /* FORTRAN_ISO_FORTRAN_BINDING_H_ */
diff --git a/flang/include/flang/Runtime/README.md b/flang/include/flang/Runtime/README.md
index a13a7e23162e98..5203465f7f2fa9 100644
--- a/flang/include/flang/Runtime/README.md
+++ b/flang/include/flang/Runtime/README.md
@@ -1,8 +1,8 @@
-Files in this directory are used by Flang (the compiler) and FortranRuntime
+Files in this directory are used by Flang (the compiler) and flang-rt
(the runtime library for Flang-compiled programs). They must be compatible by
both. For definitions used only by Flang, consider
`flang/{lib,include/flang}/Support` instead. For definitions used only by
-FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+the runtime, consider `flang-rt/{lib,include/flang-rt}/flang_rt`.
The requirements for common code include:
diff --git a/flang/include/flang/Testing/README.md b/flang/include/flang/Testing/README.md
index a722732fb76407..5203465f7f2fa9 100644
--- a/flang/include/flang/Testing/README.md
+++ b/flang/include/flang/Testing/README.md
@@ -1,8 +1,8 @@
-Files in this directory are used by Flang (the compiler) and FortranRuntime
+Files in this directory are used by Flang (the compiler) and flang-rt
(the runtime library for Flang-compiled programs). They must be compatible by
both. For definitions used only by Flang, consider
`flang/{lib,include/flang}/Support` instead. For definitions used only by
-FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+the runtime, consider `flang-rt/{lib,include/flang-rt}/flang_rt`.
The requirements for common code include:
@@ -23,3 +23,5 @@ The requirements for common code include:
* Global declarations may need to be annotated using definitions from
`api-attrs.h`.
+
+ * The `Runtime` component is header-only.
diff --git a/flang/lib/Common/README.md b/flang/lib/Common/README.md
index a722732fb76407..5203465f7f2fa9 100644
--- a/flang/lib/Common/README.md
+++ b/flang/lib/Common/README.md
@@ -1,8 +1,8 @@
-Files in this directory are used by Flang (the compiler) and FortranRuntime
+Files in this directory are used by Flang (the compiler) and flang-rt
(the runtime library for Flang-compiled programs). They must be compatible by
both. For definitions used only by Flang, consider
`flang/{lib,include/flang}/Support` instead. For definitions used only by
-FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+the runtime, consider `flang-rt/{lib,include/flang-rt}/flang_rt`.
The requirements for common code include:
@@ -23,3 +23,5 @@ The requirements for common code include:
* Global declarations may need to be annotated using definitions from
`api-attrs.h`.
+
+ * The `Runtime` component is header-only.
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index b98ab3e6999655..44c8fba5ee3c66 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -751,7 +751,7 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
// Generate a call to the Fortran runtime library providing
// support for 128-bit float math.
// On 'LDBL_MANT_DIG == 113' 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/lib/Optimizer/Transforms/CufOpConversion.cpp b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
index d7d321c6b9af3f..68ce3ab7045505 100644
--- a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
@@ -1,4 +1,4 @@
-//===-- CufOpConversion.cpp -----------------------------------------------===//
+//===-- lib/Optimizer/Transforms/CufOpConversion.cpp ------------*- 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/Testing/CMakeLists.txt b/flang/lib/Testing/CMakeLists.txt
deleted file mode 100644
index d5caada3fb68e8..00000000000000
--- a/flang/lib/Testing/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-#===-- 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
- "${FLANGRUNTIME_SOURCE_DIR}/lib/Testing/*.h"
-)
-
-add_fortranruntime_library(NonGTestTesting EXCLUDE_FROM_ALL LINK_TO_LLVM
- testing.cpp
- fp-testing.cpp
- ADDITIONAL_HEADERS
- ${public_headers}
-)
-
diff --git a/flang/lib/Testing/README.md b/flang/lib/Testing/README.md
index a722732fb76407..5203465f7f2fa9 100644
--- a/flang/lib/Testing/README.md
+++ b/flang/lib/Testing/README.md
@@ -1,8 +1,8 @@
-Files in this directory are used by Flang (the compiler) and FortranRuntime
+Files in this directory are used by Flang (the compiler) and flang-rt
(the runtime library for Flang-compiled programs). They must be compatible by
both. For definitions used only by Flang, consider
`flang/{lib,include/flang}/Support` instead. For definitions used only by
-FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`.
+the runtime, consider `flang-rt/{lib,include/flang-rt}/flang_rt`.
The requirements for common code include:
@@ -23,3 +23,5 @@ The requirements for common code include:
* Global declarations may need to be annotated using definitions from
`api-attrs.h`.
+
+ * The `Runtime` component is header-only.
diff --git a/FortranRuntime/lib/Runtime/iso_fortran_env_impl.f90 b/flang/module/iso_fortran_env_impl.f90
similarity index 97%
rename from FortranRuntime/lib/Runtime/iso_fortran_env_impl.f90
rename to flang/module/iso_fortran_env_impl.f90
index 1a4da69266c55b..782be81791af2e 100644
--- a/FortranRuntime/lib/Runtime/iso_fortran_env_impl.f90
+++ b/flang/module/iso_fortran_env_impl.f90
@@ -1,4 +1,4 @@
-!===-- lib/Runtime/iso_fortran_env_impl.f90 --------------------------------===!
+!===-- module/iso_fortran_env_impl.f90 --=--------------------------------===!
!
! 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 @@
! 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). Hence, this file is also used by Flang-RT.
module iso_fortran_env_impl
implicit none
diff --git a/flang/test/Driver/gcc-toolchain-install-dir.f90 b/flang/test/Driver/gcc-toolchain-install-dir.f90
index 5a073b0c517122..d9160e1971250f 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 fdeb95e4dd97c6..5dc89fe45c8cc0 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 e7fa63548fa840..5e4e6d5952efda 100644
--- a/flang/test/Driver/msvc-dependent-lib-flags.f90
+++ b/flang/test/Driver/msvc-dependent-lib-flags.f90
@@ -6,23 +6,23 @@
! MSVC: -fc1
! 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: -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: -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: -D_MT
! 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/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 401c7cc2bdef79..ada258fae8f7a2 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -54,8 +54,6 @@ if (NOT CMAKE_CROSSCOMPILING)
foreach(filename ${MODULES})
set(depends "")
set(opts "")
- set(sourcepath "${FLANG_SOURCE_DIR}/module/${filename}.f90")
- set(modpath "${FLANG_INTRINSIC_MODULES_DIR}/${filename}.mod")
if(${filename} STREQUAL "__fortran_builtins" OR
${filename} STREQUAL "__ppc_types")
elseif(${filename} STREQUAL "__ppc_intrinsics" OR
@@ -66,9 +64,6 @@ if (NOT CMAKE_CROSSCOMPILING)
set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__cuda_builtins.mod)
else()
set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
- if(${filename} STREQUAL "iso_fortran_env_impl")
- set(sourcepath "${FORTRANRUNTIME_SOURCE_DIR}/lib/Runtime/${filename}.f90")
- endif()
if(${filename} STREQUAL "iso_fortran_env")
set(depends ${depends} ${FLANG_INTRINSIC_MODULES_DIR}/iso_fortran_env_impl.mod)
endif()
@@ -97,27 +92,20 @@ if (NOT CMAKE_CROSSCOMPILING)
set(decls "-DFLANG_SUPPORT_R16")
endif()
- # Some modules have an implementation part that needs to be added to the
- # FortranRuntime library.
set(compile_with "-fsyntax-only")
set(object_output "")
set(include_in_link FALSE)
+ set(base ${FLANG_INTRINSIC_MODULES_DIR}/${filename})
# TODO: We may need to flag this with conditional, in case Flang is built w/o OpenMP support
- add_custom_command(OUTPUT ${modpath} ${object_output}
+ add_custom_command(OUTPUT ${base}.mod ${object_output}
COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
COMMAND flang-new ${opts} ${decls} -cpp ${compile_with} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
- ${sourcepath}
- DEPENDS flang-new ${sourcepath} ${FLANG_SOURCE_DIR}/module/__fortran_builtins.f90 ${depends}
+ ${FLANG_SOURCE_DIR}/module/${filename}.f90
+ DEPENDS flang-new ${FLANG_SOURCE_DIR}/module/${filename}.f90 ${FLANG_SOURCE_DIR}/module/__fortran_builtins.f90 ${depends}
)
- list(APPEND MODULE_FILES "${modpath}")
- install(FILES "${modpath}" 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.
- if(include_in_link)
- list(APPEND module_objects ${object_output})
- endif()
+ list(APPEND MODULE_FILES ${base}.mod)
+ install(FILES ${base}.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
endforeach()
# Special case for omp_lib.mod, because its source comes from openmp/runtime/src/include.
diff --git a/flang/unittests/Common/CMakeLists.txt b/flang/unittests/Common/CMakeLists.txt
index 5b3aebaf5f654a..709a02f5c789c7 100644
--- a/flang/unittests/Common/CMakeLists.txt
+++ b/flang/unittests/Common/CMakeLists.txt
@@ -6,8 +6,8 @@
#
#===------------------------------------------------------------------------===#
-add_fortranruntime_unittest(FlangCommonTests
+add_flangrt_unittest(FlangCommonTests
FastIntSetTest.cpp
LINK_LIBS
- FortranRuntime.unittest
+ flang_rt.unittest
)
diff --git a/flang/unittests/Decimal/CMakeLists.txt b/flang/unittests/Decimal/CMakeLists.txt
index 033773049680f6..aaa3210aade7e3 100644
--- a/flang/unittests/Decimal/CMakeLists.txt
+++ b/flang/unittests/Decimal/CMakeLists.txt
@@ -6,15 +6,15 @@
#
#===------------------------------------------------------------------------===#
-add_fortranruntime_nongtest_unittest(quick-sanity-test
+add_flangrt_nongtest_unittest(quick-sanity-test
quick-sanity-test.cpp
LINK_LIBS
- FortranRuntime.unittest
+ flang_rt.unittest
)
# This test is not run by default as it takes a long time to execute.
-add_fortranruntime_nongtest_unittest(thorough-test SLOW_TEST
+add_flangrt_nongtest_unittest(thorough-test SLOW_TEST
thorough-test.cpp
LINK_LIBS
- FortranRuntime.unittest
+ flang_rt.unittest
)
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index 74d1ae0615fa6a..ae51bd5fcae62e 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -50,11 +50,11 @@ AutoExporter::AutoExporter(
"libclang_rt.profile-x86_64",
"libc++",
"libc++abi",
- "libFortranRuntime",
- "libFortranRuntime.static",
- "libFortranRuntime.dynamic",
- "libFortranRuntime.static_dbg",
- "libFortranRuntime.dynamic_dbg",
+ "libflang_rt",
+ "libflang_rt.static",
+ "libflang_rt.dynamic",
+ "libflang_rtstatic_dbg",
+ "libflang_rt.dynamic_dbg",
"libunwind",
"libmsvcrt",
"libucrtbase",
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 70f6f50ee5e11a..60daeaae6613e9 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -149,7 +149,7 @@ endif()
# 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;FortranRuntime")
+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/projects/CMakeLists.txt b/llvm/projects/CMakeLists.txt
index d8808bc79f0129..f254cf10806d75 100644
--- a/llvm/projects/CMakeLists.txt
+++ b/llvm/projects/CMakeLists.txt
@@ -12,7 +12,7 @@ foreach(entry ${entries})
(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) AND
- (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/FortranRuntime))
+ (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/flang-rt))
get_filename_component(entry_name "${entry}" NAME)
add_llvm_external_project(${entry_name})
endif()
@@ -38,7 +38,7 @@ if(${LLVM_BUILD_RUNTIME})
if(NOT LLVM_BUILD_EXTERNAL_COMPILER_RT)
add_llvm_external_project(compiler-rt)
endif()
- add_llvm_external_project(FortranRuntime)
+ 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 80f1cf5d6b6ea6..79abe65b4c17d6 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -280,8 +280,8 @@ function(runtime_default_target)
${ARG_CMAKE_ARGS}
PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
LLVM_USE_LINKER
- CUDA # For runtimes that may look for the CUDA SDK (libc, offload)
- FLANG_RUNTIME # Shared between Flang and FortranRuntime
+ CUDA # For runtimes that may look for the CUDA SDK (libc, offload, flang-rt)
+ FLANG_RUNTIME # Shared between Flang and Flang-RT
${ARG_PREFIXES}
EXTRA_TARGETS ${extra_targets}
${test_targets}
@@ -573,7 +573,7 @@ if(build_runtimes)
if(LLVM_LIBC_FULL_BUILD)
list(APPEND extra_cmake_args "-DLLVM_LIBC_FULL_BUILD=ON")
endif()
- if("FortranRuntime" IN_LIST LLVM_ENABLE_RUNTIMES)
+ if("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
set(enable_fortran ENABLE_FORTRAN)
endif ()
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 2a7798fd60af42..1dc42ddc27d2d0 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -23,8 +23,8 @@ 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;FortranRuntime")
-set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc")
+set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload")
+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 cf35e503c8642f4f378f910faf51de5da75607b2 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Wed, 16 Oct 2024 12:46:47 +0200
Subject: [PATCH 20/58] Update MinGW.cpp
---
lld/COFF/MinGW.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index ae51bd5fcae62e..d5614996e490c2 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -53,7 +53,7 @@ AutoExporter::AutoExporter(
"libflang_rt",
"libflang_rt.static",
"libflang_rt.dynamic",
- "libflang_rtstatic_dbg",
+ "libflang_rt.static_dbg",
"libflang_rt.dynamic_dbg",
"libunwind",
"libmsvcrt",
>From 193d23da25f4f76a466262198e90bb02c93d4046 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 17 Oct 2024 17:25:26 +0200
Subject: [PATCH 21/58] Undo whitespace changes in common.cpp
---
flang/lib/Evaluate/common.cpp | 3 ---
1 file changed, 3 deletions(-)
diff --git a/flang/lib/Evaluate/common.cpp b/flang/lib/Evaluate/common.cpp
index ed040b0728c4db..c633bff57b1ecd 100644
--- a/flang/lib/Evaluate/common.cpp
+++ b/flang/lib/Evaluate/common.cpp
@@ -11,11 +11,8 @@
using namespace Fortran::parser::literals;
-
-
namespace Fortran::evaluate {
-
void RealFlagWarnings(
FoldingContext &context, const RealFlags &flags, const char *operation) {
if (context.languageFeatures().ShouldWarn(
>From 035afc6b79f353ea580ced166d4880b8b65bd2de Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 17 Oct 2024 21:52:53 +0200
Subject: [PATCH 22/58] use ARG_EXTRA_ARGS
---
llvm/runtimes/CMakeLists.txt | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 79abe65b4c17d6..6e2a4a10522e38 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -137,7 +137,6 @@ function(builtin_register_target compiler_rt_path name)
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
-DLLVM_CMAKE_DIR=${CMAKE_BINARY_DIR}
-DCMAKE_C_COMPILER_WORKS=ON
- -DCMAKE_Fortran_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
${COMMON_CMAKE_ARGS}
@@ -232,7 +231,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)
@@ -263,7 +262,6 @@ function(runtime_default_target)
llvm_ExternalProject_Add(runtimes
${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
DEPENDS ${ARG_DEPENDS}
- ${enable_fortran}
# Builtins were built separately above
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
@@ -291,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)
@@ -401,7 +399,6 @@ function(runtime_register_target name)
llvm_ExternalProject_Add(runtimes-${name}
${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
DEPENDS ${ARG_DEPENDS}
- ${enable_fortran}
# Builtins were built separately above
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=OFF
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
@@ -469,7 +466,7 @@ if(build_runtimes)
# together in a single CMake invocation.
set(extra_deps "")
set(extra_cmake_args "")
- set(enable_fortran "")
+ set(extra_args "")
if(LLVM_INCLUDE_TESTS)
foreach(dep FileCheck
@@ -574,21 +571,23 @@ if(build_runtimes)
list(APPEND extra_cmake_args "-DLLVM_LIBC_FULL_BUILD=ON")
endif()
if("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
- set(enable_fortran ENABLE_FORTRAN)
+ 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)
@@ -635,7 +634,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})
@@ -646,7 +645,7 @@ if(build_runtimes)
-DLLVM_RUNTIMES_PREFIX=${name}/
-DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
BASE_NAME ${name}
- EXTRA_ARGS TARGET_TRIPLE ${name})
+ EXTRA_ARGS TARGET_TRIPLE ${name} ${extra_args})
endforeach()
endforeach()
endif()
>From 08c1be224e69e1d3113984fb7cca5503d65f5d25 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 17 Oct 2024 22:55:26 +0200
Subject: [PATCH 23/58] Re-insert flang-rt dependency check
---
llvm/CMakeLists.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 60daeaae6613e9..71ce7593b6f395 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -144,6 +144,12 @@ if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
endif()
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
>From 2f36f41cd1de57c1ba30ef33b866963e3853c286 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 21 Oct 2024 18:02:37 +0200
Subject: [PATCH 24/58] Fix GTest include search path with other runtimes
---
flang-rt/CMakeLists.txt | 2 +-
flang-rt/cmake/modules/AddFlangRT.cmake | 4 ++--
flang-rt/unittests/CMakeLists.txt | 7 +++++--
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index bd83a51482f4af..2114792d7cc998 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -43,7 +43,7 @@ if (LLVM_TREE_AVAILABLE)
# flang-new uses the same resource dir as clang.
include(GetClangResourceDir)
get_clang_resource_dir(FLANGRT_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
- get_clang_resource_dir(FLANGRT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the install prefix itself
+ get_clang_resource_dir(FLANGRT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the install prefix itself
else ()
set(FLANGRT_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
set(FLANGRT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index 797eeddae32142..244aada5092887 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -102,8 +102,8 @@ function (add_flangrt_library name)
else()
llvm_map_components_to_libnames(llvm_libs Support)
endif()
- target_link_libraries(${name} PUBLIC ${llvm_libs})
- target_include_directories(${name} PRIVATE ${LLVM_INCLUDE_DIRS})
+ target_link_libraries(${name} PUBLIC ${llvm_libs})
+ target_include_directories(${name} PUBLIC ${LLVM_INCLUDE_DIRS})
endif ()
# If this is part of the toolchain, put it into the compiler's resource
diff --git a/flang-rt/unittests/CMakeLists.txt b/flang-rt/unittests/CMakeLists.txt
index d6ed84c9f72bf0..43dc2b5a4ac48b 100644
--- a/flang-rt/unittests/CMakeLists.txt
+++ b/flang-rt/unittests/CMakeLists.txt
@@ -7,9 +7,8 @@
#===------------------------------------------------------------------------===#
# Add GTest if not already present.
-# Using a function so include_directories/LLVM_SUBPROJECT_TITLE does not propagate
+# Using a function so LLVM_SUBPROJECT_TITLE does not propagate.
function (build_gtest)
- include_directories("${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}")
set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
add_subdirectory("${LLVM_THIRD_PARTY_DIR}/unittest" "${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest")
endfunction ()
@@ -17,6 +16,10 @@ if (NOT TARGET llvm_gtest)
build_gtest()
endif ()
+# LLVM's modified GTest depends on LLVM, but not all runtime projects using
+# GTest also add the include search path.
+target_include_directories(llvm_gtest PUBLIC "${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}")
+
# Required because LLVMSupport is compiled with this option (by default).
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
>From 3cf5f3fc31b024370fd8ddbb994362742e35d2a0 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 21 Oct 2024 20:04:57 +0200
Subject: [PATCH 25/58] Avoid global add_definitions
---
flang-rt/CMakeLists.txt | 4 ----
flang-rt/cmake/modules/AddFlangRT.cmake | 7 +++++++
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 2114792d7cc998..942bc7274e42ee 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -143,10 +143,6 @@ endif()
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
-# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
-# to avoid an unwanted dependency on libstdc++/libc++.so.
-add_definitions(-U_GLIBCXX_ASSERTIONS)
-add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
configure_file(cmake/config.h.cmake.in config.h)
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index 244aada5092887..ae867f3fe4e8eb 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -86,6 +86,13 @@ function (add_flangrt_library name)
# For flang-rt's configured config.h to be found
target_include_directories(${name} PRIVATE "${FLANGRT_BINARY_DIR}")
+ # Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS
+ # build, to avoid an unwanted dependency on libstdc++/libc++.so.
+ if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
+ 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 msv(u)crt. LLVM still emits libgcc/compiler-rt
# functions for 128-bit integer math (__udivti3, __modti3, __fixsfti,
>From 94725384ae691275abbb65e4f667a1f267a09b96 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 22 Oct 2024 11:34:11 +0200
Subject: [PATCH 26/58] Fix FortranFloat128Math include path
---
flang-rt/README.md | 5 +++++
flang-rt/lib/FortranFloat128Math/CMakeLists.txt | 9 +++++++++
2 files changed, 14 insertions(+)
diff --git a/flang-rt/README.md b/flang-rt/README.md
index 01836f9d8f714d..b398ecdba82818 100644
--- a/flang-rt/README.md
+++ b/flang-rt/README.md
@@ -100,10 +100,15 @@ cmake -S <path-to-llvm-project>/runtimes \
-GNinja \
-DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
-DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir>/bin/flang-new \
+ -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
diff --git a/flang-rt/lib/FortranFloat128Math/CMakeLists.txt b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
index b12dfee64af8f6..0d8ef07d404029 100644
--- a/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
+++ b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
@@ -98,6 +98,9 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
add_flangrt_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
${sources})
endif ()
+ target_include_directories(FortranFloat128Math PRIVATE
+ "${FLANGRT_SOURCE_DIR}/lib/flang_rt"
+ )
elseif (HAVE_LDBL_MANT_DIG_113)
# We can use 'long double' versions from libc.
check_library_exists(m sinl "" FOUND_LIBM)
@@ -105,6 +108,9 @@ elseif (HAVE_LDBL_MANT_DIG_113)
target_compile_definitions(FortranFloat128MathILib INTERFACE
HAS_LIBM
)
+ target_include_directories(FortranFloat128MathILib INTERFACE
+ "${FLANGRT_SOURCE_DIR}/lib/flang_rt"
+ )
target_sources(FortranFloat128MathILib INTERFACE ${sources})
else()
message(FATAL_ERROR "flang-rt cannot build without libm")
@@ -116,6 +122,9 @@ else()
target_compile_definitions(FortranFloat128MathILib INTERFACE
HAS_LIBMF128
)
+ target_include_directories(FortranFloat128MathILib INTERFACE
+ "${FLANGRT_SOURCE_DIR}/lib/flang_rt"
+ )
# Enable this, when math-entries.h and complex-math.h is ready.
# target_sources(FortranFloat128MathILib INTERFACE ${sources})
endif()
>From 2c5be300fd692dbbd3dc948949d22322601995ae Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 22 Oct 2024 12:16:35 +0200
Subject: [PATCH 27/58] Fix OpenMP linking
---
flang-rt/cmake/modules/AddFlangRTOffload.cmake | 3 ++-
flang-rt/lib/flang_rt/CMakeLists.txt | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/flang-rt/cmake/modules/AddFlangRTOffload.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
index a6b94602b0456f..dc1d778156cabe 100644
--- a/flang-rt/cmake/modules/AddFlangRTOffload.cmake
+++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
@@ -60,7 +60,7 @@ macro(enable_cuda_compilation name files)
endif()
endmacro()
-macro(enable_omp_offload_compilation files)
+macro(enable_omp_offload_compilation name files)
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
# OpenMP offload build only works with Clang compiler currently.
@@ -108,6 +108,7 @@ macro(enable_omp_offload_compilation files)
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}
diff --git a/flang-rt/lib/flang_rt/CMakeLists.txt b/flang-rt/lib/flang_rt/CMakeLists.txt
index 860152c39c7204..059fcb45bd5380 100644
--- a/flang-rt/lib/flang_rt/CMakeLists.txt
+++ b/flang-rt/lib/flang_rt/CMakeLists.txt
@@ -123,7 +123,7 @@ if (NOT WIN32)
)
enable_cuda_compilation(flang_rt "${supported_sources}")
- enable_omp_offload_compilation("${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.
@@ -148,7 +148,7 @@ else()
)
enable_cuda_compilation(${name} "${supported_sources}")
- enable_omp_offload_compilation("${supported_sources}")
+ enable_omp_offload_compilation(${name} "${supported_sources}")
endfunction ()
add_win_flangrt_library(STATIC static MultiThreaded)
>From c829f91cec578db587b44675554bc01e0aa77b32 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 22 Oct 2024 12:26:43 +0200
Subject: [PATCH 28/58] Re-apply: use Fortran::common::optional for CUDA build
---
flang/include/flang/Common/fast-int-set.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/flang/include/flang/Common/fast-int-set.h b/flang/include/flang/Common/fast-int-set.h
index d1c9c756a44a65..1214bac75a4bf1 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_];
}
>From a3f3a7bcec2c893960cda59b0ce398dd3a982a69 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 31 Oct 2024 10:56:00 +0100
Subject: [PATCH 29/58] Support for CMake 3.20-3.23
---
flang-rt/CMakeLists.txt | 43 +++++++++++++++++++++++++
flang-rt/cmake/modules/AddFlangRT.cmake | 2 +-
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 942bc7274e42ee..4156f0a11ca522 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -16,8 +16,42 @@ set(FLANGRT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(FLANGRT_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 "20.0")
+
+ 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
"${FLANGRT_SOURCE_DIR}/cmake/modules"
"${FLANG_SOURCE_DIR}/cmake/modules"
@@ -67,6 +101,7 @@ endif ()
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
""
@@ -84,6 +119,7 @@ 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)
@@ -124,6 +160,13 @@ if (WIN32)
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 #
#####################
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index ae867f3fe4e8eb..360a9cf22bbc4c 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -88,7 +88,7 @@ function (add_flangrt_library name)
# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS
# build, to avoid an unwanted dependency on libstdc++/libc++.so.
- if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
+ if (FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
target_compile_options(${name} PUBLIC -U_GLIBCXX_ASSERTIONS)
target_compile_options(${name} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)
endif ()
>From 16e33efe5ee44c078a127971426072e9cd9ba713 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 31 Oct 2024 14:11:33 +0100
Subject: [PATCH 30/58] Windows shared library currently not supported
---
flang-rt/CMakeLists.txt | 6 +++++
flang-rt/cmake/modules/AddFlangRT.cmake | 8 +++++-
flang-rt/lib/flang_rt/CMakeLists.txt | 34 +++++++++++++++----------
flang-rt/test/CMakeLists.txt | 10 +++++---
4 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 4156f0a11ca522..fa99fa0121de4c 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -190,6 +190,12 @@ 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 #
###################
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index 360a9cf22bbc4c..79a0cf39796d83 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -51,7 +51,7 @@ function (add_flangrt_library name)
if (ARG_OBJECT)
list(APPEND extra_args OBJECT)
endif ()
- if (EXCLUDE_FROM_ALL)
+ if (ARG_EXCLUDE_FROM_ALL)
list(APPEND extra_args EXCLUDE_FROM_ALL)
endif ()
@@ -130,4 +130,10 @@ function (add_flangrt_library name)
RUNTIME DESTINATION "${FLANGRT_INSTALL_LIB_DIR}"
)
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/lib/flang_rt/CMakeLists.txt b/flang-rt/lib/flang_rt/CMakeLists.txt
index 059fcb45bd5380..e8bdb1cccdaf63 100644
--- a/flang-rt/lib/flang_rt/CMakeLists.txt
+++ b/flang-rt/lib/flang_rt/CMakeLists.txt
@@ -130,6 +130,10 @@ if (NOT WIN32)
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 "Fortran Runtime/Meta")
+
function (add_win_flangrt_library libtype suffix msvc_lib)
set(name "flang_rt.${suffix}")
add_flangrt_library(${name} ${libtype}
@@ -149,6 +153,7 @@ else()
enable_cuda_compilation(${name} "${supported_sources}")
enable_omp_offload_compilation(${name} "${supported_sources}")
+ add_dependencies(flang_rt ${name})
endfunction ()
add_win_flangrt_library(STATIC static MultiThreaded)
@@ -157,18 +162,19 @@ else()
# unittests link against LLVMSupport which is compiled with /MD
add_win_flangrt_library(STATIC unittest MultiThreadedDLL EXCLUDE_FROM_ALL)
- # FIXME: Before DLL versions of the runtime can be used, exported definitions
- # must be annotated with __declspec(dllexport).
- add_win_flangrt_library(SHARED dynamic MultiThreadedDLL)
- add_win_flangrt_library(SHARED dynamic_dbg MultiThreadedDebugDLL)
-
- # Target for building all versions of the runtime
- add_custom_target(flang_rt)
- set_target_properties(flang_rt PROPERTIES FOLDER "Fortran Runtime/Meta")
- add_dependencies(flang_rt
- flang_rt.static
- flang_rt.static_dbg
- flang_rt.dynamic
- flang_rt.dynamic_dbg
- )
+ # FIXME: Generating runtime DLLs is currently not possible. There are two
+ # roadblocks:
+ #
+ # * Flang emits /DEFAULTLIB:flang_rt.dynamic.lib into
+ # iso_fortran_env_impl.f90.obj. Since 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 by annotated with
+ # __declspec(dllexport), or listed in a exports file. A possible workaround
+ # is CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS which would also export the internal
+ # C++ symbols.
+ #
+ #add_win_flangrt_library(SHARED dynamic MultiThreadedDLL)
+ #add_win_flangrt_library(SHARED dynamic_dbg MultiThreadedDebugDLL)
endif()
diff --git a/flang-rt/test/CMakeLists.txt b/flang-rt/test/CMakeLists.txt
index be42717b2834f3..6c542d522f4762 100644
--- a/flang-rt/test/CMakeLists.txt
+++ b/flang-rt/test/CMakeLists.txt
@@ -44,6 +44,7 @@ endif ()
set(FLANGRT_TEST_DEPENDS
FlangRTUnitTests
flang_rt.unittest
+ flang_rt.static
)
add_custom_target(flang-rt-test-depends)
@@ -51,11 +52,12 @@ set_target_properties(flang-rt-test-depends PROPERTIES FOLDER "Fortran Runtime/M
add_dependencies(flang-rt-test-depends ${FLANGRT_TEST_DEPENDS})
add_lit_testsuite(check-flang-rt "Running the flang-rt regression tests"
- ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS ${FLANGRT_TEST_DEPENDS}
-)
+ ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS flang-rt-test-depends
+ )
set_target_properties(check-flang-rt PROPERTIES FOLDER "Fortran Runtime/Meta")
add_lit_testsuites(flang-rt ${CMAKE_CURRENT_SOURCE_DIR}
- DEPENDS ${FLANGRT_TEST_DEPENDS})
+ DEPENDS flang-rt-test-depends
+ )
>From 472893a5a897219252b9d47e749465b119741e96 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 31 Oct 2024 15:14:29 +0100
Subject: [PATCH 31/58] LLVM also requires C++17
---
flang-rt/README.md | 2 --
1 file changed, 2 deletions(-)
diff --git a/flang-rt/README.md b/flang-rt/README.md
index b398ecdba82818..54e23f7e07926b 100644
--- a/flang-rt/README.md
+++ b/flang-rt/README.md
@@ -29,8 +29,6 @@ source directory. LLVM does not support in-source builds.
Requirements:
* [Same as LLVM](https://llvm.org/docs/GettingStarted.html#requirements).
- * While for LLVM C++14 suffices, Flang and flang-rt require a
- C++17-capable C++ compiler.
### Bootstrap/In-Tree Build
>From 39d6d9694b65012cda0b88dbf1865f29ddbe83f6 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 11 Nov 2024 15:38:50 +0100
Subject: [PATCH 32/58] FLANGRT -> FLANG_RT
---
flang-rt/CMakeLists.txt | 26 +++++++++----------
flang-rt/cmake/modules/AddFlangRT.cmake | 20 +++++++-------
.../cmake/modules/AddFlangRTOffload.cmake | 2 +-
flang-rt/include/flang-rt/CUDA/allocator.h | 6 ++---
.../include/flang-rt/allocator-registry.h | 6 ++---
flang-rt/include/flang-rt/array-constructor.h | 6 ++---
flang-rt/include/flang-rt/descriptor.h | 6 ++---
flang-rt/include/flang-rt/io-api-funcs.h | 6 ++---
flang-rt/include/flang-rt/iostat-funcs.h | 6 ++---
flang-rt/include/flang-rt/memory.h | 6 ++---
flang-rt/include/flang-rt/type-code.h | 6 ++---
.../lib/FortranFloat128Math/CMakeLists.txt | 6 ++---
flang-rt/lib/flang_rt/CMakeLists.txt | 8 +++---
flang-rt/lib/flang_rt/ISO_Fortran_util.h | 6 ++---
flang-rt/lib/flang_rt/allocator-registry.cpp | 4 +--
flang-rt/lib/flang_rt/buffer.h | 6 ++---
flang-rt/lib/flang_rt/copy.h | 6 ++---
flang-rt/lib/flang_rt/descriptor-io.h | 6 ++---
flang-rt/lib/flang_rt/environment.cpp | 4 +--
flang-rt/lib/flang_rt/file.h | 6 ++---
flang-rt/lib/flang_rt/internal-unit.h | 6 ++---
flang-rt/lib/flang_rt/io-api-common.h | 6 ++---
flang-rt/lib/flang_rt/io-error.h | 6 ++---
flang-rt/lib/flang_rt/io-stmt.h | 6 ++---
flang-rt/lib/flang_rt/random-templates.h | 6 ++---
flang-rt/lib/flang_rt/reduction-templates.h | 6 ++---
flang-rt/lib/flang_rt/stack.h | 6 ++---
flang-rt/lib/flang_rt/tools.h | 6 ++---
flang-rt/lib/flang_rt/type-info.h | 6 ++---
flang-rt/lib/flang_rt/unit-map.h | 6 ++---
flang-rt/lib/flang_rt/unit.cpp | 4 +--
flang-rt/lib/flang_rt/unit.h | 6 ++---
flang-rt/lib/flang_rt/utf.cpp | 4 +--
flang-rt/test/CMakeLists.txt | 4 +--
flang-rt/test/NonGtestUnit/lit.site.cfg.py.in | 4 +--
flang-rt/test/Unit/lit.site.cfg.py.in | 4 +--
flang-rt/test/lit.site.cfg.py.in | 4 +--
flang-rt/unittests/CMakeLists.txt | 4 +--
flang-rt/unittests/Runtime/tools.h | 6 ++---
39 files changed, 124 insertions(+), 124 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index fa99fa0121de4c..696ebf73c08090 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -12,8 +12,8 @@
#===------------------------------------------------------------------------===#
set(LLVM_SUBPROJECT_TITLE "Fortran Runtime")
-set(FLANGRT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
-set(FLANGRT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+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")
@@ -53,7 +53,7 @@ enable_language(Fortran)
list(APPEND CMAKE_MODULE_PATH
- "${FLANGRT_SOURCE_DIR}/cmake/modules"
+ "${FLANG_RT_SOURCE_DIR}/cmake/modules"
"${FLANG_SOURCE_DIR}/cmake/modules"
)
include(AddFlangRT)
@@ -76,19 +76,19 @@ if (LLVM_TREE_AVAILABLE)
# Despite Clang in the name, get_clang_resource_dir does not depend on Clang being added to the build
# flang-new uses the same resource dir as clang.
include(GetClangResourceDir)
- get_clang_resource_dir(FLANGRT_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
- get_clang_resource_dir(FLANGRT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the install prefix itself
+ get_clang_resource_dir(FLANG_RT_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
+ get_clang_resource_dir(FLANG_RT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the install prefix itself
else ()
- set(FLANGRT_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
- set(FLANGRT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
+ set(FLANG_RT_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
+ set(FLANG_RT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
endif ()
if (DEFINED WIN32)
- set(FLANGRT_BUILD_LIB_DIR "${FLANGRT_BUILD_LIB_DIR}/windows")
- set(FLANGRT_INSTALL_LIB_DIR "${FLANGRT_INSTALL_LIB_DIR}/windows")
+ set(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_BUILD_LIB_DIR}/windows")
+ set(FLANG_RT_INSTALL_LIB_DIR "${FLANG_RT_INSTALL_LIB_DIR}/windows")
elseif (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
- set(FLANGRT_BUILD_LIB_DIR "${FLANGRT_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
- set(FLANGRT_INSTALL_LIB_DIR "${FLANGRT_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+ set(FLANG_RT_BUILD_LIB_DIR "${FLANG_RT_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
+ set(FLANG_RT_INSTALL_LIB_DIR "${FLANG_RT_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
endif ()
@@ -153,9 +153,9 @@ if (WIN32)
ERROR_QUIET
)
if (NOT CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE AND CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT)
- string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FLANGRT_LIBCALL)
+ string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FLANG_RT_LIBCALL)
else ()
- set(FLANGRT_LIBCALL "")
+ set(FLANG_RT_LIBCALL "")
endif ()
endif ()
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index 79a0cf39796d83..33c980273152af 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -77,14 +77,14 @@ function (add_flangrt_library name)
endif ()
# Flang-rt's public headers
- target_include_directories(${name} PRIVATE "${FLANGRT_SOURCE_DIR}/include")
+ 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 "${FLANGRT_BINARY_DIR}")
+ 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.
@@ -98,8 +98,8 @@ function (add_flangrt_library name)
# functions for 128-bit integer math (__udivti3, __modti3, __fixsfti,
# __floattidf, ...) that msvc does not support. We are injecting a dependency
# to Compiler-RT where these are implemented.
- if (MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") AND FLANGRT_LIBCALL)
- target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "--dependent-lib=${FLANGRT_LIBCALL}")
+ if (MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") AND FLANG_RT_LIBCALL)
+ target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "--dependent-lib=${FLANG_RT_LIBCALL}")
endif ()
# Non-GTest unittests depend on LLVMSupport
@@ -119,15 +119,15 @@ function (add_flangrt_library name)
if (ARG_INSTALL_WITH_TOOLCHAIN)
set_target_properties(${name}
PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY "${FLANGRT_BUILD_LIB_DIR}"
- ARCHIVE_OUTPUT_DIRECTORY "${FLANGRT_BUILD_LIB_DIR}"
- RUNTIME_OUTPUT_DIRECTORY "${FLANGRT_BUILD_LIB_DIR}"
+ LIBRARY_OUTPUT_DIRECTORY "${FLANG_RT_BUILD_LIB_DIR}"
+ ARCHIVE_OUTPUT_DIRECTORY "${FLANG_RT_BUILD_LIB_DIR}"
+ RUNTIME_OUTPUT_DIRECTORY "${FLANG_RT_BUILD_LIB_DIR}"
)
install(TARGETS ${name}
- LIBRARY DESTINATION "${FLANGRT_INSTALL_LIB_DIR}"
- ARCHIVE DESTINATION "${FLANGRT_INSTALL_LIB_DIR}"
- RUNTIME DESTINATION "${FLANGRT_INSTALL_LIB_DIR}"
+ LIBRARY DESTINATION "${FLANG_RT_INSTALL_LIB_DIR}"
+ ARCHIVE DESTINATION "${FLANG_RT_INSTALL_LIB_DIR}"
+ RUNTIME DESTINATION "${FLANG_RT_INSTALL_LIB_DIR}"
)
endif ()
diff --git a/flang-rt/cmake/modules/AddFlangRTOffload.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
index dc1d778156cabe..2a02b52e143f4c 100644
--- a/flang-rt/cmake/modules/AddFlangRTOffload.cmake
+++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
@@ -54,7 +54,7 @@ macro(enable_cuda_compilation name files)
set_property(TARGET ${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
if (FLANG_RT_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
target_compile_definitions(${name}PTX
- PRIVATE FLANGRT_NO_GLOBAL_VAR_DEFS
+ PRIVATE FLANG_RT_NO_GLOBAL_VAR_DEFS
)
endif()
endif()
diff --git a/flang-rt/include/flang-rt/CUDA/allocator.h b/flang-rt/include/flang-rt/CUDA/allocator.h
index 2899931a9cb545..31ca99c646ca77 100644
--- a/flang-rt/include/flang-rt/CUDA/allocator.h
+++ b/flang-rt/include/flang-rt/CUDA/allocator.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_CUDA_ALLOCATOR_H_
-#define FLANGRT_CUDA_ALLOCATOR_H_
+#ifndef FLANG_RT_CUDA_ALLOCATOR_H_
+#define FLANG_RT_CUDA_ALLOCATOR_H_
#include "flang/Runtime/descriptor-consts.h"
#include "flang/Runtime/entry-names.h"
@@ -43,4 +43,4 @@ void *CUFAllocUnified(std::size_t);
void CUFFreeUnified(void *);
} // namespace Fortran::runtime::cuda
-#endif /* FLANGRT_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 33e30523acaa48..1f004462ca6241 100644
--- a/flang-rt/include/flang-rt/allocator-registry.h
+++ b/flang-rt/include/flang-rt/allocator-registry.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_ALLOCATOR_REGISTRY_H_
-#define FLANGRT_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 /* FLANGRT_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 e39c6fe9d050c7..a0aee59beac744 100644
--- a/flang-rt/include/flang-rt/array-constructor.h
+++ b/flang-rt/include/flang-rt/array-constructor.h
@@ -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 FLANGRT_ARRAY_CONSTRUCTOR_H_
-#define FLANGRT_ARRAY_CONSTRUCTOR_H_
+#ifndef FLANG_RT_ARRAY_CONSTRUCTOR_H_
+#define FLANG_RT_ARRAY_CONSTRUCTOR_H_
#include "flang-rt/descriptor.h"
#include "flang/Runtime/array-constructor-consts.h"
@@ -45,4 +45,4 @@ struct ArrayConstructorVector {
};
} // namespace Fortran::runtime
-#endif /* FLANGRT_ARRAY_CONSTRUCTOR_H_ */
+#endif /* FLANG_RT_ARRAY_CONSTRUCTOR_H_ */
diff --git a/flang-rt/include/flang-rt/descriptor.h b/flang-rt/include/flang-rt/descriptor.h
index adb69440be987c..4e129468e4fe6e 100644
--- a/flang-rt/include/flang-rt/descriptor.h
+++ b/flang-rt/include/flang-rt/descriptor.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_DESCRIPTOR_H_
-#define FLANGRT_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,
@@ -482,4 +482,4 @@ class alignas(Descriptor) StaticDescriptor {
};
} // namespace Fortran::runtime
-#endif /* FLANGRT_DESCRIPTOR_H_ */
+#endif /* FLANG_RT_DESCRIPTOR_H_ */
diff --git a/flang-rt/include/flang-rt/io-api-funcs.h b/flang-rt/include/flang-rt/io-api-funcs.h
index 356f2d684d2f2d..dda2f5dc96184b 100644
--- a/flang-rt/include/flang-rt/io-api-funcs.h
+++ b/flang-rt/include/flang-rt/io-api-funcs.h
@@ -8,8 +8,8 @@
// Defines API between compiled code and I/O runtime library.
-#ifndef FLANGRT_IO_API_FUNCS_H_
-#define FLANGRT_IO_API_FUNCS_H_
+#ifndef FLANG_RT_IO_API_FUNCS_H_
+#define FLANG_RT_IO_API_FUNCS_H_
#include "flang/Common/uint128.h"
#include "flang/Runtime/entry-names.h"
@@ -36,4 +36,4 @@ RT_API_ATTRS const char *InquiryKeywordHashDecode(
char *buffer, std::size_t, InquiryKeywordHash);
} // namespace Fortran::runtime::io
-#endif /* FLANGRT_IO_API_FUNCS_H_ */
+#endif /* FLANG_RT_IO_API_FUNCS_H_ */
diff --git a/flang-rt/include/flang-rt/iostat-funcs.h b/flang-rt/include/flang-rt/iostat-funcs.h
index 101256103cbf29..0edb8f402c4fe8 100644
--- a/flang-rt/include/flang-rt/iostat-funcs.h
+++ b/flang-rt/include/flang-rt/iostat-funcs.h
@@ -9,8 +9,8 @@
// Defines the values returned by the runtime for IOSTAT= specifiers
// on I/O statements.
-#ifndef FLANGRT_IOSTAT_FUNCS_H_
-#define FLANGRT_IOSTAT_FUNCS_H_
+#ifndef FLANG_RT_IOSTAT_FUNCS_H_
+#define FLANG_RT_IOSTAT_FUNCS_H_
#include "flang/Common/api-attrs.h"
#include "flang/Runtime/iostat.h"
@@ -20,4 +20,4 @@ namespace Fortran::runtime::io {
RT_API_ATTRS const char *IostatErrorString(int);
} // namespace Fortran::runtime::io
-#endif /* FLANGRT_IOSTAT_FUNCS_H_ */
+#endif /* FLANG_RT_IOSTAT_FUNCS_H_ */
diff --git a/flang-rt/include/flang-rt/memory.h b/flang-rt/include/flang-rt/memory.h
index 84cc6c5266a8ea..afbb1b34c1d2c0 100644
--- a/flang-rt/include/flang-rt/memory.h
+++ b/flang-rt/include/flang-rt/memory.h
@@ -9,8 +9,8 @@
// Thin wrapper around malloc()/free() to isolate the dependency,
// ease porting, and provide an owning pointer.
-#ifndef FLANGRT_MEMORY_H_
-#define FLANGRT_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 /* FLANGRT_MEMORY_H_ */
+#endif /* FLANG_RT_MEMORY_H_ */
diff --git a/flang-rt/include/flang-rt/type-code.h b/flang-rt/include/flang-rt/type-code.h
index 409d47b82c17d8..1d057481261a1d 100644
--- a/flang-rt/include/flang-rt/type-code.h
+++ b/flang-rt/include/flang-rt/type-code.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_TYPE_CODE_H_
-#define FLANGRT_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 /* FLANGRT_TYPE_CODE_H_ */
+#endif /* FLANG_RT_TYPE_CODE_H_ */
diff --git a/flang-rt/lib/FortranFloat128Math/CMakeLists.txt b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
index 0d8ef07d404029..9f9f94127dda6f 100644
--- a/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
+++ b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
@@ -99,7 +99,7 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
${sources})
endif ()
target_include_directories(FortranFloat128Math PRIVATE
- "${FLANGRT_SOURCE_DIR}/lib/flang_rt"
+ "${FLANG_RT_SOURCE_DIR}/lib/flang_rt"
)
elseif (HAVE_LDBL_MANT_DIG_113)
# We can use 'long double' versions from libc.
@@ -109,7 +109,7 @@ elseif (HAVE_LDBL_MANT_DIG_113)
HAS_LIBM
)
target_include_directories(FortranFloat128MathILib INTERFACE
- "${FLANGRT_SOURCE_DIR}/lib/flang_rt"
+ "${FLANG_RT_SOURCE_DIR}/lib/flang_rt"
)
target_sources(FortranFloat128MathILib INTERFACE ${sources})
else()
@@ -123,7 +123,7 @@ else()
HAS_LIBMF128
)
target_include_directories(FortranFloat128MathILib INTERFACE
- "${FLANGRT_SOURCE_DIR}/lib/flang_rt"
+ "${FLANG_RT_SOURCE_DIR}/lib/flang_rt"
)
# Enable this, when math-entries.h and complex-math.h is ready.
# target_sources(FortranFloat128MathILib INTERFACE ${sources})
diff --git a/flang-rt/lib/flang_rt/CMakeLists.txt b/flang-rt/lib/flang_rt/CMakeLists.txt
index e8bdb1cccdaf63..6068b75c17ae90 100644
--- a/flang-rt/lib/flang_rt/CMakeLists.txt
+++ b/flang-rt/lib/flang_rt/CMakeLists.txt
@@ -84,13 +84,13 @@ set(host_sources
)
file(GLOB_RECURSE public_headers
- "${FLANGRT_SOURCE_DIR}/include/flang/Runtime/*.h"
- "${FLANGRT_SOURCE_DIR}/include/flang/Common/*.h"
+ "${FLANG_RT_SOURCE_DIR}/include/flang/Runtime/*.h"
+ "${FLANG_RT_SOURCE_DIR}/include/flang/Common/*.h"
)
file(GLOB_RECURSE private_headers
- "${FLANGRT_SOURCE_DIR}/lib/Runtime/*.h"
- "${FLANGRT_SOURCE_DIR}/lib/Common/*.h"
+ "${FLANG_RT_SOURCE_DIR}/lib/Runtime/*.h"
+ "${FLANG_RT_SOURCE_DIR}/lib/Common/*.h"
)
diff --git a/flang-rt/lib/flang_rt/ISO_Fortran_util.h b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
index 3c1163851bee6b..dcbd76cc6bce24 100644
--- a/flang-rt/lib/flang_rt/ISO_Fortran_util.h
+++ b/flang-rt/lib/flang_rt/ISO_Fortran_util.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_ISO_FORTRAN_UTIL_H_
-#define FLANGRT_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.
@@ -99,4 +99,4 @@ static inline RT_API_ATTRS void EstablishDescriptor(CFI_cdesc_t *descriptor,
}
}
} // namespace Fortran::ISO
-#endif /* FLANGRT_ISO_FORTRAN_UTIL_H_ */
+#endif /* FLANG_RT_ISO_FORTRAN_UTIL_H_ */
diff --git a/flang-rt/lib/flang_rt/allocator-registry.cpp b/flang-rt/lib/flang_rt/allocator-registry.cpp
index 0f2fae7950b1b3..c6e799d7cba0dc 100644
--- a/flang-rt/lib/flang_rt/allocator-registry.cpp
+++ b/flang-rt/lib/flang_rt/allocator-registry.cpp
@@ -11,11 +11,11 @@
namespace Fortran::runtime {
-#ifndef FLANGRT_NO_GLOBAL_VAR_DEFS
+#ifndef FLANG_RT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS AllocatorRegistry allocatorRegistry;
RT_OFFLOAD_VAR_GROUP_END
-#endif // FLANGRT_NO_GLOBAL_VAR_DEFS
+#endif // FLANG_RT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
RT_API_ATTRS void AllocatorRegistry::Register(int pos, Allocator_t allocator) {
diff --git a/flang-rt/lib/flang_rt/buffer.h b/flang-rt/lib/flang_rt/buffer.h
index 01a6aa28c4ac94..84fe4c34cea0e3 100644
--- a/flang-rt/lib/flang_rt/buffer.h
+++ b/flang-rt/lib/flang_rt/buffer.h
@@ -8,8 +8,8 @@
// External file buffering
-#ifndef FLANGRT_BUFFER_H_
-#define FLANGRT_BUFFER_H_
+#ifndef FLANG_RT_BUFFER_H_
+#define FLANG_RT_BUFFER_H_
#include "flang-rt/memory.h"
#include "io-error.h"
@@ -221,4 +221,4 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
bool dirty_{false};
};
} // namespace Fortran::runtime::io
-#endif /* FLANGRT_BUFFER_H_ */
+#endif /* FLANG_RT_BUFFER_H_ */
diff --git a/flang-rt/lib/flang_rt/copy.h b/flang-rt/lib/flang_rt/copy.h
index f0520c23e4a471..468c2439baf618 100644
--- a/flang-rt/lib/flang_rt/copy.h
+++ b/flang-rt/lib/flang_rt/copy.h
@@ -9,8 +9,8 @@
// Utilities that copy data in a type-aware fashion, allocating & duplicating
// allocatable/automatic components of derived types along the way.
-#ifndef FLANGRT_COPY_H_
-#define FLANGRT_COPY_H_
+#ifndef FLANG_RT_COPY_H_
+#define FLANG_RT_COPY_H_
#include "flang-rt/descriptor.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 /* FLANGRT_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 3c5abd6f97993a..2276dfe13230ed 100644
--- a/flang-rt/lib/flang_rt/descriptor-io.h
+++ b/flang-rt/lib/flang_rt/descriptor-io.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_DESCRIPTOR_IO_H_
-#define FLANGRT_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;
@@ -608,4 +608,4 @@ static RT_API_ATTRS bool DescriptorIO(IoStatementState &io,
return false;
}
} // namespace Fortran::runtime::io::descr
-#endif /* FLANGRT_DESCRIPTOR_IO_H_ */
+#endif /* FLANG_RT_DESCRIPTOR_IO_H_ */
diff --git a/flang-rt/lib/flang_rt/environment.cpp b/flang-rt/lib/flang_rt/environment.cpp
index a9447815efeeaf..3360b5d92f2aeb 100644
--- a/flang-rt/lib/flang_rt/environment.cpp
+++ b/flang-rt/lib/flang_rt/environment.cpp
@@ -23,11 +23,11 @@ extern char **environ;
namespace Fortran::runtime {
-#ifndef FLANGRT_NO_GLOBAL_VAR_DEFS
+#ifndef FLANG_RT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS ExecutionEnvironment executionEnvironment;
RT_OFFLOAD_VAR_GROUP_END
-#endif // FLANGRT_NO_GLOBAL_VAR_DEFS
+#endif // FLANG_RT_NO_GLOBAL_VAR_DEFS
static void SetEnvironmentDefaults(const EnvironmentDefaultList *envDefaults) {
if (!envDefaults) {
diff --git a/flang-rt/lib/flang_rt/file.h b/flang-rt/lib/flang_rt/file.h
index 6975bccb987583..13a7133677c6ce 100644
--- a/flang-rt/lib/flang_rt/file.h
+++ b/flang-rt/lib/flang_rt/file.h
@@ -8,8 +8,8 @@
// Raw system I/O wrappers
-#ifndef FLANGRT_FILE_H_
-#define FLANGRT_FILE_H_
+#ifndef FLANG_RT_FILE_H_
+#define FLANG_RT_FILE_H_
#include "flang-rt/memory.h"
#include "io-error.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 /* FLANGRT_FILE_H_ */
+#endif /* FLANG_RT_FILE_H_ */
diff --git a/flang-rt/lib/flang_rt/internal-unit.h b/flang-rt/lib/flang_rt/internal-unit.h
index a825e09cdd203e..cae95855a895df 100644
--- a/flang-rt/lib/flang_rt/internal-unit.h
+++ b/flang-rt/lib/flang_rt/internal-unit.h
@@ -8,8 +8,8 @@
// Fortran internal I/O "units"
-#ifndef FLANGRT_INTERNAL_UNIT_H_
-#define FLANGRT_INTERNAL_UNIT_H_
+#ifndef FLANG_RT_INTERNAL_UNIT_H_
+#define FLANG_RT_INTERNAL_UNIT_H_
#include "connection.h"
#include "flang-rt/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 /* FLANGRT_INTERNAL_UNIT_H_ */
+#endif /* FLANG_RT_INTERNAL_UNIT_H_ */
diff --git a/flang-rt/lib/flang_rt/io-api-common.h b/flang-rt/lib/flang_rt/io-api-common.h
index 39c87ba326bea4..22de04b3d5b077 100644
--- a/flang-rt/lib/flang_rt/io-api-common.h
+++ b/flang-rt/lib/flang_rt/io-api-common.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_IO_API_COMMON_H_
-#define FLANGRT_IO_API_COMMON_H_
+#ifndef FLANG_RT_IO_API_COMMON_H_
+#define FLANG_RT_IO_API_COMMON_H_
#include "flang-rt/io-api-funcs.h"
#include "io-stmt.h"
@@ -94,4 +94,4 @@ RT_API_ATTRS Cookie BeginExternalListIO(
}
} // namespace Fortran::runtime::io
-#endif /* FLANGRT_IO_API_COMMON_H_ */
+#endif /* FLANG_RT_IO_API_COMMON_H_ */
diff --git a/flang-rt/lib/flang_rt/io-error.h b/flang-rt/lib/flang_rt/io-error.h
index 775c5d66d83530..958ce2e3fc42b8 100644
--- a/flang-rt/lib/flang_rt/io-error.h
+++ b/flang-rt/lib/flang_rt/io-error.h
@@ -12,8 +12,8 @@
// IOSTAT error codes are raw errno values augmented with values for
// Fortran-specific errors.
-#ifndef FLANGRT_IO_ERROR_H_
-#define FLANGRT_IO_ERROR_H_
+#ifndef FLANG_RT_IO_ERROR_H_
+#define FLANG_RT_IO_ERROR_H_
#include "flang-rt/iostat-funcs.h"
#include "flang-rt/memory.h"
@@ -78,4 +78,4 @@ class IoErrorHandler : public Terminator {
};
} // namespace Fortran::runtime::io
-#endif /* FLANGRT_IO_ERROR_H_ */
+#endif /* FLANG_RT_IO_ERROR_H_ */
diff --git a/flang-rt/lib/flang_rt/io-stmt.h b/flang-rt/lib/flang_rt/io-stmt.h
index c7bde114457f0e..b4089ea67e1f7c 100644
--- a/flang-rt/lib/flang_rt/io-stmt.h
+++ b/flang-rt/lib/flang_rt/io-stmt.h
@@ -8,8 +8,8 @@
// Representations of the state of an I/O statement in progress
-#ifndef FLANGRT_IO_STMT_H_
-#define FLANGRT_IO_STMT_H_
+#ifndef FLANG_RT_IO_STMT_H_
+#define FLANG_RT_IO_STMT_H_
#include "connection.h"
#include "file.h"
@@ -789,4 +789,4 @@ class ErroneousIoStatementState : public IoStatementBase {
};
} // namespace Fortran::runtime::io
-#endif /* FLANGRT_IO_STMT_H_ */
+#endif /* FLANG_RT_IO_STMT_H_ */
diff --git a/flang-rt/lib/flang_rt/random-templates.h b/flang-rt/lib/flang_rt/random-templates.h
index 8ed5757ec76a76..36701501b94ef5 100644
--- a/flang-rt/lib/flang_rt/random-templates.h
+++ b/flang-rt/lib/flang_rt/random-templates.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_RANDOM_TEMPLATES_H_
-#define FLANGRT_RANDOM_TEMPLATES_H_
+#ifndef FLANG_RT_RANDOM_TEMPLATES_H_
+#define FLANG_RT_RANDOM_TEMPLATES_H_
#include "flang-rt/descriptor.h"
#include "lock.h"
@@ -85,4 +85,4 @@ inline void Generate(const Descriptor &harvest) {
} // namespace Fortran::runtime::random
-#endif /* FLANGRT_RANDOM_TEMPLATES_H_ */
+#endif /* FLANG_RT_RANDOM_TEMPLATES_H_ */
diff --git a/flang-rt/lib/flang_rt/reduction-templates.h b/flang-rt/lib/flang_rt/reduction-templates.h
index 6764706c3fa951..496372de1752a4 100644
--- a/flang-rt/lib/flang_rt/reduction-templates.h
+++ b/flang-rt/lib/flang_rt/reduction-templates.h
@@ -18,8 +18,8 @@
// * Character-valued reductions (MAXVAL & MINVAL) return arbitrary
// length results, dynamically allocated in a caller-supplied descriptor
-#ifndef FLANGRT_REDUCTION_TEMPLATES_H_
-#define FLANGRT_REDUCTION_TEMPLATES_H_
+#ifndef FLANG_RT_REDUCTION_TEMPLATES_H_
+#define FLANG_RT_REDUCTION_TEMPLATES_H_
#include "flang-rt/descriptor.h"
#include "numeric-templates.h"
@@ -412,4 +412,4 @@ template <int KIND> struct Norm2Helper {
};
} // namespace Fortran::runtime
-#endif /* FLANGRT_REDUCTION_TEMPLATES_H_ */
+#endif /* FLANG_RT_REDUCTION_TEMPLATES_H_ */
diff --git a/flang-rt/lib/flang_rt/stack.h b/flang-rt/lib/flang_rt/stack.h
index 4b0de1e59e4596..07b34f3eef2c3d 100644
--- a/flang-rt/lib/flang_rt/stack.h
+++ b/flang-rt/lib/flang_rt/stack.h
@@ -10,8 +10,8 @@
// It is a list based stack with dynamic allocation/deallocation
// of the list nodes.
-#ifndef FLANGRT_STACK_H_
-#define FLANGRT_STACK_H_
+#ifndef FLANG_RT_STACK_H_
+#define FLANG_RT_STACK_H_
#include "flang-rt/memory.h"
#include "terminator.h"
@@ -133,4 +133,4 @@ template <typename T, unsigned N = 0> class Stack : public StackStorage<T, N> {
Terminator &terminator_;
};
} // namespace Fortran::runtime
-#endif /* FLANGRT_STACK_H_ */
+#endif /* FLANG_RT_STACK_H_ */
diff --git a/flang-rt/lib/flang_rt/tools.h b/flang-rt/lib/flang_rt/tools.h
index bc2f4ff034cb13..9892ef0fc28393 100644
--- a/flang-rt/lib/flang_rt/tools.h
+++ b/flang-rt/lib/flang_rt/tools.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_TOOLS_H_
-#define FLANGRT_TOOLS_H_
+#ifndef FLANG_RT_TOOLS_H_
+#define FLANG_RT_TOOLS_H_
#include "flang-rt/descriptor.h"
#include "flang-rt/memory.h"
@@ -535,4 +535,4 @@ RT_API_ATTRS void CreatePartialReductionResult(Descriptor &result,
const char *intrinsic, TypeCode);
} // namespace Fortran::runtime
-#endif /* FLANGRT_TOOLS_H_ */
+#endif /* FLANG_RT_TOOLS_H_ */
diff --git a/flang-rt/lib/flang_rt/type-info.h b/flang-rt/lib/flang_rt/type-info.h
index 891a6a0d032127..69ad4e4a341a3d 100644
--- a/flang-rt/lib/flang_rt/type-info.h
+++ b/flang-rt/lib/flang_rt/type-info.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_TYPE_INFO_H_
-#define FLANGRT_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.
@@ -321,4 +321,4 @@ class DerivedType {
};
} // namespace Fortran::runtime::typeInfo
-#endif /* FLANGRT_TYPE_INFO_H_ */
+#endif /* FLANG_RT_TYPE_INFO_H_ */
diff --git a/flang-rt/lib/flang_rt/unit-map.h b/flang-rt/lib/flang_rt/unit-map.h
index 50aa74aeed05bf..e37438c58a2968 100644
--- a/flang-rt/lib/flang_rt/unit-map.h
+++ b/flang-rt/lib/flang_rt/unit-map.h
@@ -9,8 +9,8 @@
// Maps Fortran unit numbers to their ExternalFileUnit instances.
// A simple hash table with forward-linked chains per bucket.
-#ifndef FLANGRT_UNIT_MAP_H_
-#define FLANGRT_UNIT_MAP_H_
+#ifndef FLANG_RT_UNIT_MAP_H_
+#define FLANG_RT_UNIT_MAP_H_
#include "flang-rt/memory.h"
#include "lock.h"
@@ -100,4 +100,4 @@ class UnitMap {
int emergencyNewUnit_{maxNewUnits_}; // not recycled
};
} // namespace Fortran::runtime::io
-#endif /* FLANGRT_UNIT_MAP_H_ */
+#endif /* FLANG_RT_UNIT_MAP_H_ */
diff --git a/flang-rt/lib/flang_rt/unit.cpp b/flang-rt/lib/flang_rt/unit.cpp
index b5a4282faf22e5..06faf60d6d6222 100644
--- a/flang-rt/lib/flang_rt/unit.cpp
+++ b/flang-rt/lib/flang_rt/unit.cpp
@@ -19,13 +19,13 @@
namespace Fortran::runtime::io {
-#ifndef FLANGRT_NO_GLOBAL_VAR_DEFS
+#ifndef FLANG_RT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_VAR_GROUP_BEGIN
RT_VAR_ATTRS ExternalFileUnit *defaultInput{nullptr}; // unit 5
RT_VAR_ATTRS ExternalFileUnit *defaultOutput{nullptr}; // unit 6
RT_VAR_ATTRS ExternalFileUnit *errorOutput{nullptr}; // unit 0 extension
RT_OFFLOAD_VAR_GROUP_END
-#endif // FLANGRT_NO_GLOBAL_VAR_DEFS
+#endif // FLANG_RT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/flang-rt/lib/flang_rt/unit.h b/flang-rt/lib/flang_rt/unit.h
index 5049f3c5db80f7..0a31de632136d2 100644
--- a/flang-rt/lib/flang_rt/unit.h
+++ b/flang-rt/lib/flang_rt/unit.h
@@ -8,8 +8,8 @@
// Fortran external I/O units
-#ifndef FLANGRT_UNIT_H_
-#define FLANGRT_UNIT_H_
+#ifndef FLANG_RT_UNIT_H_
+#define FLANG_RT_UNIT_H_
#include "buffer.h"
#include "connection.h"
@@ -291,4 +291,4 @@ class ChildIo {
};
} // namespace Fortran::runtime::io
-#endif /* FLANGRT_UNIT_H_ */
+#endif /* FLANG_RT_UNIT_H_ */
diff --git a/flang-rt/lib/flang_rt/utf.cpp b/flang-rt/lib/flang_rt/utf.cpp
index 860db5f2367d38..e4e4926ea3124d 100644
--- a/flang-rt/lib/flang_rt/utf.cpp
+++ b/flang-rt/lib/flang_rt/utf.cpp
@@ -10,7 +10,7 @@
namespace Fortran::runtime {
-#ifndef FLANGRT_NO_GLOBAL_VAR_DEFS
+#ifndef FLANG_RT_NO_GLOBAL_VAR_DEFS
// clang-format off
RT_OFFLOAD_VAR_GROUP_BEGIN
const RT_CONST_VAR_ATTRS std::uint8_t UTF8FirstByteTable[256]{
@@ -41,7 +41,7 @@ const RT_CONST_VAR_ATTRS std::uint8_t UTF8FirstByteTable[256]{
};
RT_OFFLOAD_VAR_GROUP_END
// clang-format on
-#endif // FLANGRT_NO_GLOBAL_VAR_DEFS
+#endif // FLANG_RT_NO_GLOBAL_VAR_DEFS
RT_OFFLOAD_API_GROUP_BEGIN
diff --git a/flang-rt/test/CMakeLists.txt b/flang-rt/test/CMakeLists.txt
index 6c542d522f4762..5dfd6ac35248c3 100644
--- a/flang-rt/test/CMakeLists.txt
+++ b/flang-rt/test/CMakeLists.txt
@@ -41,7 +41,7 @@ if (TARGET FlangRTUnitTests)
)
endif ()
-set(FLANGRT_TEST_DEPENDS
+set(FLANG_RT_TEST_DEPENDS
FlangRTUnitTests
flang_rt.unittest
flang_rt.static
@@ -49,7 +49,7 @@ set(FLANGRT_TEST_DEPENDS
add_custom_target(flang-rt-test-depends)
set_target_properties(flang-rt-test-depends PROPERTIES FOLDER "Fortran Runtime/Meta")
-add_dependencies(flang-rt-test-depends ${FLANGRT_TEST_DEPENDS})
+add_dependencies(flang-rt-test-depends ${FLANG_RT_TEST_DEPENDS})
add_lit_testsuite(check-flang-rt "Running the flang-rt regression tests"
${CMAKE_CURRENT_BINARY_DIR}
diff --git a/flang-rt/test/NonGtestUnit/lit.site.cfg.py.in b/flang-rt/test/NonGtestUnit/lit.site.cfg.py.in
index 9dc4d2d5a1513f..f68c87afdef812 100644
--- a/flang-rt/test/NonGtestUnit/lit.site.cfg.py.in
+++ b/flang-rt/test/NonGtestUnit/lit.site.cfg.py.in
@@ -3,8 +3,8 @@
import os
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.flangrt_source_dir = "@FLANGRT_SOURCE_DIR@"
-config.flangrt_binary_dir = "@FLANGRT_BINARY_DIR@"
+config.flangrt_source_dir = "@FLANG_RT_SOURCE_DIR@"
+config.flangrt_binary_dir = "@FLANG_RT_BINARY_DIR@"
config.flangrt_binary_test_dir = os.path.dirname(__file__)
import lit.llvm
diff --git a/flang-rt/test/Unit/lit.site.cfg.py.in b/flang-rt/test/Unit/lit.site.cfg.py.in
index f6ed1e758d9374..1441aac0d0e45b 100644
--- a/flang-rt/test/Unit/lit.site.cfg.py.in
+++ b/flang-rt/test/Unit/lit.site.cfg.py.in
@@ -4,8 +4,8 @@ import os
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_build_mode = "@LLVM_BUILD_MODE@"
-config.flangrt_source_dir = "@FLANGRT_SOURCE_DIR@"
-config.flangrt_binary_dir = "@FLANGRT_BINARY_DIR@"
+config.flangrt_source_dir = "@FLANG_RT_SOURCE_DIR@"
+config.flangrt_binary_dir = "@FLANG_RT_BINARY_DIR@"
config.flangrt_binary_test_dir = os.path.dirname(__file__)
import lit.llvm
diff --git a/flang-rt/test/lit.site.cfg.py.in b/flang-rt/test/lit.site.cfg.py.in
index 630f7dfcd508c7..664a75bdc7b9e6 100644
--- a/flang-rt/test/lit.site.cfg.py.in
+++ b/flang-rt/test/lit.site.cfg.py.in
@@ -4,9 +4,9 @@ import sys
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.flang_source_dir = "@FLANG_SOURCE_DIR@"
-config.flangrt_source_dir = "@FLANGRT_SOURCE_DIR@"
+config.flangrt_source_dir = "@FLANG_RT_SOURCE_DIR@"
config.flangrt_binary_test_dir = os.path.dirname(__file__)
-config.flangrt_build_lib_dir = "@FLANGRT_BUILD_LIB_DIR@"
+config.flangrt_build_lib_dir = "@FLANG_RT_BUILD_LIB_DIR@"
config.cc = "@CMAKE_C_COMPILER@"
config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@")
diff --git a/flang-rt/unittests/CMakeLists.txt b/flang-rt/unittests/CMakeLists.txt
index 43dc2b5a4ac48b..a15675e80473fa 100644
--- a/flang-rt/unittests/CMakeLists.txt
+++ b/flang-rt/unittests/CMakeLists.txt
@@ -64,7 +64,7 @@ function(add_flangrt_unittest test_dirname)
add_unittest(FlangRTUnitTests ${test_dirname} ${ARG_UNPARSED_ARGUMENTS})
- target_include_directories(${test_dirname} PRIVATE "${FLANGRT_SOURCE_DIR}/include")
+ 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})
@@ -86,7 +86,7 @@ function(add_flangrt_nongtest_unittest test_name)
add_executable(${test_name}${suffix} ${ARG_UNPARSED_ARGUMENTS})
set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Fortran Runtime/Tests/Unit")
- target_include_directories(${test_name}${suffix} PRIVATE "${FLANGRT_SOURCE_DIR}/include")
+ target_include_directories(${test_name}${suffix} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
target_include_directories(${test_name}${suffix} PRIVATE "${FLANG_SOURCE_DIR}/include")
target_link_libraries(${test_name}${suffix} PRIVATE NonGTestTesting ${ARG_LINK_LIBS})
diff --git a/flang-rt/unittests/Runtime/tools.h b/flang-rt/unittests/Runtime/tools.h
index 414175bde07d04..0db44c7ad0189c 100644
--- a/flang-rt/unittests/Runtime/tools.h
+++ b/flang-rt/unittests/Runtime/tools.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef FLANGRT_UNITTESTS_RUNTIME_TOOLS_H_
-#define FLANGRT_UNITTESTS_RUNTIME_TOOLS_H_
+#ifndef FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_
+#define FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_
#include "flang-rt/descriptor.h"
#include "flang-rt/type-code.h"
@@ -54,4 +54,4 @@ static OwningPtr<Descriptor> MakeArray(const std::vector<int> &shape,
}
} // namespace Fortran::runtime
-#endif /* FLANGRT_UNITTESTS_RUNTIME_TOOLS_H_ */
+#endif /* FLANG_RT_UNITTESTS_RUNTIME_TOOLS_H_ */
>From 8883b7e5b8e91db5a729b89fca6e61579b520107 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 11 Nov 2024 16:28:10 +0100
Subject: [PATCH 33/58] [Windows] Emit dependency to flang_rt.builtins.lib in
every flang-compiled object file.
The dependency is already transitive due to flang-rt depending on it, so
it shouldn't be necessary. However, CMake may depend on it, and the
transsitivity may be ignored in DLLs.
To avoid breaking things, keep the original behaviour but remove the
redundant condition and update the wrong comment.
IMHO this is a bug in LLVM: If clang/clang-cl emits calls not in user-code,
the driver should als care about linking the correct library. Even better,
do not generate such calls and adhere to the msvc-defined ABI.
---
clang/lib/Driver/ToolChains/Flang.cpp | 8 ++++++++
flang-rt/cmake/modules/AddFlangRT.cmake | 6 +++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 072d57e8a7ff46..e7d8193c843279 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -291,6 +291,14 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
assert(TC.getTriple().isKnownWindowsMSVCEnvironment() &&
"can only add VS runtime library on Windows!");
+ // 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/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index 33c980273152af..a06e322f2be973 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -95,9 +95,9 @@ function (add_flangrt_library name)
# 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 for 128-bit integer math (__udivti3, __modti3, __fixsfti,
- # __floattidf, ...) that msvc does not support. We are injecting a dependency
- # to Compiler-RT where these are implemented.
+ # 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") AND FLANG_RT_LIBCALL)
target_compile_options(${name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:-Xclang>$<$<COMPILE_LANGUAGE:Fortran>:-Xflang>" "--dependent-lib=${FLANG_RT_LIBCALL}")
endif ()
>From 3fb72841ffa95c5b76d5cc097d904c11b66cc5bb Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 14 Nov 2024 17:05:19 +0100
Subject: [PATCH 34/58] Update flang/docs/FlangDriver.md
Co-authored-by: h-vetinari <h.vetinari at gmx.com>
---
flang/docs/FlangDriver.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index 5165ac6c323ac2..f903a61857f692 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -190,7 +190,7 @@ If the code is C/C++ based and invokes Fortran routines, one can either use Clan
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_ty`. 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)
>From f1f095f4b5c69ea419e3299a41e76c3db24793b4 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 14 Nov 2024 17:04:52 +0100
Subject: [PATCH 35/58] Assume current version of Flang for CMake < 3.24
---
flang-rt/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 696ebf73c08090..dbe75d832d0aa6 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -26,7 +26,7 @@ if (CMAKE_VERSION VERSION_LESS "3.24")
CMAKE_FORCE_Fortran_COMPILER("${CMAKE_Fortran_COMPILER}" "LLVMFlang")
set(CMAKE_Fortran_COMPILER_ID "LLVMFlang")
- set(CMAKE_Fortran_COMPILER_VERSION "20.0")
+ set(CMAKE_Fortran_COMPILER_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
set(CMAKE_Fortran_SUBMODULE_SEP "-")
set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
>From 50acc4fffcb1e5e86e7855b8b1abc9ab6f6a92e7 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 14 Nov 2024 17:14:06 +0100
Subject: [PATCH 36/58] Add h-vetinari's additional info
---
flang-rt/lib/flang_rt/CMakeLists.txt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/flang-rt/lib/flang_rt/CMakeLists.txt b/flang-rt/lib/flang_rt/CMakeLists.txt
index 6068b75c17ae90..2e82bc799616ec 100644
--- a/flang-rt/lib/flang_rt/CMakeLists.txt
+++ b/flang-rt/lib/flang_rt/CMakeLists.txt
@@ -170,10 +170,11 @@ else()
# flang_rt.dynamic, this results in a recursive dependency when invoking
# the linker.
#
- # * The externally-visible functions must either by annotated with
+ # * The externally-visible functions must either be annotated with
# __declspec(dllexport), or listed in a exports file. A possible workaround
# is CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS which would also export the internal
- # C++ symbols.
+ # C++ symbols and still requires global data symbols by be annotated
+ # manually.
#
#add_win_flangrt_library(SHARED dynamic MultiThreadedDLL)
#add_win_flangrt_library(SHARED dynamic_dbg MultiThreadedDebugDLL)
>From 7570afd911d137654a74d7a1943b81b54c3125fe Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 15 Nov 2024 18:45:00 +0100
Subject: [PATCH 37/58] Post-merge fix
---
flang-rt/lib/CufRuntime/allocatable.cpp | 5 +++--
flang-rt/lib/CufRuntime/allocator.cpp | 16 ++++++++--------
flang-rt/lib/CufRuntime/descriptor.cpp | 5 +++--
flang-rt/lib/CufRuntime/memory.cpp | 2 +-
flang-rt/unittests/Runtime/CUDA/Allocatable.cpp | 9 +++++----
flang-rt/unittests/Runtime/CUDA/CMakeLists.txt | 1 +
6 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/flang-rt/lib/CufRuntime/allocatable.cpp b/flang-rt/lib/CufRuntime/allocatable.cpp
index 199fb5c9556c5d..158c5bd15d87cb 100644
--- a/flang-rt/lib/CufRuntime/allocatable.cpp
+++ b/flang-rt/lib/CufRuntime/allocatable.cpp
@@ -7,8 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/allocatable.h"
-#include "../stat.h"
-#include "../terminator.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/allocatable.h"
diff --git a/flang-rt/lib/CufRuntime/allocator.cpp b/flang-rt/lib/CufRuntime/allocator.cpp
index c764dd63df1689..143dc10f5ba5c2 100644
--- a/flang-rt/lib/CufRuntime/allocator.cpp
+++ b/flang-rt/lib/CufRuntime/allocator.cpp
@@ -6,15 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Runtime/CUDA/allocator.h"
-#include "../derived.h"
-#include "../stat.h"
-#include "../terminator.h"
-#include "../type-info.h"
-#include "flang/Common/Fortran.h"
-#include "flang/ISO_Fortran_binding_wrapper.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-rt/lib/CufRuntime/descriptor.cpp b/flang-rt/lib/CufRuntime/descriptor.cpp
index f57a69f99a6cef..ab67f07f35a6f8 100644
--- a/flang-rt/lib/CufRuntime/descriptor.cpp
+++ b/flang-rt/lib/CufRuntime/descriptor.cpp
@@ -7,8 +7,9 @@
//===----------------------------------------------------------------------===//
#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 "cuda_runtime.h"
diff --git a/flang-rt/lib/CufRuntime/memory.cpp b/flang-rt/lib/CufRuntime/memory.cpp
index 32a8f9414757cb..028f04ff296eda 100644
--- a/flang-rt/lib/CufRuntime/memory.cpp
+++ b/flang-rt/lib/CufRuntime/memory.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/memory.h"
-#include "../terminator.h"
+#include "../flang_rt/terminator.h"
#include "cuda_runtime.h"
diff --git a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
index 2afdd3ae6bb0de..c595dc61722c21 100644
--- a/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
+++ b/flang-rt/unittests/Runtime/CUDA/Allocatable.cpp
@@ -7,13 +7,14 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/allocatable.h"
+#include "flang-rt/CUDA/allocator.h"
+#include "flang-rt/allocator-registry.h"
+#include "flang-rt/descriptor.h"
#include "gtest/gtest.h"
-#include "../../../runtime/terminator.h"
-#include "flang/Common/Fortran.h"
-#include "flang/Runtime/CUDA/allocator.h"
+#include "../../../lib/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"
diff --git a/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
index 829ae9250f345e..6702f7c97a0dd8 100644
--- a/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
+++ b/flang-rt/unittests/Runtime/CUDA/CMakeLists.txt
@@ -7,6 +7,7 @@
#===------------------------------------------------------------------------===#
add_flangrt_unittest(FlangCufRuntimeTests
+ Allocatable.cpp
AllocatorCUF.cpp
)
>From 912e8fdce1647386b5f84eff6a3fc16091ce4517 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 15 Nov 2024 19:30:43 +0100
Subject: [PATCH 38/58] Post-merge fixes
---
flang-rt/lib/CufRuntime/memory.cpp | 3 ---
1 file changed, 3 deletions(-)
diff --git a/flang-rt/lib/CufRuntime/memory.cpp b/flang-rt/lib/CufRuntime/memory.cpp
index 8a54c0107d7e03..0d927ba1dbd03c 100644
--- a/flang-rt/lib/CufRuntime/memory.cpp
+++ b/flang-rt/lib/CufRuntime/memory.cpp
@@ -9,9 +9,6 @@
#include "flang/Runtime/CUDA/memory.h"
#include "../flang_rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
-#include "../flang_rt/terminator.h"
-#include "../terminator.h"
-#include "flang/Runtime/CUDA/common.h"
#include "cuda_runtime.h"
>From f34605a1f51d82cb268fbf8553cfde502579e83b Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 15 Nov 2024 21:12:46 +0100
Subject: [PATCH 39/58] Post-merge fixes
---
flang/include/flang/Semantics/semantics.h | 1 -
flang/include/flang/Tools/CrossToolHelpers.h | 2 --
flang/tools/bbc/bbc.cpp | 4 ----
3 files changed, 7 deletions(-)
diff --git a/flang/include/flang/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h
index 022c7f085170c1..2ea6e04369d43d 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -11,7 +11,6 @@
#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"
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h
index 30e72c4991c1d1..e819a448ceb7d4 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -14,9 +14,7 @@
#define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
#include "flang/Common/LangOptions.h"
-#include "flang/Common/MathOptionsBase.h"
#include "flang/Frontend/CodeGenOptions.h"
-#include "flang/Frontend/LangOptions.h"
#include "flang/Support/MathOptionsBase.h"
#include <cstdint>
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index bdfa3f68315066..3881c4a9e5a2d7 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -14,11 +14,7 @@
///
//===----------------------------------------------------------------------===//
-#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/TargetOptions.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/PFTBuilder.h"
>From e85d9f1af66e06f89897189c93109136f8384eed Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 15 Nov 2024 23:20:37 +0100
Subject: [PATCH 40/58] Post-merge fixes
---
flang-rt/CMakeLists.txt | 4 +-
flang-rt/README.md | 42 +++++++++----------
flang-rt/test/lit.cfg.py | 2 +-
.../flang/Frontend/CompilerInvocation.h | 2 +-
flang/include/flang/Semantics/semantics.h | 1 -
flang/include/flang/Tools/CrossToolHelpers.h | 2 +-
flang/tools/bbc/bbc.cpp | 2 +-
.../modules/LLVMExternalProjectUtils.cmake | 6 +--
llvm/runtimes/CMakeLists.txt | 2 +-
9 files changed, 31 insertions(+), 32 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index dbe75d832d0aa6..e8d83210386c87 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -73,8 +73,8 @@ if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSIO
endif()
if (LLVM_TREE_AVAILABLE)
- # Despite Clang in the name, get_clang_resource_dir does not depend on Clang being added to the build
- # flang-new uses the same resource dir as clang.
+ # 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_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
get_clang_resource_dir(FLANG_RT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the install prefix itself
diff --git a/flang-rt/README.md b/flang-rt/README.md
index 54e23f7e07926b..4e1e33217e89fe 100644
--- a/flang-rt/README.md
+++ b/flang-rt/README.md
@@ -65,7 +65,7 @@ cmake -S <path-to-llvm-project>/llvm \
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-new --target=<target-triple>`, add more triples to
+cross-compilation via `flang --target=<target-triple>`, add more triples to
`LLVM_RUNTIME_TARGETS`, such as
`-DLLVM_RUNTIME_TARGETS="default;aarch64-linux-gnu"`.
@@ -84,7 +84,7 @@ Instead of building Clang and Flang from scratch, the Runtime-only 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-new` built from the same Git commit as
+`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.
@@ -94,12 +94,12 @@ 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>/runtimes \
- -GNinja \
- -DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
- -DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir>/bin/flang-new \
- -DCMAKE_Fortran_COMPILER_WORKS=yes \
- -DLLVM_ENABLE_RUNTIMES=flang-rt \
+cmake -S <path-to-llvm-project>/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 \
...
```
@@ -116,19 +116,19 @@ driver using the `-L` option.
A more complete build configuration could be the following:
```bash
-cmake -S <path-to-llvm-project>/runtimes \
- -GNinja \
- -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_INSTALL_PREFIX="${HOME}/local" \
- -DLLVM_ENABLE_RUNTIMES="compiler-rt;flang-rt" \
- -DCMAKE_C_COMPILER=gcc \
- -DCMAKE_CXX_COMPILER=g++ \
- -DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
- -DLLVM_DIR=<path-to-llvm-builddir>/lib/cmake/llvm \
- -DClang_DIR=<path-to-llvm-builddir>/lib/cmake/clang \
- -DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir-or-installprefix>/bin/flang-new \
- -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-linux-gnu \
- -DLLVM_RUNTIMES_TARGET=x86_64-linux-gnu \
+cmake -S <path-to-llvm-project>/runtimes \
+ -GNinja \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX="${HOME}/local" \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt;flang-rt" \
+ -DCMAKE_C_COMPILER=gcc \
+ -DCMAKE_CXX_COMPILER=g++ \
+ -DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
+ -DLLVM_DIR=<path-to-llvm-builddir>/lib/cmake/llvm \
+ -DClang_DIR=<path-to-llvm-builddir>/lib/cmake/clang \
+ -DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir-or-installprefix>/bin/flang \
+ -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-linux-gnu \
+ -DLLVM_RUNTIMES_TARGET=x86_64-linux-gnu \
...
```
diff --git a/flang-rt/test/lit.cfg.py b/flang-rt/test/lit.cfg.py
index 1c3a08b3ae75b7..7c330a38671aab 100644
--- a/flang-rt/test/lit.cfg.py
+++ b/flang-rt/test/lit.cfg.py
@@ -64,7 +64,7 @@
tools = [
ToolSubst(
"%flang",
- command=FindTool("flang-new"),
+ command=FindTool("flang"),
extra_args=isysroot_flag,
unresolved="fatal",
)
diff --git a/flang/include/flang/Frontend/CompilerInvocation.h b/flang/include/flang/Frontend/CompilerInvocation.h
index 50d908d0832024..60a43c67e84800 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"
@@ -21,6 +20,7 @@
#include "flang/Lower/LoweringOptions.h"
#include "flang/Parser/parsing.h"
#include "flang/Semantics/semantics.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/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h
index 09393775f56c2d..4e3842ba48a75f 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -11,7 +11,6 @@
#include "scope.h"
#include "symbol.h"
-#include "flang/Common/LangOptions.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h
index 9e22bdc50a6c99..76b938c3a283d8 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -13,8 +13,8 @@
#ifndef FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
#define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
-#include "flang/Common/LangOptions.h"
#include "flang/Frontend/CodeGenOptions.h"
+#include "flang/Support/LangOptions.h"
#include "flang/Support/MathOptionsBase.h"
#include <cstdint>
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index 3881c4a9e5a2d7..6aeec5e4b07b05 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -14,7 +14,6 @@
///
//===----------------------------------------------------------------------===//
-#include "flang/Common/LangOptions.h"
#include "flang/Frontend/TargetOptions.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/PFTBuilder.h"
@@ -38,6 +37,7 @@
#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"
diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index f49ce19b3f845c..e89f25018c6fd1 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -92,7 +92,7 @@ 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-new)
+ 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)
@@ -144,7 +144,7 @@ function(llvm_ExternalProject_Add name source_dir)
set(CLANG_IN_TOOLCHAIN On)
endif()
- if(flang-new IN_LIST TOOLCHAIN_TOOLS)
+ if(flang IN_LIST TOOLCHAIN_TOOLS)
set(FLANG_IN_TOOLCHAIN On)
endif()
@@ -231,7 +231,7 @@ function(llvm_ExternalProject_Add name source_dir)
endif()
endif()
if(FLANG_IN_TOOLCHAIN)
- list(APPEND compiler_args -DCMAKE_Fortran_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/flang-new${CMAKE_EXECUTABLE_SUFFIX})
+ 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)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index d47e09eb977b6f..e68518402aaf6d 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -472,7 +472,7 @@ if(build_runtimes)
foreach(dep FileCheck
clang
clang-offload-packager
- flang-new
+ flang
count
lld
lli
>From 90ae3d1aa4e228b64be7932da9b57032c5d573f7 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Sun, 24 Nov 2024 06:04:09 +0100
Subject: [PATCH 41/58] Compile-fix of CUDA version
---
flang-rt/lib/CufRuntime/kernel.cpp | 2 +-
flang-rt/lib/CufRuntime/registration.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang-rt/lib/CufRuntime/kernel.cpp b/flang-rt/lib/CufRuntime/kernel.cpp
index 9e6f24cee157b1..c6f03dd29dec87 100644
--- a/flang-rt/lib/CufRuntime/kernel.cpp
+++ b/flang-rt/lib/CufRuntime/kernel.cpp
@@ -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-rt/lib/CufRuntime/registration.cpp b/flang-rt/lib/CufRuntime/registration.cpp
index 96dd68204bdf18..8253288f886c0d 100644
--- a/flang-rt/lib/CufRuntime/registration.cpp
+++ b/flang-rt/lib/CufRuntime/registration.cpp
@@ -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"
>From 838bbaa0efb7e090a42be9e15561e405e8a20a93 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Sun, 24 Nov 2024 21:52:07 +0100
Subject: [PATCH 42/58] Build PTX .a library
---
.../cmake/modules/AddFlangRTOffload.cmake | 26 ++++++++++++-------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/flang-rt/cmake/modules/AddFlangRTOffload.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
index 864e6ce9190802..42d47d5d546708 100644
--- a/flang-rt/cmake/modules/AddFlangRTOffload.cmake
+++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
@@ -42,21 +42,27 @@ macro(enable_cuda_compilation name files)
"${CUDA_COMPILE_OPTIONS}"
)
- if (EXISTS "${FLANG_RT_LIBCUDACXX_PATH}/include")
- # When using libcudacxx headers files, we have to use them
- # for all files of F18 runtime.
- include_directories(AFTER ${FLANG_RT_LIBCUDACXX_PATH}/include)
- add_compile_definitions(RT_USE_LIBCUDACXX=1)
- endif()
+ # 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>")
- # Add an OBJECT library consisting of CUDA PTX.
- add_flangrt_library(${name}PTX OBJECT ${files})
- set_property(TARGET ${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
+ # Apply configuration options
if (FLANG_RT_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
- target_compile_definitions(${name}PTX
+ target_compile_definitions(obj.${name}PTX
PRIVATE FLANG_RT_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")
+ target_include_directories(obj.${name}PTX AFTER PRIVATE "${FLANG_RT_LIBCUDACXX_PATH}/include")
+ target_compile_definitions(obj.${name}PTX PRIVATE RT_USE_LIBCUDACXX=1)
+ endif ()
endif()
endmacro()
>From 4299d1e131df65edc4a9e8489fec8322e9f426e7 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 25 Nov 2024 06:39:59 +0100
Subject: [PATCH 43/58] Add no GPU support comment
---
flang-rt/CMakeLists.txt | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index e8d83210386c87..579e69462cc186 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -102,19 +102,23 @@ endif ()
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(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")
-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')")
+ # 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')"
+ )
else ()
message(FATAL_ERROR "Invalid value '${FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT}' for FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT; must be empty, 'CUDA', or 'OpenMP'")
endif ()
>From 0ff144ba1317dd98f8c09d8f8859caf623d5fc0d Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 25 Nov 2024 06:48:12 +0100
Subject: [PATCH 44/58] Add IBM xlc support
---
flang-rt/cmake/modules/AddFlangRT.cmake | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index a06e322f2be973..63c691ee812e58 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -74,6 +74,10 @@ function (add_flangrt_library name)
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 ()
# Flang-rt's public headers
>From c0d60bec11fc6da43867174edc2bde8f68902aef Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 25 Nov 2024 07:25:15 +0100
Subject: [PATCH 45/58] Fix included file case
---
flang/lib/Optimizer/Transforms/CUFOpConversion.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp b/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
index eb2e0a3f511575..5a52a7cadc5c9d 100644
--- a/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "flang/Optimizer/Transforms/CufOpConversion.h"
+#include "flang/Optimizer/Transforms/CUFOpConversion.h"
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
#include "flang/Optimizer/CodeGen/TypeConverter.h"
#include "flang/Optimizer/Dialect/CUF/CUFOps.h"
@@ -15,7 +15,6 @@
#include "flang/Optimizer/HLFIR/HLFIROps.h"
#include "flang/Optimizer/Support/DataLayout.h"
#include "flang/Optimizer/Transforms/CUFCommon.h"
-#include "flang/Optimizer/Transforms/CUFOpConversion.h"
#include "flang/Runtime/CUDA/allocatable.h"
#include "flang/Runtime/CUDA/common.h"
#include "flang/Runtime/CUDA/descriptor.h"
>From f14a662c77892b084f8c18006ce073cf68c9bfc2 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 28 Nov 2024 04:19:36 +0100
Subject: [PATCH 46/58] Disable exceptions for CUDA as well
---
flang-rt/cmake/modules/AddFlangRT.cmake | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index 63c691ee812e58..67311b4bd6746b 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -65,7 +65,10 @@ function (add_flangrt_library name)
set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/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>
@@ -80,6 +83,19 @@ function (add_flangrt_library name)
)
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")
>From 18fbeda3e3f646bb73e4799eec55856b7ab7b2b0 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 29 Nov 2024 08:04:36 +0100
Subject: [PATCH 47/58] Avoid LLVM_LIBRARY_OUTPUT_INTDIR
---
flang-rt/CMakeLists.txt | 11 ++++++++++-
flang-rt/test/Driver/ctofortran.f90 | 8 ++++----
flang-rt/test/Driver/exec.f90 | 4 ++--
flang-rt/test/lit.cfg.py | 2 ++
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 579e69462cc186..29191b6058f062 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -73,13 +73,22 @@ if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSIO
endif()
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_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
get_clang_resource_dir(FLANG_RT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the install prefix itself
else ()
- set(FLANG_RT_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
+ # In a runtimes build never write into LLVM's build dir. It might be reused
+ # for mutliple Flang-RT builds (e.g. Debug/Release). Instead create our own
+ # library directory.
+ #
+ # TODO: Support multi-config generators
+ set(FLANG_RT_BUILD_LIB_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
set(FLANG_RT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
endif ()
diff --git a/flang-rt/test/Driver/ctofortran.f90 b/flang-rt/test/Driver/ctofortran.f90
index 78eac32133b18e..d8b326cef26d0d 100644
--- a/flang-rt/test/Driver/ctofortran.f90
+++ b/flang-rt/test/Driver/ctofortran.f90
@@ -1,7 +1,7 @@
! UNSUPPORTED: system-windows
! 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: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang %libdir | FileCheck %s
!--- ffile.f90
program fmain
@@ -71,16 +71,16 @@ end subroutine foo
FFILE=$2
CFILE=$3
FLANG=$4
-shift 4
+LIBDIR=$5
+shift 5
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
+ $FLANG $FLAGS $FFILE $TMPDIR/cfile.o -o $TMPDIR/ctofortran -L"${LIBDIR}"
$TMPDIR/ctofortran # should print "PASS"
else
# No clang compiler, just pass by default
diff --git a/flang-rt/test/Driver/exec.f90 b/flang-rt/test/Driver/exec.f90
index 372f6d8a8d7bfd..90796d902cc6b5 100644
--- a/flang-rt/test/Driver/exec.f90
+++ b/flang-rt/test/Driver/exec.f90
@@ -1,7 +1,7 @@
! 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: %flang -L"%libdir" %s -o %t
+! RUN: env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:%libdir" %t | FileCheck %s
! RUN: rm -f %t
! CHECK: Hello, World!
diff --git a/flang-rt/test/lit.cfg.py b/flang-rt/test/lit.cfg.py
index 7c330a38671aab..d859194b50703d 100644
--- a/flang-rt/test/lit.cfg.py
+++ b/flang-rt/test/lit.cfg.py
@@ -70,6 +70,8 @@
)
]
+tools.append(ToolSubst("%libdir", command=config.flangrt_build_lib_dir, unresolved="fatal"))
+
# 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.
libruntime = os.path.join(config.flangrt_build_lib_dir, "libflang_rt.a")
>From 4ef75088f12d3241dd22c6c9830bae000e356176 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 29 Nov 2024 08:30:59 +0100
Subject: [PATCH 48/58] Add CufRuntime target
---
flang-rt/lib/CufRuntime/CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/flang-rt/lib/CufRuntime/CMakeLists.txt b/flang-rt/lib/CufRuntime/CMakeLists.txt
index 6cb6cbbad7bbc0..1b4b2869e5aca4 100644
--- a/flang-rt/lib/CufRuntime/CMakeLists.txt
+++ b/flang-rt/lib/CufRuntime/CMakeLists.txt
@@ -6,6 +6,9 @@
#
#===------------------------------------------------------------------------===#
+# Phony build target that does not include the CUDA version.
+add_custom_target(CufRuntime)
+
# 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.
@@ -19,6 +22,7 @@ add_flangrt_library(${CUFRT_LIBNAME}
memory.cpp
registration.cpp
)
+add_dependencies(CufRuntime ${CUFRT_LIBNAME})
target_include_directories(${CUFRT_LIBNAME} PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
if (BUILD_SHARED_LIBS)
>From d91ea5f8356db26c8c55e499ae8913eb204a3ade Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Sun, 1 Dec 2024 06:28:42 +0100
Subject: [PATCH 49/58] Add -lcudart for CUDA mode
---
flang-rt/test/Driver/ctofortran.f90 | 27 +++----------------
flang-rt/test/Driver/exec.f90 | 2 +-
flang-rt/test/Runtime/no-cpp-dep.c | 6 +----
flang-rt/test/lit.cfg.py | 40 +++++++++++++++++++++--------
flang-rt/test/lit.site.cfg.py.in | 1 +
5 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/flang-rt/test/Driver/ctofortran.f90 b/flang-rt/test/Driver/ctofortran.f90
index d8b326cef26d0d..9cf7571ffd2cb6 100644
--- a/flang-rt/test/Driver/ctofortran.f90
+++ b/flang-rt/test/Driver/ctofortran.f90
@@ -1,7 +1,9 @@
! UNSUPPORTED: system-windows
+
! RUN: split-file %s %t
-! RUN: chmod +x %t/runtest.sh
-! RUN: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang %libdir | FileCheck %s
+! RUN: %clang -c %t/cfile.c -o %t/cfile.o
+! RUN: %flang -L"%libdir" %deplibs %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
@@ -65,24 +67,3 @@ end subroutine foo
foo(desc);
return;
}
-!--- runtest.sh
-#!/bin/bash
-TMPDIR=$1
-FFILE=$2
-CFILE=$3
-FLANG=$4
-LIBDIR=$5
-shift 5
-FLAGS="$*"
-BINDIR=`dirname $FLANG`
-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 -L"${LIBDIR}"
- $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 90796d902cc6b5..57f393e936df56 100644
--- a/flang-rt/test/Driver/exec.f90
+++ b/flang-rt/test/Driver/exec.f90
@@ -1,6 +1,6 @@
! Verify that flang can correctly build executables.
-! RUN: %flang -L"%libdir" %s -o %t
+! RUN: %flang -L"%libdir" %s %deplibs -o %t
! RUN: env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:%libdir" %t | FileCheck %s
! RUN: rm -f %t
diff --git a/flang-rt/test/Runtime/no-cpp-dep.c b/flang-rt/test/Runtime/no-cpp-dep.c
index 510816a07967ab..9880afc2749734 100644
--- a/flang-rt/test/Runtime/no-cpp-dep.c
+++ b/flang-rt/test/Runtime/no-cpp-dep.c
@@ -5,13 +5,9 @@ a C compiler.
UNSUPPORTED: system-windows
-FIXME: This currently fails with CUDA-enabled flang-rt because it needs
- to link libcudart.
-
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
-RUN: %cc -std=c99 %s -I%include %libruntime -lm \
+RUN: %cc -std=c99 %s -I%include %libruntime -lm %deplibs \
RUN: %if system-aix %{-lpthread %}
-RUN: rm a.out
*/
#include "flang/Runtime/entry-names.h"
diff --git a/flang-rt/test/lit.cfg.py b/flang-rt/test/lit.cfg.py
index d859194b50703d..2b28431760dcf4 100644
--- a/flang-rt/test/lit.cfg.py
+++ b/flang-rt/test/lit.cfg.py
@@ -1,10 +1,14 @@
# -*- 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.
@@ -67,22 +71,36 @@
command=FindTool("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)
-tools.append(ToolSubst("%libdir", command=config.flangrt_build_lib_dir, unresolved="fatal"))
+# Let tests find LLVM's standard tools (FileCheck, split-file, not, ...)
+llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
+
+# Library path of libflang_rt.a
+config.substitutions.append(("%libdir", config.flangrt_build_lib_dir))
# 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.
libruntime = os.path.join(config.flangrt_build_lib_dir, "libflang_rt.a")
include = os.path.join(config.flang_source_dir, "include")
-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"))
-
-# Let tests find LLVM's standard tools (FileCheck, split-file, not, ...)
-llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
+config.substitutions.append(("%libruntime", libruntime))
+config.substitutions.append(("%include", include))
-llvm_config.add_tool_substitutions(tools)
+# Additional library depedendencies the that flang driver does not add itself.
+deplibs = []
+if config.flangrt_experimental_offload_support == "CUDA":
+ deplibs.append('-lcudart')
+config.substitutions.append(("%deplibs", shjoin(deplibs)))
diff --git a/flang-rt/test/lit.site.cfg.py.in b/flang-rt/test/lit.site.cfg.py.in
index 664a75bdc7b9e6..0110267c16f6f8 100644
--- a/flang-rt/test/lit.site.cfg.py.in
+++ b/flang-rt/test/lit.site.cfg.py.in
@@ -7,6 +7,7 @@ config.flang_source_dir = "@FLANG_SOURCE_DIR@"
config.flangrt_source_dir = "@FLANG_RT_SOURCE_DIR@"
config.flangrt_binary_test_dir = os.path.dirname(__file__)
config.flangrt_build_lib_dir = "@FLANG_RT_BUILD_LIB_DIR@"
+config.flangrt_experimental_offload_support = "@FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT@"
config.cc = "@CMAKE_C_COMPILER@"
config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@")
>From e2670143888bb5e549a795e1cbdbe6a212e2382b Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Sun, 1 Dec 2024 06:31:24 +0100
Subject: [PATCH 50/58] flangrt to flang_rt in Python code
---
flang-rt/test/NonGtestUnit/lit.cfg.py | 2 +-
flang-rt/test/NonGtestUnit/lit.site.cfg.py.in | 6 +++---
flang-rt/test/Unit/lit.cfg.py | 2 +-
flang-rt/test/Unit/lit.site.cfg.py.in | 6 +++---
flang-rt/test/lit.cfg.py | 8 ++++----
flang-rt/test/lit.site.cfg.py.in | 10 +++++-----
6 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/flang-rt/test/NonGtestUnit/lit.cfg.py b/flang-rt/test/NonGtestUnit/lit.cfg.py
index 20e28b0d3b55fd..4bee709b78f43f 100644
--- a/flang-rt/test/NonGtestUnit/lit.cfg.py
+++ b/flang-rt/test/NonGtestUnit/lit.cfg.py
@@ -16,7 +16,7 @@
# 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.flangrt_binary_test_dir
+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
index f68c87afdef812..8244b5b62d3aaf 100644
--- a/flang-rt/test/NonGtestUnit/lit.site.cfg.py.in
+++ b/flang-rt/test/NonGtestUnit/lit.site.cfg.py.in
@@ -3,12 +3,12 @@
import os
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.flangrt_source_dir = "@FLANG_RT_SOURCE_DIR@"
+config.flang_rt_source_dir = "@FLANG_RT_SOURCE_DIR@"
config.flangrt_binary_dir = "@FLANG_RT_BINARY_DIR@"
-config.flangrt_binary_test_dir = os.path.dirname(__file__)
+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.flangrt_source_dir, 'test', 'NonGtestUnit', 'lit.cfg.py'))
+lit_config.load_config(config, os.path.join(config.flang_rt_source_dir, 'test', 'NonGtestUnit', 'lit.cfg.py'))
diff --git a/flang-rt/test/Unit/lit.cfg.py b/flang-rt/test/Unit/lit.cfg.py
index e46a78584c0425..516bc653f413f4 100644
--- a/flang-rt/test/Unit/lit.cfg.py
+++ b/flang-rt/test/Unit/lit.cfg.py
@@ -15,7 +15,7 @@
# 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.flangrt_binary_test_dir
+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
index 1441aac0d0e45b..ed6dea07bcdde1 100644
--- a/flang-rt/test/Unit/lit.site.cfg.py.in
+++ b/flang-rt/test/Unit/lit.site.cfg.py.in
@@ -4,12 +4,12 @@ import os
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_build_mode = "@LLVM_BUILD_MODE@"
-config.flangrt_source_dir = "@FLANG_RT_SOURCE_DIR@"
+config.flang_rt_source_dir = "@FLANG_RT_SOURCE_DIR@"
config.flangrt_binary_dir = "@FLANG_RT_BINARY_DIR@"
-config.flangrt_binary_test_dir = os.path.dirname(__file__)
+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.flangrt_source_dir, 'test', 'Unit', 'lit.cfg.py'))
+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
index 2b28431760dcf4..8c21877a91888b 100644
--- a/flang-rt/test/lit.cfg.py
+++ b/flang-rt/test/lit.cfg.py
@@ -58,7 +58,7 @@ def shjoin(args, sep=' '):
# 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.flangrt_binary_test_dir
+config.test_exec_root = config.flang_rt_binary_test_dir
# On MacOS, -isysroot is needed to build binaries.
isysroot_flag = []
@@ -90,17 +90,17 @@ def shjoin(args, sep=' '):
llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
# Library path of libflang_rt.a
-config.substitutions.append(("%libdir", config.flangrt_build_lib_dir))
+config.substitutions.append(("%libdir", config.flang_rt_build_lib_dir))
# 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.
-libruntime = os.path.join(config.flangrt_build_lib_dir, "libflang_rt.a")
+libruntime = os.path.join(config.flang_rt_build_lib_dir, "libflang_rt.a")
include = os.path.join(config.flang_source_dir, "include")
config.substitutions.append(("%libruntime", libruntime))
config.substitutions.append(("%include", include))
# Additional library depedendencies the that flang driver does not add itself.
deplibs = []
-if config.flangrt_experimental_offload_support == "CUDA":
+if config.flang_rt_experimental_offload_support == "CUDA":
deplibs.append('-lcudart')
config.substitutions.append(("%deplibs", shjoin(deplibs)))
diff --git a/flang-rt/test/lit.site.cfg.py.in b/flang-rt/test/lit.site.cfg.py.in
index 0110267c16f6f8..a587bbf8dea06c 100644
--- a/flang-rt/test/lit.site.cfg.py.in
+++ b/flang-rt/test/lit.site.cfg.py.in
@@ -4,10 +4,10 @@ import sys
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.flang_source_dir = "@FLANG_SOURCE_DIR@"
-config.flangrt_source_dir = "@FLANG_RT_SOURCE_DIR@"
-config.flangrt_binary_test_dir = os.path.dirname(__file__)
-config.flangrt_build_lib_dir = "@FLANG_RT_BUILD_LIB_DIR@"
-config.flangrt_experimental_offload_support = "@FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT@"
+config.flang_rt_source_dir = "@FLANG_RT_SOURCE_DIR@"
+config.flang_rt_binary_test_dir = os.path.dirname(__file__)
+config.flang_rt_build_lib_dir = "@FLANG_RT_BUILD_LIB_DIR@"
+config.flang_rt_experimental_offload_support = "@FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT@"
config.cc = "@CMAKE_C_COMPILER@"
config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@")
@@ -15,4 +15,4 @@ 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.flangrt_source_dir, 'test', 'lit.cfg.py'))
+lit_config.load_config(config, os.path.join(config.flang_rt_source_dir, 'test', 'lit.cfg.py'))
>From 328631225055b9ef09b1368d7d7c80fbd1f2a565 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 5 Dec 2024 13:06:15 +0100
Subject: [PATCH 51/58] Post-merge fixes
---
flang/lib/Common/CMakeLists.txt | 1 -
flang/lib/Support/CMakeLists.txt | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index 978988c93d0f92..99f66c8f1f9775 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -5,7 +5,6 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
- ../Support/OpenMP-utils.cpp
add_flang_library(FortranCommon
binary-to-decimal.cpp
diff --git a/flang/lib/Support/CMakeLists.txt b/flang/lib/Support/CMakeLists.txt
index 98ed504e3c26f4..8ec756a0fad362 100644
--- a/flang/lib/Support/CMakeLists.txt
+++ b/flang/lib/Support/CMakeLists.txt
@@ -49,6 +49,7 @@ add_flang_library(FortranSupport
default-kinds.cpp
idioms.cpp
LangOptions.cpp
+ OpenMP-utils.cpp
Version.cpp
${version_inc}
>From 48e200a4078409a1a6aafa7a0453791725e2d6fb Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 5 Dec 2024 15:24:12 +0100
Subject: [PATCH 52/58] Path to LLVM dev tools
---
flang-rt/CMakeLists.txt | 5 ++++-
flang-rt/test/CMakeLists.txt | 2 --
flang-rt/unittests/Runtime/CMakeLists.txt | 5 +++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt
index 29191b6058f062..d39c39e0caacb3 100644
--- a/flang-rt/CMakeLists.txt
+++ b/flang-rt/CMakeLists.txt
@@ -65,13 +65,16 @@ include(FlangCommon)
############################
# Setting these variables from an LLVM build is sufficient that flang-rt can
-# construct the output paths, so it can behave as if it were in-tree here.
+# construct the output paths, so it can behave as if it was in-tree here.
set(LLVM_TREE_AVAILABLE OFF)
if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
# This is a bootstap build
set(LLVM_TREE_AVAILABLE ON)
endif()
+# Path to LLVM development tools (FileCheck, llvm-lit, not, ...)
+set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin")
+
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
diff --git a/flang-rt/test/CMakeLists.txt b/flang-rt/test/CMakeLists.txt
index 5dfd6ac35248c3..40aace9d93a804 100644
--- a/flang-rt/test/CMakeLists.txt
+++ b/flang-rt/test/CMakeLists.txt
@@ -16,8 +16,6 @@ llvm_canonicalize_cmake_booleans(
LLVM_ENABLE_PLUGINS
)
-set(FLANG_TOOLS_DIR ${FLANG_BINARY_DIR}/bin)
-
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
diff --git a/flang-rt/unittests/Runtime/CMakeLists.txt b/flang-rt/unittests/Runtime/CMakeLists.txt
index 899026f0cc44a5..7786a72e1ba13d 100644
--- a/flang-rt/unittests/Runtime/CMakeLists.txt
+++ b/flang-rt/unittests/Runtime/CMakeLists.txt
@@ -37,12 +37,13 @@ add_flangrt_unittest(RuntimeTests
Time.cpp
TemporaryStack.cpp
Transformational.cpp
+
LINK_LIBS
flang_rt.unittest
)
+message("${LLVM_TOOLS_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}")
+target_compile_definitions(RuntimeTests PRIVATE NOT_EXE="${LLVM_TOOLS_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}")
if (FLANG_RT_ENABLE_CUF)
-target_compile_definitions(FlangRuntimeTests PRIVATE NOT_EXE="$<TARGET_FILE:not>")
-
add_subdirectory(CUDA)
endif ()
>From 112eb04ed7613534d96b9b803f1780d7a332cb27 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 5 Dec 2024 15:48:16 +0100
Subject: [PATCH 53/58] Update docs
---
flang-rt/README.md | 60 +++++++++++++-------------
flang-rt/lib/CufRuntime/CMakeLists.txt | 9 ++--
flang/docs/GettingStarted.md | 27 ++++++------
3 files changed, 50 insertions(+), 46 deletions(-)
diff --git a/flang-rt/README.md b/flang-rt/README.md
index 4e1e33217e89fe..31e92f63afc06c 100644
--- a/flang-rt/README.md
+++ b/flang-rt/README.md
@@ -6,15 +6,15 @@
-->
-# Fortran Runtime (flang-rt)
+# Fortran Runtime (Flang-RT)
-Flang-rt is the runtime library for code emitted by the Flang compiler
+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
+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
@@ -34,31 +34,31 @@ Requirements:
### Bootstrap/In-Tree Build
The bootstrap build will first build Clang and Flang, then use these compilers
-to compile flang-rt. CMake will create a secondary build tree in
-configured with 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
+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>/llvm \
- -DNinja \
- -DLLVM_ENABLE_PROJECTS=flang \
- -DLLVM_ENABLE_RUNTIMES=flang-rt \
+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
+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>/llvm \
- -DNinja \
- -DCMAKE_BUILD_TYPE=Release \
- -DLLVM_ENABLE_PROJECTS="flang;openmp" \
+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" \
...
```
@@ -85,16 +85,16 @@ 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
+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:
+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>/runtimes \
+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 \
@@ -107,16 +107,16 @@ 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
+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
+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.
A more complete build configuration could be the following:
```bash
-cmake -S <path-to-llvm-project>/runtimes \
+cmake -S <path-to-llvm-project-source>/runtimes \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${HOME}/local" \
@@ -134,7 +134,7 @@ cmake -S <path-to-llvm-project>/runtimes \
## Configuration Option Reference
-Flang-rt has the followign configuration options. This is in
+Flang-RT has the followign configuration options. This is in
addition to the build options the LLVM_ENABLE_RUNTIMES mechanism and
CMake itself provide.
@@ -153,11 +153,11 @@ CMake itself provide.
* `FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT` (values: `"CUDA"`,`"OpenMP"`, `""` default: `""`)
- When set to `CUDA`, builds flang-rt with experimental support for GPU
+ 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
+ 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`.
@@ -170,7 +170,7 @@ CMake itself provide.
(no `CMAKE_CUDA_COMPILER`).
-### CUDA Support
+### Exprimental CUDA Support
With `-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`, the following
additional configuration options become available.
@@ -186,13 +186,13 @@ additional configuration options become available.
default.
-### OpenMP Offload Support
+### Exprimental 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 supporting.
+ 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/lib/CufRuntime/CMakeLists.txt b/flang-rt/lib/CufRuntime/CMakeLists.txt
index 5d6957fa6f85d7..f7589a54cabf1a 100644
--- a/flang-rt/lib/CufRuntime/CMakeLists.txt
+++ b/flang-rt/lib/CufRuntime/CMakeLists.txt
@@ -6,9 +6,6 @@
#
#===------------------------------------------------------------------------===#
-# Phony build target that does not include the CUDA version.
-add_custom_target(CufRuntime)
-
# 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.
@@ -23,7 +20,6 @@ add_flangrt_library(${CUFRT_LIBNAME}
memory.cpp
registration.cpp
)
-add_dependencies(CufRuntime ${CUFRT_LIBNAME})
target_include_directories(${CUFRT_LIBNAME} PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
if (BUILD_SHARED_LIBS)
@@ -37,3 +33,8 @@ target_link_libraries(${CUFRT_LIBNAME}
flang_rt
${CUDA_RT_TARGET}
)
+
+# Phony build target that does not include the CUDA version.
+add_custom_target(CufRuntime)
+add_dependencies(CufRuntime ${CUFRT_LIBNAME})
+
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index 9061a00c2de250..81d6552fa986aa 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -197,7 +197,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.
-#### Building out-of-tree (Runtime-only build)
+#### Building out-of-tree (runtime-only build)
##### CUDA build
Clang with NVPTX backend and NVCC compilers are supported.
@@ -209,7 +209,7 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DLLVM_ENABLE_RUNTIMES=flang_rt \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
@@ -217,7 +217,7 @@ cmake \
-DCMAKE_CUDA_COMPILER=clang \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
../runtimes/
-make -j`nprocs` flang_rt
+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)
@@ -232,7 +232,7 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DLLVM_ENABLE_RUNTIMES=flang_rt \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
@@ -241,7 +241,7 @@ cmake \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
../runtimes/
-make -j`nprocs` flang_rt
+make flang-rt
```
Note that `nvcc` might limit support to certain
@@ -260,7 +260,7 @@ build config:
For example:
```bash
- -DLLVM_ENABLE_RUNTIMES=flang_rt \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=clang \
@@ -272,7 +272,7 @@ For example:
Or:
```bash
- -DLLVM_ENABLE_RUNTIMES=flang_rt \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
-DCMAKE_CUDA_ARCHITECTURES=80 \
-DCMAKE_C_COMPILER=gcc \
@@ -282,8 +282,11 @@ Or:
../llvm
```
-Normal `make -j`nprocs` check-flang` will work with such CMake configuration.
-Consider a lower value instead of `nprocs` appropriate to the available RAM.
+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.
@@ -295,14 +298,14 @@ mkdir build_flang_runtime
cd build_flang_runtime
cmake \
- -DLLVM_ENABLE_RUNTIMES=flang_rt \
+ -DLLVM_ENABLE_RUNTIMES=flang-rt \
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT="OpenMP" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
- -DFLANG_RT_DEVICE_ARCHITECTURES="all" \
+ -DFLANG_RT_DEVICE_ARCHITECTURES=all \
../runtimes/
-make -j`nprocs` flang_rt
+make flang-rt
```
The result of the build is a "device-only" library, i.e. the host
>From 949c03015e92ddb4ff3d4dd1fb4fde0e5ea44901 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Thu, 5 Dec 2024 16:01:08 +0100
Subject: [PATCH 54/58] Cleanup
---
flang-rt/cmake/modules/AddFlangRT.cmake | 8 +-
.../cmake/modules/AddFlangRTOffload.cmake | 2 +-
flang-rt/lib/CMakeLists.txt | 1 +
flang-rt/lib/CufRuntime/CMakeLists.txt | 3 +-
flang-rt/lib/CufRuntime/allocatable.cpp | 2 +-
flang-rt/lib/CufRuntime/memory.cpp | 3 +-
.../lib/FortranFloat128Math/CMakeLists.txt | 2 +-
flang-rt/lib/flang_rt/CMakeLists.txt | 16 +-
flang-rt/lib/flang_rt/io-api-minimal.cpp | 2 +-
flang-rt/test/CMakeLists.txt | 14 +-
flang-rt/test/Driver/exec.f90 | 1 -
flang-rt/unittests/CMakeLists.txt | 8 +-
flang-rt/unittests/Evaluate/CMakeLists.txt | 10 +-
flang-rt/unittests/Runtime/CMakeLists.txt | 5 +-
flang/lib/CMakeLists.txt | 2 +-
flang/lib/Common/CMakeLists.txt | 3 -
flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +-
flang/lib/Support/CMakeLists.txt | 5 +-
flang/lib/Testing/README.md | 54 +++----
flang/module/iso_fortran_env_impl.f90 | 2 +-
flang/test/lit.site.cfg.py.in | 2 -
flang/unittests/Common/CMakeLists.txt | 13 --
flang/unittests/Common/FastIntSetTest.cpp | 105 -------------
flang/unittests/Decimal/CMakeLists.txt | 20 ---
flang/unittests/Decimal/quick-sanity-test.cpp | 145 ------------------
flang/unittests/Decimal/thorough-test.cpp | 89 -----------
flang/unittests/Evaluate/CMakeLists.txt | 2 +-
llvm/runtimes/CMakeLists.txt | 1 -
28 files changed, 72 insertions(+), 450 deletions(-)
delete mode 100644 flang/unittests/Common/CMakeLists.txt
delete mode 100644 flang/unittests/Common/FastIntSetTest.cpp
delete mode 100644 flang/unittests/Decimal/CMakeLists.txt
delete mode 100644 flang/unittests/Decimal/quick-sanity-test.cpp
delete mode 100644 flang/unittests/Decimal/thorough-test.cpp
diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index 67311b4bd6746b..3cec4327c20f5f 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -1,4 +1,4 @@
-#===-- cmake/modules/AddFlangRT.cmake -------------------------------===#
+#===-- 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.
@@ -58,11 +58,11 @@ function (add_flangrt_library name)
add_library(${name} ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS})
if (ARG_INSTALL_WITH_TOOLCHAIN)
- set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Toolchain Libraries")
+ set_target_properties(${name} PROPERTIES FOLDER "Flang-RT/Toolchain Libraries")
elseif (ARG_OBJECT)
- set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Object Libraries")
+ set_target_properties(${name} PROPERTIES FOLDER "Flang-RT/Object Libraries")
else ()
- set_target_properties(${name} PROPERTIES FOLDER "Fortran Runtime/Libraries")
+ 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.
diff --git a/flang-rt/cmake/modules/AddFlangRTOffload.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
index 42d47d5d546708..84eabba05b49b9 100644
--- a/flang-rt/cmake/modules/AddFlangRTOffload.cmake
+++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake
@@ -1,4 +1,4 @@
-#===-- cmake/modules/AddFortranOffloadRuntime.txt --------------------------===#
+#===-- 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.
diff --git a/flang-rt/lib/CMakeLists.txt b/flang-rt/lib/CMakeLists.txt
index f0422f5e0a58b4..5d48043a7459a4 100644
--- a/flang-rt/lib/CMakeLists.txt
+++ b/flang-rt/lib/CMakeLists.txt
@@ -8,6 +8,7 @@
add_subdirectory(FortranFloat128Math)
add_subdirectory(flang_rt)
+
if (FLANG_RT_ENABLE_CUF)
add_subdirectory(CufRuntime)
endif()
diff --git a/flang-rt/lib/CufRuntime/CMakeLists.txt b/flang-rt/lib/CufRuntime/CMakeLists.txt
index f7589a54cabf1a..17256062d6787a 100644
--- a/flang-rt/lib/CufRuntime/CMakeLists.txt
+++ b/flang-rt/lib/CufRuntime/CMakeLists.txt
@@ -12,11 +12,10 @@
set(CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR})
add_flangrt_library(${CUFRT_LIBNAME}
- allocator.cpp
allocatable.cpp
+ allocator.cpp
descriptor.cpp
kernel.cpp
- memmove-function.cpp
memory.cpp
registration.cpp
)
diff --git a/flang-rt/lib/CufRuntime/allocatable.cpp b/flang-rt/lib/CufRuntime/allocatable.cpp
index 998ff33a542cc7..f6dd6bac734b75 100644
--- a/flang-rt/lib/CufRuntime/allocatable.cpp
+++ b/flang-rt/lib/CufRuntime/allocatable.cpp
@@ -8,7 +8,7 @@
#include "flang/Runtime/CUDA/allocatable.h"
#include "flang-rt/descriptor.h"
-#include "../assign-impl.h"
+#include "../flang_rt/assign-impl.h"
#include "../flang_rt/stat.h"
#include "../flang_rt/terminator.h"
#include "flang/Runtime/CUDA/common.h"
diff --git a/flang-rt/lib/CufRuntime/memory.cpp b/flang-rt/lib/CufRuntime/memory.cpp
index 48ff5411e6cc66..04d49fc3e4f85f 100644
--- a/flang-rt/lib/CufRuntime/memory.cpp
+++ b/flang-rt/lib/CufRuntime/memory.cpp
@@ -7,9 +7,8 @@
//===----------------------------------------------------------------------===//
#include "flang/Runtime/CUDA/memory.h"
+#include "../flang_rt/assign-impl.h"
#include "../flang_rt/terminator.h"
-#include "../assign-impl.h"
-#include "../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/FortranFloat128Math/CMakeLists.txt b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
index b778b419b9c420..881f5f9d8212d4 100644
--- a/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
+++ b/flang-rt/lib/FortranFloat128Math/CMakeLists.txt
@@ -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 cannot build without libm")
endif()
else()
# We can use '__float128' version from libc, if it has them.
diff --git a/flang-rt/lib/flang_rt/CMakeLists.txt b/flang-rt/lib/flang_rt/CMakeLists.txt
index 257f1f0722308a..4b7315c2b4bd64 100644
--- a/flang-rt/lib/flang_rt/CMakeLists.txt
+++ b/flang-rt/lib/flang_rt/CMakeLists.txt
@@ -84,13 +84,13 @@ set(host_sources
)
file(GLOB_RECURSE public_headers
- "${FLANG_RT_SOURCE_DIR}/include/flang/Runtime/*.h"
- "${FLANG_RT_SOURCE_DIR}/include/flang/Common/*.h"
+ "${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/Runtime/*.h"
- "${FLANG_RT_SOURCE_DIR}/lib/Common/*.h"
+ "${FLANG_RT_SOURCE_DIR}/lib/flang_rt/*.h"
+ "${FLANG_SOURCE_DIR}/lib/Common/*.h"
)
@@ -139,7 +139,7 @@ if (NOT WIN32)
else()
# Target for building all versions of the runtime
add_custom_target(flang_rt)
- set_target_properties(flang_rt PROPERTIES FOLDER "Fortran Runtime/Meta")
+ set_target_properties(flang_rt PROPERTIES FOLDER "Flang-RT/Meta")
function (add_win_flangrt_library libtype suffix msvc_lib)
set(name "flang_rt.${suffix}")
@@ -173,14 +173,14 @@ else()
# roadblocks:
#
# * Flang emits /DEFAULTLIB:flang_rt.dynamic.lib into
- # iso_fortran_env_impl.f90.obj. Since that file is itself part of
+ # 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 a exports file. A possible workaround
+ # __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 by be annotated
+ # C++ symbols and still requires global data symbols to be annotated
# manually.
#
#add_win_flangrt_library(SHARED dynamic MultiThreadedDLL)
diff --git a/flang-rt/lib/flang_rt/io-api-minimal.cpp b/flang-rt/lib/flang_rt/io-api-minimal.cpp
index 59093d8d45d079..3da01b87074659 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
index 40aace9d93a804..5ca07b66e4f9b5 100644
--- a/flang-rt/test/CMakeLists.txt
+++ b/flang-rt/test/CMakeLists.txt
@@ -39,22 +39,20 @@ if (TARGET FlangRTUnitTests)
)
endif ()
-set(FLANG_RT_TEST_DEPENDS
+
+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_custom_target(flang-rt-test-depends)
-set_target_properties(flang-rt-test-depends PROPERTIES FOLDER "Fortran Runtime/Meta")
-add_dependencies(flang-rt-test-depends ${FLANG_RT_TEST_DEPENDS})
-
-add_lit_testsuite(check-flang-rt "Running the flang-rt regression tests"
+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 "Fortran Runtime/Meta")
-
+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/exec.f90 b/flang-rt/test/Driver/exec.f90
index 57f393e936df56..b154270e01c43a 100644
--- a/flang-rt/test/Driver/exec.f90
+++ b/flang-rt/test/Driver/exec.f90
@@ -2,7 +2,6 @@
! RUN: %flang -L"%libdir" %s %deplibs -o %t
! RUN: env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:%libdir" %t | FileCheck %s
-! RUN: rm -f %t
! CHECK: Hello, World!
program hello
diff --git a/flang-rt/unittests/CMakeLists.txt b/flang-rt/unittests/CMakeLists.txt
index a15675e80473fa..aa2ce3aba0c4f8 100644
--- a/flang-rt/unittests/CMakeLists.txt
+++ b/flang-rt/unittests/CMakeLists.txt
@@ -16,8 +16,8 @@ if (NOT TARGET llvm_gtest)
build_gtest()
endif ()
-# LLVM's modified GTest depends on LLVM, but not all runtime projects using
-# GTest also add the include search path.
+# LLVM's modified GTest depends on LLVM, but not all sibling runtime projects
+# creating a llvm_gtest target also use target_include_directories.
target_include_directories(llvm_gtest PUBLIC "${LLVM_INCLUDE_DIR}" "${LLVM_MAIN_INCLUDE_DIR}")
# Required because LLVMSupport is compiled with this option (by default).
@@ -30,7 +30,7 @@ endif()
# Target that depends on all unittests
add_custom_target(FlangRTUnitTests)
-set_target_properties(FlangRTUnitTests PROPERTIES FOLDER "Fortran Runtime/Meta")
+set_target_properties(FlangRTUnitTests PROPERTIES FOLDER "Flang-RT/Meta")
function(add_flangrt_unittest_offload_properties target)
@@ -84,7 +84,7 @@ function(add_flangrt_nongtest_unittest test_name)
endif()
add_executable(${test_name}${suffix} ${ARG_UNPARSED_ARGUMENTS})
- set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Fortran Runtime/Tests/Unit")
+ set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Flang-RT/Tests/Unit")
target_include_directories(${test_name}${suffix} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
target_include_directories(${test_name}${suffix} PRIVATE "${FLANG_SOURCE_DIR}/include")
diff --git a/flang-rt/unittests/Evaluate/CMakeLists.txt b/flang-rt/unittests/Evaluate/CMakeLists.txt
index dd4b729f698cf6..15b813bcb19da1 100644
--- a/flang-rt/unittests/Evaluate/CMakeLists.txt
+++ b/flang-rt/unittests/Evaluate/CMakeLists.txt
@@ -8,12 +8,14 @@
add_flangrt_nongtest_unittest(reshape
reshape.cpp
-LINK_LIBS
- flang_rt.unittest
+
+ LINK_LIBS
+ flang_rt.unittest
)
add_flangrt_nongtest_unittest(ISO-Fortran-binding
ISO-Fortran-binding.cpp
-LINK_LIBS
- flang_rt.unittest
+
+ LINK_LIBS
+ flang_rt.unittest
)
diff --git a/flang-rt/unittests/Runtime/CMakeLists.txt b/flang-rt/unittests/Runtime/CMakeLists.txt
index 7786a72e1ba13d..32f12b14caca7a 100644
--- a/flang-rt/unittests/Runtime/CMakeLists.txt
+++ b/flang-rt/unittests/Runtime/CMakeLists.txt
@@ -38,10 +38,9 @@ add_flangrt_unittest(RuntimeTests
TemporaryStack.cpp
Transformational.cpp
-LINK_LIBS
- flang_rt.unittest
+ LINK_LIBS
+ flang_rt.unittest
)
-message("${LLVM_TOOLS_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}")
target_compile_definitions(RuntimeTests PRIVATE NOT_EXE="${LLVM_TOOLS_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}")
if (FLANG_RT_ENABLE_CUF)
diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt
index a7cdb4819d7252..0ab7d1c888df96 100644
--- a/flang/lib/CMakeLists.txt
+++ b/flang/lib/CMakeLists.txt
@@ -1,9 +1,9 @@
add_subdirectory(Common)
+add_subdirectory(Support)
add_subdirectory(Evaluate)
add_subdirectory(Lower)
add_subdirectory(Parser)
add_subdirectory(Semantics)
-add_subdirectory(Support)
add_subdirectory(Frontend)
add_subdirectory(FrontendTool)
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index 99f66c8f1f9775..e5d9c9eb8c3f19 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -9,7 +9,4 @@
add_flang_library(FortranCommon
binary-to-decimal.cpp
decimal-to-binary.cpp
-
- LINK_LIBS
- MLIRIR
)
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 813aed16787aba..db54913274981b 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -751,7 +751,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 flang-rt, 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/lib/Support/CMakeLists.txt b/flang/lib/Support/CMakeLists.txt
index 8ec756a0fad362..a2badde61dfe64 100644
--- a/flang/lib/Support/CMakeLists.txt
+++ b/flang/lib/Support/CMakeLists.txt
@@ -54,5 +54,8 @@ add_flang_library(FortranSupport
${version_inc}
LINK_COMPONENTS
- Support
+ Support
+
+ LINK_LIBS
+ MLIRIR
)
diff --git a/flang/lib/Testing/README.md b/flang/lib/Testing/README.md
index 5203465f7f2fa9..278de092ee5feb 100644
--- a/flang/lib/Testing/README.md
+++ b/flang/lib/Testing/README.md
@@ -1,27 +1,27 @@
-Files in this directory are used by Flang (the compiler) and flang-rt
-(the runtime library for Flang-compiled programs). They must be compatible by
-both. For definitions used only by Flang, consider
-`flang/{lib,include/flang}/Support` instead. For definitions used only by
-the runtime, consider `flang-rt/{lib,include/flang-rt}/flang_rt`.
-
-The requirements for common code include:
-
- * No dependence to LLVM, including LLVMSupport.
-
- * No link-dependence to the C++ runtime. This means that e.g. `std::string`
- cannot be used.
-
- * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used
- instead.
-
- * Preprocessor macros from `config.h` and CMake
- `(target/add)_compile_definitions` must be defined by both build scripts.
- See `flang/cmake/modules/FlangCommon.cmake`.
-
- * Some header files are included from `.c` files.
- `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C.
-
- * Global declarations may need to be annotated using definitions from
- `api-attrs.h`.
-
- * The `Runtime` component is header-only.
+Files in this directory are used by Flang (the compiler) and flang-rt
+(the runtime library for Flang-compiled programs). They must be compatible by
+both. For definitions used only by Flang, consider
+`flang/{lib,include/flang}/Support` instead. For definitions used only by
+the runtime, consider `flang-rt/{lib,include/flang-rt}/flang_rt`.
+
+The requirements for common code include:
+
+ * No dependence to LLVM, including LLVMSupport.
+
+ * No link-dependence to the C++ runtime. This means that e.g. `std::string`
+ cannot be used.
+
+ * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used
+ instead.
+
+ * Preprocessor macros from `config.h` and CMake
+ `(target/add)_compile_definitions` must be defined by both build scripts.
+ See `flang/cmake/modules/FlangCommon.cmake`.
+
+ * Some header files are included from `.c` files.
+ `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C.
+
+ * Global declarations may need to be annotated using definitions from
+ `api-attrs.h`.
+
+ * The `Runtime` component is header-only.
diff --git a/flang/module/iso_fortran_env_impl.f90 b/flang/module/iso_fortran_env_impl.f90
index 782be81791af2e..361191797a39a0 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). Hence, this file is also used by Flang-RT.
+! (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.site.cfg.py.in b/flang/test/lit.site.cfg.py.in
index 65864302fb7aec..1d26f99fa873de 100644
--- a/flang/test/lit.site.cfg.py.in
+++ b/flang/test/lit.site.cfg.py.in
@@ -10,11 +10,9 @@ 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@"
diff --git a/flang/unittests/Common/CMakeLists.txt b/flang/unittests/Common/CMakeLists.txt
deleted file mode 100644
index 709a02f5c789c7..00000000000000
--- a/flang/unittests/Common/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-#===-- unittests/Common/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(FlangCommonTests
- FastIntSetTest.cpp
- LINK_LIBS
- flang_rt.unittest
-)
diff --git a/flang/unittests/Common/FastIntSetTest.cpp b/flang/unittests/Common/FastIntSetTest.cpp
deleted file mode 100644
index bd1b953fa16631..00000000000000
--- a/flang/unittests/Common/FastIntSetTest.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//===-- flang/unittests/Common/FastIntSetTest.cpp ---------------*- 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 "gtest/gtest.h"
-#include "flang/Common/fast-int-set.h"
-#include <optional>
-
-TEST(FastIntSetTests, Sanity) {
- static constexpr int N{100};
- Fortran::common::FastIntSet<N> set;
-
- ASSERT_FALSE(set.IsValidValue(-1));
- ASSERT_TRUE(set.IsValidValue(0));
- ASSERT_TRUE(set.IsValidValue(N - 1));
- ASSERT_FALSE(set.IsValidValue(N));
- ASSERT_TRUE(set.IsEmpty());
- ASSERT_EQ(set.size(), 0);
- ASSERT_FALSE(set.Contains(0));
- ASSERT_FALSE(set.Contains(N - 1));
-
- ASSERT_TRUE(set.Add(0));
- ASSERT_FALSE(set.IsEmpty());
- ASSERT_EQ(set.size(), 1);
- ASSERT_TRUE(set.Contains(0));
-
- ASSERT_TRUE(set.Add(0)); // duplicate
- ASSERT_EQ(set.size(), 1);
- ASSERT_TRUE(set.Contains(0));
-
- ASSERT_TRUE(set.Remove(0));
- ASSERT_TRUE(set.IsEmpty());
- ASSERT_EQ(set.size(), 0);
- ASSERT_FALSE(set.Contains(0));
-
- ASSERT_FALSE(set.Add(N));
- ASSERT_TRUE(set.IsEmpty());
- ASSERT_EQ(set.size(), 0);
- ASSERT_FALSE(set.Contains(N));
-
- ASSERT_TRUE(set.Add(N - 1));
- ASSERT_FALSE(set.IsEmpty());
- ASSERT_EQ(set.size(), 1);
- ASSERT_TRUE(set.Contains(N - 1));
-
- std::optional<int> x;
- x = set.PopValue();
- ASSERT_TRUE(x.has_value());
- ASSERT_EQ(*x, N - 1);
- ASSERT_TRUE(set.IsEmpty());
- ASSERT_EQ(set.size(), 0);
-
- x = set.PopValue();
- ASSERT_FALSE(x.has_value());
-
- for (int j{0}; j < N; ++j) {
- ASSERT_TRUE(set.Add(j)) << j;
- }
- ASSERT_FALSE(set.IsEmpty());
- ASSERT_EQ(set.size(), N);
- for (int j{0}; j < N; ++j) {
- ASSERT_TRUE(set.Contains(j)) << j;
- }
-
- for (int j{0}; j < N; ++j) {
- ASSERT_TRUE(set.Remove(j)) << j;
- ASSERT_EQ(set.size(), N - j - 1) << j;
- ASSERT_FALSE(set.Contains(j)) << j;
- }
-
- ASSERT_TRUE(set.IsEmpty());
- ASSERT_EQ(set.size(), 0);
-
- for (int j{N - 1}; j >= 0; --j) {
- ASSERT_TRUE(set.Add(j)) << j;
- }
- for (int j{0}; j < N; j++) {
- x = set.PopValue();
- ASSERT_TRUE(x.has_value());
- ASSERT_EQ(*x, j) << j;
- }
- ASSERT_TRUE(set.IsEmpty());
- ASSERT_EQ(set.size(), 0);
-
- for (int j{0}; j < N; j++) {
- ASSERT_TRUE(set.Add(j)) << j;
- }
- ASSERT_FALSE(set.IsEmpty());
- ASSERT_EQ(set.size(), N);
- for (int j{0}; j < N; j += 2) {
- ASSERT_TRUE(set.Remove(j)) << j;
- }
- ASSERT_FALSE(set.IsEmpty());
- ASSERT_EQ(set.size(), N / 2);
- for (int j{0}; j < N; j++) {
- ASSERT_EQ(set.Contains(j), (j & 1) == 1);
- }
-
- set.Clear();
- ASSERT_TRUE(set.IsEmpty());
-}
diff --git a/flang/unittests/Decimal/CMakeLists.txt b/flang/unittests/Decimal/CMakeLists.txt
deleted file mode 100644
index aaa3210aade7e3..00000000000000
--- a/flang/unittests/Decimal/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-#===-- unittests/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_flangrt_nongtest_unittest(quick-sanity-test
-quick-sanity-test.cpp
-LINK_LIBS
- flang_rt.unittest
-)
-
-# This test is not run by default as it takes a long time to execute.
-add_flangrt_nongtest_unittest(thorough-test SLOW_TEST
-thorough-test.cpp
-LINK_LIBS
- flang_rt.unittest
-)
diff --git a/flang/unittests/Decimal/quick-sanity-test.cpp b/flang/unittests/Decimal/quick-sanity-test.cpp
deleted file mode 100644
index c36c73b817e1f9..00000000000000
--- a/flang/unittests/Decimal/quick-sanity-test.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#include "flang/Common/decimal.h"
-#include "llvm/Support/raw_ostream.h"
-#include <cinttypes>
-#include <cstdio>
-#include <cstring>
-
-using namespace Fortran::decimal;
-
-static int tests{0};
-static int fails{0};
-
-union u {
- float x;
- std::uint32_t u;
-};
-
-llvm::raw_ostream &failed(float x) {
- ++fails;
- union u u;
- u.x = x;
- llvm::outs() << "FAIL: 0x";
- return llvm::outs().write_hex(u.u);
-}
-
-void testDirect(float x, const char *expect, int expectExpo, int flags = 0) {
- char buffer[1024];
- ++tests;
- auto result{ConvertFloatToDecimal(buffer, sizeof buffer,
- static_cast<enum DecimalConversionFlags>(flags), 1024, RoundNearest, x)};
- if (result.str == nullptr) {
- failed(x) << ' ' << flags << ": no result str\n";
- } else if (std::strcmp(result.str, expect) != 0 ||
- result.decimalExponent != expectExpo) {
- failed(x) << ' ' << flags << ": expect '." << expect << 'e' << expectExpo
- << "', got '." << result.str << 'e' << result.decimalExponent
- << "'\n";
- }
-}
-
-void testReadback(float x, int flags) {
- char buffer[1024];
- ++tests;
- auto result{ConvertFloatToDecimal(buffer, sizeof buffer,
- static_cast<enum DecimalConversionFlags>(flags), 1024, RoundNearest, x)};
- if (result.str == nullptr) {
- failed(x) << ' ' << flags << ": no result str\n";
- } else {
- float y{0};
- char *q{const_cast<char *>(result.str)};
- int expo{result.decimalExponent};
- expo -= result.length;
- if (*q == '-' || *q == '+') {
- ++expo;
- }
- if (q >= buffer && q < buffer + sizeof buffer) {
- std::snprintf(q + result.length,
- buffer + sizeof buffer - (q + result.length), "e%d", expo);
- }
- const char *p{q};
- auto rflags{ConvertDecimalToFloat(&p, &y, RoundNearest)};
- union u u;
- if (!(x == x)) {
- if (y == y || *p != '\0' || (rflags & Invalid)) {
- u.x = y;
- (failed(x) << " (NaN) " << flags << ": -> '" << result.str << "' -> 0x")
- .write_hex(u.u)
- << " '" << p << "' " << rflags << '\n';
- }
- } else if (x != y || *p != '\0' || (rflags & Invalid)) {
- u.x = x;
- (failed(x) << ' ' << flags << ": -> '" << result.str << "' -> 0x")
- .write_hex(u.u)
- << " '" << p << "' " << rflags << '\n';
- }
- }
-}
-
-int main() {
- union u u;
- testDirect(-1.0, "-1", 1);
- testDirect(0.0, "0", 0);
- testDirect(0.0, "+0", 0, AlwaysSign);
- testDirect(1.0, "1", 1);
- testDirect(2.0, "2", 1);
- testDirect(-1.0, "-1", 1);
- testDirect(314159, "314159", 6);
- testDirect(0.0625, "625", -1);
- u.u = 0x80000000;
- testDirect(u.x, "-0", 0);
- u.u = 0x7f800000;
- testDirect(u.x, "Inf", 0);
- testDirect(u.x, "+Inf", 0, AlwaysSign);
- u.u = 0xff800000;
- testDirect(u.x, "-Inf", 0);
- u.u = 0xffffffff;
- testDirect(u.x, "NaN", 0);
- testDirect(u.x, "NaN", 0, AlwaysSign);
- u.u = 1;
- testDirect(u.x,
- "140129846432481707092372958328991613128026194187651577175706828388979108"
- "268586060148663818836212158203125",
- -44, 0);
- testDirect(u.x, "1", -44, Minimize);
- u.u = 0x7f777777;
- testDirect(u.x, "3289396118917826996438159226753253376", 39, 0);
- testDirect(u.x, "32893961", 39, Minimize);
- for (u.u = 0; u.u < 16; ++u.u) {
- testReadback(u.x, 0);
- testReadback(-u.x, 0);
- testReadback(u.x, Minimize);
- testReadback(-u.x, Minimize);
- }
- for (u.u = 1; u.u < 0x7f800000; u.u *= 2) {
- testReadback(u.x, 0);
- testReadback(-u.x, 0);
- testReadback(u.x, Minimize);
- testReadback(-u.x, Minimize);
- }
- for (u.u = 0x7f7ffff0; u.u < 0x7f800010; ++u.u) {
- testReadback(u.x, 0);
- testReadback(-u.x, 0);
- testReadback(u.x, Minimize);
- testReadback(-u.x, Minimize);
- }
- for (u.u = 0; u.u < 0x7f800000; u.u += 65536) {
- testReadback(u.x, 0);
- testReadback(-u.x, 0);
- testReadback(u.x, Minimize);
- testReadback(-u.x, Minimize);
- }
- for (u.u = 0; u.u < 0x7f800000; u.u += 99999) {
- testReadback(u.x, 0);
- testReadback(-u.x, 0);
- testReadback(u.x, Minimize);
- testReadback(-u.x, Minimize);
- }
- for (u.u = 0; u.u < 0x7f800000; u.u += 32767) {
- testReadback(u.x, 0);
- testReadback(-u.x, 0);
- testReadback(u.x, Minimize);
- testReadback(-u.x, Minimize);
- }
- llvm::outs() << tests << " tests run, " << fails << " tests failed\n";
- return fails > 0;
-}
diff --git a/flang/unittests/Decimal/thorough-test.cpp b/flang/unittests/Decimal/thorough-test.cpp
deleted file mode 100644
index 0f7a2d4b33e764..00000000000000
--- a/flang/unittests/Decimal/thorough-test.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "flang/Common/decimal.h"
-#include "llvm/Support/raw_ostream.h"
-#include <cinttypes>
-#include <cstdio>
-#include <cstring>
-
-static constexpr int incr{1}; // steps through all values
-static constexpr bool doNegative{true};
-static constexpr bool doMinimize{true};
-
-using namespace Fortran::decimal;
-
-static std::uint64_t tests{0};
-static std::uint64_t fails{0};
-
-union u {
- float x;
- std::uint32_t u;
-};
-
-llvm::raw_ostream &failed(float x) {
- ++fails;
- union u u;
- u.x = x;
- llvm::outs() << "FAIL: 0x";
- return llvm::outs().write_hex(u.u);
-}
-
-void testReadback(float x, int flags) {
- char buffer[1024];
- union u u;
- u.x = x;
- if (!(tests & 0x3fffff)) {
- llvm::errs() << "\n0x";
- llvm::errs().write_hex(u.u) << ' ';
- } else if (!(tests & 0xffff)) {
- llvm::errs() << '.';
- }
- ++tests;
- auto result{ConvertFloatToDecimal(buffer, sizeof buffer,
- static_cast<enum DecimalConversionFlags>(flags), 1024, RoundNearest, x)};
- if (result.str == nullptr) {
- failed(x) << ' ' << flags << ": no result str\n";
- } else {
- float y{0};
- char *q{const_cast<char *>(result.str)};
- if ((*q >= '0' && *q <= '9') ||
- ((*q == '-' || *q == '+') && q[1] >= '0' && q[1] <= '9')) {
- int expo{result.decimalExponent};
- expo -= result.length;
- if (*q == '-' || *q == '+') {
- ++expo;
- }
- std::snprintf(q + result.length,
- buffer + sizeof buffer - (q + result.length), "e%d", expo);
- }
- const char *p{q};
- auto rflags{ConvertDecimalToFloat(&p, &y, RoundNearest)};
- if (!(x == x)) {
- if (y == y || *p != '\0' || (rflags & Invalid)) {
- u.x = y;
- failed(x) << " (NaN) " << flags << ": -> '" << result.str << "' -> 0x";
- failed(x).write_hex(u.u) << " '" << p << "' " << rflags << '\n';
- }
- } else if (x != y || *p != '\0' || (rflags & Invalid)) {
- u.x = y;
- failed(x) << ' ' << flags << ": -> '" << result.str << "' -> 0x";
- failed(x).write_hex(u.u) << " '" << p << "' " << rflags << '\n';
- }
- }
-}
-
-int main() {
- union u u;
- for (u.u = 0; u.u < 0x7f800010; u.u += incr) {
- testReadback(u.x, 0);
- if constexpr (doNegative) {
- testReadback(-u.x, 0);
- }
- if constexpr (doMinimize) {
- testReadback(u.x, Minimize);
- if constexpr (doNegative) {
- testReadback(-u.x, Minimize);
- }
- }
- }
- llvm::outs() << '\n' << tests << " tests run, " << fails << " tests failed\n";
- return fails > 0;
-}
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 0cb0fc4dd52531..0339098df4555b 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -43,8 +43,8 @@ add_flang_nongtest_unittest(intrinsics
FortranCommon
FortranEvaluateTesting
FortranEvaluate
- FortranSemantics
FortranSupport
+ FortranSemantics
FortranParser
)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 8e805e543cd11e..c237c0be2afe8b 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -96,7 +96,6 @@ function(builtin_default_target compiler_rt_path)
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}
-DLLVM_CMAKE_DIR=${CMAKE_BINARY_DIR}
-DCMAKE_C_COMPILER_WORKS=ON
- -DCMAKE_Fortran_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
${COMMON_CMAKE_ARGS}
${BUILTINS_CMAKE_ARGS}
>From ad757fb95e4ccda4f15dd8bd920714573d27719c Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 6 Dec 2024 20:03:36 +0100
Subject: [PATCH 55/58] Buildbot flang-runtime-cuda-gcc uses CMAKE_CUDA_*
Needs to be propagated to runtime in order to continue to work.
---
llvm/runtimes/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index c237c0be2afe8b..e8d9bfc7cf3b1c 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -277,7 +277,7 @@ function(runtime_default_target)
${ARG_CMAKE_ARGS}
PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
LLVM_USE_LINKER
- CUDA # For runtimes that may look for the CUDA SDK (libc, offload, flang-rt)
+ CUDA CMAKE_CUDA # For runtimes that may look for the CUDA compiler and/or SDK (libc, offload, flang-rt)
FLANG_RUNTIME # Shared between Flang and Flang-RT
${ARG_PREFIXES}
EXTRA_TARGETS ${extra_targets}
>From b52fe0c6df77d0b7bd67b68007b8c2db94afe217 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 6 Dec 2024 22:47:02 +0100
Subject: [PATCH 56/58] Post-merge fix
---
flang-rt/include/flang-rt/CUDA/allocator.h | 2 +-
flang-rt/lib/CufRuntime/descriptor.cpp | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/flang-rt/include/flang-rt/CUDA/allocator.h b/flang-rt/include/flang-rt/CUDA/allocator.h
index 211f10458904d5..70715bc51df10a 100644
--- a/flang-rt/include/flang-rt/CUDA/allocator.h
+++ b/flang-rt/include/flang-rt/CUDA/allocator.h
@@ -9,7 +9,7 @@
#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"
diff --git a/flang-rt/lib/CufRuntime/descriptor.cpp b/flang-rt/lib/CufRuntime/descriptor.cpp
index d7d9405f7b2cd2..dd132c156284cb 100644
--- a/flang-rt/lib/CufRuntime/descriptor.cpp
+++ b/flang-rt/lib/CufRuntime/descriptor.cpp
@@ -11,7 +11,6 @@
#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"
>From ac1f46faeef2507bb680f14b9256ac38817824df Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Sat, 7 Dec 2024 04:29:04 +0100
Subject: [PATCH 57/58] Ensure test-suite is working from a build dir
---
flang/CMakeLists.txt | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 34c5661c963a80..6fee83972421bb 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -506,7 +506,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)
>From a03606822b0eaef8efdeb00c4f2c33e1a029f79f Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 9 Dec 2024 15:59:36 +0100
Subject: [PATCH 58/58] Link FortranSupport
everywhere where FortranCommon is
---
flang/lib/Optimizer/OpenMP/CMakeLists.txt | 1 +
flang/lib/Optimizer/Passes/CMakeLists.txt | 4 +---
flang/tools/bbc/CMakeLists.txt | 1 +
flang/tools/f18-parse-demo/CMakeLists.txt | 1 +
flang/tools/tco/CMakeLists.txt | 1 +
flang/unittests/Evaluate/CMakeLists.txt | 14 ++++++++------
flang/unittests/Frontend/CMakeLists.txt | 1 +
7 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/flang/lib/Optimizer/OpenMP/CMakeLists.txt b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
index 51ecbe1a664f92..1192403dd1c6fc 100644
--- a/flang/lib/Optimizer/OpenMP/CMakeLists.txt
+++ b/flang/lib/Optimizer/OpenMP/CMakeLists.txt
@@ -21,6 +21,7 @@ add_flang_library(FlangOpenMPTransforms
FIRDialectSupport
FIRSupport
FortranCommon
+ FortranSupport
MLIRFuncDialect
MLIROpenMPDialect
HLFIRDialect
diff --git a/flang/lib/Optimizer/Passes/CMakeLists.txt b/flang/lib/Optimizer/Passes/CMakeLists.txt
index 40abbdfbdd6511..029588dc7f7bbe 100644
--- a/flang/lib/Optimizer/Passes/CMakeLists.txt
+++ b/flang/lib/Optimizer/Passes/CMakeLists.txt
@@ -5,9 +5,6 @@ add_flang_library(flangPasses
CommandLineOpts.cpp
Pipelines.cpp
- DEPENDS
- FortranCommon
-
LINK_LIBS
FIRCodeGen
FIRTransforms
@@ -15,6 +12,7 @@ add_flang_library(flangPasses
${dialect_libs}
${extension_libs}
FortranCommon
+ FortranSupport
HLFIRTransforms
MLIRPass
MLIRReconcileUnrealizedCasts
diff --git a/flang/tools/bbc/CMakeLists.txt b/flang/tools/bbc/CMakeLists.txt
index 9abdcf17b6ebfd..a608d472fd997b 100644
--- a/flang/tools/bbc/CMakeLists.txt
+++ b/flang/tools/bbc/CMakeLists.txt
@@ -33,6 +33,7 @@ target_link_libraries(bbc PRIVATE
MLIRAffineToStandard
MLIRSCFToControlFlow
FortranCommon
+ FortranSupport
FortranParser
FortranEvaluate
FortranSemantics
diff --git a/flang/tools/f18-parse-demo/CMakeLists.txt b/flang/tools/f18-parse-demo/CMakeLists.txt
index df1f1d24a55e51..800b29fcf4251f 100644
--- a/flang/tools/f18-parse-demo/CMakeLists.txt
+++ b/flang/tools/f18-parse-demo/CMakeLists.txt
@@ -12,5 +12,6 @@ add_flang_tool(f18-parse-demo
target_link_libraries(f18-parse-demo
PRIVATE
FortranCommon
+ FortranSupport
FortranParser
)
diff --git a/flang/tools/tco/CMakeLists.txt b/flang/tools/tco/CMakeLists.txt
index aac80437ee11d9..4d05ba5d1f907f 100644
--- a/flang/tools/tco/CMakeLists.txt
+++ b/flang/tools/tco/CMakeLists.txt
@@ -20,6 +20,7 @@ target_link_libraries(tco PRIVATE
flangPasses
FlangOpenMPTransforms
FortranCommon
+ FortranSupport
${dialect_libs}
${extension_libs}
MLIRIR
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 0339098df4555b..49f0d06d53257b 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -27,6 +27,7 @@ add_flang_nongtest_unittest(uint128
add_flang_nongtest_unittest(expression
FortranCommon
+ FortranSupport
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
@@ -41,16 +42,16 @@ add_flang_nongtest_unittest(integer
add_flang_nongtest_unittest(intrinsics
FortranCommon
- FortranEvaluateTesting
- FortranEvaluate
FortranSupport
+ FortranEvaluate
+ FortranEvaluateTesting
FortranSemantics
FortranParser
)
add_flang_nongtest_unittest(logical
- FortranEvaluateTesting
FortranEvaluate
+ FortranEvaluateTesting
FortranSemantics
)
@@ -61,16 +62,17 @@ add_flang_nongtest_unittest(logical
set(LLVM_REQUIRES_EH ON)
set(LLVM_REQUIRES_RTTI ON)
add_flang_nongtest_unittest(real
- FortranEvaluateTesting
- FortranEvaluate
FortranSupport
+ FortranEvaluate
+ FortranEvaluateTesting
FortranSemantics
)
llvm_update_compile_flags(real.test)
add_flang_nongtest_unittest(folding
FortranCommon
- FortranEvaluateTesting
+ FortranSupport
FortranEvaluate
+ FortranEvaluateTesting
FortranSemantics
)
diff --git a/flang/unittests/Frontend/CMakeLists.txt b/flang/unittests/Frontend/CMakeLists.txt
index 22c568af3d121a..a4a18e313c1f4f 100644
--- a/flang/unittests/Frontend/CMakeLists.txt
+++ b/flang/unittests/Frontend/CMakeLists.txt
@@ -19,6 +19,7 @@ target_link_libraries(FlangFrontendTests
FortranParser
FortranSemantics
FortranCommon
+ FortranSupport
FortranEvaluate
MLIRIR
)
More information about the llvm-branch-commits
mailing list